@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/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CellValueType, CommandType, DataValidationOperator, DataValidationRenderMode, DataValidationStatus, DataValidationType, DependentOn, Disposable, ICommandService, IConfigService, IPermissionService, IUndoRedoService, IUniverInstanceService, Inject, Injector, LifecycleService, LifecycleStages, ObjectMatrix, Plugin, RBush, Range, Rectangle, RxDisposable, Tools, UniverInstanceType, WrapStrategy, bufferDebounceTime, dateKit, debounce, generateRandomId, getIntersectRange, getOriginCellValue, isFormulaString, isRangesEqual, merge, numfmt, sequenceExecute, toDisposable } from "@univerjs/core";
|
|
2
|
-
import { AddDataValidationMutation, BaseDataValidator, DataValidationModel, DataValidatorRegistryService, RemoveDataValidationMutation,
|
|
2
|
+
import { AddDataValidationMutation, BaseDataValidator, DataValidationModel, DataValidatorRegistryService, RemoveDataValidationMutation, UniverDataValidationPlugin, UpdateDataValidationMutation, UpdateRuleType, getRuleOptions, getRuleSetting } from "@univerjs/data-validation";
|
|
3
3
|
import { ERROR_TYPE_SET, LexerTreeBuilder, OtherFormulaBizType, RegisterOtherFormulaService, deserializeRangeWithSheet, deserializeRangeWithSheetWithCache, isReferenceString, operatorToken, sequenceNodeType } from "@univerjs/engine-formula";
|
|
4
|
-
import { ClearSelectionAllCommand, CopySheetCommand, RefRangeService, RemoveSheetCommand, RemoveSheetMutation, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SheetInterceptorService, SheetsSelectionsService, WorksheetViewPermission, getSheetCommandTarget, handleCommonDefaultRangeChangeWithEffectRefCommands } from "@univerjs/sheets";
|
|
4
|
+
import { ClearSelectionAllCommand, CopySheetCommand, RefRangeService, RemoveSheetCommand, RemoveSheetMutation, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SheetInterceptorService, SheetsSelectionsService, WorksheetViewPermission, deserializeListOptions, getSheetCommandTarget, handleCommonDefaultRangeChangeWithEffectRefCommands } from "@univerjs/sheets";
|
|
5
5
|
import { Subject, bufferWhen, filter, skip } from "rxjs";
|
|
6
6
|
import { UnitAction } from "@univerjs/protocol";
|
|
7
7
|
import { FormulaRefRangeService, UniverSheetsFormulaPlugin } from "@univerjs/sheets-formula";
|
|
@@ -85,7 +85,14 @@ let DataValidationCacheService = class DataValidationCacheService extends Dispos
|
|
|
85
85
|
if (cellValue) {
|
|
86
86
|
const range = new ObjectMatrix(cellValue).getDataRange();
|
|
87
87
|
if (range.endRow === -1) return;
|
|
88
|
-
const
|
|
88
|
+
const rules = this._sheetDataValidationModel.getRules(unitId, subUnitId);
|
|
89
|
+
const ranges = [];
|
|
90
|
+
for (const rule of rules) ranges.push(...rule.ranges);
|
|
91
|
+
const intersectsRanges = [];
|
|
92
|
+
for (const ruleRange of ranges) {
|
|
93
|
+
const intersect = getIntersectRange(ruleRange, range);
|
|
94
|
+
if (intersect) intersectsRanges.push(intersect);
|
|
95
|
+
}
|
|
89
96
|
if (intersectsRanges.length) this.markRangeDirty(unitId, subUnitId, intersectsRanges, true);
|
|
90
97
|
}
|
|
91
98
|
}
|
|
@@ -381,31 +388,6 @@ function getStringCellValue(cell) {
|
|
|
381
388
|
return String((_getCellValueOrigin = getCellValueOrigin(cell)) !== null && _getCellValueOrigin !== void 0 ? _getCellValueOrigin : "");
|
|
382
389
|
}
|
|
383
390
|
|
|
384
|
-
//#endregion
|
|
385
|
-
//#region src/validators/util.ts
|
|
386
|
-
function serializeListOptions(options) {
|
|
387
|
-
return options.filter(Boolean).join(",");
|
|
388
|
-
}
|
|
389
|
-
function deserializeListOptions(optionsStr) {
|
|
390
|
-
return optionsStr.split(",").filter(Boolean);
|
|
391
|
-
}
|
|
392
|
-
function getDataValidationCellValue(cellData) {
|
|
393
|
-
const cellValue = getCellValueOrigin(cellData);
|
|
394
|
-
if (cellValue === void 0 || cellValue === null) return "";
|
|
395
|
-
return cellValue.toString();
|
|
396
|
-
}
|
|
397
|
-
function getTransformedFormula(lexerTreeBuilder, rule, position) {
|
|
398
|
-
const { formula1, formula2 } = rule;
|
|
399
|
-
const originStartRow = rule.ranges[0].startRow;
|
|
400
|
-
const originStartColumn = rule.ranges[0].startColumn;
|
|
401
|
-
const offsetRow = position.row - originStartRow;
|
|
402
|
-
const offsetColumn = position.col - originStartColumn;
|
|
403
|
-
return {
|
|
404
|
-
transformedFormula1: isFormulaString(formula1) ? lexerTreeBuilder.moveFormulaRefOffset(formula1, offsetColumn, offsetRow, true) : formula1,
|
|
405
|
-
transformedFormula2: isFormulaString(formula2) ? lexerTreeBuilder.moveFormulaRefOffset(formula2, offsetColumn, offsetRow, true) : formula2
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
|
|
409
391
|
//#endregion
|
|
410
392
|
//#region src/services/dv-list-cache.service.ts
|
|
411
393
|
let DataValidationListCacheService = class DataValidationListCacheService extends Disposable {
|
|
@@ -1004,21 +986,103 @@ SheetDataValidationModel = __decorate([
|
|
|
1004
986
|
__decorateParam(6, ICommandService)
|
|
1005
987
|
], SheetDataValidationModel);
|
|
1006
988
|
|
|
989
|
+
//#endregion
|
|
990
|
+
//#region src/types/const/operator-text-map.ts
|
|
991
|
+
/**
|
|
992
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
993
|
+
*
|
|
994
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
995
|
+
* you may not use this file except in compliance with the License.
|
|
996
|
+
* You may obtain a copy of the License at
|
|
997
|
+
*
|
|
998
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
999
|
+
*
|
|
1000
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1001
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1002
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1003
|
+
* See the License for the specific language governing permissions and
|
|
1004
|
+
* limitations under the License.
|
|
1005
|
+
*/
|
|
1006
|
+
const OperatorTextMap = {
|
|
1007
|
+
[DataValidationOperator.BETWEEN]: "sheets-data-validation.operators.between",
|
|
1008
|
+
[DataValidationOperator.EQUAL]: "sheets-data-validation.operators.equal",
|
|
1009
|
+
[DataValidationOperator.GREATER_THAN]: "sheets-data-validation.operators.greaterThan",
|
|
1010
|
+
[DataValidationOperator.GREATER_THAN_OR_EQUAL]: "sheets-data-validation.operators.greaterThanOrEqual",
|
|
1011
|
+
[DataValidationOperator.LESS_THAN]: "sheets-data-validation.operators.lessThan",
|
|
1012
|
+
[DataValidationOperator.LESS_THAN_OR_EQUAL]: "sheets-data-validation.operators.lessThanOrEqual",
|
|
1013
|
+
[DataValidationOperator.NOT_BETWEEN]: "sheets-data-validation.operators.notBetween",
|
|
1014
|
+
[DataValidationOperator.NOT_EQUAL]: "sheets-data-validation.operators.notEqual"
|
|
1015
|
+
};
|
|
1016
|
+
const OperatorTitleMap = {
|
|
1017
|
+
[DataValidationOperator.BETWEEN]: "sheets-data-validation.ruleName.between",
|
|
1018
|
+
[DataValidationOperator.EQUAL]: "sheets-data-validation.ruleName.equal",
|
|
1019
|
+
[DataValidationOperator.GREATER_THAN]: "sheets-data-validation.ruleName.greaterThan",
|
|
1020
|
+
[DataValidationOperator.GREATER_THAN_OR_EQUAL]: "sheets-data-validation.ruleName.greaterThanOrEqual",
|
|
1021
|
+
[DataValidationOperator.LESS_THAN]: "sheets-data-validation.ruleName.lessThan",
|
|
1022
|
+
[DataValidationOperator.LESS_THAN_OR_EQUAL]: "sheets-data-validation.ruleName.lessThanOrEqual",
|
|
1023
|
+
[DataValidationOperator.NOT_BETWEEN]: "sheets-data-validation.ruleName.notBetween",
|
|
1024
|
+
[DataValidationOperator.NOT_EQUAL]: "sheets-data-validation.ruleName.notEqual",
|
|
1025
|
+
NONE: "sheets-data-validation.ruleName.legal"
|
|
1026
|
+
};
|
|
1027
|
+
const OperatorErrorTitleMap = {
|
|
1028
|
+
[DataValidationOperator.BETWEEN]: "sheets-data-validation.errorMsg.between",
|
|
1029
|
+
[DataValidationOperator.EQUAL]: "sheets-data-validation.errorMsg.equal",
|
|
1030
|
+
[DataValidationOperator.GREATER_THAN]: "sheets-data-validation.errorMsg.greaterThan",
|
|
1031
|
+
[DataValidationOperator.GREATER_THAN_OR_EQUAL]: "sheets-data-validation.errorMsg.greaterThanOrEqual",
|
|
1032
|
+
[DataValidationOperator.LESS_THAN]: "sheets-data-validation.errorMsg.lessThan",
|
|
1033
|
+
[DataValidationOperator.LESS_THAN_OR_EQUAL]: "sheets-data-validation.errorMsg.lessThanOrEqual",
|
|
1034
|
+
[DataValidationOperator.NOT_BETWEEN]: "sheets-data-validation.errorMsg.notBetween",
|
|
1035
|
+
[DataValidationOperator.NOT_EQUAL]: "sheets-data-validation.errorMsg.notEqual",
|
|
1036
|
+
NONE: "sheets-data-validation.errorMsg.legal"
|
|
1037
|
+
};
|
|
1038
|
+
const TextLengthErrorTitleMap = {
|
|
1039
|
+
[DataValidationOperator.BETWEEN]: "sheets-data-validation.textLength.errorMsg.between",
|
|
1040
|
+
[DataValidationOperator.EQUAL]: "sheets-data-validation.textLength.errorMsg.equal",
|
|
1041
|
+
[DataValidationOperator.GREATER_THAN]: "sheets-data-validation.textLength.errorMsg.greaterThan",
|
|
1042
|
+
[DataValidationOperator.GREATER_THAN_OR_EQUAL]: "sheets-data-validation.textLength.errorMsg.greaterThanOrEqual",
|
|
1043
|
+
[DataValidationOperator.LESS_THAN]: "sheets-data-validation.textLength.errorMsg.lessThan",
|
|
1044
|
+
[DataValidationOperator.LESS_THAN_OR_EQUAL]: "sheets-data-validation.textLength.errorMsg.lessThanOrEqual",
|
|
1045
|
+
[DataValidationOperator.NOT_BETWEEN]: "sheets-data-validation.textLength.errorMsg.notBetween",
|
|
1046
|
+
[DataValidationOperator.NOT_EQUAL]: "sheets-data-validation.textLength.errorMsg.notEqual"
|
|
1047
|
+
};
|
|
1048
|
+
|
|
1049
|
+
//#endregion
|
|
1050
|
+
//#region src/validators/base-sheet-validator.ts
|
|
1051
|
+
const FORMULA1$1 = "{FORMULA1}";
|
|
1052
|
+
const FORMULA2$1 = "{FORMULA2}";
|
|
1053
|
+
const TYPE = "{TYPE}";
|
|
1054
|
+
var BaseSheetValidator = class extends BaseDataValidator {
|
|
1055
|
+
get operatorNames() {
|
|
1056
|
+
return this.operators.map((operator) => this.localeService.t(OperatorTextMap[operator]));
|
|
1057
|
+
}
|
|
1058
|
+
generateRuleName(rule) {
|
|
1059
|
+
var _rule$formula, _rule$formula2;
|
|
1060
|
+
if (!rule.operator) return this.localeService.t(OperatorTitleMap.NONE).replace(TYPE, this.titleStr);
|
|
1061
|
+
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 : "");
|
|
1062
|
+
return `${this.titleStr} ${ruleName}`;
|
|
1063
|
+
}
|
|
1064
|
+
generateRuleErrorMessage(rule, _position) {
|
|
1065
|
+
var _rule$formula3, _rule$formula4;
|
|
1066
|
+
if (!rule.operator) return this.localeService.t(OperatorErrorTitleMap.NONE).replace(TYPE, this.titleStr);
|
|
1067
|
+
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 : "")}`;
|
|
1068
|
+
}
|
|
1069
|
+
};
|
|
1070
|
+
|
|
1007
1071
|
//#endregion
|
|
1008
1072
|
//#region src/validators/checkbox-validator.ts
|
|
1009
1073
|
const CHECKBOX_FORMULA_1 = 1;
|
|
1010
1074
|
const CHECKBOX_FORMULA_2 = 0;
|
|
1011
1075
|
function getFailMessage(formula, localeService) {
|
|
1012
|
-
if (Tools.isBlank(formula)) return localeService.t("
|
|
1013
|
-
if (isFormulaString(formula)) return localeService.t("
|
|
1076
|
+
if (Tools.isBlank(formula)) return localeService.t("sheets-data-validation.validFail.value");
|
|
1077
|
+
if (isFormulaString(formula)) return localeService.t("sheets-data-validation.validFail.primitive");
|
|
1014
1078
|
return "";
|
|
1015
1079
|
}
|
|
1016
1080
|
const transformCheckboxValue = (value) => Tools.isDefine(value) && String(value).toLowerCase() === "true" ? "1" : String(value).toLowerCase() === "false" ? "0" : value;
|
|
1017
|
-
var CheckboxValidator = class extends
|
|
1081
|
+
var CheckboxValidator = class extends BaseSheetValidator {
|
|
1018
1082
|
constructor(..._args) {
|
|
1019
1083
|
super(..._args);
|
|
1020
1084
|
_defineProperty(this, "id", DataValidationType.CHECKBOX);
|
|
1021
|
-
_defineProperty(this, "title", "
|
|
1085
|
+
_defineProperty(this, "title", "sheets-data-validation.checkbox.title");
|
|
1022
1086
|
_defineProperty(this, "operators", []);
|
|
1023
1087
|
_defineProperty(this, "scopes", ["sheet"]);
|
|
1024
1088
|
_defineProperty(this, "order", 41);
|
|
@@ -1037,8 +1101,8 @@ var CheckboxValidator = class extends BaseDataValidator {
|
|
|
1037
1101
|
if (Tools.isBlank(formula1) && Tools.isBlank(formula2)) return { success: true };
|
|
1038
1102
|
if (isEqual) return {
|
|
1039
1103
|
success: false,
|
|
1040
|
-
formula1: this.localeService.t("
|
|
1041
|
-
formula2: this.localeService.t("
|
|
1104
|
+
formula1: this.localeService.t("sheets-data-validation.validFail.checkboxEqual"),
|
|
1105
|
+
formula2: this.localeService.t("sheets-data-validation.validFail.checkboxEqual")
|
|
1042
1106
|
};
|
|
1043
1107
|
const error1 = getFailMessage(formula1, this.localeService);
|
|
1044
1108
|
const error2 = getFailMessage(formula2, this.localeService);
|
|
@@ -1088,7 +1152,7 @@ var CheckboxValidator = class extends BaseDataValidator {
|
|
|
1088
1152
|
return Tools.isDefine(value) && (String(value) === String(formula1) || String(value) === String(formula2) || String(value) === String(originFormula1 !== null && originFormula1 !== void 0 ? originFormula1 : "") || String(value) === String(originFormula2 !== null && originFormula2 !== void 0 ? originFormula2 : ""));
|
|
1089
1153
|
}
|
|
1090
1154
|
generateRuleErrorMessage(rule) {
|
|
1091
|
-
return this.localeService.t("
|
|
1155
|
+
return this.localeService.t("sheets-data-validation.checkbox.error");
|
|
1092
1156
|
}
|
|
1093
1157
|
generateRuleName(rule) {
|
|
1094
1158
|
return this.titleStr;
|
|
@@ -1113,46 +1177,46 @@ var CheckboxValidator = class extends BaseDataValidator {
|
|
|
1113
1177
|
* limitations under the License.
|
|
1114
1178
|
*/
|
|
1115
1179
|
const DateOperatorNameMap = {
|
|
1116
|
-
[DataValidationOperator.BETWEEN]: "
|
|
1117
|
-
[DataValidationOperator.EQUAL]: "
|
|
1118
|
-
[DataValidationOperator.GREATER_THAN]: "
|
|
1119
|
-
[DataValidationOperator.GREATER_THAN_OR_EQUAL]: "
|
|
1120
|
-
[DataValidationOperator.LESS_THAN]: "
|
|
1121
|
-
[DataValidationOperator.LESS_THAN_OR_EQUAL]: "
|
|
1122
|
-
[DataValidationOperator.NOT_BETWEEN]: "
|
|
1123
|
-
[DataValidationOperator.NOT_EQUAL]: "
|
|
1180
|
+
[DataValidationOperator.BETWEEN]: "sheets-data-validation.date.operators.between",
|
|
1181
|
+
[DataValidationOperator.EQUAL]: "sheets-data-validation.date.operators.equal",
|
|
1182
|
+
[DataValidationOperator.GREATER_THAN]: "sheets-data-validation.date.operators.greaterThan",
|
|
1183
|
+
[DataValidationOperator.GREATER_THAN_OR_EQUAL]: "sheets-data-validation.date.operators.greaterThanOrEqual",
|
|
1184
|
+
[DataValidationOperator.LESS_THAN]: "sheets-data-validation.date.operators.lessThan",
|
|
1185
|
+
[DataValidationOperator.LESS_THAN_OR_EQUAL]: "sheets-data-validation.date.operators.lessThanOrEqual",
|
|
1186
|
+
[DataValidationOperator.NOT_BETWEEN]: "sheets-data-validation.date.operators.notBetween",
|
|
1187
|
+
[DataValidationOperator.NOT_EQUAL]: "sheets-data-validation.date.operators.notEqual"
|
|
1124
1188
|
};
|
|
1125
1189
|
const DateOperatorTextMap = {
|
|
1126
|
-
[DataValidationOperator.BETWEEN]: "
|
|
1127
|
-
[DataValidationOperator.EQUAL]: "
|
|
1128
|
-
[DataValidationOperator.GREATER_THAN]: "
|
|
1129
|
-
[DataValidationOperator.GREATER_THAN_OR_EQUAL]: "
|
|
1130
|
-
[DataValidationOperator.LESS_THAN]: "
|
|
1131
|
-
[DataValidationOperator.LESS_THAN_OR_EQUAL]: "
|
|
1132
|
-
[DataValidationOperator.NOT_BETWEEN]: "
|
|
1133
|
-
[DataValidationOperator.NOT_EQUAL]: "
|
|
1190
|
+
[DataValidationOperator.BETWEEN]: "sheets-data-validation.date.operators.between",
|
|
1191
|
+
[DataValidationOperator.EQUAL]: "sheets-data-validation.date.operators.equal",
|
|
1192
|
+
[DataValidationOperator.GREATER_THAN]: "sheets-data-validation.date.operators.greaterThan",
|
|
1193
|
+
[DataValidationOperator.GREATER_THAN_OR_EQUAL]: "sheets-data-validation.date.operators.greaterThanOrEqual",
|
|
1194
|
+
[DataValidationOperator.LESS_THAN]: "sheets-data-validation.date.operators.lessThan",
|
|
1195
|
+
[DataValidationOperator.LESS_THAN_OR_EQUAL]: "sheets-data-validation.date.operators.lessThanOrEqual",
|
|
1196
|
+
[DataValidationOperator.NOT_BETWEEN]: "sheets-data-validation.date.operators.notBetween",
|
|
1197
|
+
[DataValidationOperator.NOT_EQUAL]: "sheets-data-validation.date.operators.notEqual"
|
|
1134
1198
|
};
|
|
1135
1199
|
const DateOperatorTitleMap = {
|
|
1136
|
-
[DataValidationOperator.BETWEEN]: "
|
|
1137
|
-
[DataValidationOperator.EQUAL]: "
|
|
1138
|
-
[DataValidationOperator.GREATER_THAN]: "
|
|
1139
|
-
[DataValidationOperator.GREATER_THAN_OR_EQUAL]: "
|
|
1140
|
-
[DataValidationOperator.LESS_THAN]: "
|
|
1141
|
-
[DataValidationOperator.LESS_THAN_OR_EQUAL]: "
|
|
1142
|
-
[DataValidationOperator.NOT_BETWEEN]: "
|
|
1143
|
-
[DataValidationOperator.NOT_EQUAL]: "
|
|
1144
|
-
NONE: "
|
|
1200
|
+
[DataValidationOperator.BETWEEN]: "sheets-data-validation.date.ruleName.between",
|
|
1201
|
+
[DataValidationOperator.EQUAL]: "sheets-data-validation.date.ruleName.equal",
|
|
1202
|
+
[DataValidationOperator.GREATER_THAN]: "sheets-data-validation.date.ruleName.greaterThan",
|
|
1203
|
+
[DataValidationOperator.GREATER_THAN_OR_EQUAL]: "sheets-data-validation.date.ruleName.greaterThanOrEqual",
|
|
1204
|
+
[DataValidationOperator.LESS_THAN]: "sheets-data-validation.date.ruleName.lessThan",
|
|
1205
|
+
[DataValidationOperator.LESS_THAN_OR_EQUAL]: "sheets-data-validation.date.ruleName.lessThanOrEqual",
|
|
1206
|
+
[DataValidationOperator.NOT_BETWEEN]: "sheets-data-validation.date.ruleName.notBetween",
|
|
1207
|
+
[DataValidationOperator.NOT_EQUAL]: "sheets-data-validation.date.ruleName.notEqual",
|
|
1208
|
+
NONE: "sheets-data-validation.date.ruleName.legal"
|
|
1145
1209
|
};
|
|
1146
1210
|
const DateOperatorErrorTitleMap = {
|
|
1147
|
-
[DataValidationOperator.BETWEEN]: "
|
|
1148
|
-
[DataValidationOperator.EQUAL]: "
|
|
1149
|
-
[DataValidationOperator.GREATER_THAN]: "
|
|
1150
|
-
[DataValidationOperator.GREATER_THAN_OR_EQUAL]: "
|
|
1151
|
-
[DataValidationOperator.LESS_THAN]: "
|
|
1152
|
-
[DataValidationOperator.LESS_THAN_OR_EQUAL]: "
|
|
1153
|
-
[DataValidationOperator.NOT_BETWEEN]: "
|
|
1154
|
-
[DataValidationOperator.NOT_EQUAL]: "
|
|
1155
|
-
NONE: "
|
|
1211
|
+
[DataValidationOperator.BETWEEN]: "sheets-data-validation.date.errorMsg.between",
|
|
1212
|
+
[DataValidationOperator.EQUAL]: "sheets-data-validation.date.errorMsg.equal",
|
|
1213
|
+
[DataValidationOperator.GREATER_THAN]: "sheets-data-validation.date.errorMsg.greaterThan",
|
|
1214
|
+
[DataValidationOperator.GREATER_THAN_OR_EQUAL]: "sheets-data-validation.date.errorMsg.greaterThanOrEqual",
|
|
1215
|
+
[DataValidationOperator.LESS_THAN]: "sheets-data-validation.date.errorMsg.lessThan",
|
|
1216
|
+
[DataValidationOperator.LESS_THAN_OR_EQUAL]: "sheets-data-validation.date.errorMsg.lessThanOrEqual",
|
|
1217
|
+
[DataValidationOperator.NOT_BETWEEN]: "sheets-data-validation.date.errorMsg.notBetween",
|
|
1218
|
+
[DataValidationOperator.NOT_EQUAL]: "sheets-data-validation.date.errorMsg.notEqual",
|
|
1219
|
+
NONE: "sheets-data-validation.date.errorMsg.legal"
|
|
1156
1220
|
};
|
|
1157
1221
|
|
|
1158
1222
|
//#endregion
|
|
@@ -1194,6 +1258,25 @@ const TWO_FORMULA_OPERATOR_COUNT = [DataValidationOperator.BETWEEN, DataValidati
|
|
|
1194
1258
|
const FORMULA1 = "{FORMULA1}";
|
|
1195
1259
|
const FORMULA2 = "{FORMULA2}";
|
|
1196
1260
|
|
|
1261
|
+
//#endregion
|
|
1262
|
+
//#region src/validators/util.ts
|
|
1263
|
+
function getDataValidationCellValue(cellData) {
|
|
1264
|
+
const cellValue = getCellValueOrigin(cellData);
|
|
1265
|
+
if (cellValue === void 0 || cellValue === null) return "";
|
|
1266
|
+
return cellValue.toString();
|
|
1267
|
+
}
|
|
1268
|
+
function getTransformedFormula(lexerTreeBuilder, rule, position) {
|
|
1269
|
+
const { formula1, formula2 } = rule;
|
|
1270
|
+
const originStartRow = rule.ranges[0].startRow;
|
|
1271
|
+
const originStartColumn = rule.ranges[0].startColumn;
|
|
1272
|
+
const offsetRow = position.row - originStartRow;
|
|
1273
|
+
const offsetColumn = position.col - originStartColumn;
|
|
1274
|
+
return {
|
|
1275
|
+
transformedFormula1: isFormulaString(formula1) ? lexerTreeBuilder.moveFormulaRefOffset(formula1, offsetColumn, offsetRow, true) : formula1,
|
|
1276
|
+
transformedFormula2: isFormulaString(formula2) ? lexerTreeBuilder.moveFormulaRefOffset(formula2, offsetColumn, offsetRow, true) : formula2
|
|
1277
|
+
};
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1197
1280
|
//#endregion
|
|
1198
1281
|
//#region src/validators/date-validator.ts
|
|
1199
1282
|
const transformDate2SerialNumber = (value) => {
|
|
@@ -1204,11 +1287,11 @@ const transformDate2SerialNumber = (value) => {
|
|
|
1204
1287
|
if (Tools.isDefine(v)) return v;
|
|
1205
1288
|
return (_numfmt$parseDate2 = numfmt.parseDate(dateKit(value).format("YYYY-MM-DD HH:mm:ss"))) === null || _numfmt$parseDate2 === void 0 ? void 0 : _numfmt$parseDate2.v;
|
|
1206
1289
|
};
|
|
1207
|
-
var DateValidator = class extends
|
|
1290
|
+
var DateValidator = class extends BaseSheetValidator {
|
|
1208
1291
|
constructor(..._args) {
|
|
1209
1292
|
super(..._args);
|
|
1210
1293
|
_defineProperty(this, "id", DataValidationType.DATE);
|
|
1211
|
-
_defineProperty(this, "title", "
|
|
1294
|
+
_defineProperty(this, "title", "sheets-data-validation.date.title");
|
|
1212
1295
|
_defineProperty(this, "order", 40);
|
|
1213
1296
|
_defineProperty(this, "operators", [
|
|
1214
1297
|
DataValidationOperator.BETWEEN,
|
|
@@ -1248,7 +1331,7 @@ var DateValidator = class extends BaseDataValidator {
|
|
|
1248
1331
|
const operator = rule.operator;
|
|
1249
1332
|
if (!operator) return { success: true };
|
|
1250
1333
|
const formula1Success = this._validatorSingleFormula(rule.formula1);
|
|
1251
|
-
const errorMsg = this.localeService.t("
|
|
1334
|
+
const errorMsg = this.localeService.t("sheets-data-validation.validFail.date");
|
|
1252
1335
|
if (TWO_FORMULA_OPERATOR_COUNT.includes(operator)) {
|
|
1253
1336
|
const formula2Success = this._validatorSingleFormula(rule.formula2);
|
|
1254
1337
|
return {
|
|
@@ -1304,67 +1387,18 @@ var DateValidator = class extends BaseDataValidator {
|
|
|
1304
1387
|
}
|
|
1305
1388
|
};
|
|
1306
1389
|
|
|
1307
|
-
//#endregion
|
|
1308
|
-
//#region src/types/const/operator-text-map.ts
|
|
1309
|
-
/**
|
|
1310
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1311
|
-
*
|
|
1312
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1313
|
-
* you may not use this file except in compliance with the License.
|
|
1314
|
-
* You may obtain a copy of the License at
|
|
1315
|
-
*
|
|
1316
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1317
|
-
*
|
|
1318
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1319
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1320
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1321
|
-
* See the License for the specific language governing permissions and
|
|
1322
|
-
* limitations under the License.
|
|
1323
|
-
*/
|
|
1324
|
-
const OperatorTextMap = {
|
|
1325
|
-
[DataValidationOperator.BETWEEN]: "dataValidation.operators.between",
|
|
1326
|
-
[DataValidationOperator.EQUAL]: "dataValidation.operators.equal",
|
|
1327
|
-
[DataValidationOperator.GREATER_THAN]: "dataValidation.operators.greaterThan",
|
|
1328
|
-
[DataValidationOperator.GREATER_THAN_OR_EQUAL]: "dataValidation.operators.greaterThanOrEqual",
|
|
1329
|
-
[DataValidationOperator.LESS_THAN]: "dataValidation.operators.lessThan",
|
|
1330
|
-
[DataValidationOperator.LESS_THAN_OR_EQUAL]: "dataValidation.operators.lessThanOrEqual",
|
|
1331
|
-
[DataValidationOperator.NOT_BETWEEN]: "dataValidation.operators.notBetween",
|
|
1332
|
-
[DataValidationOperator.NOT_EQUAL]: "dataValidation.operators.notEqual"
|
|
1333
|
-
};
|
|
1334
|
-
const OperatorTitleMap = {
|
|
1335
|
-
[DataValidationOperator.BETWEEN]: "dataValidation.ruleName.between",
|
|
1336
|
-
[DataValidationOperator.EQUAL]: "dataValidation.ruleName.equal",
|
|
1337
|
-
[DataValidationOperator.GREATER_THAN]: "dataValidation.ruleName.greaterThan",
|
|
1338
|
-
[DataValidationOperator.GREATER_THAN_OR_EQUAL]: "dataValidation.ruleName.greaterThanOrEqual",
|
|
1339
|
-
[DataValidationOperator.LESS_THAN]: "dataValidation.ruleName.lessThan",
|
|
1340
|
-
[DataValidationOperator.LESS_THAN_OR_EQUAL]: "dataValidation.ruleName.lessThanOrEqual",
|
|
1341
|
-
[DataValidationOperator.NOT_BETWEEN]: "dataValidation.ruleName.notBetween",
|
|
1342
|
-
[DataValidationOperator.NOT_EQUAL]: "dataValidation.ruleName.notEqual"
|
|
1343
|
-
};
|
|
1344
|
-
const OperatorErrorTitleMap = {
|
|
1345
|
-
[DataValidationOperator.BETWEEN]: "dataValidation.errorMsg.between",
|
|
1346
|
-
[DataValidationOperator.EQUAL]: "dataValidation.errorMsg.equal",
|
|
1347
|
-
[DataValidationOperator.GREATER_THAN]: "dataValidation.errorMsg.greaterThan",
|
|
1348
|
-
[DataValidationOperator.GREATER_THAN_OR_EQUAL]: "dataValidation.errorMsg.greaterThanOrEqual",
|
|
1349
|
-
[DataValidationOperator.LESS_THAN]: "dataValidation.errorMsg.lessThan",
|
|
1350
|
-
[DataValidationOperator.LESS_THAN_OR_EQUAL]: "dataValidation.errorMsg.lessThanOrEqual",
|
|
1351
|
-
[DataValidationOperator.NOT_BETWEEN]: "dataValidation.errorMsg.notBetween",
|
|
1352
|
-
[DataValidationOperator.NOT_EQUAL]: "dataValidation.errorMsg.notEqual",
|
|
1353
|
-
NONE: "dataValidation.errorMsg.legal"
|
|
1354
|
-
};
|
|
1355
|
-
|
|
1356
1390
|
//#endregion
|
|
1357
1391
|
//#region src/validators/decimal-validator.ts
|
|
1358
1392
|
function getCellValueNumber(cellValue) {
|
|
1359
1393
|
return +cellValue;
|
|
1360
1394
|
}
|
|
1361
|
-
var DecimalValidator = class extends
|
|
1395
|
+
var DecimalValidator = class extends BaseSheetValidator {
|
|
1362
1396
|
constructor(..._args) {
|
|
1363
1397
|
super(..._args);
|
|
1364
1398
|
_defineProperty(this, "_customFormulaService", this.injector.get(DataValidationCustomFormulaService));
|
|
1365
1399
|
_defineProperty(this, "id", DataValidationType.DECIMAL);
|
|
1366
1400
|
_defineProperty(this, "_lexerTreeBuilder", this.injector.get(LexerTreeBuilder));
|
|
1367
|
-
_defineProperty(this, "title", "
|
|
1401
|
+
_defineProperty(this, "title", "sheets-data-validation.decimal.title");
|
|
1368
1402
|
_defineProperty(this, "order", 20);
|
|
1369
1403
|
_defineProperty(this, "operators", [
|
|
1370
1404
|
DataValidationOperator.BETWEEN,
|
|
@@ -1413,7 +1447,7 @@ var DecimalValidator = class extends BaseDataValidator {
|
|
|
1413
1447
|
const formula1Success = Tools.isDefine(rule.formula1) && this._isFormulaOrNumber(rule.formula1);
|
|
1414
1448
|
const formula2Success = Tools.isDefine(rule.formula2) && this._isFormulaOrNumber(rule.formula2);
|
|
1415
1449
|
const isTwoFormula = TWO_FORMULA_OPERATOR_COUNT.includes(operator);
|
|
1416
|
-
const errorMsg = this.localeService.t("
|
|
1450
|
+
const errorMsg = this.localeService.t("sheets-data-validation.validFail.number");
|
|
1417
1451
|
if (isTwoFormula) return {
|
|
1418
1452
|
success: formula1Success && formula2Success,
|
|
1419
1453
|
formula1: formula1Success ? void 0 : errorMsg,
|
|
@@ -1475,7 +1509,7 @@ function isRuleIntersects(rule, sheetName) {
|
|
|
1475
1509
|
}
|
|
1476
1510
|
return false;
|
|
1477
1511
|
}
|
|
1478
|
-
var ListValidator = class extends
|
|
1512
|
+
var ListValidator = class extends BaseSheetValidator {
|
|
1479
1513
|
constructor(..._args) {
|
|
1480
1514
|
super(..._args);
|
|
1481
1515
|
_defineProperty(this, "formulaService", this.injector.get(DataValidationFormulaService));
|
|
@@ -1485,7 +1519,7 @@ var ListValidator = class extends BaseDataValidator {
|
|
|
1485
1519
|
_defineProperty(this, "order", 50);
|
|
1486
1520
|
_defineProperty(this, "offsetFormulaByRange", false);
|
|
1487
1521
|
_defineProperty(this, "id", DataValidationType.LIST);
|
|
1488
|
-
_defineProperty(this, "title", "
|
|
1522
|
+
_defineProperty(this, "title", "sheets-data-validation.list.title");
|
|
1489
1523
|
_defineProperty(this, "operators", []);
|
|
1490
1524
|
_defineProperty(this, "scopes", ["sheet"]);
|
|
1491
1525
|
_defineProperty(this, "skipDefaultFontRender", (rule) => {
|
|
@@ -1500,7 +1534,7 @@ var ListValidator = class extends BaseDataValidator {
|
|
|
1500
1534
|
const isIntersects = isRuleIntersects(rule, sheetName !== null && sheetName !== void 0 ? sheetName : "");
|
|
1501
1535
|
return {
|
|
1502
1536
|
success: Boolean(success && valid && !isIntersects),
|
|
1503
|
-
formula1: success ? valid ? !isIntersects ? void 0 : this.localeService.t("
|
|
1537
|
+
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")
|
|
1504
1538
|
};
|
|
1505
1539
|
}
|
|
1506
1540
|
getExtraStyle(rule, value, { style: defaultStyle }) {
|
|
@@ -1535,14 +1569,14 @@ var ListValidator = class extends BaseDataValidator {
|
|
|
1535
1569
|
return this.parseCellValue(value).every((i) => formula1Result.includes(i));
|
|
1536
1570
|
}
|
|
1537
1571
|
generateRuleName() {
|
|
1538
|
-
return this.localeService.t("
|
|
1572
|
+
return this.localeService.t("sheets-data-validation.list.name");
|
|
1539
1573
|
}
|
|
1540
1574
|
generateRuleErrorMessage() {
|
|
1541
|
-
return this.localeService.t("
|
|
1575
|
+
return this.localeService.t("sheets-data-validation.list.error");
|
|
1542
1576
|
}
|
|
1543
1577
|
_getUnitAndSubUnit(currentUnitId, currentSubUnitId) {
|
|
1544
1578
|
var _ref2, _ref3;
|
|
1545
|
-
const workbook = (_ref2 = currentUnitId ? this._univerInstanceService.getUniverSheetInstance(currentUnitId) : void 0) !== null && _ref2 !== void 0 ? _ref2 : this._univerInstanceService.
|
|
1579
|
+
const workbook = (_ref2 = currentUnitId ? this._univerInstanceService.getUniverSheetInstance(currentUnitId) : void 0) !== null && _ref2 !== void 0 ? _ref2 : this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
1546
1580
|
if (!workbook) return null;
|
|
1547
1581
|
const worksheet = (_ref3 = currentSubUnitId ? workbook.getSheetBySheetId(currentSubUnitId) : void 0) !== null && _ref3 !== void 0 ? _ref3 : workbook.getActiveSheet();
|
|
1548
1582
|
if (!worksheet) return null;
|
|
@@ -1582,11 +1616,11 @@ var ListValidator = class extends BaseDataValidator {
|
|
|
1582
1616
|
|
|
1583
1617
|
//#endregion
|
|
1584
1618
|
//#region src/validators/text-length-validator.ts
|
|
1585
|
-
var TextLengthValidator = class extends
|
|
1619
|
+
var TextLengthValidator = class extends BaseSheetValidator {
|
|
1586
1620
|
constructor(..._args) {
|
|
1587
1621
|
super(..._args);
|
|
1588
1622
|
_defineProperty(this, "id", DataValidationType.TEXT_LENGTH);
|
|
1589
|
-
_defineProperty(this, "title", "
|
|
1623
|
+
_defineProperty(this, "title", "sheets-data-validation.textLength.title");
|
|
1590
1624
|
_defineProperty(this, "_lexerTreeBuilder", this.injector.get(LexerTreeBuilder));
|
|
1591
1625
|
_defineProperty(this, "order", 30);
|
|
1592
1626
|
_defineProperty(this, "operators", [
|
|
@@ -1611,7 +1645,7 @@ var TextLengthValidator = class extends BaseDataValidator {
|
|
|
1611
1645
|
const formula1Success = Tools.isDefine(rule.formula1) && this._isFormulaOrInt(rule.formula1);
|
|
1612
1646
|
const formula2Success = Tools.isDefine(rule.formula2) && this._isFormulaOrInt(rule.formula2);
|
|
1613
1647
|
const isTwoFormula = TWO_FORMULA_OPERATOR_COUNT.includes(operator);
|
|
1614
|
-
const errorMsg = this.localeService.t("
|
|
1648
|
+
const errorMsg = this.localeService.t("sheets-data-validation.validFail.number");
|
|
1615
1649
|
if (isTwoFormula) return {
|
|
1616
1650
|
success: formula1Success && formula2Success,
|
|
1617
1651
|
formula1: formula1Success ? void 0 : errorMsg,
|
|
@@ -2245,7 +2279,7 @@ let DataValidationFormulaController = class DataValidationFormulaController exte
|
|
|
2245
2279
|
if (typeof node === "string") continue;
|
|
2246
2280
|
const { token } = node;
|
|
2247
2281
|
const sequenceGrid = deserializeRangeWithSheetWithCache(token);
|
|
2248
|
-
const workbook = this._univerInstanceService.
|
|
2282
|
+
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
2249
2283
|
let targetSheet = workbook.getActiveSheet();
|
|
2250
2284
|
const unitId = workbook.getUnitId();
|
|
2251
2285
|
if (sequenceGrid.sheetName) {
|
|
@@ -2274,7 +2308,7 @@ DataValidationFormulaController = __decorate([
|
|
|
2274
2308
|
//#endregion
|
|
2275
2309
|
//#region package.json
|
|
2276
2310
|
var name = "@univerjs/sheets-data-validation";
|
|
2277
|
-
var version = "0.
|
|
2311
|
+
var version = "0.24.0-insiders.20260528-29f582d";
|
|
2278
2312
|
|
|
2279
2313
|
//#endregion
|
|
2280
2314
|
//#region src/config/config.ts
|
|
@@ -2666,7 +2700,7 @@ let SheetDataValidationSheetController = class SheetDataValidationSheetControlle
|
|
|
2666
2700
|
if (commandInfo.id === RemoveSheetCommand.id) {
|
|
2667
2701
|
var _workbook$getActiveSh;
|
|
2668
2702
|
const params = commandInfo.params;
|
|
2669
|
-
const unitId = params.unitId || this._univerInstanceService.
|
|
2703
|
+
const unitId = params.unitId || this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET).getUnitId();
|
|
2670
2704
|
const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
|
|
2671
2705
|
if (!workbook) return {
|
|
2672
2706
|
redos: [],
|
|
@@ -2757,11 +2791,11 @@ SheetDataValidationSheetController = __decorate([
|
|
|
2757
2791
|
|
|
2758
2792
|
//#endregion
|
|
2759
2793
|
//#region src/validators/any-validator.ts
|
|
2760
|
-
var AnyValidator = class extends
|
|
2794
|
+
var AnyValidator = class extends BaseSheetValidator {
|
|
2761
2795
|
constructor(..._args) {
|
|
2762
2796
|
super(..._args);
|
|
2763
2797
|
_defineProperty(this, "id", DataValidationType.ANY);
|
|
2764
|
-
_defineProperty(this, "title", "
|
|
2798
|
+
_defineProperty(this, "title", "sheets-data-validation.any.title");
|
|
2765
2799
|
_defineProperty(this, "operators", []);
|
|
2766
2800
|
_defineProperty(this, "scopes", ["sheet"]);
|
|
2767
2801
|
_defineProperty(this, "order", 0);
|
|
@@ -2781,17 +2815,17 @@ var AnyValidator = class extends BaseDataValidator {
|
|
|
2781
2815
|
return true;
|
|
2782
2816
|
}
|
|
2783
2817
|
generateRuleErrorMessage(rule) {
|
|
2784
|
-
return this.localeService.t("
|
|
2818
|
+
return this.localeService.t("sheets-data-validation.any.error");
|
|
2785
2819
|
}
|
|
2786
2820
|
};
|
|
2787
2821
|
|
|
2788
2822
|
//#endregion
|
|
2789
2823
|
//#region src/validators/custom-validator.ts
|
|
2790
|
-
var CustomFormulaValidator = class extends
|
|
2824
|
+
var CustomFormulaValidator = class extends BaseSheetValidator {
|
|
2791
2825
|
constructor(..._args) {
|
|
2792
2826
|
super(..._args);
|
|
2793
2827
|
_defineProperty(this, "id", DataValidationType.CUSTOM);
|
|
2794
|
-
_defineProperty(this, "title", "
|
|
2828
|
+
_defineProperty(this, "title", "sheets-data-validation.custom.title");
|
|
2795
2829
|
_defineProperty(this, "operators", []);
|
|
2796
2830
|
_defineProperty(this, "scopes", ["sheet"]);
|
|
2797
2831
|
_defineProperty(this, "order", 60);
|
|
@@ -2805,7 +2839,7 @@ var CustomFormulaValidator = class extends BaseDataValidator {
|
|
|
2805
2839
|
const valid = this._lexerTreeBuilder.checkIfAddBracket(formulaText) === 0 && formulaText.startsWith(operatorToken.EQUALS);
|
|
2806
2840
|
return {
|
|
2807
2841
|
success: success && valid,
|
|
2808
|
-
formula1: success && valid ? "" : this.localeService.t("
|
|
2842
|
+
formula1: success && valid ? "" : this.localeService.t("sheets-data-validation.validFail.formula")
|
|
2809
2843
|
};
|
|
2810
2844
|
}
|
|
2811
2845
|
async parseFormula(_rule, _unitId, _subUnitId) {
|
|
@@ -2830,11 +2864,11 @@ var CustomFormulaValidator = class extends BaseDataValidator {
|
|
|
2830
2864
|
return false;
|
|
2831
2865
|
}
|
|
2832
2866
|
generateRuleErrorMessage(rule) {
|
|
2833
|
-
return this.localeService.t("
|
|
2867
|
+
return this.localeService.t("sheets-data-validation.custom.error");
|
|
2834
2868
|
}
|
|
2835
2869
|
generateRuleName(rule) {
|
|
2836
2870
|
var _rule$formula2;
|
|
2837
|
-
return this.localeService.t("
|
|
2871
|
+
return this.localeService.t("sheets-data-validation.custom.ruleName").replace("{FORMULA1}", (_rule$formula2 = rule.formula1) !== null && _rule$formula2 !== void 0 ? _rule$formula2 : "");
|
|
2838
2872
|
}
|
|
2839
2873
|
};
|
|
2840
2874
|
|
|
@@ -2859,7 +2893,7 @@ var ListMultipleValidator = class extends ListValidator {
|
|
|
2859
2893
|
constructor(..._args) {
|
|
2860
2894
|
super(..._args);
|
|
2861
2895
|
_defineProperty(this, "id", DataValidationType.LIST_MULTIPLE);
|
|
2862
|
-
_defineProperty(this, "title", "
|
|
2896
|
+
_defineProperty(this, "title", "sheets-data-validation.listMultiple.title");
|
|
2863
2897
|
_defineProperty(this, "offsetFormulaByRange", false);
|
|
2864
2898
|
_defineProperty(this, "skipDefaultFontRender", () => {
|
|
2865
2899
|
return true;
|
|
@@ -2869,13 +2903,13 @@ var ListMultipleValidator = class extends ListValidator {
|
|
|
2869
2903
|
|
|
2870
2904
|
//#endregion
|
|
2871
2905
|
//#region src/validators/whole-validator.ts
|
|
2872
|
-
var WholeValidator = class extends
|
|
2906
|
+
var WholeValidator = class extends BaseSheetValidator {
|
|
2873
2907
|
constructor(..._args) {
|
|
2874
2908
|
super(..._args);
|
|
2875
2909
|
_defineProperty(this, "_customFormulaService", this.injector.get(DataValidationCustomFormulaService));
|
|
2876
2910
|
_defineProperty(this, "_lexerTreeBuilder", this.injector.get(LexerTreeBuilder));
|
|
2877
2911
|
_defineProperty(this, "id", DataValidationType.WHOLE);
|
|
2878
|
-
_defineProperty(this, "title", "
|
|
2912
|
+
_defineProperty(this, "title", "sheets-data-validation.whole.title");
|
|
2879
2913
|
_defineProperty(this, "order", 10);
|
|
2880
2914
|
_defineProperty(this, "operators", [
|
|
2881
2915
|
DataValidationOperator.BETWEEN,
|
|
@@ -2927,7 +2961,7 @@ var WholeValidator = class extends BaseDataValidator {
|
|
|
2927
2961
|
const formula1Success = Tools.isDefine(rule.formula1) && this._isFormulaOrInt(rule.formula1);
|
|
2928
2962
|
const formula2Success = Tools.isDefine(rule.formula2) && this._isFormulaOrInt(rule.formula2);
|
|
2929
2963
|
const isTwoFormula = TWO_FORMULA_OPERATOR_COUNT.includes(operator);
|
|
2930
|
-
const errorMsg = this.localeService.t("
|
|
2964
|
+
const errorMsg = this.localeService.t("sheets-data-validation.validFail.number");
|
|
2931
2965
|
if (isTwoFormula) return {
|
|
2932
2966
|
success: formula1Success && formula2Success,
|
|
2933
2967
|
formula1: formula1Success ? void 0 : errorMsg,
|
|
@@ -2983,7 +3017,7 @@ let DataValidationController = class DataValidationController extends RxDisposab
|
|
|
2983
3017
|
this._sheetInterceptorService.interceptCommand({ getMutations: (commandInfo) => {
|
|
2984
3018
|
if (commandInfo.id === ClearSelectionAllCommand.id) {
|
|
2985
3019
|
var _this$_selectionManag;
|
|
2986
|
-
const workbook = this._univerInstanceService.
|
|
3020
|
+
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
2987
3021
|
const unitId = workbook.getUnitId();
|
|
2988
3022
|
const worksheet = workbook.getActiveSheet();
|
|
2989
3023
|
if (!worksheet) throw new Error("No active sheet found");
|
|
@@ -3014,7 +3048,7 @@ DataValidationController = __decorate([
|
|
|
3014
3048
|
], DataValidationController);
|
|
3015
3049
|
|
|
3016
3050
|
//#endregion
|
|
3017
|
-
//#region src/services/dv-validator
|
|
3051
|
+
//#region src/services/dv-validator.service.ts
|
|
3018
3052
|
let SheetsDataValidationValidatorService = class SheetsDataValidationValidatorService extends Disposable {
|
|
3019
3053
|
constructor(_univerInstanceService, _sheetDataValidationModel, _dataValidationCacheService, _lifecycleService) {
|
|
3020
3054
|
super();
|
|
@@ -3027,7 +3061,7 @@ let SheetsDataValidationValidatorService = class SheetsDataValidationValidatorSe
|
|
|
3027
3061
|
_initRecalculate() {
|
|
3028
3062
|
const handleDirtyRanges = (ranges) => {
|
|
3029
3063
|
if (ranges.length === 0) return;
|
|
3030
|
-
const workbook = this._univerInstanceService.
|
|
3064
|
+
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
3031
3065
|
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
|
|
3032
3066
|
const map = {};
|
|
3033
3067
|
ranges.flat().forEach((range) => {
|
|
@@ -3089,8 +3123,14 @@ let SheetsDataValidationValidatorService = class SheetsDataValidationValidatorSe
|
|
|
3089
3123
|
if (!workbook) throw new Error(`cannot find current workbook, unitId: ${unitId}`);
|
|
3090
3124
|
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
3091
3125
|
if (!worksheet) throw new Error(`cannot find current worksheet, sheetId: ${subUnitId}`);
|
|
3092
|
-
const
|
|
3093
|
-
const
|
|
3126
|
+
const allRules = this._sheetDataValidationModel.getRules(unitId, subUnitId);
|
|
3127
|
+
const ruleRanges = [];
|
|
3128
|
+
for (const rule of allRules) ruleRanges.push(...rule.ranges);
|
|
3129
|
+
const intersectRanges = [];
|
|
3130
|
+
for (const range of ranges) for (const ruleRange of ruleRanges) {
|
|
3131
|
+
const intersect = getIntersectRange(range, ruleRange);
|
|
3132
|
+
if (intersect) intersectRanges.push(intersect);
|
|
3133
|
+
}
|
|
3094
3134
|
const mergeCells = [];
|
|
3095
3135
|
const result = await Promise.all(intersectRanges.map((range, resultRowIndex) => {
|
|
3096
3136
|
const promises = [];
|
|
@@ -3153,7 +3193,12 @@ let SheetsDataValidationValidatorService = class SheetsDataValidationValidatorSe
|
|
|
3153
3193
|
if (ruleId) ruleIdSet.add(ruleId);
|
|
3154
3194
|
});
|
|
3155
3195
|
});
|
|
3156
|
-
|
|
3196
|
+
const rules = [];
|
|
3197
|
+
for (const id of ruleIdSet) {
|
|
3198
|
+
const rule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, id);
|
|
3199
|
+
if (rule) rules.push(rule);
|
|
3200
|
+
}
|
|
3201
|
+
return rules;
|
|
3157
3202
|
}
|
|
3158
3203
|
getDataValidation(unitId, subUnitId, ranges) {
|
|
3159
3204
|
return this.getDataValidations(unitId, subUnitId, ranges)[0];
|
|
@@ -3249,10 +3294,10 @@ function createDefaultNewRule(accessor) {
|
|
|
3249
3294
|
|
|
3250
3295
|
//#endregion
|
|
3251
3296
|
//#region src/index.ts
|
|
3252
|
-
const CUSTOM_FORMULA_INPUT_NAME = "data-validation.custom-formula-input";
|
|
3253
|
-
const BASE_FORMULA_INPUT_NAME = "data-validation.formula-input";
|
|
3254
|
-
const LIST_FORMULA_INPUT_NAME = "data-validation.list-formula-input";
|
|
3255
|
-
const CHECKBOX_FORMULA_INPUT_NAME = "data-validation.checkbox-formula-input";
|
|
3297
|
+
const CUSTOM_FORMULA_INPUT_NAME = "sheets-data-validation.custom-formula-input";
|
|
3298
|
+
const BASE_FORMULA_INPUT_NAME = "sheets-data-validation.formula-input";
|
|
3299
|
+
const LIST_FORMULA_INPUT_NAME = "sheets-data-validation.list-formula-input";
|
|
3300
|
+
const CHECKBOX_FORMULA_INPUT_NAME = "sheets-data-validation.checkbox-formula-input";
|
|
3256
3301
|
|
|
3257
3302
|
//#endregion
|
|
3258
|
-
export { AddSheetDataValidationCommand, BASE_FORMULA_INPUT_NAME, CHECKBOX_FORMULA_1, CHECKBOX_FORMULA_2, CHECKBOX_FORMULA_INPUT_NAME, CUSTOM_FORMULA_INPUT_NAME, CheckboxValidator, ClearRangeDataValidationCommand, DATA_VALIDATION_PLUGIN_NAME, DataValidationCacheService, DataValidationCustomFormulaService, DataValidationFormulaController, DataValidationFormulaService, DataValidationListCacheService, DateValidator, LIST_FORMULA_INPUT_NAME, ListMultipleValidator, ListValidator, RemoveSheetAllDataValidationCommand, RemoveSheetDataValidationCommand, SheetDataValidationModel, SheetsDataValidationValidatorService, UniverSheetsDataValidationPlugin, UpdateSheetDataValidationOptionsCommand, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand, createDefaultNewRule,
|
|
3303
|
+
export { AddSheetDataValidationCommand, BASE_FORMULA_INPUT_NAME, CHECKBOX_FORMULA_1, CHECKBOX_FORMULA_2, CHECKBOX_FORMULA_INPUT_NAME, CUSTOM_FORMULA_INPUT_NAME, CheckboxValidator, ClearRangeDataValidationCommand, DATA_VALIDATION_PLUGIN_NAME, DataValidationCacheService, DataValidationCustomFormulaService, DataValidationFormulaController, DataValidationFormulaService, DataValidationListCacheService, DateValidator, LIST_FORMULA_INPUT_NAME, ListMultipleValidator, ListValidator, RemoveSheetAllDataValidationCommand, RemoveSheetDataValidationCommand, SheetDataValidationModel, SheetsDataValidationValidatorService, UniverSheetsDataValidationPlugin, UpdateSheetDataValidationOptionsCommand, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand, createDefaultNewRule, getCellValueNumber, getCellValueOrigin, getDataValidationCellValue, getDataValidationDiffMutations, getFormulaCellData, getFormulaResult, getTransformedFormula, isLegalFormulaResult, transformCheckboxValue };
|