@univerjs/data-validation 0.2.4 → 0.2.6
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/index.js +1 -1
- package/lib/es/index.js +597 -593
- package/lib/types/commands/commands/data-validation.command.d.ts +1 -2
- package/lib/types/commands/mutations/data-validation.mutation.d.ts +4 -0
- package/lib/types/common/util.d.ts +1 -2
- package/lib/types/index.d.ts +1 -1
- package/lib/types/models/data-validation-manager.d.ts +1 -2
- package/lib/types/models/data-validation-model.d.ts +7 -5
- package/lib/types/plugin.d.ts +2 -3
- package/lib/types/services/data-validator-registry.service.d.ts +1 -1
- package/lib/types/validators/base-data-validator.d.ts +1 -2
- package/lib/umd/index.js +1 -1
- package/package.json +9 -11
package/lib/es/index.js
CHANGED
|
@@ -1,142 +1,142 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import { Inject
|
|
6
|
-
import { BehaviorSubject
|
|
7
|
-
import { SheetsSelectionsService
|
|
8
|
-
var
|
|
9
|
-
class
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
+
import { toDisposable, Tools, DataValidationType, DataValidationOperator, Disposable, DataValidationStatus, ILogService, CommandType, ICommandService, IUndoRedoService, UniverInstanceType, OnLifecycle, LifecycleStages, Inject, IResourceManagerService, IUniverInstanceService, Plugin, Injector, LocaleService } from "@univerjs/core";
|
|
6
|
+
import { BehaviorSubject, Subject, debounceTime } from "rxjs";
|
|
7
|
+
import { SheetsSelectionsService, RemoveSheetCommand, SheetInterceptorService } from "@univerjs/sheets";
|
|
8
|
+
var DataValidatorRegistryScope = /* @__PURE__ */ ((DataValidatorRegistryScope2) => (DataValidatorRegistryScope2.SHEET = "sheet", DataValidatorRegistryScope2))(DataValidatorRegistryScope || {});
|
|
9
|
+
const _DataValidatorRegistryService = class _DataValidatorRegistryService {
|
|
10
10
|
constructor() {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
_addValidatorToScope(
|
|
17
|
-
this._validatorByScopes.has(
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
throw new Error(`Validator item with the same id ${
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
_removeValidatorFromScope(
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
11
|
+
__publicField(this, "_validatorByScopes", /* @__PURE__ */ new Map());
|
|
12
|
+
__publicField(this, "_validatorMap", /* @__PURE__ */ new Map());
|
|
13
|
+
__publicField(this, "_validatorsChange$", new BehaviorSubject(void 0));
|
|
14
|
+
__publicField(this, "validatorsChange$", this._validatorsChange$.asObservable());
|
|
15
|
+
}
|
|
16
|
+
_addValidatorToScope(validator, scope) {
|
|
17
|
+
this._validatorByScopes.has(scope) || this._validatorByScopes.set(scope, []);
|
|
18
|
+
const validators = this._validatorByScopes.get(scope);
|
|
19
|
+
if (validators.findIndex((m) => m.id === validator.id) > -1)
|
|
20
|
+
throw new Error(`Validator item with the same id ${validator.id} has already been added!`);
|
|
21
|
+
validators.push(validator);
|
|
22
|
+
}
|
|
23
|
+
_removeValidatorFromScope(validator, scope) {
|
|
24
|
+
const validators = this._validatorByScopes.get(scope);
|
|
25
|
+
if (!validators)
|
|
26
26
|
return;
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
register(
|
|
31
|
-
return this._validatorMap.set(
|
|
32
|
-
this._addValidatorToScope(
|
|
33
|
-
}) : this._addValidatorToScope(
|
|
34
|
-
this._validatorMap.delete(
|
|
35
|
-
this._removeValidatorFromScope(
|
|
36
|
-
}) : this._removeValidatorFromScope(
|
|
27
|
+
const index = validators.findIndex((v) => v.id === validator.id);
|
|
28
|
+
index > -1 && validators.splice(index, 1);
|
|
29
|
+
}
|
|
30
|
+
register(validator) {
|
|
31
|
+
return this._validatorMap.set(validator.id, validator), Array.isArray(validator.scopes) ? validator.scopes.forEach((scope) => {
|
|
32
|
+
this._addValidatorToScope(validator, scope);
|
|
33
|
+
}) : this._addValidatorToScope(validator, validator.scopes), this._validatorsChange$.next(), toDisposable(() => {
|
|
34
|
+
this._validatorMap.delete(validator.id), Array.isArray(validator.scopes) ? validator.scopes.forEach((scope) => {
|
|
35
|
+
this._removeValidatorFromScope(validator, scope);
|
|
36
|
+
}) : this._removeValidatorFromScope(validator, validator.scopes), this._validatorsChange$.next();
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
getValidatorItem(
|
|
40
|
-
return this._validatorMap.get(
|
|
39
|
+
getValidatorItem(id) {
|
|
40
|
+
return this._validatorMap.get(id);
|
|
41
41
|
}
|
|
42
|
-
getValidatorsByScope(
|
|
43
|
-
return this._validatorByScopes.get(
|
|
42
|
+
getValidatorsByScope(scope) {
|
|
43
|
+
return this._validatorByScopes.get(scope);
|
|
44
44
|
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
};
|
|
46
|
+
__name(_DataValidatorRegistryService, "DataValidatorRegistryService");
|
|
47
|
+
let DataValidatorRegistryService = _DataValidatorRegistryService;
|
|
48
|
+
var UpdateRuleType = /* @__PURE__ */ ((UpdateRuleType2) => (UpdateRuleType2[UpdateRuleType2.SETTING = 0] = "SETTING", UpdateRuleType2[UpdateRuleType2.RANGE = 1] = "RANGE", UpdateRuleType2[UpdateRuleType2.OPTIONS = 2] = "OPTIONS", UpdateRuleType2))(UpdateRuleType || {});
|
|
49
|
+
function getRuleSetting(rule) {
|
|
48
50
|
return {
|
|
49
|
-
type:
|
|
50
|
-
operator:
|
|
51
|
-
formula1:
|
|
52
|
-
formula2:
|
|
53
|
-
allowBlank:
|
|
51
|
+
type: rule.type,
|
|
52
|
+
operator: rule.operator,
|
|
53
|
+
formula1: rule.formula1,
|
|
54
|
+
formula2: rule.formula2,
|
|
55
|
+
allowBlank: rule.allowBlank
|
|
54
56
|
};
|
|
55
57
|
}
|
|
56
|
-
|
|
58
|
+
__name(getRuleSetting, "getRuleSetting");
|
|
59
|
+
function getRuleOptions(rule) {
|
|
57
60
|
return {
|
|
58
|
-
error:
|
|
59
|
-
errorStyle:
|
|
60
|
-
errorTitle:
|
|
61
|
-
imeMode:
|
|
62
|
-
prompt:
|
|
63
|
-
promptTitle:
|
|
64
|
-
showDropDown:
|
|
65
|
-
showErrorMessage:
|
|
66
|
-
showInputMessage:
|
|
67
|
-
renderMode:
|
|
68
|
-
bizInfo:
|
|
61
|
+
error: rule.error,
|
|
62
|
+
errorStyle: rule.errorStyle,
|
|
63
|
+
errorTitle: rule.errorTitle,
|
|
64
|
+
imeMode: rule.imeMode,
|
|
65
|
+
prompt: rule.prompt,
|
|
66
|
+
promptTitle: rule.promptTitle,
|
|
67
|
+
showDropDown: rule.showDropDown,
|
|
68
|
+
showErrorMessage: rule.showErrorMessage,
|
|
69
|
+
showInputMessage: rule.showInputMessage,
|
|
70
|
+
renderMode: rule.renderMode,
|
|
71
|
+
bizInfo: rule.bizInfo
|
|
69
72
|
};
|
|
70
73
|
}
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
__name(getRuleOptions, "getRuleOptions");
|
|
75
|
+
function createDefaultNewRule(accessor) {
|
|
76
|
+
const currentRanges = accessor.get(SheetsSelectionsService).getCurrentSelections().map((s) => s.range);
|
|
73
77
|
return {
|
|
74
|
-
uid:
|
|
75
|
-
type:
|
|
76
|
-
operator:
|
|
78
|
+
uid: Tools.generateRandomId(6),
|
|
79
|
+
type: DataValidationType.DECIMAL,
|
|
80
|
+
operator: DataValidationOperator.EQUAL,
|
|
77
81
|
formula1: "100",
|
|
78
|
-
ranges:
|
|
82
|
+
ranges: currentRanges != null ? currentRanges : [{ startColumn: 0, endColumn: 0, startRow: 0, endRow: 0 }]
|
|
79
83
|
};
|
|
80
84
|
}
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
__name(createDefaultNewRule, "createDefaultNewRule");
|
|
86
|
+
const _DataValidationManager = class _DataValidationManager extends Disposable {
|
|
87
|
+
constructor(unitId, subUnitId) {
|
|
83
88
|
super();
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
this.unitId =
|
|
91
|
-
dispose: () => {
|
|
89
|
+
__publicField(this, "_dataValidations", []);
|
|
90
|
+
__publicField(this, "_dataValidationMap", /* @__PURE__ */ new Map());
|
|
91
|
+
__publicField(this, "_dataValidations$", new BehaviorSubject(this._dataValidations));
|
|
92
|
+
__publicField(this, "unitId");
|
|
93
|
+
__publicField(this, "subUnitId");
|
|
94
|
+
__publicField(this, "dataValidations$", this._dataValidations$.asObservable());
|
|
95
|
+
this.unitId = unitId, this.subUnitId = subUnitId, this._notice(), this.disposeWithMe({
|
|
96
|
+
dispose: /* @__PURE__ */ __name(() => {
|
|
92
97
|
this._dataValidations$.complete();
|
|
93
|
-
}
|
|
94
|
-
})
|
|
98
|
+
}, "dispose")
|
|
99
|
+
});
|
|
95
100
|
}
|
|
96
101
|
_notice() {
|
|
97
102
|
this._dataValidations$.next(this._dataValidations);
|
|
98
103
|
}
|
|
99
|
-
|
|
100
|
-
this.
|
|
101
|
-
this._dataValidationMap.set(r.uid, r);
|
|
102
|
-
});
|
|
104
|
+
getRuleById(id) {
|
|
105
|
+
return this._dataValidationMap.get(id);
|
|
103
106
|
}
|
|
104
|
-
|
|
105
|
-
return this.
|
|
107
|
+
getRuleIndex(id) {
|
|
108
|
+
return this._dataValidations.findIndex((rule) => rule.uid === id);
|
|
106
109
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const o = (Array.isArray(t) ? t : [t]).filter((i) => !this._dataValidationMap.has(i.uid));
|
|
112
|
-
typeof r == "number" && r < this._dataValidations.length ? this._dataValidations.splice(r, 0, ...o) : this._dataValidations.push(...o), o.forEach((i) => {
|
|
113
|
-
this._dataValidationMap.set(i.uid, i);
|
|
110
|
+
addRule(rule, index) {
|
|
111
|
+
const rules = (Array.isArray(rule) ? rule : [rule]).filter((item) => !this._dataValidationMap.has(item.uid));
|
|
112
|
+
typeof index == "number" && index < this._dataValidations.length ? this._dataValidations.splice(index, 0, ...rules) : this._dataValidations.push(...rules), rules.forEach((item) => {
|
|
113
|
+
this._dataValidationMap.set(item.uid, item);
|
|
114
114
|
}), this._notice();
|
|
115
115
|
}
|
|
116
|
-
removeRule(
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
updateRule(
|
|
121
|
-
const
|
|
122
|
-
if (!
|
|
123
|
-
throw new Error(`Data validation rule is not found, ruleId: ${
|
|
124
|
-
const
|
|
125
|
-
switch (
|
|
126
|
-
case
|
|
127
|
-
|
|
116
|
+
removeRule(ruleId) {
|
|
117
|
+
const index = this._dataValidations.findIndex((item) => item.uid === ruleId);
|
|
118
|
+
index > -1 && (this._dataValidations.splice(index, 1), this._dataValidationMap.delete(ruleId), this._notice());
|
|
119
|
+
}
|
|
120
|
+
updateRule(ruleId, payload) {
|
|
121
|
+
const oldRule = this._dataValidationMap.get(ruleId), index = this._dataValidations.findIndex((rule2) => ruleId === rule2.uid);
|
|
122
|
+
if (!oldRule)
|
|
123
|
+
throw new Error(`Data validation rule is not found, ruleId: ${ruleId}.`);
|
|
124
|
+
const rule = { ...oldRule };
|
|
125
|
+
switch (payload.type) {
|
|
126
|
+
case UpdateRuleType.RANGE: {
|
|
127
|
+
rule.ranges = payload.payload;
|
|
128
128
|
break;
|
|
129
129
|
}
|
|
130
|
-
case
|
|
131
|
-
Object.assign(
|
|
130
|
+
case UpdateRuleType.SETTING: {
|
|
131
|
+
Object.assign(rule, getRuleSetting(payload.payload));
|
|
132
132
|
break;
|
|
133
133
|
}
|
|
134
|
-
case
|
|
135
|
-
Object.assign(
|
|
134
|
+
case UpdateRuleType.OPTIONS: {
|
|
135
|
+
Object.assign(rule, getRuleOptions(payload.payload));
|
|
136
136
|
break;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
return this._dataValidations[
|
|
139
|
+
return this._dataValidations[index] = rule, this._dataValidationMap.set(ruleId, rule), this._notice(), rule;
|
|
140
140
|
}
|
|
141
141
|
getDataValidations() {
|
|
142
142
|
return this._dataValidations;
|
|
@@ -144,660 +144,664 @@ class ce extends O {
|
|
|
144
144
|
toJSON() {
|
|
145
145
|
return this._dataValidations;
|
|
146
146
|
}
|
|
147
|
-
validator(
|
|
148
|
-
return
|
|
147
|
+
validator(_content, _rule, _pos, _onComplete) {
|
|
148
|
+
return DataValidationStatus.VALID;
|
|
149
149
|
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
150
|
+
};
|
|
151
|
+
__name(_DataValidationManager, "DataValidationManager");
|
|
152
|
+
let DataValidationManager = _DataValidationManager;
|
|
153
|
+
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
154
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
155
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
156
|
+
return kind && result && __defProp$4(target, key, result), result;
|
|
157
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a;
|
|
158
|
+
let DataValidationModel = (_a = class extends Disposable {
|
|
159
|
+
constructor(_logService) {
|
|
158
160
|
super();
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
this._logService =
|
|
167
|
-
dispose: () => {
|
|
161
|
+
__publicField(this, "_model", /* @__PURE__ */ new Map());
|
|
162
|
+
__publicField(this, "_managerCreator", /* @__PURE__ */ __name((unitId, subUnitId) => new DataValidationManager(unitId, subUnitId), "_managerCreator"));
|
|
163
|
+
__publicField(this, "_ruleChange$", new Subject());
|
|
164
|
+
__publicField(this, "_validStatusChange$", new Subject());
|
|
165
|
+
__publicField(this, "ruleChange$", this._ruleChange$.asObservable());
|
|
166
|
+
__publicField(this, "ruleChangeDebounce$", this.ruleChange$.pipe(debounceTime(20)));
|
|
167
|
+
__publicField(this, "validStatusChange$", this._validStatusChange$.asObservable().pipe(debounceTime(20)));
|
|
168
|
+
this._logService = _logService, this.disposeWithMe({
|
|
169
|
+
dispose: /* @__PURE__ */ __name(() => {
|
|
168
170
|
this._ruleChange$.complete(), this._validStatusChange$.complete();
|
|
169
|
-
}
|
|
171
|
+
}, "dispose")
|
|
170
172
|
});
|
|
171
173
|
}
|
|
172
|
-
setManagerCreator(
|
|
173
|
-
this._managerCreator =
|
|
174
|
+
setManagerCreator(creator) {
|
|
175
|
+
this._managerCreator = creator;
|
|
174
176
|
}
|
|
175
|
-
ensureManager(
|
|
176
|
-
this._model.has(
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
return
|
|
180
|
-
const
|
|
181
|
-
return
|
|
177
|
+
ensureManager(unitId, subUnitId) {
|
|
178
|
+
this._model.has(unitId) || this._model.set(unitId, /* @__PURE__ */ new Map());
|
|
179
|
+
const unitMap = this._model.get(unitId);
|
|
180
|
+
if (unitMap.has(subUnitId))
|
|
181
|
+
return unitMap.get(subUnitId);
|
|
182
|
+
const manager = this._managerCreator(unitId, subUnitId);
|
|
183
|
+
return unitMap.set(subUnitId, manager), this.disposeWithMe(manager), manager;
|
|
182
184
|
}
|
|
183
|
-
_addRuleSideEffect(
|
|
184
|
-
this.ensureManager(
|
|
185
|
-
rule
|
|
185
|
+
_addRuleSideEffect(unitId, subUnitId, rule, source) {
|
|
186
|
+
this.ensureManager(unitId, subUnitId).getRuleById(rule.uid) || this._ruleChange$.next({
|
|
187
|
+
rule,
|
|
186
188
|
type: "add",
|
|
187
|
-
unitId
|
|
188
|
-
subUnitId
|
|
189
|
+
unitId,
|
|
190
|
+
subUnitId,
|
|
191
|
+
source
|
|
189
192
|
});
|
|
190
193
|
}
|
|
191
|
-
addRule(
|
|
194
|
+
addRule(unitId, subUnitId, rule, source, index) {
|
|
192
195
|
try {
|
|
193
|
-
const
|
|
194
|
-
(Array.isArray(
|
|
195
|
-
this._addRuleSideEffect(
|
|
196
|
-
}),
|
|
197
|
-
} catch (
|
|
198
|
-
this._logService.error(
|
|
196
|
+
const manager = this.ensureManager(unitId, subUnitId);
|
|
197
|
+
(Array.isArray(rule) ? rule : [rule]).forEach((item) => {
|
|
198
|
+
this._addRuleSideEffect(unitId, subUnitId, item, source);
|
|
199
|
+
}), manager.addRule(rule, index);
|
|
200
|
+
} catch (error) {
|
|
201
|
+
this._logService.error(error);
|
|
199
202
|
}
|
|
200
203
|
}
|
|
201
|
-
updateRule(
|
|
204
|
+
updateRule(unitId, subUnitId, ruleId, payload, source) {
|
|
202
205
|
try {
|
|
203
|
-
const
|
|
206
|
+
const rule = this.ensureManager(unitId, subUnitId).updateRule(ruleId, payload);
|
|
204
207
|
this._ruleChange$.next({
|
|
205
|
-
rule
|
|
208
|
+
rule,
|
|
206
209
|
type: "update",
|
|
207
|
-
unitId
|
|
208
|
-
subUnitId
|
|
210
|
+
unitId,
|
|
211
|
+
subUnitId,
|
|
212
|
+
source
|
|
209
213
|
});
|
|
210
|
-
} catch (
|
|
211
|
-
this._logService.error(
|
|
214
|
+
} catch (error) {
|
|
215
|
+
this._logService.error(error);
|
|
212
216
|
}
|
|
213
217
|
}
|
|
214
|
-
removeRule(
|
|
218
|
+
removeRule(unitId, subUnitId, ruleId, source) {
|
|
215
219
|
try {
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
rule:
|
|
220
|
+
const manager = this.ensureManager(unitId, subUnitId), oldRule = manager.getRuleById(ruleId);
|
|
221
|
+
oldRule && (manager.removeRule(ruleId), this._ruleChange$.next({
|
|
222
|
+
rule: oldRule,
|
|
219
223
|
type: "remove",
|
|
220
|
-
unitId
|
|
221
|
-
subUnitId
|
|
224
|
+
unitId,
|
|
225
|
+
subUnitId,
|
|
226
|
+
source
|
|
222
227
|
}));
|
|
223
|
-
} catch (
|
|
224
|
-
this._logService.error(
|
|
228
|
+
} catch (error) {
|
|
229
|
+
this._logService.error(error);
|
|
225
230
|
}
|
|
226
231
|
}
|
|
227
|
-
getRuleById(
|
|
228
|
-
return this.ensureManager(
|
|
232
|
+
getRuleById(unitId, subUnitId, ruleId) {
|
|
233
|
+
return this.ensureManager(unitId, subUnitId).getRuleById(ruleId);
|
|
229
234
|
}
|
|
230
|
-
getRuleIndex(
|
|
231
|
-
return this.ensureManager(
|
|
235
|
+
getRuleIndex(unitId, subUnitId, ruleId) {
|
|
236
|
+
return this.ensureManager(unitId, subUnitId).getRuleIndex(ruleId);
|
|
232
237
|
}
|
|
233
|
-
getRules(
|
|
234
|
-
return this.ensureManager(
|
|
238
|
+
getRules(unitId, subUnitId) {
|
|
239
|
+
return this.ensureManager(unitId, subUnitId).getDataValidations();
|
|
235
240
|
}
|
|
236
|
-
validator(
|
|
237
|
-
const { unitId
|
|
238
|
-
return this.ensureManager(
|
|
239
|
-
|
|
240
|
-
unitId
|
|
241
|
-
subUnitId
|
|
242
|
-
ruleId:
|
|
243
|
-
status
|
|
241
|
+
validator(content, rule, pos) {
|
|
242
|
+
const { unitId, subUnitId } = pos;
|
|
243
|
+
return this.ensureManager(unitId, subUnitId).validator(content, rule, pos, (status, changed) => {
|
|
244
|
+
changed && this._validStatusChange$.next({
|
|
245
|
+
unitId,
|
|
246
|
+
subUnitId,
|
|
247
|
+
ruleId: rule.uid,
|
|
248
|
+
status
|
|
244
249
|
});
|
|
245
250
|
});
|
|
246
251
|
}
|
|
247
|
-
getUnitRules(
|
|
248
|
-
const
|
|
249
|
-
if (!
|
|
252
|
+
getUnitRules(unitId) {
|
|
253
|
+
const unitMap = this._model.get(unitId);
|
|
254
|
+
if (!unitMap)
|
|
250
255
|
return [];
|
|
251
|
-
const
|
|
252
|
-
return
|
|
253
|
-
|
|
254
|
-
}),
|
|
255
|
-
}
|
|
256
|
-
deleteUnitRules(
|
|
257
|
-
this._model.delete(
|
|
258
|
-
}
|
|
259
|
-
getSubUnitIds(
|
|
260
|
-
var
|
|
261
|
-
return Array.from((
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
],
|
|
267
|
-
const
|
|
268
|
-
type:
|
|
256
|
+
const res = [];
|
|
257
|
+
return unitMap.forEach((manager) => {
|
|
258
|
+
res.push([manager.subUnitId, manager.getDataValidations()]);
|
|
259
|
+
}), res;
|
|
260
|
+
}
|
|
261
|
+
deleteUnitRules(unitId) {
|
|
262
|
+
this._model.delete(unitId);
|
|
263
|
+
}
|
|
264
|
+
getSubUnitIds(unitId) {
|
|
265
|
+
var _a6, _b;
|
|
266
|
+
return Array.from((_b = (_a6 = this._model.get(unitId)) == null ? void 0 : _a6.keys()) != null ? _b : []);
|
|
267
|
+
}
|
|
268
|
+
}, __name(_a, "DataValidationModel"), _a);
|
|
269
|
+
DataValidationModel = __decorateClass$4([
|
|
270
|
+
__decorateParam$4(0, ILogService)
|
|
271
|
+
], DataValidationModel);
|
|
272
|
+
const AddDataValidationMutation = {
|
|
273
|
+
type: CommandType.MUTATION,
|
|
269
274
|
id: "data-validation.mutation.addRule",
|
|
270
|
-
handler(
|
|
271
|
-
if (!
|
|
275
|
+
handler(accessor, params) {
|
|
276
|
+
if (!params)
|
|
272
277
|
return !1;
|
|
273
|
-
const { unitId
|
|
274
|
-
return
|
|
278
|
+
const { unitId, subUnitId, rule, index, source = "command" } = params;
|
|
279
|
+
return accessor.get(DataValidationModel).addRule(unitId, subUnitId, rule, source, index), !0;
|
|
275
280
|
}
|
|
276
|
-
},
|
|
277
|
-
type:
|
|
281
|
+
}, RemoveDataValidationMutation = {
|
|
282
|
+
type: CommandType.MUTATION,
|
|
278
283
|
id: "data-validation.mutation.removeRule",
|
|
279
|
-
handler(
|
|
280
|
-
if (!
|
|
284
|
+
handler(accessor, params) {
|
|
285
|
+
if (!params)
|
|
281
286
|
return !1;
|
|
282
|
-
const { unitId
|
|
283
|
-
return Array.isArray(
|
|
284
|
-
|
|
285
|
-
}) :
|
|
287
|
+
const { unitId, subUnitId, ruleId, source = "command" } = params, dataValidationModel = accessor.get(DataValidationModel);
|
|
288
|
+
return Array.isArray(ruleId) ? ruleId.forEach((item) => {
|
|
289
|
+
dataValidationModel.removeRule(unitId, subUnitId, item, source);
|
|
290
|
+
}) : dataValidationModel.removeRule(unitId, subUnitId, ruleId, source), !0;
|
|
286
291
|
}
|
|
287
|
-
},
|
|
288
|
-
type:
|
|
292
|
+
}, UpdateDataValidationMutation = {
|
|
293
|
+
type: CommandType.MUTATION,
|
|
289
294
|
id: "data-validation.mutation.updateRule",
|
|
290
|
-
handler(
|
|
291
|
-
if (!
|
|
295
|
+
handler(accessor, params) {
|
|
296
|
+
if (!params)
|
|
292
297
|
return !1;
|
|
293
|
-
const { unitId
|
|
294
|
-
return
|
|
298
|
+
const { unitId, subUnitId, ruleId, payload, source = "command" } = params;
|
|
299
|
+
return accessor.get(DataValidationModel).updateRule(unitId, subUnitId, ruleId, payload, source), !0;
|
|
295
300
|
}
|
|
296
|
-
},
|
|
297
|
-
type:
|
|
301
|
+
}, AddDataValidationCommand = {
|
|
302
|
+
type: CommandType.COMMAND,
|
|
298
303
|
id: "data-validation.command.addRule",
|
|
299
|
-
async handler(
|
|
300
|
-
if (
|
|
304
|
+
async handler(accessor, params) {
|
|
305
|
+
if (accessor.get(ILogService).warn("[Deprecated] AddDataValidationCommand is deprecated, please use AddSheetDataValidationCommand in @univerjs/sheets-data-validation instead!"), !params)
|
|
301
306
|
return !1;
|
|
302
|
-
const { rule
|
|
303
|
-
...
|
|
307
|
+
const { rule, unitId, subUnitId } = params, commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), mutationParams = {
|
|
308
|
+
...params,
|
|
304
309
|
rule: {
|
|
305
|
-
...
|
|
306
|
-
ranges: [
|
|
310
|
+
...params.rule,
|
|
311
|
+
ranges: [params.rule.range]
|
|
307
312
|
}
|
|
308
|
-
},
|
|
309
|
-
id:
|
|
310
|
-
params:
|
|
311
|
-
}],
|
|
312
|
-
id:
|
|
313
|
+
}, redoMutations = [{
|
|
314
|
+
id: AddDataValidationMutation.id,
|
|
315
|
+
params: mutationParams
|
|
316
|
+
}], undoMutations = [{
|
|
317
|
+
id: RemoveDataValidationMutation.id,
|
|
313
318
|
params: {
|
|
314
|
-
unitId
|
|
315
|
-
subUnitId
|
|
316
|
-
ruleId:
|
|
319
|
+
unitId,
|
|
320
|
+
subUnitId,
|
|
321
|
+
ruleId: rule.uid
|
|
317
322
|
}
|
|
318
323
|
}];
|
|
319
|
-
return
|
|
320
|
-
unitID:
|
|
321
|
-
redoMutations
|
|
322
|
-
undoMutations
|
|
323
|
-
}), await
|
|
324
|
-
}
|
|
325
|
-
},
|
|
326
|
-
const
|
|
327
|
-
if (Array.isArray(
|
|
328
|
-
const
|
|
324
|
+
return undoRedoService.pushUndoRedo({
|
|
325
|
+
unitID: unitId,
|
|
326
|
+
redoMutations,
|
|
327
|
+
undoMutations
|
|
328
|
+
}), await commandService.executeCommand(AddDataValidationMutation.id, mutationParams), !0;
|
|
329
|
+
}
|
|
330
|
+
}, removeDataValidationUndoFactory = /* @__PURE__ */ __name((accessor, redoParams) => {
|
|
331
|
+
const dataValidationModel = accessor.get(DataValidationModel), { unitId, subUnitId, ruleId, source } = redoParams;
|
|
332
|
+
if (Array.isArray(ruleId)) {
|
|
333
|
+
const rules = ruleId.map((id) => dataValidationModel.getRuleById(unitId, subUnitId, id)).filter(Boolean);
|
|
329
334
|
return [{
|
|
330
|
-
id:
|
|
335
|
+
id: AddDataValidationMutation.id,
|
|
331
336
|
params: {
|
|
332
|
-
unitId
|
|
333
|
-
subUnitId
|
|
334
|
-
rule:
|
|
337
|
+
unitId,
|
|
338
|
+
subUnitId,
|
|
339
|
+
rule: rules,
|
|
340
|
+
source
|
|
335
341
|
}
|
|
336
342
|
}];
|
|
337
343
|
}
|
|
338
344
|
return [{
|
|
339
|
-
id:
|
|
345
|
+
id: AddDataValidationMutation.id,
|
|
340
346
|
params: {
|
|
341
|
-
unitId
|
|
342
|
-
subUnitId
|
|
347
|
+
unitId,
|
|
348
|
+
subUnitId,
|
|
343
349
|
rule: {
|
|
344
|
-
...
|
|
350
|
+
...dataValidationModel.getRuleById(unitId, subUnitId, ruleId)
|
|
345
351
|
},
|
|
346
|
-
index:
|
|
352
|
+
index: dataValidationModel.getRuleIndex(unitId, subUnitId, ruleId)
|
|
347
353
|
}
|
|
348
354
|
}];
|
|
349
|
-
},
|
|
350
|
-
type:
|
|
355
|
+
}, "removeDataValidationUndoFactory"), RemoveDataValidationCommand = {
|
|
356
|
+
type: CommandType.COMMAND,
|
|
351
357
|
id: "data-validation.command.removeRule",
|
|
352
|
-
handler(
|
|
353
|
-
if (!
|
|
358
|
+
handler(accessor, params) {
|
|
359
|
+
if (!params)
|
|
354
360
|
return !1;
|
|
355
|
-
const { unitId
|
|
356
|
-
id:
|
|
357
|
-
params
|
|
358
|
-
}],
|
|
359
|
-
id:
|
|
361
|
+
const { unitId, subUnitId, ruleId } = params, commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), dataValidationModel = accessor.get(DataValidationModel), redoMutations = [{
|
|
362
|
+
id: RemoveDataValidationMutation.id,
|
|
363
|
+
params
|
|
364
|
+
}], undoMutations = [{
|
|
365
|
+
id: AddDataValidationMutation.id,
|
|
360
366
|
params: {
|
|
361
|
-
unitId
|
|
362
|
-
subUnitId
|
|
367
|
+
unitId,
|
|
368
|
+
subUnitId,
|
|
363
369
|
rule: {
|
|
364
|
-
...
|
|
370
|
+
...dataValidationModel.getRuleById(unitId, subUnitId, ruleId)
|
|
365
371
|
},
|
|
366
|
-
index:
|
|
372
|
+
index: dataValidationModel.getRuleIndex(unitId, subUnitId, ruleId)
|
|
367
373
|
}
|
|
368
374
|
}];
|
|
369
|
-
return
|
|
370
|
-
undoMutations
|
|
371
|
-
redoMutations
|
|
372
|
-
unitID:
|
|
373
|
-
}),
|
|
374
|
-
}
|
|
375
|
-
},
|
|
376
|
-
type:
|
|
375
|
+
return undoRedoService.pushUndoRedo({
|
|
376
|
+
undoMutations,
|
|
377
|
+
redoMutations,
|
|
378
|
+
unitID: params.unitId
|
|
379
|
+
}), commandService.executeCommand(RemoveDataValidationMutation.id, params), !0;
|
|
380
|
+
}
|
|
381
|
+
}, UpdateDataValidationOptionsCommand = {
|
|
382
|
+
type: CommandType.COMMAND,
|
|
377
383
|
id: "data-validation.command.updateDataValidationSetting",
|
|
378
|
-
handler(
|
|
379
|
-
if (
|
|
384
|
+
handler(accessor, params) {
|
|
385
|
+
if (accessor.get(ILogService).warn("[Deprecated] UpdateDataValidationOptionsCommand is deprecated, please use UpdateSheetDataValidationOptionsCommand in @univerjs/sheets-data-validation instead!"), !params)
|
|
380
386
|
return !1;
|
|
381
|
-
const
|
|
382
|
-
if (!
|
|
387
|
+
const commandService = accessor.get(ICommandService), redoUndoService = accessor.get(IUndoRedoService), dataValidationModel = accessor.get(DataValidationModel), { unitId, subUnitId, ruleId, options } = params, rule = dataValidationModel.getRuleById(unitId, subUnitId, ruleId);
|
|
388
|
+
if (!rule)
|
|
383
389
|
return !1;
|
|
384
|
-
const
|
|
385
|
-
unitId
|
|
386
|
-
subUnitId
|
|
387
|
-
ruleId
|
|
390
|
+
const mutationParams = {
|
|
391
|
+
unitId,
|
|
392
|
+
subUnitId,
|
|
393
|
+
ruleId,
|
|
388
394
|
payload: {
|
|
389
|
-
type:
|
|
390
|
-
payload:
|
|
395
|
+
type: UpdateRuleType.OPTIONS,
|
|
396
|
+
payload: options
|
|
391
397
|
}
|
|
392
|
-
},
|
|
393
|
-
id:
|
|
394
|
-
params:
|
|
395
|
-
}],
|
|
396
|
-
unitId
|
|
397
|
-
subUnitId
|
|
398
|
-
ruleId
|
|
398
|
+
}, redoMutations = [{
|
|
399
|
+
id: UpdateDataValidationMutation.id,
|
|
400
|
+
params: mutationParams
|
|
401
|
+
}], undoMutationParams = {
|
|
402
|
+
unitId,
|
|
403
|
+
subUnitId,
|
|
404
|
+
ruleId,
|
|
399
405
|
payload: {
|
|
400
|
-
type:
|
|
401
|
-
payload:
|
|
406
|
+
type: UpdateRuleType.OPTIONS,
|
|
407
|
+
payload: getRuleOptions(rule)
|
|
402
408
|
}
|
|
403
|
-
},
|
|
404
|
-
id:
|
|
405
|
-
params:
|
|
409
|
+
}, undoMutations = [{
|
|
410
|
+
id: UpdateDataValidationMutation.id,
|
|
411
|
+
params: undoMutationParams
|
|
406
412
|
}];
|
|
407
|
-
return
|
|
408
|
-
unitID:
|
|
409
|
-
redoMutations
|
|
410
|
-
undoMutations
|
|
411
|
-
}),
|
|
412
|
-
}
|
|
413
|
-
},
|
|
414
|
-
type:
|
|
413
|
+
return redoUndoService.pushUndoRedo({
|
|
414
|
+
unitID: unitId,
|
|
415
|
+
redoMutations,
|
|
416
|
+
undoMutations
|
|
417
|
+
}), commandService.executeCommand(UpdateDataValidationMutation.id, mutationParams), !0;
|
|
418
|
+
}
|
|
419
|
+
}, UpdateDataValidationSettingCommand = {
|
|
420
|
+
type: CommandType.COMMAND,
|
|
415
421
|
id: "data-validation.command.updateDataValidationOptions",
|
|
416
|
-
handler(
|
|
417
|
-
if (
|
|
422
|
+
handler(accessor, params) {
|
|
423
|
+
if (accessor.get(ILogService).warn("[Deprecated] UpdateDataValidationSettingCommand is deprecated, please use UpdateSheetDataValidationSettingCommand in @univerjs/sheets-data-validation instead!"), !params)
|
|
418
424
|
return !1;
|
|
419
|
-
const
|
|
420
|
-
if (!
|
|
425
|
+
const commandService = accessor.get(ICommandService), redoUndoService = accessor.get(IUndoRedoService), dataValidationModel = accessor.get(DataValidationModel), dataValidatorRegistryService = accessor.get(DataValidatorRegistryService), { unitId, subUnitId, ruleId, setting } = params, validator = dataValidatorRegistryService.getValidatorItem(setting.type);
|
|
426
|
+
if (!validator)
|
|
421
427
|
return !1;
|
|
422
|
-
const
|
|
423
|
-
if (!
|
|
428
|
+
const rule = dataValidationModel.getRuleById(unitId, subUnitId, ruleId);
|
|
429
|
+
if (!rule || !validator.validatorFormula({ ...rule, ...setting }, unitId, subUnitId).success)
|
|
424
430
|
return !1;
|
|
425
|
-
const
|
|
426
|
-
unitId
|
|
427
|
-
subUnitId
|
|
428
|
-
ruleId
|
|
431
|
+
const mutationParams = {
|
|
432
|
+
unitId,
|
|
433
|
+
subUnitId,
|
|
434
|
+
ruleId,
|
|
429
435
|
payload: {
|
|
430
|
-
type:
|
|
431
|
-
payload:
|
|
436
|
+
type: UpdateRuleType.SETTING,
|
|
437
|
+
payload: setting
|
|
432
438
|
}
|
|
433
|
-
},
|
|
434
|
-
id:
|
|
435
|
-
params:
|
|
436
|
-
}],
|
|
437
|
-
unitId
|
|
438
|
-
subUnitId
|
|
439
|
-
ruleId
|
|
439
|
+
}, redoMutations = [{
|
|
440
|
+
id: UpdateDataValidationMutation.id,
|
|
441
|
+
params: mutationParams
|
|
442
|
+
}], undoMutationParams = {
|
|
443
|
+
unitId,
|
|
444
|
+
subUnitId,
|
|
445
|
+
ruleId,
|
|
440
446
|
payload: {
|
|
441
|
-
type:
|
|
442
|
-
payload:
|
|
447
|
+
type: UpdateRuleType.SETTING,
|
|
448
|
+
payload: getRuleSetting(rule)
|
|
443
449
|
}
|
|
444
|
-
},
|
|
445
|
-
id:
|
|
446
|
-
params:
|
|
450
|
+
}, undoMutations = [{
|
|
451
|
+
id: UpdateDataValidationMutation.id,
|
|
452
|
+
params: undoMutationParams
|
|
447
453
|
}];
|
|
448
|
-
return
|
|
449
|
-
unitID:
|
|
450
|
-
redoMutations
|
|
451
|
-
undoMutations
|
|
452
|
-
}),
|
|
453
|
-
}
|
|
454
|
-
},
|
|
455
|
-
type:
|
|
454
|
+
return redoUndoService.pushUndoRedo({
|
|
455
|
+
unitID: unitId,
|
|
456
|
+
redoMutations,
|
|
457
|
+
undoMutations
|
|
458
|
+
}), commandService.executeCommand(UpdateDataValidationMutation.id, mutationParams), !0;
|
|
459
|
+
}
|
|
460
|
+
}, RemoveAllDataValidationCommand = {
|
|
461
|
+
type: CommandType.COMMAND,
|
|
456
462
|
id: "data-validation.command.removeAll",
|
|
457
|
-
handler(
|
|
458
|
-
if (!
|
|
463
|
+
handler(accessor, params) {
|
|
464
|
+
if (!params)
|
|
459
465
|
return !1;
|
|
460
|
-
const { unitId
|
|
461
|
-
unitId
|
|
462
|
-
subUnitId
|
|
463
|
-
ruleId:
|
|
464
|
-
},
|
|
465
|
-
id:
|
|
466
|
-
params:
|
|
467
|
-
}],
|
|
468
|
-
id:
|
|
466
|
+
const { unitId, subUnitId } = params, commandService = accessor.get(ICommandService), dataValidationModel = accessor.get(DataValidationModel), undoRedoService = accessor.get(IUndoRedoService), currentRules = [...dataValidationModel.getRules(unitId, subUnitId)], redoParams = {
|
|
467
|
+
unitId,
|
|
468
|
+
subUnitId,
|
|
469
|
+
ruleId: currentRules.map((rule) => rule.uid)
|
|
470
|
+
}, redoMutations = [{
|
|
471
|
+
id: RemoveDataValidationMutation.id,
|
|
472
|
+
params: redoParams
|
|
473
|
+
}], undoMutations = [{
|
|
474
|
+
id: AddDataValidationMutation.id,
|
|
469
475
|
params: {
|
|
470
|
-
unitId
|
|
471
|
-
subUnitId
|
|
472
|
-
rule:
|
|
476
|
+
unitId,
|
|
477
|
+
subUnitId,
|
|
478
|
+
rule: currentRules
|
|
473
479
|
}
|
|
474
480
|
}];
|
|
475
|
-
return
|
|
476
|
-
redoMutations
|
|
477
|
-
undoMutations
|
|
478
|
-
unitID:
|
|
479
|
-
}),
|
|
481
|
+
return undoRedoService.pushUndoRedo({
|
|
482
|
+
redoMutations,
|
|
483
|
+
undoMutations,
|
|
484
|
+
unitID: unitId
|
|
485
|
+
}), commandService.executeCommand(RemoveDataValidationMutation.id, redoParams), !0;
|
|
480
486
|
}
|
|
481
487
|
};
|
|
482
|
-
var
|
|
483
|
-
for (var
|
|
484
|
-
(
|
|
485
|
-
return
|
|
486
|
-
},
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
488
|
+
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
489
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
490
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
491
|
+
return kind && result && __defProp$3(target, key, result), result;
|
|
492
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3");
|
|
493
|
+
const DATA_VALIDATION_PLUGIN_NAME = "SHEET_DATA_VALIDATION_PLUGIN";
|
|
494
|
+
var _a2;
|
|
495
|
+
let DataValidationResourceController = (_a2 = class extends Disposable {
|
|
496
|
+
constructor(_resourceManagerService, _univerInstanceService, _dataValidationModel) {
|
|
497
|
+
super(), this._resourceManagerService = _resourceManagerService, this._univerInstanceService = _univerInstanceService, this._dataValidationModel = _dataValidationModel, this._initSnapshot();
|
|
491
498
|
}
|
|
492
499
|
_initSnapshot() {
|
|
493
|
-
const
|
|
494
|
-
const
|
|
495
|
-
return
|
|
496
|
-
|
|
497
|
-
}), JSON.stringify(
|
|
498
|
-
},
|
|
499
|
-
if (!
|
|
500
|
+
const toJson = /* @__PURE__ */ __name((unitID) => {
|
|
501
|
+
const map = this._dataValidationModel.getUnitRules(unitID), resultMap = {};
|
|
502
|
+
return map ? (map.forEach(([key, v]) => {
|
|
503
|
+
resultMap[key] = v;
|
|
504
|
+
}), JSON.stringify(resultMap)) : "";
|
|
505
|
+
}, "toJson"), parseJson = /* @__PURE__ */ __name((json) => {
|
|
506
|
+
if (!json)
|
|
500
507
|
return {};
|
|
501
508
|
try {
|
|
502
|
-
return JSON.parse(
|
|
509
|
+
return JSON.parse(json);
|
|
503
510
|
} catch {
|
|
504
511
|
return {};
|
|
505
512
|
}
|
|
506
|
-
};
|
|
513
|
+
}, "parseJson");
|
|
507
514
|
this.disposeWithMe(
|
|
508
515
|
this._resourceManagerService.registerPluginResource({
|
|
509
|
-
pluginName:
|
|
510
|
-
businesses: [
|
|
511
|
-
toJson: (
|
|
512
|
-
parseJson: (
|
|
513
|
-
onUnLoad: (
|
|
514
|
-
this._dataValidationModel.deleteUnitRules(
|
|
515
|
-
},
|
|
516
|
-
onLoad: (
|
|
517
|
-
Object.keys(
|
|
518
|
-
|
|
519
|
-
this._dataValidationModel.addRule(
|
|
516
|
+
pluginName: DATA_VALIDATION_PLUGIN_NAME,
|
|
517
|
+
businesses: [UniverInstanceType.UNIVER_SHEET],
|
|
518
|
+
toJson: /* @__PURE__ */ __name((unitID) => toJson(unitID), "toJson"),
|
|
519
|
+
parseJson: /* @__PURE__ */ __name((json) => parseJson(json), "parseJson"),
|
|
520
|
+
onUnLoad: /* @__PURE__ */ __name((unitID) => {
|
|
521
|
+
this._dataValidationModel.deleteUnitRules(unitID);
|
|
522
|
+
}, "onUnLoad"),
|
|
523
|
+
onLoad: /* @__PURE__ */ __name((unitID, value) => {
|
|
524
|
+
Object.keys(value).forEach((subunitId) => {
|
|
525
|
+
value[subunitId].forEach((rule) => {
|
|
526
|
+
this._dataValidationModel.addRule(unitID, subunitId, rule, "patched");
|
|
520
527
|
});
|
|
521
528
|
});
|
|
522
|
-
}
|
|
529
|
+
}, "onLoad")
|
|
523
530
|
})
|
|
524
531
|
);
|
|
525
532
|
}
|
|
526
|
-
};
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
],
|
|
533
|
-
var
|
|
534
|
-
for (var
|
|
535
|
-
(
|
|
536
|
-
return
|
|
537
|
-
},
|
|
538
|
-
let
|
|
539
|
-
constructor(
|
|
540
|
-
super(), this._sheetInterceptorService =
|
|
533
|
+
}, __name(_a2, "DataValidationResourceController"), _a2);
|
|
534
|
+
DataValidationResourceController = __decorateClass$3([
|
|
535
|
+
OnLifecycle(LifecycleStages.Ready, DataValidationResourceController),
|
|
536
|
+
__decorateParam$3(0, IResourceManagerService),
|
|
537
|
+
__decorateParam$3(1, IUniverInstanceService),
|
|
538
|
+
__decorateParam$3(2, Inject(DataValidationModel))
|
|
539
|
+
], DataValidationResourceController);
|
|
540
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
541
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
542
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
543
|
+
return kind && result && __defProp$2(target, key, result), result;
|
|
544
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a3;
|
|
545
|
+
let DataValidationSheetController = (_a3 = class extends Disposable {
|
|
546
|
+
constructor(_sheetInterceptorService, _univerInstanceService, _dataValidationModel) {
|
|
547
|
+
super(), this._sheetInterceptorService = _sheetInterceptorService, this._univerInstanceService = _univerInstanceService, this._dataValidationModel = _dataValidationModel, this._initSheetChange();
|
|
541
548
|
}
|
|
542
549
|
_initSheetChange() {
|
|
543
550
|
this.disposeWithMe(
|
|
544
551
|
this._sheetInterceptorService.interceptCommand({
|
|
545
|
-
getMutations: (
|
|
546
|
-
var
|
|
547
|
-
if (
|
|
548
|
-
const
|
|
549
|
-
if (!
|
|
552
|
+
getMutations: /* @__PURE__ */ __name((commandInfo) => {
|
|
553
|
+
var _a6;
|
|
554
|
+
if (commandInfo.id === RemoveSheetCommand.id) {
|
|
555
|
+
const params = commandInfo.params, unitId = params.unitId || this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getUnitId(), workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
|
|
556
|
+
if (!workbook)
|
|
550
557
|
return { redos: [], undos: [] };
|
|
551
|
-
const
|
|
552
|
-
if (!
|
|
558
|
+
const subUnitId = params.subUnitId || ((_a6 = workbook.getActiveSheet()) == null ? void 0 : _a6.getSheetId());
|
|
559
|
+
if (!subUnitId)
|
|
553
560
|
return { redos: [], undos: [] };
|
|
554
|
-
const
|
|
555
|
-
if (!
|
|
561
|
+
const manager = this._dataValidationModel.ensureManager(unitId, subUnitId);
|
|
562
|
+
if (!manager)
|
|
556
563
|
return { redos: [], undos: [] };
|
|
557
|
-
const
|
|
558
|
-
unitId
|
|
559
|
-
subUnitId
|
|
560
|
-
ruleId:
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
564
|
+
const rules = manager.getDataValidations(), ids = rules.map((i) => i.uid), redoParams = {
|
|
565
|
+
unitId,
|
|
566
|
+
subUnitId,
|
|
567
|
+
ruleId: ids,
|
|
568
|
+
source: "patched"
|
|
569
|
+
}, undoParams = {
|
|
570
|
+
unitId,
|
|
571
|
+
subUnitId,
|
|
572
|
+
rule: rules,
|
|
573
|
+
source: "patched"
|
|
565
574
|
};
|
|
566
575
|
return {
|
|
567
576
|
redos: [{
|
|
568
|
-
id:
|
|
569
|
-
params:
|
|
577
|
+
id: RemoveDataValidationMutation.id,
|
|
578
|
+
params: redoParams
|
|
570
579
|
}],
|
|
571
580
|
undos: [{
|
|
572
|
-
id:
|
|
573
|
-
params:
|
|
581
|
+
id: AddDataValidationMutation.id,
|
|
582
|
+
params: undoParams
|
|
574
583
|
}]
|
|
575
584
|
};
|
|
576
585
|
}
|
|
577
586
|
return { redos: [], undos: [] };
|
|
578
|
-
}
|
|
587
|
+
}, "getMutations")
|
|
579
588
|
})
|
|
580
589
|
);
|
|
581
590
|
}
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
],
|
|
589
|
-
var
|
|
590
|
-
for (var
|
|
591
|
-
(
|
|
592
|
-
return
|
|
593
|
-
},
|
|
594
|
-
const
|
|
595
|
-
var
|
|
596
|
-
let
|
|
597
|
-
constructor(
|
|
598
|
-
super(), this._injector =
|
|
599
|
-
}
|
|
600
|
-
onStarting(
|
|
591
|
+
}, __name(_a3, "DataValidationSheetController"), _a3);
|
|
592
|
+
DataValidationSheetController = __decorateClass$2([
|
|
593
|
+
OnLifecycle(LifecycleStages.Ready, DataValidationSheetController),
|
|
594
|
+
__decorateParam$2(0, Inject(SheetInterceptorService)),
|
|
595
|
+
__decorateParam$2(1, Inject(IUniverInstanceService)),
|
|
596
|
+
__decorateParam$2(2, Inject(DataValidationModel))
|
|
597
|
+
], DataValidationSheetController);
|
|
598
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
599
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
600
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
601
|
+
return kind && result && __defProp$1(target, key, result), result;
|
|
602
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
|
|
603
|
+
const PLUGIN_NAME = "UNIVER_DATA_VALIDATION_PLUGIN";
|
|
604
|
+
var _a4;
|
|
605
|
+
let UniverDataValidationPlugin = (_a4 = class extends Plugin {
|
|
606
|
+
constructor(_config, _injector, _commandService) {
|
|
607
|
+
super(), this._injector = _injector, this._commandService = _commandService;
|
|
608
|
+
}
|
|
609
|
+
onStarting() {
|
|
601
610
|
[
|
|
602
|
-
|
|
603
|
-
[
|
|
604
|
-
|
|
605
|
-
[
|
|
606
|
-
|
|
607
|
-
[N]
|
|
608
|
-
].forEach(
|
|
609
|
-
(e) => {
|
|
610
|
-
a.add(e);
|
|
611
|
-
}
|
|
612
|
-
), [
|
|
611
|
+
[DataValidationModel],
|
|
612
|
+
[DataValidatorRegistryService],
|
|
613
|
+
[DataValidationResourceController],
|
|
614
|
+
[DataValidationSheetController]
|
|
615
|
+
].forEach((d) => this._injector.add(d)), [
|
|
613
616
|
// command
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
617
|
+
AddDataValidationCommand,
|
|
618
|
+
RemoveAllDataValidationCommand,
|
|
619
|
+
UpdateDataValidationOptionsCommand,
|
|
620
|
+
UpdateDataValidationSettingCommand,
|
|
621
|
+
RemoveDataValidationCommand,
|
|
619
622
|
// mutation
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
].forEach((
|
|
624
|
-
this._commandService.registerCommand(
|
|
623
|
+
AddDataValidationMutation,
|
|
624
|
+
UpdateDataValidationMutation,
|
|
625
|
+
RemoveDataValidationMutation
|
|
626
|
+
].forEach((command) => {
|
|
627
|
+
this._commandService.registerCommand(command);
|
|
625
628
|
});
|
|
626
629
|
}
|
|
627
|
-
},
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
],
|
|
632
|
-
|
|
633
|
-
const
|
|
634
|
-
[
|
|
635
|
-
[
|
|
636
|
-
[
|
|
637
|
-
[
|
|
638
|
-
[
|
|
639
|
-
[
|
|
640
|
-
[
|
|
641
|
-
[
|
|
642
|
-
},
|
|
643
|
-
[
|
|
644
|
-
[
|
|
645
|
-
[
|
|
646
|
-
[
|
|
647
|
-
[
|
|
648
|
-
[
|
|
649
|
-
[
|
|
650
|
-
[
|
|
651
|
-
},
|
|
652
|
-
[
|
|
653
|
-
[
|
|
654
|
-
[
|
|
655
|
-
[
|
|
656
|
-
[
|
|
657
|
-
[
|
|
658
|
-
[
|
|
659
|
-
[
|
|
630
|
+
}, __name(_a4, "UniverDataValidationPlugin"), __publicField(_a4, "pluginName", PLUGIN_NAME), __publicField(_a4, "type", UniverInstanceType.UNIVER_SHEET), _a4);
|
|
631
|
+
UniverDataValidationPlugin = __decorateClass$1([
|
|
632
|
+
__decorateParam$1(1, Inject(Injector)),
|
|
633
|
+
__decorateParam$1(2, ICommandService)
|
|
634
|
+
], UniverDataValidationPlugin);
|
|
635
|
+
DataValidationOperator.BETWEEN + "", DataValidationOperator.EQUAL + "", DataValidationOperator.GREATER_THAN + "", DataValidationOperator.GREATER_THAN_OR_EQUAL + "", DataValidationOperator.LESS_THAN + "", DataValidationOperator.LESS_THAN_OR_EQUAL + "", DataValidationOperator.NOT_BETWEEN + "", DataValidationOperator.NOT_EQUAL + "";
|
|
636
|
+
const OperatorTitleMap = {
|
|
637
|
+
[DataValidationOperator.BETWEEN]: "dataValidation.ruleName.between",
|
|
638
|
+
[DataValidationOperator.EQUAL]: "dataValidation.ruleName.equal",
|
|
639
|
+
[DataValidationOperator.GREATER_THAN]: "dataValidation.ruleName.greaterThan",
|
|
640
|
+
[DataValidationOperator.GREATER_THAN_OR_EQUAL]: "dataValidation.ruleName.greaterThanOrEqual",
|
|
641
|
+
[DataValidationOperator.LESS_THAN]: "dataValidation.ruleName.lessThan",
|
|
642
|
+
[DataValidationOperator.LESS_THAN_OR_EQUAL]: "dataValidation.ruleName.lessThanOrEqual",
|
|
643
|
+
[DataValidationOperator.NOT_BETWEEN]: "dataValidation.ruleName.notBetween",
|
|
644
|
+
[DataValidationOperator.NOT_EQUAL]: "dataValidation.ruleName.notEqual"
|
|
645
|
+
}, OperatorErrorTitleMap = {
|
|
646
|
+
[DataValidationOperator.BETWEEN]: "dataValidation.errorMsg.between",
|
|
647
|
+
[DataValidationOperator.EQUAL]: "dataValidation.errorMsg.equal",
|
|
648
|
+
[DataValidationOperator.GREATER_THAN]: "dataValidation.errorMsg.greaterThan",
|
|
649
|
+
[DataValidationOperator.GREATER_THAN_OR_EQUAL]: "dataValidation.errorMsg.greaterThanOrEqual",
|
|
650
|
+
[DataValidationOperator.LESS_THAN]: "dataValidation.errorMsg.lessThan",
|
|
651
|
+
[DataValidationOperator.LESS_THAN_OR_EQUAL]: "dataValidation.errorMsg.lessThanOrEqual",
|
|
652
|
+
[DataValidationOperator.NOT_BETWEEN]: "dataValidation.errorMsg.notBetween",
|
|
653
|
+
[DataValidationOperator.NOT_EQUAL]: "dataValidation.errorMsg.notEqual"
|
|
654
|
+
}, TextLengthErrorTitleMap = {
|
|
655
|
+
[DataValidationOperator.BETWEEN]: "dataValidation.textLength.errorMsg.between",
|
|
656
|
+
[DataValidationOperator.EQUAL]: "dataValidation.textLength.errorMsg.equal",
|
|
657
|
+
[DataValidationOperator.GREATER_THAN]: "dataValidation.textLength.errorMsg.greaterThan",
|
|
658
|
+
[DataValidationOperator.GREATER_THAN_OR_EQUAL]: "dataValidation.textLength.errorMsg.greaterThanOrEqual",
|
|
659
|
+
[DataValidationOperator.LESS_THAN]: "dataValidation.textLength.errorMsg.lessThan",
|
|
660
|
+
[DataValidationOperator.LESS_THAN_OR_EQUAL]: "dataValidation.textLength.errorMsg.lessThanOrEqual",
|
|
661
|
+
[DataValidationOperator.NOT_BETWEEN]: "dataValidation.textLength.errorMsg.notBetween",
|
|
662
|
+
[DataValidationOperator.NOT_EQUAL]: "dataValidation.textLength.errorMsg.notEqual"
|
|
660
663
|
};
|
|
661
|
-
var
|
|
662
|
-
for (var
|
|
663
|
-
(
|
|
664
|
-
return
|
|
665
|
-
},
|
|
666
|
-
const
|
|
667
|
-
[
|
|
668
|
-
[
|
|
669
|
-
[
|
|
670
|
-
[
|
|
671
|
-
[
|
|
672
|
-
[
|
|
673
|
-
[
|
|
674
|
-
[
|
|
664
|
+
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
665
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
666
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
667
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
668
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam");
|
|
669
|
+
const FORMULA1 = "{FORMULA1}", FORMULA2 = "{FORMULA2}", operatorNameMap = {
|
|
670
|
+
[DataValidationOperator.BETWEEN]: "dataValidation.operators.between",
|
|
671
|
+
[DataValidationOperator.EQUAL]: "dataValidation.operators.equal",
|
|
672
|
+
[DataValidationOperator.GREATER_THAN]: "dataValidation.operators.greaterThan",
|
|
673
|
+
[DataValidationOperator.GREATER_THAN_OR_EQUAL]: "dataValidation.operators.greaterThanOrEqual",
|
|
674
|
+
[DataValidationOperator.LESS_THAN]: "dataValidation.operators.lessThan",
|
|
675
|
+
[DataValidationOperator.LESS_THAN_OR_EQUAL]: "dataValidation.operators.lessThanOrEqual",
|
|
676
|
+
[DataValidationOperator.NOT_BETWEEN]: "dataValidation.operators.notBetween",
|
|
677
|
+
[DataValidationOperator.NOT_EQUAL]: "dataValidation.operators.notEqual"
|
|
675
678
|
};
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
this
|
|
679
|
+
var _a5;
|
|
680
|
+
let BaseDataValidator = (_a5 = class {
|
|
681
|
+
constructor(localeService, injector) {
|
|
682
|
+
__publicField(this, "canvasRender", null);
|
|
683
|
+
__publicField(this, "dropdown");
|
|
684
|
+
__publicField(this, "optionsInput");
|
|
685
|
+
this.localeService = localeService, this.injector = injector;
|
|
682
686
|
}
|
|
683
687
|
get operatorNames() {
|
|
684
|
-
return this.operators.map((
|
|
688
|
+
return this.operators.map((operator) => this.localeService.t(operatorNameMap[operator]));
|
|
685
689
|
}
|
|
686
690
|
get titleStr() {
|
|
687
691
|
return this.localeService.t(this.title);
|
|
688
692
|
}
|
|
689
|
-
skipDefaultFontRender(
|
|
693
|
+
skipDefaultFontRender(rule, cellValue, pos) {
|
|
690
694
|
return !1;
|
|
691
695
|
}
|
|
692
|
-
generateRuleName(
|
|
693
|
-
var
|
|
694
|
-
if (!
|
|
696
|
+
generateRuleName(rule) {
|
|
697
|
+
var _a6, _b;
|
|
698
|
+
if (!rule.operator)
|
|
695
699
|
return this.titleStr;
|
|
696
|
-
const
|
|
697
|
-
return `${this.titleStr} ${
|
|
700
|
+
const ruleName = this.localeService.t(OperatorTitleMap[rule.operator]).replace(FORMULA1, (_a6 = rule.formula1) != null ? _a6 : "").replace(FORMULA2, (_b = rule.formula2) != null ? _b : "");
|
|
701
|
+
return `${this.titleStr} ${ruleName}`;
|
|
698
702
|
}
|
|
699
|
-
generateRuleErrorMessage(
|
|
700
|
-
var
|
|
701
|
-
return
|
|
703
|
+
generateRuleErrorMessage(rule) {
|
|
704
|
+
var _a6, _b;
|
|
705
|
+
return rule.operator ? `${this.localeService.t(OperatorErrorTitleMap[rule.operator]).replace(FORMULA1, (_a6 = rule.formula1) != null ? _a6 : "").replace(FORMULA2, (_b = rule.formula2) != null ? _b : "")}` : this.titleStr;
|
|
702
706
|
}
|
|
703
|
-
getRuleFinalError(
|
|
704
|
-
return
|
|
707
|
+
getRuleFinalError(rule) {
|
|
708
|
+
return rule.showInputMessage && rule.error ? rule.error : this.generateRuleErrorMessage(rule);
|
|
705
709
|
}
|
|
706
|
-
isEmptyCellValue(
|
|
707
|
-
return
|
|
710
|
+
isEmptyCellValue(cellValue) {
|
|
711
|
+
return cellValue === "" || cellValue === void 0 || cellValue === null;
|
|
708
712
|
}
|
|
709
|
-
async isValidType(
|
|
713
|
+
async isValidType(cellInfo, formula, rule) {
|
|
710
714
|
return !0;
|
|
711
715
|
}
|
|
712
|
-
transform(
|
|
713
|
-
return
|
|
716
|
+
transform(cellInfo, formula, rule) {
|
|
717
|
+
return cellInfo;
|
|
714
718
|
}
|
|
715
|
-
async validatorIsEqual(
|
|
719
|
+
async validatorIsEqual(cellInfo, formula, rule) {
|
|
716
720
|
return !0;
|
|
717
721
|
}
|
|
718
|
-
async validatorIsNotEqual(
|
|
722
|
+
async validatorIsNotEqual(cellInfo, formula, rule) {
|
|
719
723
|
return !0;
|
|
720
724
|
}
|
|
721
|
-
async validatorIsBetween(
|
|
725
|
+
async validatorIsBetween(cellInfo, formula, rule) {
|
|
722
726
|
return !0;
|
|
723
727
|
}
|
|
724
|
-
async validatorIsNotBetween(
|
|
728
|
+
async validatorIsNotBetween(cellInfo, formula, rule) {
|
|
725
729
|
return !0;
|
|
726
730
|
}
|
|
727
|
-
async validatorIsGreaterThan(
|
|
731
|
+
async validatorIsGreaterThan(cellInfo, formula, rule) {
|
|
728
732
|
return !0;
|
|
729
733
|
}
|
|
730
|
-
async validatorIsGreaterThanOrEqual(
|
|
734
|
+
async validatorIsGreaterThanOrEqual(cellInfo, formula, rule) {
|
|
731
735
|
return !0;
|
|
732
736
|
}
|
|
733
|
-
async validatorIsLessThan(
|
|
737
|
+
async validatorIsLessThan(cellInfo, formula, rule) {
|
|
734
738
|
return !0;
|
|
735
739
|
}
|
|
736
|
-
async validatorIsLessThanOrEqual(
|
|
740
|
+
async validatorIsLessThanOrEqual(cellInfo, formula, rule) {
|
|
737
741
|
return !0;
|
|
738
742
|
}
|
|
739
|
-
async validator(
|
|
740
|
-
const { value:
|
|
741
|
-
if (
|
|
742
|
-
return
|
|
743
|
-
const
|
|
744
|
-
if (!await this.isValidType(
|
|
743
|
+
async validator(cellInfo, rule) {
|
|
744
|
+
const { value: cellValue, unitId, subUnitId } = cellInfo, isEmpty = this.isEmptyCellValue(cellValue), { allowBlank = !0, operator } = rule;
|
|
745
|
+
if (isEmpty)
|
|
746
|
+
return allowBlank;
|
|
747
|
+
const formulaInfo = await this.parseFormula(rule, unitId, subUnitId);
|
|
748
|
+
if (!await this.isValidType(cellInfo, formulaInfo, rule))
|
|
745
749
|
return !1;
|
|
746
|
-
if (!
|
|
750
|
+
if (!Tools.isDefine(operator))
|
|
747
751
|
return !0;
|
|
748
|
-
const
|
|
749
|
-
switch (
|
|
750
|
-
case
|
|
751
|
-
return this.validatorIsBetween(
|
|
752
|
-
case
|
|
753
|
-
return this.validatorIsEqual(
|
|
754
|
-
case
|
|
755
|
-
return this.validatorIsGreaterThan(
|
|
756
|
-
case
|
|
757
|
-
return this.validatorIsGreaterThanOrEqual(
|
|
758
|
-
case
|
|
759
|
-
return this.validatorIsLessThan(
|
|
760
|
-
case
|
|
761
|
-
return this.validatorIsLessThanOrEqual(
|
|
762
|
-
case
|
|
763
|
-
return this.validatorIsNotBetween(
|
|
764
|
-
case
|
|
765
|
-
return this.validatorIsNotEqual(
|
|
752
|
+
const transformedCell = this.transform(cellInfo, formulaInfo, rule);
|
|
753
|
+
switch (operator) {
|
|
754
|
+
case DataValidationOperator.BETWEEN:
|
|
755
|
+
return this.validatorIsBetween(transformedCell, formulaInfo, rule);
|
|
756
|
+
case DataValidationOperator.EQUAL:
|
|
757
|
+
return this.validatorIsEqual(transformedCell, formulaInfo, rule);
|
|
758
|
+
case DataValidationOperator.GREATER_THAN:
|
|
759
|
+
return this.validatorIsGreaterThan(transformedCell, formulaInfo, rule);
|
|
760
|
+
case DataValidationOperator.GREATER_THAN_OR_EQUAL:
|
|
761
|
+
return this.validatorIsGreaterThanOrEqual(transformedCell, formulaInfo, rule);
|
|
762
|
+
case DataValidationOperator.LESS_THAN:
|
|
763
|
+
return this.validatorIsLessThan(transformedCell, formulaInfo, rule);
|
|
764
|
+
case DataValidationOperator.LESS_THAN_OR_EQUAL:
|
|
765
|
+
return this.validatorIsLessThanOrEqual(transformedCell, formulaInfo, rule);
|
|
766
|
+
case DataValidationOperator.NOT_BETWEEN:
|
|
767
|
+
return this.validatorIsNotBetween(transformedCell, formulaInfo, rule);
|
|
768
|
+
case DataValidationOperator.NOT_EQUAL:
|
|
769
|
+
return this.validatorIsNotEqual(transformedCell, formulaInfo, rule);
|
|
766
770
|
default:
|
|
767
771
|
throw new Error("Unknown operator.");
|
|
768
772
|
}
|
|
769
773
|
}
|
|
770
|
-
};
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
],
|
|
775
|
-
const
|
|
776
|
-
|
|
777
|
-
|
|
774
|
+
}, __name(_a5, "BaseDataValidator"), _a5);
|
|
775
|
+
BaseDataValidator = __decorateClass([
|
|
776
|
+
__decorateParam(0, Inject(LocaleService)),
|
|
777
|
+
__decorateParam(1, Inject(Injector))
|
|
778
|
+
], BaseDataValidator);
|
|
779
|
+
const TWO_FORMULA_OPERATOR_COUNT = [
|
|
780
|
+
DataValidationOperator.BETWEEN,
|
|
781
|
+
DataValidationOperator.NOT_BETWEEN
|
|
778
782
|
];
|
|
779
783
|
export {
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
784
|
+
AddDataValidationCommand,
|
|
785
|
+
AddDataValidationMutation,
|
|
786
|
+
BaseDataValidator,
|
|
787
|
+
DataValidationManager,
|
|
788
|
+
DataValidationModel,
|
|
789
|
+
DataValidationResourceController,
|
|
790
|
+
DataValidationSheetController,
|
|
791
|
+
DataValidatorRegistryScope,
|
|
792
|
+
DataValidatorRegistryService,
|
|
793
|
+
RemoveAllDataValidationCommand,
|
|
794
|
+
RemoveDataValidationCommand,
|
|
795
|
+
RemoveDataValidationMutation,
|
|
796
|
+
TWO_FORMULA_OPERATOR_COUNT,
|
|
797
|
+
TextLengthErrorTitleMap,
|
|
798
|
+
UniverDataValidationPlugin,
|
|
799
|
+
UpdateDataValidationMutation,
|
|
800
|
+
UpdateDataValidationOptionsCommand,
|
|
801
|
+
UpdateDataValidationSettingCommand,
|
|
802
|
+
UpdateRuleType,
|
|
803
|
+
createDefaultNewRule,
|
|
804
|
+
getRuleOptions,
|
|
805
|
+
getRuleSetting,
|
|
806
|
+
removeDataValidationUndoFactory
|
|
803
807
|
};
|