@univerjs/sheets-data-validation 0.4.2 → 0.5.0-beta.0
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 -0
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +641 -0
- package/lib/es/index.js +2070 -2290
- package/lib/types/controllers/dv-formula-ref-range.controller.d.ts +13 -0
- package/lib/types/facade/f-data-validation-builder.d.ts +247 -0
- package/lib/types/facade/f-data-validation.d.ts +88 -0
- package/lib/types/facade/f-range.d.ts +33 -0
- package/lib/types/facade/f-univer.d.ts +6 -0
- package/lib/types/facade/f-workbook.d.ts +64 -0
- package/lib/types/facade/f-worksheet.d.ts +20 -0
- package/lib/types/facade/index.d.ts +21 -0
- package/lib/types/models/sheet-data-validation-model.d.ts +1 -2
- package/lib/types/services/dv-custom-formula.service.d.ts +8 -15
- package/lib/types/services/dv-formula.service.d.ts +3 -3
- package/lib/types/utils/formula.d.ts +5 -1
- package/lib/types/validators/checkbox-validator.d.ts +3 -6
- package/lib/types/validators/const.d.ts +17 -0
- package/lib/types/validators/custom-validator.d.ts +1 -1
- package/lib/types/validators/date-validator.d.ts +5 -7
- package/lib/types/validators/decimal-validator.d.ts +6 -7
- package/lib/types/validators/text-length-validator.d.ts +5 -3
- package/lib/types/validators/util.d.ts +7 -1
- package/lib/types/validators/whole-validator.d.ts +5 -6
- package/lib/umd/facade.js +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +26 -17
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ISheetDataValidationRule, Disposable } from '@univerjs/core';
|
|
2
|
+
import { FormulaRefRangeService } from '@univerjs/sheets-formula';
|
|
3
|
+
import { SheetDataValidationModel } from '../models/sheet-data-validation-model';
|
|
4
|
+
export declare class DataValidationFormulaRefRangeController extends Disposable {
|
|
5
|
+
private _dataValidationModel;
|
|
6
|
+
private _formulaRefRangeService;
|
|
7
|
+
private _disposableMap;
|
|
8
|
+
constructor(_dataValidationModel: SheetDataValidationModel, _formulaRefRangeService: FormulaRefRangeService);
|
|
9
|
+
private _getIdWithUnitId;
|
|
10
|
+
registerRule: (unitId: string, subUnitId: string, rule: ISheetDataValidationRule) => void;
|
|
11
|
+
register(unitId: string, subUnitId: string, rule: ISheetDataValidationRule): void;
|
|
12
|
+
private _initRefRange;
|
|
13
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { IDataValidationRule, IDataValidationRuleOptions, DataValidationOperator, DataValidationType } from '@univerjs/core';
|
|
2
|
+
import { FRange } from '@univerjs/sheets/facade';
|
|
3
|
+
import { FDataValidation } from './f-data-validation';
|
|
4
|
+
/**
|
|
5
|
+
* Builder for data validation rules.
|
|
6
|
+
*
|
|
7
|
+
* Set the data validation for cell A1 to require a value from B1:B10.
|
|
8
|
+
* var rule = FUniver.newDataValidation().requireValueInRange(range).build();
|
|
9
|
+
* cell.setDataValidation(rule);
|
|
10
|
+
*/
|
|
11
|
+
export declare class FDataValidationBuilder {
|
|
12
|
+
private _rule;
|
|
13
|
+
constructor(rule?: IDataValidationRule);
|
|
14
|
+
/**
|
|
15
|
+
* Builds an FDataValidation instance based on the _rule property of the current class
|
|
16
|
+
*
|
|
17
|
+
* @returns {FDataValidation} A new instance of the FDataValidation class
|
|
18
|
+
*/
|
|
19
|
+
build(): FDataValidation;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a duplicate of the current DataValidationBuilder object
|
|
22
|
+
*
|
|
23
|
+
* @return {FDataValidationBuilder} A new instance of the DataValidationBuilder class
|
|
24
|
+
*/
|
|
25
|
+
copy(): FDataValidationBuilder;
|
|
26
|
+
/**
|
|
27
|
+
* Determines whether invalid data is allowed
|
|
28
|
+
*
|
|
29
|
+
* @returns {boolean} True if invalid data is allowed, False otherwise
|
|
30
|
+
*/
|
|
31
|
+
getAllowInvalid(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the data validation type of the rule
|
|
34
|
+
*
|
|
35
|
+
* @returns {DataValidationType} The data validation type
|
|
36
|
+
*/
|
|
37
|
+
getCriteriaType(): DataValidationType;
|
|
38
|
+
/**
|
|
39
|
+
* Gets the values used for criteria evaluation
|
|
40
|
+
*
|
|
41
|
+
* @returns {any[]} An array containing the operator, formula1, and formula2 values
|
|
42
|
+
*/
|
|
43
|
+
getCriteriaValues(): any[];
|
|
44
|
+
/**
|
|
45
|
+
* Gets the help text information, which is used to provide users with guidance and support
|
|
46
|
+
*
|
|
47
|
+
* @returns {string | undefined} Returns the help text information. If there is no error message, it returns an undefined value.
|
|
48
|
+
*/
|
|
49
|
+
getHelpText(): string | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Sets the data validation type to CHECKBOX and sets the checked and unchecked values
|
|
52
|
+
*
|
|
53
|
+
* @param checkedValue The value when the checkbox is checked (Optional)
|
|
54
|
+
* @param uncheckedValue The value when the checkbox is unchecked (Optional)
|
|
55
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
56
|
+
*/
|
|
57
|
+
requireCheckbox(checkedValue?: string, uncheckedValue?: string): FDataValidationBuilder;
|
|
58
|
+
/**
|
|
59
|
+
* Set the data validation type to DATE and configure the validation rules to be after a specific date
|
|
60
|
+
*
|
|
61
|
+
* @param date The date to compare against. The formatted date string will be set as formula1
|
|
62
|
+
* @return The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
63
|
+
*/
|
|
64
|
+
requireDateAfter(date: Date): FDataValidationBuilder;
|
|
65
|
+
/**
|
|
66
|
+
* Set the data validation type to DATE and configure the validation rules to be before a specific date
|
|
67
|
+
*
|
|
68
|
+
* @param date The date to compare against. The formatted date string will be set as formula1
|
|
69
|
+
* @return The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
70
|
+
*/
|
|
71
|
+
requireDateBefore(date: Date): FDataValidationBuilder;
|
|
72
|
+
/**
|
|
73
|
+
* Set the data validation type to DATE and configure the validation rules to be within a specific date range
|
|
74
|
+
*
|
|
75
|
+
* @param start The starting date of the range. The formatted date string will be set as formula1
|
|
76
|
+
* @param end The ending date of the range. The formatted date string will be set as formula2
|
|
77
|
+
* @return The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
78
|
+
*/
|
|
79
|
+
requireDateBetween(start: Date, end: Date): FDataValidationBuilder;
|
|
80
|
+
/**
|
|
81
|
+
* Set the data validation type to DATE and configure the validation rules to be equal to 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
|
|
85
|
+
*/
|
|
86
|
+
requireDateEqualTo(date: Date): FDataValidationBuilder;
|
|
87
|
+
/**
|
|
88
|
+
* Set the data validation type to DATE and configure the validation rules to be not within a specific date range
|
|
89
|
+
*
|
|
90
|
+
* @param start The starting date of the date range
|
|
91
|
+
* @param end The ending date of the date range
|
|
92
|
+
* @return The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
93
|
+
*/
|
|
94
|
+
requireDateNotBetween(start: Date, end: Date): FDataValidationBuilder;
|
|
95
|
+
/**
|
|
96
|
+
* Set the data validation type to DATE and configure the validation rules to be on or after a specific date
|
|
97
|
+
*
|
|
98
|
+
* @param date The date to compare against. The formatted date string will be set as formula1
|
|
99
|
+
* @return The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
100
|
+
*/
|
|
101
|
+
requireDateOnOrAfter(date: Date): FDataValidationBuilder;
|
|
102
|
+
/**
|
|
103
|
+
* Set the data validation type to DATE and configure the validation rules to be on or before a specific date
|
|
104
|
+
*
|
|
105
|
+
* @param date The date to compare against. The formatted date string will be set as formula1
|
|
106
|
+
* @return The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
107
|
+
*/
|
|
108
|
+
requireDateOnOrBefore(date: Date): FDataValidationBuilder;
|
|
109
|
+
/**
|
|
110
|
+
* Requires that a custom formula be satisfied.
|
|
111
|
+
* Sets the data validation type to CUSTOM and configures the validation rule based on the provided formula string.
|
|
112
|
+
*
|
|
113
|
+
* @param formula The formula string that needs to be satisfied.
|
|
114
|
+
* @return The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
115
|
+
*/
|
|
116
|
+
requireFormulaSatisfied(formula: string): FDataValidationBuilder;
|
|
117
|
+
/**
|
|
118
|
+
* Requires the user to enter a number within a specific range, which can be integer or decimal.
|
|
119
|
+
* Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number range.
|
|
120
|
+
*
|
|
121
|
+
* @param start The starting value of the number range.
|
|
122
|
+
* @param end The ending value of the number range.
|
|
123
|
+
* @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or decimal.
|
|
124
|
+
* @return The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
125
|
+
*/
|
|
126
|
+
requireNumberBetween(start: number, end: number, isInteger?: boolean): FDataValidationBuilder;
|
|
127
|
+
/**
|
|
128
|
+
* Requires the user to enter a number that is equal to a specific value, which can be an integer or a decimal.
|
|
129
|
+
* Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.
|
|
130
|
+
*
|
|
131
|
+
* @param num The number to which the entered number should be equal.
|
|
132
|
+
* @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.
|
|
133
|
+
* @return The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
134
|
+
*/
|
|
135
|
+
requireNumberEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder;
|
|
136
|
+
/**
|
|
137
|
+
* Requires the user to enter a number that is greater than a specific value, which can be an integer or a decimal.
|
|
138
|
+
* Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.
|
|
139
|
+
*
|
|
140
|
+
* @param num The number to which the entered number should be greater.
|
|
141
|
+
* @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.
|
|
142
|
+
* @return The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
143
|
+
*/
|
|
144
|
+
requireNumberGreaterThan(num: number, isInteger?: boolean): FDataValidationBuilder;
|
|
145
|
+
/**
|
|
146
|
+
* 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.
|
|
147
|
+
* Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.
|
|
148
|
+
*
|
|
149
|
+
* @param num The number to which the entered number should be greater than or equal.
|
|
150
|
+
* @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.
|
|
151
|
+
* @return The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
152
|
+
*/
|
|
153
|
+
requireNumberGreaterThanOrEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder;
|
|
154
|
+
/**
|
|
155
|
+
* Requires the user to enter a number that is less than a specific value, which can be an integer or a decimal.
|
|
156
|
+
* Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.
|
|
157
|
+
*
|
|
158
|
+
* @param num The number to which the entered number should be less.
|
|
159
|
+
* @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.
|
|
160
|
+
* @return The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
161
|
+
*/
|
|
162
|
+
requireNumberLessThan(num: number, isInteger?: boolean): FDataValidationBuilder;
|
|
163
|
+
/**
|
|
164
|
+
* Sets the data validation rule to require a number less than or equal to a specified value
|
|
165
|
+
* The specified value can be an integer or a decimal
|
|
166
|
+
*
|
|
167
|
+
* @param num The number to which the entered number should be less than or equal
|
|
168
|
+
* @param isInteger Indicates whether the required number is an integer
|
|
169
|
+
* @return The current instance of the DataValidationBuilder class, allowing for method chaining
|
|
170
|
+
*/
|
|
171
|
+
requireNumberLessThanOrEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder;
|
|
172
|
+
/**
|
|
173
|
+
* Sets a data validation rule that requires the user to enter a number outside a specified range
|
|
174
|
+
* The specified range includes all integers and decimals
|
|
175
|
+
*
|
|
176
|
+
* @param start The starting point of the specified range
|
|
177
|
+
* @param end The end point of the specified range
|
|
178
|
+
* @param isInteger Optional parameter, indicating whether the number to be verified is an integer. Default value is false
|
|
179
|
+
* @return An instance of the FDataValidationBuilder class, allowing for method chaining
|
|
180
|
+
*/
|
|
181
|
+
requireNumberNotBetween(start: number, end: number, isInteger?: boolean): FDataValidationBuilder;
|
|
182
|
+
/**
|
|
183
|
+
* Creates a data validation rule that requires the user to enter a number that is not equal to a specific value
|
|
184
|
+
* The specific value can be an integer or a decimal
|
|
185
|
+
*
|
|
186
|
+
* @param num The number to which the entered number should not be equal
|
|
187
|
+
* @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal
|
|
188
|
+
* @return The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
189
|
+
*/
|
|
190
|
+
requireNumberNotEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder;
|
|
191
|
+
/**
|
|
192
|
+
* Sets a data validation rule that requires the user to enter a value from a list of specific values.
|
|
193
|
+
* The list can be displayed in a dropdown, and the user can choose multiple values according to the settings.
|
|
194
|
+
*
|
|
195
|
+
* @param values An array containing the specific values that the user can enter.
|
|
196
|
+
* @param multiple Optional parameter indicating whether the user can select multiple values. Default is false, meaning only one value can be selected.
|
|
197
|
+
* @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.
|
|
198
|
+
* @return An instance of the FDataValidationBuilder class, allowing for method chaining.
|
|
199
|
+
*/
|
|
200
|
+
requireValueInList(values: string[], multiple?: boolean, showDropdown?: boolean): FDataValidationBuilder;
|
|
201
|
+
/**
|
|
202
|
+
* Sets a data validation rule that requires the user to enter a value within a specific range.
|
|
203
|
+
* The range is defined by an FRange object, which contains the unit ID, sheet name, and cell range.
|
|
204
|
+
*
|
|
205
|
+
* @param range An FRange object representing the range of values that the user can enter.
|
|
206
|
+
* @param multiple Optional parameter indicating whether the user can select multiple values. Default is false, meaning only one value can be selected.
|
|
207
|
+
* @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.
|
|
208
|
+
* @return The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
209
|
+
*/
|
|
210
|
+
requireValueInRange(range: FRange, multiple?: boolean, showDropdown?: boolean): FDataValidationBuilder;
|
|
211
|
+
/**
|
|
212
|
+
* Sets whether to allow invalid data and configures the error style for data validation.
|
|
213
|
+
* If invalid data is not allowed, the error style will be set to STOP, indicating that data entry must stop upon encountering an error.
|
|
214
|
+
* 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.
|
|
215
|
+
*
|
|
216
|
+
* @param allowInvalidData A boolean value indicating whether to allow invalid data.
|
|
217
|
+
* @return The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
218
|
+
*/
|
|
219
|
+
setAllowInvalid(allowInvalidData: boolean): FDataValidationBuilder;
|
|
220
|
+
/**
|
|
221
|
+
* Sets the help text and enables the display of error messages for data validation.
|
|
222
|
+
* This method allows you to set a custom help text that will be displayed when the user enters invalid data.
|
|
223
|
+
*
|
|
224
|
+
* @param helpText The text to display as help information.
|
|
225
|
+
* @return The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
226
|
+
*/
|
|
227
|
+
setHelpText(helpText: string): FDataValidationBuilder;
|
|
228
|
+
/**
|
|
229
|
+
* Sets the criteria values for data validation.
|
|
230
|
+
* This method is used to configure the validation rules based on specific criteria values.
|
|
231
|
+
*
|
|
232
|
+
* @param type The type of data validation.
|
|
233
|
+
* @param values An array containing the criteria values.
|
|
234
|
+
* The array should have three elements: [operator, formula1, formula2].
|
|
235
|
+
* operator is a DataValidationOperator enum value, formula1 is the first formula, and formula2 is the second formula.
|
|
236
|
+
* @return The current instance of the FDataValidationBuilder class, allowing for method chaining.
|
|
237
|
+
*/
|
|
238
|
+
withCriteriaValues(type: DataValidationType, values: [DataValidationOperator, string, string]): this;
|
|
239
|
+
/**
|
|
240
|
+
* Sets the options for the data validation rule.
|
|
241
|
+
* For details of options, please refer to https://univer.ai/typedoc/@univerjs/core/interfaces/IDataValidationRuleOptions
|
|
242
|
+
*
|
|
243
|
+
* @param options The options to set for the data validation rule.
|
|
244
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
245
|
+
*/
|
|
246
|
+
setOptions(options: Partial<IDataValidationRuleOptions>): this;
|
|
247
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { DataValidationOperator, DataValidationType, IDataValidationRule, IDataValidationRuleOptions } from '@univerjs/core';
|
|
2
|
+
import { FWorksheet, FRange } from '@univerjs/sheets/facade';
|
|
3
|
+
import { FDataValidationBuilder } from './f-data-validation-builder';
|
|
4
|
+
export declare class FDataValidation {
|
|
5
|
+
rule: IDataValidationRule;
|
|
6
|
+
private _worksheet;
|
|
7
|
+
constructor(rule: IDataValidationRule, worksheet?: FWorksheet);
|
|
8
|
+
/**
|
|
9
|
+
* Gets whether invalid data is allowed based on the error style value.
|
|
10
|
+
*
|
|
11
|
+
* @return true if invalid data is allowed, false otherwise.
|
|
12
|
+
*/
|
|
13
|
+
getAllowInvalid(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Gets the data validation type of the rule
|
|
16
|
+
*
|
|
17
|
+
* @returns The data validation type
|
|
18
|
+
*/
|
|
19
|
+
getCriteriaType(): DataValidationType;
|
|
20
|
+
/**
|
|
21
|
+
* Gets the values used for criteria evaluation
|
|
22
|
+
*
|
|
23
|
+
* @returns An array containing the operator, formula1, and formula2 values
|
|
24
|
+
*/
|
|
25
|
+
getCriteriaValues(): (string | undefined)[];
|
|
26
|
+
/**
|
|
27
|
+
* Gets the help text information, which is used to provide users with guidance and support
|
|
28
|
+
*
|
|
29
|
+
* @returns Returns the help text information. If there is no error message, it returns an undefined value.
|
|
30
|
+
*/
|
|
31
|
+
getHelpText(): string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a new instance of FDataValidationBuilder using the current rule object.
|
|
34
|
+
* This method is useful for copying an existing data validation rule configuration.
|
|
35
|
+
*
|
|
36
|
+
* @return A new FDataValidationBuilder instance with the same rule configuration.
|
|
37
|
+
*/
|
|
38
|
+
copy(): FDataValidationBuilder;
|
|
39
|
+
/**
|
|
40
|
+
* Gets whether the data validation rule is applied to the worksheet.
|
|
41
|
+
*
|
|
42
|
+
* @returns true if the rule is applied, false otherwise.
|
|
43
|
+
*/
|
|
44
|
+
getApplied(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Gets the ranges to which the data validation rule is applied.
|
|
47
|
+
*
|
|
48
|
+
* @returns An array of IRange objects representing the ranges to which the data validation rule is applied.
|
|
49
|
+
*/
|
|
50
|
+
getRanges(): FRange[];
|
|
51
|
+
/**
|
|
52
|
+
* Gets the title of the error message dialog box.
|
|
53
|
+
*
|
|
54
|
+
* @returns The title of the error message dialog box.
|
|
55
|
+
*/
|
|
56
|
+
getUnitId(): string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Gets the sheetId of the worksheet.
|
|
59
|
+
*
|
|
60
|
+
* @returns The sheetId of the worksheet.
|
|
61
|
+
*/
|
|
62
|
+
getSheetId(): string | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Set Criteria for the data validation rule.
|
|
65
|
+
* @param type The type of data validation criteria.
|
|
66
|
+
* @param values An array containing the operator, formula1, and formula2 values.
|
|
67
|
+
* @returns true if the criteria is set successfully, false otherwise.
|
|
68
|
+
*/
|
|
69
|
+
setCriteria(type: DataValidationType, values: [DataValidationOperator, string, string]): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Set the options for the data validation rule.
|
|
72
|
+
* For details of options, please refer to https://univer.ai/typedoc/@univerjs/core/interfaces/IDataValidationRuleOptions
|
|
73
|
+
* @param options An object containing the options to set. `IDataValidationRuleOptions`
|
|
74
|
+
* @returns true if the options are set successfully, false otherwise.
|
|
75
|
+
*/
|
|
76
|
+
setOptions(options: Partial<IDataValidationRuleOptions>): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Set the ranges to the data validation rule.
|
|
79
|
+
* @param ranges new ranges array.
|
|
80
|
+
* @returns true if the ranges are set successfully, false otherwise.
|
|
81
|
+
*/
|
|
82
|
+
setRanges(ranges: FRange[]): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Delete the data validation rule from the worksheet.
|
|
85
|
+
* @returns true if the rule is deleted successfully, false otherwise.
|
|
86
|
+
*/
|
|
87
|
+
delete(): boolean;
|
|
88
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DataValidationStatus, Nullable } from '@univerjs/core';
|
|
2
|
+
import { FRange } from '@univerjs/sheets/facade';
|
|
3
|
+
import { FDataValidation } from './f-data-validation';
|
|
4
|
+
interface IFRangeDataValidationMixin {
|
|
5
|
+
/**
|
|
6
|
+
* set a data validation rule to current range
|
|
7
|
+
* @param rule data validation rule, build by `FUniver.newDataValidation`
|
|
8
|
+
* @returns current range
|
|
9
|
+
*/
|
|
10
|
+
setDataValidation(this: FRange, rule: Nullable<FDataValidation>): Promise<FRange>;
|
|
11
|
+
/**
|
|
12
|
+
* get first data validation rule in current range
|
|
13
|
+
* @returns data validation rule
|
|
14
|
+
*/
|
|
15
|
+
getDataValidation(this: FRange): Nullable<FDataValidation>;
|
|
16
|
+
/**
|
|
17
|
+
* get all data validation rules in current range
|
|
18
|
+
* @returns all data validation rules
|
|
19
|
+
*/
|
|
20
|
+
getDataValidations(this: FRange): FDataValidation[];
|
|
21
|
+
getValidatorStatus(): Promise<Promise<DataValidationStatus>[][]>;
|
|
22
|
+
}
|
|
23
|
+
export declare class FRangeDataValidationMixin extends FRange implements IFRangeDataValidationMixin {
|
|
24
|
+
setDataValidation(rule: Nullable<FDataValidation>): Promise<FRange>;
|
|
25
|
+
getDataValidation(): Nullable<FDataValidation>;
|
|
26
|
+
getDataValidations(): FDataValidation[];
|
|
27
|
+
getValidatorStatus(): Promise<Promise<DataValidationStatus>[][]>;
|
|
28
|
+
}
|
|
29
|
+
declare module '@univerjs/sheets/facade' {
|
|
30
|
+
interface FRange extends IFRangeDataValidationMixin {
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { IRuleChange } from '@univerjs/data-validation';
|
|
2
|
+
import { IAddSheetDataValidationCommandParams, IDataValidationResCache, IRemoveSheetAllDataValidationCommandParams, IRemoveSheetDataValidationCommandParams, IUpdateSheetDataValidationOptionsCommandParams, IUpdateSheetDataValidationRangeCommandParams, IUpdateSheetDataValidationSettingCommandParams, IValidStatusChange } from '@univerjs/sheets-data-validation';
|
|
3
|
+
import { IDisposable, IExecutionOptions, Nullable, ObjectMatrix } from '@univerjs/core';
|
|
4
|
+
import { FWorkbook } from '@univerjs/sheets/facade';
|
|
5
|
+
interface IFWorkbookDataValidationMixin {
|
|
6
|
+
/**
|
|
7
|
+
* get data validation validator status for current workbook
|
|
8
|
+
* @returns matrix of validator status
|
|
9
|
+
*/
|
|
10
|
+
getValidatorStatus(this: FWorkbook): Promise<Record<string, ObjectMatrix<Nullable<IDataValidationResCache>>>>;
|
|
11
|
+
/**
|
|
12
|
+
* The onDataValidationChange event is fired when the data validation rule of this sheet is changed.
|
|
13
|
+
* @param callback Callback function that will be called when the event is fired
|
|
14
|
+
* @returns A disposable object that can be used to unsubscribe from the event
|
|
15
|
+
*/
|
|
16
|
+
onDataValidationChange(callback: (ruleChange: IRuleChange) => void): IDisposable;
|
|
17
|
+
/**
|
|
18
|
+
* The onDataValidationStatusChange event is fired when the data validation status of this sheet is changed.
|
|
19
|
+
* @param callback Callback function that will be called when the event is fired
|
|
20
|
+
* @returns A disposable object that can be used to unsubscribe from the event
|
|
21
|
+
*/
|
|
22
|
+
onDataValidationStatusChange(callback: (statusChange: IValidStatusChange) => void): IDisposable;
|
|
23
|
+
/**
|
|
24
|
+
* The onBeforeAddDataValidation event is fired before the data validation rule is added.
|
|
25
|
+
* @param callback Callback function that will be called when the event is fired
|
|
26
|
+
* @returns A disposable object that can be used to unsubscribe from the event
|
|
27
|
+
*/
|
|
28
|
+
onBeforeAddDataValidation(this: FWorkbook, callback: (params: IAddSheetDataValidationCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
|
29
|
+
/**
|
|
30
|
+
* The onBeforeUpdateDataValidationCriteria event is fired before the data validation rule is updated.
|
|
31
|
+
* @param callback Callback function that will be called when the event is fired
|
|
32
|
+
* @returns A disposable object that can be used to unsubscribe from the event
|
|
33
|
+
*/
|
|
34
|
+
onBeforeUpdateDataValidationCriteria(this: FWorkbook, callback: (params: IUpdateSheetDataValidationSettingCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
|
35
|
+
/**
|
|
36
|
+
* The onBeforeUpdateDataValidationRange event is fired before the data validation rule is updated.
|
|
37
|
+
* @param callback Callback function that will be called when the event is fired
|
|
38
|
+
* @returns A disposable object that can be used to unsubscribe from the event
|
|
39
|
+
*/
|
|
40
|
+
onBeforeUpdateDataValidationRange(this: FWorkbook, callback: (params: IUpdateSheetDataValidationRangeCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
|
41
|
+
/**
|
|
42
|
+
* The onBeforeUpdateDataValidationOptions event is fired before the data validation rule is updated.
|
|
43
|
+
* @param callback Callback function that will be called when the event is fired
|
|
44
|
+
* @returns A disposable object that can be used to unsubscribe from the event
|
|
45
|
+
*/
|
|
46
|
+
onBeforeUpdateDataValidationOptions(this: FWorkbook, callback: (params: IUpdateSheetDataValidationOptionsCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
|
47
|
+
/**
|
|
48
|
+
* The onBeforeDeleteDataValidation event is fired before the data validation rule is deleted.
|
|
49
|
+
* @param callback Callback function that will be called when the event is fired
|
|
50
|
+
* @returns A disposable object that can be used to unsubscribe from the event
|
|
51
|
+
*/
|
|
52
|
+
onBeforeDeleteDataValidation(this: FWorkbook, callback: (params: IRemoveSheetDataValidationCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
|
53
|
+
/**
|
|
54
|
+
* The onBeforeDeleteAllDataValidation event is fired before delete all data validation rules.
|
|
55
|
+
* @param callback Callback function that will be called when the event is fired
|
|
56
|
+
* @returns A disposable object that can be used to unsubscribe from the event
|
|
57
|
+
*/
|
|
58
|
+
onBeforeDeleteAllDataValidation(this: FWorkbook, callback: (params: IRemoveSheetAllDataValidationCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
|
59
|
+
}
|
|
60
|
+
declare module '@univerjs/sheets/facade' {
|
|
61
|
+
interface FWorkbook extends IFWorkbookDataValidationMixin {
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Nullable, ObjectMatrix } from '@univerjs/core';
|
|
2
|
+
import { IDataValidationResCache } from '@univerjs/sheets-data-validation';
|
|
3
|
+
import { FDataValidation } from './f-data-validation';
|
|
4
|
+
interface IFWorksheetDataValidationMixin {
|
|
5
|
+
/**
|
|
6
|
+
* get all data validation rules in current sheet
|
|
7
|
+
* @returns all data validation rules
|
|
8
|
+
*/
|
|
9
|
+
getDataValidations(): FDataValidation[];
|
|
10
|
+
/**
|
|
11
|
+
* get data validation validator status for current sheet
|
|
12
|
+
* @returns matrix of validator status
|
|
13
|
+
*/
|
|
14
|
+
getValidatorStatus(): Promise<ObjectMatrix<Nullable<IDataValidationResCache>>>;
|
|
15
|
+
}
|
|
16
|
+
declare module '@univerjs/sheets/facade' {
|
|
17
|
+
interface FWorksheet extends IFWorksheetDataValidationMixin {
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import './f-range';
|
|
17
|
+
import './f-univer';
|
|
18
|
+
import './f-workbook';
|
|
19
|
+
import './f-worksheet';
|
|
20
|
+
export { FDataValidation } from './f-data-validation';
|
|
21
|
+
export { FDataValidationBuilder } from './f-data-validation-builder';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ISheetDataValidationRule, DataValidationStatus,
|
|
1
|
+
import { DataValidationType, ISheetDataValidationRule, DataValidationStatus, Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
|
|
2
2
|
import { IRuleChange, DataValidationModel, DataValidatorRegistryService } from '@univerjs/data-validation';
|
|
3
3
|
import { ISheetLocation } from '@univerjs/sheets';
|
|
4
4
|
import { DataValidationCacheService } from '../services/dv-cache.service';
|
|
@@ -38,7 +38,6 @@ export declare class SheetDataValidationModel extends Disposable {
|
|
|
38
38
|
getRuleIdByLocation(unitId: string, subUnitId: string, row: number, col: number): string | undefined;
|
|
39
39
|
getRuleByLocation(unitId: string, subUnitId: string, row: number, col: number): ISheetDataValidationRule | undefined;
|
|
40
40
|
validator(rule: ISheetDataValidationRule, pos: ISheetLocation, _onCompete?: (status: DataValidationStatus, changed: boolean) => void): DataValidationStatus;
|
|
41
|
-
getRuleErrorMsg(unitId: string, subUnitId: string, ruleId: string): string;
|
|
42
41
|
getRuleObjectMatrix(unitId: string, subUnitId: string): RuleMatrix;
|
|
43
42
|
getRuleById(unitId: string, subUnitId: string, ruleId: string): ISheetDataValidationRule | undefined;
|
|
44
43
|
getRuleIndex(unitId: string, subUnitId: string, ruleId: string): number;
|
|
@@ -1,41 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ISheetDataValidationRule, Disposable, IUniverInstanceService } from '@univerjs/core';
|
|
2
2
|
import { DataValidationModel } from '@univerjs/data-validation';
|
|
3
|
-
import { LexerTreeBuilder } from '@univerjs/engine-formula';
|
|
4
3
|
import { RegisterOtherFormulaService } from '@univerjs/sheets-formula';
|
|
5
4
|
import { DataValidationCacheService } from './dv-cache.service';
|
|
6
5
|
interface IFormulaData {
|
|
7
6
|
formula: string;
|
|
8
7
|
originRow: number;
|
|
9
8
|
originCol: number;
|
|
10
|
-
|
|
11
|
-
formulaId?: string;
|
|
9
|
+
formulaId: string;
|
|
12
10
|
}
|
|
13
11
|
export declare class DataValidationCustomFormulaService extends Disposable {
|
|
14
12
|
private readonly _instanceSrv;
|
|
15
13
|
private _registerOtherFormulaService;
|
|
16
|
-
private _lexerTreeBuilder;
|
|
17
14
|
private readonly _dataValidationModel;
|
|
18
15
|
private readonly _dataValidationCacheService;
|
|
19
|
-
private readonly _injector;
|
|
20
|
-
private _formulaMap;
|
|
21
16
|
/**
|
|
22
17
|
* Map of origin formula of rule
|
|
23
18
|
*/
|
|
24
19
|
private _ruleFormulaMap;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*/
|
|
28
|
-
private _formulaCellMap;
|
|
29
|
-
constructor(_instanceSrv: IUniverInstanceService, _registerOtherFormulaService: RegisterOtherFormulaService, _lexerTreeBuilder: LexerTreeBuilder, _dataValidationModel: DataValidationModel, _dataValidationCacheService: DataValidationCacheService, _injector: Injector);
|
|
20
|
+
private _ruleFormulaMap2;
|
|
21
|
+
constructor(_instanceSrv: IUniverInstanceService, _registerOtherFormulaService: RegisterOtherFormulaService, _dataValidationModel: DataValidationModel, _dataValidationCacheService: DataValidationCacheService);
|
|
30
22
|
private _initFormulaResultHandler;
|
|
31
23
|
private _ensureMaps;
|
|
32
24
|
private _registerFormula;
|
|
33
25
|
deleteByRuleId(unitId: string, subUnitId: string, ruleId: string): void;
|
|
34
26
|
private _addFormulaByRange;
|
|
35
27
|
addRule(unitId: string, subUnitId: string, rule: ISheetDataValidationRule): void;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
getCellFormulaValue(unitId: string, subUnitId: string, ruleId: string, row: number, column: number): Promise<import('@univerjs/core').Nullable<import('@univerjs/core').ICellData>>;
|
|
29
|
+
getCellFormula2Value(unitId: string, subUnitId: string, ruleId: string, row: number, column: number): Promise<import('@univerjs/core').Nullable<import('@univerjs/core').ICellData>>;
|
|
30
|
+
getCellFormulaValueSync(unitId: string, subUnitId: string, ruleId: string, row: number, column: number): import('@univerjs/core').Nullable<import('@univerjs/core').ICellData>;
|
|
31
|
+
getCellFormula2ValueSync(unitId: string, subUnitId: string, ruleId: string, row: number, column: number): import('@univerjs/core').Nullable<import('@univerjs/core').ICellData>;
|
|
39
32
|
getRuleFormulaInfo(unitId: string, subUnitId: string, ruleId: string): IFormulaData | undefined;
|
|
40
33
|
}
|
|
41
34
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Nullable, Disposable, IUniverInstanceService } from '@univerjs/core';
|
|
1
|
+
import { ISheetDataValidationRule, Nullable, Disposable, IUniverInstanceService } from '@univerjs/core';
|
|
2
2
|
import { IFormulaInfo, IOtherFormulaResult, RegisterOtherFormulaService } from '@univerjs/sheets-formula';
|
|
3
3
|
import { DataValidationModel } from '@univerjs/data-validation';
|
|
4
4
|
import { DataValidationCacheService } from './dv-cache.service';
|
|
@@ -11,9 +11,9 @@ export declare class DataValidationFormulaService extends Disposable {
|
|
|
11
11
|
constructor(_instanceService: IUniverInstanceService, _registerOtherFormulaService: RegisterOtherFormulaService, _dataValidationCacheService: DataValidationCacheService, _dataValidationModel: DataValidationModel);
|
|
12
12
|
private _initFormulaResultHandler;
|
|
13
13
|
private _ensureRuleFormulaMap;
|
|
14
|
-
|
|
14
|
+
private _registerSingleFormula;
|
|
15
|
+
addRule(unitId: string, subUnitId: string, rule: ISheetDataValidationRule): void;
|
|
15
16
|
removeRule(unitId: string, subUnitId: string, ruleId: string): void;
|
|
16
|
-
updateRuleFormulaText(unitId: string, subUnitId: string, ruleId: string, formula1: string | undefined, formula2: string | undefined): void;
|
|
17
17
|
getRuleFormulaResult(unitId: string, subUnitId: string, ruleId: string): Promise<Nullable<[Nullable<IOtherFormulaResult>, Nullable<IOtherFormulaResult>]>>;
|
|
18
18
|
getRuleFormulaResultSync(unitId: string, subUnitId: string, ruleId: string): Nullable<IOtherFormulaResult>[] | undefined;
|
|
19
19
|
getRuleFormulaInfo(unitId: string, subUnitId: string, ruleId: string): [IFormulaInfo | undefined, IFormulaInfo | undefined] | undefined;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { ICellData, Nullable } from '@univerjs/core';
|
|
1
|
+
import { DataValidationType, ICellData, Nullable } from '@univerjs/core';
|
|
2
2
|
export declare function getFormulaResult(result: Nullable<Nullable<ICellData>[][]>): Nullable<import('@univerjs/core').CellValue>;
|
|
3
3
|
export declare function getFormulaCellData(result: Nullable<Nullable<ICellData>[][]>): Nullable<ICellData>;
|
|
4
4
|
export declare function isLegalFormulaResult(res: string): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Judge if the data-validation's formula need to be offseted by ranges
|
|
7
|
+
*/
|
|
8
|
+
export declare function isCustomFormulaType(type: DataValidationType): type is DataValidationType.CUSTOM | DataValidationType.NONE | DataValidationType.TEXT_LENGTH | DataValidationType.DATE | DataValidationType.TIME | DataValidationType.WHOLE | DataValidationType.DECIMAL;
|
|
@@ -16,18 +16,15 @@ export declare class CheckboxValidator extends BaseDataValidator {
|
|
|
16
16
|
skipDefaultFontRender: (rule: ISheetDataValidationRule, cellValue: Nullable<CellValue>, pos: {
|
|
17
17
|
unitId: string;
|
|
18
18
|
subUnitId: string;
|
|
19
|
+
row: number;
|
|
20
|
+
column: number;
|
|
19
21
|
}) => boolean;
|
|
20
22
|
validatorFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): IFormulaValidResult;
|
|
21
23
|
parseFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): Promise<ICheckboxFormulaResult>;
|
|
22
24
|
getExtraStyle(rule: IDataValidationRule, value: Nullable<CellValue>): {
|
|
23
25
|
tb: WrapStrategy;
|
|
24
26
|
};
|
|
25
|
-
parseFormulaSync(rule: IDataValidationRule, unitId: string, subUnitId: string):
|
|
26
|
-
formula1: Nullable<CellValue>;
|
|
27
|
-
formula2: Nullable<CellValue>;
|
|
28
|
-
originFormula1: Nullable<CellValue>;
|
|
29
|
-
originFormula2: Nullable<CellValue>;
|
|
30
|
-
};
|
|
27
|
+
parseFormulaSync(rule: IDataValidationRule, unitId: string, subUnitId: string): ICheckboxFormulaResult;
|
|
31
28
|
isValidType(cellInfo: IValidatorCellInfo<CellValue>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
|
|
32
29
|
generateRuleErrorMessage(rule: IDataValidationRuleBase): string;
|
|
33
30
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export declare const FORMULA1 = "{FORMULA1}";
|
|
17
|
+
export declare const FORMULA2 = "{FORMULA2}";
|
|
@@ -5,7 +5,7 @@ export declare class CustomFormulaValidator extends BaseDataValidator {
|
|
|
5
5
|
title: string;
|
|
6
6
|
operators: DataValidationOperator[];
|
|
7
7
|
scopes: string | string[];
|
|
8
|
-
private _customFormulaService;
|
|
8
|
+
private readonly _customFormulaService;
|
|
9
9
|
validatorFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): IFormulaValidResult;
|
|
10
10
|
parseFormula(_rule: IDataValidationRule, _unitId: string, _subUnitId: string): Promise<IFormulaResult>;
|
|
11
11
|
isValidType(cellInfo: IValidatorCellInfo<CellValue>, _formula: IFormulaResult, _rule: IDataValidationRule): Promise<boolean>;
|