@gridkitjs/core 0.0.0-dev-20261112195815 → 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-NA6KXHPE.js → chunk-QGKPKQIO.js} +118 -109
- package/dist/chunk-QGKPKQIO.js.map +1 -0
- package/dist/{filterEditor-Buy3CLup.d.ts → filterEditor-B7C_n89V.d.ts} +49 -16
- 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-NA6KXHPE.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
|
|
@@ -379,6 +379,10 @@ declare function formatGroupValue<Row>(value: unknown, column: ColumnDefinition<
|
|
|
379
379
|
* the app's to choose. Nor is formatting — dates and numbers follow
|
|
380
380
|
* `locale`, and so do the counts the defaults print: "1,204 of 10,000 rows"
|
|
381
381
|
* under `"en"`, "1.204 of 10.000 rows" under `"de-DE"`.
|
|
382
|
+
*
|
|
383
|
+
* A minor release may add keys. The `messages` option takes a partial set
|
|
384
|
+
* laid over the defaults, so a translation without a new key shows its
|
|
385
|
+
* English default until it gains one.
|
|
382
386
|
*/
|
|
383
387
|
interface GridMessages {
|
|
384
388
|
/** The pager's accessible name. */
|
|
@@ -698,7 +702,8 @@ interface ExportGroupSummaryRow {
|
|
|
698
702
|
}
|
|
699
703
|
/**
|
|
700
704
|
* A body row of an export, in the order the grid shows them. Discriminate on
|
|
701
|
-
* `kind
|
|
705
|
+
* `kind`; a minor release may add a kind, so a writer's `switch` over it
|
|
706
|
+
* needs a `default`.
|
|
702
707
|
*/
|
|
703
708
|
type ExportRow = ExportDataRow | ExportGroupRow | ExportGroupSummaryRow;
|
|
704
709
|
/**
|
|
@@ -1117,6 +1122,7 @@ type GridCommandTarget = {
|
|
|
1117
1122
|
/**
|
|
1118
1123
|
* Where a command was run from: a context menu, the toolbar, a renderer's
|
|
1119
1124
|
* API, or a column's filter menu — its sort entries and its "Clear filter".
|
|
1125
|
+
* A minor release may add a source, so a `switch` over it needs a `default`.
|
|
1120
1126
|
*/
|
|
1121
1127
|
type GridCommandSource = "contextMenu" | "toolbar" | "api" | "filterMenu";
|
|
1122
1128
|
/** What `onCommand` is told of a command, or an inline menu item, that ran. */
|
|
@@ -1129,13 +1135,15 @@ interface GridCommandEvent {
|
|
|
1129
1135
|
}
|
|
1130
1136
|
/**
|
|
1131
1137
|
* The panels a command can ask a renderer to open: the column chooser, and
|
|
1132
|
-
* a column's filter menu, which opens on a header target only.
|
|
1138
|
+
* a column's filter menu, which opens on a header target only. A minor
|
|
1139
|
+
* release may add a panel, so a `switch` over it needs a `default`.
|
|
1133
1140
|
*/
|
|
1134
1141
|
type GridPanelKind = "columnChooser" | "filter";
|
|
1135
1142
|
/**
|
|
1136
1143
|
* What a command needs that only a renderer has: a DOM to measure, panels to
|
|
1137
1144
|
* open, a live region to speak through. A caller with none of these — a test,
|
|
1138
|
-
* a script in Node — passes members that do nothing.
|
|
1145
|
+
* a script in Node — passes members that do nothing. A member added in a
|
|
1146
|
+
* minor release is optional, so a host built by hand keeps compiling.
|
|
1139
1147
|
*/
|
|
1140
1148
|
interface GridCommandHost {
|
|
1141
1149
|
/** Sizes each column to fit its content, as double-clicking its resize handle does. */
|
|
@@ -1236,11 +1244,15 @@ interface GridCommand<Row> {
|
|
|
1236
1244
|
readonly execute: ((context: GridCommandContext<Row>) => void) | ((context: GridCommandContext<Row>) => boolean);
|
|
1237
1245
|
}
|
|
1238
1246
|
|
|
1239
|
-
/**
|
|
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
|
+
*/
|
|
1240
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";
|
|
1241
1252
|
/**
|
|
1242
1253
|
* The icon keys the built-ins carry, which a renderer draws as icons of its
|
|
1243
|
-
* 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.
|
|
1244
1256
|
*/
|
|
1245
1257
|
type BuiltInCommandIcon = "sortAscending" | "sortDescending" | "group" | "hide" | "autoFit" | "copy" | "print";
|
|
1246
1258
|
/**
|
|
@@ -1327,7 +1339,10 @@ interface ResolvedMenuSeparator {
|
|
|
1327
1339
|
/** One entry of a menu as `resolveMenu` hands it to a renderer to draw. */
|
|
1328
1340
|
type ResolvedMenuEntry = ResolvedMenuItem | ResolvedMenuSubmenu | ResolvedMenuSeparator;
|
|
1329
1341
|
|
|
1330
|
-
/**
|
|
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
|
+
*/
|
|
1331
1346
|
type GridContextMenuArea = "header" | "cell" | "group" | "body";
|
|
1332
1347
|
/**
|
|
1333
1348
|
* Where a context menu opens: a command target in one of the context menu
|
|
@@ -1637,9 +1652,9 @@ interface GridOptions<Row> {
|
|
|
1637
1652
|
/** The cell selected to start with. Uncontrolled. */
|
|
1638
1653
|
defaultCellSelection?: CellSelectionState | undefined;
|
|
1639
1654
|
/**
|
|
1640
|
-
* The selected cell, controlled — `
|
|
1641
|
-
* the cell selection callbacks. Leave it `undefined` for the
|
|
1642
|
-
* 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.
|
|
1643
1658
|
*/
|
|
1644
1659
|
cellSelection?: CellSelectionState | undefined;
|
|
1645
1660
|
/** Whether columns can be dragged wider, unless a column says otherwise. */
|
|
@@ -2812,8 +2827,18 @@ interface SelectedCellRef {
|
|
|
2812
2827
|
readonly rowId: string;
|
|
2813
2828
|
readonly columnId: string;
|
|
2814
2829
|
}
|
|
2815
|
-
/**
|
|
2816
|
-
|
|
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
|
+
};
|
|
2817
2842
|
/**
|
|
2818
2843
|
* What changed between two selections. Ids rather than resolved members, so
|
|
2819
2844
|
* that the transform producing it stays free of the data it selects from.
|
|
@@ -2927,9 +2952,9 @@ interface CellSelectEvent<Row, Node = string> {
|
|
|
2927
2952
|
readonly selection: CellSelectionState;
|
|
2928
2953
|
}
|
|
2929
2954
|
/**
|
|
2930
|
-
* Reports a cell selection change whole.
|
|
2931
|
-
* interaction can fill both — moving between cells
|
|
2932
|
-
* 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.
|
|
2933
2958
|
*/
|
|
2934
2959
|
interface CellSelectionChangeEvent<Row, Node = string> {
|
|
2935
2960
|
readonly selected: SelectedCell<Row, Node> | null;
|
|
@@ -3004,7 +3029,14 @@ interface GridViewInput<Row, Node = string> {
|
|
|
3004
3029
|
readonly rows: readonly Row[];
|
|
3005
3030
|
readonly getRowId?: ((row: Row, index: number) => string) | undefined;
|
|
3006
3031
|
readonly columns: readonly ColumnDefinition<Row, Node>[];
|
|
3007
|
-
|
|
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
|
+
};
|
|
3008
3040
|
readonly options: GridViewOptions<Row>;
|
|
3009
3041
|
}
|
|
3010
3042
|
/**
|
|
@@ -3252,6 +3284,7 @@ declare function clearSelection(selection: SelectionState): SelectionState;
|
|
|
3252
3284
|
* same interaction cannot disagree about which it was.
|
|
3253
3285
|
*/
|
|
3254
3286
|
declare function diffSelection(previous: SelectionState, next: SelectionState): SelectionDiff;
|
|
3287
|
+
/** Whether two cell selections hold the same cells. */
|
|
3255
3288
|
declare function isSameCell(a: CellSelectionState, b: CellSelectionState): boolean;
|
|
3256
3289
|
/**
|
|
3257
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) {
|