@gridkitjs/core 0.16.0 → 0.18.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/dist/index.d.ts CHANGED
@@ -1,2984 +1,5 @@
1
- /**
2
- * A row or column selection change by id — see
3
- * `GridControllerOptions.onSelectionDiff`.
4
- */
5
- interface SelectionDiffEvent extends SelectionDiff {
6
- /** Which selection changed. */
7
- readonly target: "rows" | "columns";
8
- /** The whole selection after the change. */
9
- readonly selection: SelectionState;
10
- }
11
- /**
12
- * What `createGridController` is given: the grid's options and selection
13
- * callbacks, plus what a renderer supplies that is not a setting — the column
14
- * definitions, whose templates name the renderer's own node type, the width
15
- * the viewport measured, and a hook for its own selection feedback.
16
- */
17
- interface GridControllerOptions<Row, Node = string> extends GridOptions<Row>, SelectionCallbacks<Row, Node> {
18
- /**
19
- * The columns to show. Omitted or empty, one column is inferred per field
20
- * of `dataSource` — see `defineColumnsFromRows`.
21
- */
22
- columns?: readonly ColumnDefinition<Row, Node>[] | undefined;
23
- /**
24
- * The width, in px, `resizeMode: "fit"` fills. `null` or absent before it
25
- * has been measured, or where there is no viewport at all (an export in
26
- * Node), and then columns keep their resolved widths.
27
- */
28
- viewportWidth?: number | null | undefined;
29
- /**
30
- * Called once per row or column selection change, after the selection
31
- * callbacks, with the change by id — every id it added or removed,
32
- * including those with no row on screen (on another page, in a collapsed
33
- * group, filtered out), which the callbacks' resolved rows leave out. For a
34
- * renderer's own feedback, such as a live region announcing how many rows
35
- * are selected; an application reads the selection callbacks instead.
36
- */
37
- onSelectionDiff?: ((event: SelectionDiffEvent) => void) | undefined;
38
- }
39
- /**
40
- * A grid without a renderer: its state, the view derived from it, and every
41
- * action that changes it. A renderer creates one per grid, hands it the
42
- * current options on each update, draws `getView()` and calls the actions
43
- * from its event handlers, so no renderer decides anything the user can see.
44
- *
45
- * Each slice of `GridState` is controlled or not on its own, the way a form
46
- * input is: given as an option (`columnSort`), the grid shows that value and
47
- * an action only asks for a change through the slice's callback
48
- * (`onColumnSortChange`); left out, the controller keeps the slice itself,
49
- * starting from its default (`defaultColumnSort`).
50
- *
51
- * Every action follows the same steps: work out the next value; stop if it
52
- * is the very object the slice already holds; keep it, unless the slice is
53
- * controlled; report it through the slice's callback; then call every
54
- * subscriber, synchronously. The setters (`setColumnSort` and the like) also
55
- * stop for a value equal to the current one, so restoring what is already
56
- * there reports nothing.
57
- *
58
- * Every member is a plain function bound to its grid, safe to hand around on
59
- * its own — `onClick={controller.nextPage}`.
60
- */
61
- interface GridController<Row, Node = string> {
62
- readonly getOptions: () => GridControllerOptions<Row, Node>;
63
- /**
64
- * Replaces the options, as a renderer does with its current props on every
65
- * update; calling it again with equal options changes nothing. A controlled
66
- * slice takes its new value from here.
67
- *
68
- * Does not call subscribers: a renderer calls this while it updates, and
69
- * draws the result itself — a subscriber called mid-update would update
70
- * mid-update too. A renderer that also tells other listeners about it does
71
- * so once its update is done.
72
- */
73
- readonly setOptions: (options: GridControllerOptions<Row, Node>) => void;
74
- /** Every slice as the grid now applies it. The same object until a slice changes. */
75
- readonly getState: () => GridState<Row>;
76
- /** What the user is looking at — see `resolveGridView`. The same object until something in it changes. */
77
- readonly getView: () => GridView<Row, Node>;
78
- /**
79
- * Calls `listener` after each action that got as far as reporting a
80
- * change. Returns the function that unsubscribes it.
81
- */
82
- readonly subscribe: (listener: () => void) => () => void;
83
- /**
84
- * Puts back state saved earlier — from `getState()`, or from
85
- * `serializeGridState` and back through JSON. Every slice given is set as
86
- * its own `set*` action would set it, so each that changes fires its
87
- * callback and a controlled one only asks; slices left out keep their value.
88
- * Subscribers are called once, after every slice is in place, and a
89
- * restored pagination is kept even when the same call changed the sort,
90
- * filter or grouping that would otherwise send it back to the first page.
91
- * A slice that throws stops the restore there, after the slices before it
92
- * are shown, reported and announced as above.
93
- */
94
- readonly restoreState: (saved: Partial<GridState<Row>> | Partial<SerializedGridState<Row>>) => void;
95
- /**
96
- * Replaces the column widths. Reported through `onColumnResize` as the
97
- * `"end"` of a resize of the first column whose width changed, at its new
98
- * width — or, when its entry was removed, the width its definition gives
99
- * it. Equal widths report nothing.
100
- */
101
- readonly setColumnSizing: (sizing: ColumnSizingState) => void;
102
- /**
103
- * Sets one column's width, as a resize gesture does: `"move"` while the
104
- * gesture lasts, `"end"` once it is over. Never skipped for an unchanged
105
- * width, so a drag held against a column's minimum still reports every
106
- * move.
107
- */
108
- readonly resizeColumn: (columnId: string, width: number, phase: "move" | "end") => void;
109
- /**
110
- * Ends a resize gesture by putting its column back as it was when the
111
- * gesture began — `startSizing` is the sizing state then, `startWidth` the
112
- * width the column was drawn at — keeping any other column's change made in
113
- * the meantime. Reported as the gesture's `"end"`, at `startWidth`.
114
- */
115
- readonly cancelColumnResize: (columnId: string, startSizing: ColumnSizingState, startWidth: number) => void;
116
- /**
117
- * Replaces the column order. Reported through `onColumnOrderChange` naming
118
- * the first column whose position changed; an equal order reports nothing.
119
- */
120
- readonly setColumnOrder: (order: ColumnOrderState) => void;
121
- /**
122
- * Moves a column in front of `beforeId`, or to the end when that is
123
- * `null`, among every column — hidden ones keep their place. A move that
124
- * changes nothing reports nothing.
125
- */
126
- readonly moveColumn: (columnId: string, beforeId: string | null) => void;
127
- /**
128
- * Replaces the column visibility state. Reported through
129
- * `onColumnVisibilityChange` with every column whose entry changed; an
130
- * equal state reports nothing.
131
- */
132
- readonly setColumnVisibility: (visibility: ColumnVisibilityState) => void;
133
- /** Shows the given columns, each in the place it held when hidden. One report for the whole call. */
134
- readonly showColumns: (columnIds: readonly string[]) => void;
135
- /** Hides the given columns. A hidden column still sorts, filters and groups. */
136
- readonly hideColumns: (columnIds: readonly string[]) => void;
137
- /**
138
- * Replaces the filter. Reported through `onFilterChange`; a filter equal to
139
- * the current one — the same entries in the same order, a `Date` value
140
- * compared by time and a predicate by identity — reports nothing.
141
- */
142
- readonly setFilter: (filter: FilterState<Row>) => void;
143
- /**
144
- * Replaces the selected row ids as given, whatever `selectable` allows —
145
- * the way a controlled or default value is applied. The same ids in the
146
- * same order report nothing.
147
- */
148
- readonly setRowSelection: (selection: SelectionState) => void;
149
- /**
150
- * Selects rows as a user could, within what `selectable.rows` allows:
151
- * `"replace"` (the default) selects exactly these — only the last of them
152
- * under `"single"` — and `"toggle"` flips each one. An id need not name a
153
- * row on screen. A call that leaves the selection as it was reports
154
- * nothing.
155
- */
156
- readonly selectRows: (rowIds: readonly string[], intent?: "replace" | "toggle") => void;
157
- /**
158
- * Applies one click or key press to a row: `"replace"`, `"toggle"` or
159
- * `"range"` from the last row selected by anything but a range, across
160
- * the data rows on the current page. That anchor goes when the selection is
161
- * cleared or replaced, or its row leaves the page; a range without one
162
- * selects just this row and anchors there.
163
- */
164
- readonly selectRow: (rowId: string, intent: SelectIntent) => void;
165
- /** Selects every data row on the current page, when `selectable.rows` is `"multiple"`. */
166
- readonly selectAllRows: () => void;
167
- /**
168
- * Lets go of every row, column and cell selection at once, as Escape does:
169
- * one change, so each selection that changes fires its callback and then
170
- * subscribers are called once.
171
- */
172
- readonly clearSelection: () => void;
173
- /** Replaces the selected column ids as given — see `setRowSelection`. */
174
- readonly setColumnSelection: (selection: SelectionState) => void;
175
- /** `selectRow`, for a column among the columns as rendered. */
176
- readonly selectColumn: (columnId: string, intent: SelectIntent) => void;
177
- /** Replaces the selected cell as given, `null` for none. */
178
- readonly setCellSelection: (selection: CellSelectionState) => void;
179
- /**
180
- * Applies one click or key press to a cell: `"toggle"` lets go of it when
181
- * it is the one selected; anything else selects it. A cell holds one value,
182
- * so a range over cells reads as a plain click.
183
- */
184
- readonly selectCell: (cell: SelectedCellRef, intent: SelectIntent) => void;
185
- /**
186
- * Replaces the sort. Reported through `onColumnSortChange` naming the
187
- * first column whose place or direction changed; a sort equal to the
188
- * current one changes nothing and reports nothing.
189
- */
190
- readonly setColumnSort: (sort: ColumnSortState) => void;
191
- /**
192
- * Cycles a column's sort, as its header toggle does: ascending, descending,
193
- * off. `stack` adds it to the sort rather than replacing the sort with it.
194
- */
195
- readonly toggleColumnSort: (columnId: string, options?: {
196
- readonly stack?: boolean | undefined;
197
- }) => void;
198
- /**
199
- * Takes one column out of the sort, keeping the rest in their order, and
200
- * reports naming that column — which `setColumnSort` without it would not
201
- * when it was the first key, naming instead the key that moved up. A
202
- * column the sort leaves out already reports nothing.
203
- */
204
- readonly clearColumnSort: (columnId: string) => void;
205
- /**
206
- * Replaces the group-by stack. Reported through `onGroupByChange` naming
207
- * the first level that changed; an equal stack reports nothing.
208
- */
209
- readonly setGroupBy: (groupBy: GroupByState) => void;
210
- /** Adds a column to the end of the group-by stack, or removes it if it is already there. */
211
- readonly toggleGroupBy: (columnId: string) => void;
212
- /**
213
- * Puts a column into the group-by stack in front of `beforeColumnId`, or at
214
- * the end when that is `null` — adding it, or moving it if it is already
215
- * there.
216
- */
217
- readonly moveGroupBy: (columnId: string, beforeColumnId: string | null) => void;
218
- /**
219
- * Replaces the collapsed groups. Reported with `groupId: null`, as a change
220
- * to every group at once; the same ids in the same order report nothing.
221
- */
222
- readonly setGroupExpansion: (expansion: GroupExpansionState) => void;
223
- readonly toggleGroupExpansion: (groupId: string) => void;
224
- readonly expandAllGroups: () => void;
225
- /** Collapses every group currently shown — see `collapseAllGroups`. */
226
- readonly collapseAllGroups: () => void;
227
- /**
228
- * Replaces the page and page size. A controlled pagination asks for them
229
- * as given and the view clamps a page past the last one; an uncontrolled
230
- * one stores and reports that page clamped. An equal pagination reports
231
- * nothing.
232
- */
233
- readonly setPagination: (pagination: PaginationState) => void;
234
- /**
235
- * Moves to the given page, clamped into range. A page that clamps to the
236
- * current one reports nothing.
237
- */
238
- readonly goToPage: (pageIndex: number) => void;
239
- /** Moves one page on; on the last page it does nothing and reports nothing. */
240
- readonly nextPage: () => void;
241
- /** Moves one page back; on the first page it does nothing and reports nothing. */
242
- readonly previousPage: () => void;
243
- /**
244
- * Changes the page size and goes back to the first page. The current size,
245
- * already on the first page, reports nothing.
246
- */
247
- readonly setPageSize: (pageSize: number) => void;
248
- }
249
-
250
- /** How a column's values compare, which decides what an operand must be. */
251
- type ValueKind = "number" | "boolean" | "date" | "text";
252
-
253
- /**
254
- * The kind of value a column filters as — what decides which conditions a
255
- * filter menu offers on it, how their operators read, and what a typed
256
- * operand must be.
257
- */
258
- type FilterOperatorFamily = ValueKind;
259
- /**
260
- * The family a column of `type` falls in: `"number"` for the numeric
261
- * types, `"date"` for date, date-time and time, `"boolean"`, and `"text"`
262
- * for everything else. It is the filter engine's own reading of `type`, so
263
- * a menu never offers a condition the column would compare differently.
264
- */
265
- declare function filterOperatorFamily(type: ColumnType | undefined): FilterOperatorFamily;
266
- /**
267
- * The conditions a filter menu offers on a column of `type`, in the order it
268
- * lists them, unless the column names its own. Never `in`: a list of values
269
- * is the checklist's to pick, not a condition's to type.
270
- */
271
- declare function defaultFilterOperators(type: ColumnType | undefined): readonly FilterOperator[];
272
- /**
273
- * How many operands `operator` takes — how many inputs a condition row
274
- * shows: none for the blanks, `between`'s two ends, one for the rest. `in`
275
- * takes one list, which only a checklist writes.
276
- */
277
- declare function filterOperandArity(operator: FilterOperator): 0 | 1 | 2;
278
- /**
279
- * The operand a condition input's `text` stands for on a column of `type`,
280
- * read as the column filters — or `undefined` when the text is empty or
281
- * doesn't read as one, which an editor shows as a value still to fix.
282
- *
283
- * - Text is kept as typed, spaces and all.
284
- * - A number reads with a point for decimals, as a number input gives it:
285
- * `"12abc"` and `"1,5"` read as nothing rather than as a guess.
286
- * - A date reads as a date input gives it, `yyyy-mm-dd`, at that day's
287
- * local midnight; or as a date-time input does, `yyyy-mm-ddThh:mm`, at
288
- * that local time.
289
- * - A boolean reads `"true"` or `"false"`.
290
- */
291
- declare function parseFilterOperand(text: string, type: ColumnType | undefined): Exclude<FilterScalar, null> | undefined;
292
- /**
293
- * The text a condition input shows for `value` — `parseFilterOperand`'s
294
- * inverse, for opening a condition already applied. A date reads back in
295
- * the form its column's input takes: the day alone on a `"date"` column,
296
- * the day and time on a `"dateTime"` or `"time"` one. A blank operand is
297
- * empty, and one that isn't a date on a date column — a string set in code
298
- * that names none — shows as it is, for the user to fix.
299
- */
300
- declare function formatFilterOperand(value: FilterScalar | undefined, type: ColumnType | undefined): string;
301
-
302
- /** The locale(s) values are formatted for — `undefined` is the runtime's own. */
303
- type FormatLocale = string | readonly string[] | undefined;
304
- /**
305
- * The text a value reads as in `column` — what a cell shows when the column
306
- * has no `cellTemplate`, and what an export or a print writes, so the two
307
- * cannot disagree.
308
- *
309
- * A `valueFormatter` decides outright. `null`/`undefined` read `""`, a
310
- * boolean `"true"`/`"false"` — or `messages.booleanTrue`/`booleanFalse`
311
- * when given, for a grid speaking another language — a string as it is, a
312
- * plain object or array as JSON.
313
- *
314
- * Dates and numbers are formatted through `Intl` only once asked to — the
315
- * column has a `format`, or a `locale` is given. Until then they print as a
316
- * grid always printed them, so adopting this changes nothing on screen: a
317
- * `Date` through `toLocaleString()`, a number as-is (`1234.5`, never
318
- * `1,234.5`). Once asked:
319
- *
320
- * - A `Date` → `Intl.DateTimeFormat`: the date alone under `"date"`, the time
321
- * alone under `"time"`, both otherwise.
322
- * - A number under a numeric `type` → `Intl.NumberFormat`: `"currency"` with
323
- * a currency symbol once `format.currency` names one (two fraction digits
324
- * until then), `"percent"` reading `0.25` as 25 %. Under any other type it
325
- * is still printed as-is, the way a number id should be.
326
- *
327
- * `format` and `locale` go to the `Intl` constructor unchanged, so any
328
- * option it accepts is honoured.
329
- */
330
- declare function formatCellValue<Row>(value: unknown, column: ColumnDefinition<Row, unknown>, locale?: FormatLocale, row?: Row, messages?: Pick<GridMessages, "booleanTrue" | "booleanFalse">): string;
331
- /**
332
- * The text an aggregate result reads as — a footer cell, a group's subtotal
333
- * — through `formatCellValue`, so once a `format` or `locale` asks for it a
334
- * `sum` of a currency column reads as currency and a `max` of a date column
335
- * as a date. `column` is `undefined` for a spec naming a column the grid
336
- * does not have, which then formats by its value alone.
337
- *
338
- * Until then a numeric result reads through `toLocaleString()`, with digit
339
- * grouping, where a cell prints its number as-is: that is how a grid has
340
- * always shown its totals, and a sum easily runs into the thousands.
341
- */
342
- declare function formatAggregateValue<Row>(value: unknown, spec: AggregateSpec<Row>, column: ColumnDefinition<Row, unknown> | undefined, locale?: FormatLocale): string;
343
- /**
344
- * The text a group's own value reads as — a group header's name, and the
345
- * label an export writes for it: as the grouped column's cells read it,
346
- * except that a missing value reads `messages.blankGroupValue` ("(blank)"),
347
- * since an empty label would leave the group looking unnamed rather than
348
- * named "nothing".
349
- */
350
- declare function formatGroupValue<Row>(value: unknown, column: ColumnDefinition<Row, unknown>, locale: FormatLocale, messages: Pick<GridMessages, "booleanTrue" | "booleanFalse" | "blankGroupValue">): string;
351
-
352
- /**
353
- * Every string a grid shows or announces of its own — the pager, the group-by
354
- * bar, the loading row, the text of a boolean or missing value, the labels of
355
- * its built-in commands, the names of its menus, toolbar and column chooser,
356
- * and the live-region
357
- * announcements — so a grid can
358
- * speak a language other than English. A message that names something takes
359
- * a function, so a translation can put the name where its own grammar wants
360
- * it.
361
- *
362
- * Text the data supplies (cells, headers, labels) is not here: it is already
363
- * the app's to choose. Nor is formatting — dates and numbers follow
364
- * `locale`, and so do the counts the defaults print: "1,204 of 10,000 rows"
365
- * under `"en"`, "1.204 of 10.000 rows" under `"de-DE"`.
366
- */
367
- interface GridMessages {
368
- /** The pager's accessible name. */
369
- pagerLabel: string;
370
- /** The pager button to the first page; drawn as an icon, so this is its accessible name. */
371
- firstPage: string;
372
- /** The pager button to the previous page; its accessible name. */
373
- previousPage: string;
374
- /** The pager button to the next page; its accessible name. */
375
- nextPage: string;
376
- /** The pager button to the last page; its accessible name. */
377
- lastPage: string;
378
- /** The page-size control's label. */
379
- pageSizeLabel: string;
380
- /** A numbered pager button's accessible name. */
381
- pageButtonLabel: (page: number) => string;
382
- /**
383
- * The compact pager's status, and what a page change announces. `page`
384
- * counts from one, and is `0` while there are no pages.
385
- */
386
- pageStatus: (page: number, pageCount: number) => string;
387
- /** The row shown while `infiniteScroll` loads more. */
388
- loadingMore: string;
389
- /** A boolean cell's text. */
390
- booleanTrue: string;
391
- booleanFalse: string;
392
- /** What a group header names a group of missing values. */
393
- blankGroupValue: string;
394
- /** The group-by bar's accessible name. */
395
- groupByBarLabel: string;
396
- /** Shown in an empty group-by bar a header can be dragged into. */
397
- groupByBarPlaceholder: string;
398
- /** A group-by chip's accessible name. `level` counts from one. */
399
- groupByChipLabel: (columnName: string, level: number, levelCount: number) => string;
400
- /** A group-by chip's remove button's accessible name. */
401
- removeGroupBy: (columnName: string) => string;
402
- /** Announced when a resize ends, `width` in whole pixels. */
403
- columnResized: (columnName: string, width: number) => string;
404
- /** Announced when a column is moved. `position` counts from one. */
405
- columnMoved: (columnName: string, position: number, columnCount: number) => string;
406
- /** Announced when a column is sorted. `key` is its place in the sort, from one. */
407
- columnSorted: (columnName: string, direction: SortDirection, key: number, keyCount: number) => string;
408
- /** Announced when a column leaves the sort. */
409
- sortCleared: (columnName: string) => string;
410
- /** Announced when a column is grouped by. `level` counts from one. */
411
- groupedBy: (columnName: string, level: number, levelCount: number) => string;
412
- /** Announced when a column leaves the grouping. */
413
- groupingRemoved: (columnName: string) => string;
414
- groupExpanded: string;
415
- groupCollapsed: string;
416
- allGroupsExpanded: string;
417
- allGroupsCollapsed: string;
418
- /** Announced when one change selects or deselects more than one row or column. */
419
- selectedCount: (count: number, target: "rows" | "columns") => string;
420
- /** Announced when a cell is selected. `rowNumber` counts from one. */
421
- cellSelected: (columnName: string, rowNumber: number) => string;
422
- /** Announced when one column is hidden. */
423
- columnHidden: (columnName: string) => string;
424
- /** Announced when one column is shown. */
425
- columnShown: (columnName: string) => string;
426
- /** Announced when one change hides more than one column. */
427
- columnsHidden: (count: number) => string;
428
- /** Announced when one change shows more than one column. */
429
- columnsShown: (count: number) => string;
430
- /**
431
- * Announced when one action autofits more than one column, as
432
- * `column.autoFitAll` does, in place of each column's `columnResized`.
433
- */
434
- columnsAutoFitted: (count: number) => string;
435
- /** A column header's context menu's accessible name. */
436
- headerMenuLabel: (columnName: string) => string;
437
- /** A data cell's context menu's accessible name — a menu for its row. */
438
- cellMenuLabel: string;
439
- /** A group header row's context menu's accessible name. */
440
- groupMenuLabel: string;
441
- /** The accessible name of the menu in the body's empty space. */
442
- bodyMenuLabel: string;
443
- /** The built-in `sort.ascending` command's label. */
444
- sortAscending: string;
445
- sortDescending: string;
446
- /** `sort.clear`: takes one column out of the sort. */
447
- clearSort: string;
448
- /** `sort.clearAll` */
449
- clearAllSorting: string;
450
- /** `group.add`, naming the column it groups by. */
451
- groupByColumn: (columnName: string) => string;
452
- /** `group.clearAll`. `group.remove` reads `removeGroupBy`, as the group-by chip's button does. */
453
- ungroupAll: string;
454
- expandAllGroups: string;
455
- collapseAllGroups: string;
456
- /** `column.hide` */
457
- hideColumn: string;
458
- /** `column.autoFit`: sizes the column to its content. */
459
- autoFitColumn: string;
460
- autoFitAllColumns: string;
461
- /** `selection.selectAllRows` */
462
- selectAllRows: string;
463
- /** `selection.clear` */
464
- clearSelection: string;
465
- /** `filter.clearAll`, which clears the search too. */
466
- clearFilters: string;
467
- /** `column.choose`, which opens the column chooser. */
468
- chooseColumns: string;
469
- /** The toolbar's accessible name, unless its `label` gives one. */
470
- toolbarLabel: string;
471
- /** The toolbar's search box's accessible name. */
472
- searchLabel: string;
473
- /** Shown in the toolbar's empty search box. */
474
- searchPlaceholder: string;
475
- /** The toolbar's "More" button, holding the items that do not fit. */
476
- moreToolbarItems: string;
477
- /** Announced when a search settles: how many rows it found. */
478
- searchResults: (count: number) => string;
479
- /** The column chooser's accessible name. */
480
- columnChooserLabel: string;
481
- /** The column chooser's search box's accessible name. */
482
- columnChooserSearchLabel: string;
483
- /** The column chooser's checkbox showing or hiding every column its search lists. */
484
- showAllColumns: string;
485
- /** Shown in the column chooser when its search matches no column. */
486
- noMatchingColumns: string;
487
- /**
488
- * A condition's operator, as a filter menu lists it. `family` is the
489
- * column's (`filterOperatorFamily`), so a date can read `lt` as "Before"
490
- * where a number reads "Less than".
491
- */
492
- filterOperatorLabel: (operator: FilterOperator, family: FilterOperatorFamily) => string;
493
- /** A filter checklist's item for the column's blank cells. */
494
- filterBlanks: string;
495
- /**
496
- * Shown in place of a filter checklist whose column holds more values
497
- * than `filterMenu.valueLimit`, until something is searched.
498
- */
499
- filterSearchFirst: (total: number) => string;
500
- /** Shown under a searched filter checklist `filterMenu.valueLimit` cut short: how many matches it left out. */
501
- filterMoreValues: (count: number) => string;
502
- /** `filter.open`, which opens a column's filter menu. */
503
- openFilter: string;
504
- /** `filter.clear`, and the filter menu's button doing the same: clears one column's filter. */
505
- clearColumnFilter: string;
506
- /** A column's filter menu's accessible name. */
507
- filterMenuLabel: (columnName: string) => string;
508
- /** What a column header is described as while its column is filtered. */
509
- columnFiltered: string;
510
- /** The filter menu's button applying what it holds. */
511
- applyFilter: string;
512
- /** The filter menu's button closing it without applying. */
513
- cancelFilter: string;
514
- /**
515
- * Shown in a filter menu for a filter its editor cannot show — a
516
- * predicate, a text query, a group across columns — which applying
517
- * replaces.
518
- */
519
- customFilter: string;
520
- /** Announced when a filter menu applies: how many rows the filter keeps, of how many. */
521
- filterResults: (shown: number, total: number) => string;
522
- /** The accessible name of one of a filter menu's conditions. `position` counts from one. */
523
- filterConditionLabel: (position: number) => string;
524
- /** The accessible name of a condition's operator picker. */
525
- filterOperatorFieldLabel: string;
526
- /** The accessible name of a condition's value box. */
527
- filterValueLabel: string;
528
- /** The accessible name of a `between` condition's first value box, its lower end. */
529
- filterFromLabel: string;
530
- /** The accessible name of a `between` condition's second value box, its upper end. */
531
- filterToLabel: string;
532
- /** The accessible name of the choice joining a filter menu's two conditions. */
533
- filterCombinatorLabel: string;
534
- /** Joins two conditions: a row has to meet both. */
535
- filterAnd: string;
536
- /** Joins two conditions: a row has to meet either. */
537
- filterOr: string;
538
- /**
539
- * Shown under a filter menu's conditions when one's value is missing or
540
- * doesn't read as its column's `family` (`filterOperatorFamily`) — "Enter
541
- * a number" on a number column.
542
- */
543
- filterValueInvalid: (family: FilterOperatorFamily) => string;
544
- /** The accessible name of a filter checklist's search box. */
545
- filterSearchLabel: string;
546
- /** The checkbox above a filter checklist checking every value its search shows. */
547
- filterSelectAll: string;
548
- /** The accessible name of a filter checklist's list of values. */
549
- filterValuesLabel: string;
550
- /**
551
- * Shown above a filter checklist whose column is filtered by conditions,
552
- * which checking values replaces.
553
- */
554
- filterByCondition: string;
555
- /**
556
- * The excel editor's button opening the conditions its column offers, and
557
- * that menu's accessible name — "Number filters" on a number column, by
558
- * its `family` (`filterOperatorFamily`).
559
- */
560
- filterOperatorMenu: (family: FilterOperatorFamily) => string;
561
- /** The button taking the excel editor from a condition back to its checklist. */
562
- filterBackToValues: string;
563
- /** The toolbar's `"export"` dropdown, listing the export commands. */
564
- exportMenu: string;
565
- /** `export.csv` */
566
- exportCsv: string;
567
- /** `export.json` */
568
- exportJson: string;
569
- /** `export.xlsx`, shown once an xlsx writer is registered. */
570
- exportXlsx: string;
571
- /** `export.pdf`, shown once a PDF writer is registered. */
572
- exportPdf: string;
573
- /** `exportSelection.csv`: the selected rows only. */
574
- exportSelectionCsv: string;
575
- /** `exportSelection.json` */
576
- exportSelectionJson: string;
577
- /** `exportSelection.xlsx` */
578
- exportSelectionXlsx: string;
579
- /**
580
- * Announced when an export's writer fails or the browser refuses its
581
- * download, so no file is saved.
582
- */
583
- exportFailed: string;
584
- /** `copy.cell` */
585
- copyCell: string;
586
- /** `copy.row` */
587
- copyRow: string;
588
- /** `copy.selection` */
589
- copySelection: string;
590
- /** Announced once a copy is on the clipboard. */
591
- copied: (count: number, unit: "cells" | "rows" | "columns") => string;
592
- /** Announced when the browser refuses the clipboard, so nothing was copied. */
593
- copyFailed: string;
594
- /** `print` */
595
- print: string;
596
- /** Announced when the browser fails to print, so nothing is printed. */
597
- printFailed: string;
598
- }
599
- /**
600
- * The grid's own English, its counts printed in `locale`'s digits —
601
- * "1,204 of 10,000 rows" under `"en"`, "1.204 of 10.000 rows" under
602
- * `"de-DE"`. Without a locale, the runtime's own; that one is
603
- * `defaultMessages`.
604
- */
605
- declare function createDefaultMessages(locale?: FormatLocale): GridMessages;
606
- /** The grid's own English, which `messages` replaces key by key. */
607
- declare const defaultMessages: GridMessages;
608
- /**
609
- * `messages` over the defaults for `locale` — every key the grid needs,
610
- * whichever the caller gave, the defaults counting in `locale`'s digits. The
611
- * defaults themselves, same object for the same locale, when it gave none, so
612
- * a renderer memoising on the result does not see a change that is not one.
613
- */
614
- declare function resolveMessages(messages: Partial<GridMessages> | undefined, locale?: FormatLocale): GridMessages;
615
-
616
- /**
617
- * A value an export stores as it is rather than as text — what a cell's
618
- * `ExportCell.value` holds and a column's `exportValue` returns. Narrow on
619
- * purpose: these are the kinds every format has a reading for (a spreadsheet
620
- * number, date or boolean cell; a JSON scalar), so nothing a writer cannot
621
- * represent reaches it.
622
- */
623
- type ExportScalar = string | number | boolean | Date | null;
624
- /**
625
- * One cell of an export, in both of its readings. `text` is what the grid
626
- * shows — CSV, the clipboard and print write it, so a file reads as the
627
- * screen does. `value` is the typed value a spreadsheet stores, so a number
628
- * stays a number a formula can sum rather than text that looks like one.
629
- */
630
- interface ExportCell {
631
- readonly value: ExportScalar;
632
- readonly text: string;
633
- }
634
- /**
635
- * A column of an export, settled once so that no writer reads a column
636
- * definition for itself. `type` and `format` pass through for a writer that
637
- * keeps typed values, which derives its own number or date format from them.
638
- */
639
- interface ExportColumn {
640
- readonly id: string;
641
- /** The column's name as text — `resolveColumnHeaderText`, never markup. */
642
- readonly header: string;
643
- /** The column's `type`, `"string"` when it has none. */
644
- readonly type: ColumnType;
645
- readonly format?: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions | undefined;
646
- /** How the column's cells align, after falling back to its type. */
647
- readonly alignment: ColumnAlignment;
648
- /** Width in px: as rendered for a visible column, as it would start for a hidden one. */
649
- readonly width: number;
650
- }
651
- /** One row of data: a cell per `ExportTable.columns` entry, in that order. */
652
- interface ExportDataRow {
653
- readonly kind: "data";
654
- readonly rowId: string;
655
- readonly cells: readonly ExportCell[];
656
- }
657
- /**
658
- * A group header. `label` is the header's text, `"Region: West"`; `cells`
659
- * holds the group's aggregates under their own columns when the grid shows
660
- * them inline in the header, and is empty text elsewhere — a cell per
661
- * column either way, so a writer can lay it out like any other row.
662
- */
663
- interface ExportGroupRow {
664
- readonly kind: "group";
665
- /** Nesting depth, 0 for a top-level group. */
666
- readonly level: number;
667
- readonly groupId: string;
668
- readonly label: string;
669
- /** Data rows under this group, at every depth. */
670
- readonly count: number;
671
- readonly cells: readonly ExportCell[];
672
- }
673
- /**
674
- * A group's aggregates as a row of their own, after everything in the group
675
- * — present where the grid shows them that way (`groupAggregateDisplay:
676
- * "row"`), and at the same `level` as its group.
677
- */
678
- interface ExportGroupSummaryRow {
679
- readonly kind: "groupSummary";
680
- readonly level: number;
681
- readonly cells: readonly ExportCell[];
682
- }
683
- /**
684
- * A body row of an export, in the order the grid shows them. Discriminate on
685
- * `kind`.
686
- */
687
- type ExportRow = ExportDataRow | ExportGroupRow | ExportGroupSummaryRow;
688
- /**
689
- * The grand total — every aggregate over the exported rows. Its own kind
690
- * rather than an `ExportRow`, since it only ever stands in
691
- * `ExportTable.footer`, never among the body rows.
692
- */
693
- interface ExportTotalRow {
694
- readonly kind: "total";
695
- readonly cells: readonly ExportCell[];
696
- }
697
- /**
698
- * What an export writes, whatever the format: the grid's view as data,
699
- * built by `buildExportTable` from the controller's view and state and
700
- * never from the page. Every serialiser and writer reads this one shape, so
701
- * a file, the clipboard and a print cannot disagree.
702
- */
703
- interface ExportTable {
704
- readonly columns: readonly ExportColumn[];
705
- /** Whether a header row of column names leads the output. */
706
- readonly header: boolean;
707
- readonly rows: readonly ExportRow[];
708
- /** The grand total, or `null` when there are no aggregates to total. */
709
- readonly footer: ExportTotalRow | null;
710
- }
711
- /**
712
- * Narrows what an export holds. Every field defaults to what the user sees,
713
- * with nothing hidden by paging or a collapsed group.
714
- */
715
- interface ExportOptions {
716
- /**
717
- * Which rows: `"all"` (the default) every row the filter, search and sort
718
- * leave, across every page; `"page"` the data rows on the current page;
719
- * `"selection"` the selected rows among those `"all"` holds.
720
- */
721
- readonly scope?: "all" | "page" | "selection" | undefined;
722
- /**
723
- * Which columns: `"visible"` (the default) those shown, in their current
724
- * order; `"all"` hidden ones too; or a list of column ids, in that order.
725
- * A column with `exportable: false` is left out of every one.
726
- */
727
- readonly columns?: "visible" | "all" | readonly string[] | undefined;
728
- /**
729
- * Whether a grouped grid exports its group header rows, every group
730
- * expanded whatever its state on screen. Defaults to `true`; `false`
731
- * keeps the rows in grouped order without the headers.
732
- */
733
- readonly includeGroups?: boolean | undefined;
734
- /** Whether group aggregates and the grand total are exported. Defaults to `true`. */
735
- readonly includeAggregates?: boolean | undefined;
736
- /** Whether a header row of column names leads the output. Defaults to `true`. */
737
- readonly includeHeader?: boolean | undefined;
738
- }
739
-
740
- /**
741
- * What an export is built from: the grid's view and state as a controller
742
- * holds them, never the page — so rows virtualised, paged or scrolled out of
743
- * sight still export. Typed as the few fields it reads, so a
744
- * `GridCommandContext` is one as it stands.
745
- */
746
- interface ExportSource<Row> {
747
- readonly view: GridView<Row, unknown>;
748
- readonly state: Pick<GridState<Row>, "groupBy" | "rowSelection" | "columnSizing">;
749
- readonly options: {
750
- readonly locale?: FormatLocale;
751
- readonly aggregates?: AggregateState<Row> | undefined;
752
- readonly groupAggregateDisplay?: GroupAggregateDisplay | undefined;
753
- readonly columnSizeDefaults?: Partial<ColumnSizeDefaults> | undefined;
754
- };
755
- readonly messages: Pick<GridMessages, "booleanTrue" | "booleanFalse" | "blankGroupValue">;
756
- }
757
- /**
758
- * The grid's view as an `ExportTable` — the one model every export format,
759
- * the clipboard and print are written from, so none of them reads the page
760
- * and none can disagree with another.
761
- *
762
- * By default it holds what the user sees, minus what only hides it: every
763
- * row the filter, search and sort leave, across every page; the visible
764
- * columns in their current order, less any with `exportable: false`; and,
765
- * in a grouped grid, every group expanded whatever its state on screen,
766
- * with its aggregates where the grid shows them. `options` narrows it.
767
- *
768
- * Each cell carries the text `formatCellValue` makes of it, so the export
769
- * reads as the screen does, and a typed value — the column's `exportValue`,
770
- * else the raw value when it is a string, number, boolean or `Date`.
771
- *
772
- * The groups are rebuilt from the exported rows rather than read off
773
- * `displayRows`, which omits a collapsed group's rows; so group counts,
774
- * subtotals and the grand total describe exactly the rows exported — the
775
- * selection, under `scope: "selection"`, not the whole grid.
776
- */
777
- declare function buildExportTable<Row>(source: ExportSource<Row>, options?: ExportOptions): ExportTable;
778
-
779
- /**
780
- * What a copy is built from: an export's source, with the column and cell
781
- * selection a selection copy reads as well. A `GridCommandContext` is one
782
- * as it stands.
783
- */
784
- interface CopySource<Row> extends ExportSource<Row> {
785
- readonly state: Pick<GridState<Row>, "groupBy" | "rowSelection" | "columnSizing" | "columnSelection" | "cellSelection">;
786
- }
787
- /**
788
- * What to copy: one cell, one row, or whatever the grid has selected — the
789
- * selected rows, else the selected columns, else the selected cell.
790
- */
791
- type CopyRequest = {
792
- readonly kind: "cell";
793
- readonly rowId: string;
794
- readonly columnId: string;
795
- } | {
796
- readonly kind: "row";
797
- readonly rowId: string;
798
- } | {
799
- readonly kind: "selection";
800
- };
801
- /**
802
- * A copy in the two forms the clipboard carries, with what it holds for the
803
- * announcement: `count` cells, rows or columns.
804
- */
805
- interface CopyContent {
806
- /** Tab-separated text, as `toTsv` writes it — what a spreadsheet splits into cells. */
807
- readonly text: string;
808
- /** The same as an HTML table, as `toHtmlTable` writes it — what a word processor keeps the columns of. */
809
- readonly html: string;
810
- readonly count: number;
811
- readonly unit: "cells" | "rows" | "columns";
812
- }
813
- /**
814
- * What `request` copies, as tab-separated text and an HTML table, or `null`
815
- * when there is nothing to copy — a row the filter hides, a column hidden
816
- * or marked `exportable: false`, or an empty selection.
817
- *
818
- * Built from the export model, never the page, so a copy holds exactly what
819
- * an export would and reads as the grid shows it: each cell's formatted
820
- * text, the shown columns in their order less any with `exportable: false`.
821
- * The text has no byte order mark and no formula neutralising — what is
822
- * copied is what is seen, and pasting it is the user's own act.
823
- *
824
- * A cell copies its text alone, and a row its cells without a header. A
825
- * selection copies the selected rows, in the order the grid shows them and
826
- * under a header row once there are two or more; else the selected columns
827
- * over every row the filter leaves, under their header; else the selected
828
- * cell.
829
- */
830
- declare function copyContent<Row>(source: CopySource<Row>, request: CopyRequest): CopyContent | null;
831
-
832
- /** Which way the paper is turned. */
833
- type PrintOrientation = "portrait" | "landscape";
834
- /**
835
- * How a grid prints: which rows and columns (every `ExportOptions` field),
836
- * the text around the table, and the page it is laid out on. The grid's
837
- * `print` option.
838
- */
839
- interface PrintOptions extends ExportOptions {
840
- /** A heading above the table, and the printed document's title. */
841
- readonly title?: string | undefined;
842
- /** A line under the title. */
843
- readonly subtitle?: string | undefined;
844
- /** A line after the table. */
845
- readonly footer?: string | undefined;
846
- /**
847
- * When the print was made, under the title: `true` for now, or a `Date`
848
- * to print instead. Off by default.
849
- */
850
- readonly timestamp?: boolean | Date | undefined;
851
- /** The language the timestamp is written in. Defaults to the grid's. */
852
- readonly locale?: FormatLocale;
853
- /**
854
- * Which way the paper is turned. Defaults to `"landscape"` for a table of
855
- * more than six columns, which rarely fits a portrait page, else
856
- * `"portrait"`.
857
- */
858
- readonly orientation?: PrintOrientation | undefined;
859
- /**
860
- * A page size CSS names — `"A4"` (the default), `"Letter"`, `"A3"`,
861
- * `"Legal"`.
862
- */
863
- readonly paperSize?: "A4" | "Letter" | (string & {}) | undefined;
864
- /** Whether each page is numbered, "3 / 12", where the browser can. Defaults to `true`. */
865
- readonly pageNumbers?: boolean | undefined;
866
- /**
867
- * Whether a wide table is squeezed onto the page — a smaller font and
868
- * fixed column widths that wrap their text — rather than run off its
869
- * edge. Defaults to `false`.
870
- */
871
- readonly fitToWidth?: boolean | undefined;
872
- /** CSS added after the print stylesheet, to restyle the printed table. */
873
- readonly styles?: string | undefined;
874
- }
875
- /**
876
- * The page a print is laid out on, every choice settled — what
877
- * `@gridkitjs/dom`'s `printStyles` turns into the page's CSS.
878
- */
879
- interface PrintPage {
880
- readonly paperSize: string;
881
- readonly orientation: PrintOrientation;
882
- readonly pageNumbers: boolean;
883
- readonly fitToWidth: boolean;
884
- }
885
- /** A print ready for a renderer to put on paper: what `buildPrintDocument` returns. */
886
- interface PrintDocument {
887
- /**
888
- * The document's title as text, `""` when untitled — what the browser
889
- * puts in a page's header and names a PDF saved from the print dialog.
890
- */
891
- readonly title: string;
892
- /** The `<body>`'s markup: the heading, the table and the footer, every piece of text escaped. */
893
- readonly bodyHtml: string;
894
- readonly page: PrintPage;
895
- }
896
- /**
897
- * The table as a printable document: its heading — the title, subtitle and
898
- * timestamp `options` set — then the table as `toHtmlTable` writes it, then
899
- * the footer line, with the page it is laid out on. Every piece of text is
900
- * escaped. It holds no styles: putting it on paper, with a stylesheet for
901
- * the page, is the renderer's — `@gridkitjs/dom`'s `printStyles` and
902
- * `printDocument` in a browser.
903
- *
904
- * The heading and footer carry semantic class names for a stylesheet:
905
- * `gridkit-print-header` around `print-title`, `print-subtitle` and
906
- * `print-timestamp`, and `gridkit-print-footer`.
907
- */
908
- declare function buildPrintDocument(table: ExportTable, options?: PrintOptions): PrintDocument;
909
- /**
910
- * What `exportPrintDocument` prints from: an `ExportSource` that may carry
911
- * the grid's `label`. A `GridCommandContext` is one as it stands.
912
- */
913
- interface PrintSource<Row> extends ExportSource<Row> {
914
- readonly options: ExportSource<Row>["options"] & {
915
- readonly label?: string | undefined;
916
- };
917
- }
918
- /**
919
- * The grid's view as a print document: the table `options` narrow, laid out
920
- * as `buildPrintDocument` lays it out, with the timestamp in the grid's
921
- * locale unless `options` name another. Given no `title`, it takes the
922
- * grid's `label` — the name a screen reader already reads for it; `""`
923
- * leaves it untitled.
924
- */
925
- declare function exportPrintDocument<Row>(source: PrintSource<Row>, options?: PrintOptions): PrintDocument;
926
-
927
- /** How `toCsv` writes a file. Every field is optional. */
928
- interface CsvOptions {
929
- /**
930
- * The field separator: `","` by default, any string, or `"auto"` for the
931
- * separator a spreadsheet expects in `locale` — `";"` where a decimal is
932
- * written with a comma, as in most of Europe, since a comma there is part
933
- * of a number; `","` elsewhere.
934
- */
935
- readonly delimiter?: string | undefined;
936
- /** The locale `delimiter: "auto"` reads; the runtime's own when absent. */
937
- readonly locale?: FormatLocale;
938
- /** What ends each record. Defaults to `"\r\n"`, as RFC 4180 writes it. */
939
- readonly eol?: string | undefined;
940
- /**
941
- * Whether the file starts with a UTF-8 byte order mark. Defaults to
942
- * `true`: without one, Excel reads the file in the system's legacy code
943
- * page and garbles every character outside ASCII.
944
- */
945
- readonly bom?: boolean | undefined;
946
- /**
947
- * Whether a field a spreadsheet would run as a formula is written as text
948
- * instead. Defaults to `true`; see `toCsv`.
949
- */
950
- readonly neutralizeFormulas?: boolean | undefined;
951
- /**
952
- * Which reading of each cell is written: `"text"` (the default), as the
953
- * grid shows it; or `"raw"`, the typed value — numbers plain, dates in ISO
954
- * 8601, booleans as `true` and `false` — for a file a program reads.
955
- */
956
- readonly values?: "text" | "raw" | undefined;
957
- }
958
- /**
959
- * The table as CSV, quoted per RFC 4180: a field is quoted when it holds the
960
- * delimiter, a quote or a line break, and a quote inside one is doubled, so
961
- * a line break inside a cell survives. A group row writes its label in the
962
- * first column; summary rows and the footer write their aggregates under
963
- * their columns.
964
- *
965
- * A CSV file opened in a spreadsheet runs any field that starts with `=`,
966
- * `+`, `-` or `@` as a formula — and a tab or a carriage return can hide
967
- * such a start — so a value a user typed into the data could make another
968
- * user's spreadsheet fetch a URL or run a command. By default such a field
969
- * gets a leading `'`, which the spreadsheet shows as text. A cell whose
970
- * value is a number keeps its leading sign, since it is one.
971
- *
972
- * Returns a string, not a file: making a `Blob` of it, with the type
973
- * `text/csv;charset=utf-8`, is the renderer's job.
974
- */
975
- declare function toCsv(table: ExportTable, options?: CsvOptions): string;
976
-
977
- /** How `toJson` writes its text. Every field is optional. */
978
- interface JsonOptions {
979
- /**
980
- * What each record is keyed by: `"id"` (the default), the column's id,
981
- * stable whatever the header says; or `"header"`, its header text, for a
982
- * reader who sees the keys. A header repeated across columns is suffixed
983
- * ` (2)`, ` (3)` and so on, so no column overwrites another.
984
- */
985
- readonly keys?: "id" | "header" | undefined;
986
- /** Indentation, as `JSON.stringify` takes it; none by default. */
987
- readonly space?: number | string | undefined;
988
- }
989
- /**
990
- * The table's data rows as a JSON array of objects, one property per
991
- * column holding the cell's typed value — a number stays a number, a `Date`
992
- * becomes its ISO 8601 string. Group headers, summary rows and the footer
993
- * are left out: JSON is read by programs, which group and total for
994
- * themselves, and a row that is not data would only have to be filtered
995
- * out again.
996
- *
997
- * Returns a string; making a `Blob` of it, with the type
998
- * `application/json`, is the renderer's job.
999
- */
1000
- declare function toJson(table: ExportTable, options?: JsonOptions): string;
1001
-
1002
- /**
1003
- * How a grid exports unless a call says otherwise: which rows and columns
1004
- * (every `ExportOptions` field), what the file is called, and each built-in
1005
- * format's settings. The grid's `export` option.
1006
- */
1007
- interface GridExportOptions extends ExportOptions {
1008
- /**
1009
- * The file's name, without its extension — the writer's is added unless
1010
- * the name already ends with it. A function is asked per export with the
1011
- * format, `"csv"` or `"xlsx"`. Defaults to `"export"`.
1012
- */
1013
- readonly fileName?: string | ((format: string) => string) | undefined;
1014
- /**
1015
- * How the CSV writer writes. Its `locale`, which `delimiter: "auto"`
1016
- * reads, defaults to the grid's.
1017
- */
1018
- readonly csv?: CsvOptions | undefined;
1019
- /** How the JSON writer writes. */
1020
- readonly json?: JsonOptions | undefined;
1021
- }
1022
- /** What a writer is given beside the table: the grid's language and the export's settings. */
1023
- interface ExportWriteContext {
1024
- /** The grid's `locale`. */
1025
- readonly locale: FormatLocale;
1026
- /** The grid's messages, over the defaults. */
1027
- readonly messages: GridMessages;
1028
- /**
1029
- * The export's options, where a writer finds its own settings: the CSV
1030
- * writer reads `csv`, the JSON writer `json`. A writer of the app's own
1031
- * takes its settings when it is made instead, as a closure.
1032
- */
1033
- readonly options: GridExportOptions;
1034
- }
1035
- /**
1036
- * One export format: how to write an `ExportTable` as a file of it, and what
1037
- * the file is. CSV and JSON ship with the grid; any other — xlsx from
1038
- * `@gridkitjs/export-xlsx`, or one of the app's own — is registered through
1039
- * the grid's `exportWriters`.
1040
- *
1041
- * `write` returns the file's contents, not a file: text, bytes, or a promise
1042
- * of either for a writer that loads a library first. Making a `Blob` of it
1043
- * is the renderer's job.
1044
- */
1045
- interface ExportWriter {
1046
- /** The id the grid knows it by — `"csv"`, `"xlsx"`; one per grid. */
1047
- readonly format: string;
1048
- /** Without the dot: `"csv"`. */
1049
- readonly fileExtension: string;
1050
- /** The file's media type, the `Blob`'s `type`. */
1051
- readonly mimeType: string;
1052
- readonly write: (table: ExportTable, context: ExportWriteContext) => string | Uint8Array | Promise<string | Uint8Array>;
1053
- }
1054
- /** An export ready to save: what `exportFile` hands a renderer to download. */
1055
- interface ExportFile {
1056
- /** With its extension: `"export.csv"`. */
1057
- readonly fileName: string;
1058
- readonly mimeType: string;
1059
- readonly content: string | Uint8Array;
1060
- }
1061
- /** CSV through `toCsv`, its delimiter read for the grid's locale unless `csv.locale` says otherwise. */
1062
- declare const csvWriter: ExportWriter;
1063
- /** The data rows as JSON, through `toJson`. */
1064
- declare const jsonWriter: ExportWriter;
1065
- /**
1066
- * Every writer a grid can export with, by format: CSV and JSON, then
1067
- * `writers` — one with a built-in's format replacing it, as an app command
1068
- * replaces a built-in of the same id.
1069
- */
1070
- declare function resolveExportWriters(writers: readonly ExportWriter[] | undefined): ReadonlyMap<string, ExportWriter>;
1071
-
1072
- /**
1073
- * Where a command was asked for: the part of the grid a menu was opened on,
1074
- * the toolbar item pressed, or nowhere in particular for a call through a
1075
- * renderer's API. A built-in reads the column, row or group it acts on from
1076
- * here, and is hidden on a target that has none.
1077
- */
1078
- type GridCommandTarget = {
1079
- readonly area: "header";
1080
- readonly columnId: string;
1081
- } | {
1082
- readonly area: "cell";
1083
- readonly rowId: string;
1084
- readonly columnId: string;
1085
- } | {
1086
- readonly area: "group";
1087
- readonly groupId: string;
1088
- readonly columnId: string;
1089
- }
1090
- /** Empty body space, or a grid with no rows. */
1091
- | {
1092
- readonly area: "body";
1093
- } | {
1094
- readonly area: "toolbar";
1095
- readonly itemId: string;
1096
- }
1097
- /** A renderer's API, with no particular place. */
1098
- | {
1099
- readonly area: "grid";
1100
- };
1101
- /**
1102
- * Where a command was run from: a context menu, the toolbar, a renderer's
1103
- * API, or a column's filter menu — its sort entries and its "Clear filter".
1104
- */
1105
- type GridCommandSource = "contextMenu" | "toolbar" | "api" | "filterMenu";
1106
- /** What `onCommand` is told of a command, or an inline menu item, that ran. */
1107
- interface GridCommandEvent {
1108
- /** The command's id, or the inline item's. */
1109
- readonly commandId: string;
1110
- /** Where it was asked for. */
1111
- readonly target: GridCommandTarget;
1112
- readonly source: GridCommandSource;
1113
- }
1114
- /**
1115
- * The panels a command can ask a renderer to open: the column chooser, and
1116
- * a column's filter menu, which opens on a header target only.
1117
- */
1118
- type GridPanelKind = "columnChooser" | "filter";
1119
- /**
1120
- * What a command needs that only a renderer has: a DOM to measure, panels to
1121
- * open, a live region to speak through. A caller with none of these — a test,
1122
- * a script in Node — passes members that do nothing.
1123
- */
1124
- interface GridCommandHost {
1125
- /** Sizes each column to fit its content, as double-clicking its resize handle does. */
1126
- readonly autoFitColumns: (columnIds: readonly string[]) => void;
1127
- /** Opens one of the grid's panels, anchored to where the command was asked for. */
1128
- readonly openPanel: (kind: GridPanelKind, target: GridCommandTarget) => void;
1129
- /** Reads `text` out through the grid's live region. */
1130
- readonly announce: (text: string) => void;
1131
- /**
1132
- * Saves an export as a file — in a browser, a download. A promise is the
1133
- * file of a writer still writing; the host waits for it, and reports a
1134
- * rejected one rather than saving.
1135
- *
1136
- * Returns `false` for a file it drops without saving, as a host that saves
1137
- * one file at a time does with one asked for while it waits on the last.
1138
- * The export command that asked then did not run.
1139
- */
1140
- readonly saveFile: ((file: ExportFile | Promise<ExportFile>) => void) | ((file: ExportFile | Promise<ExportFile>) => boolean);
1141
- /**
1142
- * Puts a copy on the clipboard, as text and as HTML, and announces it —
1143
- * `count` and `unit` say what to announce — or that the browser refused.
1144
- */
1145
- readonly writeClipboard: (content: CopyContent) => void;
1146
- /**
1147
- * Puts a print document on paper — in a browser, through the print
1148
- * dialog. `options` are those it was built under, for what the host adds
1149
- * itself, such as `styles` over its print stylesheet.
1150
- */
1151
- readonly print: (document: PrintDocument, options: PrintOptions) => void;
1152
- }
1153
- /**
1154
- * Every action of the controller — the only way a command changes state, so
1155
- * each change reports through its slice's callback exactly as the user's own
1156
- * gesture would. Leaves out `setOptions`, which is the renderer's alone,
1157
- * `subscribe`, and the getters whose results the context already carries.
1158
- *
1159
- * Nothing left names the renderer's node type, so a controller of any `Node`
1160
- * is one.
1161
- */
1162
- type GridCommandActions<Row> = Omit<GridController<Row, unknown>, "getOptions" | "setOptions" | "subscribe" | "getState" | "getView">;
1163
- /**
1164
- * Everything a command reads to decide whether it shows, whether it is
1165
- * enabled and what it does — one snapshot of the grid, taken when a menu or
1166
- * toolbar is resolved. Build one with `createCommandContext`.
1167
- */
1168
- interface GridCommandContext<Row> {
1169
- readonly target: GridCommandTarget;
1170
- readonly state: GridState<Row>;
1171
- readonly view: GridView<Row, unknown>;
1172
- readonly options: GridOptions<Row>;
1173
- readonly messages: GridMessages;
1174
- readonly actions: GridCommandActions<Row>;
1175
- readonly host: GridCommandHost;
1176
- /** The row a cell target is on; `null` for any other target, or a row the filter hides. */
1177
- readonly row: ResolvedRow<Row> | null;
1178
- /** The column a header, cell or group target names, hidden or not; `null` otherwise. */
1179
- readonly column: DataColumn<Row, unknown> | null;
1180
- /**
1181
- * The selected rows that pass the filter, in the order they are shown,
1182
- * across every page and collapsed group. A function, computed on first
1183
- * call and remembered: resolving it walks every filtered row, and a toolbar
1184
- * builds a context on every change without most commands ever asking.
1185
- */
1186
- readonly selectedRows: () => readonly ResolvedRow<Row>[];
1187
- }
1188
- /**
1189
- * The one implementation behind a menu item, a toolbar button and a
1190
- * renderer's `runCommand`. Whether it shows and whether it is enabled are
1191
- * predicates over the context, asked each time a menu or toolbar is resolved,
1192
- * so a command follows the grid's state without being told about it.
1193
- */
1194
- interface GridCommand<Row> {
1195
- /** `"sort.ascending"` for a built-in, or any id of the app's own. Never `"separator"`, which a menu reads as one. */
1196
- readonly id: string;
1197
- readonly label: string | ((context: GridCommandContext<Row>) => string);
1198
- /** A key the renderer maps to an icon of its own; a key it does not know draws nothing. */
1199
- readonly icon?: string | undefined;
1200
- /** A key-combination hint in `aria-keyshortcuts` syntax, such as `"Alt+ArrowUp"`. Shown, not bound. */
1201
- readonly shortcut?: string | undefined;
1202
- /** Whether the command shows here at all. Defaults to always. */
1203
- readonly isVisible?: ((context: GridCommandContext<Row>) => boolean) | undefined;
1204
- /** Whether it can run. A disabled command still shows, so a user can see what is not possible. Defaults to always. */
1205
- readonly isEnabled?: ((context: GridCommandContext<Row>) => boolean) | undefined;
1206
- /** Present for a checkable command — drawn as a checkbox item or a toggle button — and says whether it is checked. */
1207
- readonly isChecked?: ((context: GridCommandContext<Row>) => boolean) | undefined;
1208
- /**
1209
- * Does what the command does. Returns `false` when it turns out to do
1210
- * nothing after all, such as an export the host dropped, so `runCommand`
1211
- * says it did not run and a renderer does not report it.
1212
- */
1213
- readonly execute: ((context: GridCommandContext<Row>) => void) | ((context: GridCommandContext<Row>) => boolean);
1214
- }
1215
-
1216
- /** The id of every command `builtInCommands` returns. */
1217
- type BuiltInCommandId = "sort.ascending" | "sort.descending" | "sort.clear" | "sort.clearAll" | "group.add" | "group.remove" | "group.clearAll" | "group.expandAll" | "group.collapseAll" | "column.hide" | "column.autoFit" | "column.autoFitAll" | "column.choose" | "filter.open" | "filter.clear" | "selection.selectAllRows" | "selection.clear" | "filter.clearAll" | "export.csv" | "export.json" | "export.xlsx" | "export.pdf" | "exportSelection.csv" | "exportSelection.json" | "exportSelection.xlsx" | "copy.cell" | "copy.row" | "copy.selection" | "print";
1218
- /**
1219
- * The icon keys the built-ins carry, which a renderer draws as icons of its
1220
- * own. An app command may use them too, to look like the built-ins.
1221
- */
1222
- type BuiltInCommandIcon = "sortAscending" | "sortDescending" | "group" | "hide" | "autoFit" | "copy" | "print";
1223
- /**
1224
- * The grid's own commands, one per action its menus and toolbar offer —
1225
- * sorting, grouping, hiding, fitting and choosing columns, selecting,
1226
- * clearing, exporting, copying and printing.
1227
- * Labels come from `messages`, so they follow the grid's language.
1228
- *
1229
- * A function rather than a constant so each comes typed for the caller's
1230
- * `Row`; the commands hold no state, and two calls build equal ones.
1231
- */
1232
- declare function builtInCommands<Row>(): readonly GridCommand<Row>[];
1233
-
1234
- /** A value given outright, or worked out from the context each time the menu is resolved. */
1235
- type FromContext<Row, Value> = Value | ((context: GridCommandContext<Row>) => Value);
1236
- /**
1237
- * An item written into the menu itself rather than registered as a command —
1238
- * for an action only one menu offers.
1239
- */
1240
- interface MenuItemEntry<Row> {
1241
- readonly type: "item";
1242
- readonly id: string;
1243
- readonly label: FromContext<Row, string>;
1244
- readonly icon?: string | undefined;
1245
- readonly shortcut?: string | undefined;
1246
- readonly hidden?: FromContext<Row, boolean> | undefined;
1247
- readonly disabled?: FromContext<Row, boolean> | undefined;
1248
- /** Present for a checkable item, and says whether it is checked. */
1249
- readonly checked?: FromContext<Row, boolean> | undefined;
1250
- readonly onSelect: (context: GridCommandContext<Row>) => void;
1251
- }
1252
- /** An item that opens a menu of its own. Left out when nothing in it shows. */
1253
- interface MenuSubmenuEntry<Row> {
1254
- readonly type: "submenu";
1255
- readonly id: string;
1256
- readonly label: FromContext<Row, string>;
1257
- readonly icon?: string | undefined;
1258
- readonly items: readonly MenuEntry<Row>[];
1259
- }
1260
- /**
1261
- * One entry of a menu as an app writes it: a command id — a built-in's or
1262
- * one of its own — `"separator"`, an inline item or a submenu. The same
1263
- * vocabulary every menu and toolbar is listed in.
1264
- */
1265
- type MenuEntry<Row> = BuiltInCommandId | "separator" | (string & {}) | MenuItemEntry<Row> | MenuSubmenuEntry<Row>;
1266
- /**
1267
- * A menu item ready to draw: every label a string, every flag a boolean, and
1268
- * `run` bound to the context the menu was resolved in.
1269
- */
1270
- interface ResolvedMenuItem {
1271
- readonly type: "item";
1272
- /** The command's id, or the inline item's. */
1273
- readonly id: string;
1274
- readonly label: string;
1275
- readonly icon?: string | undefined;
1276
- readonly shortcut?: string | undefined;
1277
- /** Drawn, and focusable, but `run` does nothing. */
1278
- readonly disabled: boolean;
1279
- /** `undefined` for an item that is not checkable. */
1280
- readonly checked: boolean | undefined;
1281
- /**
1282
- * Runs the item — a command only when it is still visible and enabled —
1283
- * and says whether it ran, so a renderer reports only what did something.
1284
- */
1285
- readonly run: () => boolean;
1286
- }
1287
- interface ResolvedMenuSubmenu {
1288
- readonly type: "submenu";
1289
- readonly id: string;
1290
- readonly label: string;
1291
- readonly icon?: string | undefined;
1292
- /** Never empty: a submenu with nothing to show is left out. */
1293
- readonly items: readonly ResolvedMenuEntry[];
1294
- }
1295
- interface ResolvedMenuSeparator {
1296
- readonly type: "separator";
1297
- /**
1298
- * The separator's place among the entries it was resolved from, which
1299
- * stays put however the items around it come and go — a key for a
1300
- * renderer that needs one, unique among its menu's separators.
1301
- */
1302
- readonly key: string;
1303
- }
1304
- /** One entry of a menu as `resolveMenu` hands it to a renderer to draw. */
1305
- type ResolvedMenuEntry = ResolvedMenuItem | ResolvedMenuSubmenu | ResolvedMenuSeparator;
1306
-
1307
- /** The parts of a grid that open a context menu of their own. */
1308
- type GridContextMenuArea = "header" | "cell" | "group" | "body";
1309
- /**
1310
- * Where a context menu opens: a command target in one of the context menu
1311
- * areas — a column header, a data cell, a group header row, or empty space
1312
- * in the body — or in `Area` alone.
1313
- */
1314
- type GridContextMenuTarget<Area extends GridContextMenuArea = GridContextMenuArea> = Extract<GridCommandTarget, {
1315
- readonly area: Area;
1316
- }>;
1317
- /** What `onContextMenuOpenChange` is told as a context menu opens or closes. */
1318
- interface ContextMenuOpenChangeEvent {
1319
- readonly open: boolean;
1320
- /** Where the menu opened, or where the one closing had. */
1321
- readonly target: GridContextMenuTarget;
1322
- }
1323
- /** What a function given for an area is asked, each time its menu opens. */
1324
- interface GridContextMenuRequest<Row, Area extends GridContextMenuArea = GridContextMenuArea> {
1325
- /** Where the menu opens. */
1326
- readonly target: GridContextMenuTarget<Area>;
1327
- /** The area's default entries, to keep, trim, reorder or add to. */
1328
- readonly defaults: readonly MenuEntry<Row>[];
1329
- /** The grid as the menu sees it — the context its items run in. */
1330
- readonly context: GridCommandContext<Row>;
1331
- }
1332
- /**
1333
- * An area's menu: its entries, or a function that works them out each time
1334
- * the menu opens — from where it opens, the area's defaults and the grid's
1335
- * state. A function giving `null` or `[]` shows no grid menu there, so the
1336
- * browser's own menu shows.
1337
- */
1338
- type GridContextMenuEntries<Row, Area extends GridContextMenuArea = GridContextMenuArea> = readonly MenuEntry<Row>[] | ((request: GridContextMenuRequest<Row, Area>) => readonly MenuEntry<Row>[] | null);
1339
- /**
1340
- * A grid's context menus, by area, in the vocabulary every grid menu is
1341
- * written in. An area left out shows its defaults; one given `[]` shows no
1342
- * grid menu, so the browser's own menu shows there.
1343
- */
1344
- interface GridContextMenuOptions<Row> {
1345
- /** A column header's menu. */
1346
- readonly header?: GridContextMenuEntries<Row, "header"> | undefined;
1347
- /** A data cell's menu, acting on its row and cell. */
1348
- readonly cell?: GridContextMenuEntries<Row, "cell"> | undefined;
1349
- /** A group header row's menu. */
1350
- readonly group?: GridContextMenuEntries<Row, "group"> | undefined;
1351
- /** The menu of the body's empty space, below the last row or in a grid with none. */
1352
- readonly body?: GridContextMenuEntries<Row, "body"> | undefined;
1353
- }
1354
- /**
1355
- * The menu each area shows unless the grid says otherwise — built-in
1356
- * commands only, each hidden where it has nothing to act on, so the menu a
1357
- * column header shows holds only what that column can do. The body has
1358
- * none: empty space keeps the browser's menu until a grid gives it one.
1359
- */
1360
- declare const defaultContextMenu: {
1361
- readonly [Area in GridContextMenuArea]: readonly (BuiltInCommandId | "separator")[];
1362
- };
1363
- /**
1364
- * Whether the `contextMenu` option opens a grid menu on `area` at all: it is
1365
- * on, and gives the area entries or a function rather than `[]`. A function
1366
- * may still give no menu for one place or another; this answers for the
1367
- * area, as a cell's `aria-keyshortcuts` needs to before anything is asked.
1368
- */
1369
- declare function hasContextMenu<Row>(contextMenu: boolean | GridContextMenuOptions<Row> | undefined, area: GridContextMenuArea): boolean;
1370
- /**
1371
- * The entries a grid's `contextMenu` option gives the place `context.target`
1372
- * names, to resolve with `resolveMenu` in that same context: none while the
1373
- * option is off — left out or `false` — or for a target no context menu
1374
- * opens on; the area's defaults under `true` or when the option leaves the
1375
- * area out; the entries it lists; or what its function gives this request.
1376
- * No entries means no grid menu there.
1377
- */
1378
- declare function contextMenuEntries<Row>(contextMenu: boolean | GridContextMenuOptions<Row> | undefined, context: GridCommandContext<Row>): readonly MenuEntry<Row>[];
1379
-
1380
- /** Where a toolbar item's command runs: the toolbar item it was asked from. */
1381
- type GridToolbarTarget = Extract<GridCommandTarget, {
1382
- readonly area: "toolbar";
1383
- }>;
1384
- /**
1385
- * A place in the toolbar the renderer fills with content of the app's own —
1386
- * React's `renderToolbarItem(id)` — for anything the entries cannot say.
1387
- */
1388
- interface ToolbarCustomEntry {
1389
- readonly type: "custom";
1390
- readonly id: string;
1391
- }
1392
- /**
1393
- * One entry of a toolbar as an app writes it: anything a menu lists — a
1394
- * command id, `"separator"`, an inline item, or a submenu, which the toolbar
1395
- * draws as a dropdown button — plus the entries only a toolbar has:
1396
- * `"search"`, the box searching every column; `"spacer"`, which takes up the
1397
- * free space and so pushes what follows it to the far end; `"export"`, a
1398
- * dropdown of the export commands that show; and a custom entry.
1399
- */
1400
- type ToolbarEntry<Row> = MenuEntry<Row> | "search" | "spacer" | "export" | ToolbarCustomEntry;
1401
- /**
1402
- * Attributes of the app's own for a toolbar entry's element, as hooks for
1403
- * its tests, analytics or styles: an `id` and `data-*` attributes, nothing
1404
- * that could change what the entry means or does.
1405
- */
1406
- interface ToolbarItemAttributes {
1407
- readonly id?: string | undefined;
1408
- readonly [name: `data-${string}`]: string;
1409
- }
1410
- /**
1411
- * A toolbar button ready to draw — a command, or an inline item — with
1412
- * every label a string, every flag a boolean, and `run` bound to the
1413
- * context of its place in the toolbar.
1414
- */
1415
- interface ResolvedToolbarButton {
1416
- readonly type: "button";
1417
- /** The command's id, or the inline item's. */
1418
- readonly id: string;
1419
- /** The same as `id`. */
1420
- readonly key: string;
1421
- readonly label: string;
1422
- readonly icon?: string | undefined;
1423
- readonly shortcut?: string | undefined;
1424
- /** Drawn, and focusable, but `run` does nothing. */
1425
- readonly disabled: boolean;
1426
- /**
1427
- * Whether a toggle button is pressed — `undefined` for a button that is
1428
- * not one: a checkable command or item draws as a toggle.
1429
- */
1430
- readonly pressed: boolean | undefined;
1431
- /** Runs the button, and says whether it ran — see `ResolvedMenuItem.run`. */
1432
- readonly run: () => boolean;
1433
- /** The app's attributes for its element, from `itemAttributes`. */
1434
- readonly attributes?: ToolbarItemAttributes | undefined;
1435
- }
1436
- /** A dropdown button, opening the menu its submenu entry lists. */
1437
- interface ResolvedToolbarMenu {
1438
- readonly type: "menu";
1439
- readonly id: string;
1440
- /** The same as `id`. */
1441
- readonly key: string;
1442
- readonly label: string;
1443
- readonly icon?: string | undefined;
1444
- /** Never empty: a dropdown with nothing to show is left out. */
1445
- readonly items: readonly ResolvedMenuEntry[];
1446
- /** The app's attributes for its element, from `itemAttributes`. */
1447
- readonly attributes?: ToolbarItemAttributes | undefined;
1448
- }
1449
- /** The search box, over the grid's global text filter. */
1450
- interface ResolvedToolbarSearch {
1451
- readonly type: "search";
1452
- /** Always `"search"`. */
1453
- readonly key: string;
1454
- /** The app's attributes for its element, from `itemAttributes`. */
1455
- readonly attributes?: ToolbarItemAttributes | undefined;
1456
- }
1457
- /** The free space between the entries either side of it. */
1458
- interface ResolvedToolbarSpacer {
1459
- readonly type: "spacer";
1460
- /** `spacer-<index>`, from its place among the entries it was resolved from. */
1461
- readonly key: string;
1462
- }
1463
- /** A custom entry's place, for the renderer to fill. */
1464
- interface ResolvedToolbarCustom {
1465
- readonly type: "custom";
1466
- readonly id: string;
1467
- /** The same as `id`. */
1468
- readonly key: string;
1469
- /** The app's attributes for its element, from `itemAttributes`. */
1470
- readonly attributes?: ToolbarItemAttributes | undefined;
1471
- }
1472
- /**
1473
- * One entry of a toolbar as `resolveToolbar` hands it to a renderer to draw.
1474
- * Each has a `key` — an item's id, `"search"`, or a separator's or spacer's
1475
- * place among the entries — unique among the toolbar's entries, which the
1476
- * renderer writes into the entry's `data-gridkit-toolbar-item`.
1477
- */
1478
- type ResolvedToolbarItem = ResolvedToolbarButton | ResolvedToolbarMenu | ResolvedToolbarSearch | ResolvedToolbarSpacer | ResolvedMenuSeparator | ResolvedToolbarCustom;
1479
-
1480
- /**
1481
- * A grid's toolbar: what it lists, what a screen reader calls it, and the
1482
- * attributes of the app's own its entries' elements carry.
1483
- */
1484
- interface GridToolbarOptions<Row> {
1485
- /** The toolbar's entries, in order. Left out, the defaults. */
1486
- readonly items?: readonly ToolbarEntry<Row>[] | undefined;
1487
- /** The toolbar's accessible name. Left out, `messages.toolbarLabel`. */
1488
- readonly label?: string | undefined;
1489
- /**
1490
- * Attributes for entries' elements, by the entry's key: a command's,
1491
- * inline item's, dropdown's or custom entry's id, `"search"` or
1492
- * `"export"`. A key naming no entry, or a separator or spacer, is ignored.
1493
- */
1494
- readonly itemAttributes?: Readonly<Record<string, ToolbarItemAttributes>> | undefined;
1495
- }
1496
- /**
1497
- * What a toolbar lists unless the grid says otherwise: the search box, then
1498
- * the free space, then "Clear filters" and "Choose columns" at the far end.
1499
- */
1500
- declare const defaultToolbar: readonly (BuiltInCommandId | "search" | "spacer")[];
1501
- /**
1502
- * The entries a grid's `toolbar` option lists, to resolve with
1503
- * `resolveToolbar`: none while it is off — left out or `false` — the
1504
- * defaults under `true` or an object without `items`, else its `items`.
1505
- * No entries means no toolbar.
1506
- */
1507
- declare function toolbarEntries<Row>(toolbar: boolean | GridToolbarOptions<Row> | undefined): readonly ToolbarEntry<Row>[];
1508
-
1509
- /** Which cell borders a grid draws. */
1510
- type Borders = "horizontal" | "vertical" | "all" | "none";
1511
- /** Which hover highlighting a grid shows. Every member defaults to on. */
1512
- interface HoverableConfig {
1513
- rows?: boolean;
1514
- columns?: boolean;
1515
- cells?: boolean;
1516
- }
1517
- /**
1518
- * How the group-by bar's visibility follows the active grouping. `"always"`
1519
- * renders it even with an empty `groupBy` — a fixed drop target and a
1520
- * constant reminder grouping exists. `"never"` never renders it, for a grid
1521
- * driving `groupBy` entirely by its own UI (a header toggle, `Alt+ArrowDown`)
1522
- * or programmatically. `"auto"` renders it once `groupBy` is non-empty, or
1523
- * while a header drag eligible to drop into it is in progress — so there is
1524
- * always somewhere to drop the very first column, even from a fully empty
1525
- * grouping.
1526
- */
1527
- type GroupByBarVisibility = "always" | "auto" | "never";
1528
- /**
1529
- * What `getRowProps` adds to a data row: a class for the theme or the
1530
- * app's own stylesheet to target, and `data-*` attributes for a test or a
1531
- * script to find the row by. No inline style — styling belongs to the
1532
- * stylesheet, which a class already reaches.
1533
- */
1534
- interface RowProps {
1535
- className?: string | undefined;
1536
- /**
1537
- * Set on the row alongside the grid's own `data-gridkit-*` attributes,
1538
- * which win over one of the same name — the grid finds its rows by them.
1539
- */
1540
- attributes?: Readonly<Record<`data-${string}`, string>> | undefined;
1541
- }
1542
- /**
1543
- * Every setting of a grid that names no renderer's types: the data, what the
1544
- * user may do with it, the state it starts in and the callbacks that report
1545
- * changes. A renderer's own props are this plus what only it can express —
1546
- * React's `columns` (whose templates return `ReactNode`), its pager and
1547
- * infinite-scroll templates, its `ref` — so two renderers cannot drift apart
1548
- * on what a setting is called or what it means.
1549
- */
1550
- interface GridOptions<Row> {
1551
- dataSource?: readonly Row[] | undefined;
1552
- /**
1553
- * A row's stable identity, for state keyed by it. Defaults to the row's
1554
- * position, which is enough for a static grid but ties that state to where a
1555
- * row sits rather than to the row — so anything sorting, filtering or paging
1556
- * its data should give one.
1557
- *
1558
- * Called for every row on every change to `dataSource`, so it should be
1559
- * cheap and stable; an inline arrow is fine, one that re-reads the data is
1560
- * not.
1561
- */
1562
- getRowId?: ((row: Row, index: number) => string) | undefined;
1563
- /**
1564
- * A class and `data-*` attributes for each data row, worked out from the
1565
- * row — an `is-overdue` class, a `data-status` to style or find it by.
1566
- * Group headers and summary rows are not passed to it.
1567
- *
1568
- * Called for each data row as it renders, so it should be cheap. A row
1569
- * whose result reads the same as last time is not redrawn for it, so an
1570
- * inline arrow returning a fresh object each time is fine.
1571
- */
1572
- getRowProps?: ((row: ResolvedRow<Row>) => RowProps) | undefined;
1573
- /**
1574
- * Called when a data row is clicked, after the click has changed the
1575
- * selection — so a handler reading the selection sees the new one. Not
1576
- * called for a group header, whose click expands or collapses it.
1577
- */
1578
- onRowClick?: ((event: RowPointerEvent<Row>) => void) | undefined;
1579
- /**
1580
- * Called once when a data row is double-clicked — the usual "open this
1581
- * record" gesture. The two clicks before it still report through
1582
- * `onRowClick` and select as clicks do.
1583
- */
1584
- onRowDoubleClick?: ((event: RowPointerEvent<Row>) => void) | undefined;
1585
- borders?: Borders | undefined;
1586
- hoverable?: HoverableConfig | undefined;
1587
- /**
1588
- * Which parts of the grid the user may select, and how many of each —
1589
- * `{ rows: "multiple", cells: "single" }`. A cell addresses one value, so it
1590
- * has no `"multiple"`.
1591
- *
1592
- * Off by default, unlike `hoverable`: selection claims the click, which a
1593
- * grid that only displays data should not do. Give `getRowId` alongside it
1594
- * for data that sorts, filters or pages, or a selection follows the position
1595
- * rather than the row.
1596
- */
1597
- selectable?: SelectableConfig | undefined;
1598
- /** Row ids selected to start with, keyed as `getRowId` resolves them. Uncontrolled. */
1599
- defaultRowSelection?: SelectionState | undefined;
1600
- /**
1601
- * The selected row ids, controlled — applied as given, changed only through
1602
- * the row selection callbacks (`onRowSelectionChange` carries the whole
1603
- * next state). Leave it `undefined` for the grid to keep it itself,
1604
- * starting from `defaultRowSelection`.
1605
- */
1606
- rowSelection?: SelectionState | undefined;
1607
- /** Column ids selected to start with. Uncontrolled. */
1608
- defaultColumnSelection?: SelectionState | undefined;
1609
- /**
1610
- * The selected column ids, controlled — changed only through the column
1611
- * selection callbacks. Leave it `undefined` for the grid to keep it.
1612
- */
1613
- columnSelection?: SelectionState | undefined;
1614
- /** The cell selected to start with. Uncontrolled. */
1615
- defaultCellSelection?: CellSelectionState | undefined;
1616
- /**
1617
- * The selected cell, controlled — `null` for none, changed only through
1618
- * the cell selection callbacks. Leave it `undefined` for the grid to keep
1619
- * it.
1620
- */
1621
- cellSelection?: CellSelectionState | undefined;
1622
- /** Whether columns can be dragged wider, unless a column says otherwise. */
1623
- resizableColumns?: boolean | undefined;
1624
- /**
1625
- * Whether columns can be dragged into a new position, unless a column says
1626
- * otherwise. Turning it off leaves an order the user already made in place.
1627
- */
1628
- reorderableColumns?: boolean | undefined;
1629
- /**
1630
- * Whether columns fill the grid's width or sit at their own. Defaults to
1631
- * `"fit"`, under which columns the user has sized keep their width and the
1632
- * rest share what is left.
1633
- */
1634
- resizeMode?: ResizeMode | undefined;
1635
- /** Column widths to start from, keyed by column id. Uncontrolled. */
1636
- defaultColumnSizing?: ColumnSizingState | undefined;
1637
- /**
1638
- * Column widths, controlled — applied as given, changed only through
1639
- * `onColumnResize`, whose `sizing` is the next state. Leave it
1640
- * `undefined` for the grid to keep the widths itself, starting from
1641
- * `defaultColumnSizing`.
1642
- */
1643
- columnSizing?: ColumnSizingState | undefined;
1644
- /**
1645
- * Column ids in the order to start in. Uncontrolled, and partial: ids it
1646
- * omits keep their position among `columns` and follow those it lists.
1647
- */
1648
- defaultColumnOrder?: ColumnOrderState | undefined;
1649
- /**
1650
- * The column order, controlled — applied as given, changed only through
1651
- * `onColumnOrderChange`. Leave it `undefined` for the grid to keep the
1652
- * order itself, starting from `defaultColumnOrder`.
1653
- */
1654
- columnOrder?: ColumnOrderState | undefined;
1655
- /**
1656
- * Columns shown (`true`) or hidden (`false`) to start with, keyed by
1657
- * column id, over each definition's own `hidden`. Uncontrolled.
1658
- */
1659
- defaultColumnVisibility?: ColumnVisibilityState | undefined;
1660
- /**
1661
- * Which columns are shown, controlled — applied as given, changed only
1662
- * through `onColumnVisibilityChange`. Leave it `undefined` for the grid to
1663
- * keep it itself, starting from `defaultColumnVisibility`.
1664
- */
1665
- columnVisibility?: ColumnVisibilityState | undefined;
1666
- /**
1667
- * Called once when columns are shown or hidden, with every column that one
1668
- * change touched. A call that changes nothing does not call it.
1669
- */
1670
- onColumnVisibilityChange?: ((event: ColumnVisibilityEvent) => void) | undefined;
1671
- /**
1672
- * Sizes applied to columns that do not set their own — the width they start
1673
- * at and the bounds they may be resized between. Distinct from
1674
- * `defaultColumnSizing`, which sets specific columns' starting widths.
1675
- */
1676
- columnSizeDefaults?: Partial<ColumnSizeDefaults> | undefined;
1677
- /**
1678
- * Called as the user resizes a column. Fires continuously with
1679
- * `phase: "move"` and once on release with `phase: "end"` — the latter being
1680
- * the one to persist. Auto-fitting a column calls it once, with "end".
1681
- */
1682
- onColumnResize?: ((event: ColumnResizeEvent) => void) | undefined;
1683
- /**
1684
- * Called once when the user drops a column somewhere new. A drop that leaves
1685
- * the order as it was does not call it.
1686
- */
1687
- onColumnOrderChange?: ((event: ColumnOrderEvent) => void) | undefined;
1688
- /**
1689
- * Whether columns can be sorted by clicking their header toggle, unless a
1690
- * column says otherwise. Shift-click stacks a column into the sort instead
1691
- * of replacing it.
1692
- */
1693
- sortableColumns?: boolean | undefined;
1694
- /** The sort to start with, in priority order. Uncontrolled. */
1695
- defaultColumnSort?: ColumnSortState | undefined;
1696
- /**
1697
- * The sort, controlled: the grid shows exactly this, and a header click
1698
- * only asks for a change through `onColumnSortChange`, which takes effect
1699
- * once this prop follows it. Leave it `undefined` for the grid to keep the
1700
- * sort itself, starting from `defaultColumnSort`.
1701
- */
1702
- columnSort?: ColumnSortState | undefined;
1703
- /**
1704
- * Called once when the user changes the sort — a toggle, a stack, or a
1705
- * clear back to "none".
1706
- */
1707
- onColumnSortChange?: ((event: ColumnSortEvent) => void) | undefined;
1708
- /**
1709
- * Whether columns can be grouped by — a header's click/`Alt+ArrowDown`
1710
- * toggle — unless a column says otherwise. The grouping itself still
1711
- * applies when this is off, via `defaultGroupBy` or the imperative API;
1712
- * this only gates that one interaction, the same way `sortableColumns`
1713
- * gates the sort toggle without disabling `defaultColumnSort`. Independent
1714
- * of `groupByBarVisibility` and `groupByDraggableColumns`, which gate the
1715
- * bar and the drag-in gesture respectively.
1716
- */
1717
- groupableColumns?: boolean | undefined;
1718
- /**
1719
- * Whether a groupable header shows its group-toggle icon, unless a column
1720
- * says otherwise. Purely a rendering choice: `Alt+ArrowDown` keeps working
1721
- * on a groupable header with the icon hidden.
1722
- */
1723
- groupToggleIconColumns?: boolean | undefined;
1724
- /**
1725
- * Whether a column's header may be dragged into the group-by bar to add
1726
- * it to the grouping, unless a column says otherwise. Independent of
1727
- * `groupableColumns`: a column can be groupable via its header's
1728
- * click/keyboard toggle, via this drag, both, or neither.
1729
- */
1730
- groupByDraggableColumns?: boolean | undefined;
1731
- /** How the group-by bar's visibility follows the active grouping. */
1732
- groupByBarVisibility?: GroupByBarVisibility | undefined;
1733
- /** The group-by stack to start with, outer to inner. Uncontrolled. */
1734
- defaultGroupBy?: GroupByState | undefined;
1735
- /**
1736
- * The group-by stack, controlled — applied as given, changed only through
1737
- * `onGroupByChange`. Leave it `undefined` for the grid to keep it itself,
1738
- * starting from `defaultGroupBy`.
1739
- */
1740
- groupBy?: GroupByState | undefined;
1741
- /**
1742
- * Called once when the user changes the group-by stack — adding, removing,
1743
- * or reordering a level.
1744
- */
1745
- onGroupByChange?: ((event: GroupByEvent) => void) | undefined;
1746
- /** Group keys collapsed to start with — every other group starts expanded. Uncontrolled. */
1747
- defaultGroupExpansion?: GroupExpansionState | undefined;
1748
- /**
1749
- * The collapsed groups, controlled — applied as given, changed only
1750
- * through `onGroupExpansionChange`. Leave it `undefined` for the grid to
1751
- * keep it itself, starting from `defaultGroupExpansion`.
1752
- */
1753
- groupExpansion?: GroupExpansionState | undefined;
1754
- /** Called once when the user expands or collapses a group, or every group at once. */
1755
- onGroupExpansionChange?: ((event: GroupExpansionEvent) => void) | undefined;
1756
- /** The filter to start with — every applied entry, ANDed together. Uncontrolled. */
1757
- defaultFilter?: FilterState<Row> | undefined;
1758
- /**
1759
- * The filter, controlled — applied as given, changed only through
1760
- * `onFilterChange`. Leave it `undefined` for the grid to keep it itself,
1761
- * starting from `defaultFilter`.
1762
- */
1763
- filter?: FilterState<Row> | undefined;
1764
- /**
1765
- * Called once when the filter changes — from the toolbar's search box, the
1766
- * `filter.clearAll` command, `setFilter` or a restored state.
1767
- */
1768
- onFilterChange?: ((event: FilterChangeEvent<Row>) => void) | undefined;
1769
- /**
1770
- * Whether columns get a filter menu, opened from their header, unless a
1771
- * column says otherwise. Off by default, like `sortableColumns`; the
1772
- * filter itself applies either way, from `defaultFilter`, `setFilter` or a
1773
- * search box. A renderer draws the menu from what
1774
- * `resolveColumnFilterMenu` settles.
1775
- */
1776
- filterableColumns?: boolean | undefined;
1777
- /**
1778
- * How the filter menus look: which editor they open — `"simple"`
1779
- * conditions or an `"excel"` checklist — and the checklist's counts and
1780
- * value limit. A column's own `filterMenu` wins over it. Switching `ui`
1781
- * keeps every filter, since both editors edit the one `filter`.
1782
- */
1783
- filterMenu?: GridFilterMenuOptions | undefined;
1784
- /**
1785
- * Whether the grid's rows are split into pages. Off by default, matching
1786
- * `sortableColumns`. What a page's `pageSize` counts once the rows are
1787
- * grouped is `paginationUnit`'s choice.
1788
- */
1789
- paginated?: boolean | undefined;
1790
- /**
1791
- * What `pageSize` counts in a grouped grid. `"group"` (the default) counts
1792
- * top-level groups, each with everything beneath it, so a page never
1793
- * splits a group but can grow as large as its groups. `"row"` counts data
1794
- * rows, plus collapsed group headers, which stand in for their hidden
1795
- * rows: every page holds `pageSize` of them, and a page continuing a group
1796
- * starts with that group's headers again, with a group's summary row on
1797
- * the page holding its last row. An ungrouped grid pages by data rows
1798
- * under either. Selection, export and aggregates behave the same under
1799
- * either unit.
1800
- */
1801
- paginationUnit?: PaginationUnit | undefined;
1802
- /**
1803
- * The page and page size to start on. Uncontrolled. Defaults to
1804
- * `{ pageIndex: 0, pageSize: 25 }` when `paginated` is on and this is
1805
- * omitted.
1806
- */
1807
- defaultPagination?: PaginationState | undefined;
1808
- /**
1809
- * The page and page size, controlled — applied as given, changed only
1810
- * through `onPaginationChange`. Leave it `undefined` for the grid to keep
1811
- * them itself, starting from `defaultPagination`.
1812
- *
1813
- * The grid sends an uncontrolled pagination back to the first page when
1814
- * the filter, sort, grouping or `paginationUnit` changes; a controlled
1815
- * one is the parent's to reset alongside that change. Until it does, the
1816
- * grid shows the last page that exists rather than an empty one.
1817
- */
1818
- pagination?: PaginationState | undefined;
1819
- /** Called once when the user changes the page or the page size. */
1820
- onPaginationChange?: ((event: PaginationChangeEvent) => void) | undefined;
1821
- /**
1822
- * Aggregates to compute — a subtotal per group (rendered in that group's
1823
- * header) plus a grand total over the whole filtered/grouped dataset
1824
- * (rendered in a footer). Always computed over every row, never scoped to
1825
- * the current page. A plain controlled prop, unlike `sort`/`filter`/
1826
- * `groupBy`/`pagination`: there is no built-in UI for a user to add or
1827
- * remove an aggregate interactively, so there is no `defaultAggregates`/
1828
- * `onAggregatesChange` pair to go with it.
1829
- */
1830
- aggregates?: AggregateState<Row> | undefined;
1831
- /**
1832
- * Where a group's own aggregate results render. `"inline"` (the default)
1833
- * keeps them as text in the group header, next to its leaf-row count.
1834
- * `"row"` instead renders a dedicated row after that group's last visible
1835
- * entry, with each aggregate's value in the `<td>` for its own column —
1836
- * the same alignment the grand-total footer's own cells have. Has no
1837
- * effect when `aggregates` is empty or omitted.
1838
- */
1839
- groupAggregateDisplay?: GroupAggregateDisplay | undefined;
1840
- /**
1841
- * Bounds the row area's height, independently scrollable — the grid's own
1842
- * chrome (group-by bar, header, footer, pager) stays outside it and
1843
- * always visible. A number is pixels; a string is passed through as a CSS
1844
- * length (e.g. "60vh"). Omitted, the body's height stays content-driven,
1845
- * same as today.
1846
- */
1847
- height?: number | string | undefined;
1848
- /**
1849
- * Renders only the rows near the current scroll position rather than every
1850
- * row at once — for a dataset too large to mount in full. Requires
1851
- * `height` to be set; a grid without a bounded body has no viewport to
1852
- * window rows against (a dev-time console warning fires when it's
1853
- * missing). Off by default, matching every other opt-in behavior here.
1854
- */
1855
- virtualized?: boolean | undefined;
1856
- /**
1857
- * Rows rendered outside the visible range on each side, to reduce
1858
- * blank-frame flashes on fast scrolling. Only meaningful with `virtualized`
1859
- * on.
1860
- */
1861
- overscan?: number | undefined;
1862
- /**
1863
- * Assumed height for a row never yet measured — only matters for the very
1864
- * first paint and for `scrollToRow`'s initial jump before it corrects
1865
- * itself against that row's real, measured height. Only meaningful with
1866
- * `virtualized` on.
1867
- */
1868
- estimatedRowHeight?: number | undefined;
1869
- /**
1870
- * The grid's accessible name, announced when it takes focus. A grid without
1871
- * one is read only as "grid", which says nothing about which grid.
1872
- */
1873
- label?: string | undefined;
1874
- /**
1875
- * The id of an element naming the grid, for a heading already on the page.
1876
- * Takes precedence over `label`, as `aria-labelledby` does.
1877
- */
1878
- labelledBy?: string | undefined;
1879
- /**
1880
- * The locale values are formatted for — a BCP 47 tag such as `"de-DE"`, or
1881
- * a list to fall back through. Setting it turns on `Intl` formatting of
1882
- * dates and numbers in every cell and aggregate shown without a template;
1883
- * without it, only a column with its own `format` is formatted, in the
1884
- * runtime's locale, and the rest print as they always have.
1885
- */
1886
- locale?: FormatLocale;
1887
- /**
1888
- * The grid's own strings, replacing its English key by key — the pager's
1889
- * buttons, the group-by bar, the loading row, boolean and blank values,
1890
- * the built-in commands' labels, the menus' names, and every live-region
1891
- * announcement. Keys
1892
- * left out keep their default.
1893
- * Formatting is `locale`'s, not this.
1894
- */
1895
- messages?: Partial<GridMessages> | undefined;
1896
- /**
1897
- * The grid's own context menu, opened on a column header, a data cell, a
1898
- * group row or the body's empty space by a right-click, Shift+F10 or the
1899
- * ContextMenu key. Off by default, like every other feature, leaving the
1900
- * browser's menu. `true` shows each area's defaults — see
1901
- * `defaultContextMenu`; an object lists an area's entries, an area left
1902
- * out keeping its defaults and one given `[]` showing the browser's menu
1903
- * there.
1904
- */
1905
- contextMenu?: boolean | GridContextMenuOptions<Row> | undefined;
1906
- /**
1907
- * Called when the grid's context menu opens or closes, with where. A menu
1908
- * opened in place of another reports that one closing first. The open
1909
- * state is the renderer's to keep, so no option holds it.
1910
- */
1911
- onContextMenuOpenChange?: ((event: ContextMenuOpenChangeEvent) => void) | undefined;
1912
- /**
1913
- * The app's own commands, for its menus to list by id. One with a
1914
- * built-in's id replaces it wherever that id is listed — a translated,
1915
- * privilege-gated or differently behaving "Hide column" — see
1916
- * `resolveCommands`.
1917
- */
1918
- commands?: readonly GridCommand<Row>[] | undefined;
1919
- /**
1920
- * Called after a command or an inline menu item runs — chosen from a menu,
1921
- * or run through a renderer's API — saying which, where it was asked for
1922
- * and from where. One that did not run, being hidden or disabled, is not
1923
- * reported.
1924
- */
1925
- onCommand?: ((event: GridCommandEvent) => void) | undefined;
1926
- /**
1927
- * A toolbar above the grid: its own commands, a search box over the
1928
- * filter's global text entry, dropdowns and the app's own content, in the
1929
- * menu vocabulary. Off by default. `true` lists `defaultToolbar`; an object
1930
- * lists its `items` and may name it with `label` — see `ToolbarEntry`.
1931
- */
1932
- toolbar?: boolean | GridToolbarOptions<Row> | undefined;
1933
- /**
1934
- * How the grid exports unless a call says otherwise: which rows and
1935
- * columns, the file's name, and the CSV and JSON settings. Left out, an
1936
- * export holds what the user sees, across every page, in a file named
1937
- * `export` with the format's extension.
1938
- */
1939
- export?: GridExportOptions | undefined;
1940
- /**
1941
- * Export formats beyond CSV and JSON — an xlsx writer, or one of the
1942
- * app's own — each registered by its `format`, replacing a built-in
1943
- * writer of the same format. `export.xlsx` and `export.pdf` show only
1944
- * once a writer for their format is here — see `resolveExportWriters`.
1945
- */
1946
- exportWriters?: readonly ExportWriter[] | undefined;
1947
- /**
1948
- * How the grid prints unless a call says otherwise: the rows and columns,
1949
- * the title and text around the table, and the page. Left out, a print
1950
- * holds what an export does, titled with `label`, on an A4 page.
1951
- */
1952
- print?: PrintOptions | undefined;
1953
- }
1954
- /**
1955
- * Reported as the user selects. Every one of these is fanned out from a single
1956
- * diff of the transition it describes, so no two can disagree about what one
1957
- * interaction did.
1958
- *
1959
- * Kept apart from `GridOptions` because the column payloads carry resolved
1960
- * columns, whose labels are whatever a renderer's `headerTemplate` returns —
1961
- * `Node` is that renderer's node type.
1962
- */
1963
- interface SelectionCallbacks<Row, Node = string> {
1964
- /** Called once per row newly selected. The last call names the last row. */
1965
- onRowSelect?: ((event: RowSelectEvent<Row>) => void) | undefined;
1966
- /** Called once with every row one interaction selected. */
1967
- onRowsSelect?: ((event: RowsSelectEvent<Row>) => void) | undefined;
1968
- onRowDeselect?: ((event: RowSelectEvent<Row>) => void) | undefined;
1969
- onRowsDeselect?: ((event: RowsSelectEvent<Row>) => void) | undefined;
1970
- /**
1971
- * Called once per change with what it added, what it removed and everything
1972
- * selected after it — the one to persist from.
1973
- */
1974
- onRowSelectionChange?: ((event: RowSelectionChangeEvent<Row>) => void) | undefined;
1975
- onColumnSelect?: ((event: ColumnSelectEvent<Row, Node>) => void) | undefined;
1976
- onColumnsSelect?: ((event: ColumnsSelectEvent<Row, Node>) => void) | undefined;
1977
- onColumnDeselect?: ((event: ColumnSelectEvent<Row, Node>) => void) | undefined;
1978
- onColumnsDeselect?: ((event: ColumnsSelectEvent<Row, Node>) => void) | undefined;
1979
- onColumnSelectionChange?: ((event: ColumnSelectionChangeEvent<Row, Node>) => void) | undefined;
1980
- onCellSelect?: ((event: CellSelectEvent<Row, Node>) => void) | undefined;
1981
- onCellDeselect?: ((event: CellSelectEvent<Row, Node>) => void) | undefined;
1982
- onCellSelectionChange?: ((event: CellSelectionChangeEvent<Row, Node>) => void) | undefined;
1983
- }
1984
-
1985
- /**
1986
- * Which editor a filter menu opens. Both edit the same `FilterState`, so
1987
- * switching between them keeps every filter applied.
1988
- *
1989
- * - `"simple"`: one or two conditions — an operator and a value each —
1990
- * joined by and/or.
1991
- * - `"excel"`: a search box over a checklist of the column's values, with
1992
- * the conditions a submenu away.
1993
- */
1994
- type FilterMenuUi = "simple" | "excel";
1995
- /** How a grid's filter menus look, unless a column says otherwise. */
1996
- interface GridFilterMenuOptions {
1997
- /** Which editor a filter menu opens. Defaults to `"simple"`. */
1998
- readonly ui?: FilterMenuUi | undefined;
1999
- /** Whether the excel editor's checklist shows how many rows hold each value. Off by default. */
2000
- readonly showCounts?: boolean | undefined;
2001
- /**
2002
- * How many distinct values the excel editor's checklist lists before it
2003
- * asks for a search first. Defaults to `DEFAULT_FILTER_VALUE_LIMIT`.
2004
- */
2005
- readonly valueLimit?: number | undefined;
2006
- }
2007
- /** A column's own filter menu settings, over the grid's `filterMenu`. */
2008
- interface ColumnFilterMenuOptions {
2009
- /** Which editor this column's filter menu opens, over the grid's `filterMenu.ui`. */
2010
- readonly ui?: FilterMenuUi | undefined;
2011
- /**
2012
- * The operators this column's conditions offer, in order, in place of its
2013
- * type's `defaultFilterOperators`. `in` is dropped — the checklist is its
2014
- * editor — and `[]` offers no condition, leaving the excel editor its
2015
- * checklist alone.
2016
- */
2017
- readonly operators?: readonly FilterOperator[] | undefined;
2018
- }
2019
- /** One column's filter menu with every setting settled — what a renderer draws. */
2020
- interface ResolvedColumnFilterMenu {
2021
- readonly ui: FilterMenuUi;
2022
- /** The operators its conditions offer, in order. Never `in`. */
2023
- readonly operators: readonly FilterOperator[];
2024
- /** The family the column's `type` falls in, which its operators are labelled by. */
2025
- readonly family: FilterOperatorFamily;
2026
- readonly showCounts: boolean;
2027
- readonly valueLimit: number;
2028
- }
2029
- /**
2030
- * How many distinct values a checklist lists before asking for a search —
2031
- * Excel's own cap. The list is virtualized, so what this bounds is counting
2032
- * the values, not drawing them.
2033
- */
2034
- declare const DEFAULT_FILTER_VALUE_LIMIT = 10000;
2035
- /**
2036
- * The filter menu `column` opens, or `null` when it has none: a column is
2037
- * filterable when its own `filterable` says so, else when the grid's
2038
- * `filterableColumns` does — off unless one of them turns it on, as
2039
- * `sortable` is. The column's `filterMenu` settings win over the grid's
2040
- * one by one; what neither sets takes its default.
2041
- */
2042
- declare function resolveColumnFilterMenu(options: Pick<GridOptions<unknown>, "filterableColumns" | "filterMenu">, column: Pick<ColumnDefinition<unknown, unknown>, "type" | "filterable" | "filterMenu">): ResolvedColumnFilterMenu | null;
2043
-
2044
- /**
2045
- * Values a cell shows as-is instead of being drilled into. Arrays and `Date`s
2046
- * are cell values rather than groups of columns, and `null` cannot be
2047
- * introspected, so all three end a path.
2048
- */
2049
- type LeafValue = bigint | boolean | number | string | symbol | null | undefined | Date | readonly unknown[] | ((...args: never[]) => unknown);
2050
- /** Keys of `T` holding a leaf value — the only ones a path may end on. */
2051
- type LeafKey<T> = {
2052
- [K in keyof T & string]: NonNullable<T[K]> extends LeafValue ? K : never;
2053
- }[keyof T & string];
2054
- /**
2055
- * Every addressable field of `Row`, one level deep: `"Id"` for a flat field,
2056
- * `"Application.Id"` for a leaf inside a nested object. A nested object
2057
- * contributes only its leaf children, never itself and never anything deeper.
2058
- */
2059
- type FieldPath<Row> = {
2060
- [K in keyof Row & string]: NonNullable<Row[K]> extends LeafValue ? K : `${K}.${LeafKey<NonNullable<Row[K]>>}`;
2061
- }[keyof Row & string];
2062
- /**
2063
- * The value type of a column's cells. This package is framework-agnostic so it
2064
- * defaults to `string`;
2065
- */
2066
- type ColumnType = "dateTime" | "date" | "time" | "number" | "string" | "boolean" | "decimal" | "currency" | "percent";
2067
- type ColumnAlignment = "left" | "center" | "right";
2068
- /**
2069
- * What `cellTemplate` receives. An object rather than positional arguments so
2070
- * that a later addition — a sort state, whether the row is selected — is not a
2071
- * breaking change to every template already written.
2072
- */
2073
- interface CellTemplateContext<Row> {
2074
- /**
2075
- * This cell's value, read off the column's field path. `unknown` because a
2076
- * dotted path's type cannot be recovered here; a template narrows it.
2077
- */
2078
- value: unknown;
2079
- /** The whole row, for a template that needs a sibling field. */
2080
- row: Row;
2081
- /** Position among the rows as rendered — the index within the current page once paging is on. */
2082
- rowIndex: number;
2083
- /** This row's absolute position in the whole filtered/sorted/grouped dataset, unaffected by which page is showing. */
2084
- datasetIndex: number;
2085
- /** This row's id, as `resolveRowId` settled it. */
2086
- rowId: string;
2087
- /** Whether this row is selected, so a template can style itself to match. */
2088
- selected: boolean;
2089
- }
2090
- /**
2091
- * What a column's `footerTemplate` receives. Mirrors `CellTemplateContext`'s
2092
- * shape where it applies — `value`, `rows` — minus everything scoped to one
2093
- * rendered row (`rowIndex`, `rowId`, `selected`), since a footer addresses
2094
- * every row an aggregate was computed over at once, not a single one.
2095
- */
2096
- interface FooterTemplateContext<Row> {
2097
- /** This column's aggregate result, as `computeAggregates` produced it. */
2098
- value: unknown;
2099
- /** Every row the aggregate was computed over — the grand total's full dataset, or one group's full leaf descendants. */
2100
- rows: readonly Row[];
2101
- }
2102
- /**
2103
- * @typeParam Node - What a header or cell renders to. This package is
2104
- * framework-agnostic so it defaults to `string`; `@gridkitjs/react` binds it to
2105
- * `ReactNode` so a template can return JSX.
2106
- */
2107
- interface ColumnDefinition<Row, Node = string> {
2108
- /**
2109
- * Path to this cell's value: a key of `Row`, or `"Parent.Child"` for a leaf
2110
- * one level inside a nested object. Any string still compiles — the union
2111
- * exists to drive autocomplete, not to lock the grid down.
2112
- */
2113
- field: FieldPath<Row> | (string & {});
2114
- /**
2115
- * Stable identity for state keyed by this column. Defaults to `field`, which
2116
- * is unique in the common case but need not be — two columns may render the
2117
- * same field differently.
2118
- */
2119
- id?: string;
2120
- /**
2121
- * The column's name as plain text. The header shows it when there is no
2122
- * `headerTemplate`, and anything that needs the name as text rather than
2123
- * markup — a screen-reader announcement, an export — reads it even when
2124
- * there is one, since a template's output need not be text at all.
2125
- */
2126
- header?: string | undefined;
2127
- /** Header content, or a function returning it at render time. */
2128
- headerTemplate?: Node | (() => Node) | undefined;
2129
- /**
2130
- * Renders this column's cells in place of the text `formatCellValue` makes
2131
- * of the value at `field`. The raw value is still resolved and handed over,
2132
- * so a template never repeats the field path.
2133
- */
2134
- cellTemplate?: ((context: CellTemplateContext<Row>) => Node) | undefined;
2135
- /**
2136
- * Renders this column's own aggregate result in a group footer or the
2137
- * grand-total footer, in place of the raw computed value. Absent for a
2138
- * column with no aggregate: nothing is shown, the same way a column
2139
- * missing from `AggregateState` contributes no cell to either footer.
2140
- */
2141
- footerTemplate?: ((context: FooterTemplateContext<Row>) => Node) | undefined;
2142
- /**
2143
- * The value type of this column's cells. Absent, the column has none: it
2144
- * sorts as `compareValues` does without a type, two numbers or two `Date`s
2145
- * by value and any other pair as text.
2146
- */
2147
- type?: ColumnType;
2148
- /**
2149
- * `Intl` options for how this column's values read as text: number options
2150
- * for a numeric `type`, date options for a date or time one. Passed to
2151
- * `Intl.NumberFormat`/`Intl.DateTimeFormat` with the grid's `locale` — see
2152
- * `formatCellValue` for the defaults each `type` starts from. Setting it,
2153
- * or the grid's `locale`, is what turns that formatting on: without either,
2154
- * numbers print as-is and dates through `toLocaleString()`.
2155
- */
2156
- format?: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions | undefined;
2157
- /**
2158
- * Turns a value into the text shown for it, in place of `format` and
2159
- * `type`. Applies wherever this column's values are shown as text — its
2160
- * cells and its aggregates. `row` is the cell's row, and `undefined` for a
2161
- * value no single row owns: an aggregate result, or a group header's value.
2162
- */
2163
- valueFormatter?: ((value: unknown, row: Row | undefined) => string) | undefined;
2164
- /**
2165
- * Alignment of this column's cells. This package is framework-agnostic so it
2166
- * defaults to `left` (`right` for numbers);
2167
- */
2168
- alignment?: ColumnAlignment;
2169
- /**
2170
- * Width in px this column starts at. A user resize overrides it for as long
2171
- * as that resize lives in the sizing state.
2172
- */
2173
- width?: number;
2174
- /** Lower bound a resize may not drag below. */
2175
- minWidth?: number;
2176
- /** Upper bound a resize may not drag above. */
2177
- maxWidth?: number;
2178
- /** Whether this column can be resized, overriding the grid-level default. */
2179
- resizable?: boolean;
2180
- /**
2181
- * Whether this column can be dragged to a new position, overriding the
2182
- * grid-level default. A column that cannot move can still be moved past.
2183
- */
2184
- reorderable?: boolean;
2185
- /** Whether this column can be sorted, overriding the grid-level default. */
2186
- sortable?: boolean;
2187
- /**
2188
- * Whether this column has a filter menu, overriding the grid-level
2189
- * `filterableColumns`. Like `sortable`, it gates the user's way in and
2190
- * nothing else: a filter on the column set in code still applies.
2191
- */
2192
- filterable?: boolean | undefined;
2193
- /**
2194
- * This column's own filter menu settings — its editor and the operators
2195
- * its conditions offer — over the grid's `filterMenu`.
2196
- */
2197
- filterMenu?: ColumnFilterMenuOptions | undefined;
2198
- /** Whether this column can be grouped by, overriding the grid-level default. */
2199
- groupable?: boolean;
2200
- /**
2201
- * Whether this column's header shows its group-toggle icon, overriding
2202
- * the grid-level default. Purely a rendering choice — it does not affect
2203
- * whether the column can be grouped by (`groupable`) or the
2204
- * `Alt+ArrowDown` shortcut, which keeps working with the icon hidden, the
2205
- * same way the resize handle stays `aria-hidden` while `Alt+ArrowLeft`/
2206
- * `ArrowRight` still resize.
2207
- */
2208
- groupToggleIcon?: boolean;
2209
- /**
2210
- * Whether this column's header may be dragged into the group-by bar to
2211
- * add it to the active grouping, overriding the grid-level default.
2212
- * Distinct from `groupable`: a column can be groupable via its header's
2213
- * click/`Alt+ArrowDown` toggle, via this drag, both, or neither.
2214
- */
2215
- groupByDraggable?: boolean;
2216
- /**
2217
- * Lets this column's header and/or cell text wrap onto multiple lines
2218
- * instead of the grid's default single line with an ellipsis. Off by
2219
- * default: wrapping changes row height, so it stays a column's own choice
2220
- * rather than something a minor release could turn on under an existing
2221
- * grid.
2222
- */
2223
- wrap?: ColumnWrapConfig;
2224
- /**
2225
- * Extra class names appended to this column's `th`. An escape hatch for a
2226
- * consumer's own CSS — nothing in this package reads them — for anything
2227
- * `wrap` and the rest of this type don't cover.
2228
- */
2229
- headerClassName?: string;
2230
- /**
2231
- * Extra class names appended to this column's `td`, on every row. Static
2232
- * per column: a per-row condition is already `cellTemplate`'s job (a
2233
- * template returning its own markup with a conditional class), so this
2234
- * stays a plain string rather than taking the row.
2235
- */
2236
- cellClassName?: string;
2237
- /**
2238
- * Whether this column starts out hidden. A hidden column is not rendered
2239
- * but is still a column of the grid: a sort, filter or grouping on it
2240
- * still applies, and it keeps its place in the column order. The user
2241
- * showing or hiding it lives in `ColumnVisibilityState`, which wins over
2242
- * this for as long as it holds an entry for the column.
2243
- */
2244
- hidden?: boolean | undefined;
2245
- /**
2246
- * Whether the user may hide this column — from its header's menu, or the
2247
- * column chooser. Defaults to `true`. Like `sortable`, it gates the user's
2248
- * ways to do it and nothing else: `hideColumns` still hides the column.
2249
- */
2250
- hideable?: boolean | undefined;
2251
- /**
2252
- * Whether this column is written to an export, a clipboard copy or a
2253
- * print. Defaults to `true`. `false` keeps it out of every one of them —
2254
- * even when an export names it by id — for a column whose cells mean
2255
- * nothing off screen, such as one of action buttons.
2256
- */
2257
- exportable?: boolean | undefined;
2258
- /**
2259
- * The typed value an export stores for this column's cells, where the raw
2260
- * value at `field` is not the one to keep — an id to resolve into a name,
2261
- * a string date to turn into a `Date`. Only a format that keeps typed
2262
- * values (a spreadsheet, JSON) reads it; the text every format writes
2263
- * still comes from `formatCellValue`, so what is exported reads as what
2264
- * is shown.
2265
- */
2266
- exportValue?: ((value: unknown, row: Row) => ExportScalar) | undefined;
2267
- }
2268
- /** Which parts of a column opt out of the grid's default single-line text. */
2269
- interface ColumnWrapConfig {
2270
- header?: boolean;
2271
- cells?: boolean;
2272
- }
2273
- /**
2274
- * Widths the user has changed, keyed by column id. Holding only what changed —
2275
- * rather than every width — means a `width` edited in the column definition
2276
- * still takes effect, and resetting is discarding the state.
2277
- */
2278
- type ColumnSizingState = Readonly<Record<string, number>>;
2279
- /** The active page, and how many rows/units make one up. */
2280
- interface PaginationState {
2281
- readonly pageIndex: number;
2282
- readonly pageSize: number;
2283
- }
2284
- /**
2285
- * What a grouped grid's `pageSize` counts. `"group"` counts top-level groups,
2286
- * each with everything beneath it, so a page never splits a group. `"row"`
2287
- * counts data rows and collapsed group headers, so every page holds
2288
- * `pageSize` of them however large the groups are; a page continuing a group
2289
- * starts with that group's headers again. An ungrouped grid pages by data
2290
- * rows under either.
2291
- */
2292
- type PaginationUnit = "group" | "row";
2293
- /** Reports a user page/page-size change whole — the one to persist from, mirroring ColumnSortEvent. */
2294
- interface PaginationChangeEvent {
2295
- readonly pagination: PaginationState;
2296
- readonly pageCount: number;
2297
- }
2298
- /** Sizes used for a column that does not specify its own. */
2299
- interface ColumnSizeDefaults {
2300
- width: number;
2301
- minWidth: number;
2302
- maxWidth: number;
2303
- }
2304
- /** The bounds a column's width is held between, resolved once from both. */
2305
- interface ColumnConstraints {
2306
- minWidth: number;
2307
- maxWidth: number;
2308
- }
2309
- /**
2310
- * Grid-level defaults a column falls back to when it does not set its own.
2311
- * Sizes are grouped so the rest of the grid's defaults have somewhere to go.
2312
- */
2313
- interface ColumnResolveOptions {
2314
- sizes?: Partial<ColumnSizeDefaults> | undefined;
2315
- /** Whether columns are resizable, unless a column says otherwise. */
2316
- resizable?: boolean | undefined;
2317
- /** Whether columns are reorderable, unless a column says otherwise. */
2318
- reorderable?: boolean | undefined;
2319
- /** Whether columns may be dragged into the group-by bar, unless a column says otherwise. */
2320
- groupByDraggable?: boolean | undefined;
2321
- }
2322
- /**
2323
- * How a column's width relates to the grid's.
2324
- *
2325
- * `"fit"` keeps the columns filling the grid: the space a column gives up is
2326
- * handed to the others, and the space it takes comes out of them. `"fixed"`
2327
- * lets every column keep its own width, so a resize moves one column and
2328
- * nothing else, and the grid scrolls or leaves a gap accordingly.
2329
- */
2330
- type ResizeMode = "fit" | "fixed";
2331
- /**
2332
- * A column as the data stages read it — filtering, sorting, grouping and
2333
- * aggregating need its id and its definition's `field` and `type`, never its
2334
- * width. Kept apart from `ResolvedColumn` so that a resize or a viewport
2335
- * change, which re-resolves every width, leaves these stages' input — and so
2336
- * their output — untouched. `ResolvedColumn` satisfies it structurally.
2337
- */
2338
- interface DataColumn<Row, Node = string> {
2339
- readonly id: string;
2340
- readonly column: ColumnDefinition<Row, Node>;
2341
- }
2342
- /**
2343
- * A column paired with everything it takes to render it. Each field is a
2344
- * decision made once here rather than in each adapter, so a second framework
2345
- * binding renders identically without repeating the logic.
2346
- */
2347
- interface ResolvedColumn<Row, Node = string> {
2348
- column: ColumnDefinition<Row, Node>;
2349
- id: string;
2350
- width: number;
2351
- /**
2352
- * Whether `width` came from the sizing state rather than the column
2353
- * definition — that is, whether the user set it. Auto-fit leaves these
2354
- * columns alone so that resizing one does not undo itself.
2355
- */
2356
- sized: boolean;
2357
- /**
2358
- * What the header shows: the column's own `headerTemplate`, else its
2359
- * `header`, else a label read off the field path. `string` is in the
2360
- * union because both fallbacks are text whatever `Node` is bound to.
2361
- */
2362
- label: Node | string;
2363
- /** Whether this column can be resized, after the grid-level default. */
2364
- resizable: boolean;
2365
- /** Whether this column can be dragged, after the grid-level default. */
2366
- reorderable: boolean;
2367
- /** Whether this column's header may be dragged into the group-by bar, after the grid-level default. */
2368
- groupByDraggable: boolean;
2369
- /** How this column's cells align, after falling back to its type. */
2370
- alignment: ColumnAlignment;
2371
- }
2372
- /**
2373
- * A resize in progress. It captures its constraints up front so that applying
2374
- * a pointer position is arithmetic on numbers alone — no column, no DOM.
2375
- */
2376
- interface ColumnResizeSession {
2377
- readonly columnId: string;
2378
- readonly startWidth: number;
2379
- readonly startPosition: number;
2380
- readonly constraints: ColumnConstraints;
2381
- }
2382
- /**
2383
- * Reports a user resize. `phase` separates the two audiences: `"move"` fires
2384
- * continuously for live feedback, `"end"` once on release — the one to persist.
2385
- */
2386
- interface ColumnResizeEvent {
2387
- readonly columnId: string;
2388
- readonly width: number;
2389
- readonly sizing: ColumnSizingState;
2390
- readonly phase: "move" | "end";
2391
- }
2392
- /**
2393
- * Columns shown (`true`) or hidden (`false`) since the grid started, keyed by
2394
- * column id. Holding only what changed, the way `ColumnSizingState` does: a
2395
- * column absent from it follows its definition's `hidden`, so a definition
2396
- * edited later still takes effect for every column the user never touched.
2397
- */
2398
- type ColumnVisibilityState = Readonly<Record<string, boolean>>;
2399
- /**
2400
- * Reports columns shown or hidden. `columnIds` lists every column the one
2401
- * change touched — showing three columns at once is one event, not three —
2402
- * and `visibility` is the whole state to persist from.
2403
- */
2404
- interface ColumnVisibilityEvent {
2405
- readonly columnIds: readonly string[];
2406
- readonly visibility: ColumnVisibilityState;
2407
- }
2408
- /**
2409
- * Column ids in the order they render. It need not list every column: one
2410
- * absent from it keeps its position among the definitions and follows those
2411
- * that are listed.
2412
- */
2413
- type ColumnOrderState = readonly string[];
2414
- /**
2415
- * Which side of a column a drop lands on, normalised away by
2416
- * `resolveDropBefore` so it reaches no state.
2417
- */
2418
- type DropSide = "before" | "after";
2419
- /**
2420
- * Reports a user reorder. Unlike a resize there is no `"move"` phase — the
2421
- * order does not change until the drop.
2422
- */
2423
- interface ColumnOrderEvent {
2424
- readonly columnId: string;
2425
- readonly order: ColumnOrderState;
2426
- }
2427
- /** Which way a column sorts. */
2428
- type SortDirection = "asc" | "desc";
2429
- /** One column's place in a stacked sort, and which way it sorts. */
2430
- interface ColumnSortEntry {
2431
- readonly columnId: string;
2432
- readonly direction: SortDirection;
2433
- }
2434
- /**
2435
- * The active sort, in priority order: index 0 sorts first, ties broken by
2436
- * index 1, and so on down the stack. Empty for an unsorted grid, mirroring
2437
- * `SelectionState`'s empty array for "nothing selected".
2438
- */
2439
- type ColumnSortState = readonly ColumnSortEntry[];
2440
- /**
2441
- * Reports a user sort change whole — the stack to persist from. No `phase`:
2442
- * unlike a resize, a sort has no in-progress state, only before and after.
2443
- */
2444
- interface ColumnSortEvent {
2445
- readonly columnId: string;
2446
- readonly sort: ColumnSortState;
2447
- }
2448
- /** One level of a stacked group-by, outer to inner. Mirrors ColumnSortEntry. */
2449
- interface GroupByEntry {
2450
- readonly columnId: string;
2451
- /** Order of this level's own group values (not row order within a group). Defaults to "asc". */
2452
- readonly direction?: SortDirection;
2453
- }
2454
- /**
2455
- * The active grouping, outer to inner: index 0 groups first, each
2456
- * subsequent index nests inside it. Empty for an ungrouped grid, mirroring
2457
- * ColumnSortState's empty array for "no sort".
2458
- */
2459
- type GroupByState = readonly GroupByEntry[];
2460
- /**
2461
- * Reports a user group-by change whole — the stack to persist from. Mirrors
2462
- * ColumnSortEvent's `{columnId, sort}` shape.
2463
- */
2464
- interface GroupByEvent {
2465
- readonly columnId: string;
2466
- readonly groupBy: GroupByState;
2467
- }
2468
- /**
2469
- * Group keys collapsed by the user — holding only the exceptions, the same
2470
- * way ColumnSizingState holds only resized widths. A key absent from this
2471
- * set is expanded; there is no separate "collapsed by default" concept.
2472
- */
2473
- type GroupExpansionState = readonly string[];
2474
- /**
2475
- * Reports a user expansion change. `groupId` is the group toggled, or `null`
2476
- * for expandAllGroups/collapseAllGroups, which touch every group in one call
2477
- * rather than one at a time.
2478
- */
2479
- interface GroupExpansionEvent {
2480
- readonly groupId: string | null;
2481
- readonly expansion: GroupExpansionState;
2482
- }
2483
- /**
2484
- * One group header in a grouped result. `path` is every ancestor value
2485
- * down to and including this group's own, outermost first — what a header
2486
- * template needs to render "West / Enterprise", not just "Enterprise".
2487
- *
2488
- * Not parameterized by `Row`: nothing here holds a `Row`-typed value today —
2489
- * `aggregates` holds computed `unknown` results, not rows themselves.
2490
- */
2491
- interface ResolvedGroupRow {
2492
- readonly kind: "group";
2493
- /** Stable id for this node: this plan's join of `path`, used as the React key and the GroupExpansionState entry. Opaque — build it with `groupRowId`, never construct one by hand. */
2494
- readonly groupId: string;
2495
- /** Nesting depth, 0 for a top-level group. */
2496
- readonly level: number;
2497
- readonly columnId: string;
2498
- /** This level's own value — the last entry of `path`. */
2499
- readonly value: unknown;
2500
- readonly path: readonly unknown[];
2501
- readonly expanded: boolean;
2502
- /** Leaf row count under this group, regardless of collapse state. */
2503
- readonly count: number;
2504
- /** Position among the display rows as rendered — same invariant ResolvedRow.rowIndex keeps. */
2505
- readonly rowIndex: number;
2506
- /** This header's absolute position in the whole filtered/sorted/grouped dataset, matching ResolvedRow.datasetIndex. */
2507
- readonly datasetIndex: number;
2508
- /**
2509
- * This group's own aggregate results, computed over its full leaf-row
2510
- * descendants regardless of collapse state — see `withGroupAggregates`.
2511
- * Empty when no `AggregateState` is active.
2512
- */
2513
- readonly aggregates: AggregateResults;
2514
- }
2515
- /**
2516
- * A group's own aggregate results, rendered as a row of its own rather than
2517
- * inline in its header — see `groupAggregateDisplay: "row"`. Emitted by
2518
- * `withGroupAggregates` immediately after a group's last visible
2519
- * descendant (its last nested group or data row, or immediately after its
2520
- * own header when collapsed), at that same group's `level`, one per group
2521
- * with `AggregateState` active — mirroring `ResolvedGroupRow` closely
2522
- * enough that the two are meant to be read side by side.
2523
- */
2524
- interface ResolvedGroupSummaryRow {
2525
- readonly kind: "group-summary";
2526
- /** The group this summary belongs to — shared with that group's own `ResolvedGroupRow.groupId`, not a new id of its own. */
2527
- readonly groupId: string;
2528
- /** Nesting depth, matching the group's own `level`. */
2529
- readonly level: number;
2530
- /** Position among the display rows as rendered — same invariant every other DisplayRow's `rowIndex` keeps. */
2531
- readonly rowIndex: number;
2532
- /** This row's absolute position in the whole filtered/sorted/grouped dataset, matching ResolvedRow.datasetIndex. */
2533
- readonly datasetIndex: number;
2534
- /** This group's own aggregate results — identical to its `ResolvedGroupRow.aggregates`, computed once and shared rather than recomputed. */
2535
- readonly aggregates: AggregateResults;
2536
- }
2537
- /**
2538
- * One entry of a grouped result: an ordinary data row (no `kind` field at
2539
- * all — ResolvedRow is unchanged, so every existing consumer of plain
2540
- * ResolvedRow[] keeps compiling), a group header, or — only when
2541
- * `groupAggregateDisplay: "row"` is active — that group's own summary row.
2542
- * Discriminate with `"kind" in entry`, then `entry.kind`.
2543
- */
2544
- type DisplayRow<Row> = ResolvedRow<Row> | ResolvedGroupRow | ResolvedGroupSummaryRow;
2545
- /** A reducer this package computes without a custom `AggregateFn`. */
2546
- type BuiltInAggregate = "sum" | "avg" | "min" | "max" | "count" | "countDistinct";
2547
- /**
2548
- * Called with every raw row in scope — always the full leaf set, never a
2549
- * partial reduction combined from child groups, so a non-associative
2550
- * aggregate (median, distinct count) is never computed from
2551
- * already-aggregated values. Mirrors `FilterPredicate`'s shape, minus the
2552
- * per-row `value` since an aggregate reduces across rows rather than
2553
- * testing one.
2554
- */
2555
- type AggregateFn<Row> = (rows: readonly Row[]) => unknown;
2556
- /** One aggregate to compute against a column — a built-in reducer, or custom logic via `fn`. */
2557
- interface AggregateSpec<Row> {
2558
- readonly columnId: string;
2559
- readonly fn: BuiltInAggregate | AggregateFn<Row>;
2560
- /** Distinguishes two aggregates on the same column (e.g. both sum and avg of Amount). Defaults to columnId, mirroring ColumnDefinition.id defaulting to field. */
2561
- readonly id?: string;
2562
- /**
2563
- * Overrides this aggregate's own cell alignment, in the grand-total
2564
- * footer and a group's own summary row (`groupAggregateDisplay: "row"`)
2565
- * — inline rendering (`"inline"`) is text, not a cell, so this has no
2566
- * effect there. Falls back to the column's own `alignment` when omitted.
2567
- * When two specs share a column and disagree, the first one in
2568
- * `AggregateState` wins for that shared cell, since one `<td>` can only
2569
- * take one `text-align`.
2570
- */
2571
- readonly alignment?: ColumnAlignment;
2572
- }
2573
- /**
2574
- * The active aggregates to compute. Empty for a grid with none, mirroring
2575
- * `FilterState`'s empty array for "no filter". A fully controlled prop —
2576
- * unlike `sort`/`filter`/`groupBy`/`pagination`, there is no built-in UI
2577
- * affordance for a user to add or remove an aggregate interactively.
2578
- */
2579
- type AggregateState<Row> = readonly AggregateSpec<Row>[];
2580
- /** One computed aggregate result, keyed by `spec.id ?? spec.columnId`. */
2581
- type AggregateResults = ReadonlyMap<string, unknown>;
2582
- /**
2583
- * Where a group's own aggregate results render. `"inline"` (the default)
2584
- * keeps them as text in the group header itself, next to its leaf-row
2585
- * count. `"row"` instead emits a `ResolvedGroupSummaryRow` immediately
2586
- * after that group's last visible descendant, with each aggregate's value
2587
- * in the `<td>` for its own column — the same alignment a grand-total
2588
- * footer cell has to its column, just scoped to one group instead of the
2589
- * whole dataset.
2590
- */
2591
- type GroupAggregateDisplay = "inline" | "row";
2592
- interface FilterEntryBase<Row> {
2593
- readonly columnId?: FieldPath<Row> | (string & {});
2594
- }
2595
- /** Matches a column's stringified value against an SQL LIKE-style query. */
2596
- interface TextFilterEntry<Row> extends FilterEntryBase<Row> {
2597
- /**
2598
- * A bare query is an exact match; `%text%` is contains; `text%` is
2599
- * starts-with; `%text` is ends-with. Always case-insensitive. Only the
2600
- * first and last characters are read as anchors — a `%` anywhere else is
2601
- * a literal character, not a wildcard.
2602
- */
2603
- readonly query: string;
2604
- }
2605
- /**
2606
- * Matches a column's actual (non-stringified) value by strict equality —
2607
- * only when the column's resolved `type` agrees: `number`/`decimal`/
2608
- * `currency`/`percent` for a `number` value, `boolean` for a `boolean`
2609
- * value, `date`/`dateTime`/`time` for a `Date` value (compared via
2610
- * `getTime()`). A `value` against a column of the wrong type never matches,
2611
- * rather than silently stringifying and falling through to a text
2612
- * comparison — the whole point of this variant existing separately from
2613
- * `TextFilterEntry` is that it doesn't do that.
2614
- */
2615
- interface ValueFilterEntry<Row> extends FilterEntryBase<Row> {
2616
- readonly value: number | boolean | Date;
2617
- }
2618
- type FilterPredicate<Row> = (value: unknown, row: Row) => boolean;
2619
- /**
2620
- * Matches via caller-supplied logic — a numeric range, a cross-field
2621
- * combination, anything `query`/`value` can't express. Called once per row,
2622
- * not per column: when `columnId` is given, `value` is that column's value,
2623
- * resolved for convenience; when it's omitted, `value` is `undefined` and
2624
- * the predicate is expected to read whatever it needs off `row` itself.
2625
- */
2626
- interface PredicateFilterEntry<Row> extends FilterEntryBase<Row> {
2627
- readonly predicate: FilterPredicate<Row>;
2628
- }
2629
- /**
2630
- * A nested group of entries, combined with `combinator` instead of the
2631
- * implicit AND every top-level `FilterState` uses. `entries` is itself a
2632
- * `FilterState<Row>`, so groups nest to any depth — the only entry variant
2633
- * with no `columnId` of its own, since it isn't scoped to one column, only
2634
- * to the entries it composes.
2635
- */
2636
- interface GroupFilterEntry<Row> {
2637
- readonly combinator: "and" | "or";
2638
- readonly entries: FilterState<Row>;
2639
- }
2640
- /**
2641
- * What an `OperatorFilterEntry` asks of a cell. `contains`, `notContains`,
2642
- * `startsWith` and `endsWith` read the value as text; the rest compare it as
2643
- * the column's `type` says.
2644
- */
2645
- type FilterOperator = "eq" | "ne" | "contains" | "notContains" | "startsWith" | "endsWith" | "gt" | "gte" | "lt" | "lte" | "between" | "in" | "isEmpty" | "isNotEmpty";
2646
- /** A value an `OperatorFilterEntry` compares a cell against. */
2647
- type FilterScalar = string | number | boolean | Date | null;
2648
- /**
2649
- * Matches one column's value by a named operator — plain data, unlike a
2650
- * predicate, so a filter built from these can be saved and restored.
2651
- *
2652
- * `value` is one `FilterScalar` for most operators, a list of them for
2653
- * `in`, a `[low, high]` pair for `between` (both ends inclusive), and
2654
- * absent for `isEmpty`/`isNotEmpty`.
2655
- *
2656
- * - An empty cell is `null`, `undefined` or `""`. `isEmpty` matches it,
2657
- * `isNotEmpty` does not, and so does no other operator — except `ne` and
2658
- * `notContains`, which match it: a "not" filter must not quietly drop the
2659
- * blanks. Each of those two is the exact opposite of `eq`/`contains`.
2660
- * - The text operators compare the stringified value, case-insensitively.
2661
- * - `eq`, `ne`, `gt`, `gte`, `lt`, `lte` and `between` compare as
2662
- * `compareValues` does under the column's `type`: numerically,
2663
- * chronologically, or as text (case-insensitively, like a query). A cell
2664
- * of another kind — a string in a number column — is never equal, greater
2665
- * or less.
2666
- * - `in` matches the values grouping would put in the same group.
2667
- * - A date column reads a string `value` as `new Date(value)`.
2668
- * - A `value` of the wrong kind for the column — a string against a number
2669
- * column, a missing pair for `between` — matches no row at all, as a
2670
- * `ValueFilterEntry` of the wrong type doesn't.
2671
- */
2672
- interface OperatorFilterEntry<Row> {
2673
- readonly columnId: FieldPath<Row> | (string & {});
2674
- readonly operator: FilterOperator;
2675
- readonly value?: FilterScalar | readonly FilterScalar[];
2676
- }
2677
- type FilterEntry<Row> = TextFilterEntry<Row> | ValueFilterEntry<Row> | PredicateFilterEntry<Row> | OperatorFilterEntry<Row> | GroupFilterEntry<Row>;
2678
- /**
2679
- * The active filter, every entry ANDed together at the top level — nest a
2680
- * `GroupFilterEntry` for anything that needs OR. Empty for an unfiltered
2681
- * grid, mirroring `ColumnSortState`'s empty array for "no sort".
2682
- */
2683
- type FilterState<Row> = readonly FilterEntry<Row>[];
2684
- /**
2685
- * A `ValueFilterEntry` as JSON holds it: a `Date` value becomes its ISO
2686
- * string, which restoring turns back into a `Date`.
2687
- */
2688
- interface SerializedValueFilterEntry<Row> extends FilterEntryBase<Row> {
2689
- readonly value: number | boolean | string;
2690
- }
2691
- /** A `FilterScalar` as JSON holds it: a `Date` becomes its ISO string. */
2692
- type SerializedFilterScalar = string | number | boolean | null;
2693
- /**
2694
- * An `OperatorFilterEntry` as JSON holds it: each `Date` becomes its ISO
2695
- * string, which restoring turns back into a `Date` when the column is a
2696
- * date, date-time or time column.
2697
- */
2698
- interface SerializedOperatorFilterEntry<Row> {
2699
- readonly columnId: FieldPath<Row> | (string & {});
2700
- readonly operator: FilterOperator;
2701
- readonly value?: SerializedFilterScalar | readonly SerializedFilterScalar[];
2702
- }
2703
- /** A `GroupFilterEntry` whose entries are serialised too. */
2704
- interface SerializedGroupFilterEntry<Row> {
2705
- readonly combinator: "and" | "or";
2706
- readonly entries: SerializedFilterState<Row>;
2707
- }
2708
- /**
2709
- * A filter entry that survives `JSON.stringify`: every kind but a predicate,
2710
- * which is a function and cannot be written down.
2711
- */
2712
- type SerializedFilterEntry<Row> = TextFilterEntry<Row> | SerializedValueFilterEntry<Row> | SerializedOperatorFilterEntry<Row> | SerializedGroupFilterEntry<Row>;
2713
- type SerializedFilterState<Row> = readonly SerializedFilterEntry<Row>[];
2714
- /** Reports a filter change whole — the filter to persist from. */
2715
- interface FilterChangeEvent<Row> {
2716
- readonly filter: FilterState<Row>;
2717
- }
2718
- /**
2719
- * Ids selected, in the order they were selected — so the most recent is last,
2720
- * and a consumer wanting only that reads `at(-1)` rather than tracking it
2721
- * alongside.
2722
- *
2723
- * Ordered rather than a keyed record for that reason alone; a render layer
2724
- * that needs lookups builds a `Set` from it. Rows and columns share the type:
2725
- * they are both a list of ids, and the state they live in already names which.
2726
- */
2727
- type SelectionState = readonly string[];
2728
- /**
2729
- * How much of a member may be selected at once. `false` rather than an absent
2730
- * key so that turning selection off for one member reads the same as never
2731
- * having enabled it.
2732
- */
2733
- type SelectionMode = false | "single" | "multiple";
2734
- /**
2735
- * The modes a cell may take. A cell addresses one value, so it has no
2736
- * `"multiple"` — a range of cells is a different feature, with a rectangle
2737
- * rather than a list behind it.
2738
- */
2739
- type CellSelectionMode = false | "single";
2740
- /**
2741
- * Which parts of the grid the user may select, and how many of each.
2742
- *
2743
- * Off by default, unlike `HoverableConfig`: selection claims the click, which
2744
- * a grid that only displays data should not do.
2745
- */
2746
- interface SelectableConfig {
2747
- rows?: SelectionMode | undefined;
2748
- columns?: SelectionMode | undefined;
2749
- cells?: CellSelectionMode | undefined;
2750
- /**
2751
- * Whether a plain click on a row toggles it rather than selecting it
2752
- * alone — a checklist, where picking rows one after another should not
2753
- * need Ctrl held down. Shift still selects a range and Ctrl/Cmd still
2754
- * toggles. Rows only: a column or cell click is unchanged.
2755
- */
2756
- toggleOnClick?: boolean | undefined;
2757
- }
2758
- /**
2759
- * What an interaction means for the selection, read off its modifiers once at
2760
- * the boundary so that nothing downstream handles a raw event.
2761
- */
2762
- type SelectIntent = "replace" | "toggle" | "range";
2763
- /** The address of one cell: which row, and which column within it. */
2764
- interface SelectedCellRef {
2765
- readonly rowId: string;
2766
- readonly columnId: string;
2767
- }
2768
- /** The one selected cell, or `null` for none. */
2769
- type CellSelectionState = SelectedCellRef | null;
2770
- /**
2771
- * What changed between two selections. Ids rather than resolved members, so
2772
- * that the transform producing it stays free of the data it selects from.
2773
- */
2774
- interface SelectionDiff {
2775
- readonly added: readonly string[];
2776
- readonly removed: readonly string[];
2777
- }
2778
- /**
2779
- * A row paired with the identity and position it renders under — the row
2780
- * counterpart to `ResolvedColumn`, and resolved once for the same reason: so
2781
- * no part of the grid works out a row's id for itself.
2782
- *
2783
- * It is also what the selection callbacks report, so a handler reads the row
2784
- * itself rather than an id it has to look up.
2785
- */
2786
- interface ResolvedRow<Row> {
2787
- readonly rowId: string;
2788
- readonly row: Row;
2789
- /** Position among the rows as rendered, matching `CellTemplateContext`. */
2790
- readonly rowIndex: number;
2791
- /** This row's absolute position in the whole filtered/sorted/grouped dataset, matching `CellTemplateContext`. */
2792
- readonly datasetIndex: number;
2793
- }
2794
- /**
2795
- * A selected column. Carries the resolved column rather than the bare
2796
- * definition, so a handler reads the width and label the user actually
2797
- * clicked rather than what the definition asked for.
2798
- */
2799
- interface SelectedColumn<Row, Node = string> {
2800
- readonly columnId: string;
2801
- readonly column: ResolvedColumn<Row, Node>;
2802
- /** Position among the columns as displayed, so after any reorder. */
2803
- readonly columnIndex: number;
2804
- }
2805
- /** A selected cell, resolved down to the value it shows. */
2806
- interface SelectedCell<Row, Node = string> {
2807
- readonly rowId: string;
2808
- readonly columnId: string;
2809
- readonly row: Row;
2810
- readonly column: ResolvedColumn<Row, Node>;
2811
- readonly rowIndex: number;
2812
- readonly columnIndex: number;
2813
- /** Read off the column's field path — the value a `cellTemplate` receives. */
2814
- readonly value: unknown;
2815
- }
2816
- /**
2817
- * Reports a click or double-click on a data row. Carries the modifiers and
2818
- * button rather than the browser's own event, so a handler reads the same
2819
- * payload whichever renderer drew the row.
2820
- */
2821
- interface RowPointerEvent<Row> {
2822
- readonly row: ResolvedRow<Row>;
2823
- /** The column of the cell the pointer was on, or `null` when it was on no cell. */
2824
- readonly columnId: string | null;
2825
- readonly native: {
2826
- readonly ctrlKey: boolean;
2827
- readonly metaKey: boolean;
2828
- readonly shiftKey: boolean;
2829
- readonly altKey: boolean;
2830
- /** Which button was pressed, numbered as `MouseEvent.button` numbers them — `0` for the main one. */
2831
- readonly button: number;
2832
- };
2833
- }
2834
- /** Reports one row selected or deselected. */
2835
- interface RowSelectEvent<Row> {
2836
- readonly row: ResolvedRow<Row>;
2837
- readonly selection: SelectionState;
2838
- }
2839
- /**
2840
- * Reports every row one interaction selected or deselected. Fires once for a
2841
- * range that `RowSelectEvent` reports one row at a time.
2842
- */
2843
- interface RowsSelectEvent<Row> {
2844
- readonly rows: readonly ResolvedRow<Row>[];
2845
- readonly selection: SelectionState;
2846
- }
2847
- /**
2848
- * Reports a row selection change whole: what it gained, what it lost, and
2849
- * everything it now holds. The one to persist from.
2850
- */
2851
- interface RowSelectionChangeEvent<Row> {
2852
- readonly added: readonly ResolvedRow<Row>[];
2853
- readonly removed: readonly ResolvedRow<Row>[];
2854
- /** Every selected row, not only what this interaction changed. */
2855
- readonly selected: readonly ResolvedRow<Row>[];
2856
- readonly selection: SelectionState;
2857
- }
2858
- /** Reports one column selected or deselected. */
2859
- interface ColumnSelectEvent<Row, Node = string> {
2860
- readonly column: SelectedColumn<Row, Node>;
2861
- readonly selection: SelectionState;
2862
- }
2863
- /** Reports every column one interaction selected or deselected. */
2864
- interface ColumnsSelectEvent<Row, Node = string> {
2865
- readonly columns: readonly SelectedColumn<Row, Node>[];
2866
- readonly selection: SelectionState;
2867
- }
2868
- /** Reports a column selection change whole. The one to persist from. */
2869
- interface ColumnSelectionChangeEvent<Row, Node = string> {
2870
- readonly added: readonly SelectedColumn<Row, Node>[];
2871
- readonly removed: readonly SelectedColumn<Row, Node>[];
2872
- /** Every selected column, not only what this interaction changed. */
2873
- readonly selected: readonly SelectedColumn<Row, Node>[];
2874
- readonly selection: SelectionState;
2875
- }
2876
- /** Reports the cell selected or deselected. */
2877
- interface CellSelectEvent<Row, Node = string> {
2878
- readonly cell: SelectedCell<Row, Node>;
2879
- readonly selection: CellSelectionState;
2880
- }
2881
- /**
2882
- * Reports a cell selection change whole. Both fields are nullable and one
2883
- * interaction can fill both — moving between cells deselects and selects at
2884
- * once.
2885
- */
2886
- interface CellSelectionChangeEvent<Row, Node = string> {
2887
- readonly selected: SelectedCell<Row, Node> | null;
2888
- readonly deselected: SelectedCell<Row, Node> | null;
2889
- readonly selection: CellSelectionState;
2890
- }
2891
- /**
2892
- * Everything about a grid the user can change, one slice per feature. Each
2893
- * slice is the same `*State` type its own `default*` prop and change event
2894
- * already use, so state read from here can be fed straight back as a default.
2895
- */
2896
- interface GridState<Row> {
2897
- readonly columnSizing: ColumnSizingState;
2898
- readonly columnOrder: ColumnOrderState;
2899
- readonly columnVisibility: ColumnVisibilityState;
2900
- readonly columnSort: ColumnSortState;
2901
- readonly filter: FilterState<Row>;
2902
- readonly groupBy: GroupByState;
2903
- readonly groupExpansion: GroupExpansionState;
2904
- readonly pagination: PaginationState;
2905
- readonly rowSelection: SelectionState;
2906
- readonly columnSelection: SelectionState;
2907
- readonly cellSelection: CellSelectionState;
2908
- }
2909
- /**
2910
- * `GridState` as `serializeGridState` writes it: safe to pass through
2911
- * `JSON.stringify` and back, and to hand straight to `restoreState`.
2912
- */
2913
- interface SerializedGridState<Row> extends Omit<GridState<Row>, "filter"> {
2914
- readonly filter: SerializedFilterState<Row>;
2915
- }
2916
- /**
2917
- * The slices the view is derived from: every one but the selections, which
2918
- * change what is highlighted and never what is shown. A whole `GridState`
2919
- * is one.
2920
- */
2921
- type GridViewState<Row> = Omit<GridState<Row>, "rowSelection" | "columnSelection" | "cellSelection">;
2922
- /**
2923
- * The settings that shape the view but are not user state: what the grid is
2924
- * configured to do, plus the one measurement — `viewportWidth` — that fitting
2925
- * columns needs from the page. Every field falls back to the same default
2926
- * the React grid's matching prop does.
2927
- */
2928
- interface GridViewOptions<Row> {
2929
- /** Whether `pageRows` is one page of `displayRows` rather than all of it. Defaults to `false`. */
2930
- readonly paginated?: boolean | undefined;
2931
- /** What a page's `pageSize` counts once grouped. Defaults to `"group"`. */
2932
- readonly paginationUnit?: PaginationUnit | undefined;
2933
- readonly aggregates?: AggregateState<Row> | undefined;
2934
- /** Defaults to `"inline"`. */
2935
- readonly groupAggregateDisplay?: GroupAggregateDisplay | undefined;
2936
- readonly columnSizeDefaults?: Partial<ColumnSizeDefaults> | undefined;
2937
- readonly resizableColumns?: boolean | undefined;
2938
- readonly reorderableColumns?: boolean | undefined;
2939
- readonly groupByDraggableColumns?: boolean | undefined;
2940
- /** Defaults to `"fit"`, which only takes effect once `viewportWidth` is known. */
2941
- readonly resizeMode?: ResizeMode | undefined;
2942
- /**
2943
- * The width, in px, `"fit"` fills. `null` or absent before it has been
2944
- * measured, or where there is no viewport at all (an export in Node), and
2945
- * then columns keep their resolved widths.
2946
- */
2947
- readonly viewportWidth?: number | null | undefined;
2948
- }
2949
- /** What `resolveGridView` derives the view from. */
2950
- interface GridViewInput<Row, Node = string> {
2951
- readonly rows: readonly Row[];
2952
- readonly getRowId?: ((row: Row, index: number) => string) | undefined;
2953
- readonly columns: readonly ColumnDefinition<Row, Node>[];
2954
- readonly state: GridViewState<Row>;
2955
- readonly options: GridViewOptions<Row>;
2956
- }
2957
- /**
2958
- * What the user is looking at, derived once from `GridViewInput` — every
2959
- * list a renderer draws, and the ones an export, a toolbar or a status line
2960
- * reads, so none of them composes the pipeline for itself.
2961
- */
2962
- interface GridView<Row, Node = string> {
2963
- /** Every column, hidden ones included, ordered but not sized — what the data stages read. */
2964
- readonly dataColumns: readonly DataColumn<Row, Node>[];
2965
- /** The columns as rendered: visible, ordered and sized. */
2966
- readonly columns: readonly ResolvedColumn<Row, Node>[];
2967
- /** The rows, filtered then sorted. */
2968
- readonly rows: readonly ResolvedRow<Row>[];
2969
- /** `rows` grouped, with each group's aggregates attached — every page of it. */
2970
- readonly displayRows: readonly DisplayRow<Row>[];
2971
- /** The current page of `displayRows`; all of it when not paginated. */
2972
- readonly pageRows: readonly DisplayRow<Row>[];
2973
- /** `pageRows` narrowed to its data rows, in display order — what a range selection spans. */
2974
- readonly displayDataRows: readonly ResolvedRow<Row>[];
2975
- /** `1` when not paginated. */
2976
- readonly pageCount: number;
2977
- /** `state.pagination.pageIndex` clamped into range; `0` when not paginated. */
2978
- readonly pageIndex: number;
2979
- /** Every aggregate over all of `rows`, ungrouped and unpaginated. */
2980
- readonly grandTotal: AggregateResults;
2981
- }
1
+ import { G as GridControllerOptions, a as GridController, b as GridCommandTarget, c as GridMessages, d as GridCommandHost, e as GridCommandContext, f as GridCommand, M as MenuEntry, R as ResolvedMenuEntry, g as GridToolbarTarget, T as ToolbarItemAttributes, h as ToolbarEntry, i as ResolvedToolbarItem, C as ColumnType, j as ColumnSortState, S as SortDirection, k as ResolvedRow, D as DataColumn, F as FilterState, l as FieldPath, m as ResolvedColumn, n as SelectedCellRef, o as SelectedCell, p as SelectedColumn, P as PaginationUnit, q as DisplayRow, r as PaginationState, A as AggregateState, s as AggregateResults, t as GroupByState, u as GroupAggregateDisplay, v as ColumnVisibilityState, w as ColumnDefinition, x as GridViewInput, y as GridView, z as GridState, B as SerializedGridState, E as ExportTable, H as ExportSource, I as ExportWriter, J as GridExportOptions, K as ExportFile } from './filterEditor-B7C_n89V.js';
2
+ export { L as ALL_COLLAPSED, N as ALL_EXPANDED, O as AggregateFn, Q as AggregateSpec, U as Borders, V as BuiltInAggregate, W as BuiltInCommandIcon, X as BuiltInCommandId, Y as CellSelectEvent, Z as CellSelectionChangeEvent, _ as CellSelectionMode, $ as CellSelectionState, a0 as CellTemplateContext, a1 as ColumnAlignment, a2 as ColumnConstraints, a3 as ColumnFilterMenuOptions, a4 as ColumnOrderEvent, a5 as ColumnOrderState, a6 as ColumnResizeEvent, a7 as ColumnResolveOptions, a8 as ColumnSelectEvent, a9 as ColumnSelectionChangeEvent, aa as ColumnSizeDefaults, ab as ColumnSizingState, ac as ColumnSortEntry, ad as ColumnSortEvent, ae as ColumnVisibilityEvent, af as ColumnWrapConfig, ag as ColumnsSelectEvent, ah as ContextMenuOpenChangeEvent, ai as CopyContent, aj as CsvOptions, ak as DEFAULT_COLUMN_SIZES, al as DEFAULT_FILTER_VALUE_LIMIT, am as ExportCell, an as ExportColumn, ao as ExportDataRow, ap as ExportGroupRow, aq as ExportGroupSummaryRow, ar as ExportOptions, as as ExportRow, at as ExportScalar, au as ExportTotalRow, av as ExportWriteContext, aw as FilterChangeEvent, ax as FilterEntry, ay as FilterMenuUi, az as FilterOperator, aA as FilterOperatorFamily, aB as FilterPredicate, aC as FilterScalar, aD as FooterTemplateContext, aE as FormatLocale, aF as GridCommandActions, aG as GridCommandEvent, aH as GridCommandSource, aI as GridContextMenuArea, aJ as GridContextMenuEntries, aK as GridContextMenuOptions, aL as GridContextMenuRequest, aM as GridContextMenuTarget, aN as GridFilterMenuOptions, aO as GridFocus, aP as GridOptions, aQ as GridPanelKind, aR as GridToolbarOptions, aS as GridViewOptions, aT as GridViewState, aU as GroupByBarVisibility, aV as GroupByEntry, aW as GroupByEvent, aX as GroupExpansionEvent, aY as GroupExpansionState, aZ as GroupFilterEntry, a_ as HoverableConfig, a$ as JsonOptions, b0 as MenuItemEntry, b1 as MenuSubmenuEntry, b2 as OperatorFilterEntry, b3 as PaginationChangeEvent, b4 as PredicateFilterEntry, b5 as PrintDocument, b6 as PrintOptions, b7 as PrintOrientation, b8 as PrintPage, b9 as PrintSource, ba as ResizeMode, bb as ResolvedGroupRow, bc as ResolvedGroupSummaryRow, bd as ResolvedMenuItem, be as ResolvedMenuSeparator, bf as ResolvedMenuSubmenu, bg as ResolvedToolbarButton, bh as ResolvedToolbarCustom, bi as ResolvedToolbarMenu, bj as ResolvedToolbarSearch, bk as ResolvedToolbarSpacer, bl as RowPointerEvent, bm as RowProps, bn as RowSelectEvent, bo as RowSelectionChangeEvent, bp as RowsSelectEvent, bq as SelectIntent, br as SelectableConfig, bs as SelectionCallbacks, bt as SelectionDiff, bu as SelectionDiffEvent, bv as SelectionMode, bw as SelectionState, bx as SerializedFilterEntry, by as SerializedFilterScalar, bz as SerializedFilterState, bA as SerializedGroupFilterEntry, bB as SerializedOperatorFilterEntry, bC as SerializedValueFilterEntry, bD as TextFilterEntry, bE as ToolbarCustomEntry, bF as ValueFilterEntry, bG as accessDotted, bH as alignmentForType, bI as applyColumnOrder, bJ as applySelectionIntent, bK as bodyFocus, bL as buildExportTable, bM as builtInCommands, bN as clearSelection, bO as collapseAllGroups, bP as contextMenuEntries, bQ as createDefaultMessages, bR as csvWriter, bS as defaultContextMenu, bT as defaultFilterOperators, bU as defaultMessages, bV as defaultToolbar, bW as defineColumnsFromRows, bX as expandAllGroups, bY as exportPrintDocument, bZ as formatAggregateValue, b_ as formatCellValue, b$ as formatGroupValue, c0 as getColumnId, c1 as groupRowId, c2 as groupRows, c3 as headerFocus, c4 as isColumnFiltered, c5 as isGroupExpanded, c6 as isSameCell, c7 as jsonWriter, c8 as moveColumnBefore, c9 as moveGroupByBefore, ca as resolveColumnHeaderText, cb as resolveColumnLabel, cc as resolveColumnWidths, cd as resolveDataColumns, ce as resolveExportWriters, cf as resolveMessages, cg as resolveRowId, ch as selectAll, ci as selectCell, cj as selectOnly, ck as selectRange, cl as toCsv, cm as toJson, cn as toggleCellSelection, co as toggleGroupExpansion, cp as toggleSelection, cq as toolbarEntries } from './filterEditor-B7C_n89V.js';
2982
3
 
