@univerjs/sheets-data-validation 1.0.0-insiders.20260813-7c9aa50 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +176 -0
- package/README.md +10 -2
- package/lib/cjs/facade.js +19 -12
- package/lib/cjs/index.js +122 -68
- package/lib/cjs/locale/ar-SA.js +5 -26
- package/lib/cjs/locale/ca-ES.js +5 -26
- package/lib/cjs/locale/de-DE.js +5 -26
- package/lib/cjs/locale/en-US.js +5 -26
- package/lib/cjs/locale/es-ES.js +5 -26
- package/lib/cjs/locale/fa-IR.js +5 -26
- package/lib/cjs/locale/fr-FR.js +5 -26
- package/lib/cjs/locale/id-ID.js +5 -26
- package/lib/cjs/locale/it-IT.js +5 -26
- package/lib/cjs/locale/ja-JP.js +5 -26
- package/lib/cjs/locale/ko-KR.js +5 -26
- package/lib/cjs/locale/pl-PL.js +5 -26
- package/lib/cjs/locale/pt-BR.js +5 -26
- package/lib/cjs/locale/ru-RU.js +5 -26
- package/lib/cjs/locale/sk-SK.js +5 -26
- package/lib/cjs/locale/vi-VN.js +5 -26
- package/lib/cjs/locale/zh-CN.js +5 -26
- package/lib/cjs/locale/zh-HK.js +5 -26
- package/lib/cjs/locale/zh-TW.js +5 -26
- package/lib/es/facade.js +20 -13
- package/lib/es/index.js +123 -70
- package/lib/es/locale/ar-SA.js +5 -25
- package/lib/es/locale/ca-ES.js +5 -25
- package/lib/es/locale/de-DE.js +5 -25
- package/lib/es/locale/en-US.js +5 -25
- package/lib/es/locale/es-ES.js +5 -25
- package/lib/es/locale/fa-IR.js +5 -25
- package/lib/es/locale/fr-FR.js +5 -25
- package/lib/es/locale/id-ID.js +5 -25
- package/lib/es/locale/it-IT.js +5 -25
- package/lib/es/locale/ja-JP.js +5 -25
- package/lib/es/locale/ko-KR.js +5 -25
- package/lib/es/locale/pl-PL.js +5 -25
- package/lib/es/locale/pt-BR.js +5 -25
- package/lib/es/locale/ru-RU.js +5 -25
- package/lib/es/locale/sk-SK.js +5 -25
- package/lib/es/locale/vi-VN.js +5 -25
- package/lib/es/locale/zh-CN.js +5 -25
- package/lib/es/locale/zh-HK.js +5 -25
- package/lib/es/locale/zh-TW.js +5 -25
- package/lib/facade.js +20 -13
- package/lib/index.js +123 -70
- package/lib/locale/ar-SA.js +5 -25
- package/lib/locale/ca-ES.js +5 -25
- package/lib/locale/de-DE.js +5 -25
- package/lib/locale/en-US.js +5 -25
- package/lib/locale/es-ES.js +5 -25
- package/lib/locale/fa-IR.js +5 -25
- package/lib/locale/fr-FR.js +5 -25
- package/lib/locale/id-ID.js +5 -25
- package/lib/locale/it-IT.js +5 -25
- package/lib/locale/ja-JP.js +5 -25
- package/lib/locale/ko-KR.js +5 -25
- package/lib/locale/pl-PL.js +5 -25
- package/lib/locale/pt-BR.js +5 -25
- package/lib/locale/ru-RU.js +5 -25
- package/lib/locale/sk-SK.js +5 -25
- package/lib/locale/vi-VN.js +5 -25
- package/lib/locale/zh-CN.js +5 -25
- package/lib/locale/zh-HK.js +5 -25
- package/lib/locale/zh-TW.js +5 -25
- package/lib/types/facade/f-data-validation.d.ts +5 -2
- package/lib/types/facade/f-range.d.ts +1 -1
- package/lib/types/facade/f-workbook.d.ts +3 -3
- package/lib/types/facade/f-worksheet.d.ts +5 -2
- package/lib/types/index.d.ts +1 -0
- package/lib/types/locale/en-US.d.ts +0 -18
- package/lib/types/services/dv-cache.service.d.ts +1 -0
- package/lib/types/utils/range.d.ts +18 -0
- package/lib/types/validators/date-validator.d.ts +3 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +9 -9
package/lib/cjs/locale/zh-TW.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
//#region src/locale/zh-TW.ts
|
|
3
2
|
const locale = { "sheets-data-validation": {
|
|
4
3
|
operators: {
|
|
@@ -9,8 +8,7 @@ const locale = { "sheets-data-validation": {
|
|
|
9
8
|
lessThanOrEqual: "小於或等於",
|
|
10
9
|
equal: "等於",
|
|
11
10
|
notEqual: "不等於",
|
|
12
|
-
notBetween: "未介於"
|
|
13
|
-
legal: "是合法類型"
|
|
11
|
+
notBetween: "未介於"
|
|
14
12
|
},
|
|
15
13
|
ruleName: {
|
|
16
14
|
between: "介於 {FORMULA1} 和 {FORMULA2} 之間",
|
|
@@ -43,8 +41,7 @@ const locale = { "sheets-data-validation": {
|
|
|
43
41
|
lessThanOrEqual: "早於或等於",
|
|
44
42
|
equal: "等於",
|
|
45
43
|
notEqual: "不等於",
|
|
46
|
-
notBetween: "未介於"
|
|
47
|
-
legal: "是合法日期"
|
|
44
|
+
notBetween: "未介於"
|
|
48
45
|
},
|
|
49
46
|
ruleName: {
|
|
50
47
|
between: "介於 {FORMULA1} 和 {FORMULA2} 之間",
|
|
@@ -86,20 +83,16 @@ const locale = { "sheets-data-validation": {
|
|
|
86
83
|
custom: {
|
|
87
84
|
ruleName: "自訂公式 {FORMULA1}",
|
|
88
85
|
title: "自訂公式",
|
|
89
|
-
validFail: "請輸入合法的公式",
|
|
90
86
|
error: "此儲存格的內容違反了驗證規則"
|
|
91
87
|
},
|
|
92
88
|
validFail: {
|
|
93
89
|
value: "請輸入一個合法值",
|
|
94
|
-
common: "請輸入數值或公式",
|
|
95
90
|
number: "請輸入合法的數字或公式",
|
|
96
91
|
formula: "請輸入合法的公式",
|
|
97
|
-
integer: "請輸入合法的整數或公式",
|
|
98
92
|
date: "請輸入合法的日期或公式",
|
|
99
93
|
list: "請輸入至少一個合法選項",
|
|
100
94
|
listInvalid: "清單來源必須是分隔清單或單列或欄的參考。 ",
|
|
101
95
|
checkboxEqual: "為勾選和未勾選的儲存格內容輸入不同的值。 ",
|
|
102
|
-
formulaError: "引用範圍內包含不可見的數據,請重新調整範圍",
|
|
103
96
|
listIntersects: "所選範圍不能和規則範圍相交",
|
|
104
97
|
primitive: "自訂勾選和未勾選值不允許使用公式。 "
|
|
105
98
|
},
|
|
@@ -110,28 +103,14 @@ const locale = { "sheets-data-validation": {
|
|
|
110
103
|
list: {
|
|
111
104
|
title: "下拉選單",
|
|
112
105
|
name: "值必須是列表中的值",
|
|
113
|
-
error: "輸入必須在指定的範圍內"
|
|
114
|
-
emptyError: "請輸入一個值",
|
|
115
|
-
add: "新增選項",
|
|
116
|
-
dropdown: "單選",
|
|
117
|
-
options: "選項來源",
|
|
118
|
-
customOptions: "自訂",
|
|
119
|
-
refOptions: "引用資料",
|
|
120
|
-
formulaError: "列表來源必須是劃定分界後的資料列表,或是對單一列或欄的引用。",
|
|
121
|
-
edit: "編輯"
|
|
122
|
-
},
|
|
123
|
-
listMultiple: {
|
|
124
|
-
title: "下拉式選單-多選",
|
|
125
|
-
dropdown: "多選"
|
|
106
|
+
error: "輸入必須在指定的範圍內"
|
|
126
107
|
},
|
|
108
|
+
listMultiple: { title: "下拉式選單-多選" },
|
|
127
109
|
decimal: { title: "數字" },
|
|
128
110
|
whole: { title: "整數" },
|
|
129
111
|
checkbox: {
|
|
130
112
|
title: "複選框",
|
|
131
|
-
error: "此儲存格的內容違反了驗證規則"
|
|
132
|
-
tips: "在儲存格內使用自訂值",
|
|
133
|
-
checked: "選取值",
|
|
134
|
-
unchecked: "未選取值"
|
|
113
|
+
error: "此儲存格的內容違反了驗證規則"
|
|
135
114
|
}
|
|
136
115
|
} };
|
|
137
116
|
|
package/lib/es/facade.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CanceledError, DataValidationErrorStyle, DataValidationOperator, DataValidationStatus, DataValidationType, ICommandService, IUniverInstanceService, generateRandomId } from "@univerjs/core";
|
|
2
|
-
import { AddSheetDataValidationCommand, ClearRangeDataValidationCommand, RemoveSheetAllDataValidationCommand, RemoveSheetDataValidationCommand, SheetDataValidationModel, SheetsDataValidationValidatorService, UpdateSheetDataValidationOptionsCommand, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand } from "@univerjs/sheets-data-validation";
|
|
2
|
+
import { AddSheetDataValidationCommand, ClearRangeDataValidationCommand, RemoveSheetAllDataValidationCommand, RemoveSheetDataValidationCommand, SheetDataValidationModel, SheetsDataValidationValidatorService, UpdateSheetDataValidationOptionsCommand, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand, getRangesInWorksheet } from "@univerjs/sheets-data-validation";
|
|
3
3
|
import { FRange, FWorkbook, FWorksheet } from "@univerjs/sheets/facade";
|
|
4
4
|
import { DataValidationModel, getRuleOptions } from "@univerjs/data-validation";
|
|
5
5
|
import { serializeRangeToRefString } from "@univerjs/engine-formula";
|
|
6
6
|
import { serializeListOptions } from "@univerjs/sheets";
|
|
7
7
|
import { FEventName, FUniver } from "@univerjs/core/facade";
|
|
8
8
|
|
|
9
|
-
//#region \0@oxc-project+runtime@0.
|
|
9
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
10
10
|
function _typeof(o) {
|
|
11
11
|
"@babel/helpers - typeof";
|
|
12
12
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -17,7 +17,7 @@ function _typeof(o) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
//#endregion
|
|
20
|
-
//#region \0@oxc-project+runtime@0.
|
|
20
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
21
21
|
function toPrimitive(t, r) {
|
|
22
22
|
if ("object" != _typeof(t) || !t) return t;
|
|
23
23
|
var e = t[Symbol.toPrimitive];
|
|
@@ -30,14 +30,14 @@ function toPrimitive(t, r) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
//#endregion
|
|
33
|
-
//#region \0@oxc-project+runtime@0.
|
|
33
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
34
34
|
function toPropertyKey(t) {
|
|
35
35
|
var i = toPrimitive(t, "string");
|
|
36
36
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
//#endregion
|
|
40
|
-
//#region \0@oxc-project+runtime@0.
|
|
40
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
41
41
|
function _defineProperty(e, r, t) {
|
|
42
42
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
43
43
|
value: t,
|
|
@@ -152,7 +152,7 @@ var FDataValidationBuilder = class FDataValidationBuilder {
|
|
|
152
152
|
* ```
|
|
153
153
|
*/
|
|
154
154
|
getAllowInvalid() {
|
|
155
|
-
return this._rule.errorStyle !== DataValidationErrorStyle.STOP;
|
|
155
|
+
return this._rule.showErrorMessage === false || this._rule.errorStyle !== DataValidationErrorStyle.STOP;
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
158
|
* Gets the data validation type of the rule
|
|
@@ -960,7 +960,14 @@ var FDataValidationBuilder = class FDataValidationBuilder {
|
|
|
960
960
|
*/
|
|
961
961
|
var FDataValidation = class {
|
|
962
962
|
constructor(rule, worksheet, _injector) {
|
|
963
|
-
_defineProperty(
|
|
963
|
+
_defineProperty(
|
|
964
|
+
this,
|
|
965
|
+
/**
|
|
966
|
+
* The underlying validation rule data. Use the Facade setters to update a rule attached to a worksheet.
|
|
967
|
+
*/
|
|
968
|
+
"rule",
|
|
969
|
+
void 0
|
|
970
|
+
);
|
|
964
971
|
_defineProperty(this, "_worksheet", void 0);
|
|
965
972
|
_defineProperty(this, "_injector", void 0);
|
|
966
973
|
this._injector = _injector;
|
|
@@ -982,7 +989,7 @@ var FDataValidation = class {
|
|
|
982
989
|
* ```
|
|
983
990
|
*/
|
|
984
991
|
getAllowInvalid() {
|
|
985
|
-
return this.rule.errorStyle !== DataValidationErrorStyle.STOP;
|
|
992
|
+
return this.rule.showErrorMessage === false || this.rule.errorStyle !== DataValidationErrorStyle.STOP;
|
|
986
993
|
}
|
|
987
994
|
/**
|
|
988
995
|
* Gets the data validation type of the rule
|
|
@@ -1128,8 +1135,8 @@ var FDataValidation = class {
|
|
|
1128
1135
|
return this.rule.ranges.map((range) => this._injector.createInstance(FRange, workbook, this._worksheet, range));
|
|
1129
1136
|
}
|
|
1130
1137
|
/**
|
|
1131
|
-
* Gets the unit ID of the
|
|
1132
|
-
* @returns {string | undefined} The unit ID of the
|
|
1138
|
+
* Gets the unit ID of the workbook
|
|
1139
|
+
* @returns {string | undefined} The unit ID of the workbook
|
|
1133
1140
|
* @example
|
|
1134
1141
|
* ```typescript
|
|
1135
1142
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -1359,7 +1366,7 @@ var FRangeSheetsDataValidationMixin = class extends FRange {
|
|
|
1359
1366
|
const worksheet = this._worksheet;
|
|
1360
1367
|
const sheetName = worksheet.getName();
|
|
1361
1368
|
const errors = [];
|
|
1362
|
-
for (const range of ranges) {
|
|
1369
|
+
for (const range of getRangesInWorksheet(ranges, worksheet)) {
|
|
1363
1370
|
const promises = [];
|
|
1364
1371
|
for (let row = range.startRow; row <= range.endRow; row++) for (let col = range.startColumn; col <= range.endColumn; col++) promises.push((async () => {
|
|
1365
1372
|
try {
|
|
@@ -1599,7 +1606,7 @@ var FWorkbookSheetsDataValidationMixin = class extends FWorkbook {
|
|
|
1599
1606
|
if (!worksheet) throw new Error(`Cannot find worksheet with sheetId: ${sheetId}`);
|
|
1600
1607
|
const sheetName = worksheet.getName();
|
|
1601
1608
|
const errors = [];
|
|
1602
|
-
for (const range of ranges) {
|
|
1609
|
+
for (const range of getRangesInWorksheet(ranges, worksheet)) {
|
|
1603
1610
|
const promises = [];
|
|
1604
1611
|
for (let row = range.startRow; row <= range.endRow; row++) for (let col = range.startColumn; col <= range.endColumn; col++) promises.push((async () => {
|
|
1605
1612
|
try {
|
|
@@ -1667,7 +1674,7 @@ var FWorksheetDataValidationMixin = class extends FWorksheet {
|
|
|
1667
1674
|
const worksheet = this._worksheet;
|
|
1668
1675
|
const sheetName = worksheet.getName();
|
|
1669
1676
|
const errors = [];
|
|
1670
|
-
for (const range of ranges) {
|
|
1677
|
+
for (const range of getRangesInWorksheet(ranges, worksheet)) {
|
|
1671
1678
|
const promises = [];
|
|
1672
1679
|
for (let row = range.startRow; row <= range.endRow; row++) for (let col = range.startColumn; col <= range.endColumn; col++) promises.push((async () => {
|
|
1673
1680
|
try {
|
package/lib/es/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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,
|
|
1
|
+
import { CellValueType, CommandType, DataValidationOperator, DataValidationRenderMode, DataValidationStatus, DataValidationType, DateSystem, DependentOn, Disposable, ICommandService, IConfigService, IPermissionService, IUndoRedoService, IUniverInstanceService, Inject, Injector, LifecycleService, LifecycleStages, ObjectMatrix, Plugin, RBush, Range, Rectangle, RxDisposable, Tools, UniverInstanceType, WrapStrategy, bufferDebounceTime, debounce, excelSerialToDateTimeParts, generateRandomId, getIntersectRange, getNumfmtLocaleTag, getOriginCellValue, isFormulaString, isRangesEqual, merge, numfmt, sequenceExecute, toDisposable } from "@univerjs/core";
|
|
2
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, UniverFormulaEnginePlugin, deserializeRangeWithSheet, deserializeRangeWithSheetWithCache, isReferenceString, operatorToken, sequenceNodeType } from "@univerjs/engine-formula";
|
|
4
4
|
import { ClearSelectionAllCommand, CopySheetCommand, RefRangeService, RemoveSheetCommand, RemoveSheetMutation, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SheetInterceptorService, SheetsSelectionsService, UniverSheetsPlugin, WorksheetViewPermission, deserializeListOptions, getSheetCommandTarget, handleCommonDefaultRangeChangeWithEffectRefCommands } from "@univerjs/sheets";
|
|
@@ -6,7 +6,36 @@ import { Subject, bufferWhen, filter, skip } from "rxjs";
|
|
|
6
6
|
import { UnitAction } from "@univerjs/protocol";
|
|
7
7
|
import { FormulaRefRangeService, UniverSheetsFormulaPlugin } from "@univerjs/sheets-formula";
|
|
8
8
|
|
|
9
|
-
//#region
|
|
9
|
+
//#region src/utils/range.ts
|
|
10
|
+
function getRangeInWorksheet(range, worksheet) {
|
|
11
|
+
const maxRows = worksheet.getMaxRows();
|
|
12
|
+
const maxColumns = worksheet.getMaxColumns();
|
|
13
|
+
if (maxRows <= 0 || maxColumns <= 0) return null;
|
|
14
|
+
const effectiveRange = getIntersectRange(Range.transformRange(range, worksheet), {
|
|
15
|
+
startRow: 0,
|
|
16
|
+
endRow: maxRows - 1,
|
|
17
|
+
startColumn: 0,
|
|
18
|
+
endColumn: maxColumns - 1
|
|
19
|
+
});
|
|
20
|
+
if (!effectiveRange) return null;
|
|
21
|
+
return {
|
|
22
|
+
startRow: effectiveRange.startRow,
|
|
23
|
+
endRow: effectiveRange.endRow,
|
|
24
|
+
startColumn: effectiveRange.startColumn,
|
|
25
|
+
endColumn: effectiveRange.endColumn
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function getRangesInWorksheet(ranges, worksheet) {
|
|
29
|
+
const effectiveRanges = [];
|
|
30
|
+
ranges.forEach((range) => {
|
|
31
|
+
const effectiveRange = getRangeInWorksheet(range, worksheet);
|
|
32
|
+
if (effectiveRange) effectiveRanges.push(effectiveRange);
|
|
33
|
+
});
|
|
34
|
+
return effectiveRanges;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
10
39
|
function _typeof(o) {
|
|
11
40
|
"@babel/helpers - typeof";
|
|
12
41
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -17,7 +46,7 @@ function _typeof(o) {
|
|
|
17
46
|
}
|
|
18
47
|
|
|
19
48
|
//#endregion
|
|
20
|
-
//#region \0@oxc-project+runtime@0.
|
|
49
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
21
50
|
function toPrimitive(t, r) {
|
|
22
51
|
if ("object" != _typeof(t) || !t) return t;
|
|
23
52
|
var e = t[Symbol.toPrimitive];
|
|
@@ -30,14 +59,14 @@ function toPrimitive(t, r) {
|
|
|
30
59
|
}
|
|
31
60
|
|
|
32
61
|
//#endregion
|
|
33
|
-
//#region \0@oxc-project+runtime@0.
|
|
62
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
34
63
|
function toPropertyKey(t) {
|
|
35
64
|
var i = toPrimitive(t, "string");
|
|
36
65
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
37
66
|
}
|
|
38
67
|
|
|
39
68
|
//#endregion
|
|
40
|
-
//#region \0@oxc-project+runtime@0.
|
|
69
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
41
70
|
function _defineProperty(e, r, t) {
|
|
42
71
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
43
72
|
value: t,
|
|
@@ -48,7 +77,7 @@ function _defineProperty(e, r, t) {
|
|
|
48
77
|
}
|
|
49
78
|
|
|
50
79
|
//#endregion
|
|
51
|
-
//#region \0@oxc-project+runtime@0.
|
|
80
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
52
81
|
function __decorateParam(paramIndex, decorator) {
|
|
53
82
|
return function(target, key) {
|
|
54
83
|
decorator(target, key, paramIndex);
|
|
@@ -56,7 +85,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
56
85
|
}
|
|
57
86
|
|
|
58
87
|
//#endregion
|
|
59
|
-
//#region \0@oxc-project+runtime@0.
|
|
88
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
60
89
|
function __decorate(decorators, target, key, desc) {
|
|
61
90
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
62
91
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -132,9 +161,15 @@ let DataValidationCacheService = class DataValidationCacheService extends Dispos
|
|
|
132
161
|
removeRule(unitId, subUnitId, rule) {
|
|
133
162
|
this._deleteRange(unitId, subUnitId, rule.ranges);
|
|
134
163
|
}
|
|
164
|
+
_getEffectiveRanges(unitId, subUnitId, ranges) {
|
|
165
|
+
var _this$_univerInstance;
|
|
166
|
+
const worksheet = (_this$_univerInstance = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getSheetBySheetId(subUnitId);
|
|
167
|
+
if (!worksheet) return [];
|
|
168
|
+
return getRangesInWorksheet(ranges, worksheet);
|
|
169
|
+
}
|
|
135
170
|
markRangeDirty(unitId, subUnitId, ranges, isSetRange) {
|
|
136
171
|
const cache = this._ensureCache(unitId, subUnitId);
|
|
137
|
-
ranges.forEach((range) => {
|
|
172
|
+
this._getEffectiveRanges(unitId, subUnitId, ranges).forEach((range) => {
|
|
138
173
|
Range.foreach(range, (row, col) => {
|
|
139
174
|
if (cache.getValue(row, col) !== void 0) cache.setValue(row, col, void 0);
|
|
140
175
|
});
|
|
@@ -148,7 +183,7 @@ let DataValidationCacheService = class DataValidationCacheService extends Dispos
|
|
|
148
183
|
}
|
|
149
184
|
_deleteRange(unitId, subUnitId, ranges) {
|
|
150
185
|
const cache = this._ensureCache(unitId, subUnitId);
|
|
151
|
-
ranges.forEach((range) => {
|
|
186
|
+
this._getEffectiveRanges(unitId, subUnitId, ranges).forEach((range) => {
|
|
152
187
|
Range.foreach(range, (row, col) => {
|
|
153
188
|
cache.realDeleteValue(row, col);
|
|
154
189
|
});
|
|
@@ -285,11 +320,16 @@ let DataValidationCustomFormulaService = class DataValidationCustomFormulaServic
|
|
|
285
320
|
}
|
|
286
321
|
}
|
|
287
322
|
_addFormulaByRange(unitId, subUnitId, ruleId, formula, formula2, ranges) {
|
|
323
|
+
var _this$_instanceSrv$ge;
|
|
288
324
|
const { ruleFormulaMap, ruleFormulaMap2 } = this._ensureMaps(unitId, subUnitId);
|
|
289
|
-
const
|
|
290
|
-
|
|
325
|
+
const worksheet = (_this$_instanceSrv$ge = this._instanceSrv.getUnit(unitId, UniverInstanceType.UNIVER_SHEET)) === null || _this$_instanceSrv$ge === void 0 ? void 0 : _this$_instanceSrv$ge.getSheetBySheetId(subUnitId);
|
|
326
|
+
if (!worksheet) return;
|
|
327
|
+
const effectiveRanges = getRangesInWorksheet(ranges, worksheet);
|
|
328
|
+
if (!effectiveRanges.length) return;
|
|
329
|
+
const originRow = effectiveRanges[0].startRow;
|
|
330
|
+
const originCol = effectiveRanges[0].startColumn;
|
|
291
331
|
if (formula && isFormulaString(formula)) {
|
|
292
|
-
const formulaId = this._registerFormula(unitId, subUnitId, ruleId, formula,
|
|
332
|
+
const formulaId = this._registerFormula(unitId, subUnitId, ruleId, formula, effectiveRanges);
|
|
293
333
|
ruleFormulaMap.set(ruleId, {
|
|
294
334
|
formula,
|
|
295
335
|
originCol,
|
|
@@ -298,7 +338,7 @@ let DataValidationCustomFormulaService = class DataValidationCustomFormulaServic
|
|
|
298
338
|
});
|
|
299
339
|
}
|
|
300
340
|
if (formula2 && isFormulaString(formula2)) {
|
|
301
|
-
const formulaId2 = this._registerFormula(unitId, subUnitId, ruleId, formula2,
|
|
341
|
+
const formulaId2 = this._registerFormula(unitId, subUnitId, ruleId, formula2, effectiveRanges);
|
|
302
342
|
ruleFormulaMap2.set(ruleId, {
|
|
303
343
|
formula: formula2,
|
|
304
344
|
originCol,
|
|
@@ -837,9 +877,7 @@ let SheetDataValidationModel = class SheetDataValidationModel extends Disposable
|
|
|
837
877
|
case "update":
|
|
838
878
|
this._updateRule(ruleChange.unitId, ruleChange.subUnitId, ruleChange.rule.uid, ruleChange.oldRule, ruleChange.updatePayload);
|
|
839
879
|
break;
|
|
840
|
-
case "remove":
|
|
841
|
-
this._removeRule(ruleChange.unitId, ruleChange.subUnitId, ruleChange.rule);
|
|
842
|
-
break;
|
|
880
|
+
case "remove": this._removeRule(ruleChange.unitId, ruleChange.subUnitId, ruleChange.rule);
|
|
843
881
|
}
|
|
844
882
|
this._ruleChange$.next(ruleChange);
|
|
845
883
|
}));
|
|
@@ -1273,14 +1311,15 @@ function getTransformedFormula(lexerTreeBuilder, rule, position) {
|
|
|
1273
1311
|
|
|
1274
1312
|
//#endregion
|
|
1275
1313
|
//#region src/validators/date-validator.ts
|
|
1276
|
-
const transformDate2SerialNumber = (value) => {
|
|
1277
|
-
var _numfmt$parseDate
|
|
1314
|
+
const transformDate2SerialNumber = (value, options = {}) => {
|
|
1315
|
+
var _numfmt$parseDate;
|
|
1278
1316
|
if (value === void 0 || value === null || typeof value === "boolean") return;
|
|
1279
1317
|
if (typeof value === "number" || !Number.isNaN(+value)) return +value;
|
|
1280
|
-
|
|
1281
|
-
if (Tools.isDefine(v)) return v;
|
|
1282
|
-
return (_numfmt$parseDate2 = numfmt.parseDate(dateKit(value).format("YYYY-MM-DD HH:mm:ss"))) === null || _numfmt$parseDate2 === void 0 ? void 0 : _numfmt$parseDate2.v;
|
|
1318
|
+
return (_numfmt$parseDate = numfmt.parseDate(value, options)) === null || _numfmt$parseDate === void 0 ? void 0 : _numfmt$parseDate.v;
|
|
1283
1319
|
};
|
|
1320
|
+
function pad(value) {
|
|
1321
|
+
return String(value).padStart(2, "0");
|
|
1322
|
+
}
|
|
1284
1323
|
var DateValidator = class extends BaseSheetValidator {
|
|
1285
1324
|
constructor(..._args) {
|
|
1286
1325
|
super(..._args);
|
|
@@ -1300,6 +1339,14 @@ var DateValidator = class extends BaseSheetValidator {
|
|
|
1300
1339
|
_defineProperty(this, "scopes", ["sheet"]);
|
|
1301
1340
|
_defineProperty(this, "_customFormulaService", this.injector.get(DataValidationCustomFormulaService));
|
|
1302
1341
|
_defineProperty(this, "_lexerTreeBuilder", this.injector.get(LexerTreeBuilder));
|
|
1342
|
+
_defineProperty(this, "_univerInstanceService", this.injector.get(IUniverInstanceService));
|
|
1343
|
+
}
|
|
1344
|
+
_getParseOptions(unitId, workbook) {
|
|
1345
|
+
const targetWorkbook = workbook ?? (unitId ? this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET) : void 0);
|
|
1346
|
+
return targetWorkbook ? {
|
|
1347
|
+
locale: getNumfmtLocaleTag(targetWorkbook.getSnapshot().locale),
|
|
1348
|
+
dateSystem: targetWorkbook.getDateSystem()
|
|
1349
|
+
} : { dateSystem: DateSystem.Date1900 };
|
|
1303
1350
|
}
|
|
1304
1351
|
async parseFormula(rule, unitId, subUnitId, row, column) {
|
|
1305
1352
|
const formulaResult1 = await this._customFormulaService.getCellFormulaValue(unitId, subUnitId, rule.uid, row, column);
|
|
@@ -1307,27 +1354,29 @@ var DateValidator = class extends BaseSheetValidator {
|
|
|
1307
1354
|
const { formula1, formula2 } = rule;
|
|
1308
1355
|
const isFormulaValid = isLegalFormulaResult(String(formulaResult1 === null || formulaResult1 === void 0 ? void 0 : formulaResult1.v)) && isLegalFormulaResult(String(formulaResult2 === null || formulaResult2 === void 0 ? void 0 : formulaResult2.v));
|
|
1309
1356
|
return {
|
|
1310
|
-
formula1: transformDate2SerialNumber(isFormulaString(formula1) ? formulaResult1 === null || formulaResult1 === void 0 ? void 0 : formulaResult1.v : formula1),
|
|
1311
|
-
formula2: transformDate2SerialNumber(isFormulaString(formula2) ? formulaResult2 === null || formulaResult2 === void 0 ? void 0 : formulaResult2.v : formula2),
|
|
1357
|
+
formula1: transformDate2SerialNumber(isFormulaString(formula1) ? formulaResult1 === null || formulaResult1 === void 0 ? void 0 : formulaResult1.v : formula1, this._getParseOptions(unitId)),
|
|
1358
|
+
formula2: transformDate2SerialNumber(isFormulaString(formula2) ? formulaResult2 === null || formulaResult2 === void 0 ? void 0 : formulaResult2.v : formula2, this._getParseOptions(unitId)),
|
|
1312
1359
|
isFormulaValid
|
|
1313
1360
|
};
|
|
1314
1361
|
}
|
|
1315
1362
|
async isValidType(info) {
|
|
1316
1363
|
const { interceptValue, value } = info;
|
|
1317
|
-
|
|
1318
|
-
if (typeof interceptValue === "string") return Boolean(numfmt.parseDate(interceptValue));
|
|
1364
|
+
const options = this._getParseOptions(info.unitId, info.workbook);
|
|
1365
|
+
if (typeof value === "number" && typeof interceptValue === "string") return Boolean(numfmt.parseDate(interceptValue, options));
|
|
1366
|
+
if (typeof interceptValue === "string") return Boolean(numfmt.parseDate(interceptValue, options));
|
|
1319
1367
|
return false;
|
|
1320
1368
|
}
|
|
1321
|
-
_validatorSingleFormula(formula) {
|
|
1322
|
-
return !Tools.isBlank(formula) && (isFormulaString(formula) || !Number.isNaN(+formula) || Boolean(formula && numfmt.parseDate(formula)));
|
|
1369
|
+
_validatorSingleFormula(formula, options) {
|
|
1370
|
+
return !Tools.isBlank(formula) && (isFormulaString(formula) || !Number.isNaN(+formula) || Boolean(formula && numfmt.parseDate(formula, options)));
|
|
1323
1371
|
}
|
|
1324
1372
|
validatorFormula(rule, unitId, subUnitId) {
|
|
1325
1373
|
const operator = rule.operator;
|
|
1326
1374
|
if (!operator) return { success: true };
|
|
1327
|
-
const
|
|
1375
|
+
const options = this._getParseOptions(unitId);
|
|
1376
|
+
const formula1Success = this._validatorSingleFormula(rule.formula1, options);
|
|
1328
1377
|
const errorMsg = this.localeService.t("sheets-data-validation.validFail.date");
|
|
1329
1378
|
if (TWO_FORMULA_OPERATOR_COUNT.includes(operator)) {
|
|
1330
|
-
const formula2Success = this._validatorSingleFormula(rule.formula2);
|
|
1379
|
+
const formula2Success = this._validatorSingleFormula(rule.formula2, options);
|
|
1331
1380
|
return {
|
|
1332
1381
|
success: formula1Success && formula2Success,
|
|
1333
1382
|
formula1: formula1Success ? void 0 : errorMsg,
|
|
@@ -1339,19 +1388,18 @@ var DateValidator = class extends BaseSheetValidator {
|
|
|
1339
1388
|
formula1: formula1Success ? void 0 : errorMsg
|
|
1340
1389
|
};
|
|
1341
1390
|
}
|
|
1342
|
-
normalizeFormula(rule,
|
|
1391
|
+
normalizeFormula(rule, unitId, _subUnitId) {
|
|
1343
1392
|
const { formula1, formula2, bizInfo } = rule;
|
|
1393
|
+
const options = this._getParseOptions(unitId);
|
|
1344
1394
|
const normlizeSingleFormula = (formula) => {
|
|
1395
|
+
var _numfmt$parseDate2;
|
|
1345
1396
|
if (!formula) return formula;
|
|
1346
|
-
|
|
1347
|
-
if (
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
date = numfmt.dateFromSerial(res);
|
|
1353
|
-
}
|
|
1354
|
-
return dateKit(`${date[0]}/${date[1]}/${date[2]} ${date[3]}:${date[4]}:${date[5]}`).format((bizInfo === null || bizInfo === void 0 ? void 0 : bizInfo.showTime) ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD");
|
|
1397
|
+
const serial = !Number.isNaN(+formula) ? +formula : (_numfmt$parseDate2 = numfmt.parseDate(formula, options)) === null || _numfmt$parseDate2 === void 0 ? void 0 : _numfmt$parseDate2.v;
|
|
1398
|
+
if (typeof serial !== "number") return "";
|
|
1399
|
+
const date = excelSerialToDateTimeParts(serial, { dateSystem: options.dateSystem ?? DateSystem.Date1900 });
|
|
1400
|
+
if (!date) return "";
|
|
1401
|
+
const dateText = `${String(date.year).padStart(4, "0")}-${pad(date.month)}-${pad(date.day)}`;
|
|
1402
|
+
return (bizInfo === null || bizInfo === void 0 ? void 0 : bizInfo.showTime) ? `${dateText} ${pad(date.hours)}:${pad(date.minutes)}:${pad(date.seconds)}` : dateText;
|
|
1355
1403
|
};
|
|
1356
1404
|
return {
|
|
1357
1405
|
formula1: isFormulaString(formula1) ? formula1 : normlizeSingleFormula(`${formula1}`),
|
|
@@ -1362,7 +1410,7 @@ var DateValidator = class extends BaseSheetValidator {
|
|
|
1362
1410
|
const { value } = cellInfo;
|
|
1363
1411
|
return {
|
|
1364
1412
|
...cellInfo,
|
|
1365
|
-
value: transformDate2SerialNumber(value)
|
|
1413
|
+
value: transformDate2SerialNumber(value, this._getParseOptions(cellInfo.unitId, cellInfo.workbook))
|
|
1366
1414
|
};
|
|
1367
1415
|
}
|
|
1368
1416
|
get operatorNames() {
|
|
@@ -1541,7 +1589,8 @@ var ListValidator = class extends BaseSheetValidator {
|
|
|
1541
1589
|
return { tb };
|
|
1542
1590
|
}
|
|
1543
1591
|
parseCellValue(cellValue) {
|
|
1544
|
-
|
|
1592
|
+
const cellString = cellValue.toString();
|
|
1593
|
+
return deserializeListOptions(cellString);
|
|
1545
1594
|
}
|
|
1546
1595
|
async parseFormula(rule, unitId, subUnitId) {
|
|
1547
1596
|
var _results$;
|
|
@@ -1692,7 +1741,8 @@ function getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor, sour
|
|
|
1692
1741
|
const redoMutations = [];
|
|
1693
1742
|
const undoMutations = [];
|
|
1694
1743
|
const sheetDataValidationModel = accessor.get(SheetDataValidationModel);
|
|
1695
|
-
const
|
|
1744
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
1745
|
+
const target = getSheetCommandTarget(univerInstanceService, {
|
|
1696
1746
|
unitId,
|
|
1697
1747
|
subUnitId
|
|
1698
1748
|
});
|
|
@@ -1705,7 +1755,7 @@ function getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor, sour
|
|
|
1705
1755
|
let setRangeValue = false;
|
|
1706
1756
|
function setRangesDefaultValue(ranges, defaultValue) {
|
|
1707
1757
|
if (!fillDefaultValue) return;
|
|
1708
|
-
ranges.forEach((range) => {
|
|
1758
|
+
getRangesInWorksheet(ranges, worksheet).forEach((range) => {
|
|
1709
1759
|
Range.foreach(range, (row, column) => {
|
|
1710
1760
|
const cellData = worksheet.getCellRaw(row, column);
|
|
1711
1761
|
const value = getStringCellValue(cellData);
|
|
@@ -1871,8 +1921,6 @@ function getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor, sour
|
|
|
1871
1921
|
const formula = sheetDataValidationModel.getValidator(DataValidationType.CHECKBOX).parseFormulaSync(diff.rule, unitId, subUnitId);
|
|
1872
1922
|
setRangesDefaultValue(diff.rule.ranges, formula.originFormula2);
|
|
1873
1923
|
}
|
|
1874
|
-
break;
|
|
1875
|
-
default: break;
|
|
1876
1924
|
}
|
|
1877
1925
|
});
|
|
1878
1926
|
if (setRangeValue) {
|
|
@@ -2011,7 +2059,8 @@ const UpdateSheetDataValidationSettingCommand = {
|
|
|
2011
2059
|
}];
|
|
2012
2060
|
if (setting.type === DataValidationType.CHECKBOX) {
|
|
2013
2061
|
const ranges = rule.ranges;
|
|
2014
|
-
const
|
|
2062
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
2063
|
+
const target = getSheetCommandTarget(univerInstanceService, {
|
|
2015
2064
|
unitId,
|
|
2016
2065
|
subUnitId
|
|
2017
2066
|
});
|
|
@@ -2021,7 +2070,7 @@ const UpdateSheetDataValidationSettingCommand = {
|
|
|
2021
2070
|
const { formula2: oldFormula2 = 0, formula1: oldFormula1 = 1 } = rule;
|
|
2022
2071
|
const { formula2 = 0, formula1 = 1 } = setting;
|
|
2023
2072
|
let setted = false;
|
|
2024
|
-
ranges.forEach((range) => {
|
|
2073
|
+
getRangesInWorksheet(ranges, worksheet).forEach((range) => {
|
|
2025
2074
|
Range.foreach(range, (row, column) => {
|
|
2026
2075
|
const cellData = worksheet.getCellRaw(row, column);
|
|
2027
2076
|
const value = getStringCellValue(cellData);
|
|
@@ -2122,7 +2171,8 @@ const ClearRangeDataValidationCommand = {
|
|
|
2122
2171
|
if (!params) return false;
|
|
2123
2172
|
const { unitId, subUnitId, ranges, types } = params;
|
|
2124
2173
|
const commandService = accessor.get(ICommandService);
|
|
2125
|
-
const
|
|
2174
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
2175
|
+
const target = getSheetCommandTarget(univerInstanceService, {
|
|
2126
2176
|
unitId,
|
|
2127
2177
|
subUnitId
|
|
2128
2178
|
});
|
|
@@ -2280,7 +2330,9 @@ let DataValidationFormulaController = class DataValidationFormulaController exte
|
|
|
2280
2330
|
if (!this._permissionService.getPermissionPoint(new WorksheetViewPermission(unitId, subUnitId).id)) return false;
|
|
2281
2331
|
}
|
|
2282
2332
|
if (!targetSheet) return false;
|
|
2283
|
-
const
|
|
2333
|
+
const range = getRangeInWorksheet(sequenceGrid.range, targetSheet);
|
|
2334
|
+
if (!range) continue;
|
|
2335
|
+
const { startRow, endRow, startColumn, endColumn } = range;
|
|
2284
2336
|
for (let i = startRow; i <= endRow; i++) for (let j = startColumn; j <= endColumn; j++) {
|
|
2285
2337
|
var _targetSheet$getCell;
|
|
2286
2338
|
const permission = (_targetSheet$getCell = targetSheet.getCell(i, j)) === null || _targetSheet$getCell === void 0 || (_targetSheet$getCell = _targetSheet$getCell.selectionProtection) === null || _targetSheet$getCell === void 0 ? void 0 : _targetSheet$getCell[0];
|
|
@@ -2299,7 +2351,7 @@ DataValidationFormulaController = __decorate([
|
|
|
2299
2351
|
//#endregion
|
|
2300
2352
|
//#region package.json
|
|
2301
2353
|
var name = "@univerjs/sheets-data-validation";
|
|
2302
|
-
var version = "1.0.0
|
|
2354
|
+
var version = "1.0.0";
|
|
2303
2355
|
|
|
2304
2356
|
//#endregion
|
|
2305
2357
|
//#region src/config/config.ts
|
|
@@ -3012,7 +3064,8 @@ let DataValidationController = class DataValidationController extends RxDisposab
|
|
|
3012
3064
|
const selections = (_this$_selectionManag = this._selectionManagerService.getCurrentSelections()) === null || _this$_selectionManag === void 0 ? void 0 : _this$_selectionManag.map((s) => s.range);
|
|
3013
3065
|
const ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone();
|
|
3014
3066
|
if (selections) ruleMatrix.removeRange(selections);
|
|
3015
|
-
const
|
|
3067
|
+
const diffs = ruleMatrix.diff(this._sheetDataValidationModel.getRules(unitId, subUnitId));
|
|
3068
|
+
const { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, this._injector, "patched");
|
|
3016
3069
|
return {
|
|
3017
3070
|
undos: undoMutations,
|
|
3018
3071
|
redos: redoMutations
|
|
@@ -3050,14 +3103,14 @@ let SheetsDataValidationValidatorService = class SheetsDataValidationValidatorSe
|
|
|
3050
3103
|
if (ranges.length === 0) return;
|
|
3051
3104
|
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
3052
3105
|
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
|
|
3053
|
-
const map =
|
|
3106
|
+
const map = Object.create(null);
|
|
3054
3107
|
ranges.flat().forEach((range) => {
|
|
3055
|
-
if (!map[range.unitId]) map[range.unitId] =
|
|
3108
|
+
if (!map[range.unitId]) map[range.unitId] = Object.create(null);
|
|
3056
3109
|
if (!map[range.unitId][range.subUnitId]) map[range.unitId][range.subUnitId] = [];
|
|
3057
3110
|
const workbook = this._univerInstanceService.getUnit(range.unitId, UniverInstanceType.UNIVER_SHEET);
|
|
3058
3111
|
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(range.subUnitId);
|
|
3059
3112
|
if (!worksheet) return;
|
|
3060
|
-
map[range.unitId][range.subUnitId].push(...range.ranges
|
|
3113
|
+
map[range.unitId][range.subUnitId].push(...getRangesInWorksheet(range.ranges, worksheet));
|
|
3061
3114
|
});
|
|
3062
3115
|
Object.entries(map).forEach(([unitId, subUnitMap]) => {
|
|
3063
3116
|
Object.entries(subUnitMap).forEach(([subUnitId, ranges]) => {
|
|
@@ -3110,11 +3163,10 @@ let SheetsDataValidationValidatorService = class SheetsDataValidationValidatorSe
|
|
|
3110
3163
|
if (!workbook) throw new Error(`cannot find current workbook, unitId: ${unitId}`);
|
|
3111
3164
|
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
3112
3165
|
if (!worksheet) throw new Error(`cannot find current worksheet, sheetId: ${subUnitId}`);
|
|
3113
|
-
const
|
|
3114
|
-
const ruleRanges =
|
|
3115
|
-
for (const rule of allRules) ruleRanges.push(...rule.ranges);
|
|
3166
|
+
const effectiveRanges = getRangesInWorksheet(ranges, worksheet);
|
|
3167
|
+
const ruleRanges = getRangesInWorksheet(this._sheetDataValidationModel.getRules(unitId, subUnitId).flatMap((rule) => rule.ranges), worksheet);
|
|
3116
3168
|
const intersectRanges = [];
|
|
3117
|
-
for (const range of
|
|
3169
|
+
for (const range of effectiveRanges) for (const ruleRange of ruleRanges) {
|
|
3118
3170
|
const intersect = getIntersectRange(range, ruleRange);
|
|
3119
3171
|
if (intersect) intersectRanges.push(intersect);
|
|
3120
3172
|
}
|
|
@@ -3147,31 +3199,32 @@ let SheetsDataValidationValidatorService = class SheetsDataValidationValidatorSe
|
|
|
3147
3199
|
if (!workbook) throw new Error(`cannot find current workbook, unitId: ${unitId}`);
|
|
3148
3200
|
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
3149
3201
|
if (!worksheet) throw new Error(`cannot find current worksheet, sheetId: ${subUnitId}`);
|
|
3150
|
-
const
|
|
3151
|
-
await Promise.all(
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
return Promise.all(promises);
|
|
3158
|
-
}));
|
|
3202
|
+
const ranges = getRangesInWorksheet(this._sheetDataValidationModel.getRules(unitId, subUnitId).flatMap((rule) => rule.ranges), worksheet);
|
|
3203
|
+
await Promise.all(ranges.map((range) => {
|
|
3204
|
+
const promises = [];
|
|
3205
|
+
Range.foreach(range, (row, col) => {
|
|
3206
|
+
promises.push(this._validatorByCell(workbook, worksheet, row, col));
|
|
3207
|
+
});
|
|
3208
|
+
return Promise.all(promises);
|
|
3159
3209
|
}));
|
|
3160
3210
|
return this._dataValidationCacheService.ensureCache(unitId, subUnitId);
|
|
3161
3211
|
}
|
|
3162
3212
|
async validatorWorkbook(unitId) {
|
|
3163
3213
|
const sheetIds = this._sheetDataValidationModel.getSubUnitIds(unitId);
|
|
3164
3214
|
const results = await Promise.all(sheetIds.map((id) => this.validatorWorksheet(unitId, id)));
|
|
3165
|
-
const map =
|
|
3215
|
+
const map = Object.create(null);
|
|
3166
3216
|
results.forEach((result, i) => {
|
|
3167
3217
|
map[sheetIds[i]] = result;
|
|
3168
3218
|
});
|
|
3169
3219
|
return map;
|
|
3170
3220
|
}
|
|
3171
3221
|
getDataValidations(unitId, subUnitId, ranges) {
|
|
3222
|
+
var _this$_univerInstance;
|
|
3223
|
+
const worksheet = (_this$_univerInstance = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getSheetBySheetId(subUnitId);
|
|
3224
|
+
if (!worksheet) return [];
|
|
3172
3225
|
const ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId);
|
|
3173
3226
|
const ruleIdSet = /* @__PURE__ */ new Set();
|
|
3174
|
-
ranges.forEach((range) => {
|
|
3227
|
+
getRangesInWorksheet(ranges, worksheet).forEach((range) => {
|
|
3175
3228
|
Range.foreach(range, (row, col) => {
|
|
3176
3229
|
const ruleId = ruleMatrix.getValue(row, col);
|
|
3177
3230
|
if (ruleId) ruleIdSet.add(ruleId);
|
|
@@ -3284,4 +3337,4 @@ const LIST_FORMULA_INPUT_NAME = "sheets-data-validation.list-formula-input";
|
|
|
3284
3337
|
const CHECKBOX_FORMULA_INPUT_NAME = "sheets-data-validation.checkbox-formula-input";
|
|
3285
3338
|
|
|
3286
3339
|
//#endregion
|
|
3287
|
-
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 };
|
|
3340
|
+
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, getRangesInWorksheet, getTransformedFormula, isLegalFormulaResult, transformCheckboxValue };
|