@gridkitjs/core 0.14.1 → 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 +90 -25
- package/dist/index.js +106 -26
- 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
|
|
@@ -3635,18 +3691,27 @@ interface PaginatedRows<Row> {
|
|
|
3635
3691
|
*/
|
|
3636
3692
|
readonly pageIndex: number;
|
|
3637
3693
|
}
|
|
3694
|
+
interface PaginateRowsOptions {
|
|
3695
|
+
/** What `pageSize` counts — see `PaginationUnit`. Defaults to `"group"`. */
|
|
3696
|
+
readonly unit?: PaginationUnit | undefined;
|
|
3697
|
+
}
|
|
3638
3698
|
/**
|
|
3639
|
-
* `rows` sliced into pages of `pagination.pageSize` units — see
|
|
3640
|
-
* for what a unit is
|
|
3641
|
-
*
|
|
3642
|
-
*
|
|
3643
|
-
* `
|
|
3644
|
-
*
|
|
3645
|
-
*
|
|
3646
|
-
*
|
|
3647
|
-
* the
|
|
3648
|
-
|
|
3649
|
-
|
|
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>;
|
|
3650
3715
|
|
|
3651
3716
|
type PaginationWindowEntry = number | "ellipsis";
|
|
3652
3717
|
/**
|
|
@@ -4226,4 +4291,4 @@ declare const excelFilter: {
|
|
|
4226
4291
|
};
|
|
4227
4292
|
};
|
|
4228
4293
|
|
|
4229
|
-
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
|
@@ -116,6 +116,21 @@ function isEmpty(value) {
|
|
|
116
116
|
function toTime(value) {
|
|
117
117
|
return value instanceof Date ? value.getTime() : new Date(String(value)).getTime();
|
|
118
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
|
+
}
|
|
119
134
|
function compareValues(a, b, type) {
|
|
120
135
|
if (isEmpty(a)) {
|
|
121
136
|
return isEmpty(b) ? 0 : 1;
|
|
@@ -135,6 +150,8 @@ function compareValues(a, b, type) {
|
|
|
135
150
|
case "dateTime":
|
|
136
151
|
case "time":
|
|
137
152
|
return toTime(a) - toTime(b);
|
|
153
|
+
case void 0:
|
|
154
|
+
return compareUntyped(a, b);
|
|
138
155
|
default:
|
|
139
156
|
return String(a).localeCompare(String(b));
|
|
140
157
|
}
|
|
@@ -394,7 +411,8 @@ function resolveKeyboardDropTarget(orderedIds, columnId, direction) {
|
|
|
394
411
|
}
|
|
395
412
|
|
|
396
413
|
// src/util/paging.ts
|
|
397
|
-
|
|
414
|
+
var NO_HEADERS = [];
|
|
415
|
+
function groupUnitsOf(rows) {
|
|
398
416
|
const units = [];
|
|
399
417
|
let start = 0;
|
|
400
418
|
let openedByGroup = false;
|
|
@@ -406,7 +424,7 @@ function unitsOf(rows) {
|
|
|
406
424
|
const isTopLevelHeader = "kind" in entry && entry.kind === "group" && entry.level === 0;
|
|
407
425
|
const isBoundary = index !== start && (isTopLevelHeader || !openedByGroup);
|
|
408
426
|
if (isBoundary) {
|
|
409
|
-
units.push({ start, end: index });
|
|
427
|
+
units.push({ start, end: index, headers: NO_HEADERS });
|
|
410
428
|
start = index;
|
|
411
429
|
openedByGroup = isTopLevelHeader;
|
|
412
430
|
} else if (index === start) {
|
|
@@ -414,13 +432,38 @@ function unitsOf(rows) {
|
|
|
414
432
|
}
|
|
415
433
|
}
|
|
416
434
|
if (start < rows.length) {
|
|
417
|
-
units.push({ start, end: rows.length });
|
|
435
|
+
units.push({ start, end: rows.length, headers: NO_HEADERS });
|
|
436
|
+
}
|
|
437
|
+
return units;
|
|
438
|
+
}
|
|
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
|
+
}
|
|
418
461
|
}
|
|
419
462
|
return units;
|
|
420
463
|
}
|
|
421
|
-
function paginateRows(rows, pagination) {
|
|
464
|
+
function paginateRows(rows, pagination, options = {}) {
|
|
422
465
|
const pageSize = Math.max(1, pagination.pageSize);
|
|
423
|
-
const units =
|
|
466
|
+
const units = options.unit === "row" ? rowUnitsOf(rows) : groupUnitsOf(rows);
|
|
424
467
|
const pageCount = Math.ceil(units.length / pageSize);
|
|
425
468
|
if (pageCount === 0) {
|
|
426
469
|
return { rows: [], pageCount: 0, pageIndex: 0 };
|
|
@@ -431,7 +474,10 @@ function paginateRows(rows, pagination) {
|
|
|
431
474
|
if (firstUnit === void 0 || lastUnit === void 0) {
|
|
432
475
|
return { rows: [], pageCount, pageIndex };
|
|
433
476
|
}
|
|
434
|
-
const page =
|
|
477
|
+
const page = [
|
|
478
|
+
...firstUnit.headers,
|
|
479
|
+
...rows.slice(firstUnit.start, lastUnit.end)
|
|
480
|
+
];
|
|
435
481
|
const renumbered = page.map(
|
|
436
482
|
(entry, index) => entry.rowIndex === index ? entry : { ...entry, rowIndex: index }
|
|
437
483
|
);
|
|
@@ -1233,8 +1279,8 @@ function totalAggregates(rows, aggregates, dataColumns) {
|
|
|
1233
1279
|
dataColumns
|
|
1234
1280
|
);
|
|
1235
1281
|
}
|
|
1236
|
-
function paginate(displayRows, paginated, pagination) {
|
|
1237
|
-
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 };
|
|
1238
1284
|
}
|
|
1239
1285
|
function narrowToDataRows(pageRows, rows, reshaped) {
|
|
1240
1286
|
return reshaped ? pageRows.filter((entry) => !("kind" in entry)) : rows;
|
|
@@ -1295,7 +1341,12 @@ function createGridViewResolver() {
|
|
|
1295
1341
|
rows: pageRows,
|
|
1296
1342
|
pageCount,
|
|
1297
1343
|
pageIndex
|
|
1298
|
-
} = page(
|
|
1344
|
+
} = page(
|
|
1345
|
+
displayRows,
|
|
1346
|
+
paginated,
|
|
1347
|
+
state.pagination,
|
|
1348
|
+
options.paginationUnit ?? "group"
|
|
1349
|
+
);
|
|
1299
1350
|
return assemble(
|
|
1300
1351
|
dataColumns,
|
|
1301
1352
|
columns,
|
|
@@ -1742,11 +1793,12 @@ function definedColumns(columns, rows) {
|
|
|
1742
1793
|
}
|
|
1743
1794
|
return NO_COLUMNS;
|
|
1744
1795
|
}
|
|
1745
|
-
function pagingInputsOf(state) {
|
|
1796
|
+
function pagingInputsOf(state, options) {
|
|
1746
1797
|
return {
|
|
1747
1798
|
filter: state.filter,
|
|
1748
1799
|
columnSort: state.columnSort,
|
|
1749
|
-
groupBy: state.groupBy
|
|
1800
|
+
groupBy: state.groupBy,
|
|
1801
|
+
paginationUnit: options.paginationUnit ?? "group"
|
|
1750
1802
|
};
|
|
1751
1803
|
}
|
|
1752
1804
|
function createGridController(initial) {
|
|
@@ -1758,7 +1810,7 @@ function createGridController(initial) {
|
|
|
1758
1810
|
const reportedConflicts = /* @__PURE__ */ new Set();
|
|
1759
1811
|
let heldReports;
|
|
1760
1812
|
let state = resolveSlices();
|
|
1761
|
-
let pagingInputs = pagingInputsOf(state);
|
|
1813
|
+
let pagingInputs = pagingInputsOf(state, options);
|
|
1762
1814
|
reportConflicts();
|
|
1763
1815
|
function controlledValue(key) {
|
|
1764
1816
|
const controlled = options;
|
|
@@ -1800,14 +1852,30 @@ function createGridController(initial) {
|
|
|
1800
1852
|
}
|
|
1801
1853
|
function refresh() {
|
|
1802
1854
|
let next = resolveSlices();
|
|
1803
|
-
|
|
1804
|
-
|
|
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;
|
|
1805
1858
|
if (!isControlled("pagination") && own.pagination.pageIndex !== 0) {
|
|
1806
1859
|
own.pagination = { ...own.pagination, pageIndex: 0 };
|
|
1807
1860
|
next = { ...next, pagination: own.pagination };
|
|
1808
1861
|
}
|
|
1809
1862
|
}
|
|
1810
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 };
|
|
1811
1879
|
}
|
|
1812
1880
|
function notify() {
|
|
1813
1881
|
for (const listener of [...listeners]) {
|
|
@@ -1837,6 +1905,7 @@ function createGridController(initial) {
|
|
|
1837
1905
|
state,
|
|
1838
1906
|
options: {
|
|
1839
1907
|
paginated: options.paginated,
|
|
1908
|
+
paginationUnit: options.paginationUnit,
|
|
1840
1909
|
aggregates: options.aggregates,
|
|
1841
1910
|
groupAggregateDisplay: options.groupAggregateDisplay,
|
|
1842
1911
|
columnSizeDefaults: options.columnSizeDefaults,
|
|
@@ -1897,27 +1966,31 @@ function createGridController(initial) {
|
|
|
1897
1966
|
options.onGroupExpansionChange?.({ groupId, expansion: next });
|
|
1898
1967
|
});
|
|
1899
1968
|
}
|
|
1900
|
-
function commitPagination(
|
|
1969
|
+
function commitPagination(asked) {
|
|
1970
|
+
const next = heldReports === void 0 ? storedPagination(asked) : asked;
|
|
1901
1971
|
if (samePagination(state.pagination, next)) {
|
|
1902
1972
|
return;
|
|
1903
1973
|
}
|
|
1904
1974
|
commit("pagination", next, () => {
|
|
1975
|
+
const pagination = isControlled("pagination") ? next : own.pagination;
|
|
1905
1976
|
options.onPaginationChange?.({
|
|
1906
|
-
pagination
|
|
1907
|
-
pageCount:
|
|
1977
|
+
pagination,
|
|
1978
|
+
pageCount: pageOf(pagination).pageCount
|
|
1908
1979
|
});
|
|
1909
1980
|
});
|
|
1910
1981
|
}
|
|
1982
|
+
function pageOf(pagination) {
|
|
1983
|
+
return paginateRows(getView().displayRows, pagination, {
|
|
1984
|
+
unit: options.paginationUnit
|
|
1985
|
+
});
|
|
1986
|
+
}
|
|
1911
1987
|
function goToPage(pageIndex) {
|
|
1912
1988
|
const current = state.pagination;
|
|
1913
|
-
const clamped =
|
|
1914
|
-
...current,
|
|
1915
|
-
pageIndex
|
|
1916
|
-
}).pageIndex;
|
|
1989
|
+
const clamped = pageOf({ ...current, pageIndex }).pageIndex;
|
|
1917
1990
|
commitPagination({ ...current, pageIndex: clamped });
|
|
1918
1991
|
}
|
|
1919
1992
|
function shownPageIndex() {
|
|
1920
|
-
return
|
|
1993
|
+
return pageOf(state.pagination).pageIndex;
|
|
1921
1994
|
}
|
|
1922
1995
|
const selection = createSelectionActions({
|
|
1923
1996
|
getState: () => state,
|
|
@@ -1944,7 +2017,7 @@ function createGridController(initial) {
|
|
|
1944
2017
|
heldReports = void 0;
|
|
1945
2018
|
}
|
|
1946
2019
|
if (saved.pagination !== void 0) {
|
|
1947
|
-
pagingInputs = pagingInputsOf(resolveSlices());
|
|
2020
|
+
pagingInputs = pagingInputsOf(resolveSlices(), options);
|
|
1948
2021
|
}
|
|
1949
2022
|
refresh();
|
|
1950
2023
|
for (const report of reports) {
|
|
@@ -2106,7 +2179,7 @@ function createGridController(initial) {
|
|
|
2106
2179
|
const first = { pageIndex: 0, pageSize };
|
|
2107
2180
|
commitPagination({
|
|
2108
2181
|
...first,
|
|
2109
|
-
pageIndex:
|
|
2182
|
+
pageIndex: pageOf(first).pageIndex
|
|
2110
2183
|
});
|
|
2111
2184
|
}
|
|
2112
2185
|
};
|
|
@@ -4150,7 +4223,14 @@ function exportMenu() {
|
|
|
4150
4223
|
};
|
|
4151
4224
|
}
|
|
4152
4225
|
function resolveToolbar(entries, options) {
|
|
4153
|
-
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
|
+
}
|
|
4154
4234
|
function resolveEntry(entry, index) {
|
|
4155
4235
|
if (entry === "search") {
|
|
4156
4236
|
return { type: "search", key: "search" };
|
|
@@ -4182,7 +4262,7 @@ function resolveToolbar(entries, options) {
|
|
|
4182
4262
|
return { ...item, type: "button", key: item.id, pressed: checked };
|
|
4183
4263
|
}
|
|
4184
4264
|
return collapseSeparators(
|
|
4185
|
-
entries.map(resolveEntry).filter((entry) => entry !== null),
|
|
4265
|
+
entries.map(resolveEntry).filter((entry) => entry !== null).map(withAttributes),
|
|
4186
4266
|
isSpacer
|
|
4187
4267
|
);
|
|
4188
4268
|
}
|