@univerjs/sheets-data-validation 0.5.4 → 0.5.5-experimental.20250122-3362a4a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/facade.js CHANGED
@@ -1,769 +1,1012 @@
1
- var j = Object.defineProperty;
2
- var q = (c, e, t) => e in c ? j(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t;
3
- var f = (c, e, t) => q(c, typeof e != "symbol" ? e + "" : e, t);
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
- import { FRange as y, FWorkbook as M, FWorksheet as x } from "@univerjs/sheets/facade";
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
- import { DataValidationModel as b, getRuleOptions as F } from "@univerjs/data-validation";
8
- import { serializeRangeToRefString as P } from "@univerjs/engine-formula";
9
- import { filter as R } from "rxjs";
10
- class D {
11
- constructor(e) {
12
- f(this, "_rule");
13
- this._rule = e != null ? e : {
14
- uid: B(),
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
+ import { UpdateSheetDataValidationSettingCommand, UpdateSheetDataValidationOptionsCommand, UpdateSheetDataValidationRangeCommand, RemoveSheetDataValidationCommand, ClearRangeDataValidationCommand, AddSheetDataValidationCommand, SheetsDataValidationValidatorService, SheetDataValidationModel, RemoveSheetAllDataValidationCommand } from "@univerjs/sheets-data-validation";
6
+ import { FRange, FWorkbook, FWorksheet } from "@univerjs/sheets/facade";
7
+ import { generateRandomId, DataValidationType, DataValidationErrorStyle, DataValidationOperator, IUniverInstanceService, ICommandService, FUniver, CanceledError, toDisposable, FEventName } from "@univerjs/core";
8
+ import { DataValidationModel, getRuleOptions } from "@univerjs/data-validation";
9
+ import { serializeRangeToRefString } from "@univerjs/engine-formula";
10
+ import { filter } from "rxjs";
11
+ const _FDataValidationBuilder = class _FDataValidationBuilder {
12
+ constructor(rule) {
13
+ __publicField(this, "_rule");
14
+ this._rule = rule != null ? rule : {
15
+ uid: generateRandomId(),
15
16
  ranges: void 0,
16
- type: o.CUSTOM
17
+ type: DataValidationType.CUSTOM
17
18
  };
18
19
  }
19
20
  /**
20
21
  * Builds an FDataValidation instance based on the _rule property of the current class
21
- *
22
22
  * @returns {FDataValidation} A new instance of the FDataValidation class
23
+ * @example
24
+ * ```typescript
25
+ * const builder = univerAPI.newDataValidation();
26
+ * const validation = builder.requireNumberBetween(1, 10).build();
27
+ * ```
23
28
  */
24
29
  build() {
25
- return new m(this._rule);
30
+ return new FDataValidation(this._rule);
26
31
  }
27
32
  /**
28
33
  * Creates a duplicate of the current DataValidationBuilder object
29
- *
30
- * @return {FDataValidationBuilder} A new instance of the DataValidationBuilder class
34
+ * @returns {FDataValidationBuilder} A new instance of the DataValidationBuilder class
35
+ * @example
36
+ * ```typescript
37
+ * const builder = univerAPI.newDataValidation();
38
+ * const copy = builder.requireNumberBetween(1, 10).copy();
39
+ * ```
31
40
  */
32
41
  copy() {
33
- return new D({
42
+ return new _FDataValidationBuilder({
34
43
  ...this._rule,
35
- uid: B()
44
+ uid: generateRandomId()
36
45
  });
37
46
  }
38
47
  /**
39
48
  * Determines whether invalid data is allowed
40
- *
41
49
  * @returns {boolean} True if invalid data is allowed, False otherwise
50
+ * @example
51
+ * ```typescript
52
+ * const builder = univerAPI.newDataValidation();
53
+ * const allowsInvalid = builder.getAllowInvalid();
54
+ * ```
42
55
  */
43
56
  getAllowInvalid() {
44
- return this._rule.errorStyle !== w.STOP;
57
+ return this._rule.errorStyle !== DataValidationErrorStyle.STOP;
45
58
  }
46
59
  /**
47
60
  * Gets the data validation type of the rule
48
- *
49
- * @returns {DataValidationType} The data validation type
61
+ * @returns {DataValidationType | string} The data validation type
62
+ * @example
63
+ * ```typescript
64
+ * const builder = univerAPI.newDataValidation();
65
+ * const type = builder.getCriteriaType();
66
+ * ```
50
67
  */
51
68
  getCriteriaType() {
52
69
  return this._rule.type;
53
70
  }
54
71
  /**
55
72
  * Gets the values used for criteria evaluation
56
- *
57
- * @returns {[string, string, string]} An array containing the operator, formula1, and formula2 values
73
+ * @returns {[string | undefined, string | undefined, string | undefined]} An array containing the operator, formula1, and formula2 values
74
+ * @example
75
+ * ```typescript
76
+ * const builder = univerAPI.newDataValidation();
77
+ * const [operator, formula1, formula2] = builder.getCriteriaValues();
78
+ * ```
58
79
  */
59
80
  getCriteriaValues() {
60
81
  return [this._rule.operator, this._rule.formula1, this._rule.formula2];
61
82
  }
62
83
  /**
63
84
  * Gets the help text information, which is used to provide users with guidance and support
64
- *
65
- * @returns {string | undefined} Returns the help text information. If there is no error message, it returns an undefined value.
85
+ * @returns {string | undefined} Returns the help text information. If there is no error message, it returns an undefined value
86
+ * @example
87
+ * ```typescript
88
+ * const builder = univerAPI.newDataValidation();
89
+ * const helpText = builder.getHelpText();
90
+ * ```
66
91
  */
67
92
  getHelpText() {
68
93
  return this._rule.error;
69
94
  }
70
95
  /**
71
96
  * Sets the data validation type to CHECKBOX and sets the checked and unchecked values
72
- *
73
- * @param checkedValue The value when the checkbox is checked (Optional)
74
- * @param uncheckedValue The value when the checkbox is unchecked (Optional)
75
- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining
97
+ * @param {string} [checkedValue] - The value when the checkbox is checked
98
+ * @param {string} [uncheckedValue] - The value when the checkbox is unchecked
99
+ * @returns {FDataValidationBuilder} The current instance for method chaining
100
+ * @example
101
+ * ```typescript
102
+ * const builder = univerAPI.newDataValidation();
103
+ * const rule = builder.requireCheckbox('Yes', 'No').build();
104
+ * ```
76
105
  */
77
- requireCheckbox(e, t) {
78
- return this._rule.type = o.CHECKBOX, this._rule.formula1 = e, this._rule.formula2 = t, this;
106
+ requireCheckbox(checkedValue, uncheckedValue) {
107
+ return this._rule.type = DataValidationType.CHECKBOX, this._rule.formula1 = checkedValue, this._rule.formula2 = uncheckedValue, this;
79
108
  }
80
109
  /**
81
110
  * Set the data validation type to DATE and configure the validation rules to be after a specific date
82
- *
83
- * @param date The date to compare against. The formatted date string will be set as formula1
84
- * @return The current instance of the FDataValidationBuilder class to allow for method chaining
111
+ * @param {Date} date - The date to compare against
112
+ * @returns {FDataValidationBuilder} The current instance for method chaining
113
+ * @example
114
+ * ```typescript
115
+ * const builder = univerAPI.newDataValidation();
116
+ * const rule = builder.requireDateAfter(new Date('2024-01-01')).build();
117
+ * ```
85
118
  */
86
- requireDateAfter(e) {
87
- return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.operator = d.GREATER_THAN, this;
119
+ requireDateAfter(date) {
120
+ return this._rule.type = DataValidationType.DATE, this._rule.formula1 = date.toLocaleDateString(), this._rule.operator = DataValidationOperator.GREATER_THAN, this;
88
121
  }
89
122
  /**
90
123
  * Set the data validation type to DATE and configure the validation rules to be before a specific date
91
- *
92
- * @param date The date to compare against. The formatted date string will be set as formula1
93
- * @return The current instance of the FDataValidationBuilder class to allow for method chaining
124
+ * @param {Date} date - The date to compare against
125
+ * @returns {FDataValidationBuilder} The current instance for method chaining
126
+ * @example
127
+ * ```typescript
128
+ * const builder = univerAPI.newDataValidation();
129
+ * const rule = builder.requireDateBefore(new Date('2024-12-31')).build();
130
+ * ```
94
131
  */
95
- requireDateBefore(e) {
96
- return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = d.LESS_THAN, this;
132
+ requireDateBefore(date) {
133
+ return this._rule.type = DataValidationType.DATE, this._rule.formula1 = date.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.LESS_THAN, this;
97
134
  }
98
135
  /**
99
136
  * Set the data validation type to DATE and configure the validation rules to be within a specific date range
100
- *
101
- * @param start The starting date of the range. The formatted date string will be set as formula1
102
- * @param end The ending date of the range. The formatted date string will be set as formula2
103
- * @return The current instance of the FDataValidationBuilder class to allow for method chaining
137
+ * @param {Date} start - The starting date of the range
138
+ * @param {Date} end - The ending date of the range
139
+ * @returns {FDataValidationBuilder} The current instance for method chaining
140
+ * @example
141
+ * ```typescript
142
+ * const builder = univerAPI.newDataValidation();
143
+ * const rule = builder
144
+ * .requireDateBetween(new Date('2024-01-01'), new Date('2024-12-31'))
145
+ * .build();
146
+ * ```
104
147
  */
105
- requireDateBetween(e, t) {
106
- return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = t.toLocaleDateString(), this._rule.operator = d.BETWEEN, this;
148
+ requireDateBetween(start, end) {
149
+ return this._rule.type = DataValidationType.DATE, this._rule.formula1 = start.toLocaleDateString(), this._rule.formula2 = end.toLocaleDateString(), this._rule.operator = DataValidationOperator.BETWEEN, this;
107
150
  }
108
151
  /**
109
152
  * Set the data validation type to DATE and configure the validation rules to be equal to a specific date
110
- *
111
- * @param date The date to compare against. The formatted date string will be set as formula1
112
- * @return The current instance of the FDataValidationBuilder class to allow for method chaining
153
+ * @param {Date} date - The date to compare against
154
+ * @returns {FDataValidationBuilder} The current instance for method chaining
155
+ * @example
156
+ * ```typescript
157
+ * const builder = univerAPI.newDataValidation();
158
+ * const rule = builder.requireDateEqualTo(new Date('2024-01-01')).build();
159
+ * ```
113
160
  */
114
- requireDateEqualTo(e) {
115
- return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = d.EQUAL, this;
161
+ requireDateEqualTo(date) {
162
+ return this._rule.type = DataValidationType.DATE, this._rule.formula1 = date.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.EQUAL, this;
116
163
  }
117
164
  /**
118
165
  * Set the data validation type to DATE and configure the validation rules to be not within a specific date range
119
- *
120
- * @param start The starting date of the date range
121
- * @param end The ending date of the date range
122
- * @return The current instance of the FDataValidationBuilder class to allow for method chaining
166
+ * @param {Date} start - The starting date of the date range
167
+ * @param {Date} end - The ending date of the date range
168
+ * @returns {FDataValidationBuilder} The current instance for method chaining
169
+ * @example
170
+ * ```typescript
171
+ * const builder = univerAPI.newDataValidation();
172
+ * const rule = builder
173
+ * .requireDateNotBetween(new Date('2024-01-01'), new Date('2024-12-31'))
174
+ * .build();
175
+ * ```
123
176
  */
124
- requireDateNotBetween(e, t) {
125
- return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = t.toLocaleDateString(), this._rule.operator = d.NOT_BETWEEN, this;
177
+ requireDateNotBetween(start, end) {
178
+ return this._rule.type = DataValidationType.DATE, this._rule.formula1 = start.toLocaleDateString(), this._rule.formula2 = end.toLocaleDateString(), this._rule.operator = DataValidationOperator.NOT_BETWEEN, this;
126
179
  }
127
180
  /**
128
181
  * Set the data validation type to DATE and configure the validation rules to be on or after a specific date
129
- *
130
- * @param date The date to compare against. The formatted date string will be set as formula1
131
- * @return The current instance of the FDataValidationBuilder class to allow for method chaining
182
+ * @param {Date} date - The date to compare against
183
+ * @returns {FDataValidationBuilder} The current instance for method chaining
184
+ * @example
185
+ * ```typescript
186
+ * const builder = univerAPI.newDataValidation();
187
+ * const rule = builder.requireDateOnOrAfter(new Date('2024-01-01')).build();
188
+ * ```
132
189
  */
133
- requireDateOnOrAfter(e) {
134
- return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = d.GREATER_THAN_OR_EQUAL, this;
190
+ requireDateOnOrAfter(date) {
191
+ return this._rule.type = DataValidationType.DATE, this._rule.formula1 = date.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.GREATER_THAN_OR_EQUAL, this;
135
192
  }
136
193
  /**
137
194
  * Set the data validation type to DATE and configure the validation rules to be on or before a specific date
138
- *
139
- * @param date The date to compare against. The formatted date string will be set as formula1
140
- * @return The current instance of the FDataValidationBuilder class to allow for method chaining
195
+ * @param {Date} date - The date to compare against
196
+ * @returns {FDataValidationBuilder} The current instance for method chaining
197
+ * @example
198
+ * ```typescript
199
+ * const builder = univerAPI.newDataValidation();
200
+ * const rule = builder.requireDateOnOrBefore(new Date('2024-12-31')).build();
201
+ * ```
141
202
  */
142
- requireDateOnOrBefore(e) {
143
- return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = d.LESS_THAN_OR_EQUAL, this;
203
+ requireDateOnOrBefore(date) {
204
+ return this._rule.type = DataValidationType.DATE, this._rule.formula1 = date.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.LESS_THAN_OR_EQUAL, this;
144
205
  }
145
206
  /**
146
- * Requires that a custom formula be satisfied.
147
- * Sets the data validation type to CUSTOM and configures the validation rule based on the provided formula string.
148
- *
149
- * @param formula The formula string that needs to be satisfied.
150
- * @return The current instance of the FDataValidationBuilder class to allow for method chaining.
207
+ * Requires that a custom formula be satisfied
208
+ * @param {string} formula - The formula string that needs to be satisfied
209
+ * @returns {FDataValidationBuilder} The current instance for method chaining
210
+ * @example
211
+ * ```typescript
212
+ * const builder = univerAPI.newDataValidation();
213
+ * const rule = builder.requireFormulaSatisfied('=A1>0').build();
214
+ * ```
151
215
  */
152
- requireFormulaSatisfied(e) {
153
- return this._rule.type = o.CUSTOM, this._rule.formula1 = e, this._rule.formula2 = void 0, this;
216
+ requireFormulaSatisfied(formula) {
217
+ return this._rule.type = DataValidationType.CUSTOM, this._rule.formula1 = formula, this._rule.formula2 = void 0, this;
154
218
  }
155
219
  /**
156
- * Requires the user to enter a number within a specific range, which can be integer or decimal.
157
- * Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number range.
158
- *
159
- * @param start The starting value of the number range.
160
- * @param end The ending value of the number range.
161
- * @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or decimal.
162
- * @return The current instance of the FDataValidationBuilder class to allow for method chaining.
220
+ * Requires the user to enter a number within a specific range, which can be integer or decimal
221
+ * @param {number} start - The starting value of the number range
222
+ * @param {number} end - The ending value of the number range
223
+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer
224
+ * @returns {FDataValidationBuilder} The current instance for method chaining
225
+ * @example
226
+ * ```typescript
227
+ * const builder = univerAPI.newDataValidation();
228
+ * const rule = builder.requireNumberBetween(1, 10).build();
229
+ * ```
163
230
  */
164
- requireNumberBetween(e, t, r) {
165
- return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = d.BETWEEN, this._rule.type = r ? o.WHOLE : o.DECIMAL, this;
231
+ requireNumberBetween(start, end, isInteger) {
232
+ return this._rule.formula1 = `${start}`, this._rule.formula2 = `${end}`, this._rule.operator = DataValidationOperator.BETWEEN, this._rule.type = isInteger ? DataValidationType.WHOLE : DataValidationType.DECIMAL, this;
166
233
  }
167
234
  /**
168
- * Requires the user to enter a number that is equal to a specific value, which can be an integer or a decimal.
169
- * Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.
170
- *
171
- * @param num The number to which the entered number should be equal.
172
- * @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.
173
- * @return The current instance of the FDataValidationBuilder class to allow for method chaining.
235
+ * Requires the user to enter a number that is equal to a specific value, which can be an integer or a decimal
236
+ * @param {number} num - The number to which the entered number should be equal
237
+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer
238
+ * @returns {FDataValidationBuilder} The current instance for method chaining
239
+ * @example
240
+ * ```typescript
241
+ * const builder = univerAPI.newDataValidation();
242
+ * const rule = builder.requireNumberEqualTo(10).build();
243
+ * ```
174
244
  */
175
- requireNumberEqualTo(e, t) {
176
- return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = d.EQUAL, this._rule.type = t ? o.WHOLE : o.DECIMAL, this;
245
+ requireNumberEqualTo(num, isInteger) {
246
+ return this._rule.formula1 = `${num}`, this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.EQUAL, this._rule.type = isInteger ? DataValidationType.WHOLE : DataValidationType.DECIMAL, this;
177
247
  }
178
248
  /**
179
- * Requires the user to enter a number that is greater than a specific value, which can be an integer or a decimal.
180
- * Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.
181
- *
182
- * @param num The number to which the entered number should be greater.
183
- * @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.
184
- * @return The current instance of the FDataValidationBuilder class to allow for method chaining.
249
+ * Requires the user to enter a number that is greater than a specific value, which can be an integer or a decimal
250
+ * @param {number} num - The number to which the entered number should be greater
251
+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer
252
+ * @returns {FDataValidationBuilder} The current instance for method chaining
253
+ * @example
254
+ * ```typescript
255
+ * const builder = univerAPI.newDataValidation();
256
+ * const rule = builder.requireNumberGreaterThan(10).build();
257
+ * ```
185
258
  */
186
- requireNumberGreaterThan(e, t) {
187
- return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = d.GREATER_THAN, this._rule.type = t ? o.WHOLE : o.DECIMAL, this;
259
+ requireNumberGreaterThan(num, isInteger) {
260
+ return this._rule.formula1 = `${num}`, this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.GREATER_THAN, this._rule.type = isInteger ? DataValidationType.WHOLE : DataValidationType.DECIMAL, this;
188
261
  }
189
262
  /**
190
- * 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.
191
- * Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.
192
- *
193
- * @param num The number to which the entered number should be greater than or equal.
194
- * @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.
195
- * @return The current instance of the FDataValidationBuilder class to allow for method chaining.
263
+ * Requires the user to enter a number that is greater than or equal to a specific value, which can be an integer or a decimal
264
+ * @param {number} num - The number to which the entered number should be greater than or equal
265
+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer
266
+ * @returns {FDataValidationBuilder} The current instance for method chaining
267
+ * @example
268
+ * ```typescript
269
+ * const builder = univerAPI.newDataValidation();
270
+ * const rule = builder.requireNumberGreaterThanOrEqualTo(10).build();
271
+ * ```
196
272
  */
197
- requireNumberGreaterThanOrEqualTo(e, t) {
198
- return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = d.GREATER_THAN_OR_EQUAL, this._rule.type = t ? o.WHOLE : o.DECIMAL, this;
273
+ requireNumberGreaterThanOrEqualTo(num, isInteger) {
274
+ return this._rule.formula1 = `${num}`, this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.GREATER_THAN_OR_EQUAL, this._rule.type = isInteger ? DataValidationType.WHOLE : DataValidationType.DECIMAL, this;
199
275
  }
200
276
  /**
201
- * Requires the user to enter a number that is less than a specific value, which can be an integer or a decimal.
202
- * Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.
203
- *
204
- * @param num The number to which the entered number should be less.
205
- * @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.
206
- * @return The current instance of the FDataValidationBuilder class to allow for method chaining.
277
+ * Requires the user to enter a number that is less than a specific value, which can be an integer or a decimal
278
+ * @param {number} num - The number to which the entered number should be less
279
+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer
280
+ * @returns {FDataValidationBuilder} The current instance for method chaining
281
+ * @example
282
+ * ```typescript
283
+ * const builder = univerAPI.newDataValidation();
284
+ * const rule = builder.requireNumberLessThan(10).build();
285
+ * ```
207
286
  */
208
- requireNumberLessThan(e, t) {
209
- return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = d.LESS_THAN, this._rule.type = t ? o.WHOLE : o.DECIMAL, this;
287
+ requireNumberLessThan(num, isInteger) {
288
+ return this._rule.formula1 = `${num}`, this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.LESS_THAN, this._rule.type = isInteger ? DataValidationType.WHOLE : DataValidationType.DECIMAL, this;
210
289
  }
211
290
  /**
212
291
  * Sets the data validation rule to require a number less than or equal to a specified value
213
292
  * The specified value can be an integer or a decimal
214
- *
215
- * @param num The number to which the entered number should be less than or equal
216
- * @param isInteger Indicates whether the required number is an integer
217
- * @return The current instance of the DataValidationBuilder class, allowing for method chaining
293
+ * @param {number} num - The number to which the entered number should be less than or equal
294
+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer
295
+ * @returns {FDataValidationBuilder} The current instance for method chaining
296
+ * @example
297
+ * ```typescript
298
+ * const builder = univerAPI.newDataValidation();
299
+ * const rule = builder.requireNumberLessThanOrEqualTo(10).build();
300
+ * ```
218
301
  */
219
- requireNumberLessThanOrEqualTo(e, t) {
220
- return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = d.LESS_THAN_OR_EQUAL, this._rule.type = t ? o.WHOLE : o.DECIMAL, this;
302
+ requireNumberLessThanOrEqualTo(num, isInteger) {
303
+ return this._rule.formula1 = `${num}`, this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.LESS_THAN_OR_EQUAL, this._rule.type = isInteger ? DataValidationType.WHOLE : DataValidationType.DECIMAL, this;
221
304
  }
222
305
  /**
223
306
  * Sets a data validation rule that requires the user to enter a number outside a specified range
224
307
  * The specified range includes all integers and decimals
225
- *
226
- * @param start The starting point of the specified range
227
- * @param end The end point of the specified range
228
- * @param isInteger Optional parameter, indicating whether the number to be verified is an integer. Default value is false
229
- * @return An instance of the FDataValidationBuilder class, allowing for method chaining
308
+ * @param {number} start - The starting point of the specified range
309
+ * @param {number} end - The end point of the specified range
310
+ * @param {boolean} [isInteger] - Optional parameter, indicating whether the number to be verified is an integer
311
+ * @returns {FDataValidationBuilder} The current instance for method chaining
312
+ * @example
313
+ * ```typescript
314
+ * const builder = univerAPI.newDataValidation();
315
+ * const rule = builder.requireNumberNotBetween(1, 10).build();
316
+ * ```
230
317
  */
231
- requireNumberNotBetween(e, t, r) {
232
- return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = d.NOT_BETWEEN, this._rule.type = r ? o.WHOLE : o.DECIMAL, this;
318
+ requireNumberNotBetween(start, end, isInteger) {
319
+ return this._rule.formula1 = `${start}`, this._rule.formula2 = `${end}`, this._rule.operator = DataValidationOperator.NOT_BETWEEN, this._rule.type = isInteger ? DataValidationType.WHOLE : DataValidationType.DECIMAL, this;
233
320
  }
234
321
  /**
235
322
  * Creates a data validation rule that requires the user to enter a number that is not equal to a specific value
236
323
  * The specific value can be an integer or a decimal
237
- *
238
- * @param num The number to which the entered number should not be equal
239
- * @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal
240
- * @return The current instance of the FDataValidationBuilder class to allow for method chaining
324
+ * @param {number} num - The number to which the entered number should not be equal
325
+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer
326
+ * @returns {FDataValidationBuilder} The current instance for method chaining
327
+ * @example
328
+ * ```typescript
329
+ * const builder = univerAPI.newDataValidation();
330
+ * const rule = builder.requireNumberNotEqualTo(10).build();
331
+ * ```
241
332
  */
242
- requireNumberNotEqualTo(e, t) {
243
- return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = d.NOT_EQUAL, this._rule.type = t ? o.WHOLE : o.DECIMAL, this;
333
+ requireNumberNotEqualTo(num, isInteger) {
334
+ return this._rule.formula1 = `${num}`, this._rule.formula2 = void 0, this._rule.operator = DataValidationOperator.NOT_EQUAL, this._rule.type = isInteger ? DataValidationType.WHOLE : DataValidationType.DECIMAL, this;
244
335
  }
245
336
  /**
246
- * Sets a data validation rule that requires the user to enter a value from a list of specific values.
247
- * The list can be displayed in a dropdown, and the user can choose multiple values according to the settings.
248
- *
249
- * @param values An array containing the specific values that the user can enter.
250
- * @param multiple Optional parameter indicating whether the user can select multiple values. Default is false, meaning only one value can be selected.
251
- * @param showDropdown Optional parameter indicating whether to display the list in a dropdown. Default is true, meaning the list will be displayed as a dropdown.
252
- * @return An instance of the FDataValidationBuilder class, allowing for method chaining.
337
+ * Sets a data validation rule that requires the user to enter a value from a list of specific values
338
+ * The list can be displayed in a dropdown, and the user can choose multiple values according to the settings
339
+ * @param {string[]} values - An array containing the specific values that the user can enter
340
+ * @param {boolean} [multiple] - Optional parameter indicating whether the user can select multiple values
341
+ * @param {boolean} [showDropdown] - Optional parameter indicating whether to display the list in a dropdown
342
+ * @returns {FDataValidationBuilder} The current instance for method chaining
343
+ * @example
344
+ * ```typescript
345
+ * const builder = univerAPI.newDataValidation();
346
+ * const rule = builder.requireValueInList(['Yes', 'No']).build();
347
+ * ```
253
348
  */
254
- requireValueInList(e, t, r) {
255
- return this._rule.type = t ? o.LIST_MULTIPLE : o.LIST, this._rule.formula1 = e.join(","), this._rule.formula2 = void 0, this._rule.showDropDown = r != null ? r : !0, this;
349
+ requireValueInList(values, multiple, showDropdown) {
350
+ return this._rule.type = multiple ? DataValidationType.LIST_MULTIPLE : DataValidationType.LIST, this._rule.formula1 = values.join(","), this._rule.formula2 = void 0, this._rule.showDropDown = showDropdown != null ? showDropdown : !0, this;
256
351
  }
257
352
  /**
258
- * Sets a data validation rule that requires the user to enter a value within a specific range.
259
- * The range is defined by an FRange object, which contains the unit ID, sheet name, and cell range.
260
- *
261
- * @param range An FRange object representing the range of values that the user can enter.
262
- * @param multiple Optional parameter indicating whether the user can select multiple values. Default is false, meaning only one value can be selected.
263
- * @param showDropdown Optional parameter indicating whether to display the list in a dropdown. Default is true, meaning the list will be displayed as a dropdown.
264
- * @return The current instance of the FDataValidationBuilder class to allow for method chaining.
353
+ * Sets a data validation rule that requires the user to enter a value within a specific range
354
+ * The range is defined by an FRange object, which contains the unit ID, sheet name, and cell range
355
+ * @param {FRange} range - An FRange object representing the range of values that the user can enter
356
+ * @param {boolean} [multiple] - Optional parameter indicating whether the user can select multiple values
357
+ * @param {boolean} [showDropdown] - Optional parameter indicating whether to display the list in a dropdown
358
+ * @returns {FDataValidationBuilder} The current instance for method chaining
359
+ * @example
360
+ * ```typescript
361
+ * const builder = univerAPI.newDataValidation();
362
+ * const range = FRange.create('Sheet1', 'B1:B10');
363
+ * const rule = builder.requireValueInRange(range).build();
364
+ * ```
265
365
  */
266
- requireValueInRange(e, t, r) {
267
- return this._rule.type = t ? o.LIST_MULTIPLE : o.LIST, this._rule.formula1 = `=${P({
268
- unitId: e.getUnitId(),
269
- sheetName: e.getSheetName(),
270
- range: e.getRange()
271
- })}`, this._rule.formula2 = void 0, this._rule.showDropDown = r != null ? r : !0, this;
366
+ requireValueInRange(range, multiple, showDropdown) {
367
+ return this._rule.type = multiple ? DataValidationType.LIST_MULTIPLE : DataValidationType.LIST, this._rule.formula1 = `=${serializeRangeToRefString({
368
+ unitId: range.getUnitId(),
369
+ sheetName: range.getSheetName(),
370
+ range: range.getRange()
371
+ })}`, this._rule.formula2 = void 0, this._rule.showDropDown = showDropdown != null ? showDropdown : !0, this;
272
372
  }
273
373
  /**
274
- * Sets whether to allow invalid data and configures the error style for data validation.
275
- * If invalid data is not allowed, the error style will be set to STOP, indicating that data entry must stop upon encountering an error.
276
- * If invalid data is allowed, the error style will be set to WARNING, indicating that a warning will be displayed when invalid data is entered, but data entry can continue.
277
- *
278
- * @param allowInvalidData A boolean value indicating whether to allow invalid data.
279
- * @return The current instance of the FDataValidationBuilder class to allow for method chaining.
374
+ * Sets whether to allow invalid data and configures the error style
375
+ * If invalid data is not allowed, the error style will be set to STOP, indicating that data entry must stop upon encountering an error
376
+ * If invalid data is allowed, the error style will be set to WARNING, indicating that a warning will be displayed when invalid data is entered, but data entry can continue
377
+ * @param {boolean} allowInvalidData - Whether to allow invalid data
378
+ * @returns {FDataValidationBuilder} The current instance for method chaining
379
+ * @example
380
+ * ```typescript
381
+ * const builder = univerAPI.newDataValidation();
382
+ * const rule = builder.setAllowInvalid(true).build();
383
+ * ```
280
384
  */
281
- setAllowInvalid(e) {
282
- return this._rule.errorStyle = e ? w.WARNING : w.STOP, this;
385
+ setAllowInvalid(allowInvalidData) {
386
+ return this._rule.errorStyle = allowInvalidData ? DataValidationErrorStyle.WARNING : DataValidationErrorStyle.STOP, this;
283
387
  }
284
388
  /**
285
- * Sets the help text and enables the display of error messages for data validation.
286
- * This method allows you to set a custom help text that will be displayed when the user enters invalid data.
287
- *
288
- * @param helpText The text to display as help information.
289
- * @return The current instance of the FDataValidationBuilder class to allow for method chaining.
389
+ * Sets whether to allow blank values
390
+ * @param {boolean} allowBlank - Whether to allow blank values
391
+ * @returns {FDataValidationBuilder} The current instance for method chaining
392
+ * @example
393
+ * ```typescript
394
+ * const builder = univerAPI.newDataValidation();
395
+ * const rule = builder.setAllowBlank(true).build();
396
+ * ```
290
397
  */
291
- setHelpText(e) {
292
- return this._rule.error = e, this._rule.showErrorMessage = !0, this;
398
+ setAllowBlank(allowBlank) {
399
+ return this._rule.allowBlank = allowBlank, this;
293
400
  }
294
401
  /**
295
- * Sets the criteria values for data validation.
296
- * This method is used to configure the validation rules based on specific criteria values.
297
- *
298
- * @param type The type of data validation.
299
- * @param values An array containing the criteria values.
300
- * The array should have three elements: [operator, formula1, formula2].
301
- * operator is a DataValidationOperator enum value, formula1 is the first formula, and formula2 is the second formula.
302
- * @return The current instance of the FDataValidationBuilder class, allowing for method chaining.
402
+ * Sets the options for the data validation rule
403
+ * @param {Partial<IDataValidationRuleOptions>} options - The options to set for the data validation rule
404
+ * @returns {FDataValidationBuilder} The current instance for method chaining
405
+ * @example
406
+ * ```typescript
407
+ * const builder = univerAPI.newDataValidation();
408
+ * const rule = builder.setOptions({
409
+ * allowBlank: true,
410
+ * showErrorMessage: true,
411
+ * error: 'Please enter a valid value'
412
+ * }).build();
413
+ * ```
303
414
  */
304
- withCriteriaValues(e, t) {
305
- return this._rule.type = e, this._rule.operator = t[0], this._rule.formula1 = t[1], this._rule.formula2 = t[2], this;
415
+ setOptions(options) {
416
+ return Object.assign(this._rule, options), this;
306
417
  }
307
- setAllowBlank(e) {
308
- return this._rule.allowBlank = e, this;
309
- }
310
- /**
311
- * Sets the options for the data validation rule.
312
- * For details of options, please refer to https://univer.ai/typedoc/@univerjs/core/interfaces/IDataValidationRuleOptions
313
- *
314
- * @param options The options to set for the data validation rule.
315
- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
316
- */
317
- setOptions(e) {
318
- return Object.assign(this._rule, e), this;
319
- }
320
- }
321
- class m {
322
- constructor(e, t, r) {
323
- f(this, "rule");
324
- f(this, "_worksheet");
325
- f(this, "_injector");
326
- this._injector = r, this.rule = e, this._worksheet = t;
418
+ };
419
+ __name(_FDataValidationBuilder, "FDataValidationBuilder");
420
+ let FDataValidationBuilder = _FDataValidationBuilder;
421
+ const _FDataValidation = class _FDataValidation {
422
+ constructor(rule, worksheet, _injector) {
423
+ __publicField(this, "rule");
424
+ __publicField(this, "_worksheet");
425
+ __publicField(this, "_injector");
426
+ this._injector = _injector, this.rule = rule, this._worksheet = worksheet;
327
427
  }
328
428
  /**
329
- * Gets whether invalid data is allowed based on the error style value.
330
- *
331
- * @return true if invalid data is allowed, false otherwise.
429
+ * Gets whether invalid data is allowed based on the error style value
430
+ * @returns {boolean} true if invalid data is allowed, false otherwise
431
+ * @example
432
+ * ```typescript
433
+ * const dataValidation = univerAPI
434
+ * .getActiveWorkbook()
435
+ * .getActiveWorksheet()
436
+ * .getActiveRange()
437
+ * .getDataValidation();
438
+ * const allowsInvalid = dataValidation.getAllowInvalid();
439
+ * ```
332
440
  */
333
441
  getAllowInvalid() {
334
- return this.rule.errorStyle !== w.STOP;
442
+ return this.rule.errorStyle !== DataValidationErrorStyle.STOP;
335
443
  }
336
444
  /**
337
445
  * Gets the data validation type of the rule
338
- *
339
- * @returns The data validation type
446
+ * @returns {DataValidationType | string} The data validation type
447
+ * @example
448
+ * ```typescript
449
+ * const dataValidation = univerAPI
450
+ * .getActiveWorkbook()
451
+ * .getActiveWorksheet()
452
+ * .getActiveRange()
453
+ * .getDataValidation();
454
+ * const type = dataValidation.getCriteriaType();
455
+ * ```
340
456
  */
341
457
  getCriteriaType() {
342
458
  return this.rule.type;
343
459
  }
344
460
  /**
345
461
  * Gets the values used for criteria evaluation
346
- *
347
- * @returns An array containing the operator, formula1, and formula2 values
462
+ * @returns {[string | undefined, string | undefined, string | undefined]} An array containing the operator, formula1, and formula2 values
463
+ * @example
464
+ * ```typescript
465
+ * const dataValidation = univerAPI
466
+ * .getActiveWorkbook()
467
+ * .getActiveWorksheet()
468
+ * .getActiveRange()
469
+ * .getDataValidation();
470
+ * const [operator, formula1, formula2] = dataValidation.getCriteriaValues();
471
+ * ```
348
472
  */
349
473
  getCriteriaValues() {
350
474
  return [this.rule.operator, this.rule.formula1, this.rule.formula2];
351
475
  }
352
476
  /**
353
477
  * Gets the help text information, which is used to provide users with guidance and support
354
- *
355
- * @returns Returns the help text information. If there is no error message, it returns an undefined value.
478
+ * @returns {string | undefined} Returns the help text information. If there is no error message, it returns an undefined value
479
+ * @example
480
+ * ```typescript
481
+ * const dataValidation = univerAPI
482
+ * .getActiveWorkbook()
483
+ * .getActiveWorksheet()
484
+ * .getActiveRange()
485
+ * .getDataValidation();
486
+ * const helpText = dataValidation.getHelpText();
487
+ * ```
356
488
  */
357
489
  getHelpText() {
358
490
  return this.rule.error;
359
491
  }
360
492
  /**
361
- * Creates a new instance of FDataValidationBuilder using the current rule object.
362
- * This method is useful for copying an existing data validation rule configuration.
363
- *
364
- * @return A new FDataValidationBuilder instance with the same rule configuration.
493
+ * Creates a new instance of FDataValidationBuilder using the current rule object
494
+ * @returns {FDataValidationBuilder} A new FDataValidationBuilder instance with the same rule configuration
495
+ * @example
496
+ * ```typescript
497
+ * const dataValidation = univerAPI
498
+ * .getActiveWorkbook()
499
+ * .getActiveWorksheet()
500
+ * .getActiveRange()
501
+ * .getDataValidation();
502
+ * const builder = dataValidation.copy();
503
+ * const newRule = builder.setAllowInvalid(true).build();
504
+ * ```
365
505
  */
366
506
  copy() {
367
- return new D(this.rule);
507
+ return new FDataValidationBuilder(this.rule);
368
508
  }
369
509
  /**
370
- * Gets whether the data validation rule is applied to the worksheet.
371
- *
372
- * @returns true if the rule is applied, false otherwise.
510
+ * Gets whether the data validation rule is applied to the worksheet
511
+ * @returns {boolean} true if the rule is applied, false otherwise
512
+ * @example
513
+ * ```typescript
514
+ * const dataValidation = univerAPI
515
+ * .getActiveWorkbook()
516
+ * .getActiveWorksheet()
517
+ * .getActiveRange()
518
+ * .getDataValidation();
519
+ * const isApplied = dataValidation.getApplied();
520
+ * ```
373
521
  */
374
522
  getApplied() {
375
523
  if (!this._worksheet)
376
524
  return !1;
377
- const t = this._injector.get(b).getRuleById(this._worksheet.getUnitId(), this._worksheet.getSheetId(), this.rule.uid);
378
- return !!(t && t.ranges.length);
525
+ const currentRule = this._injector.get(DataValidationModel).getRuleById(this._worksheet.getUnitId(), this._worksheet.getSheetId(), this.rule.uid);
526
+ return !!(currentRule && currentRule.ranges.length);
379
527
  }
380
528
  /**
381
- * Gets the ranges to which the data validation rule is applied.
382
- *
383
- * @returns An array of IRange objects representing the ranges to which the data validation rule is applied.
529
+ * Gets the ranges to which the data validation rule is applied
530
+ * @returns {FRange[]} An array of FRange objects representing the ranges to which the data validation rule is applied
531
+ * @example
532
+ * ```typescript
533
+ * const dataValidation = univerAPI
534
+ * .getActiveWorkbook()
535
+ * .getActiveWorksheet()
536
+ * .getActiveRange()
537
+ * .getDataValidation();
538
+ * const ranges = dataValidation.getRanges();
539
+ * ```
384
540
  */
385
541
  getRanges() {
386
542
  if (!this.getApplied())
387
543
  return [];
388
- const e = this._injector.get(H).getUnit(this._worksheet.getUnitId());
389
- return this.rule.ranges.map((t) => this._injector.createInstance(y, e, this._worksheet, t));
544
+ const workbook = this._injector.get(IUniverInstanceService).getUnit(this._worksheet.getUnitId());
545
+ return this.rule.ranges.map((range) => this._injector.createInstance(FRange, workbook, this._worksheet, range));
390
546
  }
391
547
  /**
392
- * Gets the title of the error message dialog box.
393
- *
394
- * @returns The title of the error message dialog box.
548
+ * Gets the unit ID of the worksheet
549
+ * @returns {string | undefined} The unit ID of the worksheet
550
+ * @example
551
+ * ```typescript
552
+ * const dataValidation = univerAPI
553
+ * .getActiveWorkbook()
554
+ * .getActiveWorksheet()
555
+ * .getActiveRange()
556
+ * .getDataValidation();
557
+ * const unitId = dataValidation.getUnitId();
558
+ * ```
395
559
  */
396
560
  getUnitId() {
397
- var e;
398
- return (e = this._worksheet) == null ? void 0 : e.getUnitId();
561
+ var _a;
562
+ return (_a = this._worksheet) == null ? void 0 : _a.getUnitId();
399
563
  }
400
564
  /**
401
- * Gets the sheetId of the worksheet.
402
- *
403
- * @returns The sheetId of the worksheet.
565
+ * Gets the sheet ID of the worksheet
566
+ * @returns {string | undefined} The sheet ID of the worksheet
567
+ * @example
568
+ * ```typescript
569
+ * const dataValidation = univerAPI
570
+ * .getActiveWorkbook()
571
+ * .getActiveWorksheet()
572
+ * .getActiveRange()
573
+ * .getDataValidation();
574
+ * const sheetId = dataValidation.getSheetId();
575
+ * ```
404
576
  */
405
577
  getSheetId() {
406
- var e;
407
- return (e = this._worksheet) == null ? void 0 : e.getSheetId();
578
+ var _a;
579
+ return (_a = this._worksheet) == null ? void 0 : _a.getSheetId();
408
580
  }
409
581
  /**
410
- * Set Criteria for the data validation rule.
411
- * @param type The type of data validation criteria.
412
- * @param values An array containing the operator, formula1, and formula2 values.
413
- * @returns true if the criteria is set successfully, false otherwise.
582
+ * Set Criteria for the data validation rule
583
+ * @param {DataValidationType} type - The type of data validation criteria
584
+ * @param {[DataValidationOperator, string, string]} values - An array containing the operator, formula1, and formula2 values
585
+ * @param {boolean} [allowBlank] - Whether to allow blank values
586
+ * @returns {FDataValidation} The current instance for method chaining
587
+ * @example
588
+ * ```typescript
589
+ * const dataValidation = univerAPI
590
+ * .getActiveWorkbook()
591
+ * .getActiveWorksheet()
592
+ * .getActiveRange()
593
+ * .getDataValidation();
594
+ * dataValidation.setCriteria(
595
+ * DataValidationType.DECIMAL,
596
+ * [DataValidationOperator.BETWEEN, '1', '10'],
597
+ * true
598
+ * );
599
+ * ```
414
600
  */
415
- setCriteria(e, t, r = !0) {
416
- if (this.getApplied() && !this._injector.get(p).syncExecuteCommand(U.id, {
601
+ setCriteria(type, values, allowBlank = !0) {
602
+ if (this.getApplied() && !this._injector.get(ICommandService).syncExecuteCommand(UpdateSheetDataValidationSettingCommand.id, {
417
603
  unitId: this.getUnitId(),
418
604
  subUnitId: this.getSheetId(),
419
605
  ruleId: this.rule.uid,
420
606
  setting: {
421
- operator: t[0],
422
- formula1: t[1],
423
- formula2: t[2],
607
+ operator: values[0],
608
+ formula1: values[1],
609
+ formula2: values[2],
424
610
  type: this.rule.type,
425
- allowBlank: r
611
+ allowBlank
426
612
  }
427
613
  }))
428
614
  throw new Error("setCriteria failed");
429
- return this.rule.operator = t[0], this.rule.formula1 = t[1], this.rule.formula2 = t[2], this.rule.type = e, this.rule.allowBlank = r, this;
615
+ return this.rule.operator = values[0], this.rule.formula1 = values[1], this.rule.formula2 = values[2], this.rule.type = type, this.rule.allowBlank = allowBlank, this;
430
616
  }
431
617
  /**
432
- * Set the options for the data validation rule.
433
- * For details of options, please refer to https://univer.ai/typedoc/@univerjs/core/interfaces/IDataValidationRuleOptions
434
- * @param options An object containing the options to set. `IDataValidationRuleOptions`
435
- * @returns true if the options are set successfully, false otherwise.
618
+ * Set the options for the data validation rule
619
+ * @param {Partial<IDataValidationRuleOptions>} options - The options to set for the data validation rule
620
+ * @returns {FDataValidation} The current instance for method chaining
621
+ * @example
622
+ * ```typescript
623
+ * const dataValidation = univerAPI
624
+ * .getActiveWorkbook()
625
+ * .getActiveWorksheet()
626
+ * .getActiveRange()
627
+ * .getDataValidation();
628
+ * dataValidation.setOptions({
629
+ * allowBlank: true,
630
+ * showErrorMessage: true,
631
+ * error: 'Please enter a valid value'
632
+ * });
633
+ * ```
436
634
  */
437
- setOptions(e) {
438
- if (this.getApplied() && !this._injector.get(p).syncExecuteCommand(v.id, {
635
+ setOptions(options) {
636
+ if (this.getApplied() && !this._injector.get(ICommandService).syncExecuteCommand(UpdateSheetDataValidationOptionsCommand.id, {
439
637
  unitId: this.getUnitId(),
440
638
  subUnitId: this.getSheetId(),
441
639
  ruleId: this.rule.uid,
442
640
  options: {
443
- ...F(this.rule),
444
- ...e
641
+ ...getRuleOptions(this.rule),
642
+ ...options
445
643
  }
446
644
  }))
447
645
  throw new Error("setOptions failed");
448
- return Object.assign(this.rule, e), this;
646
+ return Object.assign(this.rule, options), this;
449
647
  }
450
648
  /**
451
- * Set the ranges to the data validation rule.
452
- * @param ranges new ranges array.
453
- * @returns true if the ranges are set successfully, false otherwise.
649
+ * Set the ranges to the data validation rule
650
+ * @param {FRange[]} ranges - New ranges array
651
+ * @returns {FDataValidation} The current instance for method chaining
652
+ * @example
653
+ * ```typescript
654
+ * const dataValidation = univerAPI
655
+ * .getActiveWorkbook()
656
+ * .getActiveWorksheet()
657
+ * .getActiveRange()
658
+ * .getDataValidation();
659
+ * const range = FRange.create('Sheet1', 'A1:B10');
660
+ * dataValidation.setRanges([range]);
661
+ * ```
454
662
  */
455
- setRanges(e) {
456
- if (this.getApplied() && !this._injector.get(p).syncExecuteCommand(C.id, {
663
+ setRanges(ranges) {
664
+ if (this.getApplied() && !this._injector.get(ICommandService).syncExecuteCommand(UpdateSheetDataValidationRangeCommand.id, {
457
665
  unitId: this.getUnitId(),
458
666
  subUnitId: this.getSheetId(),
459
667
  ruleId: this.rule.uid,
460
- ranges: e.map((a) => a.getRange())
668
+ ranges: ranges.map((range) => range.getRange())
461
669
  }))
462
670
  throw new Error("setRanges failed");
463
- return this.rule.ranges = e.map((t) => t.getRange()), this;
671
+ return this.rule.ranges = ranges.map((range) => range.getRange()), this;
464
672
  }
465
673
  /**
466
- * Delete the data validation rule from the worksheet.
467
- * @returns true if the rule is deleted successfully, false otherwise.
674
+ * Delete the data validation rule from the worksheet
675
+ * @returns {boolean} true if the rule is deleted successfully, false otherwise
676
+ * @example
677
+ * ```typescript
678
+ * const dataValidation = univerAPI
679
+ * .getActiveWorkbook()
680
+ * .getActiveWorksheet()
681
+ * .getActiveRange()
682
+ * .getDataValidation();
683
+ * const isDeleted = dataValidation.delete();
684
+ * ```
468
685
  */
469
686
  delete() {
470
- return this.getApplied() ? this._injector.get(p).syncExecuteCommand(T.id, {
687
+ return this.getApplied() ? this._injector.get(ICommandService).syncExecuteCommand(RemoveSheetDataValidationCommand.id, {
471
688
  unitId: this.getUnitId(),
472
689
  subUnitId: this.getSheetId(),
473
690
  ruleId: this.rule.uid
474
691
  }) : !1;
475
692
  }
476
- }
477
- class G extends y {
478
- setDataValidation(e) {
479
- if (!e)
480
- return this._commandService.syncExecuteCommand(W.id, {
693
+ };
694
+ __name(_FDataValidation, "FDataValidation");
695
+ let FDataValidation = _FDataValidation;
696
+ const _FRangeDataValidationMixin = class _FRangeDataValidationMixin extends FRange {
697
+ setDataValidation(rule) {
698
+ if (!rule)
699
+ return this._commandService.syncExecuteCommand(ClearRangeDataValidationCommand.id, {
481
700
  unitId: this._workbook.getUnitId(),
482
701
  subUnitId: this._worksheet.getSheetId(),
483
702
  ranges: [this._range]
484
703
  }), this;
485
- const t = {
704
+ const params = {
486
705
  unitId: this._workbook.getUnitId(),
487
706
  subUnitId: this._worksheet.getSheetId(),
488
707
  rule: {
489
- ...e.rule,
708
+ ...rule.rule,
490
709
  ranges: [this._range]
491
710
  }
492
711
  };
493
- return this._commandService.syncExecuteCommand(A.id, t), this;
712
+ return this._commandService.syncExecuteCommand(AddSheetDataValidationCommand.id, params), this;
494
713
  }
495
714
  getDataValidation() {
496
- const t = this._injector.get(S).getDataValidation(
715
+ const rule = this._injector.get(SheetsDataValidationValidatorService).getDataValidation(
497
716
  this._workbook.getUnitId(),
498
717
  this._worksheet.getSheetId(),
499
718
  [this._range]
500
719
  );
501
- return t && new m(t, this._worksheet, this._injector);
720
+ return rule && new FDataValidation(rule, this._worksheet, this._injector);
502
721
  }
503
722
  getDataValidations() {
504
- return this._injector.get(S).getDataValidations(
723
+ return this._injector.get(SheetsDataValidationValidatorService).getDataValidations(
505
724
  this._workbook.getUnitId(),
506
725
  this._worksheet.getSheetId(),
507
726
  [this._range]
508
- ).map((t) => new m(t, this._worksheet, this._injector));
727
+ ).map((rule) => new FDataValidation(rule, this._worksheet, this._injector));
509
728
  }
510
729
  async getValidatorStatus() {
511
- return this._injector.get(S).validatorRanges(
730
+ return this._injector.get(SheetsDataValidationValidatorService).validatorRanges(
512
731
  this._workbook.getUnitId(),
513
732
  this._worksheet.getSheetId(),
514
733
  [this._range]
515
734
  );
516
735
  }
517
- }
518
- y.extend(G);
519
- class Q extends N {
736
+ };
737
+ __name(_FRangeDataValidationMixin, "FRangeDataValidationMixin");
738
+ let FRangeDataValidationMixin = _FRangeDataValidationMixin;
739
+ FRange.extend(FRangeDataValidationMixin);
740
+ const _FUnvierDataValidationMixin = class _FUnvierDataValidationMixin extends FUniver {
741
+ // eslint-disable-next-line jsdoc/require-returns
520
742
  /**
521
743
  /**
522
- * @deparecated use `univerAPI.newDataValidation()` as instead.
744
+ * @deprecated use `univerAPI.newDataValidation()` as instead.
523
745
  */
524
746
  static newDataValidation() {
525
- return new D();
747
+ return new FDataValidationBuilder();
526
748
  }
749
+ /**
750
+ * Creates a new instance of FDataValidationBuilder
751
+ * @returns {FDataValidationBuilder} A new instance of the FDataValidationBuilder class
752
+ * @example
753
+ * ```ts
754
+ * const rule = FUnvier.newDataValidation();
755
+ * cell.setDataValidation(rule.requireValueInRange(range));
756
+ * ```
757
+ */
527
758
  newDataValidation() {
528
- return new D();
759
+ return new FDataValidationBuilder();
529
760
  }
761
+ /**
762
+ * @ignore
763
+ */
530
764
  // eslint-disable-next-line max-lines-per-function
531
- _initialize(e) {
532
- if (!e.has(V)) return;
533
- const t = e.get(V), r = e.get(p);
534
- this.disposeWithMe(t.ruleChange$.subscribe((a) => {
535
- const { unitId: i, subUnitId: n, rule: h, oldRule: u, type: s } = a, l = this.getSheetTarget(i, n);
536
- if (!l)
765
+ _initialize(injector) {
766
+ if (!injector.has(SheetDataValidationModel)) return;
767
+ const sheetDataValidationModel = injector.get(SheetDataValidationModel), commadnService = injector.get(ICommandService);
768
+ this.disposeWithMe(sheetDataValidationModel.ruleChange$.subscribe((ruleChange) => {
769
+ const { unitId, subUnitId, rule, oldRule, type } = ruleChange, target = this.getSheetTarget(unitId, subUnitId);
770
+ if (!target)
537
771
  return;
538
- const { workbook: I, worksheet: k } = l, E = new m(h, k.getSheet(), this._injector);
772
+ const { workbook, worksheet } = target, fRule = new FDataValidation(rule, worksheet.getSheet(), this._injector);
539
773
  this.fireEvent(this.Event.SheetDataValidationChanged, {
540
- origin: a,
541
- worksheet: k,
542
- workbook: I,
543
- changeType: s,
544
- oldRule: u,
545
- rule: E
774
+ origin: ruleChange,
775
+ worksheet,
776
+ workbook,
777
+ changeType: type,
778
+ oldRule,
779
+ rule: fRule
546
780
  });
547
- })), this.disposeWithMe(t.validStatusChange$.subscribe((a) => {
548
- const { unitId: i, subUnitId: n, ruleId: h, status: u, row: s, col: l } = a, I = this.getSheetTarget(i, n);
549
- if (!I)
781
+ })), this.disposeWithMe(sheetDataValidationModel.validStatusChange$.subscribe((statusChange) => {
782
+ const { unitId, subUnitId, ruleId, status, row, col } = statusChange, target = this.getSheetTarget(unitId, subUnitId);
783
+ if (!target)
550
784
  return;
551
- const { workbook: k, worksheet: E } = I, L = E.getDataValidation(h);
552
- L && this.fireEvent(this.Event.SheetDataValidatorStatusChanged, {
553
- workbook: k,
554
- worksheet: E,
555
- row: s,
556
- column: l,
557
- rule: L,
558
- status: u
785
+ const { workbook, worksheet } = target, rule = worksheet.getDataValidation(ruleId);
786
+ rule && this.fireEvent(this.Event.SheetDataValidatorStatusChanged, {
787
+ workbook,
788
+ worksheet,
789
+ row,
790
+ column: col,
791
+ rule,
792
+ status
559
793
  });
560
- })), this.disposeWithMe(r.beforeCommandExecuted((a) => {
561
- switch (a.id) {
562
- case A.id: {
563
- const i = a.params, n = this.getSheetTarget(i.unitId, i.subUnitId);
564
- if (!n)
794
+ })), this.disposeWithMe(commadnService.beforeCommandExecuted((commandInfo) => {
795
+ switch (commandInfo.id) {
796
+ case AddSheetDataValidationCommand.id: {
797
+ const params = commandInfo.params, target = this.getSheetTarget(params.unitId, params.subUnitId);
798
+ if (!target)
565
799
  return;
566
- const { workbook: h, worksheet: u } = n, s = {
567
- worksheet: u,
568
- workbook: h,
569
- rule: i.rule
800
+ const { workbook, worksheet } = target, eventParams = {
801
+ worksheet,
802
+ workbook,
803
+ rule: params.rule
570
804
  };
571
- if (this.fireEvent(this.Event.BeforeSheetDataValidationAdd, s), s.cancel)
572
- throw new _();
805
+ if (this.fireEvent(this.Event.BeforeSheetDataValidationAdd, eventParams), eventParams.cancel)
806
+ throw new CanceledError();
573
807
  break;
574
808
  }
575
- case U.id: {
576
- const i = a.params, n = this.getSheetTarget(i.unitId, i.subUnitId);
577
- if (!n)
809
+ case UpdateSheetDataValidationSettingCommand.id: {
810
+ const params = commandInfo.params, target = this.getSheetTarget(params.unitId, params.subUnitId);
811
+ if (!target)
578
812
  return;
579
- const { workbook: h, worksheet: u } = n, s = u.getDataValidation(i.ruleId);
580
- if (!s)
813
+ const { workbook, worksheet } = target, rule = worksheet.getDataValidation(params.ruleId);
814
+ if (!rule)
581
815
  return;
582
- const l = {
583
- worksheet: u,
584
- workbook: h,
585
- rule: s,
586
- ruleId: i.ruleId,
587
- newCriteria: i.setting
816
+ const eventParams = {
817
+ worksheet,
818
+ workbook,
819
+ rule,
820
+ ruleId: params.ruleId,
821
+ newCriteria: params.setting
588
822
  };
589
- if (this.fireEvent(this.Event.BeforeSheetDataValidationCriteriaUpdate, l), l.cancel)
590
- throw new _();
823
+ if (this.fireEvent(this.Event.BeforeSheetDataValidationCriteriaUpdate, eventParams), eventParams.cancel)
824
+ throw new CanceledError();
591
825
  break;
592
826
  }
593
- case C.id: {
594
- const i = a.params, n = this.getSheetTarget(i.unitId, i.subUnitId);
595
- if (!n)
827
+ case UpdateSheetDataValidationRangeCommand.id: {
828
+ const params = commandInfo.params, target = this.getSheetTarget(params.unitId, params.subUnitId);
829
+ if (!target)
596
830
  return;
597
- const { workbook: h, worksheet: u } = n, s = u.getDataValidation(i.ruleId);
598
- if (!s)
831
+ const { workbook, worksheet } = target, rule = worksheet.getDataValidation(params.ruleId);
832
+ if (!rule)
599
833
  return;
600
- const l = {
601
- worksheet: u,
602
- workbook: h,
603
- rule: s,
604
- ruleId: i.ruleId,
605
- newRanges: i.ranges
834
+ const eventParams = {
835
+ worksheet,
836
+ workbook,
837
+ rule,
838
+ ruleId: params.ruleId,
839
+ newRanges: params.ranges
606
840
  };
607
- if (this.fireEvent(this.Event.BeforeSheetDataValidationRangeUpdate, l), l.cancel)
608
- throw new _();
841
+ if (this.fireEvent(this.Event.BeforeSheetDataValidationRangeUpdate, eventParams), eventParams.cancel)
842
+ throw new CanceledError();
609
843
  break;
610
844
  }
611
- case v.id: {
612
- const i = a.params, n = this.getSheetTarget(i.unitId, i.subUnitId);
613
- if (!n)
845
+ case UpdateSheetDataValidationOptionsCommand.id: {
846
+ const params = commandInfo.params, target = this.getSheetTarget(params.unitId, params.subUnitId);
847
+ if (!target)
614
848
  return;
615
- const { workbook: h, worksheet: u } = n, s = u.getDataValidation(i.ruleId);
616
- if (!s)
849
+ const { workbook, worksheet } = target, rule = worksheet.getDataValidation(params.ruleId);
850
+ if (!rule)
617
851
  return;
618
- const l = {
619
- worksheet: u,
620
- workbook: h,
621
- rule: s,
622
- ruleId: i.ruleId,
623
- newOptions: i.options
852
+ const eventParams = {
853
+ worksheet,
854
+ workbook,
855
+ rule,
856
+ ruleId: params.ruleId,
857
+ newOptions: params.options
624
858
  };
625
- if (this.fireEvent(this.Event.BeforeSheetDataValidationOptionsUpdate, l), l.cancel)
626
- throw new _();
859
+ if (this.fireEvent(this.Event.BeforeSheetDataValidationOptionsUpdate, eventParams), eventParams.cancel)
860
+ throw new CanceledError();
627
861
  break;
628
862
  }
629
- case T.id: {
630
- const i = a.params, n = this.getSheetTarget(i.unitId, i.subUnitId);
631
- if (!n)
863
+ case RemoveSheetDataValidationCommand.id: {
864
+ const params = commandInfo.params, target = this.getSheetTarget(params.unitId, params.subUnitId);
865
+ if (!target)
632
866
  return;
633
- const { workbook: h, worksheet: u } = n, s = u.getDataValidation(i.ruleId);
634
- if (!s)
867
+ const { workbook, worksheet } = target, rule = worksheet.getDataValidation(params.ruleId);
868
+ if (!rule)
635
869
  return;
636
- const l = {
637
- worksheet: u,
638
- workbook: h,
639
- rule: s,
640
- ruleId: i.ruleId
870
+ const eventParams = {
871
+ worksheet,
872
+ workbook,
873
+ rule,
874
+ ruleId: params.ruleId
641
875
  };
642
- if (this.fireEvent(this.Event.BeforeSheetDataValidationDelete, l), l.cancel)
643
- throw new _();
876
+ if (this.fireEvent(this.Event.BeforeSheetDataValidationDelete, eventParams), eventParams.cancel)
877
+ throw new CanceledError();
644
878
  break;
645
879
  }
646
- case O.id: {
647
- const i = a.params, n = this.getSheetTarget(i.unitId, i.subUnitId);
648
- if (!n)
880
+ case RemoveSheetAllDataValidationCommand.id: {
881
+ const params = commandInfo.params, target = this.getSheetTarget(params.unitId, params.subUnitId);
882
+ if (!target)
649
883
  return;
650
- const { workbook: h, worksheet: u } = n, s = {
651
- worksheet: u,
652
- workbook: h,
653
- rules: u.getDataValidations()
884
+ const { workbook, worksheet } = target, eventParams = {
885
+ worksheet,
886
+ workbook,
887
+ rules: worksheet.getDataValidations()
654
888
  };
655
- if (this.fireEvent(this.Event.BeforeSheetDataValidationDeleteAll, s), s.cancel)
656
- throw new _();
889
+ if (this.fireEvent(this.Event.BeforeSheetDataValidationDeleteAll, eventParams), eventParams.cancel)
890
+ throw new CanceledError();
657
891
  break;
658
892
  }
659
893
  }
660
894
  }));
661
895
  }
662
- }
663
- N.extend(Q);
664
- class z extends M {
896
+ };
897
+ __name(_FUnvierDataValidationMixin, "FUnvierDataValidationMixin");
898
+ let FUnvierDataValidationMixin = _FUnvierDataValidationMixin;
899
+ FUniver.extend(FUnvierDataValidationMixin);
900
+ const _FWorkbookDataValidationMixin = class _FWorkbookDataValidationMixin extends FWorkbook {
665
901
  _initialize() {
666
902
  Object.defineProperty(this, "_dataValidationModel", {
667
903
  get() {
668
- return this._injector.get(V);
904
+ return this._injector.get(SheetDataValidationModel);
669
905
  }
670
906
  });
671
907
  }
672
908
  getValidatorStatus() {
673
- return this._injector.get(S).validatorWorkbook(this._workbook.getUnitId());
909
+ return this._injector.get(SheetsDataValidationValidatorService).validatorWorkbook(this._workbook.getUnitId());
674
910
  }
675
911
  // region DataValidationHooks
676
- onDataValidationChange(e) {
677
- return g(this._dataValidationModel.ruleChange$.pipe(R((t) => t.unitId === this._workbook.getUnitId())).subscribe(e));
912
+ onDataValidationChange(callback) {
913
+ return toDisposable(this._dataValidationModel.ruleChange$.pipe(filter((change) => change.unitId === this._workbook.getUnitId())).subscribe(callback));
678
914
  }
679
- onDataValidationStatusChange(e) {
680
- return g(this._dataValidationModel.validStatusChange$.pipe(R((t) => t.unitId === this._workbook.getUnitId())).subscribe(e));
915
+ onDataValidationStatusChange(callback) {
916
+ return toDisposable(this._dataValidationModel.validStatusChange$.pipe(filter((change) => change.unitId === this._workbook.getUnitId())).subscribe(callback));
681
917
  }
682
- onBeforeAddDataValidation(e) {
683
- return g(this._commandService.beforeCommandExecuted((t, r) => {
684
- const a = t.params;
685
- if (t.id === A.id) {
686
- if (a.unitId !== this._workbook.getUnitId())
918
+ onBeforeAddDataValidation(callback) {
919
+ return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {
920
+ const params = commandInfo.params;
921
+ if (commandInfo.id === AddSheetDataValidationCommand.id) {
922
+ if (params.unitId !== this._workbook.getUnitId())
687
923
  return;
688
- if (e(a, r) === !1)
924
+ if (callback(params, options) === !1)
689
925
  throw new Error("Command is stopped by the hook onBeforeAddDataValidation");
690
926
  }
691
927
  }));
692
928
  }
693
- onBeforeUpdateDataValidationCriteria(e) {
694
- return g(this._commandService.beforeCommandExecuted((t, r) => {
695
- const a = t.params;
696
- if (t.id === U.id) {
697
- if (a.unitId !== this._workbook.getUnitId())
929
+ onBeforeUpdateDataValidationCriteria(callback) {
930
+ return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {
931
+ const params = commandInfo.params;
932
+ if (commandInfo.id === UpdateSheetDataValidationSettingCommand.id) {
933
+ if (params.unitId !== this._workbook.getUnitId())
698
934
  return;
699
- if (e(a, r) === !1)
935
+ if (callback(params, options) === !1)
700
936
  throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationCriteria");
701
937
  }
702
938
  }));
703
939
  }
704
- onBeforeUpdateDataValidationRange(e) {
705
- return g(this._commandService.beforeCommandExecuted((t, r) => {
706
- const a = t.params;
707
- if (t.id === C.id) {
708
- if (a.unitId !== this._workbook.getUnitId())
940
+ onBeforeUpdateDataValidationRange(callback) {
941
+ return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {
942
+ const params = commandInfo.params;
943
+ if (commandInfo.id === UpdateSheetDataValidationRangeCommand.id) {
944
+ if (params.unitId !== this._workbook.getUnitId())
709
945
  return;
710
- if (e(a, r) === !1)
946
+ if (callback(params, options) === !1)
711
947
  throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationRange");
712
948
  }
713
949
  }));
714
950
  }
715
- onBeforeUpdateDataValidationOptions(e) {
716
- return g(this._commandService.beforeCommandExecuted((t, r) => {
717
- const a = t.params;
718
- if (t.id === v.id) {
719
- if (a.unitId !== this._workbook.getUnitId())
951
+ onBeforeUpdateDataValidationOptions(callback) {
952
+ return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {
953
+ const params = commandInfo.params;
954
+ if (commandInfo.id === UpdateSheetDataValidationOptionsCommand.id) {
955
+ if (params.unitId !== this._workbook.getUnitId())
720
956
  return;
721
- if (e(a, r) === !1)
957
+ if (callback(params, options) === !1)
722
958
  throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationOptions");
723
959
  }
724
960
  }));
725
961
  }
726
- onBeforeDeleteDataValidation(e) {
727
- return g(this._commandService.beforeCommandExecuted((t, r) => {
728
- const a = t.params;
729
- if (t.id === T.id) {
730
- if (a.unitId !== this._workbook.getUnitId())
962
+ onBeforeDeleteDataValidation(callback) {
963
+ return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {
964
+ const params = commandInfo.params;
965
+ if (commandInfo.id === RemoveSheetDataValidationCommand.id) {
966
+ if (params.unitId !== this._workbook.getUnitId())
731
967
  return;
732
- if (e(a, r) === !1)
968
+ if (callback(params, options) === !1)
733
969
  throw new Error("Command is stopped by the hook onBeforeDeleteDataValidation");
734
970
  }
735
971
  }));
736
972
  }
737
- onBeforeDeleteAllDataValidation(e) {
738
- return g(this._commandService.beforeCommandExecuted((t, r) => {
739
- const a = t.params;
740
- if (t.id === O.id) {
741
- if (a.unitId !== this._workbook.getUnitId())
973
+ onBeforeDeleteAllDataValidation(callback) {
974
+ return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {
975
+ const params = commandInfo.params;
976
+ if (commandInfo.id === RemoveSheetAllDataValidationCommand.id) {
977
+ if (params.unitId !== this._workbook.getUnitId())
742
978
  return;
743
- if (e(a, r) === !1)
979
+ if (callback(params, options) === !1)
744
980
  throw new Error("Command is stopped by the hook onBeforeDeleteAllDataValidation");
745
981
  }
746
982
  }));
747
983
  }
748
- }
749
- M.extend(z);
750
- class K extends x {
984
+ };
985
+ __name(_FWorkbookDataValidationMixin, "FWorkbookDataValidationMixin");
986
+ let FWorkbookDataValidationMixin = _FWorkbookDataValidationMixin;
987
+ FWorkbook.extend(FWorkbookDataValidationMixin);
988
+ const _FWorksheetDataValidationMixin = class _FWorksheetDataValidationMixin extends FWorksheet {
751
989
  getDataValidations() {
752
- return this._injector.get(b).getRules(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((t) => new m(t, this._worksheet, this._injector));
990
+ return this._injector.get(DataValidationModel).getRules(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((rule) => new FDataValidation(rule, this._worksheet, this._injector));
753
991
  }
754
992
  getValidatorStatus() {
755
- return this._injector.get(S).validatorWorksheet(
993
+ return this._injector.get(SheetsDataValidationValidatorService).validatorWorksheet(
756
994
  this._workbook.getUnitId(),
757
995
  this._worksheet.getSheetId()
758
996
  );
759
997
  }
760
- getDataValidation(e) {
761
- const r = this._injector.get(b).getRuleById(this._workbook.getUnitId(), this._worksheet.getSheetId(), e);
762
- return r ? new m(r, this._worksheet, this._injector) : null;
998
+ getValidatorStatusAsync() {
999
+ return this.getValidatorStatus();
1000
+ }
1001
+ getDataValidation(ruleId) {
1002
+ const rule = this._injector.get(DataValidationModel).getRuleById(this._workbook.getUnitId(), this._worksheet.getSheetId(), ruleId);
1003
+ return rule ? new FDataValidation(rule, this._worksheet, this._injector) : null;
763
1004
  }
764
- }
765
- x.extend(K);
766
- class X {
1005
+ };
1006
+ __name(_FWorksheetDataValidationMixin, "FWorksheetDataValidationMixin");
1007
+ let FWorksheetDataValidationMixin = _FWorksheetDataValidationMixin;
1008
+ FWorksheet.extend(FWorksheetDataValidationMixin);
1009
+ const _FDataValidationEvent = class _FDataValidationEvent {
767
1010
  get SheetDataValidationChanged() {
768
1011
  return "SheetDataValidationChanged";
769
1012
  }
@@ -788,9 +1031,11 @@ class X {
788
1031
  get BeforeSheetDataValidationOptionsUpdate() {
789
1032
  return "BeforeSheetDataValidationOptionsUpdate";
790
1033
  }
791
- }
792
- $.extend(X);
1034
+ };
1035
+ __name(_FDataValidationEvent, "FDataValidationEvent");
1036
+ let FDataValidationEvent = _FDataValidationEvent;
1037
+ FEventName.extend(FDataValidationEvent);
793
1038
  export {
794
- m as FDataValidation,
795
- D as FDataValidationBuilder
1039
+ FDataValidation,
1040
+ FDataValidationBuilder
796
1041
  };