@tedi-design-system/react 18.0.0-rc.4 → 18.0.0-rc.6

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.
Files changed (82) hide show
  1. package/_virtual/index.es13.js +2 -2
  2. package/_virtual/index.es14.js +2 -2
  3. package/bundle-stats.html +1 -1
  4. package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.cjs.js +1 -1
  5. package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.es.js +1 -1
  6. package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
  7. package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.es.js +1 -1
  8. package/external/hoist-non-react-statics/external/react-is/index.cjs.js +1 -1
  9. package/external/hoist-non-react-statics/external/react-is/index.es.js +1 -1
  10. package/external/prop-types/external/react-is/cjs/react-is.development.cjs.js +1 -1
  11. package/external/prop-types/external/react-is/cjs/react-is.development.es.js +1 -1
  12. package/external/prop-types/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
  13. package/external/prop-types/external/react-is/cjs/react-is.production.min.es.js +1 -1
  14. package/external/prop-types/external/react-is/index.cjs.js +1 -1
  15. package/external/prop-types/external/react-is/index.es.js +1 -1
  16. package/external/react-is/index.cjs.js +1 -1
  17. package/external/react-is/index.es.js +1 -1
  18. package/external/toposort/index.cjs.js +1 -1
  19. package/external/toposort/index.es.js +1 -1
  20. package/index.css +1 -1
  21. package/package.json +1 -1
  22. package/src/tedi/components/buttons/button-group/button-group.cjs.js +1 -1
  23. package/src/tedi/components/buttons/button-group/button-group.es.js +4 -4
  24. package/src/tedi/components/buttons/collapse/collapse.cjs.js +1 -1
  25. package/src/tedi/components/buttons/collapse/collapse.d.ts +15 -0
  26. package/src/tedi/components/buttons/collapse/collapse.es.js +55 -54
  27. package/src/tedi/components/content/calendar/calendar.cjs.js +1 -1
  28. package/src/tedi/components/content/calendar/calendar.d.ts +9 -1
  29. package/src/tedi/components/content/calendar/calendar.es.js +72 -71
  30. package/src/tedi/components/content/calendar/calendar.module.scss.cjs.js +1 -1
  31. package/src/tedi/components/content/calendar/calendar.module.scss.es.js +3 -2
  32. package/src/tedi/components/content/table/index.d.ts +6 -0
  33. package/src/tedi/components/content/table/table-columns-menu/table-columns-menu.cjs.js +1 -0
  34. package/src/tedi/components/content/table/table-columns-menu/table-columns-menu.d.ts +15 -0
  35. package/src/tedi/components/content/table/table-columns-menu/table-columns-menu.es.js +37 -0
  36. package/src/tedi/components/content/table/table-context.cjs.js +1 -0
  37. package/src/tedi/components/content/table/table-context.d.ts +3 -0
  38. package/src/tedi/components/content/table/table-context.es.js +11 -0
  39. package/src/tedi/components/content/table/table-header-button/table-header-button.cjs.js +1 -0
  40. package/src/tedi/components/content/table/table-header-button/table-header-button.d.ts +51 -0
  41. package/src/tedi/components/content/table/table-header-button/table-header-button.es.js +42 -0
  42. package/src/tedi/components/content/table/table-header-button/table-header-button.module.scss.cjs.js +1 -0
  43. package/src/tedi/components/content/table/table-header-button/table-header-button.module.scss.es.js +7 -0
  44. package/src/tedi/components/content/table/table-toolbar/table-toolbar.cjs.js +1 -0
  45. package/src/tedi/components/content/table/table-toolbar/table-toolbar.d.ts +21 -0
  46. package/src/tedi/components/content/table/table-toolbar/table-toolbar.es.js +9 -0
  47. package/src/tedi/components/content/table/table.cjs.js +1 -0
  48. package/src/tedi/components/content/table/table.d.ts +519 -0
  49. package/src/tedi/components/content/table/table.es.js +856 -0
  50. package/src/tedi/components/content/table/table.module.scss.cjs.js +1 -0
  51. package/src/tedi/components/content/table/table.module.scss.es.js +54 -0
  52. package/src/tedi/components/content/table/use-table-persistence.cjs.js +1 -0
  53. package/src/tedi/components/content/table/use-table-persistence.d.ts +13 -0
  54. package/src/tedi/components/content/table/use-table-persistence.es.js +53 -0
  55. package/src/tedi/components/filter/filter/filter-group-context.cjs.js +1 -0
  56. package/src/tedi/components/filter/filter/filter-group-context.d.ts +8 -0
  57. package/src/tedi/components/filter/filter/filter-group-context.es.js +5 -0
  58. package/src/tedi/components/filter/filter/filter-group.cjs.js +1 -0
  59. package/src/tedi/components/filter/filter/filter-group.d.ts +94 -0
  60. package/src/tedi/components/filter/filter/filter-group.es.js +64 -0
  61. package/src/tedi/components/filter/filter/filter.cjs.js +1 -0
  62. package/src/tedi/components/filter/filter/filter.d.ts +98 -0
  63. package/src/tedi/components/filter/filter/filter.es.js +236 -0
  64. package/src/tedi/components/filter/filter/filter.module.scss.cjs.js +1 -0
  65. package/src/tedi/components/filter/filter/filter.module.scss.es.js +21 -0
  66. package/src/tedi/components/filter/filter/index.d.ts +3 -0
  67. package/src/tedi/components/form/search/search.cjs.js +1 -1
  68. package/src/tedi/components/form/search/search.es.js +22 -20
  69. package/src/tedi/components/navigation/pagination/pagination.cjs.js +1 -1
  70. package/src/tedi/components/navigation/pagination/pagination.d.ts +7 -0
  71. package/src/tedi/components/navigation/pagination/pagination.es.js +132 -91
  72. package/src/tedi/components/navigation/pagination/pagination.module.scss.cjs.js +1 -1
  73. package/src/tedi/components/navigation/pagination/pagination.module.scss.es.js +7 -1
  74. package/src/tedi/components/navigation/pagination/pagination.types.d.ts +100 -0
  75. package/src/tedi/components/overlays/tooltip/tooltip.cjs.js +1 -1
  76. package/src/tedi/components/overlays/tooltip/tooltip.es.js +14 -6
  77. package/src/tedi/index.d.ts +2 -0
  78. package/src/tedi/providers/label-provider/labels-map.cjs.js +1 -1
  79. package/src/tedi/providers/label-provider/labels-map.d.ts +146 -6
  80. package/src/tedi/providers/label-provider/labels-map.es.js +163 -14
  81. package/tedi.cjs.js +1 -1
  82. package/tedi.es.js +205 -185
