@univerjs/sheets-data-validation 0.2.8 → 0.2.10

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,10 +2,10 @@ 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, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DisposableCollection, IUniverInstanceService, UniverInstanceType, 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, DEFAULT_STYLES, WrapStrategy, DocumentDataModel, BooleanNumber, numfmt, Rectangle, IUndoRedoService, sequenceExecuteAsync, sequenceExecute, Optional, RxDisposable, DataValidationStatus, 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 } 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
- import { DataValidationModel as DataValidationModel2, RemoveDataValidationCommand as RemoveDataValidationCommand2 } from "@univerjs/data-validation";
8
- import { getSheetCommandTarget, SetRangeValuesCommand, WorksheetViewPermission, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, WorkbookEditablePermission, WorksheetSetCellStylePermission, WorksheetEditPermission, RangeProtectionPermissionEditPoint, SheetInterceptorService, INTERCEPTOR_POINT, SheetsSelectionsService, ClearSelectionAllCommand, RefRangeService, handleCommonDefaultRangeChangeWithEffectRefCommands, UniverSheetsPlugin } from "@univerjs/sheets";
7
+ import { DataValidationModel as DataValidationModel2, RemoveAllDataValidationCommand as RemoveAllDataValidationCommand2, RemoveDataValidationCommand as RemoveDataValidationCommand2 } from "@univerjs/data-validation";
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
10
  import { useObservable, ComponentManager, IZenZoneService, ISidebarService, TextEditor, useEvent, RangeSelector, KeyCode, IDialogService, MenuItemType, MenuPosition, MenuGroup, getMenuHiddenObservable, IMenuService } from "@univerjs/ui";
11
11
  import { IRenderManagerService, fixLineWidthByScale, Transform, Checkbox, DeviceInputEventType, getDocsSkeletonPageSize, Rect, DocumentViewModel, DocumentSkeleton, Documents, FontCache, Shape, getFontStyleString } from "@univerjs/engine-render";
@@ -14,7 +14,7 @@ import React, { forwardRef, useRef, createElement, useState, useMemo, useEffect
14
14
  import { RegisterOtherFormulaService, FormulaRefRangeService } from "@univerjs/sheets-formula";
15
15
  import { FormLayout, Input, RadioGroup, Radio, DraggableList, Select, Checkbox as Checkbox$1, Button, RectPopup, Scrollbar, DatePanel } from "@univerjs/design";
16
16
  import cs from "clsx";
17
- import { LexerTreeBuilder, deserializeRangeWithSheet, serializeRange, isReferenceString, sequenceNodeType, isFormulaTransformable, transformFormula } from "@univerjs/engine-formula";
17
+ import { LexerTreeBuilder, deserializeRangeWithSheet, serializeRange, isReferenceString, sequenceNodeType, ERROR_TYPE_SET } from "@univerjs/engine-formula";
18
18
  import dayjs from "dayjs";
19
19
  import { RichTextEditingMutation, getPlainTextFormDocument } from "@univerjs/docs";
20
20
  function getCellValueOrigin(cell) {
@@ -91,14 +91,14 @@ var __defProp$j = Object.defineProperty, __getOwnPropDesc$j = Object.getOwnPrope
91
91
  return kind && result && __defProp$j(target, key, result), result;
92
92
  }, "__decorateClass$j"), __decorateParam$j = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$j"), _a;
