@univerjs/sheets-data-validation 0.6.0-nightly.202502151605 → 0.6.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/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +33 -33
- package/lib/es/index.js +751 -751
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +6 -6
package/lib/es/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Inject as
|
|
5
|
-
import { DataValidationModel as
|
|
6
|
-
import { SetRangeValuesMutation as
|
|
7
|
-
import { Subject as
|
|
1
|
+
var ft = Object.defineProperty;
|
|
2
|
+
var vt = (o, a, e) => a in o ? ft(o, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[a] = e;
|
|
3
|
+
var g = (o, a, e) => vt(o, typeof a != "symbol" ? a + "" : a, e);
|
|
4
|
+
import { Inject as R, ICommandService as x, IUniverInstanceService as w, Disposable as W, ObjectMatrix as Se, UniverInstanceType as N, Range as b, isFormulaString as S, DataValidationType as T, getOriginCellValue as Rt, RBush as St, debounce as Vt, Rectangle as O, Tools as V, DataValidationStatus as D, WrapStrategy as Re, DataValidationOperator as h, numfmt as j, dayjs as at, DataValidationRenderMode as Be, CommandType as z, IUndoRedoService as Z, sequenceExecute as Oe, isRangesEqual as rt, generateRandomId as Mt, toDisposable as Qe, IPermissionService as yt, Injector as qe, CellValueType as Et, RxDisposable as Tt, LifecycleService as Ft, LifecycleStages as ze, bufferDebounceTime as Nt, DependentOn as Ct, IConfigService as wt, Plugin as It, merge as Ot } from "@univerjs/core";
|
|
5
|
+
import { DataValidationModel as Ge, DataValidatorRegistryService as q, UpdateRuleType as y, BaseDataValidator as G, TextLengthErrorTitleMap as At, AddDataValidationMutation as L, RemoveDataValidationMutation as A, UpdateDataValidationMutation as E, getRuleSetting as Dt, getRuleOptions as bt, UniverDataValidationPlugin as Lt } from "@univerjs/data-validation";
|
|
6
|
+
import { SetRangeValuesMutation as se, RemoveSheetMutation as it, getSheetCommandTarget as Ye, SetRangeValuesUndoMutationFactory as ot, WorksheetViewPermission as xt, RefRangeService as Bt, handleCommonDefaultRangeChangeWithEffectRefCommands as Ut, SheetInterceptorService as st, RemoveSheetCommand as Ht, SheetsSelectionsService as nt, ClearSelectionAllCommand as Wt } from "@univerjs/sheets";
|
|
7
|
+
import { Subject as je, bufferWhen as Pt, filter as Ze } from "rxjs";
|
|
8
8
|
import { RegisterOtherFormulaService as lt, FormulaRefRangeService as ut } from "@univerjs/sheets-formula";
|
|
9
|
-
import { ERROR_TYPE_SET as
|
|
10
|
-
const
|
|
11
|
-
var
|
|
12
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
13
|
-
(
|
|
14
|
-
return
|
|
15
|
-
}, Je = (
|
|
16
|
-
let
|
|
9
|
+
import { ERROR_TYPE_SET as $t, LexerTreeBuilder as Y, isReferenceString as dt, sequenceNodeType as kt, deserializeRangeWithSheet as jt, deserializeRangeWithSheetWithCache as Qt, operatorToken as qt } from "@univerjs/engine-formula";
|
|
10
|
+
const Gt = "SHEET_DATA_VALIDATION_PLUGIN";
|
|
11
|
+
var Yt = Object.getOwnPropertyDescriptor, Xt = (o, a, e, t) => {
|
|
12
|
+
for (var r = t > 1 ? void 0 : t ? Yt(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
13
|
+
(s = o[i]) && (r = s(r) || r);
|
|
14
|
+
return r;
|
|
15
|
+
}, Je = (o, a) => (e, t) => a(e, t, o);
|
|
16
|
+
let Q = class extends W {
|
|
17
17
|
constructor(a, e) {
|
|
18
18
|
super();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
g(this, "_cacheMatrix", /* @__PURE__ */ new Map());
|
|
20
|
+
g(this, "_dirtyRanges$", new je());
|
|
21
|
+
g(this, "dirtyRanges$", this._dirtyRanges$.asObservable());
|
|
22
22
|
this._commandService = a, this._univerInstanceService = e, this._initDirtyRanges(), this._initSheetRemove();
|
|
23
23
|
}
|
|
24
24
|
_initDirtyRanges() {
|
|
25
25
|
this.disposeWithMe(this._commandService.onCommandExecuted((a) => {
|
|
26
|
-
if (a.id ===
|
|
26
|
+
if (a.id === se.id) {
|
|
27
27
|
const { cellValue: e, unitId: t, subUnitId: r } = a.params;
|
|
28
28
|
if (e) {
|
|
29
|
-
const i = new
|
|
29
|
+
const i = new Se(e).getDataRange();
|
|
30
30
|
if (i.endRow === -1) return;
|
|
31
31
|
this.markRangeDirty(t, r, [i]);
|
|
32
32
|
}
|
|
@@ -48,7 +48,7 @@ let q = class extends $ {
|
|
|
48
48
|
let t = this._cacheMatrix.get(a);
|
|
49
49
|
t || (t = /* @__PURE__ */ new Map(), this._cacheMatrix.set(a, t));
|
|
50
50
|
let r = t.get(e);
|
|
51
|
-
return r || (r = new
|
|
51
|
+
return r || (r = new Se(), t.set(e, r)), r;
|
|
52
52
|
}
|
|
53
53
|
ensureCache(a, e) {
|
|
54
54
|
return this._ensureCache(a, e);
|
|
@@ -62,16 +62,16 @@ let q = class extends $ {
|
|
|
62
62
|
markRangeDirty(a, e, t) {
|
|
63
63
|
const r = this._ensureCache(a, e);
|
|
64
64
|
t.forEach((i) => {
|
|
65
|
-
b.foreach(i, (
|
|
66
|
-
r.setValue(
|
|
65
|
+
b.foreach(i, (s, n) => {
|
|
66
|
+
r.setValue(s, n, void 0);
|
|
67
67
|
});
|
|
68
68
|
}), this._dirtyRanges$.next({ unitId: a, subUnitId: e, ranges: t });
|
|
69
69
|
}
|
|
70
70
|
_deleteRange(a, e, t) {
|
|
71
71
|
const r = this._ensureCache(a, e);
|
|
72
72
|
t.forEach((i) => {
|
|
73
|
-
b.foreach(i, (
|
|
74
|
-
r.realDeleteValue(
|
|
73
|
+
b.foreach(i, (s, n) => {
|
|
74
|
+
r.realDeleteValue(s, n);
|
|
75
75
|
});
|
|
76
76
|
}), this._dirtyRanges$.next({ unitId: a, subUnitId: e, ranges: t });
|
|
77
77
|
}
|
|
@@ -79,39 +79,39 @@ let q = class extends $ {
|
|
|
79
79
|
return this._ensureCache(a, e).getValue(t, r);
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
-
|
|
83
|
-
Je(0,
|
|
84
|
-
Je(1,
|
|
85
|
-
],
|
|
86
|
-
function
|
|
82
|
+
Q = Xt([
|
|
83
|
+
Je(0, R(x)),
|
|
84
|
+
Je(1, R(w))
|
|
85
|
+
], Q);
|
|
86
|
+
function oe(o) {
|
|
87
87
|
var a, e;
|
|
88
|
-
return (e = (a =
|
|
88
|
+
return (e = (a = o == null ? void 0 : o[0]) == null ? void 0 : a[0]) == null ? void 0 : e.v;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function _e(o) {
|
|
91
91
|
var a;
|
|
92
|
-
return (a =
|
|
92
|
+
return (a = o == null ? void 0 : o[0]) == null ? void 0 : a[0];
|
|
93
93
|
}
|
|
94
|
-
function C(
|
|
95
|
-
return
|
|
94
|
+
function C(o) {
|
|
95
|
+
return !$t.has(o);
|
|
96
96
|
}
|
|
97
|
-
function de(
|
|
97
|
+
function de(o, a) {
|
|
98
98
|
var t;
|
|
99
|
-
const e = a.getValidatorItem(
|
|
99
|
+
const e = a.getValidatorItem(o);
|
|
100
100
|
return (t = e == null ? void 0 : e.offsetFormulaByRange) != null ? t : !1;
|
|
101
101
|
}
|
|
102
|
-
var
|
|
103
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
104
|
-
(
|
|
105
|
-
return
|
|
106
|
-
}, re = (
|
|
107
|
-
let
|
|
102
|
+
var Kt = Object.getOwnPropertyDescriptor, zt = (o, a, e, t) => {
|
|
103
|
+
for (var r = t > 1 ? void 0 : t ? Kt(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
104
|
+
(s = o[i]) && (r = s(r) || r);
|
|
105
|
+
return r;
|
|
106
|
+
}, re = (o, a) => (e, t) => a(e, t, o);
|
|
107
|
+
let H = class extends W {
|
|
108
108
|
constructor(a, e, t, r, i) {
|
|
109
109
|
super();
|
|
110
110
|
/**
|
|
111
111
|
* Map of origin formula of rule
|
|
112
112
|
*/
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
g(this, "_ruleFormulaMap", /* @__PURE__ */ new Map());
|
|
114
|
+
g(this, "_ruleFormulaMap2", /* @__PURE__ */ new Map());
|
|
115
115
|
this._instanceSrv = a, this._registerOtherFormulaService = e, this._dataValidationModel = t, this._dataValidationCacheService = r, this._validatorRegistryService = i, this._initFormulaResultHandler();
|
|
116
116
|
}
|
|
117
117
|
_initFormulaResultHandler() {
|
|
@@ -120,8 +120,8 @@ let P = class extends $ {
|
|
|
120
120
|
const t = a[e];
|
|
121
121
|
if (this._instanceSrv.getUnitType(e) === N.UNIVER_SHEET)
|
|
122
122
|
for (const i in t) {
|
|
123
|
-
const
|
|
124
|
-
|
|
123
|
+
const s = t[i], { ruleFormulaMap: n } = this._ensureMaps(e, i);
|
|
124
|
+
s.forEach((l) => {
|
|
125
125
|
var c, m;
|
|
126
126
|
const u = n.get((c = l.extra) == null ? void 0 : c.ruleId), d = this._dataValidationModel.getRuleById(e, i, (m = l.extra) == null ? void 0 : m.ruleId);
|
|
127
127
|
d && u && this._dataValidationCacheService.markRangeDirty(e, i, d.ranges);
|
|
@@ -135,25 +135,25 @@ let P = class extends $ {
|
|
|
135
135
|
t || (t = /* @__PURE__ */ new Map(), this._ruleFormulaMap.set(a, t)), r || (r = /* @__PURE__ */ new Map(), this._ruleFormulaMap2.set(a, r));
|
|
136
136
|
let i = t.get(e);
|
|
137
137
|
i || (i = /* @__PURE__ */ new Map(), t.set(e, i));
|
|
138
|
-
let
|
|
139
|
-
return
|
|
138
|
+
let s = r.get(e);
|
|
139
|
+
return s || (s = /* @__PURE__ */ new Map(), r.set(e, s)), { ruleFormulaMap: i, ruleFormulaMap2: s };
|
|
140
140
|
}
|
|
141
141
|
_registerFormula(a, e, t, r, i) {
|
|
142
142
|
return this._registerOtherFormulaService.registerFormulaWithRange(a, e, r, i, { ruleId: t });
|
|
143
143
|
}
|
|
144
144
|
deleteByRuleId(a, e, t) {
|
|
145
|
-
const { ruleFormulaMap: r, ruleFormulaMap2: i } = this._ensureMaps(a, e),
|
|
146
|
-
if (!
|
|
145
|
+
const { ruleFormulaMap: r, ruleFormulaMap2: i } = this._ensureMaps(a, e), s = this._dataValidationModel.getRuleById(a, e, t), n = r.get(t);
|
|
146
|
+
if (!s || !n)
|
|
147
147
|
return;
|
|
148
148
|
const l = r.get(t);
|
|
149
149
|
l && (r.delete(t), this._registerOtherFormulaService.deleteFormula(a, e, [l.formulaId]));
|
|
150
150
|
const u = i.get(t);
|
|
151
151
|
u && (i.delete(t), this._registerOtherFormulaService.deleteFormula(a, e, [u.formulaId]));
|
|
152
152
|
}
|
|
153
|
-
_addFormulaByRange(a, e, t, r, i,
|
|
154
|
-
const { ruleFormulaMap: n, ruleFormulaMap2: l } = this._ensureMaps(a, e), u =
|
|
155
|
-
if (r &&
|
|
156
|
-
const c = this._registerFormula(a, e, t, r,
|
|
153
|
+
_addFormulaByRange(a, e, t, r, i, s) {
|
|
154
|
+
const { ruleFormulaMap: n, ruleFormulaMap2: l } = this._ensureMaps(a, e), u = s[0].startRow, d = s[0].startColumn;
|
|
155
|
+
if (r && S(r)) {
|
|
156
|
+
const c = this._registerFormula(a, e, t, r, s);
|
|
157
157
|
n.set(t, {
|
|
158
158
|
formula: r,
|
|
159
159
|
originCol: d,
|
|
@@ -161,8 +161,8 @@ let P = class extends $ {
|
|
|
161
161
|
formulaId: c
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
|
-
if (i &&
|
|
165
|
-
const c = this._registerFormula(a, e, t, i,
|
|
164
|
+
if (i && S(i)) {
|
|
165
|
+
const c = this._registerFormula(a, e, t, i, s);
|
|
166
166
|
l.set(t, {
|
|
167
167
|
formula: i,
|
|
168
168
|
originCol: d,
|
|
@@ -173,63 +173,63 @@ let P = class extends $ {
|
|
|
173
173
|
}
|
|
174
174
|
addRule(a, e, t) {
|
|
175
175
|
if (de(t.type, this._validatorRegistryService)) {
|
|
176
|
-
const { ranges: r, formula1: i, formula2:
|
|
177
|
-
this._addFormulaByRange(a, e, n, i,
|
|
176
|
+
const { ranges: r, formula1: i, formula2: s, uid: n } = t;
|
|
177
|
+
this._addFormulaByRange(a, e, n, i, s, r);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
async getCellFormulaValue(a, e, t, r, i) {
|
|
181
|
-
var
|
|
182
|
-
const { ruleFormulaMap:
|
|
181
|
+
var p, _;
|
|
182
|
+
const { ruleFormulaMap: s } = this._ensureMaps(a, e), n = s.get(t);
|
|
183
183
|
if (!n)
|
|
184
184
|
return Promise.resolve(void 0);
|
|
185
185
|
const l = await this._registerOtherFormulaService.getFormulaValue(a, e, n.formulaId), { originRow: u, originCol: d } = n, c = r - u, m = i - d;
|
|
186
|
-
return
|
|
186
|
+
return _e((_ = (p = l == null ? void 0 : l.result) == null ? void 0 : p[c]) == null ? void 0 : _[m]);
|
|
187
187
|
}
|
|
188
188
|
async getCellFormula2Value(a, e, t, r, i) {
|
|
189
|
-
var
|
|
190
|
-
const { ruleFormulaMap2:
|
|
189
|
+
var p, _;
|
|
190
|
+
const { ruleFormulaMap2: s } = this._ensureMaps(a, e), n = s.get(t);
|
|
191
191
|
if (!n)
|
|
192
192
|
return Promise.resolve(void 0);
|
|
193
193
|
const l = await this._registerOtherFormulaService.getFormulaValue(a, e, n.formulaId), { originRow: u, originCol: d } = n, c = r - u, m = i - d;
|
|
194
|
-
return
|
|
194
|
+
return _e((_ = (p = l == null ? void 0 : l.result) == null ? void 0 : p[c]) == null ? void 0 : _[m]);
|
|
195
195
|
}
|
|
196
196
|
getCellFormulaValueSync(a, e, t, r, i) {
|
|
197
|
-
var
|
|
198
|
-
const { ruleFormulaMap:
|
|
197
|
+
var p, _;
|
|
198
|
+
const { ruleFormulaMap: s } = this._ensureMaps(a, e), n = s.get(t);
|
|
199
199
|
if (!n)
|
|
200
200
|
return;
|
|
201
201
|
const l = this._registerOtherFormulaService.getFormulaValueSync(a, e, n.formulaId), { originRow: u, originCol: d } = n, c = r - u, m = i - d;
|
|
202
|
-
return
|
|
202
|
+
return _e((_ = (p = l == null ? void 0 : l.result) == null ? void 0 : p[c]) == null ? void 0 : _[m]);
|
|
203
203
|
}
|
|
204
204
|
getCellFormula2ValueSync(a, e, t, r, i) {
|
|
205
|
-
var
|
|
206
|
-
const { ruleFormulaMap2:
|
|
205
|
+
var p, _;
|
|
206
|
+
const { ruleFormulaMap2: s } = this._ensureMaps(a, e), n = s.get(t);
|
|
207
207
|
if (!n)
|
|
208
208
|
return;
|
|
209
209
|
const l = this._registerOtherFormulaService.getFormulaValueSync(a, e, n.formulaId), { originRow: u, originCol: d } = n, c = r - u, m = i - d;
|
|
210
|
-
return
|
|
210
|
+
return _e((_ = (p = l == null ? void 0 : l.result) == null ? void 0 : p[c]) == null ? void 0 : _[m]);
|
|
211
211
|
}
|
|
212
212
|
getRuleFormulaInfo(a, e, t) {
|
|
213
213
|
const { ruleFormulaMap: r } = this._ensureMaps(a, e);
|
|
214
214
|
return r.get(t);
|
|
215
215
|
}
|
|
216
216
|
};
|
|
217
|
-
|
|
218
|
-
re(0,
|
|
219
|
-
re(1,
|
|
220
|
-
re(2,
|
|
221
|
-
re(3,
|
|
222
|
-
re(4,
|
|
223
|
-
],
|
|
224
|
-
var
|
|
225
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
226
|
-
(
|
|
227
|
-
return
|
|
228
|
-
}, ie = (
|
|
229
|
-
let K = class extends
|
|
217
|
+
H = zt([
|
|
218
|
+
re(0, w),
|
|
219
|
+
re(1, R(lt)),
|
|
220
|
+
re(2, R(Ge)),
|
|
221
|
+
re(3, R(Q)),
|
|
222
|
+
re(4, R(q))
|
|
223
|
+
], H);
|
|
224
|
+
var Zt = Object.getOwnPropertyDescriptor, Jt = (o, a, e, t) => {
|
|
225
|
+
for (var r = t > 1 ? void 0 : t ? Zt(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
226
|
+
(s = o[i]) && (r = s(r) || r);
|
|
227
|
+
return r;
|
|
228
|
+
}, ie = (o, a) => (e, t) => a(e, t, o);
|
|
229
|
+
let K = class extends W {
|
|
230
230
|
constructor(a, e, t, r, i) {
|
|
231
231
|
super();
|
|
232
|
-
|
|
232
|
+
g(this, "_formulaRuleMap", /* @__PURE__ */ new Map());
|
|
233
233
|
this._instanceService = a, this._registerOtherFormulaService = e, this._dataValidationCacheService = t, this._dataValidationModel = r, this._validatorRegistryService = i, this._initFormulaResultHandler();
|
|
234
234
|
}
|
|
235
235
|
_initFormulaResultHandler() {
|
|
@@ -238,8 +238,8 @@ let K = class extends $ {
|
|
|
238
238
|
const t = a[e];
|
|
239
239
|
if (this._instanceService.getUnitType(e) === N.UNIVER_SHEET)
|
|
240
240
|
for (const i in t) {
|
|
241
|
-
const
|
|
242
|
-
|
|
241
|
+
const s = t[i], n = this._ensureRuleFormulaMap(e, i);
|
|
242
|
+
s.forEach((l) => {
|
|
243
243
|
var u, d;
|
|
244
244
|
if (n.get((u = l.extra) == null ? void 0 : u.ruleId)) {
|
|
245
245
|
const c = this._dataValidationModel.getRuleById(e, i, (d = l.extra) == null ? void 0 : d.ruleId);
|
|
@@ -262,70 +262,70 @@ let K = class extends $ {
|
|
|
262
262
|
}
|
|
263
263
|
addRule(a, e, t) {
|
|
264
264
|
if (!de(t.type, this._validatorRegistryService) && t.type !== T.CHECKBOX) {
|
|
265
|
-
const { formula1: r, formula2: i, uid:
|
|
265
|
+
const { formula1: r, formula2: i, uid: s } = t, n = S(r), l = S(i);
|
|
266
266
|
if (!n && !l)
|
|
267
267
|
return;
|
|
268
268
|
const u = this._ensureRuleFormulaMap(a, e), d = [void 0, void 0];
|
|
269
269
|
if (n) {
|
|
270
|
-
const c = this._registerSingleFormula(a, e, r,
|
|
270
|
+
const c = this._registerSingleFormula(a, e, r, s);
|
|
271
271
|
d[0] = { id: c, text: r };
|
|
272
272
|
}
|
|
273
273
|
if (l) {
|
|
274
|
-
const c = this._registerSingleFormula(a, e, i,
|
|
274
|
+
const c = this._registerSingleFormula(a, e, i, s);
|
|
275
275
|
d[1] = { id: c, text: i };
|
|
276
276
|
}
|
|
277
|
-
u.set(
|
|
277
|
+
u.set(s, d);
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
removeRule(a, e, t) {
|
|
281
281
|
const i = this._ensureRuleFormulaMap(a, e).get(t);
|
|
282
282
|
if (!i)
|
|
283
283
|
return;
|
|
284
|
-
const [
|
|
284
|
+
const [s, n] = i, l = [s == null ? void 0 : s.id, n == null ? void 0 : n.id].filter(Boolean);
|
|
285
285
|
l.length && this._registerOtherFormulaService.deleteFormula(a, e, l);
|
|
286
286
|
}
|
|
287
287
|
getRuleFormulaResult(a, e, t) {
|
|
288
288
|
const i = this._ensureRuleFormulaMap(a, e).get(t);
|
|
289
289
|
if (!i)
|
|
290
290
|
return Promise.resolve(null);
|
|
291
|
-
const
|
|
291
|
+
const s = async (n) => n && this._registerOtherFormulaService.getFormulaValue(a, e, n.id);
|
|
292
292
|
return Promise.all([
|
|
293
|
-
|
|
294
|
-
|
|
293
|
+
s(i[0]),
|
|
294
|
+
s(i[1])
|
|
295
295
|
]);
|
|
296
296
|
}
|
|
297
297
|
getRuleFormulaResultSync(a, e, t) {
|
|
298
298
|
const i = this._ensureRuleFormulaMap(a, e).get(t);
|
|
299
299
|
if (i)
|
|
300
|
-
return i.map((
|
|
301
|
-
if (
|
|
302
|
-
return this._registerOtherFormulaService.getFormulaValueSync(a, e,
|
|
300
|
+
return i.map((s) => {
|
|
301
|
+
if (s)
|
|
302
|
+
return this._registerOtherFormulaService.getFormulaValueSync(a, e, s.id);
|
|
303
303
|
});
|
|
304
304
|
}
|
|
305
305
|
getRuleFormulaInfo(a, e, t) {
|
|
306
306
|
return this._ensureRuleFormulaMap(a, e).get(t);
|
|
307
307
|
}
|
|
308
308
|
};
|
|
309
|
-
K =
|
|
310
|
-
ie(0,
|
|
311
|
-
ie(1,
|
|
312
|
-
ie(2,
|
|
313
|
-
ie(3,
|
|
314
|
-
ie(4,
|
|
309
|
+
K = Jt([
|
|
310
|
+
ie(0, w),
|
|
311
|
+
ie(1, R(lt)),
|
|
312
|
+
ie(2, R(Q)),
|
|
313
|
+
ie(3, R(Ge)),
|
|
314
|
+
ie(4, R(q))
|
|
315
315
|
], K);
|
|
316
|
-
function ne(
|
|
317
|
-
return
|
|
316
|
+
function ne(o) {
|
|
317
|
+
return Rt(o);
|
|
318
318
|
}
|
|
319
|
-
function ct(
|
|
319
|
+
function ct(o) {
|
|
320
320
|
var a;
|
|
321
|
-
return String((a = ne(
|
|
321
|
+
return String((a = ne(o)) != null ? a : "");
|
|
322
322
|
}
|
|
323
323
|
class Xe {
|
|
324
324
|
constructor(a, e, t, r, i = !1) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
325
|
+
g(this, "_map");
|
|
326
|
+
g(this, "_tree", new St());
|
|
327
|
+
g(this, "_dirty", !0);
|
|
328
|
+
g(this, "_buildTree", () => {
|
|
329
329
|
if (!this._dirty || this._disableTree)
|
|
330
330
|
return;
|
|
331
331
|
this._tree.clear();
|
|
@@ -342,7 +342,7 @@ class Xe {
|
|
|
342
342
|
});
|
|
343
343
|
}), this._tree.load(a), this._dirty = !1;
|
|
344
344
|
});
|
|
345
|
-
|
|
345
|
+
g(this, "_debonceBuildTree", Vt(this._buildTree, 0));
|
|
346
346
|
this._unitId = e, this._subUnitId = t, this._univerInstanceService = r, this._disableTree = i, this._map = a, this._buildTree();
|
|
347
347
|
}
|
|
348
348
|
get _worksheet() {
|
|
@@ -352,10 +352,10 @@ class Xe {
|
|
|
352
352
|
_addRule(a, e) {
|
|
353
353
|
if (!this._worksheet)
|
|
354
354
|
return;
|
|
355
|
-
const t =
|
|
355
|
+
const t = O.mergeRanges(e.map((r) => b.transformRange(r, this._worksheet)));
|
|
356
356
|
this._map.forEach((r, i) => {
|
|
357
|
-
const
|
|
358
|
-
|
|
357
|
+
const s = O.subtractMulti(r, t);
|
|
358
|
+
s.length === 0 ? this._map.delete(i) : this._map.set(i, s);
|
|
359
359
|
}), this._dirty = !0, this._map.set(a, t), this._debonceBuildTree();
|
|
360
360
|
}
|
|
361
361
|
addRule(a) {
|
|
@@ -366,7 +366,7 @@ class Xe {
|
|
|
366
366
|
return;
|
|
367
367
|
const e = a.map((t) => b.transformRange(t, this._worksheet));
|
|
368
368
|
this._map.forEach((t, r) => {
|
|
369
|
-
const i =
|
|
369
|
+
const i = O.subtractMulti(t, e);
|
|
370
370
|
i.length === 0 ? this._map.delete(r) : this._map.set(r, i);
|
|
371
371
|
}), this._dirty = !0, this._debonceBuildTree();
|
|
372
372
|
}
|
|
@@ -384,11 +384,11 @@ class Xe {
|
|
|
384
384
|
if (!t.length)
|
|
385
385
|
return;
|
|
386
386
|
let r = this._map.get(e);
|
|
387
|
-
r ? (this._map.set(e,
|
|
388
|
-
if (
|
|
387
|
+
r ? (this._map.set(e, O.mergeRanges([...r, ...t])), r = this._map.get(e)) : (r = t, this._map.set(e, r)), this._map.forEach((i, s) => {
|
|
388
|
+
if (s === e)
|
|
389
389
|
return;
|
|
390
|
-
const n =
|
|
391
|
-
n.length === 0 ? this._map.delete(
|
|
390
|
+
const n = O.subtractMulti(i, t);
|
|
391
|
+
n.length === 0 ? this._map.delete(s) : this._map.set(s, n);
|
|
392
392
|
});
|
|
393
393
|
}), this._dirty = !0, this._debonceBuildTree();
|
|
394
394
|
}
|
|
@@ -397,14 +397,14 @@ class Xe {
|
|
|
397
397
|
let t = 0;
|
|
398
398
|
return a.forEach((r, i) => {
|
|
399
399
|
var l;
|
|
400
|
-
const
|
|
401
|
-
|
|
400
|
+
const s = (l = this._map.get(r.uid)) != null ? l : [], n = r.ranges;
|
|
401
|
+
s.length !== 0 && (s.length !== n.length || s.some((u, d) => !O.equals(u, n[d]))) && e.push({
|
|
402
402
|
type: "update",
|
|
403
403
|
ruleId: r.uid,
|
|
404
404
|
oldRanges: n,
|
|
405
|
-
newRanges:
|
|
405
|
+
newRanges: O.sort(s),
|
|
406
406
|
rule: r
|
|
407
|
-
}),
|
|
407
|
+
}), s.length === 0 && (e.push({
|
|
408
408
|
type: "delete",
|
|
409
409
|
rule: r,
|
|
410
410
|
index: i - t
|
|
@@ -414,28 +414,28 @@ class Xe {
|
|
|
414
414
|
diffWithAddition(a, e) {
|
|
415
415
|
const t = [];
|
|
416
416
|
let r = 0;
|
|
417
|
-
return a.forEach((i,
|
|
417
|
+
return a.forEach((i, s) => {
|
|
418
418
|
var u;
|
|
419
419
|
const n = (u = this._map.get(i.uid)) != null ? u : [], l = i.ranges;
|
|
420
|
-
n.length !== 0 && (n.length !== l.length || n.some((d, c) => !
|
|
420
|
+
n.length !== 0 && (n.length !== l.length || n.some((d, c) => !O.equals(d, l[c]))) && t.push({
|
|
421
421
|
type: "update",
|
|
422
422
|
ruleId: i.uid,
|
|
423
423
|
oldRanges: l,
|
|
424
|
-
newRanges:
|
|
424
|
+
newRanges: O.sort(n),
|
|
425
425
|
rule: i
|
|
426
426
|
}), n.length === 0 && (t.push({
|
|
427
427
|
type: "delete",
|
|
428
428
|
rule: i,
|
|
429
|
-
index:
|
|
429
|
+
index: s - r
|
|
430
430
|
}), r++);
|
|
431
431
|
}), Array.from(e).forEach((i) => {
|
|
432
432
|
var n;
|
|
433
|
-
const
|
|
433
|
+
const s = (n = this._map.get(i.uid)) != null ? n : [];
|
|
434
434
|
t.push({
|
|
435
435
|
type: "add",
|
|
436
436
|
rule: {
|
|
437
437
|
...i,
|
|
438
|
-
ranges:
|
|
438
|
+
ranges: O.sort(s)
|
|
439
439
|
}
|
|
440
440
|
});
|
|
441
441
|
}), t;
|
|
@@ -461,20 +461,20 @@ class Xe {
|
|
|
461
461
|
return t.length > 0 ? t[0].ruleId : void 0;
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
|
-
var
|
|
465
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
466
|
-
(
|
|
467
|
-
return
|
|
468
|
-
}, X = (
|
|
469
|
-
let F = class extends
|
|
470
|
-
constructor(a, e, t, r, i,
|
|
464
|
+
var ea = Object.getOwnPropertyDescriptor, ta = (o, a, e, t) => {
|
|
465
|
+
for (var r = t > 1 ? void 0 : t ? ea(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
466
|
+
(s = o[i]) && (r = s(r) || r);
|
|
467
|
+
return r;
|
|
468
|
+
}, X = (o, a) => (e, t) => a(e, t, o);
|
|
469
|
+
let F = class extends W {
|
|
470
|
+
constructor(a, e, t, r, i, s, n) {
|
|
471
471
|
super();
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
this._dataValidationModel = a, this._univerInstanceService = e, this._dataValidatorRegistryService = t, this._dataValidationCacheService = r, this._dataValidationFormulaService = i, this._dataValidationCustomFormulaService =
|
|
472
|
+
g(this, "_ruleMatrixMap", /* @__PURE__ */ new Map());
|
|
473
|
+
g(this, "_validStatusChange$", new je());
|
|
474
|
+
g(this, "_ruleChange$", new je());
|
|
475
|
+
g(this, "ruleChange$", this._ruleChange$.asObservable());
|
|
476
|
+
g(this, "validStatusChange$", this._validStatusChange$.asObservable());
|
|
477
|
+
this._dataValidationModel = a, this._univerInstanceService = e, this._dataValidatorRegistryService = t, this._dataValidationCacheService = r, this._dataValidationFormulaService = i, this._dataValidationCustomFormulaService = s, this._commandService = n, this._initRuleUpdateListener(), this.disposeWithMe(() => {
|
|
478
478
|
this._ruleChange$.complete(), this._validStatusChange$.complete();
|
|
479
479
|
}), this._initUniverInstanceListener();
|
|
480
480
|
}
|
|
@@ -496,12 +496,12 @@ let F = class extends $ {
|
|
|
496
496
|
const a = this._dataValidationModel.getAll();
|
|
497
497
|
for (const [e, t] of a)
|
|
498
498
|
for (const [r, i] of t)
|
|
499
|
-
for (const
|
|
500
|
-
this._addRule(e, r,
|
|
499
|
+
for (const s of i)
|
|
500
|
+
this._addRule(e, r, s), this._ruleChange$.next({
|
|
501
501
|
type: "add",
|
|
502
502
|
unitId: e,
|
|
503
503
|
subUnitId: r,
|
|
504
|
-
rule:
|
|
504
|
+
rule: s,
|
|
505
505
|
source: "patched"
|
|
506
506
|
});
|
|
507
507
|
this.disposeWithMe(
|
|
@@ -536,11 +536,11 @@ let F = class extends $ {
|
|
|
536
536
|
});
|
|
537
537
|
}
|
|
538
538
|
_updateRule(a, e, t, r, i) {
|
|
539
|
-
const
|
|
539
|
+
const s = this._ensureRuleMatrix(a, e), n = {
|
|
540
540
|
...r,
|
|
541
541
|
...i.payload
|
|
542
542
|
};
|
|
543
|
-
i.type === y.RANGE ?
|
|
543
|
+
i.type === y.RANGE ? s.updateRange(t, i.payload) : i.type === y.ALL && s.updateRange(t, i.payload.ranges), this._dataValidationCacheService.removeRule(a, e, r), this._dataValidationCacheService.addRule(a, e, n), this._dataValidationFormulaService.removeRule(a, e, r.uid), this._dataValidationFormulaService.addRule(a, e, n), this._dataValidationCustomFormulaService.deleteByRuleId(a, e, t), this._dataValidationCustomFormulaService.addRule(a, e, n);
|
|
544
544
|
}
|
|
545
545
|
_removeRule(a, e, t) {
|
|
546
546
|
this._ensureRuleMatrix(a, e).removeRule(t), this._dataValidationCacheService.removeRule(a, e, t), this._dataValidationCustomFormulaService.deleteByRuleId(a, e, t.uid);
|
|
@@ -557,22 +557,22 @@ let F = class extends $ {
|
|
|
557
557
|
return this._dataValidationModel.getRuleById(a, e, i);
|
|
558
558
|
}
|
|
559
559
|
validator(a, e, t) {
|
|
560
|
-
const { col: r, row: i, unitId:
|
|
561
|
-
t && t(
|
|
562
|
-
unitId:
|
|
560
|
+
const { col: r, row: i, unitId: s, subUnitId: n, worksheet: l } = e, u = (_, v) => {
|
|
561
|
+
t && t(_, v), v && this._validStatusChange$.next({
|
|
562
|
+
unitId: s,
|
|
563
563
|
subUnitId: n,
|
|
564
564
|
ruleId: a.uid,
|
|
565
|
-
status:
|
|
565
|
+
status: _,
|
|
566
566
|
row: i,
|
|
567
567
|
col: r
|
|
568
568
|
});
|
|
569
|
-
}, d = l.getCellValueOnly(i, r), c = this.getValidator(a.type), m = l.getCellRaw(i, r),
|
|
569
|
+
}, d = l.getCellValueOnly(i, r), c = this.getValidator(a.type), m = l.getCellRaw(i, r), p = ne(m);
|
|
570
570
|
if (c) {
|
|
571
|
-
const
|
|
572
|
-
return
|
|
571
|
+
const _ = this._dataValidationCacheService.ensureCache(s, n), v = _.getValue(i, r);
|
|
572
|
+
return v == null ? (_.setValue(i, r, D.VALIDATING), c.validator(
|
|
573
573
|
{
|
|
574
|
-
value:
|
|
575
|
-
unitId:
|
|
574
|
+
value: p,
|
|
575
|
+
unitId: s,
|
|
576
576
|
subUnitId: n,
|
|
577
577
|
row: i,
|
|
578
578
|
column: r,
|
|
@@ -583,11 +583,11 @@ let F = class extends $ {
|
|
|
583
583
|
},
|
|
584
584
|
a
|
|
585
585
|
).then((M) => {
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
const
|
|
589
|
-
u(
|
|
590
|
-
}), D.VALIDATING) : (u(
|
|
586
|
+
const f = M ? D.VALID : D.INVALID;
|
|
587
|
+
f === D.VALID ? _.realDeleteValue(i, r) : _.setValue(i, r, f);
|
|
588
|
+
const I = _.getValue(i, r);
|
|
589
|
+
u(f, v !== I);
|
|
590
|
+
}), D.VALIDATING) : (u(v != null ? v : D.VALID, !1), v != null ? v : D.VALID);
|
|
591
591
|
} else
|
|
592
592
|
return u(D.VALID, !1), D.VALID;
|
|
593
593
|
}
|
|
@@ -616,37 +616,37 @@ let F = class extends $ {
|
|
|
616
616
|
return this._dataValidationModel.getAll();
|
|
617
617
|
}
|
|
618
618
|
};
|
|
619
|
-
F =
|
|
620
|
-
X(0,
|
|
621
|
-
X(1,
|
|
622
|
-
X(2,
|
|
623
|
-
X(3,
|
|
624
|
-
X(4,
|
|
625
|
-
X(5,
|
|
619
|
+
F = ta([
|
|
620
|
+
X(0, R(Ge)),
|
|
621
|
+
X(1, w),
|
|
622
|
+
X(2, R(q)),
|
|
623
|
+
X(3, R(Q)),
|
|
624
|
+
X(4, R(K)),
|
|
625
|
+
X(5, R(H)),
|
|
626
626
|
X(6, x)
|
|
627
627
|
], F);
|
|
628
628
|
const Ve = 1, Me = 0;
|
|
629
|
-
function et(
|
|
630
|
-
return V.isBlank(
|
|
629
|
+
function et(o, a) {
|
|
630
|
+
return V.isBlank(o) ? a.t("dataValidation.validFail.value") : S(o) ? a.t("dataValidation.validFail.primitive") : "";
|
|
631
631
|
}
|
|
632
|
-
const
|
|
633
|
-
class
|
|
632
|
+
const pe = (o) => V.isDefine(o) && String(o).toLowerCase() === "true" ? "1" : String(o).toLowerCase() === "false" ? "0" : o;
|
|
633
|
+
class aa extends G {
|
|
634
634
|
constructor() {
|
|
635
635
|
super(...arguments);
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
const { unitId: i, subUnitId:
|
|
636
|
+
g(this, "id", T.CHECKBOX);
|
|
637
|
+
g(this, "title", "dataValidation.checkbox.title");
|
|
638
|
+
g(this, "operators", []);
|
|
639
|
+
g(this, "scopes", ["sheet"]);
|
|
640
|
+
g(this, "offsetFormulaByRange", !1);
|
|
641
|
+
g(this, "_formulaService", this.injector.get(K));
|
|
642
|
+
g(this, "skipDefaultFontRender", (e, t, r) => {
|
|
643
|
+
const { unitId: i, subUnitId: s } = r, { formula1: n, formula2: l } = this.parseFormulaSync(e, i, s), u = `${t != null ? t : ""}`;
|
|
644
644
|
return !u || u === `${n}` || u === `${l}`;
|
|
645
645
|
});
|
|
646
646
|
}
|
|
647
647
|
validatorFormula(e, t, r) {
|
|
648
|
-
const { formula1: i, formula2:
|
|
649
|
-
if (V.isBlank(i) && V.isBlank(
|
|
648
|
+
const { formula1: i, formula2: s } = e, n = i === s;
|
|
649
|
+
if (V.isBlank(i) && V.isBlank(s))
|
|
650
650
|
return {
|
|
651
651
|
success: !0
|
|
652
652
|
};
|
|
@@ -656,7 +656,7 @@ class na extends k {
|
|
|
656
656
|
formula1: this.localeService.t("dataValidation.validFail.checkboxEqual"),
|
|
657
657
|
formula2: this.localeService.t("dataValidation.validFail.checkboxEqual")
|
|
658
658
|
};
|
|
659
|
-
const l = et(i, this.localeService), u = et(
|
|
659
|
+
const l = et(i, this.localeService), u = et(s, this.localeService);
|
|
660
660
|
return {
|
|
661
661
|
success: !l && !u,
|
|
662
662
|
formula1: l,
|
|
@@ -664,11 +664,11 @@ class na extends k {
|
|
|
664
664
|
};
|
|
665
665
|
}
|
|
666
666
|
async parseFormula(e, t, r) {
|
|
667
|
-
var c, m,
|
|
668
|
-
const { formula1: i = Ve, formula2:
|
|
667
|
+
var c, m, p, _;
|
|
668
|
+
const { formula1: i = Ve, formula2: s = Me } = e, n = await this._formulaService.getRuleFormulaResult(t, r, e.uid), l = S(i) ? oe((m = (c = n == null ? void 0 : n[0]) == null ? void 0 : c.result) == null ? void 0 : m[0][0]) : i, u = S(s) ? oe((_ = (p = n == null ? void 0 : n[1]) == null ? void 0 : p.result) == null ? void 0 : _[0][0]) : s, d = C(String(l)) && C(String(u));
|
|
669
669
|
return {
|
|
670
|
-
formula1:
|
|
671
|
-
formula2:
|
|
670
|
+
formula1: pe(l),
|
|
671
|
+
formula2: pe(u),
|
|
672
672
|
originFormula1: l,
|
|
673
673
|
originFormula2: u,
|
|
674
674
|
isFormulaValid: d
|
|
@@ -676,29 +676,29 @@ class na extends k {
|
|
|
676
676
|
}
|
|
677
677
|
getExtraStyle(e, t) {
|
|
678
678
|
return {
|
|
679
|
-
tb:
|
|
679
|
+
tb: Re.CLIP
|
|
680
680
|
};
|
|
681
681
|
}
|
|
682
682
|
parseFormulaSync(e, t, r) {
|
|
683
|
-
var c, m,
|
|
684
|
-
const { formula1: i = Ve, formula2:
|
|
683
|
+
var c, m, p, _;
|
|
684
|
+
const { formula1: i = Ve, formula2: s = Me } = e, n = this._formulaService.getRuleFormulaResultSync(t, r, e.uid), l = S(i) ? oe((m = (c = n == null ? void 0 : n[0]) == null ? void 0 : c.result) == null ? void 0 : m[0][0]) : i, u = S(s) ? oe((_ = (p = n == null ? void 0 : n[1]) == null ? void 0 : p.result) == null ? void 0 : _[0][0]) : s, d = C(String(l)) && C(String(u));
|
|
685
685
|
return {
|
|
686
|
-
formula1:
|
|
687
|
-
formula2:
|
|
686
|
+
formula1: pe(l),
|
|
687
|
+
formula2: pe(u),
|
|
688
688
|
originFormula1: l,
|
|
689
689
|
originFormula2: u,
|
|
690
690
|
isFormulaValid: d
|
|
691
691
|
};
|
|
692
692
|
}
|
|
693
693
|
async isValidType(e, t, r) {
|
|
694
|
-
const { value: i, unitId:
|
|
694
|
+
const { value: i, unitId: s, subUnitId: n } = e, { formula1: l, formula2: u, originFormula1: d, originFormula2: c } = await this.parseFormula(r, s, n);
|
|
695
695
|
return !V.isDefine(l) || !V.isDefine(u) ? !0 : V.isDefine(i) && (String(i) === String(l) || String(i) === String(u) || String(i) === String(d != null ? d : "") || String(i) === String(c != null ? c : ""));
|
|
696
696
|
}
|
|
697
697
|
generateRuleErrorMessage(e) {
|
|
698
698
|
return this.localeService.t("dataValidation.checkbox.error");
|
|
699
699
|
}
|
|
700
700
|
}
|
|
701
|
-
const
|
|
701
|
+
const ra = {
|
|
702
702
|
[h.BETWEEN]: "dataValidation.date.operators.between",
|
|
703
703
|
[h.EQUAL]: "dataValidation.date.operators.equal",
|
|
704
704
|
[h.GREATER_THAN]: "dataValidation.date.operators.greaterThan",
|
|
@@ -709,7 +709,7 @@ const la = {
|
|
|
709
709
|
[h.NOT_EQUAL]: "dataValidation.date.operators.notEqual"
|
|
710
710
|
};
|
|
711
711
|
h.BETWEEN + "", h.EQUAL + "", h.GREATER_THAN + "", h.GREATER_THAN_OR_EQUAL + "", h.LESS_THAN + "", h.LESS_THAN_OR_EQUAL + "", h.NOT_BETWEEN + "", h.NOT_EQUAL + "";
|
|
712
|
-
const
|
|
712
|
+
const ia = {
|
|
713
713
|
[h.BETWEEN]: "dataValidation.date.ruleName.between",
|
|
714
714
|
[h.EQUAL]: "dataValidation.date.ruleName.equal",
|
|
715
715
|
[h.GREATER_THAN]: "dataValidation.date.ruleName.greaterThan",
|
|
@@ -718,7 +718,7 @@ const ua = {
|
|
|
718
718
|
[h.LESS_THAN_OR_EQUAL]: "dataValidation.date.ruleName.lessThanOrEqual",
|
|
719
719
|
[h.NOT_BETWEEN]: "dataValidation.date.ruleName.notBetween",
|
|
720
720
|
[h.NOT_EQUAL]: "dataValidation.date.ruleName.notEqual"
|
|
721
|
-
},
|
|
721
|
+
}, oa = {
|
|
722
722
|
[h.BETWEEN]: "dataValidation.date.errorMsg.between",
|
|
723
723
|
[h.EQUAL]: "dataValidation.date.errorMsg.equal",
|
|
724
724
|
[h.GREATER_THAN]: "dataValidation.date.errorMsg.greaterThan",
|
|
@@ -731,38 +731,38 @@ const ua = {
|
|
|
731
731
|
h.BETWEEN,
|
|
732
732
|
h.NOT_BETWEEN
|
|
733
733
|
], le = "{FORMULA1}", ue = "{FORMULA2}";
|
|
734
|
-
function
|
|
735
|
-
return
|
|
734
|
+
function Ya(o) {
|
|
735
|
+
return o.filter(Boolean).join(",");
|
|
736
736
|
}
|
|
737
|
-
function
|
|
738
|
-
return
|
|
737
|
+
function fe(o) {
|
|
738
|
+
return o.split(",").filter(Boolean);
|
|
739
739
|
}
|
|
740
|
-
function
|
|
741
|
-
const a = ne(
|
|
740
|
+
function Xa(o) {
|
|
741
|
+
const a = ne(o);
|
|
742
742
|
return a == null ? "" : a.toString();
|
|
743
743
|
}
|
|
744
|
-
function De(
|
|
745
|
-
const { formula1: t, formula2: r } = a, i = a.ranges[0].startRow,
|
|
744
|
+
function De(o, a, e) {
|
|
745
|
+
const { formula1: t, formula2: r } = a, i = a.ranges[0].startRow, s = a.ranges[0].startColumn, n = e.row - i, l = e.col - s, u = S(t) ? o.moveFormulaRefOffset(t, l, n, !0) : t, d = S(r) ? o.moveFormulaRefOffset(r, l, n, !0) : r;
|
|
746
746
|
return {
|
|
747
747
|
transformedFormula1: u,
|
|
748
748
|
transformedFormula2: d
|
|
749
749
|
};
|
|
750
750
|
}
|
|
751
|
-
const Ue = (
|
|
751
|
+
const Ue = (o) => {
|
|
752
752
|
var e, t;
|
|
753
|
-
if (
|
|
753
|
+
if (o == null || typeof o == "boolean")
|
|
754
754
|
return;
|
|
755
|
-
if (typeof
|
|
756
|
-
return +
|
|
757
|
-
const a = (e =
|
|
758
|
-
return V.isDefine(a) ? a : (t =
|
|
755
|
+
if (typeof o == "number" || !Number.isNaN(+o))
|
|
756
|
+
return +o;
|
|
757
|
+
const a = (e = j.parseDate(o)) == null ? void 0 : e.v;
|
|
758
|
+
return V.isDefine(a) ? a : (t = j.parseDate(at(o).format("YYYY-MM-DD HH:mm:ss"))) == null ? void 0 : t.v;
|
|
759
759
|
};
|
|
760
|
-
class
|
|
760
|
+
class sa extends G {
|
|
761
761
|
constructor() {
|
|
762
762
|
super(...arguments);
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
763
|
+
g(this, "id", T.DATE);
|
|
764
|
+
g(this, "title", "dataValidation.date.title");
|
|
765
|
+
g(this, "operators", [
|
|
766
766
|
h.BETWEEN,
|
|
767
767
|
h.EQUAL,
|
|
768
768
|
h.GREATER_THAN,
|
|
@@ -772,24 +772,24 @@ class ca extends k {
|
|
|
772
772
|
h.NOT_BETWEEN,
|
|
773
773
|
h.NOT_EQUAL
|
|
774
774
|
]);
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
775
|
+
g(this, "scopes", ["sheet"]);
|
|
776
|
+
g(this, "_customFormulaService", this.injector.get(H));
|
|
777
|
+
g(this, "_lexerTreeBuilder", this.injector.get(Y));
|
|
778
778
|
}
|
|
779
|
-
async parseFormula(e, t, r, i,
|
|
780
|
-
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i,
|
|
779
|
+
async parseFormula(e, t, r, i, s) {
|
|
780
|
+
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i, s), l = await this._customFormulaService.getCellFormula2Value(t, r, e.uid, i, s), { formula1: u, formula2: d } = e, c = C(String(n == null ? void 0 : n.v)) && C(String(l == null ? void 0 : l.v));
|
|
781
781
|
return {
|
|
782
|
-
formula1: Ue(
|
|
783
|
-
formula2: Ue(
|
|
782
|
+
formula1: Ue(S(u) ? n == null ? void 0 : n.v : u),
|
|
783
|
+
formula2: Ue(S(d) ? l == null ? void 0 : l.v : d),
|
|
784
784
|
isFormulaValid: c
|
|
785
785
|
};
|
|
786
786
|
}
|
|
787
787
|
async isValidType(e) {
|
|
788
788
|
const { interceptValue: t, value: r } = e;
|
|
789
|
-
return typeof r == "number" && typeof t == "string" ? !0 : typeof t == "string" ? !!
|
|
789
|
+
return typeof r == "number" && typeof t == "string" ? !0 : typeof t == "string" ? !!j.parseDate(t) : !1;
|
|
790
790
|
}
|
|
791
791
|
_validatorSingleFormula(e) {
|
|
792
|
-
return !V.isBlank(e) && (
|
|
792
|
+
return !V.isBlank(e) && (S(e) || !Number.isNaN(+e) || !!(e && j.parseDate(e)));
|
|
793
793
|
}
|
|
794
794
|
validatorFormula(e, t, r) {
|
|
795
795
|
const i = e.operator;
|
|
@@ -797,39 +797,39 @@ class ca extends k {
|
|
|
797
797
|
return {
|
|
798
798
|
success: !1
|
|
799
799
|
};
|
|
800
|
-
const
|
|
800
|
+
const s = this._validatorSingleFormula(e.formula1), n = this.localeService.t("dataValidation.validFail.date");
|
|
801
801
|
if (Ae.includes(i)) {
|
|
802
802
|
const u = this._validatorSingleFormula(e.formula2);
|
|
803
803
|
return {
|
|
804
|
-
success:
|
|
805
|
-
formula1:
|
|
804
|
+
success: s && u,
|
|
805
|
+
formula1: s ? void 0 : n,
|
|
806
806
|
formula2: u ? void 0 : n
|
|
807
807
|
};
|
|
808
808
|
}
|
|
809
809
|
return {
|
|
810
|
-
success:
|
|
811
|
-
formula1:
|
|
810
|
+
success: s,
|
|
811
|
+
formula1: s ? void 0 : n
|
|
812
812
|
};
|
|
813
813
|
}
|
|
814
814
|
normalizeFormula(e, t, r) {
|
|
815
|
-
const { formula1: i, formula2:
|
|
815
|
+
const { formula1: i, formula2: s, bizInfo: n } = e, l = (u) => {
|
|
816
816
|
var c;
|
|
817
817
|
if (!u)
|
|
818
818
|
return u;
|
|
819
819
|
let d;
|
|
820
820
|
if (!Number.isNaN(+u))
|
|
821
|
-
d =
|
|
821
|
+
d = j.dateFromSerial(+u);
|
|
822
822
|
else {
|
|
823
|
-
const m = (c =
|
|
823
|
+
const m = (c = j.parseDate(u)) == null ? void 0 : c.v;
|
|
824
824
|
if (m == null)
|
|
825
825
|
return "";
|
|
826
|
-
d =
|
|
826
|
+
d = j.dateFromSerial(m);
|
|
827
827
|
}
|
|
828
828
|
return at(`${d[0]}/${d[1]}/${d[2]} ${d[3]}:${d[4]}:${d[5]}`).format(n != null && n.showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD");
|
|
829
829
|
};
|
|
830
830
|
return {
|
|
831
|
-
formula1:
|
|
832
|
-
formula2:
|
|
831
|
+
formula1: S(i) ? i : l(`${i}`),
|
|
832
|
+
formula2: S(s) ? s : l(`${s}`)
|
|
833
833
|
};
|
|
834
834
|
}
|
|
835
835
|
transform(e, t, r) {
|
|
@@ -840,20 +840,20 @@ class ca extends k {
|
|
|
840
840
|
};
|
|
841
841
|
}
|
|
842
842
|
get operatorNames() {
|
|
843
|
-
return this.operators.map((e) => this.localeService.t(
|
|
843
|
+
return this.operators.map((e) => this.localeService.t(ra[e]));
|
|
844
844
|
}
|
|
845
845
|
generateRuleName(e) {
|
|
846
846
|
var r, i;
|
|
847
847
|
if (!e.operator)
|
|
848
848
|
return this.titleStr;
|
|
849
|
-
const t = this.localeService.t(
|
|
849
|
+
const t = this.localeService.t(ia[e.operator]).replace(le, (r = e.formula1) != null ? r : "").replace(ue, (i = e.formula2) != null ? i : "");
|
|
850
850
|
return `${this.titleStr} ${t}`;
|
|
851
851
|
}
|
|
852
852
|
generateRuleErrorMessage(e, t) {
|
|
853
853
|
if (!e.operator)
|
|
854
854
|
return this.titleStr;
|
|
855
855
|
const { transformedFormula1: r, transformedFormula2: i } = De(this._lexerTreeBuilder, e, t);
|
|
856
|
-
return `${this.localeService.t(
|
|
856
|
+
return `${this.localeService.t(oa[e.operator]).replace(le, r != null ? r : "").replace(ue, i != null ? i : "")}`;
|
|
857
857
|
}
|
|
858
858
|
}
|
|
859
859
|
h.BETWEEN + "", h.EQUAL + "", h.GREATER_THAN + "", h.GREATER_THAN_OR_EQUAL + "", h.LESS_THAN + "", h.LESS_THAN_OR_EQUAL + "", h.NOT_BETWEEN + "", h.NOT_EQUAL + "";
|
|
@@ -868,18 +868,18 @@ const ht = {
|
|
|
868
868
|
[h.NOT_BETWEEN]: "dataValidation.errorMsg.notBetween",
|
|
869
869
|
[h.NOT_EQUAL]: "dataValidation.errorMsg.notEqual"
|
|
870
870
|
};
|
|
871
|
-
function ye(
|
|
872
|
-
let a =
|
|
873
|
-
return typeof
|
|
871
|
+
function ye(o) {
|
|
872
|
+
let a = o;
|
|
873
|
+
return typeof o == "string" ? ((o.startsWith("¥") || o.startsWith("$")) && (a = o.slice(1)), +a) : +o;
|
|
874
874
|
}
|
|
875
|
-
class
|
|
875
|
+
class na extends G {
|
|
876
876
|
constructor() {
|
|
877
877
|
super(...arguments);
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
878
|
+
g(this, "_customFormulaService", this.injector.get(H));
|
|
879
|
+
g(this, "id", T.DECIMAL);
|
|
880
|
+
g(this, "_lexerTreeBuilder", this.injector.get(Y));
|
|
881
|
+
g(this, "title", "dataValidation.decimal.title");
|
|
882
|
+
g(this, "operators", [
|
|
883
883
|
h.BETWEEN,
|
|
884
884
|
h.EQUAL,
|
|
885
885
|
h.GREATER_THAN,
|
|
@@ -889,10 +889,10 @@ class ha extends k {
|
|
|
889
889
|
h.NOT_BETWEEN,
|
|
890
890
|
h.NOT_EQUAL
|
|
891
891
|
]);
|
|
892
|
-
|
|
892
|
+
g(this, "scopes", ["sheet"]);
|
|
893
893
|
}
|
|
894
894
|
_isFormulaOrNumber(e) {
|
|
895
|
-
return !V.isBlank(e) && (
|
|
895
|
+
return !V.isBlank(e) && (S(e) || !Number.isNaN(+e));
|
|
896
896
|
}
|
|
897
897
|
async isValidType(e, t, r) {
|
|
898
898
|
const { value: i } = e;
|
|
@@ -908,11 +908,11 @@ class ha extends k {
|
|
|
908
908
|
_parseNumber(e) {
|
|
909
909
|
return e == null ? Number.NaN : +e;
|
|
910
910
|
}
|
|
911
|
-
async parseFormula(e, t, r, i,
|
|
912
|
-
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i,
|
|
911
|
+
async parseFormula(e, t, r, i, s) {
|
|
912
|
+
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i, s), l = await this._customFormulaService.getCellFormula2Value(t, r, e.uid, i, s), { formula1: u, formula2: d } = e, c = C(String(n == null ? void 0 : n.v)) && C(String(l == null ? void 0 : l.v));
|
|
913
913
|
return {
|
|
914
|
-
formula1: this._parseNumber(
|
|
915
|
-
formula2: this._parseNumber(
|
|
914
|
+
formula1: this._parseNumber(S(u) ? n == null ? void 0 : n.v : u),
|
|
915
|
+
formula2: this._parseNumber(S(d) ? l == null ? void 0 : l.v : d),
|
|
916
916
|
isFormulaValid: c
|
|
917
917
|
};
|
|
918
918
|
}
|
|
@@ -922,14 +922,14 @@ class ha extends k {
|
|
|
922
922
|
return {
|
|
923
923
|
success: !1
|
|
924
924
|
};
|
|
925
|
-
const
|
|
925
|
+
const s = V.isDefine(e.formula1) && this._isFormulaOrNumber(e.formula1), n = V.isDefine(e.formula2) && this._isFormulaOrNumber(e.formula2), l = Ae.includes(i), u = this.localeService.t("dataValidation.validFail.number");
|
|
926
926
|
return l ? {
|
|
927
|
-
success:
|
|
928
|
-
formula1:
|
|
927
|
+
success: s && n,
|
|
928
|
+
formula1: s ? void 0 : u,
|
|
929
929
|
formula2: n ? void 0 : u
|
|
930
930
|
} : {
|
|
931
|
-
success:
|
|
932
|
-
formula1:
|
|
931
|
+
success: s,
|
|
932
|
+
formula1: s ? "" : u
|
|
933
933
|
};
|
|
934
934
|
}
|
|
935
935
|
generateRuleErrorMessage(e, t) {
|
|
@@ -939,18 +939,18 @@ class ha extends k {
|
|
|
939
939
|
return `${this.localeService.t(ht[e.operator]).replace(le, r != null ? r : "").replace(ue, i != null ? i : "")}`;
|
|
940
940
|
}
|
|
941
941
|
}
|
|
942
|
-
function
|
|
943
|
-
if (!
|
|
942
|
+
function He(o) {
|
|
943
|
+
if (!o)
|
|
944
944
|
return [];
|
|
945
945
|
const a = /* @__PURE__ */ new Set();
|
|
946
|
-
return
|
|
946
|
+
return o.forEach(
|
|
947
947
|
(e) => {
|
|
948
948
|
e.forEach((t) => {
|
|
949
|
-
var i,
|
|
949
|
+
var i, s;
|
|
950
950
|
const r = ne(t);
|
|
951
951
|
if (r != null) {
|
|
952
|
-
if (typeof r != "string" && typeof (t == null ? void 0 : t.s) == "object" && ((
|
|
953
|
-
a.add(
|
|
952
|
+
if (typeof r != "string" && typeof (t == null ? void 0 : t.s) == "object" && ((s = (i = t.s) == null ? void 0 : i.n) != null && s.pattern)) {
|
|
953
|
+
a.add(j.format(t.s.n.pattern, r, { throws: !1 }));
|
|
954
954
|
return;
|
|
955
955
|
}
|
|
956
956
|
C(r.toString()) && a.add(r.toString());
|
|
@@ -959,51 +959,51 @@ function Pe(s) {
|
|
|
959
959
|
}
|
|
960
960
|
), [...a];
|
|
961
961
|
}
|
|
962
|
-
const
|
|
962
|
+
const la = [
|
|
963
963
|
"if",
|
|
964
964
|
"indirect",
|
|
965
965
|
"choose",
|
|
966
966
|
"offset"
|
|
967
967
|
];
|
|
968
|
-
function
|
|
969
|
-
if (!
|
|
968
|
+
function ua(o, a) {
|
|
969
|
+
if (!S(o) || dt(o.slice(1)))
|
|
970
970
|
return !0;
|
|
971
|
-
const t = a.sequenceNodesBuilder(
|
|
972
|
-
return t && t.some((r) => typeof r == "object" && r.nodeType ===
|
|
971
|
+
const t = a.sequenceNodesBuilder(o);
|
|
972
|
+
return t && t.some((r) => typeof r == "object" && r.nodeType === kt.FUNCTION && la.indexOf(r.token.toLowerCase()) > -1);
|
|
973
973
|
}
|
|
974
|
-
function
|
|
975
|
-
const { formula1: e = "", ranges: t } =
|
|
974
|
+
function da(o, a) {
|
|
975
|
+
const { formula1: e = "", ranges: t } = o;
|
|
976
976
|
if (dt(e.slice(1))) {
|
|
977
|
-
const i =
|
|
978
|
-
if ((!i.sheetName || i.sheetName === a) && t.some((
|
|
977
|
+
const i = jt(e.slice(1));
|
|
978
|
+
if ((!i.sheetName || i.sheetName === a) && t.some((s) => O.intersects(s, i.range)))
|
|
979
979
|
return !0;
|
|
980
980
|
}
|
|
981
981
|
return !1;
|
|
982
982
|
}
|
|
983
|
-
class mt extends
|
|
983
|
+
class mt extends G {
|
|
984
984
|
constructor() {
|
|
985
985
|
super(...arguments);
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
986
|
+
g(this, "formulaService", this.injector.get(K));
|
|
987
|
+
g(this, "_lexer", this.injector.get(Y));
|
|
988
|
+
g(this, "_univerInstanceService", this.injector.get(w));
|
|
989
|
+
g(this, "offsetFormulaByRange", !1);
|
|
990
|
+
g(this, "id", T.LIST);
|
|
991
|
+
g(this, "title", "dataValidation.list.title");
|
|
992
|
+
g(this, "operators", []);
|
|
993
|
+
g(this, "scopes", ["sheet"]);
|
|
994
|
+
g(this, "skipDefaultFontRender", (e) => e.renderMode !== Be.TEXT);
|
|
995
995
|
}
|
|
996
996
|
validatorFormula(e, t, r) {
|
|
997
997
|
var u, d, c;
|
|
998
|
-
const i = !V.isBlank(e.formula1),
|
|
998
|
+
const i = !V.isBlank(e.formula1), s = ua((u = e.formula1) != null ? u : "", this._lexer), n = (c = (d = this._univerInstanceService.getUnit(t, N.UNIVER_SHEET)) == null ? void 0 : d.getSheetBySheetId(r)) == null ? void 0 : c.getName(), l = da(e, n != null ? n : "");
|
|
999
999
|
return {
|
|
1000
|
-
success: !!(i &&
|
|
1001
|
-
formula1: i ?
|
|
1000
|
+
success: !!(i && s && !l),
|
|
1001
|
+
formula1: i ? s ? l ? this.localeService.t("dataValidation.validFail.listIntersects") : void 0 : this.localeService.t("dataValidation.validFail.listInvalid") : this.localeService.t("dataValidation.validFail.list")
|
|
1002
1002
|
};
|
|
1003
1003
|
}
|
|
1004
1004
|
getExtraStyle(e, t, { style: r }) {
|
|
1005
|
-
var
|
|
1006
|
-
const i = (
|
|
1005
|
+
var s;
|
|
1006
|
+
const i = (s = r.tb !== Re.OVERFLOW ? r.tb : Re.CLIP) != null ? s : Re.WRAP;
|
|
1007
1007
|
if (e.type === T.LIST && (e.renderMode === Be.ARROW || e.renderMode === Be.TEXT)) {
|
|
1008
1008
|
const n = this.getListWithColorMap(e), l = `${t != null ? t : ""}`, u = n[l];
|
|
1009
1009
|
if (u)
|
|
@@ -1020,21 +1020,21 @@ class mt extends k {
|
|
|
1020
1020
|
}
|
|
1021
1021
|
parseCellValue(e) {
|
|
1022
1022
|
const t = e.toString();
|
|
1023
|
-
return
|
|
1023
|
+
return fe(t);
|
|
1024
1024
|
}
|
|
1025
1025
|
async parseFormula(e, t, r) {
|
|
1026
1026
|
var l, u;
|
|
1027
|
-
const i = await this.formulaService.getRuleFormulaResult(t, r, e.uid),
|
|
1027
|
+
const i = await this.formulaService.getRuleFormulaResult(t, r, e.uid), s = oe((u = (l = i == null ? void 0 : i[0]) == null ? void 0 : l.result) == null ? void 0 : u[0][0]);
|
|
1028
1028
|
return {
|
|
1029
1029
|
formula1: void 0,
|
|
1030
1030
|
formula2: void 0,
|
|
1031
|
-
isFormulaValid: C(String(
|
|
1031
|
+
isFormulaValid: C(String(s))
|
|
1032
1032
|
};
|
|
1033
1033
|
}
|
|
1034
1034
|
async isValidType(e, t, r) {
|
|
1035
|
-
var m,
|
|
1036
|
-
const { value: i, unitId:
|
|
1037
|
-
return this.parseCellValue(i).every((
|
|
1035
|
+
var m, p;
|
|
1036
|
+
const { value: i, unitId: s, subUnitId: n } = e, { formula1: l = "" } = r, u = await this.formulaService.getRuleFormulaResult(s, n, r.uid), d = S(l) ? He((p = (m = u == null ? void 0 : u[0]) == null ? void 0 : m.result) == null ? void 0 : p[0][0]) : fe(l);
|
|
1037
|
+
return this.parseCellValue(i).every((_) => d.includes(_));
|
|
1038
1038
|
}
|
|
1039
1039
|
generateRuleName() {
|
|
1040
1040
|
return this.localeService.t("dataValidation.list.name");
|
|
@@ -1043,41 +1043,41 @@ class mt extends k {
|
|
|
1043
1043
|
return this.localeService.t("dataValidation.list.error");
|
|
1044
1044
|
}
|
|
1045
1045
|
getList(e, t, r) {
|
|
1046
|
-
var m,
|
|
1047
|
-
const { formula1: i = "" } = e,
|
|
1046
|
+
var m, p, _, v;
|
|
1047
|
+
const { formula1: i = "" } = e, s = this.injector.get(w), n = (m = t ? s.getUniverSheetInstance(t) : void 0) != null ? m : s.getCurrentUnitForType(N.UNIVER_SHEET);
|
|
1048
1048
|
if (!n) return [];
|
|
1049
|
-
const l = (
|
|
1049
|
+
const l = (p = r ? n.getSheetBySheetId(r) : void 0) != null ? p : n.getActiveSheet();
|
|
1050
1050
|
if (!l) return [];
|
|
1051
1051
|
const u = n.getUnitId(), d = l.getSheetId(), c = this.formulaService.getRuleFormulaResultSync(u, d, e.uid);
|
|
1052
|
-
return
|
|
1052
|
+
return S(i) ? He((v = (_ = c == null ? void 0 : c[0]) == null ? void 0 : _.result) == null ? void 0 : v[0][0]) : fe(i);
|
|
1053
1053
|
}
|
|
1054
1054
|
async getListAsync(e, t, r) {
|
|
1055
|
-
var m,
|
|
1056
|
-
const { formula1: i = "" } = e,
|
|
1055
|
+
var m, p, _, v;
|
|
1056
|
+
const { formula1: i = "" } = e, s = this.injector.get(w), n = (m = t ? s.getUniverSheetInstance(t) : void 0) != null ? m : s.getCurrentUnitForType(N.UNIVER_SHEET);
|
|
1057
1057
|
if (!n) return [];
|
|
1058
|
-
const l = (
|
|
1058
|
+
const l = (p = r ? n.getSheetBySheetId(r) : void 0) != null ? p : n.getActiveSheet();
|
|
1059
1059
|
if (!l) return [];
|
|
1060
1060
|
const u = n.getUnitId(), d = l.getSheetId(), c = await this.formulaService.getRuleFormulaResult(u, d, e.uid);
|
|
1061
|
-
return
|
|
1061
|
+
return S(i) ? He((v = (_ = c == null ? void 0 : c[0]) == null ? void 0 : _.result) == null ? void 0 : v[0][0]) : fe(i);
|
|
1062
1062
|
}
|
|
1063
1063
|
getListWithColor(e, t, r) {
|
|
1064
|
-
const i = this.getList(e, t, r),
|
|
1065
|
-
return i.map((n, l) => ({ label: n, color:
|
|
1064
|
+
const i = this.getList(e, t, r), s = (e.formula2 || "").split(",");
|
|
1065
|
+
return i.map((n, l) => ({ label: n, color: s[l] }));
|
|
1066
1066
|
}
|
|
1067
1067
|
getListWithColorMap(e, t, r) {
|
|
1068
|
-
const i = this.getListWithColor(e, t, r),
|
|
1068
|
+
const i = this.getListWithColor(e, t, r), s = {};
|
|
1069
1069
|
return i.forEach((n) => {
|
|
1070
|
-
n.color && (
|
|
1071
|
-
}),
|
|
1070
|
+
n.color && (s[n.label] = n.color);
|
|
1071
|
+
}), s;
|
|
1072
1072
|
}
|
|
1073
1073
|
}
|
|
1074
|
-
class
|
|
1074
|
+
class ca extends G {
|
|
1075
1075
|
constructor() {
|
|
1076
1076
|
super(...arguments);
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1077
|
+
g(this, "id", T.TEXT_LENGTH);
|
|
1078
|
+
g(this, "title", "dataValidation.textLength.title");
|
|
1079
|
+
g(this, "_lexerTreeBuilder", this.injector.get(Y));
|
|
1080
|
+
g(this, "operators", [
|
|
1081
1081
|
h.BETWEEN,
|
|
1082
1082
|
h.EQUAL,
|
|
1083
1083
|
h.GREATER_THAN,
|
|
@@ -1087,11 +1087,11 @@ class _a extends k {
|
|
|
1087
1087
|
h.NOT_BETWEEN,
|
|
1088
1088
|
h.NOT_EQUAL
|
|
1089
1089
|
]);
|
|
1090
|
-
|
|
1091
|
-
|
|
1090
|
+
g(this, "scopes", ["sheet"]);
|
|
1091
|
+
g(this, "_customFormulaService", this.injector.get(H));
|
|
1092
1092
|
}
|
|
1093
1093
|
_isFormulaOrInt(e) {
|
|
1094
|
-
return !V.isBlank(e) && (
|
|
1094
|
+
return !V.isBlank(e) && (S(e) || !Number.isNaN(+e) && Number.isInteger(+e));
|
|
1095
1095
|
}
|
|
1096
1096
|
validatorFormula(e, t, r) {
|
|
1097
1097
|
const i = e.operator;
|
|
@@ -1099,24 +1099,24 @@ class _a extends k {
|
|
|
1099
1099
|
return {
|
|
1100
1100
|
success: !1
|
|
1101
1101
|
};
|
|
1102
|
-
const
|
|
1102
|
+
const s = V.isDefine(e.formula1) && this._isFormulaOrInt(e.formula1), n = V.isDefine(e.formula2) && this._isFormulaOrInt(e.formula2), l = Ae.includes(i), u = this.localeService.t("dataValidation.validFail.number");
|
|
1103
1103
|
return l ? {
|
|
1104
|
-
success:
|
|
1105
|
-
formula1:
|
|
1104
|
+
success: s && n,
|
|
1105
|
+
formula1: s ? void 0 : u,
|
|
1106
1106
|
formula2: n ? void 0 : u
|
|
1107
1107
|
} : {
|
|
1108
|
-
success:
|
|
1108
|
+
success: s,
|
|
1109
1109
|
formula1: u
|
|
1110
1110
|
};
|
|
1111
1111
|
}
|
|
1112
1112
|
_parseNumber(e) {
|
|
1113
1113
|
return e == null ? Number.NaN : +e;
|
|
1114
1114
|
}
|
|
1115
|
-
async parseFormula(e, t, r, i,
|
|
1116
|
-
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i,
|
|
1115
|
+
async parseFormula(e, t, r, i, s) {
|
|
1116
|
+
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i, s), l = await this._customFormulaService.getCellFormula2Value(t, r, e.uid, i, s), { formula1: u, formula2: d } = e, c = C(String(n == null ? void 0 : n.v)) && C(String(l == null ? void 0 : l.v));
|
|
1117
1117
|
return {
|
|
1118
|
-
formula1: this._parseNumber(
|
|
1119
|
-
formula2: this._parseNumber(
|
|
1118
|
+
formula1: this._parseNumber(S(u) ? n == null ? void 0 : n.v : u),
|
|
1119
|
+
formula2: this._parseNumber(S(d) ? l == null ? void 0 : l.v : d),
|
|
1120
1120
|
isFormulaValid: c
|
|
1121
1121
|
};
|
|
1122
1122
|
}
|
|
@@ -1134,109 +1134,109 @@ class _a extends k {
|
|
|
1134
1134
|
if (!e.operator)
|
|
1135
1135
|
return this.titleStr;
|
|
1136
1136
|
const { transformedFormula1: r, transformedFormula2: i } = De(this._lexerTreeBuilder, e, t);
|
|
1137
|
-
return `${this.localeService.t(
|
|
1137
|
+
return `${this.localeService.t(At[e.operator]).replace(le, r != null ? r : "").replace(ue, i != null ? i : "")}`;
|
|
1138
1138
|
}
|
|
1139
1139
|
}
|
|
1140
|
-
function
|
|
1140
|
+
function gt(o) {
|
|
1141
1141
|
var e, t;
|
|
1142
|
-
return
|
|
1142
|
+
return o ? o.p ? !((t = (e = o.p.body) == null ? void 0 : e.dataStream) != null ? t : "").slice(0, -2).trim() : V.isBlank(o.v) : !0;
|
|
1143
1143
|
}
|
|
1144
|
-
function be(
|
|
1145
|
-
const
|
|
1144
|
+
function be(o, a, e, t, r = "command", i = !0) {
|
|
1145
|
+
const s = t.get(Y), n = t.get(q), l = [], u = [], d = t.get(F), c = t.get(w), m = Ye(c, { unitId: o, subUnitId: a });
|
|
1146
1146
|
if (!m)
|
|
1147
1147
|
return {
|
|
1148
1148
|
redoMutations: l,
|
|
1149
1149
|
undoMutations: u
|
|
1150
1150
|
};
|
|
1151
|
-
const { worksheet:
|
|
1152
|
-
let
|
|
1153
|
-
function M(
|
|
1154
|
-
i &&
|
|
1155
|
-
b.foreach(
|
|
1156
|
-
const U =
|
|
1157
|
-
(
|
|
1158
|
-
v:
|
|
1151
|
+
const { worksheet: p } = m, _ = new Se();
|
|
1152
|
+
let v = !1;
|
|
1153
|
+
function M(f, I) {
|
|
1154
|
+
i && f.forEach((P) => {
|
|
1155
|
+
b.foreach(P, (B, $) => {
|
|
1156
|
+
const U = p.getCellRaw(B, $), J = ct(U);
|
|
1157
|
+
(gt(U) || J === I) && !(U != null && U.p) && (v = !0, _.setValue(B, $, {
|
|
1158
|
+
v: I,
|
|
1159
1159
|
p: null
|
|
1160
1160
|
}));
|
|
1161
1161
|
});
|
|
1162
1162
|
});
|
|
1163
1163
|
}
|
|
1164
|
-
if (e.forEach((
|
|
1165
|
-
switch (
|
|
1164
|
+
if (e.forEach((f) => {
|
|
1165
|
+
switch (f.type) {
|
|
1166
1166
|
case "delete":
|
|
1167
1167
|
l.push({
|
|
1168
1168
|
id: A.id,
|
|
1169
1169
|
params: {
|
|
1170
|
-
unitId:
|
|
1170
|
+
unitId: o,
|
|
1171
1171
|
subUnitId: a,
|
|
1172
|
-
ruleId:
|
|
1172
|
+
ruleId: f.rule.uid,
|
|
1173
1173
|
source: r
|
|
1174
1174
|
}
|
|
1175
1175
|
}), u.unshift({
|
|
1176
1176
|
id: L.id,
|
|
1177
1177
|
params: {
|
|
1178
|
-
unitId:
|
|
1178
|
+
unitId: o,
|
|
1179
1179
|
subUnitId: a,
|
|
1180
|
-
rule:
|
|
1181
|
-
index:
|
|
1180
|
+
rule: f.rule,
|
|
1181
|
+
index: f.index,
|
|
1182
1182
|
source: r
|
|
1183
1183
|
}
|
|
1184
1184
|
});
|
|
1185
1185
|
break;
|
|
1186
1186
|
case "update": {
|
|
1187
|
-
if (de(
|
|
1188
|
-
const
|
|
1189
|
-
he !==
|
|
1187
|
+
if (de(f.rule.type, n)) {
|
|
1188
|
+
const P = f.oldRanges[0].startRow, B = f.oldRanges[0].startColumn, $ = f.newRanges[0].startRow, U = f.newRanges[0].startColumn, J = $ - P, ce = U - B, he = S(f.rule.formula1) ? s.moveFormulaRefOffset(f.rule.formula1, ce, J) : f.rule.formula1, me = S(f.rule.formula2) ? s.moveFormulaRefOffset(f.rule.formula2, ce, J) : f.rule.formula2;
|
|
1189
|
+
he !== f.rule.formula1 || me !== f.rule.formula2 || !rt(f.newRanges, f.oldRanges) ? (l.push({
|
|
1190
1190
|
id: E.id,
|
|
1191
1191
|
params: {
|
|
1192
|
-
unitId:
|
|
1192
|
+
unitId: o,
|
|
1193
1193
|
subUnitId: a,
|
|
1194
|
-
ruleId:
|
|
1194
|
+
ruleId: f.ruleId,
|
|
1195
1195
|
payload: {
|
|
1196
1196
|
type: y.ALL,
|
|
1197
1197
|
payload: {
|
|
1198
1198
|
formula1: he,
|
|
1199
1199
|
formula2: me,
|
|
1200
|
-
ranges:
|
|
1200
|
+
ranges: f.newRanges
|
|
1201
1201
|
}
|
|
1202
1202
|
}
|
|
1203
1203
|
}
|
|
1204
1204
|
}), u.unshift({
|
|
1205
1205
|
id: E.id,
|
|
1206
1206
|
params: {
|
|
1207
|
-
unitId:
|
|
1207
|
+
unitId: o,
|
|
1208
1208
|
subUnitId: a,
|
|
1209
|
-
ruleId:
|
|
1209
|
+
ruleId: f.ruleId,
|
|
1210
1210
|
payload: {
|
|
1211
1211
|
type: y.ALL,
|
|
1212
1212
|
payload: {
|
|
1213
|
-
formula1:
|
|
1214
|
-
formula2:
|
|
1215
|
-
ranges:
|
|
1213
|
+
formula1: f.rule.formula1,
|
|
1214
|
+
formula2: f.rule.formula2,
|
|
1215
|
+
ranges: f.oldRanges
|
|
1216
1216
|
}
|
|
1217
1217
|
}
|
|
1218
1218
|
}
|
|
1219
1219
|
})) : (l.push({
|
|
1220
1220
|
id: E.id,
|
|
1221
1221
|
params: {
|
|
1222
|
-
unitId:
|
|
1222
|
+
unitId: o,
|
|
1223
1223
|
subUnitId: a,
|
|
1224
|
-
ruleId:
|
|
1224
|
+
ruleId: f.ruleId,
|
|
1225
1225
|
payload: {
|
|
1226
1226
|
type: y.RANGE,
|
|
1227
|
-
payload:
|
|
1227
|
+
payload: f.newRanges
|
|
1228
1228
|
},
|
|
1229
1229
|
source: r
|
|
1230
1230
|
}
|
|
1231
1231
|
}), u.unshift({
|
|
1232
1232
|
id: E.id,
|
|
1233
1233
|
params: {
|
|
1234
|
-
unitId:
|
|
1234
|
+
unitId: o,
|
|
1235
1235
|
subUnitId: a,
|
|
1236
|
-
ruleId:
|
|
1236
|
+
ruleId: f.ruleId,
|
|
1237
1237
|
payload: {
|
|
1238
1238
|
type: y.RANGE,
|
|
1239
|
-
payload:
|
|
1239
|
+
payload: f.oldRanges
|
|
1240
1240
|
},
|
|
1241
1241
|
source: r
|
|
1242
1242
|
}
|
|
@@ -1245,32 +1245,32 @@ function be(s, a, e, t, r = "command", i = !0) {
|
|
|
1245
1245
|
l.push({
|
|
1246
1246
|
id: E.id,
|
|
1247
1247
|
params: {
|
|
1248
|
-
unitId:
|
|
1248
|
+
unitId: o,
|
|
1249
1249
|
subUnitId: a,
|
|
1250
|
-
ruleId:
|
|
1250
|
+
ruleId: f.ruleId,
|
|
1251
1251
|
payload: {
|
|
1252
1252
|
type: y.RANGE,
|
|
1253
|
-
payload:
|
|
1253
|
+
payload: f.newRanges
|
|
1254
1254
|
},
|
|
1255
1255
|
source: r
|
|
1256
1256
|
}
|
|
1257
1257
|
}), u.unshift({
|
|
1258
1258
|
id: E.id,
|
|
1259
1259
|
params: {
|
|
1260
|
-
unitId:
|
|
1260
|
+
unitId: o,
|
|
1261
1261
|
subUnitId: a,
|
|
1262
|
-
ruleId:
|
|
1262
|
+
ruleId: f.ruleId,
|
|
1263
1263
|
payload: {
|
|
1264
1264
|
type: y.RANGE,
|
|
1265
|
-
payload:
|
|
1265
|
+
payload: f.oldRanges
|
|
1266
1266
|
},
|
|
1267
1267
|
source: r
|
|
1268
1268
|
}
|
|
1269
1269
|
});
|
|
1270
|
-
const
|
|
1271
|
-
if (
|
|
1272
|
-
const B = d.getValidator(T.CHECKBOX).parseFormulaSync(
|
|
1273
|
-
M(
|
|
1270
|
+
const I = d.getRuleById(o, a, f.ruleId);
|
|
1271
|
+
if (I && I.type === T.CHECKBOX) {
|
|
1272
|
+
const B = d.getValidator(T.CHECKBOX).parseFormulaSync(I, o, a);
|
|
1273
|
+
M(f.newRanges, B.formula2);
|
|
1274
1274
|
}
|
|
1275
1275
|
break;
|
|
1276
1276
|
}
|
|
@@ -1278,70 +1278,70 @@ function be(s, a, e, t, r = "command", i = !0) {
|
|
|
1278
1278
|
if (l.push({
|
|
1279
1279
|
id: L.id,
|
|
1280
1280
|
params: {
|
|
1281
|
-
unitId:
|
|
1281
|
+
unitId: o,
|
|
1282
1282
|
subUnitId: a,
|
|
1283
|
-
rule:
|
|
1283
|
+
rule: f.rule,
|
|
1284
1284
|
source: r
|
|
1285
1285
|
}
|
|
1286
1286
|
}), u.unshift({
|
|
1287
1287
|
id: A.id,
|
|
1288
1288
|
params: {
|
|
1289
|
-
unitId:
|
|
1289
|
+
unitId: o,
|
|
1290
1290
|
subUnitId: a,
|
|
1291
|
-
ruleId:
|
|
1291
|
+
ruleId: f.rule.uid,
|
|
1292
1292
|
source: r
|
|
1293
1293
|
}
|
|
1294
|
-
}),
|
|
1295
|
-
const
|
|
1296
|
-
M(
|
|
1294
|
+
}), f.rule.type === T.CHECKBOX) {
|
|
1295
|
+
const P = d.getValidator(T.CHECKBOX).parseFormulaSync(f.rule, o, a);
|
|
1296
|
+
M(f.rule.ranges, P.originFormula2);
|
|
1297
1297
|
}
|
|
1298
1298
|
break;
|
|
1299
1299
|
}
|
|
1300
1300
|
}
|
|
1301
|
-
}),
|
|
1302
|
-
const
|
|
1303
|
-
id:
|
|
1301
|
+
}), v) {
|
|
1302
|
+
const f = {
|
|
1303
|
+
id: se.id,
|
|
1304
1304
|
params: {
|
|
1305
|
-
unitId:
|
|
1305
|
+
unitId: o,
|
|
1306
1306
|
subUnitId: a,
|
|
1307
|
-
cellValue:
|
|
1307
|
+
cellValue: _.getData()
|
|
1308
1308
|
}
|
|
1309
|
-
},
|
|
1310
|
-
id:
|
|
1311
|
-
params:
|
|
1309
|
+
}, I = {
|
|
1310
|
+
id: se.id,
|
|
1311
|
+
params: ot(t, f.params)
|
|
1312
1312
|
};
|
|
1313
|
-
l.push(
|
|
1313
|
+
l.push(f), u.push(I);
|
|
1314
1314
|
}
|
|
1315
1315
|
return {
|
|
1316
1316
|
redoMutations: l,
|
|
1317
1317
|
undoMutations: u
|
|
1318
1318
|
};
|
|
1319
1319
|
}
|
|
1320
|
-
const
|
|
1320
|
+
const ha = {
|
|
1321
1321
|
type: z.COMMAND,
|
|
1322
1322
|
id: "sheet.command.updateDataValidationRuleRange",
|
|
1323
|
-
handler(
|
|
1323
|
+
handler(o, a) {
|
|
1324
1324
|
if (!a)
|
|
1325
1325
|
return !1;
|
|
1326
|
-
const { unitId: e, subUnitId: t, ranges: r, ruleId: i } = a,
|
|
1327
|
-
if (!
|
|
1326
|
+
const { unitId: e, subUnitId: t, ranges: r, ruleId: i } = a, s = o.get(F), n = o.get(x), l = o.get(Z);
|
|
1327
|
+
if (!s.getRuleById(e, t, i))
|
|
1328
1328
|
return !1;
|
|
1329
|
-
const d =
|
|
1329
|
+
const d = s.getRuleObjectMatrix(e, t).clone();
|
|
1330
1330
|
d.updateRange(i, r);
|
|
1331
|
-
const c = d.diff(
|
|
1331
|
+
const c = d.diff(s.getRules(e, t)), { redoMutations: m, undoMutations: p } = be(e, t, c, o);
|
|
1332
1332
|
return l.pushUndoRedo({
|
|
1333
|
-
undoMutations:
|
|
1333
|
+
undoMutations: p,
|
|
1334
1334
|
redoMutations: m,
|
|
1335
1335
|
unitID: e
|
|
1336
|
-
}),
|
|
1336
|
+
}), Oe(m, n), !0;
|
|
1337
1337
|
}
|
|
1338
|
-
},
|
|
1338
|
+
}, ma = {
|
|
1339
1339
|
type: z.COMMAND,
|
|
1340
1340
|
id: "sheet.command.addDataValidation",
|
|
1341
|
-
handler(
|
|
1341
|
+
handler(o, a) {
|
|
1342
1342
|
if (!a)
|
|
1343
1343
|
return !1;
|
|
1344
|
-
const { unitId: e, subUnitId: t, rule: r } = a, i =
|
|
1344
|
+
const { unitId: e, subUnitId: t, rule: r } = a, i = o.get(F), s = o.get(x), n = o.get(Z), l = i.getRuleObjectMatrix(e, t).clone();
|
|
1345
1345
|
l.addRule(r);
|
|
1346
1346
|
const u = l.diff(i.getRules(e, t)), d = i.getValidator(r.type), c = {
|
|
1347
1347
|
unitId: e,
|
|
@@ -1350,11 +1350,11 @@ const pa = {
|
|
|
1350
1350
|
...r,
|
|
1351
1351
|
...d == null ? void 0 : d.normalizeFormula(r, e, t)
|
|
1352
1352
|
}
|
|
1353
|
-
}, { redoMutations: m, undoMutations:
|
|
1353
|
+
}, { redoMutations: m, undoMutations: p } = be(e, t, u, o);
|
|
1354
1354
|
return m.push({
|
|
1355
1355
|
id: L.id,
|
|
1356
1356
|
params: c
|
|
1357
|
-
}),
|
|
1357
|
+
}), p.unshift({
|
|
1358
1358
|
id: A.id,
|
|
1359
1359
|
params: {
|
|
1360
1360
|
unitId: e,
|
|
@@ -1364,101 +1364,101 @@ const pa = {
|
|
|
1364
1364
|
}), n.pushUndoRedo({
|
|
1365
1365
|
unitID: e,
|
|
1366
1366
|
redoMutations: m,
|
|
1367
|
-
undoMutations:
|
|
1368
|
-
}),
|
|
1367
|
+
undoMutations: p
|
|
1368
|
+
}), Oe(m, s), !0;
|
|
1369
1369
|
}
|
|
1370
|
-
},
|
|
1370
|
+
}, ga = {
|
|
1371
1371
|
type: z.COMMAND,
|
|
1372
1372
|
id: "sheets.command.update-data-validation-setting",
|
|
1373
1373
|
// eslint-disable-next-line max-lines-per-function
|
|
1374
|
-
handler(
|
|
1374
|
+
handler(o, a) {
|
|
1375
1375
|
if (!a)
|
|
1376
1376
|
return !1;
|
|
1377
|
-
const e =
|
|
1377
|
+
const e = o.get(x), t = o.get(Z), r = o.get(F), i = o.get(q), { unitId: s, subUnitId: n, ruleId: l, setting: u } = a, d = i.getValidatorItem(u.type);
|
|
1378
1378
|
if (!d)
|
|
1379
1379
|
return !1;
|
|
1380
|
-
const c = r.getRuleById(
|
|
1380
|
+
const c = r.getRuleById(s, n, l);
|
|
1381
1381
|
if (!c)
|
|
1382
1382
|
return !1;
|
|
1383
1383
|
const m = { ...c, ...u };
|
|
1384
|
-
if (!d.validatorFormula(m,
|
|
1384
|
+
if (!d.validatorFormula(m, s, n).success)
|
|
1385
1385
|
return !1;
|
|
1386
|
-
const
|
|
1387
|
-
unitId:
|
|
1386
|
+
const p = {
|
|
1387
|
+
unitId: s,
|
|
1388
1388
|
subUnitId: n,
|
|
1389
1389
|
ruleId: l,
|
|
1390
1390
|
payload: {
|
|
1391
1391
|
type: y.SETTING,
|
|
1392
1392
|
payload: {
|
|
1393
1393
|
...u,
|
|
1394
|
-
...d.normalizeFormula(m,
|
|
1394
|
+
...d.normalizeFormula(m, s, n)
|
|
1395
1395
|
}
|
|
1396
1396
|
}
|
|
1397
|
-
},
|
|
1397
|
+
}, _ = [{
|
|
1398
1398
|
id: E.id,
|
|
1399
|
-
params:
|
|
1400
|
-
}],
|
|
1401
|
-
unitId:
|
|
1399
|
+
params: p
|
|
1400
|
+
}], v = {
|
|
1401
|
+
unitId: s,
|
|
1402
1402
|
subUnitId: n,
|
|
1403
1403
|
ruleId: l,
|
|
1404
1404
|
payload: {
|
|
1405
1405
|
type: y.SETTING,
|
|
1406
|
-
payload:
|
|
1406
|
+
payload: Dt(c)
|
|
1407
1407
|
}
|
|
1408
1408
|
}, M = [{
|
|
1409
1409
|
id: E.id,
|
|
1410
|
-
params:
|
|
1410
|
+
params: v
|
|
1411
1411
|
}];
|
|
1412
1412
|
if (u.type === T.CHECKBOX) {
|
|
1413
|
-
const
|
|
1413
|
+
const I = c.ranges, P = o.get(w), B = Ye(P, { unitId: s, subUnitId: n });
|
|
1414
1414
|
if (B) {
|
|
1415
|
-
const
|
|
1415
|
+
const $ = new Se(), { worksheet: U } = B, { formula2: J = Me, formula1: ce = Ve } = c, { formula2: he = Me, formula1: me = Ve } = u;
|
|
1416
1416
|
let Le = !1;
|
|
1417
|
-
if (
|
|
1418
|
-
b.foreach(
|
|
1419
|
-
const
|
|
1420
|
-
(
|
|
1417
|
+
if (I.forEach((ge) => {
|
|
1418
|
+
b.foreach(ge, (ae, xe) => {
|
|
1419
|
+
const k = U.getCellRaw(ae, xe), Ke = ct(k);
|
|
1420
|
+
(gt(k) || Ke === String(J)) && !(k != null && k.p) ? ($.setValue(ae, xe, {
|
|
1421
1421
|
v: he,
|
|
1422
1422
|
p: null
|
|
1423
|
-
}), Le = !0) : Ke === String(ce) && !(
|
|
1423
|
+
}), Le = !0) : Ke === String(ce) && !(k != null && k.p) && ($.setValue(ae, xe, {
|
|
1424
1424
|
v: me,
|
|
1425
1425
|
p: null
|
|
1426
1426
|
}), Le = !0);
|
|
1427
1427
|
});
|
|
1428
1428
|
}), Le) {
|
|
1429
|
-
const
|
|
1430
|
-
id:
|
|
1429
|
+
const ge = {
|
|
1430
|
+
id: se.id,
|
|
1431
1431
|
params: {
|
|
1432
|
-
unitId:
|
|
1432
|
+
unitId: s,
|
|
1433
1433
|
subUnitId: n,
|
|
1434
|
-
cellValue:
|
|
1434
|
+
cellValue: $.getData()
|
|
1435
1435
|
}
|
|
1436
1436
|
}, ae = {
|
|
1437
|
-
id:
|
|
1438
|
-
params:
|
|
1437
|
+
id: se.id,
|
|
1438
|
+
params: ot(o, ge.params)
|
|
1439
1439
|
};
|
|
1440
|
-
|
|
1440
|
+
_.push(ge), M.push(ae);
|
|
1441
1441
|
}
|
|
1442
1442
|
}
|
|
1443
1443
|
}
|
|
1444
|
-
return
|
|
1445
|
-
unitID:
|
|
1446
|
-
redoMutations:
|
|
1444
|
+
return Oe(_, e).result ? (t.pushUndoRedo({
|
|
1445
|
+
unitID: s,
|
|
1446
|
+
redoMutations: _,
|
|
1447
1447
|
undoMutations: M
|
|
1448
1448
|
}), !0) : !1;
|
|
1449
1449
|
}
|
|
1450
|
-
},
|
|
1450
|
+
}, _a = {
|
|
1451
1451
|
type: z.COMMAND,
|
|
1452
1452
|
id: "sheets.command.update-data-validation-options",
|
|
1453
|
-
handler(
|
|
1453
|
+
handler(o, a) {
|
|
1454
1454
|
if (!a)
|
|
1455
1455
|
return !1;
|
|
1456
|
-
const e =
|
|
1456
|
+
const e = o.get(x), t = o.get(Z), r = o.get(F), { unitId: i, subUnitId: s, ruleId: n, options: l } = a, u = r.getRuleById(i, s, n);
|
|
1457
1457
|
if (!u)
|
|
1458
1458
|
return !1;
|
|
1459
1459
|
const d = {
|
|
1460
1460
|
unitId: i,
|
|
1461
|
-
subUnitId:
|
|
1461
|
+
subUnitId: s,
|
|
1462
1462
|
ruleId: n,
|
|
1463
1463
|
payload: {
|
|
1464
1464
|
type: y.OPTIONS,
|
|
@@ -1469,46 +1469,46 @@ const pa = {
|
|
|
1469
1469
|
params: d
|
|
1470
1470
|
}], m = {
|
|
1471
1471
|
unitId: i,
|
|
1472
|
-
subUnitId:
|
|
1472
|
+
subUnitId: s,
|
|
1473
1473
|
ruleId: n,
|
|
1474
1474
|
payload: {
|
|
1475
1475
|
type: y.OPTIONS,
|
|
1476
|
-
payload:
|
|
1476
|
+
payload: bt(u)
|
|
1477
1477
|
}
|
|
1478
|
-
},
|
|
1478
|
+
}, p = [{
|
|
1479
1479
|
id: E.id,
|
|
1480
1480
|
params: m
|
|
1481
1481
|
}];
|
|
1482
1482
|
return t.pushUndoRedo({
|
|
1483
1483
|
unitID: i,
|
|
1484
1484
|
redoMutations: c,
|
|
1485
|
-
undoMutations:
|
|
1485
|
+
undoMutations: p
|
|
1486
1486
|
}), e.executeCommand(E.id, d), !0;
|
|
1487
1487
|
}
|
|
1488
|
-
},
|
|
1488
|
+
}, pa = {
|
|
1489
1489
|
type: z.COMMAND,
|
|
1490
1490
|
id: "sheets.command.clear-range-data-validation",
|
|
1491
|
-
handler(
|
|
1491
|
+
handler(o, a) {
|
|
1492
1492
|
if (!a)
|
|
1493
1493
|
return !1;
|
|
1494
|
-
const { unitId: e, subUnitId: t, ranges: r } = a, i =
|
|
1494
|
+
const { unitId: e, subUnitId: t, ranges: r } = a, i = o.get(x), s = o.get(w), n = Ye(s, { unitId: e, subUnitId: t }), l = o.get(F);
|
|
1495
1495
|
if (!n) return !1;
|
|
1496
|
-
const u =
|
|
1496
|
+
const u = o.get(Z), d = l.getRuleObjectMatrix(e, t).clone();
|
|
1497
1497
|
d.removeRange(r);
|
|
1498
|
-
const c = d.diff(l.getRules(e, t)), { redoMutations: m, undoMutations:
|
|
1498
|
+
const c = d.diff(l.getRules(e, t)), { redoMutations: m, undoMutations: p } = be(e, t, c, o);
|
|
1499
1499
|
return u.pushUndoRedo({
|
|
1500
1500
|
unitID: e,
|
|
1501
1501
|
redoMutations: m,
|
|
1502
|
-
undoMutations:
|
|
1503
|
-
}),
|
|
1502
|
+
undoMutations: p
|
|
1503
|
+
}), Oe(m, i).result;
|
|
1504
1504
|
}
|
|
1505
|
-
},
|
|
1505
|
+
}, fa = {
|
|
1506
1506
|
type: z.COMMAND,
|
|
1507
1507
|
id: "sheet.command.remove-all-data-validation",
|
|
1508
|
-
handler(
|
|
1508
|
+
handler(o, a) {
|
|
1509
1509
|
if (!a)
|
|
1510
1510
|
return !1;
|
|
1511
|
-
const { unitId: e, subUnitId: t } = a, r =
|
|
1511
|
+
const { unitId: e, subUnitId: t } = a, r = o.get(x), i = o.get(F), s = o.get(Z), n = [...i.getRules(e, t)], l = {
|
|
1512
1512
|
unitId: e,
|
|
1513
1513
|
subUnitId: t,
|
|
1514
1514
|
ruleId: n.map((c) => c.uid)
|
|
@@ -1523,14 +1523,14 @@ const pa = {
|
|
|
1523
1523
|
rule: n
|
|
1524
1524
|
}
|
|
1525
1525
|
}];
|
|
1526
|
-
return
|
|
1526
|
+
return s.pushUndoRedo({
|
|
1527
1527
|
redoMutations: u,
|
|
1528
1528
|
undoMutations: d,
|
|
1529
1529
|
unitID: e
|
|
1530
1530
|
}), r.executeCommand(A.id, l), !0;
|
|
1531
1531
|
}
|
|
1532
|
-
},
|
|
1533
|
-
const e =
|
|
1532
|
+
}, va = (o, a) => {
|
|
1533
|
+
const e = o.get(F), { unitId: t, subUnitId: r, ruleId: i, source: s } = a;
|
|
1534
1534
|
if (Array.isArray(i)) {
|
|
1535
1535
|
const l = i.map((u) => e.getRuleById(t, r, u)).filter(Boolean);
|
|
1536
1536
|
return [{
|
|
@@ -1539,7 +1539,7 @@ const pa = {
|
|
|
1539
1539
|
unitId: t,
|
|
1540
1540
|
subUnitId: r,
|
|
1541
1541
|
rule: l,
|
|
1542
|
-
source:
|
|
1542
|
+
source: s
|
|
1543
1543
|
}
|
|
1544
1544
|
}];
|
|
1545
1545
|
}
|
|
@@ -1554,13 +1554,13 @@ const pa = {
|
|
|
1554
1554
|
index: e.getRuleIndex(t, r, i)
|
|
1555
1555
|
}
|
|
1556
1556
|
}];
|
|
1557
|
-
},
|
|
1557
|
+
}, Ra = {
|
|
1558
1558
|
type: z.COMMAND,
|
|
1559
1559
|
id: "sheet.command.remove-data-validation-rule",
|
|
1560
|
-
handler(
|
|
1560
|
+
handler(o, a) {
|
|
1561
1561
|
if (!a)
|
|
1562
1562
|
return !1;
|
|
1563
|
-
const { unitId: e, subUnitId: t, ruleId: r } = a, i =
|
|
1563
|
+
const { unitId: e, subUnitId: t, ruleId: r } = a, i = o.get(x), s = o.get(Z), n = o.get(F), l = [{
|
|
1564
1564
|
id: A.id,
|
|
1565
1565
|
params: a
|
|
1566
1566
|
}], u = [{
|
|
@@ -1574,23 +1574,23 @@ const pa = {
|
|
|
1574
1574
|
index: n.getRuleIndex(e, t, r)
|
|
1575
1575
|
}
|
|
1576
1576
|
}];
|
|
1577
|
-
return
|
|
1577
|
+
return s.pushUndoRedo({
|
|
1578
1578
|
undoMutations: u,
|
|
1579
1579
|
redoMutations: l,
|
|
1580
1580
|
unitID: a.unitId
|
|
1581
1581
|
}), i.executeCommand(A.id, a), !0;
|
|
1582
1582
|
}
|
|
1583
|
-
},
|
|
1584
|
-
var
|
|
1585
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
1586
|
-
(
|
|
1587
|
-
return
|
|
1588
|
-
},
|
|
1589
|
-
let Ee = class extends
|
|
1583
|
+
}, Sa = "sheets-data-validation.config", tt = {};
|
|
1584
|
+
var Va = Object.getOwnPropertyDescriptor, Ma = (o, a, e, t) => {
|
|
1585
|
+
for (var r = t > 1 ? void 0 : t ? Va(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
1586
|
+
(s = o[i]) && (r = s(r) || r);
|
|
1587
|
+
return r;
|
|
1588
|
+
}, We = (o, a) => (e, t) => a(e, t, o);
|
|
1589
|
+
let Ee = class extends W {
|
|
1590
1590
|
constructor(a, e, t) {
|
|
1591
1591
|
super();
|
|
1592
|
-
|
|
1593
|
-
|
|
1592
|
+
g(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
1593
|
+
g(this, "registerRule", (a, e, t) => {
|
|
1594
1594
|
de(t.type, this._validatorRegistryService) && this.register(a, e, t);
|
|
1595
1595
|
});
|
|
1596
1596
|
this._dataValidationModel = a, this._formulaRefRangeService = e, this._validatorRegistryService = t, this._initRefRange();
|
|
@@ -1600,7 +1600,7 @@ let Ee = class extends $ {
|
|
|
1600
1600
|
}
|
|
1601
1601
|
// eslint-disable-next-line max-lines-per-function
|
|
1602
1602
|
register(a, e, t) {
|
|
1603
|
-
const r = t.ranges, i = t.formula1,
|
|
1603
|
+
const r = t.ranges, i = t.formula1, s = t.formula2, n = this._formulaRefRangeService.registerRangeFormula(a, e, r, [i != null ? i : "", s != null ? s : ""], (u) => {
|
|
1604
1604
|
if (u.length === 0)
|
|
1605
1605
|
return {
|
|
1606
1606
|
undos: [{
|
|
@@ -1650,14 +1650,14 @@ let Ee = class extends $ {
|
|
|
1650
1650
|
payload: {
|
|
1651
1651
|
ranges: r,
|
|
1652
1652
|
formula1: i,
|
|
1653
|
-
formula2:
|
|
1653
|
+
formula2: s
|
|
1654
1654
|
}
|
|
1655
1655
|
},
|
|
1656
1656
|
source: "patched"
|
|
1657
1657
|
}
|
|
1658
1658
|
});
|
|
1659
|
-
for (let
|
|
1660
|
-
const
|
|
1659
|
+
for (let p = 1; p < u.length; p++) {
|
|
1660
|
+
const _ = u[p], v = Mt();
|
|
1661
1661
|
d.push({
|
|
1662
1662
|
id: L.id,
|
|
1663
1663
|
params: {
|
|
@@ -1665,10 +1665,10 @@ let Ee = class extends $ {
|
|
|
1665
1665
|
subUnitId: e,
|
|
1666
1666
|
rule: {
|
|
1667
1667
|
...t,
|
|
1668
|
-
uid:
|
|
1669
|
-
formula1:
|
|
1670
|
-
formula2:
|
|
1671
|
-
ranges:
|
|
1668
|
+
uid: v,
|
|
1669
|
+
formula1: _.formulas[0],
|
|
1670
|
+
formula2: _.formulas[1],
|
|
1671
|
+
ranges: _.ranges
|
|
1672
1672
|
},
|
|
1673
1673
|
source: "patched"
|
|
1674
1674
|
}
|
|
@@ -1677,7 +1677,7 @@ let Ee = class extends $ {
|
|
|
1677
1677
|
params: {
|
|
1678
1678
|
unitId: a,
|
|
1679
1679
|
subUnitId: e,
|
|
1680
|
-
ruleId:
|
|
1680
|
+
ruleId: v,
|
|
1681
1681
|
source: "patched"
|
|
1682
1682
|
}
|
|
1683
1683
|
});
|
|
@@ -1693,99 +1693,99 @@ let Ee = class extends $ {
|
|
|
1693
1693
|
const a = this._dataValidationModel.getAll();
|
|
1694
1694
|
for (const [e, t] of a)
|
|
1695
1695
|
for (const [r, i] of t)
|
|
1696
|
-
for (const
|
|
1697
|
-
this.registerRule(e, r,
|
|
1696
|
+
for (const s of i)
|
|
1697
|
+
this.registerRule(e, r, s);
|
|
1698
1698
|
this.disposeWithMe(
|
|
1699
1699
|
this._dataValidationModel.ruleChange$.subscribe((e) => {
|
|
1700
1700
|
const { unitId: t, subUnitId: r, rule: i } = e;
|
|
1701
1701
|
switch (e.type) {
|
|
1702
1702
|
case "add": {
|
|
1703
|
-
const
|
|
1704
|
-
this.registerRule(e.unitId, e.subUnitId,
|
|
1703
|
+
const s = e.rule;
|
|
1704
|
+
this.registerRule(e.unitId, e.subUnitId, s);
|
|
1705
1705
|
break;
|
|
1706
1706
|
}
|
|
1707
1707
|
case "remove": {
|
|
1708
|
-
const
|
|
1709
|
-
|
|
1708
|
+
const s = this._disposableMap.get(this._getIdWithUnitId(t, r, i.uid));
|
|
1709
|
+
s && s.dispose();
|
|
1710
1710
|
break;
|
|
1711
1711
|
}
|
|
1712
1712
|
case "update": {
|
|
1713
|
-
const
|
|
1714
|
-
n && n.dispose(), this.registerRule(e.unitId, e.subUnitId,
|
|
1713
|
+
const s = e.rule, n = this._disposableMap.get(this._getIdWithUnitId(t, r, s.uid));
|
|
1714
|
+
n && n.dispose(), this.registerRule(e.unitId, e.subUnitId, s);
|
|
1715
1715
|
break;
|
|
1716
1716
|
}
|
|
1717
1717
|
}
|
|
1718
1718
|
})
|
|
1719
|
-
), this.disposeWithMe(
|
|
1719
|
+
), this.disposeWithMe(Qe(() => {
|
|
1720
1720
|
this._disposableMap.forEach((e) => {
|
|
1721
1721
|
e.dispose();
|
|
1722
1722
|
}), this._disposableMap.clear();
|
|
1723
1723
|
}));
|
|
1724
1724
|
}
|
|
1725
1725
|
};
|
|
1726
|
-
Ee =
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1726
|
+
Ee = Ma([
|
|
1727
|
+
We(0, R(F)),
|
|
1728
|
+
We(1, R(ut)),
|
|
1729
|
+
We(2, R(q))
|
|
1730
1730
|
], Ee);
|
|
1731
|
-
var
|
|
1732
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
1733
|
-
(
|
|
1734
|
-
return
|
|
1735
|
-
},
|
|
1736
|
-
let Te = class extends
|
|
1737
|
-
constructor(
|
|
1738
|
-
super(), this._univerInstanceService =
|
|
1739
|
-
}
|
|
1740
|
-
getFormulaRefCheck(
|
|
1731
|
+
var _t = /* @__PURE__ */ ((o) => (o[o.View = 0] = "View", o[o.Edit = 1] = "Edit", o[o.ManageCollaborator = 2] = "ManageCollaborator", o[o.Print = 3] = "Print", o[o.Duplicate = 4] = "Duplicate", o[o.Comment = 5] = "Comment", o[o.Copy = 6] = "Copy", o[o.Share = 7] = "Share", o[o.Export = 8] = "Export", o[o.MoveWorksheet = 9] = "MoveWorksheet", o[o.DeleteWorksheet = 10] = "DeleteWorksheet", o[o.HideWorksheet = 11] = "HideWorksheet", o[o.RenameWorksheet = 12] = "RenameWorksheet", o[o.CreateWorksheet = 13] = "CreateWorksheet", o[o.SetWorksheetStyle = 14] = "SetWorksheetStyle", o[o.EditWorksheetCell = 15] = "EditWorksheetCell", o[o.InsertHyperlink = 16] = "InsertHyperlink", o[o.Sort = 17] = "Sort", o[o.Filter = 18] = "Filter", o[o.PivotTable = 19] = "PivotTable", o[o.FloatImg = 20] = "FloatImg", o[o.History = 21] = "History", o[o.RwHgtClWdt = 22] = "RwHgtClWdt", o[o.ViemRwHgtClWdt = 23] = "ViemRwHgtClWdt", o[o.ViewFilter = 24] = "ViewFilter", o[o.MoveSheet = 25] = "MoveSheet", o[o.DeleteSheet = 26] = "DeleteSheet", o[o.HideSheet = 27] = "HideSheet", o[o.CopySheet = 28] = "CopySheet", o[o.RenameSheet = 29] = "RenameSheet", o[o.CreateSheet = 30] = "CreateSheet", o[o.SelectProtectedCells = 31] = "SelectProtectedCells", o[o.SelectUnProtectedCells = 32] = "SelectUnProtectedCells", o[o.SetCellStyle = 33] = "SetCellStyle", o[o.SetCellValue = 34] = "SetCellValue", o[o.SetRowStyle = 35] = "SetRowStyle", o[o.SetColumnStyle = 36] = "SetColumnStyle", o[o.InsertRow = 37] = "InsertRow", o[o.InsertColumn = 38] = "InsertColumn", o[o.DeleteRow = 39] = "DeleteRow", o[o.DeleteColumn = 40] = "DeleteColumn", o[o.EditExtraObject = 41] = "EditExtraObject", o[o.Delete = 42] = "Delete", o[o.RecoverHistory = 43] = "RecoverHistory", o[o.ViewHistory = 44] = "ViewHistory", o[o.CreatePermissionObject = 45] = "CreatePermissionObject", o[o.UNRECOGNIZED = -1] = "UNRECOGNIZED", o))(_t || {}), ya = Object.getOwnPropertyDescriptor, Ea = (o, a, e, t) => {
|
|
1732
|
+
for (var r = t > 1 ? void 0 : t ? ya(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
1733
|
+
(s = o[i]) && (r = s(r) || r);
|
|
1734
|
+
return r;
|
|
1735
|
+
}, Pe = (o, a) => (e, t) => a(e, t, o);
|
|
1736
|
+
let Te = class extends W {
|
|
1737
|
+
constructor(o, a, e) {
|
|
1738
|
+
super(), this._univerInstanceService = o, this._permissionService = a, this._lexerTreeBuilder = e;
|
|
1739
|
+
}
|
|
1740
|
+
getFormulaRefCheck(o) {
|
|
1741
1741
|
var e, t;
|
|
1742
|
-
const a = this._lexerTreeBuilder.sequenceNodesBuilder(
|
|
1742
|
+
const a = this._lexerTreeBuilder.sequenceNodesBuilder(o);
|
|
1743
1743
|
if (!a)
|
|
1744
1744
|
return !0;
|
|
1745
1745
|
for (let r = 0; r < a.length; r++) {
|
|
1746
1746
|
const i = a[r];
|
|
1747
1747
|
if (typeof i == "string")
|
|
1748
1748
|
continue;
|
|
1749
|
-
const { token:
|
|
1749
|
+
const { token: s } = i, n = Qt(s), l = this._univerInstanceService.getCurrentUnitForType(N.UNIVER_SHEET);
|
|
1750
1750
|
let u = l.getActiveSheet();
|
|
1751
1751
|
const d = l.getUnitId();
|
|
1752
1752
|
if (n.sheetName) {
|
|
1753
1753
|
if (u = l.getSheetBySheetName(n.sheetName), !u)
|
|
1754
1754
|
return !1;
|
|
1755
|
-
const
|
|
1756
|
-
if (!this._permissionService.getPermissionPoint(new
|
|
1755
|
+
const v = u == null ? void 0 : u.getSheetId();
|
|
1756
|
+
if (!this._permissionService.getPermissionPoint(new xt(d, v).id)) return !1;
|
|
1757
1757
|
}
|
|
1758
1758
|
if (!u)
|
|
1759
1759
|
return !1;
|
|
1760
|
-
const { startRow: c, endRow: m, startColumn:
|
|
1761
|
-
for (let
|
|
1762
|
-
for (let M =
|
|
1763
|
-
const
|
|
1764
|
-
if ((
|
|
1760
|
+
const { startRow: c, endRow: m, startColumn: p, endColumn: _ } = n.range;
|
|
1761
|
+
for (let v = c; v <= m; v++)
|
|
1762
|
+
for (let M = p; M <= _; M++) {
|
|
1763
|
+
const f = (t = (e = u.getCell(v, M)) == null ? void 0 : e.selectionProtection) == null ? void 0 : t[0];
|
|
1764
|
+
if ((f == null ? void 0 : f[_t.View]) === !1)
|
|
1765
1765
|
return !1;
|
|
1766
1766
|
}
|
|
1767
1767
|
}
|
|
1768
1768
|
return !0;
|
|
1769
1769
|
}
|
|
1770
1770
|
};
|
|
1771
|
-
Te =
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1771
|
+
Te = Ea([
|
|
1772
|
+
Pe(0, w),
|
|
1773
|
+
Pe(1, yt),
|
|
1774
|
+
Pe(2, R(Y))
|
|
1775
1775
|
], Te);
|
|
1776
|
-
var
|
|
1777
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
1778
|
-
(
|
|
1779
|
-
return
|
|
1780
|
-
}, ee = (
|
|
1781
|
-
let Fe = class extends
|
|
1782
|
-
constructor(a, e, t, r, i,
|
|
1776
|
+
var Ta = Object.getOwnPropertyDescriptor, Fa = (o, a, e, t) => {
|
|
1777
|
+
for (var r = t > 1 ? void 0 : t ? Ta(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
1778
|
+
(s = o[i]) && (r = s(r) || r);
|
|
1779
|
+
return r;
|
|
1780
|
+
}, ee = (o, a) => (e, t) => a(e, t, o);
|
|
1781
|
+
let Fe = class extends W {
|
|
1782
|
+
constructor(a, e, t, r, i, s) {
|
|
1783
1783
|
super();
|
|
1784
|
-
|
|
1785
|
-
|
|
1784
|
+
g(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
1785
|
+
g(this, "registerRule", (a, e, t) => {
|
|
1786
1786
|
de(t.type, this._validatorRegistryService) || (this.register(a, e, t), this.registerFormula(a, e, t));
|
|
1787
1787
|
});
|
|
1788
|
-
this._dataValidationModel = a, this._injector = e, this._refRangeService = t, this._dataValidationFormulaService = r, this._formulaRefRangeService = i, this._validatorRegistryService =
|
|
1788
|
+
this._dataValidationModel = a, this._injector = e, this._refRangeService = t, this._dataValidationFormulaService = r, this._formulaRefRangeService = i, this._validatorRegistryService = s, this._initRefRange();
|
|
1789
1789
|
}
|
|
1790
1790
|
_getIdWithUnitId(a, e, t) {
|
|
1791
1791
|
return `${a}_${e}_${t}`;
|
|
@@ -1793,14 +1793,14 @@ let Fe = class extends $ {
|
|
|
1793
1793
|
// eslint-disable-next-line max-lines-per-function
|
|
1794
1794
|
registerFormula(a, e, t) {
|
|
1795
1795
|
var u;
|
|
1796
|
-
const r = t.uid, i = this._getIdWithUnitId(a, e, r),
|
|
1796
|
+
const r = t.uid, i = this._getIdWithUnitId(a, e, r), s = (u = this._disposableMap.get(i)) != null ? u : /* @__PURE__ */ new Set(), n = (d, c) => {
|
|
1797
1797
|
const m = this._dataValidationModel.getRuleById(a, e, r);
|
|
1798
1798
|
if (!m)
|
|
1799
1799
|
return { redos: [], undos: [] };
|
|
1800
|
-
const
|
|
1801
|
-
if (!
|
|
1800
|
+
const p = m[d];
|
|
1801
|
+
if (!p || p === c)
|
|
1802
1802
|
return { redos: [], undos: [] };
|
|
1803
|
-
const
|
|
1803
|
+
const _ = {
|
|
1804
1804
|
unitId: a,
|
|
1805
1805
|
subUnitId: e,
|
|
1806
1806
|
ruleId: t.uid,
|
|
@@ -1814,7 +1814,7 @@ let Fe = class extends $ {
|
|
|
1814
1814
|
}
|
|
1815
1815
|
},
|
|
1816
1816
|
source: "patched"
|
|
1817
|
-
},
|
|
1817
|
+
}, v = {
|
|
1818
1818
|
unitId: a,
|
|
1819
1819
|
subUnitId: e,
|
|
1820
1820
|
ruleId: t.uid,
|
|
@@ -1830,15 +1830,15 @@ let Fe = class extends $ {
|
|
|
1830
1830
|
}, M = [
|
|
1831
1831
|
{
|
|
1832
1832
|
id: E.id,
|
|
1833
|
-
params:
|
|
1833
|
+
params: _
|
|
1834
1834
|
}
|
|
1835
|
-
],
|
|
1835
|
+
], f = [
|
|
1836
1836
|
{
|
|
1837
1837
|
id: E.id,
|
|
1838
|
-
params:
|
|
1838
|
+
params: v
|
|
1839
1839
|
}
|
|
1840
1840
|
];
|
|
1841
|
-
return { redos: M, undos:
|
|
1841
|
+
return { redos: M, undos: f };
|
|
1842
1842
|
}, l = this._dataValidationFormulaService.getRuleFormulaInfo(a, e, r);
|
|
1843
1843
|
if (l) {
|
|
1844
1844
|
const [d, c] = l;
|
|
@@ -1847,29 +1847,29 @@ let Fe = class extends $ {
|
|
|
1847
1847
|
a,
|
|
1848
1848
|
e,
|
|
1849
1849
|
d.text,
|
|
1850
|
-
(
|
|
1850
|
+
(p) => n("formula1", p)
|
|
1851
1851
|
);
|
|
1852
|
-
|
|
1852
|
+
s.add(() => m.dispose());
|
|
1853
1853
|
}
|
|
1854
1854
|
if (c) {
|
|
1855
1855
|
const m = this._formulaRefRangeService.registerFormula(
|
|
1856
1856
|
a,
|
|
1857
1857
|
e,
|
|
1858
1858
|
c.text,
|
|
1859
|
-
(
|
|
1859
|
+
(p) => n("formula2", p)
|
|
1860
1860
|
);
|
|
1861
|
-
|
|
1861
|
+
s.add(() => m.dispose());
|
|
1862
1862
|
}
|
|
1863
1863
|
}
|
|
1864
1864
|
}
|
|
1865
1865
|
register(a, e, t) {
|
|
1866
1866
|
var l;
|
|
1867
1867
|
const r = (u) => {
|
|
1868
|
-
const d = [...t.ranges], m = d.map((
|
|
1868
|
+
const d = [...t.ranges], m = d.map((_) => Ut(_, u)).filter((_) => !!_).flat();
|
|
1869
1869
|
if (rt(m, d))
|
|
1870
1870
|
return { redos: [], undos: [] };
|
|
1871
1871
|
if (m.length) {
|
|
1872
|
-
const
|
|
1872
|
+
const _ = {
|
|
1873
1873
|
unitId: a,
|
|
1874
1874
|
subUnitId: e,
|
|
1875
1875
|
ruleId: t.uid,
|
|
@@ -1878,7 +1878,7 @@ let Fe = class extends $ {
|
|
|
1878
1878
|
payload: m
|
|
1879
1879
|
},
|
|
1880
1880
|
source: "patched"
|
|
1881
|
-
},
|
|
1881
|
+
}, v = [{ id: E.id, params: _ }], M = [{
|
|
1882
1882
|
id: E.id,
|
|
1883
1883
|
params: {
|
|
1884
1884
|
unitId: a,
|
|
@@ -1891,86 +1891,86 @@ let Fe = class extends $ {
|
|
|
1891
1891
|
source: "patched"
|
|
1892
1892
|
}
|
|
1893
1893
|
}];
|
|
1894
|
-
return { redos:
|
|
1894
|
+
return { redos: v, undos: M };
|
|
1895
1895
|
} else {
|
|
1896
|
-
const
|
|
1897
|
-
return { redos:
|
|
1896
|
+
const _ = { unitId: a, subUnitId: e, ruleId: t.uid }, v = [{ id: A.id, params: _ }], M = va(this._injector, _);
|
|
1897
|
+
return { redos: v, undos: M };
|
|
1898
1898
|
}
|
|
1899
1899
|
}, i = [];
|
|
1900
1900
|
t.ranges.forEach((u) => {
|
|
1901
1901
|
const d = this._refRangeService.registerRefRange(u, r, a, e);
|
|
1902
1902
|
i.push(() => d.dispose());
|
|
1903
1903
|
});
|
|
1904
|
-
const
|
|
1905
|
-
n.add(() => i.forEach((u) => u())), this._disposableMap.set(
|
|
1904
|
+
const s = this._getIdWithUnitId(a, e, t.uid), n = (l = this._disposableMap.get(s)) != null ? l : /* @__PURE__ */ new Set();
|
|
1905
|
+
n.add(() => i.forEach((u) => u())), this._disposableMap.set(s, n);
|
|
1906
1906
|
}
|
|
1907
1907
|
_initRefRange() {
|
|
1908
1908
|
const a = this._dataValidationModel.getAll();
|
|
1909
1909
|
for (const [e, t] of a)
|
|
1910
1910
|
for (const [r, i] of t)
|
|
1911
|
-
for (const
|
|
1912
|
-
this.registerRule(e, r,
|
|
1911
|
+
for (const s of i)
|
|
1912
|
+
this.registerRule(e, r, s);
|
|
1913
1913
|
this.disposeWithMe(
|
|
1914
1914
|
this._dataValidationModel.ruleChange$.subscribe((e) => {
|
|
1915
1915
|
const { unitId: t, subUnitId: r, rule: i } = e;
|
|
1916
1916
|
switch (e.type) {
|
|
1917
1917
|
case "add": {
|
|
1918
|
-
const
|
|
1919
|
-
this.registerRule(e.unitId, e.subUnitId,
|
|
1918
|
+
const s = e.rule;
|
|
1919
|
+
this.registerRule(e.unitId, e.subUnitId, s);
|
|
1920
1920
|
break;
|
|
1921
1921
|
}
|
|
1922
1922
|
case "remove": {
|
|
1923
|
-
const
|
|
1924
|
-
|
|
1923
|
+
const s = this._disposableMap.get(this._getIdWithUnitId(t, r, i.uid));
|
|
1924
|
+
s && s.forEach((n) => n());
|
|
1925
1925
|
break;
|
|
1926
1926
|
}
|
|
1927
1927
|
case "update": {
|
|
1928
|
-
const
|
|
1929
|
-
n && n.forEach((l) => l()), this.registerRule(e.unitId, e.subUnitId,
|
|
1928
|
+
const s = e.rule, n = this._disposableMap.get(this._getIdWithUnitId(t, r, s.uid));
|
|
1929
|
+
n && n.forEach((l) => l()), this.registerRule(e.unitId, e.subUnitId, s);
|
|
1930
1930
|
break;
|
|
1931
1931
|
}
|
|
1932
1932
|
}
|
|
1933
1933
|
})
|
|
1934
|
-
), this.disposeWithMe(
|
|
1934
|
+
), this.disposeWithMe(Qe(() => {
|
|
1935
1935
|
this._disposableMap.forEach((e) => {
|
|
1936
1936
|
e.forEach((t) => t());
|
|
1937
1937
|
}), this._disposableMap.clear();
|
|
1938
1938
|
}));
|
|
1939
1939
|
}
|
|
1940
1940
|
};
|
|
1941
|
-
Fe =
|
|
1942
|
-
ee(0,
|
|
1943
|
-
ee(1,
|
|
1944
|
-
ee(2,
|
|
1945
|
-
ee(3,
|
|
1946
|
-
ee(4,
|
|
1947
|
-
ee(5,
|
|
1941
|
+
Fe = Fa([
|
|
1942
|
+
ee(0, R(F)),
|
|
1943
|
+
ee(1, R(qe)),
|
|
1944
|
+
ee(2, R(Bt)),
|
|
1945
|
+
ee(3, R(K)),
|
|
1946
|
+
ee(4, R(ut)),
|
|
1947
|
+
ee(5, R(q))
|
|
1948
1948
|
], Fe);
|
|
1949
|
-
var
|
|
1950
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
1951
|
-
(
|
|
1952
|
-
return
|
|
1953
|
-
},
|
|
1954
|
-
let Ne = class extends
|
|
1955
|
-
constructor(
|
|
1956
|
-
super(), this._sheetInterceptorService =
|
|
1949
|
+
var Na = Object.getOwnPropertyDescriptor, Ca = (o, a, e, t) => {
|
|
1950
|
+
for (var r = t > 1 ? void 0 : t ? Na(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
1951
|
+
(s = o[i]) && (r = s(r) || r);
|
|
1952
|
+
return r;
|
|
1953
|
+
}, $e = (o, a) => (e, t) => a(e, t, o);
|
|
1954
|
+
let Ne = class extends W {
|
|
1955
|
+
constructor(o, a, e) {
|
|
1956
|
+
super(), this._sheetInterceptorService = o, this._univerInstanceService = a, this._sheetDataValidationModel = e, this._initSheetChange();
|
|
1957
1957
|
}
|
|
1958
1958
|
_initSheetChange() {
|
|
1959
1959
|
this.disposeWithMe(
|
|
1960
1960
|
this._sheetInterceptorService.interceptCommand({
|
|
1961
|
-
getMutations: (
|
|
1961
|
+
getMutations: (o) => {
|
|
1962
1962
|
var a;
|
|
1963
|
-
if (
|
|
1964
|
-
const e =
|
|
1963
|
+
if (o.id === Ht.id) {
|
|
1964
|
+
const e = o.params, t = e.unitId || this._univerInstanceService.getCurrentUnitForType(N.UNIVER_SHEET).getUnitId(), r = this._univerInstanceService.getUniverSheetInstance(t);
|
|
1965
1965
|
if (!r)
|
|
1966
1966
|
return { redos: [], undos: [] };
|
|
1967
1967
|
const i = e.subUnitId || ((a = r.getActiveSheet()) == null ? void 0 : a.getSheetId());
|
|
1968
1968
|
if (!i)
|
|
1969
1969
|
return { redos: [], undos: [] };
|
|
1970
|
-
const
|
|
1971
|
-
if (
|
|
1970
|
+
const s = this._sheetDataValidationModel.getRules(t, i);
|
|
1971
|
+
if (s.length === 0)
|
|
1972
1972
|
return { redos: [], undos: [] };
|
|
1973
|
-
const n =
|
|
1973
|
+
const n = s.map((d) => d.uid), l = {
|
|
1974
1974
|
unitId: t,
|
|
1975
1975
|
subUnitId: i,
|
|
1976
1976
|
ruleId: n,
|
|
@@ -1978,7 +1978,7 @@ let Ne = class extends $ {
|
|
|
1978
1978
|
}, u = {
|
|
1979
1979
|
unitId: t,
|
|
1980
1980
|
subUnitId: i,
|
|
1981
|
-
rule: [...
|
|
1981
|
+
rule: [...s],
|
|
1982
1982
|
source: "patched"
|
|
1983
1983
|
};
|
|
1984
1984
|
return {
|
|
@@ -1998,19 +1998,19 @@ let Ne = class extends $ {
|
|
|
1998
1998
|
);
|
|
1999
1999
|
}
|
|
2000
2000
|
};
|
|
2001
|
-
Ne =
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2001
|
+
Ne = Ca([
|
|
2002
|
+
$e(0, R(st)),
|
|
2003
|
+
$e(1, R(w)),
|
|
2004
|
+
$e(2, R(F))
|
|
2005
2005
|
], Ne);
|
|
2006
|
-
class
|
|
2006
|
+
class wa extends G {
|
|
2007
2007
|
constructor() {
|
|
2008
2008
|
super(...arguments);
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2009
|
+
g(this, "id", T.ANY);
|
|
2010
|
+
g(this, "title", "dataValidation.any.title");
|
|
2011
|
+
g(this, "operators", []);
|
|
2012
|
+
g(this, "scopes", ["sheet"]);
|
|
2013
|
+
g(this, "offsetFormulaByRange", !1);
|
|
2014
2014
|
}
|
|
2015
2015
|
async parseFormula(e, t, r) {
|
|
2016
2016
|
return {
|
|
@@ -2031,19 +2031,19 @@ class Ua extends k {
|
|
|
2031
2031
|
return this.localeService.t("dataValidation.any.error");
|
|
2032
2032
|
}
|
|
2033
2033
|
}
|
|
2034
|
-
class
|
|
2034
|
+
class Ia extends G {
|
|
2035
2035
|
constructor() {
|
|
2036
2036
|
super(...arguments);
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2037
|
+
g(this, "id", T.CUSTOM);
|
|
2038
|
+
g(this, "title", "dataValidation.custom.title");
|
|
2039
|
+
g(this, "operators", []);
|
|
2040
|
+
g(this, "scopes", ["sheet"]);
|
|
2041
|
+
g(this, "_customFormulaService", this.injector.get(H));
|
|
2042
|
+
g(this, "_lexerTreeBuilder", this.injector.get(Y));
|
|
2043
2043
|
}
|
|
2044
2044
|
validatorFormula(e, t, r) {
|
|
2045
2045
|
var u;
|
|
2046
|
-
const i =
|
|
2046
|
+
const i = S(e.formula1), s = (u = e.formula1) != null ? u : "", l = this._lexerTreeBuilder.checkIfAddBracket(s) === 0 && s.startsWith(qt.EQUALS);
|
|
2047
2047
|
return {
|
|
2048
2048
|
success: i && l,
|
|
2049
2049
|
formula1: i && l ? "" : this.localeService.t("dataValidation.validFail.formula")
|
|
@@ -2057,8 +2057,8 @@ class Pa extends k {
|
|
|
2057
2057
|
};
|
|
2058
2058
|
}
|
|
2059
2059
|
async isValidType(e, t, r) {
|
|
2060
|
-
const { column: i, row:
|
|
2061
|
-
return C(String(d)) && V.isDefine(d) && d !== "" ? u.t ===
|
|
2060
|
+
const { column: i, row: s, unitId: n, subUnitId: l } = e, u = await this._customFormulaService.getCellFormulaValue(n, l, r.uid, s, i), d = u == null ? void 0 : u.v;
|
|
2061
|
+
return C(String(d)) && V.isDefine(d) && d !== "" ? u.t === Et.BOOLEAN ? !!d : typeof d == "boolean" ? d : typeof d == "number" ? !!d : typeof d == "string" ? C(d) : !!d : !1;
|
|
2062
2062
|
}
|
|
2063
2063
|
generateRuleErrorMessage(e) {
|
|
2064
2064
|
return this.localeService.t("dataValidation.custom.error");
|
|
@@ -2068,23 +2068,23 @@ class Pa extends k {
|
|
|
2068
2068
|
return this.localeService.t("dataValidation.custom.ruleName").replace("{FORMULA1}", (t = e.formula1) != null ? t : "");
|
|
2069
2069
|
}
|
|
2070
2070
|
}
|
|
2071
|
-
class
|
|
2071
|
+
class Oa extends mt {
|
|
2072
2072
|
constructor() {
|
|
2073
2073
|
super(...arguments);
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2074
|
+
g(this, "id", T.LIST_MULTIPLE);
|
|
2075
|
+
g(this, "title", "dataValidation.listMultiple.title");
|
|
2076
|
+
g(this, "offsetFormulaByRange", !1);
|
|
2077
|
+
g(this, "skipDefaultFontRender", () => !0);
|
|
2078
2078
|
}
|
|
2079
2079
|
}
|
|
2080
|
-
class
|
|
2080
|
+
class Aa extends G {
|
|
2081
2081
|
constructor() {
|
|
2082
2082
|
super(...arguments);
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2083
|
+
g(this, "_customFormulaService", this.injector.get(H));
|
|
2084
|
+
g(this, "_lexerTreeBuilder", this.injector.get(Y));
|
|
2085
|
+
g(this, "id", T.WHOLE);
|
|
2086
|
+
g(this, "title", "dataValidation.whole.title");
|
|
2087
|
+
g(this, "operators", [
|
|
2088
2088
|
h.BETWEEN,
|
|
2089
2089
|
h.EQUAL,
|
|
2090
2090
|
h.GREATER_THAN,
|
|
@@ -2094,14 +2094,14 @@ class Ha extends k {
|
|
|
2094
2094
|
h.NOT_BETWEEN,
|
|
2095
2095
|
h.NOT_EQUAL
|
|
2096
2096
|
]);
|
|
2097
|
-
|
|
2097
|
+
g(this, "scopes", ["sheet"]);
|
|
2098
2098
|
}
|
|
2099
2099
|
_isFormulaOrInt(e) {
|
|
2100
|
-
return !V.isBlank(e) && (
|
|
2100
|
+
return !V.isBlank(e) && (S(e) || !Number.isNaN(+e) && Number.isInteger(+e));
|
|
2101
2101
|
}
|
|
2102
2102
|
async isValidType(e, t, r) {
|
|
2103
|
-
const { value: i } = e,
|
|
2104
|
-
return !Number.isNaN(
|
|
2103
|
+
const { value: i } = e, s = ye(i);
|
|
2104
|
+
return !Number.isNaN(s) && Number.isInteger(s);
|
|
2105
2105
|
}
|
|
2106
2106
|
transform(e, t, r) {
|
|
2107
2107
|
const { value: i } = e;
|
|
@@ -2113,12 +2113,12 @@ class Ha extends k {
|
|
|
2113
2113
|
_parseNumber(e) {
|
|
2114
2114
|
return e == null ? Number.NaN : +e;
|
|
2115
2115
|
}
|
|
2116
|
-
async parseFormula(e, t, r, i,
|
|
2117
|
-
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i,
|
|
2116
|
+
async parseFormula(e, t, r, i, s) {
|
|
2117
|
+
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i, s), l = await this._customFormulaService.getCellFormula2Value(t, r, e.uid, i, s), { formula1: u, formula2: d } = e, c = S(u) ? n == null ? void 0 : n.v : u, m = S(d) ? l == null ? void 0 : l.v : d, p = C(`${c}`) && C(`${m}`);
|
|
2118
2118
|
return {
|
|
2119
2119
|
formula1: this._parseNumber(c),
|
|
2120
2120
|
formula2: this._parseNumber(m),
|
|
2121
|
-
isFormulaValid:
|
|
2121
|
+
isFormulaValid: p
|
|
2122
2122
|
};
|
|
2123
2123
|
}
|
|
2124
2124
|
validatorFormula(e, t, r) {
|
|
@@ -2127,13 +2127,13 @@ class Ha extends k {
|
|
|
2127
2127
|
return {
|
|
2128
2128
|
success: !1
|
|
2129
2129
|
};
|
|
2130
|
-
const
|
|
2130
|
+
const s = V.isDefine(e.formula1) && this._isFormulaOrInt(e.formula1), n = V.isDefine(e.formula2) && this._isFormulaOrInt(e.formula2), l = Ae.includes(i), u = this.localeService.t("dataValidation.validFail.number");
|
|
2131
2131
|
return l ? {
|
|
2132
|
-
success:
|
|
2133
|
-
formula1:
|
|
2132
|
+
success: s && n,
|
|
2133
|
+
formula1: s ? void 0 : u,
|
|
2134
2134
|
formula2: n ? void 0 : u
|
|
2135
2135
|
} : {
|
|
2136
|
-
success:
|
|
2136
|
+
success: s,
|
|
2137
2137
|
formula1: u
|
|
2138
2138
|
};
|
|
2139
2139
|
}
|
|
@@ -2144,44 +2144,44 @@ class Ha extends k {
|
|
|
2144
2144
|
return `${this.localeService.t(ht[e.operator]).replace(le, r != null ? r : "").replace(ue, i != null ? i : "")}`;
|
|
2145
2145
|
}
|
|
2146
2146
|
}
|
|
2147
|
-
var
|
|
2148
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
2149
|
-
(
|
|
2150
|
-
return
|
|
2151
|
-
}, te = (
|
|
2152
|
-
let Ce = class extends
|
|
2153
|
-
constructor(
|
|
2154
|
-
super(), this._univerInstanceService =
|
|
2147
|
+
var Da = Object.getOwnPropertyDescriptor, ba = (o, a, e, t) => {
|
|
2148
|
+
for (var r = t > 1 ? void 0 : t ? Da(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
2149
|
+
(s = o[i]) && (r = s(r) || r);
|
|
2150
|
+
return r;
|
|
2151
|
+
}, te = (o, a) => (e, t) => a(e, t, o);
|
|
2152
|
+
let Ce = class extends Tt {
|
|
2153
|
+
constructor(o, a, e, t, r, i) {
|
|
2154
|
+
super(), this._univerInstanceService = o, this._dataValidatorRegistryService = a, this._injector = e, this._selectionManagerService = t, this._sheetInterceptorService = r, this._sheetDataValidationModel = i, this._init();
|
|
2155
2155
|
}
|
|
2156
2156
|
_init() {
|
|
2157
2157
|
this._registerValidators(), this._initCommandInterceptor();
|
|
2158
2158
|
}
|
|
2159
2159
|
_registerValidators() {
|
|
2160
2160
|
[
|
|
2161
|
-
|
|
2162
|
-
ha,
|
|
2163
|
-
Ha,
|
|
2164
|
-
_a,
|
|
2165
|
-
ca,
|
|
2161
|
+
wa,
|
|
2166
2162
|
na,
|
|
2163
|
+
Aa,
|
|
2164
|
+
ca,
|
|
2165
|
+
sa,
|
|
2166
|
+
aa,
|
|
2167
2167
|
mt,
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
].forEach((
|
|
2171
|
-
const a = this._injector.createInstance(
|
|
2172
|
-
this.disposeWithMe(this._dataValidatorRegistryService.register(a)), this.disposeWithMe(
|
|
2168
|
+
Oa,
|
|
2169
|
+
Ia
|
|
2170
|
+
].forEach((o) => {
|
|
2171
|
+
const a = this._injector.createInstance(o);
|
|
2172
|
+
this.disposeWithMe(this._dataValidatorRegistryService.register(a)), this.disposeWithMe(Qe(() => this._injector.delete(o)));
|
|
2173
2173
|
});
|
|
2174
2174
|
}
|
|
2175
2175
|
_initCommandInterceptor() {
|
|
2176
2176
|
this._sheetInterceptorService.interceptCommand({
|
|
2177
|
-
getMutations: (
|
|
2177
|
+
getMutations: (o) => {
|
|
2178
2178
|
var a;
|
|
2179
|
-
if (
|
|
2179
|
+
if (o.id === Wt.id) {
|
|
2180
2180
|
const e = this._univerInstanceService.getCurrentUnitForType(N.UNIVER_SHEET), t = e.getUnitId(), r = e.getActiveSheet();
|
|
2181
2181
|
if (!r)
|
|
2182
2182
|
throw new Error("No active sheet found");
|
|
2183
|
-
const i = r.getSheetId(),
|
|
2184
|
-
|
|
2183
|
+
const i = r.getSheetId(), s = (a = this._selectionManagerService.getCurrentSelections()) == null ? void 0 : a.map((c) => c.range), n = this._sheetDataValidationModel.getRuleObjectMatrix(t, i).clone();
|
|
2184
|
+
s && n.removeRange(s);
|
|
2185
2185
|
const l = n.diff(this._sheetDataValidationModel.getRules(t, i)), { redoMutations: u, undoMutations: d } = be(t, i, l, this._injector, "patched");
|
|
2186
2186
|
return {
|
|
2187
2187
|
undos: d,
|
|
@@ -2196,158 +2196,158 @@ let Ce = class extends Ft {
|
|
|
2196
2196
|
});
|
|
2197
2197
|
}
|
|
2198
2198
|
};
|
|
2199
|
-
Ce =
|
|
2200
|
-
te(0,
|
|
2201
|
-
te(1,
|
|
2202
|
-
te(2,
|
|
2203
|
-
te(3,
|
|
2204
|
-
te(4,
|
|
2205
|
-
te(5,
|
|
2199
|
+
Ce = ba([
|
|
2200
|
+
te(0, w),
|
|
2201
|
+
te(1, R(q)),
|
|
2202
|
+
te(2, R(qe)),
|
|
2203
|
+
te(3, R(nt)),
|
|
2204
|
+
te(4, R(st)),
|
|
2205
|
+
te(5, R(F))
|
|
2206
2206
|
], Ce);
|
|
2207
|
-
var
|
|
2208
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
2209
|
-
(
|
|
2210
|
-
return
|
|
2211
|
-
},
|
|
2212
|
-
let
|
|
2213
|
-
constructor(
|
|
2214
|
-
super(), this._univerInstanceService =
|
|
2207
|
+
var La = Object.getOwnPropertyDescriptor, xa = (o, a, e, t) => {
|
|
2208
|
+
for (var r = t > 1 ? void 0 : t ? La(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
2209
|
+
(s = o[i]) && (r = s(r) || r);
|
|
2210
|
+
return r;
|
|
2211
|
+
}, ve = (o, a) => (e, t) => a(e, t, o);
|
|
2212
|
+
let we = class extends W {
|
|
2213
|
+
constructor(o, a, e, t) {
|
|
2214
|
+
super(), this._univerInstanceService = o, this._sheetDataValidationModel = a, this._dataValidationCacheService = e, this._lifecycleService = t, this._initRecalculate();
|
|
2215
2215
|
}
|
|
2216
2216
|
_initRecalculate() {
|
|
2217
|
-
const
|
|
2217
|
+
const o = (a) => {
|
|
2218
2218
|
if (a.length === 0)
|
|
2219
2219
|
return;
|
|
2220
2220
|
const e = this._univerInstanceService.getCurrentUnitForType(N.UNIVER_SHEET), t = e == null ? void 0 : e.getActiveSheet(), r = {};
|
|
2221
2221
|
a.flat().forEach((i) => {
|
|
2222
2222
|
r[i.unitId] || (r[i.unitId] = {}), r[i.unitId][i.subUnitId] || (r[i.unitId][i.subUnitId] = []);
|
|
2223
|
-
const
|
|
2223
|
+
const s = this._univerInstanceService.getUnit(i.unitId, N.UNIVER_SHEET), n = s == null ? void 0 : s.getSheetBySheetId(i.subUnitId);
|
|
2224
2224
|
n && r[i.unitId][i.subUnitId].push(...i.ranges.map((l) => b.transformRange(l, n)));
|
|
2225
|
-
}), Object.entries(r).forEach(([i,
|
|
2226
|
-
Object.entries(
|
|
2225
|
+
}), Object.entries(r).forEach(([i, s]) => {
|
|
2226
|
+
Object.entries(s).forEach(([n, l]) => {
|
|
2227
2227
|
(e == null ? void 0 : e.getUnitId()) === i && (t == null ? void 0 : t.getSheetId()) === n ? this.validatorRanges(i, n, l) : requestIdleCallback(() => {
|
|
2228
2228
|
this.validatorRanges(i, n, l);
|
|
2229
2229
|
});
|
|
2230
2230
|
});
|
|
2231
2231
|
});
|
|
2232
2232
|
};
|
|
2233
|
-
this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(
|
|
2233
|
+
this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(Pt(() => this._lifecycleService.lifecycle$.pipe(Ze((a) => a === ze.Rendered)))).subscribe(o)), this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(Ze(() => this._lifecycleService.stage >= ze.Rendered), Nt(20)).subscribe(o));
|
|
2234
2234
|
}
|
|
2235
|
-
async _validatorByCell(
|
|
2236
|
-
const r =
|
|
2235
|
+
async _validatorByCell(o, a, e, t) {
|
|
2236
|
+
const r = o.getUnitId(), i = a.getSheetId();
|
|
2237
2237
|
if (!V.isDefine(e) || !V.isDefine(t))
|
|
2238
2238
|
throw new Error(`row or col is not defined, row: ${e}, col: ${t}`);
|
|
2239
|
-
const
|
|
2240
|
-
return
|
|
2241
|
-
this._sheetDataValidationModel.validator(
|
|
2239
|
+
const s = this._sheetDataValidationModel.getRuleByLocation(r, i, e, t);
|
|
2240
|
+
return s ? new Promise((n) => {
|
|
2241
|
+
this._sheetDataValidationModel.validator(s, { unitId: r, subUnitId: i, row: e, col: t, worksheet: a, workbook: o }, (l) => {
|
|
2242
2242
|
n(l);
|
|
2243
2243
|
});
|
|
2244
2244
|
}) : D.VALID;
|
|
2245
2245
|
}
|
|
2246
|
-
async validatorCell(
|
|
2247
|
-
const r = this._univerInstanceService.getUnit(
|
|
2246
|
+
async validatorCell(o, a, e, t) {
|
|
2247
|
+
const r = this._univerInstanceService.getUnit(o, N.UNIVER_SHEET);
|
|
2248
2248
|
if (!r)
|
|
2249
|
-
throw new Error(`cannot find current workbook, unitId: ${
|
|
2249
|
+
throw new Error(`cannot find current workbook, unitId: ${o}`);
|
|
2250
2250
|
const i = r.getSheetBySheetId(a);
|
|
2251
2251
|
if (!i)
|
|
2252
2252
|
throw new Error(`cannot find current worksheet, sheetId: ${a}`);
|
|
2253
2253
|
return this._validatorByCell(r, i, e, t);
|
|
2254
2254
|
}
|
|
2255
|
-
validatorRanges(
|
|
2255
|
+
validatorRanges(o, a, e) {
|
|
2256
2256
|
if (!e.length)
|
|
2257
2257
|
return Promise.resolve([]);
|
|
2258
|
-
const t = this._univerInstanceService.getUnit(
|
|
2258
|
+
const t = this._univerInstanceService.getUnit(o, N.UNIVER_SHEET);
|
|
2259
2259
|
if (!t)
|
|
2260
|
-
throw new Error(`cannot find current workbook, unitId: ${
|
|
2260
|
+
throw new Error(`cannot find current workbook, unitId: ${o}`);
|
|
2261
2261
|
const r = t.getSheetBySheetId(a);
|
|
2262
2262
|
if (!r)
|
|
2263
2263
|
throw new Error(`cannot find current worksheet, sheetId: ${a}`);
|
|
2264
2264
|
return Promise.all(e.map((i) => {
|
|
2265
|
-
const
|
|
2265
|
+
const s = [];
|
|
2266
2266
|
return b.foreach(i, (n, l) => {
|
|
2267
|
-
|
|
2268
|
-
}), Promise.all(
|
|
2267
|
+
s.push(this._validatorByCell(t, r, n, l));
|
|
2268
|
+
}), Promise.all(s);
|
|
2269
2269
|
}));
|
|
2270
2270
|
}
|
|
2271
|
-
async validatorWorksheet(
|
|
2272
|
-
const e = this._univerInstanceService.getUnit(
|
|
2271
|
+
async validatorWorksheet(o, a) {
|
|
2272
|
+
const e = this._univerInstanceService.getUnit(o, N.UNIVER_SHEET);
|
|
2273
2273
|
if (!e)
|
|
2274
|
-
throw new Error(`cannot find current workbook, unitId: ${
|
|
2274
|
+
throw new Error(`cannot find current workbook, unitId: ${o}`);
|
|
2275
2275
|
const t = e.getSheetBySheetId(a);
|
|
2276
2276
|
if (!t)
|
|
2277
2277
|
throw new Error(`cannot find current worksheet, sheetId: ${a}`);
|
|
2278
|
-
const r = this._sheetDataValidationModel.getRules(
|
|
2279
|
-
return await Promise.all(r.map((i) => Promise.all(i.ranges.map((
|
|
2278
|
+
const r = this._sheetDataValidationModel.getRules(o, a);
|
|
2279
|
+
return await Promise.all(r.map((i) => Promise.all(i.ranges.map((s) => {
|
|
2280
2280
|
const n = [];
|
|
2281
|
-
return b.foreach(
|
|
2281
|
+
return b.foreach(s, (l, u) => {
|
|
2282
2282
|
n.push(this._validatorByCell(e, t, l, u));
|
|
2283
2283
|
}), n;
|
|
2284
|
-
})))), this._dataValidationCacheService.ensureCache(
|
|
2284
|
+
})))), this._dataValidationCacheService.ensureCache(o, a);
|
|
2285
2285
|
}
|
|
2286
|
-
async validatorWorkbook(
|
|
2287
|
-
const a = this._sheetDataValidationModel.getSubUnitIds(
|
|
2286
|
+
async validatorWorkbook(o) {
|
|
2287
|
+
const a = this._sheetDataValidationModel.getSubUnitIds(o), e = await Promise.all(a.map((r) => this.validatorWorksheet(o, r))), t = {};
|
|
2288
2288
|
return e.forEach((r, i) => {
|
|
2289
2289
|
t[a[i]] = r;
|
|
2290
2290
|
}), t;
|
|
2291
2291
|
}
|
|
2292
|
-
getDataValidations(
|
|
2293
|
-
const t = this._sheetDataValidationModel.getRuleObjectMatrix(
|
|
2294
|
-
return e.forEach((
|
|
2295
|
-
b.foreach(
|
|
2292
|
+
getDataValidations(o, a, e) {
|
|
2293
|
+
const t = this._sheetDataValidationModel.getRuleObjectMatrix(o, a), r = /* @__PURE__ */ new Set();
|
|
2294
|
+
return e.forEach((s) => {
|
|
2295
|
+
b.foreach(s, (n, l) => {
|
|
2296
2296
|
const u = t.getValue(n, l);
|
|
2297
2297
|
u && r.add(u);
|
|
2298
2298
|
});
|
|
2299
|
-
}), Array.from(r).map((
|
|
2299
|
+
}), Array.from(r).map((s) => this._sheetDataValidationModel.getRuleById(o, a, s)).filter(Boolean);
|
|
2300
2300
|
}
|
|
2301
|
-
getDataValidation(
|
|
2302
|
-
return this.getDataValidations(
|
|
2301
|
+
getDataValidation(o, a, e) {
|
|
2302
|
+
return this.getDataValidations(o, a, e)[0];
|
|
2303
2303
|
}
|
|
2304
2304
|
};
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
],
|
|
2311
|
-
var
|
|
2312
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
2313
|
-
(
|
|
2314
|
-
return
|
|
2315
|
-
},
|
|
2316
|
-
let
|
|
2317
|
-
constructor(
|
|
2318
|
-
super(), this._config =
|
|
2319
|
-
const { ...r } =
|
|
2305
|
+
we = xa([
|
|
2306
|
+
ve(0, w),
|
|
2307
|
+
ve(1, R(F)),
|
|
2308
|
+
ve(2, R(Q)),
|
|
2309
|
+
ve(3, R(Ft))
|
|
2310
|
+
], we);
|
|
2311
|
+
var Ba = Object.defineProperty, Ua = Object.getOwnPropertyDescriptor, Ha = (o, a, e) => a in o ? Ba(o, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[a] = e, Wa = (o, a, e, t) => {
|
|
2312
|
+
for (var r = t > 1 ? void 0 : t ? Ua(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
2313
|
+
(s = o[i]) && (r = s(r) || r);
|
|
2314
|
+
return r;
|
|
2315
|
+
}, ke = (o, a) => (e, t) => a(e, t, o), pt = (o, a, e) => Ha(o, typeof a != "symbol" ? a + "" : a, e);
|
|
2316
|
+
let Ie = class extends It {
|
|
2317
|
+
constructor(o = tt, a, e, t) {
|
|
2318
|
+
super(), this._config = o, this._injector = a, this._commandService = e, this._configService = t;
|
|
2319
|
+
const { ...r } = Ot(
|
|
2320
2320
|
{},
|
|
2321
2321
|
tt,
|
|
2322
2322
|
this._config
|
|
2323
2323
|
);
|
|
2324
|
-
this._configService.setConfig(
|
|
2324
|
+
this._configService.setConfig(Sa, r);
|
|
2325
2325
|
}
|
|
2326
2326
|
onStarting() {
|
|
2327
2327
|
[
|
|
2328
|
-
[
|
|
2328
|
+
[Q],
|
|
2329
2329
|
[K],
|
|
2330
|
-
[
|
|
2331
|
-
[
|
|
2330
|
+
[H],
|
|
2331
|
+
[we],
|
|
2332
2332
|
[F],
|
|
2333
2333
|
[Ce],
|
|
2334
2334
|
[Te],
|
|
2335
2335
|
[Ne],
|
|
2336
2336
|
[Fe],
|
|
2337
2337
|
[Ee]
|
|
2338
|
-
].forEach((
|
|
2339
|
-
this._injector.add(
|
|
2338
|
+
].forEach((o) => {
|
|
2339
|
+
this._injector.add(o);
|
|
2340
2340
|
}), [
|
|
2341
|
+
ma,
|
|
2342
|
+
ha,
|
|
2343
|
+
ga,
|
|
2344
|
+
_a,
|
|
2341
2345
|
Ra,
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
Va
|
|
2348
|
-
].forEach((s) => {
|
|
2349
|
-
this._commandService.registerCommand(s);
|
|
2350
|
-
}), this._injector.get(q), this._injector.get(Oe), this._injector.get(Ce), this._injector.get(Ee), this._injector.get(Fe);
|
|
2346
|
+
fa,
|
|
2347
|
+
pa
|
|
2348
|
+
].forEach((o) => {
|
|
2349
|
+
this._commandService.registerCommand(o);
|
|
2350
|
+
}), this._injector.get(Q), this._injector.get(we), this._injector.get(Ce), this._injector.get(Ee), this._injector.get(Fe);
|
|
2351
2351
|
}
|
|
2352
2352
|
onReady() {
|
|
2353
2353
|
this._injector.get(Ne);
|
|
@@ -2356,16 +2356,16 @@ let we = class extends wt {
|
|
|
2356
2356
|
this._injector.get(Te);
|
|
2357
2357
|
}
|
|
2358
2358
|
};
|
|
2359
|
-
pt(
|
|
2360
|
-
pt(
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
],
|
|
2367
|
-
function
|
|
2368
|
-
const e =
|
|
2359
|
+
pt(Ie, "pluginName", Gt);
|
|
2360
|
+
pt(Ie, "type", N.UNIVER_SHEET);
|
|
2361
|
+
Ie = Wa([
|
|
2362
|
+
Ct(Lt),
|
|
2363
|
+
ke(1, R(qe)),
|
|
2364
|
+
ke(2, x),
|
|
2365
|
+
ke(3, wt)
|
|
2366
|
+
], Ie);
|
|
2367
|
+
function Ka(o) {
|
|
2368
|
+
const e = o.get(nt).getCurrentSelections().map((i) => i.range);
|
|
2369
2369
|
return {
|
|
2370
2370
|
uid: V.generateRandomId(6),
|
|
2371
2371
|
type: T.DECIMAL,
|
|
@@ -2375,35 +2375,35 @@ function or(s) {
|
|
|
2375
2375
|
};
|
|
2376
2376
|
}
|
|
2377
2377
|
export {
|
|
2378
|
-
|
|
2378
|
+
ma as AddSheetDataValidationCommand,
|
|
2379
2379
|
Ve as CHECKBOX_FORMULA_1,
|
|
2380
2380
|
Me as CHECKBOX_FORMULA_2,
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2381
|
+
aa as CheckboxValidator,
|
|
2382
|
+
pa as ClearRangeDataValidationCommand,
|
|
2383
|
+
Gt as DATA_VALIDATION_PLUGIN_NAME,
|
|
2384
|
+
Q as DataValidationCacheService,
|
|
2385
|
+
H as DataValidationCustomFormulaService,
|
|
2386
2386
|
Te as DataValidationFormulaController,
|
|
2387
2387
|
K as DataValidationFormulaService,
|
|
2388
|
-
|
|
2389
|
-
|
|
2388
|
+
sa as DateValidator,
|
|
2389
|
+
Oa as ListMultipleValidator,
|
|
2390
2390
|
mt as ListValidator,
|
|
2391
|
-
|
|
2392
|
-
|
|
2391
|
+
fa as RemoveSheetAllDataValidationCommand,
|
|
2392
|
+
Ra as RemoveSheetDataValidationCommand,
|
|
2393
2393
|
F as SheetDataValidationModel,
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2394
|
+
we as SheetsDataValidationValidatorService,
|
|
2395
|
+
Ie as UniverSheetsDataValidationPlugin,
|
|
2396
|
+
_a as UpdateSheetDataValidationOptionsCommand,
|
|
2397
|
+
ha as UpdateSheetDataValidationRangeCommand,
|
|
2398
|
+
ga as UpdateSheetDataValidationSettingCommand,
|
|
2399
|
+
Ka as createDefaultNewRule,
|
|
2400
|
+
fe as deserializeListOptions,
|
|
2401
2401
|
ne as getCellValueOrigin,
|
|
2402
|
-
|
|
2402
|
+
Xa as getDataValidationCellValue,
|
|
2403
2403
|
be as getDataValidationDiffMutations,
|
|
2404
|
-
|
|
2405
|
-
|
|
2404
|
+
_e as getFormulaCellData,
|
|
2405
|
+
oe as getFormulaResult,
|
|
2406
2406
|
C as isLegalFormulaResult,
|
|
2407
|
-
|
|
2408
|
-
|
|
2407
|
+
Ya as serializeListOptions,
|
|
2408
|
+
pe as transformCheckboxValue
|
|
2409
2409
|
};
|