@univerjs/sheets-data-validation 0.6.2 → 0.6.3

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.
@@ -173,12 +173,15 @@ export declare class FDataValidation {
173
173
  * ```typescript
174
174
  * const fWorkbook = univerAPI.getActiveWorkbook();
175
175
  * const fWorksheet = fWorkbook.getActiveSheet();
176
+ *
177
+ * // Create a new data validation rule that requires a number equal to 20 for the range A1:B10
176
178
  * const fRange = fWorksheet.getRange('A1:B10');
177
179
  * const rule = univerAPI.newDataValidation()
178
180
  * .requireNumberEqualTo(20)
179
181
  * .build();
180
182
  * fRange.setDataValidation(rule);
181
183
  *
184
+ * // Change the rule criteria to require a number between 1 and 10
182
185
  * fRange.getDataValidation().setCriteria(
183
186
  * univerAPI.Enum.DataValidationType.DECIMAL,
184
187
  * [univerAPI.Enum.DataValidationOperator.BETWEEN, '1', '10']
@@ -194,12 +197,15 @@ export declare class FDataValidation {
194
197
  * ```typescript
195
198
  * const fWorkbook = univerAPI.getActiveWorkbook();
196
199
  * const fWorksheet = fWorkbook.getActiveSheet();
200
+ *
201
+ * // Create a new data validation rule that requires a number equal to 20 for the range A1:B10
197
202
  * const fRange = fWorksheet.getRange('A1:B10');
198
203
  * const rule = univerAPI.newDataValidation()
199
204
  * .requireNumberEqualTo(20)
200
205
  * .build();
201
206
  * fRange.setDataValidation(rule);
202
207
  *
208
+ * // Supplement the rule with additional options
203
209
  * fRange.getDataValidation().setOptions({
204
210
  * allowBlank: true,
205
211
  * showErrorMessage: true,
@@ -216,12 +222,15 @@ export declare class FDataValidation {
216
222
  * ```typescript
217
223
  * const fWorkbook = univerAPI.getActiveWorkbook();
218
224
  * const fWorksheet = fWorkbook.getActiveSheet();
225
+ *
226
+ * // Create a new data validation rule that requires a number equal to 20 for the range A1:B10
219
227
  * const fRange = fWorksheet.getRange('A1:B10');
220
228
  * const rule = univerAPI.newDataValidation()
221
229
  * .requireNumberEqualTo(20)
222
230
  * .build();
223
231
  * fRange.setDataValidation(rule);
224
232
  *
233
+ * // Change the range to C1:D10
225
234
  * const newRuleRange = fWorksheet.getRange('C1:D10');
226
235
  * fRange.getDataValidation().setRanges([newRuleRange]);
227
236
  * ```
@@ -234,12 +243,15 @@ export declare class FDataValidation {
234
243
  * ```typescript
235
244
  * const fWorkbook = univerAPI.getActiveWorkbook();
236
245
  * const fWorksheet = fWorkbook.getActiveSheet();
246
+ *
247
+ * // Create a new data validation rule that requires a number equal to 20 for the range A1:B10
237
248
  * const fRange = fWorksheet.getRange('A1:B10');
238
249
  * const rule = univerAPI.newDataValidation()
239
250
  * .requireNumberEqualTo(20)
240
251
  * .build();
241
252
  * fRange.setDataValidation(rule);
242
253
  *
254
+ * // Delete the data validation rule
243
255
  * fRange.getDataValidation().delete();
244
256
  * ```
245
257
  */
@@ -13,6 +13,8 @@ export interface IFRangeDataValidationMixin {
13
13
  * ```ts
14
14
  * const fWorkbook = univerAPI.getActiveWorkbook();
15
15
  * const fWorksheet = fWorkbook.getActiveSheet();
16
+ *
17
+ * // Create a data validation rule that requires a number between 1 and 10 for the range A1:B10
16
18
  * const fRange = fWorksheet.getRange('A1:B10');
17
19
  * const rule = univerAPI.newDataValidation()
18
20
  * .requireNumberBetween(1, 10)
@@ -33,6 +35,8 @@ export interface IFRangeDataValidationMixin {
33
35
  * ```ts
34
36
  * const fWorkbook = univerAPI.getActiveWorkbook();
35
37
  * const fWorksheet = fWorkbook.getActiveSheet();
38
+ *
39
+ * // Create a data validation rule that requires a number equal to 20 for the range A1:B10
36
40
  * const fRange = fWorksheet.getRange('A1:B10');
37
41
  * const rule = univerAPI.newDataValidation()
38
42
  * .requireNumberEqualTo(20)
@@ -40,10 +44,13 @@ export interface IFRangeDataValidationMixin {
40
44
  * fRange.setDataValidation(rule);
41
45
  * console.log(fRange.getDataValidation().getCriteriaValues());
42
46
  *
47
+ * // Change the rule criteria to require a number between 1 and 10
43
48
  * fRange.getDataValidation().setCriteria(
44
49
  * univerAPI.Enum.DataValidationType.DECIMAL,
45
50
  * [univerAPI.Enum.DataValidationOperator.BETWEEN, '1', '10']
46
51
  * );
52
+ *
53
+ * // Print the new rule criteria values
47
54
  * console.log(fRange.getDataValidation().getCriteriaValues());
48
55
  * ```
49
56
  */
@@ -55,18 +62,22 @@ export interface IFRangeDataValidationMixin {
55
62
  * ```ts
56
63
  * const fWorkbook = univerAPI.getActiveWorkbook();
57
64
  * const fWorksheet = fWorkbook.getActiveSheet();
65
+ *
66
+ * // Create a data validation rule that requires a number equal to 20 for the range A1:B10
58
67
  * const fRange1 = fWorksheet.getRange('A1:B10');
59
68
  * const rule1 = univerAPI.newDataValidation()
60
69
  * .requireNumberEqualTo(20)
61
70
  * .build();
62
71
  * fRange1.setDataValidation(rule1);
63
72
  *
73
+ * // Create a data validation rule that requires a number between 1 and 10 for the range C1:D10
64
74
  * const fRange2 = fWorksheet.getRange('C1:D10');
65
75
  * const rule2 = univerAPI.newDataValidation()
66
76
  * .requireNumberBetween(1, 10)
67
77
  * .build();
68
78
  * fRange2.setDataValidation(rule2);
69
79
  *
80
+ * // Get all data validation rules in the range A1:D10
70
81
  * const range = fWorksheet.getRange('A1:D10');
71
82
  * const rules = range.getDataValidations();
72
83
  * console.log(rules.length); // 2
@@ -80,6 +91,8 @@ export interface IFRangeDataValidationMixin {
80
91
  * ```ts
81
92
  * const fWorkbook = univerAPI.getActiveWorkbook();
82
93
  * const fWorksheet = fWorkbook.getActiveSheet();
94
+ *
95
+ * // Set some values in the range A1:B10
83
96
  * const fRange = fWorksheet.getRange('A1:B10');
84
97
  * fRange.setValues([
85
98
  * [1, 2],
@@ -93,14 +106,18 @@ export interface IFRangeDataValidationMixin {
93
106
  * [17, 18],
94
107
  * [19, 20]
95
108
  * ]);
109
+ *
110
+ * // Create a data validation rule that requires a number between 1 and 10 for the range A1:B10
96
111
  * const rule = univerAPI.newDataValidation()
97
112
  * .requireNumberBetween(1, 10)
98
113
  * .build();
99
114
  * fRange.setDataValidation(rule);
100
115
  *
116
+ * // Get the validator status for the cell B2
101
117
  * const status = await fWorksheet.getRange('B2').getValidatorStatus();
102
118
  * console.log(status?.[0]?.[0]); // 'valid'
103
119
  *
120
+ * // Get the validator status for the cell B10
104
121
  * const status2 = await fWorksheet.getRange('B10').getValidatorStatus();
105
122
  * console.log(status2?.[0]?.[0]); // 'invalid'
106
123
  * ```
@@ -10,8 +10,20 @@ export interface IFUnvierDataValidationMixin {
10
10
  * @returns {FDataValidationBuilder} A new instance of the FDataValidationBuilder class
11
11
  * @example
12
12
  * ```ts
13
- * const rule = FUnvier.newDataValidation();
14
- * cell.setDataValidation(rule.requireValueInRange(range));
13
+ * const fWorkbook = univerAPI.getActiveWorkbook();
14
+ * const fWorksheet = fWorkbook.getActiveSheet();
15
+ *
16
+ * // Create a new data validation rule that requires a number between 1 and 10 fot the range A1:B10
17
+ * const fRange = fWorksheet.getRange('A1:B10');
18
+ * const rule = univerAPI.newDataValidation()
19
+ * .requireNumberBetween(1, 10)
20
+ * .setOptions({
21
+ * allowBlank: true,
22
+ * showErrorMessage: true,
23
+ * error: 'Please enter a number between 1 and 10'
24
+ * })
25
+ * .build();
26
+ * fRange.setDataValidation(rule);
15
27
  * ```
16
28
  */
17
29
  newDataValidation(): FDataValidationBuilder;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-data-validation",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "private": false,
5
5
  "description": "Data validation for Univer Sheets",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -54,19 +54,19 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@univerjs/protocol": "0.1.43",
57
- "@univerjs/core": "0.6.2",
58
- "@univerjs/engine-formula": "0.6.2",
59
- "@univerjs/data-validation": "0.6.2",
60
- "@univerjs/sheets": "0.6.2",
61
- "@univerjs/sheets-formula": "0.6.2"
57
+ "@univerjs/engine-formula": "0.6.3",
58
+ "@univerjs/core": "0.6.3",
59
+ "@univerjs/sheets": "0.6.3",
60
+ "@univerjs/data-validation": "0.6.3",
61
+ "@univerjs/sheets-formula": "0.6.3"
62
62
  },
63
63
  "devDependencies": {
64
64
  "less": "^4.2.2",
65
65
  "rxjs": "^7.8.1",
66
- "typescript": "^5.7.3",
66
+ "typescript": "^5.8.2",
67
67
  "vite": "^6.2.0",
68
68
  "vitest": "^3.0.7",
69
- "@univerjs-infra/shared": "0.6.2"
69
+ "@univerjs-infra/shared": "0.6.3"
70
70
  },
71
71
  "scripts": {
72
72
  "dev": "vite",