@univerjs/sheets-data-validation 0.2.10 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -2,12 +2,12 @@ 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 { DEFAULT_EMPTY_DOCUMENT_VALUE, useDependency, Inject, Disposable, UniverInstanceType, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DisposableCollection, IUniverInstanceService, toDisposable, CommandType, ICommandService, ObjectMatrix, Range, isFormulaString, ThemeService, VerticalAlign, HorizontalAlign, createInternalEditorID, LocaleService, OnLifecycle, LifecycleStages, IPermissionService, DataValidationType, Tools, DataValidationOperator, DataValidationErrorStyle, UndoCommand, RedoCommand, isUnitRangesEqual, isValidRange, debounce, shallowEqual, Injector, DataValidationRenderMode, UNIVER_INTERNAL, numfmt, CellValueType, DEFAULT_STYLES, WrapStrategy, DocumentDataModel, BooleanNumber, Rectangle, IUndoRedoService, sequenceExecuteAsync, sequenceExecute, Optional, RxDisposable, DataValidationStatus, ILogService, isRangesEqual, queryObjectMatrix, IResourceManagerService, DependentOn, Plugin } from "@univerjs/core";
5
+ import { DEFAULT_EMPTY_DOCUMENT_VALUE, useDependency, Inject, Disposable, UniverInstanceType, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DisposableCollection, IUniverInstanceService, toDisposable, CommandType, ICommandService, ObjectMatrix, Range, isFormulaString, ThemeService, VerticalAlign, HorizontalAlign, createInternalEditorID, LocaleService, OnLifecycle, LifecycleStages, IPermissionService, DataValidationType, Tools, DataValidationOperator, DataValidationErrorStyle, UndoCommand, RedoCommand, isUnitRangesEqual, isValidRange, debounce, shallowEqual, Injector, DataValidationRenderMode, UNIVER_INTERNAL, numfmt, CellValueType, DEFAULT_STYLES, WrapStrategy, DocumentDataModel, BooleanNumber, Rectangle, IUndoRedoService, sequenceExecuteAsync, sequenceExecute, Optional, RxDisposable, DataValidationStatus, ILogService, isRangesEqual, queryObjectMatrix, IResourceManagerService, DependentOn, Plugin, IConfigService } from "@univerjs/core";
6
6
  import { DataValidatorRegistryService, DataValidationModel, BaseDataValidator, DataValidatorRegistryScope, TWO_FORMULA_OPERATOR_COUNT as TWO_FORMULA_OPERATOR_COUNT$1, getRuleOptions, getRuleSetting, RemoveDataValidationCommand, createDefaultNewRule, RemoveAllDataValidationCommand, TextLengthErrorTitleMap, AddDataValidationMutation, RemoveDataValidationMutation, UpdateRuleType, UpdateDataValidationMutation, removeDataValidationUndoFactory, DataValidationManager, AddDataValidationCommand, UniverDataValidationPlugin } from "@univerjs/data-validation";
7
7
  import { DataValidationModel as DataValidationModel2, RemoveAllDataValidationCommand as RemoveAllDataValidationCommand2, RemoveDataValidationCommand as RemoveDataValidationCommand2 } from "@univerjs/data-validation";
8
8
  import { SheetsSelectionsService, getSheetCommandTarget, SetRangeValuesCommand, WorksheetViewPermission, checkRangesEditablePermission, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, WorkbookEditablePermission, WorksheetSetCellStylePermission, WorksheetEditPermission, RangeProtectionPermissionEditPoint, SheetInterceptorService, INTERCEPTOR_POINT, InterceptCellContentPriority, ClearSelectionAllCommand, RefRangeService, handleCommonDefaultRangeChangeWithEffectRefCommands, UniverSheetsPlugin } from "@univerjs/sheets";
9
9
  import { SheetCanvasPopManagerService, IMarkSelectionService, IEditorBridgeService, getCurrentRangeDisable$, AutoHeightController, SheetSkeletonManagerService, HoverManagerService, CellAlertManagerService, CellAlertType, IAutoFillService, APPLY_TYPE, virtualizeDiscreteRanges, getAutoFillRepeatRange, COPY_TYPE, rangeToDiscreteRange, PREDEFINED_HOOK_NAME, getRepeatRange, ISheetClipboardService, SheetPermissionInterceptorBaseController, UniverSheetsUIPlugin } from "@univerjs/sheets-ui";
10
- import { useObservable, ComponentManager, IZenZoneService, ISidebarService, TextEditor, useEvent, RangeSelector, KeyCode, IDialogService, MenuItemType, MenuPosition, MenuGroup, getMenuHiddenObservable, IMenuService } from "@univerjs/ui";
10
+ import { useObservable, ComponentManager, IZenZoneService, ISidebarService, TextEditor, useEvent, RangeSelector, KeyCode, IDialogService, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, IMenuManagerService } from "@univerjs/ui";
11
11
  import { IRenderManagerService, fixLineWidthByScale, Transform, Checkbox, DeviceInputEventType, getDocsSkeletonPageSize, Rect, DocumentViewModel, DocumentSkeleton, Documents, FontCache, Shape, getFontStyleString } from "@univerjs/engine-render";
12
12
  import { Subject, filter, BehaviorSubject, distinctUntilChanged, debounceTime, bufferTime } from "rxjs";
13
13
  import React, { forwardRef, useRef, createElement, useState, useMemo, useEffect } from "react";
