@univerjs/sheets-data-validation 0.5.5-nightly.202501210734 → 0.5.5-nightly.202501210849
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/es/facade.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this
|
|
14
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
+
import { UpdateSheetDataValidationSettingCommand, UpdateSheetDataValidationOptionsCommand, UpdateSheetDataValidationRangeCommand, RemoveSheetDataValidationCommand, ClearRangeDataValidationCommand, AddSheetDataValidationCommand, SheetsDataValidationValidatorService, SheetDataValidationModel, RemoveSheetAllDataValidationCommand } from "@univerjs/sheets-data-validation";
|
|
6
|
+
import { FRange, FWorkbook, FWorksheet } from "@univerjs/sheets/facade";
|
|
7
|
+
import { generateRandomId, DataValidationType, DataValidationErrorStyle, DataValidationOperator, IUniverInstanceService, ICommandService, FUniver, CanceledError, toDisposable, FEventName } from "@univerjs/core";
|
|
8
|
+
import { DataValidationModel, getRuleOptions } from "@univerjs/data-validation";
|
|
9
|
+
import { serializeRangeToRefString } from "@univerjs/engine-formula";
|
|
10
|
+
import { filter } from "rxjs";
|
|
11
|
+
const _FDataValidationBuilder = class _FDataValidationBuilder {
|
|
12
|
+
constructor(rule) {
|
|
13
|
+
__publicField(this, "_rule");
|
|
14
|
+
this._rule = rule != null ? rule : {
|
|
15
|
+
uid: generateRandomId(),
|
|
15
16
|
ranges: void 0,
|
|
16
|
-
type:
|
|
17
|
+
type: DataValidationType.CUSTOM
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
@@ -26,7 +27,7 @@ class D {
|
|
|
26
27
|
* ```
|
|
27
28
|
*/
|
|
28
29
|
build() {
|
|
29
|
-
return new
|
|
30
|
+
return new FDataValidation(this._rule);
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
32
33
|
* Creates a duplicate of the current DataValidationBuilder object
|
|
@@ -38,9 +39,9 @@ class D {
|
|
|
38
39
|
* ```
|
|
39
40
|
*/
|
|
40
41
|
copy() {
|
|
41
|
-
return new
|
|
42
|
+
return new _FDataValidationBuilder({
|
|
42
43
|
...this._rule,
|
|
43
|
-
uid:
|
|
44
|
+
uid: generateRandomId()
|
|
44
45
|
});
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
@@ -53,7 +54,7 @@ class D {
|
|
|
53
54
|
* ```
|
|
54
55
|
*/
|
|
55
56
|
getAllowInvalid() {
|
|
56
|
-
return this._rule.errorStyle !==
|
|
57
|
+
return this._rule.errorStyle !== DataValidationErrorStyle.STOP;
|
|
57
58
|
}
|
|
58
59
|
/**
|
|
59
60
|
* Gets the data validation type of the rule
|
|
@@ -102,8 +103,8 @@ class D {
|
|
|
102
103
|
* const rule = builder.requireCheckbox('Yes', 'No').build();
|
|
103
104
|
* ```
|
|
104
105
|
*/
|
|
105
|
-
requireCheckbox(
|
|
106
|
-
return this._rule.type =
|
|
106
|
+
requireCheckbox(checkedValue, uncheckedValue) {
|
|
107
|
+
return this._rule.type = DataValidationType.CHECKBOX, this._rule.formula1 = checkedValue, this._rule.formula2 = uncheckedValue, this;
|
|
107
108
|
}
|
|
108
109
|
/**
|
|
109
110
|
* Set the data validation type to DATE and configure the validation rules to be after a specific date
|
|
@@ -115,8 +116,8 @@ class D {
|
|
|
115
116
|
* const rule = builder.requireDateAfter(new Date('2024-01-01')).build();
|
|
116
117
|
* ```
|
|
117
118
|
*/
|
|
118
|
-
requireDateAfter(
|
|
119
|
-
return this._rule.type =
|
|
119
|
+
requireDateAfter(date) {
|
|
120
|
+
return this._rule.type = DataValidationType.DATE, this._rule.formula1 = date.toLocaleDateString(), this._rule.operator = DataValidationOperator.GREATER_THAN, this;
|
|
120
121
|
}
|
|
121
122
|
/**
|
|
122
123
|
* Set the data validation type to DATE and configure the validation rules to be before a specific date
|
|
@@ -128,8 +129,8 @@ class D {
|
|
|
128
129
|
* const rule = builder.requireDateBefore(new Date('2024-12-31')).build();
|
|
129
130
|
* ```
|
|
130
131
|
*/
|
|
131
|
-
requireDateBefore(
|
|
132
|
-
return this._rule.type =
|
|
132
|
+
requireDateBefore(date) {
|
|
133
|
+
return this._rule.type = DataValidationType.DATE, this._rule.formula1 = date.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.LESS_THAN, this;
|
|
133
134
|
}
|
|
134
135
|
/**
|
|
135
136
|
* Set the data validation type to DATE and configure the validation rules to be within a specific date range
|
|
@@ -144,8 +145,8 @@ class D {
|
|
|
144
145
|
* .build();
|
|
145
146
|
* ```
|
|
146
147
|
*/
|
|
147
|
-
requireDateBetween(
|
|
148
|
-
return this._rule.type =
|
|
148
|
+
requireDateBetween(start, end) {
|
|
149
|
+
return this._rule.type = DataValidationType.DATE, this._rule.formula1 = start.toLocaleDateString(), this._rule.formula2 = end.toLocaleDateString(), this._rule.operator = DataValidationOperator.BETWEEN, this;
|
|
149
150
|
}
|
|
150
151
|
/**
|
|
151
152
|
* Set the data validation type to DATE and configure the validation rules to be equal to a specific date
|
|
@@ -157,8 +158,8 @@ class D {
|
|
|
157
158
|
* const rule = builder.requireDateEqualTo(new Date('2024-01-01')).build();
|
|
158
159
|
* ```
|
|
159
160
|
*/
|
|
160
|
-
requireDateEqualTo(
|
|
161
|
-
return this._rule.type =
|
|
161
|
+
requireDateEqualTo(date) {
|
|
162
|
+
return this._rule.type = DataValidationType.DATE, this._rule.formula1 = date.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.EQUAL, this;
|
|
162
163
|
}
|
|
163
164
|
/**
|
|
164
165
|
* Set the data validation type to DATE and configure the validation rules to be not within a specific date range
|
|
@@ -173,8 +174,8 @@ class D {
|
|
|
173
174
|
* .build();
|
|
174
175
|
* ```
|
|
175
176
|
*/
|
|
176
|
-
requireDateNotBetween(
|
|
177
|
-
return this._rule.type =
|
|
177
|
+
requireDateNotBetween(start, end) {
|
|
178
|
+
return this._rule.type = DataValidationType.DATE, this._rule.formula1 = start.toLocaleDateString(), this._rule.formula2 = end.toLocaleDateString(), this._rule.operator = DataValidationOperator.NOT_BETWEEN, this;
|
|
178
179
|
}
|
|
179
180
|
/**
|
|
180
181
|
* Set the data validation type to DATE and configure the validation rules to be on or after a specific date
|
|
@@ -186,8 +187,8 @@ class D {
|
|
|
186
187
|
* const rule = builder.requireDateOnOrAfter(new Date('2024-01-01')).build();
|
|
187
188
|
* ```
|
|
188
189
|
*/
|
|
189
|
-
requireDateOnOrAfter(
|
|
190
|
-
return this._rule.type =
|
|
190
|
+
requireDateOnOrAfter(date) {
|
|
191
|
+
return this._rule.type = DataValidationType.DATE, this._rule.formula1 = date.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.GREATER_THAN_OR_EQUAL, this;
|
|
191
192
|
}
|
|
192
193
|
/**
|
|
193
194
|
* Set the data validation type to DATE and configure the validation rules to be on or before a specific date
|
|
@@ -199,8 +200,8 @@ class D {
|
|
|
199
200
|
* const rule = builder.requireDateOnOrBefore(new Date('2024-12-31')).build();
|
|
200
201
|
* ```
|
|
201
202
|
*/
|
|
202
|
-
requireDateOnOrBefore(
|
|
203
|
-
return this._rule.type =
|
|
203
|
+
requireDateOnOrBefore(date) {
|
|
204
|
+
return this._rule.type = DataValidationType.DATE, this._rule.formula1 = date.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.LESS_THAN_OR_EQUAL, this;
|
|
204
205
|
}
|
|
205
206
|
/**
|
|
206
207
|
* Requires that a custom formula be satisfied
|
|
@@ -212,8 +213,8 @@ class D {
|
|
|
212
213
|
* const rule = builder.requireFormulaSatisfied('=A1>0').build();
|
|
213
214
|
* ```
|
|
214
215
|
*/
|
|
215
|
-
requireFormulaSatisfied(
|
|
216
|
-
return this._rule.type =
|
|
216
|
+
requireFormulaSatisfied(formula) {
|
|
217
|
+
return this._rule.type = DataValidationType.CUSTOM, this._rule.formula1 = formula, this._rule.formula2 = void 0, this;
|
|
217
218
|
}
|
|
218
219
|
/**
|
|
219
220
|
* Requires the user to enter a number within a specific range, which can be integer or decimal
|
|
@@ -227,8 +228,8 @@ class D {
|
|
|
227
228
|
* const rule = builder.requireNumberBetween(1, 10).build();
|
|
228
229
|
* ```
|
|
229
230
|
*/
|
|
230
|
-
requireNumberBetween(
|
|
231
|
-
return this._rule.formula1 = `${
|
|
231
|
+
requireNumberBetween(start, end, isInteger) {
|
|
232
|
+
return this._rule.formula1 = `${start}`, this._rule.formula2 = `${end}`, this._rule.operator = DataValidationOperator.BETWEEN, this._rule.type = isInteger ? DataValidationType.WHOLE : DataValidationType.DECIMAL, this;
|
|
232
233
|
}
|
|
233
234
|
/**
|
|
234
235
|
* Requires the user to enter a number that is equal to a specific value, which can be an integer or a decimal
|
|
@@ -241,8 +242,8 @@ class D {
|
|
|
241
242
|
* const rule = builder.requireNumberEqualTo(10).build();
|
|
242
243
|
* ```
|
|
243
244
|
*/
|
|
244
|
-
requireNumberEqualTo(
|
|
245
|
-
return this._rule.formula1 = `${
|
|
245
|
+
requireNumberEqualTo(num, isInteger) {
|
|
246
|
+
return this._rule.formula1 = `${num}`, this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.EQUAL, this._rule.type = isInteger ? DataValidationType.WHOLE : DataValidationType.DECIMAL, this;
|
|
246
247
|
}
|
|
247
248
|
/**
|
|
248
249
|
* Requires the user to enter a number that is greater than a specific value, which can be an integer or a decimal
|
|
@@ -255,8 +256,8 @@ class D {
|
|
|
255
256
|
* const rule = builder.requireNumberGreaterThan(10).build();
|
|
256
257
|
* ```
|
|
257
258
|
*/
|
|
258
|
-
requireNumberGreaterThan(
|
|
259
|
-
return this._rule.formula1 = `${
|
|
259
|
+
requireNumberGreaterThan(num, isInteger) {
|
|
260
|
+
return this._rule.formula1 = `${num}`, this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.GREATER_THAN, this._rule.type = isInteger ? DataValidationType.WHOLE : DataValidationType.DECIMAL, this;
|
|
260
261
|
}
|
|
261
262
|
/**
|
|
262
263
|
* Requires the user to enter a number that is greater than or equal to a specific value, which can be an integer or a decimal
|
|
@@ -269,8 +270,8 @@ class D {
|
|
|
269
270
|
* const rule = builder.requireNumberGreaterThanOrEqualTo(10).build();
|
|
270
271
|
* ```
|
|
271
272
|
*/
|
|
272
|
-
requireNumberGreaterThanOrEqualTo(
|
|
273
|
-
return this._rule.formula1 = `${
|
|
273
|
+
requireNumberGreaterThanOrEqualTo(num, isInteger) {
|
|
274
|
+
return this._rule.formula1 = `${num}`, this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.GREATER_THAN_OR_EQUAL, this._rule.type = isInteger ? DataValidationType.WHOLE : DataValidationType.DECIMAL, this;
|
|
274
275
|
}
|
|
275
276
|
/**
|
|
276
277
|
* Requires the user to enter a number that is less than a specific value, which can be an integer or a decimal
|
|
@@ -283,8 +284,8 @@ class D {
|
|
|
283
284
|
* const rule = builder.requireNumberLessThan(10).build();
|
|
284
285
|
* ```
|
|
285
286
|
*/
|
|
286
|
-
requireNumberLessThan(
|
|
287
|
-
return this._rule.formula1 = `${
|
|
287
|
+
requireNumberLessThan(num, isInteger) {
|
|
288
|
+
return this._rule.formula1 = `${num}`, this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.LESS_THAN, this._rule.type = isInteger ? DataValidationType.WHOLE : DataValidationType.DECIMAL, this;
|
|
288
289
|
}
|
|
289
290
|
/**
|
|
290
291
|
* Sets the data validation rule to require a number less than or equal to a specified value
|
|
@@ -298,8 +299,8 @@ class D {
|
|
|
298
299
|
* const rule = builder.requireNumberLessThanOrEqualTo(10).build();
|
|
299
300
|
* ```
|
|
300
301
|
*/
|
|
301
|
-
requireNumberLessThanOrEqualTo(
|
|
302
|
-
return this._rule.formula1 = `${
|
|
302
|
+
requireNumberLessThanOrEqualTo(num, isInteger) {
|
|
303
|
+
return this._rule.formula1 = `${num}`, this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.LESS_THAN_OR_EQUAL, this._rule.type = isInteger ? DataValidationType.WHOLE : DataValidationType.DECIMAL, this;
|
|
303
304
|
}
|
|
304
305
|
/**
|
|
305
306
|
* Sets a data validation rule that requires the user to enter a number outside a specified range
|
|
@@ -314,8 +315,8 @@ class D {
|
|
|
314
315
|
* const rule = builder.requireNumberNotBetween(1, 10).build();
|
|
315
316
|
* ```
|
|
316
317
|
*/
|
|
317
|
-
requireNumberNotBetween(
|
|
318
|
-
return this._rule.formula1 = `${
|
|
318
|
+
requireNumberNotBetween(start, end, isInteger) {
|
|
319
|
+
return this._rule.formula1 = `${start}`, this._rule.formula2 = `${end}`, this._rule.operator = DataValidationOperator.NOT_BETWEEN, this._rule.type = isInteger ? DataValidationType.WHOLE : DataValidationType.DECIMAL, this;
|
|
319
320
|
}
|
|
320
321
|
/**
|
|
321
322
|
* Creates a data validation rule that requires the user to enter a number that is not equal to a specific value
|
|
@@ -329,8 +330,8 @@ class D {
|
|
|
329
330
|
* const rule = builder.requireNumberNotEqualTo(10).build();
|
|
330
331
|
* ```
|
|
331
332
|
*/
|
|
332
|
-
requireNumberNotEqualTo(
|
|
333
|
-
return this._rule.formula1 = `${
|
|
333
|
+
requireNumberNotEqualTo(num, isInteger) {
|
|
334
|
+
return this._rule.formula1 = `${num}`, this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.NOT_EQUAL, this._rule.type = isInteger ? DataValidationType.WHOLE : DataValidationType.DECIMAL, this;
|
|
334
335
|
}
|
|
335
336
|
/**
|
|
336
337
|
* Sets a data validation rule that requires the user to enter a value from a list of specific values
|
|
@@ -345,8 +346,8 @@ class D {
|
|
|
345
346
|
* const rule = builder.requireValueInList(['Yes', 'No']).build();
|
|
346
347
|
* ```
|
|
347
348
|
*/
|
|
348
|
-
requireValueInList(
|
|
349
|
-
return this._rule.type =
|
|
349
|
+
requireValueInList(values, multiple, showDropdown) {
|
|
350
|
+
return this._rule.type = multiple ? DataValidationType.LIST_MULTIPLE : DataValidationType.LIST, this._rule.formula1 = values.join(","), this._rule.formula2 = void 0, this._rule.showDropDown = showDropdown != null ? showDropdown : !0, this;
|
|
350
351
|
}
|
|
351
352
|
/**
|
|
352
353
|
* Sets a data validation rule that requires the user to enter a value within a specific range
|
|
@@ -362,12 +363,12 @@ class D {
|
|
|
362
363
|
* const rule = builder.requireValueInRange(range).build();
|
|
363
364
|
* ```
|
|
364
365
|
*/
|
|
365
|
-
requireValueInRange(
|
|
366
|
-
return this._rule.type =
|
|
367
|
-
unitId:
|
|
368
|
-
sheetName:
|
|
369
|
-
range:
|
|
370
|
-
})}`, this._rule.formula2 = void 0, this._rule.showDropDown =
|
|
366
|
+
requireValueInRange(range, multiple, showDropdown) {
|
|
367
|
+
return this._rule.type = multiple ? DataValidationType.LIST_MULTIPLE : DataValidationType.LIST, this._rule.formula1 = `=${serializeRangeToRefString({
|
|
368
|
+
unitId: range.getUnitId(),
|
|
369
|
+
sheetName: range.getSheetName(),
|
|
370
|
+
range: range.getRange()
|
|
371
|
+
})}`, this._rule.formula2 = void 0, this._rule.showDropDown = showDropdown != null ? showDropdown : !0, this;
|
|
371
372
|
}
|
|
372
373
|
/**
|
|
373
374
|
* Sets whether to allow invalid data and configures the error style
|
|
@@ -381,8 +382,8 @@ class D {
|
|
|
381
382
|
* const rule = builder.setAllowInvalid(true).build();
|
|
382
383
|
* ```
|
|
383
384
|
*/
|
|
384
|
-
setAllowInvalid(
|
|
385
|
-
return this._rule.errorStyle =
|
|
385
|
+
setAllowInvalid(allowInvalidData) {
|
|
386
|
+
return this._rule.errorStyle = allowInvalidData ? DataValidationErrorStyle.WARNING : DataValidationErrorStyle.STOP, this;
|
|
386
387
|
}
|
|
387
388
|
/**
|
|
388
389
|
* Sets whether to allow blank values
|
|
@@ -394,8 +395,8 @@ class D {
|
|
|
394
395
|
* const rule = builder.setAllowBlank(true).build();
|
|
395
396
|
* ```
|
|
396
397
|
*/
|
|
397
|
-
setAllowBlank(
|
|
398
|
-
return this._rule.allowBlank =
|
|
398
|
+
setAllowBlank(allowBlank) {
|
|
399
|
+
return this._rule.allowBlank = allowBlank, this;
|
|
399
400
|
}
|
|
400
401
|
/**
|
|
401
402
|
* Sets the options for the data validation rule
|
|
@@ -411,16 +412,18 @@ class D {
|
|
|
411
412
|
* }).build();
|
|
412
413
|
* ```
|
|
413
414
|
*/
|
|
414
|
-
setOptions(
|
|
415
|
-
return Object.assign(this._rule,
|
|
415
|
+
setOptions(options) {
|
|
416
|
+
return Object.assign(this._rule, options), this;
|
|
416
417
|
}
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
this
|
|
418
|
+
};
|
|
419
|
+
__name(_FDataValidationBuilder, "FDataValidationBuilder");
|
|
420
|
+
let FDataValidationBuilder = _FDataValidationBuilder;
|
|
421
|
+
const _FDataValidation = class _FDataValidation {
|
|
422
|
+
constructor(rule, worksheet, _injector) {
|
|
423
|
+
__publicField(this, "rule");
|
|
424
|
+
__publicField(this, "_worksheet");
|
|
425
|
+
__publicField(this, "_injector");
|
|
426
|
+
this._injector = _injector, this.rule = rule, this._worksheet = worksheet;
|
|
424
427
|
}
|
|
425
428
|
/**
|
|
426
429
|
* Gets whether invalid data is allowed based on the error style value
|
|
@@ -436,7 +439,7 @@ class m {
|
|
|
436
439
|
* ```
|
|
437
440
|
*/
|
|
438
441
|
getAllowInvalid() {
|
|
439
|
-
return this.rule.errorStyle !==
|
|
442
|
+
return this.rule.errorStyle !== DataValidationErrorStyle.STOP;
|
|
440
443
|
}
|
|
441
444
|
/**
|
|
442
445
|
* Gets the data validation type of the rule
|
|
@@ -501,7 +504,7 @@ class m {
|
|
|
501
504
|
* ```
|
|
502
505
|
*/
|
|
503
506
|
copy() {
|
|
504
|
-
return new
|
|
507
|
+
return new FDataValidationBuilder(this.rule);
|
|
505
508
|
}
|
|
506
509
|
/**
|
|
507
510
|
* Gets whether the data validation rule is applied to the worksheet
|
|
@@ -519,8 +522,8 @@ class m {
|
|
|
519
522
|
getApplied() {
|
|
520
523
|
if (!this._worksheet)
|
|
521
524
|
return !1;
|
|
522
|
-
const
|
|
523
|
-
return !!(
|
|
525
|
+
const currentRule = this._injector.get(DataValidationModel).getRuleById(this._worksheet.getUnitId(), this._worksheet.getSheetId(), this.rule.uid);
|
|
526
|
+
return !!(currentRule && currentRule.ranges.length);
|
|
524
527
|
}
|
|
525
528
|
/**
|
|
526
529
|
* Gets the ranges to which the data validation rule is applied
|
|
@@ -538,8 +541,8 @@ class m {
|
|
|
538
541
|
getRanges() {
|
|
539
542
|
if (!this.getApplied())
|
|
540
543
|
return [];
|
|
541
|
-
const
|
|
542
|
-
return this.rule.ranges.map((
|
|
544
|
+
const workbook = this._injector.get(IUniverInstanceService).getUnit(this._worksheet.getUnitId());
|
|
545
|
+
return this.rule.ranges.map((range) => this._injector.createInstance(FRange, workbook, this._worksheet, range));
|
|
543
546
|
}
|
|
544
547
|
/**
|
|
545
548
|
* Gets the unit ID of the worksheet
|
|
@@ -555,8 +558,8 @@ class m {
|
|
|
555
558
|
* ```
|
|
556
559
|
*/
|
|
557
560
|
getUnitId() {
|
|
558
|
-
var
|
|
559
|
-
return (
|
|
561
|
+
var _a;
|
|
562
|
+
return (_a = this._worksheet) == null ? void 0 : _a.getUnitId();
|
|
560
563
|
}
|
|
561
564
|
/**
|
|
562
565
|
* Gets the sheet ID of the worksheet
|
|
@@ -572,8 +575,8 @@ class m {
|
|
|
572
575
|
* ```
|
|
573
576
|
*/
|
|
574
577
|
getSheetId() {
|
|
575
|
-
var
|
|
576
|
-
return (
|
|
578
|
+
var _a;
|
|
579
|
+
return (_a = this._worksheet) == null ? void 0 : _a.getSheetId();
|
|
577
580
|
}
|
|
578
581
|
/**
|
|
579
582
|
* Set Criteria for the data validation rule
|
|
@@ -595,21 +598,21 @@ class m {
|
|
|
595
598
|
* );
|
|
596
599
|
* ```
|
|
597
600
|
*/
|
|
598
|
-
setCriteria(
|
|
599
|
-
if (this.getApplied() && !this._injector.get(
|
|
601
|
+
setCriteria(type, values, allowBlank = !0) {
|
|
602
|
+
if (this.getApplied() && !this._injector.get(ICommandService).syncExecuteCommand(UpdateSheetDataValidationSettingCommand.id, {
|
|
600
603
|
unitId: this.getUnitId(),
|
|
601
604
|
subUnitId: this.getSheetId(),
|
|
602
605
|
ruleId: this.rule.uid,
|
|
603
606
|
setting: {
|
|
604
|
-
operator:
|
|
605
|
-
formula1:
|
|
606
|
-
formula2:
|
|
607
|
+
operator: values[0],
|
|
608
|
+
formula1: values[1],
|
|
609
|
+
formula2: values[2],
|
|
607
610
|
type: this.rule.type,
|
|
608
|
-
allowBlank
|
|
611
|
+
allowBlank
|
|
609
612
|
}
|
|
610
613
|
}))
|
|
611
614
|
throw new Error("setCriteria failed");
|
|
612
|
-
return this.rule.operator =
|
|
615
|
+
return this.rule.operator = values[0], this.rule.formula1 = values[1], this.rule.formula2 = values[2], this.rule.type = type, this.rule.allowBlank = allowBlank, this;
|
|
613
616
|
}
|
|
614
617
|
/**
|
|
615
618
|
* Set the options for the data validation rule
|
|
@@ -629,18 +632,18 @@ class m {
|
|
|
629
632
|
* });
|
|
630
633
|
* ```
|
|
631
634
|
*/
|
|
632
|
-
setOptions(
|
|
633
|
-
if (this.getApplied() && !this._injector.get(
|
|
635
|
+
setOptions(options) {
|
|
636
|
+
if (this.getApplied() && !this._injector.get(ICommandService).syncExecuteCommand(UpdateSheetDataValidationOptionsCommand.id, {
|
|
634
637
|
unitId: this.getUnitId(),
|
|
635
638
|
subUnitId: this.getSheetId(),
|
|
636
639
|
ruleId: this.rule.uid,
|
|
637
640
|
options: {
|
|
638
|
-
...
|
|
639
|
-
...
|
|
641
|
+
...getRuleOptions(this.rule),
|
|
642
|
+
...options
|
|
640
643
|
}
|
|
641
644
|
}))
|
|
642
645
|
throw new Error("setOptions failed");
|
|
643
|
-
return Object.assign(this.rule,
|
|
646
|
+
return Object.assign(this.rule, options), this;
|
|
644
647
|
}
|
|
645
648
|
/**
|
|
646
649
|
* Set the ranges to the data validation rule
|
|
@@ -657,15 +660,15 @@ class m {
|
|
|
657
660
|
* dataValidation.setRanges([range]);
|
|
658
661
|
* ```
|
|
659
662
|
*/
|
|
660
|
-
setRanges(
|
|
661
|
-
if (this.getApplied() && !this._injector.get(
|
|
663
|
+
setRanges(ranges) {
|
|
664
|
+
if (this.getApplied() && !this._injector.get(ICommandService).syncExecuteCommand(UpdateSheetDataValidationRangeCommand.id, {
|
|
662
665
|
unitId: this.getUnitId(),
|
|
663
666
|
subUnitId: this.getSheetId(),
|
|
664
667
|
ruleId: this.rule.uid,
|
|
665
|
-
ranges:
|
|
668
|
+
ranges: ranges.map((range) => range.getRange())
|
|
666
669
|
}))
|
|
667
670
|
throw new Error("setRanges failed");
|
|
668
|
-
return this.rule.ranges =
|
|
671
|
+
return this.rule.ranges = ranges.map((range) => range.getRange()), this;
|
|
669
672
|
}
|
|
670
673
|
/**
|
|
671
674
|
* Delete the data validation rule from the worksheet
|
|
@@ -681,63 +684,67 @@ class m {
|
|
|
681
684
|
* ```
|
|
682
685
|
*/
|
|
683
686
|
delete() {
|
|
684
|
-
return this.getApplied() ? this._injector.get(
|
|
687
|
+
return this.getApplied() ? this._injector.get(ICommandService).syncExecuteCommand(RemoveSheetDataValidationCommand.id, {
|
|
685
688
|
unitId: this.getUnitId(),
|
|
686
689
|
subUnitId: this.getSheetId(),
|
|
687
690
|
ruleId: this.rule.uid
|
|
688
691
|
}) : !1;
|
|
689
692
|
}
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
693
|
+
};
|
|
694
|
+
__name(_FDataValidation, "FDataValidation");
|
|
695
|
+
let FDataValidation = _FDataValidation;
|
|
696
|
+
const _FRangeDataValidationMixin = class _FRangeDataValidationMixin extends FRange {
|
|
697
|
+
setDataValidation(rule) {
|
|
698
|
+
if (!rule)
|
|
699
|
+
return this._commandService.syncExecuteCommand(ClearRangeDataValidationCommand.id, {
|
|
695
700
|
unitId: this._workbook.getUnitId(),
|
|
696
701
|
subUnitId: this._worksheet.getSheetId(),
|
|
697
702
|
ranges: [this._range]
|
|
698
703
|
}), this;
|
|
699
|
-
const
|
|
704
|
+
const params = {
|
|
700
705
|
unitId: this._workbook.getUnitId(),
|
|
701
706
|
subUnitId: this._worksheet.getSheetId(),
|
|
702
707
|
rule: {
|
|
703
|
-
...
|
|
708
|
+
...rule.rule,
|
|
704
709
|
ranges: [this._range]
|
|
705
710
|
}
|
|
706
711
|
};
|
|
707
|
-
return this._commandService.syncExecuteCommand(
|
|
712
|
+
return this._commandService.syncExecuteCommand(AddSheetDataValidationCommand.id, params), this;
|
|
708
713
|
}
|
|
709
714
|
getDataValidation() {
|
|
710
|
-
const
|
|
715
|
+
const rule = this._injector.get(SheetsDataValidationValidatorService).getDataValidation(
|
|
711
716
|
this._workbook.getUnitId(),
|
|
712
717
|
this._worksheet.getSheetId(),
|
|
713
718
|
[this._range]
|
|
714
719
|
);
|
|
715
|
-
return
|
|
720
|
+
return rule && new FDataValidation(rule, this._worksheet, this._injector);
|
|
716
721
|
}
|
|
717
722
|
getDataValidations() {
|
|
718
|
-
return this._injector.get(
|
|
723
|
+
return this._injector.get(SheetsDataValidationValidatorService).getDataValidations(
|
|
719
724
|
this._workbook.getUnitId(),
|
|
720
725
|
this._worksheet.getSheetId(),
|
|
721
726
|
[this._range]
|
|
722
|
-
).map((
|
|
727
|
+
).map((rule) => new FDataValidation(rule, this._worksheet, this._injector));
|
|
723
728
|
}
|
|
724
729
|
async getValidatorStatus() {
|
|
725
|
-
return this._injector.get(
|
|
730
|
+
return this._injector.get(SheetsDataValidationValidatorService).validatorRanges(
|
|
726
731
|
this._workbook.getUnitId(),
|
|
727
732
|
this._worksheet.getSheetId(),
|
|
728
733
|
[this._range]
|
|
729
734
|
);
|
|
730
735
|
}
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
|
|
736
|
+
};
|
|
737
|
+
__name(_FRangeDataValidationMixin, "FRangeDataValidationMixin");
|
|
738
|
+
let FRangeDataValidationMixin = _FRangeDataValidationMixin;
|
|
739
|
+
FRange.extend(FRangeDataValidationMixin);
|
|
740
|
+
const _FUnvierDataValidationMixin = class _FUnvierDataValidationMixin extends FUniver {
|
|
734
741
|
// eslint-disable-next-line jsdoc/require-returns
|
|
735
742
|
/**
|
|
736
743
|
/**
|
|
737
744
|
* @deprecated use `univerAPI.newDataValidation()` as instead.
|
|
738
745
|
*/
|
|
739
746
|
static newDataValidation() {
|
|
740
|
-
return new
|
|
747
|
+
return new FDataValidationBuilder();
|
|
741
748
|
}
|
|
742
749
|
/**
|
|
743
750
|
* Creates a new instance of FDataValidationBuilder
|
|
@@ -749,234 +756,241 @@ class Q extends x {
|
|
|
749
756
|
* ```
|
|
750
757
|
*/
|
|
751
758
|
newDataValidation() {
|
|
752
|
-
return new
|
|
759
|
+
return new FDataValidationBuilder();
|
|
753
760
|
}
|
|
761
|
+
/**
|
|
762
|
+
* @ignore
|
|
763
|
+
*/
|
|
754
764
|
// eslint-disable-next-line max-lines-per-function
|
|
755
|
-
_initialize(
|
|
756
|
-
if (!
|
|
757
|
-
const
|
|
758
|
-
this.disposeWithMe(
|
|
759
|
-
const { unitId
|
|
760
|
-
if (!
|
|
765
|
+
_initialize(injector) {
|
|
766
|
+
if (!injector.has(SheetDataValidationModel)) return;
|
|
767
|
+
const sheetDataValidationModel = injector.get(SheetDataValidationModel), commadnService = injector.get(ICommandService);
|
|
768
|
+
this.disposeWithMe(sheetDataValidationModel.ruleChange$.subscribe((ruleChange) => {
|
|
769
|
+
const { unitId, subUnitId, rule, oldRule, type } = ruleChange, target = this.getSheetTarget(unitId, subUnitId);
|
|
770
|
+
if (!target)
|
|
761
771
|
return;
|
|
762
|
-
const { workbook
|
|
772
|
+
const { workbook, worksheet } = target, fRule = new FDataValidation(rule, worksheet.getSheet(), this._injector);
|
|
763
773
|
this.fireEvent(this.Event.SheetDataValidationChanged, {
|
|
764
|
-
origin:
|
|
765
|
-
worksheet
|
|
766
|
-
workbook
|
|
767
|
-
changeType:
|
|
768
|
-
oldRule
|
|
769
|
-
rule:
|
|
774
|
+
origin: ruleChange,
|
|
775
|
+
worksheet,
|
|
776
|
+
workbook,
|
|
777
|
+
changeType: type,
|
|
778
|
+
oldRule,
|
|
779
|
+
rule: fRule
|
|
770
780
|
});
|
|
771
|
-
})), this.disposeWithMe(
|
|
772
|
-
const { unitId
|
|
773
|
-
if (!
|
|
781
|
+
})), this.disposeWithMe(sheetDataValidationModel.validStatusChange$.subscribe((statusChange) => {
|
|
782
|
+
const { unitId, subUnitId, ruleId, status, row, col } = statusChange, target = this.getSheetTarget(unitId, subUnitId);
|
|
783
|
+
if (!target)
|
|
774
784
|
return;
|
|
775
|
-
const { workbook
|
|
776
|
-
|
|
777
|
-
workbook
|
|
778
|
-
worksheet
|
|
779
|
-
row
|
|
780
|
-
column:
|
|
781
|
-
rule
|
|
782
|
-
status
|
|
785
|
+
const { workbook, worksheet } = target, rule = worksheet.getDataValidation(ruleId);
|
|
786
|
+
rule && this.fireEvent(this.Event.SheetDataValidatorStatusChanged, {
|
|
787
|
+
workbook,
|
|
788
|
+
worksheet,
|
|
789
|
+
row,
|
|
790
|
+
column: col,
|
|
791
|
+
rule,
|
|
792
|
+
status
|
|
783
793
|
});
|
|
784
|
-
})), this.disposeWithMe(
|
|
785
|
-
switch (
|
|
786
|
-
case
|
|
787
|
-
const
|
|
788
|
-
if (!
|
|
794
|
+
})), this.disposeWithMe(commadnService.beforeCommandExecuted((commandInfo) => {
|
|
795
|
+
switch (commandInfo.id) {
|
|
796
|
+
case AddSheetDataValidationCommand.id: {
|
|
797
|
+
const params = commandInfo.params, target = this.getSheetTarget(params.unitId, params.subUnitId);
|
|
798
|
+
if (!target)
|
|
789
799
|
return;
|
|
790
|
-
const { workbook
|
|
791
|
-
worksheet
|
|
792
|
-
workbook
|
|
793
|
-
rule:
|
|
800
|
+
const { workbook, worksheet } = target, eventParams = {
|
|
801
|
+
worksheet,
|
|
802
|
+
workbook,
|
|
803
|
+
rule: params.rule
|
|
794
804
|
};
|
|
795
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationAdd,
|
|
796
|
-
throw new
|
|
805
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationAdd, eventParams), eventParams.cancel)
|
|
806
|
+
throw new CanceledError();
|
|
797
807
|
break;
|
|
798
808
|
}
|
|
799
|
-
case
|
|
800
|
-
const
|
|
801
|
-
if (!
|
|
809
|
+
case UpdateSheetDataValidationSettingCommand.id: {
|
|
810
|
+
const params = commandInfo.params, target = this.getSheetTarget(params.unitId, params.subUnitId);
|
|
811
|
+
if (!target)
|
|
802
812
|
return;
|
|
803
|
-
const { workbook
|
|
804
|
-
if (!
|
|
813
|
+
const { workbook, worksheet } = target, rule = worksheet.getDataValidation(params.ruleId);
|
|
814
|
+
if (!rule)
|
|
805
815
|
return;
|
|
806
|
-
const
|
|
807
|
-
worksheet
|
|
808
|
-
workbook
|
|
809
|
-
rule
|
|
810
|
-
ruleId:
|
|
811
|
-
newCriteria:
|
|
816
|
+
const eventParams = {
|
|
817
|
+
worksheet,
|
|
818
|
+
workbook,
|
|
819
|
+
rule,
|
|
820
|
+
ruleId: params.ruleId,
|
|
821
|
+
newCriteria: params.setting
|
|
812
822
|
};
|
|
813
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationCriteriaUpdate,
|
|
814
|
-
throw new
|
|
823
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationCriteriaUpdate, eventParams), eventParams.cancel)
|
|
824
|
+
throw new CanceledError();
|
|
815
825
|
break;
|
|
816
826
|
}
|
|
817
|
-
case
|
|
818
|
-
const
|
|
819
|
-
if (!
|
|
827
|
+
case UpdateSheetDataValidationRangeCommand.id: {
|
|
828
|
+
const params = commandInfo.params, target = this.getSheetTarget(params.unitId, params.subUnitId);
|
|
829
|
+
if (!target)
|
|
820
830
|
return;
|
|
821
|
-
const { workbook
|
|
822
|
-
if (!
|
|
831
|
+
const { workbook, worksheet } = target, rule = worksheet.getDataValidation(params.ruleId);
|
|
832
|
+
if (!rule)
|
|
823
833
|
return;
|
|
824
|
-
const
|
|
825
|
-
worksheet
|
|
826
|
-
workbook
|
|
827
|
-
rule
|
|
828
|
-
ruleId:
|
|
829
|
-
newRanges:
|
|
834
|
+
const eventParams = {
|
|
835
|
+
worksheet,
|
|
836
|
+
workbook,
|
|
837
|
+
rule,
|
|
838
|
+
ruleId: params.ruleId,
|
|
839
|
+
newRanges: params.ranges
|
|
830
840
|
};
|
|
831
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationRangeUpdate,
|
|
832
|
-
throw new
|
|
841
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationRangeUpdate, eventParams), eventParams.cancel)
|
|
842
|
+
throw new CanceledError();
|
|
833
843
|
break;
|
|
834
844
|
}
|
|
835
|
-
case
|
|
836
|
-
const
|
|
837
|
-
if (!
|
|
845
|
+
case UpdateSheetDataValidationOptionsCommand.id: {
|
|
846
|
+
const params = commandInfo.params, target = this.getSheetTarget(params.unitId, params.subUnitId);
|
|
847
|
+
if (!target)
|
|
838
848
|
return;
|
|
839
|
-
const { workbook
|
|
840
|
-
if (!
|
|
849
|
+
const { workbook, worksheet } = target, rule = worksheet.getDataValidation(params.ruleId);
|
|
850
|
+
if (!rule)
|
|
841
851
|
return;
|
|
842
|
-
const
|
|
843
|
-
worksheet
|
|
844
|
-
workbook
|
|
845
|
-
rule
|
|
846
|
-
ruleId:
|
|
847
|
-
newOptions:
|
|
852
|
+
const eventParams = {
|
|
853
|
+
worksheet,
|
|
854
|
+
workbook,
|
|
855
|
+
rule,
|
|
856
|
+
ruleId: params.ruleId,
|
|
857
|
+
newOptions: params.options
|
|
848
858
|
};
|
|
849
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationOptionsUpdate,
|
|
850
|
-
throw new
|
|
859
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationOptionsUpdate, eventParams), eventParams.cancel)
|
|
860
|
+
throw new CanceledError();
|
|
851
861
|
break;
|
|
852
862
|
}
|
|
853
|
-
case
|
|
854
|
-
const
|
|
855
|
-
if (!
|
|
863
|
+
case RemoveSheetDataValidationCommand.id: {
|
|
864
|
+
const params = commandInfo.params, target = this.getSheetTarget(params.unitId, params.subUnitId);
|
|
865
|
+
if (!target)
|
|
856
866
|
return;
|
|
857
|
-
const { workbook
|
|
858
|
-
if (!
|
|
867
|
+
const { workbook, worksheet } = target, rule = worksheet.getDataValidation(params.ruleId);
|
|
868
|
+
if (!rule)
|
|
859
869
|
return;
|
|
860
|
-
const
|
|
861
|
-
worksheet
|
|
862
|
-
workbook
|
|
863
|
-
rule
|
|
864
|
-
ruleId:
|
|
870
|
+
const eventParams = {
|
|
871
|
+
worksheet,
|
|
872
|
+
workbook,
|
|
873
|
+
rule,
|
|
874
|
+
ruleId: params.ruleId
|
|
865
875
|
};
|
|
866
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationDelete,
|
|
867
|
-
throw new
|
|
876
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationDelete, eventParams), eventParams.cancel)
|
|
877
|
+
throw new CanceledError();
|
|
868
878
|
break;
|
|
869
879
|
}
|
|
870
|
-
case
|
|
871
|
-
const
|
|
872
|
-
if (!
|
|
880
|
+
case RemoveSheetAllDataValidationCommand.id: {
|
|
881
|
+
const params = commandInfo.params, target = this.getSheetTarget(params.unitId, params.subUnitId);
|
|
882
|
+
if (!target)
|
|
873
883
|
return;
|
|
874
|
-
const { workbook
|
|
875
|
-
worksheet
|
|
876
|
-
workbook
|
|
877
|
-
rules:
|
|
884
|
+
const { workbook, worksheet } = target, eventParams = {
|
|
885
|
+
worksheet,
|
|
886
|
+
workbook,
|
|
887
|
+
rules: worksheet.getDataValidations()
|
|
878
888
|
};
|
|
879
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationDeleteAll,
|
|
880
|
-
throw new
|
|
889
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationDeleteAll, eventParams), eventParams.cancel)
|
|
890
|
+
throw new CanceledError();
|
|
881
891
|
break;
|
|
882
892
|
}
|
|
883
893
|
}
|
|
884
894
|
}));
|
|
885
895
|
}
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
|
|
896
|
+
};
|
|
897
|
+
__name(_FUnvierDataValidationMixin, "FUnvierDataValidationMixin");
|
|
898
|
+
let FUnvierDataValidationMixin = _FUnvierDataValidationMixin;
|
|
899
|
+
FUniver.extend(FUnvierDataValidationMixin);
|
|
900
|
+
const _FWorkbookDataValidationMixin = class _FWorkbookDataValidationMixin extends FWorkbook {
|
|
889
901
|
_initialize() {
|
|
890
902
|
Object.defineProperty(this, "_dataValidationModel", {
|
|
891
903
|
get() {
|
|
892
|
-
return this._injector.get(
|
|
904
|
+
return this._injector.get(SheetDataValidationModel);
|
|
893
905
|
}
|
|
894
906
|
});
|
|
895
907
|
}
|
|
896
908
|
getValidatorStatus() {
|
|
897
|
-
return this._injector.get(
|
|
909
|
+
return this._injector.get(SheetsDataValidationValidatorService).validatorWorkbook(this._workbook.getUnitId());
|
|
898
910
|
}
|
|
899
911
|
// region DataValidationHooks
|
|
900
|
-
onDataValidationChange(
|
|
901
|
-
return
|
|
912
|
+
onDataValidationChange(callback) {
|
|
913
|
+
return toDisposable(this._dataValidationModel.ruleChange$.pipe(filter((change) => change.unitId === this._workbook.getUnitId())).subscribe(callback));
|
|
902
914
|
}
|
|
903
|
-
onDataValidationStatusChange(
|
|
904
|
-
return
|
|
915
|
+
onDataValidationStatusChange(callback) {
|
|
916
|
+
return toDisposable(this._dataValidationModel.validStatusChange$.pipe(filter((change) => change.unitId === this._workbook.getUnitId())).subscribe(callback));
|
|
905
917
|
}
|
|
906
|
-
onBeforeAddDataValidation(
|
|
907
|
-
return
|
|
908
|
-
const
|
|
909
|
-
if (
|
|
910
|
-
if (
|
|
918
|
+
onBeforeAddDataValidation(callback) {
|
|
919
|
+
return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {
|
|
920
|
+
const params = commandInfo.params;
|
|
921
|
+
if (commandInfo.id === AddSheetDataValidationCommand.id) {
|
|
922
|
+
if (params.unitId !== this._workbook.getUnitId())
|
|
911
923
|
return;
|
|
912
|
-
if (
|
|
924
|
+
if (callback(params, options) === !1)
|
|
913
925
|
throw new Error("Command is stopped by the hook onBeforeAddDataValidation");
|
|
914
926
|
}
|
|
915
927
|
}));
|
|
916
928
|
}
|
|
917
|
-
onBeforeUpdateDataValidationCriteria(
|
|
918
|
-
return
|
|
919
|
-
const
|
|
920
|
-
if (
|
|
921
|
-
if (
|
|
929
|
+
onBeforeUpdateDataValidationCriteria(callback) {
|
|
930
|
+
return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {
|
|
931
|
+
const params = commandInfo.params;
|
|
932
|
+
if (commandInfo.id === UpdateSheetDataValidationSettingCommand.id) {
|
|
933
|
+
if (params.unitId !== this._workbook.getUnitId())
|
|
922
934
|
return;
|
|
923
|
-
if (
|
|
935
|
+
if (callback(params, options) === !1)
|
|
924
936
|
throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationCriteria");
|
|
925
937
|
}
|
|
926
938
|
}));
|
|
927
939
|
}
|
|
928
|
-
onBeforeUpdateDataValidationRange(
|
|
929
|
-
return
|
|
930
|
-
const
|
|
931
|
-
if (
|
|
932
|
-
if (
|
|
940
|
+
onBeforeUpdateDataValidationRange(callback) {
|
|
941
|
+
return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {
|
|
942
|
+
const params = commandInfo.params;
|
|
943
|
+
if (commandInfo.id === UpdateSheetDataValidationRangeCommand.id) {
|
|
944
|
+
if (params.unitId !== this._workbook.getUnitId())
|
|
933
945
|
return;
|
|
934
|
-
if (
|
|
946
|
+
if (callback(params, options) === !1)
|
|
935
947
|
throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationRange");
|
|
936
948
|
}
|
|
937
949
|
}));
|
|
938
950
|
}
|
|
939
|
-
onBeforeUpdateDataValidationOptions(
|
|
940
|
-
return
|
|
941
|
-
const
|
|
942
|
-
if (
|
|
943
|
-
if (
|
|
951
|
+
onBeforeUpdateDataValidationOptions(callback) {
|
|
952
|
+
return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {
|
|
953
|
+
const params = commandInfo.params;
|
|
954
|
+
if (commandInfo.id === UpdateSheetDataValidationOptionsCommand.id) {
|
|
955
|
+
if (params.unitId !== this._workbook.getUnitId())
|
|
944
956
|
return;
|
|
945
|
-
if (
|
|
957
|
+
if (callback(params, options) === !1)
|
|
946
958
|
throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationOptions");
|
|
947
959
|
}
|
|
948
960
|
}));
|
|
949
961
|
}
|
|
950
|
-
onBeforeDeleteDataValidation(
|
|
951
|
-
return
|
|
952
|
-
const
|
|
953
|
-
if (
|
|
954
|
-
if (
|
|
962
|
+
onBeforeDeleteDataValidation(callback) {
|
|
963
|
+
return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {
|
|
964
|
+
const params = commandInfo.params;
|
|
965
|
+
if (commandInfo.id === RemoveSheetDataValidationCommand.id) {
|
|
966
|
+
if (params.unitId !== this._workbook.getUnitId())
|
|
955
967
|
return;
|
|
956
|
-
if (
|
|
968
|
+
if (callback(params, options) === !1)
|
|
957
969
|
throw new Error("Command is stopped by the hook onBeforeDeleteDataValidation");
|
|
958
970
|
}
|
|
959
971
|
}));
|
|
960
972
|
}
|
|
961
|
-
onBeforeDeleteAllDataValidation(
|
|
962
|
-
return
|
|
963
|
-
const
|
|
964
|
-
if (
|
|
965
|
-
if (
|
|
973
|
+
onBeforeDeleteAllDataValidation(callback) {
|
|
974
|
+
return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {
|
|
975
|
+
const params = commandInfo.params;
|
|
976
|
+
if (commandInfo.id === RemoveSheetAllDataValidationCommand.id) {
|
|
977
|
+
if (params.unitId !== this._workbook.getUnitId())
|
|
966
978
|
return;
|
|
967
|
-
if (
|
|
979
|
+
if (callback(params, options) === !1)
|
|
968
980
|
throw new Error("Command is stopped by the hook onBeforeDeleteAllDataValidation");
|
|
969
981
|
}
|
|
970
982
|
}));
|
|
971
983
|
}
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
|
|
984
|
+
};
|
|
985
|
+
__name(_FWorkbookDataValidationMixin, "FWorkbookDataValidationMixin");
|
|
986
|
+
let FWorkbookDataValidationMixin = _FWorkbookDataValidationMixin;
|
|
987
|
+
FWorkbook.extend(FWorkbookDataValidationMixin);
|
|
988
|
+
const _FWorksheetDataValidationMixin = class _FWorksheetDataValidationMixin extends FWorksheet {
|
|
975
989
|
getDataValidations() {
|
|
976
|
-
return this._injector.get(
|
|
990
|
+
return this._injector.get(DataValidationModel).getRules(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((rule) => new FDataValidation(rule, this._worksheet, this._injector));
|
|
977
991
|
}
|
|
978
992
|
getValidatorStatus() {
|
|
979
|
-
return this._injector.get(
|
|
993
|
+
return this._injector.get(SheetsDataValidationValidatorService).validatorWorksheet(
|
|
980
994
|
this._workbook.getUnitId(),
|
|
981
995
|
this._worksheet.getSheetId()
|
|
982
996
|
);
|
|
@@ -984,13 +998,15 @@ class K extends N {
|
|
|
984
998
|
getValidatorStatusAsync() {
|
|
985
999
|
return this.getValidatorStatus();
|
|
986
1000
|
}
|
|
987
|
-
getDataValidation(
|
|
988
|
-
const
|
|
989
|
-
return
|
|
1001
|
+
getDataValidation(ruleId) {
|
|
1002
|
+
const rule = this._injector.get(DataValidationModel).getRuleById(this._workbook.getUnitId(), this._worksheet.getSheetId(), ruleId);
|
|
1003
|
+
return rule ? new FDataValidation(rule, this._worksheet, this._injector) : null;
|
|
990
1004
|
}
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
|
|
1005
|
+
};
|
|
1006
|
+
__name(_FWorksheetDataValidationMixin, "FWorksheetDataValidationMixin");
|
|
1007
|
+
let FWorksheetDataValidationMixin = _FWorksheetDataValidationMixin;
|
|
1008
|
+
FWorksheet.extend(FWorksheetDataValidationMixin);
|
|
1009
|
+
const _FDataValidationEvent = class _FDataValidationEvent {
|
|
994
1010
|
get SheetDataValidationChanged() {
|
|
995
1011
|
return "SheetDataValidationChanged";
|
|
996
1012
|
}
|
|
@@ -1015,9 +1031,11 @@ class X {
|
|
|
1015
1031
|
get BeforeSheetDataValidationOptionsUpdate() {
|
|
1016
1032
|
return "BeforeSheetDataValidationOptionsUpdate";
|
|
1017
1033
|
}
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1034
|
+
};
|
|
1035
|
+
__name(_FDataValidationEvent, "FDataValidationEvent");
|
|
1036
|
+
let FDataValidationEvent = _FDataValidationEvent;
|
|
1037
|
+
FEventName.extend(FDataValidationEvent);
|
|
1020
1038
|
export {
|
|
1021
|
-
|
|
1022
|
-
|
|
1039
|
+
FDataValidation,
|
|
1040
|
+
FDataValidationBuilder
|
|
1023
1041
|
};
|