//#region src/data-table/schema.d.ts /** * A table's schema: which columns exist, what each can do, and how wide it * starts. Not how a cell draws — that is the caller's, and it is the reason * this module holds no React. * * The split matters because "which columns does this view have, and which of * them can be sorted, hidden, resized or pinned" is a question about data, and * a question about data can be answered by a test. It used to be answerable * only by rendering the table and asking TanStack. */ /** What a reader may do to a column. */ export type TableColumnCapabilities = { sort: boolean; hide: boolean; resize: boolean; pin: boolean; }; /** * One column. * * `render` is whatever the caller needs to draw the column: this module never * looks inside it, which is what keeps the schema free of any idea about what * a row holds. */ export type TableColumnDescriptor = { /** Unique within the schema, and stable across renders. */ id: string; /** Header text. Empty for a column whose header draws no text. */ label: string; render: TRender; /** Starting width, in pixels. */ size: number; /** Narrowest this column may be resized to; the schema's default if absent. */ minSize?: number | undefined; capabilities: TableColumnCapabilities; /** * Metadata columns read quieter than content ones; a utility column * (a selection checkbox, an add-column affordance) draws no value at all. */ emphasis: "content" | "metadata" | "utility"; }; export type TableSchema = { columns: readonly TableColumnDescriptor[]; /** Narrowest any column may be resized to. */ defaultMinSize: number; }; /** Every column a schema declares, in order. */ export declare const tableColumnIds: (schema: TableSchema) => string[]; export declare const sortableColumnIds: (schema: TableSchema) => string[]; export declare const hideableColumnIds: (schema: TableSchema) => string[]; export declare const findTableColumn: (schema: TableSchema, id: string) => TableColumnDescriptor | undefined; /** * Which columns a view shows. * * A column that cannot be hidden stays visible whatever the stored hidden list * says, so a stale list — a column that lost its hide capability while it was * hidden — cannot strand the table without its select or name column. */ export declare const visibleColumnIds: (schema: TableSchema, hiddenColumnIds: readonly string[]) => string[]; /** The starting width of every column, keyed by id. */ export declare const tableColumnSizing: (schema: TableSchema) => Record; /** * A duplicate column id silently drops a column: the table keys by id, so the * second declaration wins and the first disappears with no error anywhere. * Callers that build a schema from user data (a property list) check here. */ export declare const duplicateColumnIds: (schema: TableSchema) => string[]; //#endregion