@@ -129,7 +129,7 @@ let DataValidationDropdownManagerService = (_a = class extends Disposable {
129
129
  }));
130
130
  }
131
131
  showDropdown(param, closeOnOutSide = !0) {
132
- const { location } = param, { row, col } = location;
132
+ const { location } = param, { row, col, unitId, subUnitId } = location;
133
133
  if (this._currentPopup && this._currentPopup.dispose(), this._zenVisible)
134
134
  return;
135
135
  this._activeDropdown = param, this._activeDropdown$.next(this._activeDropdown);
@@ -143,7 +143,9 @@ let DataValidationDropdownManagerService = (_a = class extends Disposable {
143
143
  }, "onClickOutside"),
144
144
  offset: [0, 3],
145
145
  excludeOutside: [currentRender == null ? void 0 : currentRender.engine.getCanvasElement()].filter(Boolean)
146
- }
146
+ },
147
+ unitId,
148
+ subUnitId
147
149
  );
148
150
  if (!popupDisposable)
149
151
  throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");
@@ -620,7 +622,7 @@ function CustomFormulaInput(props) {
620
622
  onChange: /* @__PURE__ */ __name((newValue) => {
621
623
  onChange == null || onChange({
622
624
  ...value,
623
- formula1: newValue != null ? newValue : ""
625
+ formula1: (newValue != null ? newValue : "").trim()
624
626
  });
625
627
  }, "onChange"),
626
628
  onlyInputFormula: !0,
@@ -1050,7 +1052,7 @@ function ListFormulaInput(props) {
1050
1052
  openForSheetSubUnitId: subUnitId,
1051
1053
  onlyInputFormula: !0,
1052
1054
  onChange: /* @__PURE__ */ __name(async (newString) => {
1053
- const str = newString != null ? newString : "";
1055
+ const str = (newString != null ? newString : "").trim();
1054
1056
  setFormulaStrCopy(str), updateFormula(str);
1055
1057
  }, "onChange")
1056
1058
  }
@@ -2004,13 +2006,13 @@ function DateShowTimeOption(props) {
2004
2006
  __name(DateShowTimeOption, "DateShowTimeOption");
2005
2007
  DateShowTimeOption.componentKey = DATE_SHOW_TIME_OPTION;
2006
2008
  const FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2SerialNumber = /* @__PURE__ */ __name((value) => {
2007
- var _a22;
2009
+ var _a22, _b;
2008
2010
  if (value == null || typeof value == "boolean")
2009
2011
  return;
2010
2012
  if (typeof value == "number" || !Number.isNaN(+value))
2011
2013
  return +value;
2012
- const dateStr = `${dayjs(value).format("YYYY-MM-DD HH:mm:ss")}`;
2013
- return (_a22 = numfmt.parseDate(dateStr)) == null ? void 0 : _a22.v;
2014
+ const v = (_a22 = numfmt.parseDate(value)) == null ? void 0 : _a22.v;
2015
+ return Tools.isDefine(v) ? v : (_b = numfmt.parseDate(dayjs(value).format("YYYY-MM-DD HH:mm:ss"))) == null ? void 0 : _b.v;
2014
2016
  }, "transformDate2SerialNumber"), _DateValidator = class _DateValidator extends BaseDataValidator {
2015
2017
  constructor() {
2016
2018
  super(...arguments);
@@ -2053,7 +2055,7 @@ const FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2Serial
2053
2055
  return typeof value == "number" && typeof interceptValue == "string" ? !0 : typeof interceptValue == "string" ? !!numfmt.parseDate(interceptValue) : !1;
2054
2056
  }
2055
2057
  _validatorSingleFormula(formula) {
2056
- return !Tools.isBlank(formula) && (isFormulaString(formula) || !Number.isNaN(+formula) || !!formula && dayjs(formula).isValid());
2058
+ return !Tools.isBlank(formula) && (isFormulaString(formula) || !Number.isNaN(+formula) || !!(formula && numfmt.parseDate(formula)));
2057
2059
  }
2058
2060
  validatorFormula(rule, unitId, subUnitId) {
2059
2061
  const operator = rule.operator;
@@ -2075,6 +2077,22 @@ const FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2Serial
2075
2077
  formula1: formula1Success ? void 0 : errorMsg
2076
2078
  };
2077
2079
  }
2080
+ normlizeFormula(rule, unitId, subUnitId) {
2081
+ const { formula1, formula2, bizInfo } = rule, normlizeSingleFormula = /* @__PURE__ */ __name((formula) => {
2082
+ var _a22;
2083
+ if (!formula)
2084
+ return formula;
2085
+ const res = (_a22 = numfmt.parseDate(formula)) == null ? void 0 : _a22.v;
2086
+ if (res == null)
2087
+ return "";
2088
+ const date = numfmt.dateFromSerial(res);
2089
+ return dayjs(`${date[0]}/${date[1]}/${date[2]} ${date[3]}:${date[4]}:${date[5]}`).format(bizInfo != null && bizInfo.showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD");
2090
+ }, "normlizeSingleFormula");
2091
+ return {
2092
+ formula1: isFormulaString(formula1) ? formula1 : normlizeSingleFormula(`${formula1}`),
2093
+ formula2: isFormulaString(formula2) ? formula2 : normlizeSingleFormula(`${formula2}`)
2094
+ };
2095
+ }
2078
2096
  transform(cellInfo, _formula, _rule) {
2079
2097
  const { value } = cellInfo;
2080
2098
  return {
@@ -2725,7 +2743,7 @@ function isBlankCell(cellData) {
2725
2743
  return cellData ? cellData.p ? !((_b = (_a22 = cellData.p.body) == null ? void 0 : _a22.dataStream) != null ? _b : "").slice(0, -2).trim() : Tools.isBlank(cellData.v) : !0;
2726
2744
  }
2727
2745
  __name(isBlankCell, "isBlankCell");
2728
- function getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor, source = "command") {
2746
+ function getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor, source = "command", fillDefaultValue = !0) {
2729
2747
  const redoMutations = [], undoMutations = [], manager = accessor.get(DataValidationModel).ensureManager(unitId, subUnitId), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, { unitId, subUnitId });
2730
2748
  if (!target)
2731
2749
  return {
@@ -2734,7 +2752,7 @@ function getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor, sour
2734
2752
  };
2735
2753
  const { worksheet } = target, redoMatrix = new ObjectMatrix();
2736
2754
  function setRangesDefaultValue(ranges, defaultValue) {
2737
- ranges.forEach((range) => {
2755
+ fillDefaultValue && ranges.forEach((range) => {
2738
2756
  Range.foreach(range, (row, column) => {
2739
2757
  const cellData = worksheet.getCellRaw(row, column), value = getStringCellValue(cellData);
2740
2758
  (isBlankCell(cellData) || value === defaultValue) && redoMatrix.setValue(row, column, {
@@ -2915,7 +2933,10 @@ const UpdateSheetDataValidationRangeCommand = {
2915
2933
  if (!validator)
2916
2934
  return !1;
2917
2935
  const rule = dataValidationModel.getRuleById(unitId, subUnitId, ruleId);
2918
- if (!rule || !validator.validatorFormula({ ...rule, ...setting }, unitId, subUnitId).success)
2936
+ if (!rule)
2937
+ return !1;
2938
+ const newRule = { ...rule, ...setting };
2939
+ if (!validator.validatorFormula(newRule, unitId, subUnitId).success)
2919
2940
  return !1;
2920
2941
  const mutationParams = {
2921
2942
  unitId,
@@ -2923,7 +2944,10 @@ const UpdateSheetDataValidationRangeCommand = {
2923
2944
  ruleId,
2924
2945
  payload: {
2925
2946
  type: UpdateRuleType.SETTING,
2926
- payload: setting
2947
+ payload: {
2948
+ ...setting,
2949
+ ...validator.normlizeFormula(newRule, unitId, subUnitId)
2950
+ }
2927
2951
  }
2928
2952
  }, redoMutations = [{
2929
2953
  id: UpdateDataValidationMutation.id,
@@ -3036,8 +3060,6 @@ function dataValidationMenuFactory(accessor) {
3036
3060
  return {
3037
3061
  id: DATA_VALIDATION_MENU_ID,
3038
3062
  type: MenuItemType.SUBITEMS,
3039
- positions: [MenuPosition.TOOLBAR_START],
3040
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
3041
3063
  icon: DataValidationIcon,
3042
3064
  tooltip: "dataValidation.title",
3043
3065
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
@@ -3049,8 +3071,7 @@ function openDataValidationMenuFactory(_accessor) {
3049
3071
  return {
3050
3072
  id: OpenValidationPanelOperation.id,
3051
3073
  title: "dataValidation.panel.title",
3052
- type: MenuItemType.BUTTON,
3053
- positions: [DATA_VALIDATION_MENU_ID]
3074
+ type: MenuItemType.BUTTON
3054
3075
  };
3055
3076
  }
3056
3077
  __name(openDataValidationMenuFactory, "openDataValidationMenuFactory");
@@ -3058,17 +3079,32 @@ function addDataValidationMenuFactory(_accessor) {
3058
3079
  return {
3059
3080
  id: AddSheetDataValidationAndOpenCommand.id,
3060
3081
  title: "dataValidation.panel.add",
3061
- type: MenuItemType.BUTTON,
3062
- positions: [DATA_VALIDATION_MENU_ID]
3082
+ type: MenuItemType.BUTTON
3063
3083
  };
3064
3084
  }
3065
3085
  __name(addDataValidationMenuFactory, "addDataValidationMenuFactory");
3086
+ const menuSchema = {
3087
+ [RibbonStartGroup.FORMULAS_INSERT]: {
3088
+ [DATA_VALIDATION_MENU_ID]: {
3089
+ order: 9,
3090
+ menuItemFactory: dataValidationMenuFactory,
3091
+ [OpenValidationPanelOperation.id]: {
3092
+ order: 0,
3093
+ menuItemFactory: openDataValidationMenuFactory
3094
+ },
3095
+ [AddSheetDataValidationAndOpenCommand.id]: {
3096
+ order: 1,
3097
+ menuItemFactory: addDataValidationMenuFactory
3098
+ }
3099
+ }
3100
+ }
3101
+ };
3066
3102
  var __defProp$c = Object.defineProperty, __getOwnPropDesc$c = Object.getOwnPropertyDescriptor, __decorateClass$c = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3067
3103
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3068
3104
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
3069
3105
  return kind && result && __defProp$c(target, key, result), result;
3070
3106
  }, "__decorateClass$c"), __decorateParam$c = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$c");
3071
- const DefaultSheetsDataValidation = {}, INVALID_MARK = {
3107
+ const INVALID_MARK = {
3072
3108
  tr: {
3073
3109
  size: 6,
3074
3110
  color: "#fe4b4b"
@@ -3076,20 +3112,11 @@ const DefaultSheetsDataValidation = {}, INVALID_MARK = {
3076
3112
  };
3077
3113
  var _a8;
3078
3114
  let SheetsDataValidationRenderController = (_a8 = class extends RxDisposable {
3079
- constructor(_config, _commandService, _menuService, _renderManagerService, _univerInstanceService, _autoHeightController, _componentManager, _dropdownManagerService, _dataValidationModel, _dataValidatorRegistryService, _injector, _sheetInterceptorService, _editorBridgeService) {
3080
- super(), this._config = _config, this._commandService = _commandService, this._menuService = _menuService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._autoHeightController = _autoHeightController, this._componentManager = _componentManager, this._dropdownManagerService = _dropdownManagerService, this._dataValidationModel = _dataValidationModel, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._injector = _injector, this._sheetInterceptorService = _sheetInterceptorService, this._editorBridgeService = _editorBridgeService, this._initMenu(), this._initSkeletonChange(), this._initDropdown(), this._initViewModelIntercept(), this._initAutoHeight();
3115
+ constructor(_commandService, _menuManagerService, _renderManagerService, _univerInstanceService, _autoHeightController, _dropdownManagerService, _dataValidationModel, _dataValidatorRegistryService, _sheetInterceptorService, _editorBridgeService) {
3116
+ super(), this._commandService = _commandService, this._menuManagerService = _menuManagerService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._autoHeightController = _autoHeightController, this._dropdownManagerService = _dropdownManagerService, this._dataValidationModel = _dataValidationModel, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._sheetInterceptorService = _sheetInterceptorService, this._editorBridgeService = _editorBridgeService, this._initMenu(), this._initSkeletonChange(), this._initDropdown(), this._initViewModelIntercept(), this._initAutoHeight();
3081
3117
  }
3082
3118
  _initMenu() {
3083
- const { menu = {} } = this._config;
3084
- [
3085
- dataValidationMenuFactory,
3086
- openDataValidationMenuFactory,
3087
- addDataValidationMenuFactory
3088
- ].forEach((factory) => {
3089
- this.disposeWithMe(
3090
- this._menuService.addMenuItem(factory(this._injector), menu)
3091
- );
3092
- });
3119
+ this._menuManagerService.mergeMenu(menuSchema);
3093
3120
  }
3094
3121
  _initDropdown() {
3095
3122
  this._editorBridgeService && this.disposeWithMe(this._editorBridgeService.visible$.subscribe((visible) => {
@@ -3274,23 +3301,21 @@ let SheetsDataValidationRenderController = (_a8 = class extends RxDisposable {
3274
3301
  }, __name(_a8, "SheetsDataValidationRenderController"), _a8);
3275
3302
  SheetsDataValidationRenderController = __decorateClass$c([
3276
3303
  OnLifecycle(LifecycleStages.Rendered, SheetsDataValidationRenderController),
3277
- __decorateParam$c(1, ICommandService),
3278
- __decorateParam$c(2, IMenuService),
3279
- __decorateParam$c(3, IRenderManagerService),
3280
- __decorateParam$c(4, IUniverInstanceService),
3281
- __decorateParam$c(5, Inject(AutoHeightController)),
3282
- __decorateParam$c(6, Inject(ComponentManager)),
3283
- __decorateParam$c(7, Inject(DataValidationDropdownManagerService)),
3284
- __decorateParam$c(8, Inject(DataValidationModel)),
3285
- __decorateParam$c(9, Inject(DataValidatorRegistryService)),
3286
- __decorateParam$c(10, Inject(Injector)),
3287
- __decorateParam$c(11, Inject(SheetInterceptorService)),
3288
- __decorateParam$c(12, Optional(IEditorBridgeService))
3304
+ __decorateParam$c(0, ICommandService),
3305
+ __decorateParam$c(1, IMenuManagerService),
3306
+ __decorateParam$c(2, IRenderManagerService),
3307
+ __decorateParam$c(3, IUniverInstanceService),
3308
+ __decorateParam$c(4, Inject(AutoHeightController)),
3309
+ __decorateParam$c(5, Inject(DataValidationDropdownManagerService)),
3310
+ __decorateParam$c(6, Inject(DataValidationModel)),
3311
+ __decorateParam$c(7, Inject(DataValidatorRegistryService)),
3312
+ __decorateParam$c(8, Inject(SheetInterceptorService)),
3313
+ __decorateParam$c(9, Optional(IEditorBridgeService))
3289
3314
  ], SheetsDataValidationRenderController);
3290
3315
  var _a9;
3291
3316
  let SheetsDataValidationMobileRenderController = (_a9 = class extends RxDisposable {
3292
- constructor(_config, _commandService, _renderManagerService, _univerInstanceService, _autoHeightController, _dataValidationModel, _dataValidatorRegistryService, _sheetInterceptorService) {
3293
- super(), this._config = _config, this._commandService = _commandService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._autoHeightController = _autoHeightController, this._dataValidationModel = _dataValidationModel, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._sheetInterceptorService = _sheetInterceptorService, this._initSkeletonChange(), this._initViewModelIntercept(), this._initAutoHeight();
3317
+ constructor(_commandService, _renderManagerService, _univerInstanceService, _autoHeightController, _dataValidationModel, _dataValidatorRegistryService, _sheetInterceptorService) {
3318
+ super(), this._commandService = _commandService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._autoHeightController = _autoHeightController, this._dataValidationModel = _dataValidationModel, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._sheetInterceptorService = _sheetInterceptorService, this._initSkeletonChange(), this._initViewModelIntercept(), this._initAutoHeight();
3294
3319
  }
3295
3320
  _initSkeletonChange() {
3296
3321
  const markSkeletonDirty = /* @__PURE__ */ __name(() => {
@@ -3427,13 +3452,13 @@ let SheetsDataValidationMobileRenderController = (_a9 = class extends RxDisposab
3427
3452
  }, __name(_a9, "SheetsDataValidationMobileRenderController"), _a9);
3428
3453
  SheetsDataValidationMobileRenderController = __decorateClass$c([
3429
3454
  OnLifecycle(LifecycleStages.Rendered, SheetsDataValidationMobileRenderController),
3430
- __decorateParam$c(1, ICommandService),
3431
- __decorateParam$c(2, IRenderManagerService),
3432
- __decorateParam$c(3, IUniverInstanceService),
3433
- __decorateParam$c(4, Inject(AutoHeightController)),
3434
- __decorateParam$c(5, Inject(DataValidationModel)),
3435
- __decorateParam$c(6, Inject(DataValidatorRegistryService)),
3436
- __decorateParam$c(7, Inject(SheetInterceptorService))
3455
+ __decorateParam$c(0, ICommandService),
3456
+ __decorateParam$c(1, IRenderManagerService),
3457
+ __decorateParam$c(2, IUniverInstanceService),
3458
+ __decorateParam$c(3, Inject(AutoHeightController)),
3459
+ __decorateParam$c(4, Inject(DataValidationModel)),
3460
+ __decorateParam$c(5, Inject(DataValidatorRegistryService)),
3461
+ __decorateParam$c(6, Inject(SheetInterceptorService))
3437
3462
  ], SheetsDataValidationMobileRenderController);
3438
3463
  var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPropertyDescriptor, __decorateClass$b = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3439
3464
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
@@ -4239,7 +4264,7 @@ let DataValidationAutoFillController = (_a15 = class extends Disposable {
4239
4264
  }
4240
4265
  // eslint-disable-next-line max-lines-per-function
4241
4266
  _initAutoFill() {
4242
- const noopReturnFunc = /* @__PURE__ */ __name(() => ({ redos: [], undos: [] }), "noopReturnFunc"), generalApplyFunc = /* @__PURE__ */ __name((location) => {
4267
+ const noopReturnFunc = /* @__PURE__ */ __name(() => ({ redos: [], undos: [] }), "noopReturnFunc"), generalApplyFunc = /* @__PURE__ */ __name((location, applyType) => {
4243
4268
  const { source: sourceRange, target: targetRange, unitId, subUnitId } = location, manager = this._dataValidationModel.ensureManager(unitId, subUnitId), ruleMatrixCopy = manager.getRuleObjectMatrix().clone(), virtualRange = virtualizeDiscreteRanges([sourceRange, targetRange]), [vSourceRange, vTargetRange] = virtualRange.ranges, { mapFunc } = virtualRange, sourceStartCell = {
4244
4269
  row: vSourceRange.startRow,
4245
4270
  col: vSourceRange.startColumn
@@ -4280,7 +4305,7 @@ let DataValidationAutoFillController = (_a15 = class extends Disposable {
4280
4305
  }
4281
4306
  });
4282
4307
  });
4283
- const diffs = ruleMatrixCopy.diff(manager.getDataValidations()), { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, this._injector, "patched");
4308
+ const diffs = ruleMatrixCopy.diff(manager.getDataValidations()), { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, this._injector, "patched", applyType === APPLY_TYPE.ONLY_FORMAT);
4284
4309
  return {
4285
4310
  undos: undoMutations,
4286
4311
  redos: redoMutations
@@ -4300,7 +4325,7 @@ let DataValidationAutoFillController = (_a15 = class extends Disposable {
4300
4325
  }
4301
4326
  }
4302
4327
  }, "onBeforeFillData"),
4303
- onFillData: /* @__PURE__ */ __name((location, direction, applyType) => applyType === APPLY_TYPE.COPY || applyType === APPLY_TYPE.ONLY_FORMAT || applyType === APPLY_TYPE.SERIES ? generalApplyFunc(location) : noopReturnFunc(), "onFillData"),
4328
+ onFillData: /* @__PURE__ */ __name((location, direction, applyType) => applyType === APPLY_TYPE.COPY || applyType === APPLY_TYPE.ONLY_FORMAT || applyType === APPLY_TYPE.SERIES ? generalApplyFunc(location, applyType) : noopReturnFunc(), "onFillData"),
4304
4329
  onAfterFillData: /* @__PURE__ */ __name(() => {
4305
4330
  }, "onAfterFillData")
4306
4331
  };
@@ -4754,14 +4779,17 @@ SheetsDataValidationValidatorService = __decorateClass$2([
4754
4779
  __decorateParam$2(1, Inject(DataValidationModel)),
4755
4780
  __decorateParam$2(2, Inject(DataValidationCacheService))
4756
4781
  ], SheetsDataValidationValidatorService);
4782
+ const PLUGIN_CONFIG_KEY = "sheets-data-validation.config", defaultPluginConfig = {};
4757
4783
  var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __defNormalProp$1 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp$1"), __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
4758
4784
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4759
4785
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4760
4786
  return kind && result && __defProp$1(target, key, result), result;
4761
4787
  }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), __publicField$1 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp$1(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField$1"), _a20;
4762
4788
  let UniverSheetsDataValidationPlugin = (_a20 = class extends Plugin {
4763
- constructor(_config = {}, _injector, _commandService, _localeService) {
4764
- super(), this._config = _config, this._injector = _injector, this._commandService = _commandService, this._localeService = _localeService, this._config = Tools.deepMerge({}, DefaultSheetsDataValidation, this._config);
4789
+ constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
4790
+ super(), this._config = _config, this._injector = _injector, this._commandService = _commandService, this._configService = _configService;
4791
+ const { menu, ...rest } = this._config;
4792
+ menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
4765
4793
  }
4766
4794
  onStarting() {
4767
4795
  [
@@ -4774,12 +4802,7 @@ let UniverSheetsDataValidationPlugin = (_a20 = class extends Plugin {
4774
4802
  // controller
4775
4803
  [DataValidationModelController],
4776
4804
  [DataValidationController],
4777
- [
4778
- SheetsDataValidationRenderController,
4779
- {
4780
- useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(SheetsDataValidationRenderController, this._config), "useFactory")
4781
- }
4782
- ],
4805
+ [SheetsDataValidationRenderController],
4783
4806
  [DataValidationAlertController],
4784
4807
  [DataValidationRefRangeController],
4785
4808
  [DataValidationPermissionController],
@@ -4812,7 +4835,7 @@ UniverSheetsDataValidationPlugin = __decorateClass$1([
4812
4835
  DependentOn(UniverDataValidationPlugin, UniverSheetsPlugin, UniverSheetsUIPlugin),
4813
4836
  __decorateParam$1(1, Inject(Injector)),
4814
4837
  __decorateParam$1(2, ICommandService),
4815
- __decorateParam$1(3, Inject(LocaleService))
4838
+ __decorateParam$1(3, IConfigService)
4816
4839
  ], UniverSheetsDataValidationPlugin);
4817
4840
  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) => {
4818
4841
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
@@ -4820,8 +4843,10 @@ var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnProperty
4820
4843
  return kind && result && __defProp2(target, key, result), result;
4821
4844
  }, "__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"), _a21;
4822
4845
  let UniverSheetsDataValidationMobilePlugin = (_a21 = class extends Plugin {
4823
- constructor(_config = {}, _injector, _commandService, _localeService) {
4824
- super(), this._config = _config, this._injector = _injector, this._commandService = _commandService, this._localeService = _localeService, this._config = Tools.deepMerge({}, DefaultSheetsDataValidation, this._config);
4846
+ constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
4847
+ super(), this._config = _config, this._injector = _injector, this._commandService = _commandService, this._configService = _configService;
4848
+ const { menu, ...rest } = this._config;
4849
+ menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
4825
4850
  }
4826
4851
  onStarting() {
4827
4852
  [
@@ -4834,12 +4859,7 @@ let UniverSheetsDataValidationMobilePlugin = (_a21 = class extends Plugin {
4834
4859
  // controller
4835
4860
  [DataValidationModelController],
4836
4861
  [DataValidationController],
4837
- [
4838
- SheetsDataValidationMobileRenderController,
4839
- {
4840
- useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(SheetsDataValidationMobileRenderController, this._config), "useFactory")
4841
- }
4842
- ],
4862
+ [SheetsDataValidationMobileRenderController],
4843
4863
  [DataValidationAlertController],
4844
4864
  [DataValidationRefRangeController],
4845
4865
  [DataValidationPermissionController],
@@ -4868,7 +4888,7 @@ UniverSheetsDataValidationMobilePlugin = __decorateClass([
4868
4888
  DependentOn(UniverDataValidationPlugin, UniverSheetsPlugin, UniverSheetsUIPlugin),
4869
4889
  __decorateParam(1, Inject(Injector)),
4870
4890
  __decorateParam(2, ICommandService),
4871
- __decorateParam(3, Inject(LocaleService))
4891
+ __decorateParam(3, IConfigService)
4872
4892
  ], UniverSheetsDataValidationMobilePlugin);
4873
4893
  export {
4874
4894
  AddSheetDataValidationAndOpenCommand,
@@ -4876,11 +4896,13 @@ export {
4876
4896
  ClearRangeDataValidationCommand,
4877
4897
  CloseValidationPanelOperation,
4878
4898
  DATA_VALIDATION_PLUGIN_NAME,
4899
+ DATE_DROPDOWN_KEY,
4879
4900
  DataValidationCacheService,
4880
4901
  DataValidationCustomFormulaService,
4881
4902
  DataValidationFormulaService,
4882
4903
  DataValidationModel2 as DataValidationModel,
4883
4904
  HideDataValidationDropdown,
4905
+ LIST_DROPDOWN_KEY,
4884
4906
  OpenValidationPanelOperation,
4885
4907
  RemoveAllDataValidationCommand2 as RemoveSheetAllDataValidationCommand,
4886
4908
  RemoveDataValidationCommand2 as RemoveSheetDataValidationCommand,
@@ -8,7 +8,7 @@ export interface IUpdateSheetDataValidationRangeCommandParams {
8
8
  ruleId: string;
9
9
  ranges: IRange[];
10
10
  }
11
- export declare function getDataValidationDiffMutations(unitId: string, subUnitId: string, diffs: RangeMutation[], accessor: IAccessor, source?: DataValidationChangeSource): {
11
+ export declare function getDataValidationDiffMutations(unitId: string, subUnitId: string, diffs: RangeMutation[], accessor: IAccessor, source?: DataValidationChangeSource, fillDefaultValue?: boolean): {
12
12
  redoMutations: IMutationInfo<object>[];
13
13
  undoMutations: IMutationInfo<object>[];
14
14
  };
@@ -0,0 +1,7 @@
1
+ import { MenuConfig } from '@univerjs/ui';
2
+ export declare const PLUGIN_CONFIG_KEY = "sheets-data-validation.config";
3
+ export declare const configSymbol: unique symbol;
4
+ export interface IUniverSheetsDataValidationConfig {
5
+ menu?: MenuConfig;
6
+ }
7
+ export declare const defaultPluginConfig: IUniverSheetsDataValidationConfig;
@@ -1,29 +1,22 @@
1
- import { ICommandService, Injector, IUniverInstanceService, RxDisposable } from '@univerjs/core';
1
+ import { ICommandService, IUniverInstanceService, RxDisposable } from '@univerjs/core';
2
2
  import { DataValidationModel, DataValidatorRegistryService } from '@univerjs/data-validation';
3
- import { MenuConfig, ComponentManager, IMenuService } from '@univerjs/ui';
3
+ import { IMenuManagerService } from '@univerjs/ui';
4
4
  import { AutoHeightController, IEditorBridgeService } from '@univerjs/sheets-ui';
5
5
  import { IRenderManagerService } from '@univerjs/engine-render';
6
6
  import { SheetInterceptorService } from '@univerjs/sheets';
7
7
  import { DataValidationDropdownManagerService } from '../services/dropdown-manager.service';
8
- export interface IUniverSheetsDataValidation {
9
- menu?: MenuConfig;
10
- }
11
- export declare const DefaultSheetsDataValidation: {};
12
8
  export declare class SheetsDataValidationRenderController extends RxDisposable {
13
- private readonly _config;
14
9
  private readonly _commandService;
15
- private _menuService;
10
+ private readonly _menuManagerService;
16
11
  private readonly _renderManagerService;
17
12
  private readonly _univerInstanceService;
18
13
  private readonly _autoHeightController;
19
- private _componentManager;
20
14
  private readonly _dropdownManagerService;
21
15
  private readonly _dataValidationModel;
22
16
  private readonly _dataValidatorRegistryService;
23
- private readonly _injector;
24
17
  private readonly _sheetInterceptorService;
25
18
  private readonly _editorBridgeService?;
26
- constructor(_config: Partial<IUniverSheetsDataValidation>, _commandService: ICommandService, _menuService: IMenuService, _renderManagerService: IRenderManagerService, _univerInstanceService: IUniverInstanceService, _autoHeightController: AutoHeightController, _componentManager: ComponentManager, _dropdownManagerService: DataValidationDropdownManagerService, _dataValidationModel: DataValidationModel, _dataValidatorRegistryService: DataValidatorRegistryService, _injector: Injector, _sheetInterceptorService: SheetInterceptorService, _editorBridgeService?: IEditorBridgeService | undefined);
19
+ constructor(_commandService: ICommandService, _menuManagerService: IMenuManagerService, _renderManagerService: IRenderManagerService, _univerInstanceService: IUniverInstanceService, _autoHeightController: AutoHeightController, _dropdownManagerService: DataValidationDropdownManagerService, _dataValidationModel: DataValidationModel, _dataValidatorRegistryService: DataValidatorRegistryService, _sheetInterceptorService: SheetInterceptorService, _editorBridgeService?: IEditorBridgeService | undefined);
27
20
  private _initMenu;
28
21
  private _initDropdown;
29
22
  private _initSkeletonChange;
@@ -31,7 +24,6 @@ export declare class SheetsDataValidationRenderController extends RxDisposable {
31
24
  private _initAutoHeight;
32
25
  }
33
26
  export declare class SheetsDataValidationMobileRenderController extends RxDisposable {
34
- private readonly _config;
35
27
  private readonly _commandService;
36
28
  private readonly _renderManagerService;
37
29
  private readonly _univerInstanceService;
@@ -39,7 +31,7 @@ export declare class SheetsDataValidationMobileRenderController extends RxDispos
39
31
  private readonly _dataValidationModel;
40
32
  private readonly _dataValidatorRegistryService;
41
33
  private readonly _sheetInterceptorService;
42
- constructor(_config: Partial<IUniverSheetsDataValidation>, _commandService: ICommandService, _renderManagerService: IRenderManagerService, _univerInstanceService: IUniverInstanceService, _autoHeightController: AutoHeightController, _dataValidationModel: DataValidationModel, _dataValidatorRegistryService: DataValidatorRegistryService, _sheetInterceptorService: SheetInterceptorService);
34
+ constructor(_commandService: ICommandService, _renderManagerService: IRenderManagerService, _univerInstanceService: IUniverInstanceService, _autoHeightController: AutoHeightController, _dataValidationModel: DataValidationModel, _dataValidatorRegistryService: DataValidatorRegistryService, _sheetInterceptorService: SheetInterceptorService);
43
35
  private _initSkeletonChange;
44
36
  private _initViewModelIntercept;
45
37
  private _initAutoHeight;
@@ -1,6 +1,7 @@
1
1
  import { IMenuItem } from '@univerjs/ui';
2
2
  import { IAccessor } from '@univerjs/core';
3
3
  export declare const DataValidationIcon = "data-validation-single";
4
+ export declare const DATA_VALIDATION_MENU_ID = "sheet.menu.data-validation";
4
5
  export declare function dataValidationMenuFactory(accessor: IAccessor): IMenuItem;
5
6
  export declare function openDataValidationMenuFactory(_accessor: IAccessor): IMenuItem;
6
7
  export declare function addDataValidationMenuFactory(_accessor: IAccessor): IMenuItem;
@@ -0,0 +1,2 @@
1
+ import { MenuSchemaType } from '@univerjs/ui';
2
+ export declare const menuSchema: MenuSchemaType;
@@ -26,3 +26,4 @@ export { SheetDataValidationManager } from './models/sheet-data-validation-manag
26
26
  export { RemoveDataValidationCommand as RemoveSheetDataValidationCommand, type IRemoveDataValidationCommandParams as IRemoveSheetDataValidationCommandParams, } from '@univerjs/data-validation';
27
27
  export { UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationOptionsCommand, UpdateSheetDataValidationSettingCommand, AddSheetDataValidationCommand, AddSheetDataValidationAndOpenCommand, ClearRangeDataValidationCommand, type IAddSheetDataValidationCommandParams, type IUpdateSheetDataValidationRangeCommandParams, type IUpdateSheetDataValidationOptionsCommandParams, type IUpdateSheetDataValidationSettingCommandParams, type IClearRangeDataValidationCommandParams, } from './commands/commands/data-validation.command';
28
28
  export { OpenValidationPanelOperation, CloseValidationPanelOperation, ToggleValidationPanelOperation, ShowDataValidationDropdown, HideDataValidationDropdown, } from './commands/operations/data-validation.operation';
29
+ export { LIST_DROPDOWN_KEY, DATE_DROPDOWN_KEY } from './views';
@@ -1,12 +1,12 @@
1
- import { ICommandService, LocaleService, Plugin, UniverInstanceType, Injector } from '@univerjs/core';
2
- import { IUniverSheetsDataValidation } from './controllers/dv-render.controller';
1
+ import { ICommandService, IConfigService, Plugin, UniverInstanceType, Injector } from '@univerjs/core';
2
+ import { IUniverSheetsDataValidationConfig } from './controllers/config.schema';
3
3
  export declare class UniverSheetsDataValidationMobilePlugin extends Plugin {
4
- private _config;
4
+ private readonly _config;
5
5
  protected _injector: Injector;
6
6
  private readonly _commandService;
7
- private readonly _localeService;
7
+ private readonly _configService;
8
8
  static pluginName: string;
9
9
  static type: UniverInstanceType;
10
- constructor(_config: Partial<IUniverSheetsDataValidation>, _injector: Injector, _commandService: ICommandService, _localeService: LocaleService);
10
+ constructor(_config: Partial<IUniverSheetsDataValidationConfig>, _injector: Injector, _commandService: ICommandService, _configService: IConfigService);
11
11
  onStarting(): void;
12
12
  }
@@ -1,12 +1,12 @@
1
- import { ICommandService, LocaleService, Plugin, UniverInstanceType, Injector } from '@univerjs/core';
2
- import { IUniverSheetsDataValidation } from './controllers/dv-render.controller';
1
+ import { ICommandService, IConfigService, Plugin, UniverInstanceType, Injector } from '@univerjs/core';
2
+ import { IUniverSheetsDataValidationConfig } from './controllers/config.schema';
3
3
  export declare class UniverSheetsDataValidationPlugin extends Plugin {
4
- private _config;
4
+ private readonly _config;
5
5
  protected _injector: Injector;
6
6
  private readonly _commandService;
7
- private readonly _localeService;
7
+ private readonly _configService;
8
8
  static pluginName: string;
9
9
  static type: UniverInstanceType;
10
- constructor(_config: Partial<IUniverSheetsDataValidation>, _injector: Injector, _commandService: ICommandService, _localeService: LocaleService);
10
+ constructor(_config: Partial<IUniverSheetsDataValidationConfig>, _injector: Injector, _commandService: ICommandService, _configService: IConfigService);
11
11
  onStarting(): void;
12
12
  }
@@ -17,6 +17,10 @@ export declare class DateValidator extends BaseDataValidator<number> {
17
17
  isValidType(info: IValidatorCellInfo): Promise<boolean>;
18
18
  private _validatorSingleFormula;
19
19
  validatorFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): IFormulaValidResult;
20
+ normlizeFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): {
21
+ formula1: string | undefined;
22
+ formula2: string | undefined;
23
+ };
20
24
  transform(cellInfo: IValidatorCellInfo<CellValue>, _formula: IFormulaResult, _rule: IDataValidationRule): IValidatorCellInfo<number>;
21
25
  validatorIsEqual(cellInfo: IValidatorCellInfo<CellValue>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
22
26
  validatorIsNotEqual(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, _rule: IDataValidationRule): Promise<boolean>;