@univerjs/data-validation 0.4.2 → 0.5.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +504 -507
- package/lib/types/commands/mutations/data-validation.mutation.d.ts +1 -1
- package/lib/types/types/enum/update-rule-type.d.ts +2 -1
- package/lib/types/types/interfaces/i-update-rule-payload.d.ts +6 -2
- package/lib/types/validators/base-data-validator.d.ts +5 -4
- package/lib/umd/index.js +1 -1
- package/package.json +13 -13
package/lib/es/index.js
CHANGED
|
@@ -1,676 +1,673 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
function getRuleSetting(rule) {
|
|
1
|
+
var F = Object.defineProperty;
|
|
2
|
+
var J = (t, e, a) => e in t ? F(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
|
|
3
|
+
var c = (t, e, a) => J(t, typeof e != "symbol" ? e + "" : e, a);
|
|
4
|
+
import { Disposable as P, Tools as B, ILogService as T, Inject as O, UniverInstanceType as x, IResourceManagerService as z, IUniverInstanceService as K, toDisposable as Y, CommandType as E, ICommandService as S, IUndoRedoService as M, Plugin as X, Injector as $, IConfigService as Z, DataValidationOperator as s, LocaleService as k } from "@univerjs/core";
|
|
5
|
+
import { Subject as ee, debounceTime as te, BehaviorSubject as ae } from "rxjs";
|
|
6
|
+
function G(t) {
|
|
8
7
|
return {
|
|
9
|
-
type:
|
|
10
|
-
operator:
|
|
11
|
-
formula1:
|
|
12
|
-
formula2:
|
|
13
|
-
allowBlank:
|
|
8
|
+
type: t.type,
|
|
9
|
+
operator: t.operator,
|
|
10
|
+
formula1: t.formula1,
|
|
11
|
+
formula2: t.formula2,
|
|
12
|
+
allowBlank: t.allowBlank
|
|
14
13
|
};
|
|
15
14
|
}
|
|
16
|
-
|
|
17
|
-
function getRuleOptions(rule) {
|
|
15
|
+
function q(t) {
|
|
18
16
|
return {
|
|
19
|
-
error:
|
|
20
|
-
errorStyle:
|
|
21
|
-
errorTitle:
|
|
22
|
-
imeMode:
|
|
23
|
-
prompt:
|
|
24
|
-
promptTitle:
|
|
25
|
-
showDropDown:
|
|
26
|
-
showErrorMessage:
|
|
27
|
-
showInputMessage:
|
|
28
|
-
renderMode:
|
|
29
|
-
bizInfo:
|
|
17
|
+
error: t.error,
|
|
18
|
+
errorStyle: t.errorStyle,
|
|
19
|
+
errorTitle: t.errorTitle,
|
|
20
|
+
imeMode: t.imeMode,
|
|
21
|
+
prompt: t.prompt,
|
|
22
|
+
promptTitle: t.promptTitle,
|
|
23
|
+
showDropDown: t.showDropDown,
|
|
24
|
+
showErrorMessage: t.showErrorMessage,
|
|
25
|
+
showInputMessage: t.showInputMessage,
|
|
26
|
+
renderMode: t.renderMode,
|
|
27
|
+
bizInfo: t.bizInfo
|
|
30
28
|
};
|
|
31
29
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
constructor(_logService) {
|
|
30
|
+
var m = /* @__PURE__ */ ((t) => (t[t.SETTING = 0] = "SETTING", t[t.RANGE = 1] = "RANGE", t[t.OPTIONS = 2] = "OPTIONS", t[t.ALL = 3] = "ALL", t))(m || {}), re = Object.defineProperty, oe = Object.getOwnPropertyDescriptor, ne = (t, e, a, r) => {
|
|
31
|
+
for (var o = r > 1 ? void 0 : r ? oe(e, a) : e, n = t.length - 1, i; n >= 0; n--)
|
|
32
|
+
(i = t[n]) && (o = (r ? i(e, a, o) : i(o)) || o);
|
|
33
|
+
return r && o && re(e, a, o), o;
|
|
34
|
+
}, ie = (t, e) => (a, r) => e(a, r, t);
|
|
35
|
+
let h = class extends P {
|
|
36
|
+
constructor(e) {
|
|
40
37
|
super();
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
this._logService =
|
|
46
|
-
dispose:
|
|
38
|
+
c(this, "_model", /* @__PURE__ */ new Map());
|
|
39
|
+
c(this, "_ruleChange$", new ee());
|
|
40
|
+
c(this, "ruleChange$", this._ruleChange$.asObservable());
|
|
41
|
+
c(this, "ruleChangeDebounce$", this.ruleChange$.pipe(te(20)));
|
|
42
|
+
this._logService = e, this.disposeWithMe({
|
|
43
|
+
dispose: () => {
|
|
47
44
|
this._ruleChange$.complete();
|
|
48
|
-
}
|
|
45
|
+
}
|
|
49
46
|
});
|
|
50
47
|
}
|
|
51
|
-
_ensureMap(
|
|
52
|
-
this._model.has(
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
55
|
-
return
|
|
56
|
-
const
|
|
57
|
-
return
|
|
58
|
-
}
|
|
59
|
-
_addSubUnitRule(
|
|
60
|
-
const { map:
|
|
61
|
-
typeof
|
|
62
|
-
|
|
48
|
+
_ensureMap(e, a) {
|
|
49
|
+
this._model.has(e) || this._model.set(e, /* @__PURE__ */ new Map());
|
|
50
|
+
const r = this._model.get(e);
|
|
51
|
+
if (r.has(a))
|
|
52
|
+
return r.get(a);
|
|
53
|
+
const o = { map: /* @__PURE__ */ new Map(), list: [] };
|
|
54
|
+
return r.set(a, o), o;
|
|
55
|
+
}
|
|
56
|
+
_addSubUnitRule(e, a, r) {
|
|
57
|
+
const { map: o, list: n } = e, l = (Array.isArray(a) ? a : [a]).filter((d) => !o.has(d.uid));
|
|
58
|
+
typeof r == "number" && r < n.length ? n.splice(r, 0, ...l) : n.push(...l), l.forEach((d) => {
|
|
59
|
+
o.set(d.uid, d);
|
|
63
60
|
});
|
|
64
61
|
}
|
|
65
|
-
_removeSubUnitRule(
|
|
66
|
-
const { map:
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
_updateSubUnitRule(
|
|
70
|
-
const { map:
|
|
71
|
-
if (!
|
|
72
|
-
throw new Error(`Data validation rule is not found, ruleId: ${
|
|
73
|
-
const
|
|
74
|
-
switch (
|
|
75
|
-
case
|
|
76
|
-
|
|
62
|
+
_removeSubUnitRule(e, a) {
|
|
63
|
+
const { map: r, list: o } = e, n = o.findIndex((i) => i.uid === a);
|
|
64
|
+
n > -1 && (o.splice(n, 1), r.delete(a));
|
|
65
|
+
}
|
|
66
|
+
_updateSubUnitRule(e, a, r) {
|
|
67
|
+
const { map: o, list: n } = e, i = o.get(a), l = n.findIndex((u) => a === u.uid);
|
|
68
|
+
if (!i)
|
|
69
|
+
throw new Error(`Data validation rule is not found, ruleId: ${a}.`);
|
|
70
|
+
const d = { ...i };
|
|
71
|
+
switch (r.type) {
|
|
72
|
+
case m.RANGE: {
|
|
73
|
+
d.ranges = r.payload;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
case m.SETTING: {
|
|
77
|
+
Object.assign(d, G(r.payload));
|
|
77
78
|
break;
|
|
78
79
|
}
|
|
79
|
-
case
|
|
80
|
-
Object.assign(
|
|
80
|
+
case m.OPTIONS: {
|
|
81
|
+
Object.assign(d, q(r.payload));
|
|
81
82
|
break;
|
|
82
83
|
}
|
|
83
|
-
case
|
|
84
|
-
Object.assign(
|
|
84
|
+
case m.ALL: {
|
|
85
|
+
Object.assign(d, r.payload);
|
|
85
86
|
break;
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
|
-
return
|
|
89
|
+
return n[l] = d, o.set(a, d), d;
|
|
89
90
|
}
|
|
90
|
-
_addRuleSideEffect(
|
|
91
|
-
if (!this._ensureMap(
|
|
91
|
+
_addRuleSideEffect(e, a, r, o) {
|
|
92
|
+
if (!this._ensureMap(e, a).map.get(r.uid))
|
|
92
93
|
return {
|
|
93
|
-
rule,
|
|
94
|
+
rule: r,
|
|
94
95
|
type: "add",
|
|
95
|
-
unitId,
|
|
96
|
-
subUnitId,
|
|
97
|
-
source
|
|
96
|
+
unitId: e,
|
|
97
|
+
subUnitId: a,
|
|
98
|
+
source: o
|
|
98
99
|
};
|
|
99
100
|
}
|
|
100
|
-
addRule(
|
|
101
|
+
addRule(e, a, r, o, n) {
|
|
101
102
|
try {
|
|
102
|
-
const
|
|
103
|
-
this._addSubUnitRule(
|
|
104
|
-
|
|
103
|
+
const i = this._ensureMap(e, a), d = (Array.isArray(r) ? r : [r]).map((u) => this._addRuleSideEffect(e, a, u, o));
|
|
104
|
+
this._addSubUnitRule(i, r, n), d.forEach((u) => {
|
|
105
|
+
u && this._ruleChange$.next(u);
|
|
105
106
|
});
|
|
106
|
-
} catch (
|
|
107
|
-
this._logService.error(
|
|
107
|
+
} catch (i) {
|
|
108
|
+
this._logService.error(i);
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
|
-
updateRule(
|
|
111
|
+
updateRule(e, a, r, o, n) {
|
|
111
112
|
try {
|
|
112
|
-
const
|
|
113
|
-
if (!
|
|
114
|
-
throw new Error(`Data validation rule is not found, ruleId: ${
|
|
115
|
-
const
|
|
113
|
+
const i = this._ensureMap(e, a), l = B.deepClone(i.map.get(r));
|
|
114
|
+
if (!l)
|
|
115
|
+
throw new Error(`Data validation rule is not found, ruleId: ${r}.`);
|
|
116
|
+
const d = this._updateSubUnitRule(i, r, o);
|
|
116
117
|
this._ruleChange$.next({
|
|
117
|
-
rule,
|
|
118
|
+
rule: d,
|
|
118
119
|
type: "update",
|
|
119
|
-
unitId,
|
|
120
|
-
subUnitId,
|
|
121
|
-
source,
|
|
122
|
-
updatePayload:
|
|
123
|
-
oldRule
|
|
120
|
+
unitId: e,
|
|
121
|
+
subUnitId: a,
|
|
122
|
+
source: n,
|
|
123
|
+
updatePayload: o,
|
|
124
|
+
oldRule: l
|
|
124
125
|
});
|
|
125
|
-
} catch (
|
|
126
|
-
this._logService.error(
|
|
126
|
+
} catch (i) {
|
|
127
|
+
this._logService.error(i);
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
|
-
removeRule(
|
|
130
|
+
removeRule(e, a, r, o) {
|
|
130
131
|
try {
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
rule:
|
|
132
|
+
const n = this._ensureMap(e, a), i = n.map.get(r);
|
|
133
|
+
i && (this._removeSubUnitRule(n, r), this._ruleChange$.next({
|
|
134
|
+
rule: i,
|
|
134
135
|
type: "remove",
|
|
135
|
-
unitId,
|
|
136
|
-
subUnitId,
|
|
137
|
-
source
|
|
136
|
+
unitId: e,
|
|
137
|
+
subUnitId: a,
|
|
138
|
+
source: o
|
|
138
139
|
}));
|
|
139
|
-
} catch (
|
|
140
|
-
this._logService.error(
|
|
140
|
+
} catch (n) {
|
|
141
|
+
this._logService.error(n);
|
|
141
142
|
}
|
|
142
143
|
}
|
|
143
|
-
getRuleById(
|
|
144
|
-
return this._ensureMap(
|
|
144
|
+
getRuleById(e, a, r) {
|
|
145
|
+
return this._ensureMap(e, a).map.get(r);
|
|
145
146
|
}
|
|
146
|
-
getRuleIndex(
|
|
147
|
-
return this._ensureMap(
|
|
147
|
+
getRuleIndex(e, a, r) {
|
|
148
|
+
return this._ensureMap(e, a).list.findIndex((n) => n.uid === r);
|
|
148
149
|
}
|
|
149
|
-
getRules(
|
|
150
|
-
return [...this._ensureMap(
|
|
150
|
+
getRules(e, a) {
|
|
151
|
+
return [...this._ensureMap(e, a).list];
|
|
151
152
|
}
|
|
152
|
-
getUnitRules(
|
|
153
|
-
const
|
|
154
|
-
if (!
|
|
153
|
+
getUnitRules(e) {
|
|
154
|
+
const a = this._model.get(e);
|
|
155
|
+
if (!a)
|
|
155
156
|
return [];
|
|
156
|
-
const
|
|
157
|
-
return
|
|
158
|
-
|
|
159
|
-
}),
|
|
157
|
+
const r = [];
|
|
158
|
+
return a.forEach((o, n) => {
|
|
159
|
+
r.push([n, o.list]);
|
|
160
|
+
}), r;
|
|
160
161
|
}
|
|
161
|
-
deleteUnitRules(
|
|
162
|
-
this._model.delete(
|
|
162
|
+
deleteUnitRules(e) {
|
|
163
|
+
this._model.delete(e);
|
|
163
164
|
}
|
|
164
|
-
getSubUnitIds(
|
|
165
|
-
var
|
|
166
|
-
return Array.from((
|
|
165
|
+
getSubUnitIds(e) {
|
|
166
|
+
var a, r;
|
|
167
|
+
return Array.from((r = (a = this._model.get(e)) == null ? void 0 : a.keys()) != null ? r : []);
|
|
167
168
|
}
|
|
168
169
|
getAll() {
|
|
169
|
-
return Array.from(this._model.keys()).map((
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
],
|
|
175
|
-
var
|
|
176
|
-
for (var
|
|
177
|
-
(
|
|
178
|
-
return
|
|
179
|
-
},
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
super(), this._resourceManagerService = _resourceManagerService, this._univerInstanceService = _univerInstanceService, this._dataValidationModel = _dataValidationModel, this._initSnapshot();
|
|
170
|
+
return Array.from(this._model.keys()).map((e) => [e, this.getUnitRules(e)]);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
h = ne([
|
|
174
|
+
ie(0, T)
|
|
175
|
+
], h);
|
|
176
|
+
var se = Object.defineProperty, de = Object.getOwnPropertyDescriptor, le = (t, e, a, r) => {
|
|
177
|
+
for (var o = r > 1 ? void 0 : r ? de(e, a) : e, n = t.length - 1, i; n >= 0; n--)
|
|
178
|
+
(i = t[n]) && (o = (r ? i(e, a, o) : i(o)) || o);
|
|
179
|
+
return r && o && se(e, a, o), o;
|
|
180
|
+
}, y = (t, e) => (a, r) => e(a, r, t);
|
|
181
|
+
const ue = "SHEET_DATA_VALIDATION_PLUGIN";
|
|
182
|
+
let I = class extends P {
|
|
183
|
+
constructor(t, e, a) {
|
|
184
|
+
super(), this._resourceManagerService = t, this._univerInstanceService = e, this._dataValidationModel = a, this._initSnapshot();
|
|
185
185
|
}
|
|
186
186
|
_initSnapshot() {
|
|
187
|
-
const
|
|
188
|
-
const
|
|
189
|
-
return
|
|
190
|
-
|
|
191
|
-
}), JSON.stringify(
|
|
192
|
-
},
|
|
193
|
-
if (!
|
|
187
|
+
const t = (a) => {
|
|
188
|
+
const r = this._dataValidationModel.getUnitRules(a), o = {};
|
|
189
|
+
return r ? (r.forEach(([n, i]) => {
|
|
190
|
+
o[n] = i;
|
|
191
|
+
}), JSON.stringify(o)) : "";
|
|
192
|
+
}, e = (a) => {
|
|
193
|
+
if (!a)
|
|
194
194
|
return {};
|
|
195
195
|
try {
|
|
196
|
-
return JSON.parse(
|
|
196
|
+
return JSON.parse(a);
|
|
197
197
|
} catch {
|
|
198
198
|
return {};
|
|
199
199
|
}
|
|
200
|
-
}
|
|
200
|
+
};
|
|
201
201
|
this.disposeWithMe(
|
|
202
202
|
this._resourceManagerService.registerPluginResource({
|
|
203
|
-
pluginName:
|
|
204
|
-
businesses: [
|
|
205
|
-
toJson:
|
|
206
|
-
parseJson:
|
|
207
|
-
onUnLoad:
|
|
208
|
-
this._dataValidationModel.deleteUnitRules(
|
|
209
|
-
},
|
|
210
|
-
onLoad:
|
|
211
|
-
Object.keys(
|
|
212
|
-
|
|
213
|
-
this._dataValidationModel.addRule(
|
|
203
|
+
pluginName: ue,
|
|
204
|
+
businesses: [x.UNIVER_SHEET],
|
|
205
|
+
toJson: (a) => t(a),
|
|
206
|
+
parseJson: (a) => e(a),
|
|
207
|
+
onUnLoad: (a) => {
|
|
208
|
+
this._dataValidationModel.deleteUnitRules(a);
|
|
209
|
+
},
|
|
210
|
+
onLoad: (a, r) => {
|
|
211
|
+
Object.keys(r).forEach((o) => {
|
|
212
|
+
r[o].forEach((i) => {
|
|
213
|
+
this._dataValidationModel.addRule(a, o, i, "patched");
|
|
214
214
|
});
|
|
215
215
|
});
|
|
216
|
-
}
|
|
216
|
+
}
|
|
217
217
|
})
|
|
218
218
|
);
|
|
219
219
|
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
],
|
|
226
|
-
var
|
|
227
|
-
|
|
220
|
+
};
|
|
221
|
+
I = le([
|
|
222
|
+
y(0, z),
|
|
223
|
+
y(1, K),
|
|
224
|
+
y(2, O(h))
|
|
225
|
+
], I);
|
|
226
|
+
var ce = /* @__PURE__ */ ((t) => (t.SHEET = "sheet", t))(ce || {});
|
|
227
|
+
class H {
|
|
228
228
|
constructor() {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
_addValidatorToScope(
|
|
235
|
-
this._validatorByScopes.has(
|
|
236
|
-
const
|
|
237
|
-
if (
|
|
238
|
-
throw new Error(`Validator item with the same id ${
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
_removeValidatorFromScope(
|
|
242
|
-
const
|
|
243
|
-
if (!
|
|
229
|
+
c(this, "_validatorByScopes", /* @__PURE__ */ new Map());
|
|
230
|
+
c(this, "_validatorMap", /* @__PURE__ */ new Map());
|
|
231
|
+
c(this, "_validatorsChange$", new ae(void 0));
|
|
232
|
+
c(this, "validatorsChange$", this._validatorsChange$.asObservable());
|
|
233
|
+
}
|
|
234
|
+
_addValidatorToScope(e, a) {
|
|
235
|
+
this._validatorByScopes.has(a) || this._validatorByScopes.set(a, []);
|
|
236
|
+
const r = this._validatorByScopes.get(a);
|
|
237
|
+
if (r.findIndex((o) => o.id === e.id) > -1)
|
|
238
|
+
throw new Error(`Validator item with the same id ${e.id} has already been added!`);
|
|
239
|
+
r.push(e);
|
|
240
|
+
}
|
|
241
|
+
_removeValidatorFromScope(e, a) {
|
|
242
|
+
const r = this._validatorByScopes.get(a);
|
|
243
|
+
if (!r)
|
|
244
244
|
return;
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
register(
|
|
249
|
-
return this._validatorMap.set(
|
|
250
|
-
this._addValidatorToScope(
|
|
251
|
-
}) : this._addValidatorToScope(
|
|
252
|
-
this._validatorMap.delete(
|
|
253
|
-
this._removeValidatorFromScope(
|
|
254
|
-
}) : this._removeValidatorFromScope(
|
|
245
|
+
const o = r.findIndex((n) => n.id === e.id);
|
|
246
|
+
o > -1 && r.splice(o, 1);
|
|
247
|
+
}
|
|
248
|
+
register(e) {
|
|
249
|
+
return this._validatorMap.set(e.id, e), Array.isArray(e.scopes) ? e.scopes.forEach((a) => {
|
|
250
|
+
this._addValidatorToScope(e, a);
|
|
251
|
+
}) : this._addValidatorToScope(e, e.scopes), this._validatorsChange$.next(), Y(() => {
|
|
252
|
+
this._validatorMap.delete(e.id), Array.isArray(e.scopes) ? e.scopes.forEach((a) => {
|
|
253
|
+
this._removeValidatorFromScope(e, a);
|
|
254
|
+
}) : this._removeValidatorFromScope(e, e.scopes), this._validatorsChange$.next();
|
|
255
255
|
});
|
|
256
256
|
}
|
|
257
|
-
getValidatorItem(
|
|
258
|
-
return this._validatorMap.get(
|
|
257
|
+
getValidatorItem(e) {
|
|
258
|
+
return this._validatorMap.get(e);
|
|
259
259
|
}
|
|
260
|
-
getValidatorsByScope(
|
|
261
|
-
return this._validatorByScopes.get(
|
|
260
|
+
getValidatorsByScope(e) {
|
|
261
|
+
return this._validatorByScopes.get(e);
|
|
262
262
|
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const AddDataValidationMutation = {
|
|
267
|
-
type: CommandType.MUTATION,
|
|
263
|
+
}
|
|
264
|
+
const A = {
|
|
265
|
+
type: E.MUTATION,
|
|
268
266
|
id: "data-validation.mutation.addRule",
|
|
269
|
-
handler(
|
|
270
|
-
if (!
|
|
267
|
+
handler(t, e) {
|
|
268
|
+
if (!e)
|
|
271
269
|
return !1;
|
|
272
|
-
const { unitId, subUnitId, rule, index, source = "command" } =
|
|
273
|
-
return
|
|
270
|
+
const { unitId: a, subUnitId: r, rule: o, index: n, source: i = "command" } = e;
|
|
271
|
+
return t.get(h).addRule(a, r, o, i, n), !0;
|
|
274
272
|
}
|
|
275
|
-
},
|
|
276
|
-
type:
|
|
273
|
+
}, v = {
|
|
274
|
+
type: E.MUTATION,
|
|
277
275
|
id: "data-validation.mutation.removeRule",
|
|
278
|
-
handler(
|
|
279
|
-
if (!
|
|
276
|
+
handler(t, e) {
|
|
277
|
+
if (!e)
|
|
280
278
|
return !1;
|
|
281
|
-
const { unitId, subUnitId, ruleId, source = "command" } =
|
|
282
|
-
return Array.isArray(
|
|
283
|
-
|
|
284
|
-
}) :
|
|
279
|
+
const { unitId: a, subUnitId: r, ruleId: o, source: n = "command" } = e, i = t.get(h);
|
|
280
|
+
return Array.isArray(o) ? o.forEach((l) => {
|
|
281
|
+
i.removeRule(a, r, l, n);
|
|
282
|
+
}) : i.removeRule(a, r, o, n), !0;
|
|
285
283
|
}
|
|
286
|
-
},
|
|
287
|
-
type:
|
|
284
|
+
}, f = {
|
|
285
|
+
type: E.MUTATION,
|
|
288
286
|
id: "data-validation.mutation.updateRule",
|
|
289
|
-
handler(
|
|
290
|
-
if (!
|
|
287
|
+
handler(t, e) {
|
|
288
|
+
if (!e)
|
|
291
289
|
return !1;
|
|
292
|
-
const { unitId, subUnitId, ruleId, payload, source = "command" } =
|
|
293
|
-
return
|
|
290
|
+
const { unitId: a, subUnitId: r, ruleId: o, payload: n, source: i = "command" } = e;
|
|
291
|
+
return t.get(h).updateRule(a, r, o, n, i), !0;
|
|
294
292
|
}
|
|
295
|
-
},
|
|
296
|
-
type:
|
|
293
|
+
}, pe = {
|
|
294
|
+
type: E.COMMAND,
|
|
297
295
|
id: "data-validation.command.addRule",
|
|
298
|
-
async handler(
|
|
299
|
-
if (
|
|
296
|
+
async handler(t, e) {
|
|
297
|
+
if (t.get(T).error("[Deprecated]: `AddDataValidationCommand` is deprecated, please use `AddSheetDataValidationCommand` in `@univerjs/sheets-data-validation` instead!"), !e)
|
|
300
298
|
return !1;
|
|
301
|
-
const { rule, unitId, subUnitId } =
|
|
302
|
-
...
|
|
299
|
+
const { rule: r, unitId: o, subUnitId: n } = e, i = t.get(S), l = t.get(M), d = {
|
|
300
|
+
...e,
|
|
303
301
|
rule: {
|
|
304
|
-
...
|
|
305
|
-
ranges: [
|
|
302
|
+
...e.rule,
|
|
303
|
+
ranges: [e.rule.range]
|
|
306
304
|
}
|
|
307
|
-
},
|
|
308
|
-
id:
|
|
309
|
-
params:
|
|
310
|
-
}],
|
|
311
|
-
id:
|
|
305
|
+
}, u = [{
|
|
306
|
+
id: A.id,
|
|
307
|
+
params: d
|
|
308
|
+
}], p = [{
|
|
309
|
+
id: v.id,
|
|
312
310
|
params: {
|
|
313
|
-
unitId,
|
|
314
|
-
subUnitId,
|
|
315
|
-
ruleId:
|
|
311
|
+
unitId: o,
|
|
312
|
+
subUnitId: n,
|
|
313
|
+
ruleId: r.uid
|
|
316
314
|
}
|
|
317
315
|
}];
|
|
318
|
-
return
|
|
319
|
-
unitID:
|
|
320
|
-
redoMutations,
|
|
321
|
-
undoMutations
|
|
322
|
-
}), await
|
|
323
|
-
}
|
|
324
|
-
},
|
|
325
|
-
type:
|
|
316
|
+
return l.pushUndoRedo({
|
|
317
|
+
unitID: o,
|
|
318
|
+
redoMutations: u,
|
|
319
|
+
undoMutations: p
|
|
320
|
+
}), await i.executeCommand(A.id, d), !0;
|
|
321
|
+
}
|
|
322
|
+
}, he = {
|
|
323
|
+
type: E.COMMAND,
|
|
326
324
|
id: "data-validation.command.removeRule",
|
|
327
|
-
handler(
|
|
328
|
-
if (
|
|
325
|
+
handler(t, e) {
|
|
326
|
+
if (t.get(T).error("[Deprecated]: `RemoveDataValidationCommand` is deprecated, please use `RemoveSheetDataValidationCommand` in `@univerjs/sheets-data-validation` instead!"), !e)
|
|
329
327
|
return !1;
|
|
330
|
-
const { unitId, subUnitId, ruleId } =
|
|
331
|
-
id:
|
|
332
|
-
params
|
|
333
|
-
}],
|
|
334
|
-
id:
|
|
328
|
+
const { unitId: r, subUnitId: o, ruleId: n } = e, i = t.get(S), l = t.get(M), d = t.get(h), u = [{
|
|
329
|
+
id: v.id,
|
|
330
|
+
params: e
|
|
331
|
+
}], p = [{
|
|
332
|
+
id: A.id,
|
|
335
333
|
params: {
|
|
336
|
-
unitId,
|
|
337
|
-
subUnitId,
|
|
334
|
+
unitId: r,
|
|
335
|
+
subUnitId: o,
|
|
338
336
|
rule: {
|
|
339
|
-
...
|
|
337
|
+
...d.getRuleById(r, o, n)
|
|
340
338
|
},
|
|
341
|
-
index:
|
|
339
|
+
index: d.getRuleIndex(r, o, n)
|
|
342
340
|
}
|
|
343
341
|
}];
|
|
344
|
-
return
|
|
345
|
-
undoMutations,
|
|
346
|
-
redoMutations,
|
|
347
|
-
unitID:
|
|
348
|
-
}),
|
|
349
|
-
}
|
|
350
|
-
},
|
|
351
|
-
type:
|
|
342
|
+
return l.pushUndoRedo({
|
|
343
|
+
undoMutations: p,
|
|
344
|
+
redoMutations: u,
|
|
345
|
+
unitID: e.unitId
|
|
346
|
+
}), i.executeCommand(v.id, e), !0;
|
|
347
|
+
}
|
|
348
|
+
}, me = {
|
|
349
|
+
type: E.COMMAND,
|
|
352
350
|
id: "data-validation.command.updateDataValidationSetting",
|
|
353
|
-
handler(
|
|
354
|
-
if (
|
|
351
|
+
handler(t, e) {
|
|
352
|
+
if (t.get(T).warn("[Deprecated]: `UpdateDataValidationOptionsCommand` is deprecated, please use `UpdateSheetDataValidationOptionsCommand` in `@univerjs/sheets-data-validation` instead!"), !e)
|
|
355
353
|
return !1;
|
|
356
|
-
const
|
|
357
|
-
if (!
|
|
354
|
+
const r = t.get(S), o = t.get(M), n = t.get(h), { unitId: i, subUnitId: l, ruleId: d, options: u } = e, p = n.getRuleById(i, l, d);
|
|
355
|
+
if (!p)
|
|
358
356
|
return !1;
|
|
359
|
-
const
|
|
360
|
-
unitId,
|
|
361
|
-
subUnitId,
|
|
362
|
-
ruleId,
|
|
357
|
+
const _ = {
|
|
358
|
+
unitId: i,
|
|
359
|
+
subUnitId: l,
|
|
360
|
+
ruleId: d,
|
|
363
361
|
payload: {
|
|
364
|
-
type:
|
|
365
|
-
payload:
|
|
362
|
+
type: m.OPTIONS,
|
|
363
|
+
payload: u
|
|
366
364
|
}
|
|
367
|
-
},
|
|
368
|
-
id:
|
|
369
|
-
params:
|
|
370
|
-
}],
|
|
371
|
-
unitId,
|
|
372
|
-
subUnitId,
|
|
373
|
-
ruleId,
|
|
365
|
+
}, g = [{
|
|
366
|
+
id: f.id,
|
|
367
|
+
params: _
|
|
368
|
+
}], R = {
|
|
369
|
+
unitId: i,
|
|
370
|
+
subUnitId: l,
|
|
371
|
+
ruleId: d,
|
|
374
372
|
payload: {
|
|
375
|
-
type:
|
|
376
|
-
payload:
|
|
373
|
+
type: m.OPTIONS,
|
|
374
|
+
payload: q(p)
|
|
377
375
|
}
|
|
378
|
-
},
|
|
379
|
-
id:
|
|
380
|
-
params:
|
|
376
|
+
}, N = [{
|
|
377
|
+
id: f.id,
|
|
378
|
+
params: R
|
|
381
379
|
}];
|
|
382
|
-
return
|
|
383
|
-
unitID:
|
|
384
|
-
redoMutations,
|
|
385
|
-
undoMutations
|
|
386
|
-
}),
|
|
387
|
-
}
|
|
388
|
-
},
|
|
389
|
-
type:
|
|
380
|
+
return o.pushUndoRedo({
|
|
381
|
+
unitID: i,
|
|
382
|
+
redoMutations: g,
|
|
383
|
+
undoMutations: N
|
|
384
|
+
}), r.executeCommand(f.id, _), !0;
|
|
385
|
+
}
|
|
386
|
+
}, _e = {
|
|
387
|
+
type: E.COMMAND,
|
|
390
388
|
id: "data-validation.command.updateDataValidationOptions",
|
|
391
|
-
handler(
|
|
392
|
-
if (
|
|
389
|
+
handler(t, e) {
|
|
390
|
+
if (t.get(T).error("[Deprecated]: `UpdateDataValidationSettingCommand` is deprecated, please use `UpdateSheetDataValidationSettingCommand` in `@univerjs/sheets-data-validation` instead!"), !e)
|
|
393
391
|
return !1;
|
|
394
|
-
const
|
|
395
|
-
if (!
|
|
392
|
+
const r = t.get(S), o = t.get(M), n = t.get(h), i = t.get(H), { unitId: l, subUnitId: d, ruleId: u, setting: p } = e, _ = i.getValidatorItem(p.type);
|
|
393
|
+
if (!_)
|
|
396
394
|
return !1;
|
|
397
|
-
const
|
|
398
|
-
if (!
|
|
395
|
+
const g = n.getRuleById(l, d, u);
|
|
396
|
+
if (!g)
|
|
399
397
|
return !1;
|
|
400
|
-
const
|
|
401
|
-
if (!
|
|
398
|
+
const R = { ...g, ...p };
|
|
399
|
+
if (!_.validatorFormula(R, l, d).success)
|
|
402
400
|
return !1;
|
|
403
|
-
const
|
|
404
|
-
unitId,
|
|
405
|
-
subUnitId,
|
|
406
|
-
ruleId,
|
|
401
|
+
const N = {
|
|
402
|
+
unitId: l,
|
|
403
|
+
subUnitId: d,
|
|
404
|
+
ruleId: u,
|
|
407
405
|
payload: {
|
|
408
|
-
type:
|
|
406
|
+
type: m.SETTING,
|
|
409
407
|
payload: {
|
|
410
|
-
...
|
|
411
|
-
...
|
|
408
|
+
...p,
|
|
409
|
+
..._.normalizeFormula(R, l, d)
|
|
412
410
|
}
|
|
413
411
|
}
|
|
414
|
-
},
|
|
415
|
-
id:
|
|
416
|
-
params:
|
|
417
|
-
}],
|
|
418
|
-
unitId,
|
|
419
|
-
subUnitId,
|
|
420
|
-
ruleId,
|
|
412
|
+
}, j = [{
|
|
413
|
+
id: f.id,
|
|
414
|
+
params: N
|
|
415
|
+
}], Q = {
|
|
416
|
+
unitId: l,
|
|
417
|
+
subUnitId: d,
|
|
418
|
+
ruleId: u,
|
|
421
419
|
payload: {
|
|
422
|
-
type:
|
|
423
|
-
payload:
|
|
420
|
+
type: m.SETTING,
|
|
421
|
+
payload: G(g)
|
|
424
422
|
}
|
|
425
|
-
},
|
|
426
|
-
id:
|
|
427
|
-
params:
|
|
423
|
+
}, W = [{
|
|
424
|
+
id: f.id,
|
|
425
|
+
params: Q
|
|
428
426
|
}];
|
|
429
|
-
return
|
|
430
|
-
unitID:
|
|
431
|
-
redoMutations,
|
|
432
|
-
undoMutations
|
|
433
|
-
}),
|
|
434
|
-
}
|
|
435
|
-
},
|
|
436
|
-
type:
|
|
427
|
+
return o.pushUndoRedo({
|
|
428
|
+
unitID: l,
|
|
429
|
+
redoMutations: j,
|
|
430
|
+
undoMutations: W
|
|
431
|
+
}), r.executeCommand(f.id, N), !0;
|
|
432
|
+
}
|
|
433
|
+
}, Ee = {
|
|
434
|
+
type: E.COMMAND,
|
|
437
435
|
id: "data-validation.command.removeAll",
|
|
438
|
-
handler(
|
|
439
|
-
if (
|
|
436
|
+
handler(t, e) {
|
|
437
|
+
if (t.get(T).error("[Deprecated]: `RemoveAllDataValidationCommand` is deprecated, please use `RemoveSheetAllDataValidationCommand` in `@univerjs/sheets-data-validation` instead!"), !e)
|
|
440
438
|
return !1;
|
|
441
|
-
const { unitId, subUnitId } =
|
|
442
|
-
unitId,
|
|
443
|
-
subUnitId,
|
|
444
|
-
ruleId:
|
|
445
|
-
},
|
|
446
|
-
id:
|
|
447
|
-
params:
|
|
448
|
-
}],
|
|
449
|
-
id:
|
|
439
|
+
const { unitId: r, subUnitId: o } = e, n = t.get(S), i = t.get(h), l = t.get(M), d = [...i.getRules(r, o)], u = {
|
|
440
|
+
unitId: r,
|
|
441
|
+
subUnitId: o,
|
|
442
|
+
ruleId: d.map((g) => g.uid)
|
|
443
|
+
}, p = [{
|
|
444
|
+
id: v.id,
|
|
445
|
+
params: u
|
|
446
|
+
}], _ = [{
|
|
447
|
+
id: A.id,
|
|
450
448
|
params: {
|
|
451
|
-
unitId,
|
|
452
|
-
subUnitId,
|
|
453
|
-
rule:
|
|
449
|
+
unitId: r,
|
|
450
|
+
subUnitId: o,
|
|
451
|
+
rule: d
|
|
454
452
|
}
|
|
455
453
|
}];
|
|
456
|
-
return
|
|
457
|
-
redoMutations,
|
|
458
|
-
undoMutations,
|
|
459
|
-
unitID:
|
|
460
|
-
}),
|
|
461
|
-
}
|
|
462
|
-
},
|
|
463
|
-
var
|
|
464
|
-
for (var
|
|
465
|
-
(
|
|
466
|
-
return
|
|
467
|
-
},
|
|
468
|
-
const
|
|
469
|
-
var
|
|
470
|
-
let
|
|
471
|
-
constructor(
|
|
472
|
-
super(), this._config =
|
|
473
|
-
const { ...
|
|
474
|
-
this._configService.setConfig(
|
|
454
|
+
return l.pushUndoRedo({
|
|
455
|
+
redoMutations: p,
|
|
456
|
+
undoMutations: _,
|
|
457
|
+
unitID: r
|
|
458
|
+
}), n.executeCommand(v.id, u), !0;
|
|
459
|
+
}
|
|
460
|
+
}, ge = "data-validation.config", fe = {};
|
|
461
|
+
var ve = Object.defineProperty, Te = Object.getOwnPropertyDescriptor, Se = (t, e, a, r) => {
|
|
462
|
+
for (var o = r > 1 ? void 0 : r ? Te(e, a) : e, n = t.length - 1, i; n >= 0; n--)
|
|
463
|
+
(i = t[n]) && (o = (r ? i(e, a, o) : i(o)) || o);
|
|
464
|
+
return r && o && ve(e, a, o), o;
|
|
465
|
+
}, L = (t, e) => (a, r) => e(a, r, t);
|
|
466
|
+
const Ae = "UNIVER_DATA_VALIDATION_PLUGIN";
|
|
467
|
+
var V;
|
|
468
|
+
let U = (V = class extends X {
|
|
469
|
+
constructor(t = fe, e, a, r) {
|
|
470
|
+
super(), this._config = t, this._injector = e, this._commandService = a, this._configService = r;
|
|
471
|
+
const { ...o } = this._config;
|
|
472
|
+
this._configService.setConfig(ge, o);
|
|
475
473
|
}
|
|
476
474
|
onStarting() {
|
|
477
475
|
[
|
|
478
|
-
[
|
|
479
|
-
[
|
|
480
|
-
[
|
|
481
|
-
].forEach((
|
|
476
|
+
[h],
|
|
477
|
+
[H],
|
|
478
|
+
[I]
|
|
479
|
+
].forEach((t) => this._injector.add(t)), [
|
|
482
480
|
// command
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
481
|
+
pe,
|
|
482
|
+
Ee,
|
|
483
|
+
me,
|
|
484
|
+
_e,
|
|
485
|
+
he,
|
|
488
486
|
// mutation
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
].forEach((
|
|
493
|
-
this._commandService.registerCommand(
|
|
487
|
+
A,
|
|
488
|
+
f,
|
|
489
|
+
v
|
|
490
|
+
].forEach((t) => {
|
|
491
|
+
this._commandService.registerCommand(t);
|
|
494
492
|
});
|
|
495
493
|
}
|
|
496
494
|
onReady() {
|
|
497
|
-
this._injector.get(
|
|
498
|
-
}
|
|
499
|
-
},
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
],
|
|
505
|
-
|
|
506
|
-
const
|
|
507
|
-
[
|
|
508
|
-
[
|
|
509
|
-
[
|
|
510
|
-
[
|
|
511
|
-
[
|
|
512
|
-
[
|
|
513
|
-
[
|
|
514
|
-
[
|
|
515
|
-
},
|
|
516
|
-
[
|
|
517
|
-
[
|
|
518
|
-
[
|
|
519
|
-
[
|
|
520
|
-
[
|
|
521
|
-
[
|
|
522
|
-
[
|
|
523
|
-
[
|
|
524
|
-
},
|
|
525
|
-
[
|
|
526
|
-
[
|
|
527
|
-
[
|
|
528
|
-
[
|
|
529
|
-
[
|
|
530
|
-
[
|
|
531
|
-
[
|
|
532
|
-
[
|
|
533
|
-
},
|
|
534
|
-
|
|
535
|
-
|
|
495
|
+
this._injector.get(I);
|
|
496
|
+
}
|
|
497
|
+
}, c(V, "pluginName", Ae), c(V, "type", x.UNIVER_SHEET), V);
|
|
498
|
+
U = Se([
|
|
499
|
+
L(1, O($)),
|
|
500
|
+
L(2, S),
|
|
501
|
+
L(3, Z)
|
|
502
|
+
], U);
|
|
503
|
+
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 + "";
|
|
504
|
+
const Me = {
|
|
505
|
+
[s.BETWEEN]: "dataValidation.ruleName.between",
|
|
506
|
+
[s.EQUAL]: "dataValidation.ruleName.equal",
|
|
507
|
+
[s.GREATER_THAN]: "dataValidation.ruleName.greaterThan",
|
|
508
|
+
[s.GREATER_THAN_OR_EQUAL]: "dataValidation.ruleName.greaterThanOrEqual",
|
|
509
|
+
[s.LESS_THAN]: "dataValidation.ruleName.lessThan",
|
|
510
|
+
[s.LESS_THAN_OR_EQUAL]: "dataValidation.ruleName.lessThanOrEqual",
|
|
511
|
+
[s.NOT_BETWEEN]: "dataValidation.ruleName.notBetween",
|
|
512
|
+
[s.NOT_EQUAL]: "dataValidation.ruleName.notEqual"
|
|
513
|
+
}, Re = {
|
|
514
|
+
[s.BETWEEN]: "dataValidation.errorMsg.between",
|
|
515
|
+
[s.EQUAL]: "dataValidation.errorMsg.equal",
|
|
516
|
+
[s.GREATER_THAN]: "dataValidation.errorMsg.greaterThan",
|
|
517
|
+
[s.GREATER_THAN_OR_EQUAL]: "dataValidation.errorMsg.greaterThanOrEqual",
|
|
518
|
+
[s.LESS_THAN]: "dataValidation.errorMsg.lessThan",
|
|
519
|
+
[s.LESS_THAN_OR_EQUAL]: "dataValidation.errorMsg.lessThanOrEqual",
|
|
520
|
+
[s.NOT_BETWEEN]: "dataValidation.errorMsg.notBetween",
|
|
521
|
+
[s.NOT_EQUAL]: "dataValidation.errorMsg.notEqual"
|
|
522
|
+
}, De = {
|
|
523
|
+
[s.BETWEEN]: "dataValidation.textLength.errorMsg.between",
|
|
524
|
+
[s.EQUAL]: "dataValidation.textLength.errorMsg.equal",
|
|
525
|
+
[s.GREATER_THAN]: "dataValidation.textLength.errorMsg.greaterThan",
|
|
526
|
+
[s.GREATER_THAN_OR_EQUAL]: "dataValidation.textLength.errorMsg.greaterThanOrEqual",
|
|
527
|
+
[s.LESS_THAN]: "dataValidation.textLength.errorMsg.lessThan",
|
|
528
|
+
[s.LESS_THAN_OR_EQUAL]: "dataValidation.textLength.errorMsg.lessThanOrEqual",
|
|
529
|
+
[s.NOT_BETWEEN]: "dataValidation.textLength.errorMsg.notBetween",
|
|
530
|
+
[s.NOT_EQUAL]: "dataValidation.textLength.errorMsg.notEqual"
|
|
531
|
+
}, we = [
|
|
532
|
+
s.BETWEEN,
|
|
533
|
+
s.NOT_BETWEEN
|
|
536
534
|
];
|
|
537
|
-
var
|
|
538
|
-
for (var
|
|
539
|
-
(
|
|
540
|
-
return
|
|
541
|
-
},
|
|
542
|
-
const
|
|
543
|
-
[
|
|
544
|
-
[
|
|
545
|
-
[
|
|
546
|
-
[
|
|
547
|
-
[
|
|
548
|
-
[
|
|
549
|
-
[
|
|
550
|
-
[
|
|
535
|
+
var Ne = Object.defineProperty, Ve = Object.getOwnPropertyDescriptor, Oe = (t, e, a, r) => {
|
|
536
|
+
for (var o = r > 1 ? void 0 : r ? Ve(e, a) : e, n = t.length - 1, i; n >= 0; n--)
|
|
537
|
+
(i = t[n]) && (o = (r ? i(e, a, o) : i(o)) || o);
|
|
538
|
+
return r && o && Ne(e, a, o), o;
|
|
539
|
+
}, D = (t, e) => (a, r) => e(a, r, t);
|
|
540
|
+
const w = "{FORMULA1}", C = "{FORMULA2}", Ie = {
|
|
541
|
+
[s.BETWEEN]: "dataValidation.operators.between",
|
|
542
|
+
[s.EQUAL]: "dataValidation.operators.equal",
|
|
543
|
+
[s.GREATER_THAN]: "dataValidation.operators.greaterThan",
|
|
544
|
+
[s.GREATER_THAN_OR_EQUAL]: "dataValidation.operators.greaterThanOrEqual",
|
|
545
|
+
[s.LESS_THAN]: "dataValidation.operators.lessThan",
|
|
546
|
+
[s.LESS_THAN_OR_EQUAL]: "dataValidation.operators.lessThanOrEqual",
|
|
547
|
+
[s.NOT_BETWEEN]: "dataValidation.operators.notBetween",
|
|
548
|
+
[s.NOT_EQUAL]: "dataValidation.operators.notEqual"
|
|
551
549
|
};
|
|
552
|
-
|
|
553
|
-
let BaseDataValidator = (_a4 = class {
|
|
550
|
+
let b = class {
|
|
554
551
|
// #endregion
|
|
555
|
-
constructor(
|
|
552
|
+
constructor(t, e) {
|
|
556
553
|
// #region UI related
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
this.localeService =
|
|
554
|
+
c(this, "formulaInput");
|
|
555
|
+
c(this, "canvasRender", null);
|
|
556
|
+
c(this, "dropdown");
|
|
557
|
+
c(this, "optionsInput");
|
|
558
|
+
c(this, "skipDefaultFontRender");
|
|
559
|
+
this.localeService = t, this.injector = e;
|
|
563
560
|
}
|
|
564
561
|
get operatorNames() {
|
|
565
|
-
return this.operators.map((
|
|
562
|
+
return this.operators.map((t) => this.localeService.t(Ie[t]));
|
|
566
563
|
}
|
|
567
564
|
get titleStr() {
|
|
568
565
|
return this.localeService.t(this.title);
|
|
569
566
|
}
|
|
570
|
-
generateRuleName(
|
|
571
|
-
var
|
|
572
|
-
if (!
|
|
567
|
+
generateRuleName(t) {
|
|
568
|
+
var a, r;
|
|
569
|
+
if (!t.operator)
|
|
573
570
|
return this.titleStr;
|
|
574
|
-
const
|
|
575
|
-
return `${this.titleStr} ${
|
|
571
|
+
const e = this.localeService.t(Me[t.operator]).replace(w, (a = t.formula1) != null ? a : "").replace(C, (r = t.formula2) != null ? r : "");
|
|
572
|
+
return `${this.titleStr} ${e}`;
|
|
576
573
|
}
|
|
577
|
-
generateRuleErrorMessage(
|
|
578
|
-
var
|
|
579
|
-
return
|
|
574
|
+
generateRuleErrorMessage(t, e) {
|
|
575
|
+
var r, o;
|
|
576
|
+
return t.operator ? `${this.localeService.t(Re[t.operator]).replace(w, (r = t.formula1) != null ? r : "").replace(C, (o = t.formula2) != null ? o : "")}` : this.titleStr;
|
|
580
577
|
}
|
|
581
|
-
getExtraStyle(
|
|
578
|
+
getExtraStyle(t, e, a, r, o) {
|
|
582
579
|
}
|
|
583
|
-
getRuleFinalError(
|
|
584
|
-
return
|
|
580
|
+
getRuleFinalError(t, e) {
|
|
581
|
+
return t.showErrorMessage && t.error ? t.error : this.generateRuleErrorMessage(t, e);
|
|
585
582
|
}
|
|
586
|
-
isEmptyCellValue(
|
|
587
|
-
return
|
|
583
|
+
isEmptyCellValue(t) {
|
|
584
|
+
return t === "" || t === void 0 || t === null;
|
|
588
585
|
}
|
|
589
|
-
normalizeFormula(
|
|
586
|
+
normalizeFormula(t, e, a) {
|
|
590
587
|
return {
|
|
591
|
-
formula1:
|
|
592
|
-
formula2:
|
|
588
|
+
formula1: t.formula1,
|
|
589
|
+
formula2: t.formula2
|
|
593
590
|
};
|
|
594
591
|
}
|
|
595
|
-
async isValidType(
|
|
592
|
+
async isValidType(t, e, a) {
|
|
596
593
|
return !0;
|
|
597
594
|
}
|
|
598
|
-
transform(
|
|
599
|
-
return
|
|
595
|
+
transform(t, e, a) {
|
|
596
|
+
return t;
|
|
600
597
|
}
|
|
601
|
-
async validatorIsEqual(
|
|
598
|
+
async validatorIsEqual(t, e, a) {
|
|
602
599
|
return !0;
|
|
603
600
|
}
|
|
604
|
-
async validatorIsNotEqual(
|
|
601
|
+
async validatorIsNotEqual(t, e, a) {
|
|
605
602
|
return !0;
|
|
606
603
|
}
|
|
607
|
-
async validatorIsBetween(
|
|
604
|
+
async validatorIsBetween(t, e, a) {
|
|
608
605
|
return !0;
|
|
609
606
|
}
|
|
610
|
-
async validatorIsNotBetween(
|
|
607
|
+
async validatorIsNotBetween(t, e, a) {
|
|
611
608
|
return !0;
|
|
612
609
|
}
|
|
613
|
-
async validatorIsGreaterThan(
|
|
610
|
+
async validatorIsGreaterThan(t, e, a) {
|
|
614
611
|
return !0;
|
|
615
612
|
}
|
|
616
|
-
async validatorIsGreaterThanOrEqual(
|
|
613
|
+
async validatorIsGreaterThanOrEqual(t, e, a) {
|
|
617
614
|
return !0;
|
|
618
615
|
}
|
|
619
|
-
async validatorIsLessThan(
|
|
616
|
+
async validatorIsLessThan(t, e, a) {
|
|
620
617
|
return !0;
|
|
621
618
|
}
|
|
622
|
-
async validatorIsLessThanOrEqual(
|
|
619
|
+
async validatorIsLessThanOrEqual(t, e, a) {
|
|
623
620
|
return !0;
|
|
624
621
|
}
|
|
625
|
-
async validator(
|
|
626
|
-
const { value:
|
|
627
|
-
if (
|
|
628
|
-
return
|
|
629
|
-
const
|
|
630
|
-
if (!
|
|
622
|
+
async validator(t, e) {
|
|
623
|
+
const { value: a, unitId: r, subUnitId: o } = t, n = this.isEmptyCellValue(a), { allowBlank: i = !0, operator: l } = e;
|
|
624
|
+
if (n)
|
|
625
|
+
return i;
|
|
626
|
+
const d = await this.parseFormula(e, r, o, t.row, t.column);
|
|
627
|
+
if (!d.isFormulaValid || !await this.isValidType(t, d, e))
|
|
631
628
|
return !1;
|
|
632
|
-
if (!
|
|
629
|
+
if (!B.isDefine(l))
|
|
633
630
|
return !0;
|
|
634
|
-
const
|
|
635
|
-
switch (
|
|
636
|
-
case
|
|
637
|
-
return this.validatorIsBetween(
|
|
638
|
-
case
|
|
639
|
-
return this.validatorIsEqual(
|
|
640
|
-
case
|
|
641
|
-
return this.validatorIsGreaterThan(
|
|
642
|
-
case
|
|
643
|
-
return this.validatorIsGreaterThanOrEqual(
|
|
644
|
-
case
|
|
645
|
-
return this.validatorIsLessThan(
|
|
646
|
-
case
|
|
647
|
-
return this.validatorIsLessThanOrEqual(
|
|
648
|
-
case
|
|
649
|
-
return this.validatorIsNotBetween(
|
|
650
|
-
case
|
|
651
|
-
return this.validatorIsNotEqual(
|
|
631
|
+
const u = this.transform(t, d, e);
|
|
632
|
+
switch (l) {
|
|
633
|
+
case s.BETWEEN:
|
|
634
|
+
return this.validatorIsBetween(u, d, e);
|
|
635
|
+
case s.EQUAL:
|
|
636
|
+
return this.validatorIsEqual(u, d, e);
|
|
637
|
+
case s.GREATER_THAN:
|
|
638
|
+
return this.validatorIsGreaterThan(u, d, e);
|
|
639
|
+
case s.GREATER_THAN_OR_EQUAL:
|
|
640
|
+
return this.validatorIsGreaterThanOrEqual(u, d, e);
|
|
641
|
+
case s.LESS_THAN:
|
|
642
|
+
return this.validatorIsLessThan(u, d, e);
|
|
643
|
+
case s.LESS_THAN_OR_EQUAL:
|
|
644
|
+
return this.validatorIsLessThanOrEqual(u, d, e);
|
|
645
|
+
case s.NOT_BETWEEN:
|
|
646
|
+
return this.validatorIsNotBetween(u, d, e);
|
|
647
|
+
case s.NOT_EQUAL:
|
|
648
|
+
return this.validatorIsNotEqual(u, d, e);
|
|
652
649
|
default:
|
|
653
650
|
throw new Error("Unknown operator.");
|
|
654
651
|
}
|
|
655
652
|
}
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
],
|
|
653
|
+
};
|
|
654
|
+
b = Oe([
|
|
655
|
+
D(0, O(k)),
|
|
656
|
+
D(1, O($))
|
|
657
|
+
], b);
|
|
661
658
|
export {
|
|
662
|
-
AddDataValidationMutation,
|
|
663
|
-
BaseDataValidator,
|
|
664
|
-
DataValidationModel,
|
|
665
|
-
DataValidationResourceController,
|
|
666
|
-
DataValidatorRegistryScope,
|
|
667
|
-
DataValidatorRegistryService,
|
|
668
|
-
RemoveDataValidationMutation,
|
|
669
|
-
TWO_FORMULA_OPERATOR_COUNT,
|
|
670
|
-
TextLengthErrorTitleMap,
|
|
671
|
-
UniverDataValidationPlugin,
|
|
672
|
-
UpdateDataValidationMutation,
|
|
673
|
-
UpdateRuleType,
|
|
674
|
-
getRuleOptions,
|
|
675
|
-
getRuleSetting
|
|
659
|
+
A as AddDataValidationMutation,
|
|
660
|
+
b as BaseDataValidator,
|
|
661
|
+
h as DataValidationModel,
|
|
662
|
+
I as DataValidationResourceController,
|
|
663
|
+
ce as DataValidatorRegistryScope,
|
|
664
|
+
H as DataValidatorRegistryService,
|
|
665
|
+
v as RemoveDataValidationMutation,
|
|
666
|
+
we as TWO_FORMULA_OPERATOR_COUNT,
|
|
667
|
+
De as TextLengthErrorTitleMap,
|
|
668
|
+
U as UniverDataValidationPlugin,
|
|
669
|
+
f as UpdateDataValidationMutation,
|
|
670
|
+
m as UpdateRuleType,
|
|
671
|
+
q as getRuleOptions,
|
|
672
|
+
G as getRuleSetting
|
|
676
673
|
};
|