jenosize-ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +28 -0
- package/README.md +100 -0
- package/THIRD-PARTY-NOTICES.md +163 -0
- package/dist/Button-Bt7pzM4R.d.ts +82 -0
- package/dist/PaymentInput-CKPIPNWH.d.ts +141 -0
- package/dist/Select-CVbEQ2Ep.d.ts +118 -0
- package/dist/TagInput-CTJYOB4J.d.ts +90 -0
- package/dist/avatar.d.ts +161 -0
- package/dist/avatar.js +11 -0
- package/dist/badge.d.ts +109 -0
- package/dist/badge.js +10 -0
- package/dist/breadcrumb.d.ts +58 -0
- package/dist/breadcrumb.js +7 -0
- package/dist/button.d.ts +54 -0
- package/dist/button.js +14 -0
- package/dist/calendar.d.ts +368 -0
- package/dist/calendar.js +21 -0
- package/dist/callout.d.ts +70 -0
- package/dist/callout.js +16 -0
- package/dist/card-nWicloNi.d.ts +80 -0
- package/dist/card.d.ts +2 -0
- package/dist/card.js +7 -0
- package/dist/checkbox.d.ts +133 -0
- package/dist/checkbox.js +11 -0
- package/dist/chunk-24TO7E32.js +42 -0
- package/dist/chunk-3Y5X7B5C.js +146 -0
- package/dist/chunk-4OLULPQG.js +202 -0
- package/dist/chunk-4P2NBLBW.js +103 -0
- package/dist/chunk-52IFGFTL.js +11 -0
- package/dist/chunk-5FATN5YD.js +115 -0
- package/dist/chunk-5NOBSXJN.js +297 -0
- package/dist/chunk-5RAPA22E.js +106 -0
- package/dist/chunk-7EUAMHMU.js +16 -0
- package/dist/chunk-7EWQKTNQ.js +1336 -0
- package/dist/chunk-7HOIZ3UO.js +110 -0
- package/dist/chunk-7IU5TMFL.js +452 -0
- package/dist/chunk-7JBNLEJ7.js +29 -0
- package/dist/chunk-7S2TBALK.js +23 -0
- package/dist/chunk-BJUZVYQC.js +188 -0
- package/dist/chunk-BVJWBYIG.js +66 -0
- package/dist/chunk-CME4DIML.js +65 -0
- package/dist/chunk-CYPPEUX5.js +73 -0
- package/dist/chunk-D5BTFSL7.js +71 -0
- package/dist/chunk-D6TPWNRK.js +387 -0
- package/dist/chunk-DJSXIAFH.js +66 -0
- package/dist/chunk-DRZCJCBO.js +46 -0
- package/dist/chunk-DWKILXHE.js +17 -0
- package/dist/chunk-E7ZSWBAK.js +70 -0
- package/dist/chunk-EDSK6FEH.js +8 -0
- package/dist/chunk-F2K7VJUV.js +114 -0
- package/dist/chunk-F6NLE6XJ.js +40 -0
- package/dist/chunk-FHHAPGCR.js +32 -0
- package/dist/chunk-FXIBGTS5.js +14 -0
- package/dist/chunk-GCVA3OIV.js +72 -0
- package/dist/chunk-GFOAJVW5.js +336 -0
- package/dist/chunk-GRLSUQQE.js +136 -0
- package/dist/chunk-GTHJWR3Q.js +77 -0
- package/dist/chunk-HMUZE6EK.js +67 -0
- package/dist/chunk-I7WU4GTY.js +503 -0
- package/dist/chunk-J2BCKBHC.js +151 -0
- package/dist/chunk-J36M3KRX.js +1315 -0
- package/dist/chunk-J7ZQQFPT.js +113 -0
- package/dist/chunk-JP26LPCY.js +234 -0
- package/dist/chunk-JTNFJLIY.js +1046 -0
- package/dist/chunk-JVJRHBTD.js +50 -0
- package/dist/chunk-JYGR44ZC.js +133 -0
- package/dist/chunk-KDLPXXD2.js +173 -0
- package/dist/chunk-KMSYEE23.js +224 -0
- package/dist/chunk-KNYKWUYX.js +52 -0
- package/dist/chunk-LME57Z6J.js +138 -0
- package/dist/chunk-MFJP5FA7.js +20 -0
- package/dist/chunk-MKC5HNA7.js +1692 -0
- package/dist/chunk-MQGD2OUF.js +39 -0
- package/dist/chunk-MUFHLP4S.js +566 -0
- package/dist/chunk-O2LG3PNI.js +74 -0
- package/dist/chunk-O4GRKO3I.js +66 -0
- package/dist/chunk-OHUFNYGN.js +791 -0
- package/dist/chunk-PWKWNDBS.js +243 -0
- package/dist/chunk-QA74ITR4.js +103 -0
- package/dist/chunk-R6RGJF4L.js +170 -0
- package/dist/chunk-S7NNXWIN.js +7 -0
- package/dist/chunk-SV56BSUQ.js +162 -0
- package/dist/chunk-T7FCG7XV.js +435 -0
- package/dist/chunk-THC2ISYP.js +57 -0
- package/dist/chunk-VWC72TR3.js +115 -0
- package/dist/chunk-W46K56XU.js +216 -0
- package/dist/chunk-W5GGOUUI.js +75 -0
- package/dist/chunk-WEUJYDCV.js +269 -0
- package/dist/chunk-WFY7DKQD.js +279 -0
- package/dist/chunk-WZQFC7ZN.js +448 -0
- package/dist/chunk-Z3ETJN5G.js +136 -0
- package/dist/chunk-ZOOX3TUB.js +192 -0
- package/dist/chunk-ZSNJ6UA3.js +42 -0
- package/dist/chunk-ZZA2LUTL.js +130 -0
- package/dist/chunk-ZZT2E5VT.js +24 -0
- package/dist/color-CtSxc1Rh.d.ts +6 -0
- package/dist/combobox.d.ts +184 -0
- package/dist/combobox.js +21 -0
- package/dist/date-input.d.ts +83 -0
- package/dist/date-input.js +16 -0
- package/dist/date-picker.d.ts +249 -0
- package/dist/date-picker.js +29 -0
- package/dist/date-utils-7hTFTXNK.d.ts +34 -0
- package/dist/date-vMJBKAFK.d.ts +22 -0
- package/dist/dialog.d.ts +86 -0
- package/dist/dialog.js +15 -0
- package/dist/drawer.d.ts +77 -0
- package/dist/drawer.js +14 -0
- package/dist/dropdown-menu.d.ts +218 -0
- package/dist/dropdown-menu.js +10 -0
- package/dist/file-trigger.d.ts +42 -0
- package/dist/file-trigger.js +3 -0
- package/dist/form.d.ts +487 -0
- package/dist/form.js +1179 -0
- package/dist/header-navigation.d.ts +74 -0
- package/dist/header-navigation.js +23 -0
- package/dist/icons/app.d.ts +48 -0
- package/dist/icons/app.js +282 -0
- package/dist/icons/flag.d.ts +817 -0
- package/dist/icons/flag.js +58336 -0
- package/dist/icons/integration.d.ts +36 -0
- package/dist/icons/integration.js +531 -0
- package/dist/icons/payment.d.ts +116 -0
- package/dist/icons/payment.js +2418 -0
- package/dist/icons.d.ts +2013 -0
- package/dist/icons.js +2012 -0
- package/dist/illustration.d.ts +48 -0
- package/dist/illustration.js +4 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.js +73 -0
- package/dist/indicator.d.ts +51 -0
- package/dist/indicator.js +7 -0
- package/dist/input.d.ts +66 -0
- package/dist/input.js +15 -0
- package/dist/multi-value-CJb_tnvi.d.ts +8 -0
- package/dist/nav-Bla0o_-1.d.ts +98 -0
- package/dist/number-input.d.ts +80 -0
- package/dist/number-input.js +15 -0
- package/dist/options-CPEIgjtd.d.ts +68 -0
- package/dist/overflow-Df0h42Oi.d.ts +29 -0
- package/dist/pagination.d.ts +77 -0
- package/dist/pagination.js +17 -0
- package/dist/payment-input.d.ts +7 -0
- package/dist/payment-input.js +15 -0
- package/dist/popover.d.ts +60 -0
- package/dist/popover.js +14 -0
- package/dist/progress.d.ts +87 -0
- package/dist/progress.js +5 -0
- package/dist/radio.d.ts +77 -0
- package/dist/radio.js +12 -0
- package/dist/select.d.ts +68 -0
- package/dist/select.js +24 -0
- package/dist/shared-BNXAdgh2.d.ts +9 -0
- package/dist/shared-BYXJPnsN.d.ts +11 -0
- package/dist/shared-Dc-GgA16.d.ts +42 -0
- package/dist/sidebar-navigation.d.ts +129 -0
- package/dist/sidebar-navigation.js +15 -0
- package/dist/styles.css +2 -0
- package/dist/switch.d.ts +23 -0
- package/dist/switch.js +7 -0
- package/dist/table.d.ts +692 -0
- package/dist/table.js +44 -0
- package/dist/tabs.d.ts +111 -0
- package/dist/tabs.js +8 -0
- package/dist/tag-input.d.ts +12 -0
- package/dist/tag-input.js +19 -0
- package/dist/tag.d.ts +98 -0
- package/dist/tag.js +9 -0
- package/dist/textarea.d.ts +40 -0
- package/dist/textarea.js +12 -0
- package/dist/theme-script.d.ts +29 -0
- package/dist/theme-script.js +15 -0
- package/dist/theme.css +929 -0
- package/dist/theme.d.ts +71 -0
- package/dist/theme.js +15 -0
- package/dist/toast.d.ts +242 -0
- package/dist/toast.js +15 -0
- package/dist/tooltip.d.ts +70 -0
- package/dist/tooltip.js +6 -0
- package/dist/tree.d.ts +308 -0
- package/dist/tree.js +11 -0
- package/package.json +352 -0
package/dist/table.d.ts
ADDED
|
@@ -0,0 +1,692 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { PaginationVariant, PaginationAlign, PaginationColor } from './pagination.js';
|
|
3
|
+
import { S as SemanticColor } from './color-CtSxc1Rh.js';
|
|
4
|
+
import { O as OverflowMode } from './overflow-Df0h42Oi.js';
|
|
5
|
+
import { DropdownMenuSeparatorItem, DropdownMenuCheckboxItem, DropdownMenuRadioItem } from './dropdown-menu.js';
|
|
6
|
+
|
|
7
|
+
/** Which edge a cell's content sits against. `end` is for QUANTITIES — counts, hours, money,
|
|
8
|
+
* averages — so it also applies `tabular-nums`; figures that stack must line up digit-for-digit.
|
|
9
|
+
* It is deliberately not a general "text-align" prop: centring a column is never the right call. */
|
|
10
|
+
type ColumnAlign = "start" | "end";
|
|
11
|
+
/** Which edge a column freezes against while the table scrolls horizontally. */
|
|
12
|
+
type ColumnPin = "start" | "end";
|
|
13
|
+
type SortDirection = "asc" | "desc";
|
|
14
|
+
/** The whole sort state — one column at a time. Multi-column sort is deliberately not offered:
|
|
15
|
+
* it needs a priority UI no table of this size has ever earned. */
|
|
16
|
+
interface TableSort<K extends string = string> {
|
|
17
|
+
key: K;
|
|
18
|
+
dir: SortDirection;
|
|
19
|
+
}
|
|
20
|
+
/** A multi-select over the distinct values in this column. Options and their COUNTS are derived
|
|
21
|
+
* from the live rows when `options` is omitted, and the counts reflect the OTHER active filters
|
|
22
|
+
* (so they tell you what would happen if you picked one, not what already happened). */
|
|
23
|
+
interface FacetFilter<Row> {
|
|
24
|
+
kind: "facet";
|
|
25
|
+
/** Trigger label. Falls back to the column's `header` when it is a string. */
|
|
26
|
+
label?: string;
|
|
27
|
+
/** Fixed option set. Omit to derive from the rows. */
|
|
28
|
+
options?: readonly {
|
|
29
|
+
value: string;
|
|
30
|
+
label?: React.ReactNode;
|
|
31
|
+
}[];
|
|
32
|
+
/** For array-valued cells (a user in several teams). Falls back to the column's `value`/`key`. */
|
|
33
|
+
getValue?: (row: Row) => string | readonly string[] | null | undefined;
|
|
34
|
+
}
|
|
35
|
+
interface TextFilter {
|
|
36
|
+
kind: "text";
|
|
37
|
+
label?: string;
|
|
38
|
+
}
|
|
39
|
+
interface NumberFilter {
|
|
40
|
+
kind: "number";
|
|
41
|
+
label?: string;
|
|
42
|
+
}
|
|
43
|
+
interface DateRangeFilter {
|
|
44
|
+
kind: "dateRange";
|
|
45
|
+
label?: string;
|
|
46
|
+
}
|
|
47
|
+
type ColumnFilter<Row> = FacetFilter<Row> | TextFilter | NumberFilter | DateRangeFilter;
|
|
48
|
+
/** The runtime value a filter control holds, discriminated the same way as its declaration. */
|
|
49
|
+
type FilterValue = {
|
|
50
|
+
kind: "facet";
|
|
51
|
+
values: readonly string[];
|
|
52
|
+
} | {
|
|
53
|
+
kind: "text";
|
|
54
|
+
value: string;
|
|
55
|
+
} | {
|
|
56
|
+
kind: "number";
|
|
57
|
+
min?: number;
|
|
58
|
+
max?: number;
|
|
59
|
+
} | {
|
|
60
|
+
kind: "dateRange";
|
|
61
|
+
from?: string;
|
|
62
|
+
to?: string;
|
|
63
|
+
};
|
|
64
|
+
/** The whole filter state, keyed by column. This is what `filters` / `defaultFilters` /
|
|
65
|
+
* `onFiltersChange` speak in — a server-side table turns it into a query string. */
|
|
66
|
+
type TableFilters<K extends string = string> = Readonly<Partial<Record<K, FilterValue>>>;
|
|
67
|
+
/** One removable chip in the filter strip. */
|
|
68
|
+
interface ActiveFilter<K extends string = string> {
|
|
69
|
+
key: K;
|
|
70
|
+
label: string;
|
|
71
|
+
/** What the chip reads — "Status: Active, Invited". */
|
|
72
|
+
display: string;
|
|
73
|
+
/** Removes just this filter. */
|
|
74
|
+
clear: () => void;
|
|
75
|
+
}
|
|
76
|
+
/** How a column behaves in `responsive="cards"` mode.
|
|
77
|
+
* - `primary` — promoted into the card's title row (the name/avatar cell, typically)
|
|
78
|
+
* - `normal` — a label/value pair in the card body (default)
|
|
79
|
+
* - `hidden` — dropped from cards only; still rendered in the table */
|
|
80
|
+
type CardPriority = "primary" | "normal" | "hidden";
|
|
81
|
+
interface TableColumn<Row, K extends string = string> {
|
|
82
|
+
/** Stable identity. Also the property read from the row when `cell`/`value` are omitted. */
|
|
83
|
+
key: K;
|
|
84
|
+
/** Header content. A string also becomes the facet-filter label and the card-mode label. */
|
|
85
|
+
header?: React.ReactNode;
|
|
86
|
+
/** A help icon + Tooltip beside the header label. */
|
|
87
|
+
tooltip?: string;
|
|
88
|
+
/** Renders the cell. Omit and the raw `row[key]` is stringified. */
|
|
89
|
+
cell?: (row: Row) => React.ReactNode;
|
|
90
|
+
/**
|
|
91
|
+
* The sort / search / filter key. Required whenever `cell` renders something non-primitive:
|
|
92
|
+
* sorting a column of `<Badge>`s by its rendered node is meaningless, so the column has to say
|
|
93
|
+
* what it is really ordered by. Omit and `row[key]` is used.
|
|
94
|
+
*/
|
|
95
|
+
value?: (row: Row) => string | number | boolean | Date | null | undefined;
|
|
96
|
+
sortable?: boolean;
|
|
97
|
+
align?: ColumnAlign;
|
|
98
|
+
pin?: ColumnPin;
|
|
99
|
+
/** How the cell's content behaves when it is wider than the column. Defaults to `truncate`. */
|
|
100
|
+
overflow?: OverflowMode;
|
|
101
|
+
/**
|
|
102
|
+
* How the column claims horizontal space. Defaults to `"fit"`.
|
|
103
|
+
*
|
|
104
|
+
* - `"fit"` — size to the column's own content.
|
|
105
|
+
* - a **number** — a **PROPORTION, not a pixel**. The `<table>` is always `w-full` and
|
|
106
|
+
* `table-layout` is never set, so with slack to share every declared width inflates by the
|
|
107
|
+
* SAME factor (220·240·120·96 rendered 276·301·151·120 in an 848px container, and
|
|
108
|
+
* 456·497·249·199 at 1400px). Required for a pinned column: `sticky` offsets cannot be
|
|
109
|
+
* computed from an `auto` width, so a pinned column must declare a number — `"grow"`/`"fit"`
|
|
110
|
+
* warn in dev exactly like an omitted width.
|
|
111
|
+
* - `"grow"` — park all the slack in THIS column. **At most one per table**, and it makes every
|
|
112
|
+
* OTHER column's declared number inert: measured pixel-identical with widths, without them,
|
|
113
|
+
* and at values wider than the content. A second `"grow"` is ignored (the leftmost column has
|
|
114
|
+
* already claimed the slack) — for several flexible columns, declare numbers on all of them
|
|
115
|
+
* and let the proportional regime share the slack instead.
|
|
116
|
+
*
|
|
117
|
+
* `"grow"` and a number are therefore alternatives, never a pair — which is why this is ONE
|
|
118
|
+
* union and not `width` + a `grow` boolean. That pair could spell the contradiction
|
|
119
|
+
* (`{ width: 220, grow: true }`) and the loser was **silent**: an inline `style.width` beats the
|
|
120
|
+
* `w-full` class, so `grow` died and the table rendered as plain proportional.
|
|
121
|
+
*/
|
|
122
|
+
width?: number | "grow" | "fit";
|
|
123
|
+
/** Starts hidden; the user can still reveal it from the column-visibility menu. */
|
|
124
|
+
defaultHidden?: boolean;
|
|
125
|
+
/** `false` keeps the column out of the visibility menu entirely. Default `true`. */
|
|
126
|
+
hideable?: boolean;
|
|
127
|
+
filter?: ColumnFilter<Row>;
|
|
128
|
+
cardPriority?: CardPriority;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* A banded header — one `<th colSpan>` spanning several leaf columns.
|
|
132
|
+
*
|
|
133
|
+
* Exactly ONE level: a group may not contain another group. That is enforced by the type rather
|
|
134
|
+
* than a warning, because arbitrarily deep bands are a different feature (a pivot table) wearing
|
|
135
|
+
* this one's clothes.
|
|
136
|
+
*/
|
|
137
|
+
interface TableColumnGroup<Row, K extends string = string> {
|
|
138
|
+
header: React.ReactNode;
|
|
139
|
+
columns: readonly TableColumn<Row, K>[];
|
|
140
|
+
}
|
|
141
|
+
type TableColumns<Row, K extends string = string> = readonly (TableColumn<Row, K> | TableColumnGroup<Row, K>)[];
|
|
142
|
+
/** Narrow a banded group. */
|
|
143
|
+
declare function isColumnGroup<Row, K extends string>(entry: TableColumn<Row, K> | TableColumnGroup<Row, K>): entry is TableColumnGroup<Row, K>;
|
|
144
|
+
/** Flatten `columns` to its leaves, in visual order. Bands contribute their children. */
|
|
145
|
+
declare function flattenColumns<Row, K extends string>(columns: TableColumns<Row, K>): TableColumn<Row, K>[];
|
|
146
|
+
/** Whether ANY entry is a band — i.e. whether the header needs two rows. */
|
|
147
|
+
declare function hasColumnGroups<Row, K extends string>(columns: TableColumns<Row, K>): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* What a row expands INTO — a tree branch or a detail panel, never both.
|
|
150
|
+
*
|
|
151
|
+
* The `never` members are load-bearing: excess-property checking rejects
|
|
152
|
+
* `{ children: […], detail: <X/> }` at the call site, so the contradiction is UNREPRESENTABLE
|
|
153
|
+
* rather than merely dev-warned. A warning is not a guarantee (AGENTS §4).
|
|
154
|
+
*/
|
|
155
|
+
type RowExpansion<Row> = {
|
|
156
|
+
children: readonly Row[];
|
|
157
|
+
detail?: never;
|
|
158
|
+
} | {
|
|
159
|
+
detail: React.ReactNode;
|
|
160
|
+
children?: never;
|
|
161
|
+
};
|
|
162
|
+
/** Called per row. `null`/`undefined` means "leaf" — no chevron, not expandable. */
|
|
163
|
+
type ExpansionResolver<Row> = (row: Row) => RowExpansion<Row> | null | undefined;
|
|
164
|
+
/** The child rows of a tree branch, or `null` for a detail row / leaf. */
|
|
165
|
+
declare function expansionChildren<Row>(result: RowExpansion<Row> | null | undefined): readonly Row[] | null;
|
|
166
|
+
/** The detail panel of a row, or `null` for a tree branch / leaf. */
|
|
167
|
+
declare function expansionDetail<Row>(result: RowExpansion<Row> | null | undefined): React.ReactNode | null;
|
|
168
|
+
/**
|
|
169
|
+
* What a click on the row BODY does.
|
|
170
|
+
*
|
|
171
|
+
* ONE union, not an `onRowClick` handler beside `selectOnRowClick` / `expandOnRowClick` booleans.
|
|
172
|
+
* A click resolves to exactly one outcome, so the alternatives override each other and belong in a
|
|
173
|
+
* single prop (AGENTS §4): the boolean spelling can express `<Table onRowClick={open}
|
|
174
|
+
* selectOnRowClick />`, a contradiction only a dev-warn could police — and a warning is not a
|
|
175
|
+
* guarantee. The union also gives the "nothing happens" case a NAME (`"none"`) instead of leaving
|
|
176
|
+
* it as an unspellable default.
|
|
177
|
+
*
|
|
178
|
+
* - **`"none"`** (default) — the row is inert; only its own controls respond.
|
|
179
|
+
* - **`"select"`** — toggles this row's selection, doing exactly what its checkbox/radio does.
|
|
180
|
+
* - **`"expand"`** — toggles this row's disclosure, doing exactly what its chevron does.
|
|
181
|
+
* - **a function** — your own handler (open the record, navigate, …).
|
|
182
|
+
*
|
|
183
|
+
* `"select"` / `"expand"` are a SECOND trigger for a control that stays on the row, never a
|
|
184
|
+
* replacement for it: the checkbox is what shows *what is selected*, the chevron is what shows
|
|
185
|
+
* *open or closed*, and both remain the keyboard path — which is why the row does not become a
|
|
186
|
+
* redundant second tab stop under them. A **function** has no such control, so there the row
|
|
187
|
+
* itself is focusable and answers Enter/Space (WCAG 2.1.1).
|
|
188
|
+
*/
|
|
189
|
+
type TableRowClick<Row> = "none" | "select" | "expand" | ((row: Row) => void);
|
|
190
|
+
/**
|
|
191
|
+
* One row action — a link OR a click, never a confirmed link.
|
|
192
|
+
*
|
|
193
|
+
* `href` renders the control as a real `<a>` (`<Button render={<a href/>}>`, the same idiom
|
|
194
|
+
* `DropdownMenu` uses), so middle-click, ⌘-click and "copy link address" all work — the things an
|
|
195
|
+
* `onClick={() => router.push(…)}` silently takes away.
|
|
196
|
+
*
|
|
197
|
+
* The `never` members are load-bearing, exactly as in {@link RowExpansion}: a confirmation dialog
|
|
198
|
+
* is a JavaScript gate, and the browser follows a link before any gate can run. So
|
|
199
|
+
* `{ href, confirm }` is not a thing that could work, and it is UNREPRESENTABLE rather than
|
|
200
|
+
* dev-warned — a warning is not a guarantee (AGENTS §4). Guard a destination by making it an
|
|
201
|
+
* `onClick` that navigates once the confirm resolves.
|
|
202
|
+
*
|
|
203
|
+
* The base is spelled inline rather than as a named `RowActionBase`, so the API snapshot prints
|
|
204
|
+
* the whole contract instead of a name that is not exported.
|
|
205
|
+
*/
|
|
206
|
+
type RowAction = {
|
|
207
|
+
label: string;
|
|
208
|
+
icon?: React.ReactNode;
|
|
209
|
+
/** Fires on activation — and still fires on an `href` action, for the analytics/side-effect case. */
|
|
210
|
+
onClick?: () => void;
|
|
211
|
+
/** Tints the control — `error` for a destructive action. */
|
|
212
|
+
tone?: SemanticColor;
|
|
213
|
+
/** A disabled action is never a link: navigation is the browser's and an `<a>` cannot be
|
|
214
|
+
* disabled, so dropping the `href` is what actually makes it inert. */
|
|
215
|
+
disabled?: boolean;
|
|
216
|
+
} & ({
|
|
217
|
+
href: string;
|
|
218
|
+
confirm?: never;
|
|
219
|
+
} | {
|
|
220
|
+
href?: never;
|
|
221
|
+
/** Routes the action through a confirmation dialog before `onClick` fires. */
|
|
222
|
+
confirm?: {
|
|
223
|
+
title: string;
|
|
224
|
+
description?: string;
|
|
225
|
+
confirmLabel?: string;
|
|
226
|
+
};
|
|
227
|
+
});
|
|
228
|
+
/**
|
|
229
|
+
* One row in a `variant: "menu"` row-action menu.
|
|
230
|
+
*
|
|
231
|
+
* The `menu` variant renders through the library's own `<DropdownMenu>`, so its vocabulary is
|
|
232
|
+
* DropdownMenu's — at least, and not less. It used to be strictly less: every item flattened to a
|
|
233
|
+
* plain action row, which meant a ⋮ menu could not group its rows, rule a line between the safe
|
|
234
|
+
* actions and the destructive one, or nest a "Move to ▸" branch, even though the component doing the
|
|
235
|
+
* rendering has supported all three since it shipped. A menu that cannot say what its own menu
|
|
236
|
+
* component can say is a translation layer, not an API.
|
|
237
|
+
*
|
|
238
|
+
* So the union substitutes {@link RowAction} for DropdownMenu's action row and reuses the rest:
|
|
239
|
+
*
|
|
240
|
+
* - **action row** — a `RowAction`, keeping the row-action extras a bare menu row has no idea about
|
|
241
|
+
* (`tone`, `confirm`, and the disabled-drops-`href` rule).
|
|
242
|
+
* - **`{ separator: true }`** · **checkbox** · **radio** — no row-action semantics to add, so these
|
|
243
|
+
* are DropdownMenu's own types, passed through untouched.
|
|
244
|
+
* - **group** and **submenu** — spelled here rather than reused, because their `items` must recurse
|
|
245
|
+
* into `RowMenuItem` and NOT `DropdownMenuItem`: a `confirm`-guarded Delete nested one level deep
|
|
246
|
+
* has to keep its dialog. The submenu's icon slot is `icon`, matching `RowAction.icon` (the
|
|
247
|
+
* single-icon carve-out in AGENTS §4) rather than DropdownMenu's `leading`, so one array is
|
|
248
|
+
* written in one vocabulary.
|
|
249
|
+
*
|
|
250
|
+
* Discriminated structurally, in DropdownMenu's own order (`separator` → `type` → `group` →
|
|
251
|
+
* `items` → action). `RowAction` declares none of those keys, so it is the fallthrough.
|
|
252
|
+
*/
|
|
253
|
+
type RowMenuItem = RowAction | DropdownMenuSeparatorItem | DropdownMenuCheckboxItem | DropdownMenuRadioItem
|
|
254
|
+
/** A titled cluster of rows (aria-labelledby-wired by DropdownMenu). Recursive. */
|
|
255
|
+
| {
|
|
256
|
+
group: React.ReactNode;
|
|
257
|
+
items: readonly RowMenuItem[];
|
|
258
|
+
}
|
|
259
|
+
/** A submenu row — a `label` WITH `items`. Recursive, so it nests to any depth. */
|
|
260
|
+
| {
|
|
261
|
+
label: React.ReactNode;
|
|
262
|
+
items: readonly RowMenuItem[];
|
|
263
|
+
icon?: React.ReactNode;
|
|
264
|
+
/** The branch holding the current destination — the brand mark, no `aria-current`. */
|
|
265
|
+
active?: boolean;
|
|
266
|
+
disabled?: boolean;
|
|
267
|
+
/** Layout/spacing only, merged via `cn()`. */
|
|
268
|
+
className?: string;
|
|
269
|
+
};
|
|
270
|
+
/**
|
|
271
|
+
* The row-action column — `icons` (default) · `links` · `menu`.
|
|
272
|
+
*
|
|
273
|
+
* A UNION, not one interface with an optional `variant`, because the `icons` variant renders the
|
|
274
|
+
* glyph AS the button: an action with no `icon` there is a 32px blank that nothing can click by
|
|
275
|
+
* sight. That was not hypothetical — every demo on the Table page passed `{ label, onClick }` and
|
|
276
|
+
* the whole actions column rendered invisible. So `icon` is REQUIRED on the `icons` branch and
|
|
277
|
+
* optional on the other two (where the label carries the meaning), the same
|
|
278
|
+
* unrepresentable-rather-than-dev-warned discipline `{ href, confirm }` already uses above.
|
|
279
|
+
*
|
|
280
|
+
* A caller whose `variant` is a variable of the whole union still needs no narrowing dance: items
|
|
281
|
+
* that carry an `icon` satisfy EVERY branch, so `{ variant, items }` checks out — and items that
|
|
282
|
+
* do not are exactly the case this union exists to reject.
|
|
283
|
+
*
|
|
284
|
+
* `menu` now has its own branch for two reasons. Its items are {@link RowMenuItem}s (a separator or
|
|
285
|
+
* a group is meaningless as an icon button, so the other two variants must not accept one), and it
|
|
286
|
+
* has **no `max`**: that prop was declared here and documented "Ignored when `variant` is `menu`",
|
|
287
|
+
* i.e. a dead prop shipped in the type — the exact failure the one-state-owner rule was written
|
|
288
|
+
* about (AGENTS §11). Unrepresentable beats documented-as-ignored. It is also what keeps `max`'s
|
|
289
|
+
* `slice()` from ever cutting a group in half. The cost, paid deliberately: a caller holding
|
|
290
|
+
* `variant` as a variable of the whole union can no longer also pass `max` without narrowing.
|
|
291
|
+
*/
|
|
292
|
+
type RowActions<Row> = {
|
|
293
|
+
/** Icon buttons with tooltips — the default, and the densest. */
|
|
294
|
+
variant?: "icons";
|
|
295
|
+
/** `icon` is required here: it IS the button. */
|
|
296
|
+
items: (row: Row) => readonly (RowAction & {
|
|
297
|
+
icon: React.ReactNode;
|
|
298
|
+
})[];
|
|
299
|
+
/** Past this many, the tail collapses into a menu. */
|
|
300
|
+
max?: number;
|
|
301
|
+
} | {
|
|
302
|
+
/** `links` — inline link buttons. */
|
|
303
|
+
variant: "links";
|
|
304
|
+
items: (row: Row) => readonly RowAction[];
|
|
305
|
+
/** Past this many, the tail collapses into a menu. */
|
|
306
|
+
max?: number;
|
|
307
|
+
} | {
|
|
308
|
+
/** `menu` — one ⋮ dots menu, with DropdownMenu's whole item vocabulary. */
|
|
309
|
+
variant: "menu";
|
|
310
|
+
items: (row: Row) => readonly RowMenuItem[];
|
|
311
|
+
};
|
|
312
|
+
interface BulkAction {
|
|
313
|
+
label: string;
|
|
314
|
+
icon?: React.ReactNode;
|
|
315
|
+
tone?: SemanticColor;
|
|
316
|
+
onClick: (ids: ReadonlySet<string>) => void;
|
|
317
|
+
/** Routes the action through the same confirmation dialog a `RowAction` uses. */
|
|
318
|
+
confirm?: {
|
|
319
|
+
title: string;
|
|
320
|
+
description?: string;
|
|
321
|
+
confirmLabel?: string;
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
interface TableToolbar {
|
|
325
|
+
/** A search box filtering across every column that has a `value`/`key` yielding text. */
|
|
326
|
+
search?: boolean | {
|
|
327
|
+
placeholder?: string;
|
|
328
|
+
label?: string;
|
|
329
|
+
};
|
|
330
|
+
/** The "Columns" dropdown. */
|
|
331
|
+
columnVisibility?: boolean;
|
|
332
|
+
/** Trailing free slot — Export, New… */
|
|
333
|
+
actions?: React.ReactNode;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
type TableSize = "sm" | "md";
|
|
337
|
+
/** Divider hairlines vs. alternating fills. ONE union, not a `zebra` boolean — they are two
|
|
338
|
+
* answers to a single question and only one can win (AGENTS §4). */
|
|
339
|
+
type TableTreatment = "divided" | "striped";
|
|
340
|
+
/**
|
|
341
|
+
* Whether a row washes under the pointer.
|
|
342
|
+
*
|
|
343
|
+
* A union rather than a `rowHover?: boolean`, for the reason its sibling `rowClick` is one: the
|
|
344
|
+
* OFF state gets a name (`"none"`, the same word, so the two props read alike) instead of being an
|
|
345
|
+
* unspellable `{false}`, and a third answer can join without a breaking change — "highlight only
|
|
346
|
+
* when the row actually does something" is a real design a boolean cannot express.
|
|
347
|
+
*
|
|
348
|
+
* It is orthogonal to `treatment`, which is the row's RESTING fill: fusing them would make
|
|
349
|
+
* "striped, no hover" unspellable.
|
|
350
|
+
*/
|
|
351
|
+
type TableRowHover = "highlight" | "none";
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* A config object that must carry at least one field — `{}` is a type error.
|
|
355
|
+
*
|
|
356
|
+
* WHY: a grouped config prop (`paginate`, `pagination`) is off when absent and on when present, so
|
|
357
|
+
* an EMPTY object is a second spelling of "on with defaults" — exactly the redundancy the flat-only
|
|
358
|
+
* rules exist to delete (AGENTS §11). `Partial<T>` admits it; this does not.
|
|
359
|
+
*
|
|
360
|
+
* It expands to one branch per key, each requiring that key and leaving the rest optional, so every
|
|
361
|
+
* field stays reachable in any combination and excess-property checking still works.
|
|
362
|
+
*
|
|
363
|
+
* The one cost: a value declared as the all-optional shape does not satisfy this (TypeScript cannot
|
|
364
|
+
* know a `Partial<T>` variable is non-empty). Build such config inline, or narrow at the boundary.
|
|
365
|
+
*/
|
|
366
|
+
type AtLeastOne<T> = {
|
|
367
|
+
[K in keyof T]-?: Required<Pick<T, K>> & Partial<Omit<T, K>>;
|
|
368
|
+
}[keyof T];
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Paging, as ONE object — `useTable({ paginate: { defaultPageSize: 8 } })`.
|
|
372
|
+
*
|
|
373
|
+
* It is grouped because the switch and its settings have to travel together. As seven flat props
|
|
374
|
+
* beside a `paginate?: boolean`, this typechecked and five of them were dead:
|
|
375
|
+
*
|
|
376
|
+
* useTable({ rows, columns, getRowId, paginate: false, defaultPageSize: 8 })
|
|
377
|
+
*
|
|
378
|
+
* `paginate: false` turns on `manualPagination` and drops the pagination row model, so nothing reads
|
|
379
|
+
* `page`/`pageSize`/`rowCount` or their seeds — the same silently-dead-prop failure a duplicate state
|
|
380
|
+
* channel causes (docs/api-policy.md § one state owner), one level down. Inside the object the
|
|
381
|
+
* contradiction cannot be written: `false` carries no settings.
|
|
382
|
+
*
|
|
383
|
+
* `manual` is deliberately NOT here — it governs sorting and filtering too, so it is not paging's.
|
|
384
|
+
*/
|
|
385
|
+
interface TablePaginateOptions {
|
|
386
|
+
/** Controlled page, 1-based. */
|
|
387
|
+
page?: number;
|
|
388
|
+
/** Uncontrolled seed. @default 1 */
|
|
389
|
+
defaultPage?: number;
|
|
390
|
+
onPageChange?: (page: number) => void;
|
|
391
|
+
/** Controlled rows per page. */
|
|
392
|
+
pageSize?: number;
|
|
393
|
+
/** Uncontrolled seed. @default 10 */
|
|
394
|
+
defaultPageSize?: number;
|
|
395
|
+
onPageSizeChange?: (size: number) => void;
|
|
396
|
+
/** Total rows behind a `manual` table, for the page count. Ignored when client-side. */
|
|
397
|
+
rowCount?: number;
|
|
398
|
+
}
|
|
399
|
+
/** How a table gets its data. `client` sorts/filters/paginates in the browser; `manual` renders
|
|
400
|
+
* exactly the rows it is given and only EMITS the intent, for a server-side backend. */
|
|
401
|
+
interface UseTableOptions<Row, K extends string = string> {
|
|
402
|
+
rows: readonly Row[];
|
|
403
|
+
columns: TableColumns<Row, K>;
|
|
404
|
+
getRowId: (row: Row) => string;
|
|
405
|
+
/** Server mode: we apply nothing, you receive `onSortChange`/`onPageChange`/… and re-fetch. */
|
|
406
|
+
manual?: boolean;
|
|
407
|
+
/**
|
|
408
|
+
* Slice rows into pages, and how.
|
|
409
|
+
*
|
|
410
|
+
* On by default. `false` renders every filtered row; a config object is the same "on", settings
|
|
411
|
+
* included. There is no `true` and no `{}` — both would be a second way to say the default
|
|
412
|
+
* (see {@link AtLeastOne}).
|
|
413
|
+
*/
|
|
414
|
+
paginate?: false | AtLeastOne<TablePaginateOptions>;
|
|
415
|
+
sort?: NoInfer<TableSort<K>> | null;
|
|
416
|
+
defaultSort?: NoInfer<TableSort<K>>;
|
|
417
|
+
onSortChange?: (sort: TableSort<K> | null) => void;
|
|
418
|
+
query?: string;
|
|
419
|
+
defaultQuery?: string;
|
|
420
|
+
onQueryChange?: (query: string) => void;
|
|
421
|
+
/**
|
|
422
|
+
* Milliseconds to hold a keystroke before the query is APPLIED — the filter in client mode, and
|
|
423
|
+
* the {@link UseTableResult.appliedQuery} a `manual` table builds its request from.
|
|
424
|
+
*
|
|
425
|
+
* **Only the applied value lags.** `query` and `onQueryChange` stay on the keystroke, because they
|
|
426
|
+
* are what the search input renders from: a controlled table feeds `query` straight back from
|
|
427
|
+
* `onQueryChange`, so debouncing the EMISSION would freeze the box and drop characters. Lagging
|
|
428
|
+
* the derived value instead means the toolbar needs no knowledge of this prop at all — the input
|
|
429
|
+
* is live, the work is late.
|
|
430
|
+
*
|
|
431
|
+
* Clearing is deliberately exempt (see `appliedQuery`): an empty query applies at once.
|
|
432
|
+
*
|
|
433
|
+
* A duration is a genuinely open `number`, so it stays one and owes a tripwire instead —
|
|
434
|
+
* `warnNonNegativeInt` reports `-1` / `1.5` rather than clamping them into something that
|
|
435
|
+
* silently half-works. `0` is a real answer (apply every keystroke) and must not warn.
|
|
436
|
+
*
|
|
437
|
+
* @default 0
|
|
438
|
+
*/
|
|
439
|
+
searchDebounce?: number;
|
|
440
|
+
/**
|
|
441
|
+
* The column filters, as one object keyed by column — the same channel `sort` and `page` have.
|
|
442
|
+
*
|
|
443
|
+
* It exists because `manual` mode has to be able to hear a filter move: sort emitted through
|
|
444
|
+
* `onSortChange` and paging through `onPageChange`, but a filter only ever landed in internal
|
|
445
|
+
* state, so a server-side table's ONLY way to notice one was to watch `table.filters` from an
|
|
446
|
+
* effect. Emitting it is not the same as applying it — under `manual` the engine still filters
|
|
447
|
+
* nothing, it just tells you what the user asked for.
|
|
448
|
+
*
|
|
449
|
+
* `onFiltersChange` receives the WHOLE next object, not the one key that moved, because that is
|
|
450
|
+
* the thing a request is built from. `setFilter`'s per-key call site is unchanged.
|
|
451
|
+
*/
|
|
452
|
+
filters?: NoInfer<TableFilters<K>>;
|
|
453
|
+
defaultFilters?: NoInfer<TableFilters<K>>;
|
|
454
|
+
onFiltersChange?: (filters: TableFilters<K>) => void;
|
|
455
|
+
/**
|
|
456
|
+
* How many rows can be selected at once — and therefore what selection MEANS here.
|
|
457
|
+
*
|
|
458
|
+
* It lives on the engine, not on `<Table>`, because the engine owns every piece of selection
|
|
459
|
+
* state and two of its mutators are only coherent under `multiple`: with the mode on the view,
|
|
460
|
+
* `selection="single"` sat happily beside a caller's own `table.selectAll()` and nothing
|
|
461
|
+
* reconciled them. Now `selectAll`/`togglePage` read the mode (see their definitions), and
|
|
462
|
+
* `none` means there is no selection to reach rather than one that is merely invisible.
|
|
463
|
+
*
|
|
464
|
+
* @default "none"
|
|
465
|
+
*/
|
|
466
|
+
selection?: "none" | "single" | "multiple";
|
|
467
|
+
selectedRows?: ReadonlySet<string> | readonly string[];
|
|
468
|
+
defaultSelectedRows?: readonly string[];
|
|
469
|
+
onSelectionChange?: (ids: ReadonlySet<string>) => void;
|
|
470
|
+
/**
|
|
471
|
+
* Rows the caller renders as non-interactive. Selection must agree with the UI: without this the
|
|
472
|
+
* per-row checkbox rendered `disabled` while select-all added the id anyway, so a bulk action
|
|
473
|
+
* received rows the table had shown as untouchable.
|
|
474
|
+
*/
|
|
475
|
+
disabledRows?: (row: Row) => boolean;
|
|
476
|
+
expansion?: ExpansionResolver<Row>;
|
|
477
|
+
defaultExpanded?: readonly string[];
|
|
478
|
+
expanded?: ReadonlySet<string> | readonly string[];
|
|
479
|
+
onExpandedChange?: (ids: ReadonlySet<string>) => void;
|
|
480
|
+
}
|
|
481
|
+
/** Where the current selection sits relative to the data — drives the "Select all N" escalation. */
|
|
482
|
+
type SelectionState = "none" | "some" | "page" | "all";
|
|
483
|
+
interface UseTableResult<Row, K extends string = string> {
|
|
484
|
+
/** The rows to render: filtered, sorted, and paginated (client mode) or verbatim (manual). */
|
|
485
|
+
rows: readonly Row[];
|
|
486
|
+
/** Rows after filtering, BEFORE pagination. The number a "Select all N" link quotes. */
|
|
487
|
+
filteredRows: readonly Row[];
|
|
488
|
+
/** `filteredRows.length`, or `rowCount` in manual mode. */
|
|
489
|
+
totalRows: number;
|
|
490
|
+
/** What the search input shows — always the last keystroke, never debounced. */
|
|
491
|
+
query: string;
|
|
492
|
+
setQuery: (query: string) => void;
|
|
493
|
+
/**
|
|
494
|
+
* The query the engine is actually filtering by: `query` once `searchDebounce` has elapsed, and
|
|
495
|
+
* `query` itself when there is no debounce.
|
|
496
|
+
*
|
|
497
|
+
* A `manual` table must key its fetch on THIS — using `query` would re-request on every keystroke
|
|
498
|
+
* and defeat the debounce, which is the whole reason the two values are separately named
|
|
499
|
+
* (`paginate`/`pagination` precedent: distinct names for engine vs. view, never one overloaded
|
|
500
|
+
* one). Emptying the box short-circuits it, so a Clear button applies with no delay.
|
|
501
|
+
*/
|
|
502
|
+
appliedQuery: string;
|
|
503
|
+
filters: TableFilters<K>;
|
|
504
|
+
setFilter: (key: K, value: FilterValue | null) => void;
|
|
505
|
+
clearFilters: () => void;
|
|
506
|
+
activeFilters: readonly ActiveFilter<K>[];
|
|
507
|
+
/** `true` when a query or any filter is narrowing the set — an empty table then means
|
|
508
|
+
* "nothing matched", which is a different message from "there is no data". */
|
|
509
|
+
isFiltered: boolean;
|
|
510
|
+
/** Distinct values + live counts for a facet column, reflecting the OTHER active filters. */
|
|
511
|
+
facetCounts: (key: K) => Map<string, number>;
|
|
512
|
+
sort: TableSort<K> | null;
|
|
513
|
+
setSort: (sort: TableSort<K> | null) => void;
|
|
514
|
+
/** asc → desc → none, the cycle a header click walks. */
|
|
515
|
+
toggleSort: (key: K) => void;
|
|
516
|
+
page: number;
|
|
517
|
+
pageCount: number;
|
|
518
|
+
pageSize: number;
|
|
519
|
+
setPage: (page: number) => void;
|
|
520
|
+
setPageSize: (size: number) => void;
|
|
521
|
+
/** The mode this engine was built with — `<Table>` renders the column it implies. */
|
|
522
|
+
selectionMode: "none" | "single" | "multiple";
|
|
523
|
+
selection: ReadonlySet<string>;
|
|
524
|
+
selectionState: SelectionState;
|
|
525
|
+
/**
|
|
526
|
+
* How much of the selection is on the CURRENT page — the number that makes an off-screen
|
|
527
|
+
* selection visible instead of implied.
|
|
528
|
+
*
|
|
529
|
+
* It exists because a selection now outlives a page turn, and two views need the same fact from
|
|
530
|
+
* the same place: the bulk bar splits its count with it (`12 selected · 3 on this page`), and the
|
|
531
|
+
* header checkbox uses it to decide `indeterminate`. Derived from the same page id set that
|
|
532
|
+
* `togglePage` writes, so a disabled or expanded-child row cannot make the two disagree — which a
|
|
533
|
+
* hand-rolled `rows.filter(...)` in each view would eventually do.
|
|
534
|
+
*/
|
|
535
|
+
selectionOnPage: number;
|
|
536
|
+
/** Toggle one row. Under `single` this REPLACES the selection; under `none` it does nothing. */
|
|
537
|
+
toggleRow: (id: string) => void;
|
|
538
|
+
/** Replace the whole selection with one row — what `single` commits. */
|
|
539
|
+
selectOnly: (id: string) => void;
|
|
540
|
+
/** Select-all for the visible page. Only `multiple` has a page to select. */
|
|
541
|
+
togglePage: () => void;
|
|
542
|
+
/** Escalate to every filtered row. Only `multiple` has more than one row to escalate to. */
|
|
543
|
+
selectAll: () => void;
|
|
544
|
+
clearSelection: () => void;
|
|
545
|
+
expanded: ReadonlySet<string>;
|
|
546
|
+
toggleExpanded: (id: string) => void;
|
|
547
|
+
expandAll: () => void;
|
|
548
|
+
collapseAll: () => void;
|
|
549
|
+
columnVisibility: Readonly<Record<string, boolean>>;
|
|
550
|
+
toggleColumn: (key: K) => void;
|
|
551
|
+
setColumnVisible: (key: K, visible: boolean) => void;
|
|
552
|
+
/**
|
|
553
|
+
* Server-side mode, echoed back — and what the view reads it FOR is enumerability: under `manual`
|
|
554
|
+
* the engine holds one page of ids and can never name the other 230, so "Select all N" is a link
|
|
555
|
+
* it must not offer. Not a styling switch; the one question is "can this instance produce every
|
|
556
|
+
* id in the set?".
|
|
557
|
+
*/
|
|
558
|
+
manual: boolean;
|
|
559
|
+
/** The column set this engine was built from. */
|
|
560
|
+
columns: TableColumns<Row, K>;
|
|
561
|
+
expansion?: ExpansionResolver<Row>;
|
|
562
|
+
disabledRows?: (row: Row) => boolean;
|
|
563
|
+
/** Row identity, threaded through so the renderer never re-derives it. */
|
|
564
|
+
getRowId: (row: Row) => string;
|
|
565
|
+
/**
|
|
566
|
+
* Does any SOURCE row have children? That is the difference between a tree and a table with
|
|
567
|
+
* detail panels, and it decides where the disclosure lives.
|
|
568
|
+
*
|
|
569
|
+
* Derived from the rows the engine was GIVEN, never from the rendered page: computed from the
|
|
570
|
+
* visible slice, a filter or a page turn that happened to hide every branch would move the twisty
|
|
571
|
+
* into a different column mid-session.
|
|
572
|
+
*/
|
|
573
|
+
isTree: boolean;
|
|
574
|
+
/** Depth of a row in a tree (0 for roots). Empty unless `expansion` yields `children`. */
|
|
575
|
+
rowDepth: ReadonlyMap<string, number>;
|
|
576
|
+
}
|
|
577
|
+
declare function useTable<Row, K extends string = string>(options: UseTableOptions<Row, K>): UseTableResult<Row, K>;
|
|
578
|
+
|
|
579
|
+
/** How a table collapses when it is wider than its container. ONE union, not a `mobileCards`
|
|
580
|
+
* boolean: `scroll` is a real named member and the default, and a third strategy can join
|
|
581
|
+
* without turning into a boolean pair. */
|
|
582
|
+
type TableResponsive = "scroll" | "cards";
|
|
583
|
+
/**
|
|
584
|
+
* The footer's look, for `<Table pagination={{ … }}>`.
|
|
585
|
+
*
|
|
586
|
+
* `align`, `color`, `goto` and `siblingCount` are `<Pagination>` props the table could not reach at
|
|
587
|
+
* all — the only way to a page field or a `siblingCount={0}` window was to stop using `<Table>` and
|
|
588
|
+
* hand-render the footer.
|
|
589
|
+
*
|
|
590
|
+
* VIEW ONLY, deliberately. Everything `useTable()` owns is absent — `page`, `pageSize`, `paginate`,
|
|
591
|
+
* `rowCount`, the `default*` seeds, the `on*Change` callbacks — because a state prop here would be a
|
|
592
|
+
* second owner (docs/api-policy.md § one state owner) that no gate can catch: `state:check` compares
|
|
593
|
+
* TOP-LEVEL prop names and cannot see inside an object. `Table.test-d.tsx` is what holds that line.
|
|
594
|
+
* `pageSizeOptions` is absent for a different reason: it stays a top-level `<Table>` prop, so the
|
|
595
|
+
* select's contents keep ONE home rather than two that can disagree.
|
|
596
|
+
*/
|
|
597
|
+
interface TablePaginationOptions {
|
|
598
|
+
variant?: PaginationVariant;
|
|
599
|
+
align?: PaginationAlign;
|
|
600
|
+
color?: PaginationColor;
|
|
601
|
+
goto?: boolean;
|
|
602
|
+
siblingCount?: number;
|
|
603
|
+
}
|
|
604
|
+
interface TableProps<Row, K extends string = string> {
|
|
605
|
+
/**
|
|
606
|
+
* The engine. Build it with `useTable({ rows, columns, getRowId, … })`.
|
|
607
|
+
*
|
|
608
|
+
* There is no self-managed mode: a table has exactly ONE state owner, the same rule
|
|
609
|
+
* `const [form, Form] = useForm()` holds in `src/form/`. `<Table>` renders what the instance
|
|
610
|
+
* says — it never builds a second one, and it takes no `rows`/`columns`/`getRowId` of its own to
|
|
611
|
+
* disagree with (see `docs/api-policy.md` § one state owner).
|
|
612
|
+
*/
|
|
613
|
+
table: UseTableResult<Row, K>;
|
|
614
|
+
/** `sm` (36px header / 56px rows) · `md` (44 / 72). @default "md" */
|
|
615
|
+
size?: TableSize;
|
|
616
|
+
/** Hairline dividers, or alternating fills. @default "divided" */
|
|
617
|
+
treatment?: TableTreatment;
|
|
618
|
+
/**
|
|
619
|
+
* Whether a row washes under the pointer. `"none"` turns the wash off for a table that is pure
|
|
620
|
+
* output — nothing on the row responds to a click, so feedback that says "this is interactive"
|
|
621
|
+
* is a lie. Orthogonal to `treatment` (the resting fill) and to `selection` (a selected row
|
|
622
|
+
* keeps its brand wash either way). The card stack (`responsive="cards"`) paints no row wash at
|
|
623
|
+
* all, so this only describes the table path.
|
|
624
|
+
*
|
|
625
|
+
* @default "highlight"
|
|
626
|
+
*/
|
|
627
|
+
rowHover?: TableRowHover;
|
|
628
|
+
title?: React.ReactNode;
|
|
629
|
+
/** A count chip beside the title. A bare string/number is wrapped in a `<Badge>`. */
|
|
630
|
+
badge?: React.ReactNode;
|
|
631
|
+
description?: React.ReactNode;
|
|
632
|
+
/** Trailing slot in the card header — Export, New… */
|
|
633
|
+
headerActions?: React.ReactNode;
|
|
634
|
+
/** Accessible caption, rendered visually hidden. */
|
|
635
|
+
caption?: string;
|
|
636
|
+
rowActions?: RowActions<Row>;
|
|
637
|
+
/**
|
|
638
|
+
* What a click on the row body does — `"none"` (default) · `"select"` · `"expand"` · your own
|
|
639
|
+
* `(row) => void`. See {@link TableRowClick}; controls inside cells stop propagation, so the
|
|
640
|
+
* checkbox, the chevron and the row-action menu keep working under every member.
|
|
641
|
+
*
|
|
642
|
+
* `"select"` needs `selection` on the `useTable()` instance and `"expand"` needs `expansion` —
|
|
643
|
+
* both dev-warn (and stay inert) otherwise.
|
|
644
|
+
*
|
|
645
|
+
* @default "none"
|
|
646
|
+
*/
|
|
647
|
+
rowClick?: TableRowClick<Row>;
|
|
648
|
+
toolbar?: TableToolbar;
|
|
649
|
+
bulkActions?: readonly BulkAction[];
|
|
650
|
+
/**
|
|
651
|
+
* Renders a `<Pagination>` footer. `true` takes its defaults, a string picks the variant, an object
|
|
652
|
+
* configures it — the same widening `toolbar.search` already ships.
|
|
653
|
+
*
|
|
654
|
+
* @default false
|
|
655
|
+
*/
|
|
656
|
+
pagination?: boolean | PaginationVariant | TablePaginationOptions;
|
|
657
|
+
/** Rows-per-page choices for that footer. `<Pagination>` has always accepted this, but the
|
|
658
|
+
* table never forwarded it — so the ONLY way to reach it was to stop using `<Table>`, and a
|
|
659
|
+
* `defaultPageSize` outside the default list rendered a select with no matching option:
|
|
660
|
+
* "Rows per page: 10" while paginating in 8s. It is the SELECT's contents, not a bound on the
|
|
661
|
+
* state — `table.setPageSize(n)` still takes any `n` — so it stays on the view beside
|
|
662
|
+
* `pagination`. */
|
|
663
|
+
pageSizeOptions?: readonly number[];
|
|
664
|
+
loading?: boolean;
|
|
665
|
+
/** @default 5 */
|
|
666
|
+
loadingRows?: number;
|
|
667
|
+
/** Replaces the default empty `<Callout>`. */
|
|
668
|
+
empty?: React.ReactNode;
|
|
669
|
+
/** Replaces the body entirely. A string becomes an error-tone `Callout`. */
|
|
670
|
+
error?: React.ReactNode;
|
|
671
|
+
onRetry?: () => void;
|
|
672
|
+
stickyHeader?: boolean;
|
|
673
|
+
/** Scroller height in CSS pixels — what makes `stickyHeader` mean anything. */
|
|
674
|
+
maxHeight?: number;
|
|
675
|
+
/** @default "scroll" */
|
|
676
|
+
responsive?: TableResponsive;
|
|
677
|
+
/** Layout/spacing only. Never restyles internals. */
|
|
678
|
+
className?: string;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* A data table: `columns` describe the shape, `rows` are your own objects — and both live on the
|
|
682
|
+
* `useTable()` instance you hand it.
|
|
683
|
+
*
|
|
684
|
+
* A pure VIEW. It owns no state and builds no engine, so there is exactly one place a table's data
|
|
685
|
+
* and behaviour are configured, and one place the invariants live (page resets on filter, clamps
|
|
686
|
+
* when the set shrinks, selection clears when the scope changes). Client-side sorting, filtering,
|
|
687
|
+
* selection and pagination still work with no wiring beyond the hook call; a server-side backend
|
|
688
|
+
* passes `manual` to `useTable` and receives the intent instead.
|
|
689
|
+
*/
|
|
690
|
+
declare function Table<Row, K extends string = string>(props: TableProps<Row, K>): React.JSX.Element;
|
|
691
|
+
|
|
692
|
+
export { type ActiveFilter, type BulkAction, type CardPriority, type ColumnAlign, type ColumnFilter, type ColumnPin, type DateRangeFilter, type ExpansionResolver, type FacetFilter, type FilterValue, type NumberFilter, type RowAction, type RowActions, type RowExpansion, type RowMenuItem, type SelectionState, type SortDirection, Table, type TableColumn, type TableColumnGroup, type TableColumns, type TableFilters, type TablePaginateOptions, type TablePaginationOptions, type TableProps, type TableResponsive, type TableRowClick, type TableRowHover, type TableSize, type TableSort, type TableToolbar, type TableTreatment, type TextFilter, type UseTableOptions, type UseTableResult, expansionChildren, expansionDetail, flattenColumns, hasColumnGroups, isColumnGroup, useTable };
|