@univerjs/sheets-filter-ui 0.2.7 → 0.2.9

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.
Files changed (31) hide show
  1. package/lib/cjs/index.js +2 -2
  2. package/lib/es/index.js +92 -66
  3. package/lib/types/__testing__/data.d.ts +0 -1
  4. package/lib/types/commands/commands/sheets-filter.command.d.ts +42 -10
  5. package/lib/types/commands/operations/sheets-filter.operation.d.ts +0 -1
  6. package/lib/types/controllers/sheets-filter-permission.controller.d.ts +0 -1
  7. package/lib/types/controllers/{sheets-filter-ui.controller.d.ts → sheets-filter-ui-desktop.controller.d.ts} +2 -3
  8. package/lib/types/controllers/{sheets-filter-mobile-ui.controller.d.ts → sheets-filter-ui-mobile.controller.d.ts} +1 -2
  9. package/lib/types/controllers/sheets-filter.menu.d.ts +0 -1
  10. package/lib/types/controllers/sheets-filter.shortcut.d.ts +0 -1
  11. package/lib/types/{plugin.d.ts → filter-ui-desktop.plugin.d.ts} +6 -2
  12. package/lib/types/{mobile-plugin.d.ts → filter-ui-mobile.plugin.d.ts} +3 -2
  13. package/lib/types/index.d.ts +3 -3
  14. package/lib/types/locale/en-US.d.ts +0 -1
  15. package/lib/types/locale/ru-RU.d.ts +0 -1
  16. package/lib/types/locale/vi-VN.d.ts +0 -1
  17. package/lib/types/locale/zh-TW.d.ts +0 -1
  18. package/lib/types/models/conditions.d.ts +0 -1
  19. package/lib/types/models/utils.d.ts +0 -1
  20. package/lib/types/services/sheets-filter-panel.service.d.ts +0 -1
  21. package/lib/types/views/components/SheetsFilterByConditionsPanel.d.ts +0 -1
  22. package/lib/types/views/components/SheetsFilterByValuesPanel.d.ts +0 -1
  23. package/lib/types/views/components/SheetsFilterPanel.d.ts +0 -1
  24. package/lib/types/views/components/SheetsFilterPanel.stories.d.ts +0 -1
  25. package/lib/types/views/widgets/drawings.d.ts +0 -1
  26. package/lib/types/views/widgets/filter-button.shape.d.ts +0 -1
  27. package/lib/types/{controllers/sheets-filter-render.controller.d.ts → views/widgets/render-modules/sheets-filter.render-controller.d.ts} +0 -1
  28. package/lib/types/worker/generate-filter-values.service.d.ts +0 -1
  29. package/lib/types/worker/plugin.d.ts +1 -2
  30. package/lib/umd/index.js +2 -2
  31. package/package.json +20 -21
package/lib/es/index.js CHANGED
@@ -2,15 +2,15 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { CommandType, IUniverInstanceService, ICommandService, IUndoRedoService, UniverInstanceType, Quantity, LocaleService, sequenceExecute, BooleanNumber, createIdentifier, Disposable, Inject, extractPureTextFromCell, ILogService, Injector, IContextService, useDependency, ThemeService, RxDisposable, fromCallback, runOnLifecycle, LifecycleStages, OnLifecycle, Tools, Plugin, DependentOn, Optional } from "@univerjs/core";
6
- import { SheetsFilterService, RemoveSheetsFilterMutation, SetSheetsFilterRangeMutation, SetSheetsFilterCriteriaMutation, ReCalcSheetsFilterMutation, CustomFilterOperator, FILTER_MUTATIONS, UniverSheetsFilterPlugin } from "@univerjs/sheets-filter";
5
+ import { CommandType, ICommandService, IUndoRedoService, IUniverInstanceService, Quantity, LocaleService, UniverInstanceType, sequenceExecute, BooleanNumber, createIdentifier, Disposable, Inject, extractPureTextFromCell, ILogService, Injector, IContextService, useDependency, ThemeService, RxDisposable, fromCallback, Tools, Plugin, DependentOn, Optional } from "@univerjs/core";
6
+ import { SheetsFilterService, SetSheetsFilterRangeMutation, RemoveSheetsFilterMutation, SetSheetsFilterCriteriaMutation, ReCalcSheetsFilterMutation, CustomFilterOperator, FILTER_MUTATIONS, UniverSheetsFilterPlugin } from "@univerjs/sheets-filter";
7
7
  import { toModule, IRPCChannelService, fromModule } from "@univerjs/rpc";
8
8
  import { IMessageService, ILayoutService, useObservable, useComponentsOfPart, ComponentContainer, KeyCode, MetaKeys, MenuGroup, MenuItemType, MenuPosition, getMenuHiddenObservable, ComponentManager, IShortcutService, IMenuService } from "@univerjs/ui";
9
9
  import { BehaviorSubject, ReplaySubject, of, Subject, merge, combineLatest, throttleTime, startWith, map, shareReplay, switchMap, filter, takeUntil, distinctUntilChanged } from "rxjs";
10
10
  import { SetCellEditVisibleOperation, SheetsUIPart, whenSheetEditorFocused, getCurrentRangeDisable$, SelectionShape, getCoordByCell, SheetSkeletonManagerService, SheetsRenderService, ISheetSelectionRenderService, SheetCanvasPopManagerService, SheetPermissionInterceptorBaseController } from "@univerjs/sheets-ui";
11
11
  import { Rect, Shape, IRenderManagerService } from "@univerjs/engine-render";
