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