@gridkitjs/core 0.0.0-dev-20261112200523 → 0.0.0-dev-20261112201151
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/{chunk-AHDALZCY.js → chunk-QGKPKQIO.js} +118 -109
- package/dist/chunk-QGKPKQIO.js.map +1 -0
- package/dist/{filterEditor-9hncygVf.d.ts → filterEditor-B7C_n89V.d.ts} +40 -14
- package/dist/index.d.ts +2 -2
- package/dist/index.js +73 -22
- package/dist/index.js.map +1 -1
- package/dist/renderer.d.ts +2 -2
- package/dist/renderer.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-AHDALZCY.js.map +0 -1
|
@@ -184,7 +184,7 @@ interface GridController<Row, Node = string> {
|
|
|
184
184
|
readonly setColumnSelection: (selection: SelectionState) => void;
|
|
185
185
|
/** `selectRow`, for a column among the columns as rendered. */
|
|
186
186
|
readonly selectColumn: (columnId: string, intent: SelectIntent) => void;
|
|
187
|
-
/** Replaces the
|
|
187
|
+
/** Replaces the cell selection as given, `{ kind: "none" }` for none. */
|
|
188
188
|
readonly setCellSelection: (selection: CellSelectionState) => void;
|
|
189
189
|
/**
|
|
190
190
|
* Applies one click or key press to a cell: `"toggle"` lets go of it when
|
|
@@ -702,7 +702,8 @@ interface ExportGroupSummaryRow {
|
|
|
702
702
|
}
|
|
703
703
|
/**
|
|
704
704
|
* A body row of an export, in the order the grid shows them. Discriminate on
|
|
705
|
-
* `kind
|
|
705
|
+
* `kind`; a minor release may add a kind, so a writer's `switch` over it
|
|
706
|
+
* needs a `default`.
|
|
706
707
|
*/
|
|
707
708
|
type ExportRow = ExportDataRow | ExportGroupRow | ExportGroupSummaryRow;
|
|
708
709
|
/**
|
|
@@ -1243,11 +1244,15 @@ interface GridCommand<Row> {
|
|
|
1243
1244
|
readonly execute: ((context: GridCommandContext<Row>) => void) | ((context: GridCommandContext<Row>) => boolean);
|
|
1244
1245
|
}
|
|
1245
1246
|
|
|
1246
|
-
/**
|
|
1247
|
+
/**
|
|
1248
|
+
* The id of every command `builtInCommands` returns. A minor release may
|
|
1249
|
+
* add a command, so a `switch` over it needs a `default`.
|
|
1250
|
+
*/
|
|
1247
1251
|
type BuiltInCommandId = "sort.ascending" | "sort.descending" | "sort.clear" | "sort.clearAll" | "group.add" | "group.remove" | "group.clearAll" | "group.expandAll" | "group.collapseAll" | "column.hide" | "column.autoFit" | "column.autoFitAll" | "column.choose" | "filter.open" | "filter.clear" | "selection.selectAllRows" | "selection.clear" | "filter.clearAll" | "export.csv" | "export.json" | "export.xlsx" | "export.pdf" | "exportSelection.csv" | "exportSelection.json" | "exportSelection.xlsx" | "copy.cell" | "copy.row" | "copy.selection" | "print";
|
|
1248
1252
|
/**
|
|
1249
1253
|
* The icon keys the built-ins carry, which a renderer draws as icons of its
|
|
1250
|
-
* own. An app command may use them too, to look like the built-ins.
|
|
1254
|
+
* own. An app command may use them too, to look like the built-ins. A minor
|
|
1255
|
+
* release may add a key, so a renderer's map of them needs a fallback.
|
|
1251
1256
|
*/
|
|
1252
1257
|
type BuiltInCommandIcon = "sortAscending" | "sortDescending" | "group" | "hide" | "autoFit" | "copy" | "print";
|
|
1253
1258
|
/**
|
|
@@ -1334,7 +1339,10 @@ interface ResolvedMenuSeparator {
|
|
|
1334
1339
|
/** One entry of a menu as `resolveMenu` hands it to a renderer to draw. */
|
|
1335
1340
|
type ResolvedMenuEntry = ResolvedMenuItem | ResolvedMenuSubmenu | ResolvedMenuSeparator;
|
|
1336
1341
|
|
|
1337
|
-
/**
|
|
1342
|
+
/**
|
|
1343
|
+
* The parts of a grid that open a context menu of their own. A minor
|
|
1344
|
+
* release may add an area, so a `switch` over it needs a `default`.
|
|
1345
|
+
*/
|
|
1338
1346
|
type GridContextMenuArea = "header" | "cell" | "group" | "body";
|
|
1339
1347
|
/**
|
|
1340
1348
|
* Where a context menu opens: a command target in one of the context menu
|
|
@@ -1644,9 +1652,9 @@ interface GridOptions<Row> {
|
|
|
1644
1652
|
/** The cell selected to start with. Uncontrolled. */
|
|
1645
1653
|
defaultCellSelection?: CellSelectionState | undefined;
|
|
1646
1654
|
/**
|
|
1647
|
-
* The selected cell, controlled — `
|
|
1648
|
-
* the cell selection callbacks. Leave it `undefined` for the
|
|
1649
|
-
* it.
|
|
1655
|
+
* The selected cell, controlled — `{ kind: "none" }` for none, changed
|
|
1656
|
+
* only through the cell selection callbacks. Leave it `undefined` for the
|
|
1657
|
+
* grid to keep it.
|
|
1650
1658
|
*/
|
|
1651
1659
|
cellSelection?: CellSelectionState | undefined;
|
|
1652
1660
|
/** Whether columns can be dragged wider, unless a column says otherwise. */
|
|
@@ -2819,8 +2827,18 @@ interface SelectedCellRef {
|
|
|
2819
2827
|
readonly rowId: string;
|
|
2820
2828
|
readonly columnId: string;
|
|
2821
2829
|
}
|
|
2822
|
-
/**
|
|
2823
|
-
|
|
2830
|
+
/**
|
|
2831
|
+
* Which cells are selected: none, or one cell by its address. A minor
|
|
2832
|
+
* release may add a member, such as a range of cells, so a `switch` over
|
|
2833
|
+
* `kind` needs a `default`.
|
|
2834
|
+
*/
|
|
2835
|
+
type CellSelectionState = {
|
|
2836
|
+
readonly kind: "none";
|
|
2837
|
+
} | {
|
|
2838
|
+
readonly kind: "cell";
|
|
2839
|
+
readonly rowId: string;
|
|
2840
|
+
readonly columnId: string;
|
|
2841
|
+
};
|
|
2824
2842
|
/**
|
|
2825
2843
|
* What changed between two selections. Ids rather than resolved members, so
|
|
2826
2844
|
* that the transform producing it stays free of the data it selects from.
|
|
@@ -2934,9 +2952,9 @@ interface CellSelectEvent<Row, Node = string> {
|
|
|
2934
2952
|
readonly selection: CellSelectionState;
|
|
2935
2953
|
}
|
|
2936
2954
|
/**
|
|
2937
|
-
* Reports a cell selection change whole.
|
|
2938
|
-
* interaction can fill both — moving between cells
|
|
2939
|
-
* once.
|
|
2955
|
+
* Reports a cell selection change whole. `selected` and `deselected` are
|
|
2956
|
+
* nullable and one interaction can fill both — moving between cells
|
|
2957
|
+
* deselects and selects at once.
|
|
2940
2958
|
*/
|
|
2941
2959
|
interface CellSelectionChangeEvent<Row, Node = string> {
|
|
2942
2960
|
readonly selected: SelectedCell<Row, Node> | null;
|
|
@@ -3011,7 +3029,14 @@ interface GridViewInput<Row, Node = string> {
|
|
|
3011
3029
|
readonly rows: readonly Row[];
|
|
3012
3030
|
readonly getRowId?: ((row: Row, index: number) => string) | undefined;
|
|
3013
3031
|
readonly columns: readonly ColumnDefinition<Row, Node>[];
|
|
3014
|
-
|
|
3032
|
+
/**
|
|
3033
|
+
* The slices to show, any of them: one left out reads as the grid's
|
|
3034
|
+
* starting default — no sizes, order, hidden columns, sort, filter or
|
|
3035
|
+
* grouping, every group expanded, and the first page of 25.
|
|
3036
|
+
*/
|
|
3037
|
+
readonly state: {
|
|
3038
|
+
readonly [K in keyof GridViewState<Row>]?: GridViewState<Row>[K] | undefined;
|
|
3039
|
+
};
|
|
3015
3040
|
readonly options: GridViewOptions<Row>;
|
|
3016
3041
|
}
|
|
3017
3042
|
/**
|
|
@@ -3259,6 +3284,7 @@ declare function clearSelection(selection: SelectionState): SelectionState;
|
|
|
3259
3284
|
* same interaction cannot disagree about which it was.
|
|
3260
3285
|
*/
|
|
3261
3286
|
declare function diffSelection(previous: SelectionState, next: SelectionState): SelectionDiff;
|
|
3287
|
+
/** Whether two cell selections hold the same cells. */
|
|
3262
3288
|
declare function isSameCell(a: CellSelectionState, b: CellSelectionState): boolean;
|
|
3263
3289
|
/**
|
|
3264
3290
|
* The cell selection moved to `cell` — a plain click. Idempotent: clicking the
|
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-
|
|
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 ColumnResizeEvent, a7 as ColumnResolveOptions, a8 as ColumnSelectEvent, a9 as ColumnSelectionChangeEvent, aa as ColumnSizeDefaults, ab as ColumnSizingState, ac as ColumnSortEntry, ad as ColumnSortEvent, ae as ColumnVisibilityEvent, af as ColumnWrapConfig, ag as ColumnsSelectEvent, ah as ContextMenuOpenChangeEvent, ai as CopyContent, aj as CsvOptions, ak as DEFAULT_COLUMN_SIZES, al as DEFAULT_FILTER_VALUE_LIMIT, am as ExportCell, an as ExportColumn, ao as ExportDataRow, ap as ExportGroupRow, aq as ExportGroupSummaryRow, ar as ExportOptions, as as ExportRow, at as ExportScalar, au as ExportTotalRow, av as ExportWriteContext, aw as FilterChangeEvent, ax as FilterEntry, ay as FilterMenuUi, az as FilterOperator, aA as FilterOperatorFamily, aB as FilterPredicate, aC as FilterScalar, aD as FooterTemplateContext, aE as FormatLocale, aF as GridCommandActions, aG as GridCommandEvent, aH as GridCommandSource, aI as GridContextMenuArea, aJ as GridContextMenuEntries, aK as GridContextMenuOptions, aL as GridContextMenuRequest, aM as GridContextMenuTarget, aN as GridFilterMenuOptions, aO as GridFocus, aP as GridOptions, aQ as GridPanelKind, aR as GridToolbarOptions, aS as GridViewOptions, aT as GridViewState, aU as GroupByBarVisibility, aV as GroupByEntry, aW as GroupByEvent, aX as GroupExpansionEvent, aY as GroupExpansionState, aZ as GroupFilterEntry, a_ as HoverableConfig, a$ as JsonOptions, b0 as MenuItemEntry, b1 as MenuSubmenuEntry, b2 as OperatorFilterEntry, b3 as PaginationChangeEvent, b4 as PredicateFilterEntry, b5 as PrintDocument, b6 as PrintOptions, b7 as PrintOrientation, b8 as PrintPage, b9 as PrintSource, ba as ResizeMode, bb as ResolvedGroupRow, bc as ResolvedGroupSummaryRow, bd as ResolvedMenuItem, be as ResolvedMenuSeparator, bf as ResolvedMenuSubmenu, bg as ResolvedToolbarButton, bh as ResolvedToolbarCustom, bi as ResolvedToolbarMenu, bj as ResolvedToolbarSearch, bk as ResolvedToolbarSpacer, bl as RowPointerEvent, bm as RowProps, bn as RowSelectEvent, bo as RowSelectionChangeEvent, bp as RowsSelectEvent, bq as SelectIntent, br as SelectableConfig, bs as SelectionCallbacks, bt as SelectionDiff, bu as SelectionDiffEvent, bv as SelectionMode, bw as SelectionState, bx as SerializedFilterEntry, by as SerializedFilterScalar, bz as SerializedFilterState, bA as SerializedGroupFilterEntry, bB as SerializedOperatorFilterEntry, bC as SerializedValueFilterEntry, bD as TextFilterEntry, bE as ToolbarCustomEntry, bF as ValueFilterEntry, bG as accessDotted, bH as alignmentForType, bI as applyColumnOrder, bJ as applySelectionIntent, bK as bodyFocus, bL as buildExportTable, bM as builtInCommands, bN as clearSelection, bO as collapseAllGroups, bP as contextMenuEntries, bQ as createDefaultMessages, bR as csvWriter, bS as defaultContextMenu, bT as defaultFilterOperators, bU as defaultMessages, bV as defaultToolbar, bW as defineColumnsFromRows, bX as expandAllGroups, bY as exportPrintDocument, bZ as formatAggregateValue, b_ as formatCellValue, b$ as formatGroupValue, c0 as getColumnId, c1 as groupRowId, c2 as groupRows, c3 as headerFocus, c4 as isColumnFiltered, c5 as isGroupExpanded, c6 as isSameCell, c7 as jsonWriter, c8 as moveColumnBefore, c9 as moveGroupByBefore, ca as resolveColumnHeaderText, cb as resolveColumnLabel, cc as resolveColumnWidths, cd as resolveDataColumns, ce as resolveExportWriters, cf as resolveMessages, cg as resolveRowId, ch as selectAll, ci as selectCell, cj as selectOnly, ck as selectRange, cl as toCsv, cm as toJson, cn as toggleCellSelection, co as toggleGroupExpansion, cp as toggleSelection, cq as toolbarEntries } from './filterEditor-
|
|
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-B7C_n89V.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 ColumnResizeEvent, a7 as ColumnResolveOptions, a8 as ColumnSelectEvent, a9 as ColumnSelectionChangeEvent, aa as ColumnSizeDefaults, ab as ColumnSizingState, ac as ColumnSortEntry, ad as ColumnSortEvent, ae as ColumnVisibilityEvent, af as ColumnWrapConfig, ag as ColumnsSelectEvent, ah as ContextMenuOpenChangeEvent, ai as CopyContent, aj as CsvOptions, ak as DEFAULT_COLUMN_SIZES, al as DEFAULT_FILTER_VALUE_LIMIT, am as ExportCell, an as ExportColumn, ao as ExportDataRow, ap as ExportGroupRow, aq as ExportGroupSummaryRow, ar as ExportOptions, as as ExportRow, at as ExportScalar, au as ExportTotalRow, av as ExportWriteContext, aw as FilterChangeEvent, ax as FilterEntry, ay as FilterMenuUi, az as FilterOperator, aA as FilterOperatorFamily, aB as FilterPredicate, aC as FilterScalar, aD as FooterTemplateContext, aE as FormatLocale, aF as GridCommandActions, aG as GridCommandEvent, aH as GridCommandSource, aI as GridContextMenuArea, aJ as GridContextMenuEntries, aK as GridContextMenuOptions, aL as GridContextMenuRequest, aM as GridContextMenuTarget, aN as GridFilterMenuOptions, aO as GridFocus, aP as GridOptions, aQ as GridPanelKind, aR as GridToolbarOptions, aS as GridViewOptions, aT as GridViewState, aU as GroupByBarVisibility, aV as GroupByEntry, aW as GroupByEvent, aX as GroupExpansionEvent, aY as GroupExpansionState, aZ as GroupFilterEntry, a_ as HoverableConfig, a$ as JsonOptions, b0 as MenuItemEntry, b1 as MenuSubmenuEntry, b2 as OperatorFilterEntry, b3 as PaginationChangeEvent, b4 as PredicateFilterEntry, b5 as PrintDocument, b6 as PrintOptions, b7 as PrintOrientation, b8 as PrintPage, b9 as PrintSource, ba as ResizeMode, bb as ResolvedGroupRow, bc as ResolvedGroupSummaryRow, bd as ResolvedMenuItem, be as ResolvedMenuSeparator, bf as ResolvedMenuSubmenu, bg as ResolvedToolbarButton, bh as ResolvedToolbarCustom, bi as ResolvedToolbarMenu, bj as ResolvedToolbarSearch, bk as ResolvedToolbarSpacer, bl as RowPointerEvent, bm as RowProps, bn as RowSelectEvent, bo as RowSelectionChangeEvent, bp as RowsSelectEvent, bq as SelectIntent, br as SelectableConfig, bs as SelectionCallbacks, bt as SelectionDiff, bu as SelectionDiffEvent, bv as SelectionMode, bw as SelectionState, bx as SerializedFilterEntry, by as SerializedFilterScalar, bz as SerializedFilterState, bA as SerializedGroupFilterEntry, bB as SerializedOperatorFilterEntry, bC as SerializedValueFilterEntry, bD as TextFilterEntry, bE as ToolbarCustomEntry, bF as ValueFilterEntry, bG as accessDotted, bH as alignmentForType, bI as applyColumnOrder, bJ as applySelectionIntent, bK as bodyFocus, bL as buildExportTable, bM as builtInCommands, bN as clearSelection, bO as collapseAllGroups, bP as contextMenuEntries, bQ as createDefaultMessages, bR as csvWriter, bS as defaultContextMenu, bT as defaultFilterOperators, bU as defaultMessages, bV as defaultToolbar, bW as defineColumnsFromRows, bX as expandAllGroups, bY as exportPrintDocument, bZ as formatAggregateValue, b_ as formatCellValue, b$ as formatGroupValue, c0 as getColumnId, c1 as groupRowId, c2 as groupRows, c3 as headerFocus, c4 as isColumnFiltered, c5 as isGroupExpanded, c6 as isSameCell, c7 as jsonWriter, c8 as moveColumnBefore, c9 as moveGroupByBefore, ca as resolveColumnHeaderText, cb as resolveColumnLabel, cc as resolveColumnWidths, cd as resolveDataColumns, ce as resolveExportWriters, cf as resolveMessages, cg as resolveRowId, ch as selectAll, ci as selectCell, cj as selectOnly, ck as selectRange, cl as toCsv, cm as toJson, cn as toggleCellSelection, co as toggleGroupExpansion, cp as toggleSelection, cq as toolbarEntries } from './filterEditor-B7C_n89V.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Creates the state container for one grid — see `GridController`. Hold one
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
ALL_EXPANDED,
|
|
4
4
|
DEFAULT_COLUMN_SIZES,
|
|
5
5
|
DEFAULT_FILTER_VALUE_LIMIT,
|
|
6
|
+
NO_CELL_SELECTED,
|
|
6
7
|
accessDotted,
|
|
7
8
|
alignmentForType,
|
|
8
9
|
applyColumnOrder,
|
|
@@ -12,6 +13,7 @@ import {
|
|
|
12
13
|
buildExportTable,
|
|
13
14
|
builtInCommands,
|
|
14
15
|
clearAllFilters,
|
|
16
|
+
clearCellSelection,
|
|
15
17
|
clearSelection,
|
|
16
18
|
collapseAllGroups,
|
|
17
19
|
collapseSeparators,
|
|
@@ -86,7 +88,7 @@ import {
|
|
|
86
88
|
unknownDisplayRow,
|
|
87
89
|
unknownFilterEntry,
|
|
88
90
|
withGroupAggregates
|
|
89
|
-
} from "./chunk-
|
|
91
|
+
} from "./chunk-QGKPKQIO.js";
|
|
90
92
|
|
|
91
93
|
// src/util/memoize.ts
|
|
92
94
|
function memoizeLast(compute) {
|
|
@@ -230,13 +232,33 @@ function serializeGridState(state) {
|
|
|
230
232
|
filter: serializeFilter(state.filter)
|
|
231
233
|
};
|
|
232
234
|
}
|
|
235
|
+
function untaggedCellSelection(saved) {
|
|
236
|
+
if (saved === null) {
|
|
237
|
+
return { kind: "none" };
|
|
238
|
+
}
|
|
239
|
+
if (typeof saved === "object" && !("kind" in saved) && "rowId" in saved && typeof saved.rowId === "string" && "columnId" in saved && typeof saved.columnId === "string") {
|
|
240
|
+
return { kind: "cell", rowId: saved.rowId, columnId: saved.columnId };
|
|
241
|
+
}
|
|
242
|
+
return void 0;
|
|
243
|
+
}
|
|
244
|
+
function migrateUnversioned(state) {
|
|
245
|
+
let migrated = state;
|
|
246
|
+
if (isStringList(state.groupExpansion)) {
|
|
247
|
+
migrated = {
|
|
248
|
+
...migrated,
|
|
249
|
+
groupExpansion: { mode: "allExpanded", except: state.groupExpansion }
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
const cellSelection = untaggedCellSelection(state.cellSelection);
|
|
253
|
+
if (cellSelection !== void 0) {
|
|
254
|
+
migrated = { ...migrated, cellSelection };
|
|
255
|
+
}
|
|
256
|
+
return migrated;
|
|
257
|
+
}
|
|
233
258
|
function migrateSavedState(saved) {
|
|
234
259
|
const { version, ...state } = saved;
|
|
235
260
|
if (version === void 0) {
|
|
236
|
-
return
|
|
237
|
-
...state,
|
|
238
|
-
groupExpansion: { mode: "allExpanded", except: state.groupExpansion }
|
|
239
|
-
} : state;
|
|
261
|
+
return migrateUnversioned(state);
|
|
240
262
|
}
|
|
241
263
|
if (version === SAVED_STATE_VERSION) {
|
|
242
264
|
return state;
|
|
@@ -325,6 +347,29 @@ function reviveGroupExpansion(saved) {
|
|
|
325
347
|
|
|
326
348
|
// src/util/view.ts
|
|
327
349
|
var NO_AGGREGATES = [];
|
|
350
|
+
var DEFAULT_PAGE_SIZE = 25;
|
|
351
|
+
var STARTING_VIEW_STATE = {
|
|
352
|
+
columnSizing: {},
|
|
353
|
+
columnOrder: [],
|
|
354
|
+
columnVisibility: {},
|
|
355
|
+
columnSort: [],
|
|
356
|
+
filter: [],
|
|
357
|
+
groupBy: [],
|
|
358
|
+
groupExpansion: ALL_EXPANDED,
|
|
359
|
+
pagination: { pageIndex: 0, pageSize: DEFAULT_PAGE_SIZE }
|
|
360
|
+
};
|
|
361
|
+
function fillViewState(state) {
|
|
362
|
+
return {
|
|
363
|
+
columnSizing: state.columnSizing ?? STARTING_VIEW_STATE.columnSizing,
|
|
364
|
+
columnOrder: state.columnOrder ?? STARTING_VIEW_STATE.columnOrder,
|
|
365
|
+
columnVisibility: state.columnVisibility ?? STARTING_VIEW_STATE.columnVisibility,
|
|
366
|
+
columnSort: state.columnSort ?? STARTING_VIEW_STATE.columnSort,
|
|
367
|
+
filter: state.filter ?? STARTING_VIEW_STATE.filter,
|
|
368
|
+
groupBy: state.groupBy ?? STARTING_VIEW_STATE.groupBy,
|
|
369
|
+
groupExpansion: state.groupExpansion ?? STARTING_VIEW_STATE.groupExpansion,
|
|
370
|
+
pagination: state.pagination ?? STARTING_VIEW_STATE.pagination
|
|
371
|
+
};
|
|
372
|
+
}
|
|
328
373
|
function identifyRows(rows, getRowId) {
|
|
329
374
|
return rows.map((row, rowIndex) => ({
|
|
330
375
|
kind: "data",
|
|
@@ -381,7 +426,14 @@ function createGridViewResolver() {
|
|
|
381
426
|
grandTotal
|
|
382
427
|
})
|
|
383
428
|
);
|
|
384
|
-
return ({
|
|
429
|
+
return ({
|
|
430
|
+
rows: data,
|
|
431
|
+
getRowId,
|
|
432
|
+
columns: definitions,
|
|
433
|
+
state: given,
|
|
434
|
+
options
|
|
435
|
+
}) => {
|
|
436
|
+
const state = fillViewState(given);
|
|
385
437
|
const paginated = options.paginated ?? false;
|
|
386
438
|
const aggregates = options.aggregates ?? NO_AGGREGATES;
|
|
387
439
|
const dataColumns = orderColumns(definitions, state.columnOrder);
|
|
@@ -551,9 +603,12 @@ function reportColumnSelection(previous, next, columns, callbacks) {
|
|
|
551
603
|
});
|
|
552
604
|
return diff;
|
|
553
605
|
}
|
|
606
|
+
function selectedCellOf(selection) {
|
|
607
|
+
return selection.kind === "cell" ? selection : null;
|
|
608
|
+
}
|
|
554
609
|
function reportCellSelection(previous, next, rowsById, columns, callbacks) {
|
|
555
|
-
const selected = resolveCell(rowsById, columns, next);
|
|
556
|
-
const deselected = resolveCell(rowsById, columns, previous);
|
|
610
|
+
const selected = resolveCell(rowsById, columns, selectedCellOf(next));
|
|
611
|
+
const deselected = resolveCell(rowsById, columns, selectedCellOf(previous));
|
|
557
612
|
if (deselected !== null) {
|
|
558
613
|
callbacks.onCellDeselect?.({ cell: deselected, selection: next });
|
|
559
614
|
}
|
|
@@ -695,7 +750,7 @@ function createSelectionActions(grid) {
|
|
|
695
750
|
grid.transaction(() => {
|
|
696
751
|
commitRows(clearSelection(grid.getState().rowSelection));
|
|
697
752
|
commitColumns(clearSelection(grid.getState().columnSelection));
|
|
698
|
-
commitCell(
|
|
753
|
+
commitCell(clearCellSelection(grid.getState().cellSelection));
|
|
699
754
|
});
|
|
700
755
|
},
|
|
701
756
|
setColumnSelection(selection) {
|
|
@@ -732,7 +787,6 @@ function createSelectionActions(grid) {
|
|
|
732
787
|
}
|
|
733
788
|
|
|
734
789
|
// src/controller/createGridController.ts
|
|
735
|
-
var DEFAULT_PAGE_SIZE = 25;
|
|
736
790
|
var NO_ROWS = [];
|
|
737
791
|
var NO_COLUMNS = [];
|
|
738
792
|
var SLICE_KEYS = [
|
|
@@ -763,20 +817,17 @@ var DEFAULT_OPTION = {
|
|
|
763
817
|
};
|
|
764
818
|
function startingState(options) {
|
|
765
819
|
return {
|
|
766
|
-
columnSizing: options.defaultColumnSizing ??
|
|
767
|
-
columnOrder: options.defaultColumnOrder ??
|
|
768
|
-
columnVisibility: options.defaultColumnVisibility ??
|
|
769
|
-
columnSort: options.defaultColumnSort ??
|
|
770
|
-
filter: options.defaultFilter ??
|
|
771
|
-
groupBy: options.defaultGroupBy ??
|
|
772
|
-
groupExpansion: options.defaultGroupExpansion ??
|
|
773
|
-
pagination: options.defaultPagination ??
|
|
774
|
-
pageIndex: 0,
|
|
775
|
-
pageSize: DEFAULT_PAGE_SIZE
|
|
776
|
-
},
|
|
820
|
+
columnSizing: options.defaultColumnSizing ?? STARTING_VIEW_STATE.columnSizing,
|
|
821
|
+
columnOrder: options.defaultColumnOrder ?? STARTING_VIEW_STATE.columnOrder,
|
|
822
|
+
columnVisibility: options.defaultColumnVisibility ?? STARTING_VIEW_STATE.columnVisibility,
|
|
823
|
+
columnSort: options.defaultColumnSort ?? STARTING_VIEW_STATE.columnSort,
|
|
824
|
+
filter: options.defaultFilter ?? STARTING_VIEW_STATE.filter,
|
|
825
|
+
groupBy: options.defaultGroupBy ?? STARTING_VIEW_STATE.groupBy,
|
|
826
|
+
groupExpansion: options.defaultGroupExpansion ?? STARTING_VIEW_STATE.groupExpansion,
|
|
827
|
+
pagination: options.defaultPagination ?? STARTING_VIEW_STATE.pagination,
|
|
777
828
|
rowSelection: options.defaultRowSelection ?? [],
|
|
778
829
|
columnSelection: options.defaultColumnSelection ?? [],
|
|
779
|
-
cellSelection: options.defaultCellSelection ??
|
|
830
|
+
cellSelection: options.defaultCellSelection ?? NO_CELL_SELECTED
|
|
780
831
|
};
|
|
781
832
|
}
|
|
782
833
|
function definedColumns(columns, rows) {
|