import { ReactNode } from "react"; import "./Table.css"; import { CellRender } from "./CellRender"; type Props = { /** * List of header names */ headers: string[]; /** * The data are represented by a 2 dimensions array. * Each row contains a dataset whose data structure is a string array. */ data: string[][]; /** * The cell render is an array of function that returns the cell data. */ cells: CellRender[]; className?: string; }; export function Table({ data, headers, cells, className }: Props) { return (
{headers.map((col) => ( ))} {data.map((row, index) => ( {headers.map((header, idx) => { const render = cells[idx]; return ( ); })} ))}
{col}
{render(row[idx], row, index)}
); }