@gridkitjs/core 0.0.0-dev-20261106222533 → 0.0.0-dev-20261107202111
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 +55 -22
- package/dist/index.js +78 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1732,11 +1732,23 @@ interface GridOptions<Row> {
|
|
|
1732
1732
|
*/
|
|
1733
1733
|
filterMenu?: GridFilterMenuOptions | undefined;
|
|
1734
1734
|
/**
|
|
1735
|
-
* Whether the grid's rows are split into pages.
|
|
1736
|
-
*
|
|
1737
|
-
*
|
|
1735
|
+
* Whether the grid's rows are split into pages. Off by default, matching
|
|
1736
|
+
* `sortableColumns`. What a page's `pageSize` counts once the rows are
|
|
1737
|
+
* grouped is `paginationUnit`'s choice.
|
|
1738
1738
|
*/
|
|
1739
1739
|
paginated?: boolean | undefined;
|
|
1740
|
+
/**
|
|
1741
|
+
* What `pageSize` counts in a grouped grid. `"group"` (the default) counts
|
|
1742
|
+
* top-level groups, each with everything beneath it, so a page never
|
|
1743
|
+
* splits a group but can grow as large as its groups. `"row"` counts data
|
|
1744
|
+
* rows, plus collapsed group headers, which stand in for their hidden
|
|
1745
|
+
* rows: every page holds `pageSize` of them, and a page continuing a group
|
|
1746
|
+
* starts with that group's headers again, with a group's summary row on
|
|
1747
|
+
* the page holding its last row. An ungrouped grid pages by data rows
|
|
1748
|
+
* under either. Selection, export and aggregates behave the same under
|
|
1749
|
+
* either unit.
|
|
1750
|
+
*/
|
|
1751
|
+
paginationUnit?: PaginationUnit | undefined;
|
|
1740
1752
|
/**
|
|
1741
1753
|
* The page and page size to start on. Uncontrolled. Defaults to
|
|
1742
1754
|
* `{ pageIndex: 0, pageSize: 25 }` when `paginated` is on and this is
|
|
@@ -1749,9 +1761,9 @@ interface GridOptions<Row> {
|
|
|
1749
1761
|
* them itself, starting from `defaultPagination`.
|
|
1750
1762
|
*
|
|
1751
1763
|
* 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.
|
|
1764
|
+
* the filter, sort, grouping or `paginationUnit` changes; a controlled
|
|
1765
|
+
* one is the parent's to reset alongside that change. Until it does, the
|
|
1766
|
+
* grid shows the last page that exists rather than an empty one.
|
|
1755
1767
|
*/
|
|
1756
1768
|
pagination?: PaginationState | undefined;
|
|
1757
1769
|
/** Called once when the user changes the page or the page size. */
|
|
@@ -2078,8 +2090,9 @@ interface ColumnDefinition<Row, Node = string> {
|
|
|
2078
2090
|
*/
|
|
2079
2091
|
footerTemplate?: ((context: FooterTemplateContext<Row>) => Node) | undefined;
|
|
2080
2092
|
/**
|
|
2081
|
-
* The value type of this column's cells.
|
|
2082
|
-
*
|
|
2093
|
+
* The value type of this column's cells. Absent, the column has none: it
|
|
2094
|
+
* sorts as `compareValues` does without a type, two numbers or two `Date`s
|
|
2095
|
+
* by value and any other pair as text.
|
|
2083
2096
|
*/
|
|
2084
2097
|
type?: ColumnType;
|
|
2085
2098
|
/**
|
|
@@ -2218,6 +2231,15 @@ interface PaginationState {
|
|
|
2218
2231
|
readonly pageIndex: number;
|
|
2219
2232
|
readonly pageSize: number;
|
|
2220
2233
|
}
|
|
2234
|
+
/**
|
|
2235
|
+
* What a grouped grid's `pageSize` counts. `"group"` counts top-level groups,
|
|
2236
|
+
* each with everything beneath it, so a page never splits a group. `"row"`
|
|
2237
|
+
* counts data rows and collapsed group headers, so every page holds
|
|
2238
|
+
* `pageSize` of them however large the groups are; a page continuing a group
|
|
2239
|
+
* starts with that group's headers again. An ungrouped grid pages by data
|
|
2240
|
+
* rows under either.
|
|
2241
|
+
*/
|
|
2242
|
+
type PaginationUnit = "group" | "row";
|
|
2221
2243
|
/** Reports a user page/page-size change whole — the one to persist from, mirroring ColumnSortEvent. */
|
|
2222
2244
|
interface PaginationChangeEvent {
|
|
2223
2245
|
readonly pagination: PaginationState;
|
|
@@ -2856,6 +2878,8 @@ type GridViewState<Row> = Omit<GridState<Row>, "rowSelection" | "columnSelection
|
|
|
2856
2878
|
interface GridViewOptions<Row> {
|
|
2857
2879
|
/** Whether `pageRows` is one page of `displayRows` rather than all of it. Defaults to `false`. */
|
|
2858
2880
|
readonly paginated?: boolean | undefined;
|
|
2881
|
+
/** What a page's `pageSize` counts once grouped. Defaults to `"group"`. */
|
|
2882
|
+
readonly paginationUnit?: PaginationUnit | undefined;
|
|
2859
2883
|
readonly aggregates?: AggregateState<Row> | undefined;
|
|
2860
2884
|
/** Defaults to `"inline"`. */
|
|
2861
2885
|
readonly groupAggregateDisplay?: GroupAggregateDisplay | undefined;
|
|
@@ -3411,8 +3435,8 @@ declare function revertColumnSize(current: ColumnSizingState, base: ColumnSizing
|
|
|
3411
3435
|
/**
|
|
3412
3436
|
* Compares two cell values the way `type` implies — numerically for the
|
|
3413
3437
|
* numeric types, chronologically for the date/time types, lexically
|
|
3414
|
-
* otherwise.
|
|
3415
|
-
*
|
|
3438
|
+
* otherwise. With no `type`, two numbers or two `Date`s compare by value and
|
|
3439
|
+
* anything else as text; see `compareUntyped`.
|
|
3416
3440
|
*
|
|
3417
3441
|
* `null`/`undefined` sort after every value on both sides. Used directly,
|
|
3418
3442
|
* that ordering is fixed; `sortRows` applies it directionally without
|
|
@@ -3635,18 +3659,27 @@ interface PaginatedRows<Row> {
|
|
|
3635
3659
|
*/
|
|
3636
3660
|
readonly pageIndex: number;
|
|
3637
3661
|
}
|
|
3662
|
+
interface PaginateRowsOptions {
|
|
3663
|
+
/** What `pageSize` counts — see `PaginationUnit`. Defaults to `"group"`. */
|
|
3664
|
+
readonly unit?: PaginationUnit | undefined;
|
|
3665
|
+
}
|
|
3638
3666
|
/**
|
|
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
|
-
|
|
3667
|
+
* `rows` sliced into pages of `pagination.pageSize` units — see
|
|
3668
|
+
* `groupUnitsOf` and `rowUnitsOf` for what a unit is under each
|
|
3669
|
+
* `options.unit`. A page opens with its first unit's enclosing headers, so
|
|
3670
|
+
* under `"row"` a header repeated from the page before is the same
|
|
3671
|
+
* `DisplayRow`, and toggling it toggles its group on every page.
|
|
3672
|
+
*
|
|
3673
|
+
* `pageIndex` is clamped into range, `pageSize <= 0` is clamped to `1`
|
|
3674
|
+
* (this codebase's general tolerance for stale/odd stored state, matching
|
|
3675
|
+
* `sortRows`/`filterRows`), and the returned page's `rowIndex` is renumbered
|
|
3676
|
+
* to be page-relative — 0-based from the top of the page, header rows
|
|
3677
|
+
* included, mirroring `groupRows`'s own renumbering invariant.
|
|
3678
|
+
* `datasetIndex` is left untouched: the stages ahead of this one set it to
|
|
3679
|
+
* each row's position in the whole displayed result, which stays the same
|
|
3680
|
+
* whichever page is showing.
|
|
3681
|
+
*/
|
|
3682
|
+
declare function paginateRows<Row>(rows: readonly DisplayRow<Row>[], pagination: PaginationState, options?: PaginateRowsOptions): PaginatedRows<Row>;
|
|
3650
3683
|
|
|
3651
3684
|
type PaginationWindowEntry = number | "ellipsis";
|
|
3652
3685
|
/**
|
|
@@ -4226,4 +4259,4 @@ declare const excelFilter: {
|
|
|
4226
4259
|
};
|
|
4227
4260
|
};
|
|
4228
4261
|
|
|
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 };
|
|
4262
|
+
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 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 });
|
|
418
436
|
}
|
|
419
437
|
return units;
|
|
420
438
|
}
|
|
421
|
-
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 = {}) {
|
|
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,8 +1852,9 @@ 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 };
|
|
@@ -1837,6 +1890,7 @@ function createGridController(initial) {
|
|
|
1837
1890
|
state,
|
|
1838
1891
|
options: {
|
|
1839
1892
|
paginated: options.paginated,
|
|
1893
|
+
paginationUnit: options.paginationUnit,
|
|
1840
1894
|
aggregates: options.aggregates,
|
|
1841
1895
|
groupAggregateDisplay: options.groupAggregateDisplay,
|
|
1842
1896
|
columnSizeDefaults: options.columnSizeDefaults,
|
|
@@ -1904,20 +1958,22 @@ function createGridController(initial) {
|
|
|
1904
1958
|
commit("pagination", next, () => {
|
|
1905
1959
|
options.onPaginationChange?.({
|
|
1906
1960
|
pagination: next,
|
|
1907
|
-
pageCount:
|
|
1961
|
+
pageCount: pageOf(next).pageCount
|
|
1908
1962
|
});
|
|
1909
1963
|
});
|
|
1910
1964
|
}
|
|
1965
|
+
function pageOf(pagination) {
|
|
1966
|
+
return paginateRows(getView().displayRows, pagination, {
|
|
1967
|
+
unit: options.paginationUnit
|
|
1968
|
+
});
|
|
1969
|
+
}
|
|
1911
1970
|
function goToPage(pageIndex) {
|
|
1912
1971
|
const current = state.pagination;
|
|
1913
|
-
const clamped =
|
|
1914
|
-
...current,
|
|
1915
|
-
pageIndex
|
|
1916
|
-
}).pageIndex;
|
|
1972
|
+
const clamped = pageOf({ ...current, pageIndex }).pageIndex;
|
|
1917
1973
|
commitPagination({ ...current, pageIndex: clamped });
|
|
1918
1974
|
}
|
|
1919
1975
|
function shownPageIndex() {
|
|
1920
|
-
return
|
|
1976
|
+
return pageOf(state.pagination).pageIndex;
|
|
1921
1977
|
}
|
|
1922
1978
|
const selection = createSelectionActions({
|
|
1923
1979
|
getState: () => state,
|
|
@@ -1944,7 +2000,7 @@ function createGridController(initial) {
|
|
|
1944
2000
|
heldReports = void 0;
|
|
1945
2001
|
}
|
|
1946
2002
|
if (saved.pagination !== void 0) {
|
|
1947
|
-
pagingInputs = pagingInputsOf(resolveSlices());
|
|
2003
|
+
pagingInputs = pagingInputsOf(resolveSlices(), options);
|
|
1948
2004
|
}
|
|
1949
2005
|
refresh();
|
|
1950
2006
|
for (const report of reports) {
|
|
@@ -2106,7 +2162,7 @@ function createGridController(initial) {
|
|
|
2106
2162
|
const first = { pageIndex: 0, pageSize };
|
|
2107
2163
|
commitPagination({
|
|
2108
2164
|
...first,
|
|
2109
|
-
pageIndex:
|
|
2165
|
+
pageIndex: pageOf(first).pageIndex
|
|
2110
2166
|
});
|
|
2111
2167
|
}
|
|
2112
2168
|
};
|