12
12
  import { MessageType, Select, RadioGroup, Radio, Input, Checkbox, Tooltip, Button, Segmented } from "@univerjs/design";
13
- import { SheetsSelectionsService, isSingleCellSelection, expandToContinuousRange, RefRangeService, WorkbookEditablePermission, WorksheetFilterPermission, WorksheetEditPermission, RangeProtectionPermissionEditPoint, INTERCEPTOR_POINT, SheetInterceptorService, RangeProtectionPermissionViewPoint } from "@univerjs/sheets";
13
+ import { getSheetCommandTarget, SheetsSelectionsService, isSingleCellSelection, expandToContinuousRange, RefRangeService, WorkbookEditablePermission, WorksheetFilterPermission, WorksheetEditPermission, RangeProtectionPermissionEditPoint, INTERCEPTOR_POINT, SheetInterceptorService, RangeProtectionPermissionViewPoint } from "@univerjs/sheets";
14
14
  import * as React from "react";
15
15
  import React__default, { forwardRef, useRef, createElement, useCallback, useMemo as useMemo$1, version, isValidElement, useEffect, useState } from "react";
16
16
  import ReactDOM, { flushSync } from "react-dom";
@@ -69,45 +69,64 @@ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width:
69
69
  }));
70
70
  });
71
71
  FilterSingle.displayName = "FilterSingle";
