import {
Table,
useReactTable,
flexRender,
getCoreRowModel,
Thead,
Tbody,
Tr,
Th,
Td,
createColumnHelper,
Box,
Text,
} from "@ohah/react-wasm-table";
const helper = createColumnHelper<{ dept: string }>();
const columns = [
helper.accessor("dept", {
header: "Box + Text",
size: 140,
cell: (info) => (
<Box padding={8} borderWidth={1} borderColor="#e0e0e0" backgroundColor="#fafafa">
<Text value={info.getValue()} />
</Box>
),
}),
];
const table = useReactTable({ data, columns, getCoreRowModel: getCoreRowModel() });
<Table table={table} width={900} height={500} rowHeight={48}>
<Thead>
{table.getHeaderGroups().map((hg) => (
<Tr key={hg.id}>
{hg.headers.map((h) => (
<Th key={h.id} colSpan={h.colSpan}>
{h.isPlaceholder ? null : flexRender(h.column.columnDef.header, h.getContext())}
</Th>
))}
</Tr>
))}
</Thead>
<Tbody>
{table.getRowModel().rows.map((row) => (
<Tr key={row.id}>
{row.getVisibleCells().map((cell) => (
<Td key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</Td>
))}
</Tr>
))}
</Tbody>
</Table>;