import type { ReactNode } from 'react'; import { TableBody as AriaTableBody } from 'react-aria-components'; import { Table } from './table'; export type DynamicColumn = { id: string; label: string; headerRenderer?: () => ReactNode; width?: string; }; export type DynamicRow = { id: string; [key: string]: any; }; interface DynamicTableProps { columns: DynamicColumn[]; rows: T[]; renderCell: (row: T, columnId: string) => ReactNode; rowClassName?: (row: T) => string; size?: 'sm' | 'md'; maxRows?: number; className?: string; } export const DynamicTable = ({ columns, rows, renderCell, rowClassName, size = 'sm', maxRows, className, }: DynamicTableProps) => { const displayRows = maxRows ? rows.slice(0, maxRows) : rows; return ( {columns.map(col => ( {col.headerRenderer?.()} ))} {(row) => ( {columns.map(col => ( {renderCell(row, col.id)} ))} )}
); };