@univerjs/sheets-data-validation 0.3.0 → 0.4.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +2 -2
  2. package/lib/cjs/index.js +1 -9
  3. package/lib/es/index.js +321 -3172
  4. package/lib/types/commands/commands/data-validation.command.d.ts +0 -1
  5. package/lib/types/common/const.d.ts +0 -1
  6. package/lib/types/controllers/config.schema.d.ts +15 -3
  7. package/lib/types/controllers/dv-ref-range.controller.d.ts +1 -1
  8. package/lib/types/controllers/dv.controller.d.ts +1 -4
  9. package/lib/types/index.d.ts +10 -4
  10. package/lib/types/plugin.d.ts +3 -1
  11. package/lib/types/utils/create.d.ts +1 -1
  12. package/lib/types/validators/checkbox-validator.d.ts +2 -5
  13. package/lib/types/validators/custom-validator.d.ts +0 -1
  14. package/lib/types/validators/date-validator.d.ts +2 -5
  15. package/lib/types/validators/decimal-validator.d.ts +1 -3
  16. package/lib/types/validators/list-multiple-validator.d.ts +0 -2
  17. package/lib/types/validators/list-validator.d.ts +2 -6
  18. package/lib/types/validators/text-length-validator.d.ts +1 -2
  19. package/lib/types/validators/whole-validator.d.ts +1 -3
  20. package/lib/umd/index.js +1 -9
  21. package/package.json +17 -37
  22. package/lib/index.css +0 -1
  23. package/lib/locale/en-US.json +0 -167
  24. package/lib/locale/ru-RU.json +0 -167
  25. package/lib/locale/vi-VN.json +0 -167
  26. package/lib/locale/zh-CN.json +0 -167
  27. package/lib/locale/zh-TW.json +0 -167
  28. package/lib/types/commands/operations/data-validation.operation.d.ts +0 -17
  29. package/lib/types/controllers/dv-alert.controller.d.ts +0 -14
  30. package/lib/types/controllers/dv-auto-fill.controller.d.ts +0 -10
  31. package/lib/types/controllers/dv-copy-paste.controller.d.ts +0 -13
  32. package/lib/types/controllers/dv-permission.controller.d.ts +0 -9
  33. package/lib/types/controllers/dv-reject-input.controller.d.ts +0 -15
  34. package/lib/types/controllers/dv-render.controller.d.ts +0 -39
  35. package/lib/types/controllers/dv.menu.d.ts +0 -7
  36. package/lib/types/controllers/menu.schema.d.ts +0 -2
  37. package/lib/types/locale/en-US.d.ts +0 -3
  38. package/lib/types/locale/ru-RU.d.ts +0 -3
  39. package/lib/types/locale/vi-VN.d.ts +0 -3
  40. package/lib/types/locale/zh-CN.d.ts +0 -183
  41. package/lib/types/locale/zh-TW.d.ts +0 -3
  42. package/lib/types/mobile-plugin.d.ts +0 -12
  43. package/lib/types/services/data-validation-panel.service.d.ts +0 -32
  44. package/lib/types/services/dropdown-manager.service.d.ts +0 -40
  45. package/lib/types/views/date-dropdown/index.d.ts +0 -3
  46. package/lib/types/views/detail/index.d.ts +0 -2
  47. package/lib/types/views/drop-down/CellDropdown.d.ts +0 -2
  48. package/lib/types/views/drop-down/index.d.ts +0 -18
  49. package/lib/types/views/formula-input/base-formula-input.d.ts +0 -3
  50. package/lib/types/views/formula-input/checkbox-formula-input.d.ts +0 -3
  51. package/lib/types/views/formula-input/custom-formula-input.d.ts +0 -3
  52. package/lib/types/views/formula-input/formula-input.d.ts +0 -4
  53. package/lib/types/views/formula-input/index.d.ts +0 -6
  54. package/lib/types/views/formula-input/list-formula-input.d.ts +0 -3
  55. package/lib/types/views/index.d.ts +0 -20
  56. package/lib/types/views/item/index.d.ts +0 -10
  57. package/lib/types/views/list/index.d.ts +0 -2
  58. package/lib/types/views/list-dropdown/index.d.ts +0 -3
  59. package/lib/types/views/options/index.d.ts +0 -8
  60. package/lib/types/views/panel/index.d.ts +0 -2
  61. package/lib/types/views/render-mode/index.d.ts +0 -10
  62. package/lib/types/views/show-time/index.d.ts +0 -10
  63. package/lib/types/widgets/checkbox-widget.d.ts +0 -19
  64. package/lib/types/widgets/dropdown-multiple-widget.d.ts +0 -19
  65. package/lib/types/widgets/dropdown-widget.d.ts +0 -28
  66. package/lib/types/widgets/shape/dropdown.d.ts +0 -12
  67. package/lib/types/widgets/shape/index.d.ts +0 -18
  68. package/lib/types/widgets/shape/layout.d.ts +0 -37
package/lib/es/index.js CHANGED
@@ -2,24 +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 { ObjectMatrix, Range, Inject, Disposable, UniverInstanceType, DataValidationType, isFormulaString, IUniverInstanceService, ILogService, getOriginCellValue, debounce, Rectangle, Tools, OnLifecycle, LifecycleStages, DataValidationStatus, ICommandService, DataValidationOperator, createInternalEditorID, useDependency, LocaleService, IPermissionService, ThemeService, VerticalAlign, HorizontalAlign, WrapStrategy, DataValidationErrorStyle, numfmt, CellValueType, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DisposableCollection, toDisposable, CommandType, BuildTextUtils, DataValidationRenderMode, IConfigService, UndoCommand, RedoCommand, isUnitRangesEqual, isValidRange, shallowEqual, Injector, DEFAULT_STYLES, DocumentDataModel, DEFAULT_EMPTY_DOCUMENT_VALUE, BooleanNumber, IUndoRedoService, sequenceExecuteAsync, sequenceExecute, RxDisposable, queryObjectMatrix, isRangesEqual, Optional, InterceptorEffectEnum, DependentOn, Plugin } from "@univerjs/core";
6
- import { DataValidationModel, DataValidatorRegistryService, UpdateRuleType, BaseDataValidator, DataValidatorRegistryScope, TWO_FORMULA_OPERATOR_COUNT as TWO_FORMULA_OPERATOR_COUNT$1, getRuleOptions, getRuleSetting, TextLengthErrorTitleMap, AddDataValidationMutation, RemoveDataValidationMutation, UpdateDataValidationMutation, UniverDataValidationPlugin } from "@univerjs/data-validation";
5
+ import { ObjectMatrix, Range, Inject, Disposable, UniverInstanceType, DataValidationType, isFormulaString, IUniverInstanceService, ILogService, getOriginCellValue, debounce, Rectangle, Tools, DataValidationStatus, ICommandService, WrapStrategy, DataValidationOperator, numfmt, DataValidationRenderMode, CommandType, IUndoRedoService, sequenceExecuteAsync, sequenceExecute, CellValueType, Injector, RxDisposable, toDisposable, IPermissionService, isRangesEqual, DependentOn, Plugin, IConfigService } from "@univerjs/core";
6
+ import { DataValidationModel, DataValidatorRegistryService, UpdateRuleType, BaseDataValidator, TextLengthErrorTitleMap, AddDataValidationMutation, RemoveDataValidationMutation, UpdateDataValidationMutation, getRuleSetting, getRuleOptions, UniverDataValidationPlugin } from "@univerjs/data-validation";
7
7
  import { DataValidationModel as DataValidationModel2 } from "@univerjs/data-validation";
8
- import { RemoveSheetMutation, SheetsSelectionsService, WorksheetViewPermission, SetRangeValuesCommand, getSheetCommandTarget, WorkbookEditablePermission, RangeProtectionPermissionEditPoint, WorksheetEditPermission, checkRangesEditablePermission, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, WorksheetSetCellStylePermission, SheetInterceptorService, ClearSelectionAllCommand, RefRangeService, handleCommonDefaultRangeChangeWithEffectRefCommands, INTERCEPTOR_POINT, InterceptCellContentPriority, UniverSheetsPlugin, RemoveSheetCommand } from "@univerjs/sheets";
9
- import { IEditorBridgeService, SheetCanvasPopManagerService, SheetPermissionInterceptorBaseController, IMarkSelectionService, getCurrentRangeDisable$, HoverManagerService, CellAlertManagerService, CellAlertType, COPY_TYPE, rangeToDiscreteRange, PREDEFINED_HOOK_NAME, virtualizeDiscreteRanges, getRepeatRange, ISheetClipboardService, AutoHeightController, SheetSkeletonManagerService, UniverSheetsUIPlugin, IAutoFillService, APPLY_TYPE, getAutoFillRepeatRange } from "@univerjs/sheets-ui";
10
- import { Subject, debounceTime, filter, BehaviorSubject, distinctUntilChanged, bufferTime } from "rxjs";
11
- import { LexerTreeBuilder, deserializeRangeWithSheet, serializeRange, isReferenceString, sequenceNodeType, ERROR_TYPE_SET } from "@univerjs/engine-formula";
8
+ import { RemoveSheetMutation, getSheetCommandTarget, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SheetsSelectionsService, SheetInterceptorService, ClearSelectionAllCommand, WorksheetViewPermission, RefRangeService, handleCommonDefaultRangeChangeWithEffectRefCommands, RemoveSheetCommand } from "@univerjs/sheets";
9
+ import { Subject } from "rxjs";
10
+ import { LexerTreeBuilder, isReferenceString, sequenceNodeType, deserializeRangeWithSheet, ERROR_TYPE_SET } from "@univerjs/engine-formula";
12
11
  import { RegisterOtherFormulaService, FormulaRefRangeService } from "@univerjs/sheets-formula";
13
- import React, { forwardRef, useRef, createElement, useState, useMemo, useEffect } from "react";
14
- import { FormLayout, Input, RadioGroup, Radio, DraggableList, Select, Checkbox, Button, DatePanel, RectPopup, Scrollbar } from "@univerjs/design";
15
- import { TextEditor, RangeSelector } from "@univerjs/docs-ui";
16
- import { useObservable, useEvent, IDialogService, ComponentManager, IZenZoneService, ISidebarService, KeyCode, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, IMenuManagerService } from "@univerjs/ui";
17
- import cs from "clsx";
18
- import { fixLineWidthByScale, Transform, Checkbox as Checkbox$1, IRenderManagerService, DeviceInputEventType, getDocsSkeletonPageSize, Rect, DocumentViewModel, DocumentSkeleton, Documents, FontCache, Shape, getFontStyleString } from "@univerjs/engine-render";
19
12
  import dayjs from "dayjs";