@@ -0,0 +1,519 @@
1
+ import { ColumnDef, ColumnFiltersState, ColumnOrderState, ExpandedState, PaginationState, Row, RowSelectionState, SortingState, Table as ReactTable, VisibilityState } from '@tanstack/react-table';
2
+ import { CSSProperties, ReactNode } from 'react';
3
+ import { CollapseProps } from '../../buttons/collapse/collapse';
4
+ import { CheckboxProps } from '../../form/checkbox/checkbox';
5
+ import { RadioProps } from '../../form/radio/radio';
6
+ import { TextFieldProps } from '../../form/textfield/textfield';
7
+ import { PaginationProps } from '../../navigation/pagination';
8
+ /**
9
+ * Optional shape that columns can put in `columnDef.meta` to:
10
+ *
11
+ * - drive the column-filter aria-label when the header is non-textual (`label`),
12
+ * - align the column's `<th>` / `<td>` content horizontally (`align`) or vertically
13
+ * (`vAlign`) without wrapping every cell render in a styled span.
14
+ *
15
+ * Wrapper spans still work for the "I want this *one* cell to be different" case;
16
+ * `meta` covers the common "every cell in the column lines up the same way".
17
+ */
18
+ export interface TableColumnMeta {
19
+ /** Accessible label used when the column header isn't a plain string. */
20
+ label?: string;
21
+ /**
22
+ * Props forwarded to the built-in per-column filter input (the `TextField`
23
+ * rendered for this column when `enableColumnFilters` is set). Use it to
24
+ * constrain or tweak the filter field without replacing it — e.g. cap the
25
+ * length with `{ input: { maxLength: 40 } }`, set a custom `placeholder`, or
26
+ * attach `helper` text. The Table owns the field's identity and state
27
+ * (`id`, `name`, `label`, `hideLabel`, `value`, `onChange`), so those are not
28
+ * overridable.
29
+ */
30
+ filterProps?: Omit<TextFieldProps, 'id' | 'name' | 'label' | 'hideLabel' | 'value' | 'onChange'>;
31
+ /**
32
+ * Horizontal alignment applied to every header / body / footer cell in the column.
33
+ * Maps directly to `text-align`. Defaults to `left` (the table's CSS default).
34
+ */
35
+ align?: 'left' | 'center' | 'right';
36
+ /**
37
+ * Vertical alignment applied to every header / body / footer cell in the column.
38
+ * Maps directly to `vertical-align`. Defaults to `middle` for body cells via the
39
+ * table's stylesheet.
40
+ */
41
+ vAlign?: 'top' | 'middle' | 'bottom';
42
+ /**
43
+ * Per-cell `rowSpan` resolver. Lets a column collapse consecutive rows that
44
+ * share a value into a single vertically-spanning cell ("grouped rows").
45
+ *
46
+ * Return:
47
+ * - `n >= 2` — render the cell with `rowSpan={n}`,
48
+ * - `1` (or undefined) — render the cell normally,
49
+ * - `0` — skip the `<td>` entirely; a previous row's spanning cell covers it.
50
+ *
51
+ * Pair with the `groupRowSpan` helper for the common "consecutive rows sharing
52
+ * a key" case. Only the body cells honor this hook — header and footer cells
53
+ * are unaffected.
54
+ */
55
+ rowSpan?: (row: Row<UnknownTData>) => number;
56
+ }
57
+ /**
58
+ * Internal type alias used in `TableColumnMeta.rowSpan` so the resolver can
59
+ * accept any row shape without forcing the meta interface to be generic
60
+ * (TanStack's `columnDef.meta` is intentionally loosely-typed).
61
+ */
62
+ type UnknownTData = unknown;
63
+ /**
64
+ * Builds a `meta.rowSpan` resolver that collapses **consecutive** rows sharing
65
+ * the same key into a single spanning cell — the React equivalent of
66
+ * Angular's `groupRowSpan`.
67
+ *
68
+ * Pass the same array you hand to `<Table data={...}>` plus a key extractor:
69
+ *
70
+ * ```tsx
71
+ * const data = [
72
+ * { id: '1', date: '2026-05-20', doctor: 'Dr Tamm' },
73
+ * { id: '2', date: '2026-05-20', doctor: 'Dr Tamm' },
74
+ * { id: '3', date: '2026-05-21', doctor: 'Dr Kask' },
75
+ * ];
76
+ * const columns: ColumnDef<Row>[] = [
77
+ * { accessorKey: 'date', header: 'Date', meta: { rowSpan: groupRowSpan(data, (d) => d.date) } },
78
+ * { accessorKey: 'doctor', header: 'Doctor' },
79
+ * ];
80
+ * ```
81
+ *
82
+ * Resolves against the original `data` array order — sorting / filtering /
83
+ * pagination will not regroup rows, so the data should already be ordered
84
+ * for the grouping you want before passing it in.
85
+ */
86
+ export declare const groupRowSpan: <TData>(data: TData[], getKey: (item: TData) => unknown) => ((row: Row<TData>) => number);
87
+ /**
88
+ * Persistable state slices owned by Table. Each slice can be controlled via
89
+ * `state`/`onStateChange`, defaulted via `defaultState`, or persisted via
90
+ * `persist`.
91
+ */
92
+ export interface TableState {
93
+ columnVisibility?: VisibilityState;
94
+ columnOrder?: ColumnOrderState;
95
+ rowSelection?: RowSelectionState;
96
+ expanded?: ExpandedState;
97
+ columnFilters?: ColumnFiltersState;
98
+ sorting?: SortingState;
99
+ pagination?: PaginationState;
100
+ }
101
+ export type TableSize = 'medium' | 'small';
102
+ export type TableSelectionCheckboxProps = Omit<CheckboxProps, 'id' | 'name' | 'label' | 'hideLabel' | 'value' | 'checked' | 'defaultChecked' | 'indeterminate' | 'disabled' | 'onChange'>;
103
+ export type TableSelectionRadioProps = Omit<RadioProps, 'id' | 'name' | 'label' | 'hideLabel' | 'value' | 'checked' | 'defaultChecked' | 'disabled' | 'onChange'>;
104
+ /**
105
+ * Row-selection indicator type. `'multiple'` (default) uses checkboxes with a
106
+ * select-all header; `'single'` uses radios, hides the header, and limits
107
+ * `rowSelection` to a single row at a time.
108
+ */
109
+ export type TableSelectionMode = 'multiple' | 'single';
110
+ export type TableExpandCollapseProps = Omit<CollapseProps, 'id' | 'controlsId' | 'children' | 'open' | 'onToggle' | 'openText' | 'closeText' | 'title'>;
111
+ export interface TablePersistOptions {
112
+ /**
113
+ * Storage key used to read/write persisted state. Must be stable per table.
114
+ */
115
+ key: string;
116
+ /**
117
+ * Storage backend. Defaults to `window.localStorage` when available.
118
+ */
119
+ storage?: Storage;
120
+ /**
121
+ * Subset of state slices to persist. Defaults to user-preference slices
122
+ * only: `columnVisibility`, `columnOrder`.
123
+ * Task-scoped slices (`rowSelection`, `expanded`, `columnFilters`, `sorting`,
124
+ * `pagination`) are deliberately excluded by default — pass them explicitly
125
+ * via `include` if you want them to survive across sessions.
126
+ */
127
+ include?: (keyof TableState)[];
128
+ }
129
+ export interface TablePaginationOptions {
130
+ /**
131
+ * Rows per page.
132
+ * @default 10
133
+ */
134
+ pageSize?: number;
135
+ /**
136
+ * Options rendered in the built-in page-size selector. Pass `false` to hide
137
+ * the selector entirely.
138
+ * @default [10, 25, 50]
139
+ */
140
+ pageSizeOptions?: number[] | false;
141
+ /**
142
+ * Props forwarded to the built-in `Pagination` to customise its appearance
143
+ * and behaviour — e.g. `background`, `borders`, `hideResults`,
144
+ * `showPrevNextButtons`, `arrowVariant`, `labels`. The data / state props the
145
+ * Table owns (`pageCount`, `page`, `totalItems`, `pageSize`, `pageSizeOptions`
146
+ * and the change handlers) are managed internally and cannot be overridden.
147
+ */
148
+ paginationProps?: Omit<PaginationProps, 'pageCount' | 'page' | 'onPageChange' | 'totalItems' | 'pageSize' | 'pageSizeOptions' | 'onPageSizeChange'>;
149
+ }
150
+ export interface TableProps<TData> {
151
+ /**
152
+ * Unique identifier for the table. Used for accessibility and as the default
153
+ * persistence key namespace.
154
+ */
155
+ id?: string;
156
+ /**
157
+ * Row data. Render order mirrors the array order; reorder the array yourself
158
+ * (e.g. in `onRowDrop`) to change it.
159
+ */
160
+ data: TData[];
161
+ /**
162
+ * Returns a stable id for each row. Without it, TanStack falls back to the
163
+ * row index — so identifiers shift when rows sort / paginate / reorder, which
164
+ * breaks record stability for `rowSelection`, `activeRowId`, and the
165
+ * `onRowDrop` `fromId`/`toId`. Set this whenever your data has a stable key.
166
+ */
167
+ getRowId?: (originalRow: TData, index: number, parent?: Row<TData>) => string;
168
+ /**
169
+ * Column definitions. Must include a stable `id` on every column when
170
+ * column visibility / reorder / persistence are used.
171
+ */
172
+ columns: ColumnDef<TData>[];
173
+ /**
174
+ * Visual size of the table. Matches Figma: `medium` = 49px rows, `small` = 41px rows.
175
+ * @default medium
176
+ */
177
+ size?: TableSize;
178
+ /**
179
+ * Caption rendered above the table. Announced to assistive technology.
180
+ */
181
+ caption?: ReactNode;
182
+ /**
183
+ * Alternating row backgrounds.
184
+ * @default false
185
+ */
186
+ striped?: boolean;
187
+ /**
188
+ * Renders vertical separators between columns.
189
+ * @default false
190
+ */
191
+ verticalBorders?: boolean;
192
+ /**
193
+ * Removes the outer border + radius around the table, keeping only internal
194
+ * row dividers.
195
+ * @default false
196
+ */
197
+ borderless?: boolean;
198
+ /**
199
+ * Freezes the first column during horizontal scroll.
200
+ * @default false
201
+ */
202
+ stickyFirstColumn?: boolean;
203
+ /**
204
+ * Pins the `<thead>` row(s) to the top during vertical scroll. Requires
205
+ * `maxHeight` so the table's internal scroll container becomes the sticky
206
+ * anchor — wrapping the Table in an external scrollable div will NOT work,
207
+ * because the `<thead>` sticks to its nearest scrolling ancestor (which is
208
+ * always the internal `.tedi-table__scroll` div). Combines safely with
209
+ * `stickyFirstColumn`.
210
+ * @default false
211
+ */
212
+ stickyHeader?: boolean;
213
+ /**
214
+ * Constrains the height of the table's internal scroll container. Accepts
215
+ * any CSS length value (`number` is treated as pixels). Pair with
216
+ * `stickyHeader` for a fixed-height table whose header stays pinned during
217
+ * vertical scroll.
218
+ */
219
+ maxHeight?: number | string;
220
+ /**
221
+ * Fires when a data row is clicked. Adds `role="button"`, a pointer cursor
222
+ * and Enter/Space keyboard activation to every row.
223
+ */
224
+ onRowClick?: (row: Row<TData>) => void;
225
+ /**
226
+ * Highlights the row whose `id` matches as the currently-active row.
227
+ *
228
+ * Useful in master-detail layouts where the click handler navigates or opens a side
229
+ * panel and the table should stay visibly anchored to that row. Distinct from row
230
+ * selection (which is checkbox-driven via `enableRowSelection`) and from the
231
+ * transient `:hover` state. Renders with `aria-current="true"` for screen readers.
232
+ */
233
+ activeRowId?: string;
234
+ /**
235
+ * Paint a hover background on data rows when the cursor is over them. Off by default —
236
+ * a hover highlight implies the row is interactive, which is misleading when there's
237
+ * nothing to click. Pass `true` for read-only tables that still want the affordance,
238
+ * or omit and the table will turn hover on automatically whenever `onRowClick` is set.
239
+ */
240
+ rowHover?: boolean;
241
+ /**
242
+ * Enables row selection. When true, Table prepends a selection column with
243
+ * a checkbox (or radio, when `selectionMode === 'single'`) bound to
244
+ * `rowSelection` state.
245
+ */
246
+ enableRowSelection?: boolean | ((row: Row<TData>) => boolean);
247
+ /**
248
+ * How rows are selected when `enableRowSelection` is on:
249
+ * - `'multiple'` (default) — checkbox per row + select-all in the header.
250
+ * `rowSelection` can hold any number of row ids.
251
+ * - `'single'` — radio per row, no select-all. Selecting a row clears any
252
+ * previous selection, so `rowSelection` holds at most one row id.
253
+ *
254
+ * In both modes the controlled `state.rowSelection` / `onStateChange` API
255
+ * is unchanged — only the indicator and TanStack's underlying multi-select
256
+ * behavior change.
257
+ * @default multiple
258
+ */
259
+ selectionMode?: TableSelectionMode;
260
+ /**
261
+ * Paints the `--table-active` background tint on every selected row. Turn
262
+ * off when checkboxes are used purely for "pick some rows for a bulk
263
+ * action" and the row-level highlight would be visually noisy. The
264
+ * checkbox itself still reflects the selected state.
265
+ * @default true
266
+ */
267
+ highlightSelectedRows?: boolean;
268
+ /**
269
+ * Enables per-column filter inputs rendered below the header row.
270
+ * Only columns whose `columnDef.enableColumnFilter !== false` render an input.
271
+ */
272
+ enableColumnFilters?: boolean;
273
+ /**
274
+ * Render function for the expanded content of a row. When provided, Table
275
+ * prepends an expand/collapse toggle column and renders this node in a full-
276
+ * width row below every expanded parent row.
277
+ */
278
+ renderSubComponent?: (row: Row<TData>) => ReactNode;
279
+ /**
280
+ * Predicate controlling which rows can be expanded. Defaults to "all rows"
281
+ * when `renderSubComponent` is provided, otherwise "none".
282
+ */
283
+ getRowCanExpand?: (row: Row<TData>) => boolean;
284
+ /**
285
+ * Returns the sub-rows of a data row. Enables nested hierarchical data.
286
+ */
287
+ getSubRows?: (row: TData) => TData[] | undefined;
288
+ /**
289
+ * How an expandable row is toggled:
290
+ * - `'button'` (default) — only the chevron button toggles expansion, and it
291
+ * renders in the bordered `secondary` arrow style.
292
+ * - `'row'` — a click anywhere on an expandable row toggles it (Enter/Space
293
+ * too), and the chevron renders in the neutral `default` arrow style as a
294
+ * plain indicator. Only rows that can expand become clickable.
295
+ *
296
+ * Has no effect unless the table is expandable (`getSubRows` or
297
+ * `renderSubComponent` is set).
298
+ * @default button
299
+ */
300
+ expandTrigger?: 'button' | 'row';
301
+ /**
302
+ * Whether expanded sub-rows count toward pagination (TanStack's
303
+ * `paginateExpandedRows`). Defaults to `false` so expanding a parent keeps its
304
+ * children on the same page and only top-level rows fill `pageSize` — opening
305
+ * a row never pushes siblings to the next page or splits a parent's children
306
+ * across pages. Set to `true` for TanStack's default, where sub-rows occupy
307
+ * page slots like any other row.
308
+ *
309
+ * Has no effect unless the table is both expandable and paginated.
310
+ * @default false
311
+ */
312
+ paginateExpandedRows?: boolean;
313
+ /**
314
+ * Enables client-side pagination and renders a built-in page-switcher footer.
315
+ * Pass `true` for default settings or an options object to customise.
316
+ * Page state lives on `TableState.pagination` so it is fully controllable and
317
+ * persistable.
318
+ */
319
+ pagination?: boolean | TablePaginationOptions;
320
+ /**
321
+ * Whether the current page resets to the first page whenever `data` changes
322
+ * (TanStack's `autoResetPageIndex`). Defaults to `true`, which keeps the user
323
+ * on a valid page after filtering or sorting. Set to `false` for tables that
324
+ * mutate `data` in place — e.g. inline row editing — so saving a row doesn't
325
+ * yank the user back to page 1.
326
+ * @default true
327
+ */
328
+ autoResetPageIndex?: boolean;
329
+ /**
330
+ * Switches pagination to server-side mode. When `true`, Table stops slicing
331
+ * `data` locally — `data` is treated as the rows for the current page only.
332
+ * Pair with `pageCount` (or `rowCount`) and a controlled `state.pagination`
333
+ * + `onStateChange` to fetch the right page from the server on each change.
334
+ * @default false
335
+ */
336
+ manualPagination?: boolean;
337
+ /**
338
+ * Switches sorting to server-side mode. When `true`, Table no longer sorts
339
+ * `data` locally — sort state still updates and fires `onStateChange` so
340
+ * the parent can refetch in the new order, but the rows are rendered in
341
+ * the order they arrive in `data`.
342
+ * @default false
343
+ */
344
+ manualSorting?: boolean;
345
+ /**
346
+ * Switches filtering to server-side mode. When `true`, Table stops applying
347
+ * `columnFilters` locally; the parent is expected to translate filter state
348
+ * (visible via `onStateChange`) into a server query.
349
+ * @default false
350
+ */
351
+ manualFiltering?: boolean;
352
+ /**
353
+ * Total number of pages on the server. Required when `manualPagination` is
354
+ * `true` so the pagination footer can render the right page count — local
355
+ * row-count math is otherwise wrong, since `data` only holds the current
356
+ * page's rows.
357
+ */
358
+ pageCount?: number;
359
+ /**
360
+ * Total number of rows on the server (across all pages). Used as the
361
+ * "X tulemust" / "X results" counter in the pagination footer when
362
+ * `manualPagination` is on. Falls back to the locally filtered row count
363
+ * when omitted.
364
+ */
365
+ rowCount?: number;
366
+ /**
367
+ * Controlled state. Pair with `onStateChange`. Any key left undefined falls
368
+ * back to the corresponding default or internal state.
369
+ */
370
+ state?: Partial<TableState>;
371
+ /**
372
+ * Initial state for uncontrolled usage. Ignored when `state` is provided.
373
+ */
374
+ defaultState?: Partial<TableState>;
375
+ /**
376
+ * Callback fired whenever any state slice changes.
377
+ */
378
+ onStateChange?: (state: TableState) => void;
379
+ /**
380
+ * When set, Table wires a localStorage adapter for the named key. Acts as a
381
+ * default state provider and persists subsequent changes. Consumers can still
382
+ * supply `state`/`onStateChange` to layer extra behavior on top.
383
+ */
384
+ persist?: TablePersistOptions;
385
+ /**
386
+ * Rendered inside `<tbody>` when `data` is empty — typically an `EmptyState`
387
+ * node, or any string / node.
388
+ * @default "No data"
389
+ */
390
+ emptyState?: ReactNode;
391
+ /**
392
+ * ARIA live-region role wrapping the empty state. Use `'status'` for polite
393
+ * announcements (recommended for "no results" feedback when the user changes
394
+ * a filter) or `'alert'` for assertive announcements that interrupt the
395
+ * current SR utterance. Omit when the empty state should not announce changes
396
+ * — e.g. when the table is empty on first render and the content never changes.
397
+ */
398
+ emptyStateRole?: 'alert' | 'status';
399
+ /**
400
+ * Additional class name on the root element.
401
+ */
402
+ className?: string;
403
+ /**
404
+ * Props forwarded to the row-selection checkboxes (the header select-all
405
+ * checkbox and every per-row cell checkbox). Use this to e.g. switch the
406
+ * checkboxes to `size: 'large'`. Wiring props (id, name, label, value,
407
+ * checked, indeterminate, disabled, onChange, hideLabel) are owned by
408
+ * Table and cannot be overridden. Ignored when `selectionMode === 'single'`.
409
+ */
410
+ checkboxProps?: TableSelectionCheckboxProps;
411
+ /**
412
+ * Props forwarded to the row-selection radios when `selectionMode === 'single'`.
413
+ * Use this to e.g. switch the radios to `size: 'large'`. Wiring props
414
+ * (id, name, label, value, checked, disabled, onChange, hideLabel) are owned
415
+ * by Table and cannot be overridden.
416
+ */
417
+ radioProps?: TableSelectionRadioProps;
418
+ /**
419
+ * Props forwarded to the row-expand Collapse toggle. Use this to e.g.
420
+ * switch to `arrowType: 'default'`, change the icon size, or disable
421
+ * `iconOnly`. Wiring props (id, controlsId, open, onToggle, openText,
422
+ * closeText, children) are owned by Table and cannot be overridden.
423
+ */
424
+ collapseProps?: TableExpandCollapseProps;
425
+ /**
426
+ * Per-row className / inline style hook. Called once for every data row and
427
+ * the returned `className` is merged with Table's own row classes; the
428
+ * returned `style` is applied to the `<tr>`. Useful for drag-and-drop drop
429
+ * indicators, conditional row tinting, etc. Row event handlers are NOT
430
+ * accepted here — Table owns row click / keyboard behavior.
431
+ */
432
+ rowProps?: (row: Row<TData>) => {
433
+ className?: string;
434
+ style?: CSSProperties;
435
+ } | undefined;
436
+ /**
437
+ * Per-column className / inline style hook. Called for every header cell
438
+ * and every body cell; whatever is returned is applied to *both* the `<th>`
439
+ * (including the column-filter row) and every `<td>` belonging to the
440
+ * column. Useful for drag-and-drop drop indicators that should span the
441
+ * full column height, or for column-level theming. Identify the column via
442
+ * the `columnId` argument.
443
+ */
444
+ columnProps?: (columnId: string) => {
445
+ className?: string;
446
+ style?: CSSProperties;
447
+ } | undefined;
448
+ /**
449
+ * Toolbar + Table subcomponents such as `<Table.ColumnsMenu />`.
450
+ */
451
+ children?: ReactNode;
452
+ /**
453
+ * Enables row reordering by **mouse and keyboard**. The Table auto-injects a
454
+ * leading drag-handle column. Mouse: drag a row by its handle. Keyboard: focus
455
+ * a handle, `Space`/`Enter` to pick the row up, `↑`/`↓` to move it (clamped to
456
+ * the rendered rows), `Space`/`Enter` to drop, `Escape` to cancel — every move
457
+ * (and the drop/cancel) is announced via a live region. Both paths emit
458
+ * `onRowDrop`; the consumer applies the new order to the source `data` array.
459
+ *
460
+ * Each `row.id` returned by TanStack is used as the drag identifier, so the
461
+ * data must have a stable `id` (or supply `getRowId`).
462
+ *
463
+ * @default false
464
+ */
465
+ reorderableRows?: boolean;
466
+ /**
467
+ * Enables column reordering by **mouse and keyboard**. Each (non-built-in,
468
+ * non-grouped) leaf header gets a grip button next to its label. Mouse: drag
469
+ * the header by its grip. Keyboard: focus the grip, `Space`/`Enter` to pick
470
+ * the column up, `←`/`→` to move it, `Space`/`Enter` to drop, `Escape` to
471
+ * cancel (announced via a live region). Reordering pushes the new order into
472
+ * TanStack's `columnOrder` state — flows through `onStateChange` and the
473
+ * `persist` adapter automatically; no `onRowDrop`-style wiring needed.
474
+ *
475
+ * Grouped header parents are never draggable; only flat / leaf columns are.
476
+ * Built-in slots (`__drag__`, `__select__`, `__expand__`) are skipped.
477
+ *
478
+ * @default false
479
+ */
480
+ reorderableColumns?: boolean;
481
+ /**
482
+ * Fires when a draggable row is dropped to a new position. Receives the
483
+ * before/after `row.id`s and the convenience indexes. Apply the move to your
484
+ * data with `arrayMove(data, fromIndex, toIndex)` and pass the result back
485
+ * via `data`.
486
+ *
487
+ * Only invoked when `reorderableRows` is enabled and the drop actually changes
488
+ * the row order.
489
+ */
490
+ onRowDrop?: (event: TableRowDropEvent) => void;
491
+ }
492
+ export interface TableContextValue<TData = unknown> {
493
+ table: ReactTable<TData>;
494
+ size: TableSize;
495
+ id?: string;
496
+ state: Partial<TableState>;
497
+ }
498
+ export interface TableRowDropEvent {
499
+ fromId: string;
500
+ toId: string;
501
+ fromIndex: number;
502
+ toIndex: number;
503
+ }
504
+ declare function TableBase<TData>(props: TableProps<TData>): JSX.Element;
505
+ declare namespace TableBase {
506
+ var displayName: string;
507
+ }
508
+ export declare const Table: typeof TableBase & {
509
+ Toolbar: {
510
+ ({ children, className }: import('./table-toolbar/table-toolbar').TableToolbarProps): import("react/jsx-runtime").JSX.Element;
511
+ displayName: string;
512
+ };
513
+ ColumnsMenu: {
514
+ ({ triggerLabel, className }: import('./table-columns-menu/table-columns-menu').TableColumnsMenuProps): import("react/jsx-runtime").JSX.Element;
515
+ displayName: string;
516
+ };
517
+ HeaderButton: import('react').ForwardRefExoticComponent<import('./table-header-button/table-header-button').TableHeaderButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
518
+ };
519
+ export default Table;