@gridkitjs/core 0.19.0 → 0.20.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.
@@ -382,7 +382,7 @@ declare function formatGroupValue<Row>(value: unknown, column: ColumnDefinition<
382
382
 
383
383
  /**
384
384
  * Every string a grid shows or announces of its own — the pager, the group-by
385
- * bar, the loading row, the text of a boolean or missing value, the labels of
385
+ * bar, the loading row, an empty grid's message, the text of a boolean or missing value, the labels of
386
386
  * its built-in commands, the names of its menus, toolbar and column chooser,
387
387
  * and the live-region
388
388
  * announcements — so a grid can
@@ -416,11 +416,23 @@ interface GridMessages {
416
416
  pageButtonLabel: (page: number) => string;
417
417
  /**
418
418
  * The compact pager's status, and what a page change announces. `page`
419
- * counts from one, and is `0` while there are no pages.
419
+ * counts from one.
420
420
  */
421
421
  pageStatus: (page: number, pageCount: number) => string;
422
422
  /** The row shown while `infiniteScroll` loads more. */
423
423
  loadingMore: string;
424
+ /**
425
+ * Shown over the rows while the grid's `loading` option is on, and
426
+ * announced as it turns on.
427
+ */
428
+ loading: string;
429
+ /** Shown in place of the rows when the grid has none and no filter is active. */
430
+ noRows: string;
431
+ /**
432
+ * Shown in place of the rows when the filter, the toolbar's search
433
+ * included, hides every row.
434
+ */
435
+ noMatchingRows: string;
424
436
  /** A boolean cell's text. */
425
437
  booleanTrue: string;
426
438
  booleanFalse: string;
@@ -1612,6 +1624,35 @@ interface RowProps {
1612
1624
  */
1613
1625
  interface GridOptions<Row> {
1614
1626
  dataSource?: readonly Row[] | undefined;
1627
+ /**
1628
+ * The app is fetching rows; the grid shows it and changes nothing else. A
1629
+ * renderer draws `messages.loading` over the rows it already shows, marks
1630
+ * the grid busy and announces it once. The grid never sets it itself, and
1631
+ * never fetches.
1632
+ */
1633
+ loading?: boolean | undefined;
1634
+ /**
1635
+ * Who sorts, filters and pages the rows. `"client"` (the default): the
1636
+ * grid does, over every row in `dataSource`. `"server"`: the app's server
1637
+ * already has, and `dataSource` holds the result as it came back.
1638
+ *
1639
+ * Under `"server"` the grid shows the rows in the order given, and keeps
1640
+ * and reports sort, filter and pagination state exactly as it does under
1641
+ * `"client"`, so the callbacks say what to fetch next. With `paginated`
1642
+ * on, `dataSource` is the page `pagination` names: every row in it is
1643
+ * shown, pages are counted from `rowCount`, and `paginationUnit` is
1644
+ * ignored. Grouping, aggregates and the grand total cover only the rows
1645
+ * given, and group headers add nothing to the page count. The grid never
1646
+ * fetches.
1647
+ */
1648
+ dataMode?: DataMode | undefined;
1649
+ /**
1650
+ * The total number of rows the server has for the current filter, updated
1651
+ * with each response. Read only under `dataMode: "server"`, where it sets
1652
+ * the page count and the grid's row count; left out, both fall back to the
1653
+ * rows in `dataSource`.
1654
+ */
1655
+ rowCount?: number | undefined;
1615
1656
  /**
1616
1657
  * A row's stable identity, for state keyed by it. Defaults to the row's
1617
1658
  * position, which is enough for a static grid but ties that state to where a
@@ -1880,7 +1921,8 @@ interface GridOptions<Row> {
1880
1921
  * starts with that group's headers again, with a group's summary row on
1881
1922
  * the page holding its last row. An ungrouped grid pages by data rows
1882
1923
  * under either. Selection, export and aggregates behave the same under
1883
- * either unit.
1924
+ * either unit. Ignored under `dataMode: "server"`, where the server cuts
1925
+ * the pages.
1884
1926
  */
1885
1927
  paginationUnit?: PaginationUnit | undefined;
1886
1928
  /**
@@ -1906,7 +1948,8 @@ interface GridOptions<Row> {
1906
1948
  * Aggregates to compute — a subtotal per group (rendered in that group's
1907
1949
  * header) plus a grand total over the whole filtered/grouped dataset
1908
1950
  * (rendered in a footer). Always computed over every row, never scoped to
1909
- * the current page. A plain controlled prop, unlike `sort`/`filter`/
1951
+ * the current page — though under `dataMode: "server"` every row is the
1952
+ * rows given. A plain controlled prop, unlike `sort`/`filter`/
1910
1953
  * `groupBy`/`pagination`: there is no built-in UI for a user to add or
1911
1954
  * remove an aggregate interactively, so there is no `defaultAggregates`/
1912
1955
  * `onAggregatesChange` pair to go with it.
@@ -2387,6 +2430,14 @@ interface PaginationState {
2387
2430
  * rows under either.
2388
2431
  */
2389
2432
  type PaginationUnit = "group" | "row";
2433
+ /**
2434
+ * Who sorts, filters and pages the rows. `"client"`: the grid does, over
2435
+ * every row it holds. `"server"`: the app's server already has, so the grid
2436
+ * shows the rows it is given in the order given, and counts pages from the
2437
+ * total the app supplies. A minor release may add a mode, so a `switch` over
2438
+ * it needs a `default`.
2439
+ */
2440
+ type DataMode = "client" | "server";
2390
2441
  /** Reports a user page/page-size change whole — the one to persist from, mirroring ColumnSortEvent. */
2391
2442
  interface PaginationChangeEvent {
2392
2443
  readonly pagination: PaginationState;
@@ -3111,9 +3162,21 @@ type GridViewState<Row> = Omit<GridState<Row>, "rowSelection" | "columnSelection
3111
3162
  * the React grid's matching prop does.
3112
3163
  */
3113
3164
  interface GridViewOptions<Row> {
3165
+ /**
3166
+ * Defaults to `"client"`. Under `"server"` the rows are neither filtered
3167
+ * nor sorted, and a paginated view shows every row it is given as the
3168
+ * page `pagination.pageIndex` names, counting pages from `rowCount`.
3169
+ */
3170
+ readonly dataMode?: DataMode | undefined;
3171
+ /**
3172
+ * The total number of rows the server has for the current filter. Read
3173
+ * only under `dataMode: "server"`, which falls back to the rows given
3174
+ * when it is left out.
3175
+ */
3176
+ readonly rowCount?: number | undefined;
3114
3177
  /** Whether `pageRows` is one page of `displayRows` rather than all of it. Defaults to `false`. */
3115
3178
  readonly paginated?: boolean | undefined;
3116
- /** What a page's `pageSize` counts once grouped. Defaults to `"group"`. */
3179
+ /** What a page's `pageSize` counts once grouped. Defaults to `"group"`; ignored under `dataMode: "server"`. */
3117
3180
  readonly paginationUnit?: PaginationUnit | undefined;
3118
3181
  readonly aggregates?: AggregateState<Row> | undefined;
3119
3182
  /** Defaults to `"inline"`. */
@@ -3159,18 +3222,35 @@ interface GridView<Row, Node = string> {
3159
3222
  * pinned to the start first and those pinned to the end last.
3160
3223
  */
3161
3224
  readonly columns: readonly ResolvedColumn<Row, Node>[];
3162
- /** The rows, filtered then sorted. */
3225
+ /** The rows, filtered then sorted; under `dataMode: "server"`, as given. */
3163
3226
  readonly rows: readonly ResolvedRow<Row>[];
3164
- /** `rows` grouped, with each group's aggregates attached — every page of it. */
3227
+ /**
3228
+ * `rows` grouped, with each group's aggregates attached — every page of
3229
+ * it, or under `dataMode: "server"` the one page given.
3230
+ */
3165
3231
  readonly displayRows: readonly DisplayRow<Row>[];
3166
- /** The current page of `displayRows`; all of it when not paginated. */
3232
+ /**
3233
+ * The current page of `displayRows`; all of it when not paginated or under
3234
+ * `dataMode: "server"`. Under `"server"`, paginated, each row's
3235
+ * `datasetIndex` is offset by the pages before it.
3236
+ */
3167
3237
  readonly pageRows: readonly DisplayRow<Row>[];
3168
3238
  /** `pageRows` narrowed to its data rows, in display order — what a range selection spans. */
3169
3239
  readonly displayDataRows: readonly ResolvedRow<Row>[];
3170
- /** `1` when not paginated. */
3240
+ /** `1` when not paginated. Under `dataMode: "server"`, counted from `rowCount`. */
3171
3241
  readonly pageCount: number;
3172
3242
  /** `state.pagination.pageIndex` clamped into range; `0` when not paginated. */
3173
3243
  readonly pageIndex: number;
3244
+ /**
3245
+ * How many rows the grid has across every page: what `aria-rowcount`
3246
+ * counts besides the header and footer rows. That is every entry of
3247
+ * `displayRows` — data rows, group headers and summary rows, without the
3248
+ * rows a collapsed group hides. Under `dataMode: "server"` it is the
3249
+ * `rowCount` option (the rows given, without one), plus the group headers
3250
+ * and summary rows among the rows given, less the rows a collapsed group
3251
+ * hides there.
3252
+ */
3253
+ readonly rowCount: number;
3174
3254
  /** Every aggregate over all of `rows`, ungrouped and unpaginated. */
3175
3255
  readonly grandTotal: AggregateResults;
3176
3256
  }
@@ -3883,4 +3963,4 @@ declare function draftToFilter<Row>(draft: FilterEditorDraft<Row>, columnId: str
3883
3963
  */
3884
3964
  declare function filterDraftChanged<Row>(opened: FilterEditorDraft<Row>, draft: FilterEditorDraft<Row>): boolean;
3885
3965
 
3886
- export { type CellSelectionState as $, type AggregateState as A, type SerializedGridState as B, type ColumnType as C, type DataColumn as D, type ExportTable as E, type FilterState as F, type GridControllerOptions as G, type ExportSource as H, type ExportWriter as I, type GridExportOptions as J, type ExportFile as K, ALL_COLLAPSED as L, type MenuEntry as M, ALL_EXPANDED as N, type AggregateFn as O, type PaginationUnit as P, type AggregateSpec as Q, type ResolvedMenuEntry as R, type SortDirection as S, type ToolbarItemAttributes as T, type Borders as U, type BuiltInAggregate as V, type BuiltInCommandIcon as W, type BuiltInCommandId as X, type CellSelectEvent as Y, type CellSelectionChangeEvent as Z, type CellSelectionMode as _, type GridController as a, type GroupExpansionState as a$, type CellTemplateContext as a0, type ColumnAlignment as a1, type ColumnConstraints as a2, type ColumnFilterMenuOptions as a3, type ColumnOrderEvent as a4, type ColumnOrderState as a5, type ColumnPin as a6, type ColumnPinningEvent as a7, type ColumnPinningState as a8, type ColumnResizeEvent as a9, type FilterEntry as aA, type FilterMenuUi as aB, type FilterOperator as aC, type FilterOperatorFamily as aD, type FilterPredicate as aE, type FilterScalar as aF, type FooterTemplateContext as aG, type FormatLocale as aH, type GridCommandActions as aI, type GridCommandEvent as aJ, type GridCommandSource as aK, type GridContextMenuArea as aL, type GridContextMenuEntries as aM, type GridContextMenuOptions as aN, type GridContextMenuRequest as aO, type GridContextMenuTarget as aP, type GridFilterMenuOptions as aQ, type GridFocus as aR, type GridOptions as aS, type GridPanelKind as aT, type GridToolbarOptions as aU, type GridViewOptions as aV, type GridViewState as aW, type GroupByBarVisibility as aX, type GroupByEntry as aY, type GroupByEvent as aZ, type GroupExpansionEvent as a_, type ColumnResolveOptions as aa, type ColumnSelectEvent as ab, type ColumnSelectionChangeEvent as ac, type ColumnSizeDefaults as ad, type ColumnSizingState as ae, type ColumnSortEntry as af, type ColumnSortEvent as ag, type ColumnVisibilityEvent as ah, type ColumnWrapConfig as ai, type ColumnsSelectEvent as aj, type ContextMenuOpenChangeEvent as ak, type CopyContent as al, type CsvOptions as am, DEFAULT_COLUMN_SIZES as an, DEFAULT_FILTER_VALUE_LIMIT as ao, type ExportCell as ap, type ExportColumn as aq, type ExportDataRow as ar, type ExportGroupRow as as, type ExportGroupSummaryRow as at, type ExportOptions as au, type ExportRow as av, type ExportScalar as aw, type ExportTotalRow as ax, type ExportWriteContext as ay, type FilterChangeEvent as az, type GridCommandTarget as b, defineColumnsFromRows as b$, type GroupFilterEntry as b0, type HoverableConfig as b1, type JsonOptions as b2, type MenuItemEntry as b3, type MenuSubmenuEntry as b4, type OperatorFilterEntry as b5, type PaginationChangeEvent as b6, type PredicateFilterEntry as b7, type PrintDocument as b8, type PrintOptions as b9, type SelectionState as bA, type SerializedFilterEntry as bB, type SerializedFilterScalar as bC, type SerializedFilterState as bD, type SerializedGroupFilterEntry as bE, type SerializedOperatorFilterEntry as bF, type SerializedValueFilterEntry as bG, type TextFilterEntry as bH, type ToolbarCustomEntry as bI, type ValueFilterEntry as bJ, accessDotted as bK, alignmentForType as bL, applyColumnOrder as bM, applyColumnPinning as bN, applySelectionIntent as bO, bodyFocus as bP, buildExportTable as bQ, builtInCommands as bR, clearSelection as bS, collapseAllGroups as bT, contextMenuEntries as bU, createDefaultMessages as bV, csvWriter as bW, defaultContextMenu as bX, defaultFilterOperators as bY, defaultMessages as bZ, defaultToolbar as b_, type PrintOrientation as ba, type PrintPage as bb, type PrintSource as bc, type ResizeMode as bd, type ResolvedGroupRow as be, type ResolvedGroupSummaryRow as bf, type ResolvedMenuItem as bg, type ResolvedMenuSeparator as bh, type ResolvedMenuSubmenu as bi, type ResolvedToolbarButton as bj, type ResolvedToolbarCustom as bk, type ResolvedToolbarMenu as bl, type ResolvedToolbarSearch as bm, type ResolvedToolbarSpacer as bn, type RowGroupPosition as bo, type RowPointerEvent as bp, type RowProps as bq, type RowSelectEvent as br, type RowSelectionChangeEvent as bs, type RowsSelectEvent as bt, type SelectIntent as bu, type SelectableConfig as bv, type SelectionCallbacks as bw, type SelectionDiff as bx, type SelectionDiffEvent as by, type SelectionMode as bz, type GridMessages as c, draftToFilter as c$, expandAllGroups as c0, exportPrintDocument as c1, formatAggregateValue as c2, formatCellValue as c3, formatGroupValue as c4, getColumnId as c5, groupRowId as c6, groupRows as c7, headerFocus as c8, isColumnFiltered as c9, type ColumnValueQuery as cA, type ColumnValueOptions as cB, type ValuesDraft as cC, type ColumnResizeSession as cD, type ColumnValueOption as cE, type ConditionsDraft as cF, type CopyRequest as cG, type CopySource as cH, type DropSide as cI, type FilterEditorAction as cJ, type FilterEditorDraft as cK, type FilterEditorDraftBase as cL, KEYBOARD_STEP as cM, type KeyShortcutCapabilities as cN, type NavigationModifiers as cO, type ResolvedColumnFilterMenu as cP, type WritingDirection as cQ, applyColumnResize as cR, beginColumnResize as cS, buildKeyShortcuts as cT, buildPrintDocument as cU, clampColumnWidth as cV, clampFocus as cW, columnValueOptions as cX, copyContent as cY, describeColumnFilter as cZ, diffSelection as c_, isGroupExpanded as ca, isSameCell as cb, jsonWriter as cc, moveColumnBefore as cd, moveGroupByBefore as ce, resolveColumnHeaderText as cf, resolveColumnLabel as cg, resolveColumnPin as ch, resolveColumnWidths as ci, resolveDataColumns as cj, resolveExportWriters as ck, resolveMessages as cl, resolveRowId as cm, selectAll as cn, selectCell as co, selectOnly as cp, selectRange as cq, setColumnPin as cr, toCsv as cs, toJson as ct, toggleCellSelection as cu, toggleGroupExpansion as cv, toggleSelection as cw, toolbarEntries as cx, type SelectAllState as cy, type ColumnFilterShape as cz, type GridCommandHost as d, filterDraftChanged as d0, filterEditorReducer as d1, filterOperandArity as d2, filterOperatorFamily as d3, fitColumnsToWidth as d4, formatFilterOperand as d5, hasContextMenu as d6, initialFilterEditorDraft as d7, inlineStep as d8, intentOf as d9, moveColumnInPinGroup as da, movesColumn as db, movesGroupBy as dc, nextFocusForKey as dd, parseFilterOperand as de, pinnedWidths as df, resolveColumnConstraints as dg, resolveColumnFilterMenu as dh, resolveDropBefore as di, resolveKeyboardDropTarget as dj, revertColumnSize as dk, selectAllState as dl, sizeColumnToContent as dm, toConditionsDraft as dn, toValuesDraft as dp, totalColumnWidth as dq, visibleFilterOptions as dr, type GridCommandContext as e, type GridCommand as f, type GridToolbarTarget as g, type ToolbarEntry as h, type ResolvedToolbarItem as i, type ColumnSortState as j, type ResolvedRow as k, type FieldPath as l, type ResolvedColumn as m, type SelectedCellRef as n, type SelectedCell as o, type SelectedColumn as p, type DisplayRow as q, type PaginationState as r, type AggregateResults as s, type GroupByState as t, type GroupAggregateDisplay as u, type ColumnVisibilityState as v, type ColumnDefinition as w, type GridViewInput as x, type GridView as y, type GridState as z };
3966
+ export { type CellSelectionState as $, type AggregateState as A, type SerializedGridState as B, type ColumnType as C, type DataColumn as D, type ExportTable as E, type FilterState as F, type GridControllerOptions as G, type ExportSource as H, type ExportWriter as I, type GridExportOptions as J, type ExportFile as K, ALL_COLLAPSED as L, type MenuEntry as M, ALL_EXPANDED as N, type AggregateFn as O, type PaginationUnit as P, type AggregateSpec as Q, type ResolvedMenuEntry as R, type SortDirection as S, type ToolbarItemAttributes as T, type Borders as U, type BuiltInAggregate as V, type BuiltInCommandIcon as W, type BuiltInCommandId as X, type CellSelectEvent as Y, type CellSelectionChangeEvent as Z, type CellSelectionMode as _, type GridController as a, type GroupExpansionEvent as a$, type CellTemplateContext as a0, type ColumnAlignment as a1, type ColumnConstraints as a2, type ColumnFilterMenuOptions as a3, type ColumnOrderEvent as a4, type ColumnOrderState as a5, type ColumnPin as a6, type ColumnPinningEvent as a7, type ColumnPinningState as a8, type ColumnResizeEvent as a9, type FilterChangeEvent as aA, type FilterEntry as aB, type FilterMenuUi as aC, type FilterOperator as aD, type FilterOperatorFamily as aE, type FilterPredicate as aF, type FilterScalar as aG, type FooterTemplateContext as aH, type FormatLocale as aI, type GridCommandActions as aJ, type GridCommandEvent as aK, type GridCommandSource as aL, type GridContextMenuArea as aM, type GridContextMenuEntries as aN, type GridContextMenuOptions as aO, type GridContextMenuRequest as aP, type GridContextMenuTarget as aQ, type GridFilterMenuOptions as aR, type GridFocus as aS, type GridOptions as aT, type GridPanelKind as aU, type GridToolbarOptions as aV, type GridViewOptions as aW, type GridViewState as aX, type GroupByBarVisibility as aY, type GroupByEntry as aZ, type GroupByEvent as a_, type ColumnResolveOptions as aa, type ColumnSelectEvent as ab, type ColumnSelectionChangeEvent as ac, type ColumnSizeDefaults as ad, type ColumnSizingState as ae, type ColumnSortEntry as af, type ColumnSortEvent as ag, type ColumnVisibilityEvent as ah, type ColumnWrapConfig as ai, type ColumnsSelectEvent as aj, type ContextMenuOpenChangeEvent as ak, type CopyContent as al, type CsvOptions as am, DEFAULT_COLUMN_SIZES as an, DEFAULT_FILTER_VALUE_LIMIT as ao, type DataMode as ap, type ExportCell as aq, type ExportColumn as ar, type ExportDataRow as as, type ExportGroupRow as at, type ExportGroupSummaryRow as au, type ExportOptions as av, type ExportRow as aw, type ExportScalar as ax, type ExportTotalRow as ay, type ExportWriteContext as az, type GridCommandTarget as b, defaultToolbar as b$, type GroupExpansionState as b0, type GroupFilterEntry as b1, type HoverableConfig as b2, type JsonOptions as b3, type MenuItemEntry as b4, type MenuSubmenuEntry as b5, type OperatorFilterEntry as b6, type PaginationChangeEvent as b7, type PredicateFilterEntry as b8, type PrintDocument as b9, type SelectionMode as bA, type SelectionState as bB, type SerializedFilterEntry as bC, type SerializedFilterScalar as bD, type SerializedFilterState as bE, type SerializedGroupFilterEntry as bF, type SerializedOperatorFilterEntry as bG, type SerializedValueFilterEntry as bH, type TextFilterEntry as bI, type ToolbarCustomEntry as bJ, type ValueFilterEntry as bK, accessDotted as bL, alignmentForType as bM, applyColumnOrder as bN, applyColumnPinning as bO, applySelectionIntent as bP, bodyFocus as bQ, buildExportTable as bR, builtInCommands as bS, clearSelection as bT, collapseAllGroups as bU, contextMenuEntries as bV, createDefaultMessages as bW, csvWriter as bX, defaultContextMenu as bY, defaultFilterOperators as bZ, defaultMessages as b_, type PrintOptions as ba, type PrintOrientation as bb, type PrintPage as bc, type PrintSource as bd, type ResizeMode as be, type ResolvedGroupRow as bf, type ResolvedGroupSummaryRow as bg, type ResolvedMenuItem as bh, type ResolvedMenuSeparator as bi, type ResolvedMenuSubmenu as bj, type ResolvedToolbarButton as bk, type ResolvedToolbarCustom as bl, type ResolvedToolbarMenu as bm, type ResolvedToolbarSearch as bn, type ResolvedToolbarSpacer as bo, type RowGroupPosition as bp, type RowPointerEvent as bq, type RowProps as br, type RowSelectEvent as bs, type RowSelectionChangeEvent as bt, type RowsSelectEvent as bu, type SelectIntent as bv, type SelectableConfig as bw, type SelectionCallbacks as bx, type SelectionDiff as by, type SelectionDiffEvent as bz, type GridMessages as c, diffSelection as c$, defineColumnsFromRows as c0, expandAllGroups as c1, exportPrintDocument as c2, formatAggregateValue as c3, formatCellValue as c4, formatGroupValue as c5, getColumnId as c6, groupRowId as c7, groupRows as c8, headerFocus as c9, type ColumnFilterShape as cA, type ColumnValueQuery as cB, type ColumnValueOptions as cC, type ValuesDraft as cD, type ColumnResizeSession as cE, type ColumnValueOption as cF, type ConditionsDraft as cG, type CopyRequest as cH, type CopySource as cI, type DropSide as cJ, type FilterEditorAction as cK, type FilterEditorDraft as cL, type FilterEditorDraftBase as cM, KEYBOARD_STEP as cN, type KeyShortcutCapabilities as cO, type NavigationModifiers as cP, type ResolvedColumnFilterMenu as cQ, type WritingDirection as cR, applyColumnResize as cS, beginColumnResize as cT, buildKeyShortcuts as cU, buildPrintDocument as cV, clampColumnWidth as cW, clampFocus as cX, columnValueOptions as cY, copyContent as cZ, describeColumnFilter as c_, isColumnFiltered as ca, isGroupExpanded as cb, isSameCell as cc, jsonWriter as cd, moveColumnBefore as ce, moveGroupByBefore as cf, resolveColumnHeaderText as cg, resolveColumnLabel as ch, resolveColumnPin as ci, resolveColumnWidths as cj, resolveDataColumns as ck, resolveExportWriters as cl, resolveMessages as cm, resolveRowId as cn, selectAll as co, selectCell as cp, selectOnly as cq, selectRange as cr, setColumnPin as cs, toCsv as ct, toJson as cu, toggleCellSelection as cv, toggleGroupExpansion as cw, toggleSelection as cx, toolbarEntries as cy, type SelectAllState as cz, type GridCommandHost as d, draftToFilter as d0, filterDraftChanged as d1, filterEditorReducer as d2, filterOperandArity as d3, filterOperatorFamily as d4, fitColumnsToWidth as d5, formatFilterOperand as d6, hasContextMenu as d7, initialFilterEditorDraft as d8, inlineStep as d9, intentOf as da, moveColumnInPinGroup as db, movesColumn as dc, movesGroupBy as dd, nextFocusForKey as de, parseFilterOperand as df, pinnedWidths as dg, resolveColumnConstraints as dh, resolveColumnFilterMenu as di, resolveDropBefore as dj, resolveKeyboardDropTarget as dk, revertColumnSize as dl, selectAllState as dm, sizeColumnToContent as dn, toConditionsDraft as dp, toValuesDraft as dq, totalColumnWidth as dr, visibleFilterOptions as ds, type GridCommandContext as e, type GridCommand as f, type GridToolbarTarget as g, type ToolbarEntry as h, type ResolvedToolbarItem as i, type ColumnSortState as j, type ResolvedRow as k, type FieldPath as l, type ResolvedColumn as m, type SelectedCellRef as n, type SelectedCell as o, type SelectedColumn as p, type DisplayRow as q, type PaginationState as r, type AggregateResults as s, type GroupByState as t, type GroupAggregateDisplay as u, type ColumnVisibilityState as v, type ColumnDefinition as w, type GridViewInput as x, type GridView as y, type GridState as z };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { G as GridControllerOptions, a as GridController, b as GridCommandTarget, c as GridMessages, d as GridCommandHost, e as GridCommandContext, f as GridCommand, M as MenuEntry, R as ResolvedMenuEntry, g as GridToolbarTarget, T as ToolbarItemAttributes, h as ToolbarEntry, i as ResolvedToolbarItem, C as ColumnType, j as ColumnSortState, S as SortDirection, k as ResolvedRow, D as DataColumn, F as FilterState, l as FieldPath, m as ResolvedColumn, n as SelectedCellRef, o as SelectedCell, p as SelectedColumn, P as PaginationUnit, q as DisplayRow, r as PaginationState, A as AggregateState, s as AggregateResults, t as GroupByState, u as GroupAggregateDisplay, v as ColumnVisibilityState, w as ColumnDefinition, x as GridViewInput, y as GridView, z as GridState, B as SerializedGridState, E as ExportTable, H as ExportSource, I as ExportWriter, J as GridExportOptions, K as ExportFile } from './filterEditor-C4x0X-nh.js';
2
- export { L as ALL_COLLAPSED, N as ALL_EXPANDED, O as AggregateFn, Q as AggregateSpec, U as Borders, V as BuiltInAggregate, W as BuiltInCommandIcon, X as BuiltInCommandId, Y as CellSelectEvent, Z as CellSelectionChangeEvent, _ as CellSelectionMode, $ as CellSelectionState, a0 as CellTemplateContext, a1 as ColumnAlignment, a2 as ColumnConstraints, a3 as ColumnFilterMenuOptions, a4 as ColumnOrderEvent, a5 as ColumnOrderState, a6 as ColumnPin, a7 as ColumnPinningEvent, a8 as ColumnPinningState, a9 as ColumnResizeEvent, aa as ColumnResolveOptions, ab as ColumnSelectEvent, ac as ColumnSelectionChangeEvent, ad as ColumnSizeDefaults, ae as ColumnSizingState, af as ColumnSortEntry, ag as ColumnSortEvent, ah as ColumnVisibilityEvent, ai as ColumnWrapConfig, aj as ColumnsSelectEvent, ak as ContextMenuOpenChangeEvent, al as CopyContent, am as CsvOptions, an as DEFAULT_COLUMN_SIZES, ao as DEFAULT_FILTER_VALUE_LIMIT, ap as ExportCell, aq as ExportColumn, ar as ExportDataRow, as as ExportGroupRow, at as ExportGroupSummaryRow, au as ExportOptions, av as ExportRow, aw as ExportScalar, ax as ExportTotalRow, ay as ExportWriteContext, az as FilterChangeEvent, aA as FilterEntry, aB as FilterMenuUi, aC as FilterOperator, aD as FilterOperatorFamily, aE as FilterPredicate, aF as FilterScalar, aG as FooterTemplateContext, aH as FormatLocale, aI as GridCommandActions, aJ as GridCommandEvent, aK as GridCommandSource, aL as GridContextMenuArea, aM as GridContextMenuEntries, aN as GridContextMenuOptions, aO as GridContextMenuRequest, aP as GridContextMenuTarget, aQ as GridFilterMenuOptions, aR as GridFocus, aS as GridOptions, aT as GridPanelKind, aU as GridToolbarOptions, aV as GridViewOptions, aW as GridViewState, aX as GroupByBarVisibility, aY as GroupByEntry, aZ as GroupByEvent, a_ as GroupExpansionEvent, a$ as GroupExpansionState, b0 as GroupFilterEntry, b1 as HoverableConfig, b2 as JsonOptions, b3 as MenuItemEntry, b4 as MenuSubmenuEntry, b5 as OperatorFilterEntry, b6 as PaginationChangeEvent, b7 as PredicateFilterEntry, b8 as PrintDocument, b9 as PrintOptions, ba as PrintOrientation, bb as PrintPage, bc as PrintSource, bd as ResizeMode, be as ResolvedGroupRow, bf as ResolvedGroupSummaryRow, bg as ResolvedMenuItem, bh as ResolvedMenuSeparator, bi as ResolvedMenuSubmenu, bj as ResolvedToolbarButton, bk as ResolvedToolbarCustom, bl as ResolvedToolbarMenu, bm as ResolvedToolbarSearch, bn as ResolvedToolbarSpacer, bo as RowGroupPosition, bp as RowPointerEvent, bq as RowProps, br as RowSelectEvent, bs as RowSelectionChangeEvent, bt as RowsSelectEvent, bu as SelectIntent, bv as SelectableConfig, bw as SelectionCallbacks, bx as SelectionDiff, by as SelectionDiffEvent, bz as SelectionMode, bA as SelectionState, bB as SerializedFilterEntry, bC as SerializedFilterScalar, bD as SerializedFilterState, bE as SerializedGroupFilterEntry, bF as SerializedOperatorFilterEntry, bG as SerializedValueFilterEntry, bH as TextFilterEntry, bI as ToolbarCustomEntry, bJ as ValueFilterEntry, bK as accessDotted, bL as alignmentForType, bM as applyColumnOrder, bN as applyColumnPinning, bO as applySelectionIntent, bP as bodyFocus, bQ as buildExportTable, bR as builtInCommands, bS as clearSelection, bT as collapseAllGroups, bU as contextMenuEntries, bV as createDefaultMessages, bW as csvWriter, bX as defaultContextMenu, bY as defaultFilterOperators, bZ as defaultMessages, b_ as defaultToolbar, b$ as defineColumnsFromRows, c0 as expandAllGroups, c1 as exportPrintDocument, c2 as formatAggregateValue, c3 as formatCellValue, c4 as formatGroupValue, c5 as getColumnId, c6 as groupRowId, c7 as groupRows, c8 as headerFocus, c9 as isColumnFiltered, ca as isGroupExpanded, cb as isSameCell, cc as jsonWriter, cd as moveColumnBefore, ce as moveGroupByBefore, cf as resolveColumnHeaderText, cg as resolveColumnLabel, ch as resolveColumnPin, ci as resolveColumnWidths, cj as resolveDataColumns, ck as resolveExportWriters, cl as resolveMessages, cm as resolveRowId, cn as selectAll, co as selectCell, cp as selectOnly, cq as selectRange, cr as setColumnPin, cs as toCsv, ct as toJson, cu as toggleCellSelection, cv as toggleGroupExpansion, cw as toggleSelection, cx as toolbarEntries } from './filterEditor-C4x0X-nh.js';
1
+ import { G as GridControllerOptions, a as GridController, b as GridCommandTarget, c as GridMessages, d as GridCommandHost, e as GridCommandContext, f as GridCommand, M as MenuEntry, R as ResolvedMenuEntry, g as GridToolbarTarget, T as ToolbarItemAttributes, h as ToolbarEntry, i as ResolvedToolbarItem, C as ColumnType, j as ColumnSortState, S as SortDirection, k as ResolvedRow, D as DataColumn, F as FilterState, l as FieldPath, m as ResolvedColumn, n as SelectedCellRef, o as SelectedCell, p as SelectedColumn, P as PaginationUnit, q as DisplayRow, r as PaginationState, A as AggregateState, s as AggregateResults, t as GroupByState, u as GroupAggregateDisplay, v as ColumnVisibilityState, w as ColumnDefinition, x as GridViewInput, y as GridView, z as GridState, B as SerializedGridState, E as ExportTable, H as ExportSource, I as ExportWriter, J as GridExportOptions, K as ExportFile } from './filterEditor-D_bo2a9W.js';
2
+ export { L as ALL_COLLAPSED, N as ALL_EXPANDED, O as AggregateFn, Q as AggregateSpec, U as Borders, V as BuiltInAggregate, W as BuiltInCommandIcon, X as BuiltInCommandId, Y as CellSelectEvent, Z as CellSelectionChangeEvent, _ as CellSelectionMode, $ as CellSelectionState, a0 as CellTemplateContext, a1 as ColumnAlignment, a2 as ColumnConstraints, a3 as ColumnFilterMenuOptions, a4 as ColumnOrderEvent, a5 as ColumnOrderState, a6 as ColumnPin, a7 as ColumnPinningEvent, a8 as ColumnPinningState, a9 as ColumnResizeEvent, aa as ColumnResolveOptions, ab as ColumnSelectEvent, ac as ColumnSelectionChangeEvent, ad as ColumnSizeDefaults, ae as ColumnSizingState, af as ColumnSortEntry, ag as ColumnSortEvent, ah as ColumnVisibilityEvent, ai as ColumnWrapConfig, aj as ColumnsSelectEvent, ak as ContextMenuOpenChangeEvent, al as CopyContent, am as CsvOptions, an as DEFAULT_COLUMN_SIZES, ao as DEFAULT_FILTER_VALUE_LIMIT, ap as DataMode, aq as ExportCell, ar as ExportColumn, as as ExportDataRow, at as ExportGroupRow, au as ExportGroupSummaryRow, av as ExportOptions, aw as ExportRow, ax as ExportScalar, ay as ExportTotalRow, az as ExportWriteContext, aA as FilterChangeEvent, aB as FilterEntry, aC as FilterMenuUi, aD as FilterOperator, aE as FilterOperatorFamily, aF as FilterPredicate, aG as FilterScalar, aH as FooterTemplateContext, aI as FormatLocale, aJ as GridCommandActions, aK as GridCommandEvent, aL as GridCommandSource, aM as GridContextMenuArea, aN as GridContextMenuEntries, aO as GridContextMenuOptions, aP as GridContextMenuRequest, aQ as GridContextMenuTarget, aR as GridFilterMenuOptions, aS as GridFocus, aT as GridOptions, aU as GridPanelKind, aV as GridToolbarOptions, aW as GridViewOptions, aX as GridViewState, aY as GroupByBarVisibility, aZ as GroupByEntry, a_ as GroupByEvent, a$ as GroupExpansionEvent, b0 as GroupExpansionState, b1 as GroupFilterEntry, b2 as HoverableConfig, b3 as JsonOptions, b4 as MenuItemEntry, b5 as MenuSubmenuEntry, b6 as OperatorFilterEntry, b7 as PaginationChangeEvent, b8 as PredicateFilterEntry, b9 as PrintDocument, ba as PrintOptions, bb as PrintOrientation, bc as PrintPage, bd as PrintSource, be as ResizeMode, bf as ResolvedGroupRow, bg as ResolvedGroupSummaryRow, bh as ResolvedMenuItem, bi as ResolvedMenuSeparator, bj as ResolvedMenuSubmenu, bk as ResolvedToolbarButton, bl as ResolvedToolbarCustom, bm as ResolvedToolbarMenu, bn as ResolvedToolbarSearch, bo as ResolvedToolbarSpacer, bp as RowGroupPosition, bq as RowPointerEvent, br as RowProps, bs as RowSelectEvent, bt as RowSelectionChangeEvent, bu as RowsSelectEvent, bv as SelectIntent, bw as SelectableConfig, bx as SelectionCallbacks, by as SelectionDiff, bz as SelectionDiffEvent, bA as SelectionMode, bB as SelectionState, bC as SerializedFilterEntry, bD as SerializedFilterScalar, bE as SerializedFilterState, bF as SerializedGroupFilterEntry, bG as SerializedOperatorFilterEntry, bH as SerializedValueFilterEntry, bI as TextFilterEntry, bJ as ToolbarCustomEntry, bK as ValueFilterEntry, bL as accessDotted, bM as alignmentForType, bN as applyColumnOrder, bO as applyColumnPinning, bP as applySelectionIntent, bQ as bodyFocus, bR as buildExportTable, bS as builtInCommands, bT as clearSelection, bU as collapseAllGroups, bV as contextMenuEntries, bW as createDefaultMessages, bX as csvWriter, bY as defaultContextMenu, bZ as defaultFilterOperators, b_ as defaultMessages, b$ as defaultToolbar, c0 as defineColumnsFromRows, c1 as expandAllGroups, c2 as exportPrintDocument, c3 as formatAggregateValue, c4 as formatCellValue, c5 as formatGroupValue, c6 as getColumnId, c7 as groupRowId, c8 as groupRows, c9 as headerFocus, ca as isColumnFiltered, cb as isGroupExpanded, cc as isSameCell, cd as jsonWriter, ce as moveColumnBefore, cf as moveGroupByBefore, cg as resolveColumnHeaderText, ch as resolveColumnLabel, ci as resolveColumnPin, cj as resolveColumnWidths, ck as resolveDataColumns, cl as resolveExportWriters, cm as resolveMessages, cn as resolveRowId, co as selectAll, cp as selectCell, cq as selectOnly, cr as selectRange, cs as setColumnPin, ct as toCsv, cu as toJson, cv as toggleCellSelection, cw as toggleGroupExpansion, cx as toggleSelection, cy as toolbarEntries } from './filterEditor-D_bo2a9W.js';
3
3
 
4
4
  /**
5
5
  * Creates the state container for one grid — see `GridController`. Hold one
@@ -273,6 +273,13 @@ interface PaginateRowsOptions {
273
273
  * whichever page is showing.
274
274
  */
275
275
  declare function paginateRows<Row>(rows: readonly DisplayRow<Row>[], pagination: PaginationState, options?: PaginateRowsOptions): PaginatedRows<Row>;
276
+ /**
277
+ * How many pages `count` rows or units fill at `pageSize` a page — the one
278
+ * rule every page count in the grid follows, for a pager of the app's own
279
+ * to follow too. `pageSize` below `1` reads as `1`, and `count` below `0`
280
+ * as none.
281
+ */
282
+ declare function countPages(count: number, pageSize: number): number;
276
283
 
277
284
  /**
278
285
  * `rows` reduced through every spec in `specs`, keyed by `spec.id ??
@@ -332,9 +339,10 @@ declare function createGridViewResolver<Row, Node = string>(): (input: GridViewI
332
339
  * What the user is looking at, derived from the rows, the columns, the
333
340
  * grid's state and its options in one call: rows filtered → sorted →
334
341
  * grouped → aggregated → paginated, and columns ordered → hidden → pinned →
335
- * sized. The one function a renderer, an export or a toolbar calls instead of
336
- * composing the stages itself, so none of them can disagree about what is
337
- * shown.
342
+ * sized. Under `dataMode: "server"` the rows skip the filter and the sort,
343
+ * and the page is the rows given. The one function a renderer, an export or
344
+ * a toolbar calls instead of composing the stages itself, so none of them
345
+ * can disagree about what is shown.
338
346
  *
339
347
  * Unmemoised — a one-off resolver. A renderer that derives the view on every
340
348
  * change holds a `createGridViewResolver()` instead.
@@ -425,4 +433,4 @@ declare const excelFilter: {
425
433
  };
426
434
  };
427
435
 
428
- export { AggregateResults, AggregateState, ColumnDefinition, ColumnSortState, ColumnType, ColumnVisibilityState, DataColumn, DisplayRow, ExportFile, type ExportFileSource, ExportSource, ExportTable, ExportWriter, FieldPath, FilterState, GridCommand, GridCommandContext, type GridCommandContextInput, GridCommandHost, GridCommandTarget, GridController, GridControllerOptions, GridExportOptions, GridMessages, GridState, GridToolbarTarget, GridView, GridViewInput, GroupAggregateDisplay, GroupByState, type HtmlTableOptions, MenuEntry, type MenuResolveOptions, type PaginateRowsOptions, type PaginatedRows, PaginationState, PaginationUnit, ResolvedColumn, ResolvedMenuEntry, ResolvedRow, ResolvedToolbarItem, SelectedCell, SelectedCellRef, SelectedColumn, SerializedGridState, SortDirection, ToolbarEntry, ToolbarItemAttributes, type ToolbarResolveOptions, type TsvOptions, applyColumnVisibility, clearAllFilters, compareValues, computeAggregates, createCommandContext, createGridController, createGridViewResolver, excelFilter, exportFile, filterQueryFor, filterRows, isColumnVisible, matchesQuery, paginateRows, resolveCell, resolveColumns, resolveCommands, resolveGridView, resolveMenu, resolveRows, resolveShownRows, resolveToolbar, runCommand, serializeGridState, setColumnFilter, setColumnVisibility, sortDirectionFor, sortPriorityFor, sortRows, toHtmlTable, toTsv, toggleColumnSort, withGroupAggregates };
436
+ export { AggregateResults, AggregateState, ColumnDefinition, ColumnSortState, ColumnType, ColumnVisibilityState, DataColumn, DisplayRow, ExportFile, type ExportFileSource, ExportSource, ExportTable, ExportWriter, FieldPath, FilterState, GridCommand, GridCommandContext, type GridCommandContextInput, GridCommandHost, GridCommandTarget, GridController, GridControllerOptions, GridExportOptions, GridMessages, GridState, GridToolbarTarget, GridView, GridViewInput, GroupAggregateDisplay, GroupByState, type HtmlTableOptions, MenuEntry, type MenuResolveOptions, type PaginateRowsOptions, type PaginatedRows, PaginationState, PaginationUnit, ResolvedColumn, ResolvedMenuEntry, ResolvedRow, ResolvedToolbarItem, SelectedCell, SelectedCellRef, SelectedColumn, SerializedGridState, SortDirection, ToolbarEntry, ToolbarItemAttributes, type ToolbarResolveOptions, type TsvOptions, applyColumnVisibility, clearAllFilters, compareValues, computeAggregates, countPages, createCommandContext, createGridController, createGridViewResolver, excelFilter, exportFile, filterQueryFor, filterRows, isColumnVisible, matchesQuery, paginateRows, resolveCell, resolveColumns, resolveCommands, resolveGridView, resolveMenu, resolveRows, resolveShownRows, resolveToolbar, runCommand, serializeGridState, setColumnFilter, setColumnVisibility, sortDirectionFor, sortPriorityFor, sortRows, toHtmlTable, toTsv, toggleColumnSort, withGroupAggregates };
package/dist/index.js CHANGED
@@ -92,7 +92,7 @@ import {
92
92
  unknownDisplayRow,
93
93
  unknownFilterEntry,
94
94
  withGroupAggregates
95
- } from "./chunk-WLM4AZXN.js";
95
+ } from "./chunk-RYMILPCT.js";
96
96
 
97
97
  // src/util/memoize.ts
98
98
  function memoizeLast(compute) {
@@ -108,88 +108,6 @@ function memoizeLast(compute) {
108
108
  };
109
109
  }
110
110
 
111
- // src/util/paging.ts
112
- var NO_HEADERS = [];
113
- function groupUnitsOf(rows) {
114
- const units = [];
115
- let start = 0;
116
- let openedByGroup = false;
117
- for (let index = 0; index < rows.length; index++) {
118
- const entry = rows[index];
119
- if (entry === void 0) {
120
- continue;
121
- }
122
- const isTopLevelHeader = entry.kind === "group" && entry.level === 0;
123
- const isBoundary = index !== start && (isTopLevelHeader || !openedByGroup);
124
- if (isBoundary) {
125
- units.push({ start, end: index, headers: NO_HEADERS });
126
- start = index;
127
- openedByGroup = isTopLevelHeader;
128
- } else if (index === start) {
129
- openedByGroup = isTopLevelHeader;
130
- }
131
- }
132
- if (start < rows.length) {
133
- units.push({ start, end: rows.length, headers: NO_HEADERS });
134
- }
135
- return units;
136
- }
137
- function rowUnitsOf(rows) {
138
- const units = [];
139
- let open = NO_HEADERS;
140
- for (let index = 0; index < rows.length; index++) {
141
- const entry = rows[index];
142
- if (entry === void 0) {
143
- continue;
144
- }
145
- switch (entry.kind) {
146
- case "data":
147
- units.push({ start: index, end: index + 1, headers: open });
148
- break;
149
- case "group": {
150
- const ancestors = open.slice(0, entry.level);
151
- open = entry.expanded ? [...ancestors, entry] : ancestors;
152
- if (!entry.expanded) {
153
- units.push({ start: index, end: index + 1, headers: ancestors });
154
- }
155
- break;
156
- }
157
- case "group-summary": {
158
- const last = units.at(-1);
159
- if (last !== void 0) {
160
- units[units.length - 1] = { ...last, end: index + 1 };
161
- }
162
- break;
163
- }
164
- default:
165
- unknownDisplayRow(entry);
166
- }
167
- }
168
- return units;
169
- }
170
- function paginateRows(rows, pagination, options = {}) {
171
- const pageSize = Math.max(1, pagination.pageSize);
172
- const units = options.unit === "row" ? rowUnitsOf(rows) : groupUnitsOf(rows);
173
- const pageCount = Math.ceil(units.length / pageSize);
174
- if (pageCount === 0) {
175
- return { rows: [], pageCount: 0, pageIndex: 0 };
176
- }
177
- const pageIndex = Math.min(Math.max(pagination.pageIndex, 0), pageCount - 1);
178
- const firstUnit = units[pageIndex * pageSize];
179
- const lastUnit = units[Math.min(pageIndex * pageSize + pageSize, units.length) - 1];
180
- if (firstUnit === void 0 || lastUnit === void 0) {
181
- return { rows: [], pageCount, pageIndex };
182
- }
183
- const page = [
184
- ...firstUnit.headers,
185
- ...rows.slice(firstUnit.start, lastUnit.end)
186
- ];
187
- const renumbered = page.map(
188
- (entry, index) => entry.rowIndex === index ? entry : { ...entry, rowIndex: index }
189
- );
190
- return { rows: renumbered, pageCount, pageIndex };
191
- }
192
-
193
111
  // src/util/serialize.ts
194
112
  function serializeScalar(scalar) {
195
113
  return scalar instanceof Date ? scalar.toISOString() : scalar;
@@ -349,6 +267,105 @@ function reviveGroupExpansion(saved) {
349
267
  );
350
268
  }
351
269
 
270
+ // src/util/paging.ts
271
+ var NO_HEADERS = [];
272
+ function groupUnitsOf(rows) {
273
+ const units = [];
274
+ let start = 0;
275
+ let openedByGroup = false;
276
+ for (let index = 0; index < rows.length; index++) {
277
+ const entry = rows[index];
278
+ if (entry === void 0) {
279
+ continue;
280
+ }
281
+ const isTopLevelHeader = entry.kind === "group" && entry.level === 0;
282
+ const isBoundary = index !== start && (isTopLevelHeader || !openedByGroup);
283
+ if (isBoundary) {
284
+ units.push({ start, end: index, headers: NO_HEADERS });
285
+ start = index;
286
+ openedByGroup = isTopLevelHeader;
287
+ } else if (index === start) {
288
+ openedByGroup = isTopLevelHeader;
289
+ }
290
+ }
291
+ if (start < rows.length) {
292
+ units.push({ start, end: rows.length, headers: NO_HEADERS });
293
+ }
294
+ return units;
295
+ }
296
+ function rowUnitsOf(rows) {
297
+ const units = [];
298
+ let open = NO_HEADERS;
299
+ for (let index = 0; index < rows.length; index++) {
300
+ const entry = rows[index];
301
+ if (entry === void 0) {
302
+ continue;
303
+ }
304
+ switch (entry.kind) {
305
+ case "data":
306
+ units.push({ start: index, end: index + 1, headers: open });
307
+ break;
308
+ case "group": {
309
+ const ancestors = open.slice(0, entry.level);
310
+ open = entry.expanded ? [...ancestors, entry] : ancestors;
311
+ if (!entry.expanded) {
312
+ units.push({ start: index, end: index + 1, headers: ancestors });
313
+ }
314
+ break;
315
+ }
316
+ case "group-summary": {
317
+ const last = units.at(-1);
318
+ if (last !== void 0) {
319
+ units[units.length - 1] = { ...last, end: index + 1 };
320
+ }
321
+ break;
322
+ }
323
+ default:
324
+ unknownDisplayRow(entry);
325
+ }
326
+ }
327
+ return units;
328
+ }
329
+ function paginateRows(rows, pagination, options = {}) {
330
+ const pageSize = Math.max(1, pagination.pageSize);
331
+ const units = options.unit === "row" ? rowUnitsOf(rows) : groupUnitsOf(rows);
332
+ const pageCount = countPages(units.length, pageSize);
333
+ if (pageCount === 0) {
334
+ return { rows: [], pageCount: 0, pageIndex: 0 };
335
+ }
336
+ const pageIndex = clampPageIndex(pagination.pageIndex, pageCount);
337
+ const firstUnit = units[pageIndex * pageSize];
338
+ const lastUnit = units[Math.min(pageIndex * pageSize + pageSize, units.length) - 1];
339
+ if (firstUnit === void 0 || lastUnit === void 0) {
340
+ return { rows: [], pageCount, pageIndex };
341
+ }
342
+ const page = [
343
+ ...firstUnit.headers,
344
+ ...rows.slice(firstUnit.start, lastUnit.end)
345
+ ];
346
+ const renumbered = page.map(
347
+ (entry, index) => entry.rowIndex === index ? entry : { ...entry, rowIndex: index }
348
+ );
349
+ return { rows: renumbered, pageCount, pageIndex };
350
+ }
351
+ function paginateServerRows(rows, pagination, rowCount) {
352
+ const pageSize = Math.max(1, pagination.pageSize);
353
+ const pageCount = countPages(rowCount, pageSize);
354
+ const pageIndex = clampPageIndex(pagination.pageIndex, pageCount);
355
+ const offset = pageIndex * pageSize;
356
+ const offsetRows = offset === 0 ? rows : rows.map((entry) => ({
357
+ ...entry,
358
+ datasetIndex: entry.datasetIndex + offset
359
+ }));
360
+ return { rows: offsetRows, pageCount, pageIndex };
361
+ }
362
+ function countPages(count, pageSize) {
363
+ return Math.ceil(Math.max(0, count) / Math.max(1, pageSize));
364
+ }
365
+ function clampPageIndex(pageIndex, pageCount) {
366
+ return pageCount === 0 ? 0 : Math.min(Math.max(pageIndex, 0), pageCount - 1);
367
+ }
368
+
352
369
  // src/util/view.ts
353
370
  var NO_AGGREGATES = [];
354
371
  var DEFAULT_PAGE_SIZE = 25;
@@ -400,8 +417,25 @@ function totalAggregates(rows, aggregates, dataColumns) {
400
417
  dataColumns
401
418
  );
402
419
  }
403
- function paginate(displayRows, paginated, pagination, unit) {
404
- return paginated ? paginateRows(displayRows, pagination, { unit }) : { rows: displayRows, pageCount: 1, pageIndex: 0 };
420
+ function serverRowCount(rowCount, rows) {
421
+ return rowCount ?? rows.length;
422
+ }
423
+ function resolvePage(displayRows, rows, pagination, options) {
424
+ return options.dataMode === "server" ? paginateServerRows(
425
+ displayRows,
426
+ pagination,
427
+ serverRowCount(options.rowCount, rows)
428
+ ) : paginateRows(displayRows, pagination, { unit: options.paginationUnit });
429
+ }
430
+ function paginate(displayRows, rows, paginated, pagination, dataMode, paginationUnit, rowCount) {
431
+ return paginated ? resolvePage(displayRows, rows, pagination, {
432
+ dataMode,
433
+ paginationUnit,
434
+ rowCount
435
+ }) : { rows: displayRows, pageCount: 1, pageIndex: 0 };
436
+ }
437
+ function countRows(displayRows, rows, dataMode, rowCount) {
438
+ return dataMode === "server" ? serverRowCount(rowCount, rows) - rows.length + displayRows.length : displayRows.length;
405
439
  }
406
440
  function narrowToDataRows(pageRows, rows, reshaped) {
407
441
  return reshaped ? pageRows.filter(
@@ -421,7 +455,7 @@ function createGridViewResolver() {
421
455
  const page = memoizeLast(paginate);
422
456
  const narrow = memoizeLast(narrowToDataRows);
423
457
  const assemble = memoizeLast(
424
- (dataColumns, columns, rows, displayRows, pageRows, displayDataRows, pageCount, pageIndex, grandTotal) => ({
458
+ (dataColumns, columns, rows, displayRows, pageRows, displayDataRows, pageCount, pageIndex, rowCount, grandTotal) => ({
425
459
  dataColumns,
426
460
  columns,
427
461
  rows,
@@ -430,6 +464,7 @@ function createGridViewResolver() {
430
464
  displayDataRows,
431
465
  pageCount,
432
466
  pageIndex,
467
+ rowCount,
433
468
  grandTotal
434
469
  })
435
470
  );
@@ -442,6 +477,7 @@ function createGridViewResolver() {
442
477
  }) => {
443
478
  const state = fillViewState(given);
444
479
  const paginated = options.paginated ?? false;
480
+ const dataMode = options.dataMode ?? "client";
445
481
  const aggregates = options.aggregates ?? NO_AGGREGATES;
446
482
  const dataColumns = orderColumns(definitions, state.columnOrder);
447
483
  const columns = size(
@@ -458,8 +494,9 @@ function createGridViewResolver() {
458
494
  options.resizeMode ?? "fit",
459
495
  options.viewportWidth ?? null
460
496
  );
461
- const rows = filterAndSort(
462
- identify(data, getRowId),
497
+ const identified = identify(data, getRowId);
498
+ const rows = dataMode === "server" ? identified : filterAndSort(
499
+ identified,
463
500
  state.filter,
464
501
  state.columnSort,
465
502
  dataColumns
@@ -478,9 +515,12 @@ function createGridViewResolver() {
478
515
  pageIndex
479
516
  } = page(
480
517
  displayRows,
518
+ rows,
481
519
  paginated,
482
520
  state.pagination,
483
- options.paginationUnit ?? "group"
521
+ dataMode,
522
+ options.paginationUnit,
523
+ options.rowCount
484
524
  );
485
525
  return assemble(
486
526
  dataColumns,
@@ -491,6 +531,7 @@ function createGridViewResolver() {
491
531
  narrow(pageRows, rows, state.groupBy.length > 0 || paginated),
492
532
  pageCount,
493
533
  pageIndex,
534
+ countRows(displayRows, rows, dataMode, options.rowCount),
494
535
  total(rows, aggregates, dataColumns)
495
536
  );
496
537
  };
@@ -1001,6 +1042,8 @@ function createGridController(initial) {
1001
1042
  columns: resolveColumns2(options.columns, options.dataSource),
1002
1043
  state,
1003
1044
  options: {
1045
+ dataMode: options.dataMode,
1046
+ rowCount: options.rowCount,
1004
1047
  paginated: options.paginated,
1005
1048
  paginationUnit: options.paginationUnit,
1006
1049
  aggregates: options.aggregates,
@@ -1094,9 +1137,8 @@ function createGridController(initial) {
1094
1137
  });
1095
1138
  }
1096
1139
  function pageOf(pagination) {
1097
- return paginateRows(getView().displayRows, pagination, {
1098
- unit: options.paginationUnit
1099
- });
1140
+ const { displayRows, rows } = getView();
1141
+ return resolvePage(displayRows, rows, pagination, options);
1100
1142
  }
1101
1143
  function goToPage(pageIndex) {
1102
1144
  const current = state.pagination;
@@ -1479,6 +1521,7 @@ export {
1479
1521
  compareValues,
1480
1522
  computeAggregates,
1481
1523
  contextMenuEntries,
1524
+ countPages,
1482
1525
  createCommandContext,
1483
1526
  createDefaultMessages,
1484
1527
  createGridController,