20
- import { getPatternType, UniverSheetsNumfmtPlugin } from "@univerjs/sheets-numfmt";
21
- import { RichTextEditingMutation } from "@univerjs/docs";
22
- const DATA_VALIDATION_PLUGIN_NAME = "SHEET_DATA_VALIDATION_PLUGIN", DROP_DOWN_DEFAULT_COLOR = "#ECECEC", _DataValidationCacheService = class _DataValidationCacheService {
13
+ const DATA_VALIDATION_PLUGIN_NAME = "SHEET_DATA_VALIDATION_PLUGIN", _DataValidationCacheService = class _DataValidationCacheService {
23
14
  constructor() {
24
15
  __publicField(this, "_cacheMatrix", /* @__PURE__ */ new Map());
25
16
  }
@@ -85,11 +76,11 @@ const DATA_VALIDATION_PLUGIN_NAME = "SHEET_DATA_VALIDATION_PLUGIN", DROP_DOWN_DE
85
76
  };
86
77
  __name(_DataValidationCacheService, "DataValidationCacheService");
87
78
  let DataValidationCacheService = _DataValidationCacheService;
88
- var __defProp$k = Object.defineProperty, __getOwnPropDesc$k = Object.getOwnPropertyDescriptor, __decorateClass$k = /* @__PURE__ */ __name((decorators, target, key, kind) => {
89
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$k(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
79
+ var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
80
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
90
81
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
91
- return kind && result && __defProp$k(target, key, result), result;
92
- }, "__decorateClass$k"), __decorateParam$k = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$k");
82
+ return kind && result && __defProp$8(target, key, result), result;
83
+ }, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8");
93
84
  function transformFormula(lexerTreeBuilder, formula, originRow, originCol, targetRow, targetCol) {
94
85
  return lexerTreeBuilder.moveFormulaRefOffset(formula, targetCol - originCol, targetRow - originRow);
95
86
  }
@@ -117,8 +108,8 @@ let DataValidationCustomFormulaService = (_a = class extends Disposable {
117
108
  for (const subUnitId in unitMap) {
118
109
  const results = unitMap[subUnitId], { formulaCellMap, ruleFormulaMap } = this._ensureMaps(unitId, subUnitId);
119
110
  results.forEach((result) => {
120
- var _a24, _b;
121
- const ruleInfo = ruleFormulaMap.get((_a24 = result.extra) == null ? void 0 : _a24.ruleId), cellInfo = formulaCellMap.get(result.formulaId), rule = this._dataValidationModel.getRuleById(unitId, subUnitId, (_b = result.extra) == null ? void 0 : _b.ruleId);
111
+ var _a11, _b;
112
+ const ruleInfo = ruleFormulaMap.get((_a11 = result.extra) == null ? void 0 : _a11.ruleId), cellInfo = formulaCellMap.get(result.formulaId), rule = this._dataValidationModel.getRuleById(unitId, subUnitId, (_b = result.extra) == null ? void 0 : _b.ruleId);
122
113
  rule && ruleInfo && !ruleInfo.isTransformable && this._dataValidationCacheService.markRangeDirty(unitId, subUnitId, rule.ranges), cellInfo && this._dataValidationCacheService.markCellDirty(unitId, subUnitId, cellInfo.row, cellInfo.column);
123
114
  });
124
115
  }
@@ -196,8 +187,8 @@ let DataValidationCustomFormulaService = (_a = class extends Disposable {
196
187
  });
197
188
  }), newRanges.forEach((range) => {
198
189
  Range.foreach(range, (row, col) => {
199
- var _a24;
200
- const oldValue = (_a24 = formulaMap.getValue(row, col)) != null ? _a24 : {};
190
+ var _a11;
191
+ const oldValue = (_a11 = formulaMap.getValue(row, col)) != null ? _a11 : {};
201
192
  if (oldValue.ruleId !== ruleId) {
202
193
  const oldRuleFormula = ruleFormulaMap.get(oldValue.ruleId);
203
194
  if (oldRuleFormula != null && oldRuleFormula.isTransformable && deleteFormulaIdList.add(oldValue.formulaId), isTransformable) {
@@ -237,19 +228,19 @@ let DataValidationCustomFormulaService = (_a = class extends Disposable {
237
228
  return ruleFormulaMap.get(ruleId);
238
229
  }
239
230
  }, __name(_a, "DataValidationCustomFormulaService"), _a);
240
- DataValidationCustomFormulaService = __decorateClass$k([
241
- __decorateParam$k(0, IUniverInstanceService),
242
- __decorateParam$k(1, Inject(RegisterOtherFormulaService)),
243
- __decorateParam$k(2, Inject(LexerTreeBuilder)),
244
- __decorateParam$k(3, Inject(DataValidationModel)),
245
- __decorateParam$k(4, Inject(DataValidationCacheService)),
246
- __decorateParam$k(5, ILogService)
231
+ DataValidationCustomFormulaService = __decorateClass$8([
232
+ __decorateParam$8(0, IUniverInstanceService),
233
+ __decorateParam$8(1, Inject(RegisterOtherFormulaService)),
234
+ __decorateParam$8(2, Inject(LexerTreeBuilder)),
235
+ __decorateParam$8(3, Inject(DataValidationModel)),
236
+ __decorateParam$8(4, Inject(DataValidationCacheService)),
237
+ __decorateParam$8(5, ILogService)
247
238
  ], DataValidationCustomFormulaService);
248
- var __defProp$j = Object.defineProperty, __getOwnPropDesc$j = Object.getOwnPropertyDescriptor, __decorateClass$j = /* @__PURE__ */ __name((decorators, target, key, kind) => {
249
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$j(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
239
+ var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
240
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
250
241
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
251
- return kind && result && __defProp$j(target, key, result), result;
252
- }, "__decorateClass$j"), __decorateParam$j = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$j"), _a2;
242
+ return kind && result && __defProp$7(target, key, result), result;
243
+ }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a2;
253
244
  let DataValidationFormulaService = (_a2 = class extends Disposable {
254
245
  constructor(_instanceService, _registerOtherFormulaService, _dataValidationCacheService, _dataValidationModel) {
255
246
  super();
@@ -264,8 +255,8 @@ let DataValidationFormulaService = (_a2 = class extends Disposable {
264
255
  for (const subUnitId in unitMap) {
265
256
  const results = unitMap[subUnitId], formulaMap = this._ensureRuleFormulaMap(unitId, subUnitId);
266
257
  results.forEach((result) => {
267
- var _a24, _b;
268
- if (formulaMap.get((_a24 = result.extra) == null ? void 0 : _a24.ruleId)) {
258
+ var _a11, _b;
259
+ if (formulaMap.get((_a11 = result.extra) == null ? void 0 : _a11.ruleId)) {
269
260
  const rule = this._dataValidationModel.getRuleById(unitId, subUnitId, (_b = result.extra) == null ? void 0 : _b.ruleId);
270
261
  rule && this._dataValidationCacheService.markRangeDirty(unitId, subUnitId, rule.ranges);
271
262
  }
@@ -350,19 +341,19 @@ let DataValidationFormulaService = (_a2 = class extends Disposable {
350
341
  return this._ensureRuleFormulaMap(unitId, subUnitId).get(ruleId);
351
342
  }
352
343
  }, __name(_a2, "DataValidationFormulaService"), _a2);
353
- DataValidationFormulaService = __decorateClass$j([
354
- __decorateParam$j(0, IUniverInstanceService),
355
- __decorateParam$j(1, Inject(RegisterOtherFormulaService)),
356
- __decorateParam$j(2, Inject(DataValidationCacheService)),
357
- __decorateParam$j(3, Inject(DataValidationModel))
344
+ DataValidationFormulaService = __decorateClass$7([
345
+ __decorateParam$7(0, IUniverInstanceService),
346
+ __decorateParam$7(1, Inject(RegisterOtherFormulaService)),
347
+ __decorateParam$7(2, Inject(DataValidationCacheService)),
348
+ __decorateParam$7(3, Inject(DataValidationModel))
358
349
  ], DataValidationFormulaService);
359
350
  function getCellValueOrigin(cell) {
360
351
  return getOriginCellValue(cell);
361
352
  }
362
353
  __name(getCellValueOrigin, "getCellValueOrigin");
363
354
  function getStringCellValue(cell) {
364
- var _a24;
365
- return String((_a24 = getCellValueOrigin(cell)) != null ? _a24 : "");
355
+ var _a11;
356
+ return String((_a11 = getCellValueOrigin(cell)) != null ? _a11 : "");
366
357
  }
367
358
  __name(getStringCellValue, "getStringCellValue");
368
359
  var _a3;
@@ -790,8 +781,8 @@ const _RuleMatrix = class _RuleMatrix {
790
781
  this._unitId = _unitId, this._subUnitId = _subUnitId, this._univerInstanceService = _univerInstanceService, this._disableTree = _disableTree, this._map = value, this._buildTree();
791
782
  }
792
783
  get _worksheet() {
793
- var _a24;
794
- return (_a24 = this._univerInstanceService.getUnit(this._unitId, UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a24.getSheetBySheetId(this._subUnitId);
784
+ var _a11;
785
+ return (_a11 = this._univerInstanceService.getUnit(this._unitId, UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a11.getSheetBySheetId(this._subUnitId);
795
786
  }
796
787
  addRule(rule) {
797
788
  if (!this._worksheet)
@@ -841,8 +832,8 @@ const _RuleMatrix = class _RuleMatrix {
841
832
  const mutations = [];
842
833
  let deleteIndex = 0;
843
834
  return rules.forEach((rule, index) => {
844
- var _a24;
845
- const newRanges = (_a24 = this._map.get(rule.uid)) != null ? _a24 : [], oldRanges = rule.ranges;
835
+ var _a11;
836
+ const newRanges = (_a11 = this._map.get(rule.uid)) != null ? _a11 : [], oldRanges = rule.ranges;
846
837
  newRanges.length !== 0 && (newRanges.length !== oldRanges.length || newRanges.some((range, i) => !Rectangle.equals(range, oldRanges[i]))) && mutations.push({
847
838
  type: "update",
848
839
  ruleId: rule.uid,
@@ -859,8 +850,8 @@ const _RuleMatrix = class _RuleMatrix {
859
850
  const mutations = [];
860
851
  let deleteIndex = 0;
861
852
  return rules.forEach((rule, index) => {
862
- var _a24;
863
- const newRanges = (_a24 = this._map.get(rule.uid)) != null ? _a24 : [], oldRanges = rule.ranges;
853
+ var _a11;
854
+ const newRanges = (_a11 = this._map.get(rule.uid)) != null ? _a11 : [], oldRanges = rule.ranges;
864
855
  newRanges.length !== 0 && (newRanges.length !== oldRanges.length || newRanges.some((range, i) => !Rectangle.equals(range, oldRanges[i]))) && mutations.push({
865
856
  type: "update",
866
857
  ruleId: rule.uid,
@@ -872,8 +863,8 @@ const _RuleMatrix = class _RuleMatrix {
872
863
  index: index - deleteIndex
873
864
  }), deleteIndex++);
874
865
  }), Array.from(additionRules).forEach((rule) => {
875
- var _a24;
876
- const newRanges = (_a24 = this._map.get(rule.uid)) != null ? _a24 : [];
866
+ var _a11;
867
+ const newRanges = (_a11 = this._map.get(rule.uid)) != null ? _a11 : [];
877
868
  mutations.push({
878
869
  type: "add",
879
870
  rule: {
@@ -904,11 +895,11 @@ const _RuleMatrix = class _RuleMatrix {
904
895
  };
905
896
  __name(_RuleMatrix, "RuleMatrix");
906
897
  let RuleMatrix = _RuleMatrix;
907
- var __defProp$i = Object.defineProperty, __getOwnPropDesc$i = Object.getOwnPropertyDescriptor, __decorateClass$i = /* @__PURE__ */ __name((decorators, target, key, kind) => {
908
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$i(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
898
+ var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
899
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
909
900
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
910
- return kind && result && __defProp$i(target, key, result), result;
911
- }, "__decorateClass$i"), __decorateParam$i = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$i"), _a4;
901
+ return kind && result && __defProp$6(target, key, result), result;
902
+ }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a4;
912
903
  let SheetDataValidationModel = (_a4 = class extends Disposable {
913
904
  constructor(_dataValidationModel, _univerInstanceService, _dataValidatorRegistryService, _dataValidationCacheService, _dataValidationFormulaService, _dataValidationCustomFormulaService, _commandService) {
914
905
  super();
@@ -1068,730 +1059,25 @@ let SheetDataValidationModel = (_a4 = class extends Disposable {
1068
1059
  return this._dataValidationModel.getAll();
1069
1060
  }
1070
1061
  }, __name(_a4, "SheetDataValidationModel"), _a4);
1071
- SheetDataValidationModel = __decorateClass$i([
1072
- OnLifecycle(LifecycleStages.Starting, SheetDataValidationModel),
1073
- __decorateParam$i(0, Inject(DataValidationModel)),
1074
- __decorateParam$i(1, IUniverInstanceService),
1075
- __decorateParam$i(2, Inject(DataValidatorRegistryService)),
1076
- __decorateParam$i(3, Inject(DataValidationCacheService)),
1077
- __decorateParam$i(4, Inject(DataValidationFormulaService)),
1078
- __decorateParam$i(5, Inject(DataValidationCustomFormulaService)),
1079
- __decorateParam$i(6, ICommandService)
1062
+ SheetDataValidationModel = __decorateClass$6([
1063
+ __decorateParam$6(0, Inject(DataValidationModel)),
1064
+ __decorateParam$6(1, IUniverInstanceService),
1065
+ __decorateParam$6(2, Inject(DataValidatorRegistryService)),
1066
+ __decorateParam$6(3, Inject(DataValidationCacheService)),
1067
+ __decorateParam$6(4, Inject(DataValidationFormulaService)),
1068
+ __decorateParam$6(5, Inject(DataValidationCustomFormulaService)),
1069
+ __decorateParam$6(6, ICommandService)
1080
1070
  ], SheetDataValidationModel);
1081
- function createDefaultNewRule(accessor) {
1082
- const currentRanges = accessor.get(SheetsSelectionsService).getCurrentSelections().map((s) => s.range);
1083
- return {
1084
- uid: Tools.generateRandomId(6),
1085
- type: DataValidationType.DECIMAL,
1086
- operator: DataValidationOperator.EQUAL,
1087
- formula1: "100",
1088
- ranges: currentRanges != null ? currentRanges : [{ startColumn: 0, endColumn: 0, startRow: 0, endRow: 0 }]
1089
- };
1090
- }
1091
- __name(createDefaultNewRule, "createDefaultNewRule");
1092
1071
  function getFormulaResult(result) {
1093
- var _a24, _b;
1094
- return (_b = (_a24 = result == null ? void 0 : result[0]) == null ? void 0 : _a24[0]) == null ? void 0 : _b.v;
1072
+ var _a11, _b;
1073
+ return (_b = (_a11 = result == null ? void 0 : result[0]) == null ? void 0 : _a11[0]) == null ? void 0 : _b.v;
1095
1074
  }
1096
1075
  __name(getFormulaResult, "getFormulaResult");
1097
1076
  function getFormulaCellData(result) {
1098
- var _a24;
1099
- return (_a24 = result == null ? void 0 : result[0]) == null ? void 0 : _a24[0];
1077
+ var _a11;
1078
+ return (_a11 = result == null ? void 0 : result[0]) == null ? void 0 : _a11[0];
1100
1079
  }
1101
1080
  __name(getFormulaCellData, "getFormulaCellData");
1102
- var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
1103
- function getDefaultExportFromCjs(x) {
1104
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x.default : x;
1105
- }
1106
- __name(getDefaultExportFromCjs, "getDefaultExportFromCjs");
1107
- var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
1108
- /**
1109
- * @license React
1110
- * react-jsx-runtime.production.min.js
1111
- *
1112
- * Copyright (c) Facebook, Inc. and its affiliates.
1113
- *
1114
- * This source code is licensed under the MIT license found in the
1115
- * LICENSE file in the root directory of this source tree.
1116
- */
1117
- var f = React, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: !0, ref: !0, __self: !0, __source: !0 };
1118
- function q(c, a, g) {
1119
- var b, d = {}, e = null, h = null;
1120
- g !== void 0 && (e = "" + g), a.key !== void 0 && (e = "" + a.key), a.ref !== void 0 && (h = a.ref);
1121
- for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
1122
- if (c && c.defaultProps) for (b in a = c.defaultProps, a) d[b] === void 0 && (d[b] = a[b]);
1123
- return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
1124
- }
1125
- __name(q, "q");
1126
- reactJsxRuntime_production_min.Fragment = l;
1127
- reactJsxRuntime_production_min.jsx = q;
1128
- reactJsxRuntime_production_min.jsxs = q;
1129
- jsxRuntime.exports = reactJsxRuntime_production_min;
1130
- var jsxRuntimeExports = jsxRuntime.exports;
1131
- function CustomFormulaInput(props) {
1132
- var _a24;
1133
- const { unitId, subUnitId, value, onChange, showError, validResult } = props, formula1Res = showError ? validResult == null ? void 0 : validResult.formula1 : "";
1134
- return /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: formula1Res, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1135
- TextEditor,
1136
- {
1137
- value: (_a24 = value == null ? void 0 : value.formula1) != null ? _a24 : "",
1138
- id: createInternalEditorID(`dataValidation-custom-formula-${unitId}-${subUnitId}`),
1139
- onChange: /* @__PURE__ */ __name((newValue) => {
1140
- onChange == null || onChange({
1141
- ...value,
1142
- formula1: (newValue != null ? newValue : "").trim()
1143
- });
1144
- }, "onChange"),
1145
- onlyInputFormula: !0,
1146
- openForSheetUnitId: unitId,
1147
- openForSheetSubUnitId: subUnitId
1148
- }
1149
- ) });
1150
- }
1151
- __name(CustomFormulaInput, "CustomFormulaInput");
1152
- const dataValidationFormula = "univer-data-validation-formula", dataValidationFormulaAnd = "univer-data-validation-formula-and", dataValidationFormulaListItem = "univer-data-validation-formula-list-item", dataValidationFormulaListItemIcon = "univer-data-validation-formula-list-item-icon", dataValidationFormulaListItemDrag = "univer-data-validation-formula-list-item-drag", dataValidationFormulaListAdd = "univer-data-validation-formula-list-add", dataValidationFormulaColorSelect = "univer-data-validation-formula-color-select", dataValidationFormulaColorSelectPanel = "univer-data-validation-formula-color-select-panel", dataValidationFormulaColorItem = "univer-data-validation-formula-color-item", styles$6 = {
1153
- dataValidationFormula,
1154
- dataValidationFormulaAnd,
1155
- dataValidationFormulaListItem,
1156
- dataValidationFormulaListItemIcon,
1157
- dataValidationFormulaListItemDrag,
1158
- dataValidationFormulaListAdd,
1159
- dataValidationFormulaColorSelect,
1160
- dataValidationFormulaColorSelectPanel,
1161
- dataValidationFormulaColorItem
1162
- }, BaseFormulaInput = /* @__PURE__ */ __name((props) => {
1163
- const { isTwoFormula = !1, value, onChange, showError, validResult } = props, localeService = useDependency(LocaleService), formula1Res = showError ? validResult == null ? void 0 : validResult.formula1 : "", formula2Res = showError ? validResult == null ? void 0 : validResult.formula2 : "";
1164
- return isTwoFormula ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1165
- /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: formula1Res, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1166
- Input,
1167
- {
1168
- className: styles$6.dataValidationFormula,
1169
- placeholder: localeService.t("dataValidation.panel.formulaPlaceholder"),
1170
- value: value == null ? void 0 : value.formula1,
1171
- onChange: /* @__PURE__ */ __name((newValue) => {
1172
- onChange == null || onChange({
1173
- ...value,
1174
- formula1: newValue
1175
- });
1176
- }, "onChange")
1177
- }
1178
- ) }),
1179
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$6.dataValidationFormulaAnd, children: localeService.t("dataValidation.panel.formulaAnd") }),
1180
- /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: formula2Res, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1181
- Input,
1182
- {
1183
- className: styles$6.dataValidationFormula,
1184
- placeholder: localeService.t("dataValidation.panel.formulaPlaceholder"),
1185
- value: value == null ? void 0 : value.formula2,
1186
- onChange: /* @__PURE__ */ __name((newValue) => {
1187
- onChange == null || onChange({
1188
- ...value,
1189
- formula2: newValue
1190
- });
1191
- }, "onChange")
1192
- }
1193
- ) })
1194
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: formula1Res, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1195
- Input,
1196
- {
1197
- className: styles$6.dataValidationFormula,
1198
- placeholder: localeService.t("dataValidation.panel.formulaPlaceholder"),
1199
- value: value == null ? void 0 : value.formula1,
1200
- onChange: /* @__PURE__ */ __name((newValue) => {
1201
- onChange == null || onChange({ formula1: newValue });
1202
- }, "onChange")
1203
- }
1204
- ) });
1205
- }, "BaseFormulaInput");
1206
- var __assign = function() {
1207
- return __assign = Object.assign || function(t) {
1208
- for (var s, i = 1, n2 = arguments.length; i < n2; i++) {
1209
- s = arguments[i];
1210
- for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && (t[p2] = s[p2]);
1211
- }
1212
- return t;
1213
- }, __assign.apply(this, arguments);
1214
- }, __rest = function(s, e) {
1215
- var t = {};
1216
- for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && e.indexOf(p2) < 0 && (t[p2] = s[p2]);
1217
- if (s != null && typeof Object.getOwnPropertySymbols == "function")
1218
- for (var i = 0, p2 = Object.getOwnPropertySymbols(s); i < p2.length; i++)
1219
- e.indexOf(p2[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p2[i]) && (t[p2[i]] = s[p2[i]]);
1220
- return t;
1221
- }, IconBase = forwardRef(function(props, ref) {
1222
- var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
1223
- return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
1224
- });
1225
- function render(node, id, runtimeProps, rootProps, extend) {
1226
- return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
1227
- return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
1228
- }));
1229
- }
1230
- __name(render, "render");
1231
- function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
1232
- var attrs = __assign({}, node.attrs);
1233
- extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
1234
- var defIds = runtimeProps.defIds;
1235
- return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a24) {
1236
- var key = _a24[0], value = _a24[1];
1237
- typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
1238
- })), attrs;
1239
- }
1240
- __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
1241
- function replaceRuntimeIdsInDefs(node, runtimeProps) {
1242
- var _a24, defIds = runtimeProps.defIds;
1243
- return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a24 = node.children) === null || _a24 === void 0) && _a24.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
1244
- return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
1245
- }) }) : node;
1246
- }
1247
- __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
1248
- function generateShortUuid() {
1249
- return Math.random().toString(36).substring(2, 8);
1250
- }
1251
- __name(generateShortUuid, "generateShortUuid");
1252
- IconBase.displayName = "UniverIcon";
1253
- var element$6 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, CheckMarkSingle = forwardRef(function(props, ref) {
1254
- return createElement(IconBase, Object.assign({}, props, {
1255
- id: "check-mark-single",
1256
- ref,
1257
- icon: element$6
1258
- }));
1259
- });
1260
- CheckMarkSingle.displayName = "CheckMarkSingle";
1261
- var element$5 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.4917 3.07803C1.4917 2.19437 2.20804 1.47803 3.0917 1.47803H5.6917C6.57536 1.47803 7.2917 2.19437 7.2917 3.07803V5.67803C7.2917 6.56168 6.57535 7.27803 5.6917 7.27803H3.0917C2.20804 7.27803 1.4917 6.56168 1.4917 5.67803V3.07803ZM3.0917 2.67803C2.87078 2.67803 2.6917 2.85711 2.6917 3.07803V5.67803C2.6917 5.89894 2.87079 6.07803 3.0917 6.07803H5.6917C5.91261 6.07803 6.0917 5.89894 6.0917 5.67803V3.07803C6.0917 2.85711 5.91261 2.67803 5.6917 2.67803H3.0917Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M14.6175 2.45279C14.8518 2.68711 14.8518 3.06701 14.6175 3.30132L11.6151 6.30365C11.3957 6.52307 11.0451 6.53897 10.8067 6.34031L8.80915 4.67566C8.55458 4.46352 8.52019 4.08518 8.73233 3.83062 8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767 13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279zM14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217 14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046 13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703 10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046 9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217 9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746 9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732 13.269 9.19746C13.5033 8.96315 13.8832 8.96315 14.1175 9.19746z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.0917 8.72168C2.20804 8.72168 1.4917 9.43802 1.4917 10.3217V12.9217C1.4917 13.8053 2.20804 14.5217 3.0917 14.5217H5.6917C6.57535 14.5217 7.2917 13.8053 7.2917 12.9217V10.3217C7.2917 9.43802 6.57536 8.72168 5.6917 8.72168H3.0917ZM2.6917 10.3217C2.6917 10.1008 2.87078 9.92168 3.0917 9.92168H5.6917C5.91261 9.92168 6.0917 10.1008 6.0917 10.3217V12.9217C6.0917 13.1426 5.91261 13.3217 5.6917 13.3217H3.0917C2.87079 13.3217 2.6917 13.1426 2.6917 12.9217V10.3217Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, DataValidationSingle = forwardRef(function(props, ref) {
1262
- return createElement(IconBase, Object.assign({}, props, {
1263
- id: "data-validation-single",
1264
- ref,
1265
- icon: element$5
1266
- }));
1267
- });
1268
- DataValidationSingle.displayName = "DataValidationSingle";
1269
- var element$4 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, DeleteSingle = forwardRef(function(props, ref) {
1270
- return createElement(IconBase, Object.assign({}, props, {
1271
- id: "delete-single",
1272
- ref,
1273
- icon: element$4
1274
- }));
1275
- });
1276
- DeleteSingle.displayName = "DeleteSingle";
1277
- var element$3 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z" } }] }, IncreaseSingle = forwardRef(function(props, ref) {
1278
- return createElement(IconBase, Object.assign({}, props, {
1279
- id: "increase-single",
1280
- ref,
1281
- icon: element$3
1282
- }));
1283
- });
1284
- IncreaseSingle.displayName = "IncreaseSingle";
1285
- var element$2 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, MoreDownSingle = forwardRef(function(props, ref) {
1286
- return createElement(IconBase, Object.assign({}, props, {
1287
- id: "more-down-single",
1288
- ref,
1289
- icon: element$2
1290
- }));
1291
- });
1292
- MoreDownSingle.displayName = "MoreDownSingle";
1293
- var element$1 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M4.64645 9.85355C4.45118 9.65829 4.45118 9.34171 4.64645 9.14645L7.64645 6.14645C7.84171 5.95118 8.15829 5.95118 8.35355 6.14645L11.3536 9.14645C11.5488 9.34171 11.5488 9.65829 11.3536 9.85355C11.1583 10.0488 10.8417 10.0488 10.6464 9.85355L8 7.20711L5.35355 9.85355C5.15829 10.0488 4.84171 10.0488 4.64645 9.85355Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, MoreUpSingle = forwardRef(function(props, ref) {
1294
- return createElement(IconBase, Object.assign({}, props, {
1295
- id: "more-up-single",
1296
- ref,
1297
- icon: element$1
1298
- }));
1299
- });
1300
- MoreUpSingle.displayName = "MoreUpSingle";
1301
- var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "mask", attrs: { id: "mask0_622_8", style: { maskType: "alpha" }, width: 16, height: 16, x: 0, y: 0, maskUnits: "userSpaceOnUse" }, children: [{ tag: "path", attrs: { fill: "#D9D9D9", d: "M0 0H16V16H0z" } }] }, { tag: "g", attrs: { fill: "currentColor", mask: "url(#mask0_622_8)" }, children: [{ tag: "path", attrs: { d: "M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z" } }] }] }, SequenceSingle = forwardRef(function(props, ref) {
1302
- return createElement(IconBase, Object.assign({}, props, {
1303
- id: "sequence-single",
1304
- ref,
1305
- icon: element
1306
- }));
1307
- });
1308
- SequenceSingle.displayName = "SequenceSingle";
1309
- var P = /* @__PURE__ */ ((E) => (E[E.View = 0] = "View", E[E.Edit = 1] = "Edit", E[E.ManageCollaborator = 2] = "ManageCollaborator", E[E.Print = 3] = "Print", E[E.Duplicate = 4] = "Duplicate", E[E.Comment = 5] = "Comment", E[E.Copy = 6] = "Copy", E[E.Share = 7] = "Share", E[E.Export = 8] = "Export", E[E.MoveWorksheet = 9] = "MoveWorksheet", E[E.DeleteWorksheet = 10] = "DeleteWorksheet", E[E.HideWorksheet = 11] = "HideWorksheet", E[E.RenameWorksheet = 12] = "RenameWorksheet", E[E.CreateWorksheet = 13] = "CreateWorksheet", E[E.SetWorksheetStyle = 14] = "SetWorksheetStyle", E[E.EditWorksheetCell = 15] = "EditWorksheetCell", E[E.InsertHyperlink = 16] = "InsertHyperlink", E[E.Sort = 17] = "Sort", E[E.Filter = 18] = "Filter", E[E.PivotTable = 19] = "PivotTable", E[E.FloatImg = 20] = "FloatImg", E[E.History = 21] = "History", E[E.RwHgtClWdt = 22] = "RwHgtClWdt", E[E.ViemRwHgtClWdt = 23] = "ViemRwHgtClWdt", E[E.ViewFilter = 24] = "ViewFilter", E[E.MoveSheet = 25] = "MoveSheet", E[E.DeleteSheet = 26] = "DeleteSheet", E[E.HideSheet = 27] = "HideSheet", E[E.CopySheet = 28] = "CopySheet", E[E.RenameSheet = 29] = "RenameSheet", E[E.CreateSheet = 30] = "CreateSheet", E[E.SelectProtectedCells = 31] = "SelectProtectedCells", E[E.SelectUnProtectedCells = 32] = "SelectUnProtectedCells", E[E.SetCellStyle = 33] = "SetCellStyle", E[E.SetCellValue = 34] = "SetCellValue", E[E.SetRowStyle = 35] = "SetRowStyle", E[E.SetColumnStyle = 36] = "SetColumnStyle", E[E.InsertRow = 37] = "InsertRow", E[E.InsertColumn = 38] = "InsertColumn", E[E.DeleteRow = 39] = "DeleteRow", E[E.DeleteColumn = 40] = "DeleteColumn", E[E.EditExtraObject = 41] = "EditExtraObject", E[E.Delete = 42] = "Delete", E[E.RecoverHistory = 43] = "RecoverHistory", E[E.ViewHistory = 44] = "ViewHistory", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(P || {}), __defProp$h = Object.defineProperty, __getOwnPropDesc$h = Object.getOwnPropertyDescriptor, __decorateClass$h = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1310
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$h(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1311
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1312
- return kind && result && __defProp$h(target, key, result), result;
1313
- }, "__decorateClass$h"), __decorateParam$h = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$h"), _a5;
1314
- let DataValidationFormulaController = (_a5 = class extends Disposable {
1315
- constructor(_univerInstanceService, _permissionService, _lexerTreeBuilder) {
1316
- super(), this._univerInstanceService = _univerInstanceService, this._permissionService = _permissionService, this._lexerTreeBuilder = _lexerTreeBuilder;
1317
- }
1318
- getFormulaRefCheck(formulaString) {
1319
- var _a24, _b;
1320
- const sequenceNodes = this._lexerTreeBuilder.sequenceNodesBuilder(formulaString);
1321
- if (!sequenceNodes)
1322
- return !0;
1323
- for (let i = 0; i < sequenceNodes.length; i++) {
1324
- const node = sequenceNodes[i];
1325
- if (typeof node == "string")
1326
- continue;
1327
- const { token } = node, sequenceGrid = deserializeRangeWithSheet(token), workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
1328
- let targetSheet = workbook.getActiveSheet();
1329
- const unitId = workbook.getUnitId();
1330
- if (sequenceGrid.sheetName) {
1331
- if (targetSheet = workbook.getSheetBySheetName(sequenceGrid.sheetName), !targetSheet)
1332
- return !1;
1333
- const subUnitId = targetSheet == null ? void 0 : targetSheet.getSheetId();
1334
- if (!this._permissionService.getPermissionPoint(new WorksheetViewPermission(unitId, subUnitId).id)) return !1;
1335
- }
1336
- if (!targetSheet)
1337
- return !1;
1338
- const { startRow, endRow, startColumn, endColumn } = sequenceGrid.range;
1339
- for (let i2 = startRow; i2 <= endRow; i2++)
1340
- for (let j = startColumn; j <= endColumn; j++) {
1341
- const permission = (_b = (_a24 = targetSheet.getCell(i2, j)) == null ? void 0 : _a24.selectionProtection) == null ? void 0 : _b[0];
1342
- if ((permission == null ? void 0 : permission[P.View]) === !1)
1343
- return !1;
1344
- }
1345
- }
1346
- return !0;
1347
- }
1348
- }, __name(_a5, "DataValidationFormulaController"), _a5);
1349
- DataValidationFormulaController = __decorateClass$h([
1350
- OnLifecycle(LifecycleStages.Rendered, DataValidationFormulaController),
1351
- __decorateParam$h(0, IUniverInstanceService),
1352
- __decorateParam$h(1, IPermissionService),
1353
- __decorateParam$h(2, Inject(LexerTreeBuilder))
1354
- ], DataValidationFormulaController);
1355
- function serializeListOptions(options) {
1356
- return options.filter(Boolean).join(",");
1357
- }
1358
- __name(serializeListOptions, "serializeListOptions");
1359
- function deserializeListOptions(optionsStr) {
1360
- return optionsStr.split(",").filter(Boolean);
1361
- }
1362
- __name(deserializeListOptions, "deserializeListOptions");
1363
- function getDataValidationCellValue(cellData) {
1364
- const cellValue = getCellValueOrigin(cellData);
1365
- return cellValue == null ? "" : cellValue.toString();
1366
- }
1367
- __name(getDataValidationCellValue, "getDataValidationCellValue");
1368
- const DEFAULT_COLOR_PRESET = [
1369
- "#FFFFFF",
1370
- "#FEE7E7",
1371
- "#FEF0E6",
1372
- "#EFFBD0",
1373
- "#E4F4FE",
1374
- "#E8ECFD",
1375
- "#F1EAFA",
1376
- "#FDE8F3",
1377
- "#E5E5E5",
1378
- "#FDCECE",
1379
- "#FDC49B",
1380
- "#DEF6A2",
1381
- "#9FDAFF",
1382
- "#D0D9FB",
1383
- "#E3D5F6",
1384
- "#FBD0E8",
1385
- "#656565",
1386
- "#FE4B4B",
1387
- "#FF8C51",
1388
- "#8BBB11",
1389
- "#0B9EFB",
1390
- "#3A60F7",
1391
- "#9E6DE3",
1392
- "#F248A6"
1393
- ], ColorSelect = /* @__PURE__ */ __name((props) => {
1394
- const { value, onChange, disabled } = props, [open, setOpen] = useState(!1);
1395
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
1396
- Select,
1397
- {
1398
- disabled,
1399
- open,
1400
- onDropdownVisibleChange: setOpen,
1401
- dropdownStyle: { width: 112 },
1402
- className: styles$6.dataValidationFormulaColorSelect,
1403
- value,
1404
- onChange,
1405
- labelRender: /* @__PURE__ */ __name((item) => /* @__PURE__ */ jsxRuntimeExports.jsx(
1406
- "div",
1407
- {
1408
- className: styles$6.dataValidationFormulaColorItem,
1409
- style: { background: item.value, marginTop: 5 }
1410
- }
1411
- ), "labelRender"),
1412
- dropdownRender: /* @__PURE__ */ __name(() => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$6.dataValidationFormulaColorSelectPanel, children: DEFAULT_COLOR_PRESET.map(
1413
- (color) => /* @__PURE__ */ jsxRuntimeExports.jsx(
1414
- "div",
1415
- {
1416
- onClick: /* @__PURE__ */ __name(() => {
1417
- onChange(color), setOpen(!1);
1418
- }, "onClick"),
1419
- className: styles$6.dataValidationFormulaColorItem,
1420
- style: { background: color }
1421
- },
1422
- color
1423
- )
1424
- ) }), "dropdownRender")
1425
- }
1426
- );
1427
- }, "ColorSelect"), Template = /* @__PURE__ */ __name((props) => {
1428
- const { item, commonProps, style } = props, { onItemChange, onItemDelete } = commonProps;
1429
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$6.dataValidationFormulaListItem, style, children: [
1430
- item.isRef ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: cs(styles$6.dataValidationFormulaListItemDrag, "draggableHandle"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(SequenceSingle, {}) }),
1431
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1432
- ColorSelect,
1433
- {
1434
- value: item.color,
1435
- onChange: /* @__PURE__ */ __name((color) => {
1436
- onItemChange(item.id, item.label, color);
1437
- }, "onChange")
1438
- }
1439
- ),
1440
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1441
- Input,
1442
- {
1443
- disabled: item.isRef,
1444
- value: item.label,
1445
- onChange: /* @__PURE__ */ __name((label) => {
1446
- onItemChange(item.id, label, item.color);
1447
- }, "onChange")
1448
- }
1449
- ),
1450
- item.isRef ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$6.dataValidationFormulaListItemIcon, children: /* @__PURE__ */ jsxRuntimeExports.jsx(DeleteSingle, { onClick: /* @__PURE__ */ __name(() => onItemDelete(item.id), "onClick") }) })
1451
- ] });
1452
- }, "Template");
1453
- function ListFormulaInput(props) {
1454
- const { value, onChange: _onChange = /* @__PURE__ */ __name(() => {
1455
- }, "_onChange"), unitId, subUnitId, validResult, showError, ruleId } = props, { formula1 = "", formula2 = "" } = value || {}, containerRef = useRef(null), [isFormulaStr, setIsFormulaStr] = useState(() => isFormulaString(formula1) ? "1" : "0"), [formulaStr, setFormulaStr] = useState(isFormulaStr === "1" ? formula1 : "="), [formulaStrCopy, setFormulaStrCopy] = useState(isFormulaStr === "1" ? formula1 : "="), localeService = useDependency(LocaleService), dataValidatorRegistryService = useDependency(DataValidatorRegistryService), dataValidationModel = useDependency(DataValidationModel), dataValidationFormulaController = useDependency(DataValidationFormulaController), [refColors, setRefColors] = useState(() => formula2.split(",")), listValidator = dataValidatorRegistryService.getValidatorItem(DataValidationType.LIST), [refOptions, setRefOptions] = useState([]), [localError, setLocalError] = useState(""), formula1Res = showError ? validResult == null ? void 0 : validResult.formula1 : "", ruleChange$ = useMemo(() => dataValidationModel.ruleChange$.pipe(debounceTime(16)), []), ruleChange = useObservable(ruleChange$), onChange = useEvent(_onChange);
1456
- useEffect(() => {
1457
- (async () => {
1458
- await new Promise((resolve) => {
1459
- setTimeout(() => resolve(!0), 100);
1460
- });
1461
- const rule = dataValidationModel.getRuleById(unitId, subUnitId, ruleId), formula12 = rule == null ? void 0 : rule.formula1;
1462
- if (isFormulaString(formula12) && listValidator && rule) {
1463
- const res = await listValidator.getListAsync(rule, unitId, subUnitId);
1464
- setRefOptions(res);
1465
- }
1466
- })();
1467
- }, [dataValidationModel, ruleChange, listValidator, ruleId, subUnitId, unitId]), useEffect(() => {
1468
- isFormulaString(formula1) && formula1 !== formulaStrCopy && (setFormulaStr(formula1), setFormulaStrCopy(formulaStrCopy));
1469
- }, [formulaStrCopy, formula1]);
1470
- const [strList, setStrList] = useState(() => {
1471
- const strOptions = isFormulaStr !== "1" ? deserializeListOptions(formula1) : [], strColors = formula2.split(",");
1472
- return strOptions.map((label, i) => ({
1473
- label,
1474
- color: strColors[i] || DROP_DOWN_DEFAULT_COLOR,
1475
- isRef: !1,
1476
- id: Tools.generateRandomId(4)
1477
- }));
1478
- }), handleStrItemChange = /* @__PURE__ */ __name((id, value2, color) => {
1479
- const item = strList.find((i) => i.id === id);
1480
- item && (item.label = value2, item.color = color, setStrList([...strList]));
1481
- }, "handleStrItemChange"), handleStrItemDelete = /* @__PURE__ */ __name((id) => {
1482
- const index = strList.findIndex((i) => i.id === id);
1483
- index !== -1 && (strList.splice(index, 1), setStrList([...strList]));
1484
- }, "handleStrItemDelete"), colorList = formula2.split(","), refFinalList = useMemo(() => refOptions.map((label, i) => ({
1485
- label,
1486
- color: colorList[i] || DROP_DOWN_DEFAULT_COLOR,
1487
- id: `${i}`,
1488
- isRef: !0
1489
- })), [colorList, refOptions]), handleRefItemChange = /* @__PURE__ */ __name((id, value2, color) => {
1490
- const newColors = [...refColors];
1491
- newColors[+id] = color, setRefColors(newColors), onChange({
1492
- formula1,
1493
- formula2: newColors.join(",")
1494
- });
1495
- }, "handleRefItemChange"), handleAdd = /* @__PURE__ */ __name(() => {
1496
- setStrList([
1497
- ...strList,
1498
- {
1499
- label: "",
1500
- color: DROP_DOWN_DEFAULT_COLOR,
1501
- isRef: !1,
1502
- id: Tools.generateRandomId(4)
1503
- }
1504
- ]);
1505
- }, "handleAdd");
1506
- useEffect(() => {
1507
- if (isFormulaStr === "1")
1508
- return;
1509
- const labelSet = /* @__PURE__ */ new Set(), finalList = [];
1510
- strList.map((item) => ({
1511
- labelList: item.label.split(","),
1512
- item
1513
- })).forEach(({ item, labelList }) => {
1514
- labelList.forEach((labelItem) => {
1515
- labelSet.has(labelItem) || (labelSet.add(labelItem), finalList.push({
1516
- label: labelItem,
1517
- color: item.color
1518
- }));
1519
- });
1520
- }), onChange({
1521
- formula1: serializeListOptions(finalList.map((item) => item.label)),
1522
- formula2: finalList.map((item) => item.color === DROP_DOWN_DEFAULT_COLOR ? "" : item.color).join(",")
1523
- });
1524
- }, [strList, onChange, isFormulaStr, formulaStrCopy, refColors]);
1525
- const updateFormula = useMemo(
1526
- () => async (str) => {
1527
- if (!isFormulaString(str)) {
1528
- onChange == null || onChange({
1529
- formula1: "",
1530
- formula2
1531
- });
1532
- return;
1533
- }
1534
- dataValidationFormulaController.getFormulaRefCheck(str) ? (onChange == null || onChange({
1535
- formula1: isFormulaString(str) ? str : "",
1536
- formula2
1537
- }), setLocalError("")) : (onChange == null || onChange({
1538
- formula1: "",
1539
- formula2
1540
- }), setFormulaStr("="), setLocalError(localeService.t("dataValidation.validFail.formulaError")));
1541
- },
1542
- [formula2, onChange]
1543
- );
1544
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1545
- /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("dataValidation.list.options"), children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
1546
- RadioGroup,
1547
- {
1548
- value: isFormulaStr,
1549
- onChange: /* @__PURE__ */ __name((v) => {
1550
- setIsFormulaStr(v), setFormulaStr(formulaStrCopy), v === "1" && onChange({
1551
- formula1: formulaStrCopy === "=" ? "" : formulaStrCopy,
1552
- formula2: refColors.join(",")
1553
- });
1554
- }, "onChange"),
1555
- children: [
1556
- /* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: "0", children: localeService.t("dataValidation.list.customOptions") }),
1557
- /* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: "1", children: localeService.t("dataValidation.list.refOptions") })
1558
- ]
1559
- }
1560
- ) }),
1561
- isFormulaStr === "1" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1562
- /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: formula1Res || localError, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1563
- TextEditor,
1564
- {
1565
- id: createInternalEditorID(`list-ref-range-${unitId}-${subUnitId}`),
1566
- value: formulaStr,
1567
- openForSheetUnitId: unitId,
1568
- openForSheetSubUnitId: subUnitId,
1569
- onlyInputFormula: !0,
1570
- onChange: /* @__PURE__ */ __name(async (newString) => {
1571
- const str = (newString != null ? newString : "").trim();
1572
- setFormulaStrCopy(str), updateFormula(str);
1573
- }, "onChange")
1574
- }
1575
- ) }),
1576
- /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: containerRef, children: refFinalList.map((item) => /* @__PURE__ */ jsxRuntimeExports.jsx(Template, { item, commonProps: { onItemChange: handleRefItemChange }, style: { marginBottom: 12 } }, item.id)) }) })
1577
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: formula1Res, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: containerRef, style: { marginTop: "-12px" }, children: [
1578
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1579
- DraggableList,
1580
- {
1581
- list: strList,
1582
- onListChange: setStrList,
1583
- rowHeight: 32,
1584
- margin: [0, 12],
1585
- draggableHandle: ".draggableHandle",
1586
- itemRender: /* @__PURE__ */ __name((item) => /* @__PURE__ */ jsxRuntimeExports.jsx(
1587
- Template,
1588
- {
1589
- item,
1590
- commonProps: {
1591
- onItemChange: handleStrItemChange,
1592
- onItemDelete: handleStrItemDelete
1593
- }
1594
- },
1595
- item.id
1596
- ), "itemRender"),
1597
- idKey: "id"
1598
- }
1599
- ),
1600
- /* @__PURE__ */ jsxRuntimeExports.jsxs("a", { className: styles$6.dataValidationFormulaListAdd, onClick: handleAdd, children: [
1601
- /* @__PURE__ */ jsxRuntimeExports.jsx(IncreaseSingle, {}),
1602
- localeService.t("dataValidation.list.add")
1603
- ] })
1604
- ] }) })
1605
- ] });
1606
- }
1607
- __name(ListFormulaInput, "ListFormulaInput");
1608
- function CheckboxFormulaInput(props) {
1609
- const { value, onChange, showError, validResult } = props, localeService = useDependency(LocaleService), formula1Res = showError ? validResult == null ? void 0 : validResult.formula1 : "", formula2Res = showError ? validResult == null ? void 0 : validResult.formula2 : "", [checked, setChecked] = useState(!((value == null ? void 0 : value.formula1) === void 0 && (value == null ? void 0 : value.formula2) === void 0));
1610
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1611
- /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1612
- Checkbox,
1613
- {
1614
- checked,
1615
- onChange: /* @__PURE__ */ __name((newValue) => {
1616
- newValue ? setChecked(!0) : (setChecked(!1), onChange == null || onChange({
1617
- ...value,
1618
- formula1: void 0,
1619
- formula2: void 0
1620
- }));
1621
- }, "onChange"),
1622
- children: localeService.t("dataValidation.checkbox.tips")
1623
- }
1624
- ) }),
1625
- checked ? /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("dataValidation.checkbox.checked"), error: formula1Res, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1626
- Input,
1627
- {
1628
- className: styles$6.dataValidationFormula,
1629
- placeholder: localeService.t("dataValidation.panel.valuePlaceholder"),
1630
- value: value == null ? void 0 : value.formula1,
1631
- onChange: /* @__PURE__ */ __name((newValue) => {
1632
- onChange == null || onChange({
1633
- ...value,
1634
- formula1: newValue || void 0
1635
- });
1636
- }, "onChange")
1637
- }
1638
- ) }) : null,
1639
- checked ? /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("dataValidation.checkbox.unchecked"), error: formula2Res, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1640
- Input,
1641
- {
1642
- className: styles$6.dataValidationFormula,
1643
- placeholder: localeService.t("dataValidation.panel.valuePlaceholder"),
1644
- value: value == null ? void 0 : value.formula2,
1645
- onChange: /* @__PURE__ */ __name((newValue) => {
1646
- onChange == null || onChange({
1647
- ...value,
1648
- formula2: newValue || void 0
1649
- });
1650
- }, "onChange")
1651
- }
1652
- ) }) : null
1653
- ] });
1654
- }
1655
- __name(CheckboxFormulaInput, "CheckboxFormulaInput");
1656
- const CUSTOM_FORMULA_INPUT_NAME = "data-validation.custom-formula-input", BASE_FORMULA_INPUT_NAME = "data-validation.formula-input", LIST_FORMULA_INPUT_NAME = "data-validation.list-formula-input", CHECKBOX_FORMULA_INPUT_NAME = "data-validation.checkbox-formula-input", FORMULA_INPUTS = [
1657
- [
1658
- CUSTOM_FORMULA_INPUT_NAME,
1659
- CustomFormulaInput
1660
- ],
1661
- [
1662
- BASE_FORMULA_INPUT_NAME,
1663
- BaseFormulaInput
1664
- ],
1665
- [
1666
- LIST_FORMULA_INPUT_NAME,
1667
- ListFormulaInput
1668
- ],
1669
- [
1670
- CHECKBOX_FORMULA_INPUT_NAME,
1671
- CheckboxFormulaInput
1672
- ]
1673
- ];
1674
- var __defProp$g = Object.defineProperty, __getOwnPropDesc$g = Object.getOwnPropertyDescriptor, __decorateClass$g = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1675
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1676
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1677
- return kind && result && __defProp$g(target, key, result), result;
1678
- }, "__decorateClass$g"), __decorateParam$g = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$g");
1679
- const MARGIN_H$2 = 6;
1680
- var _a6;
1681
- let CheckboxRender = (_a6 = class {
1682
- constructor(_commandService, _formulaService, _themeService) {
1683
- this._commandService = _commandService, this._formulaService = _formulaService, this._themeService = _themeService;
1684
- }
1685
- _calc(cellInfo, style) {
1686
- var _a24, _b, _c;
1687
- const { vt, ht } = style || {}, width = cellInfo.endX - cellInfo.startX - MARGIN_H$2 * 2, height = cellInfo.endY - cellInfo.startY, size = ((_a24 = style == null ? void 0 : style.fs) != null ? _a24 : 10) * 1.6;
1688
- let widgetLeft = 0, widgetTop = 0;
1689
- switch (vt) {
1690
- case VerticalAlign.TOP:
1691
- widgetTop = 0;
1692
- break;
1693
- case VerticalAlign.BOTTOM:
1694
- widgetTop = 0 + (height - size);
1695
- break;
1696
- default:
1697
- widgetTop = 0 + (height - size) / 2;
1698
- break;
1699
- }
1700
- switch (ht) {
1701
- case HorizontalAlign.LEFT:
1702
- widgetLeft = MARGIN_H$2;
1703
- break;
1704
- case HorizontalAlign.RIGHT:
1705
- widgetLeft = MARGIN_H$2 + (width - size);
1706
- break;
1707
- default:
1708
- widgetLeft = MARGIN_H$2 + (width - size) / 2;
1709
- break;
1710
- }
1711
- return {
1712
- left: cellInfo.startX + widgetLeft,
1713
- top: cellInfo.startY + widgetTop,
1714
- width: ((_b = style == null ? void 0 : style.fs) != null ? _b : 10) * 1.6,
1715
- height: ((_c = style == null ? void 0 : style.fs) != null ? _c : 10) * 1.6
1716
- };
1717
- }
1718
- calcCellAutoHeight(info) {
1719
- var _a24;
1720
- const { style } = info;
1721
- return ((_a24 = style == null ? void 0 : style.fs) != null ? _a24 : 10) * 1.6;
1722
- }
1723
- async _parseFormula(rule, unitId, subUnitId) {
1724
- var _a24, _b;
1725
- const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid);
1726
- return {
1727
- formula1: isFormulaString(formula1) ? getFormulaResult((_a24 = results == null ? void 0 : results[0]) == null ? void 0 : _a24.result) : formula1,
1728
- formula2: isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2
1729
- };
1730
- }
1731
- drawWith(ctx, info) {
1732
- var _a24, _b, _c, _d, _e, _f;
1733
- const { style, data, primaryWithCoord, unitId, subUnitId, worksheet, row, col } = info, cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, value = getCellValueOrigin(worksheet.getCellRaw(row, col)), rule = (_a24 = data.dataValidation) == null ? void 0 : _a24.rule, validator = (_b = data.dataValidation) == null ? void 0 : _b.validator;
1734
- if (!rule || !validator)
1735
- return;
1736
- const colors = this._themeService.getCurrentTheme();
1737
- if (!((_c = validator.skipDefaultFontRender) != null && _c.call(validator, rule, value, { unitId, subUnitId })))
1738
- return;
1739
- const result = validator.parseFormulaSync(rule, unitId, subUnitId), { formula1 } = result, layout = this._calc(cellBounding, style), { a: scaleX, d: scaleY } = ctx.getTransform(), left = fixLineWidthByScale(layout.left, scaleX), top = fixLineWidthByScale(layout.top, scaleY), transform = Transform.create().composeMatrix({
1740
- left,
1741
- top,
1742
- scaleX: 1,
1743
- scaleY: 1,
1744
- angle: 0,
1745
- skewX: 0,
1746
- skewY: 0,
1747
- flipX: !1,
1748
- flipY: !1
1749
- }), cellWidth = cellBounding.endX - cellBounding.startX, cellHeight = cellBounding.endY - cellBounding.startY;
1750
- ctx.save(), ctx.beginPath(), ctx.rect(cellBounding.startX, cellBounding.startY, cellWidth, cellHeight), ctx.clip();
1751
- const m2 = transform.getMatrix();
1752
- ctx.transform(m2[0], m2[1], m2[2], m2[3], m2[4], m2[5]);
1753
- const size = ((_d = style == null ? void 0 : style.fs) != null ? _d : 10) * 1.6, checked = String(value) === String(formula1), defaultColor = colors.hyacinth500;
1754
- Checkbox$1.drawWith(ctx, {
1755
- checked,
1756
- width: size,
1757
- height: size,
1758
- fill: (_f = (_e = style == null ? void 0 : style.cl) == null ? void 0 : _e.rgb) != null ? _f : defaultColor
1759
- }), ctx.restore();
1760
- }
1761
- isHit(evt, info) {
1762
- const cellBounding = info.primaryWithCoord.isMergedMainCell ? info.primaryWithCoord.mergeInfo : info.primaryWithCoord, layout = this._calc(cellBounding, info.style), startY = layout.top, endY = layout.top + layout.height, startX = layout.left, endX = layout.left + layout.width, { x: offsetX, y: offsetY } = evt;
1763
- return offsetX <= endX && offsetX >= startX && offsetY <= endY && offsetY >= startY;
1764
- }
1765
- async onPointerDown(info, evt) {
1766
- var _a24, _b, _c;
1767
- if (evt.button === 2)
1768
- return;
1769
- const { primaryWithCoord, unitId, subUnitId, data, worksheet, row, col } = info, value = getCellValueOrigin(worksheet.getCellRaw(row, col)), rule = (_a24 = data.dataValidation) == null ? void 0 : _a24.rule, validator = (_b = data.dataValidation) == null ? void 0 : _b.validator;
1770
- if (!rule || !validator || !((_c = validator.skipDefaultFontRender) != null && _c.call(validator, rule, value, { unitId, subUnitId })))
1771
- return;
1772
- const { formula1, formula2 } = await this._parseFormula(rule, unitId, subUnitId), params = {
1773
- range: {
1774
- startColumn: primaryWithCoord.actualColumn,
1775
- endColumn: primaryWithCoord.actualColumn,
1776
- startRow: primaryWithCoord.actualRow,
1777
- endRow: primaryWithCoord.actualRow
1778
- },
1779
- value: {
1780
- v: String(value) === transformCheckboxValue(String(formula1)) ? formula2 : formula1,
1781
- p: null
1782
- }
1783
- };
1784
- this._commandService.executeCommand(
1785
- SetRangeValuesCommand.id,
1786
- params
1787
- );
1788
- }
1789
- }, __name(_a6, "CheckboxRender"), _a6);
1790
- CheckboxRender = __decorateClass$g([
1791
- __decorateParam$g(0, ICommandService),
1792
- __decorateParam$g(1, Inject(DataValidationFormulaService)),
1793
- __decorateParam$g(2, Inject(ThemeService))
1794
- ], CheckboxRender);
1795
1081
  const CHECKBOX_FORMULA_1 = 1, CHECKBOX_FORMULA_2 = 0;
