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; } export interface DataTableProps { columns: DataTableColumn[]; rows: DataTableRow[]; /** Says what the table is counting. Set above the header row in mono. */ caption?: string; className?: string; } export function DataTable({ columns, rows, caption, className }: DataTableProps) { return (
{caption !== undefined && } {columns.map((column) => ( ))} {rows.map((row) => ( {columns.map((column) => ( ))} ))}
{caption}
{column.header}
{row.cells[column.key]}
); }