@krizaka/ui 2.10.0 → 3.0.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.
Files changed (184) hide show
  1. package/README.md +3 -1
  2. package/dist/audio-player.js +1 -1
  3. package/dist/{chunk-EUPTXKH7.js → chunk-BRKMQ6JV.js} +2 -1
  4. package/dist/chunk-FDCMBWUU.js +168 -0
  5. package/dist/chunk-FDCMBWUU.js.map +1 -0
  6. package/dist/chunk-HCNOOPZE.js +210 -0
  7. package/dist/chunk-HCNOOPZE.js.map +1 -0
  8. package/dist/{chunk-X6TW3X6Y.js → chunk-LCZXS6AK.js} +2 -2
  9. package/dist/chunk-OGJI5X4W.js +157 -0
  10. package/dist/chunk-OGJI5X4W.js.map +1 -0
  11. package/dist/combobox.js +2 -2
  12. package/dist/data-table.d.ts +284 -24
  13. package/dist/data-table.js +914 -121
  14. package/dist/data-table.js.map +1 -1
  15. package/dist/date-picker.js +1 -1
  16. package/dist/filter-bar.d.ts +12 -12
  17. package/dist/filter-bar.js +9 -145
  18. package/dist/filter-bar.js.map +1 -1
  19. package/dist/image-cropper.js +1 -1
  20. package/dist/media-capture.js +1 -1
  21. package/dist/native/list.d.ts +95 -0
  22. package/dist/native/list.js +135 -0
  23. package/dist/native/list.js.map +1 -0
  24. package/dist/search-field.js +6 -160
  25. package/dist/search-field.js.map +1 -1
  26. package/dist/tag-input.js +2 -2
  27. package/dist/video-player.js +1 -1
  28. package/dist/video-trimmer.js +1 -1
  29. package/dist/virtual.d.ts +140 -0
  30. package/dist/virtual.js +19 -0
  31. package/dist/virtual.js.map +1 -0
  32. package/package.json +66 -6
  33. package/registry/achievement.json +1 -1
  34. package/registry/action-bar.json +1 -1
  35. package/registry/alert.json +1 -1
  36. package/registry/app-shell.json +1 -1
  37. package/registry/argument-card.json +1 -1
  38. package/registry/audio-player.json +1 -1
  39. package/registry/auth-layout.json +1 -1
  40. package/registry/avatar.json +1 -1
  41. package/registry/badge.json +1 -1
  42. package/registry/button.json +1 -1
  43. package/registry/card-grid.json +1 -1
  44. package/registry/card.json +1 -1
  45. package/registry/catalogue-page.json +1 -1
  46. package/registry/changelog-page.json +1 -1
  47. package/registry/checkbox.json +1 -1
  48. package/registry/chip-link.json +1 -1
  49. package/registry/chip.json +1 -1
  50. package/registry/choice-grid.json +1 -1
  51. package/registry/code-block.json +1 -1
  52. package/registry/combobox.json +1 -1
  53. package/registry/command.json +1 -1
  54. package/registry/component-page.json +1 -1
  55. package/registry/confirm-button.json +1 -1
  56. package/registry/contact-page.json +1 -1
  57. package/registry/continue-prompt.json +1 -1
  58. package/registry/countdown.json +1 -1
  59. package/registry/cta-panel.json +1 -1
  60. package/registry/dashboard-layout.json +1 -1
  61. package/registry/data-table.json +643 -49
  62. package/registry/date-picker.json +1 -1
  63. package/registry/decision-list.json +1 -1
  64. package/registry/detail-layout.json +1 -1
  65. package/registry/dialog.json +1 -1
  66. package/registry/docs-article-page.json +1 -1
  67. package/registry/docs-hub-page.json +1 -1
  68. package/registry/docs-layout.json +1 -1
  69. package/registry/dropdown-menu.json +1 -1
  70. package/registry/empty-state.json +1 -1
  71. package/registry/error-page.json +1 -1
  72. package/registry/examples/data-table/details.d.ts +4 -0
  73. package/registry/examples/data-table/details.js +33 -0
  74. package/registry/examples/data-table/details.tsx +31 -0
  75. package/registry/examples/data-table/filters.d.ts +4 -0
  76. package/registry/examples/data-table/filters.js +40 -0
  77. package/registry/examples/data-table/filters.tsx +40 -0
  78. package/registry/examples/data-table/grouped.d.ts +4 -0
  79. package/registry/examples/data-table/grouped.js +24 -0
  80. package/registry/examples/data-table/grouped.tsx +23 -0
  81. package/registry/examples/data-table/paginated.d.ts +4 -0
  82. package/registry/examples/data-table/paginated.js +23 -0
  83. package/registry/examples/data-table/paginated.tsx +22 -0
  84. package/registry/examples/data-table/pinned.d.ts +4 -0
  85. package/registry/examples/data-table/pinned.js +26 -0
  86. package/registry/examples/data-table/pinned.tsx +25 -0
  87. package/registry/examples/data-table/server.d.ts +4 -0
  88. package/registry/examples/data-table/server.js +40 -0
  89. package/registry/examples/data-table/server.tsx +40 -0
  90. package/registry/examples/data-table/virtualized.js +2 -2
  91. package/registry/examples/data-table/virtualized.tsx +3 -3
  92. package/registry/examples/list/native/default.d.ts +4 -0
  93. package/registry/examples/list/native/default.dark.png +0 -0
  94. package/registry/examples/list/native/default.js +33 -0
  95. package/registry/examples/list/native/default.light.png +0 -0
  96. package/registry/examples/list/native/default.tsx +31 -0
  97. package/registry/examples/list/native/infinite.d.ts +4 -0
  98. package/registry/examples/list/native/infinite.dark.png +0 -0
  99. package/registry/examples/list/native/infinite.js +30 -0
  100. package/registry/examples/list/native/infinite.light.png +0 -0
  101. package/registry/examples/list/native/infinite.tsx +35 -0
  102. package/registry/examples/list/native/states.d.ts +4 -0
  103. package/registry/examples/list/native/states.dark.png +0 -0
  104. package/registry/examples/list/native/states.js +26 -0
  105. package/registry/examples/list/native/states.light.png +0 -0
  106. package/registry/examples/list/native/states.tsx +21 -0
  107. package/registry/examples/virtual/feed.d.ts +4 -0
  108. package/registry/examples/virtual/feed.js +26 -0
  109. package/registry/examples/virtual/feed.tsx +24 -0
  110. package/registry/examples/virtual/gallery.d.ts +4 -0
  111. package/registry/examples/virtual/gallery.js +31 -0
  112. package/registry/examples/virtual/gallery.tsx +28 -0
  113. package/registry/examples/virtual/messages.d.ts +4 -0
  114. package/registry/examples/virtual/messages.js +28 -0
  115. package/registry/examples/virtual/messages.tsx +28 -0
  116. package/registry/field.json +1 -1
  117. package/registry/file-upload.json +1 -1
  118. package/registry/filter-bar.json +1 -1
  119. package/registry/gallery-page.json +1 -1
  120. package/registry/glow-card.json +1 -1
  121. package/registry/goal-gauge.json +1 -1
  122. package/registry/how-it-works-page.json +1 -1
  123. package/registry/image-cropper.json +1 -1
  124. package/registry/index.json +48 -5
  125. package/registry/iso.json +1 -1
  126. package/registry/kbd.json +1 -1
  127. package/registry/landing-page.json +1 -1
  128. package/registry/landscape.json +1 -1
  129. package/registry/legal-page.json +1 -1
  130. package/registry/link-card.json +1 -1
  131. package/registry/list.json +249 -0
  132. package/registry/loader.json +1 -1
  133. package/registry/longform-page.json +1 -1
  134. package/registry/marketing-layout.json +1 -1
  135. package/registry/marquee.json +1 -1
  136. package/registry/mascot-quote.json +1 -1
  137. package/registry/mascot-state.json +1 -1
  138. package/registry/mascots.json +1 -1
  139. package/registry/media-capture.json +1 -1
  140. package/registry/meter.json +1 -1
  141. package/registry/nav-bar.json +1 -1
  142. package/registry/number-ticker.json +1 -1
  143. package/registry/page-header.json +1 -1
  144. package/registry/page-hero.json +1 -1
  145. package/registry/page.json +1 -1
  146. package/registry/pagination.json +1 -1
  147. package/registry/pointer-light.json +1 -1
  148. package/registry/popover.json +1 -1
  149. package/registry/pricing-page.json +1 -1
  150. package/registry/product-page.json +1 -1
  151. package/registry/profile-card.json +1 -1
  152. package/registry/progress.json +1 -1
  153. package/registry/promise-card.json +1 -1
  154. package/registry/radio-group.json +1 -1
  155. package/registry/scroll-stage.json +1 -1
  156. package/registry/search-field.json +1 -1
  157. package/registry/section-backdrop.json +1 -1
  158. package/registry/separator.json +1 -1
  159. package/registry/settings-layout.json +1 -1
  160. package/registry/skeleton.json +1 -1
  161. package/registry/slider.json +1 -1
  162. package/registry/slot.json +1 -1
  163. package/registry/spinner.json +1 -1
  164. package/registry/split-view.json +1 -1
  165. package/registry/stage-banner.json +1 -1
  166. package/registry/stat.json +1 -1
  167. package/registry/status-page.json +1 -1
  168. package/registry/stepper.json +1 -1
  169. package/registry/switch.json +1 -1
  170. package/registry/tabs.json +1 -1
  171. package/registry/tag-input.json +1 -1
  172. package/registry/terminal-replay.json +1 -1
  173. package/registry/theme.json +1 -1
  174. package/registry/toast.json +1 -1
  175. package/registry/toc.json +1 -1
  176. package/registry/tooltip.json +1 -1
  177. package/registry/video-player.json +1 -1
  178. package/registry/video-trimmer.json +1 -1
  179. package/registry/virtual.json +569 -0
  180. package/skills/data-table/SKILL.md +56 -0
  181. package/skills/native-list/SKILL.md +39 -0
  182. package/skills/virtual/SKILL.md +35 -0
  183. /package/dist/{chunk-EUPTXKH7.js.map → chunk-BRKMQ6JV.js.map} +0 -0
  184. /package/dist/{chunk-X6TW3X6Y.js.map → chunk-LCZXS6AK.js.map} +0 -0
