import type { ReactNode } from 'react'; export interface DataTableColumn { /** Matches a key in every row's `cells`. */ key: string; header: string; /** Right-aligns the column and sets it in the data face with tabular figures. */ numeric?: boolean; } export interface DataTableRow { id: string; cells: Record; selected?: boolean; } export interface DataTableProps { columns: DataTableColumn[]; rows: DataTableRow[]; /** Says what the table is counting. Shown above the header row. */ caption?: string; /** The pack's mono row number in the first column. On by default — it is the motif. */ numbered?: boolean; className?: string; } export function DataTable({ columns, rows, caption, numbered = true, className, }: DataTableProps) { return (
{caption !== undefined && } {numbered && ))} {rows.map((row, index) => ( {numbered && } {columns.map((column) => ( ))} ))}
{caption}
} {columns.map((column) => ( {column.header}
{index + 1} {row.cells[column.key]}
); }