72
- const SmartToggleSheetsFilterCommand = {
73
- id: "sheet.command.smart-toggle-filter",
72
+ const SetSheetFilterRangeCommand = {
73
+ id: "sheet.command.set-filter-range",
74
74
  type: CommandType.COMMAND,
75
- handler: /* @__PURE__ */ __name(async (accessor) => {
76
- const univerInstanceService = accessor.get(IUniverInstanceService), sheetsFilterService = accessor.get(SheetsFilterService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), currentWorkbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), currentWorksheet = currentWorkbook == null ? void 0 : currentWorkbook.getActiveSheet();
77
- if (!currentWorksheet || !currentWorkbook) return !1;
78
- const unitId = currentWorkbook.getUnitId(), subUnitId = currentWorksheet.getSheetId(), filterModel = sheetsFilterService.getFilterModel(unitId, subUnitId);
79
- if (filterModel) {
80
- const autoFilter = filterModel == null ? void 0 : filterModel.serialize(), undoMutations = destructFilterModel(unitId, subUnitId, autoFilter), result2 = commandService.syncExecuteCommand(RemoveSheetsFilterMutation.id, { unitId, subUnitId });
81
- return result2 && undoRedoService.pushUndoRedo({
82
- unitID: unitId,
83
- undoMutations,
84
- redoMutations: [{ id: RemoveSheetsFilterMutation.id, params: { unitId, subUnitId } }]
85
- }), result2;
86
- }
87
- const lastSelection = accessor.get(SheetsSelectionsService).getCurrentLastSelection();
88
- if (!lastSelection) return !1;
89
- const startRange = lastSelection.range, targetFilterRange = isSingleCellSelection(lastSelection) ? expandToContinuousRange(startRange, { left: !0, right: !0, up: !0, down: !0 }, currentWorksheet) : startRange;
90
- if (targetFilterRange.endRow === targetFilterRange.startRow) {
75
+ handler: /* @__PURE__ */ __name((accessor, params) => {
76
+ const sheetsFilterService = accessor.get(SheetsFilterService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), instanceSrv = accessor.get(IUniverInstanceService), { unitId, subUnitId, range } = params;
77
+ if (!getSheetCommandTarget(instanceSrv, params) || sheetsFilterService.getFilterModel(unitId, subUnitId)) return !1;
78
+ if (range.endRow === range.startRow) {
91
79
  const messageService = accessor.get(IMessageService, Quantity.OPTIONAL), localeService = accessor.get(LocaleService);
92
80
  return messageService == null || messageService.show({ type: MessageType.Warning, content: localeService.t("sheets-filter.command.not-valid-filter-range") }), !1;
93
81
  }
94
- const redoMutation = { id: SetSheetsFilterRangeMutation.id, params: { unitId, subUnitId, range: targetFilterRange } }, result = commandService.syncExecuteCommand(redoMutation.id, redoMutation.params);
82
+ const redoMutation = { id: SetSheetsFilterRangeMutation.id, params: { unitId, subUnitId, range } }, result = commandService.syncExecuteCommand(redoMutation.id, redoMutation.params);
95
83
  return result && undoRedoService.pushUndoRedo({
96
84
  unitID: unitId,
97
85
  undoMutations: [{ id: RemoveSheetsFilterMutation.id, params: { unitId, subUnitId } }],
98
86
  redoMutations: [redoMutation]
99
87
  }), result;
100
88
  }, "handler")
89
+ }, RemoveSheetFilterCommand = {
90
+ id: "sheet.command.remove-sheet-filter",
91
+ type: CommandType.COMMAND,
92
+ handler: /* @__PURE__ */ __name((accessor, params) => {
93
+ const univerInstanceService = accessor.get(IUniverInstanceService), sheetsFilterService = accessor.get(SheetsFilterService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), commandTarget = getSheetCommandTarget(univerInstanceService, params);
94
+ if (!commandTarget) return !1;
95
+ const { unitId, subUnitId } = commandTarget, filterModel = sheetsFilterService.getFilterModel(unitId, subUnitId);
96
+ if (!filterModel) return !1;
97
+ const autoFilter = filterModel == null ? void 0 : filterModel.serialize(), undoMutations = destructFilterModel(unitId, subUnitId, autoFilter), result = commandService.syncExecuteCommand(RemoveSheetsFilterMutation.id, { unitId, subUnitId });
98
+ return result && undoRedoService.pushUndoRedo({
99
+ unitID: unitId,
100
+ undoMutations,
101
+ redoMutations: [{ id: RemoveSheetsFilterMutation.id, params: { unitId, subUnitId } }]
102
+ }), result;
103
+ }, "handler")
104
+ }, SmartToggleSheetsFilterCommand = {
105
+ id: "sheet.command.smart-toggle-filter",
106
+ type: CommandType.COMMAND,
107
+ handler: /* @__PURE__ */ __name(async (accessor) => {
108
+ const univerInstanceService = accessor.get(IUniverInstanceService), sheetsFilterService = accessor.get(SheetsFilterService), commandService = accessor.get(ICommandService), currentWorkbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), currentWorksheet = currentWorkbook == null ? void 0 : currentWorkbook.getActiveSheet();
109
+ if (!currentWorksheet || !currentWorkbook) return !1;
110
+ const unitId = currentWorkbook.getUnitId(), subUnitId = currentWorksheet.getSheetId();
111
+ if (sheetsFilterService.getFilterModel(unitId, subUnitId))
112
+ return commandService.executeCommand(RemoveSheetFilterCommand.id, { unitId, subUnitId });
113
+ const lastSelection = accessor.get(SheetsSelectionsService).getCurrentLastSelection();
114
+ if (!lastSelection) return !1;
115
+ const startRange = lastSelection.range, targetFilterRange = isSingleCellSelection(lastSelection) ? expandToContinuousRange(startRange, { left: !0, right: !0, up: !0, down: !0 }, currentWorksheet) : startRange;
116
+ return commandService.executeCommand(SetSheetFilterRangeCommand.id, {
117
+ unitId,
118
+ subUnitId,
119
+ range: targetFilterRange
120
+ });
121
+ }, "handler")
101
122
  }, SetSheetsFilterCriteriaCommand = {
102
123
  id: "sheet.command.set-filter-criteria",
103
124
  type: CommandType.COMMAND,
104
125
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
105
126
  const sheetsFilterService = accessor.get(SheetsFilterService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), { unitId, subUnitId, col, criteria } = params, filterModel = sheetsFilterService.getFilterModel(unitId, subUnitId);
106
- if (!filterModel)
107
- return !1;
127
+ if (!filterModel) return !1;
108
128
  const range = filterModel.getRange();
109
- if (!range || col < range.startColumn || col > range.endColumn)
110
- return !1;
129
+ if (!range || col < range.startColumn || col > range.endColumn) return !1;
111
130
  const filterColumn = filterModel.getFilterColumn(col), undoMutation = destructFilterColumn(unitId, subUnitId, col, filterColumn), redoMutation = {
112
131
  id: SetSheetsFilterCriteriaMutation.id,
113
132
  params: {
@@ -126,26 +145,26 @@ const SmartToggleSheetsFilterCommand = {
126
145
  }, ClearSheetsFilterCriteriaCommand = {
127
146
  id: "sheet.command.clear-filter-criteria",
128
147
  type: CommandType.COMMAND,
129
- handler: /* @__PURE__ */ __name((accessor) => {
130
- const sheetsFilterService = accessor.get(SheetsFilterService), undoRedoService = accessor.get(IUndoRedoService), commandService = accessor.get(ICommandService), currentFilterModel = sheetsFilterService.activeFilterModel;
131
- if (!currentFilterModel)
132
- return !1;
133
- const { unitId, subUnitId } = currentFilterModel, autoFilter = currentFilterModel.serialize(), undoMutations = destructFilterCriteria(unitId, subUnitId, autoFilter), redoMutations = generateRemoveCriteriaMutations(unitId, subUnitId, autoFilter);
134
- return sequenceExecute(redoMutations, commandService) && undoRedoService.pushUndoRedo({
148
+ handler: /* @__PURE__ */ __name((accessor, params) => {
149
+ const sheetsFilterService = accessor.get(SheetsFilterService), undoRedoService = accessor.get(IUndoRedoService), commandService = accessor.get(ICommandService), instanceSrv = accessor.get(IUniverInstanceService), commandTarget = getSheetCommandTarget(instanceSrv, params);
150
+ if (!commandTarget) return !1;
151
+ const { unitId, subUnitId } = commandTarget, filterModel = sheetsFilterService.getFilterModel(commandTarget.unitId, commandTarget.subUnitId);
152
+ if (!filterModel) return !1;
153
+ const autoFilter = filterModel.serialize(), undoMutations = destructFilterCriteria(unitId, subUnitId, autoFilter), redoMutations = generateRemoveCriteriaMutations(unitId, subUnitId, autoFilter);
154
+ return sequenceExecute(redoMutations, commandService).result ? (undoRedoService.pushUndoRedo({
135
155
  unitID: unitId,
136
156
  undoMutations,
137
157
  redoMutations
138
- }), !0;
158
+ }), !0) : !1;
139
159
  }, "handler")
140
160
  }, ReCalcSheetsFilterCommand = {
141
161
  id: "sheet.command.re-calc-filter",
142
162
  type: CommandType.COMMAND,
143
- handler: /* @__PURE__ */ __name((accessor) => {
144
- const sheetsFilterService = accessor.get(SheetsFilterService), commandService = accessor.get(ICommandService), currentFilterModel = sheetsFilterService.activeFilterModel;
145
- if (!currentFilterModel)
146
- return !1;
147
- const { unitId, subUnitId } = currentFilterModel;
148
- return commandService.executeCommand(ReCalcSheetsFilterMutation.id, { unitId, subUnitId });
163
+ handler: /* @__PURE__ */ __name((accessor, params) => {
164
+ const sheetsFilterService = accessor.get(SheetsFilterService), commandService = accessor.get(ICommandService), instanceSrv = accessor.get(IUniverInstanceService), commandTarget = getSheetCommandTarget(instanceSrv, params);
165
+ if (!commandTarget) return !1;
166
+ const { unitId, subUnitId } = commandTarget;
167
+ return sheetsFilterService.getFilterModel(commandTarget.unitId, commandTarget.subUnitId) ? commandService.executeCommand(ReCalcSheetsFilterMutation.id, { unitId, subUnitId }) : !1;
149
168
  }, "handler")
150
169
  };
151
170
  function destructFilterModel(unitId, subUnitId, autoFilter) {
@@ -3136,18 +3155,17 @@ var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPrope
3136
3155
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
3137
3156
  return kind && result && __defProp$5(target, key, result), result;
3138
3157
  }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index2, decorator) => (target, key) => decorator(target, key, index2), "__decorateParam$5"), _a7;
3139
- let SheetsFilterMobileUIController = (_a7 = class extends RxDisposable {
3158
+ let SheetsFilterUIMobileController = (_a7 = class extends RxDisposable {
3140
3159
  constructor(_renderManagerService) {
3141
3160
  super(), this._renderManagerService = _renderManagerService, this._initRenderControllers();
3142
3161
  }
3143
3162
  _initRenderControllers() {
3144
3163
  this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SHEET, [SheetsFilterRenderController]));
3145
3164
  }
3146
- }, __name(_a7, "SheetsFilterMobileUIController"), _a7);
3147
- SheetsFilterMobileUIController = __decorateClass$5([
3165
+ }, __name(_a7, "SheetsFilterUIMobileController"), _a7);
3166
+ SheetsFilterUIMobileController = __decorateClass$5([
3148
3167
  __decorateParam$5(0, IRenderManagerService)
3149
- ], SheetsFilterMobileUIController);
3150
- runOnLifecycle(LifecycleStages.Rendered, SheetsFilterMobileUIController);
3168
+ ], SheetsFilterUIMobileController);
3151
3169
  var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3152
3170
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3153
3171
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
@@ -3155,7 +3173,7 @@ var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPrope
3155
3173
  }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index2, decorator) => (target, key) => decorator(target, key, index2), "__decorateParam$4");
3156
3174
  const DefaultSheetFilterUiConfig = {}, FILTER_PANEL_POPUP_KEY = "FILTER_PANEL_POPUP";
3157
3175
  var _a8;
3158
- let SheetsFilterUIController = (_a8 = class extends SheetsFilterMobileUIController {
3176
+ let SheetsFilterUIDesktopController = (_a8 = class extends SheetsFilterUIMobileController {
3159
3177
  constructor(_config, _injector, _componentManager, _sheetsFilterPanelService, _sheetCanvasPopupService, _sheetsFilterService, _localeService, _shortcutService, _commandService, _menuService, _contextService, _messageService, _renderManagerService) {
3160
3178
  super(_renderManagerService);
3161
3179
  __publicField(this, "_popupDisposable");
@@ -3174,6 +3192,8 @@ let SheetsFilterUIController = (_a8 = class extends SheetsFilterMobileUIControll
3174
3192
  _initCommands() {
3175
3193
  [
3176
3194
  SmartToggleSheetsFilterCommand,
3195
+ RemoveSheetFilterCommand,
3196
+ SetSheetFilterRangeCommand,
3177
3197
  SetSheetsFilterCriteriaCommand,
3178
3198
  ClearSheetsFilterCriteriaCommand,
3179
3199
  ReCalcSheetsFilterCommand,
@@ -3221,9 +3241,8 @@ let SheetsFilterUIController = (_a8 = class extends SheetsFilterMobileUIControll
3221
3241
  var _a13;
3222
3242
  (_a13 = this._popupDisposable) == null || _a13.dispose(), this._popupDisposable = null;
3223
3243
  }
3224
- }, __name(_a8, "SheetsFilterUIController"), _a8);
3225
- SheetsFilterUIController = __decorateClass$4([
3226
- OnLifecycle(LifecycleStages.Rendered, SheetsFilterUIController),
3244
+ }, __name(_a8, "SheetsFilterUIDesktopController"), _a8);
3245
+ SheetsFilterUIDesktopController = __decorateClass$4([
3227
3246
  __decorateParam$4(1, Inject(Injector)),
3228
3247
  __decorateParam$4(2, Inject(ComponentManager)),
3229
3248
  __decorateParam$4(3, Inject(SheetsFilterPanelService)),
@@ -3236,7 +3255,7 @@ SheetsFilterUIController = __decorateClass$4([
3236
3255
  __decorateParam$4(10, IContextService),
3237
3256
  __decorateParam$4(11, IMessageService),
3238
3257
  __decorateParam$4(12, IRenderManagerService)
3239
- ], SheetsFilterUIController);
3258
+ ], SheetsFilterUIDesktopController);
3240
3259
  var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3241
3260
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3242
3261
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
@@ -3267,7 +3286,6 @@ let SheetsFilterPermissionController = (_a9 = class extends Disposable {
3267
3286
  }
3268
3287
  }, __name(_a9, "SheetsFilterPermissionController"), _a9);
3269
3288
  SheetsFilterPermissionController = __decorateClass$3([
3270
- OnLifecycle(LifecycleStages.Ready, SheetsFilterPermissionController),
3271
3289
  __decorateParam$3(0, Inject(SheetsFilterService)),
3272
3290
  __decorateParam$3(1, Inject(LocaleService)),
3273
3291
  __decorateParam$3(2, ICommandService),
@@ -3288,20 +3306,20 @@ let UniverSheetsFilterUIPlugin = (_a10 = class extends Plugin {
3288
3306
  [
3289
3307
  [SheetsFilterPanelService],
3290
3308
  [SheetsFilterPermissionController],
3291
- [
3292
- SheetsFilterUIController,
3293
- {
3294
- useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(SheetsFilterUIController, this._config), "useFactory")
3295
- }
3296
- ]
3297
- ].forEach((d2) => this._injector.add(d2)), this._config.useRemoteFilterValuesGenerator && this._rpcChannelService && this._injector.add([
3298
- ISheetsGenerateFilterValuesService,
3299
- {
3300
- useFactory: /* @__PURE__ */ __name(() => toModule(
3301
- this._rpcChannelService.requestChannel(SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME)
3302
- ), "useFactory")
3303
- }
3304
- ]);
3309
+ [SheetsFilterUIDesktopController, {
3310
+ useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(SheetsFilterUIDesktopController, this._config), "useFactory")
3311
+ }]
3312
+ ].forEach((d2) => this._injector.add(d2)), this._config.useRemoteFilterValuesGenerator && this._rpcChannelService && this._injector.add([ISheetsGenerateFilterValuesService, {
3313
+ useFactory: /* @__PURE__ */ __name(() => toModule(
3314
+ this._rpcChannelService.requestChannel(SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME)
3315
+ ), "useFactory")
3316
+ }]);
3317
+ }
3318
+ onReady() {
3319
+ this._injector.get(SheetsFilterPermissionController);
3320
+ }
3321
+ onRendered() {
3322
+ this._injector.get(SheetsFilterUIDesktopController);
3305
3323
  }
3306
3324
  }, __name(_a10, "UniverSheetsFilterUIPlugin"), _a10);
3307
3325
  __publicField$1(UniverSheetsFilterUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
@@ -3325,9 +3343,15 @@ let UniverSheetsFilterMobileUIPlugin = (_a11 = class extends Plugin {
3325
3343
  onStarting() {
3326
3344
  [
3327
3345
  [SheetsFilterPermissionController],
3328
- [SheetsFilterMobileUIController]
3346
+ [SheetsFilterUIMobileController]
3329
3347
  ].forEach((d2) => this._injector.add(d2));
3330
3348
  }
3349
+ onReady() {
3350
+ this._injector.get(SheetsFilterPermissionController);
3351
+ }
3352
+ onRendered() {
3353
+ this._injector.get(SheetsFilterUIMobileController);
3354
+ }
3331
3355
  }, __name(_a11, "UniverSheetsFilterMobileUIPlugin"), _a11);
3332
3356
  __publicField2(UniverSheetsFilterMobileUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
3333
3357
  __publicField2(UniverSheetsFilterMobileUIPlugin, "pluginName", NAME);
@@ -3344,7 +3368,7 @@ let UniverSheetsFilterUIWorkerPlugin = (_a12 = class extends Plugin {
3344
3368
  constructor(_config, _injector, _rpcChannelService) {
3345
3369
  super(), this._config = _config, this._injector = _injector, this._rpcChannelService = _rpcChannelService;
3346
3370
  }
3347
- onStarting(_injector) {
3371
+ onStarting() {
3348
3372
  [
3349
3373
  [ISheetsGenerateFilterValuesService, { useClass: SheetsGenerateFilterValuesService }]
3350
3374
  ].forEach((d2) => this._injector.add(d2));
@@ -3366,6 +3390,8 @@ export {
3366
3390
  CloseFilterPanelOperation,
3367
3391
  OpenFilterPanelOperation,
3368
3392
  ReCalcSheetsFilterCommand,
3393
+ RemoveSheetFilterCommand,
3394
+ SetSheetFilterRangeCommand,
3369
3395
  SetSheetsFilterCriteriaCommand,
3370
3396
  SmartToggleSheetsFilterCommand,
3371
3397
  UniverSheetsFilterMobileUIPlugin,
@@ -1,5 +1,4 @@
1
1
  import { IWorkbookData } from '@univerjs/core';
2
-
3
2
  export declare function WithCustomFilterModelFactory(): IWorkbookData;
4
3
  export declare function WithValuesFilterModelFactory(): IWorkbookData;
5
4
  export declare function WithValuesAndEmptyFilterModelFactory(): IWorkbookData;
@@ -1,25 +1,57 @@
1
- import { ICommand, IMutationInfo, Nullable } from '@univerjs/core';
1
+ import { ICommand, IMutationInfo, IRange, Nullable } from '@univerjs/core';
2
2
  import { ISheetCommandSharedParams } from '@univerjs/sheets';
3
- import { IAutoFilter, IFilterColumn } from '@univerjs/sheets-filter';
4
-
3
+ import { IAutoFilter, IFilterColumn, ISetSheetsFilterCriteriaMutationParams } from '@univerjs/sheets-filter';
5
4
  /**
6
- * This command is for toggling filter in the currently active Worksheet.
5
+ * Parameters of command {@link SetSheetFilterRangeCommand}.
6
+ * @property {IRange} range - the range to be set as filter range.
7
+ */
8
+ export interface ISetSheetFilterRangeCommandParams extends ISheetCommandSharedParams {
9
+ range: IRange;
10
+ }
11
+ /**
12
+ * A {@link CommandType.COMMAND} to set filter range in a Worksheet. Its params {@link ISetSheetFilterRangeCommandParams}
13
+ * is required. If the {@link FilterModel} does not exist, it will be created.
14
+ */
15
+ export declare const SetSheetFilterRangeCommand: ICommand<ISetSheetFilterRangeCommandParams>;
16
+ /**
17
+ * A {@link CommandType.COMMAND} to remove filter in a Worksheet. Its params {@link ISheetCommandSharedParams} is
18
+ * required. If the {@link FilterModel} does not exist, it will fail to execute.
19
+ */
20
+ export declare const RemoveSheetFilterCommand: ICommand<ISheetCommandSharedParams>;
21
+ /**
22
+ * A {@link CommandType.COMMAND} to toggle filter in the current {@link Worksheet}.
7
23
  */
8
24
  export declare const SmartToggleSheetsFilterCommand: ICommand;
25
+ /**
26
+ * Parameters of command {@link SetSheetsFilterCriteriaCommand}.
27
+ * @property {number} col - the column index of the filter criteria
28
+ * @property {Nullable<IFilterColumn>} criteria - the filter criteria to be set
29
+ */
9
30
  export interface ISetSheetsFilterCriteriaCommandParams extends ISheetCommandSharedParams {
10
31
  col: number;
11
32
  criteria: Nullable<IFilterColumn>;
12
33
  }
13
34
  /**
14
- * This command is for setting filter criteria to a column in the targeting `FilterModel`.
35
+ * A {@link CommandType.COMMAND} to set filter criteria to a column in the targeting {@link FilterModel}. Its params
36
+ * {@link ISetSheetsFilterCriteriaCommandParams} is required.
15
37
  */
16
38
  export declare const SetSheetsFilterCriteriaCommand: ICommand<ISetSheetsFilterCriteriaCommandParams>;
17
39
  /**
18
- * This command is for clearing all filter criteria in the currently active `FilterModel`.
40
+ * A {@link CommandType.COMMAND} to clear all filter criteria in the targeting {@link FilterModel}. Its params
41
+ * {@link ISheetCommandSharedParams} is required.
42
+ */
43
+ export declare const ClearSheetsFilterCriteriaCommand: ICommand<ISheetCommandSharedParams>;
44
+ /**
45
+ * A {@link CommandType.COMMAND} forcing the currently active {@link FilterModel} to re-calculate all filter criteria.
46
+ * Its params {@link ISheetCommandSharedParams} is required.
19
47
  */
20
- export declare const ClearSheetsFilterCriteriaCommand: ICommand;
48
+ export declare const ReCalcSheetsFilterCommand: ICommand<ISheetCommandSharedParams>;
21
49
  /**
22
- * This command force the currently active `FilterModel` to re-calculate all filter criteria.
50
+ * Transform a {@link FilterModel} to a list of mutations to set the filter criteria.
51
+ * @param unitId - the unit id of the {@link Workbook}
52
+ * @param subUnitId - the sub unit id of the {@link Worksheet}
53
+ * @param autoFilter - the to be destructed {@link FilterModel}
54
+ * @returns {IMutationInfo<ISetSheetsFilterCriteriaMutationParams>} a list of mutations those can be used to
55
+ * reconstruct the {@link FilterModel}
23
56
  */
24
- export declare const ReCalcSheetsFilterCommand: ICommand;
25
- export declare function destructFilterCriteria(unitId: string, subUnitId: string, autoFilter: IAutoFilter): IMutationInfo[];
57
+ export declare function destructFilterCriteria(unitId: string, subUnitId: string, autoFilter: IAutoFilter): IMutationInfo<ISetSheetsFilterCriteriaMutationParams>[];
@@ -1,6 +1,5 @@
1
1
  import { IOperation } from '@univerjs/core';
2
2
  import { FilterBy } from '../../services/sheets-filter-panel.service';
3
-
4
3
  export declare const FILTER_PANEL_OPENED_KEY = "FILTER_PANEL_OPENED";
5
4
  export interface IOpenFilterPanelOperationParams {
6
5
  unitId: string;
@@ -2,7 +2,6 @@ import { Disposable, ICommandService, LocaleService } from '@univerjs/core';
2
2
  import { MenuConfig } from '@univerjs/ui';
3
3
  import { SheetPermissionInterceptorBaseController } from '@univerjs/sheets-ui';
4
4
  import { SheetsFilterService } from '@univerjs/sheets-filter';
5
-
6
5
  export interface IUniverSheetsFilterUIConfig {
7
6
  menu: MenuConfig;
8
7
  }
@@ -4,8 +4,7 @@ import { SheetCanvasPopManagerService } from '@univerjs/sheets-ui';
4
4
  import { IRenderManagerService } from '@univerjs/engine-render';
5
5
  import { SheetsFilterService } from '@univerjs/sheets-filter';
6
6
  import { SheetsFilterPanelService } from '../services/sheets-filter-panel.service';
7
- import { SheetsFilterMobileUIController } from './sheets-filter-mobile-ui.controller';
8
-
7
+ import { SheetsFilterUIMobileController } from './sheets-filter-ui-mobile.controller';
9
8
  export interface IUniverSheetsFilterUIConfig {
10
9
  menu: MenuConfig;
11
10
  useRemoteFilterValuesGenerator?: boolean;
@@ -15,7 +14,7 @@ export declare const FILTER_PANEL_POPUP_KEY = "FILTER_PANEL_POPUP";
15
14
  /**
16
15
  * This controller controls the UI of "filter" features. Menus, commands and filter panel etc. Except for the rendering.
17
16
  */
18
- export declare class SheetsFilterUIController extends SheetsFilterMobileUIController {
17
+ export declare class SheetsFilterUIDesktopController extends SheetsFilterUIMobileController {
19
18
  private readonly _config;
20
19
  private readonly _injector;
21
20
  private readonly _componentManager;
@@ -1,7 +1,6 @@
1
1
  import { RxDisposable } from '@univerjs/core';
2
2
  import { IRenderManagerService } from '@univerjs/engine-render';
3
-
4
- export declare class SheetsFilterMobileUIController extends RxDisposable {
3
+ export declare class SheetsFilterUIMobileController extends RxDisposable {
5
4
  private readonly _renderManagerService;
6
5
  constructor(_renderManagerService: IRenderManagerService);
7
6
  private _initRenderControllers;
@@ -1,6 +1,5 @@
1
1
  import { IMenuButtonItem, IMenuSelectorItem } from '@univerjs/ui';
2
2
  import { IAccessor } from '@univerjs/core';
3
-
4
3
  export declare function SmartToggleFilterMenuItemFactory(accessor: IAccessor): IMenuSelectorItem;
5
4
  export declare function ClearFilterCriteriaMenuItemFactory(accessor: IAccessor): IMenuButtonItem;
6
5
  export declare function ReCalcFilterMenuItemFactory(accessor: IAccessor): IMenuButtonItem;
@@ -1,3 +1,2 @@
1
1
  import { IShortcutItem } from '@univerjs/ui';
2
-
3
2
  export declare const SmartToggleFilterShortcut: IShortcutItem;
@@ -1,7 +1,9 @@
1
1
  import { Injector, Plugin, UniverInstanceType } from '@univerjs/core';
2
2
  import { IRPCChannelService } from '@univerjs/rpc';
3
- import { IUniverSheetsFilterUIConfig } from './controllers/sheets-filter-ui.controller';
4
-
3
+ import { IUniverSheetsFilterUIConfig } from './controllers/sheets-filter-ui-desktop.controller';
4
+ /**
5
+ * The plugin for the desktop version of the sheets filter UI. Its type is {@link UniverInstanceType.UNIVER_SHEET}.
6
+ */
5
7
  export declare class UniverSheetsFilterUIPlugin extends Plugin {
6
8
  private readonly _config;
7
9
  protected readonly _injector: Injector;
@@ -10,4 +12,6 @@ export declare class UniverSheetsFilterUIPlugin extends Plugin {
10
12
  static pluginName: string;
11
13
  constructor(_config: Partial<IUniverSheetsFilterUIConfig>, _injector: Injector, _rpcChannelService?: IRPCChannelService | undefined);
12
14
  onStarting(): void;
15
+ onReady(): void;
16
+ onRendered(): void;
13
17
  }
@@ -1,6 +1,5 @@
1
1
  import { Injector, Plugin, UniverInstanceType } from '@univerjs/core';
2
- import { IUniverSheetsFilterUIConfig } from './controllers/sheets-filter-ui.controller';
3
-
2
+ import { IUniverSheetsFilterUIConfig } from './controllers/sheets-filter-ui-desktop.controller';
4
3
  export declare class UniverSheetsFilterMobileUIPlugin extends Plugin {
5
4
  private readonly _config;
6
5
  protected readonly _injector: Injector;
@@ -8,4 +7,6 @@ export declare class UniverSheetsFilterMobileUIPlugin extends Plugin {
8
7
  static pluginName: string;
9
8
  constructor(_config: Partial<IUniverSheetsFilterUIConfig>, _injector: Injector);
10
9
  onStarting(): void;
10
+ onReady(): void;
11
+ onRendered(): void;
11
12
  }
@@ -13,8 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export { UniverSheetsFilterUIPlugin } from './plugin';
17
- export { UniverSheetsFilterMobileUIPlugin } from './mobile-plugin';
16
+ export { UniverSheetsFilterUIPlugin } from './filter-ui-desktop.plugin';
17
+ export { UniverSheetsFilterMobileUIPlugin } from './filter-ui-mobile.plugin';
18
18
  export { UniverSheetsFilterUIWorkerPlugin } from './worker/plugin';
19
- export { SmartToggleSheetsFilterCommand, SetSheetsFilterCriteriaCommand, ClearSheetsFilterCriteriaCommand, ReCalcSheetsFilterCommand, } from './commands/commands/sheets-filter.command';
19
+ export { SmartToggleSheetsFilterCommand, SetSheetsFilterCriteriaCommand, ClearSheetsFilterCriteriaCommand, SetSheetFilterRangeCommand, RemoveSheetFilterCommand, type ISetSheetFilterRangeCommandParams, ReCalcSheetsFilterCommand, type ISetSheetsFilterCriteriaCommandParams, } from './commands/commands/sheets-filter.command';
20
20
  export { OpenFilterPanelOperation, CloseFilterPanelOperation, ChangeFilterByOperation, type IOpenFilterPanelOperationParams, } from './commands/operations/sheets-filter.operation';
@@ -1,4 +1,3 @@
1
1
  import { default as zhCN } from './zh-CN';
2
-
3
2
  declare const locale: typeof zhCN;
4
3
  export default locale;
@@ -1,4 +1,3 @@
1
1
  import { default as zhCN } from './zh-CN';
2
-
3
2
  declare const locale: typeof zhCN;
4
3
  export default locale;
@@ -1,4 +1,3 @@
1
1
  import { default as zhCN } from './zh-CN';
2
-
3
2
  declare const locale: typeof zhCN;
4
3
  export default locale;
@@ -1,4 +1,3 @@
1
1
  import { default as zhCN } from './zh-CN';
2
-
3
2
  declare const locale: typeof zhCN;
4
3
  export default locale;
@@ -1,7 +1,6 @@
1
1
  import { Nullable } from '@univerjs/core';
2
2
  import { IFilterColumn, CustomFilterOperator } from '@univerjs/sheets-filter';
3
3
  import { ExtendCustomFilterOperator, OperatorOrder } from './extended-operators';
4
-
5
4
  export type FilterOperator = ExtendCustomFilterOperator | CustomFilterOperator;
6
5
  export interface IFilterConditionFormParams {
7
6
  and?: true;
@@ -1,5 +1,4 @@
1
1
  import { IFilterByValueItem } from '../services/sheets-filter-panel.service';
2
-
3
2
  export declare function statisticFilterByValueItems(items: IFilterByValueItem[]): {
4
3
  checked: number;
5
4
  unchecked: number;
@@ -3,7 +3,6 @@ import { FilterColumn, FilterModel } from '@univerjs/sheets-filter';
3
3
  import { Observable } from 'rxjs';
4
4
  import { RefRangeService } from '@univerjs/sheets';
5
5
  import { FilterOperator, IFilterConditionFormParams, IFilterConditionItem } from '../models/conditions';
6
-
7
6
  export declare enum FilterBy {
8
7
  VALUES = 0,
9
8
  CONDITIONS = 1
@@ -1,6 +1,5 @@
1
1
  import { default as React } from 'react';
2
2
  import { ByConditionsModel } from '../../services/sheets-filter-panel.service';
3
-
4
3
  /**
5
4
  * Filter by conditions.
6
5
  */
@@ -1,6 +1,5 @@
1
1
  import { default as React } from 'react';
2
2
  import { ByValuesModel } from '../../services/sheets-filter-panel.service';
3
-
4
3
  /**
5
4
  * Filter by values.
6
5
  */
@@ -1,5 +1,4 @@
1
1
  import { default as React } from 'react';
2
-
3
2
  /**
4
3
  * This Filter Panel component is used to filter the data in the sheet.
5
4
  *
@@ -1,7 +1,6 @@
1
1
  import { default as React } from 'react';
2
2
  import { Meta } from '@storybook/react';
3
3
  import { FilterPanel } from './SheetsFilterPanel';
4
-
5
4
  declare const meta: Meta<typeof FilterPanel>;
6
5
  export default meta;
7
6
  export declare const FilterWithConditions: {
@@ -1,5 +1,4 @@
1
1
  import { UniverRenderingContext2D } from '@univerjs/engine-render';
2
-
3
2
  export declare const FILTER_BUTTON_EMPTY: Path2D;
4
3
  export declare class FilterButton {
5
4
  static drawNoCriteria(ctx: UniverRenderingContext2D, size: number, fgColor: string, bgColor: string): void;
@@ -1,6 +1,5 @@
1
1
  import { ICommandService, IContextService, ThemeService } from '@univerjs/core';
2
2
  import { IMouseEvent, IPointerEvent, IShapeProps, Shape, UniverRenderingContext2D } from '@univerjs/engine-render';
3
-
4
3
  export declare const FILTER_ICON_SIZE = 16;
5
4
  export declare const FILTER_ICON_PADDING = 1;
6
5
  export interface ISheetsFilterButtonShapeProps extends IShapeProps {
@@ -3,7 +3,6 @@ import { IRenderContext, IRenderModule, IRenderManagerService } from '@univerjs/
3
3
  import { SheetInterceptorService } from '@univerjs/sheets';
4
4
  import { SheetsFilterService } from '@univerjs/sheets-filter';
5
5
  import { ISheetSelectionRenderService, SheetSkeletonManagerService, SheetsRenderService } from '@univerjs/sheets-ui';
6
-
7
6
  export declare class SheetsFilterRenderController extends RxDisposable implements IRenderModule {
8
7
  private readonly _context;
9
8
  private readonly _injector;
@@ -1,6 +1,5 @@
1
1
  import { IRange, Worksheet, Disposable, ILogService, IUniverInstanceService, LocaleService } from '@univerjs/core';
2
2
  import { IFilterByValueItem } from '../services/sheets-filter-panel.service';
3
-
4
3
  export interface ISheetsGenerateFilterValuesService {
5
4
  getFilterValues(params: {
6
5
  unitId: string;
@@ -1,6 +1,5 @@
1
1
  import { Injector, Plugin, UniverInstanceType } from '@univerjs/core';
2
2
  import { IRPCChannelService } from '@univerjs/rpc';
3
-
4
3
  export declare class UniverSheetsFilterUIWorkerPlugin extends Plugin {
5
4
  private readonly _config;
6
5
  protected readonly _injector: Injector;
@@ -8,6 +7,6 @@ export declare class UniverSheetsFilterUIWorkerPlugin extends Plugin {
8
7
  static type: UniverInstanceType;
9
8
  static pluginName: string;
10
9
  constructor(_config: unknown, _injector: Injector, _rpcChannelService: IRPCChannelService);
11
- onStarting(_injector?: Injector): void;
10
+ onStarting(): void;
12
11
  onReady(): void;
13
12
  }