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