@gridkitjs/core 0.0.0-dev-20261109130950 → 0.0.0-dev-20261109131620
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +54 -28
- package/dist/index.js +54 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -94,6 +94,10 @@ interface GridController<Row, Node = string> {
|
|
|
94
94
|
* filter or grouping that would otherwise send it back to the first page.
|
|
95
95
|
* A slice that throws stops the restore there, after the slices before it
|
|
96
96
|
* are shown, reported and announced as above.
|
|
97
|
+
*
|
|
98
|
+
* A `groupExpansion` saved as a bare list of group ids, as GridKit saved
|
|
99
|
+
* it before the slice carried a mode, restores as `allExpanded` with those
|
|
100
|
+
* ids as the exceptions.
|
|
97
101
|
*/
|
|
98
102
|
readonly restoreState: (saved: Partial<GridState<Row>> | Partial<SerializedGridState<Row>>) => void;
|
|
99
103
|
/**
|
|
@@ -220,13 +224,19 @@ interface GridController<Row, Node = string> {
|
|
|
220
224
|
*/
|
|
221
225
|
readonly moveGroupBy: (columnId: string, beforeColumnId: string | null) => void;
|
|
222
226
|
/**
|
|
223
|
-
* Replaces
|
|
224
|
-
* to every group at once; the same
|
|
227
|
+
* Replaces which groups are expanded. Reported with `groupId: null`, as a
|
|
228
|
+
* change to every group at once; the same mode with the same exceptions
|
|
229
|
+
* in the same order reports nothing.
|
|
225
230
|
*/
|
|
226
231
|
readonly setGroupExpansion: (expansion: GroupExpansionState) => void;
|
|
232
|
+
/** Expands a collapsed group or collapses an expanded one — see `toggleGroupExpansion`. */
|
|
227
233
|
readonly toggleGroupExpansion: (groupId: string) => void;
|
|
234
|
+
/** Expands every group, including those that appear later — see `expandAllGroups`. */
|
|
228
235
|
readonly expandAllGroups: () => void;
|
|
229
|
-
/**
|
|
236
|
+
/**
|
|
237
|
+
* Collapses every group, including one under a collapsed ancestor and
|
|
238
|
+
* those that appear later — see `collapseAllGroups`.
|
|
239
|
+
*/
|
|
230
240
|
readonly collapseAllGroups: () => void;
|
|
231
241
|
/**
|
|
232
242
|
* Replaces the page and page size. A controlled pagination asks for them
|
|
@@ -1754,10 +1764,14 @@ interface GridOptions<Row> {
|
|
|
1754
1764
|
* or reordering a level.
|
|
1755
1765
|
*/
|
|
1756
1766
|
onGroupByChange?: ((event: GroupByEvent) => void) | undefined;
|
|
1757
|
-
/**
|
|
1767
|
+
/**
|
|
1768
|
+
* Which groups start expanded, as a mode with exceptions — `{ mode:
|
|
1769
|
+
* "allCollapsed", except: [] }` starts every group collapsed. Every group
|
|
1770
|
+
* starts expanded when it is left out. Uncontrolled.
|
|
1771
|
+
*/
|
|
1758
1772
|
defaultGroupExpansion?: GroupExpansionState | undefined;
|
|
1759
1773
|
/**
|
|
1760
|
-
*
|
|
1774
|
+
* Which groups are expanded, controlled — applied as given, changed only
|
|
1761
1775
|
* through `onGroupExpansionChange`. Leave it `undefined` for the grid to
|
|
1762
1776
|
* keep it itself, starting from `defaultGroupExpansion`.
|
|
1763
1777
|
*/
|
|
@@ -2480,15 +2494,24 @@ interface GroupByEvent {
|
|
|
2480
2494
|
readonly groupBy: GroupByState;
|
|
2481
2495
|
}
|
|
2482
2496
|
/**
|
|
2483
|
-
*
|
|
2484
|
-
*
|
|
2485
|
-
*
|
|
2497
|
+
* Which groups are expanded, as a policy with exceptions: under
|
|
2498
|
+
* `allExpanded` every group is expanded but those whose `groupId` is in
|
|
2499
|
+
* `except`; under `allCollapsed` every group is collapsed but those. The
|
|
2500
|
+
* mode covers every group, including one hidden under a collapsed ancestor
|
|
2501
|
+
* and one that appears only after the state was set, so `except` holds just
|
|
2502
|
+
* the groups toggled against it.
|
|
2486
2503
|
*/
|
|
2487
|
-
type GroupExpansionState =
|
|
2504
|
+
type GroupExpansionState = {
|
|
2505
|
+
readonly mode: "allExpanded";
|
|
2506
|
+
readonly except: readonly string[];
|
|
2507
|
+
} | {
|
|
2508
|
+
readonly mode: "allCollapsed";
|
|
2509
|
+
readonly except: readonly string[];
|
|
2510
|
+
};
|
|
2488
2511
|
/**
|
|
2489
2512
|
* Reports a user expansion change. `groupId` is the group toggled, or `null`
|
|
2490
|
-
* for expandAllGroups/collapseAllGroups, which touch
|
|
2491
|
-
* rather than one at a time.
|
|
2513
|
+
* for expandAllGroups/collapseAllGroups and setGroupExpansion, which touch
|
|
2514
|
+
* every group in one call rather than one at a time.
|
|
2492
2515
|
*/
|
|
2493
2516
|
interface GroupExpansionEvent {
|
|
2494
2517
|
readonly groupId: string | null;
|
|
@@ -2504,7 +2527,7 @@ interface GroupExpansionEvent {
|
|
|
2504
2527
|
*/
|
|
2505
2528
|
interface ResolvedGroupRow {
|
|
2506
2529
|
readonly kind: "group";
|
|
2507
|
-
/** Stable id for this node: this plan's join of `path`, used as the React key and
|
|
2530
|
+
/** Stable id for this node: this plan's join of `path`, used as the React key and in GroupExpansionState's `except`. Opaque — build it with `groupRowId`, never construct one by hand. */
|
|
2508
2531
|
readonly groupId: string;
|
|
2509
2532
|
/** Nesting depth, 0 for a top-level group. */
|
|
2510
2533
|
readonly level: number;
|
|
@@ -3626,9 +3649,9 @@ declare function groupRowId(path: readonly unknown[]): string;
|
|
|
3626
3649
|
* `rows`, regrouped into `groupBy`'s stacked levels — a group header per
|
|
3627
3650
|
* distinct value at each level, ordered by `compareValues` per that level's
|
|
3628
3651
|
* own `direction`, followed depth-first by its nested groups and/or data
|
|
3629
|
-
* rows. A
|
|
3630
|
-
*
|
|
3631
|
-
*
|
|
3652
|
+
* rows. A group `expansion` collapses contributes only its own header,
|
|
3653
|
+
* nothing beneath it — but its `count` still reports the group's full
|
|
3654
|
+
* leaf-row count either way.
|
|
3632
3655
|
*
|
|
3633
3656
|
* Filter and sort are expected to have already run (see `resolveShownRows`):
|
|
3634
3657
|
* this only reshapes their output, and never changes which rows appear or
|
|
@@ -3645,25 +3668,28 @@ declare function groupRowId(path: readonly unknown[]): string;
|
|
|
3645
3668
|
* removed from the definition the same way a stored `ColumnSortState` does.
|
|
3646
3669
|
*/
|
|
3647
3670
|
declare function groupRows<Row>(rows: readonly ResolvedRow<Row>[], groupBy: GroupByState, expansion: GroupExpansionState, columns: readonly DataColumn<Row, unknown>[]): readonly DisplayRow<Row>[];
|
|
3671
|
+
/** Every group expanded, with no exceptions: where an uncontrolled grid starts. */
|
|
3672
|
+
declare const ALL_EXPANDED: GroupExpansionState;
|
|
3673
|
+
/** Every group collapsed, with no exceptions. */
|
|
3674
|
+
declare const ALL_COLLAPSED: GroupExpansionState;
|
|
3675
|
+
/** Whether `expansion` shows the group `groupId` names expanded. */
|
|
3676
|
+
declare function isGroupExpanded(expansion: GroupExpansionState, groupId: string): boolean;
|
|
3648
3677
|
/**
|
|
3649
3678
|
* The expansion with `groupId` collapsed if it was expanded, or expanded if
|
|
3650
|
-
* it was collapsed.
|
|
3679
|
+
* it was collapsed: it joins `except`, or leaves it, whatever the mode.
|
|
3651
3680
|
*/
|
|
3652
3681
|
declare function toggleGroupExpansion(expansion: GroupExpansionState, groupId: string): GroupExpansionState;
|
|
3653
|
-
/**
|
|
3682
|
+
/**
|
|
3683
|
+
* Every group expanded, now and as groups appear. Returns `expansion` itself
|
|
3684
|
+
* when it already says so, so expanding twice is no change.
|
|
3685
|
+
*/
|
|
3654
3686
|
declare function expandAllGroups(expansion: GroupExpansionState): GroupExpansionState;
|
|
3655
3687
|
/**
|
|
3656
|
-
* Every group
|
|
3657
|
-
*
|
|
3658
|
-
*
|
|
3659
|
-
* absent from `rows`) keeps whatever expansion it already had rather than
|
|
3660
|
-
* being forced closed too; expanding that ancestor again reveals it exactly
|
|
3661
|
-
* as it was left.
|
|
3662
|
-
*
|
|
3663
|
-
* Group headers only: a summary row (`groupAggregateDisplay: "row"`) carries
|
|
3664
|
-
* its group's id too, and counting it would list that group twice.
|
|
3688
|
+
* Every group collapsed, now and as groups appear: one hidden under a
|
|
3689
|
+
* collapsed ancestor too, so expanding that ancestor shows its children
|
|
3690
|
+
* collapsed. Returns `expansion` itself when it already says so.
|
|
3665
3691
|
*/
|
|
3666
|
-
declare function collapseAllGroups
|
|
3692
|
+
declare function collapseAllGroups(expansion: GroupExpansionState): GroupExpansionState;
|
|
3667
3693
|
/**
|
|
3668
3694
|
* `groupBy` with `columnId` positioned in front of `beforeColumnId` — or at
|
|
3669
3695
|
* the end when that is `null` — inserting a fresh entry if `columnId` isn't
|
|
@@ -4354,4 +4380,4 @@ declare const excelFilter: {
|
|
|
4354
4380
|
};
|
|
4355
4381
|
};
|
|
4356
4382
|
|
|
4357
|
-
export { type AggregateFn, type AggregateResults, type AggregateSpec, type AggregateState, type Borders, type BuiltInAggregate, type BuiltInCommandIcon, type BuiltInCommandId, type CellSelectEvent, type CellSelectionChangeEvent, type CellSelectionMode, type CellSelectionState, type CellTemplateContext, type ColumnAlignment, type ColumnChooserEntry, type ColumnChooserInput, type ColumnChooserModel, type ColumnChooserToggle, type ColumnConstraints, type ColumnDefinition, type ColumnFilterMenuOptions, type ColumnFilterShape, type ColumnOrderEvent, type ColumnOrderState, type ColumnResizeEvent, type ColumnResizeSession, type ColumnResolveOptions, type ColumnSelectEvent, type ColumnSelectionChangeEvent, type ColumnSizeDefaults, type ColumnSizingState, type ColumnSortEntry, type ColumnSortEvent, type ColumnSortState, type ColumnType, type ColumnValueCacheQuery, type ColumnValueOption, type ColumnValueOptions, type ColumnValueOptionsCache, type ColumnValueQuery, type ColumnVisibilityEvent, type ColumnVisibilityState, type ColumnWrapConfig, type ColumnsSelectEvent, type ConditionRowDraft, type ContextMenuOpenChangeEvent, type CopyContent, type CopyRequest, type CopySource, type CsvOptions, DEFAULT_COLUMN_SIZES, DEFAULT_FILTER_VALUE_LIMIT, type DataColumn, type DisplayRow, type DropSide, type ExportCell, type ExportColumn, type ExportDataRow, type ExportFile, type ExportFileSource, type ExportGroupRow, type ExportGroupSummaryRow, type ExportOptions, type ExportRow, type ExportScalar, type ExportSource, type ExportTable, type ExportTotalRow, type ExportWriteContext, type ExportWriter, type FieldPath, type FilterChangeEvent, type FilterChecklist, type FilterChecklistItem, type FilterChecklistOptions, type FilterEditorAction, type FilterEditorDraft, type FilterEntry, type FilterMenuUi, type FilterOperator, type FilterOperatorFamily, type FilterPredicate, type FilterScalar, type FilterState, type FooterTemplateContext, type FormatLocale, type GridCommand, type GridCommandActions, type GridCommandContext, type GridCommandContextInput, type GridCommandEvent, type GridCommandHost, type GridCommandSource, type GridCommandTarget, type GridContextMenuArea, type GridContextMenuEntries, type GridContextMenuOptions, type GridContextMenuRequest, type GridContextMenuTarget, type GridController, type GridControllerOptions, type GridExportOptions, type GridFilterMenuOptions, type GridFocus, type GridMessages, type GridOptions, type GridPanelKind, type GridState, type GridToolbarOptions, type GridToolbarTarget, type GridView, type GridViewInput, type GridViewOptions, type GridViewState, type GroupAggregateDisplay, type GroupByBarVisibility, type GroupByEntry, type GroupByEvent, type GroupByState, type GroupExpansionEvent, type GroupExpansionState, type GroupFilterEntry, HEADER_ROW, type HoverableConfig, type HtmlTableOptions, type JsonOptions, KEYBOARD_STEP, type KeyShortcutCapabilities, type MenuEntry, type MenuItemEntry, type MenuMove, type MenuResolveOptions, type MenuSubmenuEntry, type NavigationModifiers, type OperatorFilterEntry, type PaginateRowsOptions, type PaginatedRows, type PaginationChangeEvent, type PaginationState, type PaginationUnit, type PaginationWindowEntry, type ParsedConditionRows, type PredicateFilterEntry, type PrintDocument, type PrintOptions, type PrintOrientation, type PrintPage, type PrintSource, type ResizeMode, type ResolvedColumn, type ResolvedColumnFilterMenu, type ResolvedGroupRow, type ResolvedGroupSummaryRow, type ResolvedMenuEntry, type ResolvedMenuItem, type ResolvedMenuSeparator, type ResolvedMenuSubmenu, type ResolvedRow, type ResolvedToolbarButton, type ResolvedToolbarCustom, type ResolvedToolbarItem, type ResolvedToolbarMenu, type ResolvedToolbarSearch, type ResolvedToolbarSpacer, type RowHeights, type RowPointerEvent, type RowProps, type RowSelectEvent, type RowSelectionChangeEvent, type RowsSelectEvent, type SelectAllState, type SelectIntent, type SelectableConfig, type SelectedCell, type SelectedCellRef, type SelectedColumn, type SelectionCallbacks, type SelectionDiff, type SelectionDiffEvent, type SelectionMode, type SelectionState, type SerializedFilterEntry, type SerializedFilterScalar, type SerializedFilterState, type SerializedGridState, type SerializedGroupFilterEntry, type SerializedOperatorFilterEntry, type SerializedValueFilterEntry, type SortDirection, type TextFilterEntry, type ToolbarCustomEntry, type ToolbarEntry, type ToolbarFitInput, type ToolbarItemAttributes, type ToolbarResolveOptions, type ToolbarSplit, type TsvOptions, type ValueFilterEntry, type VisibleRange, accessDotted, alignmentForType, applyColumnOrder, applyColumnResize, applyColumnVisibility, applySelectionIntent, beginColumnResize, buildExportTable, buildKeyShortcuts, buildPrintDocument, builtInCommands, clampColumnWidth, clampFocus, clearAllFilters, clearSelection, collapseAllGroups, columnValueOptions, compareValues, computeAggregates, conditionRowsFrom, conditionsFromRows, contextMenuEntries, copyContent, createColumnValueOptionsCache, createCommandContext, createDefaultMessages, createGridController, createGridViewResolver, csvWriter, defaultContextMenu, defaultFilterOperators, defaultMessages, defaultToolbar, defineColumnsFromRows, describeColumnFilter, diffSelection, draftToFilter, excelFilter, expandAllGroups, exportFile, exportPrintDocument, filterChecklist, filterDraftChanged, filterEditorReducer, filterOperandArity, filterOperatorFamily, filterQueryFor, filterRows, fitColumnsToWidth, fitToolbarItems, formatAggregateValue, formatCellValue, formatFilterOperand, formatGroupValue, getColumnId, groupRowId, groupRows, hasContextMenu, initialFilterEditorDraft, intentOf, isColumnFiltered, isColumnVisible, isPinnedToolbarItem, isSameCell, jsonWriter, matchesQuery, moveColumnBefore, moveGroupByBefore, movesColumn, movesGroupBy, nextFocusForKey, nextMenuIndex, paginateRows, paginationWindow, parseFilterOperand, resolveCell, resolveColumnChooser, resolveColumnConstraints, resolveColumnFilterMenu, resolveColumnHeaderText, resolveColumnLabel, resolveColumnWidths, resolveColumns, resolveCommands, resolveDataColumns, resolveDropBefore, resolveExportWriters, resolveGridView, resolveKeyboardDropTarget, resolveMenu, resolveMessages, resolveRowId, resolveRows, resolveShownRows, resolveToolbar, revertColumnSize, runCommand, searchTextOf, selectAll, selectAllState, selectCell, selectOnly, selectRange, serializeGridState, setColumnFilter, setColumnVisibility, setSearchText, sizeColumnToContent, sortDirectionFor, sortPriorityFor, sortRows, splitToolbarItems, toCsv, toHtmlTable, toJson, toTsv, toggleCellSelection, toggleColumnSort, toggleGroupExpansion, toggleSelection, toolbarEntries, totalColumnWidth, typeaheadIndex, visibleFilterOptions, visibleRange, withGroupAggregates };
|
|
4383
|
+
export { ALL_COLLAPSED, ALL_EXPANDED, type AggregateFn, type AggregateResults, type AggregateSpec, type AggregateState, type Borders, type BuiltInAggregate, type BuiltInCommandIcon, type BuiltInCommandId, type CellSelectEvent, type CellSelectionChangeEvent, type CellSelectionMode, type CellSelectionState, type CellTemplateContext, type ColumnAlignment, type ColumnChooserEntry, type ColumnChooserInput, type ColumnChooserModel, type ColumnChooserToggle, type ColumnConstraints, type ColumnDefinition, type ColumnFilterMenuOptions, type ColumnFilterShape, type ColumnOrderEvent, type ColumnOrderState, type ColumnResizeEvent, type ColumnResizeSession, type ColumnResolveOptions, type ColumnSelectEvent, type ColumnSelectionChangeEvent, type ColumnSizeDefaults, type ColumnSizingState, type ColumnSortEntry, type ColumnSortEvent, type ColumnSortState, type ColumnType, type ColumnValueCacheQuery, type ColumnValueOption, type ColumnValueOptions, type ColumnValueOptionsCache, type ColumnValueQuery, type ColumnVisibilityEvent, type ColumnVisibilityState, type ColumnWrapConfig, type ColumnsSelectEvent, type ConditionRowDraft, type ContextMenuOpenChangeEvent, type CopyContent, type CopyRequest, type CopySource, type CsvOptions, DEFAULT_COLUMN_SIZES, DEFAULT_FILTER_VALUE_LIMIT, type DataColumn, type DisplayRow, type DropSide, type ExportCell, type ExportColumn, type ExportDataRow, type ExportFile, type ExportFileSource, type ExportGroupRow, type ExportGroupSummaryRow, type ExportOptions, type ExportRow, type ExportScalar, type ExportSource, type ExportTable, type ExportTotalRow, type ExportWriteContext, type ExportWriter, type FieldPath, type FilterChangeEvent, type FilterChecklist, type FilterChecklistItem, type FilterChecklistOptions, type FilterEditorAction, type FilterEditorDraft, type FilterEntry, type FilterMenuUi, type FilterOperator, type FilterOperatorFamily, type FilterPredicate, type FilterScalar, type FilterState, type FooterTemplateContext, type FormatLocale, type GridCommand, type GridCommandActions, type GridCommandContext, type GridCommandContextInput, type GridCommandEvent, type GridCommandHost, type GridCommandSource, type GridCommandTarget, type GridContextMenuArea, type GridContextMenuEntries, type GridContextMenuOptions, type GridContextMenuRequest, type GridContextMenuTarget, type GridController, type GridControllerOptions, type GridExportOptions, type GridFilterMenuOptions, type GridFocus, type GridMessages, type GridOptions, type GridPanelKind, type GridState, type GridToolbarOptions, type GridToolbarTarget, type GridView, type GridViewInput, type GridViewOptions, type GridViewState, type GroupAggregateDisplay, type GroupByBarVisibility, type GroupByEntry, type GroupByEvent, type GroupByState, type GroupExpansionEvent, type GroupExpansionState, type GroupFilterEntry, HEADER_ROW, type HoverableConfig, type HtmlTableOptions, type JsonOptions, KEYBOARD_STEP, type KeyShortcutCapabilities, type MenuEntry, type MenuItemEntry, type MenuMove, type MenuResolveOptions, type MenuSubmenuEntry, type NavigationModifiers, type OperatorFilterEntry, type PaginateRowsOptions, type PaginatedRows, type PaginationChangeEvent, type PaginationState, type PaginationUnit, type PaginationWindowEntry, type ParsedConditionRows, type PredicateFilterEntry, type PrintDocument, type PrintOptions, type PrintOrientation, type PrintPage, type PrintSource, type ResizeMode, type ResolvedColumn, type ResolvedColumnFilterMenu, type ResolvedGroupRow, type ResolvedGroupSummaryRow, type ResolvedMenuEntry, type ResolvedMenuItem, type ResolvedMenuSeparator, type ResolvedMenuSubmenu, type ResolvedRow, type ResolvedToolbarButton, type ResolvedToolbarCustom, type ResolvedToolbarItem, type ResolvedToolbarMenu, type ResolvedToolbarSearch, type ResolvedToolbarSpacer, type RowHeights, type RowPointerEvent, type RowProps, type RowSelectEvent, type RowSelectionChangeEvent, type RowsSelectEvent, type SelectAllState, type SelectIntent, type SelectableConfig, type SelectedCell, type SelectedCellRef, type SelectedColumn, type SelectionCallbacks, type SelectionDiff, type SelectionDiffEvent, type SelectionMode, type SelectionState, type SerializedFilterEntry, type SerializedFilterScalar, type SerializedFilterState, type SerializedGridState, type SerializedGroupFilterEntry, type SerializedOperatorFilterEntry, type SerializedValueFilterEntry, type SortDirection, type TextFilterEntry, type ToolbarCustomEntry, type ToolbarEntry, type ToolbarFitInput, type ToolbarItemAttributes, type ToolbarResolveOptions, type ToolbarSplit, type TsvOptions, type ValueFilterEntry, type VisibleRange, accessDotted, alignmentForType, applyColumnOrder, applyColumnResize, applyColumnVisibility, applySelectionIntent, beginColumnResize, buildExportTable, buildKeyShortcuts, buildPrintDocument, builtInCommands, clampColumnWidth, clampFocus, clearAllFilters, clearSelection, collapseAllGroups, columnValueOptions, compareValues, computeAggregates, conditionRowsFrom, conditionsFromRows, contextMenuEntries, copyContent, createColumnValueOptionsCache, createCommandContext, createDefaultMessages, createGridController, createGridViewResolver, csvWriter, defaultContextMenu, defaultFilterOperators, defaultMessages, defaultToolbar, defineColumnsFromRows, describeColumnFilter, diffSelection, draftToFilter, excelFilter, expandAllGroups, exportFile, exportPrintDocument, filterChecklist, filterDraftChanged, filterEditorReducer, filterOperandArity, filterOperatorFamily, filterQueryFor, filterRows, fitColumnsToWidth, fitToolbarItems, formatAggregateValue, formatCellValue, formatFilterOperand, formatGroupValue, getColumnId, groupRowId, groupRows, hasContextMenu, initialFilterEditorDraft, intentOf, isColumnFiltered, isColumnVisible, isGroupExpanded, isPinnedToolbarItem, isSameCell, jsonWriter, matchesQuery, moveColumnBefore, moveGroupByBefore, movesColumn, movesGroupBy, nextFocusForKey, nextMenuIndex, paginateRows, paginationWindow, parseFilterOperand, resolveCell, resolveColumnChooser, resolveColumnConstraints, resolveColumnFilterMenu, resolveColumnHeaderText, resolveColumnLabel, resolveColumnWidths, resolveColumns, resolveCommands, resolveDataColumns, resolveDropBefore, resolveExportWriters, resolveGridView, resolveKeyboardDropTarget, resolveMenu, resolveMessages, resolveRowId, resolveRows, resolveShownRows, resolveToolbar, revertColumnSize, runCommand, searchTextOf, selectAll, selectAllState, selectCell, selectOnly, selectRange, serializeGridState, setColumnFilter, setColumnVisibility, setSearchText, sizeColumnToContent, sortDirectionFor, sortPriorityFor, sortRows, splitToolbarItems, toCsv, toHtmlTable, toJson, toTsv, toggleCellSelection, toggleColumnSort, toggleGroupExpansion, toggleSelection, toolbarEntries, totalColumnWidth, typeaheadIndex, visibleFilterOptions, visibleRange, withGroupAggregates };
|
package/dist/index.js
CHANGED
|
@@ -275,7 +275,7 @@ function buildLevel(rows, levels, parentPath, expansion, byId, out) {
|
|
|
275
275
|
for (const group of groups) {
|
|
276
276
|
const path = [...parentPath, group.value];
|
|
277
277
|
const groupId = groupRowId(path);
|
|
278
|
-
const expanded =
|
|
278
|
+
const expanded = isGroupExpanded(expansion, groupId);
|
|
279
279
|
const header = {
|
|
280
280
|
kind: "group",
|
|
281
281
|
groupId,
|
|
@@ -311,16 +311,30 @@ function groupRows(rows, groupBy, expansion, columns) {
|
|
|
311
311
|
buildLevel(rows, active, [], expansion, byId, out);
|
|
312
312
|
return renumberRows(out);
|
|
313
313
|
}
|
|
314
|
+
var ALL_EXPANDED = {
|
|
315
|
+
mode: "allExpanded",
|
|
316
|
+
except: []
|
|
317
|
+
};
|
|
318
|
+
var ALL_COLLAPSED = {
|
|
319
|
+
mode: "allCollapsed",
|
|
320
|
+
except: []
|
|
321
|
+
};
|
|
322
|
+
function isGroupExpanded(expansion, groupId) {
|
|
323
|
+
const excepted = expansion.except.includes(groupId);
|
|
324
|
+
return expansion.mode === "allExpanded" ? !excepted : excepted;
|
|
325
|
+
}
|
|
314
326
|
function toggleGroupExpansion(expansion, groupId) {
|
|
315
|
-
|
|
327
|
+
const except = expansion.except.includes(groupId) ? expansion.except.filter((id) => id !== groupId) : [...expansion.except, groupId];
|
|
328
|
+
return { mode: expansion.mode, except };
|
|
316
329
|
}
|
|
317
330
|
function expandAllGroups(expansion) {
|
|
318
|
-
return expansion
|
|
331
|
+
return isWithoutExceptions(expansion, "allExpanded") ? expansion : ALL_EXPANDED;
|
|
332
|
+
}
|
|
333
|
+
function collapseAllGroups(expansion) {
|
|
334
|
+
return isWithoutExceptions(expansion, "allCollapsed") ? expansion : ALL_COLLAPSED;
|
|
319
335
|
}
|
|
320
|
-
function
|
|
321
|
-
return
|
|
322
|
-
(entry) => "kind" in entry && entry.kind === "group"
|
|
323
|
-
).map((entry) => entry.groupId);
|
|
336
|
+
function isWithoutExceptions(expansion, mode) {
|
|
337
|
+
return expansion.mode === mode && expansion.except.length === 0;
|
|
324
338
|
}
|
|
325
339
|
function moveGroupByBefore(groupBy, columnId, beforeColumnId) {
|
|
326
340
|
if (columnId === beforeColumnId) {
|
|
@@ -923,6 +937,23 @@ function reviveFilter(filter, columns) {
|
|
|
923
937
|
const types = new Map(columns.map((entry) => [entry.id, entry.column.type]));
|
|
924
938
|
return reviveEntries(filter, (columnId) => types.get(columnId));
|
|
925
939
|
}
|
|
940
|
+
function isStringList(value) {
|
|
941
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
942
|
+
}
|
|
943
|
+
function isGroupExpansion(value) {
|
|
944
|
+
return typeof value === "object" && value !== null && "mode" in value && (value.mode === "allExpanded" || value.mode === "allCollapsed") && "except" in value && isStringList(value.except);
|
|
945
|
+
}
|
|
946
|
+
function reviveGroupExpansion(saved) {
|
|
947
|
+
if (isStringList(saved)) {
|
|
948
|
+
return { mode: "allExpanded", except: saved };
|
|
949
|
+
}
|
|
950
|
+
if (isGroupExpansion(saved)) {
|
|
951
|
+
return saved;
|
|
952
|
+
}
|
|
953
|
+
throw new TypeError(
|
|
954
|
+
"GridKit: a saved `groupExpansion` is neither `{ mode, except }` nor a list of group ids."
|
|
955
|
+
);
|
|
956
|
+
}
|
|
926
957
|
|
|
927
958
|
// src/util/sizing.ts
|
|
928
959
|
var DEFAULT_COLUMN_SIZES = {
|
|
@@ -1434,6 +1465,9 @@ function changedKeys(previous, next) {
|
|
|
1434
1465
|
function sameItems(previous, next) {
|
|
1435
1466
|
return previous.length === next.length && previous.every((item, index) => item === next[index]);
|
|
1436
1467
|
}
|
|
1468
|
+
function sameGroupExpansion(previous, next) {
|
|
1469
|
+
return previous.mode === next.mode && sameItems(previous.except, next.except);
|
|
1470
|
+
}
|
|
1437
1471
|
function samePagination(previous, next) {
|
|
1438
1472
|
return previous.pageIndex === next.pageIndex && previous.pageSize === next.pageSize;
|
|
1439
1473
|
}
|
|
@@ -1831,7 +1865,7 @@ function startingState(options) {
|
|
|
1831
1865
|
columnSort: options.defaultColumnSort ?? [],
|
|
1832
1866
|
filter: options.defaultFilter ?? [],
|
|
1833
1867
|
groupBy: options.defaultGroupBy ?? [],
|
|
1834
|
-
groupExpansion: options.defaultGroupExpansion ??
|
|
1868
|
+
groupExpansion: options.defaultGroupExpansion ?? ALL_EXPANDED,
|
|
1835
1869
|
pagination: options.defaultPagination ?? {
|
|
1836
1870
|
pageIndex: 0,
|
|
1837
1871
|
pageSize: DEFAULT_PAGE_SIZE
|
|
@@ -2236,7 +2270,7 @@ function createGridController(initial) {
|
|
|
2236
2270
|
);
|
|
2237
2271
|
},
|
|
2238
2272
|
setGroupExpansion(expansion) {
|
|
2239
|
-
if (!
|
|
2273
|
+
if (!sameGroupExpansion(state.groupExpansion, expansion)) {
|
|
2240
2274
|
commitGroupExpansion(expansion, null);
|
|
2241
2275
|
}
|
|
2242
2276
|
},
|
|
@@ -2250,7 +2284,7 @@ function createGridController(initial) {
|
|
|
2250
2284
|
commitGroupExpansion(expandAllGroups(state.groupExpansion), null);
|
|
2251
2285
|
},
|
|
2252
2286
|
collapseAllGroups() {
|
|
2253
|
-
commitGroupExpansion(collapseAllGroups(
|
|
2287
|
+
commitGroupExpansion(collapseAllGroups(state.groupExpansion), null);
|
|
2254
2288
|
},
|
|
2255
2289
|
setPagination: commitPagination,
|
|
2256
2290
|
goToPage,
|
|
@@ -2288,7 +2322,7 @@ function createGridController(initial) {
|
|
|
2288
2322
|
controller.setGroupBy(saved.groupBy);
|
|
2289
2323
|
}
|
|
2290
2324
|
if (saved.groupExpansion !== void 0) {
|
|
2291
|
-
controller.setGroupExpansion(saved.groupExpansion);
|
|
2325
|
+
controller.setGroupExpansion(reviveGroupExpansion(saved.groupExpansion));
|
|
2292
2326
|
}
|
|
2293
2327
|
if (saved.pagination !== void 0) {
|
|
2294
2328
|
controller.setPagination(saved.pagination);
|
|
@@ -2632,7 +2666,12 @@ function buildExportTable(source, options = {}) {
|
|
|
2632
2666
|
messages: source.messages
|
|
2633
2667
|
};
|
|
2634
2668
|
const rows = scopedRows(source, options.scope ?? "all");
|
|
2635
|
-
const grouped = groupRows(
|
|
2669
|
+
const grouped = groupRows(
|
|
2670
|
+
rows,
|
|
2671
|
+
state.groupBy,
|
|
2672
|
+
ALL_EXPANDED,
|
|
2673
|
+
view.dataColumns
|
|
2674
|
+
);
|
|
2636
2675
|
const displayRows = options.includeGroups ?? true ? withGroupAggregates(
|
|
2637
2676
|
grouped,
|
|
2638
2677
|
rows,
|
|
@@ -4819,6 +4858,8 @@ var excelFilter = {
|
|
|
4819
4858
|
filterMenu: { ui: "excel", showCounts: true }
|
|
4820
4859
|
};
|
|
4821
4860
|
export {
|
|
4861
|
+
ALL_COLLAPSED,
|
|
4862
|
+
ALL_EXPANDED,
|
|
4822
4863
|
DEFAULT_COLUMN_SIZES,
|
|
4823
4864
|
DEFAULT_FILTER_VALUE_LIMIT,
|
|
4824
4865
|
HEADER_ROW,
|
|
@@ -4885,6 +4926,7 @@ export {
|
|
|
4885
4926
|
intentOf,
|
|
4886
4927
|
isColumnFiltered,
|
|
4887
4928
|
isColumnVisible,
|
|
4929
|
+
isGroupExpanded,
|
|
4888
4930
|
isPinnedToolbarItem,
|
|
4889
4931
|
isSameCell,
|
|
4890
4932
|
jsonWriter,
|