import { Tr, Td } from '@patternfly/react-table'; import { flexRender, type Row } from '@tanstack/react-table'; /** Props for the {@link TableRow} component. */ interface TableRowProps { /** The TanStack row instance to render. */ row: Row; /** Unique row identifier, set as `data-id` on the ``. */ rowId: string; /** Virtual index used by PatternFly expand/select controls. */ virtualIndex: number; /** Whether to render an expand/collapse toggle cell. */ enableExpansion?: boolean; /** Whether this row controls an expanded content row. */ isContentExpanded?: boolean; /** Whether to render a row selection checkbox cell. */ enableRowSelection?: boolean; } /** * Renders a single table row with its cells. * * Uses TanStack's `flexRender` to render each cell according to its column * definition. When expansion is enabled, adds a leading toggle cell. * Sets `dataLabel` on each `` for PatternFly's responsive table behavior. * * @typeParam TData - The row data type */ export const TableRow = ({ row, rowId, virtualIndex, enableExpansion, isContentExpanded, enableRowSelection, }: TableRowProps) => { return ( {enableRowSelection && ( { row.toggleSelected(isSelected); }, isSelected: row.getIsSelected(), }} /> )} {enableExpansion && ( )} {row.getVisibleCells().map((cell) => ( {flexRender(cell.column.columnDef.cell, cell.getContext())} ))} ); };