/**
* DataTable — the flagship (W2 §The Kit). TanStack Table internals; the model
* only fills props. It sorts, filters, searches, paginates, resolves dot-path
* column keys, gives way on a narrow surface, and shows a named-query empty
* state — none of which the model has to author. A cell's TEXT is the field as
* the screen prepared it; formatting figures is the screen's own job.
*/
import { type CSSProperties, type ReactNode } from "react";
import { type KitDensity, type KitStyled } from "../tokens.js";
export interface DataTableColumn {
/** Field key; supports dot-paths ("client.name"). Absent on an ACTION column,
* which has no field: a fake key would make its header click-to-sort and its
* contents globally searchable, on data that is not there. */
key?: string;
/** Header label; defaults to a humanized last path segment. */
label?: string;
/** The same header under the other word for it. `header` is the word a model
* reaches for first, and refusing it cost the column its name: the prompt
* carried a warning nobody could act on at render time, and a screen that
* wrote `header` shipped a humanized key instead of the title it authored. */
header?: string;
align?: "start" | "center" | "end";
/** The column's width in px: the `
`'s width, and the cap a truncating cell
* ellipsizes inside. Chromium honours a `max-width` on a ` | ` in the auto
* table layout and ignores a `width` on the ` | ` while the cell can still
* grow, so a declared width is written to both. */
width?: number;
/** Clip this column's cells to one line with an ellipsis, the whole text in
* `title=`. Opt-in, and it wants a `width` — that is the edge the ellipsis
* bites against. Unasked, a cell is still one line, at the full width its
* content asks for: no column is squeezed to unreadable without a screen
* saying so. */
truncate?: boolean;
/** How important this column is when there is not room for all of them: the
* LOWEST gives way first. Declaring it on ANY column is what turns giving way
* on at all — see {@link DataTableProps.fold}. Inferred from POSITION where it
* is not declared — the first column is the most important — and a declared
* number competes with the inferred ones on that one scale rather than in a
* league of its own. */
priority?: number;
/** Kit elements rendered instead of the field's own text. Written as a function
* of the row, it arrives as ONE element per row in `rows` order; a stored
* screen holds a single element for every row. `key` still drives sorting,
* filtering and searching. */
cell?: ReactNode | readonly ReactNode[];
}
export interface DataTableProps extends KitStyled {
/** Rows from a tool call. */
rows: Array>;
/** Column descriptions; a bare string is its key. Omitted, they are inferred
* from the first row's keys. */
columns?: Array;
/** Initial sort, e.g. "dueDate asc" or "amountCents desc". */
sortBy?: string;
/** Hard cap on rows shown. */
limit?: number;
/** Column keys to expose as distinct-value filter dropdowns. */
filterableBy?: string[];
/** Show a search box filtering across all columns. */
searchable?: boolean;
/** Page size; enables pagination when set. */
paginate?: number;
/** Text shown when there are no rows (the named-query empty state). */
emptyState?: string;
/** Kit elements shown in place of `emptyState` when there are no rows. */
empty?: ReactNode;
/** Optional table caption. */
caption?: string;
/** Kit elements in the controls row, beside the search box and the filters. */
toolbar?: ReactNode;
/** Kit controls in a trailing column — the cell contract, for the half of it
* that may be OPERATED because the function that wrote it had a row to act
* on. One element per row in `rows` order. */
rowActions?: ReactNode | readonly ReactNode[];
/** Let the columns that do not fit GIVE WAY, folding each one's label and value
* into the first cell as an extra line. Off by default, and so is giving way
* itself: every folded column is another line in the row, and a row of four
* lines is the 90-160px height a judge measured (three columns folded reads at
* 132px in Chromium). Which columns are worth the width is said with
* `priority`, which turns giving way on by itself — and leaves the ones that
* went out of the row entirely. */
fold?: boolean;
/** Spacing scale for this table's subtree. */
density?: KitDensity;
/** One per record, in `rows` order — the model paints the cells
* itself. Wins over `columns[].cell`. */
children?: ReactNode;
}
/** What a TableRow needs and cannot be handed as props: the columns it places
* its cells against, which of them the surface had no room for, and whether
* those fold rather than going quiet (kit/data/table-row.tsx). The dropped ones
* are a SET and not a count, because the columns that give way are the least
* important ones wherever they sit, not the last ones. */
export declare const TableContext: import("react").Context<{
columns: DataTableColumn[];
dropped: ReadonlySet;
fold: boolean;
} | undefined>;
export declare const alignCss: (a: DataTableColumn["align"]) => CSSProperties["textAlign"];
/** A column's header text: its own label, the same thing spelled `header`, or its
* key humanized. */
export declare const headerText: (col: DataTableColumn) => string;
export declare const cellPad = "var(--vendo-density-table-padding, 10px 12px)";
/** The line-per-column list a folded column moves into. The cell it rides in
* may be a FIGURE, whose nowrap/tabular is inherited: a folded line is prose,
* and an unbreakable one scrolls the table sideways — the thing folding
* prevents. */
export declare const foldStyle: CSSProperties;
export declare function DataTable(props: DataTableProps): import("react").JSX.Element;
|