1796
1082
  function getFailMessage(formula, localeService) {
1797
1083
  return Tools.isBlank(formula) ? localeService.t("dataValidation.validFail.value") : isFormulaString(formula) ? localeService.t("dataValidation.validFail.primitive") : "";
@@ -1804,8 +1090,6 @@ const transformCheckboxValue = /* @__PURE__ */ __name((value) => Tools.isDefine(
1804
1090
  __publicField(this, "title", "dataValidation.checkbox.title");
1805
1091
  __publicField(this, "operators", []);
1806
1092
  __publicField(this, "scopes", ["sheet"]);
1807
- __publicField(this, "formulaInput", CHECKBOX_FORMULA_INPUT_NAME);
1808
- __publicField(this, "canvasRender", this.injector.createInstance(CheckboxRender));
1809
1093
  __publicField(this, "_formulaService", this.injector.get(DataValidationFormulaService));
1810
1094
  __publicField(this, "skipDefaultFontRender", /* @__PURE__ */ __name((rule, cellValue, pos) => {
1811
1095
  const { formula1, formula2 } = this.parseFormulaSync(rule, pos.unitId, pos.subUnitId), valueStr = `${cellValue != null ? cellValue : ""}`;
@@ -1832,8 +1116,8 @@ const transformCheckboxValue = /* @__PURE__ */ __name((value) => Tools.isDefine(
1832
1116
  };
1833
1117
  }
1834
1118
  async parseFormula(rule, unitId, subUnitId) {
1835
- var _a24, _b;
1836
- const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), originFormula1 = isFormulaString(formula1) ? getFormulaResult((_a24 = results == null ? void 0 : results[0]) == null ? void 0 : _a24.result) : formula1, originFormula2 = isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2;
1119
+ var _a11, _b;
1120
+ const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), originFormula1 = isFormulaString(formula1) ? getFormulaResult((_a11 = results == null ? void 0 : results[0]) == null ? void 0 : _a11.result) : formula1, originFormula2 = isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2;
1837
1121
  return {
1838
1122
  formula1: transformCheckboxValue(originFormula1),
1839
1123
  formula2: transformCheckboxValue(originFormula2),
@@ -1847,8 +1131,8 @@ const transformCheckboxValue = /* @__PURE__ */ __name((value) => Tools.isDefine(
1847
1131
  };
1848
1132
  }
1849
1133
  parseFormulaSync(rule, unitId, subUnitId) {
1850
- var _a24, _b;
1851
- const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = this._formulaService.getRuleFormulaResultSync(unitId, subUnitId, rule.uid), originFormula1 = isFormulaString(formula1) ? getFormulaResult((_a24 = results == null ? void 0 : results[0]) == null ? void 0 : _a24.result) : formula1, originFormula2 = isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2;
1134
+ var _a11, _b;
1135
+ const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = this._formulaService.getRuleFormulaResultSync(unitId, subUnitId, rule.uid), originFormula1 = isFormulaString(formula1) ? getFormulaResult((_a11 = results == null ? void 0 : results[0]) == null ? void 0 : _a11.result) : formula1, originFormula2 = isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2;
1852
1136
  return {
1853
1137
  formula1: transformCheckboxValue(originFormula1),
1854
1138
  formula2: transformCheckboxValue(originFormula2),
@@ -1898,1064 +1182,54 @@ const DateOperatorTitleMap = {
1898
1182
  }, TWO_FORMULA_OPERATOR_COUNT = [
1899
1183
  DataValidationOperator.BETWEEN,
1900
1184
  DataValidationOperator.NOT_BETWEEN
1901
- ];
1902
- var utc$1 = { exports: {} };
1903
- (function(module, exports) {
1904
- (function(t, i) {
1905
- module.exports = i();
1906
- })(commonjsGlobal, function() {
1907
- var t = "minute", i = /[+-]\d\d(?::?\d\d)?/g, e = /([+-]|\d\d)/g;
1908
- return function(s, f2, n2) {
1909
- var u = f2.prototype;
1910
- n2.utc = function(t2) {
1911
- var i2 = { date: t2, utc: !0, args: arguments };
1912
- return new f2(i2);
1913
- }, u.utc = function(i2) {
1914
- var e2 = n2(this.toDate(), { locale: this.$L, utc: !0 });
1915
- return i2 ? e2.add(this.utcOffset(), t) : e2;
1916
- }, u.local = function() {
1917
- return n2(this.toDate(), { locale: this.$L, utc: !1 });
1918
- };
1919
- var o = u.parse;
1920
- u.parse = function(t2) {
1921
- t2.utc && (this.$u = !0), this.$utils().u(t2.$offset) || (this.$offset = t2.$offset), o.call(this, t2);
1922
- };
1923
- var r = u.init;
1924
- u.init = function() {
1925
- if (this.$u) {
1926
- var t2 = this.$d;
1927
- this.$y = t2.getUTCFullYear(), this.$M = t2.getUTCMonth(), this.$D = t2.getUTCDate(), this.$W = t2.getUTCDay(), this.$H = t2.getUTCHours(), this.$m = t2.getUTCMinutes(), this.$s = t2.getUTCSeconds(), this.$ms = t2.getUTCMilliseconds();
1928
- } else r.call(this);
1929
- };
1930
- var a = u.utcOffset;
1931
- u.utcOffset = function(s2, f3) {
1932
- var n3 = this.$utils().u;
1933
- if (n3(s2)) return this.$u ? 0 : n3(this.$offset) ? a.call(this) : this.$offset;
1934
- if (typeof s2 == "string" && (s2 = function(t2) {
1935
- t2 === void 0 && (t2 = "");
1936
- var s3 = t2.match(i);
1937
- if (!s3) return null;
1938
- var f4 = ("" + s3[0]).match(e) || ["-", 0, 0], n4 = f4[0], u3 = 60 * +f4[1] + +f4[2];
1939
- return u3 === 0 ? 0 : n4 === "+" ? u3 : -u3;
1940
- }(s2), s2 === null)) return this;
1941
- var u2 = Math.abs(s2) <= 16 ? 60 * s2 : s2, o2 = this;
1942
- if (f3) return o2.$offset = u2, o2.$u = s2 === 0, o2;
1943
- if (s2 !== 0) {
1944
- var r2 = this.$u ? this.toDate().getTimezoneOffset() : -1 * this.utcOffset();
1945
- (o2 = this.local().add(u2 + r2, t)).$offset = u2, o2.$x.$localOffset = r2;
1946
- } else o2 = this.utc();
1947
- return o2;
1948
- };
1949
- var h = u.format;
1950
- u.format = function(t2) {
1951
- var i2 = t2 || (this.$u ? "YYYY-MM-DDTHH:mm:ss[Z]" : "");
1952
- return h.call(this, i2);
1953
- }, u.valueOf = function() {
1954
- var t2 = this.$utils().u(this.$offset) ? 0 : this.$offset + (this.$x.$localOffset || this.$d.getTimezoneOffset());
1955
- return this.$d.valueOf() - 6e4 * t2;
1956
- }, u.isUTC = function() {
1957
- return !!this.$u;
1958
- }, u.toISOString = function() {
1959
- return this.toDate().toISOString();
1960
- }, u.toString = function() {
1961
- return this.toDate().toUTCString();
1962
- };
1963
- var l2 = u.toDate;
1964
- u.toDate = function(t2) {
1965
- return t2 === "s" && this.$offset ? n2(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate() : l2.call(this);
1966
- };
1967
- var c = u.diff;
1968
- u.diff = function(t2, i2, e2) {
1969
- if (t2 && this.$u === t2.$u) return c.call(this, t2, i2, e2);
1970
- var s2 = this.local(), f3 = n2(t2).local();
1971
- return c.call(s2, f3, i2, e2);
1972
- };
1973
- };
1974
- });
1975
- })(utc$1);
1976
- var utcExports = utc$1.exports;
1977
- const utc = /* @__PURE__ */ getDefaultExportFromCjs(utcExports);
1978
- var __defProp$f = Object.defineProperty, __getOwnPropDesc$f = Object.getOwnPropertyDescriptor, __decorateClass$f = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1979
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1980
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1981
- return kind && result && __defProp$f(target, key, result), result;
1982
- }, "__decorateClass$f"), __decorateParam$f = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$f"), _a7;
1983
- let DataValidationRejectInputController = (_a7 = class extends Disposable {
1984
- constructor(_editorBridgeService, _dataValidationModel, _dataValidatorRegistryService, _dialogService, _localeService) {
1985
- super(), this._editorBridgeService = _editorBridgeService, this._dataValidationModel = _dataValidationModel, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._dialogService = _dialogService, this._localeService = _localeService, this._initEditorBridgeInterceptor();
1986
- }
1987
- _initEditorBridgeInterceptor() {
1988
- this._editorBridgeService.interceptor.intercept(
1989
- this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT_ASYNC,
1990
- {
1991
- handler: /* @__PURE__ */ __name(async (cellPromise, context, next) => {
1992
- var _a24;
1993
- const cell = await cellPromise, { worksheet, row, col, unitId, subUnitId, workbook } = context, ruleId = this._dataValidationModel.getRuleIdByLocation(unitId, subUnitId, row, col), rule = ruleId ? this._dataValidationModel.getRuleById(unitId, subUnitId, ruleId) : void 0;
1994
- if (!rule || rule.errorStyle !== DataValidationErrorStyle.STOP)
1995
- return next(Promise.resolve(cell));
1996
- const validator = await this._dataValidatorRegistryService.getValidatorItem(rule.type);
1997
- if (!validator || await validator.validator(
1998
- {
1999
- value: getCellValueOrigin(cell),
2000
- interceptValue: getCellValueOrigin((_a24 = context == null ? void 0 : context.origin) != null ? _a24 : cell),
2001
- row,
2002
- column: col,
2003
- unitId,
2004
- subUnitId,
2005
- worksheet,
2006
- workbook,
2007
- t: cell == null ? void 0 : cell.t
2008
- },
2009
- rule
2010
- ))
2011
- return next(Promise.resolve(cell));
2012
- const oldCell = worksheet.getCellRaw(row, col);
2013
- return this._dialogService.open({
2014
- width: 368,
2015
- title: {
2016
- title: this._localeService.t("dataValidation.alert.title")
2017
- },
2018
- id: "reject-input-dialog",
2019
- children: {
2020
- title: validator.getRuleFinalError(rule)
2021
- },
2022
- footer: {
2023
- title: React.createElement(
2024
- Button,
2025
- {
2026
- type: "primary",
2027
- onClick: /* @__PURE__ */ __name(() => this._dialogService.close("reject-input-dialog"), "onClick")
2028
- },
2029
- this._localeService.t("dataValidation.alert.ok")
2030
- )
2031
- },
2032
- onClose: /* @__PURE__ */ __name(() => {
2033
- this._dialogService.close("reject-input-dialog");
2034
- }, "onClose")
2035
- }), next(Promise.resolve(oldCell));
2036
- }, "handler")
2037
- }
2038
- );
2039
- }
2040
- showReject(title) {
2041
- this._dialogService.open({
2042
- width: 368,
2043
- title: {
2044
- title: this._localeService.t("dataValidation.alert.title")
2045
- },
2046
- id: "reject-input-dialog",
2047
- children: {
2048
- title
2049
- },
2050
- footer: {
2051
- title: React.createElement(
2052
- Button,
2053
- {
2054
- type: "primary",
2055
- onClick: /* @__PURE__ */ __name(() => this._dialogService.close("reject-input-dialog"), "onClick")
2056
- },
2057
- this._localeService.t("dataValidation.alert.ok")
2058
- )
2059
- },
2060
- onClose: /* @__PURE__ */ __name(() => {
2061
- this._dialogService.close("reject-input-dialog");
2062
- }, "onClose")
2063
- });
2064
- }
2065
- }, __name(_a7, "DataValidationRejectInputController"), _a7);
2066
- DataValidationRejectInputController = __decorateClass$f([
2067
- OnLifecycle(LifecycleStages.Ready, DataValidationRejectInputController),
2068
- __decorateParam$f(0, IEditorBridgeService),
2069
- __decorateParam$f(1, Inject(SheetDataValidationModel)),
2070
- __decorateParam$f(2, Inject(DataValidatorRegistryService)),
2071
- __decorateParam$f(3, IDialogService),
2072
- __decorateParam$f(4, Inject(LocaleService))
2073
- ], DataValidationRejectInputController);
2074
- const dvDateDropdown = "univer-dv-date-dropdown", dvDateDropdownBtns = "univer-dv-date-dropdown-btns", styles$5 = {
2075
- dvDateDropdown,
2076
- dvDateDropdownBtns
2077
- };
2078
- dayjs.extend(utc);
2079
- const transformDate = /* @__PURE__ */ __name((value) => {
1185
+ ], FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2SerialNumber = /* @__PURE__ */ __name((value) => {
1186
+ var _a11, _b;
2080
1187
  if (value == null || typeof value == "boolean")
2081
1188
  return;
2082
1189
  if (typeof value == "number" || !Number.isNaN(+value))
2083
- return dayjs(numfmt.format("yyyy-MM-dd HH:mm:ss", Number(value)));
2084
- const date = dayjs(value);
2085
- if (date.isValid())
2086
- return date;
2087
- }, "transformDate");
2088
- function DateDropdown(props) {
2089
- var _a24, _b, _c;
2090
- const { location, hideFn } = props, { worksheet, row, col, unitId, subUnitId, workbook } = location, commandService = useDependency(ICommandService), rejectInputController = useDependency(DataValidationRejectInputController), cellData = worksheet.getCell(row, col), rule = (_a24 = cellData == null ? void 0 : cellData.dataValidation) == null ? void 0 : _a24.rule, validator = (_b = cellData == null ? void 0 : cellData.dataValidation) == null ? void 0 : _b.validator, cellStr = getCellValueOrigin(worksheet.getCellRaw(row, col)), originDate = transformDate(cellStr), [localDate, setLocalDate] = useState(originDate), showTime = !!((_c = rule == null ? void 0 : rule.bizInfo) != null && _c.showTime), date = localDate && localDate.isValid() ? localDate : dayjs(), localeService = useDependency(LocaleService);
2091
- if (!cellData || !rule || !validator)
2092
- return;
2093
- const handleSave = /* @__PURE__ */ __name(async () => {
2094
- var _a25, _b2, _c2;
2095
- if (!date)
2096
- return;
2097
- const dateStr = date.format(showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD 00:00:00"), serialTime = (_a25 = numfmt.parseDate(dateStr)) == null ? void 0 : _a25.v, cellStyle = workbook.getStyles().getStyleByCell(cellData), format = (_c2 = (_b2 = cellStyle == null ? void 0 : cellStyle.n) == null ? void 0 : _b2.pattern) != null ? _c2 : "", patternType = getPatternType(format);
2098
- rule.errorStyle !== DataValidationErrorStyle.STOP || await validator.validator({
2099
- value: serialTime,
2100
- unitId,
2101
- subUnitId,
2102
- row,
2103
- column: col,
2104
- worksheet,
2105
- workbook,
2106
- interceptValue: dateStr.replace("Z", "").replace("T", " "),
2107
- t: CellValueType.NUMBER
2108
- }, rule) ? (commandService.executeCommand(SetRangeValuesCommand.id, {
2109
- unitId,
2110
- subUnitId,
2111
- range: {
2112
- startColumn: col,
2113
- endColumn: col,
2114
- startRow: row,
2115
- endRow: row
2116
- },
2117
- value: {
2118
- v: serialTime,
2119
- t: 2,
2120
- p: null,
2121
- f: null,
2122
- si: null,
2123
- s: {
2124
- n: {
2125
- pattern: showTime ? patternType === "datetime" ? format : "yyyy-MM-dd hh:mm:ss" : patternType === "date" ? format : "yyyy-MM-dd"
2126
- }
2127
- }
2128
- }
2129
- }), hideFn()) : rejectInputController.showReject(validator.getRuleFinalError(rule));
2130
- }, "handleSave");
2131
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$5.dvDateDropdown, children: [
2132
- /* @__PURE__ */ jsxRuntimeExports.jsx(
2133
- DatePanel,
2134
- {
2135
- defaultValue: date,
2136
- pickerValue: date,
2137
- showTime: showTime || void 0,
2138
- onSelect: /* @__PURE__ */ __name(async (newValue) => {
2139
- setLocalDate(newValue);
2140
- }, "onSelect"),
2141
- onPanelChange: /* @__PURE__ */ __name((value) => {
2142
- setLocalDate(value);
2143
- }, "onPanelChange"),
2144
- disabledDate: /* @__PURE__ */ __name((current) => !numfmt.parseDate(current.format("YYYY-MM-DD")), "disabledDate")
2145
- }
2146
- ),
2147
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.dvDateDropdownBtns, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "small", type: "primary", onClick: handleSave, disabled: !date.isValid(), children: localeService.t("dataValidation.alert.ok") }) })
2148
- ] });
2149
- }
2150
- __name(DateDropdown, "DateDropdown");
2151
- function CellDropdown() {
2152
- const dropdownManagerService = useDependency(DataValidationDropdownManagerService), activeDropdown = useObservable(dropdownManagerService.activeDropdown$, dropdownManagerService.activeDropdown), componentManager = useDependency(ComponentManager);
2153
- if (!activeDropdown)
2154
- return null;
2155
- const { location, componentKey } = activeDropdown, Component = componentManager.get(componentKey), key = `${location.unitId}-${location.subUnitId}-${location.row}-${location.col}`;
2156
- if (!Component)
2157
- return null;
2158
- const hideFn = /* @__PURE__ */ __name(() => {
2159
- dropdownManagerService.hideDropdown();
2160
- }, "hideFn");
2161
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
2162
- Component,
2163
- {
2164
- location,
2165
- hideFn
2166
- },
2167
- key
2168
- );
2169
- }
2170
- __name(CellDropdown, "CellDropdown");
2171
- const DROP_DOWN_KEY = "sheet.ui.dropdown";
2172
- var __defProp$e = Object.defineProperty, __getOwnPropDesc$e = Object.getOwnPropertyDescriptor, __decorateClass$e = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2173
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2174
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2175
- return kind && result && __defProp$e(target, key, result), result;
2176
- }, "__decorateClass$e"), __decorateParam$e = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$e"), _a8;
2177
- let DataValidationDropdownManagerService = (_a8 = class extends Disposable {
2178
- constructor(_canvasPopupManagerService, _univerInstanceService, _dataValidatorRegistryService, _zenZoneService, _renderManagerService, _dataValidationModel, _sheetsSelectionsService) {
2179
- super();
2180
- __publicField(this, "_activeDropdown");
2181
- __publicField(this, "_activeDropdown$", new Subject());
2182
- __publicField(this, "_currentPopup", null);
2183
- __publicField(this, "activeDropdown$", this._activeDropdown$.asObservable());
2184
- __publicField(this, "_zenVisible", !1);
2185
- this._canvasPopupManagerService = _canvasPopupManagerService, this._univerInstanceService = _univerInstanceService, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._zenZoneService = _zenZoneService, this._renderManagerService = _renderManagerService, this._dataValidationModel = _dataValidationModel, this._sheetsSelectionsService = _sheetsSelectionsService, this._init(), this._initSelectionChange(), this.disposeWithMe(() => {
2186
- this._activeDropdown$.complete();
2187
- });
2188
- }
2189
- get activeDropdown() {
2190
- return this._activeDropdown;
2191
- }
2192
- _init() {
2193
- this.disposeWithMe(this._zenZoneService.visible$.subscribe((visible) => {
2194
- this._zenVisible = visible, visible && this.hideDropdown();
2195
- }));
2196
- }
2197
- _getDropdownByCell(unitId, subUnitId, row, col) {
2198
- const workbook = unitId ? this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET) : this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
2199
- if (!workbook)
2200
- return;
2201
- const worksheet = subUnitId ? workbook.getSheetBySheetId(subUnitId) : workbook.getActiveSheet();
2202
- if (!worksheet)
2203
- return;
2204
- const rule = this._dataValidationModel.getRuleByLocation(workbook.getUnitId(), worksheet.getSheetId(), row, col);
2205
- if (!rule)
2206
- return;
2207
- const validator = this._dataValidatorRegistryService.getValidatorItem(rule.type);
2208
- return validator == null ? void 0 : validator.dropdown;
2209
- }
2210
- _initSelectionChange() {
2211
- this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe((selections) => {
2212
- selections && selections.every((selection) => !(selection.primary && this._getDropdownByCell(selection.primary.unitId, selection.primary.sheetId, selection.primary.actualRow, selection.primary.actualColumn))) && this.hideDropdown();
2213
- }));
2214
- }
2215
- showDropdown(param, closeOnOutSide = !0) {
2216
- const { location } = param, { row, col, unitId, subUnitId } = location;
2217
- if (this._currentPopup && this._currentPopup.dispose(), this._zenVisible)
2218
- return;
2219
- this._activeDropdown = param, this._activeDropdown$.next(this._activeDropdown);
2220
- const currentRender = this._renderManagerService.getRenderById(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY), popupDisposable = this._canvasPopupManagerService.attachPopupToCell(
2221
- row,
2222
- col,
2223
- {
2224
- componentKey: DROP_DOWN_KEY,
2225
- onClickOutside: /* @__PURE__ */ __name(() => {
2226
- closeOnOutSide && this.hideDropdown();
2227
- }, "onClickOutside"),
2228
- offset: [0, 3],
2229
- excludeOutside: [currentRender == null ? void 0 : currentRender.engine.getCanvasElement()].filter(Boolean)
2230
- },
2231
- unitId,
2232
- subUnitId
2233
- );
2234
- if (!popupDisposable)
2235
- throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");
2236
- const disposableCollection = new DisposableCollection();
2237
- disposableCollection.add(popupDisposable), disposableCollection.add({
2238
- dispose: /* @__PURE__ */ __name(() => {
2239
- var _a24, _b;
2240
- (_b = (_a24 = this._activeDropdown) == null ? void 0 : _a24.onHide) == null || _b.call(_a24);
2241
- }, "dispose")
2242
- }), this._currentPopup = disposableCollection;
2243
- }
2244
- hideDropdown() {
2245
- this._activeDropdown && (this._currentPopup && this._currentPopup.dispose(), this._currentPopup = null, this._activeDropdown = null, this._activeDropdown$.next(null));
2246
- }
2247
- showDataValidationDropdown(unitId, subUnitId, row, col, onHide) {
2248
- const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
2249
- if (!workbook)
2250
- return;
2251
- const worksheet = workbook.getSheetBySheetId(subUnitId);
2252
- if (!worksheet)
2253
- return;
2254
- const rule = this._dataValidationModel.getRuleByLocation(workbook.getUnitId(), worksheet.getSheetId(), row, col);
2255
- if (!rule)
2256
- return;
2257
- const validator = this._dataValidatorRegistryService.getValidatorItem(rule.type);
2258
- if (!validator || !validator.dropdown) {
2259
- this.hideDropdown();
2260
- return;
2261
- }
2262
- this.showDropdown({
2263
- location: {
2264
- workbook,
2265
- worksheet,
2266
- row,
2267
- col,
2268
- unitId,
2269
- subUnitId
2270
- },
2271
- componentKey: validator.dropdown,
2272
- onHide
2273
- });
1190
+ return +value;
1191
+ const v = (_a11 = numfmt.parseDate(value)) == null ? void 0 : _a11.v;
1192
+ return Tools.isDefine(v) ? v : (_b = numfmt.parseDate(dayjs(value).format("YYYY-MM-DD HH:mm:ss"))) == null ? void 0 : _b.v;
1193
+ }, "transformDate2SerialNumber"), _DateValidator = class _DateValidator extends BaseDataValidator {
1194
+ constructor() {
1195
+ super(...arguments);
1196
+ __publicField(this, "id", DataValidationType.DATE);
1197
+ __publicField(this, "title", "dataValidation.date.title");
1198
+ __publicField(this, "operators", [
1199
+ DataValidationOperator.BETWEEN,
1200
+ DataValidationOperator.EQUAL,
1201
+ DataValidationOperator.GREATER_THAN,
1202
+ DataValidationOperator.GREATER_THAN_OR_EQUAL,
1203
+ DataValidationOperator.LESS_THAN,
1204
+ DataValidationOperator.LESS_THAN_OR_EQUAL,
1205
+ DataValidationOperator.NOT_BETWEEN,
1206
+ DataValidationOperator.NOT_EQUAL
1207
+ ]);
1208
+ __publicField(this, "scopes", ["sheet"]);
1209
+ __publicField(this, "_formulaService", this.injector.get(DataValidationFormulaService));
2274
1210
  }
2275
- }, __name(_a8, "DataValidationDropdownManagerService"), _a8);
2276
- DataValidationDropdownManagerService = __decorateClass$e([
2277
- __decorateParam$e(0, Inject(SheetCanvasPopManagerService)),
2278
- __decorateParam$e(1, IUniverInstanceService),
2279
- __decorateParam$e(2, Inject(DataValidatorRegistryService)),
2280
- __decorateParam$e(3, IZenZoneService),
2281
- __decorateParam$e(4, IRenderManagerService),
2282
- __decorateParam$e(5, Inject(SheetDataValidationModel)),
2283
- __decorateParam$e(6, Inject(SheetsSelectionsService))
2284
- ], DataValidationDropdownManagerService);
2285
- var __defProp$d = Object.defineProperty, __getOwnPropDesc$d = Object.getOwnPropertyDescriptor, __decorateClass$d = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2286
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2287
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2288
- return kind && result && __defProp$d(target, key, result), result;
2289
- }, "__decorateClass$d"), __decorateParam$d = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$d"), _a9;
2290
- let DataValidationPanelService = (_a9 = class extends Disposable {
2291
- constructor(_univerInstanceService, _sidebarService) {
2292
- super();
2293
- __publicField(this, "_open$", new BehaviorSubject(!1));
2294
- __publicField(this, "open$", this._open$.pipe(distinctUntilChanged()));
2295
- __publicField(this, "_activeRule");
2296
- __publicField(this, "_activeRule$", new BehaviorSubject(void 0));
2297
- __publicField(this, "activeRule$", this._activeRule$.asObservable());
2298
- __publicField(this, "_closeDisposable", null);
2299
- this._univerInstanceService = _univerInstanceService, this._sidebarService = _sidebarService, this.disposeWithMe(
2300
- this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(filter((sheet) => !sheet)).subscribe(() => {
2301
- this.close();
2302
- })
2303
- );
1211
+ async parseFormula(rule, unitId, subUnitId) {
1212
+ var _a11, _b;
1213
+ const results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
1214
+ return {
1215
+ formula1: transformDate2SerialNumber(isFormulaString(formula1) ? getFormulaResult((_a11 = results == null ? void 0 : results[0]) == null ? void 0 : _a11.result) : formula1),
1216
+ formula2: transformDate2SerialNumber(isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2)
1217
+ };
2304
1218
  }
2305
- get activeRule() {
2306
- return this._activeRule;
1219
+ parseFormulaSync(rule, unitId, subUnitId) {
1220
+ var _a11, _b;
1221
+ const results = this._formulaService.getRuleFormulaResultSync(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
1222
+ return {
1223
+ formula1: transformDate2SerialNumber(isFormulaString(formula1) ? getFormulaResult((_a11 = results == null ? void 0 : results[0]) == null ? void 0 : _a11.result) : formula1),
1224
+ formula2: transformDate2SerialNumber(isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2)
1225
+ };
2307
1226
  }
2308
- get isOpen() {
2309
- return this._open$.getValue();
1227
+ async isValidType(info) {
1228
+ const { interceptValue, value } = info;
1229
+ return typeof value == "number" && typeof interceptValue == "string" ? !0 : typeof interceptValue == "string" ? !!numfmt.parseDate(interceptValue) : !1;
2310
1230
  }
2311
- dispose() {
2312
- var _a24;
2313
- super.dispose(), this._open$.next(!1), this._open$.complete(), this._activeRule$.complete(), (_a24 = this._closeDisposable) == null || _a24.dispose();
2314
- }
2315
- open() {
2316
- this._open$.next(!0);
2317
- }
2318
- close() {
2319
- var _a24;
2320
- this._open$.next(!1), (_a24 = this._closeDisposable) == null || _a24.dispose();
2321
- }
2322
- setCloseDisposable(disposable) {
2323
- this._closeDisposable = toDisposable(() => {
2324
- disposable.dispose(), this._closeDisposable = null;
2325
- });
2326
- }
2327
- setActiveRule(rule) {
2328
- this._activeRule = rule, this._activeRule$.next(rule);
2329
- }
2330
- }, __name(_a9, "DataValidationPanelService"), _a9);
2331
- DataValidationPanelService = __decorateClass$d([
2332
- __decorateParam$d(0, IUniverInstanceService),
2333
- __decorateParam$d(1, ISidebarService)
2334
- ], DataValidationPanelService);
2335
- const DATA_VALIDATION_PANEL = "DataValidationPanel", OpenValidationPanelOperation = {
2336
- id: "data-validation.operation.open-validation-panel",
2337
- type: CommandType.OPERATION,
2338
- handler(accessor, params) {
2339
- if (!params)
2340
- return !1;
2341
- const { ruleId, isAdd } = params, dataValidationPanelService = accessor.get(DataValidationPanelService), dataValidationModel = accessor.get(DataValidationModel), univerInstanceService = accessor.get(IUniverInstanceService), sidebarService = accessor.get(ISidebarService), target = getSheetCommandTarget(univerInstanceService);
2342
- if (!target) return !1;
2343
- const { unitId, subUnitId } = target, rule = ruleId ? dataValidationModel.getRuleById(unitId, subUnitId, ruleId) : void 0;
2344
- dataValidationPanelService.open(), dataValidationPanelService.setActiveRule(rule && {
2345
- unitId,
2346
- subUnitId,
2347
- rule
2348
- });
2349
- const disposable = sidebarService.open({
2350
- header: { title: isAdd ? "dataValidation.panel.addTitle" : "dataValidation.panel.title" },
2351
- children: { label: DATA_VALIDATION_PANEL },
2352
- width: 312,
2353
- onClose: /* @__PURE__ */ __name(() => dataValidationPanelService.close(), "onClose")
2354
- });
2355
- return dataValidationPanelService.setCloseDisposable(disposable), !0;
2356
- }
2357
- }, CloseValidationPanelOperation = {
2358
- id: "data-validation.operation.close-validation-panel",
2359
- type: CommandType.OPERATION,
2360
- handler(accessor) {
2361
- return accessor.get(DataValidationPanelService).close(), !0;
2362
- }
2363
- }, ToggleValidationPanelOperation = {
2364
- id: "data-validation.operation.toggle-validation-panel",
2365
- type: CommandType.OPERATION,
2366
- handler(accessor) {
2367
- const commandService = accessor.get(ICommandService), dataValidationPanelService = accessor.get(DataValidationPanelService);
2368
- return dataValidationPanelService.open(), dataValidationPanelService.isOpen ? commandService.executeCommand(CloseValidationPanelOperation.id) : commandService.executeCommand(OpenValidationPanelOperation.id), !0;
2369
- }
2370
- }, ShowDataValidationDropdown = {
2371
- type: CommandType.OPERATION,
2372
- id: "sheet.operation.show-data-validation-dropdown",
2373
- handler(accessor, params) {
2374
- if (!params)
2375
- return !1;
2376
- const dataValidationDropdownManagerService = accessor.get(DataValidationDropdownManagerService), { unitId, subUnitId, row, column } = params, activeDropdown = dataValidationDropdownManagerService.activeDropdown, currLoc = activeDropdown == null ? void 0 : activeDropdown.location;
2377
- return currLoc && currLoc.unitId === unitId && currLoc.subUnitId === subUnitId && currLoc.row === row && currLoc.col === column || dataValidationDropdownManagerService.showDataValidationDropdown(
2378
- unitId,
2379
- subUnitId,
2380
- row,
2381
- column
2382
- ), !0;
2383
- }
2384
- }, HideDataValidationDropdown = {
2385
- type: CommandType.OPERATION,
2386
- id: "sheet.operation.hide-data-validation-dropdown",
2387
- handler(accessor, params) {
2388
- return params ? (accessor.get(DataValidationDropdownManagerService).hideDropdown(), !0) : !1;
2389
- }
2390
- }, PLUGIN_CONFIG_KEY = "sheets-data-validation.config", defaultPluginConfig = {}, dvListDropdown = "univer-dv-list-dropdown", dvListDropdownTitle = "univer-dv-list-dropdown-title", dvListDropdownList = "univer-dv-list-dropdown-list", dvListDropdownListContainer = "univer-dv-list-dropdown-list-container", dvListDropdownSelectedIcon = "univer-dv-list-dropdown-selected-icon", dvListDropdownItemContainer = "univer-dv-list-dropdown-item-container", dvListDropdownItem = "univer-dv-list-dropdown-item", dvListDropdownSplit = "univer-dv-list-dropdown-split", dvListDropdownEdit = "univer-dv-list-dropdown-edit", styles$4 = {
2391
- dvListDropdown,
2392
- dvListDropdownTitle,
2393
- dvListDropdownList,
2394
- dvListDropdownListContainer,
2395
- dvListDropdownSelectedIcon,
2396
- dvListDropdownItemContainer,
2397
- dvListDropdownItem,
2398
- dvListDropdownSplit,
2399
- dvListDropdownEdit
2400
- }, SelectList = /* @__PURE__ */ __name((props) => {
2401
- var _a24, _b;
2402
- const { value, onChange, multiple, options, title, onEdit, style, filter: filter2, location } = props, localeService = useDependency(LocaleService), configService = useDependency(IConfigService), lowerFilter = filter2 == null ? void 0 : filter2.toLowerCase(), { row, col, unitId, subUnitId } = location, filteredOptions = options.filter((item) => lowerFilter ? item.label.toLowerCase().includes(lowerFilter) : !0), showEditOnDropdown = (_b = (_a24 = configService.getConfig(PLUGIN_CONFIG_KEY)) == null ? void 0 : _a24.showEditOnDropdown) != null ? _b : !0, sheetPermissionInterceptorBaseController = useDependency(SheetPermissionInterceptorBaseController), hasPermission = useMemo(() => sheetPermissionInterceptorBaseController.permissionCheckWithRanges(
2403
- {
2404
- workbookTypes: [WorkbookEditablePermission],
2405
- rangeTypes: [RangeProtectionPermissionEditPoint],
2406
- worksheetTypes: [WorksheetEditPermission]
2407
- },
2408
- [{ startColumn: col, startRow: row, endColumn: col, endRow: row }],
2409
- unitId,
2410
- subUnitId
2411
- ), [sheetPermissionInterceptorBaseController, col, row, unitId, subUnitId]);
2412
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$4.dvListDropdown, style, children: [
2413
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$4.dvListDropdownTitle, children: title }),
2414
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$4.dvListDropdownList, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Scrollbar, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$4.dvListDropdownListContainer, children: filteredOptions.map((item, i) => {
2415
- const selected = value.indexOf(item.value) > -1, handleClick = /* @__PURE__ */ __name(() => {
2416
- let set;
2417
- selected ? set = new Set(value.filter((sub) => sub !== item.value)) : set = new Set(multiple ? [...value, item.value] : [item.value]);
2418
- const newValue = [];
2419
- options.forEach((opt) => {
2420
- set.has(opt.value) && newValue.push(opt.value);
2421
- }), onChange(newValue);
2422
- }, "handleClick"), index = item.label.toLocaleLowerCase().indexOf(lowerFilter);
2423
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$4.dvListDropdownItemContainer, onClick: handleClick, children: [
2424
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$4.dvListDropdownItem, style: { background: item.color || DROP_DOWN_DEFAULT_COLOR }, children: lowerFilter && item.label.toLowerCase().includes(lowerFilter) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
2425
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: item.label.substring(0, index) }),
2426
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { fontWeight: "bold" }, children: item.label.substring(index, index + lowerFilter.length) }),
2427
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: item.label.substring(index + lowerFilter.length) })
2428
- ] }) : item.label }),
2429
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$4.dvListDropdownSelectedIcon, children: selected ? /* @__PURE__ */ jsxRuntimeExports.jsx(CheckMarkSingle, {}) : null })
2430
- ] }, i);
2431
- }) }) }, filter2) }),
2432
- showEditOnDropdown && hasPermission ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
2433
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$4.dvListDropdownSplit }),
2434
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$4.dvListDropdownEdit, children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { onClick: onEdit, children: localeService.t("dataValidation.list.edit") }) })
2435
- ] }) : null
2436
- ] });
2437
- }, "SelectList");
2438
- function ListDropDown(props) {
2439
- var _a24, _b;
2440
- const { location, hideFn } = props, { worksheet, row, col, unitId, subUnitId } = location, dataValidationModel = useDependency(DataValidationModel), [editingText, setEditingText] = useState(""), commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), [localValue, setLocalValue] = useState(""), editorBridgeService = useDependency(IEditorBridgeService), instanceService = useDependency(IUniverInstanceService), ruleChange$ = useMemo(() => dataValidationModel.ruleChange$.pipe(debounceTime(16)), []);
2441
- useObservable(ruleChange$);
2442
- const anchorRect = RectPopup.useContext(), cellWidth = anchorRect.right - anchorRect.left;
2443
- if (useEffect(() => {
2444
- const dispose = commandService.onCommandExecuted((command) => {
2445
- var _a25, _b2;
2446
- if (command.id === RichTextEditingMutation.id) {
2447
- const params = command.params, { unitId: unitId2 } = params, unit = instanceService.getUnit(unitId2, UniverInstanceType.UNIVER_DOC);
2448
- if (!unit)
2449
- return;
2450
- const text = BuildTextUtils.transform.getPlainText((_b2 = (_a25 = unit.getSnapshot().body) == null ? void 0 : _a25.dataStream) != null ? _b2 : "");
2451
- setEditingText(text);
2452
- }
2453
- });
2454
- return () => {
2455
- dispose.dispose();
2456
- };
2457
- }, [commandService, instanceService]), !worksheet)
2458
- return null;
2459
- const cellData = worksheet.getCell(row, col), rule = (_a24 = cellData == null ? void 0 : cellData.dataValidation) == null ? void 0 : _a24.rule, validator = (_b = cellData == null ? void 0 : cellData.dataValidation) == null ? void 0 : _b.validator, showColor = (rule == null ? void 0 : rule.renderMode) === DataValidationRenderMode.CUSTOM || (rule == null ? void 0 : rule.renderMode) === void 0;
2460
- if (!cellData || !rule || !validator || validator.id.indexOf(DataValidationType.LIST) !== 0)
2461
- return;
2462
- const multiple = rule.type === DataValidationType.LIST_MULTIPLE, list = validator.getListWithColor(rule, unitId, subUnitId), cellStr = localValue || getDataValidationCellValue(worksheet.getCellRaw(row, col)), value = deserializeListOptions(cellStr), handleEdit = /* @__PURE__ */ __name(() => {
2463
- commandService.executeCommand(OpenValidationPanelOperation.id, {
2464
- ruleId: rule.uid
2465
- }), hideFn();
2466
- }, "handleEdit"), options = list.map((item) => ({
2467
- label: item.label,
2468
- value: item.label,
2469
- color: showColor ? item.color : "transparent"
2470
- }));
2471
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
2472
- SelectList,
2473
- {
2474
- style: { minWidth: cellWidth, maxWidth: Math.max(cellWidth, 200) },
2475
- title: multiple ? localeService.t("dataValidation.listMultiple.dropdown") : localeService.t("dataValidation.list.dropdown"),
2476
- value,
2477
- multiple,
2478
- onChange: /* @__PURE__ */ __name((newValue) => {
2479
- const str = serializeListOptions(newValue), params = {
2480
- unitId,
2481
- subUnitId,
2482
- range: {
2483
- startColumn: col,
2484
- endColumn: col,
2485
- startRow: row,
2486
- endRow: row
2487
- },
2488
- value: {
2489
- v: str,
2490
- p: null,
2491
- f: null,
2492
- si: null
2493
- }
2494
- };
2495
- editorBridgeService.isVisible() && editorBridgeService.changeVisible({
2496
- visible: !1,
2497
- keycode: KeyCode.ESC,
2498
- eventType: DeviceInputEventType.Keyboard,
2499
- unitId
2500
- }), commandService.executeCommand(SetRangeValuesCommand.id, params), setLocalValue(str), multiple || hideFn();
2501
- }, "onChange"),
2502
- options,
2503
- onEdit: handleEdit,
2504
- filter: editingText,
2505
- location
2506
- }
2507
- );
2508
- }
2509
- __name(ListDropDown, "ListDropDown");
2510
- const dataValidationOptionsButton = "univer-data-validation-options-button", dataValidationOptionsButtonIcon = "univer-data-validation-options-button-icon", styles$3 = {
2511
- dataValidationOptionsButton,
2512
- dataValidationOptionsButtonIcon
2513
- };
2514
- function DataValidationOptions(props) {
2515
- var _a24;
2516
- const localeService = useDependency(LocaleService), componentManager = useDependency(ComponentManager), { value, onChange, extraComponent } = props, [show, setShow] = useState(!1), ExtraOptions = extraComponent ? componentManager.get(extraComponent) : null;
2517
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
2518
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$3.dataValidationOptionsButton, onClick: /* @__PURE__ */ __name(() => setShow(!show), "onClick"), children: [
2519
- localeService.t("dataValidation.panel.options"),
2520
- show ? /* @__PURE__ */ jsxRuntimeExports.jsx(MoreUpSingle, { className: styles$3.dataValidationOptionsButtonIcon }) : /* @__PURE__ */ jsxRuntimeExports.jsx(MoreDownSingle, { className: styles$3.dataValidationOptionsButtonIcon })
2521
- ] }),
2522
- show && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
2523
- ExtraOptions ? /* @__PURE__ */ jsxRuntimeExports.jsx(ExtraOptions, { value, onChange }) : null,
2524
- /* @__PURE__ */ jsxRuntimeExports.jsx(
2525
- FormLayout,
2526
- {
2527
- label: localeService.t("dataValidation.panel.invalid"),
2528
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
2529
- RadioGroup,
2530
- {
2531
- value: `${(_a24 = value.errorStyle) != null ? _a24 : DataValidationErrorStyle.WARNING}`,
2532
- onChange: /* @__PURE__ */ __name((errorStyle) => onChange({ ...value, errorStyle: +errorStyle }), "onChange"),
2533
- children: [
2534
- /* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationErrorStyle.WARNING}`, children: localeService.t("dataValidation.panel.showWarning") }),
2535
- /* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationErrorStyle.STOP}`, children: localeService.t("dataValidation.panel.rejectInput") })
2536
- ]
2537
- }
2538
- )
2539
- }
2540
- ),
2541
- /* @__PURE__ */ jsxRuntimeExports.jsx(
2542
- FormLayout,
2543
- {
2544
- label: localeService.t("dataValidation.panel.messageInfo"),
2545
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2546
- Checkbox,
2547
- {
2548
- checked: value.showErrorMessage,
2549
- onChange: /* @__PURE__ */ __name(() => onChange({
2550
- ...value,
2551
- showErrorMessage: !value.showErrorMessage
2552
- }), "onChange"),
2553
- children: localeService.t("dataValidation.panel.showInfo")
2554
- }
2555
- )
2556
- }
2557
- ),
2558
- value.showErrorMessage ? /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { value: value.error, onChange: /* @__PURE__ */ __name((error) => onChange({ ...value, error }), "onChange") }) }) : null
2559
- ] })
2560
- ] });
2561
- }
2562
- __name(DataValidationOptions, "DataValidationOptions");
2563
- const dataValidationDetail = "univer-data-validation-detail", dataValidationDetailFormItem = "univer-data-validation-detail-form-item", dataValidationDetailButtons = "univer-data-validation-detail-buttons", dataValidationDetailButton = "univer-data-validation-detail-button", styles$2 = {
2564
- dataValidationDetail,
2565
- dataValidationDetailFormItem,
2566
- dataValidationDetailButtons,
2567
- dataValidationDetailButton
2568
- }, debounceExecuteFactory = /* @__PURE__ */ __name((commandService) => debounce(
2569
- async (id, params, options, callback) => {
2570
- const res = await commandService.executeCommand(id, params, options);
2571
- callback == null || callback(res);
2572
- },
2573
- 1e3
2574
- ), "debounceExecuteFactory");
2575
- function DataValidationDetail() {
2576
- const [key, setKey] = useState(0), dataValidationPanelService = useDependency(DataValidationPanelService), activeRuleInfo = useObservable(dataValidationPanelService.activeRule$, dataValidationPanelService.activeRule), { unitId, subUnitId, rule } = activeRuleInfo || {}, ruleId = rule.uid, validatorService = useDependency(DataValidatorRegistryService), componentManager = useDependency(ComponentManager), commandService = useDependency(ICommandService), dataValidationModel = useDependency(DataValidationModel), localeService = useDependency(LocaleService), [localRule, setLocalRule] = useState(rule), validator = validatorService.getValidatorItem(localRule.type), [showError, setShowError] = useState(!1), validators = validatorService.getValidatorsByScope(DataValidatorRegistryScope.SHEET), [localRanges, setLocalRanges] = useState(() => localRule.ranges.map((i) => ({ unitId: "", sheetId: "", range: i }))), debounceExecute = useMemo(() => debounceExecuteFactory(commandService), [commandService]);
2577
- if (useEffect(() => {
2578
- commandService.onCommandExecuted((commandInfo) => {
2579
- (commandInfo.id === UndoCommand.id || commandInfo.id === RedoCommand.id) && setTimeout(() => {
2580
- const activeRule = dataValidationModel.getRuleById(unitId, subUnitId, ruleId);
2581
- setKey((k2) => k2 + 1), activeRule && (setLocalRule(activeRule), setLocalRanges(activeRule.ranges.map((i) => ({ unitId: "", sheetId: "", range: i }))));
2582
- }, 20);
2583
- });
2584
- }, [commandService, dataValidationModel, ruleId, subUnitId, unitId]), !validator)
2585
- return null;
2586
- const operators = validator.operators, operatorNames = validator.operatorNames, isTwoFormula = localRule.operator ? TWO_FORMULA_OPERATOR_COUNT$1.includes(localRule.operator) : !1, handleOk = /* @__PURE__ */ __name(() => {
2587
- localRule.ranges.length && (validator.validatorFormula(localRule, unitId, subUnitId).success ? dataValidationPanelService.setActiveRule(null) : setShowError(!0));
2588
- }, "handleOk"), handleUpdateRuleRanges = useEvent((unitRanges) => {
2589
- if (isUnitRangesEqual(unitRanges, localRanges))
2590
- return;
2591
- setLocalRanges(unitRanges);
2592
- const ranges = unitRanges.filter((i) => (!i.unitId || i.unitId === unitId) && (!i.sheetId || i.sheetId === subUnitId)).map((i) => i.range);
2593
- if (setLocalRule({
2594
- ...localRule,
2595
- ranges
2596
- }), ranges.length === 0)
2597
- return;
2598
- const params = {
2599
- unitId,
2600
- subUnitId,
2601
- ruleId,
2602
- ranges
2603
- };
2604
- debounceExecute(UpdateSheetDataValidationRangeCommand.id, params);
2605
- }), handleUpdateRuleSetting = /* @__PURE__ */ __name((setting) => {
2606
- if (shallowEqual(setting, getRuleSetting(localRule)))
2607
- return;
2608
- setLocalRule({
2609
- ...localRule,
2610
- ...setting
2611
- });
2612
- const params = {
2613
- unitId,
2614
- subUnitId,
2615
- ruleId,
2616
- setting
2617
- };
2618
- debounceExecute(
2619
- UpdateSheetDataValidationSettingCommand.id,
2620
- params,
2621
- void 0
2622
- );
2623
- }, "handleUpdateRuleSetting"), handleDelete = /* @__PURE__ */ __name(async () => {
2624
- await commandService.executeCommand(RemoveSheetDataValidationCommand.id, {
2625
- ruleId,
2626
- unitId,
2627
- subUnitId
2628
- }), dataValidationPanelService.setActiveRule(null);
2629
- }, "handleDelete"), baseRule = {
2630
- type: localRule.type,
2631
- operator: localRule.operator,
2632
- formula1: localRule.formula1,
2633
- formula2: localRule.formula2,
2634
- allowBlank: localRule.allowBlank
2635
- }, handleChangeType = /* @__PURE__ */ __name((newType) => {
2636
- const validator2 = validatorService.getValidatorItem(newType);
2637
- if (!validator2)
2638
- return;
2639
- const operators2 = validator2.operators, rule2 = dataValidationModel.getRuleById(unitId, subUnitId, ruleId), newRule = newType === (rule2 == null ? void 0 : rule2.type) || newType.includes("list") && (rule2 != null && rule2.type.includes("list")) ? {
2640
- ...rule2,
2641
- type: newType
2642
- } : {
2643
- ...localRule,
2644
- type: newType,
2645
- operator: operators2[0],
2646
- formula1: void 0,
2647
- formula2: void 0
2648
- };
2649
- setLocalRule(newRule), commandService.executeCommand(UpdateSheetDataValidationSettingCommand.id, {
2650
- unitId,
2651
- subUnitId,
2652
- ruleId: localRule.uid,
2653
- setting: getRuleSetting(newRule)
2654
- });
2655
- }, "handleChangeType"), FormulaInput = componentManager.get(validator.formulaInput), rangeStr = useMemo(() => localRanges.map((i) => serializeRange(i.range)).join(","), []), options = getRuleOptions(localRule), handleUpdateRuleOptions = /* @__PURE__ */ __name((newOptions) => {
2656
- shallowEqual(newOptions, getRuleOptions(localRule)) || (setLocalRule({
2657
- ...localRule,
2658
- ...newOptions
2659
- }), debounceExecute(
2660
- UpdateSheetDataValidationOptionsCommand.id,
2661
- {
2662
- unitId,
2663
- subUnitId,
2664
- ruleId,
2665
- options: newOptions
2666
- }
2667
- ));
2668
- }, "handleUpdateRuleOptions");
2669
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$2.dataValidationDetail, children: [
2670
- /* @__PURE__ */ jsxRuntimeExports.jsx(
2671
- FormLayout,
2672
- {
2673
- label: localeService.t("dataValidation.panel.range"),
2674
- error: localRule.ranges.length ? "" : localeService.t("dataValidation.panel.rangeError"),
2675
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2676
- RangeSelector,
2677
- {
2678
- className: styles$2.dataValidationDetailFormItem,
2679
- value: rangeStr,
2680
- id: createInternalEditorID("data-validation-detail"),
2681
- openForSheetUnitId: unitId,
2682
- openForSheetSubUnitId: subUnitId,
2683
- onChange: /* @__PURE__ */ __name((newRange) => {
2684
- newRange.some((i) => !isValidRange(i.range) || i.range.endColumn < i.range.startColumn || i.range.endRow < i.range.startRow) || handleUpdateRuleRanges(newRange);
2685
- }, "onChange")
2686
- },
2687
- key
2688
- )
2689
- }
2690
- ),
2691
- /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("dataValidation.panel.type"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2692
- Select,
2693
- {
2694
- options: validators == null ? void 0 : validators.map((validator2) => ({
2695
- label: localeService.t(validator2.title),
2696
- value: validator2.id
2697
- })),
2698
- value: localRule.type,
2699
- onChange: handleChangeType,
2700
- className: styles$2.dataValidationDetailFormItem
2701
- }
2702
- ) }),
2703
- operators != null && operators.length ? /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("dataValidation.panel.operator"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2704
- Select,
2705
- {
2706
- options: operators.map((op, i) => ({
2707
- value: `${op}`,
2708
- label: operatorNames[i]
2709
- })),
2710
- value: `${localRule.operator}`,
2711
- onChange: /* @__PURE__ */ __name((operator) => {
2712
- handleUpdateRuleSetting({
2713
- ...baseRule,
2714
- operator
2715
- });
2716
- }, "onChange"),
2717
- className: styles$2.dataValidationDetailFormItem
2718
- }
2719
- ) }) : null,
2720
- FormulaInput ? /* @__PURE__ */ jsxRuntimeExports.jsx(
2721
- FormulaInput,
2722
- {
2723
- isTwoFormula,
2724
- value: {
2725
- formula1: localRule.formula1,
2726
- formula2: localRule.formula2
2727
- },
2728
- onChange: /* @__PURE__ */ __name((value) => {
2729
- handleUpdateRuleSetting({
2730
- ...baseRule,
2731
- ...value
2732
- });
2733
- }, "onChange"),
2734
- showError,
2735
- validResult: validator.validatorFormula(localRule, unitId, subUnitId),
2736
- unitId,
2737
- subUnitId,
2738
- ruleId
2739
- },
2740
- key + localRule.type
2741
- ) : null,
2742
- /* @__PURE__ */ jsxRuntimeExports.jsx(DataValidationOptions, { value: options, onChange: handleUpdateRuleOptions, extraComponent: validator.optionsInput }),
2743
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$2.dataValidationDetailButtons, children: [
2744
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: styles$2.dataValidationDetailButton, onClick: handleDelete, children: localeService.t("dataValidation.panel.removeRule") }),
2745
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: styles$2.dataValidationDetailButton, type: "primary", onClick: handleOk, children: localeService.t("dataValidation.panel.done") })
2746
- ] })
2747
- ] });
2748
- }
2749
- __name(DataValidationDetail, "DataValidationDetail");
2750
- const dataValidationItemContainer = "univer-data-validation-item-container", dataValidationItemTitle = "univer-data-validation-item-title", dataValidationItemContent = "univer-data-validation-item-content", dataValidationItemIcon = "univer-data-validation-item-icon", styles$1 = {
2751
- dataValidationItemContainer,
2752
- dataValidationItemTitle,
2753
- dataValidationItemContent,
2754
- dataValidationItemIcon
2755
- }, DataValidationItem = /* @__PURE__ */ __name((props) => {
2756
- const { rule, onClick, unitId, subUnitId, disable } = props, validatorRegistry = useDependency(DataValidatorRegistryService), commandService = useDependency(ICommandService), markSelectionService = useDependency(IMarkSelectionService), validator = validatorRegistry.getValidatorItem(rule.type), ids = useRef(), [isHover, setIsHover] = useState(!1), handleDelete = /* @__PURE__ */ __name((e) => {
2757
- commandService.executeCommand(RemoveSheetDataValidationCommand.id, {
2758
- ruleId: rule.uid,
2759
- unitId,
2760
- subUnitId
2761
- }), e.stopPropagation();
2762
- }, "handleDelete");
2763
- return useEffect(() => () => {
2764
- var _a24;
2765
- ids.current && ((_a24 = ids.current) == null || _a24.forEach((id) => {
2766
- id && markSelectionService.removeShape(id);
2767
- }));
2768
- }, [markSelectionService]), /* @__PURE__ */ jsxRuntimeExports.jsxs(
2769
- "div",
2770
- {
2771
- className: styles$1.dataValidationItemContainer,
2772
- onClick,
2773
- onMouseEnter: /* @__PURE__ */ __name(() => {
2774
- disable || (setIsHover(!0), ids.current = rule.ranges.map((range) => markSelectionService.addShape({
2775
- range,
2776
- style: {
2777
- hasAutoFill: !1,
2778
- fill: "rgba(73, 184, 17, 0.05)",
2779
- strokeWidth: 1,
2780
- stroke: "#49B811",
2781
- widgets: {}
2782
- },
2783
- primary: {
2784
- startColumn: range.startColumn,
2785
- endColumn: range.endColumn,
2786
- startRow: range.startRow,
2787
- endRow: range.endRow,
2788
- actualRow: range.startRow,
2789
- actualColumn: range.startColumn,
2790
- isMerged: !1,
2791
- isMergedMainCell: !1
2792
- }
2793
- })));
2794
- }, "onMouseEnter"),
2795
- onMouseLeave: /* @__PURE__ */ __name(() => {
2796
- var _a24;
2797
- setIsHover(!1), (_a24 = ids.current) == null || _a24.forEach((id) => {
2798
- id && markSelectionService.removeShape(id);
2799
- }), ids.current = void 0;
2800
- }, "onMouseLeave"),
2801
- children: [
2802
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$1.dataValidationItemTitle, children: validator == null ? void 0 : validator.generateRuleName(rule) }),
2803
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$1.dataValidationItemContent, children: rule.ranges.map((range) => serializeRange(range)).join(",") }),
2804
- isHover ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$1.dataValidationItemIcon, onClick: handleDelete, children: /* @__PURE__ */ jsxRuntimeExports.jsx(DeleteSingle, {}) }) : null
2805
- ]
2806
- }
2807
- );
2808
- }, "DataValidationItem"), dataValidationList = "univer-data-validation-list", dataValidationListButtons = "univer-data-validation-list-buttons", dataValidationListButton = "univer-data-validation-list-button", styles = {
2809
- dataValidationList,
2810
- dataValidationListButtons,
2811
- dataValidationListButton
2812
- };
2813
- function DataValidationList() {
2814
- const univerInstanceService = useDependency(IUniverInstanceService), workbook = useObservable(
2815
- () => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET),
2816
- void 0,
2817
- void 0,
2818
- []
2819
- );
2820
- return workbook ? /* @__PURE__ */ jsxRuntimeExports.jsx(DataValidationListWithWorkbook, { workbook }) : null;
2821
- }
2822
- __name(DataValidationList, "DataValidationList");
2823
- function DataValidationListWithWorkbook(props) {
2824
- const sheetDataValidationModel = useDependency(SheetDataValidationModel), univerInstanceService = useDependency(IUniverInstanceService), commandService = useDependency(ICommandService), injector = useDependency(Injector), dataValidationPanelService = useDependency(DataValidationPanelService), localeService = useDependency(LocaleService), [rules, setRules] = useState([]), { workbook } = props, worksheet = useObservable(workbook.activeSheet$, void 0, !0), unitId = workbook.getUnitId(), subUnitId = worksheet == null ? void 0 : worksheet.getSheetId();
2825
- useEffect(() => {
2826
- setRules(sheetDataValidationModel.getRules(unitId, subUnitId));
2827
- const subscription = sheetDataValidationModel.ruleChange$.subscribe((change) => {
2828
- change.unitId === unitId && change.subUnitId === subUnitId && setRules(sheetDataValidationModel.getRules(unitId, subUnitId));
2829
- });
2830
- return () => {
2831
- subscription.unsubscribe();
2832
- };
2833
- }, [unitId, subUnitId, sheetDataValidationModel]);
2834
- const handleAddRule = /* @__PURE__ */ __name(async () => {
2835
- const rule = createDefaultNewRule(injector), params = {
2836
- unitId,
2837
- subUnitId,
2838
- rule
2839
- };
2840
- await commandService.executeCommand(AddSheetDataValidationCommand.id, params), dataValidationPanelService.setActiveRule({
2841
- unitId,
2842
- subUnitId,
2843
- rule
2844
- });
2845
- }, "handleAddRule"), handleRemoveAll = /* @__PURE__ */ __name(() => {
2846
- commandService.executeCommand(RemoveSheetAllDataValidationCommand.id, {
2847
- unitId,
2848
- subUnitId
2849
- });
2850
- }, "handleRemoveAll"), rulesByPermissionCheck = (/* @__PURE__ */ __name((rules2) => {
2851
- const workbook2 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), worksheet2 = workbook2.getActiveSheet(), unitId2 = workbook2.getUnitId(), subUnitId2 = worksheet2.getSheetId();
2852
- return rules2.map((rule) => checkRangesEditablePermission(injector, unitId2, subUnitId2, rule.ranges) ? { ...rule } : { ...rule, disable: !0 });
2853
- }, "getDvRulesByPermissionCorrect"))(rules), hasDisableRule = rulesByPermissionCheck == null ? void 0 : rulesByPermissionCheck.some((rule) => rule.disable);
2854
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.dataValidationList, children: [
2855
- rulesByPermissionCheck == null ? void 0 : rulesByPermissionCheck.map((rule) => {
2856
- var _a24;
2857
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
2858
- DataValidationItem,
2859
- {
2860
- unitId,
2861
- subUnitId,
2862
- onClick: /* @__PURE__ */ __name(() => {
2863
- rule.disable || dataValidationPanelService.setActiveRule({
2864
- unitId,
2865
- subUnitId,
2866
- rule
2867
- });
2868
- }, "onClick"),
2869
- rule,
2870
- disable: (_a24 = rule.disable) != null ? _a24 : !1
2871
- },
2872
- rule.uid
2873
- );
2874
- }),
2875
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.dataValidationListButtons, children: [
2876
- rules.length && !hasDisableRule ? /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: styles.dataValidationListButton, onClick: handleRemoveAll, children: localeService.t("dataValidation.panel.removeAll") }) : null,
2877
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: styles.dataValidationListButton, type: "primary", onClick: handleAddRule, children: localeService.t("dataValidation.panel.add") })
2878
- ] })
2879
- ] });
2880
- }
2881
- __name(DataValidationListWithWorkbook, "DataValidationListWithWorkbook");
2882
- const DataValidationPanel = /* @__PURE__ */ __name(() => {
2883
- const dataValidationPanelService = useDependency(DataValidationPanelService), activeRule = useObservable(dataValidationPanelService.activeRule$, dataValidationPanelService.activeRule);
2884
- return activeRule ? /* @__PURE__ */ jsxRuntimeExports.jsx(DataValidationDetail, {}, activeRule.rule.uid) : /* @__PURE__ */ jsxRuntimeExports.jsx(DataValidationList, {});
2885
- }, "DataValidationPanel"), LIST_DROPDOWN_KEY = "data-validation.list.dropdown", DATE_DROPDOWN_KEY = "data-validation.date.dropdown", DATE_SHOW_TIME_OPTION = "DATE_SHOW_TIME_OPTION";
2886
- function DateShowTimeOption(props) {
2887
- var _a24;
2888
- const { value, onChange } = props, localeService = useDependency(LocaleService);
2889
- return /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2890
- Checkbox,
2891
- {
2892
- checked: (_a24 = value.bizInfo) == null ? void 0 : _a24.showTime,
2893
- onChange: /* @__PURE__ */ __name((showTime) => {
2894
- onChange({
2895
- ...value,
2896
- bizInfo: {
2897
- ...value.bizInfo,
2898
- showTime
2899
- }
2900
- });
2901
- }, "onChange"),
2902
- children: localeService.t("dataValidation.showTime.label")
2903
- }
2904
- ) });
2905
- }
2906
- __name(DateShowTimeOption, "DateShowTimeOption");
2907
- DateShowTimeOption.componentKey = DATE_SHOW_TIME_OPTION;
2908
- const FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2SerialNumber = /* @__PURE__ */ __name((value) => {
2909
- var _a24, _b;
2910
- if (value == null || typeof value == "boolean")
2911
- return;
2912
- if (typeof value == "number" || !Number.isNaN(+value))
2913
- return +value;
2914
- const v = (_a24 = numfmt.parseDate(value)) == null ? void 0 : _a24.v;
2915
- return Tools.isDefine(v) ? v : (_b = numfmt.parseDate(dayjs(value).format("YYYY-MM-DD HH:mm:ss"))) == null ? void 0 : _b.v;
2916
- }, "transformDate2SerialNumber"), _DateValidator = class _DateValidator extends BaseDataValidator {
2917
- constructor() {
2918
- super(...arguments);
2919
- __publicField(this, "id", DataValidationType.DATE);
2920
- __publicField(this, "title", "dataValidation.date.title");
2921
- __publicField(this, "operators", [
2922
- DataValidationOperator.BETWEEN,
2923
- DataValidationOperator.EQUAL,
2924
- DataValidationOperator.GREATER_THAN,
2925
- DataValidationOperator.GREATER_THAN_OR_EQUAL,
2926
- DataValidationOperator.LESS_THAN,
2927
- DataValidationOperator.LESS_THAN_OR_EQUAL,
2928
- DataValidationOperator.NOT_BETWEEN,
2929
- DataValidationOperator.NOT_EQUAL
2930
- ]);
2931
- __publicField(this, "scopes", ["sheet"]);
2932
- __publicField(this, "formulaInput", BASE_FORMULA_INPUT_NAME);
2933
- __publicField(this, "optionsInput", DateShowTimeOption.componentKey);
2934
- __publicField(this, "dropdown", DATE_DROPDOWN_KEY);
2935
- __publicField(this, "_formulaService", this.injector.get(DataValidationFormulaService));
2936
- }
2937
- async parseFormula(rule, unitId, subUnitId) {
2938
- var _a24, _b;
2939
- const results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
2940
- return {
2941
- formula1: transformDate2SerialNumber(isFormulaString(formula1) ? getFormulaResult((_a24 = results == null ? void 0 : results[0]) == null ? void 0 : _a24.result) : formula1),
2942
- formula2: transformDate2SerialNumber(isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2)
2943
- };
2944
- }
2945
- parseFormulaSync(rule, unitId, subUnitId) {
2946
- var _a24, _b;
2947
- const results = this._formulaService.getRuleFormulaResultSync(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
2948
- return {
2949
- formula1: transformDate2SerialNumber(isFormulaString(formula1) ? getFormulaResult((_a24 = results == null ? void 0 : results[0]) == null ? void 0 : _a24.result) : formula1),
2950
- formula2: transformDate2SerialNumber(isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2)
2951
- };
2952
- }
2953
- async isValidType(info) {
2954
- const { interceptValue, value } = info;
2955
- return typeof value == "number" && typeof interceptValue == "string" ? !0 : typeof interceptValue == "string" ? !!numfmt.parseDate(interceptValue) : !1;
2956
- }
2957
- _validatorSingleFormula(formula) {
2958
- return !Tools.isBlank(formula) && (isFormulaString(formula) || !Number.isNaN(+formula) || !!(formula && numfmt.parseDate(formula)));
1231
+ _validatorSingleFormula(formula) {
1232
+ return !Tools.isBlank(formula) && (isFormulaString(formula) || !Number.isNaN(+formula) || !!(formula && numfmt.parseDate(formula)));
2959
1233
  }
2960
1234
  validatorFormula(rule, unitId, subUnitId) {
2961
1235
  const operator = rule.operator;
@@ -2979,14 +1253,14 @@ const FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2Serial
2979
1253
  }
2980
1254
  normalizeFormula(rule, _unitId, _subUnitId) {
2981
1255
  const { formula1, formula2, bizInfo } = rule, normlizeSingleFormula = /* @__PURE__ */ __name((formula) => {
2982
- var _a24;
1256
+ var _a11;
2983
1257
  if (!formula)
2984
1258
  return formula;
2985
1259
  let date;
2986
1260
  if (!Number.isNaN(+formula))
2987
1261
  date = numfmt.dateFromSerial(+formula);
2988
1262
  else {
2989
- const res = (_a24 = numfmt.parseDate(formula)) == null ? void 0 : _a24.v;
1263
+ const res = (_a11 = numfmt.parseDate(formula)) == null ? void 0 : _a11.v;
2990
1264
  if (res == null)
2991
1265
  return "";
2992
1266
  date = numfmt.dateFromSerial(res);
@@ -3047,15 +1321,15 @@ const FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2Serial
3047
1321
  return this.operators.map((operator) => this.localeService.t(DateOperatorNameMap[operator]));
3048
1322
  }
3049
1323
  generateRuleName(rule) {
3050
- var _a24, _b;
1324
+ var _a11, _b;
3051
1325
  if (!rule.operator)
3052
1326
  return this.titleStr;
3053
- const ruleName = this.localeService.t(DateOperatorTitleMap[rule.operator]).replace(FORMULA1$1, (_a24 = rule.formula1) != null ? _a24 : "").replace(FORMULA2$1, (_b = rule.formula2) != null ? _b : "");
1327
+ const ruleName = this.localeService.t(DateOperatorTitleMap[rule.operator]).replace(FORMULA1$1, (_a11 = rule.formula1) != null ? _a11 : "").replace(FORMULA2$1, (_b = rule.formula2) != null ? _b : "");
3054
1328
  return `${this.titleStr} ${ruleName}`;
3055
1329
  }
3056
1330
  generateRuleErrorMessage(rule) {
3057
- var _a24, _b;
3058
- return rule.operator ? `${this.localeService.t(DateOperatorErrorTitleMap[rule.operator]).replace(FORMULA1$1, (_a24 = rule.formula1) != null ? _a24 : "").replace(FORMULA2$1, (_b = rule.formula2) != null ? _b : "")}` : this.titleStr;
1331
+ var _a11, _b;
1332
+ return rule.operator ? `${this.localeService.t(DateOperatorErrorTitleMap[rule.operator]).replace(FORMULA1$1, (_a11 = rule.formula1) != null ? _a11 : "").replace(FORMULA2$1, (_b = rule.formula2) != null ? _b : "")}` : this.titleStr;
3059
1333
  }
3060
1334
  };
3061
1335
  __name(_DateValidator, "DateValidator");
@@ -3082,8 +1356,6 @@ const _DecimalValidator = class _DecimalValidator extends BaseDataValidator {
3082
1356
  DataValidationOperator.NOT_EQUAL
3083
1357
  ]);
3084
1358
  __publicField(this, "scopes", ["sheet"]);
3085
- __publicField(this, "formulaInput", BASE_FORMULA_INPUT_NAME);
3086
- __publicField(this, "dropDownInput");
3087
1359
  }
3088
1360
  _isFormulaOrNumber(formula) {
3089
1361
  return !Tools.isBlank(formula) && (isFormulaString(formula) || !Number.isNaN(+formula));
@@ -3103,10 +1375,10 @@ const _DecimalValidator = class _DecimalValidator extends BaseDataValidator {
3103
1375
  return formula == null ? Number.NaN : +formula;
3104
1376
  }
3105
1377
  async parseFormula(rule, unitId, subUnitId) {
3106
- var _a24, _b, _c, _d, _e, _f, _g, _h;
1378
+ var _a11, _b, _c, _d, _e, _f, _g, _h;
3107
1379
  const formulaInfo = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
3108
1380
  return {
3109
- formula1: this._parseNumber(isFormulaString(formula1) ? (_d = (_c = (_b = (_a24 = formulaInfo == null ? void 0 : formulaInfo[0]) == null ? void 0 : _a24.result) == null ? void 0 : _b[0]) == null ? void 0 : _c[0]) == null ? void 0 : _d.v : formula1),
1381
+ formula1: this._parseNumber(isFormulaString(formula1) ? (_d = (_c = (_b = (_a11 = formulaInfo == null ? void 0 : formulaInfo[0]) == null ? void 0 : _a11.result) == null ? void 0 : _b[0]) == null ? void 0 : _c[0]) == null ? void 0 : _d.v : formula1),
3110
1382
  formula2: this._parseNumber(isFormulaString(formula2) ? (_h = (_g = (_f = (_e = formulaInfo == null ? void 0 : formulaInfo[1]) == null ? void 0 : _e.result) == null ? void 0 : _f[0]) == null ? void 0 : _g[0]) == null ? void 0 : _h.v : formula2)
3111
1383
  };
3112
1384
  }
@@ -3167,246 +1439,19 @@ const _DecimalValidator = class _DecimalValidator extends BaseDataValidator {
3167
1439
  };
3168
1440
  __name(_DecimalValidator, "DecimalValidator");
3169
1441
  let DecimalValidator = _DecimalValidator;
3170
- const LIST_RENDER_MODE_OPTION_INPUT = "LIST_RENDER_MODE_OPTION_INPUT";
3171
- function ListRenderModeInput(props) {
3172
- var _a24;
3173
- const { value, onChange } = props, localeService = useDependency(LocaleService);
3174
- return /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("dataValidation.renderMode.label"), children: /* @__PURE__ */ jsxRuntimeExports.jsxs(RadioGroup, { value: `${(_a24 = value.renderMode) != null ? _a24 : DataValidationRenderMode.CUSTOM}`, onChange: /* @__PURE__ */ __name((renderMode) => onChange({ ...value, renderMode: +renderMode }), "onChange"), children: [
3175
- /* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.CUSTOM}`, children: localeService.t("dataValidation.renderMode.chip") }),
3176
- /* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.ARROW}`, children: localeService.t("dataValidation.renderMode.arrow") }),
3177
- /* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.TEXT}`, children: localeService.t("dataValidation.renderMode.text") })
3178
- ] }) });
3179
- }
3180
- __name(ListRenderModeInput, "ListRenderModeInput");
3181
- ListRenderModeInput.componentKey = LIST_RENDER_MODE_OPTION_INPUT;
3182
- var __defProp$c = Object.defineProperty, __getOwnPropDesc$c = Object.getOwnPropertyDescriptor, __decorateClass$c = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3183
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3184
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
3185
- return kind && result && __defProp$c(target, key, result), result;
3186
- }, "__decorateClass$c"), __decorateParam$c = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$c");
3187
- const PADDING_H$1 = 4, ICON_SIZE = 4, ICON_PLACE$1 = 14, MARGIN_H$1 = 6, MARGIN_V$1 = 4, DROP_DOWN_ICON_COLOR = "#565656", downPath$1 = new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");
3188
- function convertToDocumentData(text, style) {
3189
- const contentLength = text.length;
3190
- return {
3191
- id: "d",
3192
- body: {
3193
- dataStream: `${text}${DEFAULT_EMPTY_DOCUMENT_VALUE}`,
3194
- textRuns: [
3195
- {
3196
- ts: {
3197
- fs: 11,
3198
- ff: void 0,
3199
- it: BooleanNumber.FALSE,
3200
- bl: BooleanNumber.FALSE,
3201
- ul: {
3202
- s: BooleanNumber.FALSE
3203
- },
3204
- st: {
3205
- s: BooleanNumber.FALSE
3206
- },
3207
- ol: {
3208
- s: BooleanNumber.FALSE
3209
- },
3210
- cl: void 0,
3211
- ...style,
3212
- bg: void 0,
3213
- bd: void 0
3214
- },
3215
- st: 0,
3216
- ed: contentLength
3217
- }
3218
- ]
3219
- },
3220
- documentStyle: {
3221
- pageSize: {
3222
- width: Number.POSITIVE_INFINITY,
3223
- height: Number.POSITIVE_INFINITY
3224
- }
3225
- }
3226
- };
3227
- }
3228
- __name(convertToDocumentData, "convertToDocumentData");
3229
- function createDocSkeleton(text, localeService, style) {
3230
- const documentData = convertToDocumentData(text, style), docModel = new DocumentDataModel(documentData), docViewModel = new DocumentViewModel(docModel);
3231
- return {
3232
- documentSkeleton: DocumentSkeleton.create(docViewModel, localeService),
3233
- docModel,
3234
- docViewModel
3235
- };
1442
+ function serializeListOptions(options) {
1443
+ return options.filter(Boolean).join(",");
3236
1444
  }
3237
- __name(createDocSkeleton, "createDocSkeleton");
3238
- function createDocuments(text, localeService, style) {
3239
- const {
3240
- documentSkeleton,
3241
- docModel,
3242
- docViewModel
3243
- } = createDocSkeleton(text, localeService, style);
3244
- return {
3245
- documents: new Documents(`DOCUMENTS_${Tools.generateRandomId()}`, documentSkeleton, {
3246
- pageMarginLeft: 0,
3247
- pageMarginTop: 0
3248
- }),
3249
- documentSkeleton,
3250
- docModel,
3251
- docViewModel
3252
- };
1445
+ __name(serializeListOptions, "serializeListOptions");
1446
+ function deserializeListOptions(optionsStr) {
1447
+ return optionsStr.split(",").filter(Boolean);
3253
1448
  }
3254
- __name(createDocuments, "createDocuments");
3255
- function calcPadding(cellWidth, cellHeight, fontWidth, fontHeight, vt, ht, margin = !0) {
3256
- let paddingTop = 0;
3257
- const realMargin = margin ? MARGIN_V$1 : 0;
3258
- switch (vt) {
3259
- case VerticalAlign.BOTTOM:
3260
- paddingTop = cellHeight - fontHeight - realMargin;
3261
- break;
3262
- case VerticalAlign.MIDDLE:
3263
- paddingTop = (cellHeight - fontHeight) / 2;
3264
- break;
3265
- default:
3266
- paddingTop = realMargin;
3267
- break;
3268
- }
3269
- paddingTop = Math.max(MARGIN_V$1, paddingTop);
3270
- let paddingLeft = 0;
3271
- switch (ht) {
3272
- case HorizontalAlign.CENTER:
3273
- paddingLeft = (cellWidth - fontWidth) / 2;
3274
- break;
3275
- case HorizontalAlign.RIGHT:
3276
- paddingLeft = cellWidth - fontWidth;
3277
- break;
3278
- }
3279
- return paddingLeft = Math.max(MARGIN_H$1, paddingLeft), {
3280
- paddingLeft,
3281
- paddingTop
3282
- };
1449
+ __name(deserializeListOptions, "deserializeListOptions");
1450
+ function getDataValidationCellValue(cellData) {
1451
+ const cellValue = getCellValueOrigin(cellData);
1452
+ return cellValue == null ? "" : cellValue.toString();
3283
1453
  }
3284
- __name(calcPadding, "calcPadding");
3285
- var _a10;
3286
- let DropdownWidget = (_a10 = class {
3287
- constructor(_localeService, _commandService) {
3288
- __publicField(this, "_dropdownInfoMap", /* @__PURE__ */ new Map());
3289
- __publicField(this, "zIndex");
3290
- __publicField(this, "onPointerEnter");
3291
- __publicField(this, "onPointerLeave");
3292
- this._localeService = _localeService, this._commandService = _commandService;
3293
- }
3294
- _ensureMap(subUnitId) {
3295
- let map = this._dropdownInfoMap.get(subUnitId);
3296
- return map || (map = /* @__PURE__ */ new Map(), this._dropdownInfoMap.set(subUnitId, map)), map;
3297
- }
3298
- _generateKey(row, col) {
3299
- return `${row}.${col}`;
3300
- }
3301
- _drawDownIcon(ctx, cellBounding, cellWidth, cellHeight, fontHeight, vt, pd) {
3302
- const { t = DEFAULT_STYLES.pd.t, b = DEFAULT_STYLES.pd.b } = pd, left = cellWidth - ICON_PLACE$1;
3303
- let top;
3304
- switch (vt) {
3305
- case VerticalAlign.MIDDLE:
3306
- top = (cellHeight - ICON_SIZE) / 2;
3307
- break;
3308
- case VerticalAlign.BOTTOM:
3309
- top = cellHeight - b - fontHeight - MARGIN_V$1 + (fontHeight / 2 - ICON_SIZE / 2);
3310
- break;
3311
- default:
3312
- top = t + MARGIN_V$1 + (fontHeight / 2 - ICON_SIZE / 2);
3313
- break;
3314
- }
3315
- ctx.save(), ctx.translateWithPrecision(cellBounding.startX + left, cellBounding.startY + top), ctx.fillStyle = "#565656", ctx.fill(downPath$1), ctx.restore();
3316
- }
3317
- // eslint-disable-next-line max-lines-per-function, complexity
3318
- drawWith(ctx, info, skeleton) {
3319
- var _a24, _b;
3320
- const { primaryWithCoord, row, col, style, data, subUnitId } = info, _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, rule = (_a24 = data.dataValidation) == null ? void 0 : _a24.rule, validator = (_b = data.dataValidation) == null ? void 0 : _b.validator, fontRenderExtension = data.fontRenderExtension, { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = fontRenderExtension || {};
3321
- if (!rule || !validator || !validator || validator.id.indexOf(DataValidationType.LIST) !== 0 || !validator.skipDefaultFontRender(rule))
3322
- return;
3323
- const cellBounding = {
3324
- startX: _cellBounding.startX + leftOffset,
3325
- endX: _cellBounding.endX - rightOffset,
3326
- startY: _cellBounding.startY + topOffset,
3327
- endY: _cellBounding.endY - downOffset
3328
- }, cellWidth = cellBounding.endX - cellBounding.startX, cellHeight = cellBounding.endY - cellBounding.startY, map = this._ensureMap(subUnitId), key = this._generateKey(row, col), list = validator.getListWithColor(rule), value = getCellValueOrigin(data), valueStr = `${value != null ? value : ""}`, activeItem = list.find((i) => i.label === valueStr);
3329
- let { tb, vt, ht, pd } = style || {};
3330
- if (tb = tb != null ? tb : WrapStrategy.WRAP, vt = vt != null ? vt : VerticalAlign.BOTTOM, ht = ht != null ? ht : DEFAULT_STYLES.ht, pd = pd != null ? pd : DEFAULT_STYLES.pd, rule.renderMode === DataValidationRenderMode.ARROW) {
3331
- const { l: l2 = DEFAULT_STYLES.pd.l, t = DEFAULT_STYLES.pd.t, r = DEFAULT_STYLES.pd.r, b = DEFAULT_STYLES.pd.b } = pd, realWidth = cellWidth - l2 - r - ICON_PLACE$1, { documentSkeleton, documents, docModel } = createDocuments(valueStr, this._localeService, style);
3332
- tb === WrapStrategy.WRAP && docModel.updateDocumentDataPageSize(Math.max(realWidth, 1)), documentSkeleton.calculate(), documentSkeleton.getActualSize();
3333
- const textLayout = getDocsSkeletonPageSize(documentSkeleton), { height: fontHeight, width: fontWidth } = textLayout, { paddingTop, paddingLeft } = calcPadding(realWidth, cellHeight - t - b, fontWidth, fontHeight, vt, ht, !0);
3334
- this._drawDownIcon(ctx, cellBounding, cellWidth, cellHeight, fontHeight, vt, pd), ctx.save(), ctx.translateWithPrecision(cellBounding.startX + l2, cellBounding.startY + t), ctx.beginPath(), ctx.rect(0, 0, cellWidth - l2 - r, cellHeight - t - b), ctx.clip(), ctx.translateWithPrecision(0, paddingTop), ctx.save(), ctx.translateWithPrecision(PADDING_H$1, 0), ctx.beginPath(), ctx.rect(0, 0, realWidth, fontHeight), ctx.clip(), documents.render(ctx), ctx.translateWithPrecision(paddingLeft, 0), ctx.restore(), ctx.restore(), map.set(key, {
3335
- left: cellBounding.endX + l2 + skeleton.rowHeaderWidth - ICON_PLACE$1,
3336
- top: cellBounding.startY + t + skeleton.columnHeaderHeight,
3337
- width: ICON_PLACE$1,
3338
- height: cellHeight - t - b
3339
- });
3340
- } else {
3341
- ctx.save(), ctx.translateWithPrecision(cellBounding.startX, cellBounding.startY), ctx.beginPath(), ctx.rect(0, 0, cellWidth, cellHeight), ctx.clip();
3342
- const realWidth = cellWidth - MARGIN_H$1 * 2 - PADDING_H$1 - ICON_PLACE$1, { documentSkeleton, documents, docModel } = createDocuments(valueStr, this._localeService, style);
3343
- tb === WrapStrategy.WRAP && docModel.updateDocumentDataPageSize(Math.max(realWidth, 1)), documentSkeleton.calculate();
3344
- const textLayout = getDocsSkeletonPageSize(documentSkeleton), { height: fontHeight, width: fontWidth } = textLayout, { paddingTop, paddingLeft } = calcPadding(realWidth, cellHeight, fontWidth, fontHeight, vt, ht);
3345
- ctx.translateWithPrecision(MARGIN_H$1, paddingTop);
3346
- const rectWidth = Math.max(cellWidth - MARGIN_H$1 * 2, 1), rectHeight = fontHeight;
3347
- Rect.drawWith(ctx, {
3348
- width: rectWidth,
3349
- height: rectHeight,
3350
- fill: (activeItem == null ? void 0 : activeItem.color) || DROP_DOWN_DEFAULT_COLOR,
3351
- radius: 8
3352
- }), ctx.save(), ctx.translateWithPrecision(PADDING_H$1, 0), ctx.beginPath(), ctx.rect(0, 0, realWidth, fontHeight), ctx.clip(), ctx.translateWithPrecision(paddingLeft, 0), documents.render(ctx), ctx.restore(), ctx.translateWithPrecision(realWidth + PADDING_H$1 + 4, (fontHeight - ICON_SIZE) / 2), ctx.fillStyle = DROP_DOWN_ICON_COLOR, ctx.fill(downPath$1), ctx.restore(), map.set(key, {
3353
- left: cellBounding.startX + MARGIN_H$1 + skeleton.rowHeaderWidth,
3354
- top: cellBounding.startY + paddingTop + skeleton.columnHeaderHeight,
3355
- width: rectWidth,
3356
- height: rectHeight
3357
- });
3358
- }
3359
- }
3360
- calcCellAutoHeight(info) {
3361
- var _a24;
3362
- const { primaryWithCoord, style, data } = info, _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, fontRenderExtension = data.fontRenderExtension, { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = fontRenderExtension || {}, rule = (_a24 = data.dataValidation) == null ? void 0 : _a24.rule;
3363
- if (!rule || rule.renderMode === DataValidationRenderMode.TEXT)
3364
- return;
3365
- const cellBounding = {
3366
- startX: _cellBounding.startX + leftOffset,
3367
- endX: _cellBounding.endX - rightOffset,
3368
- startY: _cellBounding.startY + topOffset,
3369
- endY: _cellBounding.endY - downOffset
3370
- }, cellWidth = cellBounding.endX - cellBounding.startX, value = getCellValueOrigin(data), valueStr = `${value != null ? value : ""}`;
3371
- let { tb, pd } = style || {};
3372
- const { t = DEFAULT_STYLES.pd.t, b = DEFAULT_STYLES.pd.b } = pd != null ? pd : {};
3373
- if (tb = tb != null ? tb : WrapStrategy.WRAP, rule.renderMode === DataValidationRenderMode.ARROW) {
3374
- const realWidth = cellWidth - ICON_PLACE$1, { documentSkeleton, docModel } = createDocuments(valueStr, this._localeService, style);
3375
- tb === WrapStrategy.WRAP && docModel.updateDocumentDataPageSize(Math.max(realWidth, 1)), documentSkeleton.calculate(), documentSkeleton.getActualSize();
3376
- const textLayout = getDocsSkeletonPageSize(documentSkeleton), { height: fontHeight } = textLayout;
3377
- return fontHeight + t + b + MARGIN_V$1 * 2;
3378
- } else {
3379
- const realWidth = cellWidth - MARGIN_H$1 * 2 - PADDING_H$1 - ICON_PLACE$1, { documentSkeleton, docModel } = createDocSkeleton(valueStr, this._localeService, style);
3380
- tb === WrapStrategy.WRAP && docModel.updateDocumentDataPageSize(Math.max(realWidth, 1)), documentSkeleton.calculate();
3381
- const textLayout = getDocsSkeletonPageSize(documentSkeleton), {
3382
- height: fontHeight
3383
- } = textLayout;
3384
- return fontHeight + MARGIN_V$1 * 2;
3385
- }
3386
- }
3387
- isHit(position, info) {
3388
- const { data, subUnitId, row, col } = info, dropdownInfo = this._ensureMap(subUnitId).get(this._generateKey(row, col)), validation = data.dataValidation;
3389
- if (!validation || !dropdownInfo || validation.rule.renderMode === DataValidationRenderMode.TEXT)
3390
- return !1;
3391
- const { top, left, width, height } = dropdownInfo, { x, y } = position;
3392
- return x >= left && x <= left + width && y >= top && y <= top + height;
3393
- }
3394
- onPointerDown(info, evt) {
3395
- if (evt.button === 2)
3396
- return;
3397
- const { unitId, subUnitId, row, col } = info, params = {
3398
- unitId,
3399
- subUnitId,
3400
- row,
3401
- column: col
3402
- };
3403
- this._commandService.executeCommand(ShowDataValidationDropdown.id, params);
3404
- }
3405
- }, __name(_a10, "DropdownWidget"), _a10);
3406
- DropdownWidget = __decorateClass$c([
3407
- __decorateParam$c(0, Inject(LocaleService)),
3408
- __decorateParam$c(1, ICommandService)
3409
- ], DropdownWidget);
1454
+ __name(getDataValidationCellValue, "getDataValidationCellValue");
3410
1455
  function getRuleFormulaResultSet(result) {
3411
1456
  if (!result)
3412
1457
  return [];
@@ -3414,10 +1459,10 @@ function getRuleFormulaResultSet(result) {
3414
1459
  return result.forEach(
3415
1460
  (row) => {
3416
1461
  row.forEach((cell) => {
3417
- var _a24, _b;
1462
+ var _a11, _b;
3418
1463
  const value = getCellValueOrigin(cell);
3419
1464
  if (value != null) {
3420
- if (typeof value != "string" && typeof (cell == null ? void 0 : cell.s) == "object" && ((_b = (_a24 = cell.s) == null ? void 0 : _a24.n) != null && _b.pattern)) {
1465
+ if (typeof value != "string" && typeof (cell == null ? void 0 : cell.s) == "object" && ((_b = (_a11 = cell.s) == null ? void 0 : _a11.n) != null && _b.pattern)) {
3421
1466
  resultSet.add(numfmt.format(cell.s.n.pattern, value, { throws: !1 }));
3422
1467
  return;
3423
1468
  }
@@ -3461,23 +1506,19 @@ const _ListValidator = class _ListValidator extends BaseDataValidator {
3461
1506
  __publicField(this, "title", "dataValidation.list.title");
3462
1507
  __publicField(this, "operators", []);
3463
1508
  __publicField(this, "scopes", ["sheet"]);
3464
- __publicField(this, "formulaInput", LIST_FORMULA_INPUT_NAME);
3465
- __publicField(this, "canvasRender", this.injector.createInstance(DropdownWidget));
3466
- __publicField(this, "dropdown", LIST_DROPDOWN_KEY);
3467
- __publicField(this, "optionsInput", ListRenderModeInput.componentKey);
3468
1509
  __publicField(this, "skipDefaultFontRender", /* @__PURE__ */ __name((rule) => rule.renderMode !== DataValidationRenderMode.TEXT, "skipDefaultFontRender"));
3469
1510
  }
3470
1511
  validatorFormula(rule, unitId, subUnitId) {
3471
- var _a24, _b, _c;
3472
- const success = !Tools.isBlank(rule.formula1), valid = isValidListFormula((_a24 = rule.formula1) != null ? _a24 : "", this._lexer), sheetName = (_c = (_b = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _b.getSheetBySheetId(subUnitId)) == null ? void 0 : _c.getName(), isIntersects = isRuleIntersects(rule, sheetName != null ? sheetName : "");
1512
+ var _a11, _b, _c;
1513
+ const success = !Tools.isBlank(rule.formula1), valid = isValidListFormula((_a11 = rule.formula1) != null ? _a11 : "", this._lexer), sheetName = (_c = (_b = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _b.getSheetBySheetId(subUnitId)) == null ? void 0 : _c.getName(), isIntersects = isRuleIntersects(rule, sheetName != null ? sheetName : "");
3473
1514
  return {
3474
1515
  success: !!(success && valid && !isIntersects),
3475
1516
  formula1: success ? valid ? isIntersects ? this.localeService.t("dataValidation.validFail.listIntersects") : void 0 : this.localeService.t("dataValidation.validFail.listInvalid") : this.localeService.t("dataValidation.validFail.list")
3476
1517
  };
3477
1518
  }
3478
1519
  getExtraStyle(rule, value, { style: defaultStyle }) {
3479
- var _a24;
3480
- const tb = (_a24 = defaultStyle.tb !== WrapStrategy.OVERFLOW ? defaultStyle.tb : WrapStrategy.CLIP) != null ? _a24 : WrapStrategy.WRAP;
1520
+ var _a11;
1521
+ const tb = (_a11 = defaultStyle.tb !== WrapStrategy.OVERFLOW ? defaultStyle.tb : WrapStrategy.CLIP) != null ? _a11 : WrapStrategy.WRAP;
3481
1522
  if (rule.type === DataValidationType.LIST && (rule.renderMode === DataValidationRenderMode.ARROW || rule.renderMode === DataValidationRenderMode.TEXT)) {
3482
1523
  const colorMap = this.getListWithColorMap(rule), valueStr = `${value != null ? value : ""}`, color = colorMap[valueStr];
3483
1524
  if (color)
@@ -3497,10 +1538,10 @@ const _ListValidator = class _ListValidator extends BaseDataValidator {
3497
1538
  return deserializeListOptions(cellString);
3498
1539
  }
3499
1540
  async parseFormula(rule, unitId, subUnitId) {
3500
- var _a24;
1541
+ var _a11;
3501
1542
  const { formula1 = "" } = rule, results = await this.formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid);
3502
1543
  return {
3503
- formula1: isFormulaString(formula1) ? getRuleFormulaResultSet((_a24 = results == null ? void 0 : results[0]) == null ? void 0 : _a24.result) : deserializeListOptions(formula1),
1544
+ formula1: isFormulaString(formula1) ? getRuleFormulaResultSet((_a11 = results == null ? void 0 : results[0]) == null ? void 0 : _a11.result) : deserializeListOptions(formula1),
3504
1545
  formula2: void 0
3505
1546
  };
3506
1547
  }
@@ -3515,8 +1556,8 @@ const _ListValidator = class _ListValidator extends BaseDataValidator {
3515
1556
  return this.localeService.t("dataValidation.list.error");
3516
1557
  }
3517
1558
  getList(rule, currentUnitId, currentSubUnitId) {
3518
- var _a24, _b, _c;
3519
- const { formula1 = "" } = rule, univerInstanceService = this.injector.get(IUniverInstanceService), workbook = (_a24 = currentUnitId ? univerInstanceService.getUniverSheetInstance(currentUnitId) : void 0) != null ? _a24 : univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
1559
+ var _a11, _b, _c;
1560
+ const { formula1 = "" } = rule, univerInstanceService = this.injector.get(IUniverInstanceService), workbook = (_a11 = currentUnitId ? univerInstanceService.getUniverSheetInstance(currentUnitId) : void 0) != null ? _a11 : univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
3520
1561
  if (!workbook) return [];
3521
1562
  const worksheet = (_b = currentSubUnitId ? workbook.getSheetBySheetId(currentSubUnitId) : void 0) != null ? _b : workbook.getActiveSheet();
3522
1563
  if (!worksheet) return [];
@@ -3524,8 +1565,8 @@ const _ListValidator = class _ListValidator extends BaseDataValidator {
3524
1565
  return isFormulaString(formula1) ? getRuleFormulaResultSet((_c = results == null ? void 0 : results[0]) == null ? void 0 : _c.result) : deserializeListOptions(formula1);
3525
1566
  }
3526
1567
  async getListAsync(rule, currentUnitId, currentSubUnitId) {
3527
- var _a24, _b, _c;
3528
- const { formula1 = "" } = rule, univerInstanceService = this.injector.get(IUniverInstanceService), workbook = (_a24 = currentUnitId ? univerInstanceService.getUniverSheetInstance(currentUnitId) : void 0) != null ? _a24 : univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
1568
+ var _a11, _b, _c;
1569
+ const { formula1 = "" } = rule, univerInstanceService = this.injector.get(IUniverInstanceService), workbook = (_a11 = currentUnitId ? univerInstanceService.getUniverSheetInstance(currentUnitId) : void 0) != null ? _a11 : univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
3529
1570
  if (!workbook) return [];
3530
1571
  const worksheet = (_b = currentSubUnitId ? workbook.getSheetBySheetId(currentSubUnitId) : void 0) != null ? _b : workbook.getActiveSheet();
3531
1572
  if (!worksheet) return [];
@@ -3561,7 +1602,6 @@ const FORMULA1 = "{FORMULA1}", FORMULA2 = "{FORMULA2}", _TextLengthValidator = c
3561
1602
  DataValidationOperator.NOT_EQUAL
3562
1603
  ]);
3563
1604
  __publicField(this, "scopes", ["sheet"]);
3564
- __publicField(this, "formulaInput", BASE_FORMULA_INPUT_NAME);
3565
1605
  __publicField(this, "_formulaService", this.injector.get(DataValidationFormulaService));
3566
1606
  }
3567
1607
  _isFormulaOrInt(formula) {
@@ -3590,10 +1630,10 @@ const FORMULA1 = "{FORMULA1}", FORMULA2 = "{FORMULA2}", _TextLengthValidator = c
3590
1630
  return !Number.isNaN(formula);
3591
1631
  }
3592
1632
  async parseFormula(rule, unitId, subUnitId) {
3593
- var _a24, _b, _c, _d, _e, _f, _g, _h;
1633
+ var _a11, _b, _c, _d, _e, _f, _g, _h;
3594
1634
  const formulaInfo = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
3595
1635
  return {
3596
- formula1: this._parseNumber(isFormulaString(formula1) ? (_d = (_c = (_b = (_a24 = formulaInfo == null ? void 0 : formulaInfo[0]) == null ? void 0 : _a24.result) == null ? void 0 : _b[0]) == null ? void 0 : _c[0]) == null ? void 0 : _d.v : formula1),
1636
+ formula1: this._parseNumber(isFormulaString(formula1) ? (_d = (_c = (_b = (_a11 = formulaInfo == null ? void 0 : formulaInfo[0]) == null ? void 0 : _a11.result) == null ? void 0 : _b[0]) == null ? void 0 : _c[0]) == null ? void 0 : _d.v : formula1),
3597
1637
  formula2: this._parseNumber(isFormulaString(formula2) ? (_h = (_g = (_f = (_e = formulaInfo == null ? void 0 : formulaInfo[1]) == null ? void 0 : _e.result) == null ? void 0 : _f[0]) == null ? void 0 : _g[0]) == null ? void 0 : _h.v : formula2)
3598
1638
  };
3599
1639
  }
@@ -3646,15 +1686,15 @@ const FORMULA1 = "{FORMULA1}", FORMULA2 = "{FORMULA2}", _TextLengthValidator = c
3646
1686
  return this._isValidFormula(formula1) ? cellValue <= formula1 : !1;
3647
1687
  }
3648
1688
  generateRuleErrorMessage(rule) {
3649
- var _a24, _b;
3650
- return rule.operator ? `${this.localeService.t(TextLengthErrorTitleMap[rule.operator]).replace(FORMULA1, (_a24 = rule.formula1) != null ? _a24 : "").replace(FORMULA2, (_b = rule.formula2) != null ? _b : "")}` : this.titleStr;
1689
+ var _a11, _b;
1690
+ return rule.operator ? `${this.localeService.t(TextLengthErrorTitleMap[rule.operator]).replace(FORMULA1, (_a11 = rule.formula1) != null ? _a11 : "").replace(FORMULA2, (_b = rule.formula2) != null ? _b : "")}` : this.titleStr;
3651
1691
  }
3652
1692
  };
3653
1693
  __name(_TextLengthValidator, "TextLengthValidator");
3654
1694
  let TextLengthValidator = _TextLengthValidator;
3655
1695
  function isBlankCell(cellData) {
3656
- var _a24, _b;
3657
- return cellData ? cellData.p ? !((_b = (_a24 = cellData.p.body) == null ? void 0 : _a24.dataStream) != null ? _b : "").slice(0, -2).trim() : Tools.isBlank(cellData.v) : !0;
1696
+ var _a11, _b;
1697
+ return cellData ? cellData.p ? !((_b = (_a11 = cellData.p.body) == null ? void 0 : _a11.dataStream) != null ? _b : "").slice(0, -2).trim() : Tools.isBlank(cellData.v) : !0;
3658
1698
  }
3659
1699
  __name(isBlankCell, "isBlankCell");
3660
1700
  function getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor, source = "command", fillDefaultValue = !0) {
@@ -3820,22 +1860,6 @@ const UpdateSheetDataValidationRangeCommand = {
3820
1860
  undoMutations
3821
1861
  }), await sequenceExecuteAsync(redoMutations, commandService), !0;
3822
1862
  }
3823
- }, AddSheetDataValidationAndOpenCommand = {
3824
- type: CommandType.COMMAND,
3825
- id: "data-validation.command.addRuleAndOpen",
3826
- async handler(accessor) {
3827
- const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
3828
- if (!target) return !1;
3829
- const { workbook, worksheet } = target, rule = createDefaultNewRule(accessor), commandService = accessor.get(ICommandService), unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), addParams = {
3830
- rule,
3831
- unitId,
3832
- subUnitId
3833
- };
3834
- return await commandService.executeCommand(AddSheetDataValidationCommand.id, addParams) ? (commandService.executeCommand(OpenValidationPanelOperation.id, {
3835
- ruleId: rule.uid,
3836
- isAdd: !0
3837
- }), !0) : !1;
3838
- }
3839
1863
  }, UpdateSheetDataValidationSettingCommand = {
3840
1864
  type: CommandType.COMMAND,
3841
1865
  id: "sheets.command.update-data-validation-setting",
@@ -4047,7 +2071,7 @@ const UpdateSheetDataValidationRangeCommand = {
4047
2071
  unitID: params.unitId
4048
2072
  }), commandService.executeCommand(RemoveDataValidationMutation.id, params), !0;
4049
2073
  }
4050
- };
2074
+ }, PLUGIN_CONFIG_KEY = "sheets-data-validation.config", defaultPluginConfig = {};
4051
2075
  function isLegalFormulaResult(res) {
4052
2076
  return !ERROR_TYPE_SET.has(res);
4053
2077
  }
@@ -4059,7 +2083,6 @@ const _CustomFormulaValidator = class _CustomFormulaValidator extends BaseDataVa
4059
2083
  __publicField(this, "title", "dataValidation.custom.title");
4060
2084
  __publicField(this, "operators", []);
4061
2085
  __publicField(this, "scopes", ["sheet"]);
4062
- __publicField(this, "formulaInput", CUSTOM_FORMULA_INPUT_NAME);
4063
2086
  __publicField(this, "_customFormulaService", this.injector.get(DataValidationCustomFormulaService));
4064
2087
  }
4065
2088
  validatorFormula(rule, unitId, subUnitId) {
@@ -4085,182 +2108,11 @@ const _CustomFormulaValidator = class _CustomFormulaValidator extends BaseDataVa
4085
2108
  };
4086
2109
  __name(_CustomFormulaValidator, "CustomFormulaValidator");
4087
2110
  let CustomFormulaValidator = _CustomFormulaValidator;
4088
- const PADDING_H = 4, PADDING_V = 0, MARGIN_H = 4, MARGIN_V = 4, CELL_PADDING_H = 6, CELL_PADDING_V = 6, ICON_PLACE = 14;
4089
- function getDropdownItemSize(text, fontStyle) {
4090
- const bBox = FontCache.getTextSize(text, fontStyle), rectWidth = bBox.width + PADDING_H * 2, { ba, bd } = bBox, height = ba + bd;
4091
- return {
4092
- width: rectWidth,
4093
- height: height + PADDING_V * 2,
4094
- ba
4095
- };
4096
- }
4097
- __name(getDropdownItemSize, "getDropdownItemSize");
4098
- function layoutDropdowns(items, fontStyle, cellWidth, cellHeight) {
4099
- const contentWidth = cellWidth - ICON_PLACE - CELL_PADDING_H, contentHeight = cellHeight - CELL_PADDING_V * 2, textLayout = items.map((item) => ({
4100
- layout: getDropdownItemSize(item, fontStyle),
4101
- text: item
4102
- }));
4103
- let currentLine;
4104
- const lines = [];
4105
- textLayout.forEach((item) => {
4106
- const { layout } = item, { width, height } = layout;
4107
- !currentLine || currentLine.width + width + MARGIN_H > contentWidth ? (currentLine = {
4108
- width,
4109
- height,
4110
- items: [{
4111
- ...item,
4112
- left: 0
4113
- }]
4114
- }, lines.push(currentLine)) : (currentLine.items.push({
4115
- ...item,
4116
- left: currentLine.width + MARGIN_H
4117
- }), currentLine.width = currentLine.width + width + MARGIN_H);
4118
- });
4119
- let totalHeight = 0;
4120
- return lines.forEach((line, index) => {
4121
- index === lines.length - 1 ? totalHeight += line.height : totalHeight += line.height + MARGIN_V;
4122
- }), {
4123
- lines,
4124
- totalHeight,
4125
- contentWidth,
4126
- contentHeight,
4127
- cellAutoHeight: totalHeight + CELL_PADDING_V * 2
4128
- };
4129
- }
4130
- __name(layoutDropdowns, "layoutDropdowns");
4131
- const RADIUS = 8, _Dropdown = class _Dropdown extends Shape {
4132
- static drawWith(ctx, props) {
4133
- const { fontFamily, fontString, fontSize, info, fill, color } = props, { layout, text } = info;
4134
- ctx.save(), Rect.drawWith(ctx, {
4135
- width: layout.width,
4136
- height: layout.height,
4137
- radius: RADIUS,
4138
- fill: fill || DROP_DOWN_DEFAULT_COLOR
4139
- }), ctx.translateWithPrecision(PADDING_H, layout.ba), ctx.font = fontString, ctx.fillStyle = color, ctx.fillText(text, 0, 0), ctx.restore();
4140
- }
4141
- };
4142
- __name(_Dropdown, "Dropdown");
4143
- let Dropdown = _Dropdown;
4144
- var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPropertyDescriptor, __decorateClass$b = /* @__PURE__ */ __name((decorators, target, key, kind) => {
4145
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4146
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4147
- return kind && result && __defProp$b(target, key, result), result;
4148
- }, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b");
4149
- const downPath = new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");
4150
- var _a11;
4151
- let DropdownMultipleWidget = (_a11 = class {
4152
- constructor(_commandService) {
4153
- __publicField(this, "zIndex");
4154
- __publicField(this, "_dropdownInfoMap", /* @__PURE__ */ new Map());
4155
- this._commandService = _commandService;
4156
- }
4157
- _ensureMap(subUnitId) {
4158
- let map = this._dropdownInfoMap.get(subUnitId);
4159
- return map || (map = /* @__PURE__ */ new Map(), this._dropdownInfoMap.set(subUnitId, map)), map;
4160
- }
4161
- _generateKey(row, col) {
4162
- return `${row}.${col}`;
4163
- }
4164
- _drawDownIcon(ctx, cellBounding, cellWidth, cellHeight, vt) {
4165
- const left = cellWidth - ICON_PLACE + 4;
4166
- let top = 4;
4167
- switch (vt) {
4168
- case VerticalAlign.MIDDLE:
4169
- top = (cellHeight - ICON_PLACE) / 2 + 4;
4170
- break;
4171
- case VerticalAlign.BOTTOM:
4172
- top = cellHeight - ICON_PLACE + 4;
4173
- break;
4174
- }
4175
- ctx.save(), ctx.translateWithPrecision(cellBounding.startX + left, cellBounding.startY + top), ctx.fillStyle = "#565656", ctx.fill(downPath), ctx.restore();
4176
- }
4177
- // eslint-disable-next-line max-lines-per-function
4178
- drawWith(ctx, info, skeleton, spreadsheets) {
4179
- var _a24, _b;
4180
- const { primaryWithCoord, row, col, style, data, subUnitId } = info, _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, fontRenderExtension = data.fontRenderExtension, { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = fontRenderExtension || {}, validation = data.dataValidation, map = this._ensureMap(subUnitId), key = this._generateKey(row, col);
4181
- if (!validation)
4182
- return;
4183
- const cellBounding = {
4184
- startX: _cellBounding.startX + leftOffset,
4185
- endX: _cellBounding.endX - rightOffset,
4186
- startY: _cellBounding.startY + topOffset,
4187
- endY: _cellBounding.endY - downOffset
4188
- }, cellWidth = cellBounding.endX - cellBounding.startX, cellHeight = cellBounding.endY - cellBounding.startY, { cl } = style || {}, color = (_a24 = typeof cl == "object" ? cl == null ? void 0 : cl.rgb : cl) != null ? _a24 : "#000", fontStyle = getFontStyleString(style != null ? style : void 0), { rule, validator: _validator } = validation, validator = _validator, { vt: _vt, ht } = style || {}, vt = _vt != null ? _vt : VerticalAlign.MIDDLE, cellValue = (_b = getCellValueOrigin(data)) != null ? _b : "", items = validator.parseCellValue(cellValue), labelColorMap = validator.getListWithColorMap(rule), layout = layoutDropdowns(items, fontStyle, cellWidth, cellHeight);
4189
- this._drawDownIcon(ctx, cellBounding, cellWidth, cellHeight, vt), ctx.save(), ctx.translateWithPrecision(cellBounding.startX, cellBounding.startY), ctx.beginPath(), ctx.rect(0, 0, cellWidth - ICON_PLACE, cellHeight), ctx.clip(), ctx.translateWithPrecision(CELL_PADDING_H, CELL_PADDING_V);
4190
- let top = 0;
4191
- switch (vt) {
4192
- case VerticalAlign.MIDDLE:
4193
- top = (layout.contentHeight - layout.totalHeight) / 2;
4194
- break;
4195
- case VerticalAlign.BOTTOM:
4196
- top = layout.contentHeight - layout.totalHeight;
4197
- break;
4198
- }
4199
- ctx.translateWithPrecision(0, top), layout.lines.forEach((line, index) => {
4200
- ctx.save();
4201
- const { width, height, items: items2 } = line;
4202
- let left = 0;
4203
- switch (ht) {
4204
- case HorizontalAlign.RIGHT:
4205
- left = layout.contentWidth - width;
4206
- break;
4207
- case HorizontalAlign.CENTER:
4208
- left = (layout.contentWidth - width) / 2;
4209
- break;
4210
- }
4211
- ctx.translate(left, index * (height + MARGIN_V)), items2.forEach((item) => {
4212
- ctx.save(), ctx.translateWithPrecision(item.left, 0), Dropdown.drawWith(ctx, {
4213
- ...fontStyle,
4214
- info: item,
4215
- color,
4216
- fill: labelColorMap[item.text]
4217
- }), ctx.restore();
4218
- }), ctx.restore();
4219
- }), ctx.restore(), map.set(key, {
4220
- left: cellBounding.startX,
4221
- top: cellBounding.startY,
4222
- width: layout.contentWidth + CELL_PADDING_H + ICON_PLACE,
4223
- height: layout.contentHeight + CELL_PADDING_V * 2
4224
- });
4225
- }
4226
- calcCellAutoHeight(info) {
4227
- var _a24;
4228
- const { primaryWithCoord, style, data } = info, fontRenderExtension = data.fontRenderExtension, { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = fontRenderExtension || {}, _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, cellBounding = {
4229
- startX: _cellBounding.startX + leftOffset,
4230
- endX: _cellBounding.endX - rightOffset,
4231
- startY: _cellBounding.startY + topOffset,
4232
- endY: _cellBounding.endY - downOffset
4233
- }, validation = data.dataValidation;
4234
- if (!validation)
4235
- return;
4236
- const cellWidth = cellBounding.endX - cellBounding.startX, cellHeight = cellBounding.endY - cellBounding.startY, cellValue = (_a24 = getCellValueOrigin(data)) != null ? _a24 : "", { validator: _validator } = validation, items = _validator.parseCellValue(cellValue), fontStyle = getFontStyleString(style != null ? style : void 0);
4237
- return layoutDropdowns(items, fontStyle, cellWidth, cellHeight).cellAutoHeight;
4238
- }
4239
- isHit(position, info) {
4240
- const { primaryWithCoord } = info, cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, { endX } = cellBounding, { x } = position;
4241
- return x >= endX - ICON_PLACE && x <= endX;
4242
- }
4243
- onPointerDown(info, evt) {
4244
- if (evt.button === 2)
4245
- return;
4246
- const { unitId, subUnitId, row, col } = info, params = {
4247
- unitId,
4248
- subUnitId,
4249
- row,
4250
- column: col
4251
- };
4252
- this._commandService.executeCommand(ShowDataValidationDropdown.id, params);
4253
- }
4254
- }, __name(_a11, "DropdownMultipleWidget"), _a11);
4255
- DropdownMultipleWidget = __decorateClass$b([
4256
- __decorateParam$b(0, ICommandService)
4257
- ], DropdownMultipleWidget);
4258
2111
  const _ListMultipleValidator = class _ListMultipleValidator extends ListValidator {
4259
2112
  constructor() {
4260
2113
  super(...arguments);
4261
2114
  __publicField(this, "id", DataValidationType.LIST_MULTIPLE);
4262
2115
  __publicField(this, "title", "dataValidation.listMultiple.title");
4263
- __publicField(this, "canvasRender", this.injector.createInstance(DropdownMultipleWidget));
4264
2116
  __publicField(this, "skipDefaultFontRender", /* @__PURE__ */ __name(() => !0, "skipDefaultFontRender"));
4265
2117
  }
4266
2118
  };
@@ -4283,8 +2135,6 @@ const _WholeValidator = class _WholeValidator extends BaseDataValidator {
4283
2135
  DataValidationOperator.NOT_EQUAL
4284
2136
  ]);
4285
2137
  __publicField(this, "scopes", ["sheet"]);
4286
- __publicField(this, "formulaInput", BASE_FORMULA_INPUT_NAME);
4287
- __publicField(this, "dropDownInput");
4288
2138
  }
4289
2139
  _isFormulaOrInt(formula) {
4290
2140
  return !Tools.isBlank(formula) && (isFormulaString(formula) || !Number.isNaN(+formula) && Number.isInteger(+formula));
@@ -4304,10 +2154,10 @@ const _WholeValidator = class _WholeValidator extends BaseDataValidator {
4304
2154
  return formula == null ? Number.NaN : +formula;
4305
2155
  }
4306
2156
  async parseFormula(rule, unitId, subUnitId) {
4307
- var _a24, _b, _c, _d, _e, _f, _g, _h;
2157
+ var _a11, _b, _c, _d, _e, _f, _g, _h;
4308
2158
  const formulaInfo = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
4309
2159
  return {
4310
- formula1: this._parseNumber(isFormulaString(formula1) ? (_d = (_c = (_b = (_a24 = formulaInfo == null ? void 0 : formulaInfo[0]) == null ? void 0 : _a24.result) == null ? void 0 : _b[0]) == null ? void 0 : _c[0]) == null ? void 0 : _d.v : formula1),
2160
+ formula1: this._parseNumber(isFormulaString(formula1) ? (_d = (_c = (_b = (_a11 = formulaInfo == null ? void 0 : formulaInfo[0]) == null ? void 0 : _a11.result) == null ? void 0 : _b[0]) == null ? void 0 : _c[0]) == null ? void 0 : _d.v : formula1),
4311
2161
  formula2: this._parseNumber(isFormulaString(formula2) ? (_h = (_g = (_f = (_e = formulaInfo == null ? void 0 : formulaInfo[1]) == null ? void 0 : _e.result) == null ? void 0 : _f[0]) == null ? void 0 : _g[0]) == null ? void 0 : _h.v : formula2)
4312
2162
  };
4313
2163
  }
@@ -4368,45 +2218,17 @@ const _WholeValidator = class _WholeValidator extends BaseDataValidator {
4368
2218
  };
4369
2219
  __name(_WholeValidator, "WholeValidator");
4370
2220
  let WholeValidator = _WholeValidator;
4371
- const DataValidationIcon = "data-validation-single", DATA_VALIDATION_MENU_ID = "sheet.menu.data-validation";
4372
- function dataValidationMenuFactory(accessor) {
4373
- return {
4374
- id: DATA_VALIDATION_MENU_ID,
4375
- type: MenuItemType.SUBITEMS,
4376
- icon: DataValidationIcon,
4377
- tooltip: "dataValidation.title",
4378
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
4379
- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetSetCellStylePermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
4380
- };
4381
- }
4382
- __name(dataValidationMenuFactory, "dataValidationMenuFactory");
4383
- function openDataValidationMenuFactory(_accessor) {
4384
- return {
4385
- id: OpenValidationPanelOperation.id,
4386
- title: "dataValidation.panel.title",
4387
- type: MenuItemType.BUTTON
4388
- };
4389
- }
4390
- __name(openDataValidationMenuFactory, "openDataValidationMenuFactory");
4391
- function addDataValidationMenuFactory(_accessor) {
4392
- return {
4393
- id: AddSheetDataValidationAndOpenCommand.id,
4394
- title: "dataValidation.panel.add",
4395
- type: MenuItemType.BUTTON
4396
- };
4397
- }
4398
- __name(addDataValidationMenuFactory, "addDataValidationMenuFactory");
4399
- var __defProp$a = Object.defineProperty, __getOwnPropDesc$a = Object.getOwnPropertyDescriptor, __decorateClass$a = /* @__PURE__ */ __name((decorators, target, key, kind) => {
4400
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2221
+ var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2222
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4401
2223
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4402
- return kind && result && __defProp$a(target, key, result), result;
4403
- }, "__decorateClass$a"), __decorateParam$a = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$a"), _a12;
4404
- let DataValidationController = (_a12 = class extends RxDisposable {
4405
- constructor(_univerInstanceService, _dataValidatorRegistryService, _injector, _componentManger, _selectionManagerService, _sheetInterceptorService, _sheetDataValidationModel) {
4406
- super(), this._univerInstanceService = _univerInstanceService, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._injector = _injector, this._componentManger = _componentManger, this._selectionManagerService = _selectionManagerService, this._sheetInterceptorService = _sheetInterceptorService, this._sheetDataValidationModel = _sheetDataValidationModel, this._init();
2224
+ return kind && result && __defProp$5(target, key, result), result;
2225
+ }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a5;
2226
+ let DataValidationController = (_a5 = class extends RxDisposable {
2227
+ constructor(_univerInstanceService, _dataValidatorRegistryService, _injector, _selectionManagerService, _sheetInterceptorService, _sheetDataValidationModel) {
2228
+ super(), this._univerInstanceService = _univerInstanceService, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._injector = _injector, this._selectionManagerService = _selectionManagerService, this._sheetInterceptorService = _sheetInterceptorService, this._sheetDataValidationModel = _sheetDataValidationModel, this._init();
4407
2229
  }
4408
2230
  _init() {
4409
- this._registerValidators(), this._initCommandInterceptor(), this._initComponents();
2231
+ this._registerValidators(), this._initCommandInterceptor();
4410
2232
  }
4411
2233
  _registerValidators() {
4412
2234
  [
@@ -4420,24 +2242,18 @@ let DataValidationController = (_a12 = class extends RxDisposable {
4420
2242
  CustomFormulaValidator
4421
2243
  ].forEach((Validator) => {
4422
2244
  const validator = this._injector.createInstance(Validator);
4423
- this.disposeWithMe(
4424
- this._dataValidatorRegistryService.register(validator)
4425
- ), this.disposeWithMe({
4426
- dispose: /* @__PURE__ */ __name(() => {
4427
- this._injector.delete(Validator);
4428
- }, "dispose")
4429
- });
2245
+ this.disposeWithMe(this._dataValidatorRegistryService.register(validator)), this.disposeWithMe(toDisposable(() => this._injector.delete(Validator)));
4430
2246
  });
4431
2247
  }
4432
2248
  _initCommandInterceptor() {
4433
2249
  this._sheetInterceptorService.interceptCommand({
4434
2250
  getMutations: /* @__PURE__ */ __name((commandInfo) => {
4435
- var _a24;
2251
+ var _a11;
4436
2252
  if (commandInfo.id === ClearSelectionAllCommand.id) {
4437
2253
  const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), unitId = workbook.getUnitId(), worksheet = workbook.getActiveSheet();
4438
2254
  if (!worksheet)
4439
2255
  throw new Error("No active sheet found");
4440
- const subUnitId = worksheet.getSheetId(), selections = (_a24 = this._selectionManagerService.getCurrentSelections()) == null ? void 0 : _a24.map((s) => s.range), ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone();
2256
+ const subUnitId = worksheet.getSheetId(), selections = (_a11 = this._selectionManagerService.getCurrentSelections()) == null ? void 0 : _a11.map((s) => s.range), ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone();
4441
2257
  selections && ruleMatrix.removeRange(selections);
4442
2258
  const diffs = ruleMatrix.diff(this._sheetDataValidationModel.getRules(unitId, subUnitId)), { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, this._injector, "patched");
4443
2259
  return {
@@ -4452,256 +2268,66 @@ let DataValidationController = (_a12 = class extends RxDisposable {
4452
2268
  }, "getMutations")
4453
2269
  });
4454
2270
  }
4455
- _initComponents() {
4456
- [
4457
- [DataValidationIcon, DataValidationSingle],
4458
- [DATA_VALIDATION_PANEL, DataValidationPanel],
4459
- [DROP_DOWN_KEY, CellDropdown],
4460
- [LIST_DROPDOWN_KEY, ListDropDown],
4461
- [DATE_DROPDOWN_KEY, DateDropdown],
4462
- [ListRenderModeInput.componentKey, ListRenderModeInput],
4463
- [DateShowTimeOption.componentKey, DateShowTimeOption],
4464
- ...FORMULA_INPUTS
4465
- ].forEach(([key, component]) => {
4466
- this.disposeWithMe(this._componentManger.register(
4467
- key,
4468
- component
4469
- ));
4470
- });
4471
- }
4472
- }, __name(_a12, "DataValidationController"), _a12);
4473
- DataValidationController = __decorateClass$a([
4474
- OnLifecycle(LifecycleStages.Rendered, DataValidationController),
4475
- __decorateParam$a(0, IUniverInstanceService),
4476
- __decorateParam$a(1, Inject(DataValidatorRegistryService)),
4477
- __decorateParam$a(2, Inject(Injector)),
4478
- __decorateParam$a(3, Inject(ComponentManager)),
4479
- __decorateParam$a(4, Inject(SheetsSelectionsService)),
4480
- __decorateParam$a(5, Inject(SheetInterceptorService)),
4481
- __decorateParam$a(6, Inject(SheetDataValidationModel))
2271
+ }, __name(_a5, "DataValidationController"), _a5);
2272
+ DataValidationController = __decorateClass$5([
2273
+ __decorateParam$5(0, IUniverInstanceService),
2274
+ __decorateParam$5(1, Inject(DataValidatorRegistryService)),
2275
+ __decorateParam$5(2, Inject(Injector)),
2276
+ __decorateParam$5(3, Inject(SheetsSelectionsService)),
2277
+ __decorateParam$5(4, Inject(SheetInterceptorService)),
2278
+ __decorateParam$5(5, Inject(SheetDataValidationModel))
4482
2279
  ], DataValidationController);
4483
- var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor, __decorateClass$9 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
4484
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2280
+ var P = /* @__PURE__ */ ((E) => (E[E.View = 0] = "View", E[E.Edit = 1] = "Edit", E[E.ManageCollaborator = 2] = "ManageCollaborator", E[E.Print = 3] = "Print", E[E.Duplicate = 4] = "Duplicate", E[E.Comment = 5] = "Comment", E[E.Copy = 6] = "Copy", E[E.Share = 7] = "Share", E[E.Export = 8] = "Export", E[E.MoveWorksheet = 9] = "MoveWorksheet", E[E.DeleteWorksheet = 10] = "DeleteWorksheet", E[E.HideWorksheet = 11] = "HideWorksheet", E[E.RenameWorksheet = 12] = "RenameWorksheet", E[E.CreateWorksheet = 13] = "CreateWorksheet", E[E.SetWorksheetStyle = 14] = "SetWorksheetStyle", E[E.EditWorksheetCell = 15] = "EditWorksheetCell", E[E.InsertHyperlink = 16] = "InsertHyperlink", E[E.Sort = 17] = "Sort", E[E.Filter = 18] = "Filter", E[E.PivotTable = 19] = "PivotTable", E[E.FloatImg = 20] = "FloatImg", E[E.History = 21] = "History", E[E.RwHgtClWdt = 22] = "RwHgtClWdt", E[E.ViemRwHgtClWdt = 23] = "ViemRwHgtClWdt", E[E.ViewFilter = 24] = "ViewFilter", E[E.MoveSheet = 25] = "MoveSheet", E[E.DeleteSheet = 26] = "DeleteSheet", E[E.HideSheet = 27] = "HideSheet", E[E.CopySheet = 28] = "CopySheet", E[E.RenameSheet = 29] = "RenameSheet", E[E.CreateSheet = 30] = "CreateSheet", E[E.SelectProtectedCells = 31] = "SelectProtectedCells", E[E.SelectUnProtectedCells = 32] = "SelectUnProtectedCells", E[E.SetCellStyle = 33] = "SetCellStyle", E[E.SetCellValue = 34] = "SetCellValue", E[E.SetRowStyle = 35] = "SetRowStyle", E[E.SetColumnStyle = 36] = "SetColumnStyle", E[E.InsertRow = 37] = "InsertRow", E[E.InsertColumn = 38] = "InsertColumn", E[E.DeleteRow = 39] = "DeleteRow", E[E.DeleteColumn = 40] = "DeleteColumn", E[E.EditExtraObject = 41] = "EditExtraObject", E[E.Delete = 42] = "Delete", E[E.RecoverHistory = 43] = "RecoverHistory", E[E.ViewHistory = 44] = "ViewHistory", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(P || {}), __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2281
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4485
2282
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4486
- return kind && result && __defProp$9(target, key, result), result;
4487
- }, "__decorateClass$9"), __decorateParam$9 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$9");
4488
- const ALERT_KEY = "SHEET_DATA_VALIDATION_ALERT";
4489
- var _a13;
4490
- let DataValidationAlertController = (_a13 = class extends Disposable {
4491
- constructor(_hoverManagerService, _cellAlertManagerService, _univerInstanceService, _localeService, _zenZoneService) {
4492
- super(), this._hoverManagerService = _hoverManagerService, this._cellAlertManagerService = _cellAlertManagerService, this._univerInstanceService = _univerInstanceService, this._localeService = _localeService, this._zenZoneService = _zenZoneService, this._init();
2283
+ return kind && result && __defProp$4(target, key, result), result;
2284
+ }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a6;
2285
+ let DataValidationFormulaController = (_a6 = class extends Disposable {
2286
+ constructor(_univerInstanceService, _permissionService, _lexerTreeBuilder) {
2287
+ super(), this._univerInstanceService = _univerInstanceService, this._permissionService = _permissionService, this._lexerTreeBuilder = _lexerTreeBuilder;
4493
2288
  }
4494
- _init() {
4495
- this._initCellAlertPopup(), this._initZenService();
4496
- }
4497
- _initCellAlertPopup() {
4498
- this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(debounceTime(100)).subscribe((cellPos) => {
4499
- var _a24, _b;
4500
- if (cellPos) {
4501
- const worksheet = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getActiveSheet();
4502
- if (!worksheet) return;
4503
- const cellData = worksheet.getCell(cellPos.location.row, cellPos.location.col);
4504
- if (((_a24 = cellData == null ? void 0 : cellData.dataValidation) == null ? void 0 : _a24.validStatus) === DataValidationStatus.INVALID) {
4505
- const currentAlert = this._cellAlertManagerService.currentAlert.get(ALERT_KEY), currentLoc = (_b = currentAlert == null ? void 0 : currentAlert.alert) == null ? void 0 : _b.location;
4506
- if (currentLoc && currentLoc.row === cellPos.location.row && currentLoc.col === cellPos.location.col && currentLoc.subUnitId === cellPos.location.subUnitId && currentLoc.unitId === cellPos.location.unitId)
4507
- return;
4508
- const validator = cellData.dataValidation.validator, rule = cellData.dataValidation.rule;
4509
- if (!validator)
4510
- return;
4511
- this._cellAlertManagerService.showAlert({
4512
- type: CellAlertType.ERROR,
4513
- title: this._localeService.t("dataValidation.error.title"),
4514
- message: validator == null ? void 0 : validator.getRuleFinalError(rule),
4515
- location: cellPos.location,
4516
- width: 200,
4517
- height: 74,
4518
- key: ALERT_KEY
4519
- });
4520
- return;
4521
- }
2289
+ getFormulaRefCheck(formulaString) {
2290
+ var _a11, _b;
2291
+ const sequenceNodes = this._lexerTreeBuilder.sequenceNodesBuilder(formulaString);
2292
+ if (!sequenceNodes)
2293
+ return !0;
2294
+ for (let i = 0; i < sequenceNodes.length; i++) {
2295
+ const node = sequenceNodes[i];
2296
+ if (typeof node == "string")
2297
+ continue;
2298
+ const { token } = node, sequenceGrid = deserializeRangeWithSheet(token), workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
2299
+ let targetSheet = workbook.getActiveSheet();
2300
+ const unitId = workbook.getUnitId();
2301
+ if (sequenceGrid.sheetName) {
2302
+ if (targetSheet = workbook.getSheetBySheetName(sequenceGrid.sheetName), !targetSheet)
2303
+ return !1;
2304
+ const subUnitId = targetSheet == null ? void 0 : targetSheet.getSheetId();
2305
+ if (!this._permissionService.getPermissionPoint(new WorksheetViewPermission(unitId, subUnitId).id)) return !1;
4522
2306
  }
4523
- this._cellAlertManagerService.removeAlert(ALERT_KEY);
4524
- }));
4525
- }
4526
- _initZenService() {
4527
- this.disposeWithMe(this._zenZoneService.visible$.subscribe((visible) => {
4528
- visible && this._cellAlertManagerService.removeAlert(ALERT_KEY);
4529
- }));
4530
- }
4531
- }, __name(_a13, "DataValidationAlertController"), _a13);
4532
- DataValidationAlertController = __decorateClass$9([
4533
- OnLifecycle(LifecycleStages.Rendered, DataValidationAlertController),
4534
- __decorateParam$9(0, Inject(HoverManagerService)),
4535
- __decorateParam$9(1, Inject(CellAlertManagerService)),
4536
- __decorateParam$9(2, IUniverInstanceService),
4537
- __decorateParam$9(3, Inject(LocaleService)),
4538
- __decorateParam$9(4, IZenZoneService)
4539
- ], DataValidationAlertController);
4540
- var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
4541
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4542
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4543
- return kind && result && __defProp$8(target, key, result), result;
4544
- }, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"), _a14;
4545
- let DataValidationCopyPasteController = (_a14 = class extends Disposable {
4546
- constructor(_sheetClipboardService, _sheetDataValidationModel, _injector) {
4547
- super();
4548
- __publicField(this, "_copyInfo");
4549
- this._sheetClipboardService = _sheetClipboardService, this._sheetDataValidationModel = _sheetDataValidationModel, this._injector = _injector, this._initCopyPaste();
4550
- }
4551
- _initCopyPaste() {
4552
- this._sheetClipboardService.addClipboardHook({
4553
- id: DATA_VALIDATION_PLUGIN_NAME,
4554
- onBeforeCopy: /* @__PURE__ */ __name((unitId, subUnitId, range) => this._collect(unitId, subUnitId, range), "onBeforeCopy"),
4555
- onPasteCells: /* @__PURE__ */ __name((pasteFrom, pasteTo, data, payload) => {
4556
- const { copyType = COPY_TYPE.COPY, pasteType } = payload, { range: copyRange } = pasteFrom || {}, { range: pastedRange, unitId, subUnitId } = pasteTo;
4557
- return this._generateMutations(pastedRange, { copyType, pasteType, copyRange, unitId, subUnitId });
4558
- }, "onPasteCells")
4559
- });
4560
- }
4561
- _collect(unitId, subUnitId, range) {
4562
- const matrix = new ObjectMatrix();
4563
- this._copyInfo = {
4564
- unitId,
4565
- subUnitId,
4566
- matrix
4567
- };
4568
- const discreteRange = this._injector.invoke((accessor) => rangeToDiscreteRange(range, accessor, unitId, subUnitId));
4569
- if (!discreteRange)
4570
- return;
4571
- const { rows, cols } = discreteRange;
4572
- rows.forEach((row, rowIndex) => {
4573
- cols.forEach((col, colIndex) => {
4574
- const ruleId = this._sheetDataValidationModel.getRuleIdByLocation(unitId, subUnitId, row, col);
4575
- matrix.setValue(rowIndex, colIndex, ruleId != null ? ruleId : "");
4576
- });
4577
- });
4578
- }
4579
- // eslint-disable-next-line max-lines-per-function
4580
- _generateMutations(pastedRange, copyInfo) {
4581
- if (!this._copyInfo)
4582
- return { redos: [], undos: [] };
4583
- if (copyInfo.copyType === COPY_TYPE.CUT)
4584
- return this._copyInfo = null, { redos: [], undos: [] };
4585
- if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !copyInfo.copyRange)
4586
- return { redos: [], undos: [] };
4587
- if ([
4588
- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,
4589
- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,
4590
- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,
4591
- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA
4592
- ].includes(
4593
- copyInfo.pasteType
4594
- ))
4595
- return { redos: [], undos: [] };
4596
- const { unitId, subUnitId } = this._copyInfo;
4597
- if (copyInfo.unitId !== unitId || subUnitId !== copyInfo.subUnitId) {
4598
- const ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(copyInfo.unitId, copyInfo.subUnitId).clone(), additionMatrix = new ObjectMatrix(), addRules = /* @__PURE__ */ new Set(), { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyInfo.copyRange, pastedRange]), repeatRange = getRepeatRange(vCopyRange, vPastedRange, !0), additionRules = /* @__PURE__ */ new Map();
4599
- repeatRange.forEach(({ startRange }) => {
4600
- var _a24;
4601
- (_a24 = this._copyInfo) == null || _a24.matrix.forValue((row, col, ruleId) => {
4602
- const range = Rectangle.getPositionRange(
4603
- {
4604
- startRow: row,
4605
- endRow: row,
4606
- startColumn: col,
4607
- endColumn: col
4608
- },
4609
- startRange
4610
- ), transformedRuleId = `${subUnitId}-${ruleId}`, oldRule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
4611
- !this._sheetDataValidationModel.getRuleById(copyInfo.unitId, copyInfo.subUnitId, transformedRuleId) && oldRule && additionRules.set(transformedRuleId, { ...oldRule, uid: transformedRuleId });
4612
- const { row: startRow, col: startColumn } = mapFunc(range.startRow, range.startColumn);
4613
- addRules.add(transformedRuleId), additionMatrix.setValue(startRow, startColumn, transformedRuleId);
4614
- });
4615
- });
4616
- const additions = Array.from(addRules).map((id) => ({ id, ranges: queryObjectMatrix(additionMatrix, (value) => value === id) }));
4617
- ruleMatrix.addRangeRules(additions);
4618
- const { redoMutations, undoMutations } = getDataValidationDiffMutations(
4619
- copyInfo.unitId,
4620
- copyInfo.subUnitId,
4621
- ruleMatrix.diffWithAddition(this._sheetDataValidationModel.getRules(copyInfo.unitId, copyInfo.subUnitId), additionRules.values()),
4622
- this._injector,
4623
- "patched"
4624
- );
4625
- return {
4626
- redos: redoMutations,
4627
- undos: undoMutations
4628
- };
4629
- } else {
4630
- const ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone(), additionMatrix = new ObjectMatrix(), additionRules = /* @__PURE__ */ new Set(), { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyInfo.copyRange, pastedRange]);
4631
- getRepeatRange(vCopyRange, vPastedRange, !0).forEach(({ startRange }) => {
4632
- var _a24;
4633
- (_a24 = this._copyInfo) == null || _a24.matrix.forValue((row, col, ruleId) => {
4634
- const range = Rectangle.getPositionRange(
4635
- {
4636
- startRow: row,
4637
- endRow: row,
4638
- startColumn: col,
4639
- endColumn: col
4640
- },
4641
- startRange
4642
- ), { row: startRow, col: startColumn } = mapFunc(range.startRow, range.startColumn);
4643
- additionMatrix.setValue(startRow, startColumn, ruleId), additionRules.add(ruleId);
4644
- });
4645
- });
4646
- const additions = Array.from(additionRules).map((id) => ({ id, ranges: queryObjectMatrix(additionMatrix, (value) => value === id) }));
4647
- ruleMatrix.addRangeRules(additions);
4648
- const { redoMutations, undoMutations } = getDataValidationDiffMutations(
4649
- unitId,
4650
- subUnitId,
4651
- ruleMatrix.diff(this._sheetDataValidationModel.getRules(unitId, subUnitId)),
4652
- this._injector,
4653
- "patched"
4654
- );
4655
- return {
4656
- redos: redoMutations,
4657
- undos: undoMutations
4658
- };
2307
+ if (!targetSheet)
2308
+ return !1;
2309
+ const { startRow, endRow, startColumn, endColumn } = sequenceGrid.range;
2310
+ for (let i2 = startRow; i2 <= endRow; i2++)
2311
+ for (let j = startColumn; j <= endColumn; j++) {
2312
+ const permission = (_b = (_a11 = targetSheet.getCell(i2, j)) == null ? void 0 : _a11.selectionProtection) == null ? void 0 : _b[0];
2313
+ if ((permission == null ? void 0 : permission[P.View]) === !1)
2314
+ return !1;
2315
+ }
4659
2316
  }
2317
+ return !0;
4660
2318
  }
4661
- }, __name(_a14, "DataValidationCopyPasteController"), _a14);
4662
- DataValidationCopyPasteController = __decorateClass$8([
4663
- OnLifecycle(LifecycleStages.Ready, DataValidationCopyPasteController),
4664
- __decorateParam$8(0, ISheetClipboardService),
4665
- __decorateParam$8(1, Inject(SheetDataValidationModel)),
4666
- __decorateParam$8(2, Inject(Injector))
4667
- ], DataValidationCopyPasteController);
4668
- var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
4669
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4670
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4671
- return kind && result && __defProp$7(target, key, result), result;
4672
- }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a15;
4673
- let DataValidationPermissionController = (_a15 = class extends Disposable {
4674
- constructor(_localeService, _commandService, _sheetPermissionInterceptorBaseController) {
4675
- super(), this._localeService = _localeService, this._commandService = _commandService, this._sheetPermissionInterceptorBaseController = _sheetPermissionInterceptorBaseController, this._commandExecutedListener();
4676
- }
4677
- _commandExecutedListener() {
4678
- this.disposeWithMe(
4679
- this._commandService.beforeCommandExecuted((command) => {
4680
- command.id === AddSheetDataValidationCommand.id && (this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
4681
- workbookTypes: [WorkbookEditablePermission],
4682
- rangeTypes: [RangeProtectionPermissionEditPoint],
4683
- worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission]
4684
- }) || this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr"))), command.id === UpdateSheetDataValidationRangeCommand.id && (this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
4685
- workbookTypes: [WorkbookEditablePermission],
4686
- rangeTypes: [RangeProtectionPermissionEditPoint],
4687
- worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission]
4688
- }, command.params.ranges) || this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr")));
4689
- })
4690
- );
4691
- }
4692
- }, __name(_a15, "DataValidationPermissionController"), _a15);
4693
- DataValidationPermissionController = __decorateClass$7([
4694
- OnLifecycle(LifecycleStages.Ready, DataValidationPermissionController),
4695
- __decorateParam$7(0, Inject(LocaleService)),
4696
- __decorateParam$7(1, ICommandService),
4697
- __decorateParam$7(2, Inject(SheetPermissionInterceptorBaseController))
4698
- ], DataValidationPermissionController);
4699
- var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
4700
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2319
+ }, __name(_a6, "DataValidationFormulaController"), _a6);
2320
+ DataValidationFormulaController = __decorateClass$4([
2321
+ __decorateParam$4(0, IUniverInstanceService),
2322
+ __decorateParam$4(1, IPermissionService),
2323
+ __decorateParam$4(2, Inject(LexerTreeBuilder))
2324
+ ], DataValidationFormulaController);
2325
+ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2326
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4701
2327
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4702
- return kind && result && __defProp$6(target, key, result), result;
4703
- }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a16;
4704
- let DataValidationRefRangeController = (_a16 = class extends Disposable {
2328
+ return kind && result && __defProp$3(target, key, result), result;
2329
+ }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a7;
2330
+ let DataValidationRefRangeController = (_a7 = class extends Disposable {
4705
2331
  constructor(_dataValidationModel, _injector, _refRangeService, _dataValidationCustomFormulaService, _dataValidationFormulaService, _formulaRefRangeService) {
4706
2332
  super();
4707
2333
  __publicField(this, "_disposableMap", /* @__PURE__ */ new Map());
@@ -4715,8 +2341,8 @@ let DataValidationRefRangeController = (_a16 = class extends Disposable {
4715
2341
  }
4716
2342
  // eslint-disable-next-line max-lines-per-function
4717
2343
  registerFormula(unitId, subUnitId, rule) {
4718
- var _a24;
4719
- const ruleId = rule.uid, id = this._getIdWithUnitId(unitId, subUnitId, ruleId), disposeSet = (_a24 = this._disposableMap.get(id)) != null ? _a24 : /* @__PURE__ */ new Set(), handleFormulaChange = /* @__PURE__ */ __name((type, formulaString) => {
2344
+ var _a11;
2345
+ const ruleId = rule.uid, id = this._getIdWithUnitId(unitId, subUnitId, ruleId), disposeSet = (_a11 = this._disposableMap.get(id)) != null ? _a11 : /* @__PURE__ */ new Set(), handleFormulaChange = /* @__PURE__ */ __name((type, formulaString) => {
4720
2346
  const oldRule = this._dataValidationModel.getRuleById(unitId, subUnitId, ruleId);
4721
2347
  if (!oldRule)
4722
2348
  return { redos: [], undos: [] };
@@ -4793,7 +2419,7 @@ let DataValidationRefRangeController = (_a16 = class extends Disposable {
4793
2419
  }
4794
2420
  }
4795
2421
  register(unitId, subUnitId, rule) {
4796
- var _a24;
2422
+ var _a11;
4797
2423
  const handleRangeChange = /* @__PURE__ */ __name((commandInfo) => {
4798
2424
  const oldRanges = [...rule.ranges], resultRanges = oldRanges.map((range) => handleCommonDefaultRangeChangeWithEffectRefCommands(range, commandInfo)).filter((range) => !!range).flat();
4799
2425
  if (isRangesEqual(resultRanges, oldRanges))
@@ -4831,7 +2457,7 @@ let DataValidationRefRangeController = (_a16 = class extends Disposable {
4831
2457
  const disposable = this._refRangeService.registerRefRange(range, handleRangeChange, unitId, subUnitId);
4832
2458
  disposeList.push(() => disposable.dispose());
4833
2459
  });
4834
- const id = this._getIdWithUnitId(unitId, subUnitId, rule.uid), current = (_a24 = this._disposableMap.get(id)) != null ? _a24 : /* @__PURE__ */ new Set();
2460
+ const id = this._getIdWithUnitId(unitId, subUnitId, rule.uid), current = (_a11 = this._disposableMap.get(id)) != null ? _a11 : /* @__PURE__ */ new Set();
4835
2461
  current.add(() => disposeList.forEach((dispose) => dispose())), this._disposableMap.set(id, current);
4836
2462
  }
4837
2463
  _initRefRange() {
@@ -4867,360 +2493,78 @@ let DataValidationRefRangeController = (_a16 = class extends Disposable {
4867
2493
  }), this._disposableMap.clear();
4868
2494
  }));
4869
2495
  }
4870
- }, __name(_a16, "DataValidationRefRangeController"), _a16);
4871
- DataValidationRefRangeController = __decorateClass$6([
4872
- OnLifecycle(LifecycleStages.Starting, DataValidationRefRangeController),
4873
- __decorateParam$6(0, Inject(SheetDataValidationModel)),
4874
- __decorateParam$6(1, Inject(Injector)),
4875
- __decorateParam$6(2, Inject(RefRangeService)),
4876
- __decorateParam$6(3, Inject(DataValidationCustomFormulaService)),
4877
- __decorateParam$6(4, Inject(DataValidationFormulaService)),
4878
- __decorateParam$6(5, Inject(FormulaRefRangeService))
2496
+ }, __name(_a7, "DataValidationRefRangeController"), _a7);
2497
+ DataValidationRefRangeController = __decorateClass$3([
2498
+ __decorateParam$3(0, Inject(SheetDataValidationModel)),
2499
+ __decorateParam$3(1, Inject(Injector)),
2500
+ __decorateParam$3(2, Inject(RefRangeService)),
2501
+ __decorateParam$3(3, Inject(DataValidationCustomFormulaService)),
2502
+ __decorateParam$3(4, Inject(DataValidationFormulaService)),
2503
+ __decorateParam$3(5, Inject(FormulaRefRangeService))
4879
2504
  ], DataValidationRefRangeController);
4880
- const menuSchema = {
4881
- [RibbonStartGroup.FORMULAS_INSERT]: {
4882
- [DATA_VALIDATION_MENU_ID]: {
4883
- order: 9,
4884
- menuItemFactory: dataValidationMenuFactory,
4885
- [OpenValidationPanelOperation.id]: {
4886
- order: 0,
4887
- menuItemFactory: openDataValidationMenuFactory
4888
- },
4889
- [AddSheetDataValidationAndOpenCommand.id]: {
4890
- order: 1,
4891
- menuItemFactory: addDataValidationMenuFactory
4892
- }
4893
- }
4894
- }
4895
- };
4896
- var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
4897
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2505
+ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2506
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4898
2507
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4899
- return kind && result && __defProp$5(target, key, result), result;
4900
- }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5");
4901
- const INVALID_MARK = {
4902
- tr: {
4903
- size: 6,
4904
- color: "#fe4b4b"
4905
- }
4906
- };
4907
- var _a17;
4908
- let SheetsDataValidationRenderController = (_a17 = class extends RxDisposable {
4909
- constructor(_commandService, _menuManagerService, _renderManagerService, _univerInstanceService, _autoHeightController, _dropdownManagerService, _sheetDataValidationModel, _dataValidatorRegistryService, _sheetInterceptorService, _editorBridgeService) {
4910
- super(), this._commandService = _commandService, this._menuManagerService = _menuManagerService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._autoHeightController = _autoHeightController, this._dropdownManagerService = _dropdownManagerService, this._sheetDataValidationModel = _sheetDataValidationModel, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._sheetInterceptorService = _sheetInterceptorService, this._editorBridgeService = _editorBridgeService, this._initMenu(), this._initSkeletonChange(), this._initDropdown(), this._initViewModelIntercept(), this._initAutoHeight();
4911
- }
4912
- _initMenu() {
4913
- this._menuManagerService.mergeMenu(menuSchema);
4914
- }
4915
- _initDropdown() {
4916
- this._editorBridgeService && this.disposeWithMe(this._editorBridgeService.visible$.subscribe((visible) => {
4917
- var _a24;
4918
- if (!visible.visible) {
4919
- ((_a24 = this._dropdownManagerService.activeDropdown) == null ? void 0 : _a24.trigger) === "editor-bridge" && this._dropdownManagerService.hideDropdown();
4920
- return;
4921
- }
4922
- const state = this._editorBridgeService.getEditCellState();
4923
- if (state) {
4924
- const { unitId, sheetId, row, column } = state, workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
4925
- if (!workbook)
4926
- return;
4927
- const rule = this._sheetDataValidationModel.getRuleByLocation(unitId, sheetId, row, column);
4928
- if (!rule)
4929
- return;
4930
- const validator = this._dataValidatorRegistryService.getValidatorItem(rule.type);
4931
- if (!(validator != null && validator.dropdown))
4932
- return;
4933
- const worksheet = workbook.getActiveSheet();
4934
- if (!worksheet) return;
4935
- const activeDropdown = this._dropdownManagerService.activeDropdown, currLoc = activeDropdown == null ? void 0 : activeDropdown.location;
4936
- if (currLoc && currLoc.unitId === unitId && currLoc.subUnitId === sheetId && currLoc.row === row && currLoc.col === column)
4937
- return;
4938
- this._dropdownManagerService.showDropdown(
4939
- {
4940
- location: {
4941
- unitId,
4942
- subUnitId: sheetId,
4943
- row,
4944
- col: column,
4945
- workbook,
4946
- worksheet
4947
- },
4948
- componentKey: validator.dropdown,
4949
- onHide: /* @__PURE__ */ __name(() => {
4950
- }, "onHide"),
4951
- trigger: "editor-bridge"
4952
- },
4953
- !1
4954
- );
4955
- }
4956
- }));
4957
- }
4958
- _initSkeletonChange() {
4959
- const markSkeletonDirty = /* @__PURE__ */ __name(() => {
4960
- var _a24, _b, _c;
4961
- const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
4962
- if (!workbook) return;
4963
- const unitId = workbook.getUnitId(), subUnitId = (_a24 = workbook.getActiveSheet()) == null ? void 0 : _a24.getSheetId();
4964
- if (!subUnitId) return;
4965
- const skeleton = (_c = (_b = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _b.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId)) == null ? void 0 : _c.skeleton, currentRender = this._renderManagerService.getRenderById(unitId);
4966
- skeleton == null || skeleton.makeDirty(!0), skeleton == null || skeleton.calculate(), currentRender && currentRender.mainComponent.makeForceDirty();
4967
- }, "markSkeletonDirty");
4968
- this.disposeWithMe(this._sheetDataValidationModel.ruleChange$.pipe(debounceTime(16)).subscribe(() => markSkeletonDirty())), this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(debounceTime(16)).subscribe(() => markSkeletonDirty()));
2508
+ return kind && result && __defProp$2(target, key, result), result;
2509
+ }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a8;
2510
+ let SheetDataValidationSheetController = (_a8 = class extends Disposable {
2511
+ constructor(_sheetInterceptorService, _univerInstanceService, _sheetDataValidationModel) {
2512
+ super(), this._sheetInterceptorService = _sheetInterceptorService, this._univerInstanceService = _univerInstanceService, this._sheetDataValidationModel = _sheetDataValidationModel, this._initSheetChange();
4969
2513
  }
4970
- // eslint-disable-next-line max-lines-per-function
4971
- _initViewModelIntercept() {
2514
+ _initSheetChange() {
4972
2515
  this.disposeWithMe(
4973
- this._sheetInterceptorService.intercept(
4974
- INTERCEPTOR_POINT.CELL_CONTENT,
4975
- {
4976
- effect: InterceptorEffectEnum.Style,
4977
- // must be after numfmt
4978
- priority: InterceptCellContentPriority.DATA_VALIDATION,
4979
- // eslint-disable-next-line max-lines-per-function, complexity
4980
- handler: /* @__PURE__ */ __name((cell, pos, next) => {
4981
- var _a24, _b, _c, _d;
4982
- const { row, col, unitId, subUnitId, workbook, worksheet } = pos, ruleId = this._sheetDataValidationModel.getRuleIdByLocation(unitId, subUnitId, row, col);
4983
- if (!ruleId)
4984
- return next(cell);
4985
- const rule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
4986
- if (!rule)
4987
- return next(cell);
4988
- const validStatus = this._sheetDataValidationModel.validator(cell, rule, pos), validator = this._dataValidatorRegistryService.getValidatorItem(rule.type), cellOrigin = pos.rawData;
4989
- let cache;
4990
- const cellValue = {
4991
- get value() {
4992
- var _a25;
4993
- return cache !== void 0 || (cache = (_a25 = getCellValueOrigin(cellOrigin)) != null ? _a25 : null), cache;
4994
- }
4995
- }, valueStr = {
4996
- get value() {
4997
- var _a25;
4998
- return `${(_a25 = cellValue.value) != null ? _a25 : ""}`;
4999
- }
2516
+ this._sheetInterceptorService.interceptCommand({
2517
+ getMutations: /* @__PURE__ */ __name((commandInfo) => {
2518
+ var _a11;
2519
+ if (commandInfo.id === RemoveSheetCommand.id) {
2520
+ const params = commandInfo.params, unitId = params.unitId || this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getUnitId(), workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
2521
+ if (!workbook)
2522
+ return { redos: [], undos: [] };
2523
+ const subUnitId = params.subUnitId || ((_a11 = workbook.getActiveSheet()) == null ? void 0 : _a11.getSheetId());
2524
+ if (!subUnitId)
2525
+ return { redos: [], undos: [] };
2526
+ const rules = this._sheetDataValidationModel.getRules(unitId, subUnitId);
2527
+ if (rules.length === 0)
2528
+ return { redos: [], undos: [] };
2529
+ const ids = rules.map((i) => i.uid), redoParams = {
2530
+ unitId,
2531
+ subUnitId,
2532
+ ruleId: ids,
2533
+ source: "patched"
2534
+ }, undoParams = {
2535
+ unitId,
2536
+ subUnitId,
2537
+ rule: [...rules],
2538
+ source: "patched"
5000
2539
  };
5001
- return next({
5002
- ...cell,
5003
- dataValidation: {
5004
- ruleId,
5005
- validStatus,
5006
- rule,
5007
- validator
5008
- },
5009
- markers: {
5010
- ...cell == null ? void 0 : cell.markers,
5011
- ...validStatus === DataValidationStatus.INVALID ? INVALID_MARK : null
5012
- },
5013
- customRender: [
5014
- ...(_a24 = cell == null ? void 0 : cell.customRender) != null ? _a24 : [],
5015
- ...validator != null && validator.canvasRender ? [validator.canvasRender] : []
5016
- ],
5017
- fontRenderExtension: {
5018
- ...cell == null ? void 0 : cell.fontRenderExtension,
5019
- isSkip: ((_b = cell == null ? void 0 : cell.fontRenderExtension) == null ? void 0 : _b.isSkip) || ((_c = validator == null ? void 0 : validator.skipDefaultFontRender) == null ? void 0 : _c.call(validator, rule, cellValue.value, pos))
5020
- },
5021
- interceptorStyle: {
5022
- ...cell == null ? void 0 : cell.interceptorStyle,
5023
- ...validator == null ? void 0 : validator.getExtraStyle(rule, valueStr.value, {
5024
- get style() {
5025
- const styleMap = workbook.getStyles();
5026
- return (typeof (cell == null ? void 0 : cell.s) == "string" ? styleMap.get(cell == null ? void 0 : cell.s) : cell == null ? void 0 : cell.s) || {};
5027
- }
5028
- })
5029
- },
5030
- interceptorAutoHeight: /* @__PURE__ */ __name(() => {
5031
- var _a25, _b2, _c2, _d2, _e, _f;
5032
- const skeleton = (_b2 = (_a25 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a25.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId)) == null ? void 0 : _b2.skeleton;
5033
- if (!skeleton)
5034
- return;
5035
- const mergeCell = skeleton.worksheet.getMergedCell(row, col), info = {
5036
- data: {
5037
- ...cell,
5038
- dataValidation: {
5039
- ruleId,
5040
- validStatus,
5041
- rule,
5042
- validator
5043
- }
5044
- },
5045
- style: skeleton.getsStyles().getStyleByCell(cell),
5046
- primaryWithCoord: skeleton.getCellByIndex((_c2 = mergeCell == null ? void 0 : mergeCell.startRow) != null ? _c2 : row, (_d2 = mergeCell == null ? void 0 : mergeCell.startColumn) != null ? _d2 : col),
5047
- unitId,
5048
- subUnitId,
5049
- row,
5050
- col,
5051
- workbook,
5052
- worksheet
5053
- };
5054
- return (_f = (_e = validator == null ? void 0 : validator.canvasRender) == null ? void 0 : _e.calcCellAutoHeight) == null ? void 0 : _f.call(_e, info);
5055
- }, "interceptorAutoHeight"),
5056
- coverable: ((_d = cell == null ? void 0 : cell.coverable) != null ? _d : !0) && !(rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE)
5057
- });
5058
- }, "handler")
5059
- }
5060
- )
5061
- );
5062
- }
5063
- _initAutoHeight() {
5064
- this._sheetDataValidationModel.ruleChange$.pipe(
5065
- // patched data-validation change don't need to re-calc row height
5066
- // re-calc of row height will be triggered precisely by the origin command
5067
- filter((change) => change.source === "command"),
5068
- bufferTime(16)
5069
- ).subscribe((infos) => {
5070
- const ranges = [];
5071
- if (infos.forEach((info) => {
5072
- var _a24;
5073
- (_a24 = info.rule) != null && _a24.ranges && ranges.push(...info.rule.ranges);
5074
- }), ranges.length) {
5075
- const mutations = this._autoHeightController.getUndoRedoParamsOfAutoHeight(ranges);
5076
- sequenceExecute(mutations.redos, this._commandService);
5077
- }
5078
- });
5079
- }
5080
- }, __name(_a17, "SheetsDataValidationRenderController"), _a17);
5081
- SheetsDataValidationRenderController = __decorateClass$5([
5082
- OnLifecycle(LifecycleStages.Rendered, SheetsDataValidationRenderController),
5083
- __decorateParam$5(0, ICommandService),
5084
- __decorateParam$5(1, IMenuManagerService),
5085
- __decorateParam$5(2, IRenderManagerService),
5086
- __decorateParam$5(3, IUniverInstanceService),
5087
- __decorateParam$5(4, Inject(AutoHeightController)),
5088
- __decorateParam$5(5, Inject(DataValidationDropdownManagerService)),
5089
- __decorateParam$5(6, Inject(SheetDataValidationModel)),
5090
- __decorateParam$5(7, Inject(DataValidatorRegistryService)),
5091
- __decorateParam$5(8, Inject(SheetInterceptorService)),
5092
- __decorateParam$5(9, Optional(IEditorBridgeService))
5093
- ], SheetsDataValidationRenderController);
5094
- var _a18;
5095
- let SheetsDataValidationMobileRenderController = (_a18 = class extends RxDisposable {
5096
- constructor(_commandService, _renderManagerService, _univerInstanceService, _autoHeightController, _dataValidatorRegistryService, _sheetInterceptorService, _sheetDataValidationModel) {
5097
- super(), this._commandService = _commandService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._autoHeightController = _autoHeightController, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._sheetInterceptorService = _sheetInterceptorService, this._sheetDataValidationModel = _sheetDataValidationModel, this._initSkeletonChange(), this._initViewModelIntercept(), this._initAutoHeight();
5098
- }
5099
- _initSkeletonChange() {
5100
- const markSkeletonDirty = /* @__PURE__ */ __name(() => {
5101
- var _a24, _b, _c;
5102
- const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
5103
- if (!workbook) return;
5104
- const unitId = workbook.getUnitId(), subUnitId = (_a24 = workbook.getActiveSheet()) == null ? void 0 : _a24.getSheetId();
5105
- if (!subUnitId) return;
5106
- const skeleton = (_c = (_b = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _b.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId)) == null ? void 0 : _c.skeleton, currentRender = this._renderManagerService.getRenderById(unitId);
5107
- skeleton == null || skeleton.makeDirty(!0), skeleton == null || skeleton.calculate(), currentRender && currentRender.mainComponent.makeForceDirty();
5108
- }, "markSkeletonDirty");
5109
- this.disposeWithMe(this._sheetDataValidationModel.ruleChange$.pipe(debounceTime(16)).subscribe(() => markSkeletonDirty())), this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(debounceTime(16)).subscribe(() => markSkeletonDirty()));
5110
- }
5111
- // eslint-disable-next-line max-lines-per-function
5112
- _initViewModelIntercept() {
5113
- this.disposeWithMe(
5114
- this._sheetInterceptorService.intercept(
5115
- INTERCEPTOR_POINT.CELL_CONTENT,
5116
- {
5117
- effect: InterceptorEffectEnum.Style,
5118
- // must be after numfmt
5119
- priority: InterceptCellContentPriority.DATA_VALIDATION,
5120
- // eslint-disable-next-line complexity
5121
- handler: /* @__PURE__ */ __name((cell, pos, next) => {
5122
- var _a24, _b, _c, _d;
5123
- const { row, col, unitId, subUnitId, workbook, worksheet } = pos, ruleId = this._sheetDataValidationModel.getRuleIdByLocation(unitId, subUnitId, row, col);
5124
- if (!ruleId)
5125
- return next(cell);
5126
- const rule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
5127
- if (!rule)
5128
- return next(cell);
5129
- const validStatus = this._sheetDataValidationModel.validator(cell, rule, pos), validator = this._dataValidatorRegistryService.getValidatorItem(rule.type), cellOrigin = worksheet.getCellRaw(row, col), cellValue = getCellValueOrigin(cellOrigin), valueStr = `${cellValue != null ? cellValue : ""}`;
5130
- return next({
5131
- ...cell,
5132
- dataValidation: {
5133
- ruleId,
5134
- validStatus,
5135
- rule,
5136
- validator
5137
- },
5138
- markers: {
5139
- ...cell == null ? void 0 : cell.markers,
5140
- ...validStatus === DataValidationStatus.INVALID ? INVALID_MARK : null
5141
- },
5142
- customRender: [
5143
- ...(_a24 = cell == null ? void 0 : cell.customRender) != null ? _a24 : [],
5144
- ...validator != null && validator.canvasRender ? [validator.canvasRender] : []
5145
- ],
5146
- fontRenderExtension: {
5147
- ...cell == null ? void 0 : cell.fontRenderExtension,
5148
- isSkip: ((_b = cell == null ? void 0 : cell.fontRenderExtension) == null ? void 0 : _b.isSkip) || ((_c = validator == null ? void 0 : validator.skipDefaultFontRender) == null ? void 0 : _c.call(validator, rule, cellValue, pos))
5149
- },
5150
- interceptorStyle: {
5151
- ...cell == null ? void 0 : cell.interceptorStyle,
5152
- ...validator == null ? void 0 : validator.getExtraStyle(rule, valueStr, {
5153
- get style() {
5154
- const styleMap = workbook.getStyles();
5155
- return (typeof (cell == null ? void 0 : cell.s) == "string" ? styleMap.get(cell == null ? void 0 : cell.s) : cell == null ? void 0 : cell.s) || {};
5156
- }
5157
- })
5158
- },
5159
- interceptorAutoHeight: /* @__PURE__ */ __name(() => {
5160
- var _a25, _b2, _c2, _d2, _e, _f;
5161
- const skeleton = (_b2 = (_a25 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a25.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId)) == null ? void 0 : _b2.skeleton;
5162
- if (!skeleton)
5163
- return;
5164
- const mergeCell = skeleton.worksheet.getMergedCell(row, col), info = {
5165
- data: {
5166
- ...cell,
5167
- dataValidation: {
5168
- ruleId,
5169
- validStatus,
5170
- rule,
5171
- validator
5172
- }
5173
- },
5174
- style: skeleton.getsStyles().getStyleByCell(cell),
5175
- primaryWithCoord: skeleton.getCellByIndex((_c2 = mergeCell == null ? void 0 : mergeCell.startRow) != null ? _c2 : row, (_d2 = mergeCell == null ? void 0 : mergeCell.startColumn) != null ? _d2 : col),
5176
- unitId,
5177
- subUnitId,
5178
- row,
5179
- col,
5180
- workbook,
5181
- worksheet
5182
- };
5183
- return (_f = (_e = validator == null ? void 0 : validator.canvasRender) == null ? void 0 : _e.calcCellAutoHeight) == null ? void 0 : _f.call(_e, info);
5184
- }, "interceptorAutoHeight"),
5185
- coverable: ((_d = cell == null ? void 0 : cell.coverable) != null ? _d : !0) && !(rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE)
5186
- });
5187
- }, "handler")
5188
- }
5189
- )
2540
+ return {
2541
+ redos: [{
2542
+ id: RemoveDataValidationMutation.id,
2543
+ params: redoParams
2544
+ }],
2545
+ undos: [{
2546
+ id: AddDataValidationMutation.id,
2547
+ params: undoParams
2548
+ }]
2549
+ };
2550
+ }
2551
+ return { redos: [], undos: [] };
2552
+ }, "getMutations")
2553
+ })
5190
2554
  );
5191
2555
  }
5192
- _initAutoHeight() {
5193
- this._sheetDataValidationModel.ruleChange$.pipe(
5194
- filter((change) => change.source === "command"),
5195
- bufferTime(16)
5196
- ).subscribe((infos) => {
5197
- const ranges = [];
5198
- if (infos.forEach((info) => {
5199
- var _a24;
5200
- (_a24 = info.rule) != null && _a24.ranges && ranges.push(...info.rule.ranges);
5201
- }), ranges.length) {
5202
- const mutations = this._autoHeightController.getUndoRedoParamsOfAutoHeight(ranges);
5203
- sequenceExecute(mutations.redos, this._commandService);
5204
- }
5205
- });
5206
- }
5207
- }, __name(_a18, "SheetsDataValidationMobileRenderController"), _a18);
5208
- SheetsDataValidationMobileRenderController = __decorateClass$5([
5209
- OnLifecycle(LifecycleStages.Rendered, SheetsDataValidationMobileRenderController),
5210
- __decorateParam$5(0, ICommandService),
5211
- __decorateParam$5(1, IRenderManagerService),
5212
- __decorateParam$5(2, IUniverInstanceService),
5213
- __decorateParam$5(3, Inject(AutoHeightController)),
5214
- __decorateParam$5(4, Inject(DataValidatorRegistryService)),
5215
- __decorateParam$5(5, Inject(SheetInterceptorService)),
5216
- __decorateParam$5(6, Inject(SheetDataValidationModel))
5217
- ], SheetsDataValidationMobileRenderController);
5218
- var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
5219
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2556
+ }, __name(_a8, "SheetDataValidationSheetController"), _a8);
2557
+ SheetDataValidationSheetController = __decorateClass$2([
2558
+ __decorateParam$2(0, Inject(SheetInterceptorService)),
2559
+ __decorateParam$2(1, Inject(IUniverInstanceService)),
2560
+ __decorateParam$2(2, Inject(SheetDataValidationModel))
2561
+ ], SheetDataValidationSheetController);
2562
+ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2563
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
5220
2564
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
5221
- return kind && result && __defProp$4(target, key, result), result;
5222
- }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a19;
5223
- let SheetsDataValidationValidatorService = (_a19 = class {
2565
+ return kind && result && __defProp$1(target, key, result), result;
2566
+ }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a9;
2567
+ let SheetsDataValidationValidatorService = (_a9 = class {
5224
2568
  constructor(_univerInstanceService, _sheetDataValidationModel, _dataValidationCacheService) {
5225
2569
  this._univerInstanceService = _univerInstanceService, this._sheetDataValidationModel = _sheetDataValidationModel, this._dataValidationCacheService = _dataValidationCacheService;
5226
2570
  }
@@ -5273,299 +2617,104 @@ let SheetsDataValidationValidatorService = (_a19 = class {
5273
2617
  getDataValidation(unitId, subUnitId, ranges) {
5274
2618
  return this.getDataValidations(unitId, subUnitId, ranges)[0];
5275
2619
  }
5276
- }, __name(_a19, "SheetsDataValidationValidatorService"), _a19);
5277
- SheetsDataValidationValidatorService = __decorateClass$4([
5278
- __decorateParam$4(0, IUniverInstanceService),
5279
- __decorateParam$4(1, Inject(SheetDataValidationModel)),
5280
- __decorateParam$4(2, Inject(DataValidationCacheService))
2620
+ }, __name(_a9, "SheetsDataValidationValidatorService"), _a9);
2621
+ SheetsDataValidationValidatorService = __decorateClass$1([
2622
+ __decorateParam$1(0, IUniverInstanceService),
2623
+ __decorateParam$1(1, Inject(SheetDataValidationModel)),
2624
+ __decorateParam$1(2, Inject(DataValidationCacheService))
5281
2625
  ], SheetsDataValidationValidatorService);
5282
- var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __defNormalProp$1 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp$1"), __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
5283
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
5284
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
5285
- return kind && result && __defProp$3(target, key, result), result;
5286
- }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), __publicField$1 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp$1(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField$1"), _a20;
5287
- let UniverSheetsDataValidationMobilePlugin = (_a20 = class extends Plugin {
5288
- constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
5289
- super(), this._config = _config, this._injector = _injector, this._commandService = _commandService, this._configService = _configService;
5290
- const { menu, ...rest } = this._config;
5291
- menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
5292
- }
5293
- onStarting() {
5294
- [
5295
- [DataValidationPanelService],
5296
- [DataValidationCacheService],
5297
- [DataValidationFormulaService],
5298
- [DataValidationCustomFormulaService],
5299
- [DataValidationDropdownManagerService],
5300
- [SheetsDataValidationValidatorService],
5301
- [SheetDataValidationModel],
5302
- // controller
5303
- [DataValidationController],
5304
- [SheetsDataValidationMobileRenderController],
5305
- [DataValidationAlertController],
5306
- [DataValidationRefRangeController],
5307
- [DataValidationPermissionController],
5308
- [DataValidationCopyPasteController],
5309
- [DataValidationFormulaController]
5310
- ].forEach((dep) => {
5311
- this._injector.add(dep);
5312
- }), [
5313
- AddSheetDataValidationCommand,
5314
- AddSheetDataValidationAndOpenCommand,
5315
- UpdateSheetDataValidationRangeCommand,
5316
- UpdateSheetDataValidationSettingCommand,
5317
- UpdateSheetDataValidationOptionsCommand,
5318
- RemoveSheetDataValidationCommand,
5319
- RemoveSheetAllDataValidationCommand,
5320
- ClearRangeDataValidationCommand,
5321
- // operation
5322
- ShowDataValidationDropdown,
5323
- HideDataValidationDropdown,
5324
- CloseValidationPanelOperation,
5325
- OpenValidationPanelOperation,
5326
- ToggleValidationPanelOperation
5327
- ].forEach((command) => {
5328
- this._commandService.registerCommand(command);
5329
- });
5330
- }
5331
- }, __name(_a20, "UniverSheetsDataValidationMobilePlugin"), _a20);
5332
- __publicField$1(UniverSheetsDataValidationMobilePlugin, "pluginName", DATA_VALIDATION_PLUGIN_NAME);
5333
- __publicField$1(UniverSheetsDataValidationMobilePlugin, "type", UniverInstanceType.UNIVER_SHEET);
5334
- UniverSheetsDataValidationMobilePlugin = __decorateClass$3([
5335
- DependentOn(UniverDataValidationPlugin, UniverSheetsPlugin, UniverSheetsUIPlugin),
5336
- __decorateParam$3(1, Inject(Injector)),
5337
- __decorateParam$3(2, ICommandService),
5338
- __decorateParam$3(3, IConfigService)
5339
- ], UniverSheetsDataValidationMobilePlugin);
5340
- var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
5341
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
5342
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
5343
- return kind && result && __defProp$2(target, key, result), result;
5344
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a21;
5345
- let DataValidationAutoFillController = (_a21 = class extends Disposable {
5346
- constructor(_autoFillService, _dataValidationModel, _injector) {
5347
- super(), this._autoFillService = _autoFillService, this._dataValidationModel = _dataValidationModel, this._injector = _injector, this._initAutoFill();
5348
- }
5349
- // eslint-disable-next-line max-lines-per-function
5350
- _initAutoFill() {
5351
- const noopReturnFunc = /* @__PURE__ */ __name(() => ({ redos: [], undos: [] }), "noopReturnFunc"), generalApplyFunc = /* @__PURE__ */ __name((location, applyType) => {
5352
- const { source: sourceRange, target: targetRange, unitId, subUnitId } = location, ruleMatrixCopy = this._dataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone(), virtualRange = virtualizeDiscreteRanges([sourceRange, targetRange]), [vSourceRange, vTargetRange] = virtualRange.ranges, { mapFunc } = virtualRange, sourceStartCell = {
5353
- row: vSourceRange.startRow,
5354
- col: vSourceRange.startColumn
5355
- }, repeats = getAutoFillRepeatRange(vSourceRange, vTargetRange), additionMatrix = new ObjectMatrix(), additionRules = /* @__PURE__ */ new Set();
5356
- repeats.forEach((repeat) => {
5357
- const targetStartCell = repeat.repeatStartCell, relativeRange = repeat.relativeRange, sourceRange2 = {
5358
- startRow: sourceStartCell.row,
5359
- startColumn: sourceStartCell.col,
5360
- endColumn: sourceStartCell.col,
5361
- endRow: sourceStartCell.row
5362
- }, targetRange2 = {
5363
- startRow: targetStartCell.row,
5364
- startColumn: targetStartCell.col,
5365
- endColumn: targetStartCell.col,
5366
- endRow: targetStartCell.row
5367
- };
5368
- Range.foreach(relativeRange, (row, col) => {
5369
- const sourcePositionRange = Rectangle.getPositionRange(
5370
- {
5371
- startRow: row,
5372
- startColumn: col,
5373
- endColumn: col,
5374
- endRow: row
5375
- },
5376
- sourceRange2
5377
- ), { row: sourceRow, col: sourceCol } = mapFunc(sourcePositionRange.startRow, sourcePositionRange.startColumn), ruleId = this._dataValidationModel.getRuleIdByLocation(unitId, subUnitId, sourceRow, sourceCol);
5378
- if (ruleId) {
5379
- const targetPositionRange = Rectangle.getPositionRange(
5380
- {
5381
- startRow: row,
5382
- startColumn: col,
5383
- endColumn: col,
5384
- endRow: row
5385
- },
5386
- targetRange2
5387
- ), { row: targetRow, col: targetCol } = mapFunc(targetPositionRange.startRow, targetPositionRange.startColumn);
5388
- additionMatrix.setValue(targetRow, targetCol, ruleId), additionRules.add(ruleId);
5389
- }
5390
- });
5391
- });
5392
- const additions = Array.from(additionRules).map((id) => ({ id, ranges: queryObjectMatrix(additionMatrix, (value) => value === id) }));
5393
- ruleMatrixCopy.addRangeRules(additions);
5394
- const diffs = ruleMatrixCopy.diff(this._dataValidationModel.getRules(unitId, subUnitId)), { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, this._injector, "patched", applyType === APPLY_TYPE.ONLY_FORMAT);
5395
- return {
5396
- undos: undoMutations,
5397
- redos: redoMutations
5398
- };
5399
- }, "generalApplyFunc"), disabledDataVallation = [
5400
- DataValidationType.CHECKBOX
5401
- ], hook = {
5402
- id: DATA_VALIDATION_PLUGIN_NAME,
5403
- onBeforeFillData: /* @__PURE__ */ __name((location) => {
5404
- const { source: sourceRange, unitId, subUnitId } = location;
5405
- for (const row of sourceRange.rows)
5406
- for (const col of sourceRange.cols) {
5407
- const dv = this._dataValidationModel.getRuleByLocation(unitId, subUnitId, row, col);
5408
- if (dv && disabledDataVallation.indexOf(dv.type) > -1) {
5409
- this._autoFillService.setDisableApplyType(APPLY_TYPE.SERIES, !0);
5410
- return;
5411
- }
5412
- }
5413
- }, "onBeforeFillData"),
5414
- onFillData: /* @__PURE__ */ __name((location, direction, applyType) => applyType === APPLY_TYPE.COPY || applyType === APPLY_TYPE.ONLY_FORMAT || applyType === APPLY_TYPE.SERIES ? generalApplyFunc(location, applyType) : noopReturnFunc(), "onFillData"),
5415
- onAfterFillData: /* @__PURE__ */ __name(() => {
5416
- }, "onAfterFillData")
5417
- };
5418
- this.disposeWithMe(this._autoFillService.addHook(hook));
5419
- }
5420
- }, __name(_a21, "DataValidationAutoFillController"), _a21);
5421
- DataValidationAutoFillController = __decorateClass$2([
5422
- OnLifecycle(LifecycleStages.Ready, DataValidationAutoFillController),
5423
- __decorateParam$2(0, IAutoFillService),
5424
- __decorateParam$2(1, Inject(SheetDataValidationModel)),
5425
- __decorateParam$2(2, Inject(Injector))
5426
- ], DataValidationAutoFillController);
5427
- var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
5428
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
5429
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
5430
- return kind && result && __defProp$1(target, key, result), result;
5431
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a22;
5432
- let SheetDataValidationSheetController = (_a22 = class extends Disposable {
5433
- constructor(_sheetInterceptorService, _univerInstanceService, _sheetDataValidationModel) {
5434
- super(), this._sheetInterceptorService = _sheetInterceptorService, this._univerInstanceService = _univerInstanceService, this._sheetDataValidationModel = _sheetDataValidationModel, this._initSheetChange();
5435
- }
5436
- _initSheetChange() {
5437
- this.disposeWithMe(
5438
- this._sheetInterceptorService.interceptCommand({
5439
- getMutations: /* @__PURE__ */ __name((commandInfo) => {
5440
- var _a24;
5441
- if (commandInfo.id === RemoveSheetCommand.id) {
5442
- const params = commandInfo.params, unitId = params.unitId || this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getUnitId(), workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
5443
- if (!workbook)
5444
- return { redos: [], undos: [] };
5445
- const subUnitId = params.subUnitId || ((_a24 = workbook.getActiveSheet()) == null ? void 0 : _a24.getSheetId());
5446
- if (!subUnitId)
5447
- return { redos: [], undos: [] };
5448
- const rules = this._sheetDataValidationModel.getRules(unitId, subUnitId);
5449
- if (rules.length === 0)
5450
- return { redos: [], undos: [] };
5451
- const ids = rules.map((i) => i.uid), redoParams = {
5452
- unitId,
5453
- subUnitId,
5454
- ruleId: ids,
5455
- source: "patched"
5456
- }, undoParams = {
5457
- unitId,
5458
- subUnitId,
5459
- rule: [...rules],
5460
- source: "patched"
5461
- };
5462
- return {
5463
- redos: [{
5464
- id: RemoveDataValidationMutation.id,
5465
- params: redoParams
5466
- }],
5467
- undos: [{
5468
- id: AddDataValidationMutation.id,
5469
- params: undoParams
5470
- }]
5471
- };
5472
- }
5473
- return { redos: [], undos: [] };
5474
- }, "getMutations")
5475
- })
5476
- );
5477
- }
5478
- }, __name(_a22, "SheetDataValidationSheetController"), _a22);
5479
- SheetDataValidationSheetController = __decorateClass$1([
5480
- OnLifecycle(LifecycleStages.Ready, SheetDataValidationSheetController),
5481
- __decorateParam$1(0, Inject(SheetInterceptorService)),
5482
- __decorateParam$1(1, Inject(IUniverInstanceService)),
5483
- __decorateParam$1(2, Inject(SheetDataValidationModel))
5484
- ], SheetDataValidationSheetController);
5485
2626
  var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
5486
2627
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
5487
2628
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
5488
2629
  return kind && result && __defProp2(target, key, result), result;
5489
- }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField"), _a23;
5490
- let UniverSheetsDataValidationPlugin = (_a23 = class extends Plugin {
2630
+ }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField"), _a10;
2631
+ let UniverSheetsDataValidationPlugin = (_a10 = class extends Plugin {
5491
2632
  constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
5492
2633
  super(), this._config = _config, this._injector = _injector, this._commandService = _commandService, this._configService = _configService;
5493
- const { menu, ...rest } = this._config;
5494
- menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
2634
+ const { ...rest } = this._config;
2635
+ this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
5495
2636
  }
5496
2637
  onStarting() {
5497
2638
  [
5498
- [DataValidationPanelService],
5499
2639
  [DataValidationCacheService],
5500
2640
  [DataValidationFormulaService],
5501
2641
  [DataValidationCustomFormulaService],
5502
- [DataValidationDropdownManagerService],
5503
2642
  [SheetsDataValidationValidatorService],
5504
2643
  [SheetDataValidationModel],
5505
- // controller
5506
2644
  [DataValidationController],
5507
- [SheetsDataValidationRenderController],
5508
- [DataValidationAlertController],
5509
2645
  [DataValidationRefRangeController],
5510
- [DataValidationPermissionController],
5511
- [DataValidationAutoFillController],
5512
- [DataValidationCopyPasteController],
5513
2646
  [DataValidationFormulaController],
5514
- [DataValidationRejectInputController],
5515
2647
  [SheetDataValidationSheetController]
5516
2648
  ].forEach((dep) => {
5517
2649
  this._injector.add(dep);
5518
2650
  }), [
5519
2651
  AddSheetDataValidationCommand,
5520
- AddSheetDataValidationAndOpenCommand,
5521
2652
  UpdateSheetDataValidationRangeCommand,
5522
2653
  UpdateSheetDataValidationSettingCommand,
5523
2654
  UpdateSheetDataValidationOptionsCommand,
5524
2655
  RemoveSheetDataValidationCommand,
5525
2656
  RemoveSheetAllDataValidationCommand,
5526
- ClearRangeDataValidationCommand,
5527
- // operation
5528
- ShowDataValidationDropdown,
5529
- HideDataValidationDropdown,
5530
- CloseValidationPanelOperation,
5531
- OpenValidationPanelOperation,
5532
- ToggleValidationPanelOperation
2657
+ ClearRangeDataValidationCommand
5533
2658
  ].forEach((command) => {
5534
2659
  this._commandService.registerCommand(command);
5535
- });
2660
+ }), this._injector.get(DataValidationRefRangeController);
2661
+ }
2662
+ onReady() {
2663
+ this._injector.get(SheetDataValidationSheetController);
5536
2664
  }
5537
- }, __name(_a23, "UniverSheetsDataValidationPlugin"), _a23);
2665
+ onRendered() {
2666
+ this._injector.get(DataValidationController), this._injector.get(DataValidationFormulaController);
2667
+ }
2668
+ }, __name(_a10, "UniverSheetsDataValidationPlugin"), _a10);
5538
2669
  __publicField2(UniverSheetsDataValidationPlugin, "pluginName", DATA_VALIDATION_PLUGIN_NAME);
5539
2670
  __publicField2(UniverSheetsDataValidationPlugin, "type", UniverInstanceType.UNIVER_SHEET);
5540
2671
  UniverSheetsDataValidationPlugin = __decorateClass([
5541
- DependentOn(UniverSheetsNumfmtPlugin, UniverDataValidationPlugin, UniverSheetsUIPlugin),
2672
+ DependentOn(UniverDataValidationPlugin),
5542
2673
  __decorateParam(1, Inject(Injector)),
5543
2674
  __decorateParam(2, ICommandService),
5544
2675
  __decorateParam(3, IConfigService)
5545
2676
  ], UniverSheetsDataValidationPlugin);
2677
+ function createDefaultNewRule(accessor) {
2678
+ const currentRanges = accessor.get(SheetsSelectionsService).getCurrentSelections().map((s) => s.range);
2679
+ return {
2680
+ uid: Tools.generateRandomId(6),
2681
+ type: DataValidationType.DECIMAL,
2682
+ operator: DataValidationOperator.EQUAL,
2683
+ formula1: "100",
2684
+ ranges: currentRanges != null ? currentRanges : [{ startColumn: 0, endColumn: 0, startRow: 0, endRow: 0 }]
2685
+ };
2686
+ }
2687
+ __name(createDefaultNewRule, "createDefaultNewRule");
5546
2688
  export {
5547
- AddSheetDataValidationAndOpenCommand,
5548
2689
  AddSheetDataValidationCommand,
2690
+ CHECKBOX_FORMULA_1,
2691
+ CHECKBOX_FORMULA_2,
2692
+ CheckboxValidator,
5549
2693
  ClearRangeDataValidationCommand,
5550
- CloseValidationPanelOperation,
5551
2694
  DATA_VALIDATION_PLUGIN_NAME,
5552
- DATE_DROPDOWN_KEY,
5553
2695
  DataValidationCacheService,
5554
2696
  DataValidationCustomFormulaService,
2697
+ DataValidationFormulaController,
5555
2698
  DataValidationFormulaService,
5556
2699
  DataValidationModel2 as DataValidationModel,
5557
- HideDataValidationDropdown,
5558
- LIST_DROPDOWN_KEY,
5559
- OpenValidationPanelOperation,
2700
+ DateValidator,
2701
+ ListMultipleValidator,
2702
+ ListValidator,
5560
2703
  RemoveSheetAllDataValidationCommand,
5561
2704
  RemoveSheetDataValidationCommand,
5562
2705
  SheetDataValidationModel,
5563
2706
  SheetsDataValidationValidatorService,
5564
- ShowDataValidationDropdown,
5565
- ToggleValidationPanelOperation,
5566
- UniverSheetsDataValidationMobilePlugin,
5567
2707
  UniverSheetsDataValidationPlugin,
5568
2708
  UpdateSheetDataValidationOptionsCommand,
5569
2709
  UpdateSheetDataValidationRangeCommand,
5570
- UpdateSheetDataValidationSettingCommand
2710
+ UpdateSheetDataValidationSettingCommand,
2711
+ createDefaultNewRule,
2712
+ deserializeListOptions,
2713
+ getCellValueOrigin,
2714
+ getDataValidationCellValue,
2715
+ getDataValidationDiffMutations,
2716
+ getFormulaCellData,
2717
+ getFormulaResult,
2718
+ serializeListOptions,
2719
+ transformCheckboxValue
5571
2720
  };