@univerjs/sheets-data-validation 0.6.0-nightly.202502101606 → 0.6.0-nightly.202502121606
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 +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +221 -200
- package/lib/es/index.js +2 -2
- package/lib/types/common/const.d.ts +1 -1
- package/lib/types/controllers/config.schema.d.ts +1 -1
- package/lib/types/facade/index.d.ts +1 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/plugin.d.ts +1 -1
- package/lib/types/types/const/index.d.ts +1 -1
- package/lib/types/types/index.d.ts +1 -1
- package/lib/types/types/interface/i-update-rule-formula.d.ts +1 -1
- package/lib/types/types/interface/index.d.ts +1 -1
- package/lib/types/validators/const.d.ts +1 -1
- package/lib/types/validators/index.d.ts +1 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +6 -6
package/lib/es/facade.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { UpdateSheetDataValidationSettingCommand as
|
|
5
|
-
import { FRange as y, FWorkbook as
|
|
6
|
-
import { generateRandomId as
|
|
7
|
-
import { DataValidationModel as
|
|
1
|
+
var H = Object.defineProperty;
|
|
2
|
+
var j = (g, e, t) => e in g ? H(g, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[e] = t;
|
|
3
|
+
var m = (g, e, t) => j(g, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { UpdateSheetDataValidationSettingCommand as b, UpdateSheetDataValidationOptionsCommand as U, UpdateSheetDataValidationRangeCommand as C, RemoveSheetDataValidationCommand as A, ClearRangeDataValidationCommand as q, AddSheetDataValidationCommand as T, SheetsDataValidationValidatorService as S, SheetDataValidationModel as w, RemoveSheetAllDataValidationCommand as O } from "@univerjs/sheets-data-validation";
|
|
5
|
+
import { FRange as y, FWorkbook as x, FWorksheet as N } from "@univerjs/sheets/facade";
|
|
6
|
+
import { generateRandomId as L, DataValidationType as n, DataValidationErrorStyle as k, DataValidationOperator as h, IUniverInstanceService as W, ICommandService as p, FUniver as M, CanceledError as f, toDisposable as c, FEventName as $ } from "@univerjs/core";
|
|
7
|
+
import { DataValidationModel as v, getRuleOptions as F } from "@univerjs/data-validation";
|
|
8
8
|
import { serializeRangeToRefString as P } from "@univerjs/engine-formula";
|
|
9
9
|
import { filter as R } from "rxjs";
|
|
10
|
-
class
|
|
10
|
+
class E {
|
|
11
11
|
constructor(e) {
|
|
12
|
-
|
|
12
|
+
m(this, "_rule");
|
|
13
13
|
this._rule = e != null ? e : {
|
|
14
|
-
uid:
|
|
14
|
+
uid: L(),
|
|
15
15
|
ranges: void 0,
|
|
16
|
-
type:
|
|
16
|
+
type: n.CUSTOM
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
@@ -26,7 +26,7 @@ class D {
|
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
build() {
|
|
29
|
-
return new
|
|
29
|
+
return new _(this._rule);
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Creates a duplicate of the current DataValidationBuilder object
|
|
@@ -38,9 +38,9 @@ class D {
|
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
40
|
copy() {
|
|
41
|
-
return new
|
|
41
|
+
return new E({
|
|
42
42
|
...this._rule,
|
|
43
|
-
uid:
|
|
43
|
+
uid: L()
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
@@ -53,7 +53,7 @@ class D {
|
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
55
|
getAllowInvalid() {
|
|
56
|
-
return this._rule.errorStyle !==
|
|
56
|
+
return this._rule.errorStyle !== k.STOP;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Gets the data validation type of the rule
|
|
@@ -103,7 +103,7 @@ class D {
|
|
|
103
103
|
* ```
|
|
104
104
|
*/
|
|
105
105
|
requireCheckbox(e, t) {
|
|
106
|
-
return this._rule.type =
|
|
106
|
+
return this._rule.type = n.CHECKBOX, this._rule.formula1 = e, this._rule.formula2 = t, this;
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
109
|
* Set the data validation type to DATE and configure the validation rules to be after a specific date
|
|
@@ -116,7 +116,7 @@ class D {
|
|
|
116
116
|
* ```
|
|
117
117
|
*/
|
|
118
118
|
requireDateAfter(e) {
|
|
119
|
-
return this._rule.type =
|
|
119
|
+
return this._rule.type = n.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.operator = h.GREATER_THAN, this;
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
122
|
* Set the data validation type to DATE and configure the validation rules to be before a specific date
|
|
@@ -129,7 +129,7 @@ class D {
|
|
|
129
129
|
* ```
|
|
130
130
|
*/
|
|
131
131
|
requireDateBefore(e) {
|
|
132
|
-
return this._rule.type =
|
|
132
|
+
return this._rule.type = n.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = h.LESS_THAN, this;
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
135
135
|
* Set the data validation type to DATE and configure the validation rules to be within a specific date range
|
|
@@ -145,7 +145,7 @@ class D {
|
|
|
145
145
|
* ```
|
|
146
146
|
*/
|
|
147
147
|
requireDateBetween(e, t) {
|
|
148
|
-
return this._rule.type =
|
|
148
|
+
return this._rule.type = n.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = t.toLocaleDateString(), this._rule.operator = h.BETWEEN, this;
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
151
|
* Set the data validation type to DATE and configure the validation rules to be equal to a specific date
|
|
@@ -158,7 +158,7 @@ class D {
|
|
|
158
158
|
* ```
|
|
159
159
|
*/
|
|
160
160
|
requireDateEqualTo(e) {
|
|
161
|
-
return this._rule.type =
|
|
161
|
+
return this._rule.type = n.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = h.EQUAL, this;
|
|
162
162
|
}
|
|
163
163
|
/**
|
|
164
164
|
* Set the data validation type to DATE and configure the validation rules to be not within a specific date range
|
|
@@ -174,7 +174,7 @@ class D {
|
|
|
174
174
|
* ```
|
|
175
175
|
*/
|
|
176
176
|
requireDateNotBetween(e, t) {
|
|
177
|
-
return this._rule.type =
|
|
177
|
+
return this._rule.type = n.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = t.toLocaleDateString(), this._rule.operator = h.NOT_BETWEEN, this;
|
|
178
178
|
}
|
|
179
179
|
/**
|
|
180
180
|
* Set the data validation type to DATE and configure the validation rules to be on or after a specific date
|
|
@@ -187,7 +187,7 @@ class D {
|
|
|
187
187
|
* ```
|
|
188
188
|
*/
|
|
189
189
|
requireDateOnOrAfter(e) {
|
|
190
|
-
return this._rule.type =
|
|
190
|
+
return this._rule.type = n.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = h.GREATER_THAN_OR_EQUAL, this;
|
|
191
191
|
}
|
|
192
192
|
/**
|
|
193
193
|
* Set the data validation type to DATE and configure the validation rules to be on or before a specific date
|
|
@@ -200,7 +200,7 @@ class D {
|
|
|
200
200
|
* ```
|
|
201
201
|
*/
|
|
202
202
|
requireDateOnOrBefore(e) {
|
|
203
|
-
return this._rule.type =
|
|
203
|
+
return this._rule.type = n.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = h.LESS_THAN_OR_EQUAL, this;
|
|
204
204
|
}
|
|
205
205
|
/**
|
|
206
206
|
* Requires that a custom formula be satisfied
|
|
@@ -213,7 +213,7 @@ class D {
|
|
|
213
213
|
* ```
|
|
214
214
|
*/
|
|
215
215
|
requireFormulaSatisfied(e) {
|
|
216
|
-
return this._rule.type =
|
|
216
|
+
return this._rule.type = n.CUSTOM, this._rule.formula1 = e, this._rule.formula2 = void 0, this;
|
|
217
217
|
}
|
|
218
218
|
/**
|
|
219
219
|
* Requires the user to enter a number within a specific range, which can be integer or decimal
|
|
@@ -227,8 +227,8 @@ class D {
|
|
|
227
227
|
* const rule = builder.requireNumberBetween(1, 10).build();
|
|
228
228
|
* ```
|
|
229
229
|
*/
|
|
230
|
-
requireNumberBetween(e, t,
|
|
231
|
-
return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = h.BETWEEN, this._rule.type =
|
|
230
|
+
requireNumberBetween(e, t, i) {
|
|
231
|
+
return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = h.BETWEEN, this._rule.type = i ? n.WHOLE : n.DECIMAL, this;
|
|
232
232
|
}
|
|
233
233
|
/**
|
|
234
234
|
* Requires the user to enter a number that is equal to a specific value, which can be an integer or a decimal
|
|
@@ -242,7 +242,7 @@ class D {
|
|
|
242
242
|
* ```
|
|
243
243
|
*/
|
|
244
244
|
requireNumberEqualTo(e, t) {
|
|
245
|
-
return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = h.EQUAL, this._rule.type = t ?
|
|
245
|
+
return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = h.EQUAL, this._rule.type = t ? n.WHOLE : n.DECIMAL, this;
|
|
246
246
|
}
|
|
247
247
|
/**
|
|
248
248
|
* Requires the user to enter a number that is greater than a specific value, which can be an integer or a decimal
|
|
@@ -256,7 +256,7 @@ class D {
|
|
|
256
256
|
* ```
|
|
257
257
|
*/
|
|
258
258
|
requireNumberGreaterThan(e, t) {
|
|
259
|
-
return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = h.GREATER_THAN, this._rule.type = t ?
|
|
259
|
+
return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = h.GREATER_THAN, this._rule.type = t ? n.WHOLE : n.DECIMAL, this;
|
|
260
260
|
}
|
|
261
261
|
/**
|
|
262
262
|
* 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
|
|
@@ -270,7 +270,7 @@ class D {
|
|
|
270
270
|
* ```
|
|
271
271
|
*/
|
|
272
272
|
requireNumberGreaterThanOrEqualTo(e, t) {
|
|
273
|
-
return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = h.GREATER_THAN_OR_EQUAL, this._rule.type = t ?
|
|
273
|
+
return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = h.GREATER_THAN_OR_EQUAL, this._rule.type = t ? n.WHOLE : n.DECIMAL, this;
|
|
274
274
|
}
|
|
275
275
|
/**
|
|
276
276
|
* Requires the user to enter a number that is less than a specific value, which can be an integer or a decimal
|
|
@@ -284,7 +284,7 @@ class D {
|
|
|
284
284
|
* ```
|
|
285
285
|
*/
|
|
286
286
|
requireNumberLessThan(e, t) {
|
|
287
|
-
return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = h.LESS_THAN, this._rule.type = t ?
|
|
287
|
+
return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = h.LESS_THAN, this._rule.type = t ? n.WHOLE : n.DECIMAL, this;
|
|
288
288
|
}
|
|
289
289
|
/**
|
|
290
290
|
* Sets the data validation rule to require a number less than or equal to a specified value
|
|
@@ -299,7 +299,7 @@ class D {
|
|
|
299
299
|
* ```
|
|
300
300
|
*/
|
|
301
301
|
requireNumberLessThanOrEqualTo(e, t) {
|
|
302
|
-
return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = h.LESS_THAN_OR_EQUAL, this._rule.type = t ?
|
|
302
|
+
return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = h.LESS_THAN_OR_EQUAL, this._rule.type = t ? n.WHOLE : n.DECIMAL, this;
|
|
303
303
|
}
|
|
304
304
|
/**
|
|
305
305
|
* Sets a data validation rule that requires the user to enter a number outside a specified range
|
|
@@ -314,8 +314,8 @@ class D {
|
|
|
314
314
|
* const rule = builder.requireNumberNotBetween(1, 10).build();
|
|
315
315
|
* ```
|
|
316
316
|
*/
|
|
317
|
-
requireNumberNotBetween(e, t,
|
|
318
|
-
return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = h.NOT_BETWEEN, this._rule.type =
|
|
317
|
+
requireNumberNotBetween(e, t, i) {
|
|
318
|
+
return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = h.NOT_BETWEEN, this._rule.type = i ? n.WHOLE : n.DECIMAL, this;
|
|
319
319
|
}
|
|
320
320
|
/**
|
|
321
321
|
* Creates a data validation rule that requires the user to enter a number that is not equal to a specific value
|
|
@@ -330,7 +330,7 @@ class D {
|
|
|
330
330
|
* ```
|
|
331
331
|
*/
|
|
332
332
|
requireNumberNotEqualTo(e, t) {
|
|
333
|
-
return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = h.NOT_EQUAL, this._rule.type = t ?
|
|
333
|
+
return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = h.NOT_EQUAL, this._rule.type = t ? n.WHOLE : n.DECIMAL, this;
|
|
334
334
|
}
|
|
335
335
|
/**
|
|
336
336
|
* Sets a data validation rule that requires the user to enter a value from a list of specific values
|
|
@@ -345,8 +345,8 @@ class D {
|
|
|
345
345
|
* const rule = builder.requireValueInList(['Yes', 'No']).build();
|
|
346
346
|
* ```
|
|
347
347
|
*/
|
|
348
|
-
requireValueInList(e, t,
|
|
349
|
-
return this._rule.type = t ?
|
|
348
|
+
requireValueInList(e, t, i) {
|
|
349
|
+
return this._rule.type = t ? n.LIST_MULTIPLE : n.LIST, this._rule.formula1 = e.join(","), this._rule.formula2 = void 0, this._rule.showDropDown = i != null ? i : !0, this;
|
|
350
350
|
}
|
|
351
351
|
/**
|
|
352
352
|
* Sets a data validation rule that requires the user to enter a value within a specific range
|
|
@@ -362,12 +362,12 @@ class D {
|
|
|
362
362
|
* const rule = builder.requireValueInRange(range).build();
|
|
363
363
|
* ```
|
|
364
364
|
*/
|
|
365
|
-
requireValueInRange(e, t,
|
|
366
|
-
return this._rule.type = t ?
|
|
365
|
+
requireValueInRange(e, t, i) {
|
|
366
|
+
return this._rule.type = t ? n.LIST_MULTIPLE : n.LIST, this._rule.formula1 = `=${P({
|
|
367
367
|
unitId: e.getUnitId(),
|
|
368
368
|
sheetName: e.getSheetName(),
|
|
369
369
|
range: e.getRange()
|
|
370
|
-
})}`, this._rule.formula2 = void 0, this._rule.showDropDown =
|
|
370
|
+
})}`, this._rule.formula2 = void 0, this._rule.showDropDown = i != null ? i : !0, this;
|
|
371
371
|
}
|
|
372
372
|
/**
|
|
373
373
|
* Sets whether to allow invalid data and configures the error style
|
|
@@ -382,7 +382,7 @@ class D {
|
|
|
382
382
|
* ```
|
|
383
383
|
*/
|
|
384
384
|
setAllowInvalid(e) {
|
|
385
|
-
return this._rule.errorStyle = e ?
|
|
385
|
+
return this._rule.errorStyle = e ? k.WARNING : k.STOP, this;
|
|
386
386
|
}
|
|
387
387
|
/**
|
|
388
388
|
* Sets whether to allow blank values
|
|
@@ -415,12 +415,12 @@ class D {
|
|
|
415
415
|
return Object.assign(this._rule, e), this;
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
|
-
class
|
|
419
|
-
constructor(e, t,
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
this._injector =
|
|
418
|
+
class _ {
|
|
419
|
+
constructor(e, t, i) {
|
|
420
|
+
m(this, "rule");
|
|
421
|
+
m(this, "_worksheet");
|
|
422
|
+
m(this, "_injector");
|
|
423
|
+
this._injector = i, this.rule = e, this._worksheet = t;
|
|
424
424
|
}
|
|
425
425
|
/**
|
|
426
426
|
* Gets whether invalid data is allowed based on the error style value
|
|
@@ -436,7 +436,7 @@ class m {
|
|
|
436
436
|
* ```
|
|
437
437
|
*/
|
|
438
438
|
getAllowInvalid() {
|
|
439
|
-
return this.rule.errorStyle !==
|
|
439
|
+
return this.rule.errorStyle !== k.STOP;
|
|
440
440
|
}
|
|
441
441
|
/**
|
|
442
442
|
* Gets the data validation type of the rule
|
|
@@ -501,7 +501,7 @@ class m {
|
|
|
501
501
|
* ```
|
|
502
502
|
*/
|
|
503
503
|
copy() {
|
|
504
|
-
return new
|
|
504
|
+
return new E(this.rule);
|
|
505
505
|
}
|
|
506
506
|
/**
|
|
507
507
|
* Gets whether the data validation rule is applied to the worksheet
|
|
@@ -519,7 +519,7 @@ class m {
|
|
|
519
519
|
getApplied() {
|
|
520
520
|
if (!this._worksheet)
|
|
521
521
|
return !1;
|
|
522
|
-
const t = this._injector.get(
|
|
522
|
+
const t = this._injector.get(v).getRuleById(this._worksheet.getUnitId(), this._worksheet.getSheetId(), this.rule.uid);
|
|
523
523
|
return !!(t && t.ranges.length);
|
|
524
524
|
}
|
|
525
525
|
/**
|
|
@@ -538,7 +538,7 @@ class m {
|
|
|
538
538
|
getRanges() {
|
|
539
539
|
if (!this.getApplied())
|
|
540
540
|
return [];
|
|
541
|
-
const e = this._injector.get(
|
|
541
|
+
const e = this._injector.get(W).getUnit(this._worksheet.getUnitId());
|
|
542
542
|
return this.rule.ranges.map((t) => this._injector.createInstance(y, e, this._worksheet, t));
|
|
543
543
|
}
|
|
544
544
|
/**
|
|
@@ -595,8 +595,8 @@ class m {
|
|
|
595
595
|
* );
|
|
596
596
|
* ```
|
|
597
597
|
*/
|
|
598
|
-
setCriteria(e, t,
|
|
599
|
-
if (this.getApplied() && !this._injector.get(p).syncExecuteCommand(
|
|
598
|
+
setCriteria(e, t, i = !0) {
|
|
599
|
+
if (this.getApplied() && !this._injector.get(p).syncExecuteCommand(b.id, {
|
|
600
600
|
unitId: this.getUnitId(),
|
|
601
601
|
subUnitId: this.getSheetId(),
|
|
602
602
|
ruleId: this.rule.uid,
|
|
@@ -605,11 +605,11 @@ class m {
|
|
|
605
605
|
formula1: t[1],
|
|
606
606
|
formula2: t[2],
|
|
607
607
|
type: this.rule.type,
|
|
608
|
-
allowBlank:
|
|
608
|
+
allowBlank: i
|
|
609
609
|
}
|
|
610
610
|
}))
|
|
611
611
|
throw new Error("setCriteria failed");
|
|
612
|
-
return this.rule.operator = t[0], this.rule.formula1 = t[1], this.rule.formula2 = t[2], this.rule.type = e, this.rule.allowBlank =
|
|
612
|
+
return this.rule.operator = t[0], this.rule.formula1 = t[1], this.rule.formula2 = t[2], this.rule.type = e, this.rule.allowBlank = i, this;
|
|
613
613
|
}
|
|
614
614
|
/**
|
|
615
615
|
* Set the options for the data validation rule
|
|
@@ -630,7 +630,7 @@ class m {
|
|
|
630
630
|
* ```
|
|
631
631
|
*/
|
|
632
632
|
setOptions(e) {
|
|
633
|
-
if (this.getApplied() && !this._injector.get(p).syncExecuteCommand(
|
|
633
|
+
if (this.getApplied() && !this._injector.get(p).syncExecuteCommand(U.id, {
|
|
634
634
|
unitId: this.getUnitId(),
|
|
635
635
|
subUnitId: this.getSheetId(),
|
|
636
636
|
ruleId: this.rule.uid,
|
|
@@ -662,7 +662,7 @@ class m {
|
|
|
662
662
|
unitId: this.getUnitId(),
|
|
663
663
|
subUnitId: this.getSheetId(),
|
|
664
664
|
ruleId: this.rule.uid,
|
|
665
|
-
ranges: e.map((
|
|
665
|
+
ranges: e.map((r) => r.getRange())
|
|
666
666
|
}))
|
|
667
667
|
throw new Error("setRanges failed");
|
|
668
668
|
return this.rule.ranges = e.map((t) => t.getRange()), this;
|
|
@@ -681,7 +681,7 @@ class m {
|
|
|
681
681
|
* ```
|
|
682
682
|
*/
|
|
683
683
|
delete() {
|
|
684
|
-
return this.getApplied() ? this._injector.get(p).syncExecuteCommand(
|
|
684
|
+
return this.getApplied() ? this._injector.get(p).syncExecuteCommand(A.id, {
|
|
685
685
|
unitId: this.getUnitId(),
|
|
686
686
|
subUnitId: this.getSheetId(),
|
|
687
687
|
ruleId: this.rule.uid
|
|
@@ -691,7 +691,7 @@ class m {
|
|
|
691
691
|
class G extends y {
|
|
692
692
|
setDataValidation(e) {
|
|
693
693
|
if (!e)
|
|
694
|
-
return this._commandService.syncExecuteCommand(
|
|
694
|
+
return this._commandService.syncExecuteCommand(q.id, {
|
|
695
695
|
unitId: this._workbook.getUnitId(),
|
|
696
696
|
subUnitId: this._worksheet.getSheetId(),
|
|
697
697
|
ranges: [this._range]
|
|
@@ -704,7 +704,7 @@ class G extends y {
|
|
|
704
704
|
ranges: [this._range]
|
|
705
705
|
}
|
|
706
706
|
};
|
|
707
|
-
return this._commandService.syncExecuteCommand(
|
|
707
|
+
return this._commandService.syncExecuteCommand(T.id, t), this;
|
|
708
708
|
}
|
|
709
709
|
getDataValidation() {
|
|
710
710
|
const t = this._injector.get(S).getDataValidation(
|
|
@@ -712,14 +712,14 @@ class G extends y {
|
|
|
712
712
|
this._worksheet.getSheetId(),
|
|
713
713
|
[this._range]
|
|
714
714
|
);
|
|
715
|
-
return t && new
|
|
715
|
+
return t && new _(t, this._worksheet, this._injector);
|
|
716
716
|
}
|
|
717
717
|
getDataValidations() {
|
|
718
718
|
return this._injector.get(S).getDataValidations(
|
|
719
719
|
this._workbook.getUnitId(),
|
|
720
720
|
this._worksheet.getSheetId(),
|
|
721
721
|
[this._range]
|
|
722
|
-
).map((t) => new
|
|
722
|
+
).map((t) => new _(t, this._worksheet, this._injector));
|
|
723
723
|
}
|
|
724
724
|
async getValidatorStatus() {
|
|
725
725
|
return this._injector.get(S).validatorRanges(
|
|
@@ -730,159 +730,180 @@ class G extends y {
|
|
|
730
730
|
}
|
|
731
731
|
}
|
|
732
732
|
y.extend(G);
|
|
733
|
-
class Q extends
|
|
733
|
+
class Q extends M {
|
|
734
734
|
/**
|
|
735
735
|
* @deprecated use `univerAPI.newDataValidation()` as instead.
|
|
736
736
|
* @returns {FDataValidationBuilder} A new instance of the FDataValidationBuilder class
|
|
737
737
|
*/
|
|
738
738
|
static newDataValidation() {
|
|
739
|
-
return new
|
|
739
|
+
return new E();
|
|
740
740
|
}
|
|
741
741
|
newDataValidation() {
|
|
742
|
-
return new
|
|
742
|
+
return new E();
|
|
743
743
|
}
|
|
744
744
|
/**
|
|
745
745
|
* @ignore
|
|
746
746
|
*/
|
|
747
747
|
// eslint-disable-next-line max-lines-per-function
|
|
748
748
|
_initialize(e) {
|
|
749
|
-
if (!e.has(
|
|
750
|
-
const t = e.get(
|
|
751
|
-
this.
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
749
|
+
if (!e.has(w)) return;
|
|
750
|
+
const t = e.get(w), i = e.get(p);
|
|
751
|
+
this.registerEventHandler(
|
|
752
|
+
this.Event.SheetDataValidationChanged,
|
|
753
|
+
() => t.ruleChange$.subscribe((r) => {
|
|
754
|
+
const { unitId: a, subUnitId: o, rule: u, oldRule: l, type: s } = r, d = this.getSheetTarget(a, o);
|
|
755
|
+
if (!d)
|
|
756
|
+
return;
|
|
757
|
+
const { workbook: D, worksheet: I } = d, V = new _(u, I.getSheet(), this._injector);
|
|
758
|
+
this.fireEvent(this.Event.SheetDataValidationChanged, {
|
|
759
|
+
origin: r,
|
|
760
|
+
worksheet: I,
|
|
761
|
+
workbook: D,
|
|
762
|
+
changeType: s,
|
|
763
|
+
oldRule: l,
|
|
764
|
+
rule: V
|
|
765
|
+
});
|
|
766
|
+
})
|
|
767
|
+
), this.registerEventHandler(
|
|
768
|
+
this.Event.SheetDataValidatorStatusChanged,
|
|
769
|
+
() => t.validStatusChange$.subscribe((r) => {
|
|
770
|
+
const { unitId: a, subUnitId: o, ruleId: u, status: l, row: s, col: d } = r, D = this.getSheetTarget(a, o);
|
|
771
|
+
if (!D)
|
|
772
|
+
return;
|
|
773
|
+
const { workbook: I, worksheet: V } = D, B = V.getDataValidation(u);
|
|
774
|
+
B && this.fireEvent(this.Event.SheetDataValidatorStatusChanged, {
|
|
775
|
+
workbook: I,
|
|
776
|
+
worksheet: V,
|
|
777
|
+
row: s,
|
|
778
|
+
column: d,
|
|
779
|
+
rule: B,
|
|
780
|
+
status: l
|
|
781
|
+
});
|
|
782
|
+
})
|
|
783
|
+
), this.registerEventHandler(
|
|
784
|
+
this.Event.BeforeSheetDataValidationAdd,
|
|
785
|
+
() => i.beforeCommandExecuted((r) => {
|
|
786
|
+
if (r.id === T.id) {
|
|
787
|
+
const a = r.params, o = this.getSheetTarget(a.unitId, a.subUnitId);
|
|
788
|
+
if (!o)
|
|
782
789
|
return;
|
|
783
|
-
const { workbook:
|
|
784
|
-
worksheet:
|
|
785
|
-
workbook:
|
|
786
|
-
rule:
|
|
790
|
+
const { workbook: u, worksheet: l } = o, s = {
|
|
791
|
+
worksheet: l,
|
|
792
|
+
workbook: u,
|
|
793
|
+
rule: a.rule
|
|
787
794
|
};
|
|
788
795
|
if (this.fireEvent(this.Event.BeforeSheetDataValidationAdd, s), s.cancel)
|
|
789
|
-
throw new
|
|
790
|
-
break;
|
|
796
|
+
throw new f();
|
|
791
797
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
798
|
+
})
|
|
799
|
+
), this.registerEventHandler(
|
|
800
|
+
this.Event.BeforeSheetDataValidationCriteriaUpdate,
|
|
801
|
+
() => i.beforeCommandExecuted((r) => {
|
|
802
|
+
if (r.id === b.id) {
|
|
803
|
+
const a = r.params, o = this.getSheetTarget(a.unitId, a.subUnitId);
|
|
804
|
+
if (!o)
|
|
795
805
|
return;
|
|
796
|
-
const { workbook:
|
|
806
|
+
const { workbook: u, worksheet: l } = o, s = l.getDataValidation(a.ruleId);
|
|
797
807
|
if (!s)
|
|
798
808
|
return;
|
|
799
|
-
const
|
|
800
|
-
worksheet:
|
|
801
|
-
workbook:
|
|
809
|
+
const d = {
|
|
810
|
+
worksheet: l,
|
|
811
|
+
workbook: u,
|
|
802
812
|
rule: s,
|
|
803
|
-
ruleId:
|
|
804
|
-
newCriteria:
|
|
813
|
+
ruleId: a.ruleId,
|
|
814
|
+
newCriteria: a.setting
|
|
805
815
|
};
|
|
806
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationCriteriaUpdate,
|
|
807
|
-
throw new
|
|
808
|
-
break;
|
|
816
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationCriteriaUpdate, d), d.cancel)
|
|
817
|
+
throw new f();
|
|
809
818
|
}
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
819
|
+
})
|
|
820
|
+
), this.registerEventHandler(
|
|
821
|
+
this.Event.BeforeSheetDataValidationRangeUpdate,
|
|
822
|
+
() => i.beforeCommandExecuted((r) => {
|
|
823
|
+
if (r.id === C.id) {
|
|
824
|
+
const a = r.params, o = this.getSheetTarget(a.unitId, a.subUnitId);
|
|
825
|
+
if (!o)
|
|
813
826
|
return;
|
|
814
|
-
const { workbook:
|
|
827
|
+
const { workbook: u, worksheet: l } = o, s = l.getDataValidation(a.ruleId);
|
|
815
828
|
if (!s)
|
|
816
829
|
return;
|
|
817
|
-
const
|
|
818
|
-
worksheet:
|
|
819
|
-
workbook:
|
|
830
|
+
const d = {
|
|
831
|
+
worksheet: l,
|
|
832
|
+
workbook: u,
|
|
820
833
|
rule: s,
|
|
821
|
-
ruleId:
|
|
822
|
-
newRanges:
|
|
834
|
+
ruleId: a.ruleId,
|
|
835
|
+
newRanges: a.ranges
|
|
823
836
|
};
|
|
824
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationRangeUpdate,
|
|
825
|
-
throw new
|
|
826
|
-
break;
|
|
837
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationRangeUpdate, d), d.cancel)
|
|
838
|
+
throw new f();
|
|
827
839
|
}
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
840
|
+
})
|
|
841
|
+
), this.registerEventHandler(
|
|
842
|
+
this.Event.BeforeSheetDataValidationOptionsUpdate,
|
|
843
|
+
() => i.beforeCommandExecuted((r) => {
|
|
844
|
+
if (r.id === U.id) {
|
|
845
|
+
const a = r.params, o = this.getSheetTarget(a.unitId, a.subUnitId);
|
|
846
|
+
if (!o)
|
|
831
847
|
return;
|
|
832
|
-
const { workbook:
|
|
848
|
+
const { workbook: u, worksheet: l } = o, s = l.getDataValidation(a.ruleId);
|
|
833
849
|
if (!s)
|
|
834
850
|
return;
|
|
835
|
-
const
|
|
836
|
-
worksheet:
|
|
837
|
-
workbook:
|
|
851
|
+
const d = {
|
|
852
|
+
worksheet: l,
|
|
853
|
+
workbook: u,
|
|
838
854
|
rule: s,
|
|
839
|
-
ruleId:
|
|
840
|
-
newOptions:
|
|
855
|
+
ruleId: a.ruleId,
|
|
856
|
+
newOptions: a.options
|
|
841
857
|
};
|
|
842
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationOptionsUpdate,
|
|
843
|
-
throw new
|
|
844
|
-
break;
|
|
858
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationOptionsUpdate, d), d.cancel)
|
|
859
|
+
throw new f();
|
|
845
860
|
}
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
861
|
+
})
|
|
862
|
+
), this.registerEventHandler(
|
|
863
|
+
this.Event.BeforeSheetDataValidationDelete,
|
|
864
|
+
() => i.beforeCommandExecuted((r) => {
|
|
865
|
+
if (r.id === A.id) {
|
|
866
|
+
const a = r.params, o = this.getSheetTarget(a.unitId, a.subUnitId);
|
|
867
|
+
if (!o)
|
|
849
868
|
return;
|
|
850
|
-
const { workbook:
|
|
869
|
+
const { workbook: u, worksheet: l } = o, s = l.getDataValidation(a.ruleId);
|
|
851
870
|
if (!s)
|
|
852
871
|
return;
|
|
853
|
-
const
|
|
854
|
-
worksheet:
|
|
855
|
-
workbook:
|
|
872
|
+
const d = {
|
|
873
|
+
worksheet: l,
|
|
874
|
+
workbook: u,
|
|
856
875
|
rule: s,
|
|
857
|
-
ruleId:
|
|
876
|
+
ruleId: a.ruleId
|
|
858
877
|
};
|
|
859
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationDelete,
|
|
860
|
-
throw new
|
|
861
|
-
break;
|
|
878
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationDelete, d), d.cancel)
|
|
879
|
+
throw new f();
|
|
862
880
|
}
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
881
|
+
})
|
|
882
|
+
), this.registerEventHandler(
|
|
883
|
+
this.Event.BeforeSheetDataValidationDeleteAll,
|
|
884
|
+
() => i.beforeCommandExecuted((r) => {
|
|
885
|
+
if (r.id === O.id) {
|
|
886
|
+
const a = r.params, o = this.getSheetTarget(a.unitId, a.subUnitId);
|
|
887
|
+
if (!o)
|
|
866
888
|
return;
|
|
867
|
-
const { workbook:
|
|
868
|
-
worksheet:
|
|
869
|
-
workbook:
|
|
870
|
-
rules:
|
|
889
|
+
const { workbook: u, worksheet: l } = o, s = {
|
|
890
|
+
worksheet: l,
|
|
891
|
+
workbook: u,
|
|
892
|
+
rules: l.getDataValidations()
|
|
871
893
|
};
|
|
872
894
|
if (this.fireEvent(this.Event.BeforeSheetDataValidationDeleteAll, s), s.cancel)
|
|
873
|
-
throw new
|
|
874
|
-
break;
|
|
895
|
+
throw new f();
|
|
875
896
|
}
|
|
876
|
-
}
|
|
877
|
-
|
|
897
|
+
})
|
|
898
|
+
);
|
|
878
899
|
}
|
|
879
900
|
}
|
|
880
|
-
|
|
881
|
-
class z extends
|
|
901
|
+
M.extend(Q);
|
|
902
|
+
class z extends x {
|
|
882
903
|
_initialize() {
|
|
883
904
|
Object.defineProperty(this, "_dataValidationModel", {
|
|
884
905
|
get() {
|
|
885
|
-
return this._injector.get(
|
|
906
|
+
return this._injector.get(w);
|
|
886
907
|
}
|
|
887
908
|
});
|
|
888
909
|
}
|
|
@@ -891,82 +912,82 @@ class z extends M {
|
|
|
891
912
|
}
|
|
892
913
|
// region DataValidationHooks
|
|
893
914
|
onDataValidationChange(e) {
|
|
894
|
-
return
|
|
915
|
+
return c(this._dataValidationModel.ruleChange$.pipe(R((t) => t.unitId === this._workbook.getUnitId())).subscribe(e));
|
|
895
916
|
}
|
|
896
917
|
onDataValidationStatusChange(e) {
|
|
897
|
-
return
|
|
918
|
+
return c(this._dataValidationModel.validStatusChange$.pipe(R((t) => t.unitId === this._workbook.getUnitId())).subscribe(e));
|
|
898
919
|
}
|
|
899
920
|
onBeforeAddDataValidation(e) {
|
|
900
|
-
return
|
|
901
|
-
const
|
|
902
|
-
if (t.id ===
|
|
903
|
-
if (
|
|
921
|
+
return c(this._commandService.beforeCommandExecuted((t, i) => {
|
|
922
|
+
const r = t.params;
|
|
923
|
+
if (t.id === T.id) {
|
|
924
|
+
if (r.unitId !== this._workbook.getUnitId())
|
|
904
925
|
return;
|
|
905
|
-
if (e(
|
|
926
|
+
if (e(r, i) === !1)
|
|
906
927
|
throw new Error("Command is stopped by the hook onBeforeAddDataValidation");
|
|
907
928
|
}
|
|
908
929
|
}));
|
|
909
930
|
}
|
|
910
931
|
onBeforeUpdateDataValidationCriteria(e) {
|
|
911
|
-
return
|
|
912
|
-
const
|
|
913
|
-
if (t.id ===
|
|
914
|
-
if (
|
|
932
|
+
return c(this._commandService.beforeCommandExecuted((t, i) => {
|
|
933
|
+
const r = t.params;
|
|
934
|
+
if (t.id === b.id) {
|
|
935
|
+
if (r.unitId !== this._workbook.getUnitId())
|
|
915
936
|
return;
|
|
916
|
-
if (e(
|
|
937
|
+
if (e(r, i) === !1)
|
|
917
938
|
throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationCriteria");
|
|
918
939
|
}
|
|
919
940
|
}));
|
|
920
941
|
}
|
|
921
942
|
onBeforeUpdateDataValidationRange(e) {
|
|
922
|
-
return
|
|
923
|
-
const
|
|
943
|
+
return c(this._commandService.beforeCommandExecuted((t, i) => {
|
|
944
|
+
const r = t.params;
|
|
924
945
|
if (t.id === C.id) {
|
|
925
|
-
if (
|
|
946
|
+
if (r.unitId !== this._workbook.getUnitId())
|
|
926
947
|
return;
|
|
927
|
-
if (e(
|
|
948
|
+
if (e(r, i) === !1)
|
|
928
949
|
throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationRange");
|
|
929
950
|
}
|
|
930
951
|
}));
|
|
931
952
|
}
|
|
932
953
|
onBeforeUpdateDataValidationOptions(e) {
|
|
933
|
-
return
|
|
934
|
-
const
|
|
935
|
-
if (t.id ===
|
|
936
|
-
if (
|
|
954
|
+
return c(this._commandService.beforeCommandExecuted((t, i) => {
|
|
955
|
+
const r = t.params;
|
|
956
|
+
if (t.id === U.id) {
|
|
957
|
+
if (r.unitId !== this._workbook.getUnitId())
|
|
937
958
|
return;
|
|
938
|
-
if (e(
|
|
959
|
+
if (e(r, i) === !1)
|
|
939
960
|
throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationOptions");
|
|
940
961
|
}
|
|
941
962
|
}));
|
|
942
963
|
}
|
|
943
964
|
onBeforeDeleteDataValidation(e) {
|
|
944
|
-
return
|
|
945
|
-
const
|
|
946
|
-
if (t.id ===
|
|
947
|
-
if (
|
|
965
|
+
return c(this._commandService.beforeCommandExecuted((t, i) => {
|
|
966
|
+
const r = t.params;
|
|
967
|
+
if (t.id === A.id) {
|
|
968
|
+
if (r.unitId !== this._workbook.getUnitId())
|
|
948
969
|
return;
|
|
949
|
-
if (e(
|
|
970
|
+
if (e(r, i) === !1)
|
|
950
971
|
throw new Error("Command is stopped by the hook onBeforeDeleteDataValidation");
|
|
951
972
|
}
|
|
952
973
|
}));
|
|
953
974
|
}
|
|
954
975
|
onBeforeDeleteAllDataValidation(e) {
|
|
955
|
-
return
|
|
956
|
-
const
|
|
976
|
+
return c(this._commandService.beforeCommandExecuted((t, i) => {
|
|
977
|
+
const r = t.params;
|
|
957
978
|
if (t.id === O.id) {
|
|
958
|
-
if (
|
|
979
|
+
if (r.unitId !== this._workbook.getUnitId())
|
|
959
980
|
return;
|
|
960
|
-
if (e(
|
|
981
|
+
if (e(r, i) === !1)
|
|
961
982
|
throw new Error("Command is stopped by the hook onBeforeDeleteAllDataValidation");
|
|
962
983
|
}
|
|
963
984
|
}));
|
|
964
985
|
}
|
|
965
986
|
}
|
|
966
|
-
|
|
987
|
+
x.extend(z);
|
|
967
988
|
class K extends N {
|
|
968
989
|
getDataValidations() {
|
|
969
|
-
return this._injector.get(
|
|
990
|
+
return this._injector.get(v).getRules(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((t) => new _(t, this._worksheet, this._injector));
|
|
970
991
|
}
|
|
971
992
|
getValidatorStatus() {
|
|
972
993
|
return this._injector.get(S).validatorWorksheet(
|
|
@@ -978,8 +999,8 @@ class K extends N {
|
|
|
978
999
|
return this.getValidatorStatus();
|
|
979
1000
|
}
|
|
980
1001
|
getDataValidation(e) {
|
|
981
|
-
const
|
|
982
|
-
return
|
|
1002
|
+
const i = this._injector.get(v).getRuleById(this._workbook.getUnitId(), this._worksheet.getSheetId(), e);
|
|
1003
|
+
return i ? new _(i, this._worksheet, this._injector) : null;
|
|
983
1004
|
}
|
|
984
1005
|
}
|
|
985
1006
|
N.extend(K);
|
|
@@ -1011,6 +1032,6 @@ class X {
|
|
|
1011
1032
|
}
|
|
1012
1033
|
$.extend(X);
|
|
1013
1034
|
export {
|
|
1014
|
-
|
|
1015
|
-
|
|
1035
|
+
_ as FDataValidation,
|
|
1036
|
+
E as FDataValidationBuilder
|
|
1016
1037
|
};
|