@univerjs/sheets-data-validation 1.0.0-alpha.8 → 1.0.0-beta.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.
package/lib/cjs/facade.js CHANGED
@@ -80,7 +80,7 @@ function _defineProperty(e, r, t) {
80
80
  var FDataValidationBuilder = class FDataValidationBuilder {
81
81
  constructor(rule) {
82
82
  _defineProperty(this, "_rule", void 0);
83
- this._rule = rule !== null && rule !== void 0 ? rule : {
83
+ this._rule = rule ?? {
84
84
  uid: (0, _univerjs_core.generateRandomId)(),
85
85
  ranges: void 0,
86
86
  type: _univerjs_core.DataValidationType.CUSTOM
@@ -813,7 +813,7 @@ var FDataValidationBuilder = class FDataValidationBuilder {
813
813
  this._rule.type = multiple ? _univerjs_core.DataValidationType.LIST_MULTIPLE : _univerjs_core.DataValidationType.LIST;
814
814
  this._rule.formula1 = (0, _univerjs_sheets.serializeListOptions)(values);
815
815
  this._rule.formula2 = void 0;
816
- this._rule.showDropDown = showDropdown !== null && showDropdown !== void 0 ? showDropdown : true;
816
+ this._rule.showDropDown = showDropdown ?? true;
817
817
  return this;
818
818
  }
819
819
  /**
@@ -857,7 +857,7 @@ var FDataValidationBuilder = class FDataValidationBuilder {
857
857
  range: range.getRange()
858
858
  })}`;
859
859
  this._rule.formula2 = void 0;
860
- this._rule.showDropDown = showDropdown !== null && showDropdown !== void 0 ? showDropdown : true;
860
+ this._rule.showDropDown = showDropdown ?? true;
861
861
  return this;
862
862
  }
863
863
  /**
package/lib/cjs/index.js CHANGED
@@ -187,9 +187,8 @@ function isLegalFormulaResult(res) {
187
187
  * Judge if the data-validation's formula need to be offseted by ranges
188
188
  */
189
189
  function shouldOffsetFormulaByRange(type, validatorRegistryService) {
190
- var _validator$offsetForm;
191
190
  const validator = validatorRegistryService.getValidatorItem(type);
192
- return (_validator$offsetForm = validator === null || validator === void 0 ? void 0 : validator.offsetFormulaByRange) !== null && _validator$offsetForm !== void 0 ? _validator$offsetForm : false;
191
+ return (validator === null || validator === void 0 ? void 0 : validator.offsetFormulaByRange) ?? false;
193
192
  }
194
193
 
195
194
  //#endregion
@@ -385,8 +384,7 @@ function getCellValueOrigin(cell) {
385
384
  return (0, _univerjs_core.getOriginCellValue)(cell);
386
385
  }
387
386
  function getStringCellValue(cell) {
388
- var _getCellValueOrigin;
389
- return String((_getCellValueOrigin = getCellValueOrigin(cell)) !== null && _getCellValueOrigin !== void 0 ? _getCellValueOrigin : "");
387
+ return String(getCellValueOrigin(cell) ?? "");
390
388
  }
391
389
 
392
390
  //#endregion
@@ -715,8 +713,7 @@ var RuleMatrix = class RuleMatrix {
715
713
  const mutations = [];
716
714
  let deleteIndex = 0;
717
715
  rules.forEach((rule, index) => {
718
- var _this$_map$get;
719
- const newRanges = (_this$_map$get = this._map.get(rule.uid)) !== null && _this$_map$get !== void 0 ? _this$_map$get : [];
716
+ const newRanges = this._map.get(rule.uid) ?? [];
720
717
  const oldRanges = rule.ranges;
721
718
  if (newRanges.length !== 0 && (newRanges.length !== oldRanges.length || newRanges.some((range, i) => !_univerjs_core.Rectangle.equals(range, oldRanges[i])))) mutations.push({
722
719
  type: "update",
@@ -740,8 +737,7 @@ var RuleMatrix = class RuleMatrix {
740
737
  const mutations = [];
741
738
  let deleteIndex = 0;
742
739
  rules.forEach((rule, index) => {
743
- var _this$_map$get2;
744
- const newRanges = (_this$_map$get2 = this._map.get(rule.uid)) !== null && _this$_map$get2 !== void 0 ? _this$_map$get2 : [];
740
+ const newRanges = this._map.get(rule.uid) ?? [];
745
741
  const oldRanges = rule.ranges;
746
742
  if (newRanges.length !== 0 && (newRanges.length !== oldRanges.length || newRanges.some((range, i) => !_univerjs_core.Rectangle.equals(range, oldRanges[i])))) mutations.push({
747
743
  type: "update",
@@ -760,8 +756,7 @@ var RuleMatrix = class RuleMatrix {
760
756
  }
761
757
  });
762
758
  Array.from(additionRules).forEach((rule) => {
763
- var _this$_map$get3;
764
- const newRanges = (_this$_map$get3 = this._map.get(rule.uid)) !== null && _this$_map$get3 !== void 0 ? _this$_map$get3 : [];
759
+ const newRanges = this._map.get(rule.uid) ?? [];
765
760
  mutations.push({
766
761
  type: "add",
767
762
  rule: {
@@ -946,8 +941,8 @@ let SheetDataValidationModel = class SheetDataValidationModel extends _univerjs_
946
941
  });
947
942
  return _univerjs_core.DataValidationStatus.VALIDATING;
948
943
  }
949
- onCompete(current !== null && current !== void 0 ? current : _univerjs_core.DataValidationStatus.VALID, false);
950
- return current !== null && current !== void 0 ? current : _univerjs_core.DataValidationStatus.VALID;
944
+ onCompete(current ?? _univerjs_core.DataValidationStatus.VALID, false);
945
+ return current ?? _univerjs_core.DataValidationStatus.VALID;
951
946
  } else {
952
947
  onCompete(_univerjs_core.DataValidationStatus.VALID, false);
953
948
  return _univerjs_core.DataValidationStatus.VALID;
@@ -1058,15 +1053,13 @@ var BaseSheetValidator = class extends _univerjs_data_validation.BaseDataValidat
1058
1053
  return this.operators.map((operator) => this.localeService.t(OperatorTextMap[operator]));
1059
1054
  }
1060
1055
  generateRuleName(rule) {
1061
- var _rule$formula, _rule$formula2;
1062
1056
  if (!rule.operator) return this.localeService.t(OperatorTitleMap.NONE).replace(TYPE, this.titleStr);
1063
- const ruleName = this.localeService.t(OperatorTitleMap[rule.operator]).replace(FORMULA1$1, (_rule$formula = rule.formula1) !== null && _rule$formula !== void 0 ? _rule$formula : "").replace(FORMULA2$1, (_rule$formula2 = rule.formula2) !== null && _rule$formula2 !== void 0 ? _rule$formula2 : "");
1057
+ const ruleName = this.localeService.t(OperatorTitleMap[rule.operator]).replace(FORMULA1$1, rule.formula1 ?? "").replace(FORMULA2$1, rule.formula2 ?? "");
1064
1058
  return `${this.titleStr} ${ruleName}`;
1065
1059
  }
1066
1060
  generateRuleErrorMessage(rule, _position) {
1067
- var _rule$formula3, _rule$formula4;
1068
1061
  if (!rule.operator) return this.localeService.t(OperatorErrorTitleMap.NONE).replace(TYPE, this.titleStr);
1069
- return `${this.localeService.t(OperatorErrorTitleMap[rule.operator]).replace(FORMULA1$1, (_rule$formula3 = rule.formula1) !== null && _rule$formula3 !== void 0 ? _rule$formula3 : "").replace(FORMULA2$1, (_rule$formula4 = rule.formula2) !== null && _rule$formula4 !== void 0 ? _rule$formula4 : "")}`;
1062
+ return `${this.localeService.t(OperatorErrorTitleMap[rule.operator]).replace(FORMULA1$1, rule.formula1 ?? "").replace(FORMULA2$1, rule.formula2 ?? "")}`;
1070
1063
  }
1071
1064
  };
1072
1065
 
@@ -1093,7 +1086,7 @@ var CheckboxValidator = class extends BaseSheetValidator {
1093
1086
  _defineProperty(this, "skipDefaultFontRender", (rule, cellValue, pos) => {
1094
1087
  const { unitId, subUnitId } = pos;
1095
1088
  const { formula1, formula2 } = this.parseFormulaSync(rule, unitId, subUnitId);
1096
- const valueStr = `${cellValue !== null && cellValue !== void 0 ? cellValue : ""}`;
1089
+ const valueStr = `${cellValue ?? ""}`;
1097
1090
  return !valueStr || valueStr === `${formula1}` || valueStr === `${formula2}`;
1098
1091
  });
1099
1092
  }
@@ -1151,7 +1144,7 @@ var CheckboxValidator = class extends BaseSheetValidator {
1151
1144
  const { value, unitId, subUnitId } = cellInfo;
1152
1145
  const { formula1, formula2, originFormula1, originFormula2 } = await this.parseFormula(rule, unitId, subUnitId);
1153
1146
  if (!_univerjs_core.Tools.isDefine(formula1) || !_univerjs_core.Tools.isDefine(formula2)) return true;
1154
- return _univerjs_core.Tools.isDefine(value) && (String(value) === String(formula1) || String(value) === String(formula2) || String(value) === String(originFormula1 !== null && originFormula1 !== void 0 ? originFormula1 : "") || String(value) === String(originFormula2 !== null && originFormula2 !== void 0 ? originFormula2 : ""));
1147
+ return _univerjs_core.Tools.isDefine(value) && (String(value) === String(formula1) || String(value) === String(formula2) || String(value) === String(originFormula1 ?? "") || String(value) === String(originFormula2 ?? ""));
1155
1148
  }
1156
1149
  generateRuleErrorMessage(rule) {
1157
1150
  return this.localeService.t("sheets-data-validation.checkbox.error");
@@ -1377,15 +1370,14 @@ var DateValidator = class extends BaseSheetValidator {
1377
1370
  return this.operators.map((operator) => this.localeService.t(DateOperatorNameMap[operator]));
1378
1371
  }
1379
1372
  generateRuleName(rule) {
1380
- var _rule$formula, _rule$formula2;
1381
1373
  if (!rule.operator) return this.localeService.t(DateOperatorTitleMap.NONE);
1382
- const ruleName = this.localeService.t(DateOperatorTitleMap[rule.operator]).replace(FORMULA1, (_rule$formula = rule.formula1) !== null && _rule$formula !== void 0 ? _rule$formula : "").replace(FORMULA2, (_rule$formula2 = rule.formula2) !== null && _rule$formula2 !== void 0 ? _rule$formula2 : "");
1374
+ const ruleName = this.localeService.t(DateOperatorTitleMap[rule.operator]).replace(FORMULA1, rule.formula1 ?? "").replace(FORMULA2, rule.formula2 ?? "");
1383
1375
  return `${this.titleStr} ${ruleName}`;
1384
1376
  }
1385
1377
  generateRuleErrorMessage(rule, pos) {
1386
1378
  if (!rule.operator) return this.titleStr;
1387
1379
  const { transformedFormula1, transformedFormula2 } = getTransformedFormula(this._lexerTreeBuilder, rule, pos);
1388
- return `${this.localeService.t(DateOperatorErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 !== null && transformedFormula1 !== void 0 ? transformedFormula1 : "").replace(FORMULA2, transformedFormula2 !== null && transformedFormula2 !== void 0 ? transformedFormula2 : "")}`;
1380
+ return `${this.localeService.t(DateOperatorErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 ?? "").replace(FORMULA2, transformedFormula2 ?? "")}`;
1389
1381
  }
1390
1382
  };
1391
1383
 
@@ -1463,7 +1455,7 @@ var DecimalValidator = class extends BaseSheetValidator {
1463
1455
  generateRuleErrorMessage(rule, position) {
1464
1456
  if (!rule.operator) return this.localeService.t(OperatorErrorTitleMap.NONE).replace("{TYPE}", this.titleStr);
1465
1457
  const { transformedFormula1, transformedFormula2 } = getTransformedFormula(this._lexerTreeBuilder, rule, position);
1466
- return `${this.localeService.t(OperatorErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 !== null && transformedFormula1 !== void 0 ? transformedFormula1 : "").replace(FORMULA2, transformedFormula2 !== null && transformedFormula2 !== void 0 ? transformedFormula2 : "")}`;
1458
+ return `${this.localeService.t(OperatorErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 ?? "").replace(FORMULA2, transformedFormula2 ?? "")}`;
1467
1459
  }
1468
1460
  };
1469
1461
 
@@ -1529,21 +1521,19 @@ var ListValidator = class extends BaseSheetValidator {
1529
1521
  });
1530
1522
  }
1531
1523
  validatorFormula(rule, unitId, subUnitId) {
1532
- var _rule$formula, _this$_univerInstance;
1524
+ var _this$_univerInstance;
1533
1525
  const success = !_univerjs_core.Tools.isBlank(rule.formula1);
1534
- const valid = isValidListFormula((_rule$formula = rule.formula1) !== null && _rule$formula !== void 0 ? _rule$formula : "", this._lexer);
1535
- const sheetName = (_this$_univerInstance = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 || (_this$_univerInstance = _this$_univerInstance.getSheetBySheetId(subUnitId)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getName();
1536
- const isIntersects = isRuleIntersects(rule, sheetName !== null && sheetName !== void 0 ? sheetName : "");
1526
+ const valid = isValidListFormula(rule.formula1 ?? "", this._lexer);
1527
+ const isIntersects = isRuleIntersects(rule, ((_this$_univerInstance = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 || (_this$_univerInstance = _this$_univerInstance.getSheetBySheetId(subUnitId)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getName()) ?? "");
1537
1528
  return {
1538
1529
  success: Boolean(success && valid && !isIntersects),
1539
1530
  formula1: success ? valid ? !isIntersects ? void 0 : this.localeService.t("sheets-data-validation.validFail.listIntersects") : this.localeService.t("sheets-data-validation.validFail.listInvalid") : this.localeService.t("sheets-data-validation.validFail.list")
1540
1531
  };
1541
1532
  }
1542
1533
  getExtraStyle(rule, value, { style: defaultStyle }) {
1543
- var _ref;
1544
- const tb = (_ref = defaultStyle.tb !== _univerjs_core.WrapStrategy.OVERFLOW ? defaultStyle.tb : _univerjs_core.WrapStrategy.CLIP) !== null && _ref !== void 0 ? _ref : _univerjs_core.WrapStrategy.WRAP;
1534
+ const tb = (defaultStyle.tb !== _univerjs_core.WrapStrategy.OVERFLOW ? defaultStyle.tb : _univerjs_core.WrapStrategy.CLIP) ?? _univerjs_core.WrapStrategy.WRAP;
1545
1535
  if (rule.type === _univerjs_core.DataValidationType.LIST && (rule.renderMode === _univerjs_core.DataValidationRenderMode.ARROW || rule.renderMode === _univerjs_core.DataValidationRenderMode.TEXT)) {
1546
- const color = this.getListWithColorMap(rule)[`${value !== null && value !== void 0 ? value : ""}`];
1536
+ const color = this.getListWithColorMap(rule)[`${value ?? ""}`];
1547
1537
  if (color) return {
1548
1538
  bg: { rgb: color },
1549
1539
  tb
@@ -1577,10 +1567,9 @@ var ListValidator = class extends BaseSheetValidator {
1577
1567
  return this.localeService.t("sheets-data-validation.list.error");
1578
1568
  }
1579
1569
  _getUnitAndSubUnit(currentUnitId, currentSubUnitId) {
1580
- var _ref2, _ref3;
1581
- const workbook = (_ref2 = currentUnitId ? this._univerInstanceService.getUnit(currentUnitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET) : void 0) !== null && _ref2 !== void 0 ? _ref2 : this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
1570
+ const workbook = (currentUnitId ? this._univerInstanceService.getUnit(currentUnitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET) : void 0) ?? this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
1582
1571
  if (!workbook) return null;
1583
- const worksheet = (_ref3 = currentSubUnitId ? workbook.getSheetBySheetId(currentSubUnitId) : void 0) !== null && _ref3 !== void 0 ? _ref3 : workbook.getActiveSheet();
1572
+ const worksheet = (currentSubUnitId ? workbook.getSheetBySheetId(currentSubUnitId) : void 0) ?? workbook.getActiveSheet();
1584
1573
  if (!worksheet) return null;
1585
1574
  return {
1586
1575
  unitId: workbook.getUnitId(),
@@ -1686,17 +1675,17 @@ var TextLengthValidator = class extends BaseSheetValidator {
1686
1675
  generateRuleErrorMessage(rule, pos) {
1687
1676
  if (!rule.operator) return this.titleStr;
1688
1677
  const { transformedFormula1, transformedFormula2 } = getTransformedFormula(this._lexerTreeBuilder, rule, pos);
1689
- return `${this.localeService.t(TextLengthErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 !== null && transformedFormula1 !== void 0 ? transformedFormula1 : "").replace(FORMULA2, transformedFormula2 !== null && transformedFormula2 !== void 0 ? transformedFormula2 : "")}`;
1678
+ return `${this.localeService.t(TextLengthErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 ?? "").replace(FORMULA2, transformedFormula2 ?? "")}`;
1690
1679
  }
1691
1680
  };
1692
1681
 
1693
1682
  //#endregion
1694
1683
  //#region src/commands/commands/data-validation.command.ts
1695
1684
  function isBlankCell(cellData) {
1696
- var _cellData$p$body$data, _cellData$p$body;
1685
+ var _cellData$p$body;
1697
1686
  if (!cellData) return true;
1698
1687
  if (!cellData.p) return _univerjs_core.Tools.isBlank(cellData.v);
1699
- return !((_cellData$p$body$data = (_cellData$p$body = cellData.p.body) === null || _cellData$p$body === void 0 ? void 0 : _cellData$p$body.dataStream) !== null && _cellData$p$body$data !== void 0 ? _cellData$p$body$data : "").slice(0, -2).trim();
1688
+ return !(((_cellData$p$body = cellData.p.body) === null || _cellData$p$body === void 0 ? void 0 : _cellData$p$body.dataStream) ?? "").slice(0, -2).trim();
1700
1689
  }
1701
1690
  function getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor, source = "command", fillDefaultValue = true) {
1702
1691
  const lexerTreeBuilder = accessor.get(_univerjs_engine_formula.LexerTreeBuilder);
@@ -2311,7 +2300,7 @@ DataValidationFormulaController = __decorate([
2311
2300
  //#endregion
2312
2301
  //#region package.json
2313
2302
  var name = "@univerjs/sheets-data-validation";
2314
- var version = "1.0.0-alpha.8";
2303
+ var version = "1.0.0-beta.0";
2315
2304
 
2316
2305
  //#endregion
2317
2306
  //#region src/config/config.ts
@@ -2356,7 +2345,7 @@ let DataValidationFormulaRefRangeController = class DataValidationFormulaRefRang
2356
2345
  const oldRanges = rule.ranges;
2357
2346
  const oldFormula1 = rule.formula1;
2358
2347
  const oldFormula2 = rule.formula2;
2359
- const disposable = this._formulaRefRangeService.registerRangeFormula(unitId, subUnitId, oldRanges, [oldFormula1 !== null && oldFormula1 !== void 0 ? oldFormula1 : "", oldFormula2 !== null && oldFormula2 !== void 0 ? oldFormula2 : ""], (res) => {
2348
+ const disposable = this._formulaRefRangeService.registerRangeFormula(unitId, subUnitId, oldRanges, [oldFormula1 ?? "", oldFormula2 ?? ""], (res) => {
2360
2349
  if (res.length === 0) return {
2361
2350
  undos: [{
2362
2351
  id: _univerjs_data_validation.AddDataValidationMutation.id,
@@ -2512,10 +2501,9 @@ let DataValidationRefRangeController = class DataValidationRefRangeController ex
2512
2501
  return `${unitID}_${subUnitId}_${ruleId}`;
2513
2502
  }
2514
2503
  registerFormula(unitId, subUnitId, rule) {
2515
- var _this$_disposableMap$;
2516
2504
  const ruleId = rule.uid;
2517
2505
  const id = this._getIdWithUnitId(unitId, subUnitId, ruleId);
2518
- const disposeSet = (_this$_disposableMap$ = this._disposableMap.get(id)) !== null && _this$_disposableMap$ !== void 0 ? _this$_disposableMap$ : /* @__PURE__ */ new Set();
2506
+ const disposeSet = this._disposableMap.get(id) ?? /* @__PURE__ */ new Set();
2519
2507
  const handleFormulaChange = (type, formulaString) => {
2520
2508
  const oldRule = this._dataValidationModel.getRuleById(unitId, subUnitId, ruleId);
2521
2509
  if (!oldRule) return {
@@ -2581,7 +2569,6 @@ let DataValidationRefRangeController = class DataValidationRefRangeController ex
2581
2569
  }
2582
2570
  }
2583
2571
  register(unitId, subUnitId, rule) {
2584
- var _this$_disposableMap$2;
2585
2572
  const handleRangeChange = (commandInfo) => {
2586
2573
  const oldRanges = [...rule.ranges];
2587
2574
  const resultRanges = oldRanges.map((range) => {
@@ -2642,7 +2629,7 @@ let DataValidationRefRangeController = class DataValidationRefRangeController ex
2642
2629
  disposeList.push(() => disposable.dispose());
2643
2630
  });
2644
2631
  const id = this._getIdWithUnitId(unitId, subUnitId, rule.uid);
2645
- const current = (_this$_disposableMap$2 = this._disposableMap.get(id)) !== null && _this$_disposableMap$2 !== void 0 ? _this$_disposableMap$2 : /* @__PURE__ */ new Set();
2632
+ const current = this._disposableMap.get(id) ?? /* @__PURE__ */ new Set();
2646
2633
  current.add(() => disposeList.forEach((dispose) => dispose()));
2647
2634
  this._disposableMap.set(id, current);
2648
2635
  }
@@ -2836,9 +2823,8 @@ var CustomFormulaValidator = class extends BaseSheetValidator {
2836
2823
  _defineProperty(this, "_lexerTreeBuilder", this.injector.get(_univerjs_engine_formula.LexerTreeBuilder));
2837
2824
  }
2838
2825
  validatorFormula(rule, unitId, subUnitId) {
2839
- var _rule$formula;
2840
2826
  const success = (0, _univerjs_core.isFormulaString)(rule.formula1);
2841
- const formulaText = (_rule$formula = rule.formula1) !== null && _rule$formula !== void 0 ? _rule$formula : "";
2827
+ const formulaText = rule.formula1 ?? "";
2842
2828
  const valid = this._lexerTreeBuilder.checkIfAddBracket(formulaText) === 0 && formulaText.startsWith(_univerjs_engine_formula.operatorToken.EQUALS);
2843
2829
  return {
2844
2830
  success: success && valid,
@@ -2870,8 +2856,7 @@ var CustomFormulaValidator = class extends BaseSheetValidator {
2870
2856
  return this.localeService.t("sheets-data-validation.custom.error");
2871
2857
  }
2872
2858
  generateRuleName(rule) {
2873
- var _rule$formula2;
2874
- return this.localeService.t("sheets-data-validation.custom.ruleName").replace("{FORMULA1}", (_rule$formula2 = rule.formula1) !== null && _rule$formula2 !== void 0 ? _rule$formula2 : "");
2859
+ return this.localeService.t("sheets-data-validation.custom.ruleName").replace("{FORMULA1}", rule.formula1 ?? "");
2875
2860
  }
2876
2861
  };
2877
2862
 
@@ -2978,7 +2963,7 @@ var WholeValidator = class extends BaseSheetValidator {
2978
2963
  generateRuleErrorMessage(rule, position) {
2979
2964
  if (!rule.operator) return this.localeService.t(OperatorErrorTitleMap.NONE).replace("{TYPE}", this.titleStr);
2980
2965
  const { transformedFormula1, transformedFormula2 } = getTransformedFormula(this._lexerTreeBuilder, rule, position);
2981
- return `${this.localeService.t(OperatorErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 !== null && transformedFormula1 !== void 0 ? transformedFormula1 : "").replace(FORMULA2, transformedFormula2 !== null && transformedFormula2 !== void 0 ? transformedFormula2 : "")}`;
2966
+ return `${this.localeService.t(OperatorErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 ?? "").replace(FORMULA2, transformedFormula2 ?? "")}`;
2982
2967
  }
2983
2968
  };
2984
2969
 
@@ -3154,10 +3139,7 @@ let SheetsDataValidationValidatorService = class SheetsDataValidationValidatorSe
3154
3139
  * Because during the validation process, merged cells are all marked as VALIDATING status in cache.
3155
3140
  */
3156
3141
  if (mergeCells.length) mergeCells.forEach(({ resultRowIndex, resultColIndex, row, col }) => {
3157
- if (result[resultRowIndex][resultColIndex] === _univerjs_core.DataValidationStatus.VALIDATING) {
3158
- var _this$_dataValidation;
3159
- result[resultRowIndex][resultColIndex] = (_this$_dataValidation = this._dataValidationCacheService.getValue(unitId, subUnitId, row, col)) !== null && _this$_dataValidation !== void 0 ? _this$_dataValidation : _univerjs_core.DataValidationStatus.VALID;
3160
- }
3142
+ if (result[resultRowIndex][resultColIndex] === _univerjs_core.DataValidationStatus.VALIDATING) result[resultRowIndex][resultColIndex] = this._dataValidationCacheService.getValue(unitId, subUnitId, row, col) ?? _univerjs_core.DataValidationStatus.VALID;
3161
3143
  });
3162
3144
  return result;
3163
3145
  }
@@ -3286,7 +3268,7 @@ function createDefaultNewRule(accessor) {
3286
3268
  type: _univerjs_core.DataValidationType.DECIMAL,
3287
3269
  operator: _univerjs_core.DataValidationOperator.EQUAL,
3288
3270
  formula1: "100",
3289
- ranges: currentRanges !== null && currentRanges !== void 0 ? currentRanges : [{
3271
+ ranges: currentRanges ?? [{
3290
3272
  startColumn: 0,
3291
3273
  endColumn: 0,
3292
3274
  startRow: 0,
package/lib/es/facade.js CHANGED
@@ -79,7 +79,7 @@ function _defineProperty(e, r, t) {
79
79
  var FDataValidationBuilder = class FDataValidationBuilder {
80
80
  constructor(rule) {
81
81
  _defineProperty(this, "_rule", void 0);
82
- this._rule = rule !== null && rule !== void 0 ? rule : {
82
+ this._rule = rule ?? {
83
83
  uid: generateRandomId(),
84
84
  ranges: void 0,
85
85
  type: DataValidationType.CUSTOM
@@ -812,7 +812,7 @@ var FDataValidationBuilder = class FDataValidationBuilder {
812
812
  this._rule.type = multiple ? DataValidationType.LIST_MULTIPLE : DataValidationType.LIST;
813
813
  this._rule.formula1 = serializeListOptions(values);
814
814
  this._rule.formula2 = void 0;
815
- this._rule.showDropDown = showDropdown !== null && showDropdown !== void 0 ? showDropdown : true;
815
+ this._rule.showDropDown = showDropdown ?? true;
816
816
  return this;
817
817
  }
818
818
  /**
@@ -856,7 +856,7 @@ var FDataValidationBuilder = class FDataValidationBuilder {
856
856
  range: range.getRange()
857
857
  })}`;
858
858
  this._rule.formula2 = void 0;
859
- this._rule.showDropDown = showDropdown !== null && showDropdown !== void 0 ? showDropdown : true;
859
+ this._rule.showDropDown = showDropdown ?? true;
860
860
  return this;
861
861
  }
862
862
  /**
package/lib/es/index.js CHANGED
@@ -186,9 +186,8 @@ function isLegalFormulaResult(res) {
186
186
  * Judge if the data-validation's formula need to be offseted by ranges
187
187
  */
188
188
  function shouldOffsetFormulaByRange(type, validatorRegistryService) {
189
- var _validator$offsetForm;
190
189
  const validator = validatorRegistryService.getValidatorItem(type);
191
- return (_validator$offsetForm = validator === null || validator === void 0 ? void 0 : validator.offsetFormulaByRange) !== null && _validator$offsetForm !== void 0 ? _validator$offsetForm : false;
190
+ return (validator === null || validator === void 0 ? void 0 : validator.offsetFormulaByRange) ?? false;
192
191
  }
193
192
 
194
193
  //#endregion
@@ -384,8 +383,7 @@ function getCellValueOrigin(cell) {
384
383
  return getOriginCellValue(cell);
385
384
  }
386
385
  function getStringCellValue(cell) {
387
- var _getCellValueOrigin;
388
- return String((_getCellValueOrigin = getCellValueOrigin(cell)) !== null && _getCellValueOrigin !== void 0 ? _getCellValueOrigin : "");
386
+ return String(getCellValueOrigin(cell) ?? "");
389
387
  }
390
388
 
391
389
  //#endregion
@@ -714,8 +712,7 @@ var RuleMatrix = class RuleMatrix {
714
712
  const mutations = [];
715
713
  let deleteIndex = 0;
716
714
  rules.forEach((rule, index) => {
717
- var _this$_map$get;
718
- const newRanges = (_this$_map$get = this._map.get(rule.uid)) !== null && _this$_map$get !== void 0 ? _this$_map$get : [];
715
+ const newRanges = this._map.get(rule.uid) ?? [];
719
716
  const oldRanges = rule.ranges;
720
717
  if (newRanges.length !== 0 && (newRanges.length !== oldRanges.length || newRanges.some((range, i) => !Rectangle.equals(range, oldRanges[i])))) mutations.push({
721
718
  type: "update",
@@ -739,8 +736,7 @@ var RuleMatrix = class RuleMatrix {
739
736
  const mutations = [];
740
737
  let deleteIndex = 0;
741
738
  rules.forEach((rule, index) => {
742
- var _this$_map$get2;
743
- const newRanges = (_this$_map$get2 = this._map.get(rule.uid)) !== null && _this$_map$get2 !== void 0 ? _this$_map$get2 : [];
739
+ const newRanges = this._map.get(rule.uid) ?? [];
744
740
  const oldRanges = rule.ranges;
745
741
  if (newRanges.length !== 0 && (newRanges.length !== oldRanges.length || newRanges.some((range, i) => !Rectangle.equals(range, oldRanges[i])))) mutations.push({
746
742
  type: "update",
@@ -759,8 +755,7 @@ var RuleMatrix = class RuleMatrix {
759
755
  }
760
756
  });
761
757
  Array.from(additionRules).forEach((rule) => {
762
- var _this$_map$get3;
763
- const newRanges = (_this$_map$get3 = this._map.get(rule.uid)) !== null && _this$_map$get3 !== void 0 ? _this$_map$get3 : [];
758
+ const newRanges = this._map.get(rule.uid) ?? [];
764
759
  mutations.push({
765
760
  type: "add",
766
761
  rule: {
@@ -945,8 +940,8 @@ let SheetDataValidationModel = class SheetDataValidationModel extends Disposable
945
940
  });
946
941
  return DataValidationStatus.VALIDATING;
947
942
  }
948
- onCompete(current !== null && current !== void 0 ? current : DataValidationStatus.VALID, false);
949
- return current !== null && current !== void 0 ? current : DataValidationStatus.VALID;
943
+ onCompete(current ?? DataValidationStatus.VALID, false);
944
+ return current ?? DataValidationStatus.VALID;
950
945
  } else {
951
946
  onCompete(DataValidationStatus.VALID, false);
952
947
  return DataValidationStatus.VALID;
@@ -1057,15 +1052,13 @@ var BaseSheetValidator = class extends BaseDataValidator {
1057
1052
  return this.operators.map((operator) => this.localeService.t(OperatorTextMap[operator]));
1058
1053
  }
1059
1054
  generateRuleName(rule) {
1060
- var _rule$formula, _rule$formula2;
1061
1055
  if (!rule.operator) return this.localeService.t(OperatorTitleMap.NONE).replace(TYPE, this.titleStr);
1062
- const ruleName = this.localeService.t(OperatorTitleMap[rule.operator]).replace(FORMULA1$1, (_rule$formula = rule.formula1) !== null && _rule$formula !== void 0 ? _rule$formula : "").replace(FORMULA2$1, (_rule$formula2 = rule.formula2) !== null && _rule$formula2 !== void 0 ? _rule$formula2 : "");
1056
+ const ruleName = this.localeService.t(OperatorTitleMap[rule.operator]).replace(FORMULA1$1, rule.formula1 ?? "").replace(FORMULA2$1, rule.formula2 ?? "");
1063
1057
  return `${this.titleStr} ${ruleName}`;
1064
1058
  }
1065
1059
  generateRuleErrorMessage(rule, _position) {
1066
- var _rule$formula3, _rule$formula4;
1067
1060
  if (!rule.operator) return this.localeService.t(OperatorErrorTitleMap.NONE).replace(TYPE, this.titleStr);
1068
- return `${this.localeService.t(OperatorErrorTitleMap[rule.operator]).replace(FORMULA1$1, (_rule$formula3 = rule.formula1) !== null && _rule$formula3 !== void 0 ? _rule$formula3 : "").replace(FORMULA2$1, (_rule$formula4 = rule.formula2) !== null && _rule$formula4 !== void 0 ? _rule$formula4 : "")}`;
1061
+ return `${this.localeService.t(OperatorErrorTitleMap[rule.operator]).replace(FORMULA1$1, rule.formula1 ?? "").replace(FORMULA2$1, rule.formula2 ?? "")}`;
1069
1062
  }
1070
1063
  };
1071
1064
 
@@ -1092,7 +1085,7 @@ var CheckboxValidator = class extends BaseSheetValidator {
1092
1085
  _defineProperty(this, "skipDefaultFontRender", (rule, cellValue, pos) => {
1093
1086
  const { unitId, subUnitId } = pos;
1094
1087
  const { formula1, formula2 } = this.parseFormulaSync(rule, unitId, subUnitId);
1095
- const valueStr = `${cellValue !== null && cellValue !== void 0 ? cellValue : ""}`;
1088
+ const valueStr = `${cellValue ?? ""}`;
1096
1089
  return !valueStr || valueStr === `${formula1}` || valueStr === `${formula2}`;
1097
1090
  });
1098
1091
  }
@@ -1150,7 +1143,7 @@ var CheckboxValidator = class extends BaseSheetValidator {
1150
1143
  const { value, unitId, subUnitId } = cellInfo;
1151
1144
  const { formula1, formula2, originFormula1, originFormula2 } = await this.parseFormula(rule, unitId, subUnitId);
1152
1145
  if (!Tools.isDefine(formula1) || !Tools.isDefine(formula2)) return true;
1153
- return Tools.isDefine(value) && (String(value) === String(formula1) || String(value) === String(formula2) || String(value) === String(originFormula1 !== null && originFormula1 !== void 0 ? originFormula1 : "") || String(value) === String(originFormula2 !== null && originFormula2 !== void 0 ? originFormula2 : ""));
1146
+ return Tools.isDefine(value) && (String(value) === String(formula1) || String(value) === String(formula2) || String(value) === String(originFormula1 ?? "") || String(value) === String(originFormula2 ?? ""));
1154
1147
  }
1155
1148
  generateRuleErrorMessage(rule) {
1156
1149
  return this.localeService.t("sheets-data-validation.checkbox.error");
@@ -1376,15 +1369,14 @@ var DateValidator = class extends BaseSheetValidator {
1376
1369
  return this.operators.map((operator) => this.localeService.t(DateOperatorNameMap[operator]));
1377
1370
  }
1378
1371
  generateRuleName(rule) {
1379
- var _rule$formula, _rule$formula2;
1380
1372
  if (!rule.operator) return this.localeService.t(DateOperatorTitleMap.NONE);
1381
- const ruleName = this.localeService.t(DateOperatorTitleMap[rule.operator]).replace(FORMULA1, (_rule$formula = rule.formula1) !== null && _rule$formula !== void 0 ? _rule$formula : "").replace(FORMULA2, (_rule$formula2 = rule.formula2) !== null && _rule$formula2 !== void 0 ? _rule$formula2 : "");
1373
+ const ruleName = this.localeService.t(DateOperatorTitleMap[rule.operator]).replace(FORMULA1, rule.formula1 ?? "").replace(FORMULA2, rule.formula2 ?? "");
1382
1374
  return `${this.titleStr} ${ruleName}`;
1383
1375
  }
1384
1376
  generateRuleErrorMessage(rule, pos) {
1385
1377
  if (!rule.operator) return this.titleStr;
1386
1378
  const { transformedFormula1, transformedFormula2 } = getTransformedFormula(this._lexerTreeBuilder, rule, pos);
1387
- return `${this.localeService.t(DateOperatorErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 !== null && transformedFormula1 !== void 0 ? transformedFormula1 : "").replace(FORMULA2, transformedFormula2 !== null && transformedFormula2 !== void 0 ? transformedFormula2 : "")}`;
1379
+ return `${this.localeService.t(DateOperatorErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 ?? "").replace(FORMULA2, transformedFormula2 ?? "")}`;
1388
1380
  }
1389
1381
  };
1390
1382
 
@@ -1462,7 +1454,7 @@ var DecimalValidator = class extends BaseSheetValidator {
1462
1454
  generateRuleErrorMessage(rule, position) {
1463
1455
  if (!rule.operator) return this.localeService.t(OperatorErrorTitleMap.NONE).replace("{TYPE}", this.titleStr);
1464
1456
  const { transformedFormula1, transformedFormula2 } = getTransformedFormula(this._lexerTreeBuilder, rule, position);
1465
- return `${this.localeService.t(OperatorErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 !== null && transformedFormula1 !== void 0 ? transformedFormula1 : "").replace(FORMULA2, transformedFormula2 !== null && transformedFormula2 !== void 0 ? transformedFormula2 : "")}`;
1457
+ return `${this.localeService.t(OperatorErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 ?? "").replace(FORMULA2, transformedFormula2 ?? "")}`;
1466
1458
  }
1467
1459
  };
1468
1460
 
@@ -1528,21 +1520,19 @@ var ListValidator = class extends BaseSheetValidator {
1528
1520
  });
1529
1521
  }
1530
1522
  validatorFormula(rule, unitId, subUnitId) {
1531
- var _rule$formula, _this$_univerInstance;
1523
+ var _this$_univerInstance;
1532
1524
  const success = !Tools.isBlank(rule.formula1);
1533
- const valid = isValidListFormula((_rule$formula = rule.formula1) !== null && _rule$formula !== void 0 ? _rule$formula : "", this._lexer);
1534
- const sheetName = (_this$_univerInstance = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 || (_this$_univerInstance = _this$_univerInstance.getSheetBySheetId(subUnitId)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getName();
1535
- const isIntersects = isRuleIntersects(rule, sheetName !== null && sheetName !== void 0 ? sheetName : "");
1525
+ const valid = isValidListFormula(rule.formula1 ?? "", this._lexer);
1526
+ const isIntersects = isRuleIntersects(rule, ((_this$_univerInstance = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 || (_this$_univerInstance = _this$_univerInstance.getSheetBySheetId(subUnitId)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getName()) ?? "");
1536
1527
  return {
1537
1528
  success: Boolean(success && valid && !isIntersects),
1538
1529
  formula1: success ? valid ? !isIntersects ? void 0 : this.localeService.t("sheets-data-validation.validFail.listIntersects") : this.localeService.t("sheets-data-validation.validFail.listInvalid") : this.localeService.t("sheets-data-validation.validFail.list")
1539
1530
  };
1540
1531
  }
1541
1532
  getExtraStyle(rule, value, { style: defaultStyle }) {
1542
- var _ref;
1543
- const tb = (_ref = defaultStyle.tb !== WrapStrategy.OVERFLOW ? defaultStyle.tb : WrapStrategy.CLIP) !== null && _ref !== void 0 ? _ref : WrapStrategy.WRAP;
1533
+ const tb = (defaultStyle.tb !== WrapStrategy.OVERFLOW ? defaultStyle.tb : WrapStrategy.CLIP) ?? WrapStrategy.WRAP;
1544
1534
  if (rule.type === DataValidationType.LIST && (rule.renderMode === DataValidationRenderMode.ARROW || rule.renderMode === DataValidationRenderMode.TEXT)) {
1545
- const color = this.getListWithColorMap(rule)[`${value !== null && value !== void 0 ? value : ""}`];
1535
+ const color = this.getListWithColorMap(rule)[`${value ?? ""}`];
1546
1536
  if (color) return {
1547
1537
  bg: { rgb: color },
1548
1538
  tb
@@ -1576,10 +1566,9 @@ var ListValidator = class extends BaseSheetValidator {
1576
1566
  return this.localeService.t("sheets-data-validation.list.error");
1577
1567
  }
1578
1568
  _getUnitAndSubUnit(currentUnitId, currentSubUnitId) {
1579
- var _ref2, _ref3;
1580
- const workbook = (_ref2 = currentUnitId ? this._univerInstanceService.getUnit(currentUnitId, UniverInstanceType.UNIVER_SHEET) : void 0) !== null && _ref2 !== void 0 ? _ref2 : this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
1569
+ const workbook = (currentUnitId ? this._univerInstanceService.getUnit(currentUnitId, UniverInstanceType.UNIVER_SHEET) : void 0) ?? this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
1581
1570
  if (!workbook) return null;
1582
- const worksheet = (_ref3 = currentSubUnitId ? workbook.getSheetBySheetId(currentSubUnitId) : void 0) !== null && _ref3 !== void 0 ? _ref3 : workbook.getActiveSheet();
1571
+ const worksheet = (currentSubUnitId ? workbook.getSheetBySheetId(currentSubUnitId) : void 0) ?? workbook.getActiveSheet();
1583
1572
  if (!worksheet) return null;
1584
1573
  return {
1585
1574
  unitId: workbook.getUnitId(),
@@ -1685,17 +1674,17 @@ var TextLengthValidator = class extends BaseSheetValidator {
1685
1674
  generateRuleErrorMessage(rule, pos) {
1686
1675
  if (!rule.operator) return this.titleStr;
1687
1676
  const { transformedFormula1, transformedFormula2 } = getTransformedFormula(this._lexerTreeBuilder, rule, pos);
1688
- return `${this.localeService.t(TextLengthErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 !== null && transformedFormula1 !== void 0 ? transformedFormula1 : "").replace(FORMULA2, transformedFormula2 !== null && transformedFormula2 !== void 0 ? transformedFormula2 : "")}`;
1677
+ return `${this.localeService.t(TextLengthErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 ?? "").replace(FORMULA2, transformedFormula2 ?? "")}`;
1689
1678
  }
1690
1679
  };
1691
1680
 
1692
1681
  //#endregion
1693
1682
  //#region src/commands/commands/data-validation.command.ts
1694
1683
  function isBlankCell(cellData) {
1695
- var _cellData$p$body$data, _cellData$p$body;
1684
+ var _cellData$p$body;
1696
1685
  if (!cellData) return true;
1697
1686
  if (!cellData.p) return Tools.isBlank(cellData.v);
1698
- return !((_cellData$p$body$data = (_cellData$p$body = cellData.p.body) === null || _cellData$p$body === void 0 ? void 0 : _cellData$p$body.dataStream) !== null && _cellData$p$body$data !== void 0 ? _cellData$p$body$data : "").slice(0, -2).trim();
1687
+ return !(((_cellData$p$body = cellData.p.body) === null || _cellData$p$body === void 0 ? void 0 : _cellData$p$body.dataStream) ?? "").slice(0, -2).trim();
1699
1688
  }
1700
1689
  function getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor, source = "command", fillDefaultValue = true) {
1701
1690
  const lexerTreeBuilder = accessor.get(LexerTreeBuilder);
@@ -2310,7 +2299,7 @@ DataValidationFormulaController = __decorate([
2310
2299
  //#endregion
2311
2300
  //#region package.json
2312
2301
  var name = "@univerjs/sheets-data-validation";
2313
- var version = "1.0.0-alpha.8";
2302
+ var version = "1.0.0-beta.0";
2314
2303
 
2315
2304
  //#endregion
2316
2305
  //#region src/config/config.ts
@@ -2355,7 +2344,7 @@ let DataValidationFormulaRefRangeController = class DataValidationFormulaRefRang
2355
2344
  const oldRanges = rule.ranges;
2356
2345
  const oldFormula1 = rule.formula1;
2357
2346
  const oldFormula2 = rule.formula2;
2358
- const disposable = this._formulaRefRangeService.registerRangeFormula(unitId, subUnitId, oldRanges, [oldFormula1 !== null && oldFormula1 !== void 0 ? oldFormula1 : "", oldFormula2 !== null && oldFormula2 !== void 0 ? oldFormula2 : ""], (res) => {
2347
+ const disposable = this._formulaRefRangeService.registerRangeFormula(unitId, subUnitId, oldRanges, [oldFormula1 ?? "", oldFormula2 ?? ""], (res) => {
2359
2348
  if (res.length === 0) return {
2360
2349
  undos: [{
2361
2350
  id: AddDataValidationMutation.id,
@@ -2511,10 +2500,9 @@ let DataValidationRefRangeController = class DataValidationRefRangeController ex
2511
2500
  return `${unitID}_${subUnitId}_${ruleId}`;
2512
2501
  }
2513
2502
  registerFormula(unitId, subUnitId, rule) {
2514
- var _this$_disposableMap$;
2515
2503
  const ruleId = rule.uid;
2516
2504
  const id = this._getIdWithUnitId(unitId, subUnitId, ruleId);
2517
- const disposeSet = (_this$_disposableMap$ = this._disposableMap.get(id)) !== null && _this$_disposableMap$ !== void 0 ? _this$_disposableMap$ : /* @__PURE__ */ new Set();
2505
+ const disposeSet = this._disposableMap.get(id) ?? /* @__PURE__ */ new Set();
2518
2506
  const handleFormulaChange = (type, formulaString) => {
2519
2507
  const oldRule = this._dataValidationModel.getRuleById(unitId, subUnitId, ruleId);
2520
2508
  if (!oldRule) return {
@@ -2580,7 +2568,6 @@ let DataValidationRefRangeController = class DataValidationRefRangeController ex
2580
2568
  }
2581
2569
  }
2582
2570
  register(unitId, subUnitId, rule) {
2583
- var _this$_disposableMap$2;
2584
2571
  const handleRangeChange = (commandInfo) => {
2585
2572
  const oldRanges = [...rule.ranges];
2586
2573
  const resultRanges = oldRanges.map((range) => {
@@ -2641,7 +2628,7 @@ let DataValidationRefRangeController = class DataValidationRefRangeController ex
2641
2628
  disposeList.push(() => disposable.dispose());
2642
2629
  });
2643
2630
  const id = this._getIdWithUnitId(unitId, subUnitId, rule.uid);
2644
- const current = (_this$_disposableMap$2 = this._disposableMap.get(id)) !== null && _this$_disposableMap$2 !== void 0 ? _this$_disposableMap$2 : /* @__PURE__ */ new Set();
2631
+ const current = this._disposableMap.get(id) ?? /* @__PURE__ */ new Set();
2645
2632
  current.add(() => disposeList.forEach((dispose) => dispose()));
2646
2633
  this._disposableMap.set(id, current);
2647
2634
  }
@@ -2835,9 +2822,8 @@ var CustomFormulaValidator = class extends BaseSheetValidator {
2835
2822
  _defineProperty(this, "_lexerTreeBuilder", this.injector.get(LexerTreeBuilder));
2836
2823
  }
2837
2824
  validatorFormula(rule, unitId, subUnitId) {
2838
- var _rule$formula;
2839
2825
  const success = isFormulaString(rule.formula1);
2840
- const formulaText = (_rule$formula = rule.formula1) !== null && _rule$formula !== void 0 ? _rule$formula : "";
2826
+ const formulaText = rule.formula1 ?? "";
2841
2827
  const valid = this._lexerTreeBuilder.checkIfAddBracket(formulaText) === 0 && formulaText.startsWith(operatorToken.EQUALS);
2842
2828
  return {
2843
2829
  success: success && valid,
@@ -2869,8 +2855,7 @@ var CustomFormulaValidator = class extends BaseSheetValidator {
2869
2855
  return this.localeService.t("sheets-data-validation.custom.error");
2870
2856
  }
2871
2857
  generateRuleName(rule) {
2872
- var _rule$formula2;
2873
- return this.localeService.t("sheets-data-validation.custom.ruleName").replace("{FORMULA1}", (_rule$formula2 = rule.formula1) !== null && _rule$formula2 !== void 0 ? _rule$formula2 : "");
2858
+ return this.localeService.t("sheets-data-validation.custom.ruleName").replace("{FORMULA1}", rule.formula1 ?? "");
2874
2859
  }
2875
2860
  };
2876
2861
 
@@ -2977,7 +2962,7 @@ var WholeValidator = class extends BaseSheetValidator {
2977
2962
  generateRuleErrorMessage(rule, position) {
2978
2963
  if (!rule.operator) return this.localeService.t(OperatorErrorTitleMap.NONE).replace("{TYPE}", this.titleStr);
2979
2964
  const { transformedFormula1, transformedFormula2 } = getTransformedFormula(this._lexerTreeBuilder, rule, position);
2980
- return `${this.localeService.t(OperatorErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 !== null && transformedFormula1 !== void 0 ? transformedFormula1 : "").replace(FORMULA2, transformedFormula2 !== null && transformedFormula2 !== void 0 ? transformedFormula2 : "")}`;
2965
+ return `${this.localeService.t(OperatorErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 ?? "").replace(FORMULA2, transformedFormula2 ?? "")}`;
2981
2966
  }
2982
2967
  };
2983
2968
 
@@ -3153,10 +3138,7 @@ let SheetsDataValidationValidatorService = class SheetsDataValidationValidatorSe
3153
3138
  * Because during the validation process, merged cells are all marked as VALIDATING status in cache.
3154
3139
  */
3155
3140
  if (mergeCells.length) mergeCells.forEach(({ resultRowIndex, resultColIndex, row, col }) => {
3156
- if (result[resultRowIndex][resultColIndex] === DataValidationStatus.VALIDATING) {
3157
- var _this$_dataValidation;
3158
- result[resultRowIndex][resultColIndex] = (_this$_dataValidation = this._dataValidationCacheService.getValue(unitId, subUnitId, row, col)) !== null && _this$_dataValidation !== void 0 ? _this$_dataValidation : DataValidationStatus.VALID;
3159
- }
3141
+ if (result[resultRowIndex][resultColIndex] === DataValidationStatus.VALIDATING) result[resultRowIndex][resultColIndex] = this._dataValidationCacheService.getValue(unitId, subUnitId, row, col) ?? DataValidationStatus.VALID;
3160
3142
  });
3161
3143
  return result;
3162
3144
  }
@@ -3285,7 +3267,7 @@ function createDefaultNewRule(accessor) {
3285
3267
  type: DataValidationType.DECIMAL,
3286
3268
  operator: DataValidationOperator.EQUAL,
3287
3269
  formula1: "100",
3288
- ranges: currentRanges !== null && currentRanges !== void 0 ? currentRanges : [{
3270
+ ranges: currentRanges ?? [{
3289
3271
  startColumn: 0,
3290
3272
  endColumn: 0,
3291
3273
  startRow: 0,