@gridkitjs/core 0.15.0 → 0.16.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.
package/dist/index.d.ts CHANGED
@@ -88,6 +88,8 @@ interface GridController<Row, Node = string> {
88
88
  * Subscribers are called once, after every slice is in place, and a
89
89
  * restored pagination is kept even when the same call changed the sort,
90
90
  * filter or grouping that would otherwise send it back to the first page.
91
+ * A slice that throws stops the restore there, after the slices before it
92
+ * are shown, reported and announced as above.
91
93
  */
92
94
  readonly restoreState: (saved: Partial<GridState<Row>> | Partial<SerializedGridState<Row>>) => void;
93
95
  /**
@@ -155,12 +157,18 @@ interface GridController<Row, Node = string> {
155
157
  /**
156
158
  * Applies one click or key press to a row: `"replace"`, `"toggle"` or
157
159
  * `"range"` from the last row selected by anything but a range, across
158
- * the data rows on the current page.
160
+ * the data rows on the current page. That anchor goes when the selection is
161
+ * cleared or replaced, or its row leaves the page; a range without one
162
+ * selects just this row and anchors there.
159
163
  */
160
164
  readonly selectRow: (rowId: string, intent: SelectIntent) => void;
161
165
  /** Selects every data row on the current page, when `selectable.rows` is `"multiple"`. */
162
166
  readonly selectAllRows: () => void;
163
- /** Lets go of every row, column and cell selection at once, as Escape does. */
167
+ /**
168
+ * Lets go of every row, column and cell selection at once, as Escape does:
169
+ * one change, so each selection that changes fires its callback and then
170
+ * subscribers are called once.
171
+ */
164
172
  readonly clearSelection: () => void;
165
173
  /** Replaces the selected column ids as given — see `setRowSelection`. */
166
174
  readonly setColumnSelection: (selection: SelectionState) => void;
@@ -568,7 +576,10 @@ interface GridMessages {
568
576
  exportSelectionJson: string;
569
577
  /** `exportSelection.xlsx` */
570
578
  exportSelectionXlsx: string;
571
- /** Announced when an export's writer fails, so no file is saved. */
579
+ /**
580
+ * Announced when an export's writer fails or the browser refuses its
581
+ * download, so no file is saved.
582
+ */
572
583
  exportFailed: string;
573
584
  /** `copy.cell` */
574
585
  copyCell: string;
@@ -582,6 +593,8 @@ interface GridMessages {
582
593
  copyFailed: string;
583
594
  /** `print` */
584
595
  print: string;
596
+ /** Announced when the browser fails to print, so nothing is printed. */
597
+ printFailed: string;
585
598
  }
586
599
  /**
587
600
  * The grid's own English, its counts printed in `locale`'s digits —
@@ -1119,8 +1132,12 @@ interface GridCommandHost {
1119
1132
  * Saves an export as a file — in a browser, a download. A promise is the
1120
1133
  * file of a writer still writing; the host waits for it, and reports a
1121
1134
  * rejected one rather than saving.
1135
+ *
1136
+ * Returns `false` for a file it drops without saving, as a host that saves
1137
+ * one file at a time does with one asked for while it waits on the last.
1138
+ * The export command that asked then did not run.
1122
1139
  */
1123
- readonly saveFile: (file: ExportFile | Promise<ExportFile>) => void;
1140
+ readonly saveFile: ((file: ExportFile | Promise<ExportFile>) => void) | ((file: ExportFile | Promise<ExportFile>) => boolean);
1124
1141
  /**
1125
1142
  * Puts a copy on the clipboard, as text and as HTML, and announces it —
1126
1143
  * `count` and `unit` say what to announce — or that the browser refused.
@@ -1188,7 +1205,12 @@ interface GridCommand<Row> {
1188
1205
  readonly isEnabled?: ((context: GridCommandContext<Row>) => boolean) | undefined;
1189
1206
  /** Present for a checkable command — drawn as a checkbox item or a toggle button — and says whether it is checked. */
1190
1207
  readonly isChecked?: ((context: GridCommandContext<Row>) => boolean) | undefined;
1191
- readonly execute: (context: GridCommandContext<Row>) => void;
1208
+ /**
1209
+ * Does what the command does. Returns `false` when it turns out to do
1210
+ * nothing after all, such as an export the host dropped, so `runCommand`
1211
+ * says it did not run and a renderer does not report it.
1212
+ */
1213
+ readonly execute: ((context: GridCommandContext<Row>) => void) | ((context: GridCommandContext<Row>) => boolean);
1192
1214
  }
1193
1215
 
1194
1216
  /** The id of every command `builtInCommands` returns. */
@@ -2998,7 +3020,7 @@ declare function resolveCommands<Row>(commands: readonly GridCommand<Row>[] | un
2998
3020
  * Runs `command` when it is visible and enabled on `context`'s target, and
2999
3021
  * says whether it did — so a renderer reports only a command that ran, and a
3000
3022
  * stale button or a call through the API cannot run one the grid's state no
3001
- * longer allows.
3023
+ * longer allows. A command whose `execute` returns `false` did not run.
3002
3024
  */
3003
3025
  declare function runCommand<Row>(command: GridCommand<Row>, context: GridCommandContext<Row>): boolean;
3004
3026
 
@@ -3947,6 +3969,24 @@ declare function filterEditorReducer<Row>(draft: FilterEditorDraft<Row>, action:
3947
3969
  * draft's combinator. Returns `current` itself when nothing changes.
3948
3970
  */
3949
3971
  declare function draftToFilter<Row>(draft: FilterEditorDraft<Row>, columnId: string, current: FilterState<Row>): FilterState<Row>;
3972
+ /**
3973
+ * Whether `draft` changes anything since the editor opened at `opened` — for
3974
+ * an Apply that changes nothing to leave the column's filter as it is,
3975
+ * rather than writing the draft over it. Compared by value, not identity, so
3976
+ * a value unchecked and checked again, or the same conditions typed again,
3977
+ * is no change; the search never is one.
3978
+ *
3979
+ * Only the half `draftToFilter` applies counts. A checklist changes when its
3980
+ * checked values or blanks differ from those it opened with, so one left as
3981
+ * it opened over conditions or a custom filter leaves that filter be.
3982
+ * Conditions change when they differ from those the draft opened with, and
3983
+ * always when it opened on a checklist, no filter or a custom one: setting
3984
+ * conditions there replaces it, none removing it.
3985
+ *
3986
+ * `clear` over a custom filter leaves a draft equal to the one it opened
3987
+ * with, so this reads it as no change.
3988
+ */
3989
+ declare function filterDraftChanged<Row>(opened: FilterEditorDraft<Row>, draft: FilterEditorDraft<Row>): boolean;
3950
3990
 
3951
3991
  /** What a column chooser is drawn from: every column, the visibility, and the search typed. */
3952
3992
  interface ColumnChooserInput<Row> {
@@ -4291,4 +4331,4 @@ declare const excelFilter: {
4291
4331
  };
4292
4332
  };
4293
4333
 
4294
- 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, 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 };
4334
+ 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 };
package/dist/index.js CHANGED
@@ -1596,6 +1596,21 @@ function indexRows(rows) {
1596
1596
  function distinct(ids) {
1597
1597
  return [...new Set(ids)];
1598
1598
  }
1599
+ function click(selection, orderedIds, anchor, id, intent, mode) {
1600
+ const live = anchor !== null && orderedIds.includes(anchor) ? anchor : null;
1601
+ const keepsAnchor = mode === false || intent === "range" && live !== null;
1602
+ return {
1603
+ selection: applySelectionIntent(
1604
+ selection,
1605
+ orderedIds,
1606
+ live,
1607
+ id,
1608
+ intent,
1609
+ mode
1610
+ ),
1611
+ anchor: keepsAnchor ? anchor : id
1612
+ };
1613
+ }
1599
1614
  function createSelectionActions(grid) {
1600
1615
  let rowAnchor = null;
1601
1616
  let columnAnchor = null;
@@ -1659,6 +1674,7 @@ function createSelectionActions(grid) {
1659
1674
  }
1660
1675
  return {
1661
1676
  setRowSelection(selection) {
1677
+ rowAnchor = null;
1662
1678
  if (!sameItems(grid.getState().rowSelection, selection)) {
1663
1679
  commitRows(selection);
1664
1680
  }
@@ -1679,7 +1695,7 @@ function createSelectionActions(grid) {
1679
1695
  }
1680
1696
  },
1681
1697
  selectRow(rowId, intent) {
1682
- const next = applySelectionIntent(
1698
+ const next = click(
1683
1699
  grid.getState().rowSelection,
1684
1700
  rowIds(),
1685
1701
  rowAnchor,
@@ -1687,10 +1703,8 @@ function createSelectionActions(grid) {
1687
1703
  intent,
1688
1704
  modes().rows
1689
1705
  );
1690
- if (intent !== "range") {
1691
- rowAnchor = rowId;
1692
- }
1693
- commitRows(next);
1706
+ rowAnchor = next.anchor;
1707
+ commitRows(next.selection);
1694
1708
  },
1695
1709
  selectAllRows() {
1696
1710
  commitRows(
@@ -1698,17 +1712,22 @@ function createSelectionActions(grid) {
1698
1712
  );
1699
1713
  },
1700
1714
  clearSelection() {
1701
- commitRows(clearSelection(grid.getState().rowSelection));
1702
- commitColumns(clearSelection(grid.getState().columnSelection));
1703
- commitCell(null);
1715
+ rowAnchor = null;
1716
+ columnAnchor = null;
1717
+ grid.transaction(() => {
1718
+ commitRows(clearSelection(grid.getState().rowSelection));
1719
+ commitColumns(clearSelection(grid.getState().columnSelection));
1720
+ commitCell(null);
1721
+ });
1704
1722
  },
1705
1723
  setColumnSelection(selection) {
1724
+ columnAnchor = null;
1706
1725
  if (!sameItems(grid.getState().columnSelection, selection)) {
1707
1726
  commitColumns(selection);
1708
1727
  }
1709
1728
  },
1710
1729
  selectColumn(columnId, intent) {
1711
- const next = applySelectionIntent(
1730
+ const next = click(
1712
1731
  grid.getState().columnSelection,
1713
1732
  columnIds(),
1714
1733
  columnAnchor,
@@ -1716,10 +1735,8 @@ function createSelectionActions(grid) {
1716
1735
  intent,
1717
1736
  modes().columns
1718
1737
  );
1719
- if (intent !== "range") {
1720
- columnAnchor = columnId;
1721
- }
1722
- commitColumns(next);
1738
+ columnAnchor = next.anchor;
1739
+ commitColumns(next.selection);
1723
1740
  },
1724
1741
  setCellSelection(selection) {
1725
1742
  if (!isSameCell(grid.getState().cellSelection, selection)) {
@@ -1793,6 +1810,10 @@ function definedColumns(columns, rows) {
1793
1810
  }
1794
1811
  return NO_COLUMNS;
1795
1812
  }
1813
+ var IDLE = { kind: "idle" };
1814
+ function samePagingInputs(a, b) {
1815
+ return a.filter === b.filter && a.columnSort === b.columnSort && a.groupBy === b.groupBy && a.paginationUnit === b.paginationUnit;
1816
+ }
1796
1817
  function pagingInputsOf(state, options) {
1797
1818
  return {
1798
1819
  filter: state.filter,
@@ -1808,7 +1829,7 @@ function createGridController(initial) {
1808
1829
  const resolveColumns2 = memoizeLast(definedColumns);
1809
1830
  const listeners = /* @__PURE__ */ new Set();
1810
1831
  const reportedConflicts = /* @__PURE__ */ new Set();
1811
- let heldReports;
1832
+ let mode = IDLE;
1812
1833
  let state = resolveSlices();
1813
1834
  let pagingInputs = pagingInputsOf(state, options);
1814
1835
  reportConflicts();
@@ -1850,19 +1871,23 @@ function createGridController(initial) {
1850
1871
  );
1851
1872
  }
1852
1873
  }
1853
- function refresh() {
1854
- let next = resolveSlices();
1855
- const inputs = pagingInputsOf(next, options);
1856
- if (inputs.filter !== pagingInputs.filter || inputs.columnSort !== pagingInputs.columnSort || inputs.groupBy !== pagingInputs.groupBy || inputs.paginationUnit !== pagingInputs.paginationUnit) {
1857
- pagingInputs = inputs;
1858
- if (!isControlled("pagination") && own.pagination.pageIndex !== 0) {
1859
- own.pagination = { ...own.pagination, pageIndex: 0 };
1860
- next = { ...next, pagination: own.pagination };
1861
- }
1862
- }
1874
+ function refresh(keepPage = false) {
1875
+ const next = followPagingInputs(resolveSlices(), keepPage);
1863
1876
  state = SLICE_KEYS.every((key) => next[key] === state[key]) ? state : next;
1864
1877
  storeShownPage();
1865
1878
  }
1879
+ function followPagingInputs(next, keepPage) {
1880
+ const inputs = pagingInputsOf(next, options);
1881
+ if (samePagingInputs(inputs, pagingInputs)) {
1882
+ return next;
1883
+ }
1884
+ pagingInputs = inputs;
1885
+ if (keepPage || isControlled("pagination") || own.pagination.pageIndex === 0) {
1886
+ return next;
1887
+ }
1888
+ own.pagination = { ...own.pagination, pageIndex: 0 };
1889
+ return { ...next, pagination: own.pagination };
1890
+ }
1866
1891
  function storeShownPage() {
1867
1892
  const stored = storedPagination(state.pagination);
1868
1893
  if (stored !== state.pagination) {
@@ -1889,14 +1914,38 @@ function createGridController(initial) {
1889
1914
  if (!isControlled(key)) {
1890
1915
  own[key] = next;
1891
1916
  }
1892
- if (heldReports !== void 0) {
1893
- heldReports.push(report);
1917
+ if (mode.kind === "transaction") {
1918
+ mode.held.push(report);
1894
1919
  return;
1895
1920
  }
1896
1921
  refresh();
1897
1922
  report();
1898
1923
  notify();
1899
1924
  }
1925
+ function transaction(run) {
1926
+ if (mode.kind === "transaction") {
1927
+ run();
1928
+ return;
1929
+ }
1930
+ const current = {
1931
+ kind: "transaction",
1932
+ held: [],
1933
+ pageAsked: false
1934
+ };
1935
+ mode = current;
1936
+ try {
1937
+ run();
1938
+ } finally {
1939
+ mode = IDLE;
1940
+ refresh(current.pageAsked);
1941
+ for (const report of current.held) {
1942
+ report();
1943
+ }
1944
+ if (current.held.length > 0) {
1945
+ notify();
1946
+ }
1947
+ }
1948
+ }
1900
1949
  function getView() {
1901
1950
  return resolveView({
1902
1951
  rows: options.dataSource ?? NO_ROWS,
@@ -1967,7 +2016,12 @@ function createGridController(initial) {
1967
2016
  });
1968
2017
  }
1969
2018
  function commitPagination(asked) {
1970
- const next = heldReports === void 0 ? storedPagination(asked) : asked;
2019
+ let next = asked;
2020
+ if (mode.kind === "transaction") {
2021
+ mode.pageAsked = true;
2022
+ } else {
2023
+ next = storedPagination(asked);
2024
+ }
1971
2025
  if (samePagination(state.pagination, next)) {
1972
2026
  return;
1973
2027
  }
@@ -1996,7 +2050,8 @@ function createGridController(initial) {
1996
2050
  getState: () => state,
1997
2051
  getOptions: () => options,
1998
2052
  getView,
1999
- commit
2053
+ commit,
2054
+ transaction
2000
2055
  });
2001
2056
  const controller = {
2002
2057
  ...selection,
@@ -2009,23 +2064,9 @@ function createGridController(initial) {
2009
2064
  getState: () => state,
2010
2065
  getView,
2011
2066
  restoreState(saved) {
2012
- const reports = [];
2013
- heldReports = reports;
2014
- try {
2067
+ transaction(() => {
2015
2068
  restoreSlices(saved);
2016
- } finally {
2017
- heldReports = void 0;
2018
- }
2019
- if (saved.pagination !== void 0) {
2020
- pagingInputs = pagingInputsOf(resolveSlices(), options);
2021
- }
2022
- refresh();
2023
- for (const report of reports) {
2024
- report();
2025
- }
2026
- if (reports.length > 0) {
2027
- notify();
2028
- }
2069
+ });
2029
2070
  },
2030
2071
  subscribe(listener) {
2031
2072
  listeners.add(listener);
@@ -3280,7 +3321,8 @@ function createDefaultMessages(locale) {
3280
3321
  copySelection: "Copy selection",
3281
3322
  copied: (count, unit) => copied(n, count, unit),
3282
3323
  copyFailed: "Copy failed",
3283
- print: "Print"
3324
+ print: "Print",
3325
+ printFailed: "Print failed"
3284
3326
  };
3285
3327
  }
3286
3328
  var defaultMessages = createDefaultMessages();
@@ -3549,6 +3591,27 @@ function draftToFilter(draft, columnId, current) {
3549
3591
  const kept = current.filter((entry) => !touchesColumn(entry, columnId));
3550
3592
  return [...kept.slice(0, first), ...replacement, ...kept.slice(first)];
3551
3593
  }
3594
+ function sameValues(a, b) {
3595
+ return a.includeBlanks === b.includeBlanks && a.checked.size === b.checked.size && [...a.checked.keys()].every((key) => b.checked.has(key));
3596
+ }
3597
+ function sameOperand2(a, b, type) {
3598
+ if (isScalarList(a) || isScalarList(b)) {
3599
+ return isScalarList(a) && isScalarList(b) && a.length === b.length && a.every((scalar, index) => sameOperand2(scalar, b[index], type));
3600
+ }
3601
+ return filterValueKey(a, type) === filterValueKey(b, type);
3602
+ }
3603
+ function sameConditions(a, b) {
3604
+ return a.conditions.length === b.conditions.length && (a.conditions.length < 2 || a.combinator === b.combinator) && a.conditions.every((condition, index) => {
3605
+ const other = b.conditions[index];
3606
+ return other !== void 0 && condition.operator === other.operator && sameOperand2(condition.value, other.value, a.columnType);
3607
+ });
3608
+ }
3609
+ function filterDraftChanged(opened, draft) {
3610
+ if (draft.mode === "values") {
3611
+ return !sameValues(opened, draft);
3612
+ }
3613
+ return opened.mode !== "conditions" || !sameConditions(opened, draft);
3614
+ }
3552
3615
 
3553
3616
  // src/commands/builtInCommands.ts
3554
3617
  function isOn(context, areas) {
@@ -3650,9 +3713,10 @@ function exportCommand({
3650
3713
  selection ? { ...defaults, scope: "selection" } : defaults,
3651
3714
  resolveExportWriters(exportWriters)
3652
3715
  );
3653
- if (file !== null) {
3654
- context.host.saveFile(file);
3716
+ if (file === null) {
3717
+ return;
3655
3718
  }
3719
+ return context.host.saveFile(file) !== false;
3656
3720
  }
3657
3721
  };
3658
3722
  }
@@ -3956,8 +4020,7 @@ function runCommand(command, context) {
3956
4020
  if (!isCommandVisible(command, context) || !isCommandEnabled(command, context)) {
3957
4021
  return false;
3958
4022
  }
3959
- command.execute(context);
3960
- return true;
4023
+ return command.execute(context) !== false;
3961
4024
  }
3962
4025
 
3963
4026
  // src/menu/resolveMenu.ts
@@ -4750,6 +4813,7 @@ export {
4750
4813
  exportFile,
4751
4814
  exportPrintDocument,
4752
4815
  filterChecklist,
4816
+ filterDraftChanged,
4753
4817
  filterEditorReducer,
4754
4818
  filterOperandArity,
4755
4819
  filterOperatorFamily,