DataTable
The console's table: a 36px header on a strong rule, 40px rows on hairlines, numbers right, sorting, resizing, selection, virtualization.
function Logs() {
const [open, setOpen] = useState<LogRow | null>(null);
const [n, setN] = useState(60);
const data = useMemo(() => logs.slice(0, n), [n]);
return (
<div className="h-480 w-full overflow-y-auto scrollbar-quiet">
<DataTable
aria-label="Request logs"
data={data}
columns={columns}
getRowId={(r) => r.id}
selectable
activeRowId={open?.id}
onRowClick={setOpen}
rowMenu={(r) => (
<>
<Menu.Item icon={icons.openExternal} onClick={() => setOpen(r)}>
Open request
</Menu.Item>
<Menu.Item icon={icons.copy}>Copy request id</Menu.Item>
<Menu.Item icon={icons.filter}>Filter by {r.model}</Menu.Item>
</>
)}
hasMore={n < logs.length}
onLoadMore={() => setN((x) => x + 60)}
/>
<Sheet
open={!!open}
onOpenChange={(o) => !o && setOpen(null)}
title={open ? `${open.method} ${open.endpoint}` : ""}
subtitle={open?.id}
size="md"
modal={false}
>
{open && (
<div className="flex flex-col gap-24">
<RequestTimeline ttfbMs={open.ttfbMs} totalMs={open.latencyMs} />
<KeyValue
items={[
{ label: "Status", value: <StatusCode code={open.status} showText /> },
{ label: "Model", value: open.model, mono: true },
{ label: "Key", value: open.key },
{ label: "Cost", value: `$${open.cost}` },
]}
/>
</div>
)}
</Sheet>
</div>
);
}import { DataTable, col } from "@logicplanes/kaeso-ui";Props
activeRowIdstringThe id of the row whose detail is open, in a sheet beside the table: it keeps the selected fill and is marked aria-current.
aria-labelstringThe table's accessible name.
canSelectRow((row: T) => boolean)Whether a row can be selected; a row that can't keeps a disabled checkbox, and select all skips it.
columnsColumnDef<T, any>[]The columns, as TanStack Table column definitions.
dataT[]The rows.
data-force-rowstringForce a state on the first row for state matrices: hover, pressed, focus.
density"default" | "compact" | "comfortable"How much room each row gets.
emptyReactNodeWhat to show when there are no rows: an
Emptywith the page's own sentence, such as "No requests yet" or, behind filters, "No requests match". Without it the table says "No rows".errorReactNodeThe rows failed to load: the table says so where its rows would be and offers Try again (
onRetry), or, without it, says to reload the page. Errors are toasts, so the value isn't shown; toast the message where the request fails.freshRowIdsReadonlySet<string>Rows that just arrived (a live list): each shows a fill that fades out over a second.
getRowId((row: T) => string)Returns a row's stable id, for selection and keys.
hasMorebooleanWhether more rows can be loaded.
loadingbooleanShows skeleton rows while the first page loads.
loadingMorebooleanShows that more rows are loading.
manualSortingbooleanSorting happens on the server: the data arrives sorted.
onHiddenColumnsChange((ids: string[]) => void)Called with the ids of the columns left out at the table's width, so a kept column can show what they held.
onLoadMore(() => void)Called to load the next rows. When Load more asked for them, focus moves to the first new row once they arrive; screen readers hear how many came.
onRetry(() => void)Shows a Retry button when loading failed.
onRowClick((row: T) => void)Called when a row is clicked; rows then show that they can be opened.
onSelectionChange((selection: RowSelectionState) => void)Called with the selected rows.
onSortingChange((sorting: SortingState) => void)Called with the new sort order.
refRef<HTMLDivElement>A ref to the outer element.
rowMenu((row: T) => ReactNode)Items for a row's context menu (right-click).
selectablebooleanAdds a checkbox to every row, named after the row's first text column; Space, Shift with the arrows and ⌘A select from the keyboard.
selectionRowSelectionStateThe selected rows, when you control them.
sortingSortingStateThe sort order, when you control it.
stickyFirstColumnbooleanKeeps the first column in view while scrolling sideways.
virtualizeAbovenumberAbove this many rows (50), only the visible rows are rendered.