@univerjs/sheets-data-validation 0.6.0-experimental.20250125-1d060b9 → 0.6.0-experimental.20250220-d9a8e74
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 +198 -176
- 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/f-event.d.ts +3 -2
- package/lib/types/facade/f-univer.d.ts +3 -2
- 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 +10 -10
package/lib/es/facade.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
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
|
|
8
|
-
import { serializeRangeToRefString 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 _ = (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 o, DataValidationErrorStyle as k, DataValidationOperator as h, IUniverInstanceService as W, ICommandService as p, CanceledError as f, toDisposable as c } from "@univerjs/core";
|
|
7
|
+
import { DataValidationModel as v, getRuleOptions as $ } from "@univerjs/data-validation";
|
|
8
|
+
import { serializeRangeToRefString as F } from "@univerjs/engine-formula";
|
|
9
|
+
import { FUniver as M, FEventName as P } from "@univerjs/core/facade";
|
|
9
10
|
import { filter as R } from "rxjs";
|
|
10
|
-
class
|
|
11
|
+
class E {
|
|
11
12
|
constructor(e) {
|
|
12
|
-
|
|
13
|
+
_(this, "_rule");
|
|
13
14
|
this._rule = e != null ? e : {
|
|
14
|
-
uid:
|
|
15
|
+
uid: L(),
|
|
15
16
|
ranges: void 0,
|
|
16
17
|
type: o.CUSTOM
|
|
17
18
|
};
|
|
@@ -38,9 +39,9 @@ class D {
|
|
|
38
39
|
* ```
|
|
39
40
|
*/
|
|
40
41
|
copy() {
|
|
41
|
-
return new
|
|
42
|
+
return new E({
|
|
42
43
|
...this._rule,
|
|
43
|
-
uid:
|
|
44
|
+
uid: L()
|
|
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 !== k.STOP;
|
|
57
58
|
}
|
|
58
59
|
/**
|
|
59
60
|
* Gets the data validation type of the rule
|
|
@@ -227,8 +228,8 @@ class D {
|
|
|
227
228
|
* const rule = builder.requireNumberBetween(1, 10).build();
|
|
228
229
|
* ```
|
|
229
230
|
*/
|
|
230
|
-
requireNumberBetween(e, t,
|
|
231
|
-
return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = h.BETWEEN, this._rule.type =
|
|
231
|
+
requireNumberBetween(e, t, i) {
|
|
232
|
+
return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = h.BETWEEN, this._rule.type = i ? o.WHOLE : o.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
|
|
@@ -314,8 +315,8 @@ class D {
|
|
|
314
315
|
* const rule = builder.requireNumberNotBetween(1, 10).build();
|
|
315
316
|
* ```
|
|
316
317
|
*/
|
|
317
|
-
requireNumberNotBetween(e, t,
|
|
318
|
-
return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = h.NOT_BETWEEN, this._rule.type =
|
|
318
|
+
requireNumberNotBetween(e, t, i) {
|
|
319
|
+
return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = h.NOT_BETWEEN, this._rule.type = i ? o.WHOLE : o.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
|
|
@@ -345,8 +346,8 @@ class D {
|
|
|
345
346
|
* const rule = builder.requireValueInList(['Yes', 'No']).build();
|
|
346
347
|
* ```
|
|
347
348
|
*/
|
|
348
|
-
requireValueInList(e, t,
|
|
349
|
-
return this._rule.type = t ? o.LIST_MULTIPLE : o.LIST, this._rule.formula1 = e.join(","), this._rule.formula2 = void 0, this._rule.showDropDown =
|
|
349
|
+
requireValueInList(e, t, i) {
|
|
350
|
+
return this._rule.type = t ? o.LIST_MULTIPLE : o.LIST, this._rule.formula1 = e.join(","), this._rule.formula2 = void 0, this._rule.showDropDown = i != null ? i : !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(e, t,
|
|
366
|
-
return this._rule.type = t ? o.LIST_MULTIPLE : o.LIST, this._rule.formula1 = `=${
|
|
366
|
+
requireValueInRange(e, t, i) {
|
|
367
|
+
return this._rule.type = t ? o.LIST_MULTIPLE : o.LIST, this._rule.formula1 = `=${F({
|
|
367
368
|
unitId: e.getUnitId(),
|
|
368
369
|
sheetName: e.getSheetName(),
|
|
369
370
|
range: e.getRange()
|
|
370
|
-
})}`, this._rule.formula2 = void 0, this._rule.showDropDown =
|
|
371
|
+
})}`, this._rule.formula2 = void 0, this._rule.showDropDown = i != null ? i : !0, this;
|
|
371
372
|
}
|
|
372
373
|
/**
|
|
373
374
|
* Sets whether to allow invalid data and configures the error style
|
|
@@ -382,7 +383,7 @@ class D {
|
|
|
382
383
|
* ```
|
|
383
384
|
*/
|
|
384
385
|
setAllowInvalid(e) {
|
|
385
|
-
return this._rule.errorStyle = e ?
|
|
386
|
+
return this._rule.errorStyle = e ? k.WARNING : k.STOP, this;
|
|
386
387
|
}
|
|
387
388
|
/**
|
|
388
389
|
* Sets whether to allow blank values
|
|
@@ -416,11 +417,11 @@ class D {
|
|
|
416
417
|
}
|
|
417
418
|
}
|
|
418
419
|
class m {
|
|
419
|
-
constructor(e, t,
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
this._injector =
|
|
420
|
+
constructor(e, t, i) {
|
|
421
|
+
_(this, "rule");
|
|
422
|
+
_(this, "_worksheet");
|
|
423
|
+
_(this, "_injector");
|
|
424
|
+
this._injector = i, this.rule = e, this._worksheet = t;
|
|
424
425
|
}
|
|
425
426
|
/**
|
|
426
427
|
* Gets whether invalid data is allowed based on the error style value
|
|
@@ -436,7 +437,7 @@ class m {
|
|
|
436
437
|
* ```
|
|
437
438
|
*/
|
|
438
439
|
getAllowInvalid() {
|
|
439
|
-
return this.rule.errorStyle !==
|
|
440
|
+
return this.rule.errorStyle !== k.STOP;
|
|
440
441
|
}
|
|
441
442
|
/**
|
|
442
443
|
* Gets the data validation type of the rule
|
|
@@ -501,7 +502,7 @@ class m {
|
|
|
501
502
|
* ```
|
|
502
503
|
*/
|
|
503
504
|
copy() {
|
|
504
|
-
return new
|
|
505
|
+
return new E(this.rule);
|
|
505
506
|
}
|
|
506
507
|
/**
|
|
507
508
|
* Gets whether the data validation rule is applied to the worksheet
|
|
@@ -519,7 +520,7 @@ class m {
|
|
|
519
520
|
getApplied() {
|
|
520
521
|
if (!this._worksheet)
|
|
521
522
|
return !1;
|
|
522
|
-
const t = this._injector.get(
|
|
523
|
+
const t = this._injector.get(v).getRuleById(this._worksheet.getUnitId(), this._worksheet.getSheetId(), this.rule.uid);
|
|
523
524
|
return !!(t && t.ranges.length);
|
|
524
525
|
}
|
|
525
526
|
/**
|
|
@@ -538,7 +539,7 @@ class m {
|
|
|
538
539
|
getRanges() {
|
|
539
540
|
if (!this.getApplied())
|
|
540
541
|
return [];
|
|
541
|
-
const e = this._injector.get(
|
|
542
|
+
const e = this._injector.get(W).getUnit(this._worksheet.getUnitId());
|
|
542
543
|
return this.rule.ranges.map((t) => this._injector.createInstance(y, e, this._worksheet, t));
|
|
543
544
|
}
|
|
544
545
|
/**
|
|
@@ -595,8 +596,8 @@ class m {
|
|
|
595
596
|
* );
|
|
596
597
|
* ```
|
|
597
598
|
*/
|
|
598
|
-
setCriteria(e, t,
|
|
599
|
-
if (this.getApplied() && !this._injector.get(p).syncExecuteCommand(
|
|
599
|
+
setCriteria(e, t, i = !0) {
|
|
600
|
+
if (this.getApplied() && !this._injector.get(p).syncExecuteCommand(b.id, {
|
|
600
601
|
unitId: this.getUnitId(),
|
|
601
602
|
subUnitId: this.getSheetId(),
|
|
602
603
|
ruleId: this.rule.uid,
|
|
@@ -605,11 +606,11 @@ class m {
|
|
|
605
606
|
formula1: t[1],
|
|
606
607
|
formula2: t[2],
|
|
607
608
|
type: this.rule.type,
|
|
608
|
-
allowBlank:
|
|
609
|
+
allowBlank: i
|
|
609
610
|
}
|
|
610
611
|
}))
|
|
611
612
|
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 =
|
|
613
|
+
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
614
|
}
|
|
614
615
|
/**
|
|
615
616
|
* Set the options for the data validation rule
|
|
@@ -630,12 +631,12 @@ class m {
|
|
|
630
631
|
* ```
|
|
631
632
|
*/
|
|
632
633
|
setOptions(e) {
|
|
633
|
-
if (this.getApplied() && !this._injector.get(p).syncExecuteCommand(
|
|
634
|
+
if (this.getApplied() && !this._injector.get(p).syncExecuteCommand(U.id, {
|
|
634
635
|
unitId: this.getUnitId(),
|
|
635
636
|
subUnitId: this.getSheetId(),
|
|
636
637
|
ruleId: this.rule.uid,
|
|
637
638
|
options: {
|
|
638
|
-
|
|
639
|
+
...$(this.rule),
|
|
639
640
|
...e
|
|
640
641
|
}
|
|
641
642
|
}))
|
|
@@ -662,7 +663,7 @@ class m {
|
|
|
662
663
|
unitId: this.getUnitId(),
|
|
663
664
|
subUnitId: this.getSheetId(),
|
|
664
665
|
ruleId: this.rule.uid,
|
|
665
|
-
ranges: e.map((
|
|
666
|
+
ranges: e.map((r) => r.getRange())
|
|
666
667
|
}))
|
|
667
668
|
throw new Error("setRanges failed");
|
|
668
669
|
return this.rule.ranges = e.map((t) => t.getRange()), this;
|
|
@@ -681,7 +682,7 @@ class m {
|
|
|
681
682
|
* ```
|
|
682
683
|
*/
|
|
683
684
|
delete() {
|
|
684
|
-
return this.getApplied() ? this._injector.get(p).syncExecuteCommand(
|
|
685
|
+
return this.getApplied() ? this._injector.get(p).syncExecuteCommand(A.id, {
|
|
685
686
|
unitId: this.getUnitId(),
|
|
686
687
|
subUnitId: this.getSheetId(),
|
|
687
688
|
ruleId: this.rule.uid
|
|
@@ -691,7 +692,7 @@ class m {
|
|
|
691
692
|
class G extends y {
|
|
692
693
|
setDataValidation(e) {
|
|
693
694
|
if (!e)
|
|
694
|
-
return this._commandService.syncExecuteCommand(
|
|
695
|
+
return this._commandService.syncExecuteCommand(q.id, {
|
|
695
696
|
unitId: this._workbook.getUnitId(),
|
|
696
697
|
subUnitId: this._worksheet.getSheetId(),
|
|
697
698
|
ranges: [this._range]
|
|
@@ -704,7 +705,7 @@ class G extends y {
|
|
|
704
705
|
ranges: [this._range]
|
|
705
706
|
}
|
|
706
707
|
};
|
|
707
|
-
return this._commandService.syncExecuteCommand(
|
|
708
|
+
return this._commandService.syncExecuteCommand(T.id, t), this;
|
|
708
709
|
}
|
|
709
710
|
getDataValidation() {
|
|
710
711
|
const t = this._injector.get(S).getDataValidation(
|
|
@@ -730,159 +731,180 @@ class G extends y {
|
|
|
730
731
|
}
|
|
731
732
|
}
|
|
732
733
|
y.extend(G);
|
|
733
|
-
class Q extends
|
|
734
|
+
class Q extends M {
|
|
734
735
|
/**
|
|
735
736
|
* @deprecated use `univerAPI.newDataValidation()` as instead.
|
|
736
737
|
* @returns {FDataValidationBuilder} A new instance of the FDataValidationBuilder class
|
|
737
738
|
*/
|
|
738
739
|
static newDataValidation() {
|
|
739
|
-
return new
|
|
740
|
+
return new E();
|
|
740
741
|
}
|
|
741
742
|
newDataValidation() {
|
|
742
|
-
return new
|
|
743
|
+
return new E();
|
|
743
744
|
}
|
|
744
745
|
/**
|
|
745
746
|
* @ignore
|
|
746
747
|
*/
|
|
747
748
|
// eslint-disable-next-line max-lines-per-function
|
|
748
749
|
_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
|
-
|
|
750
|
+
if (!e.has(w)) return;
|
|
751
|
+
const t = e.get(w), i = e.get(p);
|
|
752
|
+
this.registerEventHandler(
|
|
753
|
+
this.Event.SheetDataValidationChanged,
|
|
754
|
+
() => t.ruleChange$.subscribe((r) => {
|
|
755
|
+
const { unitId: a, subUnitId: n, rule: u, oldRule: l, type: s } = r, d = this.getSheetTarget(a, n);
|
|
756
|
+
if (!d)
|
|
757
|
+
return;
|
|
758
|
+
const { workbook: D, worksheet: I } = d, V = new m(u, I.getSheet(), this._injector);
|
|
759
|
+
this.fireEvent(this.Event.SheetDataValidationChanged, {
|
|
760
|
+
origin: r,
|
|
761
|
+
worksheet: I,
|
|
762
|
+
workbook: D,
|
|
763
|
+
changeType: s,
|
|
764
|
+
oldRule: l,
|
|
765
|
+
rule: V
|
|
766
|
+
});
|
|
767
|
+
})
|
|
768
|
+
), this.registerEventHandler(
|
|
769
|
+
this.Event.SheetDataValidatorStatusChanged,
|
|
770
|
+
() => t.validStatusChange$.subscribe((r) => {
|
|
771
|
+
const { unitId: a, subUnitId: n, ruleId: u, status: l, row: s, col: d } = r, D = this.getSheetTarget(a, n);
|
|
772
|
+
if (!D)
|
|
773
|
+
return;
|
|
774
|
+
const { workbook: I, worksheet: V } = D, B = V.getDataValidation(u);
|
|
775
|
+
B && this.fireEvent(this.Event.SheetDataValidatorStatusChanged, {
|
|
776
|
+
workbook: I,
|
|
777
|
+
worksheet: V,
|
|
778
|
+
row: s,
|
|
779
|
+
column: d,
|
|
780
|
+
rule: B,
|
|
781
|
+
status: l
|
|
782
|
+
});
|
|
783
|
+
})
|
|
784
|
+
), this.registerEventHandler(
|
|
785
|
+
this.Event.BeforeSheetDataValidationAdd,
|
|
786
|
+
() => i.beforeCommandExecuted((r) => {
|
|
787
|
+
if (r.id === T.id) {
|
|
788
|
+
const a = r.params, n = this.getSheetTarget(a.unitId, a.subUnitId);
|
|
781
789
|
if (!n)
|
|
782
790
|
return;
|
|
783
|
-
const { workbook:
|
|
784
|
-
worksheet:
|
|
785
|
-
workbook:
|
|
786
|
-
rule:
|
|
791
|
+
const { workbook: u, worksheet: l } = n, s = {
|
|
792
|
+
worksheet: l,
|
|
793
|
+
workbook: u,
|
|
794
|
+
rule: a.rule
|
|
787
795
|
};
|
|
788
796
|
if (this.fireEvent(this.Event.BeforeSheetDataValidationAdd, s), s.cancel)
|
|
789
|
-
throw new
|
|
790
|
-
break;
|
|
797
|
+
throw new f();
|
|
791
798
|
}
|
|
792
|
-
|
|
793
|
-
|
|
799
|
+
})
|
|
800
|
+
), this.registerEventHandler(
|
|
801
|
+
this.Event.BeforeSheetDataValidationCriteriaUpdate,
|
|
802
|
+
() => i.beforeCommandExecuted((r) => {
|
|
803
|
+
if (r.id === b.id) {
|
|
804
|
+
const a = r.params, n = this.getSheetTarget(a.unitId, a.subUnitId);
|
|
794
805
|
if (!n)
|
|
795
806
|
return;
|
|
796
|
-
const { workbook:
|
|
807
|
+
const { workbook: u, worksheet: l } = n, s = l.getDataValidation(a.ruleId);
|
|
797
808
|
if (!s)
|
|
798
809
|
return;
|
|
799
|
-
const
|
|
800
|
-
worksheet:
|
|
801
|
-
workbook:
|
|
810
|
+
const d = {
|
|
811
|
+
worksheet: l,
|
|
812
|
+
workbook: u,
|
|
802
813
|
rule: s,
|
|
803
|
-
ruleId:
|
|
804
|
-
newCriteria:
|
|
814
|
+
ruleId: a.ruleId,
|
|
815
|
+
newCriteria: a.setting
|
|
805
816
|
};
|
|
806
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationCriteriaUpdate,
|
|
807
|
-
throw new
|
|
808
|
-
break;
|
|
817
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationCriteriaUpdate, d), d.cancel)
|
|
818
|
+
throw new f();
|
|
809
819
|
}
|
|
810
|
-
|
|
811
|
-
|
|
820
|
+
})
|
|
821
|
+
), this.registerEventHandler(
|
|
822
|
+
this.Event.BeforeSheetDataValidationRangeUpdate,
|
|
823
|
+
() => i.beforeCommandExecuted((r) => {
|
|
824
|
+
if (r.id === C.id) {
|
|
825
|
+
const a = r.params, n = this.getSheetTarget(a.unitId, a.subUnitId);
|
|
812
826
|
if (!n)
|
|
813
827
|
return;
|
|
814
|
-
const { workbook:
|
|
828
|
+
const { workbook: u, worksheet: l } = n, s = l.getDataValidation(a.ruleId);
|
|
815
829
|
if (!s)
|
|
816
830
|
return;
|
|
817
|
-
const
|
|
818
|
-
worksheet:
|
|
819
|
-
workbook:
|
|
831
|
+
const d = {
|
|
832
|
+
worksheet: l,
|
|
833
|
+
workbook: u,
|
|
820
834
|
rule: s,
|
|
821
|
-
ruleId:
|
|
822
|
-
newRanges:
|
|
835
|
+
ruleId: a.ruleId,
|
|
836
|
+
newRanges: a.ranges
|
|
823
837
|
};
|
|
824
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationRangeUpdate,
|
|
825
|
-
throw new
|
|
826
|
-
break;
|
|
838
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationRangeUpdate, d), d.cancel)
|
|
839
|
+
throw new f();
|
|
827
840
|
}
|
|
828
|
-
|
|
829
|
-
|
|
841
|
+
})
|
|
842
|
+
), this.registerEventHandler(
|
|
843
|
+
this.Event.BeforeSheetDataValidationOptionsUpdate,
|
|
844
|
+
() => i.beforeCommandExecuted((r) => {
|
|
845
|
+
if (r.id === U.id) {
|
|
846
|
+
const a = r.params, n = this.getSheetTarget(a.unitId, a.subUnitId);
|
|
830
847
|
if (!n)
|
|
831
848
|
return;
|
|
832
|
-
const { workbook:
|
|
849
|
+
const { workbook: u, worksheet: l } = n, s = l.getDataValidation(a.ruleId);
|
|
833
850
|
if (!s)
|
|
834
851
|
return;
|
|
835
|
-
const
|
|
836
|
-
worksheet:
|
|
837
|
-
workbook:
|
|
852
|
+
const d = {
|
|
853
|
+
worksheet: l,
|
|
854
|
+
workbook: u,
|
|
838
855
|
rule: s,
|
|
839
|
-
ruleId:
|
|
840
|
-
newOptions:
|
|
856
|
+
ruleId: a.ruleId,
|
|
857
|
+
newOptions: a.options
|
|
841
858
|
};
|
|
842
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationOptionsUpdate,
|
|
843
|
-
throw new
|
|
844
|
-
break;
|
|
859
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationOptionsUpdate, d), d.cancel)
|
|
860
|
+
throw new f();
|
|
845
861
|
}
|
|
846
|
-
|
|
847
|
-
|
|
862
|
+
})
|
|
863
|
+
), this.registerEventHandler(
|
|
864
|
+
this.Event.BeforeSheetDataValidationDelete,
|
|
865
|
+
() => i.beforeCommandExecuted((r) => {
|
|
866
|
+
if (r.id === A.id) {
|
|
867
|
+
const a = r.params, n = this.getSheetTarget(a.unitId, a.subUnitId);
|
|
848
868
|
if (!n)
|
|
849
869
|
return;
|
|
850
|
-
const { workbook:
|
|
870
|
+
const { workbook: u, worksheet: l } = n, s = l.getDataValidation(a.ruleId);
|
|
851
871
|
if (!s)
|
|
852
872
|
return;
|
|
853
|
-
const
|
|
854
|
-
worksheet:
|
|
855
|
-
workbook:
|
|
873
|
+
const d = {
|
|
874
|
+
worksheet: l,
|
|
875
|
+
workbook: u,
|
|
856
876
|
rule: s,
|
|
857
|
-
ruleId:
|
|
877
|
+
ruleId: a.ruleId
|
|
858
878
|
};
|
|
859
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationDelete,
|
|
860
|
-
throw new
|
|
861
|
-
break;
|
|
879
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationDelete, d), d.cancel)
|
|
880
|
+
throw new f();
|
|
862
881
|
}
|
|
863
|
-
|
|
864
|
-
|
|
882
|
+
})
|
|
883
|
+
), this.registerEventHandler(
|
|
884
|
+
this.Event.BeforeSheetDataValidationDeleteAll,
|
|
885
|
+
() => i.beforeCommandExecuted((r) => {
|
|
886
|
+
if (r.id === O.id) {
|
|
887
|
+
const a = r.params, n = this.getSheetTarget(a.unitId, a.subUnitId);
|
|
865
888
|
if (!n)
|
|
866
889
|
return;
|
|
867
|
-
const { workbook:
|
|
868
|
-
worksheet:
|
|
869
|
-
workbook:
|
|
870
|
-
rules:
|
|
890
|
+
const { workbook: u, worksheet: l } = n, s = {
|
|
891
|
+
worksheet: l,
|
|
892
|
+
workbook: u,
|
|
893
|
+
rules: l.getDataValidations()
|
|
871
894
|
};
|
|
872
895
|
if (this.fireEvent(this.Event.BeforeSheetDataValidationDeleteAll, s), s.cancel)
|
|
873
|
-
throw new
|
|
874
|
-
break;
|
|
896
|
+
throw new f();
|
|
875
897
|
}
|
|
876
|
-
}
|
|
877
|
-
|
|
898
|
+
})
|
|
899
|
+
);
|
|
878
900
|
}
|
|
879
901
|
}
|
|
880
|
-
|
|
881
|
-
class z extends
|
|
902
|
+
M.extend(Q);
|
|
903
|
+
class z extends x {
|
|
882
904
|
_initialize() {
|
|
883
905
|
Object.defineProperty(this, "_dataValidationModel", {
|
|
884
906
|
get() {
|
|
885
|
-
return this._injector.get(
|
|
907
|
+
return this._injector.get(w);
|
|
886
908
|
}
|
|
887
909
|
});
|
|
888
910
|
}
|
|
@@ -891,82 +913,82 @@ class z extends M {
|
|
|
891
913
|
}
|
|
892
914
|
// region DataValidationHooks
|
|
893
915
|
onDataValidationChange(e) {
|
|
894
|
-
return
|
|
916
|
+
return c(this._dataValidationModel.ruleChange$.pipe(R((t) => t.unitId === this._workbook.getUnitId())).subscribe(e));
|
|
895
917
|
}
|
|
896
918
|
onDataValidationStatusChange(e) {
|
|
897
|
-
return
|
|
919
|
+
return c(this._dataValidationModel.validStatusChange$.pipe(R((t) => t.unitId === this._workbook.getUnitId())).subscribe(e));
|
|
898
920
|
}
|
|
899
921
|
onBeforeAddDataValidation(e) {
|
|
900
|
-
return
|
|
901
|
-
const
|
|
902
|
-
if (t.id ===
|
|
903
|
-
if (
|
|
922
|
+
return c(this._commandService.beforeCommandExecuted((t, i) => {
|
|
923
|
+
const r = t.params;
|
|
924
|
+
if (t.id === T.id) {
|
|
925
|
+
if (r.unitId !== this._workbook.getUnitId())
|
|
904
926
|
return;
|
|
905
|
-
if (e(
|
|
927
|
+
if (e(r, i) === !1)
|
|
906
928
|
throw new Error("Command is stopped by the hook onBeforeAddDataValidation");
|
|
907
929
|
}
|
|
908
930
|
}));
|
|
909
931
|
}
|
|
910
932
|
onBeforeUpdateDataValidationCriteria(e) {
|
|
911
|
-
return
|
|
912
|
-
const
|
|
913
|
-
if (t.id ===
|
|
914
|
-
if (
|
|
933
|
+
return c(this._commandService.beforeCommandExecuted((t, i) => {
|
|
934
|
+
const r = t.params;
|
|
935
|
+
if (t.id === b.id) {
|
|
936
|
+
if (r.unitId !== this._workbook.getUnitId())
|
|
915
937
|
return;
|
|
916
|
-
if (e(
|
|
938
|
+
if (e(r, i) === !1)
|
|
917
939
|
throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationCriteria");
|
|
918
940
|
}
|
|
919
941
|
}));
|
|
920
942
|
}
|
|
921
943
|
onBeforeUpdateDataValidationRange(e) {
|
|
922
|
-
return
|
|
923
|
-
const
|
|
944
|
+
return c(this._commandService.beforeCommandExecuted((t, i) => {
|
|
945
|
+
const r = t.params;
|
|
924
946
|
if (t.id === C.id) {
|
|
925
|
-
if (
|
|
947
|
+
if (r.unitId !== this._workbook.getUnitId())
|
|
926
948
|
return;
|
|
927
|
-
if (e(
|
|
949
|
+
if (e(r, i) === !1)
|
|
928
950
|
throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationRange");
|
|
929
951
|
}
|
|
930
952
|
}));
|
|
931
953
|
}
|
|
932
954
|
onBeforeUpdateDataValidationOptions(e) {
|
|
933
|
-
return
|
|
934
|
-
const
|
|
935
|
-
if (t.id ===
|
|
936
|
-
if (
|
|
955
|
+
return c(this._commandService.beforeCommandExecuted((t, i) => {
|
|
956
|
+
const r = t.params;
|
|
957
|
+
if (t.id === U.id) {
|
|
958
|
+
if (r.unitId !== this._workbook.getUnitId())
|
|
937
959
|
return;
|
|
938
|
-
if (e(
|
|
960
|
+
if (e(r, i) === !1)
|
|
939
961
|
throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationOptions");
|
|
940
962
|
}
|
|
941
963
|
}));
|
|
942
964
|
}
|
|
943
965
|
onBeforeDeleteDataValidation(e) {
|
|
944
|
-
return
|
|
945
|
-
const
|
|
946
|
-
if (t.id ===
|
|
947
|
-
if (
|
|
966
|
+
return c(this._commandService.beforeCommandExecuted((t, i) => {
|
|
967
|
+
const r = t.params;
|
|
968
|
+
if (t.id === A.id) {
|
|
969
|
+
if (r.unitId !== this._workbook.getUnitId())
|
|
948
970
|
return;
|
|
949
|
-
if (e(
|
|
971
|
+
if (e(r, i) === !1)
|
|
950
972
|
throw new Error("Command is stopped by the hook onBeforeDeleteDataValidation");
|
|
951
973
|
}
|
|
952
974
|
}));
|
|
953
975
|
}
|
|
954
976
|
onBeforeDeleteAllDataValidation(e) {
|
|
955
|
-
return
|
|
956
|
-
const
|
|
977
|
+
return c(this._commandService.beforeCommandExecuted((t, i) => {
|
|
978
|
+
const r = t.params;
|
|
957
979
|
if (t.id === O.id) {
|
|
958
|
-
if (
|
|
980
|
+
if (r.unitId !== this._workbook.getUnitId())
|
|
959
981
|
return;
|
|
960
|
-
if (e(
|
|
982
|
+
if (e(r, i) === !1)
|
|
961
983
|
throw new Error("Command is stopped by the hook onBeforeDeleteAllDataValidation");
|
|
962
984
|
}
|
|
963
985
|
}));
|
|
964
986
|
}
|
|
965
987
|
}
|
|
966
|
-
|
|
988
|
+
x.extend(z);
|
|
967
989
|
class K extends N {
|
|
968
990
|
getDataValidations() {
|
|
969
|
-
return this._injector.get(
|
|
991
|
+
return this._injector.get(v).getRules(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((t) => new m(t, this._worksheet, this._injector));
|
|
970
992
|
}
|
|
971
993
|
getValidatorStatus() {
|
|
972
994
|
return this._injector.get(S).validatorWorksheet(
|
|
@@ -978,8 +1000,8 @@ class K extends N {
|
|
|
978
1000
|
return this.getValidatorStatus();
|
|
979
1001
|
}
|
|
980
1002
|
getDataValidation(e) {
|
|
981
|
-
const
|
|
982
|
-
return
|
|
1003
|
+
const i = this._injector.get(v).getRuleById(this._workbook.getUnitId(), this._worksheet.getSheetId(), e);
|
|
1004
|
+
return i ? new m(i, this._worksheet, this._injector) : null;
|
|
983
1005
|
}
|
|
984
1006
|
}
|
|
985
1007
|
N.extend(K);
|
|
@@ -1009,8 +1031,8 @@ class X {
|
|
|
1009
1031
|
return "BeforeSheetDataValidationOptionsUpdate";
|
|
1010
1032
|
}
|
|
1011
1033
|
}
|
|
1012
|
-
|
|
1034
|
+
P.extend(X);
|
|
1013
1035
|
export {
|
|
1014
1036
|
m as FDataValidation,
|
|
1015
|
-
|
|
1037
|
+
E as FDataValidationBuilder
|
|
1016
1038
|
};
|
package/lib/es/index.js
CHANGED
|
@@ -2347,13 +2347,13 @@ let we = class extends wt {
|
|
|
2347
2347
|
Va
|
|
2348
2348
|
].forEach((s) => {
|
|
2349
2349
|
this._commandService.registerCommand(s);
|
|
2350
|
-
}), this._injector.get(q), this._injector.get(Oe), this._injector.get(Ee), this._injector.get(Fe);
|
|
2350
|
+
}), this._injector.get(q), this._injector.get(Oe), this._injector.get(Ce), this._injector.get(Ee), this._injector.get(Fe);
|
|
2351
2351
|
}
|
|
2352
2352
|
onReady() {
|
|
2353
2353
|
this._injector.get(Ne);
|
|
2354
2354
|
}
|
|
2355
2355
|
onRendered() {
|
|
2356
|
-
this._injector.get(
|
|
2356
|
+
this._injector.get(Te);
|
|
2357
2357
|
}
|
|
2358
2358
|
};
|
|
2359
2359
|
pt(we, "pluginName", Yt);
|