@gridkitjs/core 0.0.0-dev-20261109131620 → 0.0.0-dev-20261109133348

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
@@ -3907,28 +3907,42 @@ interface ColumnValueOptions {
3907
3907
  */
3908
3908
  readonly columnType?: ColumnType | undefined;
3909
3909
  }
3910
- /**
3911
- * A checklist or condition editor's working copy of one column's filter,
3912
- * changed by `filterEditorReducer` and turned into a filter by
3913
- * `draftToFilter` only when the user applies it — so cancelling is just
3914
- * dropping the draft.
3915
- */
3916
- interface FilterEditorDraft<Row> {
3917
- /** Which half of the draft `draftToFilter` applies: the last one changed. */
3918
- readonly mode: "values" | "conditions";
3910
+ /** What a `FilterEditorDraft` holds on either arm. */
3911
+ interface FilterEditorDraftBase<Row> {
3919
3912
  /** Every value the editor offers, from `columnValueOptions`. */
3920
3913
  readonly options: readonly ColumnValueOption[];
3921
3914
  /** How many rows hold a blank; the blanks entry only matters when some do. */
3922
3915
  readonly blanks: number;
3923
3916
  readonly search: string;
3917
+ /**
3918
+ * The column's filter as the editor opened on it. An action for the other
3919
+ * arm builds that arm from it, as reopening the editor would show it.
3920
+ */
3921
+ readonly openedShape: ColumnFilterShape<Row>;
3922
+ /** The column's `type`, from `ColumnValueOptions` — what values are keyed by. */
3923
+ readonly columnType?: ColumnType | undefined;
3924
+ }
3925
+ /** A draft on its checklist: the values `draftToFilter` writes as an `in` entry. */
3926
+ interface ValuesDraft<Row> extends FilterEditorDraftBase<Row> {
3927
+ readonly kind: "values";
3924
3928
  /** The checked values, keyed as an `in` filter on the column keys them. */
3925
3929
  readonly checked: ReadonlyMap<string, FilterScalar>;
3926
3930
  readonly includeBlanks: boolean;
3931
+ }
3932
+ /** A draft on its conditions: the operator entries `draftToFilter` writes. */
3933
+ interface ConditionsDraft<Row> extends FilterEditorDraftBase<Row> {
3934
+ readonly kind: "conditions";
3927
3935
  readonly conditions: readonly OperatorFilterEntry<Row>[];
3928
3936
  readonly combinator: "and" | "or";
3929
- /** The column's `type`, from `ColumnValueOptions` — what values are keyed by. */
3930
- readonly columnType?: ColumnType | undefined;
3931
3937
  }
3938
+ /**
3939
+ * A checklist or condition editor's working copy of one column's filter,
3940
+ * changed by `filterEditorReducer` and turned into a filter by
3941
+ * `draftToFilter` only when the user applies it — so cancelling is just
3942
+ * dropping the draft. It is on one arm at a time, the one `draftToFilter`
3943
+ * applies: the last one changed.
3944
+ */
3945
+ type FilterEditorDraft<Row> = ValuesDraft<Row> | ConditionsDraft<Row>;
3932
3946
  type FilterEditorAction<Row> = {
3933
3947
  readonly type: "search";
3934
3948
  readonly search: string;
@@ -3945,10 +3959,16 @@ type FilterEditorAction<Row> = {
3945
3959
  } | {
3946
3960
  readonly type: "setConditions";
3947
3961
  readonly conditions: readonly OperatorFilterEntry<Row>[];
3948
- /** Keeps the draft's own when omitted. */
3962
+ /**
3963
+ * Keeps the draft's own when omitted; a checklist draft's is the opened
3964
+ * filter's, or `"and"`.
3965
+ */
3949
3966
  readonly combinator?: "and" | "or";
3950
3967
  }
3951
- /** Back to "no filter": every value checked, no conditions, no search. */
3968
+ /**
3969
+ * Back to "no filter" on the draft's own arm — every value checked, or no
3970
+ * conditions — and no search.
3971
+ */
3952
3972
  | {
3953
3973
  readonly type: "clear";
3954
3974
  };
@@ -3986,11 +4006,24 @@ declare function isColumnFiltered<Row>(filter: FilterState<Row>, columnId: strin
3986
4006
  declare function columnValueOptions<Row>(rows: readonly Row[], dataColumns: readonly DataColumn<Row, unknown>[], filter: FilterState<Row>, columnId: string, query?: ColumnValueQuery): ColumnValueOptions;
3987
4007
  /**
3988
4008
  * A draft showing `shape` over `values` — what an editor opens with. A
3989
- * column with no filter, or one only a custom editor could show, opens with
3990
- * every value checked; a checklist with its own values checked, kept even
3991
- * when the other filters now hide them; conditions as they are.
4009
+ * column filtered by conditions opens on them as they are. Anything else
4010
+ * opens on the checklist: with no filter, or one only a custom editor could
4011
+ * show, every value checked; a checklist with its own values checked, kept
4012
+ * even when the other filters now hide them.
3992
4013
  */
3993
4014
  declare function initialFilterEditorDraft<Row>(shape: ColumnFilterShape<Row>, values: ColumnValueOptions): FilterEditorDraft<Row>;
4015
+ /**
4016
+ * `draft` on its checklist: itself when it is there, otherwise the checklist
4017
+ * the filter it opened on shows, its conditions dropped. What a value action
4018
+ * starts from, and what a checklist draws over a draft on its conditions.
4019
+ */
4020
+ declare function toValuesDraft<Row>(draft: FilterEditorDraft<Row>): ValuesDraft<Row>;
4021
+ /**
4022
+ * `draft` on its conditions: itself when it is there, otherwise the
4023
+ * conditions the filter it opened on holds (none unless it was conditions),
4024
+ * its checklist dropped. What `setConditions` starts from.
4025
+ */
4026
+ declare function toConditionsDraft<Row>(draft: FilterEditorDraft<Row>): ConditionsDraft<Row>;
3994
4027
  /** The options the draft's search shows — those a select-all acts on. */
3995
4028
  declare function visibleFilterOptions<Row>(draft: FilterEditorDraft<Row>): readonly ColumnValueOption[];
3996
4029
  /**
@@ -3998,12 +4031,14 @@ declare function visibleFilterOptions<Row>(draft: FilterEditorDraft<Row>): reado
3998
4031
  * checked, none is, or some are — blanks included while nothing is
3999
4032
  * searched.
4000
4033
  */
4001
- declare function selectAllState<Row>(draft: FilterEditorDraft<Row>): SelectAllState;
4034
+ declare function selectAllState<Row>(draft: ValuesDraft<Row>): SelectAllState;
4002
4035
  /**
4003
4036
  * The next draft after `action` — a plain reducer, so a renderer can hold
4004
4037
  * the draft in whatever state it has (`useReducer`, a signal, a store).
4005
- * Changing a value or the blanks switches the draft to its checklist;
4006
- * setting conditions switches it to them.
4038
+ * Changing a value or the blanks puts the draft on its checklist; setting
4039
+ * conditions puts it on its conditions. An action for the arm the draft
4040
+ * is not on starts that arm as the filter the editor opened on shows it
4041
+ * (`toValuesDraft`, `toConditionsDraft`), dropping what the other arm held.
4007
4042
  */
4008
4043
  declare function filterEditorReducer<Row>(draft: FilterEditorDraft<Row>, action: FilterEditorAction<Row>): FilterEditorDraft<Row>;
4009
4044
  /**
@@ -4025,12 +4060,13 @@ declare function draftToFilter<Row>(draft: FilterEditorDraft<Row>, columnId: str
4025
4060
  * a value unchecked and checked again, or the same conditions typed again,
4026
4061
  * is no change; the search never is one.
4027
4062
  *
4028
- * Only the half `draftToFilter` applies counts. A checklist changes when its
4029
- * checked values or blanks differ from those it opened with, so one left as
4030
- * it opened over conditions or a custom filter leaves that filter be.
4031
- * Conditions change when they differ from those the draft opened with, and
4032
- * always when it opened on a checklist, no filter or a custom one: setting
4033
- * conditions there replaces it, none removing it.
4063
+ * Only the arm `draft` is on counts. A checklist changes when its checked
4064
+ * values or blanks differ from those `opened` shows (`toValuesDraft`), so
4065
+ * one left as it opened over conditions or a custom filter leaves that
4066
+ * filter be. Conditions change when they differ from those `opened` holds,
4067
+ * and always when `opened` is on its checklist (it opened on a checklist,
4068
+ * no filter or a custom one): setting conditions there replaces it, none
4069
+ * removing it.
4034
4070
  *
4035
4071
  * `clear` over a custom filter leaves a draft equal to the one it opened
4036
4072
  * with, so this reads it as no change.
@@ -4258,7 +4294,7 @@ interface FilterChecklist {
4258
4294
  /**
4259
4295
  * The list a checklist editor draws for `draft`: the window of values its
4260
4296
  * search shows, as items carrying what each row says and whether it is
4261
- * checked.
4297
+ * checked. A draft on its conditions draws through `toValuesDraft`.
4262
4298
  *
4263
4299
  * A column can hold far more values than a list is worth scrolling, so the
4264
4300
  * list shows at most `valueLimit` of them. Past that, it shows nothing until
@@ -4271,7 +4307,7 @@ interface FilterChecklist {
4271
4307
  * searched: exactly when select-all counts the blanks, so the checkbox acts
4272
4308
  * on what the list shows.
4273
4309
  */
4274
- declare function filterChecklist<Row>(draft: FilterEditorDraft<Row>, { valueLimit, blanksLabel }: FilterChecklistOptions): FilterChecklist;
4310
+ declare function filterChecklist<Row>(draft: ValuesDraft<Row>, { valueLimit, blanksLabel }: FilterChecklistOptions): FilterChecklist;
4275
4311
 
4276
4312
  /**
4277
4313
  * One entry per row: its measured height once known, `undefined` until then.
@@ -4380,4 +4416,4 @@ declare const excelFilter: {
4380
4416
  };
4381
4417
  };
4382
4418
 
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 };
4419
+ 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 ConditionsDraft, 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 FilterEditorDraftBase, 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 ValuesDraft, 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, toConditionsDraft, toCsv, toHtmlTable, toJson, toTsv, toValuesDraft, toggleCellSelection, toggleColumnSort, toggleGroupExpansion, toggleSelection, toolbarEntries, totalColumnWidth, typeaheadIndex, visibleFilterOptions, visibleRange, withGroupAggregates };
package/dist/index.js CHANGED
@@ -3531,38 +3531,53 @@ function everyOption(draft) {
3531
3531
  draft.options.map((option) => [keyOf2(draft, option.value), option.value])
3532
3532
  );
3533
3533
  }
3534
+ function baseOf(draft) {
3535
+ const { options, blanks, search, openedShape, columnType } = draft;
3536
+ return { options, blanks, search, openedShape, columnType };
3537
+ }
3538
+ function openedValues(base) {
3539
+ const shape = base.openedShape;
3540
+ if (shape.kind !== "values") {
3541
+ return {
3542
+ kind: "values",
3543
+ ...base,
3544
+ checked: everyOption(base),
3545
+ includeBlanks: base.blanks > 0
3546
+ };
3547
+ }
3548
+ return {
3549
+ kind: "values",
3550
+ ...base,
3551
+ checked: new Map(
3552
+ shape.values.filter((value) => !isEmptyCell(value)).map((value) => [keyOf2(base, value), value])
3553
+ ),
3554
+ includeBlanks: shape.includeBlanks
3555
+ };
3556
+ }
3557
+ function openedConditions(base) {
3558
+ const shape = base.openedShape;
3559
+ return shape.kind === "conditions" ? {
3560
+ kind: "conditions",
3561
+ ...base,
3562
+ conditions: shape.conditions,
3563
+ combinator: shape.combinator
3564
+ } : { kind: "conditions", ...base, conditions: [], combinator: "and" };
3565
+ }
3534
3566
  function initialFilterEditorDraft(shape, values) {
3535
- const draft = {
3536
- mode: "values",
3567
+ const base = {
3537
3568
  options: values.options,
3538
3569
  blanks: values.blanks,
3539
3570
  search: "",
3540
- checked: everyOption(values),
3541
- includeBlanks: values.blanks > 0,
3542
- conditions: [],
3543
- combinator: "and",
3571
+ openedShape: shape,
3544
3572
  columnType: values.columnType
3545
3573
  };
3546
- switch (shape.kind) {
3547
- case "values":
3548
- return {
3549
- ...draft,
3550
- checked: new Map(
3551
- shape.values.filter((value) => !isEmptyCell(value)).map((value) => [keyOf2(draft, value), value])
3552
- ),
3553
- includeBlanks: shape.includeBlanks
3554
- };
3555
- case "conditions":
3556
- return {
3557
- ...draft,
3558
- mode: "conditions",
3559
- conditions: shape.conditions,
3560
- combinator: shape.combinator
3561
- };
3562
- case "none":
3563
- case "custom":
3564
- return draft;
3565
- }
3574
+ return shape.kind === "conditions" ? openedConditions(base) : openedValues(base);
3575
+ }
3576
+ function toValuesDraft(draft) {
3577
+ return draft.kind === "values" ? draft : openedValues(baseOf(draft));
3578
+ }
3579
+ function toConditionsDraft(draft) {
3580
+ return draft.kind === "conditions" ? draft : openedConditions(baseOf(draft));
3566
3581
  }
3567
3582
  function visibleFilterOptions(draft) {
3568
3583
  return draft.search === "" ? draft.options : draft.options.filter(
@@ -3584,6 +3599,16 @@ function selectAllState(draft) {
3584
3599
  }
3585
3600
  return states.some(Boolean) ? "mixed" : "unchecked";
3586
3601
  }
3602
+ function toggleValue(draft, value) {
3603
+ const key = keyOf2(draft, value);
3604
+ const checked = new Map(draft.checked);
3605
+ if (checked.has(key)) {
3606
+ checked.delete(key);
3607
+ } else {
3608
+ checked.set(key, value);
3609
+ }
3610
+ return { ...draft, checked };
3611
+ }
3587
3612
  function toggleAll(draft) {
3588
3613
  const check = selectAllState(draft) !== "checked";
3589
3614
  const checked = new Map(draft.checked);
@@ -3597,44 +3622,43 @@ function toggleAll(draft) {
3597
3622
  }
3598
3623
  return {
3599
3624
  ...draft,
3600
- mode: "values",
3601
3625
  checked,
3602
3626
  includeBlanks: selectAllCoversBlanks(draft) ? check : draft.includeBlanks
3603
3627
  };
3604
3628
  }
3629
+ function cleared(draft) {
3630
+ switch (draft.kind) {
3631
+ case "values":
3632
+ return {
3633
+ ...draft,
3634
+ search: "",
3635
+ checked: everyOption(draft),
3636
+ includeBlanks: draft.blanks > 0
3637
+ };
3638
+ case "conditions":
3639
+ return { ...draft, search: "", conditions: [] };
3640
+ }
3641
+ }
3605
3642
  function filterEditorReducer(draft, action) {
3606
3643
  switch (action.type) {
3607
3644
  case "search":
3608
3645
  return { ...draft, search: action.search };
3609
- case "toggleValue": {
3610
- const key = keyOf2(draft, action.value);
3611
- const checked = new Map(draft.checked);
3612
- if (checked.has(key)) {
3613
- checked.delete(key);
3614
- } else {
3615
- checked.set(key, action.value);
3616
- }
3617
- return { ...draft, mode: "values", checked };
3618
- }
3646
+ case "toggleValue":
3647
+ return toggleValue(toValuesDraft(draft), action.value);
3619
3648
  case "toggleAll":
3620
- return toggleAll(draft);
3649
+ return toggleAll(toValuesDraft(draft));
3621
3650
  case "setIncludeBlanks":
3622
- return { ...draft, mode: "values", includeBlanks: action.includeBlanks };
3623
- case "setConditions":
3651
+ return { ...toValuesDraft(draft), includeBlanks: action.includeBlanks };
3652
+ case "setConditions": {
3653
+ const conditions = toConditionsDraft(draft);
3624
3654
  return {
3625
- ...draft,
3626
- mode: "conditions",
3655
+ ...conditions,
3627
3656
  conditions: action.conditions,
3628
- combinator: action.combinator ?? draft.combinator
3657
+ combinator: action.combinator ?? conditions.combinator
3629
3658
  };
3659
+ }
3630
3660
  case "clear":
3631
- return {
3632
- ...draft,
3633
- search: "",
3634
- checked: everyOption(draft),
3635
- includeBlanks: draft.blanks > 0,
3636
- conditions: []
3637
- };
3661
+ return cleared(draft);
3638
3662
  }
3639
3663
  }
3640
3664
  function checksEverything(draft) {
@@ -3642,14 +3666,7 @@ function checksEverything(draft) {
3642
3666
  (option) => draft.checked.has(keyOf2(draft, option.value))
3643
3667
  ) && (draft.includeBlanks || draft.blanks === 0);
3644
3668
  }
3645
- function draftEntries(draft, columnId) {
3646
- if (draft.mode === "conditions") {
3647
- const conditions = draft.conditions.map((condition) => ({
3648
- ...condition,
3649
- columnId
3650
- }));
3651
- return conditions.length > 1 ? [{ kind: "group", combinator: draft.combinator, entries: conditions }] : conditions;
3652
- }
3669
+ function valuesEntries(draft, columnId) {
3653
3670
  if (checksEverything(draft)) {
3654
3671
  return [];
3655
3672
  }
@@ -3670,6 +3687,21 @@ function draftEntries(draft, columnId) {
3670
3687
  }
3671
3688
  ] : [picked];
3672
3689
  }
3690
+ function conditionsEntries(draft, columnId) {
3691
+ const conditions = draft.conditions.map((condition) => ({
3692
+ ...condition,
3693
+ columnId
3694
+ }));
3695
+ return conditions.length > 1 ? [{ kind: "group", combinator: draft.combinator, entries: conditions }] : conditions;
3696
+ }
3697
+ function draftEntries(draft, columnId) {
3698
+ switch (draft.kind) {
3699
+ case "values":
3700
+ return valuesEntries(draft, columnId);
3701
+ case "conditions":
3702
+ return conditionsEntries(draft, columnId);
3703
+ }
3704
+ }
3673
3705
  function draftToFilter(draft, columnId, current) {
3674
3706
  const replacement = draftEntries(draft, columnId);
3675
3707
  const first = current.findIndex((entry) => touchesColumn(entry, columnId));
@@ -3695,10 +3727,12 @@ function sameConditions(a, b) {
3695
3727
  });
3696
3728
  }
3697
3729
  function filterDraftChanged(opened, draft) {
3698
- if (draft.mode === "values") {
3699
- return !sameValues(opened, draft);
3730
+ switch (draft.kind) {
3731
+ case "values":
3732
+ return !sameValues(toValuesDraft(opened), draft);
3733
+ case "conditions":
3734
+ return opened.kind !== "conditions" || !sameConditions(opened, draft);
3700
3735
  }
3701
- return opened.mode !== "conditions" || !sameConditions(opened, draft);
3702
3736
  }
3703
3737
 
3704
3738
  // src/commands/builtInCommands.ts
@@ -4977,10 +5011,12 @@ export {
4977
5011
  sortPriorityFor,
4978
5012
  sortRows,
4979
5013
  splitToolbarItems,
5014
+ toConditionsDraft,
4980
5015
  toCsv,
4981
5016
  toHtmlTable,
4982
5017
  toJson,
4983
5018
  toTsv,
5019
+ toValuesDraft,
4984
5020
  toggleCellSelection,
4985
5021
  toggleColumnSort,
4986
5022
  toggleGroupExpansion,