@gridkitjs/core 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +101 -34
- package/dist/index.js +118 -47
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -217,8 +217,10 @@ interface GridController<Row, Node = string> {
|
|
|
217
217
|
/** Collapses every group currently shown — see `collapseAllGroups`. */
|
|
218
218
|
readonly collapseAllGroups: () => void;
|
|
219
219
|
/**
|
|
220
|
-
* Replaces the page and page size
|
|
221
|
-
* the
|
|
220
|
+
* Replaces the page and page size. A controlled pagination asks for them
|
|
221
|
+
* as given and the view clamps a page past the last one; an uncontrolled
|
|
222
|
+
* one stores and reports that page clamped. An equal pagination reports
|
|
223
|
+
* nothing.
|
|
222
224
|
*/
|
|
223
225
|
readonly setPagination: (pagination: PaginationState) => void;
|
|
224
226
|
/**
|
|
@@ -1374,6 +1376,15 @@ interface ToolbarCustomEntry {
|
|
|
1374
1376
|
* dropdown of the export commands that show; and a custom entry.
|
|
1375
1377
|
*/
|
|
1376
1378
|
type ToolbarEntry<Row> = MenuEntry<Row> | "search" | "spacer" | "export" | ToolbarCustomEntry;
|
|
1379
|
+
/**
|
|
1380
|
+
* Attributes of the app's own for a toolbar entry's element, as hooks for
|
|
1381
|
+
* its tests, analytics or styles: an `id` and `data-*` attributes, nothing
|
|
1382
|
+
* that could change what the entry means or does.
|
|
1383
|
+
*/
|
|
1384
|
+
interface ToolbarItemAttributes {
|
|
1385
|
+
readonly id?: string | undefined;
|
|
1386
|
+
readonly [name: `data-${string}`]: string;
|
|
1387
|
+
}
|
|
1377
1388
|
/**
|
|
1378
1389
|
* A toolbar button ready to draw — a command, or an inline item — with
|
|
1379
1390
|
* every label a string, every flag a boolean, and `run` bound to the
|
|
@@ -1397,6 +1408,8 @@ interface ResolvedToolbarButton {
|
|
|
1397
1408
|
readonly pressed: boolean | undefined;
|
|
1398
1409
|
/** Runs the button, and says whether it ran — see `ResolvedMenuItem.run`. */
|
|
1399
1410
|
readonly run: () => boolean;
|
|
1411
|
+
/** The app's attributes for its element, from `itemAttributes`. */
|
|
1412
|
+
readonly attributes?: ToolbarItemAttributes | undefined;
|
|
1400
1413
|
}
|
|
1401
1414
|
/** A dropdown button, opening the menu its submenu entry lists. */
|
|
1402
1415
|
interface ResolvedToolbarMenu {
|
|
@@ -1408,12 +1421,16 @@ interface ResolvedToolbarMenu {
|
|
|
1408
1421
|
readonly icon?: string | undefined;
|
|
1409
1422
|
/** Never empty: a dropdown with nothing to show is left out. */
|
|
1410
1423
|
readonly items: readonly ResolvedMenuEntry[];
|
|
1424
|
+
/** The app's attributes for its element, from `itemAttributes`. */
|
|
1425
|
+
readonly attributes?: ToolbarItemAttributes | undefined;
|
|
1411
1426
|
}
|
|
1412
1427
|
/** The search box, over the grid's global text filter. */
|
|
1413
1428
|
interface ResolvedToolbarSearch {
|
|
1414
1429
|
readonly type: "search";
|
|
1415
1430
|
/** Always `"search"`. */
|
|
1416
1431
|
readonly key: string;
|
|
1432
|
+
/** The app's attributes for its element, from `itemAttributes`. */
|
|
1433
|
+
readonly attributes?: ToolbarItemAttributes | undefined;
|
|
1417
1434
|
}
|
|
1418
1435
|
/** The free space between the entries either side of it. */
|
|
1419
1436
|
interface ResolvedToolbarSpacer {
|
|
@@ -1427,6 +1444,8 @@ interface ResolvedToolbarCustom {
|
|
|
1427
1444
|
readonly id: string;
|
|
1428
1445
|
/** The same as `id`. */
|
|
1429
1446
|
readonly key: string;
|
|
1447
|
+
/** The app's attributes for its element, from `itemAttributes`. */
|
|
1448
|
+
readonly attributes?: ToolbarItemAttributes | undefined;
|
|
1430
1449
|
}
|
|
1431
1450
|
/**
|
|
1432
1451
|
* One entry of a toolbar as `resolveToolbar` hands it to a renderer to draw.
|
|
@@ -1436,12 +1455,21 @@ interface ResolvedToolbarCustom {
|
|
|
1436
1455
|
*/
|
|
1437
1456
|
type ResolvedToolbarItem = ResolvedToolbarButton | ResolvedToolbarMenu | ResolvedToolbarSearch | ResolvedToolbarSpacer | ResolvedMenuSeparator | ResolvedToolbarCustom;
|
|
1438
1457
|
|
|
1439
|
-
/**
|
|
1458
|
+
/**
|
|
1459
|
+
* A grid's toolbar: what it lists, what a screen reader calls it, and the
|
|
1460
|
+
* attributes of the app's own its entries' elements carry.
|
|
1461
|
+
*/
|
|
1440
1462
|
interface GridToolbarOptions<Row> {
|
|
1441
1463
|
/** The toolbar's entries, in order. Left out, the defaults. */
|
|
1442
1464
|
readonly items?: readonly ToolbarEntry<Row>[] | undefined;
|
|
1443
1465
|
/** The toolbar's accessible name. Left out, `messages.toolbarLabel`. */
|
|
1444
1466
|
readonly label?: string | undefined;
|
|
1467
|
+
/**
|
|
1468
|
+
* Attributes for entries' elements, by the entry's key: a command's,
|
|
1469
|
+
* inline item's, dropdown's or custom entry's id, `"search"` or
|
|
1470
|
+
* `"export"`. A key naming no entry, or a separator or spacer, is ignored.
|
|
1471
|
+
*/
|
|
1472
|
+
readonly itemAttributes?: Readonly<Record<string, ToolbarItemAttributes>> | undefined;
|
|
1445
1473
|
}
|
|
1446
1474
|
/**
|
|
1447
1475
|
* What a toolbar lists unless the grid says otherwise: the search box, then
|
|
@@ -1732,11 +1760,23 @@ interface GridOptions<Row> {
|
|
|
1732
1760
|
*/
|
|
1733
1761
|
filterMenu?: GridFilterMenuOptions | undefined;
|
|
1734
1762
|
/**
|
|
1735
|
-
* Whether the grid's rows are split into pages.
|
|
1736
|
-
*
|
|
1737
|
-
*
|
|
1763
|
+
* Whether the grid's rows are split into pages. Off by default, matching
|
|
1764
|
+
* `sortableColumns`. What a page's `pageSize` counts once the rows are
|
|
1765
|
+
* grouped is `paginationUnit`'s choice.
|
|
1738
1766
|
*/
|
|
1739
1767
|
paginated?: boolean | undefined;
|
|
1768
|
+
/**
|
|
1769
|
+
* What `pageSize` counts in a grouped grid. `"group"` (the default) counts
|
|
1770
|
+
* top-level groups, each with everything beneath it, so a page never
|
|
1771
|
+
* splits a group but can grow as large as its groups. `"row"` counts data
|
|
1772
|
+
* rows, plus collapsed group headers, which stand in for their hidden
|
|
1773
|
+
* rows: every page holds `pageSize` of them, and a page continuing a group
|
|
1774
|
+
* starts with that group's headers again, with a group's summary row on
|
|
1775
|
+
* the page holding its last row. An ungrouped grid pages by data rows
|
|
1776
|
+
* under either. Selection, export and aggregates behave the same under
|
|
1777
|
+
* either unit.
|
|
1778
|
+
*/
|
|
1779
|
+
paginationUnit?: PaginationUnit | undefined;
|
|
1740
1780
|
/**
|
|
1741
1781
|
* The page and page size to start on. Uncontrolled. Defaults to
|
|
1742
1782
|
* `{ pageIndex: 0, pageSize: 25 }` when `paginated` is on and this is
|
|
@@ -1749,9 +1789,9 @@ interface GridOptions<Row> {
|
|
|
1749
1789
|
* them itself, starting from `defaultPagination`.
|
|
1750
1790
|
*
|
|
1751
1791
|
* The grid sends an uncontrolled pagination back to the first page when
|
|
1752
|
-
* the filter, sort or
|
|
1753
|
-
* to reset alongside that change. Until it does, the
|
|
1754
|
-
* page that exists rather than an empty one.
|
|
1792
|
+
* the filter, sort, grouping or `paginationUnit` changes; a controlled
|
|
1793
|
+
* one is the parent's to reset alongside that change. Until it does, the
|
|
1794
|
+
* grid shows the last page that exists rather than an empty one.
|
|
1755
1795
|
*/
|
|
1756
1796
|
pagination?: PaginationState | undefined;
|
|
1757
1797
|
/** Called once when the user changes the page or the page size. */
|
|
@@ -2078,8 +2118,9 @@ interface ColumnDefinition<Row, Node = string> {
|
|
|
2078
2118
|
*/
|
|
2079
2119
|
footerTemplate?: ((context: FooterTemplateContext<Row>) => Node) | undefined;
|
|
2080
2120
|
/**
|
|
2081
|
-
* The value type of this column's cells.
|
|
2082
|
-
*
|
|
2121
|
+
* The value type of this column's cells. Absent, the column has none: it
|
|
2122
|
+
* sorts as `compareValues` does without a type, two numbers or two `Date`s
|
|
2123
|
+
* by value and any other pair as text.
|
|
2083
2124
|
*/
|
|
2084
2125
|
type?: ColumnType;
|
|
2085
2126
|
/**
|
|
@@ -2218,6 +2259,15 @@ interface PaginationState {
|
|
|
2218
2259
|
readonly pageIndex: number;
|
|
2219
2260
|
readonly pageSize: number;
|
|
2220
2261
|
}
|
|
2262
|
+
/**
|
|
2263
|
+
* What a grouped grid's `pageSize` counts. `"group"` counts top-level groups,
|
|
2264
|
+
* each with everything beneath it, so a page never splits a group. `"row"`
|
|
2265
|
+
* counts data rows and collapsed group headers, so every page holds
|
|
2266
|
+
* `pageSize` of them however large the groups are; a page continuing a group
|
|
2267
|
+
* starts with that group's headers again. An ungrouped grid pages by data
|
|
2268
|
+
* rows under either.
|
|
2269
|
+
*/
|
|
2270
|
+
type PaginationUnit = "group" | "row";
|
|
2221
2271
|
/** Reports a user page/page-size change whole — the one to persist from, mirroring ColumnSortEvent. */
|
|
2222
2272
|
interface PaginationChangeEvent {
|
|
2223
2273
|
readonly pagination: PaginationState;
|
|
@@ -2856,6 +2906,8 @@ type GridViewState<Row> = Omit<GridState<Row>, "rowSelection" | "columnSelection
|
|
|
2856
2906
|
interface GridViewOptions<Row> {
|
|
2857
2907
|
/** Whether `pageRows` is one page of `displayRows` rather than all of it. Defaults to `false`. */
|
|
2858
2908
|
readonly paginated?: boolean | undefined;
|
|
2909
|
+
/** What a page's `pageSize` counts once grouped. Defaults to `"group"`. */
|
|
2910
|
+
readonly paginationUnit?: PaginationUnit | undefined;
|
|
2859
2911
|
readonly aggregates?: AggregateState<Row> | undefined;
|
|
2860
2912
|
/** Defaults to `"inline"`. */
|
|
2861
2913
|
readonly groupAggregateDisplay?: GroupAggregateDisplay | undefined;
|
|
@@ -3011,6 +3063,8 @@ interface ToolbarResolveOptions<Row> {
|
|
|
3011
3063
|
* opens a panel anchors it there.
|
|
3012
3064
|
*/
|
|
3013
3065
|
readonly contextFor: (target: GridToolbarTarget) => GridCommandContext<Row>;
|
|
3066
|
+
/** Attributes for entries' elements, by key — see `GridToolbarOptions`. */
|
|
3067
|
+
readonly itemAttributes?: Readonly<Record<string, ToolbarItemAttributes>> | undefined;
|
|
3014
3068
|
}
|
|
3015
3069
|
/**
|
|
3016
3070
|
* A toolbar's entries resolved against the grid, ready to draw, by the
|
|
@@ -3026,6 +3080,8 @@ interface ToolbarResolveOptions<Row> {
|
|
|
3026
3080
|
* - `"search"`, `"spacer"` and custom entries stay as they are.
|
|
3027
3081
|
* - Separators never lead, trail, double up or sit next to a spacer, which
|
|
3028
3082
|
* already parts what is on either side of it.
|
|
3083
|
+
* - A button, dropdown, search box or custom entry whose key
|
|
3084
|
+
* `itemAttributes` names carries those `attributes`.
|
|
3029
3085
|
*
|
|
3030
3086
|
* Resolve again whenever the grid changes, so each button's label, flags
|
|
3031
3087
|
* and `run` follow its state.
|
|
@@ -3411,8 +3467,8 @@ declare function revertColumnSize(current: ColumnSizingState, base: ColumnSizing
|
|
|
3411
3467
|
/**
|
|
3412
3468
|
* Compares two cell values the way `type` implies — numerically for the
|
|
3413
3469
|
* numeric types, chronologically for the date/time types, lexically
|
|
3414
|
-
* otherwise.
|
|
3415
|
-
*
|
|
3470
|
+
* otherwise. With no `type`, two numbers or two `Date`s compare by value and
|
|
3471
|
+
* anything else as text; see `compareUntyped`.
|
|
3416
3472
|
*
|
|
3417
3473
|
* `null`/`undefined` sort after every value on both sides. Used directly,
|
|
3418
3474
|
* that ordering is fixed; `sortRows` applies it directionally without
|
|
@@ -3441,9 +3497,9 @@ declare function toggleColumnSort(sort: ColumnSortState, columnId: string, optio
|
|
|
3441
3497
|
}): ColumnSortState;
|
|
3442
3498
|
/**
|
|
3443
3499
|
* `rows` ordered by `sort` — each entry read against `columns` for its
|
|
3444
|
-
* `field` and `type` — with `rowIndex` renumbered to
|
|
3445
|
-
* positions, the invariant the rest of the grid relies on for
|
|
3446
|
-
* navigation and `aria-rowindex`.
|
|
3500
|
+
* `field` and `type` — with `rowIndex` and `datasetIndex` renumbered to
|
|
3501
|
+
* match the new positions, the invariant the rest of the grid relies on for
|
|
3502
|
+
* keyboard navigation and `aria-rowindex`.
|
|
3447
3503
|
*
|
|
3448
3504
|
* Stable (`Array.prototype.sort` has been stable since ES2019), so rows
|
|
3449
3505
|
* equal under every active key keep their relative order. A `null`/
|
|
@@ -3493,8 +3549,9 @@ declare function setColumnFilter<Row>(filter: FilterState<Row>, columnId: (Field
|
|
|
3493
3549
|
declare function clearAllFilters<Row>(filter: FilterState<Row>): FilterState<Row>;
|
|
3494
3550
|
/**
|
|
3495
3551
|
* `rows` reduced to those matching every entry in `filter` (AND at the top
|
|
3496
|
-
* level — nest a `GroupFilterEntry` for OR). `rowIndex`
|
|
3497
|
-
* match the retained positions — the same invariant
|
|
3552
|
+
* level — nest a `GroupFilterEntry` for OR). `rowIndex` and `datasetIndex`
|
|
3553
|
+
* are renumbered to match the retained positions — the same invariant
|
|
3554
|
+
* `sortRows` keeps,
|
|
3498
3555
|
* needed here independently since `filterRows` runs before `sortRows` in
|
|
3499
3556
|
* the composed pipeline (see `resolveShownRows`).
|
|
3500
3557
|
*
|
|
@@ -3532,10 +3589,11 @@ declare function groupRowId(path: readonly unknown[]): string;
|
|
|
3532
3589
|
* this only reshapes their output, and never changes which rows appear or
|
|
3533
3590
|
* their relative order within a group.
|
|
3534
3591
|
*
|
|
3535
|
-
* `rowIndex`
|
|
3536
|
-
* included — the same invariant `sortRows`/`filterRows`
|
|
3537
|
-
* `ResolvedRow
|
|
3538
|
-
*
|
|
3592
|
+
* `rowIndex` and `datasetIndex` are renumbered across the whole flattened
|
|
3593
|
+
* output, header rows included — the same invariant `sortRows`/`filterRows`
|
|
3594
|
+
* keep for a `ResolvedRow`, extended to `ResolvedGroupRow` since `GridBody`
|
|
3595
|
+
* addresses both kinds by the same flat position, and `aria-rowindex`
|
|
3596
|
+
* counts both.
|
|
3539
3597
|
*
|
|
3540
3598
|
* Returns `rows` itself, untouched, when `groupBy` is empty or names only
|
|
3541
3599
|
* columns absent from `columns` — a stored grouping tolerates a column
|
|
@@ -3633,18 +3691,27 @@ interface PaginatedRows<Row> {
|
|
|
3633
3691
|
*/
|
|
3634
3692
|
readonly pageIndex: number;
|
|
3635
3693
|
}
|
|
3694
|
+
interface PaginateRowsOptions {
|
|
3695
|
+
/** What `pageSize` counts — see `PaginationUnit`. Defaults to `"group"`. */
|
|
3696
|
+
readonly unit?: PaginationUnit | undefined;
|
|
3697
|
+
}
|
|
3636
3698
|
/**
|
|
3637
|
-
* `rows` sliced into pages of `pagination.pageSize` units — see
|
|
3638
|
-
* for what a unit is
|
|
3639
|
-
*
|
|
3640
|
-
*
|
|
3641
|
-
* `
|
|
3642
|
-
*
|
|
3643
|
-
*
|
|
3644
|
-
*
|
|
3645
|
-
*
|
|
3646
|
-
|
|
3647
|
-
|
|
3699
|
+
* `rows` sliced into pages of `pagination.pageSize` units — see
|
|
3700
|
+
* `groupUnitsOf` and `rowUnitsOf` for what a unit is under each
|
|
3701
|
+
* `options.unit`. A page opens with its first unit's enclosing headers, so
|
|
3702
|
+
* under `"row"` a header repeated from the page before is the same
|
|
3703
|
+
* `DisplayRow`, and toggling it toggles its group on every page.
|
|
3704
|
+
*
|
|
3705
|
+
* `pageIndex` is clamped into range, `pageSize <= 0` is clamped to `1`
|
|
3706
|
+
* (this codebase's general tolerance for stale/odd stored state, matching
|
|
3707
|
+
* `sortRows`/`filterRows`), and the returned page's `rowIndex` is renumbered
|
|
3708
|
+
* to be page-relative — 0-based from the top of the page, header rows
|
|
3709
|
+
* included, mirroring `groupRows`'s own renumbering invariant.
|
|
3710
|
+
* `datasetIndex` is left untouched: the stages ahead of this one set it to
|
|
3711
|
+
* each row's position in the whole displayed result, which stays the same
|
|
3712
|
+
* whichever page is showing.
|
|
3713
|
+
*/
|
|
3714
|
+
declare function paginateRows<Row>(rows: readonly DisplayRow<Row>[], pagination: PaginationState, options?: PaginateRowsOptions): PaginatedRows<Row>;
|
|
3648
3715
|
|
|
3649
3716
|
type PaginationWindowEntry = number | "ellipsis";
|
|
3650
3717
|
/**
|
|
@@ -4224,4 +4291,4 @@ declare const excelFilter: {
|
|
|
4224
4291
|
};
|
|
4225
4292
|
};
|
|
4226
4293
|
|
|
4227
|
-
export { type AggregateFn, type AggregateResults, type AggregateSpec, type AggregateState, type Borders, type BuiltInAggregate, type BuiltInCommandIcon, type BuiltInCommandId, type CellSelectEvent, type CellSelectionChangeEvent, type CellSelectionMode, type CellSelectionState, type CellTemplateContext, type ColumnAlignment, type ColumnChooserEntry, type ColumnChooserInput, type ColumnChooserModel, type ColumnChooserToggle, type ColumnConstraints, type ColumnDefinition, type ColumnFilterMenuOptions, type ColumnFilterShape, type ColumnOrderEvent, type ColumnOrderState, type ColumnResizeEvent, type ColumnResizeSession, type ColumnResolveOptions, type ColumnSelectEvent, type ColumnSelectionChangeEvent, type ColumnSizeDefaults, type ColumnSizingState, type ColumnSortEntry, type ColumnSortEvent, type ColumnSortState, type ColumnType, type ColumnValueCacheQuery, type ColumnValueOption, type ColumnValueOptions, type ColumnValueOptionsCache, type ColumnValueQuery, type ColumnVisibilityEvent, type ColumnVisibilityState, type ColumnWrapConfig, type ColumnsSelectEvent, type ConditionRowDraft, type ContextMenuOpenChangeEvent, type CopyContent, type CopyRequest, type CopySource, type CsvOptions, DEFAULT_COLUMN_SIZES, DEFAULT_FILTER_VALUE_LIMIT, type DataColumn, type DisplayRow, type DropSide, type ExportCell, type ExportColumn, type ExportDataRow, type ExportFile, type ExportFileSource, type ExportGroupRow, type ExportGroupSummaryRow, type ExportOptions, type ExportRow, type ExportScalar, type ExportSource, type ExportTable, type ExportTotalRow, type ExportWriteContext, type ExportWriter, type FieldPath, type FilterChangeEvent, type FilterChecklist, type FilterChecklistItem, type FilterChecklistOptions, type FilterEditorAction, type FilterEditorDraft, type FilterEntry, type FilterMenuUi, type FilterOperator, type FilterOperatorFamily, type FilterPredicate, type FilterScalar, type FilterState, type FooterTemplateContext, type FormatLocale, type GridCommand, type GridCommandActions, type GridCommandContext, type GridCommandContextInput, type GridCommandEvent, type GridCommandHost, type GridCommandSource, type GridCommandTarget, type GridContextMenuArea, type GridContextMenuEntries, type GridContextMenuOptions, type GridContextMenuRequest, type GridContextMenuTarget, type GridController, type GridControllerOptions, type GridExportOptions, type GridFilterMenuOptions, type GridFocus, type GridMessages, type GridOptions, type GridPanelKind, type GridState, type GridToolbarOptions, type GridToolbarTarget, type GridView, type GridViewInput, type GridViewOptions, type GridViewState, type GroupAggregateDisplay, type GroupByBarVisibility, type GroupByEntry, type GroupByEvent, type GroupByState, type GroupExpansionEvent, type GroupExpansionState, type GroupFilterEntry, HEADER_ROW, type HoverableConfig, type HtmlTableOptions, type JsonOptions, KEYBOARD_STEP, type KeyShortcutCapabilities, type MenuEntry, type MenuItemEntry, type MenuMove, type MenuResolveOptions, type MenuSubmenuEntry, type NavigationModifiers, type OperatorFilterEntry, type PaginatedRows, type PaginationChangeEvent, type PaginationState, 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 ToolbarResolveOptions, type ToolbarSplit, type TsvOptions, type ValueFilterEntry, type VisibleRange, accessDotted, alignmentForType, applyColumnOrder, applyColumnResize, applyColumnVisibility, applySelectionIntent, beginColumnResize, buildExportTable, buildKeyShortcuts, buildPrintDocument, builtInCommands, clampColumnWidth, clampFocus, clearAllFilters, clearSelection, collapseAllGroups, columnValueOptions, compareValues, computeAggregates, conditionRowsFrom, conditionsFromRows, contextMenuEntries, copyContent, createColumnValueOptionsCache, createCommandContext, createDefaultMessages, createGridController, createGridViewResolver, csvWriter, defaultContextMenu, defaultFilterOperators, defaultMessages, defaultToolbar, defineColumnsFromRows, describeColumnFilter, diffSelection, draftToFilter, excelFilter, expandAllGroups, exportFile, exportPrintDocument, filterChecklist, filterEditorReducer, filterOperandArity, filterOperatorFamily, filterQueryFor, filterRows, fitColumnsToWidth, fitToolbarItems, formatAggregateValue, formatCellValue, formatFilterOperand, formatGroupValue, getColumnId, groupRowId, groupRows, hasContextMenu, initialFilterEditorDraft, intentOf, isColumnFiltered, isColumnVisible, isPinnedToolbarItem, isSameCell, jsonWriter, matchesQuery, moveColumnBefore, moveGroupByBefore, movesColumn, movesGroupBy, nextFocusForKey, nextMenuIndex, paginateRows, paginationWindow, parseFilterOperand, resolveCell, resolveColumnChooser, resolveColumnConstraints, resolveColumnFilterMenu, resolveColumnHeaderText, resolveColumnLabel, resolveColumnWidths, resolveColumns, resolveCommands, resolveDataColumns, resolveDropBefore, resolveExportWriters, resolveGridView, resolveKeyboardDropTarget, resolveMenu, resolveMessages, resolveRowId, resolveRows, resolveShownRows, resolveToolbar, revertColumnSize, runCommand, searchTextOf, selectAll, selectAllState, selectCell, selectOnly, selectRange, serializeGridState, setColumnFilter, setColumnVisibility, setSearchText, sizeColumnToContent, sortDirectionFor, sortPriorityFor, sortRows, splitToolbarItems, toCsv, toHtmlTable, toJson, toTsv, toggleCellSelection, toggleColumnSort, toggleGroupExpansion, toggleSelection, toolbarEntries, totalColumnWidth, typeaheadIndex, visibleFilterOptions, visibleRange, withGroupAggregates };
|
|
4294
|
+
export { type AggregateFn, type AggregateResults, type AggregateSpec, type AggregateState, type Borders, type BuiltInAggregate, type BuiltInCommandIcon, type BuiltInCommandId, type CellSelectEvent, type CellSelectionChangeEvent, type CellSelectionMode, type CellSelectionState, type CellTemplateContext, type ColumnAlignment, type ColumnChooserEntry, type ColumnChooserInput, type ColumnChooserModel, type ColumnChooserToggle, type ColumnConstraints, type ColumnDefinition, type ColumnFilterMenuOptions, type ColumnFilterShape, type ColumnOrderEvent, type ColumnOrderState, type ColumnResizeEvent, type ColumnResizeSession, type ColumnResolveOptions, type ColumnSelectEvent, type ColumnSelectionChangeEvent, type ColumnSizeDefaults, type ColumnSizingState, type ColumnSortEntry, type ColumnSortEvent, type ColumnSortState, type ColumnType, type ColumnValueCacheQuery, type ColumnValueOption, type ColumnValueOptions, type ColumnValueOptionsCache, type ColumnValueQuery, type ColumnVisibilityEvent, type ColumnVisibilityState, type ColumnWrapConfig, type ColumnsSelectEvent, type ConditionRowDraft, type ContextMenuOpenChangeEvent, type CopyContent, type CopyRequest, type CopySource, type CsvOptions, DEFAULT_COLUMN_SIZES, DEFAULT_FILTER_VALUE_LIMIT, type DataColumn, type DisplayRow, type DropSide, type ExportCell, type ExportColumn, type ExportDataRow, type ExportFile, type ExportFileSource, type ExportGroupRow, type ExportGroupSummaryRow, type ExportOptions, type ExportRow, type ExportScalar, type ExportSource, type ExportTable, type ExportTotalRow, type ExportWriteContext, type ExportWriter, type FieldPath, type FilterChangeEvent, type FilterChecklist, type FilterChecklistItem, type FilterChecklistOptions, type FilterEditorAction, type FilterEditorDraft, type FilterEntry, type FilterMenuUi, type FilterOperator, type FilterOperatorFamily, type FilterPredicate, type FilterScalar, type FilterState, type FooterTemplateContext, type FormatLocale, type GridCommand, type GridCommandActions, type GridCommandContext, type GridCommandContextInput, type GridCommandEvent, type GridCommandHost, type GridCommandSource, type GridCommandTarget, type GridContextMenuArea, type GridContextMenuEntries, type GridContextMenuOptions, type GridContextMenuRequest, type GridContextMenuTarget, type GridController, type GridControllerOptions, type GridExportOptions, type GridFilterMenuOptions, type GridFocus, type GridMessages, type GridOptions, type GridPanelKind, type GridState, type GridToolbarOptions, type GridToolbarTarget, type GridView, type GridViewInput, type GridViewOptions, type GridViewState, type GroupAggregateDisplay, type GroupByBarVisibility, type GroupByEntry, type GroupByEvent, type GroupByState, type GroupExpansionEvent, type GroupExpansionState, type GroupFilterEntry, HEADER_ROW, type HoverableConfig, type HtmlTableOptions, type JsonOptions, KEYBOARD_STEP, type KeyShortcutCapabilities, type MenuEntry, type MenuItemEntry, type MenuMove, type MenuResolveOptions, type MenuSubmenuEntry, type NavigationModifiers, type OperatorFilterEntry, type PaginateRowsOptions, type PaginatedRows, type PaginationChangeEvent, type PaginationState, type PaginationUnit, type PaginationWindowEntry, type ParsedConditionRows, type PredicateFilterEntry, type PrintDocument, type PrintOptions, type PrintOrientation, type PrintPage, type PrintSource, type ResizeMode, type ResolvedColumn, type ResolvedColumnFilterMenu, type ResolvedGroupRow, type ResolvedGroupSummaryRow, type ResolvedMenuEntry, type ResolvedMenuItem, type ResolvedMenuSeparator, type ResolvedMenuSubmenu, type ResolvedRow, type ResolvedToolbarButton, type ResolvedToolbarCustom, type ResolvedToolbarItem, type ResolvedToolbarMenu, type ResolvedToolbarSearch, type ResolvedToolbarSpacer, type RowHeights, type RowPointerEvent, type RowProps, type RowSelectEvent, type RowSelectionChangeEvent, type RowsSelectEvent, type SelectAllState, type SelectIntent, type SelectableConfig, type SelectedCell, type SelectedCellRef, type SelectedColumn, type SelectionCallbacks, type SelectionDiff, type SelectionDiffEvent, type SelectionMode, type SelectionState, type SerializedFilterEntry, type SerializedFilterScalar, type SerializedFilterState, type SerializedGridState, type SerializedGroupFilterEntry, type SerializedOperatorFilterEntry, type SerializedValueFilterEntry, type SortDirection, type TextFilterEntry, type ToolbarCustomEntry, type ToolbarEntry, type ToolbarFitInput, type ToolbarItemAttributes, type ToolbarResolveOptions, type ToolbarSplit, type TsvOptions, type ValueFilterEntry, type VisibleRange, accessDotted, alignmentForType, applyColumnOrder, applyColumnResize, applyColumnVisibility, applySelectionIntent, beginColumnResize, buildExportTable, buildKeyShortcuts, buildPrintDocument, builtInCommands, clampColumnWidth, clampFocus, clearAllFilters, clearSelection, collapseAllGroups, columnValueOptions, compareValues, computeAggregates, conditionRowsFrom, conditionsFromRows, contextMenuEntries, copyContent, createColumnValueOptionsCache, createCommandContext, createDefaultMessages, createGridController, createGridViewResolver, csvWriter, defaultContextMenu, defaultFilterOperators, defaultMessages, defaultToolbar, defineColumnsFromRows, describeColumnFilter, diffSelection, draftToFilter, excelFilter, expandAllGroups, exportFile, exportPrintDocument, filterChecklist, filterEditorReducer, filterOperandArity, filterOperatorFamily, filterQueryFor, filterRows, fitColumnsToWidth, fitToolbarItems, formatAggregateValue, formatCellValue, formatFilterOperand, formatGroupValue, getColumnId, groupRowId, groupRows, hasContextMenu, initialFilterEditorDraft, intentOf, isColumnFiltered, isColumnVisible, isPinnedToolbarItem, isSameCell, jsonWriter, matchesQuery, moveColumnBefore, moveGroupByBefore, movesColumn, movesGroupBy, nextFocusForKey, nextMenuIndex, paginateRows, paginationWindow, parseFilterOperand, resolveCell, resolveColumnChooser, resolveColumnConstraints, resolveColumnFilterMenu, resolveColumnHeaderText, resolveColumnLabel, resolveColumnWidths, resolveColumns, resolveCommands, resolveDataColumns, resolveDropBefore, resolveExportWriters, resolveGridView, resolveKeyboardDropTarget, resolveMenu, resolveMessages, resolveRowId, resolveRows, resolveShownRows, resolveToolbar, revertColumnSize, runCommand, searchTextOf, selectAll, selectAllState, selectCell, selectOnly, selectRange, serializeGridState, setColumnFilter, setColumnVisibility, setSearchText, sizeColumnToContent, sortDirectionFor, sortPriorityFor, sortRows, splitToolbarItems, toCsv, toHtmlTable, toJson, toTsv, toggleCellSelection, toggleColumnSort, toggleGroupExpansion, toggleSelection, toolbarEntries, totalColumnWidth, typeaheadIndex, visibleFilterOptions, visibleRange, withGroupAggregates };
|
package/dist/index.js
CHANGED
|
@@ -102,6 +102,13 @@ function accessDotted(obj, path) {
|
|
|
102
102
|
return path.split(".").reduce((value, key) => isNested(value) ? value[key] : void 0, obj);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
// src/util/position.ts
|
|
106
|
+
function renumberRows(entries) {
|
|
107
|
+
return entries.map(
|
|
108
|
+
(entry, index) => entry.rowIndex === index && entry.datasetIndex === index ? entry : { ...entry, rowIndex: index, datasetIndex: index }
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
105
112
|
// src/util/sorting.ts
|
|
106
113
|
function isEmpty(value) {
|
|
107
114
|
return value === null || value === void 0;
|
|
@@ -109,6 +116,21 @@ function isEmpty(value) {
|
|
|
109
116
|
function toTime(value) {
|
|
110
117
|
return value instanceof Date ? value.getTime() : new Date(String(value)).getTime();
|
|
111
118
|
}
|
|
119
|
+
function isFiniteNumber(value) {
|
|
120
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
121
|
+
}
|
|
122
|
+
function isValidDate(value) {
|
|
123
|
+
return value instanceof Date && !Number.isNaN(value.getTime());
|
|
124
|
+
}
|
|
125
|
+
function compareUntyped(a, b) {
|
|
126
|
+
if (isFiniteNumber(a) && isFiniteNumber(b)) {
|
|
127
|
+
return a - b;
|
|
128
|
+
}
|
|
129
|
+
if (isValidDate(a) && isValidDate(b)) {
|
|
130
|
+
return a.getTime() - b.getTime();
|
|
131
|
+
}
|
|
132
|
+
return String(a).localeCompare(String(b));
|
|
133
|
+
}
|
|
112
134
|
function compareValues(a, b, type) {
|
|
113
135
|
if (isEmpty(a)) {
|
|
114
136
|
return isEmpty(b) ? 0 : 1;
|
|
@@ -128,6 +150,8 @@ function compareValues(a, b, type) {
|
|
|
128
150
|
case "dateTime":
|
|
129
151
|
case "time":
|
|
130
152
|
return toTime(a) - toTime(b);
|
|
153
|
+
case void 0:
|
|
154
|
+
return compareUntyped(a, b);
|
|
131
155
|
default:
|
|
132
156
|
return String(a).localeCompare(String(b));
|
|
133
157
|
}
|
|
@@ -189,9 +213,7 @@ function sortRows(rows, sort, columns) {
|
|
|
189
213
|
}
|
|
190
214
|
return 0;
|
|
191
215
|
});
|
|
192
|
-
return sorted
|
|
193
|
-
(row, index) => row.rowIndex === index ? row : { ...row, rowIndex: index }
|
|
194
|
-
);
|
|
216
|
+
return renumberRows(sorted);
|
|
195
217
|
}
|
|
196
218
|
|
|
197
219
|
// src/util/grouping.ts
|
|
@@ -263,9 +285,7 @@ function buildLevel(rows, levels, parentPath, expansion, byId, out) {
|
|
|
263
285
|
path,
|
|
264
286
|
expanded,
|
|
265
287
|
count: group.rows.length,
|
|
266
|
-
//
|
|
267
|
-
// a header has no row of its own to carry a dataset position, so
|
|
268
|
-
// `datasetIndex` takes the same renumbered value `rowIndex` does.
|
|
288
|
+
// Both set by `groupRows` once it has the whole flattened array.
|
|
269
289
|
rowIndex: -1,
|
|
270
290
|
datasetIndex: -1,
|
|
271
291
|
// Set by `withGroupAggregates`, downstream of grouping — empty here
|
|
@@ -289,12 +309,7 @@ function groupRows(rows, groupBy, expansion, columns) {
|
|
|
289
309
|
}
|
|
290
310
|
const out = [];
|
|
291
311
|
buildLevel(rows, active, [], expansion, byId, out);
|
|
292
|
-
return out
|
|
293
|
-
if ("kind" in entry) {
|
|
294
|
-
return entry.rowIndex === index && entry.datasetIndex === index ? entry : { ...entry, rowIndex: index, datasetIndex: index };
|
|
295
|
-
}
|
|
296
|
-
return entry.rowIndex === index ? entry : { ...entry, rowIndex: index };
|
|
297
|
-
});
|
|
312
|
+
return renumberRows(out);
|
|
298
313
|
}
|
|
299
314
|
function toggleGroupExpansion(expansion, groupId) {
|
|
300
315
|
return expansion.includes(groupId) ? expansion.filter((id) => id !== groupId) : [...expansion, groupId];
|
|
@@ -396,7 +411,8 @@ function resolveKeyboardDropTarget(orderedIds, columnId, direction) {
|
|
|
396
411
|
}
|
|
397
412
|
|
|
398
413
|
// src/util/paging.ts
|
|
399
|
-
|
|
414
|
+
var NO_HEADERS = [];
|
|
415
|
+
function groupUnitsOf(rows) {
|
|
400
416
|
const units = [];
|
|
401
417
|
let start = 0;
|
|
402
418
|
let openedByGroup = false;
|
|
@@ -408,7 +424,7 @@ function unitsOf(rows) {
|
|
|
408
424
|
const isTopLevelHeader = "kind" in entry && entry.kind === "group" && entry.level === 0;
|
|
409
425
|
const isBoundary = index !== start && (isTopLevelHeader || !openedByGroup);
|
|
410
426
|
if (isBoundary) {
|
|
411
|
-
units.push({ start, end: index });
|
|
427
|
+
units.push({ start, end: index, headers: NO_HEADERS });
|
|
412
428
|
start = index;
|
|
413
429
|
openedByGroup = isTopLevelHeader;
|
|
414
430
|
} else if (index === start) {
|
|
@@ -416,13 +432,38 @@ function unitsOf(rows) {
|
|
|
416
432
|
}
|
|
417
433
|
}
|
|
418
434
|
if (start < rows.length) {
|
|
419
|
-
units.push({ start, end: rows.length });
|
|
435
|
+
units.push({ start, end: rows.length, headers: NO_HEADERS });
|
|
420
436
|
}
|
|
421
437
|
return units;
|
|
422
438
|
}
|
|
423
|
-
function
|
|
439
|
+
function rowUnitsOf(rows) {
|
|
440
|
+
const units = [];
|
|
441
|
+
let open = NO_HEADERS;
|
|
442
|
+
for (let index = 0; index < rows.length; index++) {
|
|
443
|
+
const entry = rows[index];
|
|
444
|
+
if (entry === void 0) {
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
447
|
+
if (!("kind" in entry)) {
|
|
448
|
+
units.push({ start: index, end: index + 1, headers: open });
|
|
449
|
+
} else if (entry.kind === "group") {
|
|
450
|
+
const ancestors = open.slice(0, entry.level);
|
|
451
|
+
open = entry.expanded ? [...ancestors, entry] : ancestors;
|
|
452
|
+
if (!entry.expanded) {
|
|
453
|
+
units.push({ start: index, end: index + 1, headers: ancestors });
|
|
454
|
+
}
|
|
455
|
+
} else {
|
|
456
|
+
const last = units.at(-1);
|
|
457
|
+
if (last !== void 0) {
|
|
458
|
+
units[units.length - 1] = { ...last, end: index + 1 };
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
return units;
|
|
463
|
+
}
|
|
464
|
+
function paginateRows(rows, pagination, options = {}) {
|
|
424
465
|
const pageSize = Math.max(1, pagination.pageSize);
|
|
425
|
-
const units =
|
|
466
|
+
const units = options.unit === "row" ? rowUnitsOf(rows) : groupUnitsOf(rows);
|
|
426
467
|
const pageCount = Math.ceil(units.length / pageSize);
|
|
427
468
|
if (pageCount === 0) {
|
|
428
469
|
return { rows: [], pageCount: 0, pageIndex: 0 };
|
|
@@ -433,7 +474,10 @@ function paginateRows(rows, pagination) {
|
|
|
433
474
|
if (firstUnit === void 0 || lastUnit === void 0) {
|
|
434
475
|
return { rows: [], pageCount, pageIndex };
|
|
435
476
|
}
|
|
436
|
-
const page =
|
|
477
|
+
const page = [
|
|
478
|
+
...firstUnit.headers,
|
|
479
|
+
...rows.slice(firstUnit.start, lastUnit.end)
|
|
480
|
+
];
|
|
437
481
|
const renumbered = page.map(
|
|
438
482
|
(entry, index) => entry.rowIndex === index ? entry : { ...entry, rowIndex: index }
|
|
439
483
|
);
|
|
@@ -985,12 +1029,7 @@ function withGroupAggregates(displayRows, flatRows, groupBy, specs, columns, dis
|
|
|
985
1029
|
display,
|
|
986
1030
|
out
|
|
987
1031
|
);
|
|
988
|
-
return out
|
|
989
|
-
if ("kind" in entry) {
|
|
990
|
-
return entry.rowIndex === position && entry.datasetIndex === position ? entry : { ...entry, rowIndex: position, datasetIndex: position };
|
|
991
|
-
}
|
|
992
|
-
return entry.rowIndex === position ? entry : { ...entry, rowIndex: position };
|
|
993
|
-
});
|
|
1032
|
+
return renumberRows(out);
|
|
994
1033
|
}
|
|
995
1034
|
|
|
996
1035
|
// src/util/filtering.ts
|
|
@@ -1151,9 +1190,7 @@ function filterRows(rows, filter, columns) {
|
|
|
1151
1190
|
return rows;
|
|
1152
1191
|
}
|
|
1153
1192
|
const filtered = rows.filter((row) => test(row.row));
|
|
1154
|
-
return filtered
|
|
1155
|
-
(row, index) => row.rowIndex === index ? row : { ...row, rowIndex: index }
|
|
1156
|
-
);
|
|
1193
|
+
return renumberRows(filtered);
|
|
1157
1194
|
}
|
|
1158
1195
|
|
|
1159
1196
|
// src/util/rows.ts
|
|
@@ -1242,8 +1279,8 @@ function totalAggregates(rows, aggregates, dataColumns) {
|
|
|
1242
1279
|
dataColumns
|
|
1243
1280
|
);
|
|
1244
1281
|
}
|
|
1245
|
-
function paginate(displayRows, paginated, pagination) {
|
|
1246
|
-
return paginated ? paginateRows(displayRows, pagination) : { rows: displayRows, pageCount: 1, pageIndex: 0 };
|
|
1282
|
+
function paginate(displayRows, paginated, pagination, unit) {
|
|
1283
|
+
return paginated ? paginateRows(displayRows, pagination, { unit }) : { rows: displayRows, pageCount: 1, pageIndex: 0 };
|
|
1247
1284
|
}
|
|
1248
1285
|
function narrowToDataRows(pageRows, rows, reshaped) {
|
|
1249
1286
|
return reshaped ? pageRows.filter((entry) => !("kind" in entry)) : rows;
|
|
@@ -1304,7 +1341,12 @@ function createGridViewResolver() {
|
|
|
1304
1341
|
rows: pageRows,
|
|
1305
1342
|
pageCount,
|
|
1306
1343
|
pageIndex
|
|
1307
|
-
} = page(
|
|
1344
|
+
} = page(
|
|
1345
|
+
displayRows,
|
|
1346
|
+
paginated,
|
|
1347
|
+
state.pagination,
|
|
1348
|
+
options.paginationUnit ?? "group"
|
|
1349
|
+
);
|
|
1308
1350
|
return assemble(
|
|
1309
1351
|
dataColumns,
|
|
1310
1352
|
columns,
|
|
@@ -1751,11 +1793,12 @@ function definedColumns(columns, rows) {
|
|
|
1751
1793
|
}
|
|
1752
1794
|
return NO_COLUMNS;
|
|
1753
1795
|
}
|
|
1754
|
-
function pagingInputsOf(state) {
|
|
1796
|
+
function pagingInputsOf(state, options) {
|
|
1755
1797
|
return {
|
|
1756
1798
|
filter: state.filter,
|
|
1757
1799
|
columnSort: state.columnSort,
|
|
1758
|
-
groupBy: state.groupBy
|
|
1800
|
+
groupBy: state.groupBy,
|
|
1801
|
+
paginationUnit: options.paginationUnit ?? "group"
|
|
1759
1802
|
};
|
|
1760
1803
|
}
|
|
1761
1804
|
function createGridController(initial) {
|
|
@@ -1767,7 +1810,7 @@ function createGridController(initial) {
|
|
|
1767
1810
|
const reportedConflicts = /* @__PURE__ */ new Set();
|
|
1768
1811
|
let heldReports;
|
|
1769
1812
|
let state = resolveSlices();
|
|
1770
|
-
let pagingInputs = pagingInputsOf(state);
|
|
1813
|
+
let pagingInputs = pagingInputsOf(state, options);
|
|
1771
1814
|
reportConflicts();
|
|
1772
1815
|
function controlledValue(key) {
|
|
1773
1816
|
const controlled = options;
|
|
@@ -1809,14 +1852,30 @@ function createGridController(initial) {
|
|
|
1809
1852
|
}
|
|
1810
1853
|
function refresh() {
|
|
1811
1854
|
let next = resolveSlices();
|
|
1812
|
-
|
|
1813
|
-
|
|
1855
|
+
const inputs = pagingInputsOf(next, options);
|
|
1856
|
+
if (inputs.filter !== pagingInputs.filter || inputs.columnSort !== pagingInputs.columnSort || inputs.groupBy !== pagingInputs.groupBy || inputs.paginationUnit !== pagingInputs.paginationUnit) {
|
|
1857
|
+
pagingInputs = inputs;
|
|
1814
1858
|
if (!isControlled("pagination") && own.pagination.pageIndex !== 0) {
|
|
1815
1859
|
own.pagination = { ...own.pagination, pageIndex: 0 };
|
|
1816
1860
|
next = { ...next, pagination: own.pagination };
|
|
1817
1861
|
}
|
|
1818
1862
|
}
|
|
1819
1863
|
state = SLICE_KEYS.every((key) => next[key] === state[key]) ? state : next;
|
|
1864
|
+
storeShownPage();
|
|
1865
|
+
}
|
|
1866
|
+
function storeShownPage() {
|
|
1867
|
+
const stored = storedPagination(state.pagination);
|
|
1868
|
+
if (stored !== state.pagination) {
|
|
1869
|
+
own.pagination = stored;
|
|
1870
|
+
state = { ...state, pagination: stored };
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
function storedPagination(pagination) {
|
|
1874
|
+
if (options.paginated !== true || isControlled("pagination")) {
|
|
1875
|
+
return pagination;
|
|
1876
|
+
}
|
|
1877
|
+
const { pageCount, pageIndex } = pageOf(pagination);
|
|
1878
|
+
return pageCount === 0 || pageIndex === pagination.pageIndex ? pagination : { ...pagination, pageIndex };
|
|
1820
1879
|
}
|
|
1821
1880
|
function notify() {
|
|
1822
1881
|
for (const listener of [...listeners]) {
|
|
@@ -1846,6 +1905,7 @@ function createGridController(initial) {
|
|
|
1846
1905
|
state,
|
|
1847
1906
|
options: {
|
|
1848
1907
|
paginated: options.paginated,
|
|
1908
|
+
paginationUnit: options.paginationUnit,
|
|
1849
1909
|
aggregates: options.aggregates,
|
|
1850
1910
|
groupAggregateDisplay: options.groupAggregateDisplay,
|
|
1851
1911
|
columnSizeDefaults: options.columnSizeDefaults,
|
|
@@ -1906,27 +1966,31 @@ function createGridController(initial) {
|
|
|
1906
1966
|
options.onGroupExpansionChange?.({ groupId, expansion: next });
|
|
1907
1967
|
});
|
|
1908
1968
|
}
|
|
1909
|
-
function commitPagination(
|
|
1969
|
+
function commitPagination(asked) {
|
|
1970
|
+
const next = heldReports === void 0 ? storedPagination(asked) : asked;
|
|
1910
1971
|
if (samePagination(state.pagination, next)) {
|
|
1911
1972
|
return;
|
|
1912
1973
|
}
|
|
1913
1974
|
commit("pagination", next, () => {
|
|
1975
|
+
const pagination = isControlled("pagination") ? next : own.pagination;
|
|
1914
1976
|
options.onPaginationChange?.({
|
|
1915
|
-
pagination
|
|
1916
|
-
pageCount:
|
|
1977
|
+
pagination,
|
|
1978
|
+
pageCount: pageOf(pagination).pageCount
|
|
1917
1979
|
});
|
|
1918
1980
|
});
|
|
1919
1981
|
}
|
|
1982
|
+
function pageOf(pagination) {
|
|
1983
|
+
return paginateRows(getView().displayRows, pagination, {
|
|
1984
|
+
unit: options.paginationUnit
|
|
1985
|
+
});
|
|
1986
|
+
}
|
|
1920
1987
|
function goToPage(pageIndex) {
|
|
1921
1988
|
const current = state.pagination;
|
|
1922
|
-
const clamped =
|
|
1923
|
-
...current,
|
|
1924
|
-
pageIndex
|
|
1925
|
-
}).pageIndex;
|
|
1989
|
+
const clamped = pageOf({ ...current, pageIndex }).pageIndex;
|
|
1926
1990
|
commitPagination({ ...current, pageIndex: clamped });
|
|
1927
1991
|
}
|
|
1928
1992
|
function shownPageIndex() {
|
|
1929
|
-
return
|
|
1993
|
+
return pageOf(state.pagination).pageIndex;
|
|
1930
1994
|
}
|
|
1931
1995
|
const selection = createSelectionActions({
|
|
1932
1996
|
getState: () => state,
|
|
@@ -1953,7 +2017,7 @@ function createGridController(initial) {
|
|
|
1953
2017
|
heldReports = void 0;
|
|
1954
2018
|
}
|
|
1955
2019
|
if (saved.pagination !== void 0) {
|
|
1956
|
-
pagingInputs = pagingInputsOf(resolveSlices());
|
|
2020
|
+
pagingInputs = pagingInputsOf(resolveSlices(), options);
|
|
1957
2021
|
}
|
|
1958
2022
|
refresh();
|
|
1959
2023
|
for (const report of reports) {
|
|
@@ -2115,7 +2179,7 @@ function createGridController(initial) {
|
|
|
2115
2179
|
const first = { pageIndex: 0, pageSize };
|
|
2116
2180
|
commitPagination({
|
|
2117
2181
|
...first,
|
|
2118
|
-
pageIndex:
|
|
2182
|
+
pageIndex: pageOf(first).pageIndex
|
|
2119
2183
|
});
|
|
2120
2184
|
}
|
|
2121
2185
|
};
|
|
@@ -4159,7 +4223,14 @@ function exportMenu() {
|
|
|
4159
4223
|
};
|
|
4160
4224
|
}
|
|
4161
4225
|
function resolveToolbar(entries, options) {
|
|
4162
|
-
const { commands, contextFor } = options;
|
|
4226
|
+
const { commands, contextFor, itemAttributes } = options;
|
|
4227
|
+
function withAttributes(item) {
|
|
4228
|
+
if (item.type === "separator" || item.type === "spacer" || itemAttributes === void 0 || !Object.hasOwn(itemAttributes, item.key)) {
|
|
4229
|
+
return item;
|
|
4230
|
+
}
|
|
4231
|
+
const attributes = itemAttributes[item.key];
|
|
4232
|
+
return attributes === void 0 ? item : { ...item, attributes };
|
|
4233
|
+
}
|
|
4163
4234
|
function resolveEntry(entry, index) {
|
|
4164
4235
|
if (entry === "search") {
|
|
4165
4236
|
return { type: "search", key: "search" };
|
|
@@ -4191,7 +4262,7 @@ function resolveToolbar(entries, options) {
|
|
|
4191
4262
|
return { ...item, type: "button", key: item.id, pressed: checked };
|
|
4192
4263
|
}
|
|
4193
4264
|
return collapseSeparators(
|
|
4194
|
-
entries.map(resolveEntry).filter((entry) => entry !== null),
|
|
4265
|
+
entries.map(resolveEntry).filter((entry) => entry !== null).map(withAttributes),
|
|
4195
4266
|
isSpacer
|
|
4196
4267
|
);
|
|
4197
4268
|
}
|