@univerjs/sheets-data-validation 0.24.0 → 0.25.0-insiders.20260604-29ebbff
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 +114 -128
- package/lib/cjs/index.js +185 -160
- 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 +115 -129
- package/lib/es/index.js +183 -156
- 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 +115 -129
- package/lib/index.js +183 -156
- 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 +5 -5
- 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 +14 -9
- package/LICENSE +0 -176
package/lib/cjs/index.js
CHANGED
|
@@ -7,7 +7,7 @@ let rxjs = require("rxjs");
|
|
|
7
7
|
let _univerjs_protocol = require("@univerjs/protocol");
|
|
8
8
|
let _univerjs_sheets_formula = require("@univerjs/sheets-formula");
|
|
9
9
|
|
|
10
|
-
//#region \0@oxc-project+runtime@0.
|
|
10
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
|
|
11
11
|
function _typeof(o) {
|
|
12
12
|
"@babel/helpers - typeof";
|
|
13
13
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -18,7 +18,7 @@ function _typeof(o) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
//#endregion
|
|
21
|
-
//#region \0@oxc-project+runtime@0.
|
|
21
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
|
|
22
22
|
function toPrimitive(t, r) {
|
|
23
23
|
if ("object" != _typeof(t) || !t) return t;
|
|
24
24
|
var e = t[Symbol.toPrimitive];
|
|
@@ -31,14 +31,14 @@ function toPrimitive(t, r) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
//#endregion
|
|
34
|
-
//#region \0@oxc-project+runtime@0.
|
|
34
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
|
|
35
35
|
function toPropertyKey(t) {
|
|
36
36
|
var i = toPrimitive(t, "string");
|
|
37
37
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
//#endregion
|
|
41
|
-
//#region \0@oxc-project+runtime@0.
|
|
41
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
|
|
42
42
|
function _defineProperty(e, r, t) {
|
|
43
43
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
44
44
|
value: t,
|
|
@@ -49,7 +49,7 @@ function _defineProperty(e, r, t) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
//#endregion
|
|
52
|
-
//#region \0@oxc-project+runtime@0.
|
|
52
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
|
|
53
53
|
function __decorateParam(paramIndex, decorator) {
|
|
54
54
|
return function(target, key) {
|
|
55
55
|
decorator(target, key, paramIndex);
|
|
@@ -57,7 +57,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
//#endregion
|
|
60
|
-
//#region \0@oxc-project+runtime@0.
|
|
60
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
|
|
61
61
|
function __decorate(decorators, target, key, desc) {
|
|
62
62
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
63
63
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -389,31 +389,6 @@ function getStringCellValue(cell) {
|
|
|
389
389
|
return String((_getCellValueOrigin = getCellValueOrigin(cell)) !== null && _getCellValueOrigin !== void 0 ? _getCellValueOrigin : "");
|
|
390
390
|
}
|
|
391
391
|
|
|
392
|
-
//#endregion
|
|
393
|
-
//#region src/validators/util.ts
|
|
394
|
-
function serializeListOptions(options) {
|
|
395
|
-
return options.filter(Boolean).join(",");
|
|
396
|
-
}
|
|
397
|
-
function deserializeListOptions(optionsStr) {
|
|
398
|
-
return optionsStr.split(",").filter(Boolean);
|
|
399
|
-
}
|
|
400
|
-
function getDataValidationCellValue(cellData) {
|
|
401
|
-
const cellValue = getCellValueOrigin(cellData);
|
|
402
|
-
if (cellValue === void 0 || cellValue === null) return "";
|
|
403
|
-
return cellValue.toString();
|
|
404
|
-
}
|
|
405
|
-
function getTransformedFormula(lexerTreeBuilder, rule, position) {
|
|
406
|
-
const { formula1, formula2 } = rule;
|
|
407
|
-
const originStartRow = rule.ranges[0].startRow;
|
|
408
|
-
const originStartColumn = rule.ranges[0].startColumn;
|
|
409
|
-
const offsetRow = position.row - originStartRow;
|
|
410
|
-
const offsetColumn = position.col - originStartColumn;
|
|
411
|
-
return {
|
|
412
|
-
transformedFormula1: (0, _univerjs_core.isFormulaString)(formula1) ? lexerTreeBuilder.moveFormulaRefOffset(formula1, offsetColumn, offsetRow, true) : formula1,
|
|
413
|
-
transformedFormula2: (0, _univerjs_core.isFormulaString)(formula2) ? lexerTreeBuilder.moveFormulaRefOffset(formula2, offsetColumn, offsetRow, true) : formula2
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
|
|
417
392
|
//#endregion
|
|
418
393
|
//#region src/services/dv-list-cache.service.ts
|
|
419
394
|
let DataValidationListCacheService = class DataValidationListCacheService extends _univerjs_core.Disposable {
|
|
@@ -484,7 +459,7 @@ let DataValidationListCacheService = class DataValidationListCacheService extend
|
|
|
484
459
|
computeAndCache(unitId, subUnitId, rule, formulaResult) {
|
|
485
460
|
var _formulaResult$;
|
|
486
461
|
const { formula1 = "", formula2 = "" } = rule;
|
|
487
|
-
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);
|
|
488
463
|
const colorList = formula2.split(",");
|
|
489
464
|
const listWithColor = list.map((label, i) => ({
|
|
490
465
|
label,
|
|
@@ -1012,21 +987,103 @@ SheetDataValidationModel = __decorate([
|
|
|
1012
987
|
__decorateParam(6, _univerjs_core.ICommandService)
|
|
1013
988
|
], SheetDataValidationModel);
|
|
1014
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
|
+
|
|
1015
1072
|
//#endregion
|
|
1016
1073
|
//#region src/validators/checkbox-validator.ts
|
|
1017
1074
|
const CHECKBOX_FORMULA_1 = 1;
|
|
1018
1075
|
const CHECKBOX_FORMULA_2 = 0;
|
|
1019
1076
|
function getFailMessage(formula, localeService) {
|
|
1020
|
-
if (_univerjs_core.Tools.isBlank(formula)) return localeService.t("
|
|
1021
|
-
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");
|
|
1022
1079
|
return "";
|
|
1023
1080
|
}
|
|
1024
1081
|
const transformCheckboxValue = (value) => _univerjs_core.Tools.isDefine(value) && String(value).toLowerCase() === "true" ? "1" : String(value).toLowerCase() === "false" ? "0" : value;
|
|
1025
|
-
var CheckboxValidator = class extends
|
|
1082
|
+
var CheckboxValidator = class extends BaseSheetValidator {
|
|
1026
1083
|
constructor(..._args) {
|
|
1027
1084
|
super(..._args);
|
|
1028
1085
|
_defineProperty(this, "id", _univerjs_core.DataValidationType.CHECKBOX);
|
|
1029
|
-
_defineProperty(this, "title", "
|
|
1086
|
+
_defineProperty(this, "title", "sheets-data-validation.checkbox.title");
|
|
1030
1087
|
_defineProperty(this, "operators", []);
|
|
1031
1088
|
_defineProperty(this, "scopes", ["sheet"]);
|
|
1032
1089
|
_defineProperty(this, "order", 41);
|
|
@@ -1045,8 +1102,8 @@ var CheckboxValidator = class extends _univerjs_data_validation.BaseDataValidato
|
|
|
1045
1102
|
if (_univerjs_core.Tools.isBlank(formula1) && _univerjs_core.Tools.isBlank(formula2)) return { success: true };
|
|
1046
1103
|
if (isEqual) return {
|
|
1047
1104
|
success: false,
|
|
1048
|
-
formula1: this.localeService.t("
|
|
1049
|
-
formula2: this.localeService.t("
|
|
1105
|
+
formula1: this.localeService.t("sheets-data-validation.validFail.checkboxEqual"),
|
|
1106
|
+
formula2: this.localeService.t("sheets-data-validation.validFail.checkboxEqual")
|
|
1050
1107
|
};
|
|
1051
1108
|
const error1 = getFailMessage(formula1, this.localeService);
|
|
1052
1109
|
const error2 = getFailMessage(formula2, this.localeService);
|
|
@@ -1096,7 +1153,7 @@ var CheckboxValidator = class extends _univerjs_data_validation.BaseDataValidato
|
|
|
1096
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 : ""));
|
|
1097
1154
|
}
|
|
1098
1155
|
generateRuleErrorMessage(rule) {
|
|
1099
|
-
return this.localeService.t("
|
|
1156
|
+
return this.localeService.t("sheets-data-validation.checkbox.error");
|
|
1100
1157
|
}
|
|
1101
1158
|
generateRuleName(rule) {
|
|
1102
1159
|
return this.titleStr;
|
|
@@ -1121,46 +1178,46 @@ var CheckboxValidator = class extends _univerjs_data_validation.BaseDataValidato
|
|
|
1121
1178
|
* limitations under the License.
|
|
1122
1179
|
*/
|
|
1123
1180
|
const DateOperatorNameMap = {
|
|
1124
|
-
[_univerjs_core.DataValidationOperator.BETWEEN]: "
|
|
1125
|
-
[_univerjs_core.DataValidationOperator.EQUAL]: "
|
|
1126
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "
|
|
1127
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "
|
|
1128
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN]: "
|
|
1129
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "
|
|
1130
|
-
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "
|
|
1131
|
-
[_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"
|
|
1132
1189
|
};
|
|
1133
1190
|
const DateOperatorTextMap = {
|
|
1134
|
-
[_univerjs_core.DataValidationOperator.BETWEEN]: "
|
|
1135
|
-
[_univerjs_core.DataValidationOperator.EQUAL]: "
|
|
1136
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "
|
|
1137
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "
|
|
1138
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN]: "
|
|
1139
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "
|
|
1140
|
-
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "
|
|
1141
|
-
[_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"
|
|
1142
1199
|
};
|
|
1143
1200
|
const DateOperatorTitleMap = {
|
|
1144
|
-
[_univerjs_core.DataValidationOperator.BETWEEN]: "
|
|
1145
|
-
[_univerjs_core.DataValidationOperator.EQUAL]: "
|
|
1146
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "
|
|
1147
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "
|
|
1148
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN]: "
|
|
1149
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "
|
|
1150
|
-
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "
|
|
1151
|
-
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "
|
|
1152
|
-
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"
|
|
1153
1210
|
};
|
|
1154
1211
|
const DateOperatorErrorTitleMap = {
|
|
1155
|
-
[_univerjs_core.DataValidationOperator.BETWEEN]: "
|
|
1156
|
-
[_univerjs_core.DataValidationOperator.EQUAL]: "
|
|
1157
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "
|
|
1158
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "
|
|
1159
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN]: "
|
|
1160
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "
|
|
1161
|
-
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "
|
|
1162
|
-
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "
|
|
1163
|
-
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"
|
|
1164
1221
|
};
|
|
1165
1222
|
|
|
1166
1223
|
//#endregion
|
|
@@ -1202,6 +1259,25 @@ const TWO_FORMULA_OPERATOR_COUNT = [_univerjs_core.DataValidationOperator.BETWEE
|
|
|
1202
1259
|
const FORMULA1 = "{FORMULA1}";
|
|
1203
1260
|
const FORMULA2 = "{FORMULA2}";
|
|
1204
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
|
+
|
|
1205
1281
|
//#endregion
|
|
1206
1282
|
//#region src/validators/date-validator.ts
|
|
1207
1283
|
const transformDate2SerialNumber = (value) => {
|
|
@@ -1212,11 +1288,11 @@ const transformDate2SerialNumber = (value) => {
|
|
|
1212
1288
|
if (_univerjs_core.Tools.isDefine(v)) return v;
|
|
1213
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;
|
|
1214
1290
|
};
|
|
1215
|
-
var DateValidator = class extends
|
|
1291
|
+
var DateValidator = class extends BaseSheetValidator {
|
|
1216
1292
|
constructor(..._args) {
|
|
1217
1293
|
super(..._args);
|
|
1218
1294
|
_defineProperty(this, "id", _univerjs_core.DataValidationType.DATE);
|
|
1219
|
-
_defineProperty(this, "title", "
|
|
1295
|
+
_defineProperty(this, "title", "sheets-data-validation.date.title");
|
|
1220
1296
|
_defineProperty(this, "order", 40);
|
|
1221
1297
|
_defineProperty(this, "operators", [
|
|
1222
1298
|
_univerjs_core.DataValidationOperator.BETWEEN,
|
|
@@ -1256,7 +1332,7 @@ var DateValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
1256
1332
|
const operator = rule.operator;
|
|
1257
1333
|
if (!operator) return { success: true };
|
|
1258
1334
|
const formula1Success = this._validatorSingleFormula(rule.formula1);
|
|
1259
|
-
const errorMsg = this.localeService.t("
|
|
1335
|
+
const errorMsg = this.localeService.t("sheets-data-validation.validFail.date");
|
|
1260
1336
|
if (TWO_FORMULA_OPERATOR_COUNT.includes(operator)) {
|
|
1261
1337
|
const formula2Success = this._validatorSingleFormula(rule.formula2);
|
|
1262
1338
|
return {
|
|
@@ -1312,67 +1388,18 @@ var DateValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
1312
1388
|
}
|
|
1313
1389
|
};
|
|
1314
1390
|
|
|
1315
|
-
//#endregion
|
|
1316
|
-
//#region src/types/const/operator-text-map.ts
|
|
1317
|
-
/**
|
|
1318
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1319
|
-
*
|
|
1320
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1321
|
-
* you may not use this file except in compliance with the License.
|
|
1322
|
-
* You may obtain a copy of the License at
|
|
1323
|
-
*
|
|
1324
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1325
|
-
*
|
|
1326
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1327
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1328
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1329
|
-
* See the License for the specific language governing permissions and
|
|
1330
|
-
* limitations under the License.
|
|
1331
|
-
*/
|
|
1332
|
-
const OperatorTextMap = {
|
|
1333
|
-
[_univerjs_core.DataValidationOperator.BETWEEN]: "dataValidation.operators.between",
|
|
1334
|
-
[_univerjs_core.DataValidationOperator.EQUAL]: "dataValidation.operators.equal",
|
|
1335
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "dataValidation.operators.greaterThan",
|
|
1336
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "dataValidation.operators.greaterThanOrEqual",
|
|
1337
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN]: "dataValidation.operators.lessThan",
|
|
1338
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "dataValidation.operators.lessThanOrEqual",
|
|
1339
|
-
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "dataValidation.operators.notBetween",
|
|
1340
|
-
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "dataValidation.operators.notEqual"
|
|
1341
|
-
};
|
|
1342
|
-
const OperatorTitleMap = {
|
|
1343
|
-
[_univerjs_core.DataValidationOperator.BETWEEN]: "dataValidation.ruleName.between",
|
|
1344
|
-
[_univerjs_core.DataValidationOperator.EQUAL]: "dataValidation.ruleName.equal",
|
|
1345
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "dataValidation.ruleName.greaterThan",
|
|
1346
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "dataValidation.ruleName.greaterThanOrEqual",
|
|
1347
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN]: "dataValidation.ruleName.lessThan",
|
|
1348
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "dataValidation.ruleName.lessThanOrEqual",
|
|
1349
|
-
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "dataValidation.ruleName.notBetween",
|
|
1350
|
-
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "dataValidation.ruleName.notEqual"
|
|
1351
|
-
};
|
|
1352
|
-
const OperatorErrorTitleMap = {
|
|
1353
|
-
[_univerjs_core.DataValidationOperator.BETWEEN]: "dataValidation.errorMsg.between",
|
|
1354
|
-
[_univerjs_core.DataValidationOperator.EQUAL]: "dataValidation.errorMsg.equal",
|
|
1355
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN]: "dataValidation.errorMsg.greaterThan",
|
|
1356
|
-
[_univerjs_core.DataValidationOperator.GREATER_THAN_OR_EQUAL]: "dataValidation.errorMsg.greaterThanOrEqual",
|
|
1357
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN]: "dataValidation.errorMsg.lessThan",
|
|
1358
|
-
[_univerjs_core.DataValidationOperator.LESS_THAN_OR_EQUAL]: "dataValidation.errorMsg.lessThanOrEqual",
|
|
1359
|
-
[_univerjs_core.DataValidationOperator.NOT_BETWEEN]: "dataValidation.errorMsg.notBetween",
|
|
1360
|
-
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "dataValidation.errorMsg.notEqual",
|
|
1361
|
-
NONE: "dataValidation.errorMsg.legal"
|
|
1362
|
-
};
|
|
1363
|
-
|
|
1364
1391
|
//#endregion
|
|
1365
1392
|
//#region src/validators/decimal-validator.ts
|
|
1366
1393
|
function getCellValueNumber(cellValue) {
|
|
1367
1394
|
return +cellValue;
|
|
1368
1395
|
}
|
|
1369
|
-
var DecimalValidator = class extends
|
|
1396
|
+
var DecimalValidator = class extends BaseSheetValidator {
|
|
1370
1397
|
constructor(..._args) {
|
|
1371
1398
|
super(..._args);
|
|
1372
1399
|
_defineProperty(this, "_customFormulaService", this.injector.get(DataValidationCustomFormulaService));
|
|
1373
1400
|
_defineProperty(this, "id", _univerjs_core.DataValidationType.DECIMAL);
|
|
1374
1401
|
_defineProperty(this, "_lexerTreeBuilder", this.injector.get(_univerjs_engine_formula.LexerTreeBuilder));
|
|
1375
|
-
_defineProperty(this, "title", "
|
|
1402
|
+
_defineProperty(this, "title", "sheets-data-validation.decimal.title");
|
|
1376
1403
|
_defineProperty(this, "order", 20);
|
|
1377
1404
|
_defineProperty(this, "operators", [
|
|
1378
1405
|
_univerjs_core.DataValidationOperator.BETWEEN,
|
|
@@ -1421,7 +1448,7 @@ var DecimalValidator = class extends _univerjs_data_validation.BaseDataValidator
|
|
|
1421
1448
|
const formula1Success = _univerjs_core.Tools.isDefine(rule.formula1) && this._isFormulaOrNumber(rule.formula1);
|
|
1422
1449
|
const formula2Success = _univerjs_core.Tools.isDefine(rule.formula2) && this._isFormulaOrNumber(rule.formula2);
|
|
1423
1450
|
const isTwoFormula = TWO_FORMULA_OPERATOR_COUNT.includes(operator);
|
|
1424
|
-
const errorMsg = this.localeService.t("
|
|
1451
|
+
const errorMsg = this.localeService.t("sheets-data-validation.validFail.number");
|
|
1425
1452
|
if (isTwoFormula) return {
|
|
1426
1453
|
success: formula1Success && formula2Success,
|
|
1427
1454
|
formula1: formula1Success ? void 0 : errorMsg,
|
|
@@ -1483,7 +1510,7 @@ function isRuleIntersects(rule, sheetName) {
|
|
|
1483
1510
|
}
|
|
1484
1511
|
return false;
|
|
1485
1512
|
}
|
|
1486
|
-
var ListValidator = class extends
|
|
1513
|
+
var ListValidator = class extends BaseSheetValidator {
|
|
1487
1514
|
constructor(..._args) {
|
|
1488
1515
|
super(..._args);
|
|
1489
1516
|
_defineProperty(this, "formulaService", this.injector.get(DataValidationFormulaService));
|
|
@@ -1493,7 +1520,7 @@ var ListValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
1493
1520
|
_defineProperty(this, "order", 50);
|
|
1494
1521
|
_defineProperty(this, "offsetFormulaByRange", false);
|
|
1495
1522
|
_defineProperty(this, "id", _univerjs_core.DataValidationType.LIST);
|
|
1496
|
-
_defineProperty(this, "title", "
|
|
1523
|
+
_defineProperty(this, "title", "sheets-data-validation.list.title");
|
|
1497
1524
|
_defineProperty(this, "operators", []);
|
|
1498
1525
|
_defineProperty(this, "scopes", ["sheet"]);
|
|
1499
1526
|
_defineProperty(this, "skipDefaultFontRender", (rule) => {
|
|
@@ -1508,7 +1535,7 @@ var ListValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
1508
1535
|
const isIntersects = isRuleIntersects(rule, sheetName !== null && sheetName !== void 0 ? sheetName : "");
|
|
1509
1536
|
return {
|
|
1510
1537
|
success: Boolean(success && valid && !isIntersects),
|
|
1511
|
-
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")
|
|
1512
1539
|
};
|
|
1513
1540
|
}
|
|
1514
1541
|
getExtraStyle(rule, value, { style: defaultStyle }) {
|
|
@@ -1524,7 +1551,7 @@ var ListValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
1524
1551
|
return { tb };
|
|
1525
1552
|
}
|
|
1526
1553
|
parseCellValue(cellValue) {
|
|
1527
|
-
return deserializeListOptions(cellValue.toString());
|
|
1554
|
+
return (0, _univerjs_sheets.deserializeListOptions)(cellValue.toString());
|
|
1528
1555
|
}
|
|
1529
1556
|
async parseFormula(rule, unitId, subUnitId) {
|
|
1530
1557
|
var _results$;
|
|
@@ -1539,14 +1566,14 @@ var ListValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
1539
1566
|
async isValidType(cellInfo, formula, rule) {
|
|
1540
1567
|
const { value, unitId, subUnitId } = cellInfo;
|
|
1541
1568
|
const { formula1 = "" } = rule;
|
|
1542
|
-
const formula1Result = (0, _univerjs_core.isFormulaString)(formula1) ? this._listCacheService.getOrCompute(unitId, subUnitId, rule).list : deserializeListOptions(formula1);
|
|
1543
|
-
return this.parseCellValue(value).every((i) => formula1Result.includes(i));
|
|
1569
|
+
const formula1Result = (0, _univerjs_core.isFormulaString)(formula1) ? this._listCacheService.getOrCompute(unitId, subUnitId, rule).list : (0, _univerjs_sheets.deserializeListOptions)(formula1);
|
|
1570
|
+
return (rule.type === _univerjs_core.DataValidationType.LIST ? value === void 0 || value === null || value === "" ? [] : [`${value}`] : this.parseCellValue(value)).every((i) => formula1Result.includes(i));
|
|
1544
1571
|
}
|
|
1545
1572
|
generateRuleName() {
|
|
1546
|
-
return this.localeService.t("
|
|
1573
|
+
return this.localeService.t("sheets-data-validation.list.name");
|
|
1547
1574
|
}
|
|
1548
1575
|
generateRuleErrorMessage() {
|
|
1549
|
-
return this.localeService.t("
|
|
1576
|
+
return this.localeService.t("sheets-data-validation.list.error");
|
|
1550
1577
|
}
|
|
1551
1578
|
_getUnitAndSubUnit(currentUnitId, currentSubUnitId) {
|
|
1552
1579
|
var _ref2, _ref3;
|
|
@@ -1572,7 +1599,7 @@ var ListValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
1572
1599
|
if (!location) return [];
|
|
1573
1600
|
const { unitId, subUnitId } = location;
|
|
1574
1601
|
const results = await this.formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid);
|
|
1575
|
-
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);
|
|
1576
1603
|
}
|
|
1577
1604
|
getListWithColor(rule, currentUnitId, currentSubUnitId) {
|
|
1578
1605
|
const location = this._getUnitAndSubUnit(currentUnitId, currentSubUnitId);
|
|
@@ -1590,11 +1617,11 @@ var ListValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
1590
1617
|
|
|
1591
1618
|
//#endregion
|
|
1592
1619
|
//#region src/validators/text-length-validator.ts
|
|
1593
|
-
var TextLengthValidator = class extends
|
|
1620
|
+
var TextLengthValidator = class extends BaseSheetValidator {
|
|
1594
1621
|
constructor(..._args) {
|
|
1595
1622
|
super(..._args);
|
|
1596
1623
|
_defineProperty(this, "id", _univerjs_core.DataValidationType.TEXT_LENGTH);
|
|
1597
|
-
_defineProperty(this, "title", "
|
|
1624
|
+
_defineProperty(this, "title", "sheets-data-validation.textLength.title");
|
|
1598
1625
|
_defineProperty(this, "_lexerTreeBuilder", this.injector.get(_univerjs_engine_formula.LexerTreeBuilder));
|
|
1599
1626
|
_defineProperty(this, "order", 30);
|
|
1600
1627
|
_defineProperty(this, "operators", [
|
|
@@ -1619,7 +1646,7 @@ var TextLengthValidator = class extends _univerjs_data_validation.BaseDataValida
|
|
|
1619
1646
|
const formula1Success = _univerjs_core.Tools.isDefine(rule.formula1) && this._isFormulaOrInt(rule.formula1);
|
|
1620
1647
|
const formula2Success = _univerjs_core.Tools.isDefine(rule.formula2) && this._isFormulaOrInt(rule.formula2);
|
|
1621
1648
|
const isTwoFormula = TWO_FORMULA_OPERATOR_COUNT.includes(operator);
|
|
1622
|
-
const errorMsg = this.localeService.t("
|
|
1649
|
+
const errorMsg = this.localeService.t("sheets-data-validation.validFail.number");
|
|
1623
1650
|
if (isTwoFormula) return {
|
|
1624
1651
|
success: formula1Success && formula2Success,
|
|
1625
1652
|
formula1: formula1Success ? void 0 : errorMsg,
|
|
@@ -1658,7 +1685,7 @@ var TextLengthValidator = class extends _univerjs_data_validation.BaseDataValida
|
|
|
1658
1685
|
generateRuleErrorMessage(rule, pos) {
|
|
1659
1686
|
if (!rule.operator) return this.titleStr;
|
|
1660
1687
|
const { transformedFormula1, transformedFormula2 } = getTransformedFormula(this._lexerTreeBuilder, rule, pos);
|
|
1661
|
-
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 : "")}`;
|
|
1662
1689
|
}
|
|
1663
1690
|
};
|
|
1664
1691
|
|
|
@@ -2282,7 +2309,7 @@ DataValidationFormulaController = __decorate([
|
|
|
2282
2309
|
//#endregion
|
|
2283
2310
|
//#region package.json
|
|
2284
2311
|
var name = "@univerjs/sheets-data-validation";
|
|
2285
|
-
var version = "0.
|
|
2312
|
+
var version = "0.25.0-insiders.20260604-29ebbff";
|
|
2286
2313
|
|
|
2287
2314
|
//#endregion
|
|
2288
2315
|
//#region src/config/config.ts
|
|
@@ -2765,11 +2792,11 @@ SheetDataValidationSheetController = __decorate([
|
|
|
2765
2792
|
|
|
2766
2793
|
//#endregion
|
|
2767
2794
|
//#region src/validators/any-validator.ts
|
|
2768
|
-
var AnyValidator = class extends
|
|
2795
|
+
var AnyValidator = class extends BaseSheetValidator {
|
|
2769
2796
|
constructor(..._args) {
|
|
2770
2797
|
super(..._args);
|
|
2771
2798
|
_defineProperty(this, "id", _univerjs_core.DataValidationType.ANY);
|
|
2772
|
-
_defineProperty(this, "title", "
|
|
2799
|
+
_defineProperty(this, "title", "sheets-data-validation.any.title");
|
|
2773
2800
|
_defineProperty(this, "operators", []);
|
|
2774
2801
|
_defineProperty(this, "scopes", ["sheet"]);
|
|
2775
2802
|
_defineProperty(this, "order", 0);
|
|
@@ -2789,17 +2816,17 @@ var AnyValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
2789
2816
|
return true;
|
|
2790
2817
|
}
|
|
2791
2818
|
generateRuleErrorMessage(rule) {
|
|
2792
|
-
return this.localeService.t("
|
|
2819
|
+
return this.localeService.t("sheets-data-validation.any.error");
|
|
2793
2820
|
}
|
|
2794
2821
|
};
|
|
2795
2822
|
|
|
2796
2823
|
//#endregion
|
|
2797
2824
|
//#region src/validators/custom-validator.ts
|
|
2798
|
-
var CustomFormulaValidator = class extends
|
|
2825
|
+
var CustomFormulaValidator = class extends BaseSheetValidator {
|
|
2799
2826
|
constructor(..._args) {
|
|
2800
2827
|
super(..._args);
|
|
2801
2828
|
_defineProperty(this, "id", _univerjs_core.DataValidationType.CUSTOM);
|
|
2802
|
-
_defineProperty(this, "title", "
|
|
2829
|
+
_defineProperty(this, "title", "sheets-data-validation.custom.title");
|
|
2803
2830
|
_defineProperty(this, "operators", []);
|
|
2804
2831
|
_defineProperty(this, "scopes", ["sheet"]);
|
|
2805
2832
|
_defineProperty(this, "order", 60);
|
|
@@ -2813,7 +2840,7 @@ var CustomFormulaValidator = class extends _univerjs_data_validation.BaseDataVal
|
|
|
2813
2840
|
const valid = this._lexerTreeBuilder.checkIfAddBracket(formulaText) === 0 && formulaText.startsWith(_univerjs_engine_formula.operatorToken.EQUALS);
|
|
2814
2841
|
return {
|
|
2815
2842
|
success: success && valid,
|
|
2816
|
-
formula1: success && valid ? "" : this.localeService.t("
|
|
2843
|
+
formula1: success && valid ? "" : this.localeService.t("sheets-data-validation.validFail.formula")
|
|
2817
2844
|
};
|
|
2818
2845
|
}
|
|
2819
2846
|
async parseFormula(_rule, _unitId, _subUnitId) {
|
|
@@ -2838,11 +2865,11 @@ var CustomFormulaValidator = class extends _univerjs_data_validation.BaseDataVal
|
|
|
2838
2865
|
return false;
|
|
2839
2866
|
}
|
|
2840
2867
|
generateRuleErrorMessage(rule) {
|
|
2841
|
-
return this.localeService.t("
|
|
2868
|
+
return this.localeService.t("sheets-data-validation.custom.error");
|
|
2842
2869
|
}
|
|
2843
2870
|
generateRuleName(rule) {
|
|
2844
2871
|
var _rule$formula2;
|
|
2845
|
-
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 : "");
|
|
2846
2873
|
}
|
|
2847
2874
|
};
|
|
2848
2875
|
|
|
@@ -2867,7 +2894,7 @@ var ListMultipleValidator = class extends ListValidator {
|
|
|
2867
2894
|
constructor(..._args) {
|
|
2868
2895
|
super(..._args);
|
|
2869
2896
|
_defineProperty(this, "id", _univerjs_core.DataValidationType.LIST_MULTIPLE);
|
|
2870
|
-
_defineProperty(this, "title", "
|
|
2897
|
+
_defineProperty(this, "title", "sheets-data-validation.listMultiple.title");
|
|
2871
2898
|
_defineProperty(this, "offsetFormulaByRange", false);
|
|
2872
2899
|
_defineProperty(this, "skipDefaultFontRender", () => {
|
|
2873
2900
|
return true;
|
|
@@ -2877,13 +2904,13 @@ var ListMultipleValidator = class extends ListValidator {
|
|
|
2877
2904
|
|
|
2878
2905
|
//#endregion
|
|
2879
2906
|
//#region src/validators/whole-validator.ts
|
|
2880
|
-
var WholeValidator = class extends
|
|
2907
|
+
var WholeValidator = class extends BaseSheetValidator {
|
|
2881
2908
|
constructor(..._args) {
|
|
2882
2909
|
super(..._args);
|
|
2883
2910
|
_defineProperty(this, "_customFormulaService", this.injector.get(DataValidationCustomFormulaService));
|
|
2884
2911
|
_defineProperty(this, "_lexerTreeBuilder", this.injector.get(_univerjs_engine_formula.LexerTreeBuilder));
|
|
2885
2912
|
_defineProperty(this, "id", _univerjs_core.DataValidationType.WHOLE);
|
|
2886
|
-
_defineProperty(this, "title", "
|
|
2913
|
+
_defineProperty(this, "title", "sheets-data-validation.whole.title");
|
|
2887
2914
|
_defineProperty(this, "order", 10);
|
|
2888
2915
|
_defineProperty(this, "operators", [
|
|
2889
2916
|
_univerjs_core.DataValidationOperator.BETWEEN,
|
|
@@ -2935,7 +2962,7 @@ var WholeValidator = class extends _univerjs_data_validation.BaseDataValidator {
|
|
|
2935
2962
|
const formula1Success = _univerjs_core.Tools.isDefine(rule.formula1) && this._isFormulaOrInt(rule.formula1);
|
|
2936
2963
|
const formula2Success = _univerjs_core.Tools.isDefine(rule.formula2) && this._isFormulaOrInt(rule.formula2);
|
|
2937
2964
|
const isTwoFormula = TWO_FORMULA_OPERATOR_COUNT.includes(operator);
|
|
2938
|
-
const errorMsg = this.localeService.t("
|
|
2965
|
+
const errorMsg = this.localeService.t("sheets-data-validation.validFail.number");
|
|
2939
2966
|
if (isTwoFormula) return {
|
|
2940
2967
|
success: formula1Success && formula2Success,
|
|
2941
2968
|
formula1: formula1Success ? void 0 : errorMsg,
|
|
@@ -3268,10 +3295,10 @@ function createDefaultNewRule(accessor) {
|
|
|
3268
3295
|
|
|
3269
3296
|
//#endregion
|
|
3270
3297
|
//#region src/index.ts
|
|
3271
|
-
const CUSTOM_FORMULA_INPUT_NAME = "data-validation.custom-formula-input";
|
|
3272
|
-
const BASE_FORMULA_INPUT_NAME = "data-validation.formula-input";
|
|
3273
|
-
const LIST_FORMULA_INPUT_NAME = "data-validation.list-formula-input";
|
|
3274
|
-
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";
|
|
3275
3302
|
|
|
3276
3303
|
//#endregion
|
|
3277
3304
|
exports.AddSheetDataValidationCommand = AddSheetDataValidationCommand;
|
|
@@ -3341,7 +3368,6 @@ exports.UpdateSheetDataValidationOptionsCommand = UpdateSheetDataValidationOptio
|
|
|
3341
3368
|
exports.UpdateSheetDataValidationRangeCommand = UpdateSheetDataValidationRangeCommand;
|
|
3342
3369
|
exports.UpdateSheetDataValidationSettingCommand = UpdateSheetDataValidationSettingCommand;
|
|
3343
3370
|
exports.createDefaultNewRule = createDefaultNewRule;
|
|
3344
|
-
exports.deserializeListOptions = deserializeListOptions;
|
|
3345
3371
|
exports.getCellValueNumber = getCellValueNumber;
|
|
3346
3372
|
exports.getCellValueOrigin = getCellValueOrigin;
|
|
3347
3373
|
exports.getDataValidationCellValue = getDataValidationCellValue;
|
|
@@ -3350,5 +3376,4 @@ exports.getFormulaCellData = getFormulaCellData;
|
|
|
3350
3376
|
exports.getFormulaResult = getFormulaResult;
|
|
3351
3377
|
exports.getTransformedFormula = getTransformedFormula;
|
|
3352
3378
|
exports.isLegalFormulaResult = isLegalFormulaResult;
|
|
3353
|
-
exports.serializeListOptions = serializeListOptions;
|
|
3354
3379
|
exports.transformCheckboxValue = transformCheckboxValue;
|