import { flexRender, type RowData, type Table as TableType, } from "@tanstack/react-table"; import { Table, TableCell, TableHead, TableHeader, TableRow } from "../table"; declare module "@tanstack/react-table" { // eslint-disable-next-line @typescript-eslint/no-unused-vars interface ColumnMeta { align: "left" | "center" | "right"; } } function THead({ table }: { table: TableType }) { return ( {table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => { const { meta } = header.column.columnDef; return ( {header.isPlaceholder ? null : flexRender( header.column.columnDef.header, header.getContext(), )} ); })} ))} ); } type TableProps = { table: TableType; variant?: "default" | "secondary" | "line"; onRowClick?: (row: T) => void; }; function DataTable({ table, variant = "default", onRowClick, }: TableProps) { return ( {table.getRowModel().rows.map((row) => ( onRowClick?.(row.original)} className={onRowClick ? "cursor-pointer hover:bg-muted" : ""} > {row.getVisibleCells().map((cell) => { const { meta } = cell.column.columnDef; return ( {flexRender(cell.column.columnDef.cell, cell.getContext())} ); })} ))}
); } export { DataTable };