@gridkitjs/core 0.0.0-dev-20261107195236 → 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 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. A page's unit is a
1736
- * top-level group or a bare data row, never a leaf row — a group is never
1737
- * split across a page boundary. Off by default, matching `sortableColumns`.
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 grouping changes; a controlled one is the parent's
1753
- * to reset alongside that change. Until it does, the grid shows the last
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. */
@@ -2219,6 +2231,15 @@ interface PaginationState {
2219
2231
  readonly pageIndex: number;
2220
2232
  readonly pageSize: number;
2221
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";
2222
2243
  /** Reports a user page/page-size change whole — the one to persist from, mirroring ColumnSortEvent. */
2223
2244
  interface PaginationChangeEvent {
2224
2245
  readonly pagination: PaginationState;
@@ -2857,6 +2878,8 @@ type GridViewState<Row> = Omit<GridState<Row>, "rowSelection" | "columnSelection
2857
2878
  interface GridViewOptions<Row> {
2858
2879
  /** Whether `pageRows` is one page of `displayRows` rather than all of it. Defaults to `false`. */
2859
2880
  readonly paginated?: boolean | undefined;
2881
+ /** What a page's `pageSize` counts once grouped. Defaults to `"group"`. */
2882
+ readonly paginationUnit?: PaginationUnit | undefined;
2860
2883
  readonly aggregates?: AggregateState<Row> | undefined;
2861
2884
  /** Defaults to `"inline"`. */
2862
2885
  readonly groupAggregateDisplay?: GroupAggregateDisplay | undefined;
@@ -3636,18 +3659,27 @@ interface PaginatedRows<Row> {
3636
3659
  */
3637
3660
  readonly pageIndex: number;
3638
3661
  }
3662
+ interface PaginateRowsOptions {
3663
+ /** What `pageSize` counts — see `PaginationUnit`. Defaults to `"group"`. */
3664
+ readonly unit?: PaginationUnit | undefined;
3665
+ }
3639
3666
  /**
3640
- * `rows` sliced into pages of `pagination.pageSize` units — see `unitsOf`
3641
- * for what a unit is. `pageIndex` is clamped into range, `pageSize <= 0` is
3642
- * clamped to `1` (this codebase's general tolerance for stale/odd stored
3643
- * state, matching `sortRows`/`filterRows`), and the returned page's
3644
- * `rowIndex` is renumbered to be page-relative — 0-based from the top of the
3645
- * page, header rows included, mirroring `groupRows`'s own renumbering
3646
- * invariant. `datasetIndex` is left untouched: the stages ahead of this one
3647
- * set it to each row's position in the whole displayed result, which stays
3648
- * the same whichever page is showing.
3649
- */
3650
- declare function paginateRows<Row>(rows: readonly DisplayRow<Row>[], pagination: PaginationState): PaginatedRows<Row>;
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>;
3651
3683
 
3652
3684
  type PaginationWindowEntry = number | "ellipsis";
3653
3685
  /**
@@ -4227,4 +4259,4 @@ declare const excelFilter: {
4227
4259
  };
4228
4260
  };
4229
4261
 
4230
- 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
@@ -411,7 +411,8 @@ function resolveKeyboardDropTarget(orderedIds, columnId, direction) {
411
411
  }
412
412
 
413
413
  // src/util/paging.ts
414
- function unitsOf(rows) {
414
+ var NO_HEADERS = [];
415
+ function groupUnitsOf(rows) {
415
416
  const units = [];
416
417
  let start = 0;
417
418
  let openedByGroup = false;
@@ -423,7 +424,7 @@ function unitsOf(rows) {
423
424
  const isTopLevelHeader = "kind" in entry && entry.kind === "group" && entry.level === 0;
424
425
  const isBoundary = index !== start && (isTopLevelHeader || !openedByGroup);
425
426
  if (isBoundary) {
426
- units.push({ start, end: index });
427
+ units.push({ start, end: index, headers: NO_HEADERS });
427
428
  start = index;
428
429
  openedByGroup = isTopLevelHeader;
429
430
  } else if (index === start) {
@@ -431,13 +432,38 @@ function unitsOf(rows) {
431
432
  }
432
433
  }
433
434
  if (start < rows.length) {
434
- units.push({ start, end: rows.length });
435
+ units.push({ start, end: rows.length, headers: NO_HEADERS });
435
436
  }
436
437
  return units;
437
438
  }
438
- function paginateRows(rows, pagination) {
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 = {}) {
439
465
  const pageSize = Math.max(1, pagination.pageSize);
440
- const units = unitsOf(rows);
466
+ const units = options.unit === "row" ? rowUnitsOf(rows) : groupUnitsOf(rows);
441
467
  const pageCount = Math.ceil(units.length / pageSize);
442
468
  if (pageCount === 0) {
443
469
  return { rows: [], pageCount: 0, pageIndex: 0 };
@@ -448,7 +474,10 @@ function paginateRows(rows, pagination) {
448
474
  if (firstUnit === void 0 || lastUnit === void 0) {
449
475
  return { rows: [], pageCount, pageIndex };
450
476
  }
451
- const page = rows.slice(firstUnit.start, lastUnit.end);
477
+ const page = [
478
+ ...firstUnit.headers,
479
+ ...rows.slice(firstUnit.start, lastUnit.end)
480
+ ];
452
481
  const renumbered = page.map(
453
482
  (entry, index) => entry.rowIndex === index ? entry : { ...entry, rowIndex: index }
454
483
  );
@@ -1250,8 +1279,8 @@ function totalAggregates(rows, aggregates, dataColumns) {
1250
1279
  dataColumns
1251
1280
  );
1252
1281
  }
1253
- function paginate(displayRows, paginated, pagination) {
1254
- 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 };
1255
1284
  }
1256
1285
  function narrowToDataRows(pageRows, rows, reshaped) {
1257
1286
  return reshaped ? pageRows.filter((entry) => !("kind" in entry)) : rows;
@@ -1312,7 +1341,12 @@ function createGridViewResolver() {
1312
1341
  rows: pageRows,
1313
1342
  pageCount,
1314
1343
  pageIndex
1315
- } = page(displayRows, paginated, state.pagination);
1344
+ } = page(
1345
+ displayRows,
1346
+ paginated,
1347
+ state.pagination,
1348
+ options.paginationUnit ?? "group"
1349
+ );
1316
1350
  return assemble(
1317
1351
  dataColumns,
1318
1352
  columns,
@@ -1759,11 +1793,12 @@ function definedColumns(columns, rows) {
1759
1793
  }
1760
1794
  return NO_COLUMNS;
1761
1795
  }
1762
- function pagingInputsOf(state) {
1796
+ function pagingInputsOf(state, options) {
1763
1797
  return {
1764
1798
  filter: state.filter,
1765
1799
  columnSort: state.columnSort,
1766
- groupBy: state.groupBy
1800
+ groupBy: state.groupBy,
1801
+ paginationUnit: options.paginationUnit ?? "group"
1767
1802
  };
1768
1803
  }
1769
1804
  function createGridController(initial) {
@@ -1775,7 +1810,7 @@ function createGridController(initial) {
1775
1810
  const reportedConflicts = /* @__PURE__ */ new Set();
1776
1811
  let heldReports;
1777
1812
  let state = resolveSlices();
1778
- let pagingInputs = pagingInputsOf(state);
1813
+ let pagingInputs = pagingInputsOf(state, options);
1779
1814
  reportConflicts();
1780
1815
  function controlledValue(key) {
1781
1816
  const controlled = options;
@@ -1817,8 +1852,9 @@ function createGridController(initial) {
1817
1852
  }
1818
1853
  function refresh() {
1819
1854
  let next = resolveSlices();
1820
- if (next.filter !== pagingInputs.filter || next.columnSort !== pagingInputs.columnSort || next.groupBy !== pagingInputs.groupBy) {
1821
- pagingInputs = pagingInputsOf(next);
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;
1822
1858
  if (!isControlled("pagination") && own.pagination.pageIndex !== 0) {
1823
1859
  own.pagination = { ...own.pagination, pageIndex: 0 };
1824
1860
  next = { ...next, pagination: own.pagination };
@@ -1854,6 +1890,7 @@ function createGridController(initial) {
1854
1890
  state,
1855
1891
  options: {
1856
1892
  paginated: options.paginated,
1893
+ paginationUnit: options.paginationUnit,
1857
1894
  aggregates: options.aggregates,
1858
1895
  groupAggregateDisplay: options.groupAggregateDisplay,
1859
1896
  columnSizeDefaults: options.columnSizeDefaults,
@@ -1921,20 +1958,22 @@ function createGridController(initial) {
1921
1958
  commit("pagination", next, () => {
1922
1959
  options.onPaginationChange?.({
1923
1960
  pagination: next,
1924
- pageCount: paginateRows(getView().displayRows, next).pageCount
1961
+ pageCount: pageOf(next).pageCount
1925
1962
  });
1926
1963
  });
1927
1964
  }
1965
+ function pageOf(pagination) {
1966
+ return paginateRows(getView().displayRows, pagination, {
1967
+ unit: options.paginationUnit
1968
+ });
1969
+ }
1928
1970
  function goToPage(pageIndex) {
1929
1971
  const current = state.pagination;
1930
- const clamped = paginateRows(getView().displayRows, {
1931
- ...current,
1932
- pageIndex
1933
- }).pageIndex;
1972
+ const clamped = pageOf({ ...current, pageIndex }).pageIndex;
1934
1973
  commitPagination({ ...current, pageIndex: clamped });
1935
1974
  }
1936
1975
  function shownPageIndex() {
1937
- return paginateRows(getView().displayRows, state.pagination).pageIndex;
1976
+ return pageOf(state.pagination).pageIndex;
1938
1977
  }
1939
1978
  const selection = createSelectionActions({
1940
1979
  getState: () => state,
@@ -1961,7 +2000,7 @@ function createGridController(initial) {
1961
2000
  heldReports = void 0;
1962
2001
  }
1963
2002
  if (saved.pagination !== void 0) {
1964
- pagingInputs = pagingInputsOf(resolveSlices());
2003
+ pagingInputs = pagingInputsOf(resolveSlices(), options);
1965
2004
  }
1966
2005
  refresh();
1967
2006
  for (const report of reports) {
@@ -2123,7 +2162,7 @@ function createGridController(initial) {
2123
2162
  const first = { pageIndex: 0, pageSize };
2124
2163
  commitPagination({
2125
2164
  ...first,
2126
- pageIndex: paginateRows(getView().displayRows, first).pageIndex
2165
+ pageIndex: pageOf(first).pageIndex
2127
2166
  });
2128
2167
  }
2129
2168
  };