@univerjs/sheets-data-validation 0.5.3-nightly.202501070959 → 0.5.3-nightly.202501081606
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 +59 -59
- package/lib/es/index.js +632 -632
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +7 -7
package/lib/es/facade.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var j = Object.defineProperty;
|
|
2
2
|
var q = (c, e, t) => e in c ? j(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t;
|
|
3
3
|
var f = (c, e, t) => q(c, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { UpdateSheetDataValidationSettingCommand as
|
|
4
|
+
import { UpdateSheetDataValidationSettingCommand as U, UpdateSheetDataValidationOptionsCommand as v, UpdateSheetDataValidationRangeCommand as C, RemoveSheetDataValidationCommand as T, ClearRangeDataValidationCommand as W, AddSheetDataValidationCommand as A, SheetsDataValidationValidatorService as S, SheetDataValidationModel as V, RemoveSheetAllDataValidationCommand as O } from "@univerjs/sheets-data-validation";
|
|
5
5
|
import { FRange as y, FWorkbook as M, FWorksheet as x } from "@univerjs/sheets/facade";
|
|
6
6
|
import { generateRandomId as B, DataValidationType as o, DataValidationErrorStyle as w, DataValidationOperator as d, IUniverInstanceService as H, ICommandService as p, FUniver as N, CanceledError as _, toDisposable as g, FEventName as $ } from "@univerjs/core";
|
|
7
7
|
import { DataValidationModel as b, getRuleOptions as F } from "@univerjs/data-validation";
|
|
@@ -413,7 +413,7 @@ class m {
|
|
|
413
413
|
* @returns true if the criteria is set successfully, false otherwise.
|
|
414
414
|
*/
|
|
415
415
|
setCriteria(e, t, r = !0) {
|
|
416
|
-
if (this.getApplied() && !this._injector.get(p).syncExecuteCommand(
|
|
416
|
+
if (this.getApplied() && !this._injector.get(p).syncExecuteCommand(U.id, {
|
|
417
417
|
unitId: this.getUnitId(),
|
|
418
418
|
subUnitId: this.getSheetId(),
|
|
419
419
|
ruleId: this.rule.uid,
|
|
@@ -435,7 +435,7 @@ class m {
|
|
|
435
435
|
* @returns true if the options are set successfully, false otherwise.
|
|
436
436
|
*/
|
|
437
437
|
setOptions(e) {
|
|
438
|
-
if (this.getApplied() && !this._injector.get(p).syncExecuteCommand(
|
|
438
|
+
if (this.getApplied() && !this._injector.get(p).syncExecuteCommand(v.id, {
|
|
439
439
|
unitId: this.getUnitId(),
|
|
440
440
|
subUnitId: this.getSheetId(),
|
|
441
441
|
ruleId: this.rule.uid,
|
|
@@ -532,127 +532,127 @@ class Q extends N {
|
|
|
532
532
|
if (!e.has(V)) return;
|
|
533
533
|
const t = e.get(V), r = e.get(p);
|
|
534
534
|
this.disposeWithMe(t.ruleChange$.subscribe((a) => {
|
|
535
|
-
const { unitId: i, subUnitId:
|
|
536
|
-
if (!
|
|
535
|
+
const { unitId: i, subUnitId: n, rule: h, oldRule: u, type: s } = a, l = this.getSheetTarget(i, n);
|
|
536
|
+
if (!l)
|
|
537
537
|
return;
|
|
538
|
-
const { workbook: I, worksheet: k } =
|
|
538
|
+
const { workbook: I, worksheet: k } = l, E = new m(h, k.getSheet(), this._injector);
|
|
539
539
|
this.fireEvent(this.Event.SheetDataValidationChanged, {
|
|
540
540
|
origin: a,
|
|
541
541
|
worksheet: k,
|
|
542
542
|
workbook: I,
|
|
543
|
-
changeType:
|
|
544
|
-
oldRule:
|
|
543
|
+
changeType: s,
|
|
544
|
+
oldRule: u,
|
|
545
545
|
rule: E
|
|
546
546
|
});
|
|
547
547
|
})), this.disposeWithMe(t.validStatusChange$.subscribe((a) => {
|
|
548
|
-
const { unitId: i, subUnitId:
|
|
548
|
+
const { unitId: i, subUnitId: n, ruleId: h, status: u, row: s, col: l } = a, I = this.getSheetTarget(i, n);
|
|
549
549
|
if (!I)
|
|
550
550
|
return;
|
|
551
551
|
const { workbook: k, worksheet: E } = I, L = E.getDataValidation(h);
|
|
552
552
|
L && this.fireEvent(this.Event.SheetDataValidatorStatusChanged, {
|
|
553
553
|
workbook: k,
|
|
554
554
|
worksheet: E,
|
|
555
|
-
row:
|
|
556
|
-
column:
|
|
555
|
+
row: s,
|
|
556
|
+
column: l,
|
|
557
557
|
rule: L,
|
|
558
|
-
status:
|
|
558
|
+
status: u
|
|
559
559
|
});
|
|
560
560
|
})), this.disposeWithMe(r.beforeCommandExecuted((a) => {
|
|
561
561
|
switch (a.id) {
|
|
562
562
|
case A.id: {
|
|
563
|
-
const i = a.params,
|
|
564
|
-
if (!
|
|
563
|
+
const i = a.params, n = this.getSheetTarget(i.unitId, i.subUnitId);
|
|
564
|
+
if (!n)
|
|
565
565
|
return;
|
|
566
|
-
const { workbook: h, worksheet:
|
|
567
|
-
worksheet:
|
|
566
|
+
const { workbook: h, worksheet: u } = n, s = {
|
|
567
|
+
worksheet: u,
|
|
568
568
|
workbook: h,
|
|
569
569
|
rule: i.rule
|
|
570
570
|
};
|
|
571
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationAdd,
|
|
571
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationAdd, s), s.cancel)
|
|
572
572
|
throw new _();
|
|
573
573
|
break;
|
|
574
574
|
}
|
|
575
|
-
case
|
|
576
|
-
const i = a.params,
|
|
577
|
-
if (!s)
|
|
578
|
-
return;
|
|
579
|
-
const { workbook: h, worksheet: l } = s, n = l.getDataValidation(i.ruleId);
|
|
575
|
+
case U.id: {
|
|
576
|
+
const i = a.params, n = this.getSheetTarget(i.unitId, i.subUnitId);
|
|
580
577
|
if (!n)
|
|
581
578
|
return;
|
|
582
|
-
const u =
|
|
583
|
-
|
|
579
|
+
const { workbook: h, worksheet: u } = n, s = u.getDataValidation(i.ruleId);
|
|
580
|
+
if (!s)
|
|
581
|
+
return;
|
|
582
|
+
const l = {
|
|
583
|
+
worksheet: u,
|
|
584
584
|
workbook: h,
|
|
585
|
-
rule:
|
|
585
|
+
rule: s,
|
|
586
586
|
ruleId: i.ruleId,
|
|
587
587
|
newCriteria: i.setting
|
|
588
588
|
};
|
|
589
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationCriteriaUpdate,
|
|
589
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationCriteriaUpdate, l), l.cancel)
|
|
590
590
|
throw new _();
|
|
591
591
|
break;
|
|
592
592
|
}
|
|
593
593
|
case C.id: {
|
|
594
|
-
const i = a.params,
|
|
595
|
-
if (!s)
|
|
596
|
-
return;
|
|
597
|
-
const { workbook: h, worksheet: l } = s, n = l.getDataValidation(i.ruleId);
|
|
594
|
+
const i = a.params, n = this.getSheetTarget(i.unitId, i.subUnitId);
|
|
598
595
|
if (!n)
|
|
599
596
|
return;
|
|
600
|
-
const u =
|
|
601
|
-
|
|
597
|
+
const { workbook: h, worksheet: u } = n, s = u.getDataValidation(i.ruleId);
|
|
598
|
+
if (!s)
|
|
599
|
+
return;
|
|
600
|
+
const l = {
|
|
601
|
+
worksheet: u,
|
|
602
602
|
workbook: h,
|
|
603
|
-
rule:
|
|
603
|
+
rule: s,
|
|
604
604
|
ruleId: i.ruleId,
|
|
605
605
|
newRanges: i.ranges
|
|
606
606
|
};
|
|
607
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationRangeUpdate,
|
|
607
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationRangeUpdate, l), l.cancel)
|
|
608
608
|
throw new _();
|
|
609
609
|
break;
|
|
610
610
|
}
|
|
611
|
-
case
|
|
612
|
-
const i = a.params,
|
|
613
|
-
if (!s)
|
|
614
|
-
return;
|
|
615
|
-
const { workbook: h, worksheet: l } = s, n = l.getDataValidation(i.ruleId);
|
|
611
|
+
case v.id: {
|
|
612
|
+
const i = a.params, n = this.getSheetTarget(i.unitId, i.subUnitId);
|
|
616
613
|
if (!n)
|
|
617
614
|
return;
|
|
618
|
-
const u =
|
|
619
|
-
|
|
615
|
+
const { workbook: h, worksheet: u } = n, s = u.getDataValidation(i.ruleId);
|
|
616
|
+
if (!s)
|
|
617
|
+
return;
|
|
618
|
+
const l = {
|
|
619
|
+
worksheet: u,
|
|
620
620
|
workbook: h,
|
|
621
|
-
rule:
|
|
621
|
+
rule: s,
|
|
622
622
|
ruleId: i.ruleId,
|
|
623
623
|
newOptions: i.options
|
|
624
624
|
};
|
|
625
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationOptionsUpdate,
|
|
625
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationOptionsUpdate, l), l.cancel)
|
|
626
626
|
throw new _();
|
|
627
627
|
break;
|
|
628
628
|
}
|
|
629
629
|
case T.id: {
|
|
630
|
-
const i = a.params,
|
|
631
|
-
if (!s)
|
|
632
|
-
return;
|
|
633
|
-
const { workbook: h, worksheet: l } = s, n = l.getDataValidation(i.ruleId);
|
|
630
|
+
const i = a.params, n = this.getSheetTarget(i.unitId, i.subUnitId);
|
|
634
631
|
if (!n)
|
|
635
632
|
return;
|
|
636
|
-
const u =
|
|
637
|
-
|
|
633
|
+
const { workbook: h, worksheet: u } = n, s = u.getDataValidation(i.ruleId);
|
|
634
|
+
if (!s)
|
|
635
|
+
return;
|
|
636
|
+
const l = {
|
|
637
|
+
worksheet: u,
|
|
638
638
|
workbook: h,
|
|
639
|
-
rule:
|
|
639
|
+
rule: s,
|
|
640
640
|
ruleId: i.ruleId
|
|
641
641
|
};
|
|
642
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationDelete,
|
|
642
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationDelete, l), l.cancel)
|
|
643
643
|
throw new _();
|
|
644
644
|
break;
|
|
645
645
|
}
|
|
646
646
|
case O.id: {
|
|
647
|
-
const i = a.params,
|
|
648
|
-
if (!
|
|
647
|
+
const i = a.params, n = this.getSheetTarget(i.unitId, i.subUnitId);
|
|
648
|
+
if (!n)
|
|
649
649
|
return;
|
|
650
|
-
const { workbook: h, worksheet:
|
|
651
|
-
worksheet:
|
|
650
|
+
const { workbook: h, worksheet: u } = n, s = {
|
|
651
|
+
worksheet: u,
|
|
652
652
|
workbook: h,
|
|
653
|
-
rules:
|
|
653
|
+
rules: u.getDataValidations()
|
|
654
654
|
};
|
|
655
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationDeleteAll,
|
|
655
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationDeleteAll, s), s.cancel)
|
|
656
656
|
throw new _();
|
|
657
657
|
break;
|
|
658
658
|
}
|
|
@@ -693,7 +693,7 @@ class z extends M {
|
|
|
693
693
|
onBeforeUpdateDataValidationCriteria(e) {
|
|
694
694
|
return g(this._commandService.beforeCommandExecuted((t, r) => {
|
|
695
695
|
const a = t.params;
|
|
696
|
-
if (t.id ===
|
|
696
|
+
if (t.id === U.id) {
|
|
697
697
|
if (a.unitId !== this._workbook.getUnitId())
|
|
698
698
|
return;
|
|
699
699
|
if (e(a, r) === !1)
|
|
@@ -715,7 +715,7 @@ class z extends M {
|
|
|
715
715
|
onBeforeUpdateDataValidationOptions(e) {
|
|
716
716
|
return g(this._commandService.beforeCommandExecuted((t, r) => {
|
|
717
717
|
const a = t.params;
|
|
718
|
-
if (t.id ===
|
|
718
|
+
if (t.id === v.id) {
|
|
719
719
|
if (a.unitId !== this._workbook.getUnitId())
|
|
720
720
|
return;
|
|
721
721
|
if (e(a, r) === !1)
|