@univerjs/sheets-data-validation 1.0.0-alpha.8 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/lib/cjs/facade.js +3 -3
  2. package/lib/cjs/index.js +33 -51
  3. package/lib/cjs/locale/ar-SA.js +5 -25
  4. package/lib/cjs/locale/ca-ES.js +5 -25
  5. package/lib/cjs/locale/de-DE.js +5 -25
  6. package/lib/cjs/locale/en-US.js +5 -25
  7. package/lib/cjs/locale/es-ES.js +5 -25
  8. package/lib/cjs/locale/fa-IR.js +5 -25
  9. package/lib/cjs/locale/fr-FR.js +5 -25
  10. package/lib/cjs/locale/id-ID.js +5 -25
  11. package/lib/cjs/locale/it-IT.js +5 -25
  12. package/lib/cjs/locale/ja-JP.js +5 -25
  13. package/lib/cjs/locale/ko-KR.js +5 -25
  14. package/lib/cjs/locale/pl-PL.js +5 -25
  15. package/lib/cjs/locale/pt-BR.js +5 -25
  16. package/lib/cjs/locale/ru-RU.js +5 -25
  17. package/lib/cjs/locale/sk-SK.js +5 -25
  18. package/lib/cjs/locale/vi-VN.js +5 -25
  19. package/lib/cjs/locale/zh-CN.js +5 -25
  20. package/lib/cjs/locale/zh-HK.js +5 -25
  21. package/lib/cjs/locale/zh-TW.js +5 -25
  22. package/lib/es/facade.js +3 -3
  23. package/lib/es/index.js +33 -51
  24. package/lib/es/locale/ar-SA.js +5 -25
  25. package/lib/es/locale/ca-ES.js +5 -25
  26. package/lib/es/locale/de-DE.js +5 -25
  27. package/lib/es/locale/en-US.js +5 -25
  28. package/lib/es/locale/es-ES.js +5 -25
  29. package/lib/es/locale/fa-IR.js +5 -25
  30. package/lib/es/locale/fr-FR.js +5 -25
  31. package/lib/es/locale/id-ID.js +5 -25
  32. package/lib/es/locale/it-IT.js +5 -25
  33. package/lib/es/locale/ja-JP.js +5 -25
  34. package/lib/es/locale/ko-KR.js +5 -25
  35. package/lib/es/locale/pl-PL.js +5 -25
  36. package/lib/es/locale/pt-BR.js +5 -25
  37. package/lib/es/locale/ru-RU.js +5 -25
  38. package/lib/es/locale/sk-SK.js +5 -25
  39. package/lib/es/locale/vi-VN.js +5 -25
  40. package/lib/es/locale/zh-CN.js +5 -25
  41. package/lib/es/locale/zh-HK.js +5 -25
  42. package/lib/es/locale/zh-TW.js +5 -25
  43. package/lib/facade.js +3 -3
  44. package/lib/index.js +33 -51
  45. package/lib/locale/ar-SA.js +5 -25
  46. package/lib/locale/ca-ES.js +5 -25
  47. package/lib/locale/de-DE.js +5 -25
  48. package/lib/locale/en-US.js +5 -25
  49. package/lib/locale/es-ES.js +5 -25
  50. package/lib/locale/fa-IR.js +5 -25
  51. package/lib/locale/fr-FR.js +5 -25
  52. package/lib/locale/id-ID.js +5 -25
  53. package/lib/locale/it-IT.js +5 -25
  54. package/lib/locale/ja-JP.js +5 -25
  55. package/lib/locale/ko-KR.js +5 -25
  56. package/lib/locale/pl-PL.js +5 -25
  57. package/lib/locale/pt-BR.js +5 -25
  58. package/lib/locale/ru-RU.js +5 -25
  59. package/lib/locale/sk-SK.js +5 -25
  60. package/lib/locale/vi-VN.js +5 -25
  61. package/lib/locale/zh-CN.js +5 -25
  62. package/lib/locale/zh-HK.js +5 -25
  63. package/lib/locale/zh-TW.js +5 -25
  64. package/lib/types/locale/en-US.d.ts +0 -18
  65. package/lib/umd/facade.js +1 -1
  66. package/lib/umd/index.js +1 -1
  67. package/lib/umd/locale/ar-SA.js +1 -1
  68. package/lib/umd/locale/ca-ES.js +1 -1
  69. package/lib/umd/locale/de-DE.js +1 -1
  70. package/lib/umd/locale/en-US.js +1 -1
  71. package/lib/umd/locale/es-ES.js +1 -1
  72. package/lib/umd/locale/fa-IR.js +1 -1
  73. package/lib/umd/locale/fr-FR.js +1 -1
  74. package/lib/umd/locale/id-ID.js +1 -1
  75. package/lib/umd/locale/it-IT.js +1 -1
  76. package/lib/umd/locale/ja-JP.js +1 -1
  77. package/lib/umd/locale/ko-KR.js +1 -1
  78. package/lib/umd/locale/pl-PL.js +1 -1
  79. package/lib/umd/locale/pt-BR.js +1 -1
  80. package/lib/umd/locale/ru-RU.js +1 -1
  81. package/lib/umd/locale/sk-SK.js +1 -1
  82. package/lib/umd/locale/vi-VN.js +1 -1
  83. package/lib/umd/locale/zh-CN.js +1 -1
  84. package/lib/umd/locale/zh-HK.js +1 -1
  85. package/lib/umd/locale/zh-TW.js +1 -1
  86. package/package.json +8 -8
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.1";
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,
@@ -9,8 +9,7 @@ const locale = { "sheets-data-validation": {
9
9
  lessThanOrEqual: "أقل من أو يساوي",
10
10
  equal: "يساوي",
11
11
  notEqual: "لا يساوي",
12
- notBetween: "ليس بين",
13
- legal: "نوع قانوني"
12
+ notBetween: "ليس بين"
14
13
  },
15
14
  ruleName: {
16
15
  between: "بين {FORMULA1} و{FORMULA2}",
@@ -43,8 +42,7 @@ const locale = { "sheets-data-validation": {
43
42
  lessThanOrEqual: "في أو قبل",
44
43
  equal: "يساوي",
45
44
  notEqual: "لا يساوي",
46
- notBetween: "ليس بين",
47
- legal: "تاريخ قانوني"
45
+ notBetween: "ليس بين"
48
46
  },
49
47
  ruleName: {
50
48
  between: "بين {FORMULA1} و{FORMULA2}",
@@ -86,20 +84,16 @@ const locale = { "sheets-data-validation": {
86
84
  custom: {
87
85
  ruleName: "الصيغة المخصصة هي {FORMULA1}",
88
86
  title: "صيغة مخصصة",
89
- validFail: "يرجى إدخال صيغة صالحة",
90
87
  error: "محتويات هذه الخلية تنتهك قاعدة التحقق"
91
88
  },
92
89
  validFail: {
93
90
  value: "يرجى إدخال قيمة",
94
- common: "يرجى إدخال قيمة أو صيغة",
95
91
  number: "يرجى إدخال رقم أو صيغة",
96
92
  formula: "يرجى إدخال صيغة",
97
- integer: "يرجى إدخال عدد صحيح أو صيغة",
98
93
  date: "يرجى إدخال تاريخ أو صيغة",
99
94
  list: "يرجى إدخال خيارات",
100
95
  listInvalid: "يجب أن يكون مصدر القائمة قائمة محددة بفواصل أو مرجعًا لصف أو عمود واحد",
101
96
  checkboxEqual: "أدخل قيمًا مختلفة لمحتويات الخلية المحددة وغير المحددة.",
102
- formulaError: "يحتوي نطاق المرجع على بيانات غير مرئية، يرجى إعادة ضبط النطاق",
103
97
  listIntersects: "لا يمكن أن يتقاطع النطاق المحدد مع نطاق القواعد",
104
98
  primitive: "غير مسموح بالصيغ لقيم المحدد وغير المحدد المخصصة."
105
99
  },
@@ -110,28 +104,14 @@ const locale = { "sheets-data-validation": {
110
104
  list: {
111
105
  title: "قائمة منسدلة",
112
106
  name: "القيمة تحتوي على واحدة من النطاق",
113
- error: "يجب أن يكون الإدخال ضمن النطاق المحدد",
114
- emptyError: "يرجى إدخال قيمة",
115
- add: "إضافة",
116
- dropdown: "تحديد",
117
- options: "خيارات",
118
- customOptions: "مخصص",
119
- refOptions: "من نطاق",
120
- formulaError: "يجب أن يكون مصدر القائمة قائمة بيانات محددة بفواصل، أو مرجعًا لصف أو عمود واحد.",
121
- edit: "تحرير"
122
- },
123
- listMultiple: {
124
- title: "قائمة منسدلة - متعددة",
125
- dropdown: "تحديد متعدد"
107
+ error: "يجب أن يكون الإدخال ضمن النطاق المحدد"
126
108
  },
109
+ listMultiple: { title: "قائمة منسدلة - متعددة" },
127
110
  decimal: { title: "رقم" },
128
111
  whole: { title: "عدد صحيح" },
129
112
  checkbox: {
130
113
  title: "خانة اختيار",
131
- error: "محتويات هذه الخلية تنتهك قاعدة التحقق",
132
- tips: "استخدم قيمًا مخصصة داخل الخلايا",
133
- checked: "القيمة المحددة",
134
- unchecked: "القيمة غير المحددة"
114
+ error: "محتويات هذه الخلية تنتهك قاعدة التحقق"
135
115
  }
136
116
  } };
137
117
 
@@ -9,8 +9,7 @@ const locale = { "sheets-data-validation": {
9
9
  lessThanOrEqual: "menys o igual que",
10
10
  equal: "igual",
11
11
  notEqual: "no igual",
12
- notBetween: "no entre",
13
- legal: "és tipus legal"
12
+ notBetween: "no entre"
14
13
  },
15
14
  ruleName: {
16
15
  between: "Està entre {FORMULA1} i {FORMULA2}",
@@ -43,8 +42,7 @@ const locale = { "sheets-data-validation": {
43
42
  lessThanOrEqual: "en o abans de",
44
43
  equal: "igual",
45
44
  notEqual: "no igual",
46
- notBetween: "no entre",
47
- legal: "és una data legal"
45
+ notBetween: "no entre"
48
46
  },
49
47
  ruleName: {
50
48
  between: "està entre {FORMULA1} i {FORMULA2}",
@@ -86,20 +84,16 @@ const locale = { "sheets-data-validation": {
86
84
  custom: {
87
85
  ruleName: "La fórmula personalitzada és {FORMULA1}",
88
86
  title: "Fórmula personalitzada",
89
- validFail: "Si us plau, introdueix una fórmula vàlida",
90
87
  error: "El contingut d’aquesta cel·la incompleix la seva regla de validació"
91
88
  },
92
89
  validFail: {
93
90
  value: "Si us plau, introdueix un valor",
94
- common: "Si us plau, introdueix un valor o una fórmula",
95
91
  number: "Si us plau, introdueix un número o una fórmula",
96
92
  formula: "Si us plau, introdueix una fórmula",
97
- integer: "Si us plau, introdueix un enter o una fórmula",
98
93
  date: "Si us plau, introdueix una data o una fórmula",
99
94
  list: "Si us plau, introdueix opcions",
100
95
  listInvalid: "La font de la llista ha de ser una llista delimitada o una referència a una sola fila o columna",
101
96
  checkboxEqual: "Introdueix valors diferents per als continguts de cel·la marcats i desmarcats.",
102
- formulaError: "L’interval de referència conté dades invisibles, ajusta l’interval",
103
97
  listIntersects: "L’interval seleccionat no pot creuar-se amb l’àmbit de les regles",
104
98
  primitive: "No es permeten fórmules per a valors personalitzats marcats i desmarcats."
105
99
  },
@@ -110,28 +104,14 @@ const locale = { "sheets-data-validation": {
110
104
  list: {
111
105
  title: "Desplegable",
112
106
  name: "El valor conté un del rang",
113
- error: "L’entrada ha d’estar dins del rang especificat",
114
- emptyError: "Si us plau, introdueix un valor",
115
- add: "Afegeix",
116
- dropdown: "Selecciona",
117
- options: "Opcions",
118
- customOptions: "Personalitzat",
119
- refOptions: "D’un interval",
120
- formulaError: "La font de la llista ha de ser una llista delimitada de dades o una referència a una sola fila o columna.",
121
- edit: "Edita"
122
- },
123
- listMultiple: {
124
- title: "Desplegable-múltiple",
125
- dropdown: "Selecció múltiple"
107
+ error: "L’entrada ha d’estar dins del rang especificat"
126
108
  },
109
+ listMultiple: { title: "Desplegable-múltiple" },
127
110
  decimal: { title: "Número" },
128
111
  whole: { title: "Enter" },
129
112
  checkbox: {
130
113
  title: "Casella de selecció",
131
- error: "El contingut d’aquesta cel·la incompleix la seva regla de validació",
132
- tips: "Utilitza valors personalitzats dins de les cel·les",
133
- checked: "Valor seleccionat",
134
- unchecked: "Valor no seleccionat"
114
+ error: "El contingut d’aquesta cel·la incompleix la seva regla de validació"
135
115
  }
136
116
  } };
137
117
 
@@ -9,8 +9,7 @@ const locale = { "sheets-data-validation": {
9
9
  lessThanOrEqual: "kleiner als oder gleich",
10
10
  equal: "gleich",
11
11
  notEqual: "ungleich",
12
- notBetween: "nicht zwischen",
13
- legal: "ist gültiger Typ"
12
+ notBetween: "nicht zwischen"
14
13
  },
15
14
  ruleName: {
16
15
  between: "Ist zwischen {FORMULA1} und {FORMULA2}",
@@ -43,8 +42,7 @@ const locale = { "sheets-data-validation": {
43
42
  lessThanOrEqual: "am oder vor",
44
43
  equal: "gleich",
45
44
  notEqual: "ungleich",
46
- notBetween: "nicht zwischen",
47
- legal: "ist ein gültiges Datum"
45
+ notBetween: "nicht zwischen"
48
46
  },
49
47
  ruleName: {
50
48
  between: "ist zwischen {FORMULA1} und {FORMULA2}",
@@ -86,20 +84,16 @@ const locale = { "sheets-data-validation": {
86
84
  custom: {
87
85
  ruleName: "Benutzerdefinierte Formel ist {FORMULA1}",
88
86
  title: "Benutzerdefinierte Formel",
89
- validFail: "Bitte geben Sie eine gültige Formel ein",
90
87
  error: "Der Inhalt dieser Zelle verstößt gegen die Überprüfungsregel"
91
88
  },
92
89
  validFail: {
93
90
  value: "Bitte geben Sie einen Wert ein",
94
- common: "Bitte geben Sie einen Wert oder eine Formel ein",
95
91
  number: "Bitte geben Sie eine Zahl oder eine Formel ein",
96
92
  formula: "Bitte geben Sie eine Formel ein",
97
- integer: "Bitte geben Sie eine ganze Zahl oder eine Formel ein",
98
93
  date: "Bitte geben Sie ein Datum oder eine Formel ein",
99
94
  list: "Bitte geben Sie Optionen ein",
100
95
  listInvalid: "Die Listenquelle muss eine durch Trennzeichen getrennte Liste oder ein Bezug auf eine einzelne Zeile oder Spalte sein",
101
96
  checkboxEqual: "Geben Sie unterschiedliche Werte für angekreuzte und nicht angekreuzte Zelleninhalte ein.",
102
- formulaError: "Der Bezugsbereich enthält unsichtbare Daten, bitte passen Sie den Bereich an",
103
97
  listIntersects: "Der ausgewählte Bereich darf sich nicht mit dem Geltungsbereich der Regeln überschneiden",
104
98
  primitive: "Formeln sind für benutzerdefinierte angekreuzte und nicht angekreuzte Werte nicht zulässig."
105
99
  },
@@ -110,28 +104,14 @@ const locale = { "sheets-data-validation": {
110
104
  list: {
111
105
  title: "Dropdown",
112
106
  name: "Wert enthält einen aus dem Bereich",
113
- error: "Eingabe muss im angegebenen Bereich liegen",
114
- emptyError: "Bitte geben Sie einen Wert ein",
115
- add: "Hinzufügen",
116
- dropdown: "Auswählen",
117
- options: "Optionen",
118
- customOptions: "Benutzerdefiniert",
119
- refOptions: "Aus einem Bereich",
120
- formulaError: "Die Listenquelle muss eine durch Trennzeichen getrennte Datenliste oder ein Bezug auf eine einzelne Zeile oder Spalte sein.",
121
- edit: "Bearbeiten"
122
- },
123
- listMultiple: {
124
- title: "Dropdown-Mehrfachauswahl",
125
- dropdown: "Mehrfachauswahl"
107
+ error: "Eingabe muss im angegebenen Bereich liegen"
126
108
  },
109
+ listMultiple: { title: "Dropdown-Mehrfachauswahl" },
127
110
  decimal: { title: "Zahl" },
128
111
  whole: { title: "Ganze Zahl" },
129
112
  checkbox: {
130
113
  title: "Kontrollkästchen",
131
- error: "Der Inhalt dieser Zelle verstößt gegen die Überprüfungsregel",
132
- tips: "Benutzerdefinierte Werte in Zellen verwenden",
133
- checked: "Ausgewählter Wert",
134
- unchecked: "Nicht ausgewählter Wert"
114
+ error: "Der Inhalt dieser Zelle verstößt gegen die Überprüfungsregel"
135
115
  }
136
116
  } };
137
117
 
@@ -24,8 +24,7 @@ const locale = { "sheets-data-validation": {
24
24
  lessThanOrEqual: "less than or equal",
25
25
  equal: "equal",
26
26
  notEqual: "not equal",
27
- notBetween: "not between",
28
- legal: "is legal type"
27
+ notBetween: "not between"
29
28
  },
30
29
  ruleName: {
31
30
  between: "Is between {FORMULA1} and {FORMULA2}",
@@ -58,8 +57,7 @@ const locale = { "sheets-data-validation": {
58
57
  lessThanOrEqual: "on or before",
59
58
  equal: "equal",
60
59
  notEqual: "not equal",
61
- notBetween: "not between",
62
- legal: "is a legal date"
60
+ notBetween: "not between"
63
61
  },
64
62
  ruleName: {
65
63
  between: "is between {FORMULA1} and {FORMULA2}",
@@ -101,20 +99,16 @@ const locale = { "sheets-data-validation": {
101
99
  custom: {
102
100
  ruleName: "Custom formula is {FORMULA1}",
103
101
  title: "Custom formula",
104
- validFail: "Please input a valid formula",
105
102
  error: "This cell's contents violate its validation rule"
106
103
  },
107
104
  validFail: {
108
105
  value: "Please input a value",
109
- common: "Please input value or formula",
110
106
  number: "Please input number or formula",
111
107
  formula: "Please input formula",
112
- integer: "Please input integer or formula",
113
108
  date: "Please input date or formula",
114
109
  list: "Please input options",
115
110
  listInvalid: "The list source must be a delimited list or a reference to a single row or column",
116
111
  checkboxEqual: "Enter different values for ticked and unticked cell contents.",
117
- formulaError: "The reference range contains invisible data, please readjust the range",
118
112
  listIntersects: "The selected range cannot intersect with the scope of the rules",
119
113
  primitive: "Formulas are not permitted for custom ticked and unticked values."
120
114
  },
@@ -125,28 +119,14 @@ const locale = { "sheets-data-validation": {
125
119
  list: {
126
120
  title: "Dropdown",
127
121
  name: "Value contains one from range",
128
- error: "Input must fall within specified range",
129
- emptyError: "Please enter a value",
130
- add: "Add",
131
- dropdown: "Select",
132
- options: "Options",
133
- customOptions: "Custom",
134
- refOptions: "From a range",
135
- formulaError: "The list source must be a delimited list of data, or a reference to a single row or column.",
136
- edit: "Edit"
137
- },
138
- listMultiple: {
139
- title: "Dropdown-Multiple",
140
- dropdown: "Multiple select"
122
+ error: "Input must fall within specified range"
141
123
  },
124
+ listMultiple: { title: "Dropdown-Multiple" },
142
125
  decimal: { title: "Number" },
143
126
  whole: { title: "Integer" },
144
127
  checkbox: {
145
128
  title: "Checkbox",
146
- error: "This cell's contents violate its validation rule",
147
- tips: "Use custom values within cells",
148
- checked: "Selected value",
149
- unchecked: "Unselected value"
129
+ error: "This cell's contents violate its validation rule"
150
130
  }
151
131
  } };
152
132