@univerjs/sheets-data-validation 0.10.6 → 0.10.7-nightly.202509080357

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/facade.js CHANGED
@@ -1,20 +1,20 @@
1
- var H = Object.defineProperty;
2
- var q = (h, e, t) => e in h ? H(h, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[e] = t;
3
- var _ = (h, e, t) => q(h, typeof e != "symbol" ? e + "" : e, t);
4
- import { UpdateSheetDataValidationSettingCommand as b, UpdateSheetDataValidationOptionsCommand as U, UpdateSheetDataValidationRangeCommand as C, RemoveSheetDataValidationCommand as A, ClearRangeDataValidationCommand as j, AddSheetDataValidationCommand as T, SheetsDataValidationValidatorService as S, SheetDataValidationModel as f, RemoveSheetAllDataValidationCommand as O } from "@univerjs/sheets-data-validation";
5
- import { FRange as y, FWorkbook as x, FWorksheet as M } from "@univerjs/sheets/facade";
6
- import { DataValidationType as a, generateRandomId as L, DataValidationErrorStyle as k, DataValidationOperator as u, IUniverInstanceService as W, ICommandService as p, CanceledError as c, toDisposable as g } from "@univerjs/core";
7
- import { DataValidationModel as w, getRuleOptions as $ } from "@univerjs/data-validation";
8
- import { serializeRangeToRefString as F } from "@univerjs/engine-formula";
9
- import { FUniver as N, FEventName as P } from "@univerjs/core/facade";
10
- import { filter as R } from "rxjs";
11
- class E {
12
- constructor(e) {
13
- _(this, "_rule");
14
- this._rule = e != null ? e : {
15
- uid: L(),
1
+ var $ = Object.defineProperty;
2
+ var W = (f, t, e) => t in f ? $(f, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : f[t] = e;
3
+ var v = (f, t, e) => W(f, typeof t != "symbol" ? t + "" : t, e);
4
+ import { DataValidationType as n, generateRandomId as N, DataValidationErrorStyle as U, DataValidationOperator as g, IUniverInstanceService as P, ICommandService as b, DataValidationStatus as A, CanceledError as D, toDisposable as p } from "@univerjs/core";
5
+ import { UpdateSheetDataValidationSettingCommand as R, UpdateSheetDataValidationOptionsCommand as T, UpdateSheetDataValidationRangeCommand as B, RemoveSheetDataValidationCommand as L, ClearRangeDataValidationCommand as G, AddSheetDataValidationCommand as O, SheetsDataValidationValidatorService as S, SheetDataValidationModel as V, RemoveSheetAllDataValidationCommand as j } from "@univerjs/sheets-data-validation";
6
+ import { FRange as M, FWorkbook as H, FWorksheet as F } from "@univerjs/sheets/facade";
7
+ import { DataValidationModel as y, getRuleOptions as Q } from "@univerjs/data-validation";
8
+ import { serializeRangeToRefString as z } from "@univerjs/engine-formula";
9
+ import { FUniver as q, FEventName as K } from "@univerjs/core/facade";
10
+ import { filter as x } from "rxjs";
11
+ class C {
12
+ constructor(t) {
13
+ v(this, "_rule");
14
+ this._rule = t != null ? t : {
15
+ uid: N(),
16
16
  ranges: void 0,
17
- type: a.CUSTOM
17
+ type: n.CUSTOM
18
18
  };
19
19
  }
20
20
  /**
@@ -39,7 +39,7 @@ class E {
39
39
  * ```
40
40
  */
41
41
  build() {
42
- return new m(this._rule);
42
+ return new w(this._rule);
43
43
  }
44
44
  /**
45
45
  * Creates a duplicate of the current DataValidationBuilder object
@@ -67,9 +67,9 @@ class E {
67
67
  * ```
68
68
  */
69
69
  copy() {
70
- return new E({
70
+ return new C({
71
71
  ...this._rule,
72
- uid: L()
72
+ uid: N()
73
73
  });
74
74
  }
75
75
  /**
@@ -82,7 +82,7 @@ class E {
82
82
  * ```
83
83
  */
84
84
  getAllowInvalid() {
85
- return this._rule.errorStyle !== k.STOP;
85
+ return this._rule.errorStyle !== U.STOP;
86
86
  }
87
87
  /**
88
88
  * Gets the data validation type of the rule
@@ -158,8 +158,8 @@ class E {
158
158
  * fRange2.setDataValidation(rule2);
159
159
  * ```
160
160
  */
161
- requireCheckbox(e, t) {
162
- return this._rule.type = a.CHECKBOX, this._rule.formula1 = e, this._rule.formula2 = t, this;
161
+ requireCheckbox(t, e) {
162
+ return this._rule.type = n.CHECKBOX, this._rule.formula1 = t, this._rule.formula2 = e, this;
163
163
  }
164
164
  /**
165
165
  * Set the data validation type to DATE and configure the validation rules to be after a specific date.
@@ -188,8 +188,8 @@ class E {
188
188
  * console.log(status); // [['invalid', 'invalid', 'invalid', 'valid']]
189
189
  * ```
190
190
  */
191
- requireDateAfter(e) {
192
- return this._rule.type = a.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.operator = u.GREATER_THAN, this;
191
+ requireDateAfter(t) {
192
+ return this._rule.type = n.DATE, this._rule.formula1 = t.toLocaleDateString(), this._rule.operator = g.GREATER_THAN, this;
193
193
  }
194
194
  /**
195
195
  * Set the data validation type to DATE and configure the validation rules to be before a specific date.
@@ -218,8 +218,8 @@ class E {
218
218
  * console.log(status); // [['valid', 'valid', 'invalid', 'invalid']]
219
219
  * ```
220
220
  */
221
- requireDateBefore(e) {
222
- return this._rule.type = a.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = u.LESS_THAN, this;
221
+ requireDateBefore(t) {
222
+ return this._rule.type = n.DATE, this._rule.formula1 = t.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = g.LESS_THAN, this;
223
223
  }
224
224
  /**
225
225
  * Set the data validation type to DATE and configure the validation rules to be within a specific date range.
@@ -249,8 +249,8 @@ class E {
249
249
  * console.log(status); // [['invalid', 'valid', 'valid', 'invalid']]
250
250
  * ```
251
251
  */
252
- requireDateBetween(e, t) {
253
- return this._rule.type = a.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = t.toLocaleDateString(), this._rule.operator = u.BETWEEN, this;
252
+ requireDateBetween(t, e) {
253
+ return this._rule.type = n.DATE, this._rule.formula1 = t.toLocaleDateString(), this._rule.formula2 = e.toLocaleDateString(), this._rule.operator = g.BETWEEN, this;
254
254
  }
255
255
  /**
256
256
  * Set the data validation type to DATE and configure the validation rules to be equal to a specific date.
@@ -283,8 +283,8 @@ class E {
283
283
  * console.log(status2?.[0]?.[0]); // 'invalid'
284
284
  * ```
285
285
  */
286
- requireDateEqualTo(e) {
287
- return this._rule.type = a.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = u.EQUAL, this;
286
+ requireDateEqualTo(t) {
287
+ return this._rule.type = n.DATE, this._rule.formula1 = t.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = g.EQUAL, this;
288
288
  }
289
289
  /**
290
290
  * Set the data validation type to DATE and configure the validation rules to be not within a specific date range.
@@ -314,8 +314,8 @@ class E {
314
314
  * console.log(status); // [['valid', 'invalid', 'invalid', 'valid']]
315
315
  * ```
316
316
  */
317
- requireDateNotBetween(e, t) {
318
- return this._rule.type = a.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = t.toLocaleDateString(), this._rule.operator = u.NOT_BETWEEN, this;
317
+ requireDateNotBetween(t, e) {
318
+ return this._rule.type = n.DATE, this._rule.formula1 = t.toLocaleDateString(), this._rule.formula2 = e.toLocaleDateString(), this._rule.operator = g.NOT_BETWEEN, this;
319
319
  }
320
320
  /**
321
321
  * Set the data validation type to DATE and configure the validation rules to be on or after a specific date.
@@ -344,8 +344,8 @@ class E {
344
344
  * console.log(status); // [['invalid', 'invalid', 'valid', 'valid']]
345
345
  * ```
346
346
  */
347
- requireDateOnOrAfter(e) {
348
- return this._rule.type = a.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = u.GREATER_THAN_OR_EQUAL, this;
347
+ requireDateOnOrAfter(t) {
348
+ return this._rule.type = n.DATE, this._rule.formula1 = t.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = g.GREATER_THAN_OR_EQUAL, this;
349
349
  }
350
350
  /**
351
351
  * Set the data validation type to DATE and configure the validation rules to be on or before a specific date.
@@ -374,8 +374,8 @@ class E {
374
374
  * console.log(status); // [['valid', 'valid', 'valid', 'invalid']]
375
375
  * ```
376
376
  */
377
- requireDateOnOrBefore(e) {
378
- return this._rule.type = a.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = u.LESS_THAN_OR_EQUAL, this;
377
+ requireDateOnOrBefore(t) {
378
+ return this._rule.type = n.DATE, this._rule.formula1 = t.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = g.LESS_THAN_OR_EQUAL, this;
379
379
  }
380
380
  /**
381
381
  * Sets the data validation rule to require that the given formula evaluates to `true`.
@@ -413,8 +413,8 @@ class E {
413
413
  * console.log(status); // [['valid', 'valid', 'invalid', 'invalid']]
414
414
  * ```
415
415
  */
416
- requireFormulaSatisfied(e) {
417
- return this._rule.type = a.CUSTOM, this._rule.formula1 = e, this._rule.formula2 = void 0, this;
416
+ requireFormulaSatisfied(t) {
417
+ return this._rule.type = n.CUSTOM, this._rule.formula1 = t, this._rule.formula2 = void 0, this;
418
418
  }
419
419
  /**
420
420
  * Sets the data validation rule to require a number that falls between, or is either of, two specified numbers.
@@ -440,8 +440,8 @@ class E {
440
440
  * fRange.setDataValidation(rule);
441
441
  * ```
442
442
  */
443
- requireNumberBetween(e, t, i) {
444
- return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = u.BETWEEN, this._rule.type = i ? a.WHOLE : a.DECIMAL, this;
443
+ requireNumberBetween(t, e, a) {
444
+ return this._rule.formula1 = `${t}`, this._rule.formula2 = `${e}`, this._rule.operator = g.BETWEEN, this._rule.type = a ? n.WHOLE : n.DECIMAL, this;
445
445
  }
446
446
  /**
447
447
  * Sets the data validation rule to require a number equal to the given value.
@@ -466,8 +466,8 @@ class E {
466
466
  * fRange.setDataValidation(rule);
467
467
  * ```
468
468
  */
469
- requireNumberEqualTo(e, t) {
470
- return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = u.EQUAL, this._rule.type = t ? a.WHOLE : a.DECIMAL, this;
469
+ requireNumberEqualTo(t, e) {
470
+ return this._rule.formula1 = `${t}`, this._rule.formula2 = void 0, this._rule.operator = g.EQUAL, this._rule.type = e ? n.WHOLE : n.DECIMAL, this;
471
471
  }
472
472
  /**
473
473
  * Sets the data validation rule to require a number greater than the given value.
@@ -492,8 +492,8 @@ class E {
492
492
  * fRange.setDataValidation(rule);
493
493
  * ```
494
494
  */
495
- requireNumberGreaterThan(e, t) {
496
- return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = u.GREATER_THAN, this._rule.type = t ? a.WHOLE : a.DECIMAL, this;
495
+ requireNumberGreaterThan(t, e) {
496
+ return this._rule.formula1 = `${t}`, this._rule.formula2 = void 0, this._rule.operator = g.GREATER_THAN, this._rule.type = e ? n.WHOLE : n.DECIMAL, this;
497
497
  }
498
498
  /**
499
499
  * Sets the data validation rule to require a number greater than or equal to the given value.
@@ -518,8 +518,8 @@ class E {
518
518
  * fRange.setDataValidation(rule);
519
519
  * ```
520
520
  */
521
- requireNumberGreaterThanOrEqualTo(e, t) {
522
- return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = u.GREATER_THAN_OR_EQUAL, this._rule.type = t ? a.WHOLE : a.DECIMAL, this;
521
+ requireNumberGreaterThanOrEqualTo(t, e) {
522
+ return this._rule.formula1 = `${t}`, this._rule.formula2 = void 0, this._rule.operator = g.GREATER_THAN_OR_EQUAL, this._rule.type = e ? n.WHOLE : n.DECIMAL, this;
523
523
  }
524
524
  /**
525
525
  * Sets the data validation rule to require a number less than the given value.
@@ -544,8 +544,8 @@ class E {
544
544
  * fRange.setDataValidation(rule);
545
545
  * ```
546
546
  */
547
- requireNumberLessThan(e, t) {
548
- return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = u.LESS_THAN, this._rule.type = t ? a.WHOLE : a.DECIMAL, this;
547
+ requireNumberLessThan(t, e) {
548
+ return this._rule.formula1 = `${t}`, this._rule.formula2 = void 0, this._rule.operator = g.LESS_THAN, this._rule.type = e ? n.WHOLE : n.DECIMAL, this;
549
549
  }
550
550
  /**
551
551
  * Sets the data validation rule to require a number less than or equal to the given value.
@@ -570,8 +570,8 @@ class E {
570
570
  * fRange.setDataValidation(rule);
571
571
  * ```
572
572
  */
573
- requireNumberLessThanOrEqualTo(e, t) {
574
- return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = u.LESS_THAN_OR_EQUAL, this._rule.type = t ? a.WHOLE : a.DECIMAL, this;
573
+ requireNumberLessThanOrEqualTo(t, e) {
574
+ return this._rule.formula1 = `${t}`, this._rule.formula2 = void 0, this._rule.operator = g.LESS_THAN_OR_EQUAL, this._rule.type = e ? n.WHOLE : n.DECIMAL, this;
575
575
  }
576
576
  /**
577
577
  * Sets the data validation rule to require a number that does not fall between, and is neither of, two specified numbers.
@@ -597,8 +597,8 @@ class E {
597
597
  * fRange.setDataValidation(rule);
598
598
  * ```
599
599
  */
600
- requireNumberNotBetween(e, t, i) {
601
- return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = u.NOT_BETWEEN, this._rule.type = i ? a.WHOLE : a.DECIMAL, this;
600
+ requireNumberNotBetween(t, e, a) {
601
+ return this._rule.formula1 = `${t}`, this._rule.formula2 = `${e}`, this._rule.operator = g.NOT_BETWEEN, this._rule.type = a ? n.WHOLE : n.DECIMAL, this;
602
602
  }
603
603
  /**
604
604
  * Sets the data validation rule to require a number not equal to the given value.
@@ -623,8 +623,8 @@ class E {
623
623
  * fRange.setDataValidation(rule);
624
624
  * ```
625
625
  */
626
- requireNumberNotEqualTo(e, t) {
627
- return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = u.NOT_EQUAL, this._rule.type = t ? a.WHOLE : a.DECIMAL, this;
626
+ requireNumberNotEqualTo(t, e) {
627
+ return this._rule.formula1 = `${t}`, this._rule.formula2 = void 0, this._rule.operator = g.NOT_EQUAL, this._rule.type = e ? n.WHOLE : n.DECIMAL, this;
628
628
  }
629
629
  /**
630
630
  * Sets a data validation rule that requires the user to enter a value from a list of specific values.
@@ -651,8 +651,8 @@ class E {
651
651
  * fRange.setDataValidation(rule);
652
652
  * ```
653
653
  */
654
- requireValueInList(e, t, i) {
655
- return this._rule.type = t ? a.LIST_MULTIPLE : a.LIST, this._rule.formula1 = e.join(","), this._rule.formula2 = void 0, this._rule.showDropDown = i != null ? i : !0, this;
654
+ requireValueInList(t, e, a) {
655
+ return this._rule.type = e ? n.LIST_MULTIPLE : n.LIST, this._rule.formula1 = t.join(","), this._rule.formula2 = void 0, this._rule.showDropDown = a != null ? a : !0, this;
656
656
  }
657
657
  /**
658
658
  * Sets a data validation rule that requires the user to enter a value within a specific range.
@@ -686,12 +686,12 @@ class E {
686
686
  * cell.setDataValidation(rule);
687
687
  * ```
688
688
  */
689
- requireValueInRange(e, t, i) {
690
- return this._rule.type = t ? a.LIST_MULTIPLE : a.LIST, this._rule.formula1 = `=${F({
691
- unitId: e.getUnitId(),
692
- sheetName: e.getSheetName(),
693
- range: e.getRange()
694
- })}`, this._rule.formula2 = void 0, this._rule.showDropDown = i != null ? i : !0, this;
689
+ requireValueInRange(t, e, a) {
690
+ return this._rule.type = e ? n.LIST_MULTIPLE : n.LIST, this._rule.formula1 = `=${z({
691
+ unitId: t.getUnitId(),
692
+ sheetName: t.getSheetName(),
693
+ range: t.getRange()
694
+ })}`, this._rule.formula2 = void 0, this._rule.showDropDown = a != null ? a : !0, this;
695
695
  }
696
696
  /**
697
697
  * Sets whether to allow invalid data and configures the error style.
@@ -721,8 +721,8 @@ class E {
721
721
  * fRange2.setDataValidation(rule2);
722
722
  * ```
723
723
  */
724
- setAllowInvalid(e) {
725
- return this._rule.errorStyle = e ? k.WARNING : k.STOP, this;
724
+ setAllowInvalid(t) {
725
+ return this._rule.errorStyle = t ? U.WARNING : U.STOP, this;
726
726
  }
727
727
  /**
728
728
  * Sets whether to allow blank values.
@@ -751,8 +751,8 @@ class E {
751
751
  * fRange2.setDataValidation(rule2);
752
752
  * ```
753
753
  */
754
- setAllowBlank(e) {
755
- return this._rule.allowBlank = e, this;
754
+ setAllowBlank(t) {
755
+ return this._rule.allowBlank = t, this;
756
756
  }
757
757
  /**
758
758
  * Sets the options for the data validation rule.
@@ -776,16 +776,16 @@ class E {
776
776
  * fRange.setDataValidation(rule);
777
777
  * ```
778
778
  */
779
- setOptions(e) {
780
- return Object.assign(this._rule, e), this;
779
+ setOptions(t) {
780
+ return Object.assign(this._rule, t), this;
781
781
  }
782
782
  }
783
- class m {
784
- constructor(e, t, i) {
785
- _(this, "rule");
786
- _(this, "_worksheet");
787
- _(this, "_injector");
788
- this._injector = i, this.rule = e, this._worksheet = t;
783
+ class w {
784
+ constructor(t, e, a) {
785
+ v(this, "rule");
786
+ v(this, "_worksheet");
787
+ v(this, "_injector");
788
+ this._injector = a, this.rule = t, this._worksheet = e;
789
789
  }
790
790
  /**
791
791
  * Gets whether invalid data is allowed based on the error style value
@@ -801,7 +801,7 @@ class m {
801
801
  * ```
802
802
  */
803
803
  getAllowInvalid() {
804
- return this.rule.errorStyle !== k.STOP;
804
+ return this.rule.errorStyle !== U.STOP;
805
805
  }
806
806
  /**
807
807
  * Gets the data validation type of the rule
@@ -890,7 +890,7 @@ class m {
890
890
  * ```
891
891
  */
892
892
  copy() {
893
- return new E(this.rule);
893
+ return new C(this.rule);
894
894
  }
895
895
  /**
896
896
  * Gets whether the data validation rule is applied to the worksheet
@@ -911,8 +911,8 @@ class m {
911
911
  getApplied() {
912
912
  if (!this._worksheet)
913
913
  return !1;
914
- const t = this._injector.get(w).getRuleById(this._worksheet.getUnitId(), this._worksheet.getSheetId(), this.rule.uid);
915
- return !!(t && t.ranges.length);
914
+ const e = this._injector.get(y).getRuleById(this._worksheet.getUnitId(), this._worksheet.getSheetId(), this.rule.uid);
915
+ return !!(e && e.ranges.length);
916
916
  }
917
917
  /**
918
918
  * Gets the ranges to which the data validation rule is applied
@@ -934,8 +934,8 @@ class m {
934
934
  getRanges() {
935
935
  if (!this.getApplied())
936
936
  return [];
937
- const e = this._injector.get(W).getUnit(this._worksheet.getUnitId());
938
- return this.rule.ranges.map((t) => this._injector.createInstance(y, e, this._worksheet, t));
937
+ const t = this._injector.get(P).getUnit(this._worksheet.getUnitId());
938
+ return this.rule.ranges.map((e) => this._injector.createInstance(M, t, this._worksheet, e));
939
939
  }
940
940
  /**
941
941
  * Gets the unit ID of the worksheet
@@ -949,8 +949,8 @@ class m {
949
949
  * ```
950
950
  */
951
951
  getUnitId() {
952
- var e;
953
- return (e = this._worksheet) == null ? void 0 : e.getUnitId();
952
+ var t;
953
+ return (t = this._worksheet) == null ? void 0 : t.getUnitId();
954
954
  }
955
955
  /**
956
956
  * Gets the sheet ID of the worksheet
@@ -964,8 +964,8 @@ class m {
964
964
  * ```
965
965
  */
966
966
  getSheetId() {
967
- var e;
968
- return (e = this._worksheet) == null ? void 0 : e.getSheetId();
967
+ var t;
968
+ return (t = this._worksheet) == null ? void 0 : t.getSheetId();
969
969
  }
970
970
  /**
971
971
  * Set Criteria for the data validation rule
@@ -992,21 +992,21 @@ class m {
992
992
  * );
993
993
  * ```
994
994
  */
995
- setCriteria(e, t, i = !0) {
996
- if (this.getApplied() && !this._injector.get(p).syncExecuteCommand(b.id, {
995
+ setCriteria(t, e, a = !0) {
996
+ if (this.getApplied() && !this._injector.get(b).syncExecuteCommand(R.id, {
997
997
  unitId: this.getUnitId(),
998
998
  subUnitId: this.getSheetId(),
999
999
  ruleId: this.rule.uid,
1000
1000
  setting: {
1001
- operator: t[0],
1002
- formula1: t[1],
1003
- formula2: t[2],
1001
+ operator: e[0],
1002
+ formula1: e[1],
1003
+ formula2: e[2],
1004
1004
  type: this.rule.type,
1005
- allowBlank: i
1005
+ allowBlank: a
1006
1006
  }
1007
1007
  }))
1008
1008
  throw new Error("setCriteria failed");
1009
- 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;
1009
+ return this.rule.operator = e[0], this.rule.formula1 = e[1], this.rule.formula2 = e[2], this.rule.type = t, this.rule.allowBlank = a, this;
1010
1010
  }
1011
1011
  /**
1012
1012
  * Set the options for the data validation rule
@@ -1032,18 +1032,18 @@ class m {
1032
1032
  * });
1033
1033
  * ```
1034
1034
  */
1035
- setOptions(e) {
1036
- if (this.getApplied() && !this._injector.get(p).syncExecuteCommand(U.id, {
1035
+ setOptions(t) {
1036
+ if (this.getApplied() && !this._injector.get(b).syncExecuteCommand(T.id, {
1037
1037
  unitId: this.getUnitId(),
1038
1038
  subUnitId: this.getSheetId(),
1039
1039
  ruleId: this.rule.uid,
1040
1040
  options: {
1041
- ...$(this.rule),
1042
- ...e
1041
+ ...Q(this.rule),
1042
+ ...t
1043
1043
  }
1044
1044
  }))
1045
1045
  throw new Error("setOptions failed");
1046
- return Object.assign(this.rule, e), this;
1046
+ return Object.assign(this.rule, t), this;
1047
1047
  }
1048
1048
  /**
1049
1049
  * Set the ranges to the data validation rule
@@ -1066,15 +1066,15 @@ class m {
1066
1066
  * fRange.getDataValidation().setRanges([newRuleRange]);
1067
1067
  * ```
1068
1068
  */
1069
- setRanges(e) {
1070
- if (this.getApplied() && !this._injector.get(p).syncExecuteCommand(C.id, {
1069
+ setRanges(t) {
1070
+ if (this.getApplied() && !this._injector.get(b).syncExecuteCommand(B.id, {
1071
1071
  unitId: this.getUnitId(),
1072
1072
  subUnitId: this.getSheetId(),
1073
1073
  ruleId: this.rule.uid,
1074
- ranges: e.map((r) => r.getRange())
1074
+ ranges: t.map((r) => r.getRange())
1075
1075
  }))
1076
1076
  throw new Error("setRanges failed");
1077
- return this.rule.ranges = e.map((t) => t.getRange()), this;
1077
+ return this.rule.ranges = t.map((e) => e.getRange()), this;
1078
1078
  }
1079
1079
  /**
1080
1080
  * Delete the data validation rule from the worksheet
@@ -1096,45 +1096,45 @@ class m {
1096
1096
  * ```
1097
1097
  */
1098
1098
  delete() {
1099
- return this.getApplied() ? this._injector.get(p).syncExecuteCommand(A.id, {
1099
+ return this.getApplied() ? this._injector.get(b).syncExecuteCommand(L.id, {
1100
1100
  unitId: this.getUnitId(),
1101
1101
  subUnitId: this.getSheetId(),
1102
1102
  ruleId: this.rule.uid
1103
1103
  }) : !1;
1104
1104
  }
1105
1105
  }
1106
- class G extends y {
1107
- setDataValidation(e) {
1108
- if (!e)
1109
- return this._commandService.syncExecuteCommand(j.id, {
1106
+ class X extends M {
1107
+ setDataValidation(t) {
1108
+ if (!t)
1109
+ return this._commandService.syncExecuteCommand(G.id, {
1110
1110
  unitId: this._workbook.getUnitId(),
1111
1111
  subUnitId: this._worksheet.getSheetId(),
1112
1112
  ranges: [this._range]
1113
1113
  }), this;
1114
- const t = {
1114
+ const e = {
1115
1115
  unitId: this._workbook.getUnitId(),
1116
1116
  subUnitId: this._worksheet.getSheetId(),
1117
1117
  rule: {
1118
- ...e.rule,
1118
+ ...t.rule,
1119
1119
  ranges: [this._range]
1120
1120
  }
1121
1121
  };
1122
- return this._commandService.syncExecuteCommand(T.id, t), this;
1122
+ return this._commandService.syncExecuteCommand(O.id, e), this;
1123
1123
  }
1124
1124
  getDataValidation() {
1125
- const t = this._injector.get(S).getDataValidation(
1125
+ const e = this._injector.get(S).getDataValidation(
1126
1126
  this._workbook.getUnitId(),
1127
1127
  this._worksheet.getSheetId(),
1128
1128
  [this._range]
1129
1129
  );
1130
- return t && new m(t, this._worksheet, this._injector);
1130
+ return e && new w(e, this._worksheet, this._injector);
1131
1131
  }
1132
1132
  getDataValidations() {
1133
1133
  return this._injector.get(S).getDataValidations(
1134
1134
  this._workbook.getUnitId(),
1135
1135
  this._worksheet.getSheetId(),
1136
1136
  [this._range]
1137
- ).map((t) => new m(t, this._worksheet, this._injector));
1137
+ ).map((e) => new w(e, this._worksheet, this._injector));
1138
1138
  }
1139
1139
  async getValidatorStatus() {
1140
1140
  return this._injector.get(S).validatorRanges(
@@ -1143,267 +1143,373 @@ class G extends y {
1143
1143
  [this._range]
1144
1144
  );
1145
1145
  }
1146
+ async getDataValidationErrorAsync() {
1147
+ const t = this._workbook.getUnitId(), e = this._worksheet.getSheetId();
1148
+ return this._collectValidationErrorsForRange(t, e, [this._range]);
1149
+ }
1150
+ async _collectValidationErrorsForRange(t, e, a) {
1151
+ if (!a.length)
1152
+ return [];
1153
+ const r = this._injector.get(S), i = this._worksheet, h = i.getName(), s = [];
1154
+ for (const o of a) {
1155
+ const d = [];
1156
+ for (let u = o.startRow; u <= o.endRow; u++)
1157
+ for (let l = o.startColumn; l <= o.endColumn; l++)
1158
+ d.push((async () => {
1159
+ var c;
1160
+ try {
1161
+ if (await r.validatorCell(t, e, u, l) !== A.VALID) {
1162
+ const m = this._injector.get(V).getRuleByLocation(t, e, u, l);
1163
+ if (m) {
1164
+ const k = ((c = i.getCell(u, l)) == null ? void 0 : c.v) || null, I = this._createDataValidationError(
1165
+ h,
1166
+ u,
1167
+ l,
1168
+ m,
1169
+ k
1170
+ );
1171
+ s.push(I);
1172
+ }
1173
+ }
1174
+ } catch (_) {
1175
+ console.warn(`Failed to validate cell [${u}, ${l}]:`, _);
1176
+ }
1177
+ })());
1178
+ await Promise.all(d);
1179
+ }
1180
+ return s;
1181
+ }
1182
+ _createDataValidationError(t, e, a, r, i) {
1183
+ return {
1184
+ sheetName: t,
1185
+ row: e,
1186
+ column: a,
1187
+ ruleId: r.uid,
1188
+ inputValue: i,
1189
+ rule: r
1190
+ };
1191
+ }
1146
1192
  }
1147
- y.extend(G);
1148
- class Q extends N {
1193
+ M.extend(X);
1194
+ class J extends q {
1149
1195
  /**
1150
1196
  * @deprecated use `univerAPI.newDataValidation()` as instead.
1151
1197
  * @returns {FDataValidationBuilder} A new instance of the FDataValidationBuilder class
1152
1198
  */
1153
1199
  static newDataValidation() {
1154
- return new E();
1200
+ return new C();
1155
1201
  }
1156
1202
  newDataValidation() {
1157
- return new E();
1203
+ return new C();
1158
1204
  }
1159
1205
  /**
1160
1206
  * @ignore
1161
1207
  */
1162
1208
  // eslint-disable-next-line max-lines-per-function
1163
- _initialize(e) {
1164
- const t = e.get(p);
1209
+ _initialize(t) {
1210
+ const e = t.get(b);
1165
1211
  this.registerEventHandler(
1166
1212
  this.Event.SheetDataValidationChanged,
1167
- () => e.has(f) ? e.get(f).ruleChange$.subscribe((r) => {
1168
- const { unitId: o, subUnitId: l, rule: s, oldRule: n, type: d } = r, D = this.getSheetTarget(o, l);
1169
- if (!D)
1213
+ () => t.has(V) ? t.get(V).ruleChange$.subscribe((r) => {
1214
+ const { unitId: i, subUnitId: h, rule: s, oldRule: o, type: d } = r, u = this.getSheetTarget(i, h);
1215
+ if (!u)
1170
1216
  return;
1171
- const { workbook: I, worksheet: V } = D, v = new m(s, V.getSheet(), this._injector);
1217
+ const { workbook: l, worksheet: c } = u, _ = new w(s, c.getSheet(), this._injector);
1172
1218
  this.fireEvent(this.Event.SheetDataValidationChanged, {
1173
1219
  origin: r,
1174
- worksheet: V,
1175
- workbook: I,
1220
+ worksheet: c,
1221
+ workbook: l,
1176
1222
  changeType: d,
1177
- oldRule: n,
1178
- rule: v
1223
+ oldRule: o,
1224
+ rule: _
1179
1225
  });
1180
1226
  }) : { dispose: () => {
1181
1227
  } }
1182
1228
  ), this.registerEventHandler(
1183
1229
  this.Event.SheetDataValidatorStatusChanged,
1184
- () => e.has(f) ? e.get(f).validStatusChange$.subscribe((r) => {
1185
- const { unitId: o, subUnitId: l, ruleId: s, status: n, row: d, col: D } = r, I = this.getSheetTarget(o, l);
1186
- if (!I)
1230
+ () => t.has(V) ? t.get(V).validStatusChange$.subscribe((r) => {
1231
+ const { unitId: i, subUnitId: h, ruleId: s, status: o, row: d, col: u } = r, l = this.getSheetTarget(i, h);
1232
+ if (!l)
1187
1233
  return;
1188
- const { workbook: V, worksheet: v } = I, B = v.getDataValidation(s);
1189
- B && this.fireEvent(this.Event.SheetDataValidatorStatusChanged, {
1190
- workbook: V,
1191
- worksheet: v,
1234
+ const { workbook: c, worksheet: _ } = l, E = _.getDataValidation(s);
1235
+ E && this.fireEvent(this.Event.SheetDataValidatorStatusChanged, {
1236
+ workbook: c,
1237
+ worksheet: _,
1192
1238
  row: d,
1193
- column: D,
1194
- rule: B,
1195
- status: n
1239
+ column: u,
1240
+ rule: E,
1241
+ status: o
1196
1242
  });
1197
1243
  }) : { dispose: () => {
1198
1244
  } }
1199
1245
  ), this.registerEventHandler(
1200
1246
  this.Event.BeforeSheetDataValidationAdd,
1201
- () => t.beforeCommandExecuted((i) => {
1202
- if (i.id === T.id) {
1203
- const r = i.params, o = this.getSheetTarget(r.unitId, r.subUnitId);
1204
- if (!o)
1247
+ () => e.beforeCommandExecuted((a) => {
1248
+ if (a.id === O.id) {
1249
+ const r = a.params, i = this.getSheetTarget(r.unitId, r.subUnitId);
1250
+ if (!i)
1205
1251
  return;
1206
- const { workbook: l, worksheet: s } = o, n = {
1252
+ const { workbook: h, worksheet: s } = i, o = {
1207
1253
  worksheet: s,
1208
- workbook: l,
1254
+ workbook: h,
1209
1255
  rule: r.rule
1210
1256
  };
1211
- if (this.fireEvent(this.Event.BeforeSheetDataValidationAdd, n), n.cancel)
1212
- throw new c();
1257
+ if (this.fireEvent(this.Event.BeforeSheetDataValidationAdd, o), o.cancel)
1258
+ throw new D();
1213
1259
  }
1214
1260
  })
1215
1261
  ), this.registerEventHandler(
1216
1262
  this.Event.BeforeSheetDataValidationCriteriaUpdate,
1217
- () => t.beforeCommandExecuted((i) => {
1218
- if (i.id === b.id) {
1219
- const r = i.params, o = this.getSheetTarget(r.unitId, r.subUnitId);
1220
- if (!o)
1263
+ () => e.beforeCommandExecuted((a) => {
1264
+ if (a.id === R.id) {
1265
+ const r = a.params, i = this.getSheetTarget(r.unitId, r.subUnitId);
1266
+ if (!i)
1221
1267
  return;
1222
- const { workbook: l, worksheet: s } = o, n = s.getDataValidation(r.ruleId);
1223
- if (!n)
1268
+ const { workbook: h, worksheet: s } = i, o = s.getDataValidation(r.ruleId);
1269
+ if (!o)
1224
1270
  return;
1225
1271
  const d = {
1226
1272
  worksheet: s,
1227
- workbook: l,
1228
- rule: n,
1273
+ workbook: h,
1274
+ rule: o,
1229
1275
  ruleId: r.ruleId,
1230
1276
  newCriteria: r.setting
1231
1277
  };
1232
1278
  if (this.fireEvent(this.Event.BeforeSheetDataValidationCriteriaUpdate, d), d.cancel)
1233
- throw new c();
1279
+ throw new D();
1234
1280
  }
1235
1281
  })
1236
1282
  ), this.registerEventHandler(
1237
1283
  this.Event.BeforeSheetDataValidationRangeUpdate,
1238
- () => t.beforeCommandExecuted((i) => {
1239
- if (i.id === C.id) {
1240
- const r = i.params, o = this.getSheetTarget(r.unitId, r.subUnitId);
1241
- if (!o)
1284
+ () => e.beforeCommandExecuted((a) => {
1285
+ if (a.id === B.id) {
1286
+ const r = a.params, i = this.getSheetTarget(r.unitId, r.subUnitId);
1287
+ if (!i)
1242
1288
  return;
1243
- const { workbook: l, worksheet: s } = o, n = s.getDataValidation(r.ruleId);
1244
- if (!n)
1289
+ const { workbook: h, worksheet: s } = i, o = s.getDataValidation(r.ruleId);
1290
+ if (!o)
1245
1291
  return;
1246
1292
  const d = {
1247
1293
  worksheet: s,
1248
- workbook: l,
1249
- rule: n,
1294
+ workbook: h,
1295
+ rule: o,
1250
1296
  ruleId: r.ruleId,
1251
1297
  newRanges: r.ranges
1252
1298
  };
1253
1299
  if (this.fireEvent(this.Event.BeforeSheetDataValidationRangeUpdate, d), d.cancel)
1254
- throw new c();
1300
+ throw new D();
1255
1301
  }
1256
1302
  })
1257
1303
  ), this.registerEventHandler(
1258
1304
  this.Event.BeforeSheetDataValidationOptionsUpdate,
1259
- () => t.beforeCommandExecuted((i) => {
1260
- if (i.id === U.id) {
1261
- const r = i.params, o = this.getSheetTarget(r.unitId, r.subUnitId);
1262
- if (!o)
1305
+ () => e.beforeCommandExecuted((a) => {
1306
+ if (a.id === T.id) {
1307
+ const r = a.params, i = this.getSheetTarget(r.unitId, r.subUnitId);
1308
+ if (!i)
1263
1309
  return;
1264
- const { workbook: l, worksheet: s } = o, n = s.getDataValidation(r.ruleId);
1265
- if (!n)
1310
+ const { workbook: h, worksheet: s } = i, o = s.getDataValidation(r.ruleId);
1311
+ if (!o)
1266
1312
  return;
1267
1313
  const d = {
1268
1314
  worksheet: s,
1269
- workbook: l,
1270
- rule: n,
1315
+ workbook: h,
1316
+ rule: o,
1271
1317
  ruleId: r.ruleId,
1272
1318
  newOptions: r.options
1273
1319
  };
1274
1320
  if (this.fireEvent(this.Event.BeforeSheetDataValidationOptionsUpdate, d), d.cancel)
1275
- throw new c();
1321
+ throw new D();
1276
1322
  }
1277
1323
  })
1278
1324
  ), this.registerEventHandler(
1279
1325
  this.Event.BeforeSheetDataValidationDelete,
1280
- () => t.beforeCommandExecuted((i) => {
1281
- if (i.id === A.id) {
1282
- const r = i.params, o = this.getSheetTarget(r.unitId, r.subUnitId);
1283
- if (!o)
1326
+ () => e.beforeCommandExecuted((a) => {
1327
+ if (a.id === L.id) {
1328
+ const r = a.params, i = this.getSheetTarget(r.unitId, r.subUnitId);
1329
+ if (!i)
1284
1330
  return;
1285
- const { workbook: l, worksheet: s } = o, n = s.getDataValidation(r.ruleId);
1286
- if (!n)
1331
+ const { workbook: h, worksheet: s } = i, o = s.getDataValidation(r.ruleId);
1332
+ if (!o)
1287
1333
  return;
1288
1334
  const d = {
1289
1335
  worksheet: s,
1290
- workbook: l,
1291
- rule: n,
1336
+ workbook: h,
1337
+ rule: o,
1292
1338
  ruleId: r.ruleId
1293
1339
  };
1294
1340
  if (this.fireEvent(this.Event.BeforeSheetDataValidationDelete, d), d.cancel)
1295
- throw new c();
1341
+ throw new D();
1296
1342
  }
1297
1343
  })
1298
1344
  ), this.registerEventHandler(
1299
1345
  this.Event.BeforeSheetDataValidationDeleteAll,
1300
- () => t.beforeCommandExecuted((i) => {
1301
- if (i.id === O.id) {
1302
- const r = i.params, o = this.getSheetTarget(r.unitId, r.subUnitId);
1303
- if (!o)
1346
+ () => e.beforeCommandExecuted((a) => {
1347
+ if (a.id === j.id) {
1348
+ const r = a.params, i = this.getSheetTarget(r.unitId, r.subUnitId);
1349
+ if (!i)
1304
1350
  return;
1305
- const { workbook: l, worksheet: s } = o, n = {
1351
+ const { workbook: h, worksheet: s } = i, o = {
1306
1352
  worksheet: s,
1307
- workbook: l,
1353
+ workbook: h,
1308
1354
  rules: s.getDataValidations()
1309
1355
  };
1310
- if (this.fireEvent(this.Event.BeforeSheetDataValidationDeleteAll, n), n.cancel)
1311
- throw new c();
1356
+ if (this.fireEvent(this.Event.BeforeSheetDataValidationDeleteAll, o), o.cancel)
1357
+ throw new D();
1312
1358
  }
1313
1359
  })
1314
1360
  );
1315
1361
  }
1316
1362
  }
1317
- N.extend(Q);
1318
- class z extends x {
1363
+ q.extend(J);
1364
+ class Y extends H {
1319
1365
  _initialize() {
1320
1366
  Object.defineProperty(this, "_dataValidationModel", {
1321
1367
  get() {
1322
- return this._injector.get(f);
1368
+ return this._injector.get(V);
1323
1369
  }
1324
1370
  });
1325
1371
  }
1326
1372
  getValidatorStatus() {
1327
1373
  return this._injector.get(S).validatorWorkbook(this._workbook.getUnitId());
1328
1374
  }
1375
+ async getAllDataValidationErrorAsync() {
1376
+ const t = this._workbook.getUnitId(), e = this._dataValidationModel.getSubUnitIds(t), a = [];
1377
+ for (const r of e) {
1378
+ const i = await this._collectValidationErrorsForSheet(t, r);
1379
+ a.push(...i);
1380
+ }
1381
+ return a;
1382
+ }
1383
+ async _collectValidationErrorsForSheet(t, e) {
1384
+ const a = this._dataValidationModel.getRules(t, e);
1385
+ if (!a.length)
1386
+ return [];
1387
+ const r = a.flatMap((i) => i.ranges);
1388
+ return this._collectValidationErrorsForRange(t, e, r);
1389
+ }
1390
+ async _collectValidationErrorsForRange(t, e, a) {
1391
+ if (!a.length)
1392
+ return [];
1393
+ const r = this._injector.get(S), h = this._workbook.getSheetBySheetId(e);
1394
+ if (!h)
1395
+ throw new Error(`Cannot find worksheet with sheetId: ${e}`);
1396
+ const s = h.getName(), o = [];
1397
+ for (const d of a) {
1398
+ const u = [];
1399
+ for (let l = d.startRow; l <= d.endRow; l++)
1400
+ for (let c = d.startColumn; c <= d.endColumn; c++)
1401
+ u.push((async () => {
1402
+ var _;
1403
+ try {
1404
+ if (await r.validatorCell(t, e, l, c) !== A.VALID) {
1405
+ const m = this._dataValidationModel.getRuleByLocation(t, e, l, c);
1406
+ if (m) {
1407
+ const k = ((_ = h.getCell(l, c)) == null ? void 0 : _.v) || null, I = this._createDataValidationError(
1408
+ s,
1409
+ l,
1410
+ c,
1411
+ m,
1412
+ k
1413
+ );
1414
+ o.push(I);
1415
+ }
1416
+ }
1417
+ } catch (E) {
1418
+ console.warn(`Failed to validate cell [${l}, ${c}]:`, E);
1419
+ }
1420
+ })());
1421
+ await Promise.all(u);
1422
+ }
1423
+ return o;
1424
+ }
1425
+ _createDataValidationError(t, e, a, r, i) {
1426
+ return {
1427
+ sheetName: t,
1428
+ row: e,
1429
+ column: a,
1430
+ ruleId: r.uid,
1431
+ inputValue: i,
1432
+ rule: r
1433
+ };
1434
+ }
1329
1435
  // region DataValidationHooks
1330
- onDataValidationChange(e) {
1331
- return g(this._dataValidationModel.ruleChange$.pipe(R((t) => t.unitId === this._workbook.getUnitId())).subscribe(e));
1436
+ onDataValidationChange(t) {
1437
+ return p(this._dataValidationModel.ruleChange$.pipe(x((e) => e.unitId === this._workbook.getUnitId())).subscribe(t));
1332
1438
  }
1333
- onDataValidationStatusChange(e) {
1334
- return g(this._dataValidationModel.validStatusChange$.pipe(R((t) => t.unitId === this._workbook.getUnitId())).subscribe(e));
1439
+ onDataValidationStatusChange(t) {
1440
+ return p(this._dataValidationModel.validStatusChange$.pipe(x((e) => e.unitId === this._workbook.getUnitId())).subscribe(t));
1335
1441
  }
1336
- onBeforeAddDataValidation(e) {
1337
- return g(this._commandService.beforeCommandExecuted((t, i) => {
1338
- const r = t.params;
1339
- if (t.id === T.id) {
1442
+ onBeforeAddDataValidation(t) {
1443
+ return p(this._commandService.beforeCommandExecuted((e, a) => {
1444
+ const r = e.params;
1445
+ if (e.id === O.id) {
1340
1446
  if (r.unitId !== this._workbook.getUnitId())
1341
1447
  return;
1342
- if (e(r, i) === !1)
1448
+ if (t(r, a) === !1)
1343
1449
  throw new Error("Command is stopped by the hook onBeforeAddDataValidation");
1344
1450
  }
1345
1451
  }));
1346
1452
  }
1347
- onBeforeUpdateDataValidationCriteria(e) {
1348
- return g(this._commandService.beforeCommandExecuted((t, i) => {
1349
- const r = t.params;
1350
- if (t.id === b.id) {
1453
+ onBeforeUpdateDataValidationCriteria(t) {
1454
+ return p(this._commandService.beforeCommandExecuted((e, a) => {
1455
+ const r = e.params;
1456
+ if (e.id === R.id) {
1351
1457
  if (r.unitId !== this._workbook.getUnitId())
1352
1458
  return;
1353
- if (e(r, i) === !1)
1459
+ if (t(r, a) === !1)
1354
1460
  throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationCriteria");
1355
1461
  }
1356
1462
  }));
1357
1463
  }
1358
- onBeforeUpdateDataValidationRange(e) {
1359
- return g(this._commandService.beforeCommandExecuted((t, i) => {
1360
- const r = t.params;
1361
- if (t.id === C.id) {
1464
+ onBeforeUpdateDataValidationRange(t) {
1465
+ return p(this._commandService.beforeCommandExecuted((e, a) => {
1466
+ const r = e.params;
1467
+ if (e.id === B.id) {
1362
1468
  if (r.unitId !== this._workbook.getUnitId())
1363
1469
  return;
1364
- if (e(r, i) === !1)
1470
+ if (t(r, a) === !1)
1365
1471
  throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationRange");
1366
1472
  }
1367
1473
  }));
1368
1474
  }
1369
- onBeforeUpdateDataValidationOptions(e) {
1370
- return g(this._commandService.beforeCommandExecuted((t, i) => {
1371
- const r = t.params;
1372
- if (t.id === U.id) {
1475
+ onBeforeUpdateDataValidationOptions(t) {
1476
+ return p(this._commandService.beforeCommandExecuted((e, a) => {
1477
+ const r = e.params;
1478
+ if (e.id === T.id) {
1373
1479
  if (r.unitId !== this._workbook.getUnitId())
1374
1480
  return;
1375
- if (e(r, i) === !1)
1481
+ if (t(r, a) === !1)
1376
1482
  throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationOptions");
1377
1483
  }
1378
1484
  }));
1379
1485
  }
1380
- onBeforeDeleteDataValidation(e) {
1381
- return g(this._commandService.beforeCommandExecuted((t, i) => {
1382
- const r = t.params;
1383
- if (t.id === A.id) {
1486
+ onBeforeDeleteDataValidation(t) {
1487
+ return p(this._commandService.beforeCommandExecuted((e, a) => {
1488
+ const r = e.params;
1489
+ if (e.id === L.id) {
1384
1490
  if (r.unitId !== this._workbook.getUnitId())
1385
1491
  return;
1386
- if (e(r, i) === !1)
1492
+ if (t(r, a) === !1)
1387
1493
  throw new Error("Command is stopped by the hook onBeforeDeleteDataValidation");
1388
1494
  }
1389
1495
  }));
1390
1496
  }
1391
- onBeforeDeleteAllDataValidation(e) {
1392
- return g(this._commandService.beforeCommandExecuted((t, i) => {
1393
- const r = t.params;
1394
- if (t.id === O.id) {
1497
+ onBeforeDeleteAllDataValidation(t) {
1498
+ return p(this._commandService.beforeCommandExecuted((e, a) => {
1499
+ const r = e.params;
1500
+ if (e.id === j.id) {
1395
1501
  if (r.unitId !== this._workbook.getUnitId())
1396
1502
  return;
1397
- if (e(r, i) === !1)
1503
+ if (t(r, a) === !1)
1398
1504
  throw new Error("Command is stopped by the hook onBeforeDeleteAllDataValidation");
1399
1505
  }
1400
1506
  }));
1401
1507
  }
1402
1508
  }
1403
- x.extend(z);
1404
- class K extends M {
1509
+ H.extend(Y);
1510
+ class Z extends F {
1405
1511
  getDataValidations() {
1406
- return this._injector.get(w).getRules(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((t) => new m(t, this._worksheet, this._injector));
1512
+ return this._injector.get(y).getRules(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((e) => new w(e, this._worksheet, this._injector));
1407
1513
  }
1408
1514
  getValidatorStatus() {
1409
1515
  return this._injector.get(S).validatorWorksheet(
@@ -1414,13 +1520,66 @@ class K extends M {
1414
1520
  getValidatorStatusAsync() {
1415
1521
  return this.getValidatorStatus();
1416
1522
  }
1417
- getDataValidation(e) {
1418
- const i = this._injector.get(w).getRuleById(this._workbook.getUnitId(), this._worksheet.getSheetId(), e);
1419
- return i ? new m(i, this._worksheet, this._injector) : null;
1523
+ getDataValidation(t) {
1524
+ const a = this._injector.get(y).getRuleById(this._workbook.getUnitId(), this._worksheet.getSheetId(), t);
1525
+ return a ? new w(a, this._worksheet, this._injector) : null;
1526
+ }
1527
+ async getAllDataValidationErrorAsync() {
1528
+ const t = this._workbook.getUnitId(), e = this._worksheet.getSheetId();
1529
+ return this._collectValidationErrorsForSheet(t, e);
1530
+ }
1531
+ async _collectValidationErrorsForSheet(t, e) {
1532
+ const r = this._injector.get(y).getRules(t, e);
1533
+ if (!r.length)
1534
+ return [];
1535
+ const i = r.flatMap((h) => h.ranges);
1536
+ return this._collectValidationErrorsForRange(t, e, i);
1537
+ }
1538
+ async _collectValidationErrorsForRange(t, e, a) {
1539
+ if (!a.length)
1540
+ return [];
1541
+ const r = this._injector.get(S), i = this._worksheet, h = i.getName(), s = [];
1542
+ for (const o of a) {
1543
+ const d = [];
1544
+ for (let u = o.startRow; u <= o.endRow; u++)
1545
+ for (let l = o.startColumn; l <= o.endColumn; l++)
1546
+ d.push((async () => {
1547
+ var c;
1548
+ try {
1549
+ if (await r.validatorCell(t, e, u, l) !== A.VALID) {
1550
+ const m = this._injector.get(V).getRuleByLocation(t, e, u, l);
1551
+ if (m) {
1552
+ const k = ((c = i.getCell(u, l)) == null ? void 0 : c.v) || null, I = this._createDataValidationError(
1553
+ h,
1554
+ u,
1555
+ l,
1556
+ m,
1557
+ k
1558
+ );
1559
+ s.push(I);
1560
+ }
1561
+ }
1562
+ } catch (_) {
1563
+ console.warn(`Failed to validate cell [${u}, ${l}]:`, _);
1564
+ }
1565
+ })());
1566
+ await Promise.all(d);
1567
+ }
1568
+ return s;
1569
+ }
1570
+ _createDataValidationError(t, e, a, r, i) {
1571
+ return {
1572
+ sheetName: t,
1573
+ row: e,
1574
+ column: a,
1575
+ ruleId: r.uid,
1576
+ inputValue: i,
1577
+ rule: r
1578
+ };
1420
1579
  }
1421
1580
  }
1422
- M.extend(K);
1423
- class X {
1581
+ F.extend(Z);
1582
+ class tt {
1424
1583
  get SheetDataValidationChanged() {
1425
1584
  return "SheetDataValidationChanged";
1426
1585
  }
@@ -1446,8 +1605,8 @@ class X {
1446
1605
  return "BeforeSheetDataValidationOptionsUpdate";
1447
1606
  }
1448
1607
  }
1449
- P.extend(X);
1608
+ K.extend(tt);
1450
1609
  export {
1451
- m as FDataValidation,
1452
- E as FDataValidationBuilder
1610
+ w as FDataValidation,
1611
+ C as FDataValidationBuilder
1453
1612
  };