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; /** * The pack mandates `--accent-weak` plus a 2px accent inset for the selected * state, and this component shipped without one until 1.16.0 — the single * atom on an admin dashboard that most needs selection was the one that * lacked it, while `Chip` implemented the same state correctly. */ selected?: boolean; } export interface DataTableProps { columns: DataTableColumn[]; rows: DataTableRow[]; /** Says what the table is counting. Shown above the header row. */ 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]}
); }