@@ -1,9 +1,70 @@
1
+ import * as _tanstack_react_table from '@tanstack/react-table';
2
+ import { RowData, ReactTable } from '@tanstack/react-table';
1
3
  import * as tailwind_variants from 'tailwind-variants';
2
4
  import * as React from 'react';
3
5
 
6
+ declare const features: {
7
+ columnFilteringFeature: _tanstack_react_table.TableFeature;
8
+ filteredRowModel: (table: _tanstack_react_table.Table<any, any>) => () => _tanstack_react_table.RowModel<any, any>;
9
+ columnFacetingFeature: _tanstack_react_table.TableFeature;
10
+ facetedRowModel: (table: _tanstack_react_table.Table<any, any>, columnId: string) => () => _tanstack_react_table.RowModel<any, any>;
11
+ facetedUniqueValues: (table: _tanstack_react_table.Table<_tanstack_react_table.TableFeatures, any>, columnId: string) => () => Map<any, number>;
12
+ facetedMinMaxValues: (table: _tanstack_react_table.Table<_tanstack_react_table.TableFeatures, any>, columnId: string) => () => undefined | [number, number];
13
+ columnGroupingFeature: _tanstack_react_table.TableFeature;
14
+ groupedRowModel: (table: _tanstack_react_table.Table<any, any>) => () => _tanstack_react_table.RowModel<any, any>;
15
+ rowSortingFeature: _tanstack_react_table.TableFeature;
16
+ sortedRowModel: (table: _tanstack_react_table.Table<any, any>) => () => _tanstack_react_table.RowModel<any, any>;
17
+ rowExpandingFeature: _tanstack_react_table.TableFeature;
18
+ expandedRowModel: (table: _tanstack_react_table.Table<any, any>) => () => _tanstack_react_table.RowModel<any, any>;
19
+ rowPaginationFeature: _tanstack_react_table.TableFeature;
20
+ paginatedRowModel: (table: _tanstack_react_table.Table<any, any>) => () => _tanstack_react_table.RowModel<any, any>;
21
+ rowSelectionFeature: _tanstack_react_table.TableFeature;
22
+ columnVisibilityFeature: _tanstack_react_table.TableFeature;
23
+ columnPinningFeature: _tanstack_react_table.TableFeature;
24
+ columnSizingFeature: _tanstack_react_table.TableFeature;
25
+ columnResizingFeature: _tanstack_react_table.TableFeature;
26
+ };
27
+ type Features = typeof features;
28
+ /** The TanStack Table instance behind a DataTable — the escape hatch of `useDataTable()`. */
29
+ type DataTableInstance<T extends RowData> = ReactTable<Features, T>;
30
+ /** What a cell holds for sorting, filtering and the CSV export: a string, a number, a date, a boolean, or nothing. */
31
+ type CellValue = string | number | boolean | Date | null | undefined;
32
+ /** A filter's value: a text (`text`), the values chosen (`facet`), or bounds, either open (`range`). */
33
+ type FilterValue = string | readonly string[] | readonly [number | null, number | null];
34
+ /** The filters in force, by column id. */
35
+ type DataTableFilterState = Readonly<Record<string, FilterValue>>;
36
+ /** The order of two values: empty last, dates and numbers by value, text in natural order ("item 2" < "item 10"). */
37
+ declare function compareValues(a: CellValue, b: CellValue): number;
38
+
39
+ type CsvColumn<T> = {
40
+ id: string;
41
+ header: string;
42
+ value?: (row: T) => CellValue;
43
+ };
44
+ /** The rows as CSV text: a header line, then one line per row, separated by `\r\n`. */
45
+ declare function dataTableCsv<T>(rows: readonly T[], columns: readonly CsvColumn<T>[], separator?: string): string;
46
+
47
+ type PaginationLabels = {
48
+ /** The accessible name of the navigation ("Pagination", "Pages of results"). */
49
+ nav: string;
50
+ /** The previous-page control. */
51
+ previous: string;
52
+ /** The next-page control. */
53
+ next: string;
54
+ /** The accessible name of a page number: `(3) => "Page 3"`. */
55
+ page: (page: number) => string;
56
+ /** The folded form, in a narrow container: `(3, 12) => "Page 3 of 12"`. */
57
+ compact: (page: number, pageCount: number) => string;
58
+ /** The label of the page-size select ("Rows per page"). */
59
+ pageSize: string;
60
+ };
61
+
4
62
  declare const dataTable: tailwind_variants.TVReturnType<{
5
63
  layout: {
6
- table: {};
64
+ table: {
65
+ th: string;
66
+ td: string;
67
+ };
7
68
  auto: {
8
69
  table: string;
9
70
  caption: string;
@@ -14,6 +75,7 @@ declare const dataTable: tailwind_variants.TVReturnType<{
14
75
  tr: string;
15
76
  td: string;
16
77
  select: string;
78
+ expander: string;
17
79
  };
18
80
  cards: {
19
81
  table: string;
@@ -25,6 +87,7 @@ declare const dataTable: tailwind_variants.TVReturnType<{
25
87
  tr: string;
26
88
  td: string;
27
89
  select: string;
90
+ expander: string;
28
91
  };
29
92
  };
30
93
  density: {
@@ -36,6 +99,7 @@ declare const dataTable: tailwind_variants.TVReturnType<{
36
99
  };
37
100
  }, {
38
101
  root: string;
102
+ toolbar: string;
39
103
  scroller: string;
40
104
  table: string;
41
105
  caption: string;
@@ -43,16 +107,24 @@ declare const dataTable: tailwind_variants.TVReturnType<{
43
107
  headRow: string;
44
108
  th: string;
45
109
  sortButton: string;
110
+ resizer: string;
46
111
  tbody: string;
47
112
  tr: string;
113
+ groupRow: string;
48
114
  td: string;
49
115
  select: string;
116
+ expander: string;
117
+ toggle: string;
118
+ detail: string;
50
119
  message: string;
51
120
  skeleton: string;
52
121
  footer: string;
53
122
  }, undefined, {
54
123
  layout: {
55
- table: {};
124
+ table: {
125
+ th: string;
126
+ td: string;
127
+ };
56
128
  auto: {
57
129
  table: string;
58
130
  caption: string;
@@ -63,6 +135,7 @@ declare const dataTable: tailwind_variants.TVReturnType<{
63
135
  tr: string;
64
136
  td: string;
65
137
  select: string;
138
+ expander: string;
66
139
  };
67
140
  cards: {
68
141
  table: string;
@@ -74,6 +147,7 @@ declare const dataTable: tailwind_variants.TVReturnType<{
74
147
  tr: string;
75
148
  td: string;
76
149
  select: string;
150
+ expander: string;
77
151
  };
78
152
  };
79
153
  density: {
@@ -85,6 +159,7 @@ declare const dataTable: tailwind_variants.TVReturnType<{
85
159
  };
86
160
  }, {
87
161
  root: string;
162
+ toolbar: string;
88
163
  scroller: string;
89
164
  table: string;
90
165
  caption: string;
@@ -92,16 +167,24 @@ declare const dataTable: tailwind_variants.TVReturnType<{
92
167
  headRow: string;
93
168
  th: string;
94
169
  sortButton: string;
170
+ resizer: string;
95
171
  tbody: string;
96
172
  tr: string;
173
+ groupRow: string;
97
174
  td: string;
98
175
  select: string;
176
+ expander: string;
177
+ toggle: string;
178
+ detail: string;
99
179
  message: string;
100
180
  skeleton: string;
101
181
  footer: string;
102
182
  }, tailwind_variants.TVReturnTypeLike<{
103
183
  layout: {
104
- table: {};
184
+ table: {
185
+ th: string;
186
+ td: string;
187
+ };
105
188
  auto: {
106
189
  table: string;
107
190
  caption: string;
@@ -112,6 +195,7 @@ declare const dataTable: tailwind_variants.TVReturnType<{
112
195
  tr: string;
113
196
  td: string;
114
197
  select: string;
198
+ expander: string;
115
199
  };
116
200
  cards: {
117
201
  table: string;
@@ -123,6 +207,7 @@ declare const dataTable: tailwind_variants.TVReturnType<{
123
207
  tr: string;
124
208
  td: string;
125
209
  select: string;
210
+ expander: string;
126
211
  };
127
212
  };
128
213
  density: {
@@ -134,6 +219,7 @@ declare const dataTable: tailwind_variants.TVReturnType<{
134
219
  };
135
220
  }, {
136
221
  root: string;
222
+ toolbar: string;
137
223
  scroller: string;
138
224
  table: string;
139
225
  caption: string;
@@ -141,10 +227,15 @@ declare const dataTable: tailwind_variants.TVReturnType<{
141
227
  headRow: string;
142
228
  th: string;
143
229
  sortButton: string;
230
+ resizer: string;
144
231
  tbody: string;
145
232
  tr: string;
233
+ groupRow: string;
146
234
  td: string;
147
235
  select: string;
236
+ expander: string;
237
+ toggle: string;
238
+ detail: string;
148
239
  message: string;
149
240
  skeleton: string;
150
241
  footer: string;
@@ -154,26 +245,52 @@ type DataTableSort = {
154
245
  column: string;
155
246
  direction: SortDirection;
156
247
  } | null;
157
- type Sortable = string | number | boolean | Date | null | undefined;
248
+ /** What the server needs to fetch a page (`manual` mode): given to `onStateChange` at each change. */
249
+ type DataTableQuery = {
250
+ /** The sorted column, or `null`. */
251
+ sort: DataTableSort;
252
+ /** The filters in force, by column id. */
253
+ filters: DataTableFilterState;
254
+ /** The page, from 1 (1 without pagination). */
255
+ page: number;
256
+ /** Rows per page (`Infinity` without pagination). */
257
+ pageSize: number;
258
+ };
158
259
  type DataTableColumn<T> = {
159
- /** A key of the column (and of the row, for the default cell and sort). */
260
+ /** A key of the column (and of the row, for the default value). */
160
261
  id: string;
161
- /** The column's name, passed translated: the header, and the label of the value in a card. */
262
+ /** The column's name, passed translated: the header, the label of the value in a card, the filter's name. */
162
263
  header: string;
163
- /** What a cell shows. Default: `value(row)`, or `row[id]`. */
264
+ /** What a cell shows. Default: the value as text. */
164
265
  cell?: (row: T) => React.ReactNode;
165
- /** The value sorted on (and shown by default): a string, a number, a date. Default `row[id]`. */
166
- value?: (row: T) => Sortable;
266
+ /** The value sorted, filtered, grouped and exported. Default `row[id]`. */
267
+ value?: (row: T) => CellValue;
167
268
  /** The header becomes a sort button (ascending → descending → none). */
168
269
  sortable?: boolean;
270
+ /** How `DataTableFilters` filters it: `text` (a search), `facet` (values to choose), `range` (numbers between bounds). */
271
+ filter?: "text" | "facet" | "range";
272
+ /** The choices of a `facet` filter, with their words (and counts from the server). Default: the values found in the rows. */
273
+ options?: readonly {
274
+ value: string;
275
+ label: string;
276
+ count?: number;
277
+ }[];
278
+ /** The rows can be grouped by this column (`groupBy`). */
279
+ groupable?: boolean;
280
+ /** What a group's row shows in this column, from the group's rows (a sum, a count). */
281
+ aggregate?: (rows: readonly T[]) => React.ReactNode;
169
282
  /** Text alignment: `end` for amounts and counts. */
170
283
  align?: "start" | "center" | "end";
171
- /** A CSS width (`"8rem"`, `"30%"`). */
172
- width?: string;
284
+ /** The width, in px (the starting width when `resizing`). */
285
+ width?: number;
286
+ /** The narrowest a resized column may be, in px. Default 64. */
287
+ minWidth?: number;
173
288
  /** In a card: `title` (the heading of the card), `label` (default: "Header value"), `hidden`. */
174
289
  card?: "title" | "label" | "hidden";
175
290
  /** Hides the header visually (an actions column), keeping it for screen readers. */
176
291
  headerHidden?: boolean;
292
+ /** Listed in `DataTableColumnsMenu`, so a person can hide it. Default `true`. */
293
+ hideable?: boolean;
177
294
  };
178
295
  type DataTableLabels = {
179
296
  /** The checkbox of the header ("Select all rows"). */
@@ -184,14 +301,44 @@ type DataTableLabels = {
184
301
  loading: string;
185
302
  /** The default empty state ("Nothing to show"). */
186
303
  empty: string;
304
+ /** The header of the column of the expand buttons, for screen readers ("Details"). */
305
+ details: string;
306
+ /** The button that opens a row: `(name) => "Show details of " + name`. */
307
+ expandRow: (name: string) => string;
308
+ /** The button of a group's row: `(value, count) => value + ", " + count + " rows"`. */
309
+ group: (value: string, count: number) => string;
310
+ /** The handle that resizes a column: `(header) => "Resize " + header`. */
311
+ resize: (header: string) => string;
312
+ /** The count of results under the filters: `(count) => count + " rows"`. */
313
+ results: (count: number) => string;
314
+ /** The accessible name of the filters' bar ("Filter the table"). */
315
+ filters: string;
316
+ /** "Clear filters". */
317
+ clearFilters: string;
318
+ /** A filter's chip remove button: `(label) => "Remove " + label`. */
319
+ removeFilter: (label: string) => string;
320
+ /** The words of a filter in force: `(header, value) => header + ": " + value`. */
321
+ activeFilter: (header: string, value: string) => string;
322
+ /** A `text` filter's field: `(header) => "Search " + header`. */
323
+ search: (header: string) => string;
324
+ /** The lower bound of a `range` filter: `(header) => header + " from"`. */
325
+ rangeFrom: (header: string) => string;
326
+ /** The upper bound of a `range` filter: `(header) => header + " to"`. */
327
+ rangeTo: (header: string) => string;
328
+ /** The button of the columns menu ("Columns"). */
329
+ columns: string;
330
+ /** The export button ("Export CSV"). */
331
+ export: string;
332
+ /** The words of the pagination under the table. */
333
+ pagination?: Partial<PaginationLabels>;
187
334
  };
188
335
  declare const dataTableLabels: DataTableLabels;
189
336
  type DataTableProps<T> = {
190
- /** The rows, in the order the server gave (sorted here unless `manualSort`). */
337
+ /** The rows (stable: module scope, state or a query's data). Sorted, filtered and paginated here unless `manual`. */
191
338
  rows: readonly T[];
192
- /** The columns, in order. */
339
+ /** The columns, in order (stable: module scope or `useMemo`). */
193
340
  columns: readonly DataTableColumn<T>[];
194
- /** A stable id per row: the React key and the selection's value. */
341
+ /** A stable id per row: the React key, the selection's value, the expansion's key. */
195
342
  getRowId: (row: T) => string;
196
343
  /** What the table lists ("Jobs", "Your videos"): its `<caption>`, hidden unless `showCaption`. */
197
344
  caption: string;
@@ -203,8 +350,12 @@ type DataTableProps<T> = {
203
350
  defaultSort?: DataTableSort;
204
351
  /** Called when a header asks for a new sort. */
205
352
  onSortChange?: (sort: DataTableSort) => void;
206
- /** The server sorts (`onSortChange` fetches): the rows are shown as given. */
207
- manualSort?: boolean;
353
+ /** The filters in force (controlled), by column id — what `DataTableFilters` edits. */
354
+ filters?: DataTableFilterState;
355
+ /** The filters at first, uncontrolled. */
356
+ defaultFilters?: DataTableFilterState;
357
+ /** Called with the new filters. */
358
+ onFiltersChange?: (filters: DataTableFilterState) => void;
208
359
  /** Adds a checkbox per row and one in the header. */
209
360
  selectable?: boolean;
210
361
  /** The ids selected (controlled). */
@@ -213,8 +364,61 @@ type DataTableProps<T> = {
213
364
  defaultSelected?: readonly string[];
214
365
  /** Called with the new selection. */
215
366
  onSelectedChange?: (selected: string[]) => void;
216
- /** The name of a row in its checkbox's label (default: its id). */
367
+ /** The name of a row in its labels (checkbox, expand button). Default: its id. */
217
368
  rowLabel?: (row: T) => string;
369
+ /** The columns the rows are grouped by, in order (controlled) — each `groupable`. */
370
+ groupBy?: readonly string[];
371
+ /** The grouping at first, uncontrolled. */
372
+ defaultGroupBy?: readonly string[];
373
+ /** Called with the new grouping. */
374
+ onGroupByChange?: (groupBy: string[]) => void;
375
+ /** Visible (`true`) or hidden (`false`) columns, by id (controlled); a column not listed is visible. */
376
+ columnVisibility?: Readonly<Record<string, boolean>>;
377
+ /** The visibility at first, uncontrolled. */
378
+ defaultColumnVisibility?: Readonly<Record<string, boolean>>;
379
+ /** Called with the new visibility (`DataTableColumnsMenu`). */
380
+ onColumnVisibilityChange?: (visibility: Record<string, boolean>) => void;
381
+ /** Columns that stay in view while the table scrolls sideways: at the start (a name) or the end (actions). */
382
+ pinning?: {
383
+ start?: readonly string[];
384
+ end?: readonly string[];
385
+ };
386
+ /** Columns can be resized (pointer drag, or the arrow keys on the focused handle). */
387
+ resizing?: boolean;
388
+ /** The children of a row (a tree): each row with children gets a button that shows them. */
389
+ getSubRows?: (row: T) => readonly T[] | undefined;
390
+ /** A panel under an opened row (the details of a job): each row gets a button that opens it. */
391
+ renderDetail?: (row: T) => React.ReactNode;
392
+ /** The opened rows and groups (controlled), by id. */
393
+ expanded?: Readonly<Record<string, boolean>>;
394
+ /** The opened rows at first, uncontrolled. */
395
+ defaultExpanded?: Readonly<Record<string, boolean>>;
396
+ /** Called with the opened rows. */
397
+ onExpandedChange?: (expanded: Record<string, boolean>) => void;
398
+ /** Rows per page (controlled): turns on the pagination under the table. */
399
+ pageSize?: number;
400
+ /** Rows per page at first, uncontrolled: turns on the pagination under the table. */
401
+ defaultPageSize?: number;
402
+ /** Called with the size chosen in the pagination's select (`pageSizeOptions`). */
403
+ onPageSizeChange?: (pageSize: number) => void;
404
+ /** The sizes the pagination offers (`[10, 25, 50]`). */
405
+ pageSizeOptions?: readonly number[];
406
+ /** The page, from 1 (controlled). */
407
+ page?: number;
408
+ /** The page at first, uncontrolled. Default 1. */
409
+ defaultPage?: number;
410
+ /** Called with the page asked for. */
411
+ onPageChange?: (page: number) => void;
412
+ /** The server does the work: the rows are shown as given (sorted, filtered, a single page) — fetch in `onStateChange`. */
413
+ manual?: {
414
+ sorting?: boolean;
415
+ filtering?: boolean;
416
+ pagination?: boolean;
417
+ };
418
+ /** The number of rows on the server (`manual.pagination`): the page count and the results' count. */
419
+ rowCount?: number;
420
+ /** Called with the sort, the filters and the page after each change: the query key of a server table. */
421
+ onStateChange?: (query: DataTableQuery) => void;
218
422
  /** Rows are loading: skeleton rows (`loadingRows` of them) and `aria-busy`. */
219
423
  loading?: boolean;
220
424
  /** How many skeleton rows while loading. Default 5. */
@@ -227,20 +431,76 @@ type DataTableProps<T> = {
227
431
  layout?: "auto" | "table" | "cards";
228
432
  /** comfortable (default) · compact. */
229
433
  density?: "comfortable" | "compact";
230
- /** Renders only the rows in view (fixed `rowHeight`, a scrolling body of `height` px). Forces the table layout. */
231
- virtualize?: {
232
- rowHeight: number;
434
+ /** Renders only the rows in view, in a scrolling body of `height` px; rows are measured (`estimateRowHeight` is a guess). Forces the table layout. */
435
+ virtualized?: {
233
436
  height: number;
437
+ estimateRowHeight?: number;
234
438
  overscan?: number;
235
439
  };
236
- /** Under the table: a `Pagination`, a total. */
440
+ /** Above the table, inside its frame: `DataTableFilters`, `DataTableColumnsMenu`, `DataTableExport`, actions. */
441
+ toolbar?: React.ReactNode;
442
+ /** Under the table (after the pagination): a total, a note. */
237
443
  footer?: React.ReactNode;
238
444
  /** The words, passed translated; English by default. */
239
445
  labels?: Partial<DataTableLabels>;
240
446
  /** Classes merged on the root. */
241
447
  className?: string;
242
448
  };
243
- /** A table of records: sort, selection, loading / empty / error, cards on a phone, windowing for long lists. */
244
- declare function DataTable<T>({ rows, columns, getRowId, caption, showCaption, sort: sortProp, defaultSort, onSortChange, manualSort, selectable, selected: selectedProp, defaultSelected, onSelectedChange, rowLabel, loading, loadingRows, error, empty, layout, density, virtualize, footer, labels: given, className, }: DataTableProps<T>): React.JSX.Element;
449
+ type Context = {
450
+ table: DataTableInstance<object>;
451
+ columns: readonly DataTableColumn<object>[];
452
+ labels: DataTableLabels;
453
+ filters: DataTableFilterState;
454
+ setFilters: (filters: DataTableFilterState) => void;
455
+ /** The rows after the filters (all pages), or the server's count. */
456
+ resultCount: number;
457
+ /** The rows to export: filtered and sorted, every page, without the group rows. */
458
+ exportRows: () => readonly unknown[];
459
+ manualFiltering: boolean;
460
+ };
461
+ /**
462
+ * The table a component sits in (`toolbar`, or anything under it): the TanStack Table instance (`table` — the escape
463
+ * hatch for what the props do not cover), the columns, the words, the filters and their setter.
464
+ */
465
+ declare function useDataTable<T extends RowData = object>(): Omit<Context, "table" | "columns" | "exportRows"> & {
466
+ table: DataTableInstance<T>;
467
+ columns: readonly DataTableColumn<T>[];
468
+ exportRows: () => readonly T[];
469
+ };
470
+ /** A table of records — sort, filters and facets, groups, details, pages, selection, visibility, pinning, resizing — on the client or the server, cards on a phone, windowing for long lists. */
471
+ declare function DataTable<T extends RowData>({ rows, columns, getRowId, caption, showCaption, sort: sortProp, defaultSort, onSortChange, filters: filtersProp, defaultFilters, onFiltersChange, selectable, selected: selectedProp, defaultSelected, onSelectedChange, rowLabel, groupBy: groupByProp, defaultGroupBy, onGroupByChange, columnVisibility: visibilityProp, defaultColumnVisibility, onColumnVisibilityChange, pinning, resizing, getSubRows, renderDetail, expanded: expandedProp, defaultExpanded, onExpandedChange, pageSize: pageSizeProp, defaultPageSize, onPageSizeChange, pageSizeOptions, page: pageProp, defaultPage, onPageChange, manual, rowCount, onStateChange, loading, loadingRows, error, empty, layout, density, virtualized, toolbar, footer, labels: given, className, }: DataTableProps<T>): React.JSX.Element;
472
+
473
+ type DataTableFiltersProps = {
474
+ /** The search's wait after the last key, in ms, before the filter applies (a request, in server mode). Default 250. */
475
+ debounce?: number;
476
+ /** More controls in the bar (a date range picker, a toggle). */
477
+ children?: React.ReactNode;
478
+ /** Classes merged on the bar. */
479
+ className?: string;
480
+ };
481
+ /**
482
+ * The filters of the table, from its columns: a search per `text` column, a menu of values (with their counts) per
483
+ * `facet` column, two bounds per `range` column; the filters in force as removable chips, "clear all", and the count
484
+ * of results, announced.
485
+ */
486
+ declare function DataTableFilters({ debounce, children, className }: DataTableFiltersProps): React.JSX.Element;
487
+ type DataTableColumnsMenuProps = {
488
+ /** Opens the menu at first (a story, a test). */
489
+ defaultOpen?: boolean;
490
+ /** Classes merged on the button. */
491
+ className?: string;
492
+ };
493
+ /** A menu of the `hideable` columns, each a checkbox: the person chooses what the table shows. */
494
+ declare function DataTableColumnsMenu({ defaultOpen, className }: DataTableColumnsMenuProps): React.JSX.Element;
495
+ type DataTableExportProps = {
496
+ /** The file's name. Default `"export.csv"`. */
497
+ filename?: string;
498
+ /** Receives the CSV instead of downloading it (send it to the server, a test). */
499
+ onExport?: (csv: string) => void;
500
+ /** Classes merged on the button. */
501
+ className?: string;
502
+ };
503
+ /** Downloads what the table shows — the filtered and sorted rows of every page, the visible columns — as CSV. */
504
+ declare function DataTableExport({ filename, onExport, className }: DataTableExportProps): React.JSX.Element;
245
505
 
246
- export { DataTable, type DataTableColumn, type DataTableLabels, type DataTableProps, type DataTableSort, type SortDirection, dataTable, dataTableLabels };
506
+ export { type CellValue, DataTable, type DataTableColumn, DataTableColumnsMenu, type DataTableColumnsMenuProps, DataTableExport, type DataTableExportProps, type DataTableFilterState, DataTableFilters, type DataTableFiltersProps, type DataTableInstance, type DataTableLabels, type DataTableProps, type DataTableQuery, type DataTableSort, type FilterValue, type SortDirection, compareValues, dataTable, dataTableCsv, dataTableLabels, useDataTable };