@univerjs/sheets-data-validation 0.5.4 → 0.5.5-experimental.20250123-34738ff
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +681 -446
- package/lib/es/index.js +1741 -1702
- package/lib/types/facade/f-data-validation-builder.d.ts +239 -134
- package/lib/types/facade/f-data-validation.d.ts +158 -38
- package/lib/types/facade/f-event.d.ts +12 -0
- package/lib/types/facade/f-range.d.ts +42 -9
- package/lib/types/facade/f-univer.d.ts +29 -2
- package/lib/types/facade/f-workbook.d.ts +14 -24
- package/lib/types/facade/f-worksheet.d.ts +15 -4
- package/lib/types/services/dv-validator-service.d.ts +1 -1
- package/lib/types/validators/custom-validator.d.ts +1 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +9 -9
- package/LICENSE +0 -176
|
@@ -1,89 +1,209 @@
|
|
|
1
1
|
import { DataValidationOperator, DataValidationType, IDataValidationRule, IDataValidationRuleOptions, Injector, Worksheet } from '@univerjs/core';
|
|
2
2
|
import { FRange } from '@univerjs/sheets/facade';
|
|
3
3
|
import { FDataValidationBuilder } from './f-data-validation-builder';
|
|
4
|
+
/**
|
|
5
|
+
* @hideconstructor
|
|
6
|
+
*/
|
|
4
7
|
export declare class FDataValidation {
|
|
5
8
|
rule: IDataValidationRule;
|
|
6
9
|
private _worksheet;
|
|
7
10
|
private _injector;
|
|
8
11
|
constructor(rule: IDataValidationRule, worksheet?: Worksheet, _injector?: Injector);
|
|
9
12
|
/**
|
|
10
|
-
* Gets whether invalid data is allowed based on the error style value
|
|
11
|
-
*
|
|
12
|
-
* @
|
|
13
|
+
* Gets whether invalid data is allowed based on the error style value
|
|
14
|
+
* @returns {boolean} true if invalid data is allowed, false otherwise
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const dataValidation = univerAPI
|
|
18
|
+
* .getActiveWorkbook()
|
|
19
|
+
* .getActiveWorksheet()
|
|
20
|
+
* .getActiveRange()
|
|
21
|
+
* .getDataValidation();
|
|
22
|
+
* const allowsInvalid = dataValidation.getAllowInvalid();
|
|
23
|
+
* ```
|
|
13
24
|
*/
|
|
14
25
|
getAllowInvalid(): boolean;
|
|
15
26
|
/**
|
|
16
27
|
* Gets the data validation type of the rule
|
|
17
|
-
*
|
|
18
|
-
* @
|
|
28
|
+
* @returns {DataValidationType | string} The data validation type
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const dataValidation = univerAPI
|
|
32
|
+
* .getActiveWorkbook()
|
|
33
|
+
* .getActiveWorksheet()
|
|
34
|
+
* .getActiveRange()
|
|
35
|
+
* .getDataValidation();
|
|
36
|
+
* const type = dataValidation.getCriteriaType();
|
|
37
|
+
* ```
|
|
19
38
|
*/
|
|
20
39
|
getCriteriaType(): DataValidationType | string;
|
|
21
40
|
/**
|
|
22
41
|
* Gets the values used for criteria evaluation
|
|
23
|
-
*
|
|
24
|
-
* @
|
|
42
|
+
* @returns {[string | undefined, string | undefined, string | undefined]} An array containing the operator, formula1, and formula2 values
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const dataValidation = univerAPI
|
|
46
|
+
* .getActiveWorkbook()
|
|
47
|
+
* .getActiveWorksheet()
|
|
48
|
+
* .getActiveRange()
|
|
49
|
+
* .getDataValidation();
|
|
50
|
+
* const [operator, formula1, formula2] = dataValidation.getCriteriaValues();
|
|
51
|
+
* ```
|
|
25
52
|
*/
|
|
26
53
|
getCriteriaValues(): [string | undefined, string | undefined, string | undefined];
|
|
27
54
|
/**
|
|
28
55
|
* Gets the help text information, which is used to provide users with guidance and support
|
|
29
|
-
*
|
|
30
|
-
* @
|
|
56
|
+
* @returns {string | undefined} Returns the help text information. If there is no error message, it returns an undefined value
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const dataValidation = univerAPI
|
|
60
|
+
* .getActiveWorkbook()
|
|
61
|
+
* .getActiveWorksheet()
|
|
62
|
+
* .getActiveRange()
|
|
63
|
+
* .getDataValidation();
|
|
64
|
+
* const helpText = dataValidation.getHelpText();
|
|
65
|
+
* ```
|
|
31
66
|
*/
|
|
32
67
|
getHelpText(): string | undefined;
|
|
33
68
|
/**
|
|
34
|
-
* Creates a new instance of FDataValidationBuilder using the current rule object
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
69
|
+
* Creates a new instance of FDataValidationBuilder using the current rule object
|
|
70
|
+
* @returns {FDataValidationBuilder} A new FDataValidationBuilder instance with the same rule configuration
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const dataValidation = univerAPI
|
|
74
|
+
* .getActiveWorkbook()
|
|
75
|
+
* .getActiveWorksheet()
|
|
76
|
+
* .getActiveRange()
|
|
77
|
+
* .getDataValidation();
|
|
78
|
+
* const builder = dataValidation.copy();
|
|
79
|
+
* const newRule = builder.setAllowInvalid(true).build();
|
|
80
|
+
* ```
|
|
38
81
|
*/
|
|
39
82
|
copy(): FDataValidationBuilder;
|
|
40
83
|
/**
|
|
41
|
-
* Gets whether the data validation rule is applied to the worksheet
|
|
42
|
-
*
|
|
43
|
-
* @
|
|
84
|
+
* Gets whether the data validation rule is applied to the worksheet
|
|
85
|
+
* @returns {boolean} true if the rule is applied, false otherwise
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const dataValidation = univerAPI
|
|
89
|
+
* .getActiveWorkbook()
|
|
90
|
+
* .getActiveWorksheet()
|
|
91
|
+
* .getActiveRange()
|
|
92
|
+
* .getDataValidation();
|
|
93
|
+
* const isApplied = dataValidation.getApplied();
|
|
94
|
+
* ```
|
|
44
95
|
*/
|
|
45
96
|
getApplied(): boolean;
|
|
46
97
|
/**
|
|
47
|
-
* Gets the ranges to which the data validation rule is applied
|
|
48
|
-
*
|
|
49
|
-
* @
|
|
98
|
+
* Gets the ranges to which the data validation rule is applied
|
|
99
|
+
* @returns {FRange[]} An array of FRange objects representing the ranges to which the data validation rule is applied
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const dataValidation = univerAPI
|
|
103
|
+
* .getActiveWorkbook()
|
|
104
|
+
* .getActiveWorksheet()
|
|
105
|
+
* .getActiveRange()
|
|
106
|
+
* .getDataValidation();
|
|
107
|
+
* const ranges = dataValidation.getRanges();
|
|
108
|
+
* ```
|
|
50
109
|
*/
|
|
51
110
|
getRanges(): FRange[];
|
|
52
111
|
/**
|
|
53
|
-
* Gets the
|
|
54
|
-
*
|
|
55
|
-
* @
|
|
112
|
+
* Gets the unit ID of the worksheet
|
|
113
|
+
* @returns {string | undefined} The unit ID of the worksheet
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const dataValidation = univerAPI
|
|
117
|
+
* .getActiveWorkbook()
|
|
118
|
+
* .getActiveWorksheet()
|
|
119
|
+
* .getActiveRange()
|
|
120
|
+
* .getDataValidation();
|
|
121
|
+
* const unitId = dataValidation.getUnitId();
|
|
122
|
+
* ```
|
|
56
123
|
*/
|
|
57
124
|
getUnitId(): string | undefined;
|
|
58
125
|
/**
|
|
59
|
-
* Gets the
|
|
60
|
-
*
|
|
61
|
-
* @
|
|
126
|
+
* Gets the sheet ID of the worksheet
|
|
127
|
+
* @returns {string | undefined} The sheet ID of the worksheet
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* const dataValidation = univerAPI
|
|
131
|
+
* .getActiveWorkbook()
|
|
132
|
+
* .getActiveWorksheet()
|
|
133
|
+
* .getActiveRange()
|
|
134
|
+
* .getDataValidation();
|
|
135
|
+
* const sheetId = dataValidation.getSheetId();
|
|
136
|
+
* ```
|
|
62
137
|
*/
|
|
63
138
|
getSheetId(): string | undefined;
|
|
64
139
|
/**
|
|
65
|
-
* Set Criteria for the data validation rule
|
|
66
|
-
* @param type The type of data validation criteria
|
|
67
|
-
* @param values An array containing the operator, formula1, and formula2 values
|
|
68
|
-
* @
|
|
140
|
+
* Set Criteria for the data validation rule
|
|
141
|
+
* @param {DataValidationType} type - The type of data validation criteria
|
|
142
|
+
* @param {[DataValidationOperator, string, string]} values - An array containing the operator, formula1, and formula2 values
|
|
143
|
+
* @param {boolean} [allowBlank] - Whether to allow blank values
|
|
144
|
+
* @returns {FDataValidation} The current instance for method chaining
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* const dataValidation = univerAPI
|
|
148
|
+
* .getActiveWorkbook()
|
|
149
|
+
* .getActiveWorksheet()
|
|
150
|
+
* .getActiveRange()
|
|
151
|
+
* .getDataValidation();
|
|
152
|
+
* dataValidation.setCriteria(
|
|
153
|
+
* DataValidationType.DECIMAL,
|
|
154
|
+
* [DataValidationOperator.BETWEEN, '1', '10'],
|
|
155
|
+
* true
|
|
156
|
+
* );
|
|
157
|
+
* ```
|
|
69
158
|
*/
|
|
70
159
|
setCriteria(type: DataValidationType, values: [DataValidationOperator, string, string], allowBlank?: boolean): FDataValidation;
|
|
71
160
|
/**
|
|
72
|
-
* Set the options for the data validation rule
|
|
73
|
-
*
|
|
74
|
-
* @
|
|
75
|
-
* @
|
|
161
|
+
* Set the options for the data validation rule
|
|
162
|
+
* @param {Partial<IDataValidationRuleOptions>} options - The options to set for the data validation rule
|
|
163
|
+
* @returns {FDataValidation} The current instance for method chaining
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* const dataValidation = univerAPI
|
|
167
|
+
* .getActiveWorkbook()
|
|
168
|
+
* .getActiveWorksheet()
|
|
169
|
+
* .getActiveRange()
|
|
170
|
+
* .getDataValidation();
|
|
171
|
+
* dataValidation.setOptions({
|
|
172
|
+
* allowBlank: true,
|
|
173
|
+
* showErrorMessage: true,
|
|
174
|
+
* error: 'Please enter a valid value'
|
|
175
|
+
* });
|
|
176
|
+
* ```
|
|
76
177
|
*/
|
|
77
178
|
setOptions(options: Partial<IDataValidationRuleOptions>): FDataValidation;
|
|
78
179
|
/**
|
|
79
|
-
* Set the ranges to the data validation rule
|
|
80
|
-
* @param ranges
|
|
81
|
-
* @returns
|
|
180
|
+
* Set the ranges to the data validation rule
|
|
181
|
+
* @param {FRange[]} ranges - New ranges array
|
|
182
|
+
* @returns {FDataValidation} The current instance for method chaining
|
|
183
|
+
* @example
|
|
184
|
+
* ```typescript
|
|
185
|
+
* const dataValidation = univerAPI
|
|
186
|
+
* .getActiveWorkbook()
|
|
187
|
+
* .getActiveWorksheet()
|
|
188
|
+
* .getActiveRange()
|
|
189
|
+
* .getDataValidation();
|
|
190
|
+
* const range = FRange.create('Sheet1', 'A1:B10');
|
|
191
|
+
* dataValidation.setRanges([range]);
|
|
192
|
+
* ```
|
|
82
193
|
*/
|
|
83
194
|
setRanges(ranges: FRange[]): FDataValidation;
|
|
84
195
|
/**
|
|
85
|
-
* Delete the data validation rule from the worksheet
|
|
86
|
-
* @returns true if the rule is deleted successfully, false otherwise
|
|
196
|
+
* Delete the data validation rule from the worksheet
|
|
197
|
+
* @returns {boolean} true if the rule is deleted successfully, false otherwise
|
|
198
|
+
* @example
|
|
199
|
+
* ```typescript
|
|
200
|
+
* const dataValidation = univerAPI
|
|
201
|
+
* .getActiveWorkbook()
|
|
202
|
+
* .getActiveWorksheet()
|
|
203
|
+
* .getActiveRange()
|
|
204
|
+
* .getDataValidation();
|
|
205
|
+
* const isDeleted = dataValidation.delete();
|
|
206
|
+
* ```
|
|
87
207
|
*/
|
|
88
208
|
delete(): boolean;
|
|
89
209
|
}
|
|
@@ -132,6 +132,9 @@ export interface IBeforeSheetDataValidationDeleteAllEvent extends IEventBase {
|
|
|
132
132
|
/** Array of all validation rules to be deleted */
|
|
133
133
|
rules: FDataValidation[];
|
|
134
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* @ignore
|
|
137
|
+
*/
|
|
135
138
|
export interface IDataValidationEventParamConfig {
|
|
136
139
|
SheetDataValidationChanged: ISheetDataValidationChangedEvent;
|
|
137
140
|
SheetDataValidatorStatusChanged: ISheetDataValidatorStatusChangedEvent;
|
|
@@ -142,6 +145,9 @@ export interface IDataValidationEventParamConfig {
|
|
|
142
145
|
BeforeSheetDataValidationRangeUpdate: IBeforeSheetDataValidationRangeUpdateEvent;
|
|
143
146
|
BeforeSheetDataValidationOptionsUpdate: IBeforeSheetDataValidationOptionsUpdateEvent;
|
|
144
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* @ignore
|
|
150
|
+
*/
|
|
145
151
|
interface IDataValidationEvent {
|
|
146
152
|
/**
|
|
147
153
|
* Event fired when a rule is added, deleted, or modified
|
|
@@ -240,6 +246,9 @@ interface IDataValidationEvent {
|
|
|
240
246
|
*/
|
|
241
247
|
readonly BeforeSheetDataValidationOptionsUpdate: 'BeforeSheetDataValidationOptionsUpdate';
|
|
242
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* @ignore
|
|
251
|
+
*/
|
|
243
252
|
export declare class FDataValidationEvent implements IDataValidationEvent {
|
|
244
253
|
get SheetDataValidationChanged(): 'SheetDataValidationChanged';
|
|
245
254
|
get SheetDataValidatorStatusChanged(): 'SheetDataValidatorStatusChanged';
|
|
@@ -250,6 +259,9 @@ export declare class FDataValidationEvent implements IDataValidationEvent {
|
|
|
250
259
|
get BeforeSheetDataValidationRangeUpdate(): 'BeforeSheetDataValidationRangeUpdate';
|
|
251
260
|
get BeforeSheetDataValidationOptionsUpdate(): 'BeforeSheetDataValidationOptionsUpdate';
|
|
252
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* @ignore
|
|
264
|
+
*/
|
|
253
265
|
export interface IDataValidationEventConfig {
|
|
254
266
|
SheetDataValidationChanged: ISheetDataValidationChangedEvent;
|
|
255
267
|
SheetDataValidatorStatusChanged: ISheetDataValidatorStatusChangedEvent;
|
|
@@ -1,30 +1,63 @@
|
|
|
1
1
|
import { DataValidationStatus, Nullable } from '@univerjs/core';
|
|
2
2
|
import { FRange } from '@univerjs/sheets/facade';
|
|
3
3
|
import { FDataValidation } from './f-data-validation';
|
|
4
|
+
/**
|
|
5
|
+
* @ignore
|
|
6
|
+
*/
|
|
4
7
|
export interface IFRangeDataValidationMixin {
|
|
5
8
|
/**
|
|
6
|
-
* Set a data validation rule to current range.
|
|
7
|
-
* @param rule data validation rule, build by `FUniver.newDataValidation`
|
|
9
|
+
* Set a data validation rule to current range. if rule is null, clear data validation rule.
|
|
10
|
+
* @param {Nullable<FDataValidation>} rule data validation rule, build by `FUniver.newDataValidation`
|
|
8
11
|
* @returns current range
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const rule = FUniver.newDataValidation().requireValueInRange(range).build();
|
|
15
|
+
* cell.setDataValidation(rule);
|
|
16
|
+
* ```
|
|
9
17
|
*/
|
|
10
|
-
setDataValidation(
|
|
18
|
+
setDataValidation(rule: Nullable<FDataValidation>): FRange;
|
|
11
19
|
/**
|
|
12
20
|
* Get first data validation rule in current range.
|
|
13
|
-
* @returns data validation rule
|
|
21
|
+
* @returns {Nullable<FDataValidation>} data validation rule
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
25
|
+
* const worksheet = workbook.getActiveSheet();
|
|
26
|
+
* const dataValidation = worksheet.getActiveRange().getDataValidation();
|
|
27
|
+
* ```
|
|
14
28
|
*/
|
|
15
|
-
getDataValidation(
|
|
29
|
+
getDataValidation(): Nullable<FDataValidation>;
|
|
16
30
|
/**
|
|
17
31
|
* Get all data validation rules in current range.
|
|
18
|
-
* @returns all data validation rules
|
|
32
|
+
* @returns {FDataValidation[]} all data validation rules
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
36
|
+
* const worksheet = workbook.getActiveSheet();
|
|
37
|
+
* const dataValidations = worksheet.getActiveRange().getDataValidations();
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
getDataValidations(): FDataValidation[];
|
|
41
|
+
/**
|
|
42
|
+
* Get data validation validator status for current range.
|
|
43
|
+
* @returns {Promise<DataValidationStatus[][]>} matrix of validator status
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
47
|
+
* const worksheet = workbook.getActiveSheet();
|
|
48
|
+
* const validatorStatus = worksheet.getActiveRange().getValidatorStatus();
|
|
49
|
+
* ```
|
|
19
50
|
*/
|
|
20
|
-
|
|
21
|
-
getValidatorStatus(): Promise<Promise<DataValidationStatus>[][]>;
|
|
51
|
+
getValidatorStatus(): Promise<DataValidationStatus[][]>;
|
|
22
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* @ignore
|
|
55
|
+
*/
|
|
23
56
|
export declare class FRangeDataValidationMixin extends FRange implements IFRangeDataValidationMixin {
|
|
24
57
|
setDataValidation(rule: Nullable<FDataValidation>): FRange;
|
|
25
58
|
getDataValidation(): Nullable<FDataValidation>;
|
|
26
59
|
getDataValidations(): FDataValidation[];
|
|
27
|
-
getValidatorStatus(): Promise<
|
|
60
|
+
getValidatorStatus(): Promise<DataValidationStatus[][]>;
|
|
28
61
|
}
|
|
29
62
|
declare module '@univerjs/sheets/facade' {
|
|
30
63
|
interface FRange extends IFRangeDataValidationMixin {
|
|
@@ -1,16 +1,43 @@
|
|
|
1
1
|
import { Injector, FUniver } from '@univerjs/core';
|
|
2
2
|
import { FDataValidationBuilder } from './f-data-validation-builder';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
export interface IFUnvierDataValidationMixin {
|
|
4
7
|
/**
|
|
8
|
+
* Creates a new instance of FDataValidationBuilder
|
|
9
|
+
* @returns {FDataValidationBuilder} A new instance of the FDataValidationBuilder class
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const rule = FUnvier.newDataValidation();
|
|
13
|
+
* cell.setDataValidation(rule.requireValueInRange(range));
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
newDataValidation(): FDataValidationBuilder;
|
|
17
|
+
}
|
|
18
|
+
export declare class FUnvierDataValidationMixin extends FUniver implements IFUnvierDataValidationMixin {
|
|
5
19
|
/**
|
|
6
|
-
* @
|
|
20
|
+
* @deprecated use `univerAPI.newDataValidation()` as instead.
|
|
21
|
+
* @returns {FDataValidationBuilder} A new instance of the FDataValidationBuilder class
|
|
7
22
|
*/
|
|
8
23
|
static newDataValidation(): FDataValidationBuilder;
|
|
9
24
|
newDataValidation(): FDataValidationBuilder;
|
|
25
|
+
/**
|
|
26
|
+
* @ignore
|
|
27
|
+
*/
|
|
10
28
|
_initialize(injector: Injector): void;
|
|
11
29
|
}
|
|
12
30
|
declare module '@univerjs/core' {
|
|
31
|
+
/**
|
|
32
|
+
* @ignore
|
|
33
|
+
*/
|
|
13
34
|
namespace FUniver {
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated use `univerAPI.newDataValidation()` as instead.
|
|
37
|
+
* @returns {FDataValidationBuilder} A new instance of the FDataValidationBuilder class
|
|
38
|
+
*/
|
|
14
39
|
function newDataValidation(): FDataValidationBuilder;
|
|
15
40
|
}
|
|
41
|
+
interface FUniver extends IFUnvierDataValidationMixin {
|
|
42
|
+
}
|
|
16
43
|
}
|
|
@@ -2,6 +2,9 @@ import { IRuleChange } from '@univerjs/data-validation';
|
|
|
2
2
|
import { IAddSheetDataValidationCommandParams, IRemoveSheetAllDataValidationCommandParams, IRemoveSheetDataValidationCommandParams, IUpdateSheetDataValidationOptionsCommandParams, IUpdateSheetDataValidationRangeCommandParams, IUpdateSheetDataValidationSettingCommandParams, IValidStatusChange, SheetDataValidationModel } from '@univerjs/sheets-data-validation';
|
|
3
3
|
import { DataValidationStatus, IDisposable, IExecutionOptions, Nullable, ObjectMatrix } from '@univerjs/core';
|
|
4
4
|
import { FWorkbook } from '@univerjs/sheets/facade';
|
|
5
|
+
/**
|
|
6
|
+
* @ignore
|
|
7
|
+
*/
|
|
5
8
|
export interface IFWorkbookDataValidationMixin {
|
|
6
9
|
/**
|
|
7
10
|
* Get data validation validator status for current workbook.
|
|
@@ -13,54 +16,41 @@ export interface IFWorkbookDataValidationMixin {
|
|
|
13
16
|
*/
|
|
14
17
|
getValidatorStatus(this: FWorkbook): Promise<Record<string, ObjectMatrix<Nullable<DataValidationStatus>>>>;
|
|
15
18
|
/**
|
|
16
|
-
*
|
|
17
|
-
* @param {function(IRuleChange): void} callback - Callback function that will be called when the event is fired
|
|
18
|
-
* @returns {IDisposable} A disposable object that can be used to unsubscribe from the event
|
|
19
|
+
* @deprecated Use `univerAPI.addEvent(univerAPI.Event.SheetDataValidationChanged, (event) => { ... })` instead
|
|
19
20
|
*/
|
|
20
21
|
onDataValidationChange(callback: (ruleChange: IRuleChange) => void): IDisposable;
|
|
21
22
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {function(IValidStatusChange): void} callback - Callback function that will be called when the event is fired
|
|
24
|
-
* @returns {IDisposable} A disposable object that can be used to unsubscribe from the event
|
|
23
|
+
* @deprecated Use `univerAPI.addEvent(univerAPI.Event.SheetDataValidatorStatusChanged, (event) => { ... })` instead
|
|
25
24
|
*/
|
|
26
25
|
onDataValidationStatusChange(callback: (statusChange: IValidStatusChange) => void): IDisposable;
|
|
27
26
|
/**
|
|
28
|
-
*
|
|
29
|
-
* @param {function(IAddSheetDataValidationCommandParams, IExecutionOptions | undefined): void | false} callback - Callback function that will be called when the event is fired
|
|
30
|
-
* @returns {IDisposable} A disposable object that can be used to unsubscribe from the event
|
|
27
|
+
* @deprecated Use `univerAPI.addEvent(univerAPI.Event.BeforeSheetDataValidationAdd, (event) => { ... })` instead
|
|
31
28
|
*/
|
|
32
29
|
onBeforeAddDataValidation(this: FWorkbook, callback: (params: IAddSheetDataValidationCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
|
33
30
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @param callback - Callback function that will be called when the event is fired
|
|
36
|
-
* @returns A disposable object that can be used to unsubscribe from the event
|
|
31
|
+
* @deprecated Use `univerAPI.addEvent(univerAPI.Event.BeforeSheetDataValidationCriteriaUpdate, (event) => { ... })` instead
|
|
37
32
|
*/
|
|
38
33
|
onBeforeUpdateDataValidationCriteria(this: FWorkbook, callback: (params: IUpdateSheetDataValidationSettingCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
|
39
34
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @param callback - Callback function that will be called when the event is fired
|
|
42
|
-
* @returns A disposable object that can be used to unsubscribe from the event
|
|
35
|
+
* @deprecated Use `univerAPI.addEvent(univerAPI.Event.BeforeSheetDataValidationRangeUpdate, (event) => { ... })` instead
|
|
43
36
|
*/
|
|
44
37
|
onBeforeUpdateDataValidationRange(this: FWorkbook, callback: (params: IUpdateSheetDataValidationRangeCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
|
45
38
|
/**
|
|
46
|
-
*
|
|
47
|
-
* @param callback - Callback function that will be called when the event is fired
|
|
48
|
-
* @returns A disposable object that can be used to unsubscribe from the event
|
|
39
|
+
* @deprecated Use `univerAPI.addEvent(univerAPI.Event.BeforeSheetDataValidationOptionsUpdate, (event) => { ... })` instead
|
|
49
40
|
*/
|
|
50
41
|
onBeforeUpdateDataValidationOptions(this: FWorkbook, callback: (params: IUpdateSheetDataValidationOptionsCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
|
51
42
|
/**
|
|
52
|
-
*
|
|
53
|
-
* @param callback - Callback function that will be called when the event is fired
|
|
54
|
-
* @returns A disposable object that can be used to unsubscribe from the event
|
|
43
|
+
* @deprecated Use `univerAPI.addEvent(univerAPI.Event.BeforeSheetDataValidationDelete, (event) => { ... })` instead
|
|
55
44
|
*/
|
|
56
45
|
onBeforeDeleteDataValidation(this: FWorkbook, callback: (params: IRemoveSheetDataValidationCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
|
57
46
|
/**
|
|
58
|
-
*
|
|
59
|
-
* @param callback - Callback function that will be called when the event is fired
|
|
60
|
-
* @returns A disposable object that can be used to unsubscribe from the event
|
|
47
|
+
* @deprecated Use `univerAPI.addEvent(univerAPI.Event.BeforeSheetDataValidationDeleteAll, (event) => { ... })` instead
|
|
61
48
|
*/
|
|
62
49
|
onBeforeDeleteAllDataValidation(this: FWorkbook, callback: (params: IRemoveSheetAllDataValidationCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
|
63
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* @ignore
|
|
53
|
+
*/
|
|
64
54
|
export declare class FWorkbookDataValidationMixin extends FWorkbook implements IFWorkbookDataValidationMixin {
|
|
65
55
|
_dataValidationModel: SheetDataValidationModel;
|
|
66
56
|
_initialize(): void;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { DataValidationStatus, Nullable, ObjectMatrix } from '@univerjs/core';
|
|
2
2
|
import { FWorksheet } from '@univerjs/sheets/facade';
|
|
3
3
|
import { FDataValidation } from './f-data-validation';
|
|
4
|
+
/**
|
|
5
|
+
* @ignore
|
|
6
|
+
*/
|
|
4
7
|
export interface IFWorksheetDataValidationMixin {
|
|
5
8
|
/**
|
|
6
9
|
* Get all data validation rules in current sheet.
|
|
7
|
-
* @returns all data validation rules
|
|
10
|
+
* @returns {FDataValidation[]} all data validation rules
|
|
8
11
|
* ```ts
|
|
9
12
|
* const workbook = univerAPI.getActiveWorkbook();
|
|
10
13
|
* const worksheet = workbook.getWorksheet('sheet1');
|
|
@@ -12,20 +15,24 @@ export interface IFWorksheetDataValidationMixin {
|
|
|
12
15
|
* ```
|
|
13
16
|
*/
|
|
14
17
|
getDataValidations(): FDataValidation[];
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated use `getValidatorStatusAsync` instead
|
|
20
|
+
*/
|
|
21
|
+
getValidatorStatus(): Promise<ObjectMatrix<Nullable<DataValidationStatus>>>;
|
|
15
22
|
/**
|
|
16
23
|
* Get data validation validator status for current sheet.
|
|
17
|
-
* @returns matrix of validator status
|
|
24
|
+
* @returns {Promise<ObjectMatrix<Nullable<DataValidationStatus>>>} matrix of validator status
|
|
18
25
|
* ```ts
|
|
19
26
|
* const workbook = univerAPI.getActiveWorkbook();
|
|
20
27
|
* const worksheet = workbook.getWorksheet('sheet1');
|
|
21
28
|
* const validatorStatus = worksheet.getValidatorStatus();
|
|
22
29
|
* ```
|
|
23
30
|
*/
|
|
24
|
-
|
|
31
|
+
getValidatorStatusAsync(): Promise<ObjectMatrix<Nullable<DataValidationStatus>>>;
|
|
25
32
|
/**
|
|
26
33
|
* get data validation rule by rule id
|
|
27
34
|
* @param ruleId - the rule id
|
|
28
|
-
* @returns data validation rule
|
|
35
|
+
* @returns {Nullable<FDataValidation>} data validation rule
|
|
29
36
|
* ```ts
|
|
30
37
|
* const workbook = univerAPI.getActiveWorkbook();
|
|
31
38
|
* const worksheet = workbook.getWorksheet('sheet1');
|
|
@@ -34,9 +41,13 @@ export interface IFWorksheetDataValidationMixin {
|
|
|
34
41
|
*/
|
|
35
42
|
getDataValidation(ruleId: string): Nullable<FDataValidation>;
|
|
36
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* @ignore
|
|
46
|
+
*/
|
|
37
47
|
export declare class FWorksheetDataValidationMixin extends FWorksheet implements IFWorksheetDataValidationMixin {
|
|
38
48
|
getDataValidations(): FDataValidation[];
|
|
39
49
|
getValidatorStatus(): Promise<ObjectMatrix<Nullable<DataValidationStatus>>>;
|
|
50
|
+
getValidatorStatusAsync(): Promise<ObjectMatrix<Nullable<DataValidationStatus>>>;
|
|
40
51
|
getDataValidation(ruleId: string): Nullable<FDataValidation>;
|
|
41
52
|
}
|
|
42
53
|
declare module '@univerjs/sheets/facade' {
|
|
@@ -10,7 +10,7 @@ export declare class SheetsDataValidationValidatorService extends Disposable {
|
|
|
10
10
|
private _initRecalculate;
|
|
11
11
|
private _validatorByCell;
|
|
12
12
|
validatorCell(unitId: string, subUnitId: string, row: number, col: number): Promise<DataValidationStatus>;
|
|
13
|
-
validatorRanges(unitId: string, subUnitId: string, ranges: IRange[]): Promise<
|
|
13
|
+
validatorRanges(unitId: string, subUnitId: string, ranges: IRange[]): Promise<DataValidationStatus[][]>;
|
|
14
14
|
validatorWorksheet(unitId: string, subUnitId: string): Promise<ObjectMatrix<Nullable<DataValidationStatus>>>;
|
|
15
15
|
validatorWorkbook(unitId: string): Promise<Record<string, ObjectMatrix<Nullable<DataValidationStatus>>>>;
|
|
16
16
|
getDataValidations(unitId: string, subUnitId: string, ranges: IRange[]): IDataValidationRule[];
|
|
@@ -6,6 +6,7 @@ export declare class CustomFormulaValidator extends BaseDataValidator {
|
|
|
6
6
|
operators: DataValidationOperator[];
|
|
7
7
|
scopes: string | string[];
|
|
8
8
|
private readonly _customFormulaService;
|
|
9
|
+
private readonly _lexerTreeBuilder;
|
|
9
10
|
validatorFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): IFormulaValidResult;
|
|
10
11
|
parseFormula(_rule: IDataValidationRule, _unitId: string, _subUnitId: string): Promise<IFormulaResult>;
|
|
11
12
|
isValidType(cellInfo: IValidatorCellInfo<CellValue>, _formula: IFormulaResult, _rule: IDataValidationRule): Promise<boolean>;
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(u,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/sheets-data-validation"),require("@univerjs/sheets/facade"),require("@univerjs/core"),require("@univerjs/data-validation"),require("@univerjs/engine-formula"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/sheets-data-validation","@univerjs/sheets/facade","@univerjs/core","@univerjs/data-validation","@univerjs/engine-formula","rxjs"],i):(u=typeof globalThis<"u"?globalThis:u||self,i(u.UniverSheetsDataValidationFacade={},u.UniverSheetsDataValidation,u.UniverSheetsFacade,u.UniverCore,u.UniverDataValidation,u.UniverEngineFormula,u.rxjs))})(this,function(u,i,m,a,D,v,E){"use strict";var U=Object.defineProperty;var A=(u,i,m)=>i in u?U(u,i,{enumerable:!0,configurable:!0,writable:!0,value:m}):u[i]=m;var S=(u,i,m)=>A(u,typeof i!="symbol"?i+"":i,m);class _{constructor(t){S(this,"_rule");this._rule=t!=null?t:{uid:a.generateRandomId(),ranges:void 0,type:a.DataValidationType.CUSTOM}}build(){return new g(this._rule)}copy(){return new _({...this._rule,uid:a.generateRandomId()})}getAllowInvalid(){return this._rule.errorStyle!==a.DataValidationErrorStyle.STOP}getCriteriaType(){return this._rule.type}getCriteriaValues(){return[this._rule.operator,this._rule.formula1,this._rule.formula2]}getHelpText(){return this._rule.error}requireCheckbox(t,e){return this._rule.type=a.DataValidationType.CHECKBOX,this._rule.formula1=t,this._rule.formula2=e,this}requireDateAfter(t){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.operator=a.DataValidationOperator.GREATER_THAN,this}requireDateBefore(t){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.LESS_THAN,this}requireDateBetween(t,e){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=e.toLocaleDateString(),this._rule.operator=a.DataValidationOperator.BETWEEN,this}requireDateEqualTo(t){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.EQUAL,this}requireDateNotBetween(t,e){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=e.toLocaleDateString(),this._rule.operator=a.DataValidationOperator.NOT_BETWEEN,this}requireDateOnOrAfter(t){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.GREATER_THAN_OR_EQUAL,this}requireDateOnOrBefore(t){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.LESS_THAN_OR_EQUAL,this}requireFormulaSatisfied(t){return this._rule.type=a.DataValidationType.CUSTOM,this._rule.formula1=t,this._rule.formula2=void 0,this}requireNumberBetween(t,e,r){return this._rule.formula1=`${t}`,this._rule.formula2=`${e}`,this._rule.operator=a.DataValidationOperator.BETWEEN,this._rule.type=r?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.EQUAL,this._rule.type=e?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberGreaterThan(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.GREATER_THAN,this._rule.type=e?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberGreaterThanOrEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.GREATER_THAN_OR_EQUAL,this._rule.type=e?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberLessThan(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.LESS_THAN,this._rule.type=e?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberLessThanOrEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.LESS_THAN_OR_EQUAL,this._rule.type=e?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberNotBetween(t,e,r){return this._rule.formula1=`${t}`,this._rule.formula2=`${e}`,this._rule.operator=a.DataValidationOperator.NOT_BETWEEN,this._rule.type=r?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberNotEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.NOT_EQUAL,this._rule.type=e?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireValueInList(t,e,r){return this._rule.type=e?a.DataValidationType.LIST_MULTIPLE:a.DataValidationType.LIST,this._rule.formula1=t.join(","),this._rule.formula2=void 0,this._rule.showDropDown=r!=null?r:!0,this}requireValueInRange(t,e,r){return this._rule.type=e?a.DataValidationType.LIST_MULTIPLE:a.DataValidationType.LIST,this._rule.formula1=`=${v.serializeRangeToRefString({unitId:t.getUnitId(),sheetName:t.getSheetName(),range:t.getRange()})}`,this._rule.formula2=void 0,this._rule.showDropDown=r!=null?r:!0,this}setAllowInvalid(t){return this._rule.errorStyle=t?a.DataValidationErrorStyle.WARNING:a.DataValidationErrorStyle.STOP,this}setHelpText(t){return this._rule.error=t,this._rule.showErrorMessage=!0,this}withCriteriaValues(t,e){return this._rule.type=t,this._rule.operator=e[0],this._rule.formula1=e[1],this._rule.formula2=e[2],this}setAllowBlank(t){return this._rule.allowBlank=t,this}setOptions(t){return Object.assign(this._rule,t),this}}class g{constructor(t,e,r){S(this,"rule");S(this,"_worksheet");S(this,"_injector");this._injector=r,this.rule=t,this._worksheet=e}getAllowInvalid(){return this.rule.errorStyle!==a.DataValidationErrorStyle.STOP}getCriteriaType(){return this.rule.type}getCriteriaValues(){return[this.rule.operator,this.rule.formula1,this.rule.formula2]}getHelpText(){return this.rule.error}copy(){return new _(this.rule)}getApplied(){if(!this._worksheet)return!1;const e=this._injector.get(D.DataValidationModel).getRuleById(this._worksheet.getUnitId(),this._worksheet.getSheetId(),this.rule.uid);return!!(e&&e.ranges.length)}getRanges(){if(!this.getApplied())return[];const t=this._injector.get(a.IUniverInstanceService).getUnit(this._worksheet.getUnitId());return this.rule.ranges.map(e=>this._injector.createInstance(m.FRange,t,this._worksheet,e))}getUnitId(){var t;return(t=this._worksheet)==null?void 0:t.getUnitId()}getSheetId(){var t;return(t=this._worksheet)==null?void 0:t.getSheetId()}setCriteria(t,e,r=!0){if(this.getApplied()&&!this._injector.get(a.ICommandService).syncExecuteCommand(i.UpdateSheetDataValidationSettingCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,setting:{operator:e[0],formula1:e[1],formula2:e[2],type:this.rule.type,allowBlank:r}}))throw new Error("setCriteria failed");return this.rule.operator=e[0],this.rule.formula1=e[1],this.rule.formula2=e[2],this.rule.type=t,this.rule.allowBlank=r,this}setOptions(t){if(this.getApplied()&&!this._injector.get(a.ICommandService).syncExecuteCommand(i.UpdateSheetDataValidationOptionsCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,options:{...D.getRuleOptions(this.rule),...t}}))throw new Error("setOptions failed");return Object.assign(this.rule,t),this}setRanges(t){if(this.getApplied()&&!this._injector.get(a.ICommandService).syncExecuteCommand(i.UpdateSheetDataValidationRangeCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,ranges:t.map(o=>o.getRange())}))throw new Error("setRanges failed");return this.rule.ranges=t.map(e=>e.getRange()),this}delete(){return this.getApplied()?this._injector.get(a.ICommandService).syncExecuteCommand(i.RemoveSheetDataValidationCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid}):!1}}class w extends m.FRange{setDataValidation(t){if(!t)return this._commandService.syncExecuteCommand(i.ClearRangeDataValidationCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),ranges:[this._range]}),this;const e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:{...t.rule,ranges:[this._range]}};return this._commandService.syncExecuteCommand(i.AddSheetDataValidationCommand.id,e),this}getDataValidation(){const e=this._injector.get(i.SheetsDataValidationValidatorService).getDataValidation(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range]);return e&&new g(e,this._worksheet,this._injector)}getDataValidations(){return this._injector.get(i.SheetsDataValidationValidatorService).getDataValidations(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range]).map(e=>new g(e,this._worksheet,this._injector))}async getValidatorStatus(){return this._injector.get(i.SheetsDataValidationValidatorService).validatorRanges(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range])}}m.FRange.extend(w);class T extends a.FUniver{static newDataValidation(){return new _}newDataValidation(){return new _}_initialize(t){if(!t.has(i.SheetDataValidationModel))return;const e=t.get(i.SheetDataValidationModel),r=t.get(a.ICommandService);this.disposeWithMe(e.ruleChange$.subscribe(o=>{const{unitId:n,subUnitId:s,rule:p,oldRule:d,type:l}=o,h=this.getSheetTarget(n,s);if(!h)return;const{workbook:c,worksheet:V}=h,I=new g(p,V.getSheet(),this._injector);this.fireEvent(this.Event.SheetDataValidationChanged,{origin:o,worksheet:V,workbook:c,changeType:l,oldRule:d,rule:I})})),this.disposeWithMe(e.validStatusChange$.subscribe(o=>{const{unitId:n,subUnitId:s,ruleId:p,status:d,row:l,col:h}=o,c=this.getSheetTarget(n,s);if(!c)return;const{workbook:V,worksheet:I}=c,k=I.getDataValidation(p);k&&this.fireEvent(this.Event.SheetDataValidatorStatusChanged,{workbook:V,worksheet:I,row:l,column:h,rule:k,status:d})})),this.disposeWithMe(r.beforeCommandExecuted(o=>{switch(o.id){case i.AddSheetDataValidationCommand.id:{const n=o.params,s=this.getSheetTarget(n.unitId,n.subUnitId);if(!s)return;const{workbook:p,worksheet:d}=s,l={worksheet:d,workbook:p,rule:n.rule};if(this.fireEvent(this.Event.BeforeSheetDataValidationAdd,l),l.cancel)throw new a.CanceledError;break}case i.UpdateSheetDataValidationSettingCommand.id:{const n=o.params,s=this.getSheetTarget(n.unitId,n.subUnitId);if(!s)return;const{workbook:p,worksheet:d}=s,l=d.getDataValidation(n.ruleId);if(!l)return;const h={worksheet:d,workbook:p,rule:l,ruleId:n.ruleId,newCriteria:n.setting};if(this.fireEvent(this.Event.BeforeSheetDataValidationCriteriaUpdate,h),h.cancel)throw new a.CanceledError;break}case i.UpdateSheetDataValidationRangeCommand.id:{const n=o.params,s=this.getSheetTarget(n.unitId,n.subUnitId);if(!s)return;const{workbook:p,worksheet:d}=s,l=d.getDataValidation(n.ruleId);if(!l)return;const h={worksheet:d,workbook:p,rule:l,ruleId:n.ruleId,newRanges:n.ranges};if(this.fireEvent(this.Event.BeforeSheetDataValidationRangeUpdate,h),h.cancel)throw new a.CanceledError;break}case i.UpdateSheetDataValidationOptionsCommand.id:{const n=o.params,s=this.getSheetTarget(n.unitId,n.subUnitId);if(!s)return;const{workbook:p,worksheet:d}=s,l=d.getDataValidation(n.ruleId);if(!l)return;const h={worksheet:d,workbook:p,rule:l,ruleId:n.ruleId,newOptions:n.options};if(this.fireEvent(this.Event.BeforeSheetDataValidationOptionsUpdate,h),h.cancel)throw new a.CanceledError;break}case i.RemoveSheetDataValidationCommand.id:{const n=o.params,s=this.getSheetTarget(n.unitId,n.subUnitId);if(!s)return;const{workbook:p,worksheet:d}=s,l=d.getDataValidation(n.ruleId);if(!l)return;const h={worksheet:d,workbook:p,rule:l,ruleId:n.ruleId};if(this.fireEvent(this.Event.BeforeSheetDataValidationDelete,h),h.cancel)throw new a.CanceledError;break}case i.RemoveSheetAllDataValidationCommand.id:{const n=o.params,s=this.getSheetTarget(n.unitId,n.subUnitId);if(!s)return;const{workbook:p,worksheet:d}=s,l={worksheet:d,workbook:p,rules:d.getDataValidations()};if(this.fireEvent(this.Event.BeforeSheetDataValidationDeleteAll,l),l.cancel)throw new a.CanceledError;break}}}))}}a.FUniver.extend(T);class b extends m.FWorkbook{_initialize(){Object.defineProperty(this,"_dataValidationModel",{get(){return this._injector.get(i.SheetDataValidationModel)}})}getValidatorStatus(){return this._injector.get(i.SheetsDataValidationValidatorService).validatorWorkbook(this._workbook.getUnitId())}onDataValidationChange(t){return a.toDisposable(this._dataValidationModel.ruleChange$.pipe(E.filter(e=>e.unitId===this._workbook.getUnitId())).subscribe(t))}onDataValidationStatusChange(t){return a.toDisposable(this._dataValidationModel.validStatusChange$.pipe(E.filter(e=>e.unitId===this._workbook.getUnitId())).subscribe(t))}onBeforeAddDataValidation(t){return a.toDisposable(this._commandService.beforeCommandExecuted((e,r)=>{const o=e.params;if(e.id===i.AddSheetDataValidationCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(t(o,r)===!1)throw new Error("Command is stopped by the hook onBeforeAddDataValidation")}}))}onBeforeUpdateDataValidationCriteria(t){return a.toDisposable(this._commandService.beforeCommandExecuted((e,r)=>{const o=e.params;if(e.id===i.UpdateSheetDataValidationSettingCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(t(o,r)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationCriteria")}}))}onBeforeUpdateDataValidationRange(t){return a.toDisposable(this._commandService.beforeCommandExecuted((e,r)=>{const o=e.params;if(e.id===i.UpdateSheetDataValidationRangeCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(t(o,r)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationRange")}}))}onBeforeUpdateDataValidationOptions(t){return a.toDisposable(this._commandService.beforeCommandExecuted((e,r)=>{const o=e.params;if(e.id===i.UpdateSheetDataValidationOptionsCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(t(o,r)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationOptions")}}))}onBeforeDeleteDataValidation(t){return a.toDisposable(this._commandService.beforeCommandExecuted((e,r)=>{const o=e.params;if(e.id===i.RemoveSheetDataValidationCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(t(o,r)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteDataValidation")}}))}onBeforeDeleteAllDataValidation(t){return a.toDisposable(this._commandService.beforeCommandExecuted((e,r)=>{const o=e.params;if(e.id===i.RemoveSheetAllDataValidationCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(t(o,r)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteAllDataValidation")}}))}}m.FWorkbook.extend(b);class y extends m.FWorksheet{getDataValidations(){return this._injector.get(D.DataValidationModel).getRules(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(e=>new g(e,this._worksheet,this._injector))}getValidatorStatus(){return this._injector.get(i.SheetsDataValidationValidatorService).validatorWorksheet(this._workbook.getUnitId(),this._worksheet.getSheetId())}getDataValidation(t){const r=this._injector.get(D.DataValidationModel).getRuleById(this._workbook.getUnitId(),this._worksheet.getSheetId(),t);return r?new g(r,this._worksheet,this._injector):null}}m.FWorksheet.extend(y);class C{get SheetDataValidationChanged(){return"SheetDataValidationChanged"}get SheetDataValidatorStatusChanged(){return"SheetDataValidatorStatusChanged"}get BeforeSheetDataValidationAdd(){return"BeforeSheetDataValidationAdd"}get BeforeSheetDataValidationDelete(){return"BeforeSheetDataValidationDelete"}get BeforeSheetDataValidationDeleteAll(){return"BeforeSheetDataValidationDeleteAll"}get BeforeSheetDataValidationCriteriaUpdate(){return"BeforeSheetDataValidationCriteriaUpdate"}get BeforeSheetDataValidationRangeUpdate(){return"BeforeSheetDataValidationRangeUpdate"}get BeforeSheetDataValidationOptionsUpdate(){return"BeforeSheetDataValidationOptionsUpdate"}}a.FEventName.extend(C),u.FDataValidation=g,u.FDataValidationBuilder=_,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/sheets-data-validation"),require("@univerjs/sheets/facade"),require("@univerjs/core"),require("@univerjs/data-validation"),require("@univerjs/engine-formula"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/sheets-data-validation","@univerjs/sheets/facade","@univerjs/core","@univerjs/data-validation","@univerjs/engine-formula","rxjs"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverSheetsDataValidationFacade={},global.UniverSheetsDataValidation,global.UniverSheetsFacade,global.UniverCore,global.UniverDataValidation,global.UniverEngineFormula,global.rxjs))})(this,function(exports2,sheetsDataValidation,facade,core,dataValidation,engineFormula,rxjs){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);const _FDataValidationBuilder=class _FDataValidationBuilder{constructor(rule){__publicField(this,"_rule");this._rule=rule!=null?rule:{uid:core.generateRandomId(),ranges:void 0,type:core.DataValidationType.CUSTOM}}build(){return new FDataValidation(this._rule)}copy(){return new _FDataValidationBuilder({...this._rule,uid:core.generateRandomId()})}getAllowInvalid(){return this._rule.errorStyle!==core.DataValidationErrorStyle.STOP}getCriteriaType(){return this._rule.type}getCriteriaValues(){return[this._rule.operator,this._rule.formula1,this._rule.formula2]}getHelpText(){return this._rule.error}requireCheckbox(checkedValue,uncheckedValue){return this._rule.type=core.DataValidationType.CHECKBOX,this._rule.formula1=checkedValue,this._rule.formula2=uncheckedValue,this}requireDateAfter(date){return this._rule.type=core.DataValidationType.DATE,this._rule.formula1=date.toLocaleDateString(),this._rule.operator=core.DataValidationOperator.GREATER_THAN,this}requireDateBefore(date){return this._rule.type=core.DataValidationType.DATE,this._rule.formula1=date.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=core.DataValidationOperator.LESS_THAN,this}requireDateBetween(start,end){return this._rule.type=core.DataValidationType.DATE,this._rule.formula1=start.toLocaleDateString(),this._rule.formula2=end.toLocaleDateString(),this._rule.operator=core.DataValidationOperator.BETWEEN,this}requireDateEqualTo(date){return this._rule.type=core.DataValidationType.DATE,this._rule.formula1=date.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=core.DataValidationOperator.EQUAL,this}requireDateNotBetween(start,end){return this._rule.type=core.DataValidationType.DATE,this._rule.formula1=start.toLocaleDateString(),this._rule.formula2=end.toLocaleDateString(),this._rule.operator=core.DataValidationOperator.NOT_BETWEEN,this}requireDateOnOrAfter(date){return this._rule.type=core.DataValidationType.DATE,this._rule.formula1=date.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=core.DataValidationOperator.GREATER_THAN_OR_EQUAL,this}requireDateOnOrBefore(date){return this._rule.type=core.DataValidationType.DATE,this._rule.formula1=date.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=core.DataValidationOperator.LESS_THAN_OR_EQUAL,this}requireFormulaSatisfied(formula){return this._rule.type=core.DataValidationType.CUSTOM,this._rule.formula1=formula,this._rule.formula2=void 0,this}requireNumberBetween(start,end,isInteger){return this._rule.formula1=`${start}`,this._rule.formula2=`${end}`,this._rule.operator=core.DataValidationOperator.BETWEEN,this._rule.type=isInteger?core.DataValidationType.WHOLE:core.DataValidationType.DECIMAL,this}requireNumberEqualTo(num,isInteger){return this._rule.formula1=`${num}`,this._rule.formula2=void 0,this._rule.operator=core.DataValidationOperator.EQUAL,this._rule.type=isInteger?core.DataValidationType.WHOLE:core.DataValidationType.DECIMAL,this}requireNumberGreaterThan(num,isInteger){return this._rule.formula1=`${num}`,this._rule.formula2=void 0,this._rule.operator=core.DataValidationOperator.GREATER_THAN,this._rule.type=isInteger?core.DataValidationType.WHOLE:core.DataValidationType.DECIMAL,this}requireNumberGreaterThanOrEqualTo(num,isInteger){return this._rule.formula1=`${num}`,this._rule.formula2=void 0,this._rule.operator=core.DataValidationOperator.GREATER_THAN_OR_EQUAL,this._rule.type=isInteger?core.DataValidationType.WHOLE:core.DataValidationType.DECIMAL,this}requireNumberLessThan(num,isInteger){return this._rule.formula1=`${num}`,this._rule.formula2=void 0,this._rule.operator=core.DataValidationOperator.LESS_THAN,this._rule.type=isInteger?core.DataValidationType.WHOLE:core.DataValidationType.DECIMAL,this}requireNumberLessThanOrEqualTo(num,isInteger){return this._rule.formula1=`${num}`,this._rule.formula2=void 0,this._rule.operator=core.DataValidationOperator.LESS_THAN_OR_EQUAL,this._rule.type=isInteger?core.DataValidationType.WHOLE:core.DataValidationType.DECIMAL,this}requireNumberNotBetween(start,end,isInteger){return this._rule.formula1=`${start}`,this._rule.formula2=`${end}`,this._rule.operator=core.DataValidationOperator.NOT_BETWEEN,this._rule.type=isInteger?core.DataValidationType.WHOLE:core.DataValidationType.DECIMAL,this}requireNumberNotEqualTo(num,isInteger){return this._rule.formula1=`${num}`,this._rule.formula2=void 0,this._rule.operator=core.DataValidationOperator.NOT_EQUAL,this._rule.type=isInteger?core.DataValidationType.WHOLE:core.DataValidationType.DECIMAL,this}requireValueInList(values,multiple,showDropdown){return this._rule.type=multiple?core.DataValidationType.LIST_MULTIPLE:core.DataValidationType.LIST,this._rule.formula1=values.join(","),this._rule.formula2=void 0,this._rule.showDropDown=showDropdown!=null?showDropdown:!0,this}requireValueInRange(range,multiple,showDropdown){return this._rule.type=multiple?core.DataValidationType.LIST_MULTIPLE:core.DataValidationType.LIST,this._rule.formula1=`=${engineFormula.serializeRangeToRefString({unitId:range.getUnitId(),sheetName:range.getSheetName(),range:range.getRange()})}`,this._rule.formula2=void 0,this._rule.showDropDown=showDropdown!=null?showDropdown:!0,this}setAllowInvalid(allowInvalidData){return this._rule.errorStyle=allowInvalidData?core.DataValidationErrorStyle.WARNING:core.DataValidationErrorStyle.STOP,this}setAllowBlank(allowBlank){return this._rule.allowBlank=allowBlank,this}setOptions(options){return Object.assign(this._rule,options),this}};__name(_FDataValidationBuilder,"FDataValidationBuilder");let FDataValidationBuilder=_FDataValidationBuilder;const _FDataValidation=class _FDataValidation{constructor(rule,worksheet,_injector){__publicField(this,"rule");__publicField(this,"_worksheet");__publicField(this,"_injector");this._injector=_injector,this.rule=rule,this._worksheet=worksheet}getAllowInvalid(){return this.rule.errorStyle!==core.DataValidationErrorStyle.STOP}getCriteriaType(){return this.rule.type}getCriteriaValues(){return[this.rule.operator,this.rule.formula1,this.rule.formula2]}getHelpText(){return this.rule.error}copy(){return new FDataValidationBuilder(this.rule)}getApplied(){if(!this._worksheet)return!1;const currentRule=this._injector.get(dataValidation.DataValidationModel).getRuleById(this._worksheet.getUnitId(),this._worksheet.getSheetId(),this.rule.uid);return!!(currentRule&¤tRule.ranges.length)}getRanges(){if(!this.getApplied())return[];const workbook=this._injector.get(core.IUniverInstanceService).getUnit(this._worksheet.getUnitId());return this.rule.ranges.map(range=>this._injector.createInstance(facade.FRange,workbook,this._worksheet,range))}getUnitId(){var _a;return(_a=this._worksheet)==null?void 0:_a.getUnitId()}getSheetId(){var _a;return(_a=this._worksheet)==null?void 0:_a.getSheetId()}setCriteria(type,values,allowBlank=!0){if(this.getApplied()&&!this._injector.get(core.ICommandService).syncExecuteCommand(sheetsDataValidation.UpdateSheetDataValidationSettingCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,setting:{operator:values[0],formula1:values[1],formula2:values[2],type:this.rule.type,allowBlank}}))throw new Error("setCriteria failed");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}setOptions(options){if(this.getApplied()&&!this._injector.get(core.ICommandService).syncExecuteCommand(sheetsDataValidation.UpdateSheetDataValidationOptionsCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,options:{...dataValidation.getRuleOptions(this.rule),...options}}))throw new Error("setOptions failed");return Object.assign(this.rule,options),this}setRanges(ranges){if(this.getApplied()&&!this._injector.get(core.ICommandService).syncExecuteCommand(sheetsDataValidation.UpdateSheetDataValidationRangeCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,ranges:ranges.map(range=>range.getRange())}))throw new Error("setRanges failed");return this.rule.ranges=ranges.map(range=>range.getRange()),this}delete(){return this.getApplied()?this._injector.get(core.ICommandService).syncExecuteCommand(sheetsDataValidation.RemoveSheetDataValidationCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid}):!1}};__name(_FDataValidation,"FDataValidation");let FDataValidation=_FDataValidation;const _FRangeDataValidationMixin=class _FRangeDataValidationMixin extends facade.FRange{setDataValidation(rule){if(!rule)return this._commandService.syncExecuteCommand(sheetsDataValidation.ClearRangeDataValidationCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),ranges:[this._range]}),this;const params={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:{...rule.rule,ranges:[this._range]}};return this._commandService.syncExecuteCommand(sheetsDataValidation.AddSheetDataValidationCommand.id,params),this}getDataValidation(){const rule=this._injector.get(sheetsDataValidation.SheetsDataValidationValidatorService).getDataValidation(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range]);return rule&&new FDataValidation(rule,this._worksheet,this._injector)}getDataValidations(){return this._injector.get(sheetsDataValidation.SheetsDataValidationValidatorService).getDataValidations(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range]).map(rule=>new FDataValidation(rule,this._worksheet,this._injector))}async getValidatorStatus(){return this._injector.get(sheetsDataValidation.SheetsDataValidationValidatorService).validatorRanges(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range])}};__name(_FRangeDataValidationMixin,"FRangeDataValidationMixin");let FRangeDataValidationMixin=_FRangeDataValidationMixin;facade.FRange.extend(FRangeDataValidationMixin);const _FUnvierDataValidationMixin=class _FUnvierDataValidationMixin extends core.FUniver{static newDataValidation(){return new FDataValidationBuilder}newDataValidation(){return new FDataValidationBuilder}_initialize(injector){if(!injector.has(sheetsDataValidation.SheetDataValidationModel))return;const sheetDataValidationModel=injector.get(sheetsDataValidation.SheetDataValidationModel),commadnService=injector.get(core.ICommandService);this.disposeWithMe(sheetDataValidationModel.ruleChange$.subscribe(ruleChange=>{const{unitId,subUnitId,rule,oldRule,type}=ruleChange,target=this.getSheetTarget(unitId,subUnitId);if(!target)return;const{workbook,worksheet}=target,fRule=new FDataValidation(rule,worksheet.getSheet(),this._injector);this.fireEvent(this.Event.SheetDataValidationChanged,{origin:ruleChange,worksheet,workbook,changeType:type,oldRule,rule:fRule})})),this.disposeWithMe(sheetDataValidationModel.validStatusChange$.subscribe(statusChange=>{const{unitId,subUnitId,ruleId,status,row,col}=statusChange,target=this.getSheetTarget(unitId,subUnitId);if(!target)return;const{workbook,worksheet}=target,rule=worksheet.getDataValidation(ruleId);rule&&this.fireEvent(this.Event.SheetDataValidatorStatusChanged,{workbook,worksheet,row,column:col,rule,status})})),this.disposeWithMe(commadnService.beforeCommandExecuted(commandInfo=>{switch(commandInfo.id){case sheetsDataValidation.AddSheetDataValidationCommand.id:{const params=commandInfo.params,target=this.getSheetTarget(params.unitId,params.subUnitId);if(!target)return;const{workbook,worksheet}=target,eventParams={worksheet,workbook,rule:params.rule};if(this.fireEvent(this.Event.BeforeSheetDataValidationAdd,eventParams),eventParams.cancel)throw new core.CanceledError;break}case sheetsDataValidation.UpdateSheetDataValidationSettingCommand.id:{const params=commandInfo.params,target=this.getSheetTarget(params.unitId,params.subUnitId);if(!target)return;const{workbook,worksheet}=target,rule=worksheet.getDataValidation(params.ruleId);if(!rule)return;const eventParams={worksheet,workbook,rule,ruleId:params.ruleId,newCriteria:params.setting};if(this.fireEvent(this.Event.BeforeSheetDataValidationCriteriaUpdate,eventParams),eventParams.cancel)throw new core.CanceledError;break}case sheetsDataValidation.UpdateSheetDataValidationRangeCommand.id:{const params=commandInfo.params,target=this.getSheetTarget(params.unitId,params.subUnitId);if(!target)return;const{workbook,worksheet}=target,rule=worksheet.getDataValidation(params.ruleId);if(!rule)return;const eventParams={worksheet,workbook,rule,ruleId:params.ruleId,newRanges:params.ranges};if(this.fireEvent(this.Event.BeforeSheetDataValidationRangeUpdate,eventParams),eventParams.cancel)throw new core.CanceledError;break}case sheetsDataValidation.UpdateSheetDataValidationOptionsCommand.id:{const params=commandInfo.params,target=this.getSheetTarget(params.unitId,params.subUnitId);if(!target)return;const{workbook,worksheet}=target,rule=worksheet.getDataValidation(params.ruleId);if(!rule)return;const eventParams={worksheet,workbook,rule,ruleId:params.ruleId,newOptions:params.options};if(this.fireEvent(this.Event.BeforeSheetDataValidationOptionsUpdate,eventParams),eventParams.cancel)throw new core.CanceledError;break}case sheetsDataValidation.RemoveSheetDataValidationCommand.id:{const params=commandInfo.params,target=this.getSheetTarget(params.unitId,params.subUnitId);if(!target)return;const{workbook,worksheet}=target,rule=worksheet.getDataValidation(params.ruleId);if(!rule)return;const eventParams={worksheet,workbook,rule,ruleId:params.ruleId};if(this.fireEvent(this.Event.BeforeSheetDataValidationDelete,eventParams),eventParams.cancel)throw new core.CanceledError;break}case sheetsDataValidation.RemoveSheetAllDataValidationCommand.id:{const params=commandInfo.params,target=this.getSheetTarget(params.unitId,params.subUnitId);if(!target)return;const{workbook,worksheet}=target,eventParams={worksheet,workbook,rules:worksheet.getDataValidations()};if(this.fireEvent(this.Event.BeforeSheetDataValidationDeleteAll,eventParams),eventParams.cancel)throw new core.CanceledError;break}}}))}};__name(_FUnvierDataValidationMixin,"FUnvierDataValidationMixin");let FUnvierDataValidationMixin=_FUnvierDataValidationMixin;core.FUniver.extend(FUnvierDataValidationMixin);const _FWorkbookDataValidationMixin=class _FWorkbookDataValidationMixin extends facade.FWorkbook{_initialize(){Object.defineProperty(this,"_dataValidationModel",{get(){return this._injector.get(sheetsDataValidation.SheetDataValidationModel)}})}getValidatorStatus(){return this._injector.get(sheetsDataValidation.SheetsDataValidationValidatorService).validatorWorkbook(this._workbook.getUnitId())}onDataValidationChange(callback){return core.toDisposable(this._dataValidationModel.ruleChange$.pipe(rxjs.filter(change=>change.unitId===this._workbook.getUnitId())).subscribe(callback))}onDataValidationStatusChange(callback){return core.toDisposable(this._dataValidationModel.validStatusChange$.pipe(rxjs.filter(change=>change.unitId===this._workbook.getUnitId())).subscribe(callback))}onBeforeAddDataValidation(callback){return core.toDisposable(this._commandService.beforeCommandExecuted((commandInfo,options)=>{const params=commandInfo.params;if(commandInfo.id===sheetsDataValidation.AddSheetDataValidationCommand.id){if(params.unitId!==this._workbook.getUnitId())return;if(callback(params,options)===!1)throw new Error("Command is stopped by the hook onBeforeAddDataValidation")}}))}onBeforeUpdateDataValidationCriteria(callback){return core.toDisposable(this._commandService.beforeCommandExecuted((commandInfo,options)=>{const params=commandInfo.params;if(commandInfo.id===sheetsDataValidation.UpdateSheetDataValidationSettingCommand.id){if(params.unitId!==this._workbook.getUnitId())return;if(callback(params,options)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationCriteria")}}))}onBeforeUpdateDataValidationRange(callback){return core.toDisposable(this._commandService.beforeCommandExecuted((commandInfo,options)=>{const params=commandInfo.params;if(commandInfo.id===sheetsDataValidation.UpdateSheetDataValidationRangeCommand.id){if(params.unitId!==this._workbook.getUnitId())return;if(callback(params,options)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationRange")}}))}onBeforeUpdateDataValidationOptions(callback){return core.toDisposable(this._commandService.beforeCommandExecuted((commandInfo,options)=>{const params=commandInfo.params;if(commandInfo.id===sheetsDataValidation.UpdateSheetDataValidationOptionsCommand.id){if(params.unitId!==this._workbook.getUnitId())return;if(callback(params,options)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationOptions")}}))}onBeforeDeleteDataValidation(callback){return core.toDisposable(this._commandService.beforeCommandExecuted((commandInfo,options)=>{const params=commandInfo.params;if(commandInfo.id===sheetsDataValidation.RemoveSheetDataValidationCommand.id){if(params.unitId!==this._workbook.getUnitId())return;if(callback(params,options)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteDataValidation")}}))}onBeforeDeleteAllDataValidation(callback){return core.toDisposable(this._commandService.beforeCommandExecuted((commandInfo,options)=>{const params=commandInfo.params;if(commandInfo.id===sheetsDataValidation.RemoveSheetAllDataValidationCommand.id){if(params.unitId!==this._workbook.getUnitId())return;if(callback(params,options)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteAllDataValidation")}}))}};__name(_FWorkbookDataValidationMixin,"FWorkbookDataValidationMixin");let FWorkbookDataValidationMixin=_FWorkbookDataValidationMixin;facade.FWorkbook.extend(FWorkbookDataValidationMixin);const _FWorksheetDataValidationMixin=class _FWorksheetDataValidationMixin extends facade.FWorksheet{getDataValidations(){return this._injector.get(dataValidation.DataValidationModel).getRules(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(rule=>new FDataValidation(rule,this._worksheet,this._injector))}getValidatorStatus(){return this._injector.get(sheetsDataValidation.SheetsDataValidationValidatorService).validatorWorksheet(this._workbook.getUnitId(),this._worksheet.getSheetId())}getValidatorStatusAsync(){return this.getValidatorStatus()}getDataValidation(ruleId){const rule=this._injector.get(dataValidation.DataValidationModel).getRuleById(this._workbook.getUnitId(),this._worksheet.getSheetId(),ruleId);return rule?new FDataValidation(rule,this._worksheet,this._injector):null}};__name(_FWorksheetDataValidationMixin,"FWorksheetDataValidationMixin");let FWorksheetDataValidationMixin=_FWorksheetDataValidationMixin;facade.FWorksheet.extend(FWorksheetDataValidationMixin);const _FDataValidationEvent=class _FDataValidationEvent{get SheetDataValidationChanged(){return"SheetDataValidationChanged"}get SheetDataValidatorStatusChanged(){return"SheetDataValidatorStatusChanged"}get BeforeSheetDataValidationAdd(){return"BeforeSheetDataValidationAdd"}get BeforeSheetDataValidationDelete(){return"BeforeSheetDataValidationDelete"}get BeforeSheetDataValidationDeleteAll(){return"BeforeSheetDataValidationDeleteAll"}get BeforeSheetDataValidationCriteriaUpdate(){return"BeforeSheetDataValidationCriteriaUpdate"}get BeforeSheetDataValidationRangeUpdate(){return"BeforeSheetDataValidationRangeUpdate"}get BeforeSheetDataValidationOptionsUpdate(){return"BeforeSheetDataValidationOptionsUpdate"}};__name(_FDataValidationEvent,"FDataValidationEvent");let FDataValidationEvent=_FDataValidationEvent;core.FEventName.extend(FDataValidationEvent),exports2.FDataValidation=FDataValidation,exports2.FDataValidationBuilder=FDataValidationBuilder,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
|