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