@univerjs/sheets-data-validation 0.23.0 → 0.24.0-insiders.20260528-29f582d
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 +79 -104
- package/lib/cjs/index.js +206 -163
- package/lib/cjs/locale/ar-SA.js +139 -0
- package/lib/cjs/locale/ca-ES.js +139 -0
- package/lib/cjs/locale/de-DE.js +139 -0
- package/lib/cjs/locale/en-US.js +154 -0
- package/lib/cjs/locale/es-ES.js +139 -0
- package/lib/cjs/locale/fa-IR.js +139 -0
- package/lib/cjs/locale/fr-FR.js +139 -0
- package/lib/cjs/locale/id-ID.js +139 -0
- package/lib/cjs/locale/it-IT.js +139 -0
- package/lib/cjs/locale/ja-JP.js +139 -0
- package/lib/cjs/locale/ko-KR.js +139 -0
- package/lib/cjs/locale/pl-PL.js +139 -0
- package/lib/cjs/locale/pt-BR.js +139 -0
- package/lib/cjs/locale/ru-RU.js +139 -0
- package/lib/cjs/locale/sk-SK.js +139 -0
- package/lib/cjs/locale/vi-VN.js +139 -0
- package/lib/cjs/locale/zh-CN.js +139 -0
- package/lib/cjs/locale/zh-HK.js +139 -0
- package/lib/cjs/locale/zh-TW.js +139 -0
- package/lib/es/facade.js +80 -105
- package/lib/es/index.js +204 -159
- package/lib/es/locale/ar-SA.js +138 -0
- package/lib/es/locale/ca-ES.js +138 -0
- package/lib/es/locale/de-DE.js +138 -0
- package/lib/es/locale/en-US.js +153 -0
- package/lib/es/locale/es-ES.js +138 -0
- package/lib/es/locale/fa-IR.js +138 -0
- package/lib/es/locale/fr-FR.js +138 -0
- package/lib/es/locale/id-ID.js +138 -0
- package/lib/es/locale/it-IT.js +138 -0
- package/lib/es/locale/ja-JP.js +138 -0
- package/lib/es/locale/ko-KR.js +138 -0
- package/lib/es/locale/pl-PL.js +138 -0
- package/lib/es/locale/pt-BR.js +138 -0
- package/lib/es/locale/ru-RU.js +138 -0
- package/lib/es/locale/sk-SK.js +138 -0
- package/lib/es/locale/vi-VN.js +138 -0
- package/lib/es/locale/zh-CN.js +138 -0
- package/lib/es/locale/zh-HK.js +138 -0
- package/lib/es/locale/zh-TW.js +138 -0
- package/lib/facade.js +80 -105
- package/lib/index.js +204 -159
- package/lib/locale/ar-SA.js +138 -0
- package/lib/locale/ca-ES.js +138 -0
- package/lib/locale/de-DE.js +138 -0
- package/lib/locale/en-US.js +153 -0
- package/lib/locale/es-ES.js +138 -0
- package/lib/locale/fa-IR.js +138 -0
- package/lib/locale/fr-FR.js +138 -0
- package/lib/locale/id-ID.js +138 -0
- package/lib/locale/it-IT.js +138 -0
- package/lib/locale/ja-JP.js +138 -0
- package/lib/locale/ko-KR.js +138 -0
- package/lib/locale/pl-PL.js +138 -0
- package/lib/locale/pt-BR.js +138 -0
- package/lib/locale/ru-RU.js +138 -0
- package/lib/locale/sk-SK.js +138 -0
- package/lib/locale/vi-VN.js +138 -0
- package/lib/locale/zh-CN.js +138 -0
- package/lib/locale/zh-HK.js +138 -0
- package/lib/locale/zh-TW.js +138 -0
- package/lib/types/facade/f-data-validation-builder.d.ts +50 -25
- package/lib/types/facade/f-data-validation.d.ts +26 -13
- package/lib/types/facade/f-range.d.ts +10 -5
- package/lib/types/facade/f-univer.d.ts +2 -1
- package/lib/types/facade/f-workbook.d.ts +1 -43
- package/lib/types/facade/f-worksheet.d.ts +8 -9
- package/lib/types/index.d.ts +6 -6
- package/lib/types/locale/ar-SA.d.ts +18 -0
- package/lib/types/locale/ca-ES.d.ts +18 -0
- package/lib/types/locale/de-DE.d.ts +18 -0
- package/lib/types/locale/en-US.d.ts +156 -0
- package/lib/types/locale/es-ES.d.ts +18 -0
- package/lib/types/locale/fa-IR.d.ts +18 -0
- package/lib/types/locale/fr-FR.d.ts +18 -0
- package/lib/types/locale/id-ID.d.ts +18 -0
- package/lib/types/locale/it-IT.d.ts +18 -0
- package/lib/types/locale/ja-JP.d.ts +18 -0
- package/lib/types/locale/ko-KR.d.ts +18 -0
- package/lib/types/locale/pl-PL.d.ts +18 -0
- package/lib/types/locale/pt-BR.d.ts +18 -0
- package/lib/types/locale/ru-RU.d.ts +18 -0
- package/lib/types/locale/sk-SK.d.ts +18 -0
- package/lib/types/locale/vi-VN.d.ts +18 -0
- package/lib/types/locale/zh-CN.d.ts +18 -0
- package/lib/types/locale/zh-HK.d.ts +18 -0
- package/lib/types/locale/zh-TW.d.ts +18 -0
- package/lib/types/types/const/operator-text-map.d.ts +2 -1
- package/lib/types/validators/any-validator.d.ts +2 -2
- package/lib/types/validators/base-sheet-validator.d.ts +26 -0
- package/lib/types/validators/checkbox-validator.d.ts +2 -2
- package/lib/types/validators/custom-validator.d.ts +2 -2
- package/lib/types/validators/date-validator.d.ts +2 -2
- package/lib/types/validators/decimal-validator.d.ts +2 -2
- package/lib/types/validators/list-validator.d.ts +2 -2
- package/lib/types/validators/text-length-validator.d.ts +2 -2
- package/lib/types/validators/util.d.ts +0 -2
- package/lib/types/validators/whole-validator.d.ts +2 -2
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/ar-SA.js +1 -0
- package/lib/umd/locale/ca-ES.js +1 -0
- package/lib/umd/locale/de-DE.js +1 -0
- package/lib/umd/locale/en-US.js +1 -0
- package/lib/umd/locale/es-ES.js +1 -0
- package/lib/umd/locale/fa-IR.js +1 -0
- package/lib/umd/locale/fr-FR.js +1 -0
- package/lib/umd/locale/id-ID.js +1 -0
- package/lib/umd/locale/it-IT.js +1 -0
- package/lib/umd/locale/ja-JP.js +1 -0
- package/lib/umd/locale/ko-KR.js +1 -0
- package/lib/umd/locale/pl-PL.js +1 -0
- package/lib/umd/locale/pt-BR.js +1 -0
- package/lib/umd/locale/ru-RU.js +1 -0
- package/lib/umd/locale/sk-SK.js +1 -0
- package/lib/umd/locale/vi-VN.js +1 -0
- package/lib/umd/locale/zh-CN.js +1 -0
- package/lib/umd/locale/zh-HK.js +1 -0
- package/lib/umd/locale/zh-TW.js +1 -0
- package/package.json +13 -8
- package/LICENSE +0 -176
- /package/lib/types/services/{dv-validator-service.d.ts → dv-validator.service.d.ts} +0 -0
package/lib/cjs/index.js
CHANGED
|
@@ -86,7 +86,14 @@ let DataValidationCacheService = class DataValidationCacheService extends _unive
|
|
|
86
86
|
if (cellValue) {
|
|
87
87
|
const range = new _univerjs_core.ObjectMatrix(cellValue).getDataRange();
|
|
88
88
|
if (range.endRow === -1) return;
|
|
89
|
-
const
|
|
89
|
+
const rules = this._sheetDataValidationModel.getRules(unitId, subUnitId);
|
|
90
|
+
const ranges = [];
|
|
91
|
+
for (const rule of rules) ranges.push(...rule.ranges);
|
|
92
|
+
const intersectsRanges = [];
|
|
93
|
+
for (const ruleRange of ranges) {
|
|
94
|
+
const intersect = (0, _univerjs_core.getIntersectRange)(ruleRange, range);
|
|
95
|
+
if (intersect) intersectsRanges.push(intersect);
|
|
96
|
+
}
|
|
90
97
|
if (intersectsRanges.length) this.markRangeDirty(unitId, subUnitId, intersectsRanges, true);
|
|
91
98
|
}
|
|
92
99
|
}
|
|
@@ -382,31 +389,6 @@ function getStringCellValue(cell) {
|
|
|
382
389
|
return String((_getCellValueOrigin = getCellValueOrigin(cell)) !== null && _getCellValueOrigin !== void 0 ? _getCellValueOrigin : "");
|
|
383
390
|
}
|
|
384
391
|
|
|
385
|
-
//#endregion
|
|
386
|
-
//#region src/validators/util.ts
|
|
387
|
-
function serializeListOptions(options) {
|
|
388
|
-
return options.filter(Boolean).join(",");
|
|
389
|
-
}
|
|
390
|
-
function deserializeListOptions(optionsStr) {
|
|
391
|
-
return optionsStr.split(",").filter(Boolean);
|
|
392
|
-
}
|
|
393
|
-
function getDataValidationCellValue(cellData) {
|
|
394
|
-
const cellValue = getCellValueOrigin(cellData);
|
|
395
|
-
if (cellValue === void 0 || cellValue === null) return "";
|
|
396
|
-
return cellValue.toString();
|
|
397
|
-
}
|
|
398
|
-
function getTransformedFormula(lexerTreeBuilder, rule, position) {
|
|
399
|
-
const { formula1, formula2 } = rule;
|
|
400
|
-
const originStartRow = rule.ranges[0].startRow;
|
|
401
|
-
const originStartColumn = rule.ranges[0].startColumn;
|
|
402
|
-
const offsetRow = position.row - originStartRow;
|
|
403
|
-
const offsetColumn = position.col - originStartColumn;
|
|
404
|
-
return {
|
|
405
|
-
transformedFormula1: (0, _univerjs_core.isFormulaString)(formula1) ? lexerTreeBuilder.moveFormulaRefOffset(formula1, offsetColumn, offsetRow, true) : formula1,
|
|
406
|
-
transformedFormula2: (0, _univerjs_core.isFormulaString)(formula2) ? lexerTreeBuilder.moveFormulaRefOffset(formula2, offsetColumn, offsetRow, true) : formula2
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
|
|
410
392
|
//#endregion
|
|
411
393
|
//#region src/services/dv-list-cache.service.ts
|
|
412
394
|
let DataValidationListCacheService = class DataValidationListCacheService extends _univerjs_core.Disposable {
|
|
@@ -477,7 +459,7 @@ let DataValidationListCacheService = class DataValidationListCacheService extend
|
|
|
477
459
|
computeAndCache(unitId, subUnitId, rule, formulaResult) {
|
|
478
460
|
var _formulaResult$;
|
|
479
461
|
const { formula1 = "", formula2 = "" } = rule;
|
|
480
|
-
const list = (0, _univerjs_core.isFormulaString)(formula1) ? this._getRuleFormulaResultSet(formulaResult === null || formulaResult === void 0 || (_formulaResult$ = formulaResult[0]) === null || _formulaResult$ === void 0 || (_formulaResult$ = _formulaResult$.result) === null || _formulaResult$ === void 0 || (_formulaResult$ = _formulaResult$[0]) === null || _formulaResult$ === void 0 ? void 0 : _formulaResult$[0]) : deserializeListOptions(formula1);
|
|
462
|
+
const list = (0, _univerjs_core.isFormulaString)(formula1) ? this._getRuleFormulaResultSet(formulaResult === null || formulaResult === void 0 || (_formulaResult$ = formulaResult[0]) === null || _formulaResult$ === void 0 || (_formulaResult$ = _formulaResult$.result) === null || _formulaResult$ === void 0 || (_formulaResult$ = _formulaResult$[0]) === null || _formulaResult$ === void 0 ? void 0 : _formulaResult$[0]) : (0, _univerjs_sheets.deserializeListOptions)(formula1);
|
|
481
463
|
const colorList = formula2.split(",");
|
|
482
464
|
const listWithColor = list.map((label, i) => ({
|
|
483
465
|
label,
|
|
@@ -1005,21 +987,103 @@ SheetDataValidationModel = __decorate([
|
|
|
1005
987
|
__decorateParam(6, _univerjs_core.ICommandService)
|
|
1006
988
|
], SheetDataValidationModel);
|
|
1007
989
|
|
|
990
|
+
//#endregion
|
|
991
|
+
//#region src/types/const/operator-text-map.ts
|
|
992
|
+
/**
|
|
993
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
994
|
+
*
|
|
995
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
996
|
+
* you may not use this file except in compliance with the License.
|
|
997
|
+
* You may obtain a copy of the License at
|
|
998
|
+
*
|
|
999
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1000
|
+
*
|
|
1001
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1002
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1003
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1004
|
+
* See the License for the specific language governing permissions and
|
|
1005
|
+
* limitations under the License.
|
|
1006
|
+
*/
|
|
1007
|
+
const OperatorTextMap = {
|
|
1008
|
+
[_univerjs_core.DataValidationOperator.BETWEEN]: "sheets-data-validation.operators.between",
|
|
1009
|
+
[_univerjs_core.DataValidationOperator.EQUAL]: "sheets-data-validation.operators.equal",
|
|
1010
|
+
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "sheets-data-validation.operators.greaterThan",
|
|
1011
|
+
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "sheets-data-validation.operators.greaterThanOrEqual",
|
|
1012
|
+
[_univerjs_core.DataValidationOperator.LESS_THAN]: "sheets-data-validation.operators.lessThan",
|
|
1013
|
+
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "sheets-data-validation.operators.lessThanOrEqual",
|
|
1014
|
+
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "sheets-data-validation.operators.notBetween",
|
|
1015
|
+
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "sheets-data-validation.operators.notEqual"
|
|
1016
|
+
};
|
|
1017
|
+
const OperatorTitleMap = {
|
|
1018
|
+
[_univerjs_core.DataValidationOperator.BETWEEN]: "sheets-data-validation.ruleName.between",
|
|
1019
|
+
[_univerjs_core.DataValidationOperator.EQUAL]: "sheets-data-validation.ruleName.equal",
|
|
1020
|
+
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "sheets-data-validation.ruleName.greaterThan",
|
|
1021
|
+
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "sheets-data-validation.ruleName.greaterThanOrEqual",
|
|
1022
|
+
[_univerjs_core.DataValidationOperator.LESS_THAN]: "sheets-data-validation.ruleName.lessThan",
|
|
1023
|
+
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "sheets-data-validation.ruleName.lessThanOrEqual",
|
|
1024
|
+
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "sheets-data-validation.ruleName.notBetween",
|
|
1025
|
+
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "sheets-data-validation.ruleName.notEqual",
|
|
1026
|
+
NONE: "sheets-data-validation.ruleName.legal"
|
|
1027
|
+
};
|
|
1028
|
+
const OperatorErrorTitleMap = {
|
|
1029
|
+
[_univerjs_core.DataValidationOperator.BETWEEN]: "sheets-data-validation.errorMsg.between",
|
|
1030
|
+
[_univerjs_core.DataValidationOperator.EQUAL]: "sheets-data-validation.errorMsg.equal",
|
|
1031
|
+
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "sheets-data-validation.errorMsg.greaterThan",
|
|
1032
|
+
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "sheets-data-validation.errorMsg.greaterThanOrEqual",
|
|
1033
|
+
[_univerjs_core.DataValidationOperator.LESS_THAN]: "sheets-data-validation.errorMsg.lessThan",
|
|
1034
|
+
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "sheets-data-validation.errorMsg.lessThanOrEqual",
|
|
1035
|
+
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "sheets-data-validation.errorMsg.notBetween",
|
|
1036
|
+
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "sheets-data-validation.errorMsg.notEqual",
|
|
1037
|
+
NONE: "sheets-data-validation.errorMsg.legal"
|
|
1038
|
+
};
|
|
1039
|
+
const TextLengthErrorTitleMap = {
|
|
1040
|
+
[_univerjs_core.DataValidationOperator.BETWEEN]: "sheets-data-validation.textLength.errorMsg.between",
|
|
1041
|
+
[_univerjs_core.DataValidationOperator.EQUAL]: "sheets-data-validation.textLength.errorMsg.equal",
|
|
1042
|
+
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "sheets-data-validation.textLength.errorMsg.greaterThan",
|
|
1043
|
+
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "sheets-data-validation.textLength.errorMsg.greaterThanOrEqual",
|
|
1044
|
+
[_univerjs_core.DataValidationOperator.LESS_THAN]: "sheets-data-validation.textLength.errorMsg.lessThan",
|
|
1045
|
+
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "sheets-data-validation.textLength.errorMsg.lessThanOrEqual",
|
|
1046
|
+
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "sheets-data-validation.textLength.errorMsg.notBetween",
|
|
1047
|
+
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "sheets-data-validation.textLength.errorMsg.notEqual"
|
|
1048
|
+
};
|
|
1049
|
+
|
|
1050
|
+
//#endregion
|
|
1051
|
+
//#region src/validators/base-sheet-validator.ts
|
|
1052
|
+
const FORMULA1$1 = "{FORMULA1}";
|
|
1053
|
+
const FORMULA2$1 = "{FORMULA2}";
|
|
1054
|
+
const TYPE = "{TYPE}";
|
|
1055
|
+
var BaseSheetValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
1056
|
+
get operatorNames() {
|
|
1057
|
+
return this.operators.map((operator) => this.localeService.t(OperatorTextMap[operator]));
|
|
1058
|
+
}
|
|
1059
|
+
generateRuleName(rule) {
|
|
1060
|
+
var _rule$formula, _rule$formula2;
|
|
1061
|
+
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 : "");
|
|
1063
|
+
return `${this.titleStr} ${ruleName}`;
|
|
1064
|
+
}
|
|
1065
|
+
generateRuleErrorMessage(rule, _position) {
|
|
1066
|
+
var _rule$formula3, _rule$formula4;
|
|
1067
|
+
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 : "")}`;
|
|
1069
|
+
}
|
|
1070
|
+
};
|
|
1071
|
+
|
|
1008
1072
|
//#endregion
|
|
1009
1073
|
//#region src/validators/checkbox-validator.ts
|
|
1010
1074
|
const CHECKBOX_FORMULA_1 = 1;
|
|
1011
1075
|
const CHECKBOX_FORMULA_2 = 0;
|
|
1012
1076
|
function getFailMessage(formula, localeService) {
|
|
1013
|
-
if (_univerjs_core.Tools.isBlank(formula)) return localeService.t("
|
|
1014
|
-
if ((0, _univerjs_core.isFormulaString)(formula)) return localeService.t("
|
|
1077
|
+
if (_univerjs_core.Tools.isBlank(formula)) return localeService.t("sheets-data-validation.validFail.value");
|
|
1078
|
+
if ((0, _univerjs_core.isFormulaString)(formula)) return localeService.t("sheets-data-validation.validFail.primitive");
|
|
1015
1079
|
return "";
|
|
1016
1080
|
}
|
|
1017
1081
|
const transformCheckboxValue = (value) => _univerjs_core.Tools.isDefine(value) && String(value).toLowerCase() === "true" ? "1" : String(value).toLowerCase() === "false" ? "0" : value;
|
|
1018
|
-
var CheckboxValidator = class extends
|
|
1082
|
+
var CheckboxValidator = class extends BaseSheetValidator {
|
|
1019
1083
|
constructor(..._args) {
|
|
1020
1084
|
super(..._args);
|
|
1021
1085
|
_defineProperty(this, "id", _univerjs_core.DataValidationType.CHECKBOX);
|
|
1022
|
-
_defineProperty(this, "title", "
|
|
1086
|
+
_defineProperty(this, "title", "sheets-data-validation.checkbox.title");
|
|
1023
1087
|
_defineProperty(this, "operators", []);
|
|
1024
1088
|
_defineProperty(this, "scopes", ["sheet"]);
|
|
1025
1089
|
_defineProperty(this, "order", 41);
|
|
@@ -1038,8 +1102,8 @@ var CheckboxValidator = class extends _univerjs_data_validation.BaseDataValidato
|
|
|
1038
1102
|
if (_univerjs_core.Tools.isBlank(formula1) && _univerjs_core.Tools.isBlank(formula2)) return { success: true };
|
|
1039
1103
|
if (isEqual) return {
|
|
1040
1104
|
success: false,
|
|
1041
|
-
formula1: this.localeService.t("
|
|
1042
|
-
formula2: this.localeService.t("
|
|
1105
|
+
formula1: this.localeService.t("sheets-data-validation.validFail.checkboxEqual"),
|
|
1106
|
+
formula2: this.localeService.t("sheets-data-validation.validFail.checkboxEqual")
|
|
1043
1107
|
};
|
|
1044
1108
|
const error1 = getFailMessage(formula1, this.localeService);
|
|
1045
1109
|
const error2 = getFailMessage(formula2, this.localeService);
|
|
@@ -1089,7 +1153,7 @@ var CheckboxValidator = class extends _univerjs_data_validation.BaseDataValidato
|
|
|
1089
1153
|
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 : ""));
|
|
1090
1154
|
}
|
|
1091
1155
|
generateRuleErrorMessage(rule) {
|
|
1092
|
-
return this.localeService.t("
|
|
1156
|
+
return this.localeService.t("sheets-data-validation.checkbox.error");
|
|
1093
1157
|
}
|
|
1094
1158
|
generateRuleName(rule) {
|
|
1095
1159
|
return this.titleStr;
|
|
@@ -1114,46 +1178,46 @@ var CheckboxValidator = class extends _univerjs_data_validation.BaseDataValidato
|
|
|
1114
1178
|
* limitations under the License.
|
|
1115
1179
|
*/
|
|
1116
1180
|
const DateOperatorNameMap = {
|
|
1117
|
-
[_univerjs_core.DataValidationOperator.BETWEEN]: "
|
|
1118
|
-
[_univerjs_core.DataValidationOperator.EQUAL]: "
|
|
1119
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "
|
|
1120
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "
|
|
1121
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN]: "
|
|
1122
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "
|
|
1123
|
-
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "
|
|
1124
|
-
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "
|
|
1181
|
+
[_univerjs_core.DataValidationOperator.BETWEEN]: "sheets-data-validation.date.operators.between",
|
|
1182
|
+
[_univerjs_core.DataValidationOperator.EQUAL]: "sheets-data-validation.date.operators.equal",
|
|
1183
|
+
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "sheets-data-validation.date.operators.greaterThan",
|
|
1184
|
+
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "sheets-data-validation.date.operators.greaterThanOrEqual",
|
|
1185
|
+
[_univerjs_core.DataValidationOperator.LESS_THAN]: "sheets-data-validation.date.operators.lessThan",
|
|
1186
|
+
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "sheets-data-validation.date.operators.lessThanOrEqual",
|
|
1187
|
+
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "sheets-data-validation.date.operators.notBetween",
|
|
1188
|
+
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "sheets-data-validation.date.operators.notEqual"
|
|
1125
1189
|
};
|
|
1126
1190
|
const DateOperatorTextMap = {
|
|
1127
|
-
[_univerjs_core.DataValidationOperator.BETWEEN]: "
|
|
1128
|
-
[_univerjs_core.DataValidationOperator.EQUAL]: "
|
|
1129
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "
|
|
1130
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "
|
|
1131
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN]: "
|
|
1132
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "
|
|
1133
|
-
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "
|
|
1134
|
-
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "
|
|
1191
|
+
[_univerjs_core.DataValidationOperator.BETWEEN]: "sheets-data-validation.date.operators.between",
|
|
1192
|
+
[_univerjs_core.DataValidationOperator.EQUAL]: "sheets-data-validation.date.operators.equal",
|
|
1193
|
+
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "sheets-data-validation.date.operators.greaterThan",
|
|
1194
|
+
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "sheets-data-validation.date.operators.greaterThanOrEqual",
|
|
1195
|
+
[_univerjs_core.DataValidationOperator.LESS_THAN]: "sheets-data-validation.date.operators.lessThan",
|
|
1196
|
+
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "sheets-data-validation.date.operators.lessThanOrEqual",
|
|
1197
|
+
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "sheets-data-validation.date.operators.notBetween",
|
|
1198
|
+
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "sheets-data-validation.date.operators.notEqual"
|
|
1135
1199
|
};
|
|
1136
1200
|
const DateOperatorTitleMap = {
|
|
1137
|
-
[_univerjs_core.DataValidationOperator.BETWEEN]: "
|
|
1138
|
-
[_univerjs_core.DataValidationOperator.EQUAL]: "
|
|
1139
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "
|
|
1140
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "
|
|
1141
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN]: "
|
|
1142
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "
|
|
1143
|
-
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "
|
|
1144
|
-
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "
|
|
1145
|
-
NONE: "
|
|
1201
|
+
[_univerjs_core.DataValidationOperator.BETWEEN]: "sheets-data-validation.date.ruleName.between",
|
|
1202
|
+
[_univerjs_core.DataValidationOperator.EQUAL]: "sheets-data-validation.date.ruleName.equal",
|
|
1203
|
+
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "sheets-data-validation.date.ruleName.greaterThan",
|
|
1204
|
+
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "sheets-data-validation.date.ruleName.greaterThanOrEqual",
|
|
1205
|
+
[_univerjs_core.DataValidationOperator.LESS_THAN]: "sheets-data-validation.date.ruleName.lessThan",
|
|
1206
|
+
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "sheets-data-validation.date.ruleName.lessThanOrEqual",
|
|
1207
|
+
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "sheets-data-validation.date.ruleName.notBetween",
|
|
1208
|
+
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "sheets-data-validation.date.ruleName.notEqual",
|
|
1209
|
+
NONE: "sheets-data-validation.date.ruleName.legal"
|
|
1146
1210
|
};
|
|
1147
1211
|
const DateOperatorErrorTitleMap = {
|
|
1148
|
-
[_univerjs_core.DataValidationOperator.BETWEEN]: "
|
|
1149
|
-
[_univerjs_core.DataValidationOperator.EQUAL]: "
|
|
1150
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "
|
|
1151
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "
|
|
1152
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN]: "
|
|
1153
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "
|
|
1154
|
-
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "
|
|
1155
|
-
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "
|
|
1156
|
-
NONE: "
|
|
1212
|
+
[_univerjs_core.DataValidationOperator.BETWEEN]: "sheets-data-validation.date.errorMsg.between",
|
|
1213
|
+
[_univerjs_core.DataValidationOperator.EQUAL]: "sheets-data-validation.date.errorMsg.equal",
|
|
1214
|
+
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "sheets-data-validation.date.errorMsg.greaterThan",
|
|
1215
|
+
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "sheets-data-validation.date.errorMsg.greaterThanOrEqual",
|
|
1216
|
+
[_univerjs_core.DataValidationOperator.LESS_THAN]: "sheets-data-validation.date.errorMsg.lessThan",
|
|
1217
|
+
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "sheets-data-validation.date.errorMsg.lessThanOrEqual",
|
|
1218
|
+
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "sheets-data-validation.date.errorMsg.notBetween",
|
|
1219
|
+
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "sheets-data-validation.date.errorMsg.notEqual",
|
|
1220
|
+
NONE: "sheets-data-validation.date.errorMsg.legal"
|
|
1157
1221
|
};
|
|
1158
1222
|
|
|
1159
1223
|
//#endregion
|
|
@@ -1195,6 +1259,25 @@ const TWO_FORMULA_OPERATOR_COUNT = [_univerjs_core.DataValidationOperator.BETWEE
|
|
|
1195
1259
|
const FORMULA1 = "{FORMULA1}";
|
|
1196
1260
|
const FORMULA2 = "{FORMULA2}";
|
|
1197
1261
|
|
|
1262
|
+
//#endregion
|
|
1263
|
+
//#region src/validators/util.ts
|
|
1264
|
+
function getDataValidationCellValue(cellData) {
|
|
1265
|
+
const cellValue = getCellValueOrigin(cellData);
|
|
1266
|
+
if (cellValue === void 0 || cellValue === null) return "";
|
|
1267
|
+
return cellValue.toString();
|
|
1268
|
+
}
|
|
1269
|
+
function getTransformedFormula(lexerTreeBuilder, rule, position) {
|
|
1270
|
+
const { formula1, formula2 } = rule;
|
|
1271
|
+
const originStartRow = rule.ranges[0].startRow;
|
|
1272
|
+
const originStartColumn = rule.ranges[0].startColumn;
|
|
1273
|
+
const offsetRow = position.row - originStartRow;
|
|
1274
|
+
const offsetColumn = position.col - originStartColumn;
|
|
1275
|
+
return {
|
|
1276
|
+
transformedFormula1: (0, _univerjs_core.isFormulaString)(formula1) ? lexerTreeBuilder.moveFormulaRefOffset(formula1, offsetColumn, offsetRow, true) : formula1,
|
|
1277
|
+
transformedFormula2: (0, _univerjs_core.isFormulaString)(formula2) ? lexerTreeBuilder.moveFormulaRefOffset(formula2, offsetColumn, offsetRow, true) : formula2
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1198
1281
|
//#endregion
|
|
1199
1282
|
//#region src/validators/date-validator.ts
|
|
1200
1283
|
const transformDate2SerialNumber = (value) => {
|
|
@@ -1205,11 +1288,11 @@ const transformDate2SerialNumber = (value) => {
|
|
|
1205
1288
|
if (_univerjs_core.Tools.isDefine(v)) return v;
|
|
1206
1289
|
return (_numfmt$parseDate2 = _univerjs_core.numfmt.parseDate((0, _univerjs_core.dateKit)(value).format("YYYY-MM-DD HH:mm:ss"))) === null || _numfmt$parseDate2 === void 0 ? void 0 : _numfmt$parseDate2.v;
|
|
1207
1290
|
};
|
|
1208
|
-
var DateValidator = class extends
|
|
1291
|
+
var DateValidator = class extends BaseSheetValidator {
|
|
1209
1292
|
constructor(..._args) {
|
|
1210
1293
|
super(..._args);
|
|
1211
1294
|
_defineProperty(this, "id", _univerjs_core.DataValidationType.DATE);
|
|
1212
|
-
_defineProperty(this, "title", "
|
|
1295
|
+
_defineProperty(this, "title", "sheets-data-validation.date.title");
|
|
1213
1296
|
_defineProperty(this, "order", 40);
|
|
1214
1297
|
_defineProperty(this, "operators", [
|
|
1215
1298
|
_univerjs_core.DataValidationOperator.BETWEEN,
|
|
@@ -1249,7 +1332,7 @@ var DateValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
1249
1332
|
const operator = rule.operator;
|
|
1250
1333
|
if (!operator) return { success: true };
|
|
1251
1334
|
const formula1Success = this._validatorSingleFormula(rule.formula1);
|
|
1252
|
-
const errorMsg = this.localeService.t("
|
|
1335
|
+
const errorMsg = this.localeService.t("sheets-data-validation.validFail.date");
|
|
1253
1336
|
if (TWO_FORMULA_OPERATOR_COUNT.includes(operator)) {
|
|
1254
1337
|
const formula2Success = this._validatorSingleFormula(rule.formula2);
|
|
1255
1338
|
return {
|
|
@@ -1305,67 +1388,18 @@ var DateValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
1305
1388
|
}
|
|
1306
1389
|
};
|
|
1307
1390
|
|
|
1308
|
-
//#endregion
|
|
1309
|
-
//#region src/types/const/operator-text-map.ts
|
|
1310
|
-
/**
|
|
1311
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1312
|
-
*
|
|
1313
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1314
|
-
* you may not use this file except in compliance with the License.
|
|
1315
|
-
* You may obtain a copy of the License at
|
|
1316
|
-
*
|
|
1317
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1318
|
-
*
|
|
1319
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1320
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1321
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1322
|
-
* See the License for the specific language governing permissions and
|
|
1323
|
-
* limitations under the License.
|
|
1324
|
-
*/
|
|
1325
|
-
const OperatorTextMap = {
|
|
1326
|
-
[_univerjs_core.DataValidationOperator.BETWEEN]: "dataValidation.operators.between",
|
|
1327
|
-
[_univerjs_core.DataValidationOperator.EQUAL]: "dataValidation.operators.equal",
|
|
1328
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "dataValidation.operators.greaterThan",
|
|
1329
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "dataValidation.operators.greaterThanOrEqual",
|
|
1330
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN]: "dataValidation.operators.lessThan",
|
|
1331
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "dataValidation.operators.lessThanOrEqual",
|
|
1332
|
-
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "dataValidation.operators.notBetween",
|
|
1333
|
-
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "dataValidation.operators.notEqual"
|
|
1334
|
-
};
|
|
1335
|
-
const OperatorTitleMap = {
|
|
1336
|
-
[_univerjs_core.DataValidationOperator.BETWEEN]: "dataValidation.ruleName.between",
|
|
1337
|
-
[_univerjs_core.DataValidationOperator.EQUAL]: "dataValidation.ruleName.equal",
|
|
1338
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "dataValidation.ruleName.greaterThan",
|
|
1339
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "dataValidation.ruleName.greaterThanOrEqual",
|
|
1340
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN]: "dataValidation.ruleName.lessThan",
|
|
1341
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "dataValidation.ruleName.lessThanOrEqual",
|
|
1342
|
-
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "dataValidation.ruleName.notBetween",
|
|
1343
|
-
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "dataValidation.ruleName.notEqual"
|
|
1344
|
-
};
|
|
1345
|
-
const OperatorErrorTitleMap = {
|
|
1346
|
-
[_univerjs_core.DataValidationOperator.BETWEEN]: "dataValidation.errorMsg.between",
|
|
1347
|
-
[_univerjs_core.DataValidationOperator.EQUAL]: "dataValidation.errorMsg.equal",
|
|
1348
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "dataValidation.errorMsg.greaterThan",
|
|
1349
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "dataValidation.errorMsg.greaterThanOrEqual",
|
|
1350
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN]: "dataValidation.errorMsg.lessThan",
|
|
1351
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "dataValidation.errorMsg.lessThanOrEqual",
|
|
1352
|
-
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "dataValidation.errorMsg.notBetween",
|
|
1353
|
-
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "dataValidation.errorMsg.notEqual",
|
|
1354
|
-
NONE: "dataValidation.errorMsg.legal"
|
|
1355
|
-
};
|
|
1356
|
-
|
|
1357
1391
|
//#endregion
|
|
1358
1392
|
//#region src/validators/decimal-validator.ts
|
|
1359
1393
|
function getCellValueNumber(cellValue) {
|
|
1360
1394
|
return +cellValue;
|
|
1361
1395
|
}
|
|
1362
|
-
var DecimalValidator = class extends
|
|
1396
|
+
var DecimalValidator = class extends BaseSheetValidator {
|
|
1363
1397
|
constructor(..._args) {
|
|
1364
1398
|
super(..._args);
|
|
1365
1399
|
_defineProperty(this, "_customFormulaService", this.injector.get(DataValidationCustomFormulaService));
|
|
1366
1400
|
_defineProperty(this, "id", _univerjs_core.DataValidationType.DECIMAL);
|
|
1367
1401
|
_defineProperty(this, "_lexerTreeBuilder", this.injector.get(_univerjs_engine_formula.LexerTreeBuilder));
|
|
1368
|
-
_defineProperty(this, "title", "
|
|
1402
|
+
_defineProperty(this, "title", "sheets-data-validation.decimal.title");
|
|
1369
1403
|
_defineProperty(this, "order", 20);
|
|
1370
1404
|
_defineProperty(this, "operators", [
|
|
1371
1405
|
_univerjs_core.DataValidationOperator.BETWEEN,
|
|
@@ -1414,7 +1448,7 @@ var DecimalValidator = class extends _univerjs_data_validation.BaseDataValidator
|
|
|
1414
1448
|
const formula1Success = _univerjs_core.Tools.isDefine(rule.formula1) && this._isFormulaOrNumber(rule.formula1);
|
|
1415
1449
|
const formula2Success = _univerjs_core.Tools.isDefine(rule.formula2) && this._isFormulaOrNumber(rule.formula2);
|
|
1416
1450
|
const isTwoFormula = TWO_FORMULA_OPERATOR_COUNT.includes(operator);
|
|
1417
|
-
const errorMsg = this.localeService.t("
|
|
1451
|
+
const errorMsg = this.localeService.t("sheets-data-validation.validFail.number");
|
|
1418
1452
|
if (isTwoFormula) return {
|
|
1419
1453
|
success: formula1Success && formula2Success,
|
|
1420
1454
|
formula1: formula1Success ? void 0 : errorMsg,
|
|
@@ -1476,7 +1510,7 @@ function isRuleIntersects(rule, sheetName) {
|
|
|
1476
1510
|
}
|
|
1477
1511
|
return false;
|
|
1478
1512
|
}
|
|
1479
|
-
var ListValidator = class extends
|
|
1513
|
+
var ListValidator = class extends BaseSheetValidator {
|
|
1480
1514
|
constructor(..._args) {
|
|
1481
1515
|
super(..._args);
|
|
1482
1516
|
_defineProperty(this, "formulaService", this.injector.get(DataValidationFormulaService));
|
|
@@ -1486,7 +1520,7 @@ var ListValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
1486
1520
|
_defineProperty(this, "order", 50);
|
|
1487
1521
|
_defineProperty(this, "offsetFormulaByRange", false);
|
|
1488
1522
|
_defineProperty(this, "id", _univerjs_core.DataValidationType.LIST);
|
|
1489
|
-
_defineProperty(this, "title", "
|
|
1523
|
+
_defineProperty(this, "title", "sheets-data-validation.list.title");
|
|
1490
1524
|
_defineProperty(this, "operators", []);
|
|
1491
1525
|
_defineProperty(this, "scopes", ["sheet"]);
|
|
1492
1526
|
_defineProperty(this, "skipDefaultFontRender", (rule) => {
|
|
@@ -1501,7 +1535,7 @@ var ListValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
1501
1535
|
const isIntersects = isRuleIntersects(rule, sheetName !== null && sheetName !== void 0 ? sheetName : "");
|
|
1502
1536
|
return {
|
|
1503
1537
|
success: Boolean(success && valid && !isIntersects),
|
|
1504
|
-
formula1: success ? valid ? !isIntersects ? void 0 : this.localeService.t("
|
|
1538
|
+
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")
|
|
1505
1539
|
};
|
|
1506
1540
|
}
|
|
1507
1541
|
getExtraStyle(rule, value, { style: defaultStyle }) {
|
|
@@ -1517,7 +1551,7 @@ var ListValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
1517
1551
|
return { tb };
|
|
1518
1552
|
}
|
|
1519
1553
|
parseCellValue(cellValue) {
|
|
1520
|
-
return deserializeListOptions(cellValue.toString());
|
|
1554
|
+
return (0, _univerjs_sheets.deserializeListOptions)(cellValue.toString());
|
|
1521
1555
|
}
|
|
1522
1556
|
async parseFormula(rule, unitId, subUnitId) {
|
|
1523
1557
|
var _results$;
|
|
@@ -1532,18 +1566,18 @@ var ListValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
1532
1566
|
async isValidType(cellInfo, formula, rule) {
|
|
1533
1567
|
const { value, unitId, subUnitId } = cellInfo;
|
|
1534
1568
|
const { formula1 = "" } = rule;
|
|
1535
|
-
const formula1Result = (0, _univerjs_core.isFormulaString)(formula1) ? this._listCacheService.getOrCompute(unitId, subUnitId, rule).list : deserializeListOptions(formula1);
|
|
1569
|
+
const formula1Result = (0, _univerjs_core.isFormulaString)(formula1) ? this._listCacheService.getOrCompute(unitId, subUnitId, rule).list : (0, _univerjs_sheets.deserializeListOptions)(formula1);
|
|
1536
1570
|
return this.parseCellValue(value).every((i) => formula1Result.includes(i));
|
|
1537
1571
|
}
|
|
1538
1572
|
generateRuleName() {
|
|
1539
|
-
return this.localeService.t("
|
|
1573
|
+
return this.localeService.t("sheets-data-validation.list.name");
|
|
1540
1574
|
}
|
|
1541
1575
|
generateRuleErrorMessage() {
|
|
1542
|
-
return this.localeService.t("
|
|
1576
|
+
return this.localeService.t("sheets-data-validation.list.error");
|
|
1543
1577
|
}
|
|
1544
1578
|
_getUnitAndSubUnit(currentUnitId, currentSubUnitId) {
|
|
1545
1579
|
var _ref2, _ref3;
|
|
1546
|
-
const workbook = (_ref2 = currentUnitId ? this._univerInstanceService.getUniverSheetInstance(currentUnitId) : void 0) !== null && _ref2 !== void 0 ? _ref2 : this._univerInstanceService.
|
|
1580
|
+
const workbook = (_ref2 = currentUnitId ? this._univerInstanceService.getUniverSheetInstance(currentUnitId) : void 0) !== null && _ref2 !== void 0 ? _ref2 : this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
1547
1581
|
if (!workbook) return null;
|
|
1548
1582
|
const worksheet = (_ref3 = currentSubUnitId ? workbook.getSheetBySheetId(currentSubUnitId) : void 0) !== null && _ref3 !== void 0 ? _ref3 : workbook.getActiveSheet();
|
|
1549
1583
|
if (!worksheet) return null;
|
|
@@ -1565,7 +1599,7 @@ var ListValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
1565
1599
|
if (!location) return [];
|
|
1566
1600
|
const { unitId, subUnitId } = location;
|
|
1567
1601
|
const results = await this.formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid);
|
|
1568
|
-
return (0, _univerjs_core.isFormulaString)(formula1) ? getRuleFormulaResultSet(results === null || results === void 0 || (_results$2 = results[0]) === null || _results$2 === void 0 || (_results$2 = _results$2.result) === null || _results$2 === void 0 ? void 0 : _results$2[0][0]) : deserializeListOptions(formula1);
|
|
1602
|
+
return (0, _univerjs_core.isFormulaString)(formula1) ? getRuleFormulaResultSet(results === null || results === void 0 || (_results$2 = results[0]) === null || _results$2 === void 0 || (_results$2 = _results$2.result) === null || _results$2 === void 0 ? void 0 : _results$2[0][0]) : (0, _univerjs_sheets.deserializeListOptions)(formula1);
|
|
1569
1603
|
}
|
|
1570
1604
|
getListWithColor(rule, currentUnitId, currentSubUnitId) {
|
|
1571
1605
|
const location = this._getUnitAndSubUnit(currentUnitId, currentSubUnitId);
|
|
@@ -1583,11 +1617,11 @@ var ListValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
1583
1617
|
|
|
1584
1618
|
//#endregion
|
|
1585
1619
|
//#region src/validators/text-length-validator.ts
|
|
1586
|
-
var TextLengthValidator = class extends
|
|
1620
|
+
var TextLengthValidator = class extends BaseSheetValidator {
|
|
1587
1621
|
constructor(..._args) {
|
|
1588
1622
|
super(..._args);
|
|
1589
1623
|
_defineProperty(this, "id", _univerjs_core.DataValidationType.TEXT_LENGTH);
|
|
1590
|
-
_defineProperty(this, "title", "
|
|
1624
|
+
_defineProperty(this, "title", "sheets-data-validation.textLength.title");
|
|
1591
1625
|
_defineProperty(this, "_lexerTreeBuilder", this.injector.get(_univerjs_engine_formula.LexerTreeBuilder));
|
|
1592
1626
|
_defineProperty(this, "order", 30);
|
|
1593
1627
|
_defineProperty(this, "operators", [
|
|
@@ -1612,7 +1646,7 @@ var TextLengthValidator = class extends _univerjs_data_validation.BaseDataValida
|
|
|
1612
1646
|
const formula1Success = _univerjs_core.Tools.isDefine(rule.formula1) && this._isFormulaOrInt(rule.formula1);
|
|
1613
1647
|
const formula2Success = _univerjs_core.Tools.isDefine(rule.formula2) && this._isFormulaOrInt(rule.formula2);
|
|
1614
1648
|
const isTwoFormula = TWO_FORMULA_OPERATOR_COUNT.includes(operator);
|
|
1615
|
-
const errorMsg = this.localeService.t("
|
|
1649
|
+
const errorMsg = this.localeService.t("sheets-data-validation.validFail.number");
|
|
1616
1650
|
if (isTwoFormula) return {
|
|
1617
1651
|
success: formula1Success && formula2Success,
|
|
1618
1652
|
formula1: formula1Success ? void 0 : errorMsg,
|
|
@@ -1651,7 +1685,7 @@ var TextLengthValidator = class extends _univerjs_data_validation.BaseDataValida
|
|
|
1651
1685
|
generateRuleErrorMessage(rule, pos) {
|
|
1652
1686
|
if (!rule.operator) return this.titleStr;
|
|
1653
1687
|
const { transformedFormula1, transformedFormula2 } = getTransformedFormula(this._lexerTreeBuilder, rule, pos);
|
|
1654
|
-
return `${this.localeService.t(
|
|
1688
|
+
return `${this.localeService.t(TextLengthErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 !== null && transformedFormula1 !== void 0 ? transformedFormula1 : "").replace(FORMULA2, transformedFormula2 !== null && transformedFormula2 !== void 0 ? transformedFormula2 : "")}`;
|
|
1655
1689
|
}
|
|
1656
1690
|
};
|
|
1657
1691
|
|
|
@@ -2246,7 +2280,7 @@ let DataValidationFormulaController = class DataValidationFormulaController exte
|
|
|
2246
2280
|
if (typeof node === "string") continue;
|
|
2247
2281
|
const { token } = node;
|
|
2248
2282
|
const sequenceGrid = (0, _univerjs_engine_formula.deserializeRangeWithSheetWithCache)(token);
|
|
2249
|
-
const workbook = this._univerInstanceService.
|
|
2283
|
+
const workbook = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
2250
2284
|
let targetSheet = workbook.getActiveSheet();
|
|
2251
2285
|
const unitId = workbook.getUnitId();
|
|
2252
2286
|
if (sequenceGrid.sheetName) {
|
|
@@ -2275,7 +2309,7 @@ DataValidationFormulaController = __decorate([
|
|
|
2275
2309
|
//#endregion
|
|
2276
2310
|
//#region package.json
|
|
2277
2311
|
var name = "@univerjs/sheets-data-validation";
|
|
2278
|
-
var version = "0.
|
|
2312
|
+
var version = "0.24.0-insiders.20260528-29f582d";
|
|
2279
2313
|
|
|
2280
2314
|
//#endregion
|
|
2281
2315
|
//#region src/config/config.ts
|
|
@@ -2667,7 +2701,7 @@ let SheetDataValidationSheetController = class SheetDataValidationSheetControlle
|
|
|
2667
2701
|
if (commandInfo.id === _univerjs_sheets.RemoveSheetCommand.id) {
|
|
2668
2702
|
var _workbook$getActiveSh;
|
|
2669
2703
|
const params = commandInfo.params;
|
|
2670
|
-
const unitId = params.unitId || this._univerInstanceService.
|
|
2704
|
+
const unitId = params.unitId || this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET).getUnitId();
|
|
2671
2705
|
const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
|
|
2672
2706
|
if (!workbook) return {
|
|
2673
2707
|
redos: [],
|
|
@@ -2758,11 +2792,11 @@ SheetDataValidationSheetController = __decorate([
|
|
|
2758
2792
|
|
|
2759
2793
|
//#endregion
|
|
2760
2794
|
//#region src/validators/any-validator.ts
|
|
2761
|
-
var AnyValidator = class extends
|
|
2795
|
+
var AnyValidator = class extends BaseSheetValidator {
|
|
2762
2796
|
constructor(..._args) {
|
|
2763
2797
|
super(..._args);
|
|
2764
2798
|
_defineProperty(this, "id", _univerjs_core.DataValidationType.ANY);
|
|
2765
|
-
_defineProperty(this, "title", "
|
|
2799
|
+
_defineProperty(this, "title", "sheets-data-validation.any.title");
|
|
2766
2800
|
_defineProperty(this, "operators", []);
|
|
2767
2801
|
_defineProperty(this, "scopes", ["sheet"]);
|
|
2768
2802
|
_defineProperty(this, "order", 0);
|
|
@@ -2782,17 +2816,17 @@ var AnyValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
2782
2816
|
return true;
|
|
2783
2817
|
}
|
|
2784
2818
|
generateRuleErrorMessage(rule) {
|
|
2785
|
-
return this.localeService.t("
|
|
2819
|
+
return this.localeService.t("sheets-data-validation.any.error");
|
|
2786
2820
|
}
|
|
2787
2821
|
};
|
|
2788
2822
|
|
|
2789
2823
|
//#endregion
|
|
2790
2824
|
//#region src/validators/custom-validator.ts
|
|
2791
|
-
var CustomFormulaValidator = class extends
|
|
2825
|
+
var CustomFormulaValidator = class extends BaseSheetValidator {
|
|
2792
2826
|
constructor(..._args) {
|
|
2793
2827
|
super(..._args);
|
|
2794
2828
|
_defineProperty(this, "id", _univerjs_core.DataValidationType.CUSTOM);
|
|
2795
|
-
_defineProperty(this, "title", "
|
|
2829
|
+
_defineProperty(this, "title", "sheets-data-validation.custom.title");
|
|
2796
2830
|
_defineProperty(this, "operators", []);
|
|
2797
2831
|
_defineProperty(this, "scopes", ["sheet"]);
|
|
2798
2832
|
_defineProperty(this, "order", 60);
|
|
@@ -2806,7 +2840,7 @@ var CustomFormulaValidator = class extends _univerjs_data_validation.BaseDataVal
|
|
|
2806
2840
|
const valid = this._lexerTreeBuilder.checkIfAddBracket(formulaText) === 0 && formulaText.startsWith(_univerjs_engine_formula.operatorToken.EQUALS);
|
|
2807
2841
|
return {
|
|
2808
2842
|
success: success && valid,
|
|
2809
|
-
formula1: success && valid ? "" : this.localeService.t("
|
|
2843
|
+
formula1: success && valid ? "" : this.localeService.t("sheets-data-validation.validFail.formula")
|
|
2810
2844
|
};
|
|
2811
2845
|
}
|
|
2812
2846
|
async parseFormula(_rule, _unitId, _subUnitId) {
|
|
@@ -2831,11 +2865,11 @@ var CustomFormulaValidator = class extends _univerjs_data_validation.BaseDataVal
|
|
|
2831
2865
|
return false;
|
|
2832
2866
|
}
|
|
2833
2867
|
generateRuleErrorMessage(rule) {
|
|
2834
|
-
return this.localeService.t("
|
|
2868
|
+
return this.localeService.t("sheets-data-validation.custom.error");
|
|
2835
2869
|
}
|
|
2836
2870
|
generateRuleName(rule) {
|
|
2837
2871
|
var _rule$formula2;
|
|
2838
|
-
return this.localeService.t("
|
|
2872
|
+
return this.localeService.t("sheets-data-validation.custom.ruleName").replace("{FORMULA1}", (_rule$formula2 = rule.formula1) !== null && _rule$formula2 !== void 0 ? _rule$formula2 : "");
|
|
2839
2873
|
}
|
|
2840
2874
|
};
|
|
2841
2875
|
|
|
@@ -2860,7 +2894,7 @@ var ListMultipleValidator = class extends ListValidator {
|
|
|
2860
2894
|
constructor(..._args) {
|
|
2861
2895
|
super(..._args);
|
|
2862
2896
|
_defineProperty(this, "id", _univerjs_core.DataValidationType.LIST_MULTIPLE);
|
|
2863
|
-
_defineProperty(this, "title", "
|
|
2897
|
+
_defineProperty(this, "title", "sheets-data-validation.listMultiple.title");
|
|
2864
2898
|
_defineProperty(this, "offsetFormulaByRange", false);
|
|
2865
2899
|
_defineProperty(this, "skipDefaultFontRender", () => {
|
|
2866
2900
|
return true;
|
|
@@ -2870,13 +2904,13 @@ var ListMultipleValidator = class extends ListValidator {
|
|
|
2870
2904
|
|
|
2871
2905
|
//#endregion
|
|
2872
2906
|
//#region src/validators/whole-validator.ts
|
|
2873
|
-
var WholeValidator = class extends
|
|
2907
|
+
var WholeValidator = class extends BaseSheetValidator {
|
|
2874
2908
|
constructor(..._args) {
|
|
2875
2909
|
super(..._args);
|
|
2876
2910
|
_defineProperty(this, "_customFormulaService", this.injector.get(DataValidationCustomFormulaService));
|
|
2877
2911
|
_defineProperty(this, "_lexerTreeBuilder", this.injector.get(_univerjs_engine_formula.LexerTreeBuilder));
|
|
2878
2912
|
_defineProperty(this, "id", _univerjs_core.DataValidationType.WHOLE);
|
|
2879
|
-
_defineProperty(this, "title", "
|
|
2913
|
+
_defineProperty(this, "title", "sheets-data-validation.whole.title");
|
|
2880
2914
|
_defineProperty(this, "order", 10);
|
|
2881
2915
|
_defineProperty(this, "operators", [
|
|
2882
2916
|
_univerjs_core.DataValidationOperator.BETWEEN,
|
|
@@ -2928,7 +2962,7 @@ var WholeValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
2928
2962
|
const formula1Success = _univerjs_core.Tools.isDefine(rule.formula1) && this._isFormulaOrInt(rule.formula1);
|
|
2929
2963
|
const formula2Success = _univerjs_core.Tools.isDefine(rule.formula2) && this._isFormulaOrInt(rule.formula2);
|
|
2930
2964
|
const isTwoFormula = TWO_FORMULA_OPERATOR_COUNT.includes(operator);
|
|
2931
|
-
const errorMsg = this.localeService.t("
|
|
2965
|
+
const errorMsg = this.localeService.t("sheets-data-validation.validFail.number");
|
|
2932
2966
|
if (isTwoFormula) return {
|
|
2933
2967
|
success: formula1Success && formula2Success,
|
|
2934
2968
|
formula1: formula1Success ? void 0 : errorMsg,
|
|
@@ -2984,7 +3018,7 @@ let DataValidationController = class DataValidationController extends _univerjs_
|
|
|
2984
3018
|
this._sheetInterceptorService.interceptCommand({ getMutations: (commandInfo) => {
|
|
2985
3019
|
if (commandInfo.id === _univerjs_sheets.ClearSelectionAllCommand.id) {
|
|
2986
3020
|
var _this$_selectionManag;
|
|
2987
|
-
const workbook = this._univerInstanceService.
|
|
3021
|
+
const workbook = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
2988
3022
|
const unitId = workbook.getUnitId();
|
|
2989
3023
|
const worksheet = workbook.getActiveSheet();
|
|
2990
3024
|
if (!worksheet) throw new Error("No active sheet found");
|
|
@@ -3015,7 +3049,7 @@ DataValidationController = __decorate([
|
|
|
3015
3049
|
], DataValidationController);
|
|
3016
3050
|
|
|
3017
3051
|
//#endregion
|
|
3018
|
-
//#region src/services/dv-validator
|
|
3052
|
+
//#region src/services/dv-validator.service.ts
|
|
3019
3053
|
let SheetsDataValidationValidatorService = class SheetsDataValidationValidatorService extends _univerjs_core.Disposable {
|
|
3020
3054
|
constructor(_univerInstanceService, _sheetDataValidationModel, _dataValidationCacheService, _lifecycleService) {
|
|
3021
3055
|
super();
|
|
@@ -3028,7 +3062,7 @@ let SheetsDataValidationValidatorService = class SheetsDataValidationValidatorSe
|
|
|
3028
3062
|
_initRecalculate() {
|
|
3029
3063
|
const handleDirtyRanges = (ranges) => {
|
|
3030
3064
|
if (ranges.length === 0) return;
|
|
3031
|
-
const workbook = this._univerInstanceService.
|
|
3065
|
+
const workbook = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
3032
3066
|
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
|
|
3033
3067
|
const map = {};
|
|
3034
3068
|
ranges.flat().forEach((range) => {
|
|
@@ -3090,8 +3124,14 @@ let SheetsDataValidationValidatorService = class SheetsDataValidationValidatorSe
|
|
|
3090
3124
|
if (!workbook) throw new Error(`cannot find current workbook, unitId: ${unitId}`);
|
|
3091
3125
|
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
3092
3126
|
if (!worksheet) throw new Error(`cannot find current worksheet, sheetId: ${subUnitId}`);
|
|
3093
|
-
const
|
|
3094
|
-
const
|
|
3127
|
+
const allRules = this._sheetDataValidationModel.getRules(unitId, subUnitId);
|
|
3128
|
+
const ruleRanges = [];
|
|
3129
|
+
for (const rule of allRules) ruleRanges.push(...rule.ranges);
|
|
3130
|
+
const intersectRanges = [];
|
|
3131
|
+
for (const range of ranges) for (const ruleRange of ruleRanges) {
|
|
3132
|
+
const intersect = (0, _univerjs_core.getIntersectRange)(range, ruleRange);
|
|
3133
|
+
if (intersect) intersectRanges.push(intersect);
|
|
3134
|
+
}
|
|
3095
3135
|
const mergeCells = [];
|
|
3096
3136
|
const result = await Promise.all(intersectRanges.map((range, resultRowIndex) => {
|
|
3097
3137
|
const promises = [];
|
|
@@ -3154,7 +3194,12 @@ let SheetsDataValidationValidatorService = class SheetsDataValidationValidatorSe
|
|
|
3154
3194
|
if (ruleId) ruleIdSet.add(ruleId);
|
|
3155
3195
|
});
|
|
3156
3196
|
});
|
|
3157
|
-
|
|
3197
|
+
const rules = [];
|
|
3198
|
+
for (const id of ruleIdSet) {
|
|
3199
|
+
const rule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, id);
|
|
3200
|
+
if (rule) rules.push(rule);
|
|
3201
|
+
}
|
|
3202
|
+
return rules;
|
|
3158
3203
|
}
|
|
3159
3204
|
getDataValidation(unitId, subUnitId, ranges) {
|
|
3160
3205
|
return this.getDataValidations(unitId, subUnitId, ranges)[0];
|
|
@@ -3250,10 +3295,10 @@ function createDefaultNewRule(accessor) {
|
|
|
3250
3295
|
|
|
3251
3296
|
//#endregion
|
|
3252
3297
|
//#region src/index.ts
|
|
3253
|
-
const CUSTOM_FORMULA_INPUT_NAME = "data-validation.custom-formula-input";
|
|
3254
|
-
const BASE_FORMULA_INPUT_NAME = "data-validation.formula-input";
|
|
3255
|
-
const LIST_FORMULA_INPUT_NAME = "data-validation.list-formula-input";
|
|
3256
|
-
const CHECKBOX_FORMULA_INPUT_NAME = "data-validation.checkbox-formula-input";
|
|
3298
|
+
const CUSTOM_FORMULA_INPUT_NAME = "sheets-data-validation.custom-formula-input";
|
|
3299
|
+
const BASE_FORMULA_INPUT_NAME = "sheets-data-validation.formula-input";
|
|
3300
|
+
const LIST_FORMULA_INPUT_NAME = "sheets-data-validation.list-formula-input";
|
|
3301
|
+
const CHECKBOX_FORMULA_INPUT_NAME = "sheets-data-validation.checkbox-formula-input";
|
|
3257
3302
|
|
|
3258
3303
|
//#endregion
|
|
3259
3304
|
exports.AddSheetDataValidationCommand = AddSheetDataValidationCommand;
|
|
@@ -3323,7 +3368,6 @@ exports.UpdateSheetDataValidationOptionsCommand = UpdateSheetDataValidationOptio
|
|
|
3323
3368
|
exports.UpdateSheetDataValidationRangeCommand = UpdateSheetDataValidationRangeCommand;
|
|
3324
3369
|
exports.UpdateSheetDataValidationSettingCommand = UpdateSheetDataValidationSettingCommand;
|
|
3325
3370
|
exports.createDefaultNewRule = createDefaultNewRule;
|
|
3326
|
-
exports.deserializeListOptions = deserializeListOptions;
|
|
3327
3371
|
exports.getCellValueNumber = getCellValueNumber;
|
|
3328
3372
|
exports.getCellValueOrigin = getCellValueOrigin;
|
|
3329
3373
|
exports.getDataValidationCellValue = getDataValidationCellValue;
|
|
@@ -3332,5 +3376,4 @@ exports.getFormulaCellData = getFormulaCellData;
|
|
|
3332
3376
|
exports.getFormulaResult = getFormulaResult;
|
|
3333
3377
|
exports.getTransformedFormula = getTransformedFormula;
|
|
3334
3378
|
exports.isLegalFormulaResult = isLegalFormulaResult;
|
|
3335
|
-
exports.serializeListOptions = serializeListOptions;
|
|
3336
3379
|
exports.transformCheckboxValue = transformCheckboxValue;
|