2983
4
  /**
2984
5
  * Creates the state container for one grid — see `GridController`. Hold one
@@ -3049,32 +70,6 @@ interface MenuResolveOptions<Row> {
3049
70
  */
3050
71
  declare function resolveMenu<Row>(entries: readonly MenuEntry<Row>[], options: MenuResolveOptions<Row>): readonly ResolvedMenuEntry[];
3051
72
 
3052
- /** Where an arrow, Home or End key moves a menu's focus. */
3053
- type MenuMove = "next" | "previous" | "first" | "last";
3054
- /**
3055
- * The index of the item focus moves to from `from` — `-1` when nothing is
3056
- * focused yet, so `"next"` lands on the first item and `"previous"` on the
3057
- * last. Separators are skipped and `"next"`/`"previous"` wrap round the
3058
- * ends; disabled items count, since they stay focusable for a screen reader
3059
- * to find. `-1` when there is no item at all.
3060
- *
3061
- * Takes anything with a `type`, so a behaviour that reads its items off the
3062
- * page can pass `{ type: "item" }` for each.
3063
- */
3064
- declare function nextMenuIndex(entries: readonly Pick<ResolvedMenuEntry, "type">[], from: number, move: MenuMove): number;
3065
- /**
3066
- * The index of the item `query` — what was typed, buffered for a moment —
3067
- * picks, matched case-insensitively against the start of each label and
3068
- * wrapping round the end; `-1` when none matches.
3069
- *
3070
- * `from` is the item focused now. A single letter, or the same letter
3071
- * typed again and again, searches from the item after it, so repeating a
3072
- * letter steps through every item it starts. A longer query searches from
3073
- * `from` itself, so the item already found stays put while what is typed
3074
- * still matches it.
3075
- */
3076
- declare function typeaheadIndex(labels: readonly string[], from: number, query: string): number;
3077
-
3078
73
  /** What `resolveToolbar` resolves a toolbar's entries against. */
