@gridkitjs/core 0.0.0-dev-20261112193732 → 0.0.0-dev-20261112194323

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