93
93
  let DataValidationDropdownManagerService = (_a = class extends Disposable {
94
- constructor(_canvasPopupManagerService, _univerInstanceService, _dataValidatorRegistryService, _zenZoneService, _renderManagerService, _dataValidationModel) {
94
+ constructor(_canvasPopupManagerService, _univerInstanceService, _dataValidatorRegistryService, _zenZoneService, _renderManagerService, _dataValidationModel, _sheetsSelectionsService) {
95
95
  super();
96
96
  __publicField(this, "_activeDropdown");
97
97
  __publicField(this, "_activeDropdown$", new Subject());
98
98
  __publicField(this, "_currentPopup", null);
99
99
  __publicField(this, "activeDropdown$", this._activeDropdown$.asObservable());
100
100
  __publicField(this, "_zenVisible", !1);
101
- this._canvasPopupManagerService = _canvasPopupManagerService, this._univerInstanceService = _univerInstanceService, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._zenZoneService = _zenZoneService, this._renderManagerService = _renderManagerService, this._dataValidationModel = _dataValidationModel, this._init(), this.disposeWithMe(() => {
101
+ 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(() => {
102
102
  this._activeDropdown$.complete();
103
103
  });
104
104
  }
@@ -110,6 +110,24 @@ let DataValidationDropdownManagerService = (_a = class extends Disposable {
110
110
  this._zenVisible = visible, visible && this.hideDropdown();
111
111
  }));
112
112
  }
113
+ _getDropdownByCell(unitId, subUnitId, row, col) {
114
+ const workbook = unitId ? this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET) : this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
115
+ if (!workbook)
116
+ return;
117
+ const worksheet = subUnitId ? workbook.getSheetBySheetId(subUnitId) : workbook.getActiveSheet();
118
+ if (!worksheet)
119
+ return;
120
+ const rule = this._dataValidationModel.ensureManager(workbook.getUnitId(), worksheet.getSheetId()).getRuleByLocation(row, col);
121
+ if (!rule)
122
+ return;
123
+ const validator = this._dataValidatorRegistryService.getValidatorItem(rule.type);
124
+ return validator == null ? void 0 : validator.dropdown;
125
+ }
126
+ _initSelectionChange() {
127
+ this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe((selections) => {
128
+ selections && selections.every((selection) => !(selection.primary && this._getDropdownByCell(selection.primary.unitId, selection.primary.sheetId, selection.primary.actualRow, selection.primary.actualColumn))) && this.hideDropdown();
129
+ }));
130
+ }
113
131
  showDropdown(param, closeOnOutSide = !0) {
114
132
  const { location } = param, { row, col } = location;
115
133
  if (this._currentPopup && this._currentPopup.dispose(), this._zenVisible)
@@ -141,7 +159,7 @@ let DataValidationDropdownManagerService = (_a = class extends Disposable {
141
159
  this._activeDropdown && (this._currentPopup && this._currentPopup.dispose(), this._currentPopup = null, this._activeDropdown = null, this._activeDropdown$.next(null));
142
160
  }
143
161
  showDataValidationDropdown(unitId, subUnitId, row, col, onHide) {
144
- const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
162
+ const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
145
163
  if (!workbook)
146
164
  return;
147
165
  const worksheet = workbook.getSheetBySheetId(subUnitId);
@@ -175,7 +193,8 @@ DataValidationDropdownManagerService = __decorateClass$j([
175
193
  __decorateParam$j(2, Inject(DataValidatorRegistryService)),
176
194
  __decorateParam$j(3, IZenZoneService),
177
195
  __decorateParam$j(4, IRenderManagerService),
178
- __decorateParam$j(5, Inject(DataValidationModel))
196
+ __decorateParam$j(5, Inject(DataValidationModel)),
197
+ __decorateParam$j(6, Inject(SheetsSelectionsService))
179
198
  ], DataValidationDropdownManagerService);
180
199
  var __defProp$i = Object.defineProperty, __getOwnPropDesc$i = Object.getOwnPropertyDescriptor, __decorateClass$i = /* @__PURE__ */ __name((decorators, target, key, kind) => {
181
200
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$i(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
@@ -464,6 +483,11 @@ function getFormulaResult(result) {
464
483
  return (_b = (_a22 = result == null ? void 0 : result[0]) == null ? void 0 : _a22[0]) == null ? void 0 : _b.v;
465
484
  }
466
485
  __name(getFormulaResult, "getFormulaResult");
486
+ function getFormulaCellData(result) {
487
+ var _a22;
488
+ return (_a22 = result == null ? void 0 : result[0]) == null ? void 0 : _a22[0];
489
+ }
490
+ __name(getFormulaCellData, "getFormulaCellData");
467
491
  var __defProp$g = Object.defineProperty, __getOwnPropDesc$g = Object.getOwnPropertyDescriptor, __decorateClass$g = /* @__PURE__ */ __name((decorators, target, key, kind) => {
468
492
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
469
493
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
@@ -1196,12 +1220,7 @@ let CheckboxValidator = _CheckboxValidator;
1196
1220
  const TWO_FORMULA_OPERATOR_COUNT = [
1197
1221
  DataValidationOperator.BETWEEN,
1198
1222
  DataValidationOperator.NOT_BETWEEN
1199
- ];
1200
- function excelSerialToUnixTimestamp(excelSerial) {
1201
- return new Date((excelSerial - 25569) * 86400).getTime();
1202
- }
1203
- __name(excelSerialToUnixTimestamp, "excelSerialToUnixTimestamp");
1204
- const timestamp2SerialTime = /* @__PURE__ */ __name((timestamp) => timestamp / 86400 + 25569, "timestamp2SerialTime"), dataValidationOptionsButton = "univer-data-validation-options-button", dataValidationOptionsButtonIcon = "univer-data-validation-options-button-icon", styles$5 = {
1223
+ ], dataValidationOptionsButton = "univer-data-validation-options-button", dataValidationOptionsButtonIcon = "univer-data-validation-options-button-icon", styles$5 = {
1205
1224
  dataValidationOptionsButton,
1206
1225
  dataValidationOptionsButtonIcon
1207
1226
  };
@@ -1540,21 +1559,8 @@ function DataValidationListWithWorkbook(props) {
1540
1559
  subUnitId
1541
1560
  });
1542
1561
  }, "handleRemoveAll"), rulesByPermissionCheck = (/* @__PURE__ */ __name((rules2) => {
1543
- const worksheet2 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getActiveSheet();
1544
- return rules2.map((rule) => {
1545
- const { ranges } = rule;
1546
- return (ranges == null ? void 0 : ranges.some((range) => {
1547
- var _a22, _b;
1548
- const { startRow, startColumn, endRow, endColumn } = range;
1549
- for (let row = startRow; row <= endRow; row++)
1550
- for (let col = startColumn; col <= endColumn; col++) {
1551
- const permission = (_b = (_a22 = worksheet2 == null ? void 0 : worksheet2.getCell(row, col)) == null ? void 0 : _a22.selectionProtection) == null ? void 0 : _b[0];
1552
- if ((permission == null ? void 0 : permission[P.Edit]) === !1 || (permission == null ? void 0 : permission[P.View]) === !1)
1553
- return !0;
1554
- }
1555
- return !1;
1556
- })) ? { ...rule, disable: !0 } : { ...rule };
1557
- });
1562
+ const workbook2 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), worksheet2 = workbook2.getActiveSheet(), unitId2 = workbook2.getUnitId(), subUnitId2 = worksheet2.getSheetId();
1563
+ return rules2.map((rule) => checkRangesEditablePermission(injector, unitId2, subUnitId2, rule.ranges) ? { ...rule } : { ...rule, disable: !0 });
1558
1564
  }, "getDvRulesByPermissionCorrect"))(rules), hasDisableRule = rulesByPermissionCheck == null ? void 0 : rulesByPermissionCheck.some((rule) => rule.disable);
1559
1565
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1560
1566
  rulesByPermissionCheck == null ? void 0 : rulesByPermissionCheck.map((rule) => {
@@ -1786,6 +1792,7 @@ let DataValidationRejectInputController = (_a6 = class extends Disposable {
1786
1792
  this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT_ASYNC,
1787
1793
  {
1788
1794
  handler: /* @__PURE__ */ __name(async (cellPromise, context, next) => {
1795
+ var _a22, _b, _c;
1789
1796
  const cell = await cellPromise, { worksheet, row, col, unitId, subUnitId, workbook } = context, manager = this._dataValidationModel.ensureManager(unitId, subUnitId), ruleId = manager.getRuleIdByLocation(row, col), rule = ruleId ? manager.getRuleById(ruleId) : void 0;
1790
1797
  if (!rule || rule.errorStyle !== DataValidationErrorStyle.STOP)
1791
1798
  return next(Promise.resolve(cell));
@@ -1793,12 +1800,14 @@ let DataValidationRejectInputController = (_a6 = class extends Disposable {
1793
1800
  if (!validator || await validator.validator(
1794
1801
  {
1795
1802
  value: getCellValueOrigin(cell),
1803
+ interceptValue: getCellValueOrigin((_c = (_b = (_a22 = cell == null ? void 0 : cell.custom) == null ? void 0 : _a22[UNIVER_INTERNAL]) == null ? void 0 : _b.origin) != null ? _c : cell),
1796
1804
  row,
1797
1805
  column: col,
1798
1806
  unitId,
1799
1807
  subUnitId,
1800
1808
  worksheet,
1801
- workbook
1809
+ workbook,
1810
+ t: cell == null ? void 0 : cell.t
1802
1811
  },
1803
1812
  rule
1804
1813
  ))
@@ -1873,10 +1882,8 @@ dayjs.extend(utc);
1873
1882
  const transformDate = /* @__PURE__ */ __name((value) => {
1874
1883
  if (value == null || typeof value == "boolean")
1875
1884
  return;
1876
- if (typeof value == "number" || !Number.isNaN(+value)) {
1877
- const date2 = dayjs.unix(excelSerialToUnixTimestamp(+value)).utc().format().slice(0, -1);
1878
- return dayjs(date2);
1879
- }
1885
+ if (typeof value == "number" || !Number.isNaN(+value))
1886
+ return dayjs(numfmt.format("yyyy-MM-dd HH:mm:ss", Number(value)));
1880
1887
  const date = dayjs(value);
1881
1888
  if (date.isValid())
1882
1889
  return date;
@@ -1887,9 +1894,10 @@ function DateDropdown(props) {
1887
1894
  if (!cellData || !rule || !validator)
1888
1895
  return;
1889
1896
  const handleSave = /* @__PURE__ */ __name(async () => {
1897
+ var _a23;
1890
1898
  if (!date)
1891
1899
  return;
1892
- const dateStr = `${date.format(showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD 00:00:00").split(" ").join("T")}Z`, serialTime = timestamp2SerialTime(dayjs(dateStr).unix());
1900
+ const dateStr = date.format(showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD 00:00:00"), serialTime = (_a23 = numfmt.parseDate(dateStr)) == null ? void 0 : _a23.v;
1893
1901
  rule.errorStyle !== DataValidationErrorStyle.STOP || await validator.validator({
1894
1902
  value: serialTime,
1895
1903
  unitId,
@@ -1897,7 +1905,9 @@ function DateDropdown(props) {
1897
1905
  row,
1898
1906
  column: col,
1899
1907
  worksheet,
1900
- workbook
1908
+ workbook,
1909
+ interceptValue: dateStr.replace("Z", "").replace("T", " "),
1910
+ t: CellValueType.NUMBER
1901
1911
  }, rule) ? (commandService.executeCommand(SetRangeValuesCommand.id, {
1902
1912
  unitId,
1903
1913
  subUnitId,
@@ -1933,7 +1943,8 @@ function DateDropdown(props) {
1933
1943
  }, "onSelect"),
1934
1944
  onPanelChange: /* @__PURE__ */ __name((value) => {
1935
1945
  setLocalDate(value);
1936
- }, "onPanelChange")
1946
+ }, "onPanelChange"),
1947
+ disabledDate: /* @__PURE__ */ __name((current) => !numfmt.parseDate(current.format("YYYY-MM-DD")), "disabledDate")
1937
1948
  }
1938
1949
  ),
1939
1950
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.dvDateDropdownBtns, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "small", type: "primary", onClick: handleSave, disabled: !date.isValid(), children: localeService.t("dataValidation.alert.ok") }) })
@@ -1993,12 +2004,13 @@ function DateShowTimeOption(props) {
1993
2004
  __name(DateShowTimeOption, "DateShowTimeOption");
1994
2005
  DateShowTimeOption.componentKey = DATE_SHOW_TIME_OPTION;
1995
2006
  const FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2SerialNumber = /* @__PURE__ */ __name((value) => {
2007
+ var _a22;
1996
2008
  if (value == null || typeof value == "boolean")
1997
2009
  return;
1998
2010
  if (typeof value == "number" || !Number.isNaN(+value))
1999
2011
  return +value;
2000
- const dateStr = `${dayjs(value).format("YYYY-MM-DD HH:mm:ss").split(" ").join("T")}Z`;
2001
- return timestamp2SerialTime(dayjs(dateStr).unix());
2012
+ const dateStr = `${dayjs(value).format("YYYY-MM-DD HH:mm:ss")}`;
2013
+ return (_a22 = numfmt.parseDate(dateStr)) == null ? void 0 : _a22.v;
2002
2014
  }, "transformDate2SerialNumber"), _DateValidator = class _DateValidator extends BaseDataValidator {
2003
2015
  constructor() {
2004
2016
  super(...arguments);
@@ -2037,8 +2049,8 @@ const FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2Serial
2037
2049
  };
2038
2050
  }
2039
2051
  async isValidType(info) {
2040
- const { value, worksheet, row, column } = info, cell = worksheet.getCell(row, column), interceptValue = getCellValueOrigin(cell);
2041
- return typeof interceptValue == "string" && typeof value == "number" ? dayjs(interceptValue).isValid() : !1;
2052
+ const { interceptValue, value } = info;
2053
+ return typeof value == "number" && typeof interceptValue == "string" ? !0 : typeof interceptValue == "string" ? !!numfmt.parseDate(interceptValue) : !1;
2042
2054
  }
2043
2055
  _validatorSingleFormula(formula) {
2044
2056
  return !Tools.isBlank(formula) && (isFormulaString(formula) || !Number.isNaN(+formula) || !!formula && dayjs(formula).isValid());
@@ -2212,6 +2224,7 @@ function calcPadding(cellWidth, cellHeight, fontWidth, fontHeight, vt, ht, margi
2212
2224
  paddingTop = realMargin;
2213
2225
  break;
2214
2226
  }
2227
+ paddingTop = Math.max(MARGIN_V$1, paddingTop);
2215
2228
  let paddingLeft = 0;
2216
2229
  switch (ht) {
2217
2230
  case HorizontalAlign.CENTER:
@@ -2221,7 +2234,7 @@ function calcPadding(cellWidth, cellHeight, fontWidth, fontHeight, vt, ht, margi
2221
2234
  paddingLeft = cellWidth - fontWidth;
2222
2235
  break;
2223
2236
  }
2224
- return {
2237
+ return paddingLeft = Math.max(MARGIN_H$1, paddingLeft), {
2225
2238
  paddingLeft,
2226
2239
  paddingTop
2227
2240
  };
@@ -3005,7 +3018,18 @@ const UpdateSheetDataValidationRangeCommand = {
3005
3018
  type: CommandType.COMMAND,
3006
3019
  id: "sheets.command.clear-range-data-validation",
3007
3020
  handler(accessor, params) {
3008
- return params ? (accessor.get(ICommandService), !0) : !1;
3021
+ if (!params)
3022
+ return !1;
3023
+ const { unitId, subUnitId, ranges } = params, commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, { unitId, subUnitId }), dataValidationModel = accessor.get(DataValidationModel);
3024
+ if (!target) return !1;
3025
+ const undoRedoService = accessor.get(IUndoRedoService), manager = dataValidationModel.ensureManager(unitId, subUnitId), matrix = manager.getRuleObjectMatrix().clone();
3026
+ matrix.removeRange(ranges);
3027
+ const diffs = matrix.diff(manager.getDataValidations()), { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor);
3028
+ return undoRedoService.pushUndoRedo({
3029
+ unitID: unitId,
3030
+ redoMutations,
3031
+ undoMutations
3032
+ }), sequenceExecute(redoMutations, commandService).result;
3009
3033
  }
3010
3034
  }, DataValidationIcon = "data-validation-single", DATA_VALIDATION_MENU_ID = "sheet.menu.data-validation";
3011
3035
  function dataValidationMenuFactory(accessor) {
@@ -3128,10 +3152,11 @@ let SheetsDataValidationRenderController = (_a8 = class extends RxDisposable {
3128
3152
  this._sheetInterceptorService.intercept(
3129
3153
  INTERCEPTOR_POINT.CELL_CONTENT,
3130
3154
  {
3131
- priority: 200,
3155
+ // must be after numfmt
3156
+ priority: InterceptCellContentPriority.DATA_VALIDATION,
3132
3157
  // eslint-disable-next-line max-lines-per-function, complexity
3133
3158
  handler: /* @__PURE__ */ __name((cell, pos, next) => {
3134
- var _a22, _b, _c, _d, _e, _f;
3159
+ var _a22, _b, _c, _d, _e, _f, _g;
3135
3160
  const { row, col, unitId, subUnitId, workbook, worksheet } = pos, manager = this._dataValidationModel.ensureManager(unitId, subUnitId);
3136
3161
  if (!manager)
3137
3162
  return next(cell);
@@ -3144,7 +3169,7 @@ let SheetsDataValidationRenderController = (_a8 = class extends RxDisposable {
3144
3169
  const rule = manager.getRuleById(ruleId);
3145
3170
  if (!rule)
3146
3171
  return next(cell);
3147
- const cellRaw = worksheet.getCellRaw(pos.row, pos.col), validStatus = this._dataValidationModel.validator(getCellValueOrigin(cellRaw), rule, pos), validator = this._dataValidatorRegistryService.getValidatorItem(rule.type), cellValue = getCellValueOrigin(cell);
3172
+ const validStatus = this._dataValidationModel.validator(rule, pos, cell), validator = this._dataValidatorRegistryService.getValidatorItem(rule.type), cellValue = getCellValueOrigin(cell);
3148
3173
  let extra = {};
3149
3174
  if ((rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE) && (extra = {
3150
3175
  interceptorStyle: {
@@ -3189,13 +3214,14 @@ let SheetsDataValidationRenderController = (_a8 = class extends RxDisposable {
3189
3214
  fontRenderExtension: {
3190
3215
  // @ts-ignore
3191
3216
  ...cell == null ? void 0 : cell.fontRenderExtension,
3192
- isSkip: validator == null ? void 0 : validator.skipDefaultFontRender(rule, cellValue, pos)
3217
+ // @ts-ignore
3218
+ isSkip: ((_f = cell == null ? void 0 : cell.fontRenderExtension) == null ? void 0 : _f.isSkip) || (validator == null ? void 0 : validator.skipDefaultFontRender(rule, cellValue, pos))
3193
3219
  },
3194
3220
  interceptorStyle: {
3195
3221
  ...cell == null ? void 0 : cell.interceptorStyle,
3196
3222
  ...extra.interceptorStyle
3197
3223
  },
3198
- get interceptorAutoHeight() {
3224
+ interceptorAutoHeight: /* @__PURE__ */ __name(() => {
3199
3225
  var _a23, _b2, _c2, _d2;
3200
3226
  const mergeCell = skeleton.mergeData.find((range) => {
3201
3227
  const { startColumn, startRow, endColumn, endRow } = range;
@@ -3220,8 +3246,8 @@ let SheetsDataValidationRenderController = (_a8 = class extends RxDisposable {
3220
3246
  worksheet
3221
3247
  };
3222
3248
  return (_d2 = (_c2 = validator == null ? void 0 : validator.canvasRender) == null ? void 0 : _c2.calcCellAutoHeight) == null ? void 0 : _d2.call(_c2, info);
3223
- },
3224
- coverable: ((_f = cell == null ? void 0 : cell.coverable) != null ? _f : !0) && !(rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE)
3249
+ }, "interceptorAutoHeight"),
3250
+ coverable: ((_g = cell == null ? void 0 : cell.coverable) != null ? _g : !0) && !(rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE)
3225
3251
  });
3226
3252
  }, "handler")
3227
3253
  }
@@ -3284,7 +3310,7 @@ let SheetsDataValidationMobileRenderController = (_a9 = class extends RxDisposab
3284
3310
  this._sheetInterceptorService.intercept(
3285
3311
  INTERCEPTOR_POINT.CELL_CONTENT,
3286
3312
  {
3287
- priority: 200,
3313
+ priority: InterceptCellContentPriority.DATA_VALIDATION,
3288
3314
  // eslint-disable-next-line max-lines-per-function, complexity
3289
3315
  handler: /* @__PURE__ */ __name((cell, pos, next) => {
3290
3316
  var _a22, _b, _c, _d, _e;
@@ -3300,7 +3326,7 @@ let SheetsDataValidationMobileRenderController = (_a9 = class extends RxDisposab
3300
3326
  const rule = manager.getRuleById(ruleId);
3301
3327
  if (!rule)
3302
3328
  return next(cell);
3303
- const cellRaw = pos.worksheet.getCellRaw(pos.row, pos.col), validStatus = this._dataValidationModel.validator(getCellValueOrigin(cellRaw), rule, pos), validator = this._dataValidatorRegistryService.getValidatorItem(rule.type), cellValue = getCellValueOrigin(cell);
3329
+ const validStatus = this._dataValidationModel.validator(rule, pos, cell), validator = this._dataValidatorRegistryService.getValidatorItem(rule.type), cellValue = getCellValueOrigin(cell);
3304
3330
  let extra = {};
3305
3331
  if ((rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE) && (extra = {
3306
3332
  interceptorStyle: {
@@ -3351,7 +3377,7 @@ let SheetsDataValidationMobileRenderController = (_a9 = class extends RxDisposab
3351
3377
  ...cell == null ? void 0 : cell.interceptorStyle,
3352
3378
  ...extra.interceptorStyle
3353
3379
  },
3354
- get interceptorAutoHeight() {
3380
+ interceptorAutoHeight: /* @__PURE__ */ __name(() => {
3355
3381
  var _a23, _b2, _c2, _d2;
3356
3382
  const mergeCell = skeleton.mergeData.find((range) => {
3357
3383
  const { startColumn, startRow, endColumn, endRow } = range;
@@ -3376,7 +3402,7 @@ let SheetsDataValidationMobileRenderController = (_a9 = class extends RxDisposab
3376
3402
  workbook
3377
3403
  };
3378
3404
  return (_d2 = (_c2 = validator == null ? void 0 : validator.canvasRender) == null ? void 0 : _c2.calcCellAutoHeight) == null ? void 0 : _d2.call(_c2, info);
3379
- }
3405
+ }, "interceptorAutoHeight")
3380
3406
  });
3381
3407
  }, "handler")
3382
3408
  }
@@ -3413,9 +3439,14 @@ var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPrope
3413
3439
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3414
3440
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
3415
3441
  return kind && result && __defProp$b(target, key, result), result;
3416
- }, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b"), _a10;
3442
+ }, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b");
3443
+ function transformFormula(lexerTreeBuilder, formula, originRow, originCol, targetRow, targetCol) {
3444
+ return lexerTreeBuilder.moveFormulaRefOffset(formula, targetCol - originCol, targetRow - originRow);
3445
+ }
3446
+ __name(transformFormula, "transformFormula");
3447
+ var _a10;
3417
3448
  let DataValidationCustomFormulaService = (_a10 = class extends Disposable {
3418
- constructor(_instanceSrv, _registerOtherFormulaService, _lexerTreeBuilder, _dataValidationModel, _dataValidationCacheService) {
3449
+ constructor(_instanceSrv, _registerOtherFormulaService, _lexerTreeBuilder, _dataValidationModel, _dataValidationCacheService, _logService) {
3419
3450
  super();
3420
3451
  __publicField(this, "_formulaMap", /* @__PURE__ */ new Map());
3421
3452
  /**
@@ -3426,7 +3457,7 @@ let DataValidationCustomFormulaService = (_a10 = class extends Disposable {
3426
3457
  * reflect of formulaId to cell, only store transformable formula
3427
3458
  */
3428
3459
  __publicField(this, "_formulaCellMap", /* @__PURE__ */ new Map());
3429
- this._instanceSrv = _instanceSrv, this._registerOtherFormulaService = _registerOtherFormulaService, this._lexerTreeBuilder = _lexerTreeBuilder, this._dataValidationModel = _dataValidationModel, this._dataValidationCacheService = _dataValidationCacheService, this._initFormulaResultHandler();
3460
+ this._instanceSrv = _instanceSrv, this._registerOtherFormulaService = _registerOtherFormulaService, this._lexerTreeBuilder = _lexerTreeBuilder, this._dataValidationModel = _dataValidationModel, this._dataValidationCacheService = _dataValidationCacheService, this._logService = _logService, this._initFormulaResultHandler();
3430
3461
  }
3431
3462
  _initFormulaResultHandler() {
3432
3463
  this.disposeWithMe(this._registerOtherFormulaService.formulaResult$.subscribe((resultMap) => {
@@ -3473,12 +3504,9 @@ let DataValidationCustomFormulaService = (_a10 = class extends Disposable {
3473
3504
  const { formulaMap, ruleFormulaMap, formulaCellMap } = this._ensureMaps(unitId, subUnitId);
3474
3505
  if (!formula)
3475
3506
  return;
3476
- const isTransformable = isFormulaTransformable(
3477
- this._lexerTreeBuilder,
3478
- formula
3479
- ), originRow = ranges[0].startRow, originCol = ranges[0].startColumn;
3507
+ const originRow = ranges[0].startRow, originCol = ranges[0].startColumn;
3480
3508
  let originFormulaId;
3481
- isTransformable ? ranges.forEach((range) => {
3509
+ ranges.forEach((range) => {
3482
3510
  Range.foreach(range, (row, column) => {
3483
3511
  const relativeFormula = transformFormula(
3484
3512
  this._lexerTreeBuilder,
@@ -3494,20 +3522,12 @@ let DataValidationCustomFormulaService = (_a10 = class extends Disposable {
3494
3522
  ruleId
3495
3523
  }), formulaCellMap.set(formulaId, { row, column });
3496
3524
  });
3497
- }) : (originFormulaId = this._registerFormula(unitId, subUnitId, ruleId, formula), ranges.forEach((range) => {
3498
- Range.foreach(range, (row, col) => {
3499
- formulaMap.setValue(row, col, {
3500
- formulaId: originFormulaId,
3501
- // formulaText: formula,
3502
- ruleId
3503
- });
3504
- });
3505
- })), ruleFormulaMap.set(ruleId, {
3525
+ }), ruleFormulaMap.set(ruleId, {
3506
3526
  formula,
3507
3527
  originCol,
3508
3528
  originRow,
3509
- isTransformable,
3510
- formulaId: originFormulaId
3529
+ formulaId: originFormulaId,
3530
+ isTransformable: !0
3511
3531
  });
3512
3532
  }
3513
3533
  addRule(unitId, subUnitId, rule) {
@@ -3533,7 +3553,6 @@ let DataValidationCustomFormulaService = (_a10 = class extends Disposable {
3533
3553
  if (oldRuleFormula != null && oldRuleFormula.isTransformable && deleteFormulaIdList.add(oldValue.formulaId), isTransformable) {
3534
3554
  const relativeText = transformFormula(this._lexerTreeBuilder, formula, originRow, originCol, row, col), formulaId2 = this._registerFormula(unitId, subUnitId, ruleId, relativeText);
3535
3555
  formulaMap.setValue(row, col, {
3536
- // formulaText: relativeText,
3537
3556
  ruleId,
3538
3557
  formulaId: formulaId2
3539
3558
  }), formulaCellMap.set(formulaId2, { row, column: col });
@@ -3573,8 +3592,13 @@ DataValidationCustomFormulaService = __decorateClass$b([
3573
3592
  __decorateParam$b(1, Inject(RegisterOtherFormulaService)),
3574
3593
  __decorateParam$b(2, Inject(LexerTreeBuilder)),
3575
3594
  __decorateParam$b(3, Inject(DataValidationModel)),
3576
- __decorateParam$b(4, Inject(DataValidationCacheService))
3595
+ __decorateParam$b(4, Inject(DataValidationCacheService)),
3596
+ __decorateParam$b(5, ILogService)
3577
3597
  ], DataValidationCustomFormulaService);
3598
+ function isLegalFormulaResult(res) {
3599
+ return !ERROR_TYPE_SET.has(res);
3600
+ }
3601
+ __name(isLegalFormulaResult, "isLegalFormulaResult");
3578
3602
  const _CustomFormulaValidator = class _CustomFormulaValidator extends BaseDataValidator {
3579
3603
  constructor() {
3580
3604
  super(...arguments);
@@ -3599,8 +3623,8 @@ const _CustomFormulaValidator = class _CustomFormulaValidator extends BaseDataVa
3599
3623
  };
3600
3624
  }
3601
3625
  async isValidType(cellInfo, _formula, _rule) {
3602
- const { column, row, unitId, subUnitId } = cellInfo, result = await this._customFormulaService.getCellFormulaValue(unitId, subUnitId, row, column);
3603
- return !!getFormulaResult(result == null ? void 0 : result.result);
3626
+ const { column, row, unitId, subUnitId } = cellInfo, result = await this._customFormulaService.getCellFormulaValue(unitId, subUnitId, row, column), cellData = getFormulaCellData(result == null ? void 0 : result.result), formulaResult = cellData == null ? void 0 : cellData.v;
3627
+ return Tools.isDefine(formulaResult) && formulaResult !== "" ? cellData.t === CellValueType.BOOLEAN ? !!formulaResult : typeof formulaResult == "boolean" ? formulaResult : typeof formulaResult == "number" ? !!formulaResult : typeof formulaResult == "string" ? isLegalFormulaResult(formulaResult) : !!formulaResult : !1;
3604
3628
  }
3605
3629
  generateRuleErrorMessage(rule) {
3606
3630
  return this.localeService.t("dataValidation.custom.error");
@@ -4561,12 +4585,13 @@ const _SheetDataValidationManager = class _SheetDataValidationManager extends Da
4561
4585
  if (ruleId)
4562
4586
  return this.getRuleById(ruleId);
4563
4587
  }
4564
- validator(cellValue, rule, pos, onCompete) {
4565
- const { col, row, unitId, subUnitId } = pos, ruleId = rule.uid, validator = this.getValidator(rule.type);
4588
+ validator(cell, rule, pos, onCompete) {
4589
+ const { col, row, unitId, subUnitId, worksheet } = pos, ruleId = rule.uid, validator = this.getValidator(rule.type), cellRaw = worksheet.getCellRaw(row, col), cellValue = getCellValueOrigin(cellRaw), interceptValue = getCellValueOrigin(cell);
4566
4590
  if (validator) {
4567
4591
  const current = this._cache.getValue(row, col);
4568
- return !current || current.value !== cellValue ? (this._cache.setValue(row, col, {
4592
+ return !current || current.value !== cellValue || current.interceptValue !== interceptValue || current.ruleId !== ruleId ? (this._cache.setValue(row, col, {
4569
4593
  value: cellValue,
4594
+ interceptValue,
4570
4595
  status: DataValidationStatus.VALIDATING,
4571
4596
  ruleId
4572
4597
  }), validator.validator(
@@ -4577,7 +4602,9 @@ const _SheetDataValidationManager = class _SheetDataValidationManager extends Da
4577
4602
  row,
4578
4603
  column: col,
4579
4604
  worksheet: pos.worksheet,
4580
- workbook: pos.workbook
4605
+ workbook: pos.workbook,
4606
+ interceptValue: getCellValueOrigin(cell),
4607
+ t: cellRaw == null ? void 0 : cellRaw.t
4581
4608
  },
4582
4609
  rule
4583
4610
  ).then((status) => {
@@ -4585,7 +4612,8 @@ const _SheetDataValidationManager = class _SheetDataValidationManager extends Da
4585
4612
  this._cache.setValue(row, col, {
4586
4613
  value: cellValue,
4587
4614
  status: realStatus,
4588
- ruleId
4615
+ ruleId,
4616
+ interceptValue
4589
4617
  }), onCompete(realStatus, !0);
4590
4618
  }), DataValidationStatus.VALIDATING) : (onCompete(current.status, !1), current.status);
4591
4619
  } else
@@ -4678,9 +4706,11 @@ let SheetsDataValidationValidatorService = (_a19 = class {
4678
4706
  const worksheet = workbook.getSheetBySheetId(subUnitId);
4679
4707
  if (!worksheet)
4680
4708
  throw new Error(`cannot find current worksheet, sheetId: ${subUnitId}`);
4681
- const cellRaw = worksheet.getCellRaw(row, col), manager = this._dataValidationModel.ensureManager(unitId, subUnitId), rule = manager.getRuleByLocation(row, col);
4709
+ if (!Tools.isDefine(row) || !Tools.isDefine(col))
4710
+ throw new Error(`row or col is not defined, row: ${row}, col: ${col}`);
4711
+ const manager = this._dataValidationModel.ensureManager(unitId, subUnitId), cell = worksheet.getCell(row, col), rule = manager.getRuleByLocation(row, col);
4682
4712
  return rule ? new Promise((resolve) => {
4683
- manager.validator(getCellValueOrigin(cellRaw), rule, { unitId, subUnitId, row, col, worksheet, workbook }, resolve);
4713
+ manager.validator(cell, rule, { unitId, subUnitId, row, col, worksheet, workbook }, resolve);
4684
4714
  }) : DataValidationStatus.VALID;
4685
4715
  }
4686
4716
  validatorRanges(unitId, subUnitId, ranges) {
@@ -4852,6 +4882,7 @@ export {
4852
4882
  DataValidationModel2 as DataValidationModel,
4853
4883
  HideDataValidationDropdown,
4854
4884
  OpenValidationPanelOperation,
4885
+ RemoveAllDataValidationCommand2 as RemoveSheetAllDataValidationCommand,
4855
4886
  RemoveDataValidationCommand2 as RemoveSheetDataValidationCommand,
4856
4887
  SheetDataValidationManager,
4857
4888
  SheetsDataValidationValidatorService,
@@ -16,11 +16,12 @@
16
16
  export { UniverSheetsDataValidationPlugin } from './plugin';
17
17
  export { UniverSheetsDataValidationMobilePlugin } from './mobile-plugin';
18
18
  export { DataValidationCacheService } from './services/dv-cache.service';
19
+ export type { IDataValidationResCache } from './services/dv-cache.service';
19
20
  export { DataValidationFormulaService } from './services/dv-formula.service';
20
21
  export { DataValidationCustomFormulaService } from './services/dv-custom-formula.service';
21
22
  export { DATA_VALIDATION_PLUGIN_NAME } from './common/const';
22
23
  export { SheetsDataValidationValidatorService } from './services/dv-validator-service';
23
- export { DataValidationModel } from '@univerjs/data-validation';
24
+ export { DataValidationModel, RemoveAllDataValidationCommand as RemoveSheetAllDataValidationCommand, type IRemoveAllDataValidationCommandParams as IRemoveSheetAllDataValidationCommandParams, } from '@univerjs/data-validation';
24
25
  export { SheetDataValidationManager } from './models/sheet-data-validation-manager';
25
26
  export { RemoveDataValidationCommand as RemoveSheetDataValidationCommand, type IRemoveDataValidationCommandParams as IRemoveSheetDataValidationCommandParams, } from '@univerjs/data-validation';
26
27
  export { UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationOptionsCommand, UpdateSheetDataValidationSettingCommand, AddSheetDataValidationCommand, AddSheetDataValidationAndOpenCommand, ClearRangeDataValidationCommand, type IAddSheetDataValidationCommandParams, type IUpdateSheetDataValidationRangeCommandParams, type IUpdateSheetDataValidationOptionsCommandParams, type IUpdateSheetDataValidationSettingCommandParams, type IClearRangeDataValidationCommandParams, } from './commands/commands/data-validation.command';
@@ -1,4 +1,4 @@
1
- import { CellValue, Injector, ISheetDataValidationRule, Nullable, DataValidationStatus, DataValidationType } from '@univerjs/core';
1
+ import { ICellDataForSheetInterceptor, Injector, ISheetDataValidationRule, Nullable, DataValidationStatus, DataValidationType } from '@univerjs/core';
2
2
  import { DataValidationManager, IUpdateRulePayload } from '@univerjs/data-validation';
3
3
  import { ISheetLocation } from '@univerjs/sheets';
4
4
  import { RuleMatrix } from './rule-matrix';
@@ -18,10 +18,10 @@ export declare class SheetDataValidationManager extends DataValidationManager<IS
18
18
  addRule(rule: ISheetDataValidationRule | ISheetDataValidationRule[], index?: number): void;
19
19
  updateRule(ruleId: string, payload: IUpdateRulePayload): ISheetDataValidationRule;
20
20
  removeRule(ruleId: string): void;
21
- getValidator(type: DataValidationType): import('@univerjs/data-validation').BaseDataValidator<CellValue> | undefined;
21
+ getValidator(type: DataValidationType): import('@univerjs/data-validation').BaseDataValidator<import('@univerjs/core').CellValue> | undefined;
22
22
  getRuleIdByLocation(row: number, col: number): string | undefined;
23
23
  getRuleByLocation(row: number, col: number): ISheetDataValidationRule | undefined;
24
- validator(cellValue: Nullable<CellValue>, rule: ISheetDataValidationRule, pos: ISheetLocation, onCompete: (status: DataValidationStatus, changed: boolean) => void): DataValidationStatus;
24
+ validator(cell: Nullable<ICellDataForSheetInterceptor>, rule: ISheetDataValidationRule, pos: ISheetLocation, onCompete: (status: DataValidationStatus, changed: boolean) => void): DataValidationStatus;
25
25
  getRuleErrorMsg(ruleId: string): string;
26
26
  getRuleObjectMatrix(): RuleMatrix;
27
27
  }
@@ -1,5 +1,5 @@
1
1
  import { Nullable, Disposable, IUniverInstanceService } from '@univerjs/core';
2
- import { ISheetLocation } from '@univerjs/sheets';
2
+ import { ISheetLocation, SheetsSelectionsService } from '@univerjs/sheets';
3
3
  import { SheetCanvasPopManagerService } from '@univerjs/sheets-ui';
4
4
  import { DataValidationModel, DataValidatorRegistryService } from '@univerjs/data-validation';
5
5
  import { IZenZoneService } from '@univerjs/ui';
@@ -22,14 +22,17 @@ export declare class DataValidationDropdownManagerService extends Disposable {
22
22
  private readonly _zenZoneService;
23
23
  private readonly _renderManagerService;
24
24
  private readonly _dataValidationModel;
25
+ private readonly _sheetsSelectionsService;
25
26
  private _activeDropdown;
26
27
  private _activeDropdown$;
27
28
  private _currentPopup;
28
29
  activeDropdown$: import('rxjs').Observable<Nullable<IDropdownParam>>;
29
30
  private _zenVisible;
30
31
  get activeDropdown(): Nullable<IDropdownParam>;
31
- constructor(_canvasPopupManagerService: SheetCanvasPopManagerService, _univerInstanceService: IUniverInstanceService, _dataValidatorRegistryService: DataValidatorRegistryService, _zenZoneService: IZenZoneService, _renderManagerService: IRenderManagerService, _dataValidationModel: DataValidationModel);
32
+ constructor(_canvasPopupManagerService: SheetCanvasPopManagerService, _univerInstanceService: IUniverInstanceService, _dataValidatorRegistryService: DataValidatorRegistryService, _zenZoneService: IZenZoneService, _renderManagerService: IRenderManagerService, _dataValidationModel: DataValidationModel, _sheetsSelectionsService: SheetsSelectionsService);
32
33
  private _init;
34
+ private _getDropdownByCell;
35
+ private _initSelectionChange;
33
36
  showDropdown(param: IDropdownParam, closeOnOutSide?: boolean): void;
34
37
  hideDropdown(): void;
35
38
  showDataValidationDropdown(unitId: string, subUnitId: string, row: number, col: number, onHide?: () => void): void;
@@ -1,6 +1,7 @@
1
1
  import { ObjectMatrix, CellValue, DataValidationStatus, IRange, ISheetDataValidationRule, Nullable } from '@univerjs/core';
2
2
  export interface IDataValidationResCache {
3
3
  value: Nullable<CellValue>;
4
+ interceptValue: Nullable<CellValue>;
4
5
  status: DataValidationStatus;
5
6
  ruleId: string;
6
7
  temp?: boolean;
@@ -1,4 +1,4 @@
1
- import { IRange, ISheetDataValidationRule, Disposable, IUniverInstanceService } from '@univerjs/core';
1
+ import { IRange, ISheetDataValidationRule, Disposable, ILogService, IUniverInstanceService } from '@univerjs/core';
2
2
  import { LexerTreeBuilder } from '@univerjs/engine-formula';
3
3
  import { DataValidationModel } from '@univerjs/data-validation';
4
4
  import { RegisterOtherFormulaService } from '@univerjs/sheets-formula';
@@ -16,6 +16,7 @@ export declare class DataValidationCustomFormulaService extends Disposable {
16
16
  private _lexerTreeBuilder;
17
17
  private readonly _dataValidationModel;
18
18
  private readonly _dataValidationCacheService;
19
+ private readonly _logService;
19
20
  private _formulaMap;
20
21
  /**
21
22
  * Map of origin formula of rule
@@ -25,7 +26,7 @@ export declare class DataValidationCustomFormulaService extends Disposable {
25
26
  * reflect of formulaId to cell, only store transformable formula
26
27
  */
27
28
  private _formulaCellMap;
28
- constructor(_instanceSrv: IUniverInstanceService, _registerOtherFormulaService: RegisterOtherFormulaService, _lexerTreeBuilder: LexerTreeBuilder, _dataValidationModel: DataValidationModel, _dataValidationCacheService: DataValidationCacheService);
29
+ constructor(_instanceSrv: IUniverInstanceService, _registerOtherFormulaService: RegisterOtherFormulaService, _lexerTreeBuilder: LexerTreeBuilder, _dataValidationModel: DataValidationModel, _dataValidationCacheService: DataValidationCacheService, _logService: ILogService);
29
30
  private _initFormulaResultHandler;
30
31
  private _ensureMaps;
31
32
  private _registerFormula;
@@ -1,2 +1,3 @@
1
1
  import { ICellData, Nullable } from '@univerjs/core';
2
2
  export declare function getFormulaResult(result: Nullable<Nullable<ICellData>[][]>): Nullable<import('@univerjs/core').CellValue>;
3
+ export declare function getFormulaCellData(result: Nullable<Nullable<ICellData>[][]>): Nullable<ICellData>;
@@ -1,4 +1,4 @@
1
- import { DataValidationOperator, CellValue, IDataValidationRule } from '@univerjs/core';
1
+ import { DataValidationOperator, CellValue, IDataValidationRule, Nullable } from '@univerjs/core';
2
2
  import { IFormulaResult, IFormulaValidResult, IValidatorCellInfo, BaseDataValidator } from '@univerjs/data-validation';
3
3
  export declare function getCellValueNumber(cellValue: CellValue): number;
4
4
  export declare class DecimalValidator extends BaseDataValidator<number> {
@@ -13,12 +13,14 @@ export declare class DecimalValidator extends BaseDataValidator<number> {
13
13
  isValidType(cellInfo: IValidatorCellInfo<CellValue>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
14
14
  transform(cellInfo: IValidatorCellInfo<CellValue>, formula: IFormulaResult, rule: IDataValidationRule): {
15
15
  value: number;
16
+ interceptValue: Nullable<CellValue>;
16
17
  row: number;
17
18
  column: number;
18
19
  unitId: string;
19
20
  subUnitId: string;
20
21
  worksheet: import('@univerjs/core').Worksheet;
21
22
  workbook: import('@univerjs/core').Workbook;
23
+ t: Nullable<import('@univerjs/protocol').CellValueType>;
22
24
  };
23
25
  private _parseNumber;
24
26
  parseFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): Promise<{