3079
74
  interface ToolbarResolveOptions<Row> {
3080
75
  /** Every command the grid knows, by id — see `resolveCommands`. */
@@ -3110,382 +105,6 @@ interface ToolbarResolveOptions<Row> {
3110
105
  */
3111
106
  declare function resolveToolbar<Row>(entries: readonly ToolbarEntry<Row>[], options: ToolbarResolveOptions<Row>): readonly ResolvedToolbarItem[];
3112
107
 
3113
- /** What `fitToolbarItems` fits: a toolbar's entries, by width, into its space. */
3114
- interface ToolbarFitInput {
3115
- /** Each entry's width, in order — `0` for a spacer, whose width is only the space left over. */
3116
- readonly widths: readonly number[];
3117
- /** The width the entries share. */
3118
- readonly available: number;
3119
- /** The width of the "More" button the entries that do not fit go into. */
3120
- readonly moreWidth: number;
3121
- /** Whether each entry, in order, stays however little room there is. */
3122
- readonly pinned: readonly boolean[];
3123
- }
3124
- /**
3125
- * How many of a toolbar's entries fit, from the start: the first `count`
3126
- * stay in the toolbar, with every pinned entry after them, and the rest go
3127
- * into a "More" menu.
3128
- *
3129
- * Pinned entries take their room first, wherever they are. Room for "More"
3130
- * is kept only when something does not fit — when everything does, the
3131
- * result is every entry and no "More" is drawn. Entries are taken in order
3132
- * and the first that does not fit ends the count, so the toolbar keeps its
3133
- * order rather than filling gaps with later, narrower entries; one with no
3134
- * width, a spacer, fits wherever the entries before it did.
3135
- */
3136
- declare function fitToolbarItems({ widths, available, moreWidth, pinned, }: ToolbarFitInput): number;
3137
- /**
3138
- * Whether a toolbar entry stays in the toolbar however narrow it gets: the
3139
- * search box and custom entries, which have no menu item to become.
3140
- */
3141
- declare function isPinnedToolbarItem(item: Pick<ResolvedToolbarItem, "type">): boolean;
3142
- /** A toolbar split at the count `fitToolbarItems` gave — see `splitToolbarItems`. */
3143
- interface ToolbarSplit {
3144
- /** What stays in the toolbar. */
3145
- readonly shown: readonly ResolvedToolbarItem[];
3146
- /** The "More" menu's entries, empty when everything fits. */
3147
- readonly overflow: readonly ResolvedMenuEntry[];
3148
- }
3149
- /**
3150
- * `items` split at the first `fit`: those before it, and every pinned item,
3151
- * stay in the toolbar; the rest become the "More" menu's entries — a button
3152
- * an item, checked where it was pressed, and a dropdown a submenu. Neither
3153
- * side keeps a separator at its ends, doubled, or beside a spacer.
3154
- */
3155
- declare function splitToolbarItems(items: readonly ResolvedToolbarItem[], fit: number): ToolbarSplit;
3156
-
3157
- /**
3158
- * What a search box shows for `filter`: the global text entry's query — the
3159
- * one naming no column — without the `%` anchors that make it a "contains"
3160
- * match, or `""` when there is none. A `%` the user typed inside the text
3161
- * stays: only the first and last characters are anchors.
3162
- */
3163
- declare function searchTextOf<Row>(filter: FilterState<Row>): string;
3164
- /**
3165
- * `filter` with its global text entry set to search for `text` anywhere in
3166
- * any column — the query `%text%` — or removed for an empty `text`. Every
3167
- * entry naming a column stays as it was. `filter` itself, unchanged, when
3168
- * it already searches for `text`.
3169
- *
3170
- * `text` is written as typed, spaces and all: a search box reads its text
3171
- * back from the filter, and trimming here would take a space away from
3172
- * under the caret as the user types it.
3173
- */
3174
- declare function setSearchText<Row>(filter: FilterState<Row>, text: string): FilterState<Row>;
3175
-
3176
- /**
3177
- * How a column of `type` aligns by default. Numeric types align right so that
3178
- * their digits line up by place value; everything else reads from the left.
3179
- */
3180
- declare function alignmentForType(type: ColumnType): ColumnAlignment;
3181
- /**
3182
- * Derives one column per field across `rows`, in the order each field is first
3183
- * seen — so a key that only appears in a later row still gets a column,
3184
- * appended at the end. Nested objects contribute their non-object properties
3185
- * as `"Parent.Child"`; anything deeper is skipped, as is the nested object
3186
- * itself.
3187
- *
3188
- * Order follows `Object.entries`, which lists integer-like keys first
3189
- * regardless of the order they were written in.
3190
- *
3191
- * `Node` is whatever the caller's renderer draws: an inferred column sets no
3192
- * template, so it suits any.
3193
- */
3194
- declare function defineColumnsFromRows<Row, Node = string>(rows: readonly Row[]): readonly ColumnDefinition<Row, Node>[];
3195
- /**
3196
- * The key state about a column is stored under, and the key it renders with.
3197
- * Every such lookup goes through here so the two can never disagree.
3198
- */
3199
- declare function getColumnId<Row>(column: ColumnDefinition<Row, unknown>): string;
3200
- /**
3201
- * The key state about a row is stored under, and the key it renders with — the
3202
- * row's counterpart to `getColumnId`, and for the same reason: every such
3203
- * lookup goes through here so no two can disagree.
3204
- *
3205
- * Falls back to the position so a grid given no `getRowId` still works. That
3206
- * fallback ties a selection to where a row sits rather than to the row, so
3207
- * anything that sorts, filters or pages its data has to supply one — otherwise
3208
- * a re-sort leaves the same positions selected under different rows.
3209
- */
3210
- declare function resolveRowId<Row>(row: Row, index: number, getRowId?: (row: Row, index: number) => string): string;
3211
- /**
3212
- * What a column's header shows: its own `headerTemplate`, called first if it is
3213
- * a function, or else its plain-text `header`, or else a label read off the
3214
- * field path.
3215
- */
3216
- declare function resolveColumnLabel<Row, Node>(column: ColumnDefinition<Row, Node>): Node | string;
3217
- /**
3218
- * A column's name as text, for wherever markup will not do — an
3219
- * announcement, an export. Its `header` first, even beside a
3220
- * `headerTemplate`, since a template's output need not be text; then the
3221
- * label `resolveColumnLabel` gives, when that is a string; then the label
3222
- * read off the field path.
3223
- */
3224
- declare function resolveColumnHeaderText<Row>(column: ColumnDefinition<Row, unknown>): string;
3225
- /** Which of a column header's keyboard interactions to announce. */
3226
- interface KeyShortcutCapabilities {
3227
- reorderable: boolean;
3228
- resizable: boolean;
3229
- sortable: boolean;
3230
- groupable: boolean;
3231
- /** Whether the column has a filter menu the header opens. Defaults to `false`. */
3232
- filterable?: boolean | undefined;
3233
- /** Whether the header opens the grid's context menu. Defaults to `false`. */
3234
- contextMenu?: boolean | undefined;
3235
- }
3236
- /**
3237
- * The `aria-keyshortcuts` string for a column header, naming only the keys
3238
- * that column actually responds to — so the keys are discoverable, since
3239
- * none of them is a convention a user would try unprompted.
3240
- */
3241
- declare function buildKeyShortcuts(capabilities: KeyShortcutCapabilities): string;
3242
- /**
3243
- * Accesses a value at a dotted path, e.g. `foo.bar.baz`.
3244
- *
3245
- * @param obj The object to access
3246
- * @param path Path to the value, e.g. `"foo.bar"`
3247
- * @returns The value at `path`, or `undefined` if it doesn't exist
3248
- */
3249
- declare function accessDotted(obj: unknown, path: string): unknown;
3250
-
3251
- /**
3252
- * The header's row index. One coordinate space covers the header and the body
3253
- * so that arrowing up out of the first row reaches the header without a case
3254
- * of its own, and every other move is plain arithmetic.
3255
- */
3256
- declare const HEADER_ROW = -1;
3257
- /** The cell the grid's single tab stop sits on. */
3258
- interface GridFocus {
3259
- readonly rowIndex: number;
3260
- readonly columnIndex: number;
3261
- }
3262
- /** The modifier keys held with a navigation key press. */
3263
- interface NavigationModifiers {
3264
- readonly ctrlKey: boolean;
3265
- readonly metaKey: boolean;
3266
- readonly altKey: boolean;
3267
- readonly shiftKey: boolean;
3268
- }
3269
- /**
3270
- * Holds a coordinate inside the grid, so that a focus surviving a column
3271
- * removal or a shorter page never leaves the grid with no tab stop at all —
3272
- * which is a grid a keyboard cannot reach.
3273
- */
3274
- declare function clampFocus(focus: GridFocus, rowCount: number, columnCount: number): GridFocus;
3275
- /**
3276
- * The focus a navigation key press moves to, or `null` when the key isn't
3277
- * this grid's to handle — left for the browser or another handler.
3278
- *
3279
- * `pageSize` is a pre-measured row count rather than a callback: this
3280
- * function takes plain data only, so a caller measures the viewport once and
3281
- * hands over the number.
3282
- *
3283
- * `isSkippableRow` names rows the vertical moves (`ArrowUp`/`ArrowDown`/
3284
- * `PageUp`/`PageDown`/`Ctrl+End`) never land a tab stop on — a group's own
3285
- * summary row (`groupAggregateDisplay: "row"`), which still occupies a real
3286
- * row slot for `rowCount`/`aria-rowindex` purposes but is presentational,
3287
- * not a stop of its own. Left/right and plain `Home`/`End` stay row-scoped
3288
- * and so never consult it. Defaults to skipping nothing, so every existing
3289
- * caller (and every horizontal move) is unaffected.
3290
- */
3291
- declare function nextFocusForKey(key: string, modifiers: NavigationModifiers, focus: GridFocus, rowCount: number, columnCount: number, pageSize: number, isSkippableRow?: (rowIndex: number) => boolean): GridFocus | null;
3292
-
3293
- /**
3294
- * Puts `columns` in the order `order` gives. Ids it lists come first, in that
3295
- * order; columns it omits keep their position among the definitions and
3296
- * follow. Ids naming no column are ignored.
3297
- *
3298
- * Tolerating both gaps is what lets a stored order outlive the column list it
3299
- * was made against.
3300
- */
3301
- declare function applyColumnOrder<Row, Node>(columns: readonly ColumnDefinition<Row, Node>[], order: ColumnOrderState): readonly ColumnDefinition<Row, Node>[];
3302
- /**
3303
- * `columns` in the order `order` gives, each paired with its id — the
3304
- * width-free column list the data stages (filter, sort, group, aggregate)
3305
- * read. Ordered here, ahead of sizing, so every later stage sees the one
3306
- * already-ordered list and no part of the grid has to know a reorder
3307
- * happened.
3308
- */
3309
- declare function resolveDataColumns<Row, Node>(columns: readonly ColumnDefinition<Row, Node>[], order: ColumnOrderState): readonly DataColumn<Row, Node>[];
3310
- /**
3311
- * The order with `movedId` lifted out and put back in front of `beforeId`, or
3312
- * at the end when that is `null`.
3313
- *
3314
- * Returns `orderedIds` itself when the move changes nothing, so callers can
3315
- * treat an unchanged reference as "no move happened".
3316
- */
3317
- declare function moveColumnBefore(orderedIds: ColumnOrderState, movedId: string, beforeId: string | null): ColumnOrderState;
3318
- /**
3319
- * Whether moving `movedId` in front of `beforeId` would rearrange anything, so
3320
- * that a drop indicator promises exactly the moves that happen.
3321
- *
3322
- * Defined against `moveColumnBefore` rather than restating its conditions, so
3323
- * the two cannot disagree about what a no-op is.
3324
- */
3325
- declare function movesColumn(orderedIds: ColumnOrderState, movedId: string, beforeId: string | null): boolean;
3326
- /**
3327
- * The id a drop on `side` of `targetId` lands in front of, which is `null`
3328
- * past the last column.
3329
- *
3330
- * "After C" and "before D" name the same gap, so collapsing both to one id
3331
- * keeps a drop target a single nullable string.
3332
- */
3333
- declare function resolveDropBefore(orderedIds: ColumnOrderState, targetId: string, side: DropSide): string | null;
3334
- /**
3335
- * The `beforeId` a keyboard nudge on `columnId` produces, for `onDrop` to
3336
- * apply the same way a pointer drop does — or `undefined` when the nudge is a
3337
- * no-op: `columnId` is not in `orderedIds`, or the nudge would move it left
3338
- * of the start.
3339
- *
3340
- * `null` is a real answer here, not "no-op": it means append to the end, the
3341
- * same convention `moveColumnBefore` uses.
3342
- */
3343
- declare function resolveKeyboardDropTarget(orderedIds: ColumnOrderState, columnId: string, direction: -1 | 1): string | null | undefined;
3344
-
3345
- /**
3346
- * The selection with `id` added if absent and removed if present — a
3347
- * Ctrl-click, or Space on the focused member.
3348
- *
3349
- * The mode is enforced here rather than by each caller, so `"single"` cannot
3350
- * accumulate no matter which interaction reaches it. Returns `selection`
3351
- * itself when `mode` is `false`, keeping the unchanged-reference contract
3352
- * `moveColumnBefore` set: a caller treats an unchanged reference as "nothing
3353
- * happened" and neither renders nor reports.
3354
- */
3355
- declare function toggleSelection(selection: SelectionState, id: string, mode: SelectionMode): SelectionState;
3356
- /**
3357
- * The selection reduced to `id` alone — a plain click, which discards what
3358
- * came before rather than adding to it.
3359
- *
3360
- * Never deselects, so clicking the one selected row leaves it selected.
3361
- * Letting go of it is Ctrl-click's job, and `toggleSelection`'s.
3362
- */
3363
- declare function selectOnly(selection: SelectionState, id: string, mode: SelectionMode): SelectionState;
3364
- /**
3365
- * The selection replaced by every id from `anchorId` to `focusId` inclusive — a
3366
- * Shift-click. The two may be given in either order.
3367
- *
3368
- * Spans `orderedIds`, the order as displayed, rather than the selection's own:
3369
- * the range a user drew across the screen is the range they mean, whatever
3370
- * order they clicked its ends in. Degrades to `selectOnly` under `"single"`,
3371
- * where a range has nowhere to go.
3372
- */
3373
- declare function selectRange(selection: SelectionState, orderedIds: readonly string[], anchorId: string, focusId: string, mode: SelectionMode): SelectionState;
3374
- /**
3375
- * Every id in `orderedIds`, or `selection` untouched under any mode but
3376
- * `"multiple"` — there is no selecting all of one thing.
3377
- */
3378
- declare function selectAll(selection: SelectionState, orderedIds: readonly string[], mode: SelectionMode): SelectionState;
3379
- declare function clearSelection(selection: SelectionState): SelectionState;
3380
- /**
3381
- * What one transition added and what it removed.
3382
- *
3383
- * Defined here rather than in an adapter so that every callback reporting a
3384
- * selection change reads one answer, and a select and a deselect fired for the
3385
- * same interaction cannot disagree about which it was.
3386
- */
3387
- declare function diffSelection(previous: SelectionState, next: SelectionState): SelectionDiff;
3388
- declare function isSameCell(a: CellSelectionState, b: CellSelectionState): boolean;
3389
- /**
3390
- * The cell selection moved to `cell` — a plain click. Idempotent: clicking the
3391
- * selected cell again leaves it selected, matching `selectOnly`.
3392
- */
3393
- declare function selectCell(selection: CellSelectionState, cell: SelectedCellRef, mode: CellSelectionMode): CellSelectionState;
3394
- /**
3395
- * The cell selection moved to `cell`, or cleared when it is already there — a
3396
- * Ctrl-click, matching `toggleSelection`.
3397
- */
3398
- declare function toggleCellSelection(selection: CellSelectionState, cell: SelectedCellRef, mode: CellSelectionMode): CellSelectionState;
3399
- /**
3400
- * The intent a click or key press carries, by the modifiers held with it.
3401
- *
3402
- * `toggleOnClick` makes the unmodified press a toggle — the
3403
- * `selectable.toggleOnClick` checklist behaviour — leaving Shift and Ctrl
3404
- * to mean what they always do.
3405
- */
3406
- declare function intentOf(event: {
3407
- ctrlKey: boolean;
3408
- metaKey: boolean;
3409
- shiftKey: boolean;
3410
- }, options?: {
3411
- toggleOnClick?: boolean | undefined;
3412
- }): SelectIntent;
3413
- /**
3414
- * The transform an intent asks for. A function rather than a branch inside
3415
- * each caller, so a row and a column cannot come to mean different things by
3416
- * the same click.
3417
- */
3418
- declare function applySelectionIntent(selection: SelectionState, orderedIds: readonly string[], anchorId: string | null, id: string, intent: SelectIntent, mode: SelectionMode): SelectionState;
3419
-
3420
- /**
3421
- * Applied to any column that does not size itself. The minimum is a width a
3422
- * header stays legible at rather than a measured value — a column dragged
3423
- * narrower than this reads as a rendering fault.
3424
- */
3425
- declare const DEFAULT_COLUMN_SIZES: ColumnSizeDefaults;
3426
- /** How far one arrow key press moves a column edge. */
3427
- declare const KEYBOARD_STEP = 10;
3428
- /**
3429
- * The bounds `column` may be sized between. Resolved in one place so that a
3430
- * drag, a clamp and an auto-fit cannot disagree about a column's limits.
3431
- */
3432
- declare function resolveColumnConstraints<Row>(column: ColumnDefinition<Row, unknown>, defaults?: Partial<ColumnSizeDefaults>): ColumnConstraints;
3433
- /** Holds `width` within `constraints`. */
3434
- declare function clampColumnWidth(width: number, constraints: ColumnConstraints): number;
3435
- /**
3436
- * Pairs each column with everything needed to render it — the width it sits
3437
- * at, the label its header shows, whether it may be resized and how its cells
3438
- * align. Widths take the first of the sizing state, the column's own `width`,
3439
- * and the default, then clamp.
3440
- *
3441
- * The sizing state winning means a user's drag outlives a re-render; a column
3442
- * absent from it still tracks a `width` edited in the definition.
3443
- */
3444
- declare function resolveColumnWidths<Row, Node>(columns: readonly ColumnDefinition<Row, Node>[], sizing: ColumnSizingState, options?: ColumnResolveOptions): readonly ResolvedColumn<Row, Node>[];
3445
- declare function totalColumnWidth<Row, Node>(resolved: readonly ResolvedColumn<Row, Node>[]): number;
3446
- /**
3447
- * Opens a resize. The session captures its constraints and starting point up
3448
- * front, so applying a pointer position later is arithmetic on numbers alone —
3449
- * which is what keeps the drag testable without a DOM.
3450
- *
3451
- * @param startPosition Where the pointer went down, on the axis being dragged.
3452
- */
3453
- declare function beginColumnResize<Row>(column: ColumnDefinition<Row, unknown>, startWidth: number, startPosition: number, defaults?: Partial<ColumnSizeDefaults>): ColumnResizeSession;
3454
- /**
3455
- * The width the dragged column takes with the pointer at `position`. The delta
3456
- * is signed, so a right-to-left adapter negates it and nothing else changes.
3457
- */
3458
- declare function applyColumnResize(session: ColumnResizeSession, position: number): number;
3459
- /**
3460
- * Fits columns to `availableWidth`: grows them to fill leftover space, or
3461
- * shrinks them to relieve an overflow, in both cases proportionally to each
3462
- * column's current width. Columns the user has sized are left alone in
3463
- * either direction, so dragging one column neither rubber-bands it back nor
3464
- * has it absorb a squeeze meant for the rest.
3465
- *
3466
- * Growing stops at each column's `maxWidth`; shrinking stops at its
3467
- * `minWidth`. If shrinking every adjustable column to its floor still does
3468
- * not reach `availableWidth`, the columns are returned untouched and the
3469
- * container scrolls rather than crushing them further.
3470
- */
3471
- declare function fitColumnsToWidth<Row, Node>(resolved: readonly ResolvedColumn<Row, Node>[], availableWidth: number, defaults?: Partial<ColumnSizeDefaults>): readonly ResolvedColumn<Row, Node>[];
3472
- /**
3473
- * The width a column needs to show `measuredWidth` of content.
3474
- *
3475
- * `padding` is an allowance on top of the measurement, since a column sized to
3476
- * exactly its content can still round down into an ellipsis.
3477
- */
3478
- declare function sizeColumnToContent(measuredWidth: number, constraints: ColumnConstraints, padding?: number): number;
3479
- /**
3480
- * `current` with `columnId` reverted to its width in `base` — or omitted
3481
- * entirely if `base` had none — for Escape to restore a resize in progress.
3482
- *
3483
- * A column with no stored width in `base` is correctly omitted by deleting
3484
- * the key rather than merging its `base` width back in, which would
3485
- * otherwise leave it pinned and hidden from auto-fit.
3486
- */
3487
- declare function revertColumnSize(current: ColumnSizingState, base: ColumnSizingState, columnId: string): ColumnSizingState;
3488
-
3489
108
  /**
3490
109
  * Compares two cell values the way `type` implies — numerically for the
3491
110
  * numeric types, chronologically for the date/time types, lexically
@@ -3589,86 +208,6 @@ declare function clearAllFilters<Row>(filter: FilterState<Row>): FilterState<Row
3589
208
  */
3590
209
  declare function filterRows<Row>(rows: readonly ResolvedRow<Row>[], filter: FilterState<Row>, columns: readonly DataColumn<Row, unknown>[]): readonly ResolvedRow<Row>[];
3591
210
 
3592
- /**
3593
- * This group's id, from its path. Every group-id producer/consumer in this
3594
- * package goes through this — never join `path` by hand elsewhere.
3595
- *
3596
- * `JSON.stringify` rather than a delimiter join: a delimiter would have to be
3597
- * escaped in every segment to stay collision-free against a value that
3598
- * legitimately contains it, and `JSON.stringify` already draws that
3599
- * boundary between array entries for free.
3600
- */
3601
- declare function groupRowId(path: readonly unknown[]): string;
3602
- /**
3603
- * `rows`, regrouped into `groupBy`'s stacked levels — a group header per
3604
- * distinct value at each level, ordered by `compareValues` per that level's
3605
- * own `direction`, followed depth-first by its nested groups and/or data
3606
- * rows. A collapsed group (its `groupId` present in `expansion`) contributes
3607
- * only its own header, nothing beneath it — but its `count` still reports
3608
- * the group's full leaf-row count either way.
3609
- *
3610
- * Filter and sort are expected to have already run (see `resolveShownRows`):
3611
- * this only reshapes their output, and never changes which rows appear or
3612
- * their relative order within a group.
3613
- *
3614
- * `rowIndex` and `datasetIndex` are renumbered across the whole flattened
3615
- * output, header rows included — the same invariant `sortRows`/`filterRows`
3616
- * keep for a `ResolvedRow`, extended to `ResolvedGroupRow` since `GridBody`
3617
- * addresses both kinds by the same flat position, and `aria-rowindex`
3618
- * counts both.
3619
- *
3620
- * Returns `rows` itself, untouched, when `groupBy` is empty or names only
3621
- * columns absent from `columns` — a stored grouping tolerates a column
3622
- * removed from the definition the same way a stored `ColumnSortState` does.
3623
- */
3624
- declare function groupRows<Row>(rows: readonly ResolvedRow<Row>[], groupBy: GroupByState, expansion: GroupExpansionState, columns: readonly DataColumn<Row, unknown>[]): readonly DisplayRow<Row>[];
3625
- /**
3626
- * The expansion with `groupId` collapsed if it was expanded, or expanded if
3627
- * it was collapsed.
3628
- */
3629
- declare function toggleGroupExpansion(expansion: GroupExpansionState, groupId: string): GroupExpansionState;
3630
- /** `expansion` reduced to empty — every group expanded. Mirrors `clearAllFilters`. */
3631
- declare function expandAllGroups(expansion: GroupExpansionState): GroupExpansionState;
3632
- /**
3633
- * Every group id present in `rows` — for collapsing every group currently
3634
- * shown in one call. Operates on the already-grouped display, not the raw
3635
- * grouping, so a group hidden beneath an already-collapsed ancestor (and so
3636
- * absent from `rows`) keeps whatever expansion it already had rather than
3637
- * being forced closed too; expanding that ancestor again reveals it exactly
3638
- * as it was left.
3639
- *
3640
- * Group headers only: a summary row (`groupAggregateDisplay: "row"`) carries
3641
- * its group's id too, and counting it would list that group twice.
3642
- */
3643
- declare function collapseAllGroups<Row>(rows: readonly DisplayRow<Row>[]): GroupExpansionState;
3644
- /**
3645
- * `groupBy` with `columnId` positioned in front of `beforeColumnId` — or at
3646
- * the end when that is `null` — inserting a fresh entry if `columnId` isn't
3647
- * already part of the stack, or lifting its existing entry out and back in
3648
- * if it is. The one function both a header dropped on the group-by bar and
3649
- * a chip dragged within it need: the former's `columnId` is usually new to
3650
- * the stack, the latter's never is, and this doesn't need to be told which.
3651
- *
3652
- * An existing entry keeps its own object (and so its own `direction`)
3653
- * rather than being rebuilt, so a level merely repositioned stays
3654
- * reference-equal at its new index — the same reason `moveColumnBefore`
3655
- * moves ids rather than rebuilding them.
3656
- *
3657
- * Returns `groupBy` itself, untouched, when the move changes nothing: a
3658
- * drop on the entry's own id, or back into the gap it already occupies, or
3659
- * naming a `beforeColumnId` absent from the stack. Inserting a column not
3660
- * yet in the stack is never a no-op.
3661
- */
3662
- declare function moveGroupByBefore(groupBy: GroupByState, columnId: string, beforeColumnId: string | null): GroupByState;
3663
- /**
3664
- * Whether moving `columnId` in front of `beforeColumnId` would change
3665
- * `groupBy` at all, so that a drop indicator promises exactly the move that
3666
- * happens. Defined against `moveGroupByBefore` rather than restating its
3667
- * conditions, the same relationship `movesColumn` keeps with
3668
- * `moveColumnBefore`.
3669
- */
3670
- declare function movesGroupBy(groupBy: GroupByState, columnId: string, beforeColumnId: string | null): boolean;
3671
-
3672
211
  /**
3673
212
  * `rows`, filtered then sorted — the one function `DataGrid.tsx` (and any
3674
213
  * future framework binding) calls instead of composing `filterRows`/
@@ -3735,25 +274,6 @@ interface PaginateRowsOptions {
3735
274
  */
3736
275
  declare function paginateRows<Row>(rows: readonly DisplayRow<Row>[], pagination: PaginationState, options?: PaginateRowsOptions): PaginatedRows<Row>;
3737
276
 
3738
- type PaginationWindowEntry = number | "ellipsis";
3739
- /**
3740
- * Which page numbers a numbered pager should show for `currentPage` of
3741
- * `pageCount` — the boundary + sibling windowing MUI's `usePagination` uses.
3742
- * Always includes the first/last `boundaryCount` pages and a run of
3743
- * `2 * siblingCount + 1` pages around `currentPage`, slid inwards rather than
3744
- * cut short near either end, with one slot between each boundary and that
3745
- * run holding either the single page it skips or an `"ellipsis"`.
3746
- *
3747
- * So once `pageCount` exceeds `2 * boundaryCount + 2 * siblingCount + 3`,
3748
- * every window is exactly that many entries long, wherever `currentPage`
3749
- * sits: a pager drawing one fixed-width slot per entry keeps its trailing
3750
- * controls in place as the user pages through. Below that, every page shows.
3751
- */
3752
- declare function paginationWindow(currentPage: number, pageCount: number, options?: {
3753
- boundaryCount?: number | undefined;
3754
- siblingCount?: number | undefined;
3755
- }): readonly PaginationWindowEntry[];
3756
-
3757
277
  /**
3758
278
  * `rows` reduced through every spec in `specs`, keyed by `spec.id ??
3759
279
  * spec.columnId`. A custom `fn` (a plain function, not a `BuiltInAggregate`
@@ -3793,253 +313,6 @@ declare function applyColumnVisibility<Row, Node>(columns: readonly DataColumn<R
3793
313
  */
3794
314
  declare function setColumnVisibility<Row>(columns: readonly DataColumn<Row, unknown>[], visibility: ColumnVisibilityState, columnIds: readonly string[], visible: boolean): ColumnVisibilityState;
3795
315
 
3796
- /**
3797
- * What one column's filter looks like to an editor — which of its forms can
3798
- * show it, or that none can.
3799
- *
3800
- * - `"none"`: no entry touches the column.
3801
- * - `"values"`: a checklist — one `in` entry, optionally OR-grouped with an
3802
- * `isEmpty` on the same column (`includeBlanks`).
3803
- * - `"conditions"`: one or two operator entries on the column (any but
3804
- * `in`), at the top level (ANDed) or alone in one group with its
3805
- * combinator.
3806
- * - `"custom"`: anything else that touches the column — a text query, a
3807
- * predicate, a group spanning several columns. An editor shows it as
3808
- * such, and applying an editor's draft replaces it.
3809
- */
3810
- type ColumnFilterShape<Row> = {
3811
- readonly kind: "none";
3812
- } | {
3813
- readonly kind: "values";
3814
- readonly values: readonly FilterScalar[];
3815
- readonly includeBlanks: boolean;
3816
- } | {
3817
- readonly kind: "conditions";
3818
- readonly conditions: readonly OperatorFilterEntry<Row>[];
3819
- readonly combinator: "and" | "or";
3820
- } | {
3821
- readonly kind: "custom";
3822
- };
3823
- /** One distinct value a column holds, as a checklist offers it. */
3824
- interface ColumnValueOption {
3825
- readonly value: Exclude<FilterScalar, null>;
3826
- /** The value as the column prints it — what a search matches against. */
3827
- readonly label: string;
3828
- /** How many rows hold it, among the rows the other columns' filters keep. */
3829
- readonly count: number;
3830
- }
3831
- /** What `columnValueOptions` narrows its list by. */
3832
- interface ColumnValueQuery {
3833
- /** Keeps the values whose label contains this, ignoring case. */
3834
- readonly search?: string;
3835
- /** Keeps at most this many values, first in sorted order. */
3836
- readonly limit?: number;
3837
- /** The locale labels are formatted for — the grid's own `locale`. */
3838
- readonly locale?: FormatLocale;
3839
- /**
3840
- * The grid's own `messages`, over the defaults: a boolean is labelled
3841
- * `booleanTrue`/`booleanFalse`, as its cells print it.
3842
- */
3843
- readonly messages?: Partial<GridMessages>;
3844
- }
3845
- interface ColumnValueOptions {
3846
- /** The distinct values, sorted as the column sorts, searched and cut to `limit`. */
3847
- readonly options: readonly ColumnValueOption[];
3848
- /** How many values matched the search, before `limit` cut them. */
3849
- readonly total: number;
3850
- /** Whether `limit` left values out. */
3851
- readonly truncated: boolean;
3852
- /** How many of the same rows hold a blank — `null`, `undefined` or `""`. */
3853
- readonly blanks: number;
3854
- /**
3855
- * The column's `type`, which tells values apart the way an `in` filter
3856
- * does — on a date column, a date string and the `Date` it names are one
3857
- * value. `initialFilterEditorDraft` carries it into the draft.
3858
- */
3859
- readonly columnType?: ColumnType | undefined;
3860
- }
3861
- /**
3862
- * A checklist or condition editor's working copy of one column's filter,
3863
- * changed by `filterEditorReducer` and turned into a filter by
3864
- * `draftToFilter` only when the user applies it — so cancelling is just
3865
- * dropping the draft.
3866
- */
3867
- interface FilterEditorDraft<Row> {
3868
- /** Which half of the draft `draftToFilter` applies: the last one changed. */
3869
- readonly mode: "values" | "conditions";
3870
- /** Every value the editor offers, from `columnValueOptions`. */
3871
- readonly options: readonly ColumnValueOption[];
3872
- /** How many rows hold a blank; the blanks entry only matters when some do. */
3873
- readonly blanks: number;
3874
- readonly search: string;
3875
- /** The checked values, keyed as an `in` filter on the column keys them. */
3876
- readonly checked: ReadonlyMap<string, FilterScalar>;
3877
- readonly includeBlanks: boolean;
3878
- readonly conditions: readonly OperatorFilterEntry<Row>[];
3879
- readonly combinator: "and" | "or";
3880
- /** The column's `type`, from `ColumnValueOptions` — what values are keyed by. */
3881
- readonly columnType?: ColumnType | undefined;
3882
- }
3883
- type FilterEditorAction<Row> = {
3884
- readonly type: "search";
3885
- readonly search: string;
3886
- } | {
3887
- readonly type: "toggleValue";
3888
- readonly value: FilterScalar;
3889
- }
3890
- /** Checks every value the search shows, or unchecks them once all are. */
3891
- | {
3892
- readonly type: "toggleAll";
3893
- } | {
3894
- readonly type: "setIncludeBlanks";
3895
- readonly includeBlanks: boolean;
3896
- } | {
3897
- readonly type: "setConditions";
3898
- readonly conditions: readonly OperatorFilterEntry<Row>[];
3899
- /** Keeps the draft's own when omitted. */
3900
- readonly combinator?: "and" | "or";
3901
- }
3902
- /** Back to "no filter": every value checked, no conditions, no search. */
3903
- | {
3904
- readonly type: "clear";
3905
- };
3906
- /** A select-all checkbox's state over the values the search shows. */
3907
- type SelectAllState = "checked" | "unchecked" | "mixed";
3908
- /**
3909
- * How `filter` filters `columnId`, as one of the forms an editor can show —
3910
- * see `ColumnFilterShape`. Entries about other columns don't count, nor do
3911
- * entries across every column (a global search).
3912
- */
3913
- declare function describeColumnFilter<Row>(filter: FilterState<Row>, columnId: string): ColumnFilterShape<Row>;
3914
- /**
3915
- * Whether `filter` filters `columnId` — whether `describeColumnFilter` reads
3916
- * it as anything but `"none"` — for a header to show its column as
3917
- * filtered. A global search filters every column alike, so it marks none.
3918
- */
3919
- declare function isColumnFiltered<Row>(filter: FilterState<Row>, columnId: string): boolean;
3920
- /**
3921
- * The distinct values `columnId` holds, for a checklist editor: each with
3922
- * its label and how many rows hold it.
3923
- *
3924
- * Counted over the rows every *other* column's filter keeps — every entry
3925
- * except those `describeColumnFilter` would count for this column — so a
3926
- * column's list cascades from the other filters without its own pick
3927
- * hiding the values the user unchecked. Values are told apart as an `in`
3928
- * filter tells them apart — as grouping does, except that a date column's
3929
- * date strings are the dates they name — ordered as the column sorts, and
3930
- * labelled as its cells print, a boolean in `query.messages`' words; blanks
3931
- * are counted apart, in `blanks`.
3932
- *
3933
- * Costs one pass over `rows` (tens of milliseconds at 100k rows), so compute
3934
- * it when an editor opens rather than on every render, and hand the whole
3935
- * list to `initialFilterEditorDraft`, whose search needs no recount.
3936
- */
3937
- declare function columnValueOptions<Row>(rows: readonly Row[], dataColumns: readonly DataColumn<Row, unknown>[], filter: FilterState<Row>, columnId: string, query?: ColumnValueQuery): ColumnValueOptions;
3938
- /**
3939
- * A draft showing `shape` over `values` — what an editor opens with. A
3940
- * column with no filter, or one only a custom editor could show, opens with
3941
- * every value checked; a checklist with its own values checked, kept even
3942
- * when the other filters now hide them; conditions as they are.
3943
- */
3944
- declare function initialFilterEditorDraft<Row>(shape: ColumnFilterShape<Row>, values: ColumnValueOptions): FilterEditorDraft<Row>;
3945
- /** The options the draft's search shows — those a select-all acts on. */
3946
- declare function visibleFilterOptions<Row>(draft: FilterEditorDraft<Row>): readonly ColumnValueOption[];
3947
- /**
3948
- * The select-all checkbox's state: whether every value the search shows is
3949
- * checked, none is, or some are — blanks included while nothing is
3950
- * searched.
3951
- */
3952
- declare function selectAllState<Row>(draft: FilterEditorDraft<Row>): SelectAllState;
3953
- /**
3954
- * The next draft after `action` — a plain reducer, so a renderer can hold
3955
- * the draft in whatever state it has (`useReducer`, a signal, a store).
3956
- * Changing a value or the blanks switches the draft to its checklist;
3957
- * setting conditions switches it to them.
3958
- */
3959
- declare function filterEditorReducer<Row>(draft: FilterEditorDraft<Row>, action: FilterEditorAction<Row>): FilterEditorDraft<Row>;
3960
- /**
3961
- * `current` with `columnId`'s filter replaced by what `draft` holds — what
3962
- * applying an editor sets. Every entry about the column goes (custom ones
3963
- * included); the draft's entries take the place of the first, so the rest
3964
- * keep their order.
3965
- *
3966
- * A checklist with everything checked is no filter at all, and a partial
3967
- * pick is one `in` entry, OR-grouped with an `isEmpty` when blanks are
3968
- * kept. One condition is stored as itself, two as a group with the
3969
- * draft's combinator. Returns `current` itself when nothing changes.
3970
- */
3971
- declare function draftToFilter<Row>(draft: FilterEditorDraft<Row>, columnId: string, current: FilterState<Row>): FilterState<Row>;
3972
- /**
3973
- * Whether `draft` changes anything since the editor opened at `opened` — for
3974
- * an Apply that changes nothing to leave the column's filter as it is,
3975
- * rather than writing the draft over it. Compared by value, not identity, so
3976
- * a value unchecked and checked again, or the same conditions typed again,
3977
- * is no change; the search never is one.
3978
- *
3979
- * Only the half `draftToFilter` applies counts. A checklist changes when its
3980
- * checked values or blanks differ from those it opened with, so one left as
3981
- * it opened over conditions or a custom filter leaves that filter be.
3982
- * Conditions change when they differ from those the draft opened with, and
3983
- * always when it opened on a checklist, no filter or a custom one: setting
3984
- * conditions there replaces it, none removing it.
3985
- *
3986
- * `clear` over a custom filter leaves a draft equal to the one it opened
3987
- * with, so this reads it as no change.
3988
- */
3989
- declare function filterDraftChanged<Row>(opened: FilterEditorDraft<Row>, draft: FilterEditorDraft<Row>): boolean;
3990
-
3991
- /** What a column chooser is drawn from: every column, the visibility, and the search typed. */
3992
- interface ColumnChooserInput<Row> {
3993
- /** Every column in its current order, hidden ones included — a view's `dataColumns`. */
3994
- readonly columns: readonly DataColumn<Row, unknown>[];
3995
- readonly visibility: ColumnVisibilityState;
3996
- /** Narrows the list to the columns whose header text contains it, ignoring case. */
3997
- readonly search?: string | undefined;
3998
- }
3999
- /** One column's checkbox in a column chooser. */
4000
- interface ColumnChooserEntry {
4001
- readonly columnId: string;
4002
- /** The column's header text — what the search matches, and the checkbox's label. */
4003
- readonly label: string;
4004
- /** Whether the column is shown — whether its checkbox is checked. */
4005
- readonly visible: boolean;
4006
- /**
4007
- * Whether the checkbox cannot be unchecked: the column is shown and is
4008
- * either not `hideable` or the last column shown. A hidden column can
4009
- * always be shown, `hideable` or not.
4010
- */
4011
- readonly disabled: boolean;
4012
- }
4013
- /** What toggling a chooser's "Show all" checkbox does: shows these columns, or hides them. */
4014
- interface ColumnChooserToggle {
4015
- readonly visible: boolean;
4016
- readonly columnIds: readonly string[];
4017
- }
4018
- interface ColumnChooserModel {
4019
- /** The columns the search matches, in column order. */
4020
- readonly entries: readonly ColumnChooserEntry[];
4021
- /**
4022
- * The "Show all" checkbox's state over the entries whose columns are
4023
- * `hideable` — the ones it acts on. A column the user cannot hide is
4024
- * always on, so counting it would leave "Show all" stuck at mixed.
4025
- */
4026
- readonly selectAll: SelectAllState;
4027
- /** What toggling "Show all" does, or `null` when it can do nothing — a disabled checkbox. */
4028
- readonly toggleAll: ColumnChooserToggle | null;
4029
- }
4030
- /**
4031
- * A column chooser's list for a search, and what its "Show all" checkbox
4032
- * says and does — the same tri-state over what the search shows that a
4033
- * filter editor's select-all is (`selectAllState`).
4034
- *
4035
- * "Show all" shows every hidden column the search shows once any is hidden,
4036
- * and hides those it shows once none is. It never touches a column that is
4037
- * not `hideable`, and never hides the last column shown: when that is all
4038
- * that would be left, the first of them in column order stays, since a grid
4039
- * with no column shown has no header to bring one back from.
4040
- */
4041
- declare function resolveColumnChooser<Row>({ columns, visibility, search, }: ColumnChooserInput<Row>): ColumnChooserModel;
4042
-
4043
316
  /**
4044
317
  * `resolveGridView`, memoised per stage: each stage remembers its last
4045
318
  * inputs and returns its last output when none of them changed identity, so
@@ -4074,190 +347,11 @@ declare function resolveGridView<Row, Node = string>(input: GridViewInput<Row, N
4074
347
  * it to `restoreState` later. Every slice is plain data already except the
4075
348
  * filter: a `Date` value or operand is written as its ISO string, and a
4076
349
  * predicate entry, being a function, cannot be written at all and is left
4077
- * out with a `console.error` naming its column.
350
+ * out with a `console.error` naming its column. The result carries the
351
+ * `version` of its shape, which `restoreState` reads it by.
4078
352
  */
4079
353
  declare function serializeGridState<Row>(state: GridState<Row>): SerializedGridState<Row>;
4080
354
 
4081
- /**
4082
- * One condition row of a simple filter editor as the user types it: text,
4083
- * not yet a value, so a half-typed number or date stays in its input until
4084
- * the editor is applied and `conditionsFromRows` reads it.
4085
- */
4086
- interface ConditionRowDraft {
4087
- readonly operator: FilterOperator;
4088
- /** The operand as typed — `between`'s lower end. */
4089
- readonly text: string;
4090
- /**
4091
- * `between`'s upper end, as typed. Kept under any other operator, unread,
4092
- * so switching back to `between` finds it still there.
4093
- */
4094
- readonly textTo: string;
4095
- }
4096
- /** What `conditionsFromRows` reads off an editor's rows. */
4097
- interface ParsedConditionRows<Row> {
4098
- /** A condition for each row that reads as one, in row order. */
4099
- readonly conditions: readonly OperatorFilterEntry<Row>[];
4100
- /**
4101
- * The indexes of the rows that don't, for the editor to mark. Apply the
4102
- * conditions only once this is empty.
4103
- */
4104
- readonly invalid: readonly number[];
4105
- }
4106
- /**
4107
- * The rows a simple editor opens with over a column's filter `shape`, its
4108
- * operands written as the column's `type` reads them: two, holding the
4109
- * column's conditions when its filter is conditions, and each row they
4110
- * don't fill starting at the first of `operators`, empty. With no operator
4111
- * to start one at, only the rows the filter fills.
4112
- */
4113
- declare function conditionRowsFrom<Row>(shape: ColumnFilterShape<Row>, operators: readonly FilterOperator[], type: ColumnType | undefined): readonly ConditionRowDraft[];
4114
- /**
4115
- * The conditions a simple editor's rows stand for on `columnId`, each
4116
- * operand read as the column's `type` filters (`parseFilterOperand`) — for
4117
- * `filterEditorReducer`'s `setConditions`, with the combinator the editor
4118
- * shows.
4119
- *
4120
- * A row needs every operand its operator takes, or it is `invalid`; the
4121
- * blanks operators take none. A row after the first left empty is dropped
4122
- * rather than invalid, since the second condition is optional; an empty
4123
- * first row is invalid — clearing the filter is the editor's clear action,
4124
- * not an apply with nothing typed.
4125
- */
4126
- declare function conditionsFromRows<Row>(rows: readonly ConditionRowDraft[], columnId: string, type: ColumnType | undefined): ParsedConditionRows<Row>;
4127
-
4128
- /**
4129
- * What a cached list is labelled by: `columnValueOptions`' query without
4130
- * `search` and `limit`, which a draft applies over the whole list.
4131
- */
4132
- type ColumnValueCacheQuery = Pick<ColumnValueQuery, "locale" | "messages">;
4133
- /** `columnValueOptions`, remembered per column. */
4134
- interface ColumnValueOptionsCache<Row> {
4135
- /**
4136
- * `columnId`'s whole value list — `columnValueOptions` with no `search`
4137
- * or `limit` — or the very list it returned last time, when nothing the
4138
- * list is counted from or labelled by has changed since.
4139
- */
4140
- readonly get: (rows: readonly Row[], dataColumns: readonly DataColumn<Row, unknown>[], filter: FilterState<Row>, columnId: string, query?: ColumnValueCacheQuery) => ColumnValueOptions;
4141
- }
4142
- /**
4143
- * A memo of each column's checklist values, for a renderer to hold one of
4144
- * per grid: reopening a column's checklist hands back the list it was given
4145
- * last time — the same object — rather than counting `rows` again, until
4146
- * something the list depends on changes.
4147
- *
4148
- * That is the `rows` and `dataColumns`, the `locale` and `messages` it is
4149
- * labelled in, and the filter's entries not about the column — all compared
4150
- * by identity, the entries one by one. Identity holds across an apply:
4151
- * `draftToFilter` keeps every entry it doesn't replace as it was, so
4152
- * filtering one column leaves the lists of the others to recount and its
4153
- * own cached, since a column's list never depends on its own entries.
4154
- *
4155
- * Each column keeps its latest list. New rows, columns, locale or messages
4156
- * drop every list, so the cache never holds on to rows the grid has let go
4157
- * of — pass the grid's own, which keep their identity between renders.
4158
- */
4159
- declare function createColumnValueOptionsCache<Row>(): ColumnValueOptionsCache<Row>;
4160
-
4161
- /** One row of a checklist: a value the column holds, or its blank cells. */
4162
- type FilterChecklistItem = {
4163
- /**
4164
- * Tells the item apart from every other in the list: a value's key is the
4165
- * one `draft.checked` holds it under, and the blanks have their own.
4166
- */
4167
- readonly key: string;
4168
- /** The value as its cells print it, or the blanks' label. */
4169
- readonly label: string;
4170
- /** How many rows hold it, among those the other columns' filters keep. */
4171
- readonly count: number;
4172
- readonly checked: boolean;
4173
- } & ({
4174
- /** Toggled with `filterEditorReducer`'s `toggleValue`. */
4175
- readonly kind: "value";
4176
- readonly value: Exclude<FilterScalar, null>;
4177
- } | {
4178
- /** Toggled with `filterEditorReducer`'s `setIncludeBlanks`. */
4179
- readonly kind: "blanks";
4180
- });
4181
- interface FilterChecklistOptions {
4182
- /** How many values the list shows at most: the column's resolved `valueLimit`. */
4183
- readonly valueLimit: number;
4184
- /** The blanks item's label: the grid's `filterBlanks` message. */
4185
- readonly blanksLabel: string;
4186
- }
4187
- /** What a checklist editor draws below its search box and select-all. */
4188
- interface FilterChecklist {
4189
- /**
4190
- * The rows to draw, in order: the values the search shows, cut to
4191
- * `valueLimit`, then the blanks while nothing is searched and some cells
4192
- * are blank. Empty while `needsSearch`.
4193
- */
4194
- readonly items: readonly FilterChecklistItem[];
4195
- /**
4196
- * Whether the list waits for a search: the column holds more values than
4197
- * `valueLimit` and nothing is searched yet — `filterSearchFirst(total)`.
4198
- */
4199
- readonly needsSearch: boolean;
4200
- /**
4201
- * How many of the values the search matches `valueLimit` left out of
4202
- * `items` — `filterMoreValues(hiddenCount)`. `0` while `needsSearch`, so
4203
- * the two notes never show together.
4204
- */
4205
- readonly hiddenCount: number;
4206
- /** How many values the search matches — every value while nothing is searched. Blanks aside. */
4207
- readonly total: number;
4208
- }
4209
- /**
4210
- * The list a checklist editor draws for `draft`: the window of values its
4211
- * search shows, as items carrying what each row says and whether it is
4212
- * checked.
4213
- *
4214
- * A column can hold far more values than a list is worth scrolling, so the
4215
- * list shows at most `valueLimit` of them. Past that, it shows nothing until
4216
- * something is searched (`needsSearch`) — every value is still in the draft,
4217
- * and select-all still covers them all — and a search matching more shows
4218
- * the first `valueLimit` of its matches in sort order, with the rest counted
4219
- * in `hiddenCount`.
4220
- *
4221
- * The blanks item comes last, as in Excel's, and only while nothing is
4222
- * searched: exactly when select-all counts the blanks, so the checkbox acts
4223
- * on what the list shows.
4224
- */
4225
- declare function filterChecklist<Row>(draft: FilterEditorDraft<Row>, { valueLimit, blanksLabel }: FilterChecklistOptions): FilterChecklist;
4226
-
4227
- /**
4228
- * One entry per row: its measured height once known, `undefined` until then.
4229
- * A row never yet rendered (or rendered but not yet observed) falls back to
4230
- * `visibleRange`'s own `estimatedHeight` argument.
4231
- */
4232
- type RowHeights = readonly (number | undefined)[];
4233
- interface VisibleRange {
4234
- readonly startIndex: number;
4235
- readonly endIndex: number;
4236
- /** Total height of every row before `startIndex` — the leading spacer's height. */
4237
- readonly offsetBefore: number;
4238
- /** Total height of every row after `endIndex` — the trailing spacer's height. */
4239
- readonly offsetAfter: number;
4240
- }
4241
- /**
4242
- * Which rows of a dynamic-height, virtualized list fall within
4243
- * `[scrollTop, scrollTop + viewportHeight)`, padded by `overscan` rows on
4244
- * each side and clamped to the array's own bounds.
4245
- *
4246
- * Walks a cumulative-offset prefix sum built from `heights` (measured height
4247
- * where known, `estimatedHeight` otherwise) rather than assuming a uniform
4248
- * row height — this codebase's rows are not uniform (`.is-wrapped` cells,
4249
- * group header/summary rows), so a fixed-height virtualizer would either
4250
- * break wrapping or force it out of scope.
4251
- *
4252
- * `O(n)` in `heights.length`. Deliberately not a Fenwick tree or a
4253
- * binary-searchable prefix-sum structure — that optimization belongs in the
4254
- * mutable height cache that already owns mutability (`createRowVirtualizer`
4255
- * in `@gridkitjs/dom`), not in this pure function's contract, and is not
4256
- * worth taking on until a profiled scenario actually shows it matters at
4257
- * realistic row counts.
4258
- */
4259
- declare function visibleRange(heights: RowHeights, estimatedHeight: number, scrollTop: number, viewportHeight: number, overscan: number): VisibleRange;
4260
-
4261
355
  /** How `toTsv` writes its text. */
4262
356
  interface TsvOptions {
4263
357
  /**
@@ -4286,8 +380,8 @@ interface HtmlTableOptions {
4286
380
  * the table has a header, every row in `<tbody>`, and the grand total in
4287
381
  * `<tfoot>`. Every piece of text is escaped. It carries the semantic class
4288
382
  * names a stylesheet targets — `gridkit-export-table` on the table,
4289
- * `export-group` with a `data-level` on group headers,
4290
- * `export-group-summary` on summary rows — and nothing else of style but
383
+ * `gridkit-export-group` with a `data-level` on group headers,
384
+ * `gridkit-export-group-summary` on summary rows — and nothing else of style but
4291
385
  * each column's alignment, so it reads the same pasted into a document as
4292
386
  * it does printed.
4293
387
  */
@@ -4331,4 +425,4 @@ declare const excelFilter: {
4331
425
  };
4332
426
  };
4333
427
 
4334
- export { type AggregateFn, type AggregateResults, type AggregateSpec, type AggregateState, type Borders, type BuiltInAggregate, type BuiltInCommandIcon, type BuiltInCommandId, type CellSelectEvent, type CellSelectionChangeEvent, type CellSelectionMode, type CellSelectionState, type CellTemplateContext, type ColumnAlignment, type ColumnChooserEntry, type ColumnChooserInput, type ColumnChooserModel, type ColumnChooserToggle, type ColumnConstraints, type ColumnDefinition, type ColumnFilterMenuOptions, type ColumnFilterShape, type ColumnOrderEvent, type ColumnOrderState, type ColumnResizeEvent, type ColumnResizeSession, type ColumnResolveOptions, type ColumnSelectEvent, type ColumnSelectionChangeEvent, type ColumnSizeDefaults, type ColumnSizingState, type ColumnSortEntry, type ColumnSortEvent, type ColumnSortState, type ColumnType, type ColumnValueCacheQuery, type ColumnValueOption, type ColumnValueOptions, type ColumnValueOptionsCache, type ColumnValueQuery, type ColumnVisibilityEvent, type ColumnVisibilityState, type ColumnWrapConfig, type ColumnsSelectEvent, type ConditionRowDraft, type ContextMenuOpenChangeEvent, type CopyContent, type CopyRequest, type CopySource, type CsvOptions, DEFAULT_COLUMN_SIZES, DEFAULT_FILTER_VALUE_LIMIT, type DataColumn, type DisplayRow, type DropSide, type ExportCell, type ExportColumn, type ExportDataRow, type ExportFile, type ExportFileSource, type ExportGroupRow, type ExportGroupSummaryRow, type ExportOptions, type ExportRow, type ExportScalar, type ExportSource, type ExportTable, type ExportTotalRow, type ExportWriteContext, type ExportWriter, type FieldPath, type FilterChangeEvent, type FilterChecklist, type FilterChecklistItem, type FilterChecklistOptions, type FilterEditorAction, type FilterEditorDraft, type FilterEntry, type FilterMenuUi, type FilterOperator, type FilterOperatorFamily, type FilterPredicate, type FilterScalar, type FilterState, type FooterTemplateContext, type FormatLocale, type GridCommand, type GridCommandActions, type GridCommandContext, type GridCommandContextInput, type GridCommandEvent, type GridCommandHost, type GridCommandSource, type GridCommandTarget, type GridContextMenuArea, type GridContextMenuEntries, type GridContextMenuOptions, type GridContextMenuRequest, type GridContextMenuTarget, type GridController, type GridControllerOptions, type GridExportOptions, type GridFilterMenuOptions, type GridFocus, type GridMessages, type GridOptions, type GridPanelKind, type GridState, type GridToolbarOptions, type GridToolbarTarget, type GridView, type GridViewInput, type GridViewOptions, type GridViewState, type GroupAggregateDisplay, type GroupByBarVisibility, type GroupByEntry, type GroupByEvent, type GroupByState, type GroupExpansionEvent, type GroupExpansionState, type GroupFilterEntry, HEADER_ROW, type HoverableConfig, type HtmlTableOptions, type JsonOptions, KEYBOARD_STEP, type KeyShortcutCapabilities, type MenuEntry, type MenuItemEntry, type MenuMove, type MenuResolveOptions, type MenuSubmenuEntry, type NavigationModifiers, type OperatorFilterEntry, type PaginateRowsOptions, type PaginatedRows, type PaginationChangeEvent, type PaginationState, type PaginationUnit, type PaginationWindowEntry, type ParsedConditionRows, type PredicateFilterEntry, type PrintDocument, type PrintOptions, type PrintOrientation, type PrintPage, type PrintSource, type ResizeMode, type ResolvedColumn, type ResolvedColumnFilterMenu, type ResolvedGroupRow, type ResolvedGroupSummaryRow, type ResolvedMenuEntry, type ResolvedMenuItem, type ResolvedMenuSeparator, type ResolvedMenuSubmenu, type ResolvedRow, type ResolvedToolbarButton, type ResolvedToolbarCustom, type ResolvedToolbarItem, type ResolvedToolbarMenu, type ResolvedToolbarSearch, type ResolvedToolbarSpacer, type RowHeights, type RowPointerEvent, type RowProps, type RowSelectEvent, type RowSelectionChangeEvent, type RowsSelectEvent, type SelectAllState, type SelectIntent, type SelectableConfig, type SelectedCell, type SelectedCellRef, type SelectedColumn, type SelectionCallbacks, type SelectionDiff, type SelectionDiffEvent, type SelectionMode, type SelectionState, type SerializedFilterEntry, type SerializedFilterScalar, type SerializedFilterState, type SerializedGridState, type SerializedGroupFilterEntry, type SerializedOperatorFilterEntry, type SerializedValueFilterEntry, type SortDirection, type TextFilterEntry, type ToolbarCustomEntry, type ToolbarEntry, type ToolbarFitInput, type ToolbarItemAttributes, type ToolbarResolveOptions, type ToolbarSplit, type TsvOptions, type ValueFilterEntry, type VisibleRange, accessDotted, alignmentForType, applyColumnOrder, applyColumnResize, applyColumnVisibility, applySelectionIntent, beginColumnResize, buildExportTable, buildKeyShortcuts, buildPrintDocument, builtInCommands, clampColumnWidth, clampFocus, clearAllFilters, clearSelection, collapseAllGroups, columnValueOptions, compareValues, computeAggregates, conditionRowsFrom, conditionsFromRows, contextMenuEntries, copyContent, createColumnValueOptionsCache, createCommandContext, createDefaultMessages, createGridController, createGridViewResolver, csvWriter, defaultContextMenu, defaultFilterOperators, defaultMessages, defaultToolbar, defineColumnsFromRows, describeColumnFilter, diffSelection, draftToFilter, excelFilter, expandAllGroups, exportFile, exportPrintDocument, filterChecklist, filterDraftChanged, filterEditorReducer, filterOperandArity, filterOperatorFamily, filterQueryFor, filterRows, fitColumnsToWidth, fitToolbarItems, formatAggregateValue, formatCellValue, formatFilterOperand, formatGroupValue, getColumnId, groupRowId, groupRows, hasContextMenu, initialFilterEditorDraft, intentOf, isColumnFiltered, isColumnVisible, isPinnedToolbarItem, isSameCell, jsonWriter, matchesQuery, moveColumnBefore, moveGroupByBefore, movesColumn, movesGroupBy, nextFocusForKey, nextMenuIndex, paginateRows, paginationWindow, parseFilterOperand, resolveCell, resolveColumnChooser, resolveColumnConstraints, resolveColumnFilterMenu, resolveColumnHeaderText, resolveColumnLabel, resolveColumnWidths, resolveColumns, resolveCommands, resolveDataColumns, resolveDropBefore, resolveExportWriters, resolveGridView, resolveKeyboardDropTarget, resolveMenu, resolveMessages, resolveRowId, resolveRows, resolveShownRows, resolveToolbar, revertColumnSize, runCommand, searchTextOf, selectAll, selectAllState, selectCell, selectOnly, selectRange, serializeGridState, setColumnFilter, setColumnVisibility, setSearchText, sizeColumnToContent, sortDirectionFor, sortPriorityFor, sortRows, splitToolbarItems, toCsv, toHtmlTable, toJson, toTsv, toggleCellSelection, toggleColumnSort, toggleGroupExpansion, toggleSelection, toolbarEntries, totalColumnWidth, typeaheadIndex, visibleFilterOptions, visibleRange, withGroupAggregates };
428
+ export { AggregateResults, AggregateState, ColumnDefinition, ColumnSortState, ColumnType, ColumnVisibilityState, DataColumn, DisplayRow, ExportFile, type ExportFileSource, ExportSource, ExportTable, ExportWriter, FieldPath, FilterState, GridCommand, GridCommandContext, type GridCommandContextInput, GridCommandHost, GridCommandTarget, GridController, GridControllerOptions, GridExportOptions, GridMessages, GridState, GridToolbarTarget, GridView, GridViewInput, GroupAggregateDisplay, GroupByState, type HtmlTableOptions, MenuEntry, type MenuResolveOptions, type PaginateRowsOptions, type PaginatedRows, PaginationState, PaginationUnit, ResolvedColumn, ResolvedMenuEntry, ResolvedRow, ResolvedToolbarItem, SelectedCell, SelectedCellRef, SelectedColumn, SerializedGridState, SortDirection, ToolbarEntry, ToolbarItemAttributes, type ToolbarResolveOptions, type TsvOptions, applyColumnVisibility, clearAllFilters, compareValues, computeAggregates, createCommandContext, createGridController, createGridViewResolver, excelFilter, exportFile, filterQueryFor, filterRows, isColumnVisible, matchesQuery, paginateRows, resolveCell, resolveColumns, resolveCommands, resolveGridView, resolveMenu, resolveRows, resolveShownRows, resolveToolbar, runCommand, serializeGridState, setColumnFilter, setColumnVisibility, sortDirectionFor, sortPriorityFor, sortRows, toHtmlTable, toTsv, toggleColumnSort, withGroupAggregates };