@gridkitjs/core 0.0.0-dev-20261108231045 → 0.0.0-dev-20261109083020

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
@@ -576,7 +576,10 @@ interface GridMessages {
576
576
  exportSelectionJson: string;
577
577
  /** `exportSelection.xlsx` */
578
578
  exportSelectionXlsx: string;
579
- /** 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
+ */
580
583
  exportFailed: string;
581
584
  /** `copy.cell` */
582
585
  copyCell: string;
@@ -590,6 +593,8 @@ interface GridMessages {
590
593
  copyFailed: string;
591
594
  /** `print` */
592
595
  print: string;
596
+ /** Announced when the browser fails to print, so nothing is printed. */
597
+ printFailed: string;
593
598
  }
594
599
  /**
595
600
  * The grid's own English, its counts printed in `locale`'s digits —
@@ -1127,8 +1132,12 @@ interface GridCommandHost {
1127
1132
  * Saves an export as a file — in a browser, a download. A promise is the
1128
1133
  * file of a writer still writing; the host waits for it, and reports a
1129
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.
1130
1139
  */
1131
- readonly saveFile: (file: ExportFile | Promise<ExportFile>) => void;
1140
+ readonly saveFile: ((file: ExportFile | Promise<ExportFile>) => void) | ((file: ExportFile | Promise<ExportFile>) => boolean);
1132
1141
  /**
1133
1142
  * Puts a copy on the clipboard, as text and as HTML, and announces it —
1134
1143
  * `count` and `unit` say what to announce — or that the browser refused.
@@ -1196,7 +1205,12 @@ interface GridCommand<Row> {
1196
1205
  readonly isEnabled?: ((context: GridCommandContext<Row>) => boolean) | undefined;
1197
1206
  /** Present for a checkable command — drawn as a checkbox item or a toggle button — and says whether it is checked. */
1198
1207
  readonly isChecked?: ((context: GridCommandContext<Row>) => boolean) | undefined;
1199
- 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);
1200
1214
  }
1201
1215
 
1202
1216
  /** The id of every command `builtInCommands` returns. */
@@ -3006,7 +3020,7 @@ declare function resolveCommands<Row>(commands: readonly GridCommand<Row>[] | un
3006
3020
  * Runs `command` when it is visible and enabled on `context`'s target, and
3007
3021
  * says whether it did — so a renderer reports only a command that ran, and a
3008
3022
  * stale button or a call through the API cannot run one the grid's state no
3009
- * longer allows.
3023
+ * longer allows. A command whose `execute` returns `false` did not run.
3010
3024
  */
3011
3025
  declare function runCommand<Row>(command: GridCommand<Row>, context: GridCommandContext<Row>): boolean;
3012
3026
 
@@ -3955,6 +3969,24 @@ declare function filterEditorReducer<Row>(draft: FilterEditorDraft<Row>, action:
3955
3969
  * draft's combinator. Returns `current` itself when nothing changes.
3956
3970
  */
3957
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;
3958
3990
 
3959
3991
  /** What a column chooser is drawn from: every column, the visibility, and the search typed. */
3960
3992
  interface ColumnChooserInput<Row> {
@@ -4299,4 +4331,4 @@ declare const excelFilter: {
4299
4331
  };
4300
4332
  };
4301
4333
 
4302
- 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
@@ -3321,7 +3321,8 @@ function createDefaultMessages(locale) {
3321
3321
  copySelection: "Copy selection",
3322
3322
  copied: (count, unit) => copied(n, count, unit),
3323
3323
  copyFailed: "Copy failed",
3324
- print: "Print"
3324
+ print: "Print",
3325
+ printFailed: "Print failed"
3325
3326
  };
3326
3327
  }
3327
3328
  var defaultMessages = createDefaultMessages();
@@ -3590,6 +3591,27 @@ function draftToFilter(draft, columnId, current) {
3590
3591
  const kept = current.filter((entry) => !touchesColumn(entry, columnId));
3591
3592
  return [...kept.slice(0, first), ...replacement, ...kept.slice(first)];
3592
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
+ }
3593
3615
 
3594
3616
  // src/commands/builtInCommands.ts
3595
3617
  function isOn(context, areas) {
@@ -3691,9 +3713,10 @@ function exportCommand({
3691
3713
  selection ? { ...defaults, scope: "selection" } : defaults,
3692
3714
  resolveExportWriters(exportWriters)
3693
3715
  );
3694
- if (file !== null) {
3695
- context.host.saveFile(file);
3716
+ if (file === null) {
3717
+ return;
3696
3718
  }
3719
+ return context.host.saveFile(file) !== false;
3697
3720
  }
3698
3721
  };
3699
3722
  }
@@ -3997,8 +4020,7 @@ function runCommand(command, context) {
3997
4020
  if (!isCommandVisible(command, context) || !isCommandEnabled(command, context)) {
3998
4021
  return false;
3999
4022
  }
4000
- command.execute(context);
4001
- return true;
4023
+ return command.execute(context) !== false;
4002
4024
  }
4003
4025
 
4004
4026
  // src/menu/resolveMenu.ts
@@ -4791,6 +4813,7 @@ export {
4791
4813
  exportFile,
4792
4814
  exportPrintDocument,
4793
4815
  filterChecklist,
4816
+ filterDraftChanged,
4794
4817
  filterEditorReducer,
4795
4818
  filterOperandArity,
4796
4819
  filterOperatorFamily,