@univerjs/sheets-data-validation 0.12.3 → 0.12.4-experimental.20251210-8d33c6e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +990 -842
- package/lib/index.js +990 -842
- package/lib/types/index.d.ts +1 -0
- package/lib/types/services/dv-formula.service.d.ts +3 -1
- package/lib/types/services/dv-list-cache.service.d.ts +53 -0
- package/lib/types/validators/list-validator.d.ts +4 -2
- package/lib/umd/index.js +1 -1
- package/package.json +9 -9
- package/LICENSE +0 -176
package/lib/es/index.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var m = (
|
|
4
|
-
import { Inject as v, ICommandService as U, IUniverInstanceService as
|
|
5
|
-
import { DataValidationModel as
|
|
6
|
-
import { ERROR_TYPE_SET as
|
|
7
|
-
import { SetRangeValuesMutation as
|
|
8
|
-
import { Subject as
|
|
9
|
-
import { RegisterOtherFormulaService as
|
|
10
|
-
var
|
|
11
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
12
|
-
(
|
|
1
|
+
var Et = Object.defineProperty;
|
|
2
|
+
var Mt = (s, a, e) => a in s ? Et(s, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[a] = e;
|
|
3
|
+
var m = (s, a, e) => Mt(s, typeof a != "symbol" ? a + "" : a, e);
|
|
4
|
+
import { Inject as v, ICommandService as U, IUniverInstanceService as D, Disposable as B, ObjectMatrix as Me, getIntersectRange as ot, UniverInstanceType as N, Range as H, Rectangle as O, isFormulaString as S, getOriginCellValue as Vt, Injector as be, numfmt as L, DataValidationType as C, RBush as yt, debounce as Ct, Tools as M, DataValidationStatus as A, WrapStrategy as Se, DataValidationOperator as h, dayjs as nt, DataValidationRenderMode as We, CommandType as z, IUndoRedoService as Z, sequenceExecute as Le, isRangesEqual as lt, IPermissionService as Tt, generateRandomId as Xe, toDisposable as Ke, CellValueType as Ft, RxDisposable as Nt, LifecycleService as wt, LifecycleStages as et, bufferDebounceTime as Ot, DependentOn as At, IConfigService as It, Plugin as Dt, merge as bt } from "@univerjs/core";
|
|
5
|
+
import { DataValidationModel as de, DataValidatorRegistryService as q, UpdateRuleType as V, BaseDataValidator as Y, TextLengthErrorTitleMap as Lt, AddDataValidationMutation as b, RemoveDataValidationMutation as I, UpdateDataValidationMutation as y, getRuleSetting as Ut, getRuleOptions as Bt, UniverDataValidationPlugin as xt } from "@univerjs/data-validation";
|
|
6
|
+
import { ERROR_TYPE_SET as Pt, LexerTreeBuilder as X, isReferenceString as ut, sequenceNodeType as Ht, deserializeRangeWithSheet as Wt, deserializeRangeWithSheetWithCache as $t, operatorToken as kt } from "@univerjs/engine-formula";
|
|
7
|
+
import { SetRangeValuesMutation as ne, RemoveSheetMutation as ct, getSheetCommandTarget as ze, SetRangeValuesUndoMutationFactory as dt, WorksheetViewPermission as jt, RefRangeService as Qt, handleCommonDefaultRangeChangeWithEffectRefCommands as Gt, SheetInterceptorService as ht, RemoveSheetCommand as qt, CopySheetCommand as Yt, SheetsSelectionsService as mt, ClearSelectionAllCommand as Xt } from "@univerjs/sheets";
|
|
8
|
+
import { Subject as Ye, bufferWhen as Kt, filter as tt } from "rxjs";
|
|
9
|
+
import { RegisterOtherFormulaService as gt, FormulaRefRangeService as pt } from "@univerjs/sheets-formula";
|
|
10
|
+
var zt = Object.getOwnPropertyDescriptor, Zt = (s, a, e, t) => {
|
|
11
|
+
for (var r = t > 1 ? void 0 : t ? zt(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
12
|
+
(o = s[i]) && (r = o(r) || r);
|
|
13
13
|
return r;
|
|
14
|
-
},
|
|
15
|
-
let Q = class extends
|
|
14
|
+
}, $e = (s, a) => (e, t) => a(e, t, s);
|
|
15
|
+
let Q = class extends B {
|
|
16
16
|
constructor(a, e, t) {
|
|
17
17
|
super();
|
|
18
18
|
m(this, "_cacheMatrix", /* @__PURE__ */ new Map());
|
|
19
|
-
m(this, "_dirtyRanges$", new
|
|
19
|
+
m(this, "_dirtyRanges$", new Ye());
|
|
20
20
|
m(this, "dirtyRanges$", this._dirtyRanges$.asObservable());
|
|
21
21
|
this._commandService = a, this._univerInstanceService = e, this._sheetDataValidationModel = t, this._initDirtyRanges(), this._initSheetRemove();
|
|
22
22
|
}
|
|
23
23
|
_initDirtyRanges() {
|
|
24
24
|
this.disposeWithMe(this._commandService.onCommandExecuted((a, e) => {
|
|
25
|
-
if (a.id ===
|
|
25
|
+
if (a.id === ne.id && !(e != null && e.onlyLocal)) {
|
|
26
26
|
const { cellValue: t, unitId: r, subUnitId: i } = a.params;
|
|
27
27
|
if (t) {
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
const u = this._sheetDataValidationModel.getRules(r, i).map((
|
|
28
|
+
const o = new Me(t).getDataRange();
|
|
29
|
+
if (o.endRow === -1) return;
|
|
30
|
+
const u = this._sheetDataValidationModel.getRules(r, i).map((c) => c.ranges).flat().map((c) => ot(c, o)).filter(Boolean);
|
|
31
31
|
u.length && this.markRangeDirty(r, i, u, !0);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -36,7 +36,7 @@ let Q = class extends W {
|
|
|
36
36
|
_initSheetRemove() {
|
|
37
37
|
this.disposeWithMe(this._commandService.onCommandExecuted((a) => {
|
|
38
38
|
var e;
|
|
39
|
-
if (a.id ===
|
|
39
|
+
if (a.id === ct.id) {
|
|
40
40
|
const { unitId: t, subUnitId: r } = a.params;
|
|
41
41
|
(e = this._cacheMatrix.get(t)) == null || e.delete(r);
|
|
42
42
|
}
|
|
@@ -48,7 +48,7 @@ let Q = class extends W {
|
|
|
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 Me(), t.set(e, r)), r;
|
|
52
52
|
}
|
|
53
53
|
ensureCache(a, e) {
|
|
54
54
|
return this._ensureCache(a, e);
|
|
@@ -61,8 +61,8 @@ let Q = class extends W {
|
|
|
61
61
|
}
|
|
62
62
|
markRangeDirty(a, e, t, r) {
|
|
63
63
|
const i = this._ensureCache(a, e);
|
|
64
|
-
t.forEach((
|
|
65
|
-
|
|
64
|
+
t.forEach((o) => {
|
|
65
|
+
H.foreach(o, (n, l) => {
|
|
66
66
|
i.getValue(n, l) !== void 0 && i.setValue(n, l, void 0);
|
|
67
67
|
});
|
|
68
68
|
}), this._dirtyRanges$.next({ unitId: a, subUnitId: e, ranges: t, isSetRange: r });
|
|
@@ -70,8 +70,8 @@ let Q = class extends W {
|
|
|
70
70
|
_deleteRange(a, e, t) {
|
|
71
71
|
const r = this._ensureCache(a, e);
|
|
72
72
|
t.forEach((i) => {
|
|
73
|
-
|
|
74
|
-
r.realDeleteValue(
|
|
73
|
+
H.foreach(i, (o, n) => {
|
|
74
|
+
r.realDeleteValue(o, n);
|
|
75
75
|
});
|
|
76
76
|
}), this._dirtyRanges$.next({ unitId: a, subUnitId: e, ranges: t });
|
|
77
77
|
}
|
|
@@ -79,33 +79,33 @@ let Q = class extends W {
|
|
|
79
79
|
return this._ensureCache(a, e).getValue(t, r);
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
-
Q =
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
Q = Zt([
|
|
83
|
+
$e(0, v(U)),
|
|
84
|
+
$e(1, v(D)),
|
|
85
|
+
$e(2, v(de))
|
|
86
86
|
], Q);
|
|
87
|
-
function oe(
|
|
87
|
+
function oe(s) {
|
|
88
88
|
var a, e;
|
|
89
|
-
return (e = (a =
|
|
89
|
+
return (e = (a = s == null ? void 0 : s[0]) == null ? void 0 : a[0]) == null ? void 0 : e.v;
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function _e(s) {
|
|
92
92
|
var a;
|
|
93
|
-
return (a =
|
|
93
|
+
return (a = s == null ? void 0 : s[0]) == null ? void 0 : a[0];
|
|
94
94
|
}
|
|
95
|
-
function
|
|
96
|
-
return !
|
|
95
|
+
function T(s) {
|
|
96
|
+
return !Pt.has(s);
|
|
97
97
|
}
|
|
98
|
-
function
|
|
98
|
+
function he(s, a) {
|
|
99
99
|
var t;
|
|
100
|
-
const e = a.getValidatorItem(
|
|
100
|
+
const e = a.getValidatorItem(s);
|
|
101
101
|
return (t = e == null ? void 0 : e.offsetFormulaByRange) != null ? t : !1;
|
|
102
102
|
}
|
|
103
|
-
var
|
|
104
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
105
|
-
(
|
|
103
|
+
var Jt = Object.getOwnPropertyDescriptor, ea = (s, a, e, t) => {
|
|
104
|
+
for (var r = t > 1 ? void 0 : t ? Jt(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
105
|
+
(o = s[i]) && (r = o(r) || r);
|
|
106
106
|
return r;
|
|
107
|
-
},
|
|
108
|
-
let
|
|
107
|
+
}, se = (s, a) => (e, t) => a(e, t, s);
|
|
108
|
+
let W = class extends B {
|
|
109
109
|
constructor(a, e, t, r, i) {
|
|
110
110
|
super();
|
|
111
111
|
/**
|
|
@@ -124,11 +124,11 @@ let H = class extends W {
|
|
|
124
124
|
const t = a[e];
|
|
125
125
|
if (this._instanceSrv.getUnitType(e) === N.UNIVER_SHEET)
|
|
126
126
|
for (const i in t) {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
var
|
|
130
|
-
const u = n.get((
|
|
131
|
-
|
|
127
|
+
const o = t[i], { ruleFormulaMap: n } = this._ensureMaps(e, i);
|
|
128
|
+
o.forEach((l) => {
|
|
129
|
+
var d, g;
|
|
130
|
+
const u = n.get((d = l.extra) == null ? void 0 : d.ruleId), c = this._dataValidationModel.getRuleById(e, i, (g = l.extra) == null ? void 0 : g.ruleId);
|
|
131
|
+
c && u && this._dataValidationCacheService.markRangeDirty(e, i, c.ranges);
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
134
|
}
|
|
@@ -139,16 +139,16 @@ let H = class extends W {
|
|
|
139
139
|
t || (t = /* @__PURE__ */ new Map(), this._ruleFormulaMap.set(a, t)), r || (r = /* @__PURE__ */ new Map(), this._ruleFormulaMap2.set(a, r));
|
|
140
140
|
let i = t.get(e);
|
|
141
141
|
i || (i = /* @__PURE__ */ new Map(), t.set(e, i));
|
|
142
|
-
let
|
|
143
|
-
return
|
|
142
|
+
let o = r.get(e);
|
|
143
|
+
return o || (o = /* @__PURE__ */ new Map(), r.set(e, o)), { ruleFormulaMap: i, ruleFormulaMap2: o };
|
|
144
144
|
}
|
|
145
145
|
_registerFormula(a, e, t, r, i) {
|
|
146
146
|
return this._registerOtherFormulaService.registerFormulaWithRange(a, e, r, i, { ruleId: t });
|
|
147
147
|
}
|
|
148
148
|
_handleDirtyRanges(a, e, t) {
|
|
149
149
|
this._dataValidationModel.getRules(a, e).forEach((i) => {
|
|
150
|
-
const
|
|
151
|
-
|
|
150
|
+
const o = i.ranges;
|
|
151
|
+
O.doAnyRangesIntersect(o, t) && this.makeRuleDirty(a, e, i.uid);
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
_initDirtyRanges() {
|
|
@@ -157,100 +157,227 @@ let H = class extends W {
|
|
|
157
157
|
}));
|
|
158
158
|
}
|
|
159
159
|
deleteByRuleId(a, e, t) {
|
|
160
|
-
const { ruleFormulaMap: r, ruleFormulaMap2: i } = this._ensureMaps(a, e),
|
|
161
|
-
if (!
|
|
160
|
+
const { ruleFormulaMap: r, ruleFormulaMap2: i } = this._ensureMaps(a, e), o = this._dataValidationModel.getRuleById(a, e, t), n = r.get(t);
|
|
161
|
+
if (!o || !n)
|
|
162
162
|
return;
|
|
163
163
|
const l = r.get(t);
|
|
164
164
|
l && (r.delete(t), this._registerOtherFormulaService.deleteFormula(a, e, [l.formulaId]));
|
|
165
165
|
const u = i.get(t);
|
|
166
166
|
u && (i.delete(t), this._registerOtherFormulaService.deleteFormula(a, e, [u.formulaId]));
|
|
167
167
|
}
|
|
168
|
-
_addFormulaByRange(a, e, t, r, i,
|
|
169
|
-
const { ruleFormulaMap: n, ruleFormulaMap2: l } = this._ensureMaps(a, e), u =
|
|
168
|
+
_addFormulaByRange(a, e, t, r, i, o) {
|
|
169
|
+
const { ruleFormulaMap: n, ruleFormulaMap2: l } = this._ensureMaps(a, e), u = o[0].startRow, c = o[0].startColumn;
|
|
170
170
|
if (r && S(r)) {
|
|
171
|
-
const
|
|
171
|
+
const d = this._registerFormula(a, e, t, r, o);
|
|
172
172
|
n.set(t, {
|
|
173
173
|
formula: r,
|
|
174
|
-
originCol:
|
|
174
|
+
originCol: c,
|
|
175
175
|
originRow: u,
|
|
176
|
-
formulaId:
|
|
176
|
+
formulaId: d
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
179
|
if (i && S(i)) {
|
|
180
|
-
const
|
|
180
|
+
const d = this._registerFormula(a, e, t, i, o);
|
|
181
181
|
l.set(t, {
|
|
182
182
|
formula: i,
|
|
183
|
-
originCol:
|
|
183
|
+
originCol: c,
|
|
184
184
|
originRow: u,
|
|
185
|
-
formulaId:
|
|
185
|
+
formulaId: d
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
addRule(a, e, t) {
|
|
190
|
-
if (
|
|
191
|
-
const { ranges: r, formula1: i, formula2:
|
|
192
|
-
this._addFormulaByRange(a, e, n, i,
|
|
190
|
+
if (he(t.type, this._validatorRegistryService)) {
|
|
191
|
+
const { ranges: r, formula1: i, formula2: o, uid: n } = t;
|
|
192
|
+
this._addFormulaByRange(a, e, n, i, o, r);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
async getCellFormulaValue(a, e, t, r, i) {
|
|
196
196
|
var f, p;
|
|
197
|
-
const { ruleFormulaMap:
|
|
197
|
+
const { ruleFormulaMap: o } = this._ensureMaps(a, e), n = o.get(t);
|
|
198
198
|
if (!n)
|
|
199
199
|
return Promise.resolve(void 0);
|
|
200
|
-
const l = await this._registerOtherFormulaService.getFormulaValue(a, e, n.formulaId), { originRow: u, originCol:
|
|
201
|
-
return
|
|
200
|
+
const l = await this._registerOtherFormulaService.getFormulaValue(a, e, n.formulaId), { originRow: u, originCol: c } = n, d = r - u, g = i - c;
|
|
201
|
+
return _e((p = (f = l == null ? void 0 : l.result) == null ? void 0 : f[d]) == null ? void 0 : p[g]);
|
|
202
202
|
}
|
|
203
203
|
async getCellFormula2Value(a, e, t, r, i) {
|
|
204
204
|
var f, p;
|
|
205
|
-
const { ruleFormulaMap2:
|
|
205
|
+
const { ruleFormulaMap2: o } = this._ensureMaps(a, e), n = o.get(t);
|
|
206
206
|
if (!n)
|
|
207
207
|
return Promise.resolve(void 0);
|
|
208
|
-
const l = await this._registerOtherFormulaService.getFormulaValue(a, e, n.formulaId), { originRow: u, originCol:
|
|
209
|
-
return
|
|
208
|
+
const l = await this._registerOtherFormulaService.getFormulaValue(a, e, n.formulaId), { originRow: u, originCol: c } = n, d = r - u, g = i - c;
|
|
209
|
+
return _e((p = (f = l == null ? void 0 : l.result) == null ? void 0 : f[d]) == null ? void 0 : p[g]);
|
|
210
210
|
}
|
|
211
211
|
getCellFormulaValueSync(a, e, t, r, i) {
|
|
212
212
|
var f, p;
|
|
213
|
-
const { ruleFormulaMap:
|
|
213
|
+
const { ruleFormulaMap: o } = this._ensureMaps(a, e), n = o.get(t);
|
|
214
214
|
if (!n)
|
|
215
215
|
return;
|
|
216
|
-
const l = this._registerOtherFormulaService.getFormulaValueSync(a, e, n.formulaId), { originRow: u, originCol:
|
|
217
|
-
return
|
|
216
|
+
const l = this._registerOtherFormulaService.getFormulaValueSync(a, e, n.formulaId), { originRow: u, originCol: c } = n, d = r - u, g = i - c;
|
|
217
|
+
return _e((p = (f = l == null ? void 0 : l.result) == null ? void 0 : f[d]) == null ? void 0 : p[g]);
|
|
218
218
|
}
|
|
219
219
|
getCellFormula2ValueSync(a, e, t, r, i) {
|
|
220
220
|
var f, p;
|
|
221
|
-
const { ruleFormulaMap2:
|
|
221
|
+
const { ruleFormulaMap2: o } = this._ensureMaps(a, e), n = o.get(t);
|
|
222
222
|
if (!n)
|
|
223
223
|
return;
|
|
224
|
-
const l = this._registerOtherFormulaService.getFormulaValueSync(a, e, n.formulaId), { originRow: u, originCol:
|
|
225
|
-
return
|
|
224
|
+
const l = this._registerOtherFormulaService.getFormulaValueSync(a, e, n.formulaId), { originRow: u, originCol: c } = n, d = r - u, g = i - c;
|
|
225
|
+
return _e((p = (f = l == null ? void 0 : l.result) == null ? void 0 : f[d]) == null ? void 0 : p[g]);
|
|
226
226
|
}
|
|
227
227
|
getRuleFormulaInfo(a, e, t) {
|
|
228
228
|
const { ruleFormulaMap: r } = this._ensureMaps(a, e);
|
|
229
229
|
return r.get(t);
|
|
230
230
|
}
|
|
231
231
|
makeRuleDirty(a, e, t) {
|
|
232
|
-
var
|
|
233
|
-
const r = (n = (
|
|
232
|
+
var o, n, l, u;
|
|
233
|
+
const r = (n = (o = this._ruleFormulaMap.get(a)) == null ? void 0 : o.get(e)) == null ? void 0 : n.get(t), i = (u = (l = this._ruleFormulaMap2.get(a)) == null ? void 0 : l.get(e)) == null ? void 0 : u.get(t);
|
|
234
234
|
r && this._registerOtherFormulaService.markFormulaDirty(a, e, r.formulaId), i && this._registerOtherFormulaService.markFormulaDirty(a, e, i.formulaId);
|
|
235
235
|
}
|
|
236
236
|
};
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
],
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
237
|
+
W = ea([
|
|
238
|
+
se(0, D),
|
|
239
|
+
se(1, v(gt)),
|
|
240
|
+
se(2, v(de)),
|
|
241
|
+
se(3, v(Q)),
|
|
242
|
+
se(4, v(q))
|
|
243
|
+
], W);
|
|
244
|
+
function re(s) {
|
|
245
|
+
return Vt(s);
|
|
246
|
+
}
|
|
247
|
+
function ft(s) {
|
|
248
|
+
var a;
|
|
249
|
+
return String((a = re(s)) != null ? a : "");
|
|
250
|
+
}
|
|
251
|
+
function er(s) {
|
|
252
|
+
return s.filter(Boolean).join(",");
|
|
253
|
+
}
|
|
254
|
+
function Ee(s) {
|
|
255
|
+
return s.split(",").filter(Boolean);
|
|
256
|
+
}
|
|
257
|
+
function tr(s) {
|
|
258
|
+
const a = re(s);
|
|
259
|
+
return a == null ? "" : a.toString();
|
|
260
|
+
}
|
|
261
|
+
function Ue(s, a, e) {
|
|
262
|
+
const { formula1: t, formula2: r } = a, i = a.ranges[0].startRow, o = a.ranges[0].startColumn, n = e.row - i, l = e.col - o, u = S(t) ? s.moveFormulaRefOffset(t, l, n, !0) : t, c = S(r) ? s.moveFormulaRefOffset(r, l, n, !0) : r;
|
|
263
|
+
return {
|
|
264
|
+
transformedFormula1: u,
|
|
265
|
+
transformedFormula2: c
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
var ta = Object.getOwnPropertyDescriptor, aa = (s, a, e, t) => {
|
|
269
|
+
for (var r = t > 1 ? void 0 : t ? ta(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
270
|
+
(o = s[i]) && (r = o(r) || r);
|
|
247
271
|
return r;
|
|
248
|
-
},
|
|
249
|
-
let
|
|
250
|
-
constructor(a, e
|
|
272
|
+
}, at = (s, a) => (e, t) => a(e, t, s);
|
|
273
|
+
let le = class extends B {
|
|
274
|
+
constructor(a, e) {
|
|
275
|
+
super();
|
|
276
|
+
// Cache structure: unitId -> subUnitId -> ruleId -> cache item
|
|
277
|
+
m(this, "_cache", /* @__PURE__ */ new Map());
|
|
278
|
+
this._injector = a, this._dataValidationModel = e, this._initRuleChangeListener();
|
|
279
|
+
}
|
|
280
|
+
_initRuleChangeListener() {
|
|
281
|
+
this.disposeWithMe(
|
|
282
|
+
this._dataValidationModel.ruleChange$.subscribe((a) => {
|
|
283
|
+
(a.type === "remove" || a.type === "update") && this.markRuleDirty(a.unitId, a.subUnitId, a.rule.uid);
|
|
284
|
+
})
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Get cached list data or compute and cache it if not exists.
|
|
289
|
+
*/
|
|
290
|
+
getOrCompute(a, e, t) {
|
|
291
|
+
const r = this.getCache(a, e, t.uid);
|
|
292
|
+
if (r)
|
|
293
|
+
return r;
|
|
294
|
+
const o = this._injector.get(G).getRuleFormulaResultSync(a, e, t.uid);
|
|
295
|
+
return this.computeAndCache(a, e, t, o);
|
|
296
|
+
}
|
|
297
|
+
_ensureCache(a, e) {
|
|
298
|
+
let t = this._cache.get(a);
|
|
299
|
+
t || (t = /* @__PURE__ */ new Map(), this._cache.set(a, t));
|
|
300
|
+
let r = t.get(e);
|
|
301
|
+
return r || (r = /* @__PURE__ */ new Map(), t.set(e, r)), r;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Get cached list data for a rule. Returns undefined if not cached.
|
|
305
|
+
*/
|
|
306
|
+
getCache(a, e, t) {
|
|
307
|
+
var r, i;
|
|
308
|
+
return (i = (r = this._cache.get(a)) == null ? void 0 : r.get(e)) == null ? void 0 : i.get(t);
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Set cache for a rule.
|
|
312
|
+
*/
|
|
313
|
+
setCache(a, e, t, r) {
|
|
314
|
+
this._ensureCache(a, e).set(t, r);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Mark a rule's cache as dirty (invalidate it).
|
|
318
|
+
* Called when formula results change.
|
|
319
|
+
*/
|
|
320
|
+
markRuleDirty(a, e, t) {
|
|
321
|
+
var r, i;
|
|
322
|
+
(i = (r = this._cache.get(a)) == null ? void 0 : r.get(e)) == null || i.delete(t);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Clear all caches.
|
|
326
|
+
*/
|
|
327
|
+
clear() {
|
|
328
|
+
this._cache.clear();
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Compute list data from formula result and cache it.
|
|
332
|
+
*/
|
|
333
|
+
computeAndCache(a, e, t, r) {
|
|
334
|
+
var f, p, R;
|
|
335
|
+
const { formula1: i = "", formula2: o = "" } = t, n = S(i) ? this._getRuleFormulaResultSet((R = (p = (f = r == null ? void 0 : r[0]) == null ? void 0 : f.result) == null ? void 0 : p[0]) == null ? void 0 : R[0]) : Ee(i), l = o.split(","), u = n.map((E, _) => ({ label: E, color: l[_] || "" })), c = {};
|
|
336
|
+
for (const E of u)
|
|
337
|
+
E.color && (c[E.label] = E.color);
|
|
338
|
+
const d = new Set(n), g = { list: n, listWithColor: u, colorMap: c, set: d };
|
|
339
|
+
return this.setCache(a, e, t.uid, g), g;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Extract string list from formula result cells.
|
|
343
|
+
*/
|
|
344
|
+
_getRuleFormulaResultSet(a) {
|
|
345
|
+
var t, r;
|
|
346
|
+
if (!a)
|
|
347
|
+
return [];
|
|
348
|
+
const e = /* @__PURE__ */ new Set();
|
|
349
|
+
for (let i = 0, o = a.length; i < o; i++) {
|
|
350
|
+
const n = a[i];
|
|
351
|
+
if (n)
|
|
352
|
+
for (let l = 0, u = n.length; l < u; l++) {
|
|
353
|
+
const c = n[l], d = re(c);
|
|
354
|
+
if (d != null) {
|
|
355
|
+
if (typeof d != "string" && typeof (c == null ? void 0 : c.s) == "object" && ((r = (t = c.s) == null ? void 0 : t.n) != null && r.pattern)) {
|
|
356
|
+
e.add(L.format(c.s.n.pattern, d, { throws: !1 }));
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
const g = typeof d == "string" ? d : String(d);
|
|
360
|
+
T(g) && e.add(g);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return [...e];
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
le = aa([
|
|
368
|
+
at(0, v(be)),
|
|
369
|
+
at(1, v(de))
|
|
370
|
+
], le);
|
|
371
|
+
var ra = Object.getOwnPropertyDescriptor, ia = (s, a, e, t) => {
|
|
372
|
+
for (var r = t > 1 ? void 0 : t ? ra(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
373
|
+
(o = s[i]) && (r = o(r) || r);
|
|
374
|
+
return r;
|
|
375
|
+
}, ee = (s, a) => (e, t) => a(e, t, s);
|
|
376
|
+
let G = class extends B {
|
|
377
|
+
constructor(a, e, t, r, i, o) {
|
|
251
378
|
super();
|
|
252
379
|
m(this, "_formulaRuleMap", /* @__PURE__ */ new Map());
|
|
253
|
-
this._instanceService = a, this._registerOtherFormulaService = e, this._dataValidationCacheService = t, this._dataValidationModel = r, this._validatorRegistryService = i, this._initFormulaResultHandler();
|
|
380
|
+
this._instanceService = a, this._registerOtherFormulaService = e, this._dataValidationCacheService = t, this._dataValidationModel = r, this._validatorRegistryService = i, this._listCacheService = o, this._initFormulaResultHandler();
|
|
254
381
|
}
|
|
255
382
|
_initFormulaResultHandler() {
|
|
256
383
|
this.disposeWithMe(this._registerOtherFormulaService.formulaResult$.subscribe((a) => {
|
|
@@ -258,12 +385,13 @@ let K = class extends W {
|
|
|
258
385
|
const t = a[e];
|
|
259
386
|
if (this._instanceService.getUnitType(e) === N.UNIVER_SHEET)
|
|
260
387
|
for (const i in t) {
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
var
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
388
|
+
const o = t[i], n = this._ensureRuleFormulaMap(e, i);
|
|
389
|
+
o.forEach((l) => {
|
|
390
|
+
var c;
|
|
391
|
+
const u = (c = l.extra) == null ? void 0 : c.ruleId;
|
|
392
|
+
if (u && n.get(u)) {
|
|
393
|
+
const d = this._dataValidationModel.getRuleById(e, i, u);
|
|
394
|
+
d && (this._listCacheService.markRuleDirty(e, i, u), this._dataValidationCacheService.markRangeDirty(e, i, d.ranges));
|
|
267
395
|
}
|
|
268
396
|
});
|
|
269
397
|
}
|
|
@@ -281,69 +409,63 @@ let K = class extends W {
|
|
|
281
409
|
return this._registerOtherFormulaService.registerFormulaWithRange(a, e, t, i, { ruleId: r });
|
|
282
410
|
}
|
|
283
411
|
addRule(a, e, t) {
|
|
284
|
-
if (!
|
|
285
|
-
const { formula1: r, formula2: i, uid:
|
|
412
|
+
if (!he(t.type, this._validatorRegistryService) && t.type !== C.CHECKBOX) {
|
|
413
|
+
const { formula1: r, formula2: i, uid: o } = t, n = S(r), l = S(i);
|
|
286
414
|
if (!n && !l)
|
|
287
415
|
return;
|
|
288
|
-
const u = this._ensureRuleFormulaMap(a, e),
|
|
416
|
+
const u = this._ensureRuleFormulaMap(a, e), c = [void 0, void 0];
|
|
289
417
|
if (n) {
|
|
290
|
-
const
|
|
291
|
-
|
|
418
|
+
const d = this._registerSingleFormula(a, e, r, o);
|
|
419
|
+
c[0] = { id: d, text: r };
|
|
292
420
|
}
|
|
293
421
|
if (l) {
|
|
294
|
-
const
|
|
295
|
-
|
|
422
|
+
const d = this._registerSingleFormula(a, e, i, o);
|
|
423
|
+
c[1] = { id: d, text: i };
|
|
296
424
|
}
|
|
297
|
-
u.set(
|
|
425
|
+
u.set(o, c);
|
|
298
426
|
}
|
|
299
427
|
}
|
|
300
428
|
removeRule(a, e, t) {
|
|
301
429
|
const i = this._ensureRuleFormulaMap(a, e).get(t);
|
|
302
430
|
if (!i)
|
|
303
431
|
return;
|
|
304
|
-
const [
|
|
432
|
+
const [o, n] = i, l = [o == null ? void 0 : o.id, n == null ? void 0 : n.id].filter(Boolean);
|
|
305
433
|
l.length && this._registerOtherFormulaService.deleteFormula(a, e, l);
|
|
306
434
|
}
|
|
307
435
|
getRuleFormulaResult(a, e, t) {
|
|
308
436
|
const i = this._ensureRuleFormulaMap(a, e).get(t);
|
|
309
437
|
if (!i)
|
|
310
438
|
return Promise.resolve(null);
|
|
311
|
-
const
|
|
439
|
+
const o = async (n) => n && this._registerOtherFormulaService.getFormulaValue(a, e, n.id);
|
|
312
440
|
return Promise.all([
|
|
313
|
-
|
|
314
|
-
|
|
441
|
+
o(i[0]),
|
|
442
|
+
o(i[1])
|
|
315
443
|
]);
|
|
316
444
|
}
|
|
317
445
|
getRuleFormulaResultSync(a, e, t) {
|
|
318
446
|
const i = this._ensureRuleFormulaMap(a, e).get(t);
|
|
319
447
|
if (i)
|
|
320
|
-
return i.map((
|
|
321
|
-
if (
|
|
322
|
-
return this._registerOtherFormulaService.getFormulaValueSync(a, e,
|
|
448
|
+
return i.map((o) => {
|
|
449
|
+
if (o)
|
|
450
|
+
return this._registerOtherFormulaService.getFormulaValueSync(a, e, o.id);
|
|
323
451
|
});
|
|
324
452
|
}
|
|
325
453
|
getRuleFormulaInfo(a, e, t) {
|
|
326
454
|
return this._ensureRuleFormulaMap(a, e).get(t);
|
|
327
455
|
}
|
|
328
456
|
};
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
return Vt(o);
|
|
338
|
-
}
|
|
339
|
-
function pt(o) {
|
|
340
|
-
var a;
|
|
341
|
-
return String((a = ne(o)) != null ? a : "");
|
|
342
|
-
}
|
|
457
|
+
G = ia([
|
|
458
|
+
ee(0, D),
|
|
459
|
+
ee(1, v(gt)),
|
|
460
|
+
ee(2, v(Q)),
|
|
461
|
+
ee(3, v(de)),
|
|
462
|
+
ee(4, v(q)),
|
|
463
|
+
ee(5, v(le))
|
|
464
|
+
], G);
|
|
343
465
|
class Ze {
|
|
344
466
|
constructor(a, e, t, r, i = !1) {
|
|
345
467
|
m(this, "_map");
|
|
346
|
-
m(this, "_tree", new
|
|
468
|
+
m(this, "_tree", new yt());
|
|
347
469
|
m(this, "_dirty", !0);
|
|
348
470
|
m(this, "_buildTree", () => {
|
|
349
471
|
if (!this._dirty || this._disableTree)
|
|
@@ -362,7 +484,7 @@ class Ze {
|
|
|
362
484
|
});
|
|
363
485
|
}), this._tree.load(a), this._dirty = !1;
|
|
364
486
|
});
|
|
365
|
-
m(this, "_debonceBuildTree",
|
|
487
|
+
m(this, "_debonceBuildTree", Ct(this._buildTree, 0));
|
|
366
488
|
this._unitId = e, this._subUnitId = t, this._univerInstanceService = r, this._disableTree = i, this._map = a, this._buildTree();
|
|
367
489
|
}
|
|
368
490
|
get _worksheet() {
|
|
@@ -372,10 +494,10 @@ class Ze {
|
|
|
372
494
|
_addRule(a, e) {
|
|
373
495
|
if (!this._worksheet)
|
|
374
496
|
return;
|
|
375
|
-
const t =
|
|
497
|
+
const t = O.mergeRanges(e.map((r) => H.transformRange(r, this._worksheet)));
|
|
376
498
|
this._map.forEach((r, i) => {
|
|
377
|
-
const
|
|
378
|
-
|
|
499
|
+
const o = O.subtractMulti(r, t);
|
|
500
|
+
o.length === 0 ? this._map.delete(i) : this._map.set(i, o);
|
|
379
501
|
}), this._dirty = !0, this._map.set(a, t), this._debonceBuildTree();
|
|
380
502
|
}
|
|
381
503
|
addRule(a) {
|
|
@@ -384,9 +506,9 @@ class Ze {
|
|
|
384
506
|
removeRange(a) {
|
|
385
507
|
if (!this._worksheet)
|
|
386
508
|
return;
|
|
387
|
-
const e = a.map((t) =>
|
|
509
|
+
const e = a.map((t) => H.transformRange(t, this._worksheet));
|
|
388
510
|
this._map.forEach((t, r) => {
|
|
389
|
-
const i =
|
|
511
|
+
const i = O.subtractMulti(t, e);
|
|
390
512
|
i.length === 0 ? this._map.delete(r) : this._map.set(r, i);
|
|
391
513
|
}), this._dirty = !0, this._debonceBuildTree();
|
|
392
514
|
}
|
|
@@ -404,11 +526,11 @@ class Ze {
|
|
|
404
526
|
if (!t.length)
|
|
405
527
|
return;
|
|
406
528
|
let r = this._map.get(e);
|
|
407
|
-
r ? (this._map.set(e,
|
|
408
|
-
if (
|
|
529
|
+
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, o) => {
|
|
530
|
+
if (o === e)
|
|
409
531
|
return;
|
|
410
|
-
const n =
|
|
411
|
-
n.length === 0 ? this._map.delete(
|
|
532
|
+
const n = O.subtractMulti(i, t);
|
|
533
|
+
n.length === 0 ? this._map.delete(o) : this._map.set(o, n);
|
|
412
534
|
});
|
|
413
535
|
}), this._dirty = !0, this._debonceBuildTree();
|
|
414
536
|
}
|
|
@@ -417,14 +539,14 @@ class Ze {
|
|
|
417
539
|
let t = 0;
|
|
418
540
|
return a.forEach((r, i) => {
|
|
419
541
|
var l;
|
|
420
|
-
const
|
|
421
|
-
|
|
542
|
+
const o = (l = this._map.get(r.uid)) != null ? l : [], n = r.ranges;
|
|
543
|
+
o.length !== 0 && (o.length !== n.length || o.some((u, c) => !O.equals(u, n[c]))) && e.push({
|
|
422
544
|
type: "update",
|
|
423
545
|
ruleId: r.uid,
|
|
424
546
|
oldRanges: n,
|
|
425
|
-
newRanges:
|
|
547
|
+
newRanges: O.sort(o),
|
|
426
548
|
rule: r
|
|
427
|
-
}),
|
|
549
|
+
}), o.length === 0 && (e.push({
|
|
428
550
|
type: "delete",
|
|
429
551
|
rule: r,
|
|
430
552
|
index: i - t
|
|
@@ -434,35 +556,35 @@ class Ze {
|
|
|
434
556
|
diffWithAddition(a, e) {
|
|
435
557
|
const t = [];
|
|
436
558
|
let r = 0;
|
|
437
|
-
return a.forEach((i,
|
|
559
|
+
return a.forEach((i, o) => {
|
|
438
560
|
var u;
|
|
439
561
|
const n = (u = this._map.get(i.uid)) != null ? u : [], l = i.ranges;
|
|
440
|
-
n.length !== 0 && (n.length !== l.length || n.some((
|
|
562
|
+
n.length !== 0 && (n.length !== l.length || n.some((c, d) => !O.equals(c, l[d]))) && t.push({
|
|
441
563
|
type: "update",
|
|
442
564
|
ruleId: i.uid,
|
|
443
565
|
oldRanges: l,
|
|
444
|
-
newRanges:
|
|
566
|
+
newRanges: O.sort(n),
|
|
445
567
|
rule: i
|
|
446
568
|
}), n.length === 0 && (t.push({
|
|
447
569
|
type: "delete",
|
|
448
570
|
rule: i,
|
|
449
|
-
index:
|
|
571
|
+
index: o - r
|
|
450
572
|
}), r++);
|
|
451
573
|
}), Array.from(e).forEach((i) => {
|
|
452
574
|
var n;
|
|
453
|
-
const
|
|
575
|
+
const o = (n = this._map.get(i.uid)) != null ? n : [];
|
|
454
576
|
t.push({
|
|
455
577
|
type: "add",
|
|
456
578
|
rule: {
|
|
457
579
|
...i,
|
|
458
|
-
ranges:
|
|
580
|
+
ranges: O.sort(o)
|
|
459
581
|
}
|
|
460
582
|
});
|
|
461
583
|
}), t;
|
|
462
584
|
}
|
|
463
585
|
clone() {
|
|
464
586
|
return new Ze(
|
|
465
|
-
new Map(
|
|
587
|
+
new Map(M.deepClone(Array.from(this._map.entries()))),
|
|
466
588
|
this._unitId,
|
|
467
589
|
this._subUnitId,
|
|
468
590
|
this._univerInstanceService,
|
|
@@ -481,20 +603,20 @@ class Ze {
|
|
|
481
603
|
return t.length > 0 ? t[0].ruleId : void 0;
|
|
482
604
|
}
|
|
483
605
|
}
|
|
484
|
-
var
|
|
485
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
486
|
-
(
|
|
606
|
+
var sa = Object.getOwnPropertyDescriptor, oa = (s, a, e, t) => {
|
|
607
|
+
for (var r = t > 1 ? void 0 : t ? sa(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
608
|
+
(o = s[i]) && (r = o(r) || r);
|
|
487
609
|
return r;
|
|
488
|
-
},
|
|
489
|
-
let F = class extends
|
|
490
|
-
constructor(a, e, t, r, i,
|
|
610
|
+
}, K = (s, a) => (e, t) => a(e, t, s);
|
|
611
|
+
let F = class extends B {
|
|
612
|
+
constructor(a, e, t, r, i, o, n) {
|
|
491
613
|
super();
|
|
492
614
|
m(this, "_ruleMatrixMap", /* @__PURE__ */ new Map());
|
|
493
|
-
m(this, "_validStatusChange$", new
|
|
494
|
-
m(this, "_ruleChange$", new
|
|
615
|
+
m(this, "_validStatusChange$", new Ye());
|
|
616
|
+
m(this, "_ruleChange$", new Ye());
|
|
495
617
|
m(this, "ruleChange$", this._ruleChange$.asObservable());
|
|
496
618
|
m(this, "validStatusChange$", this._validStatusChange$.asObservable());
|
|
497
|
-
this._dataValidationModel = a, this._univerInstanceService = e, this._dataValidatorRegistryService = t, this._dataValidationCacheService = r, this._dataValidationFormulaService = i, this._dataValidationCustomFormulaService =
|
|
619
|
+
this._dataValidationModel = a, this._univerInstanceService = e, this._dataValidatorRegistryService = t, this._dataValidationCacheService = r, this._dataValidationFormulaService = i, this._dataValidationCustomFormulaService = o, this._commandService = n, this._initRuleUpdateListener(), this.disposeWithMe(() => {
|
|
498
620
|
this._ruleChange$.complete(), this._validStatusChange$.complete();
|
|
499
621
|
}), this._initUniverInstanceListener();
|
|
500
622
|
}
|
|
@@ -505,7 +627,7 @@ let F = class extends W {
|
|
|
505
627
|
})
|
|
506
628
|
), this.disposeWithMe(
|
|
507
629
|
this._commandService.onCommandExecuted((a) => {
|
|
508
|
-
if (a.id ===
|
|
630
|
+
if (a.id === ct.id) {
|
|
509
631
|
const { unitId: e, subUnitId: t } = a.params, r = this._ruleMatrixMap.get(e);
|
|
510
632
|
r && r.delete(t);
|
|
511
633
|
}
|
|
@@ -516,12 +638,12 @@ let F = class extends W {
|
|
|
516
638
|
const a = this._dataValidationModel.getAll();
|
|
517
639
|
for (const [e, t] of a)
|
|
518
640
|
for (const [r, i] of t)
|
|
519
|
-
for (const
|
|
520
|
-
this._addRule(e, r,
|
|
641
|
+
for (const o of i)
|
|
642
|
+
this._addRule(e, r, o), this._ruleChange$.next({
|
|
521
643
|
type: "add",
|
|
522
644
|
unitId: e,
|
|
523
645
|
subUnitId: r,
|
|
524
|
-
rule:
|
|
646
|
+
rule: o,
|
|
525
647
|
source: "patched"
|
|
526
648
|
});
|
|
527
649
|
this.disposeWithMe(
|
|
@@ -556,11 +678,11 @@ let F = class extends W {
|
|
|
556
678
|
});
|
|
557
679
|
}
|
|
558
680
|
_updateRule(a, e, t, r, i) {
|
|
559
|
-
const
|
|
681
|
+
const o = this._ensureRuleMatrix(a, e), n = {
|
|
560
682
|
...r,
|
|
561
683
|
...i.payload
|
|
562
684
|
};
|
|
563
|
-
i.type ===
|
|
685
|
+
i.type === V.RANGE ? o.updateRange(t, i.payload) : i.type === V.ALL && o.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);
|
|
564
686
|
}
|
|
565
687
|
_removeRule(a, e, t) {
|
|
566
688
|
this._ensureRuleMatrix(a, e).removeRule(t), this._dataValidationCacheService.removeRule(a, e, t), this._dataValidationCustomFormulaService.deleteByRuleId(a, e, t.uid);
|
|
@@ -577,37 +699,37 @@ let F = class extends W {
|
|
|
577
699
|
return this._dataValidationModel.getRuleById(a, e, i);
|
|
578
700
|
}
|
|
579
701
|
validator(a, e, t) {
|
|
580
|
-
const { col: r, row: i, unitId:
|
|
702
|
+
const { col: r, row: i, unitId: o, subUnitId: n, worksheet: l } = e, u = (p, R) => {
|
|
581
703
|
t && t(p, R), R && this._validStatusChange$.next({
|
|
582
|
-
unitId:
|
|
704
|
+
unitId: o,
|
|
583
705
|
subUnitId: n,
|
|
584
706
|
ruleId: a.uid,
|
|
585
707
|
status: p,
|
|
586
708
|
row: i,
|
|
587
709
|
col: r
|
|
588
710
|
});
|
|
589
|
-
},
|
|
590
|
-
if (
|
|
591
|
-
const p = this._dataValidationCacheService.ensureCache(
|
|
592
|
-
return R == null ? (p.setValue(i, r,
|
|
711
|
+
}, c = l.getCellValueOnly(i, r), d = this.getValidator(a.type), g = l.getCellRaw(i, r), f = re(g);
|
|
712
|
+
if (d) {
|
|
713
|
+
const p = this._dataValidationCacheService.ensureCache(o, n), R = p.getValue(i, r);
|
|
714
|
+
return R == null ? (p.setValue(i, r, A.VALIDATING), d.validator(
|
|
593
715
|
{
|
|
594
716
|
value: f,
|
|
595
|
-
unitId:
|
|
717
|
+
unitId: o,
|
|
596
718
|
subUnitId: n,
|
|
597
719
|
row: i,
|
|
598
720
|
column: r,
|
|
599
721
|
worksheet: e.worksheet,
|
|
600
722
|
workbook: e.workbook,
|
|
601
|
-
interceptValue:
|
|
723
|
+
interceptValue: re(c),
|
|
602
724
|
t: g == null ? void 0 : g.t
|
|
603
725
|
},
|
|
604
726
|
a
|
|
605
|
-
).then((
|
|
606
|
-
const _ =
|
|
607
|
-
_ ===
|
|
608
|
-
}),
|
|
727
|
+
).then((E) => {
|
|
728
|
+
const _ = E ? A.VALID : A.INVALID, w = p.getValue(i, r);
|
|
729
|
+
_ === A.VALID ? p.realDeleteValue(i, r) : p.setValue(i, r, _), u(_, R !== w);
|
|
730
|
+
}), A.VALIDATING) : (u(R != null ? R : A.VALID, !1), R != null ? R : A.VALID);
|
|
609
731
|
} else
|
|
610
|
-
return u(
|
|
732
|
+
return u(A.VALID, !1), A.VALID;
|
|
611
733
|
}
|
|
612
734
|
getRuleObjectMatrix(a, e) {
|
|
613
735
|
return this._ensureRuleMatrix(a, e);
|
|
@@ -634,38 +756,38 @@ let F = class extends W {
|
|
|
634
756
|
return this._dataValidationModel.getAll();
|
|
635
757
|
}
|
|
636
758
|
};
|
|
637
|
-
F =
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
759
|
+
F = oa([
|
|
760
|
+
K(0, v(de)),
|
|
761
|
+
K(1, D),
|
|
762
|
+
K(2, v(q)),
|
|
763
|
+
K(3, v(Q)),
|
|
764
|
+
K(4, v(G)),
|
|
765
|
+
K(5, v(W)),
|
|
766
|
+
K(6, U)
|
|
645
767
|
], F);
|
|
646
|
-
const
|
|
647
|
-
function
|
|
648
|
-
return
|
|
768
|
+
const Ve = 1, ye = 0;
|
|
769
|
+
function rt(s, a) {
|
|
770
|
+
return M.isBlank(s) ? a.t("dataValidation.validFail.value") : S(s) ? a.t("dataValidation.validFail.primitive") : "";
|
|
649
771
|
}
|
|
650
|
-
const
|
|
651
|
-
class
|
|
772
|
+
const ve = (s) => M.isDefine(s) && String(s).toLowerCase() === "true" ? "1" : String(s).toLowerCase() === "false" ? "0" : s;
|
|
773
|
+
class na extends Y {
|
|
652
774
|
constructor() {
|
|
653
775
|
super(...arguments);
|
|
654
|
-
m(this, "id",
|
|
776
|
+
m(this, "id", C.CHECKBOX);
|
|
655
777
|
m(this, "title", "dataValidation.checkbox.title");
|
|
656
778
|
m(this, "operators", []);
|
|
657
779
|
m(this, "scopes", ["sheet"]);
|
|
658
780
|
m(this, "order", 41);
|
|
659
781
|
m(this, "offsetFormulaByRange", !1);
|
|
660
|
-
m(this, "_formulaService", this.injector.get(
|
|
782
|
+
m(this, "_formulaService", this.injector.get(G));
|
|
661
783
|
m(this, "skipDefaultFontRender", (e, t, r) => {
|
|
662
|
-
const { unitId: i, subUnitId:
|
|
784
|
+
const { unitId: i, subUnitId: o } = r, { formula1: n, formula2: l } = this.parseFormulaSync(e, i, o), u = `${t != null ? t : ""}`;
|
|
663
785
|
return !u || u === `${n}` || u === `${l}`;
|
|
664
786
|
});
|
|
665
787
|
}
|
|
666
788
|
validatorFormula(e, t, r) {
|
|
667
|
-
const { formula1: i, formula2:
|
|
668
|
-
if (
|
|
789
|
+
const { formula1: i, formula2: o } = e, n = i === o;
|
|
790
|
+
if (M.isBlank(i) && M.isBlank(o))
|
|
669
791
|
return {
|
|
670
792
|
success: !0
|
|
671
793
|
};
|
|
@@ -675,7 +797,7 @@ class ia extends G {
|
|
|
675
797
|
formula1: this.localeService.t("dataValidation.validFail.checkboxEqual"),
|
|
676
798
|
formula2: this.localeService.t("dataValidation.validFail.checkboxEqual")
|
|
677
799
|
};
|
|
678
|
-
const l =
|
|
800
|
+
const l = rt(i, this.localeService), u = rt(o, this.localeService);
|
|
679
801
|
return {
|
|
680
802
|
success: !l && !u,
|
|
681
803
|
formula1: l,
|
|
@@ -683,35 +805,35 @@ class ia extends G {
|
|
|
683
805
|
};
|
|
684
806
|
}
|
|
685
807
|
async parseFormula(e, t, r) {
|
|
686
|
-
var
|
|
687
|
-
const { formula1: i =
|
|
808
|
+
var d, g, f, p;
|
|
809
|
+
const { formula1: i = Ve, formula2: o = ye } = e, n = await this._formulaService.getRuleFormulaResult(t, r, e.uid), l = S(i) ? oe((g = (d = n == null ? void 0 : n[0]) == null ? void 0 : d.result) == null ? void 0 : g[0][0]) : i, u = S(o) ? oe((p = (f = n == null ? void 0 : n[1]) == null ? void 0 : f.result) == null ? void 0 : p[0][0]) : o, c = T(String(l)) && T(String(u));
|
|
688
810
|
return {
|
|
689
|
-
formula1:
|
|
690
|
-
formula2:
|
|
811
|
+
formula1: ve(l),
|
|
812
|
+
formula2: ve(u),
|
|
691
813
|
originFormula1: l,
|
|
692
814
|
originFormula2: u,
|
|
693
|
-
isFormulaValid:
|
|
815
|
+
isFormulaValid: c
|
|
694
816
|
};
|
|
695
817
|
}
|
|
696
818
|
getExtraStyle(e, t) {
|
|
697
819
|
return {
|
|
698
|
-
tb:
|
|
820
|
+
tb: Se.CLIP
|
|
699
821
|
};
|
|
700
822
|
}
|
|
701
823
|
parseFormulaSync(e, t, r) {
|
|
702
|
-
var
|
|
703
|
-
const { formula1: i =
|
|
824
|
+
var d, g, f, p;
|
|
825
|
+
const { formula1: i = Ve, formula2: o = ye } = e, n = this._formulaService.getRuleFormulaResultSync(t, r, e.uid), l = S(i) ? oe((g = (d = n == null ? void 0 : n[0]) == null ? void 0 : d.result) == null ? void 0 : g[0][0]) : i, u = S(o) ? oe((p = (f = n == null ? void 0 : n[1]) == null ? void 0 : f.result) == null ? void 0 : p[0][0]) : o, c = T(String(l)) && T(String(u));
|
|
704
826
|
return {
|
|
705
|
-
formula1:
|
|
706
|
-
formula2:
|
|
827
|
+
formula1: ve(l),
|
|
828
|
+
formula2: ve(u),
|
|
707
829
|
originFormula1: l,
|
|
708
830
|
originFormula2: u,
|
|
709
|
-
isFormulaValid:
|
|
831
|
+
isFormulaValid: c
|
|
710
832
|
};
|
|
711
833
|
}
|
|
712
834
|
async isValidType(e, t, r) {
|
|
713
|
-
const { value: i, unitId:
|
|
714
|
-
return !
|
|
835
|
+
const { value: i, unitId: o, subUnitId: n } = e, { formula1: l, formula2: u, originFormula1: c, originFormula2: d } = await this.parseFormula(r, o, n);
|
|
836
|
+
return !M.isDefine(l) || !M.isDefine(u) ? !0 : M.isDefine(i) && (String(i) === String(l) || String(i) === String(u) || String(i) === String(c != null ? c : "") || String(i) === String(d != null ? d : ""));
|
|
715
837
|
}
|
|
716
838
|
generateRuleErrorMessage(e) {
|
|
717
839
|
return this.localeService.t("dataValidation.checkbox.error");
|
|
@@ -720,7 +842,7 @@ class ia extends G {
|
|
|
720
842
|
return this.titleStr;
|
|
721
843
|
}
|
|
722
844
|
}
|
|
723
|
-
const
|
|
845
|
+
const la = {
|
|
724
846
|
[h.BETWEEN]: "dataValidation.date.operators.between",
|
|
725
847
|
[h.EQUAL]: "dataValidation.date.operators.equal",
|
|
726
848
|
[h.GREATER_THAN]: "dataValidation.date.operators.greaterThan",
|
|
@@ -731,7 +853,7 @@ const oa = {
|
|
|
731
853
|
[h.NOT_EQUAL]: "dataValidation.date.operators.notEqual"
|
|
732
854
|
};
|
|
733
855
|
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 + "";
|
|
734
|
-
const
|
|
856
|
+
const it = {
|
|
735
857
|
[h.BETWEEN]: "dataValidation.date.ruleName.between",
|
|
736
858
|
[h.EQUAL]: "dataValidation.date.ruleName.equal",
|
|
737
859
|
[h.GREATER_THAN]: "dataValidation.date.ruleName.greaterThan",
|
|
@@ -741,7 +863,7 @@ const rt = {
|
|
|
741
863
|
[h.NOT_BETWEEN]: "dataValidation.date.ruleName.notBetween",
|
|
742
864
|
[h.NOT_EQUAL]: "dataValidation.date.ruleName.notEqual",
|
|
743
865
|
NONE: "dataValidation.date.ruleName.legal"
|
|
744
|
-
},
|
|
866
|
+
}, ua = {
|
|
745
867
|
[h.BETWEEN]: "dataValidation.date.errorMsg.between",
|
|
746
868
|
[h.EQUAL]: "dataValidation.date.errorMsg.equal",
|
|
747
869
|
[h.GREATER_THAN]: "dataValidation.date.errorMsg.greaterThan",
|
|
@@ -751,40 +873,22 @@ const rt = {
|
|
|
751
873
|
[h.NOT_BETWEEN]: "dataValidation.date.errorMsg.notBetween",
|
|
752
874
|
[h.NOT_EQUAL]: "dataValidation.date.errorMsg.notEqual",
|
|
753
875
|
NONE: "dataValidation.date.errorMsg.legal"
|
|
754
|
-
},
|
|
876
|
+
}, Be = [
|
|
755
877
|
h.BETWEEN,
|
|
756
878
|
h.NOT_BETWEEN
|
|
757
|
-
],
|
|
758
|
-
function Ka(o) {
|
|
759
|
-
return o.filter(Boolean).join(",");
|
|
760
|
-
}
|
|
761
|
-
function _e(o) {
|
|
762
|
-
return o.split(",").filter(Boolean);
|
|
763
|
-
}
|
|
764
|
-
function za(o) {
|
|
765
|
-
const a = ne(o);
|
|
766
|
-
return a == null ? "" : a.toString();
|
|
767
|
-
}
|
|
768
|
-
function Le(o, a, e) {
|
|
769
|
-
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;
|
|
770
|
-
return {
|
|
771
|
-
transformedFormula1: u,
|
|
772
|
-
transformedFormula2: d
|
|
773
|
-
};
|
|
774
|
-
}
|
|
775
|
-
const We = (o) => {
|
|
879
|
+
], ue = "{FORMULA1}", ce = "{FORMULA2}", ke = (s) => {
|
|
776
880
|
var e, t;
|
|
777
|
-
if (
|
|
881
|
+
if (s == null || typeof s == "boolean")
|
|
778
882
|
return;
|
|
779
|
-
if (typeof
|
|
780
|
-
return +
|
|
781
|
-
const a = (e =
|
|
782
|
-
return
|
|
883
|
+
if (typeof s == "number" || !Number.isNaN(+s))
|
|
884
|
+
return +s;
|
|
885
|
+
const a = (e = L.parseDate(s)) == null ? void 0 : e.v;
|
|
886
|
+
return M.isDefine(a) ? a : (t = L.parseDate(nt(s).format("YYYY-MM-DD HH:mm:ss"))) == null ? void 0 : t.v;
|
|
783
887
|
};
|
|
784
|
-
class
|
|
888
|
+
class ca extends Y {
|
|
785
889
|
constructor() {
|
|
786
890
|
super(...arguments);
|
|
787
|
-
m(this, "id",
|
|
891
|
+
m(this, "id", C.DATE);
|
|
788
892
|
m(this, "title", "dataValidation.date.title");
|
|
789
893
|
m(this, "order", 40);
|
|
790
894
|
m(this, "operators", [
|
|
@@ -798,23 +902,23 @@ class na extends G {
|
|
|
798
902
|
h.NOT_EQUAL
|
|
799
903
|
]);
|
|
800
904
|
m(this, "scopes", ["sheet"]);
|
|
801
|
-
m(this, "_customFormulaService", this.injector.get(
|
|
802
|
-
m(this, "_lexerTreeBuilder", this.injector.get(
|
|
905
|
+
m(this, "_customFormulaService", this.injector.get(W));
|
|
906
|
+
m(this, "_lexerTreeBuilder", this.injector.get(X));
|
|
803
907
|
}
|
|
804
|
-
async parseFormula(e, t, r, i,
|
|
805
|
-
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i,
|
|
908
|
+
async parseFormula(e, t, r, i, o) {
|
|
909
|
+
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i, o), l = await this._customFormulaService.getCellFormula2Value(t, r, e.uid, i, o), { formula1: u, formula2: c } = e, d = T(String(n == null ? void 0 : n.v)) && T(String(l == null ? void 0 : l.v));
|
|
806
910
|
return {
|
|
807
|
-
formula1:
|
|
808
|
-
formula2:
|
|
809
|
-
isFormulaValid:
|
|
911
|
+
formula1: ke(S(u) ? n == null ? void 0 : n.v : u),
|
|
912
|
+
formula2: ke(S(c) ? l == null ? void 0 : l.v : c),
|
|
913
|
+
isFormulaValid: d
|
|
810
914
|
};
|
|
811
915
|
}
|
|
812
916
|
async isValidType(e) {
|
|
813
917
|
const { interceptValue: t, value: r } = e;
|
|
814
|
-
return typeof r == "number" && typeof t == "string" ? !!
|
|
918
|
+
return typeof r == "number" && typeof t == "string" ? !!L.parseDate(t) : typeof t == "string" ? !!L.parseDate(t) : !1;
|
|
815
919
|
}
|
|
816
920
|
_validatorSingleFormula(e) {
|
|
817
|
-
return !
|
|
921
|
+
return !M.isBlank(e) && (S(e) || !Number.isNaN(+e) || !!(e && L.parseDate(e)));
|
|
818
922
|
}
|
|
819
923
|
validatorFormula(e, t, r) {
|
|
820
924
|
const i = e.operator;
|
|
@@ -822,68 +926,68 @@ class na extends G {
|
|
|
822
926
|
return {
|
|
823
927
|
success: !0
|
|
824
928
|
};
|
|
825
|
-
const
|
|
826
|
-
if (
|
|
929
|
+
const o = this._validatorSingleFormula(e.formula1), n = this.localeService.t("dataValidation.validFail.date");
|
|
930
|
+
if (Be.includes(i)) {
|
|
827
931
|
const u = this._validatorSingleFormula(e.formula2);
|
|
828
932
|
return {
|
|
829
|
-
success:
|
|
830
|
-
formula1:
|
|
933
|
+
success: o && u,
|
|
934
|
+
formula1: o ? void 0 : n,
|
|
831
935
|
formula2: u ? void 0 : n
|
|
832
936
|
};
|
|
833
937
|
}
|
|
834
938
|
return {
|
|
835
|
-
success:
|
|
836
|
-
formula1:
|
|
939
|
+
success: o,
|
|
940
|
+
formula1: o ? void 0 : n
|
|
837
941
|
};
|
|
838
942
|
}
|
|
839
943
|
normalizeFormula(e, t, r) {
|
|
840
|
-
const { formula1: i, formula2:
|
|
841
|
-
var
|
|
944
|
+
const { formula1: i, formula2: o, bizInfo: n } = e, l = (u) => {
|
|
945
|
+
var d;
|
|
842
946
|
if (!u)
|
|
843
947
|
return u;
|
|
844
|
-
let
|
|
948
|
+
let c;
|
|
845
949
|
if (!Number.isNaN(+u))
|
|
846
|
-
|
|
950
|
+
c = L.dateFromSerial(+u);
|
|
847
951
|
else {
|
|
848
|
-
const g = (
|
|
952
|
+
const g = (d = L.parseDate(u)) == null ? void 0 : d.v;
|
|
849
953
|
if (g == null)
|
|
850
954
|
return "";
|
|
851
|
-
|
|
955
|
+
c = L.dateFromSerial(g);
|
|
852
956
|
}
|
|
853
|
-
return
|
|
957
|
+
return nt(`${c[0]}/${c[1]}/${c[2]} ${c[3]}:${c[4]}:${c[5]}`).format(n != null && n.showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD");
|
|
854
958
|
};
|
|
855
959
|
return {
|
|
856
960
|
formula1: S(i) ? i : l(`${i}`),
|
|
857
|
-
formula2: S(
|
|
961
|
+
formula2: S(o) ? o : l(`${o}`)
|
|
858
962
|
};
|
|
859
963
|
}
|
|
860
964
|
transform(e, t, r) {
|
|
861
965
|
const { value: i } = e;
|
|
862
966
|
return {
|
|
863
967
|
...e,
|
|
864
|
-
value:
|
|
968
|
+
value: ke(i)
|
|
865
969
|
};
|
|
866
970
|
}
|
|
867
971
|
get operatorNames() {
|
|
868
|
-
return this.operators.map((e) => this.localeService.t(
|
|
972
|
+
return this.operators.map((e) => this.localeService.t(la[e]));
|
|
869
973
|
}
|
|
870
974
|
generateRuleName(e) {
|
|
871
975
|
var r, i;
|
|
872
976
|
if (!e.operator)
|
|
873
|
-
return this.localeService.t(
|
|
874
|
-
const t = this.localeService.t(
|
|
977
|
+
return this.localeService.t(it.NONE);
|
|
978
|
+
const t = this.localeService.t(it[e.operator]).replace(ue, (r = e.formula1) != null ? r : "").replace(ce, (i = e.formula2) != null ? i : "");
|
|
875
979
|
return `${this.titleStr} ${t}`;
|
|
876
980
|
}
|
|
877
981
|
generateRuleErrorMessage(e, t) {
|
|
878
982
|
if (!e.operator)
|
|
879
983
|
return this.titleStr;
|
|
880
|
-
const { transformedFormula1: r, transformedFormula2: i } =
|
|
881
|
-
return `${this.localeService.t(
|
|
984
|
+
const { transformedFormula1: r, transformedFormula2: i } = Ue(this._lexerTreeBuilder, e, t);
|
|
985
|
+
return `${this.localeService.t(ua[e.operator]).replace(ue, r != null ? r : "").replace(ce, i != null ? i : "")}`;
|
|
882
986
|
}
|
|
883
987
|
}
|
|
884
988
|
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 + "";
|
|
885
989
|
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 + "";
|
|
886
|
-
const
|
|
990
|
+
const Ce = {
|
|
887
991
|
[h.BETWEEN]: "dataValidation.errorMsg.between",
|
|
888
992
|
[h.EQUAL]: "dataValidation.errorMsg.equal",
|
|
889
993
|
[h.GREATER_THAN]: "dataValidation.errorMsg.greaterThan",
|
|
@@ -894,15 +998,15 @@ const Me = {
|
|
|
894
998
|
[h.NOT_EQUAL]: "dataValidation.errorMsg.notEqual",
|
|
895
999
|
NONE: "dataValidation.errorMsg.legal"
|
|
896
1000
|
};
|
|
897
|
-
function
|
|
898
|
-
return +
|
|
1001
|
+
function Te(s) {
|
|
1002
|
+
return +s;
|
|
899
1003
|
}
|
|
900
|
-
class
|
|
1004
|
+
class da extends Y {
|
|
901
1005
|
constructor() {
|
|
902
1006
|
super(...arguments);
|
|
903
|
-
m(this, "_customFormulaService", this.injector.get(
|
|
904
|
-
m(this, "id",
|
|
905
|
-
m(this, "_lexerTreeBuilder", this.injector.get(
|
|
1007
|
+
m(this, "_customFormulaService", this.injector.get(W));
|
|
1008
|
+
m(this, "id", C.DECIMAL);
|
|
1009
|
+
m(this, "_lexerTreeBuilder", this.injector.get(X));
|
|
906
1010
|
m(this, "title", "dataValidation.decimal.title");
|
|
907
1011
|
m(this, "order", 20);
|
|
908
1012
|
m(this, "operators", [
|
|
@@ -918,28 +1022,28 @@ class la extends G {
|
|
|
918
1022
|
m(this, "scopes", ["sheet"]);
|
|
919
1023
|
}
|
|
920
1024
|
_isFormulaOrNumber(e) {
|
|
921
|
-
return !
|
|
1025
|
+
return !M.isBlank(e) && (S(e) || !Number.isNaN(+e));
|
|
922
1026
|
}
|
|
923
1027
|
async isValidType(e, t, r) {
|
|
924
1028
|
const { value: i } = e;
|
|
925
|
-
return !Number.isNaN(
|
|
1029
|
+
return !Number.isNaN(Te(i));
|
|
926
1030
|
}
|
|
927
1031
|
transform(e, t, r) {
|
|
928
1032
|
const { value: i } = e;
|
|
929
1033
|
return {
|
|
930
1034
|
...e,
|
|
931
|
-
value:
|
|
1035
|
+
value: Te(i)
|
|
932
1036
|
};
|
|
933
1037
|
}
|
|
934
1038
|
_parseNumber(e) {
|
|
935
1039
|
return e == null ? Number.NaN : +e;
|
|
936
1040
|
}
|
|
937
|
-
async parseFormula(e, t, r, i,
|
|
938
|
-
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i,
|
|
1041
|
+
async parseFormula(e, t, r, i, o) {
|
|
1042
|
+
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i, o), l = await this._customFormulaService.getCellFormula2Value(t, r, e.uid, i, o), { formula1: u, formula2: c } = e, d = T(String(n == null ? void 0 : n.v)) && T(String(l == null ? void 0 : l.v));
|
|
939
1043
|
return {
|
|
940
1044
|
formula1: this._parseNumber(S(u) ? n == null ? void 0 : n.v : u),
|
|
941
|
-
formula2: this._parseNumber(S(
|
|
942
|
-
isFormulaValid:
|
|
1045
|
+
formula2: this._parseNumber(S(c) ? l == null ? void 0 : l.v : c),
|
|
1046
|
+
isFormulaValid: d
|
|
943
1047
|
};
|
|
944
1048
|
}
|
|
945
1049
|
validatorFormula(e, t, r) {
|
|
@@ -948,90 +1052,93 @@ class la extends G {
|
|
|
948
1052
|
return {
|
|
949
1053
|
success: !0
|
|
950
1054
|
};
|
|
951
|
-
const
|
|
1055
|
+
const o = M.isDefine(e.formula1) && this._isFormulaOrNumber(e.formula1), n = M.isDefine(e.formula2) && this._isFormulaOrNumber(e.formula2), l = Be.includes(i), u = this.localeService.t("dataValidation.validFail.number");
|
|
952
1056
|
return l ? {
|
|
953
|
-
success:
|
|
954
|
-
formula1:
|
|
1057
|
+
success: o && n,
|
|
1058
|
+
formula1: o ? void 0 : u,
|
|
955
1059
|
formula2: n ? void 0 : u
|
|
956
1060
|
} : {
|
|
957
|
-
success:
|
|
958
|
-
formula1:
|
|
1061
|
+
success: o,
|
|
1062
|
+
formula1: o ? "" : u
|
|
959
1063
|
};
|
|
960
1064
|
}
|
|
961
1065
|
generateRuleErrorMessage(e, t) {
|
|
962
1066
|
if (!e.operator)
|
|
963
|
-
return this.localeService.t(
|
|
964
|
-
const { transformedFormula1: r, transformedFormula2: i } =
|
|
965
|
-
return `${this.localeService.t(
|
|
1067
|
+
return this.localeService.t(Ce.NONE).replace("{TYPE}", this.titleStr);
|
|
1068
|
+
const { transformedFormula1: r, transformedFormula2: i } = Ue(this._lexerTreeBuilder, e, t);
|
|
1069
|
+
return `${this.localeService.t(Ce[e.operator]).replace(ue, r != null ? r : "").replace(ce, i != null ? i : "")}`;
|
|
966
1070
|
}
|
|
967
1071
|
}
|
|
968
|
-
function
|
|
969
|
-
|
|
1072
|
+
function ha(s) {
|
|
1073
|
+
var e, t;
|
|
1074
|
+
if (!s)
|
|
970
1075
|
return [];
|
|
971
1076
|
const a = /* @__PURE__ */ new Set();
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
const
|
|
977
|
-
if (
|
|
978
|
-
if (typeof
|
|
979
|
-
a.add(
|
|
980
|
-
|
|
1077
|
+
for (let r = 0, i = s.length; r < i; r++) {
|
|
1078
|
+
const o = s[r];
|
|
1079
|
+
if (o)
|
|
1080
|
+
for (let n = 0, l = o.length; n < l; n++) {
|
|
1081
|
+
const u = o[n], c = re(u);
|
|
1082
|
+
if (c != null) {
|
|
1083
|
+
if (typeof c != "string" && typeof (u == null ? void 0 : u.s) == "object" && ((t = (e = u.s) == null ? void 0 : e.n) != null && t.pattern)) {
|
|
1084
|
+
a.add(L.format(u.s.n.pattern, c, { throws: !1 }));
|
|
1085
|
+
continue;
|
|
981
1086
|
}
|
|
982
|
-
|
|
1087
|
+
const d = typeof c == "string" ? c : String(c);
|
|
1088
|
+
T(d) && a.add(d);
|
|
983
1089
|
}
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
return [...a];
|
|
987
1093
|
}
|
|
988
|
-
const
|
|
1094
|
+
const ma = [
|
|
989
1095
|
"if",
|
|
990
1096
|
"indirect",
|
|
991
1097
|
"choose",
|
|
992
1098
|
"offset"
|
|
993
1099
|
];
|
|
994
|
-
function
|
|
995
|
-
if (!S(
|
|
1100
|
+
function ga(s, a) {
|
|
1101
|
+
if (!S(s) || ut(s.slice(1)))
|
|
996
1102
|
return !0;
|
|
997
|
-
const t = a.sequenceNodesBuilder(
|
|
998
|
-
return t && t.some((r) => typeof r == "object" && r.nodeType ===
|
|
1103
|
+
const t = a.sequenceNodesBuilder(s);
|
|
1104
|
+
return t && t.some((r) => typeof r == "object" && r.nodeType === Ht.FUNCTION && ma.indexOf(r.token.toLowerCase()) > -1);
|
|
999
1105
|
}
|
|
1000
|
-
function
|
|
1001
|
-
const { formula1: e = "", ranges: t } =
|
|
1002
|
-
if (
|
|
1003
|
-
const i =
|
|
1004
|
-
if ((!i.sheetName || i.sheetName === a) && t.some((
|
|
1106
|
+
function pa(s, a) {
|
|
1107
|
+
const { formula1: e = "", ranges: t } = s;
|
|
1108
|
+
if (ut(e.slice(1))) {
|
|
1109
|
+
const i = Wt(e.slice(1));
|
|
1110
|
+
if ((!i.sheetName || i.sheetName === a) && t.some((o) => O.intersects(o, i.range)))
|
|
1005
1111
|
return !0;
|
|
1006
1112
|
}
|
|
1007
1113
|
return !1;
|
|
1008
1114
|
}
|
|
1009
|
-
class
|
|
1115
|
+
class _t extends Y {
|
|
1010
1116
|
constructor() {
|
|
1011
1117
|
super(...arguments);
|
|
1012
|
-
m(this, "formulaService", this.injector.get(
|
|
1013
|
-
m(this, "_lexer", this.injector.get(
|
|
1014
|
-
m(this, "_univerInstanceService", this.injector.get(
|
|
1118
|
+
m(this, "formulaService", this.injector.get(G));
|
|
1119
|
+
m(this, "_lexer", this.injector.get(X));
|
|
1120
|
+
m(this, "_univerInstanceService", this.injector.get(D));
|
|
1121
|
+
m(this, "_listCacheService", this.injector.get(le));
|
|
1015
1122
|
m(this, "order", 50);
|
|
1016
1123
|
m(this, "offsetFormulaByRange", !1);
|
|
1017
|
-
m(this, "id",
|
|
1124
|
+
m(this, "id", C.LIST);
|
|
1018
1125
|
m(this, "title", "dataValidation.list.title");
|
|
1019
1126
|
m(this, "operators", []);
|
|
1020
1127
|
m(this, "scopes", ["sheet"]);
|
|
1021
|
-
m(this, "skipDefaultFontRender", (e) => e.renderMode !==
|
|
1128
|
+
m(this, "skipDefaultFontRender", (e) => e.renderMode !== We.TEXT);
|
|
1022
1129
|
}
|
|
1023
1130
|
validatorFormula(e, t, r) {
|
|
1024
|
-
var u,
|
|
1025
|
-
const i = !
|
|
1131
|
+
var u, c, d;
|
|
1132
|
+
const i = !M.isBlank(e.formula1), o = ga((u = e.formula1) != null ? u : "", this._lexer), n = (d = (c = this._univerInstanceService.getUnit(t, N.UNIVER_SHEET)) == null ? void 0 : c.getSheetBySheetId(r)) == null ? void 0 : d.getName(), l = pa(e, n != null ? n : "");
|
|
1026
1133
|
return {
|
|
1027
|
-
success: !!(i &&
|
|
1028
|
-
formula1: i ?
|
|
1134
|
+
success: !!(i && o && !l),
|
|
1135
|
+
formula1: i ? o ? l ? this.localeService.t("dataValidation.validFail.listIntersects") : void 0 : this.localeService.t("dataValidation.validFail.listInvalid") : this.localeService.t("dataValidation.validFail.list")
|
|
1029
1136
|
};
|
|
1030
1137
|
}
|
|
1031
1138
|
getExtraStyle(e, t, { style: r }) {
|
|
1032
|
-
var
|
|
1033
|
-
const i = (
|
|
1034
|
-
if (e.type ===
|
|
1139
|
+
var o;
|
|
1140
|
+
const i = (o = r.tb !== Se.OVERFLOW ? r.tb : Se.CLIP) != null ? o : Se.WRAP;
|
|
1141
|
+
if (e.type === C.LIST && (e.renderMode === We.ARROW || e.renderMode === We.TEXT)) {
|
|
1035
1142
|
const n = this.getListWithColorMap(e), l = `${t != null ? t : ""}`, u = n[l];
|
|
1036
1143
|
if (u)
|
|
1037
1144
|
return {
|
|
@@ -1047,21 +1154,24 @@ class ft extends G {
|
|
|
1047
1154
|
}
|
|
1048
1155
|
parseCellValue(e) {
|
|
1049
1156
|
const t = e.toString();
|
|
1050
|
-
return
|
|
1157
|
+
return Ee(t);
|
|
1051
1158
|
}
|
|
1052
1159
|
async parseFormula(e, t, r) {
|
|
1053
1160
|
var l, u;
|
|
1054
|
-
const i = await this.formulaService.getRuleFormulaResult(t, r, e.uid),
|
|
1161
|
+
const i = await this.formulaService.getRuleFormulaResult(t, r, e.uid), o = oe((u = (l = i == null ? void 0 : i[0]) == null ? void 0 : l.result) == null ? void 0 : u[0][0]);
|
|
1055
1162
|
return {
|
|
1056
1163
|
formula1: void 0,
|
|
1057
1164
|
formula2: void 0,
|
|
1058
|
-
isFormulaValid:
|
|
1165
|
+
isFormulaValid: T(String(o))
|
|
1059
1166
|
};
|
|
1060
1167
|
}
|
|
1061
1168
|
async isValidType(e, t, r) {
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1169
|
+
const { value: i, unitId: o, subUnitId: n } = e, { formula1: l = "" } = r, u = S(l) ? this._listCacheService.getOrCompute(
|
|
1170
|
+
o,
|
|
1171
|
+
n,
|
|
1172
|
+
r
|
|
1173
|
+
).list : Ee(l);
|
|
1174
|
+
return this.parseCellValue(i).every((d) => u.includes(d));
|
|
1065
1175
|
}
|
|
1066
1176
|
generateRuleName() {
|
|
1067
1177
|
return this.localeService.t("dataValidation.list.name");
|
|
@@ -1069,41 +1179,60 @@ class ft extends G {
|
|
|
1069
1179
|
generateRuleErrorMessage() {
|
|
1070
1180
|
return this.localeService.t("dataValidation.list.error");
|
|
1071
1181
|
}
|
|
1182
|
+
_getUnitAndSubUnit(e, t) {
|
|
1183
|
+
var o, n;
|
|
1184
|
+
const r = (o = e ? this._univerInstanceService.getUniverSheetInstance(e) : void 0) != null ? o : this._univerInstanceService.getCurrentUnitForType(N.UNIVER_SHEET);
|
|
1185
|
+
if (!r) return null;
|
|
1186
|
+
const i = (n = t ? r.getSheetBySheetId(t) : void 0) != null ? n : r.getActiveSheet();
|
|
1187
|
+
return i ? {
|
|
1188
|
+
unitId: r.getUnitId(),
|
|
1189
|
+
subUnitId: i.getSheetId()
|
|
1190
|
+
} : null;
|
|
1191
|
+
}
|
|
1072
1192
|
getList(e, t, r) {
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1193
|
+
const i = this._getUnitAndSubUnit(t, r);
|
|
1194
|
+
if (!i) return [];
|
|
1195
|
+
const { unitId: o, subUnitId: n } = i;
|
|
1196
|
+
return this._listCacheService.getOrCompute(
|
|
1197
|
+
o,
|
|
1198
|
+
n,
|
|
1199
|
+
e
|
|
1200
|
+
).list;
|
|
1080
1201
|
}
|
|
1081
1202
|
async getListAsync(e, t, r) {
|
|
1082
|
-
var
|
|
1083
|
-
const { formula1: i = "" } = e,
|
|
1084
|
-
if (!
|
|
1085
|
-
const
|
|
1086
|
-
|
|
1087
|
-
const u = n.getUnitId(), d = l.getSheetId(), c = await this.formulaService.getRuleFormulaResult(u, d, e.uid);
|
|
1088
|
-
return S(i) ? $e((R = (p = c == null ? void 0 : c[0]) == null ? void 0 : p.result) == null ? void 0 : R[0][0]) : _e(i);
|
|
1203
|
+
var c, d;
|
|
1204
|
+
const { formula1: i = "" } = e, o = this._getUnitAndSubUnit(t, r);
|
|
1205
|
+
if (!o) return [];
|
|
1206
|
+
const { unitId: n, subUnitId: l } = o, u = await this.formulaService.getRuleFormulaResult(n, l, e.uid);
|
|
1207
|
+
return S(i) ? ha((d = (c = u == null ? void 0 : u[0]) == null ? void 0 : c.result) == null ? void 0 : d[0][0]) : Ee(i);
|
|
1089
1208
|
}
|
|
1090
1209
|
getListWithColor(e, t, r) {
|
|
1091
|
-
const i = this.
|
|
1092
|
-
|
|
1210
|
+
const i = this._getUnitAndSubUnit(t, r);
|
|
1211
|
+
if (!i) return [];
|
|
1212
|
+
const { unitId: o, subUnitId: n } = i;
|
|
1213
|
+
return this._listCacheService.getOrCompute(
|
|
1214
|
+
o,
|
|
1215
|
+
n,
|
|
1216
|
+
e
|
|
1217
|
+
).listWithColor;
|
|
1093
1218
|
}
|
|
1094
1219
|
getListWithColorMap(e, t, r) {
|
|
1095
|
-
const i = this.
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1220
|
+
const i = this._getUnitAndSubUnit(t, r);
|
|
1221
|
+
if (!i) return {};
|
|
1222
|
+
const { unitId: o, subUnitId: n } = i;
|
|
1223
|
+
return this._listCacheService.getOrCompute(
|
|
1224
|
+
o,
|
|
1225
|
+
n,
|
|
1226
|
+
e
|
|
1227
|
+
).colorMap;
|
|
1099
1228
|
}
|
|
1100
1229
|
}
|
|
1101
|
-
class
|
|
1230
|
+
class fa extends Y {
|
|
1102
1231
|
constructor() {
|
|
1103
1232
|
super(...arguments);
|
|
1104
|
-
m(this, "id",
|
|
1233
|
+
m(this, "id", C.TEXT_LENGTH);
|
|
1105
1234
|
m(this, "title", "dataValidation.textLength.title");
|
|
1106
|
-
m(this, "_lexerTreeBuilder", this.injector.get(
|
|
1235
|
+
m(this, "_lexerTreeBuilder", this.injector.get(X));
|
|
1107
1236
|
m(this, "order", 30);
|
|
1108
1237
|
m(this, "operators", [
|
|
1109
1238
|
h.BETWEEN,
|
|
@@ -1116,10 +1245,10 @@ class ha extends G {
|
|
|
1116
1245
|
h.NOT_EQUAL
|
|
1117
1246
|
]);
|
|
1118
1247
|
m(this, "scopes", ["sheet"]);
|
|
1119
|
-
m(this, "_customFormulaService", this.injector.get(
|
|
1248
|
+
m(this, "_customFormulaService", this.injector.get(W));
|
|
1120
1249
|
}
|
|
1121
1250
|
_isFormulaOrInt(e) {
|
|
1122
|
-
return !
|
|
1251
|
+
return !M.isBlank(e) && (S(e) || !Number.isNaN(+e) && Number.isInteger(+e));
|
|
1123
1252
|
}
|
|
1124
1253
|
validatorFormula(e, t, r) {
|
|
1125
1254
|
const i = e.operator;
|
|
@@ -1127,25 +1256,25 @@ class ha extends G {
|
|
|
1127
1256
|
return {
|
|
1128
1257
|
success: !1
|
|
1129
1258
|
};
|
|
1130
|
-
const
|
|
1259
|
+
const o = M.isDefine(e.formula1) && this._isFormulaOrInt(e.formula1), n = M.isDefine(e.formula2) && this._isFormulaOrInt(e.formula2), l = Be.includes(i), u = this.localeService.t("dataValidation.validFail.number");
|
|
1131
1260
|
return l ? {
|
|
1132
|
-
success:
|
|
1133
|
-
formula1:
|
|
1261
|
+
success: o && n,
|
|
1262
|
+
formula1: o ? void 0 : u,
|
|
1134
1263
|
formula2: n ? void 0 : u
|
|
1135
1264
|
} : {
|
|
1136
|
-
success:
|
|
1265
|
+
success: o,
|
|
1137
1266
|
formula1: u
|
|
1138
1267
|
};
|
|
1139
1268
|
}
|
|
1140
1269
|
_parseNumber(e) {
|
|
1141
1270
|
return e == null ? Number.NaN : +e;
|
|
1142
1271
|
}
|
|
1143
|
-
async parseFormula(e, t, r, i,
|
|
1144
|
-
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i,
|
|
1272
|
+
async parseFormula(e, t, r, i, o) {
|
|
1273
|
+
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i, o), l = await this._customFormulaService.getCellFormula2Value(t, r, e.uid, i, o), { formula1: u, formula2: c } = e, d = T(String(n == null ? void 0 : n.v)) && T(String(l == null ? void 0 : l.v));
|
|
1145
1274
|
return {
|
|
1146
1275
|
formula1: this._parseNumber(S(u) ? n == null ? void 0 : n.v : u),
|
|
1147
|
-
formula2: this._parseNumber(S(
|
|
1148
|
-
isFormulaValid:
|
|
1276
|
+
formula2: this._parseNumber(S(c) ? l == null ? void 0 : l.v : c),
|
|
1277
|
+
isFormulaValid: d
|
|
1149
1278
|
};
|
|
1150
1279
|
}
|
|
1151
1280
|
transform(e, t, r) {
|
|
@@ -1161,28 +1290,28 @@ class ha extends G {
|
|
|
1161
1290
|
generateRuleErrorMessage(e, t) {
|
|
1162
1291
|
if (!e.operator)
|
|
1163
1292
|
return this.titleStr;
|
|
1164
|
-
const { transformedFormula1: r, transformedFormula2: i } =
|
|
1165
|
-
return `${this.localeService.t(
|
|
1293
|
+
const { transformedFormula1: r, transformedFormula2: i } = Ue(this._lexerTreeBuilder, e, t);
|
|
1294
|
+
return `${this.localeService.t(Lt[e.operator]).replace(ue, r != null ? r : "").replace(ce, i != null ? i : "")}`;
|
|
1166
1295
|
}
|
|
1167
1296
|
}
|
|
1168
|
-
function
|
|
1297
|
+
function vt(s) {
|
|
1169
1298
|
var e, t;
|
|
1170
|
-
return
|
|
1299
|
+
return s ? s.p ? !((t = (e = s.p.body) == null ? void 0 : e.dataStream) != null ? t : "").slice(0, -2).trim() : M.isBlank(s.v) : !0;
|
|
1171
1300
|
}
|
|
1172
|
-
function
|
|
1173
|
-
const
|
|
1301
|
+
function xe(s, a, e, t, r = "command", i = !0) {
|
|
1302
|
+
const o = t.get(X), n = t.get(q), l = [], u = [], c = t.get(F), d = t.get(D), g = ze(d, { unitId: s, subUnitId: a });
|
|
1174
1303
|
if (!g)
|
|
1175
1304
|
return {
|
|
1176
1305
|
redoMutations: l,
|
|
1177
1306
|
undoMutations: u
|
|
1178
1307
|
};
|
|
1179
|
-
const { worksheet: f } = g, p = new
|
|
1308
|
+
const { worksheet: f } = g, p = new Me();
|
|
1180
1309
|
let R = !1;
|
|
1181
|
-
function
|
|
1310
|
+
function E(_, w) {
|
|
1182
1311
|
i && _.forEach(($) => {
|
|
1183
|
-
|
|
1184
|
-
const
|
|
1185
|
-
(
|
|
1312
|
+
H.foreach($, (x, k) => {
|
|
1313
|
+
const P = f.getCellRaw(x, k), J = ft(P);
|
|
1314
|
+
(vt(P) || J === w) && !(P != null && P.p) && (R = !0, p.setValue(x, k, {
|
|
1186
1315
|
v: w,
|
|
1187
1316
|
p: null
|
|
1188
1317
|
}));
|
|
@@ -1193,17 +1322,17 @@ function Ue(o, a, e, t, r = "command", i = !0) {
|
|
|
1193
1322
|
switch (_.type) {
|
|
1194
1323
|
case "delete":
|
|
1195
1324
|
l.push({
|
|
1196
|
-
id:
|
|
1325
|
+
id: I.id,
|
|
1197
1326
|
params: {
|
|
1198
|
-
unitId:
|
|
1327
|
+
unitId: s,
|
|
1199
1328
|
subUnitId: a,
|
|
1200
1329
|
ruleId: _.rule.uid,
|
|
1201
1330
|
source: r
|
|
1202
1331
|
}
|
|
1203
1332
|
}), u.unshift({
|
|
1204
|
-
id:
|
|
1333
|
+
id: b.id,
|
|
1205
1334
|
params: {
|
|
1206
|
-
unitId:
|
|
1335
|
+
unitId: s,
|
|
1207
1336
|
subUnitId: a,
|
|
1208
1337
|
rule: _.rule,
|
|
1209
1338
|
index: _.index,
|
|
@@ -1212,19 +1341,19 @@ function Ue(o, a, e, t, r = "command", i = !0) {
|
|
|
1212
1341
|
});
|
|
1213
1342
|
break;
|
|
1214
1343
|
case "update": {
|
|
1215
|
-
if (
|
|
1216
|
-
const $ = _.oldRanges[0].startRow,
|
|
1217
|
-
|
|
1344
|
+
if (he(_.rule.type, n)) {
|
|
1345
|
+
const $ = _.oldRanges[0].startRow, x = _.oldRanges[0].startColumn, k = _.newRanges[0].startRow, P = _.newRanges[0].startColumn, J = k - $, me = P - x, ge = S(_.rule.formula1) ? o.moveFormulaRefOffset(_.rule.formula1, me, J) : _.rule.formula1, pe = S(_.rule.formula2) ? o.moveFormulaRefOffset(_.rule.formula2, me, J) : _.rule.formula2;
|
|
1346
|
+
ge !== _.rule.formula1 || pe !== _.rule.formula2 || !lt(_.newRanges, _.oldRanges) ? (l.push({
|
|
1218
1347
|
id: y.id,
|
|
1219
1348
|
params: {
|
|
1220
|
-
unitId:
|
|
1349
|
+
unitId: s,
|
|
1221
1350
|
subUnitId: a,
|
|
1222
1351
|
ruleId: _.ruleId,
|
|
1223
1352
|
payload: {
|
|
1224
|
-
type:
|
|
1353
|
+
type: V.ALL,
|
|
1225
1354
|
payload: {
|
|
1226
|
-
formula1:
|
|
1227
|
-
formula2:
|
|
1355
|
+
formula1: ge,
|
|
1356
|
+
formula2: pe,
|
|
1228
1357
|
ranges: _.newRanges
|
|
1229
1358
|
}
|
|
1230
1359
|
}
|
|
@@ -1232,11 +1361,11 @@ function Ue(o, a, e, t, r = "command", i = !0) {
|
|
|
1232
1361
|
}), u.unshift({
|
|
1233
1362
|
id: y.id,
|
|
1234
1363
|
params: {
|
|
1235
|
-
unitId:
|
|
1364
|
+
unitId: s,
|
|
1236
1365
|
subUnitId: a,
|
|
1237
1366
|
ruleId: _.ruleId,
|
|
1238
1367
|
payload: {
|
|
1239
|
-
type:
|
|
1368
|
+
type: V.ALL,
|
|
1240
1369
|
payload: {
|
|
1241
1370
|
formula1: _.rule.formula1,
|
|
1242
1371
|
formula2: _.rule.formula2,
|
|
@@ -1247,11 +1376,11 @@ function Ue(o, a, e, t, r = "command", i = !0) {
|
|
|
1247
1376
|
})) : (l.push({
|
|
1248
1377
|
id: y.id,
|
|
1249
1378
|
params: {
|
|
1250
|
-
unitId:
|
|
1379
|
+
unitId: s,
|
|
1251
1380
|
subUnitId: a,
|
|
1252
1381
|
ruleId: _.ruleId,
|
|
1253
1382
|
payload: {
|
|
1254
|
-
type:
|
|
1383
|
+
type: V.RANGE,
|
|
1255
1384
|
payload: _.newRanges
|
|
1256
1385
|
},
|
|
1257
1386
|
source: r
|
|
@@ -1259,11 +1388,11 @@ function Ue(o, a, e, t, r = "command", i = !0) {
|
|
|
1259
1388
|
}), u.unshift({
|
|
1260
1389
|
id: y.id,
|
|
1261
1390
|
params: {
|
|
1262
|
-
unitId:
|
|
1391
|
+
unitId: s,
|
|
1263
1392
|
subUnitId: a,
|
|
1264
1393
|
ruleId: _.ruleId,
|
|
1265
1394
|
payload: {
|
|
1266
|
-
type:
|
|
1395
|
+
type: V.RANGE,
|
|
1267
1396
|
payload: _.oldRanges
|
|
1268
1397
|
},
|
|
1269
1398
|
source: r
|
|
@@ -1273,11 +1402,11 @@ function Ue(o, a, e, t, r = "command", i = !0) {
|
|
|
1273
1402
|
l.push({
|
|
1274
1403
|
id: y.id,
|
|
1275
1404
|
params: {
|
|
1276
|
-
unitId:
|
|
1405
|
+
unitId: s,
|
|
1277
1406
|
subUnitId: a,
|
|
1278
1407
|
ruleId: _.ruleId,
|
|
1279
1408
|
payload: {
|
|
1280
|
-
type:
|
|
1409
|
+
type: V.RANGE,
|
|
1281
1410
|
payload: _.newRanges
|
|
1282
1411
|
},
|
|
1283
1412
|
source: r
|
|
@@ -1285,57 +1414,57 @@ function Ue(o, a, e, t, r = "command", i = !0) {
|
|
|
1285
1414
|
}), u.unshift({
|
|
1286
1415
|
id: y.id,
|
|
1287
1416
|
params: {
|
|
1288
|
-
unitId:
|
|
1417
|
+
unitId: s,
|
|
1289
1418
|
subUnitId: a,
|
|
1290
1419
|
ruleId: _.ruleId,
|
|
1291
1420
|
payload: {
|
|
1292
|
-
type:
|
|
1421
|
+
type: V.RANGE,
|
|
1293
1422
|
payload: _.oldRanges
|
|
1294
1423
|
},
|
|
1295
1424
|
source: r
|
|
1296
1425
|
}
|
|
1297
1426
|
});
|
|
1298
|
-
const w =
|
|
1299
|
-
if (w && w.type ===
|
|
1300
|
-
const
|
|
1301
|
-
|
|
1427
|
+
const w = c.getRuleById(s, a, _.ruleId);
|
|
1428
|
+
if (w && w.type === C.CHECKBOX) {
|
|
1429
|
+
const x = c.getValidator(C.CHECKBOX).parseFormulaSync(w, s, a);
|
|
1430
|
+
E(_.newRanges, x.formula2);
|
|
1302
1431
|
}
|
|
1303
1432
|
break;
|
|
1304
1433
|
}
|
|
1305
1434
|
case "add": {
|
|
1306
1435
|
if (l.push({
|
|
1307
|
-
id:
|
|
1436
|
+
id: b.id,
|
|
1308
1437
|
params: {
|
|
1309
|
-
unitId:
|
|
1438
|
+
unitId: s,
|
|
1310
1439
|
subUnitId: a,
|
|
1311
1440
|
rule: _.rule,
|
|
1312
1441
|
source: r
|
|
1313
1442
|
}
|
|
1314
1443
|
}), u.unshift({
|
|
1315
|
-
id:
|
|
1444
|
+
id: I.id,
|
|
1316
1445
|
params: {
|
|
1317
|
-
unitId:
|
|
1446
|
+
unitId: s,
|
|
1318
1447
|
subUnitId: a,
|
|
1319
1448
|
ruleId: _.rule.uid,
|
|
1320
1449
|
source: r
|
|
1321
1450
|
}
|
|
1322
|
-
}), _.rule.type ===
|
|
1323
|
-
const $ =
|
|
1324
|
-
|
|
1451
|
+
}), _.rule.type === C.CHECKBOX) {
|
|
1452
|
+
const $ = c.getValidator(C.CHECKBOX).parseFormulaSync(_.rule, s, a);
|
|
1453
|
+
E(_.rule.ranges, $.originFormula2);
|
|
1325
1454
|
}
|
|
1326
1455
|
break;
|
|
1327
1456
|
}
|
|
1328
1457
|
}
|
|
1329
1458
|
}), R) {
|
|
1330
1459
|
const _ = {
|
|
1331
|
-
id:
|
|
1460
|
+
id: ne.id,
|
|
1332
1461
|
params: {
|
|
1333
|
-
unitId:
|
|
1462
|
+
unitId: s,
|
|
1334
1463
|
subUnitId: a,
|
|
1335
1464
|
cellValue: p.getData()
|
|
1336
1465
|
}
|
|
1337
1466
|
}, w = {
|
|
1338
|
-
id:
|
|
1467
|
+
id: ne.id,
|
|
1339
1468
|
params: dt(t, _.params)
|
|
1340
1469
|
};
|
|
1341
1470
|
l.push(_), u.push(w);
|
|
@@ -1345,45 +1474,45 @@ function Ue(o, a, e, t, r = "command", i = !0) {
|
|
|
1345
1474
|
undoMutations: u
|
|
1346
1475
|
};
|
|
1347
1476
|
}
|
|
1348
|
-
const
|
|
1477
|
+
const _a = {
|
|
1349
1478
|
type: z.COMMAND,
|
|
1350
1479
|
id: "sheet.command.updateDataValidationRuleRange",
|
|
1351
|
-
handler(
|
|
1480
|
+
handler(s, a) {
|
|
1352
1481
|
if (!a)
|
|
1353
1482
|
return !1;
|
|
1354
|
-
const { unitId: e, subUnitId: t, ranges: r, ruleId: i } = a,
|
|
1355
|
-
if (!
|
|
1483
|
+
const { unitId: e, subUnitId: t, ranges: r, ruleId: i } = a, o = s.get(F), n = s.get(U), l = s.get(Z);
|
|
1484
|
+
if (!o.getRuleById(e, t, i))
|
|
1356
1485
|
return !1;
|
|
1357
|
-
const
|
|
1358
|
-
|
|
1359
|
-
const
|
|
1486
|
+
const c = o.getRuleObjectMatrix(e, t).clone();
|
|
1487
|
+
c.updateRange(i, r);
|
|
1488
|
+
const d = c.diff(o.getRules(e, t)), { redoMutations: g, undoMutations: f } = xe(e, t, d, s);
|
|
1360
1489
|
return l.pushUndoRedo({
|
|
1361
1490
|
undoMutations: f,
|
|
1362
1491
|
redoMutations: g,
|
|
1363
1492
|
unitID: e
|
|
1364
|
-
}),
|
|
1493
|
+
}), Le(g, n), !0;
|
|
1365
1494
|
}
|
|
1366
|
-
},
|
|
1495
|
+
}, va = {
|
|
1367
1496
|
type: z.COMMAND,
|
|
1368
1497
|
id: "sheet.command.addDataValidation",
|
|
1369
|
-
handler(
|
|
1498
|
+
handler(s, a) {
|
|
1370
1499
|
if (!a)
|
|
1371
1500
|
return !1;
|
|
1372
|
-
const { unitId: e, subUnitId: t, rule: r } = a, i =
|
|
1501
|
+
const { unitId: e, subUnitId: t, rule: r } = a, i = s.get(F), o = s.get(U), n = s.get(Z), l = i.getRuleObjectMatrix(e, t).clone();
|
|
1373
1502
|
l.addRule(r);
|
|
1374
|
-
const u = l.diff(i.getRules(e, t)),
|
|
1503
|
+
const u = l.diff(i.getRules(e, t)), c = i.getValidator(r.type), d = {
|
|
1375
1504
|
unitId: e,
|
|
1376
1505
|
subUnitId: t,
|
|
1377
1506
|
rule: {
|
|
1378
1507
|
...r,
|
|
1379
|
-
...
|
|
1508
|
+
...c == null ? void 0 : c.normalizeFormula(r, e, t)
|
|
1380
1509
|
}
|
|
1381
|
-
}, { redoMutations: g, undoMutations: f } =
|
|
1510
|
+
}, { redoMutations: g, undoMutations: f } = xe(e, t, u, s);
|
|
1382
1511
|
return g.push({
|
|
1383
|
-
id:
|
|
1384
|
-
params:
|
|
1512
|
+
id: b.id,
|
|
1513
|
+
params: d
|
|
1385
1514
|
}), f.unshift({
|
|
1386
|
-
id:
|
|
1515
|
+
id: I.id,
|
|
1387
1516
|
params: {
|
|
1388
1517
|
unitId: e,
|
|
1389
1518
|
subUnitId: t,
|
|
@@ -1393,115 +1522,115 @@ const ma = {
|
|
|
1393
1522
|
unitID: e,
|
|
1394
1523
|
redoMutations: g,
|
|
1395
1524
|
undoMutations: f
|
|
1396
|
-
}),
|
|
1525
|
+
}), Le(g, o), !0;
|
|
1397
1526
|
}
|
|
1398
|
-
},
|
|
1527
|
+
}, Ra = {
|
|
1399
1528
|
type: z.COMMAND,
|
|
1400
1529
|
id: "sheets.command.update-data-validation-setting",
|
|
1401
1530
|
// eslint-disable-next-line max-lines-per-function
|
|
1402
|
-
handler(
|
|
1531
|
+
handler(s, a) {
|
|
1403
1532
|
if (!a)
|
|
1404
1533
|
return !1;
|
|
1405
|
-
const e =
|
|
1406
|
-
if (!d)
|
|
1407
|
-
return !1;
|
|
1408
|
-
const c = r.getRuleById(s, n, l);
|
|
1534
|
+
const e = s.get(U), t = s.get(Z), r = s.get(F), i = s.get(q), { unitId: o, subUnitId: n, ruleId: l, setting: u } = a, c = i.getValidatorItem(u.type);
|
|
1409
1535
|
if (!c)
|
|
1410
1536
|
return !1;
|
|
1411
|
-
const
|
|
1412
|
-
if (!d
|
|
1537
|
+
const d = r.getRuleById(o, n, l);
|
|
1538
|
+
if (!d)
|
|
1539
|
+
return !1;
|
|
1540
|
+
const g = { ...d, ...u };
|
|
1541
|
+
if (!c.validatorFormula(g, o, n).success)
|
|
1413
1542
|
return !1;
|
|
1414
1543
|
const f = {
|
|
1415
|
-
unitId:
|
|
1544
|
+
unitId: o,
|
|
1416
1545
|
subUnitId: n,
|
|
1417
1546
|
ruleId: l,
|
|
1418
1547
|
payload: {
|
|
1419
|
-
type:
|
|
1548
|
+
type: V.SETTING,
|
|
1420
1549
|
payload: {
|
|
1421
1550
|
...u,
|
|
1422
|
-
...
|
|
1551
|
+
...c.normalizeFormula(g, o, n)
|
|
1423
1552
|
}
|
|
1424
1553
|
}
|
|
1425
1554
|
}, p = [{
|
|
1426
1555
|
id: y.id,
|
|
1427
1556
|
params: f
|
|
1428
1557
|
}], R = {
|
|
1429
|
-
unitId:
|
|
1558
|
+
unitId: o,
|
|
1430
1559
|
subUnitId: n,
|
|
1431
1560
|
ruleId: l,
|
|
1432
1561
|
payload: {
|
|
1433
|
-
type:
|
|
1434
|
-
payload:
|
|
1562
|
+
type: V.SETTING,
|
|
1563
|
+
payload: Ut(d)
|
|
1435
1564
|
}
|
|
1436
|
-
},
|
|
1565
|
+
}, E = [{
|
|
1437
1566
|
id: y.id,
|
|
1438
1567
|
params: R
|
|
1439
1568
|
}];
|
|
1440
|
-
if (u.type ===
|
|
1441
|
-
const w =
|
|
1442
|
-
if (
|
|
1443
|
-
const k = new
|
|
1444
|
-
let
|
|
1445
|
-
if (w.forEach((
|
|
1446
|
-
|
|
1447
|
-
const j =
|
|
1448
|
-
(
|
|
1449
|
-
v:
|
|
1569
|
+
if (u.type === C.CHECKBOX) {
|
|
1570
|
+
const w = d.ranges, $ = s.get(D), x = ze($, { unitId: o, subUnitId: n });
|
|
1571
|
+
if (x) {
|
|
1572
|
+
const k = new Me(), { worksheet: P } = x, { formula2: J = ye, formula1: me = Ve } = d, { formula2: ge = ye, formula1: pe = Ve } = u;
|
|
1573
|
+
let Pe = !1;
|
|
1574
|
+
if (w.forEach((fe) => {
|
|
1575
|
+
H.foreach(fe, (ie, He) => {
|
|
1576
|
+
const j = P.getCellRaw(ie, He), Je = ft(j);
|
|
1577
|
+
(vt(j) || Je === String(J)) && !(j != null && j.p) ? (k.setValue(ie, He, {
|
|
1578
|
+
v: ge,
|
|
1450
1579
|
p: null
|
|
1451
|
-
}),
|
|
1452
|
-
v:
|
|
1580
|
+
}), Pe = !0) : Je === String(me) && !(j != null && j.p) && (k.setValue(ie, He, {
|
|
1581
|
+
v: pe,
|
|
1453
1582
|
p: null
|
|
1454
|
-
}),
|
|
1583
|
+
}), Pe = !0);
|
|
1455
1584
|
});
|
|
1456
|
-
}),
|
|
1457
|
-
const
|
|
1458
|
-
id:
|
|
1585
|
+
}), Pe) {
|
|
1586
|
+
const fe = {
|
|
1587
|
+
id: ne.id,
|
|
1459
1588
|
params: {
|
|
1460
|
-
unitId:
|
|
1589
|
+
unitId: o,
|
|
1461
1590
|
subUnitId: n,
|
|
1462
1591
|
cellValue: k.getData()
|
|
1463
1592
|
}
|
|
1464
|
-
},
|
|
1465
|
-
id:
|
|
1466
|
-
params: dt(
|
|
1593
|
+
}, ie = {
|
|
1594
|
+
id: ne.id,
|
|
1595
|
+
params: dt(s, fe.params)
|
|
1467
1596
|
};
|
|
1468
|
-
p.push(
|
|
1597
|
+
p.push(fe), E.push(ie);
|
|
1469
1598
|
}
|
|
1470
1599
|
}
|
|
1471
1600
|
}
|
|
1472
|
-
return
|
|
1473
|
-
unitID:
|
|
1601
|
+
return Le(p, e).result ? (t.pushUndoRedo({
|
|
1602
|
+
unitID: o,
|
|
1474
1603
|
redoMutations: p,
|
|
1475
|
-
undoMutations:
|
|
1604
|
+
undoMutations: E
|
|
1476
1605
|
}), !0) : !1;
|
|
1477
1606
|
}
|
|
1478
|
-
},
|
|
1607
|
+
}, Sa = {
|
|
1479
1608
|
type: z.COMMAND,
|
|
1480
1609
|
id: "sheets.command.update-data-validation-options",
|
|
1481
|
-
handler(
|
|
1610
|
+
handler(s, a) {
|
|
1482
1611
|
if (!a)
|
|
1483
1612
|
return !1;
|
|
1484
|
-
const e =
|
|
1613
|
+
const e = s.get(U), t = s.get(Z), r = s.get(F), { unitId: i, subUnitId: o, ruleId: n, options: l } = a, u = r.getRuleById(i, o, n);
|
|
1485
1614
|
if (!u)
|
|
1486
1615
|
return !1;
|
|
1487
|
-
const
|
|
1616
|
+
const c = {
|
|
1488
1617
|
unitId: i,
|
|
1489
|
-
subUnitId:
|
|
1618
|
+
subUnitId: o,
|
|
1490
1619
|
ruleId: n,
|
|
1491
1620
|
payload: {
|
|
1492
|
-
type:
|
|
1621
|
+
type: V.OPTIONS,
|
|
1493
1622
|
payload: l
|
|
1494
1623
|
}
|
|
1495
|
-
},
|
|
1624
|
+
}, d = [{
|
|
1496
1625
|
id: y.id,
|
|
1497
|
-
params:
|
|
1626
|
+
params: c
|
|
1498
1627
|
}], g = {
|
|
1499
1628
|
unitId: i,
|
|
1500
|
-
subUnitId:
|
|
1629
|
+
subUnitId: o,
|
|
1501
1630
|
ruleId: n,
|
|
1502
1631
|
payload: {
|
|
1503
|
-
type:
|
|
1504
|
-
payload:
|
|
1632
|
+
type: V.OPTIONS,
|
|
1633
|
+
payload: Bt(u)
|
|
1505
1634
|
}
|
|
1506
1635
|
}, f = [{
|
|
1507
1636
|
id: y.id,
|
|
@@ -1509,70 +1638,70 @@ const ma = {
|
|
|
1509
1638
|
}];
|
|
1510
1639
|
return t.pushUndoRedo({
|
|
1511
1640
|
unitID: i,
|
|
1512
|
-
redoMutations:
|
|
1641
|
+
redoMutations: d,
|
|
1513
1642
|
undoMutations: f
|
|
1514
|
-
}), e.executeCommand(y.id,
|
|
1643
|
+
}), e.executeCommand(y.id, c), !0;
|
|
1515
1644
|
}
|
|
1516
|
-
},
|
|
1645
|
+
}, Ea = {
|
|
1517
1646
|
type: z.COMMAND,
|
|
1518
1647
|
id: "sheets.command.clear-range-data-validation",
|
|
1519
|
-
handler(
|
|
1648
|
+
handler(s, a) {
|
|
1520
1649
|
if (!a)
|
|
1521
1650
|
return !1;
|
|
1522
|
-
const { unitId: e, subUnitId: t, ranges: r } = a, i =
|
|
1651
|
+
const { unitId: e, subUnitId: t, ranges: r } = a, i = s.get(U), o = s.get(D), n = ze(o, { unitId: e, subUnitId: t }), l = s.get(F);
|
|
1523
1652
|
if (!n) return !1;
|
|
1524
|
-
const u =
|
|
1525
|
-
|
|
1526
|
-
const
|
|
1653
|
+
const u = s.get(Z), c = l.getRuleObjectMatrix(e, t).clone();
|
|
1654
|
+
c.removeRange(r);
|
|
1655
|
+
const d = c.diff(l.getRules(e, t)), { redoMutations: g, undoMutations: f } = xe(e, t, d, s);
|
|
1527
1656
|
return u.pushUndoRedo({
|
|
1528
1657
|
unitID: e,
|
|
1529
1658
|
redoMutations: g,
|
|
1530
1659
|
undoMutations: f
|
|
1531
|
-
}),
|
|
1660
|
+
}), Le(g, i).result;
|
|
1532
1661
|
}
|
|
1533
|
-
},
|
|
1662
|
+
}, Ma = {
|
|
1534
1663
|
type: z.COMMAND,
|
|
1535
1664
|
id: "sheet.command.remove-all-data-validation",
|
|
1536
|
-
handler(
|
|
1665
|
+
handler(s, a) {
|
|
1537
1666
|
if (!a)
|
|
1538
1667
|
return !1;
|
|
1539
|
-
const { unitId: e, subUnitId: t } = a, r =
|
|
1668
|
+
const { unitId: e, subUnitId: t } = a, r = s.get(U), i = s.get(F), o = s.get(Z), n = [...i.getRules(e, t)], l = {
|
|
1540
1669
|
unitId: e,
|
|
1541
1670
|
subUnitId: t,
|
|
1542
|
-
ruleId: n.map((
|
|
1671
|
+
ruleId: n.map((d) => d.uid)
|
|
1543
1672
|
}, u = [{
|
|
1544
|
-
id:
|
|
1673
|
+
id: I.id,
|
|
1545
1674
|
params: l
|
|
1546
|
-
}],
|
|
1547
|
-
id:
|
|
1675
|
+
}], c = [{
|
|
1676
|
+
id: b.id,
|
|
1548
1677
|
params: {
|
|
1549
1678
|
unitId: e,
|
|
1550
1679
|
subUnitId: t,
|
|
1551
1680
|
rule: n
|
|
1552
1681
|
}
|
|
1553
1682
|
}];
|
|
1554
|
-
return
|
|
1683
|
+
return o.pushUndoRedo({
|
|
1555
1684
|
redoMutations: u,
|
|
1556
|
-
undoMutations:
|
|
1685
|
+
undoMutations: c,
|
|
1557
1686
|
unitID: e
|
|
1558
|
-
}), r.executeCommand(
|
|
1687
|
+
}), r.executeCommand(I.id, l), !0;
|
|
1559
1688
|
}
|
|
1560
|
-
},
|
|
1561
|
-
const e =
|
|
1689
|
+
}, Va = (s, a) => {
|
|
1690
|
+
const e = s.get(F), { unitId: t, subUnitId: r, ruleId: i, source: o } = a;
|
|
1562
1691
|
if (Array.isArray(i)) {
|
|
1563
1692
|
const l = i.map((u) => e.getRuleById(t, r, u)).filter(Boolean);
|
|
1564
1693
|
return [{
|
|
1565
|
-
id:
|
|
1694
|
+
id: b.id,
|
|
1566
1695
|
params: {
|
|
1567
1696
|
unitId: t,
|
|
1568
1697
|
subUnitId: r,
|
|
1569
1698
|
rule: l,
|
|
1570
|
-
source:
|
|
1699
|
+
source: o
|
|
1571
1700
|
}
|
|
1572
1701
|
}];
|
|
1573
1702
|
}
|
|
1574
1703
|
return [{
|
|
1575
|
-
id:
|
|
1704
|
+
id: b.id,
|
|
1576
1705
|
params: {
|
|
1577
1706
|
unitId: t,
|
|
1578
1707
|
subUnitId: r,
|
|
@@ -1582,17 +1711,17 @@ const ma = {
|
|
|
1582
1711
|
index: e.getRuleIndex(t, r, i)
|
|
1583
1712
|
}
|
|
1584
1713
|
}];
|
|
1585
|
-
},
|
|
1714
|
+
}, ya = {
|
|
1586
1715
|
type: z.COMMAND,
|
|
1587
1716
|
id: "sheet.command.remove-data-validation-rule",
|
|
1588
|
-
handler(
|
|
1717
|
+
handler(s, a) {
|
|
1589
1718
|
if (!a)
|
|
1590
1719
|
return !1;
|
|
1591
|
-
const { unitId: e, subUnitId: t, ruleId: r } = a, i =
|
|
1592
|
-
id:
|
|
1720
|
+
const { unitId: e, subUnitId: t, ruleId: r } = a, i = s.get(U), o = s.get(Z), n = s.get(F), l = [{
|
|
1721
|
+
id: I.id,
|
|
1593
1722
|
params: a
|
|
1594
1723
|
}], u = [{
|
|
1595
|
-
id:
|
|
1724
|
+
id: b.id,
|
|
1596
1725
|
params: {
|
|
1597
1726
|
unitId: e,
|
|
1598
1727
|
subUnitId: t,
|
|
@@ -1602,46 +1731,46 @@ const ma = {
|
|
|
1602
1731
|
index: n.getRuleIndex(e, t, r)
|
|
1603
1732
|
}
|
|
1604
1733
|
}];
|
|
1605
|
-
return
|
|
1734
|
+
return o.pushUndoRedo({
|
|
1606
1735
|
undoMutations: u,
|
|
1607
1736
|
redoMutations: l,
|
|
1608
1737
|
unitID: a.unitId
|
|
1609
|
-
}), i.executeCommand(
|
|
1738
|
+
}), i.executeCommand(I.id, a), !0;
|
|
1610
1739
|
}
|
|
1611
|
-
},
|
|
1612
|
-
var Rt = /* @__PURE__ */ ((
|
|
1613
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
1614
|
-
(
|
|
1740
|
+
}, Ca = "SHEET_DATA_VALIDATION_PLUGIN";
|
|
1741
|
+
var Rt = /* @__PURE__ */ ((s) => (s[s.View = 0] = "View", s[s.Edit = 1] = "Edit", s[s.ManageCollaborator = 2] = "ManageCollaborator", s[s.Print = 3] = "Print", s[s.Duplicate = 4] = "Duplicate", s[s.Comment = 5] = "Comment", s[s.Copy = 6] = "Copy", s[s.Share = 7] = "Share", s[s.Export = 8] = "Export", s[s.MoveWorksheet = 9] = "MoveWorksheet", s[s.DeleteWorksheet = 10] = "DeleteWorksheet", s[s.HideWorksheet = 11] = "HideWorksheet", s[s.RenameWorksheet = 12] = "RenameWorksheet", s[s.CreateWorksheet = 13] = "CreateWorksheet", s[s.SetWorksheetStyle = 14] = "SetWorksheetStyle", s[s.EditWorksheetCell = 15] = "EditWorksheetCell", s[s.InsertHyperlink = 16] = "InsertHyperlink", s[s.Sort = 17] = "Sort", s[s.Filter = 18] = "Filter", s[s.PivotTable = 19] = "PivotTable", s[s.FloatImg = 20] = "FloatImg", s[s.History = 21] = "History", s[s.RwHgtClWdt = 22] = "RwHgtClWdt", s[s.ViemRwHgtClWdt = 23] = "ViemRwHgtClWdt", s[s.ViewFilter = 24] = "ViewFilter", s[s.MoveSheet = 25] = "MoveSheet", s[s.DeleteSheet = 26] = "DeleteSheet", s[s.HideSheet = 27] = "HideSheet", s[s.CopySheet = 28] = "CopySheet", s[s.RenameSheet = 29] = "RenameSheet", s[s.CreateSheet = 30] = "CreateSheet", s[s.SelectProtectedCells = 31] = "SelectProtectedCells", s[s.SelectUnProtectedCells = 32] = "SelectUnProtectedCells", s[s.SetCellStyle = 33] = "SetCellStyle", s[s.SetCellValue = 34] = "SetCellValue", s[s.SetRowStyle = 35] = "SetRowStyle", s[s.SetColumnStyle = 36] = "SetColumnStyle", s[s.InsertRow = 37] = "InsertRow", s[s.InsertColumn = 38] = "InsertColumn", s[s.DeleteRow = 39] = "DeleteRow", s[s.DeleteColumn = 40] = "DeleteColumn", s[s.EditExtraObject = 41] = "EditExtraObject", s[s.Delete = 42] = "Delete", s[s.RecoverHistory = 43] = "RecoverHistory", s[s.ViewHistory = 44] = "ViewHistory", s[s.CreatePermissionObject = 45] = "CreatePermissionObject", s[s.UNRECOGNIZED = -1] = "UNRECOGNIZED", s))(Rt || {}), Ta = Object.getOwnPropertyDescriptor, Fa = (s, a, e, t) => {
|
|
1742
|
+
for (var r = t > 1 ? void 0 : t ? Ta(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
1743
|
+
(o = s[i]) && (r = o(r) || r);
|
|
1615
1744
|
return r;
|
|
1616
|
-
},
|
|
1617
|
-
let
|
|
1618
|
-
constructor(
|
|
1619
|
-
super(), this._univerInstanceService =
|
|
1745
|
+
}, je = (s, a) => (e, t) => a(e, t, s);
|
|
1746
|
+
let Fe = class extends B {
|
|
1747
|
+
constructor(s, a, e) {
|
|
1748
|
+
super(), this._univerInstanceService = s, this._permissionService = a, this._lexerTreeBuilder = e;
|
|
1620
1749
|
}
|
|
1621
|
-
getFormulaRefCheck(
|
|
1750
|
+
getFormulaRefCheck(s) {
|
|
1622
1751
|
var e, t;
|
|
1623
|
-
const a = this._lexerTreeBuilder.sequenceNodesBuilder(
|
|
1752
|
+
const a = this._lexerTreeBuilder.sequenceNodesBuilder(s);
|
|
1624
1753
|
if (!a)
|
|
1625
1754
|
return !0;
|
|
1626
1755
|
for (let r = 0; r < a.length; r++) {
|
|
1627
1756
|
const i = a[r];
|
|
1628
1757
|
if (typeof i == "string")
|
|
1629
1758
|
continue;
|
|
1630
|
-
const { token:
|
|
1759
|
+
const { token: o } = i, n = $t(o), l = this._univerInstanceService.getCurrentUnitForType(N.UNIVER_SHEET);
|
|
1631
1760
|
let u = l.getActiveSheet();
|
|
1632
|
-
const
|
|
1761
|
+
const c = l.getUnitId();
|
|
1633
1762
|
if (n.sheetName) {
|
|
1634
1763
|
if (u = l.getSheetBySheetName(n.sheetName), !u)
|
|
1635
1764
|
return !1;
|
|
1636
1765
|
const R = u == null ? void 0 : u.getSheetId();
|
|
1637
|
-
if (!this._permissionService.getPermissionPoint(new
|
|
1766
|
+
if (!this._permissionService.getPermissionPoint(new jt(c, R).id)) return !1;
|
|
1638
1767
|
}
|
|
1639
1768
|
if (!u)
|
|
1640
1769
|
return !1;
|
|
1641
|
-
const { startRow:
|
|
1642
|
-
for (let R =
|
|
1643
|
-
for (let
|
|
1644
|
-
const _ = (t = (e = u.getCell(R,
|
|
1770
|
+
const { startRow: d, endRow: g, startColumn: f, endColumn: p } = n.range;
|
|
1771
|
+
for (let R = d; R <= g; R++)
|
|
1772
|
+
for (let E = f; E <= p; E++) {
|
|
1773
|
+
const _ = (t = (e = u.getCell(R, E)) == null ? void 0 : e.selectionProtection) == null ? void 0 : t[0];
|
|
1645
1774
|
if ((_ == null ? void 0 : _[Rt.View]) === !1)
|
|
1646
1775
|
return !1;
|
|
1647
1776
|
}
|
|
@@ -1649,23 +1778,23 @@ let Te = class extends W {
|
|
|
1649
1778
|
return !0;
|
|
1650
1779
|
}
|
|
1651
1780
|
};
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
],
|
|
1657
|
-
const
|
|
1658
|
-
var
|
|
1659
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
1660
|
-
(
|
|
1781
|
+
Fe = Fa([
|
|
1782
|
+
je(0, D),
|
|
1783
|
+
je(1, Tt),
|
|
1784
|
+
je(2, v(X))
|
|
1785
|
+
], Fe);
|
|
1786
|
+
const Na = "sheets-data-validation.config", st = {};
|
|
1787
|
+
var wa = Object.getOwnPropertyDescriptor, Oa = (s, a, e, t) => {
|
|
1788
|
+
for (var r = t > 1 ? void 0 : t ? wa(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
1789
|
+
(o = s[i]) && (r = o(r) || r);
|
|
1661
1790
|
return r;
|
|
1662
|
-
},
|
|
1663
|
-
let
|
|
1791
|
+
}, Qe = (s, a) => (e, t) => a(e, t, s);
|
|
1792
|
+
let Ne = class extends B {
|
|
1664
1793
|
constructor(a, e, t) {
|
|
1665
1794
|
super();
|
|
1666
1795
|
m(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
1667
1796
|
m(this, "registerRule", (a, e, t) => {
|
|
1668
|
-
|
|
1797
|
+
he(t.type, this._validatorRegistryService) && this.register(a, e, t);
|
|
1669
1798
|
});
|
|
1670
1799
|
this._dataValidationModel = a, this._formulaRefRangeService = e, this._validatorRegistryService = t, this._initRefRange();
|
|
1671
1800
|
}
|
|
@@ -1674,11 +1803,11 @@ let Fe = class extends W {
|
|
|
1674
1803
|
}
|
|
1675
1804
|
// eslint-disable-next-line max-lines-per-function
|
|
1676
1805
|
register(a, e, t) {
|
|
1677
|
-
const r = t.ranges, i = t.formula1,
|
|
1806
|
+
const r = t.ranges, i = t.formula1, o = t.formula2, n = this._formulaRefRangeService.registerRangeFormula(a, e, r, [i != null ? i : "", o != null ? o : ""], (u) => {
|
|
1678
1807
|
if (u.length === 0)
|
|
1679
1808
|
return {
|
|
1680
1809
|
undos: [{
|
|
1681
|
-
id:
|
|
1810
|
+
id: b.id,
|
|
1682
1811
|
params: {
|
|
1683
1812
|
unitId: a,
|
|
1684
1813
|
subUnitId: e,
|
|
@@ -1687,7 +1816,7 @@ let Fe = class extends W {
|
|
|
1687
1816
|
}
|
|
1688
1817
|
}],
|
|
1689
1818
|
redos: [{
|
|
1690
|
-
id:
|
|
1819
|
+
id: I.id,
|
|
1691
1820
|
params: {
|
|
1692
1821
|
unitId: a,
|
|
1693
1822
|
subUnitId: e,
|
|
@@ -1696,15 +1825,15 @@ let Fe = class extends W {
|
|
|
1696
1825
|
}
|
|
1697
1826
|
}]
|
|
1698
1827
|
};
|
|
1699
|
-
const
|
|
1700
|
-
|
|
1828
|
+
const c = [], d = [], g = u[0];
|
|
1829
|
+
c.push({
|
|
1701
1830
|
id: y.id,
|
|
1702
1831
|
params: {
|
|
1703
1832
|
unitId: a,
|
|
1704
1833
|
subUnitId: e,
|
|
1705
1834
|
ruleId: t.uid,
|
|
1706
1835
|
payload: {
|
|
1707
|
-
type:
|
|
1836
|
+
type: V.ALL,
|
|
1708
1837
|
payload: {
|
|
1709
1838
|
ranges: g.ranges,
|
|
1710
1839
|
formula1: g.formulas[0],
|
|
@@ -1713,27 +1842,27 @@ let Fe = class extends W {
|
|
|
1713
1842
|
},
|
|
1714
1843
|
source: "patched"
|
|
1715
1844
|
}
|
|
1716
|
-
}),
|
|
1845
|
+
}), d.push({
|
|
1717
1846
|
id: y.id,
|
|
1718
1847
|
params: {
|
|
1719
1848
|
unitId: a,
|
|
1720
1849
|
subUnitId: e,
|
|
1721
1850
|
ruleId: t.uid,
|
|
1722
1851
|
payload: {
|
|
1723
|
-
type:
|
|
1852
|
+
type: V.ALL,
|
|
1724
1853
|
payload: {
|
|
1725
1854
|
ranges: r,
|
|
1726
1855
|
formula1: i,
|
|
1727
|
-
formula2:
|
|
1856
|
+
formula2: o
|
|
1728
1857
|
}
|
|
1729
1858
|
},
|
|
1730
1859
|
source: "patched"
|
|
1731
1860
|
}
|
|
1732
1861
|
});
|
|
1733
1862
|
for (let f = 1; f < u.length; f++) {
|
|
1734
|
-
const p = u[f], R =
|
|
1735
|
-
|
|
1736
|
-
id:
|
|
1863
|
+
const p = u[f], R = Xe();
|
|
1864
|
+
c.push({
|
|
1865
|
+
id: b.id,
|
|
1737
1866
|
params: {
|
|
1738
1867
|
unitId: a,
|
|
1739
1868
|
subUnitId: e,
|
|
@@ -1746,8 +1875,8 @@ let Fe = class extends W {
|
|
|
1746
1875
|
},
|
|
1747
1876
|
source: "patched"
|
|
1748
1877
|
}
|
|
1749
|
-
}),
|
|
1750
|
-
id:
|
|
1878
|
+
}), d.push({
|
|
1879
|
+
id: I.id,
|
|
1751
1880
|
params: {
|
|
1752
1881
|
unitId: a,
|
|
1753
1882
|
subUnitId: e,
|
|
@@ -1757,8 +1886,8 @@ let Fe = class extends W {
|
|
|
1757
1886
|
});
|
|
1758
1887
|
}
|
|
1759
1888
|
return {
|
|
1760
|
-
undos:
|
|
1761
|
-
redos:
|
|
1889
|
+
undos: d,
|
|
1890
|
+
redos: c
|
|
1762
1891
|
};
|
|
1763
1892
|
}), l = this._getIdWithUnitId(a, e, t.uid);
|
|
1764
1893
|
this._disposableMap.set(l, n);
|
|
@@ -1767,54 +1896,54 @@ let Fe = class extends W {
|
|
|
1767
1896
|
const a = this._dataValidationModel.getAll();
|
|
1768
1897
|
for (const [e, t] of a)
|
|
1769
1898
|
for (const [r, i] of t)
|
|
1770
|
-
for (const
|
|
1771
|
-
this.registerRule(e, r,
|
|
1899
|
+
for (const o of i)
|
|
1900
|
+
this.registerRule(e, r, o);
|
|
1772
1901
|
this.disposeWithMe(
|
|
1773
1902
|
this._dataValidationModel.ruleChange$.subscribe((e) => {
|
|
1774
1903
|
const { unitId: t, subUnitId: r, rule: i } = e;
|
|
1775
1904
|
switch (e.type) {
|
|
1776
1905
|
case "add": {
|
|
1777
|
-
const
|
|
1778
|
-
this.registerRule(e.unitId, e.subUnitId,
|
|
1906
|
+
const o = e.rule;
|
|
1907
|
+
this.registerRule(e.unitId, e.subUnitId, o);
|
|
1779
1908
|
break;
|
|
1780
1909
|
}
|
|
1781
1910
|
case "remove": {
|
|
1782
|
-
const
|
|
1783
|
-
|
|
1911
|
+
const o = this._disposableMap.get(this._getIdWithUnitId(t, r, i.uid));
|
|
1912
|
+
o && o.dispose();
|
|
1784
1913
|
break;
|
|
1785
1914
|
}
|
|
1786
1915
|
case "update": {
|
|
1787
|
-
const
|
|
1788
|
-
n && n.dispose(), this.registerRule(e.unitId, e.subUnitId,
|
|
1916
|
+
const o = e.rule, n = this._disposableMap.get(this._getIdWithUnitId(t, r, o.uid));
|
|
1917
|
+
n && n.dispose(), this.registerRule(e.unitId, e.subUnitId, o);
|
|
1789
1918
|
break;
|
|
1790
1919
|
}
|
|
1791
1920
|
}
|
|
1792
1921
|
})
|
|
1793
|
-
), this.disposeWithMe(
|
|
1922
|
+
), this.disposeWithMe(Ke(() => {
|
|
1794
1923
|
this._disposableMap.forEach((e) => {
|
|
1795
1924
|
e.dispose();
|
|
1796
1925
|
}), this._disposableMap.clear();
|
|
1797
1926
|
}));
|
|
1798
1927
|
}
|
|
1799
1928
|
};
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
],
|
|
1805
|
-
var
|
|
1806
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
1807
|
-
(
|
|
1929
|
+
Ne = Oa([
|
|
1930
|
+
Qe(0, v(F)),
|
|
1931
|
+
Qe(1, v(pt)),
|
|
1932
|
+
Qe(2, v(q))
|
|
1933
|
+
], Ne);
|
|
1934
|
+
var Aa = Object.getOwnPropertyDescriptor, Ia = (s, a, e, t) => {
|
|
1935
|
+
for (var r = t > 1 ? void 0 : t ? Aa(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
1936
|
+
(o = s[i]) && (r = o(r) || r);
|
|
1808
1937
|
return r;
|
|
1809
|
-
},
|
|
1810
|
-
let
|
|
1811
|
-
constructor(a, e, t, r, i,
|
|
1938
|
+
}, te = (s, a) => (e, t) => a(e, t, s);
|
|
1939
|
+
let we = class extends B {
|
|
1940
|
+
constructor(a, e, t, r, i, o) {
|
|
1812
1941
|
super();
|
|
1813
1942
|
m(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
1814
1943
|
m(this, "registerRule", (a, e, t) => {
|
|
1815
|
-
|
|
1944
|
+
he(t.type, this._validatorRegistryService) || (this.register(a, e, t), this.registerFormula(a, e, t));
|
|
1816
1945
|
});
|
|
1817
|
-
this._dataValidationModel = a, this._injector = e, this._refRangeService = t, this._dataValidationFormulaService = r, this._formulaRefRangeService = i, this._validatorRegistryService =
|
|
1946
|
+
this._dataValidationModel = a, this._injector = e, this._refRangeService = t, this._dataValidationFormulaService = r, this._formulaRefRangeService = i, this._validatorRegistryService = o, this._initRefRange();
|
|
1818
1947
|
}
|
|
1819
1948
|
_getIdWithUnitId(a, e, t) {
|
|
1820
1949
|
return `${a}_${e}_${t}`;
|
|
@@ -1822,24 +1951,24 @@ let Ne = class extends W {
|
|
|
1822
1951
|
// eslint-disable-next-line max-lines-per-function
|
|
1823
1952
|
registerFormula(a, e, t) {
|
|
1824
1953
|
var u;
|
|
1825
|
-
const r = t.uid, i = this._getIdWithUnitId(a, e, r),
|
|
1954
|
+
const r = t.uid, i = this._getIdWithUnitId(a, e, r), o = (u = this._disposableMap.get(i)) != null ? u : /* @__PURE__ */ new Set(), n = (c, d) => {
|
|
1826
1955
|
const g = this._dataValidationModel.getRuleById(a, e, r);
|
|
1827
1956
|
if (!g)
|
|
1828
1957
|
return { redos: [], undos: [] };
|
|
1829
|
-
const f = g[
|
|
1830
|
-
if (!f || f ===
|
|
1958
|
+
const f = g[c];
|
|
1959
|
+
if (!f || f === d)
|
|
1831
1960
|
return { redos: [], undos: [] };
|
|
1832
1961
|
const p = {
|
|
1833
1962
|
unitId: a,
|
|
1834
1963
|
subUnitId: e,
|
|
1835
1964
|
ruleId: t.uid,
|
|
1836
1965
|
payload: {
|
|
1837
|
-
type:
|
|
1966
|
+
type: V.SETTING,
|
|
1838
1967
|
payload: {
|
|
1839
1968
|
type: g.type,
|
|
1840
1969
|
formula1: g.formula1,
|
|
1841
1970
|
formula2: g.formula2,
|
|
1842
|
-
[
|
|
1971
|
+
[c]: d
|
|
1843
1972
|
}
|
|
1844
1973
|
},
|
|
1845
1974
|
source: "patched"
|
|
@@ -1848,7 +1977,7 @@ let Ne = class extends W {
|
|
|
1848
1977
|
subUnitId: e,
|
|
1849
1978
|
ruleId: t.uid,
|
|
1850
1979
|
payload: {
|
|
1851
|
-
type:
|
|
1980
|
+
type: V.SETTING,
|
|
1852
1981
|
payload: {
|
|
1853
1982
|
type: g.type,
|
|
1854
1983
|
formula1: g.formula1,
|
|
@@ -1856,7 +1985,7 @@ let Ne = class extends W {
|
|
|
1856
1985
|
}
|
|
1857
1986
|
},
|
|
1858
1987
|
source: "patched"
|
|
1859
|
-
},
|
|
1988
|
+
}, E = [
|
|
1860
1989
|
{
|
|
1861
1990
|
id: y.id,
|
|
1862
1991
|
params: p
|
|
@@ -1867,35 +1996,35 @@ let Ne = class extends W {
|
|
|
1867
1996
|
params: R
|
|
1868
1997
|
}
|
|
1869
1998
|
];
|
|
1870
|
-
return { redos:
|
|
1999
|
+
return { redos: E, undos: _ };
|
|
1871
2000
|
}, l = this._dataValidationFormulaService.getRuleFormulaInfo(a, e, r);
|
|
1872
2001
|
if (l) {
|
|
1873
|
-
const [
|
|
1874
|
-
if (
|
|
2002
|
+
const [c, d] = l;
|
|
2003
|
+
if (c) {
|
|
1875
2004
|
const g = this._formulaRefRangeService.registerFormula(
|
|
1876
2005
|
a,
|
|
1877
2006
|
e,
|
|
1878
|
-
|
|
2007
|
+
c.text,
|
|
1879
2008
|
(f) => n("formula1", f)
|
|
1880
2009
|
);
|
|
1881
|
-
|
|
2010
|
+
o.add(() => g.dispose());
|
|
1882
2011
|
}
|
|
1883
|
-
if (
|
|
2012
|
+
if (d) {
|
|
1884
2013
|
const g = this._formulaRefRangeService.registerFormula(
|
|
1885
2014
|
a,
|
|
1886
2015
|
e,
|
|
1887
|
-
|
|
2016
|
+
d.text,
|
|
1888
2017
|
(f) => n("formula2", f)
|
|
1889
2018
|
);
|
|
1890
|
-
|
|
2019
|
+
o.add(() => g.dispose());
|
|
1891
2020
|
}
|
|
1892
2021
|
}
|
|
1893
2022
|
}
|
|
1894
2023
|
register(a, e, t) {
|
|
1895
2024
|
var l;
|
|
1896
2025
|
const r = (u) => {
|
|
1897
|
-
const
|
|
1898
|
-
if (
|
|
2026
|
+
const c = [...t.ranges], g = c.map((p) => Gt(p, u)).filter((p) => !!p).flat();
|
|
2027
|
+
if (lt(g, c))
|
|
1899
2028
|
return { redos: [], undos: [] };
|
|
1900
2029
|
if (g.length) {
|
|
1901
2030
|
const p = {
|
|
@@ -1903,105 +2032,105 @@ let Ne = class extends W {
|
|
|
1903
2032
|
subUnitId: e,
|
|
1904
2033
|
ruleId: t.uid,
|
|
1905
2034
|
payload: {
|
|
1906
|
-
type:
|
|
2035
|
+
type: V.RANGE,
|
|
1907
2036
|
payload: g
|
|
1908
2037
|
},
|
|
1909
2038
|
source: "patched"
|
|
1910
|
-
}, R = [{ id: y.id, params: p }],
|
|
2039
|
+
}, R = [{ id: y.id, params: p }], E = [{
|
|
1911
2040
|
id: y.id,
|
|
1912
2041
|
params: {
|
|
1913
2042
|
unitId: a,
|
|
1914
2043
|
subUnitId: e,
|
|
1915
2044
|
ruleId: t.uid,
|
|
1916
2045
|
payload: {
|
|
1917
|
-
type:
|
|
1918
|
-
payload:
|
|
2046
|
+
type: V.RANGE,
|
|
2047
|
+
payload: c
|
|
1919
2048
|
},
|
|
1920
2049
|
source: "patched"
|
|
1921
2050
|
}
|
|
1922
2051
|
}];
|
|
1923
|
-
return { redos: R, undos:
|
|
2052
|
+
return { redos: R, undos: E };
|
|
1924
2053
|
} else {
|
|
1925
|
-
const p = { unitId: a, subUnitId: e, ruleId: t.uid }, R = [{ id:
|
|
1926
|
-
return { redos: R, undos:
|
|
2054
|
+
const p = { unitId: a, subUnitId: e, ruleId: t.uid }, R = [{ id: I.id, params: p }], E = Va(this._injector, p);
|
|
2055
|
+
return { redos: R, undos: E };
|
|
1927
2056
|
}
|
|
1928
2057
|
}, i = [];
|
|
1929
2058
|
t.ranges.forEach((u) => {
|
|
1930
|
-
const
|
|
1931
|
-
i.push(() =>
|
|
2059
|
+
const c = this._refRangeService.registerRefRange(u, r, a, e);
|
|
2060
|
+
i.push(() => c.dispose());
|
|
1932
2061
|
});
|
|
1933
|
-
const
|
|
1934
|
-
n.add(() => i.forEach((u) => u())), this._disposableMap.set(
|
|
2062
|
+
const o = this._getIdWithUnitId(a, e, t.uid), n = (l = this._disposableMap.get(o)) != null ? l : /* @__PURE__ */ new Set();
|
|
2063
|
+
n.add(() => i.forEach((u) => u())), this._disposableMap.set(o, n);
|
|
1935
2064
|
}
|
|
1936
2065
|
_initRefRange() {
|
|
1937
2066
|
const a = this._dataValidationModel.getAll();
|
|
1938
2067
|
for (const [e, t] of a)
|
|
1939
2068
|
for (const [r, i] of t)
|
|
1940
|
-
for (const
|
|
1941
|
-
this.registerRule(e, r,
|
|
2069
|
+
for (const o of i)
|
|
2070
|
+
this.registerRule(e, r, o);
|
|
1942
2071
|
this.disposeWithMe(
|
|
1943
2072
|
this._dataValidationModel.ruleChange$.subscribe((e) => {
|
|
1944
2073
|
const { unitId: t, subUnitId: r, rule: i } = e;
|
|
1945
2074
|
switch (e.type) {
|
|
1946
2075
|
case "add": {
|
|
1947
|
-
const
|
|
1948
|
-
this.registerRule(e.unitId, e.subUnitId,
|
|
2076
|
+
const o = e.rule;
|
|
2077
|
+
this.registerRule(e.unitId, e.subUnitId, o);
|
|
1949
2078
|
break;
|
|
1950
2079
|
}
|
|
1951
2080
|
case "remove": {
|
|
1952
|
-
const
|
|
1953
|
-
|
|
2081
|
+
const o = this._disposableMap.get(this._getIdWithUnitId(t, r, i.uid));
|
|
2082
|
+
o && o.forEach((n) => n());
|
|
1954
2083
|
break;
|
|
1955
2084
|
}
|
|
1956
2085
|
case "update": {
|
|
1957
|
-
const
|
|
1958
|
-
n && n.forEach((l) => l()), this.registerRule(e.unitId, e.subUnitId,
|
|
2086
|
+
const o = e.rule, n = this._disposableMap.get(this._getIdWithUnitId(t, r, o.uid));
|
|
2087
|
+
n && n.forEach((l) => l()), this.registerRule(e.unitId, e.subUnitId, o);
|
|
1959
2088
|
break;
|
|
1960
2089
|
}
|
|
1961
2090
|
}
|
|
1962
2091
|
})
|
|
1963
|
-
), this.disposeWithMe(
|
|
2092
|
+
), this.disposeWithMe(Ke(() => {
|
|
1964
2093
|
this._disposableMap.forEach((e) => {
|
|
1965
2094
|
e.forEach((t) => t());
|
|
1966
2095
|
}), this._disposableMap.clear();
|
|
1967
2096
|
}));
|
|
1968
2097
|
}
|
|
1969
2098
|
};
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
],
|
|
1978
|
-
var
|
|
1979
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
1980
|
-
(
|
|
2099
|
+
we = Ia([
|
|
2100
|
+
te(0, v(F)),
|
|
2101
|
+
te(1, v(be)),
|
|
2102
|
+
te(2, v(Qt)),
|
|
2103
|
+
te(3, v(G)),
|
|
2104
|
+
te(4, v(pt)),
|
|
2105
|
+
te(5, v(q))
|
|
2106
|
+
], we);
|
|
2107
|
+
var Da = Object.getOwnPropertyDescriptor, ba = (s, a, e, t) => {
|
|
2108
|
+
for (var r = t > 1 ? void 0 : t ? Da(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
2109
|
+
(o = s[i]) && (r = o(r) || r);
|
|
1981
2110
|
return r;
|
|
1982
|
-
},
|
|
1983
|
-
let
|
|
1984
|
-
constructor(
|
|
1985
|
-
super(), this._sheetInterceptorService =
|
|
2111
|
+
}, Ge = (s, a) => (e, t) => a(e, t, s);
|
|
2112
|
+
let Oe = class extends B {
|
|
2113
|
+
constructor(s, a, e) {
|
|
2114
|
+
super(), this._sheetInterceptorService = s, this._univerInstanceService = a, this._sheetDataValidationModel = e, this._initSheetChange();
|
|
1986
2115
|
}
|
|
1987
2116
|
// eslint-disable-next-line max-lines-per-function
|
|
1988
2117
|
_initSheetChange() {
|
|
1989
2118
|
this.disposeWithMe(
|
|
1990
2119
|
this._sheetInterceptorService.interceptCommand({
|
|
1991
2120
|
// eslint-disable-next-line max-lines-per-function
|
|
1992
|
-
getMutations: (
|
|
2121
|
+
getMutations: (s) => {
|
|
1993
2122
|
var a;
|
|
1994
|
-
if (
|
|
1995
|
-
const e =
|
|
2123
|
+
if (s.id === qt.id) {
|
|
2124
|
+
const e = s.params, t = e.unitId || this._univerInstanceService.getCurrentUnitForType(N.UNIVER_SHEET).getUnitId(), r = this._univerInstanceService.getUniverSheetInstance(t);
|
|
1996
2125
|
if (!r)
|
|
1997
2126
|
return { redos: [], undos: [] };
|
|
1998
2127
|
const i = e.subUnitId || ((a = r.getActiveSheet()) == null ? void 0 : a.getSheetId());
|
|
1999
2128
|
if (!i)
|
|
2000
2129
|
return { redos: [], undos: [] };
|
|
2001
|
-
const
|
|
2002
|
-
if (
|
|
2130
|
+
const o = this._sheetDataValidationModel.getRules(t, i);
|
|
2131
|
+
if (o.length === 0)
|
|
2003
2132
|
return { redos: [], undos: [] };
|
|
2004
|
-
const n =
|
|
2133
|
+
const n = o.map((c) => c.uid), l = {
|
|
2005
2134
|
unitId: t,
|
|
2006
2135
|
subUnitId: i,
|
|
2007
2136
|
ruleId: n,
|
|
@@ -2009,31 +2138,31 @@ let Ce = class extends W {
|
|
|
2009
2138
|
}, u = {
|
|
2010
2139
|
unitId: t,
|
|
2011
2140
|
subUnitId: i,
|
|
2012
|
-
rule: [...
|
|
2141
|
+
rule: [...o],
|
|
2013
2142
|
source: "patched"
|
|
2014
2143
|
};
|
|
2015
2144
|
return {
|
|
2016
2145
|
redos: [{
|
|
2017
|
-
id:
|
|
2146
|
+
id: I.id,
|
|
2018
2147
|
params: l
|
|
2019
2148
|
}],
|
|
2020
2149
|
undos: [{
|
|
2021
|
-
id:
|
|
2150
|
+
id: b.id,
|
|
2022
2151
|
params: u
|
|
2023
2152
|
}]
|
|
2024
2153
|
};
|
|
2025
|
-
} else if (
|
|
2026
|
-
const e =
|
|
2154
|
+
} else if (s.id === Yt.id) {
|
|
2155
|
+
const e = s.params, { unitId: t, subUnitId: r, targetSubUnitId: i } = e;
|
|
2027
2156
|
if (!t || !r || !i)
|
|
2028
2157
|
return { redos: [], undos: [] };
|
|
2029
|
-
const
|
|
2030
|
-
if (
|
|
2158
|
+
const o = this._sheetDataValidationModel.getRules(t, r);
|
|
2159
|
+
if (o.length === 0)
|
|
2031
2160
|
return { redos: [], undos: [] };
|
|
2032
|
-
const n =
|
|
2161
|
+
const n = o.map((l) => ({ ...l, uid: Xe(6) }));
|
|
2033
2162
|
return {
|
|
2034
2163
|
redos: [
|
|
2035
2164
|
{
|
|
2036
|
-
id:
|
|
2165
|
+
id: b.id,
|
|
2037
2166
|
params: {
|
|
2038
2167
|
unitId: t,
|
|
2039
2168
|
subUnitId: i,
|
|
@@ -2044,7 +2173,7 @@ let Ce = class extends W {
|
|
|
2044
2173
|
],
|
|
2045
2174
|
undos: [
|
|
2046
2175
|
{
|
|
2047
|
-
id:
|
|
2176
|
+
id: I.id,
|
|
2048
2177
|
params: {
|
|
2049
2178
|
unitId: t,
|
|
2050
2179
|
subUnitId: i,
|
|
@@ -2061,15 +2190,15 @@ let Ce = class extends W {
|
|
|
2061
2190
|
);
|
|
2062
2191
|
}
|
|
2063
2192
|
};
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
],
|
|
2069
|
-
class
|
|
2193
|
+
Oe = ba([
|
|
2194
|
+
Ge(0, v(ht)),
|
|
2195
|
+
Ge(1, v(D)),
|
|
2196
|
+
Ge(2, v(F))
|
|
2197
|
+
], Oe);
|
|
2198
|
+
class La extends Y {
|
|
2070
2199
|
constructor() {
|
|
2071
2200
|
super(...arguments);
|
|
2072
|
-
m(this, "id",
|
|
2201
|
+
m(this, "id", C.ANY);
|
|
2073
2202
|
m(this, "title", "dataValidation.any.title");
|
|
2074
2203
|
m(this, "operators", []);
|
|
2075
2204
|
m(this, "scopes", ["sheet"]);
|
|
@@ -2095,20 +2224,20 @@ class Ia extends G {
|
|
|
2095
2224
|
return this.localeService.t("dataValidation.any.error");
|
|
2096
2225
|
}
|
|
2097
2226
|
}
|
|
2098
|
-
class
|
|
2227
|
+
class Ua extends Y {
|
|
2099
2228
|
constructor() {
|
|
2100
2229
|
super(...arguments);
|
|
2101
|
-
m(this, "id",
|
|
2230
|
+
m(this, "id", C.CUSTOM);
|
|
2102
2231
|
m(this, "title", "dataValidation.custom.title");
|
|
2103
2232
|
m(this, "operators", []);
|
|
2104
2233
|
m(this, "scopes", ["sheet"]);
|
|
2105
2234
|
m(this, "order", 60);
|
|
2106
|
-
m(this, "_customFormulaService", this.injector.get(
|
|
2107
|
-
m(this, "_lexerTreeBuilder", this.injector.get(
|
|
2235
|
+
m(this, "_customFormulaService", this.injector.get(W));
|
|
2236
|
+
m(this, "_lexerTreeBuilder", this.injector.get(X));
|
|
2108
2237
|
}
|
|
2109
2238
|
validatorFormula(e, t, r) {
|
|
2110
2239
|
var u;
|
|
2111
|
-
const i = S(e.formula1),
|
|
2240
|
+
const i = S(e.formula1), o = (u = e.formula1) != null ? u : "", l = this._lexerTreeBuilder.checkIfAddBracket(o) === 0 && o.startsWith(kt.EQUALS);
|
|
2112
2241
|
return {
|
|
2113
2242
|
success: i && l,
|
|
2114
2243
|
formula1: i && l ? "" : this.localeService.t("dataValidation.validFail.formula")
|
|
@@ -2122,8 +2251,8 @@ class Aa extends G {
|
|
|
2122
2251
|
};
|
|
2123
2252
|
}
|
|
2124
2253
|
async isValidType(e, t, r) {
|
|
2125
|
-
const { column: i, row:
|
|
2126
|
-
return
|
|
2254
|
+
const { column: i, row: o, unitId: n, subUnitId: l } = e, u = await this._customFormulaService.getCellFormulaValue(n, l, r.uid, o, i), c = u == null ? void 0 : u.v;
|
|
2255
|
+
return T(String(c)) && M.isDefine(c) && c !== "" ? u.t === Ft.BOOLEAN ? !!c : typeof c == "boolean" ? c : typeof c == "number" ? !!c : typeof c == "string" ? T(c) : !!c : !1;
|
|
2127
2256
|
}
|
|
2128
2257
|
generateRuleErrorMessage(e) {
|
|
2129
2258
|
return this.localeService.t("dataValidation.custom.error");
|
|
@@ -2133,21 +2262,21 @@ class Aa extends G {
|
|
|
2133
2262
|
return this.localeService.t("dataValidation.custom.ruleName").replace("{FORMULA1}", (t = e.formula1) != null ? t : "");
|
|
2134
2263
|
}
|
|
2135
2264
|
}
|
|
2136
|
-
class
|
|
2265
|
+
class Ba extends _t {
|
|
2137
2266
|
constructor() {
|
|
2138
2267
|
super(...arguments);
|
|
2139
|
-
m(this, "id",
|
|
2268
|
+
m(this, "id", C.LIST_MULTIPLE);
|
|
2140
2269
|
m(this, "title", "dataValidation.listMultiple.title");
|
|
2141
2270
|
m(this, "offsetFormulaByRange", !1);
|
|
2142
2271
|
m(this, "skipDefaultFontRender", () => !0);
|
|
2143
2272
|
}
|
|
2144
2273
|
}
|
|
2145
|
-
class
|
|
2274
|
+
class xa extends Y {
|
|
2146
2275
|
constructor() {
|
|
2147
2276
|
super(...arguments);
|
|
2148
|
-
m(this, "_customFormulaService", this.injector.get(
|
|
2149
|
-
m(this, "_lexerTreeBuilder", this.injector.get(
|
|
2150
|
-
m(this, "id",
|
|
2277
|
+
m(this, "_customFormulaService", this.injector.get(W));
|
|
2278
|
+
m(this, "_lexerTreeBuilder", this.injector.get(X));
|
|
2279
|
+
m(this, "id", C.WHOLE);
|
|
2151
2280
|
m(this, "title", "dataValidation.whole.title");
|
|
2152
2281
|
m(this, "order", 10);
|
|
2153
2282
|
m(this, "operators", [
|
|
@@ -2163,26 +2292,26 @@ class ba extends G {
|
|
|
2163
2292
|
m(this, "scopes", ["sheet"]);
|
|
2164
2293
|
}
|
|
2165
2294
|
_isFormulaOrInt(e) {
|
|
2166
|
-
return !
|
|
2295
|
+
return !M.isBlank(e) && (S(e) || !Number.isNaN(+e) && Number.isInteger(+e));
|
|
2167
2296
|
}
|
|
2168
2297
|
async isValidType(e, t, r) {
|
|
2169
|
-
const { value: i } = e,
|
|
2170
|
-
return !Number.isNaN(
|
|
2298
|
+
const { value: i } = e, o = Te(i);
|
|
2299
|
+
return !Number.isNaN(o) && Number.isInteger(o);
|
|
2171
2300
|
}
|
|
2172
2301
|
transform(e, t, r) {
|
|
2173
2302
|
const { value: i } = e;
|
|
2174
2303
|
return {
|
|
2175
2304
|
...e,
|
|
2176
|
-
value:
|
|
2305
|
+
value: Te(i)
|
|
2177
2306
|
};
|
|
2178
2307
|
}
|
|
2179
2308
|
_parseNumber(e) {
|
|
2180
2309
|
return e == null ? Number.NaN : +e;
|
|
2181
2310
|
}
|
|
2182
|
-
async parseFormula(e, t, r, i,
|
|
2183
|
-
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i,
|
|
2311
|
+
async parseFormula(e, t, r, i, o) {
|
|
2312
|
+
const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i, o), l = await this._customFormulaService.getCellFormula2Value(t, r, e.uid, i, o), { formula1: u, formula2: c } = e, d = S(u) ? n == null ? void 0 : n.v : u, g = S(c) ? l == null ? void 0 : l.v : c, f = T(`${d}`) && T(`${g}`);
|
|
2184
2313
|
return {
|
|
2185
|
-
formula1: this._parseNumber(
|
|
2314
|
+
formula1: this._parseNumber(d),
|
|
2186
2315
|
formula2: this._parseNumber(g),
|
|
2187
2316
|
isFormulaValid: f
|
|
2188
2317
|
};
|
|
@@ -2193,64 +2322,64 @@ class ba extends G {
|
|
|
2193
2322
|
return {
|
|
2194
2323
|
success: !0
|
|
2195
2324
|
};
|
|
2196
|
-
const
|
|
2325
|
+
const o = M.isDefine(e.formula1) && this._isFormulaOrInt(e.formula1), n = M.isDefine(e.formula2) && this._isFormulaOrInt(e.formula2), l = Be.includes(i), u = this.localeService.t("dataValidation.validFail.number");
|
|
2197
2326
|
return l ? {
|
|
2198
|
-
success:
|
|
2199
|
-
formula1:
|
|
2327
|
+
success: o && n,
|
|
2328
|
+
formula1: o ? void 0 : u,
|
|
2200
2329
|
formula2: n ? void 0 : u
|
|
2201
2330
|
} : {
|
|
2202
|
-
success:
|
|
2331
|
+
success: o,
|
|
2203
2332
|
formula1: u
|
|
2204
2333
|
};
|
|
2205
2334
|
}
|
|
2206
2335
|
generateRuleErrorMessage(e, t) {
|
|
2207
2336
|
if (!e.operator)
|
|
2208
|
-
return this.localeService.t(
|
|
2209
|
-
const { transformedFormula1: r, transformedFormula2: i } =
|
|
2210
|
-
return `${this.localeService.t(
|
|
2337
|
+
return this.localeService.t(Ce.NONE).replace("{TYPE}", this.titleStr);
|
|
2338
|
+
const { transformedFormula1: r, transformedFormula2: i } = Ue(this._lexerTreeBuilder, e, t);
|
|
2339
|
+
return `${this.localeService.t(Ce[e.operator]).replace(ue, r != null ? r : "").replace(ce, i != null ? i : "")}`;
|
|
2211
2340
|
}
|
|
2212
2341
|
}
|
|
2213
|
-
var
|
|
2214
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
2215
|
-
(
|
|
2342
|
+
var Pa = Object.getOwnPropertyDescriptor, Ha = (s, a, e, t) => {
|
|
2343
|
+
for (var r = t > 1 ? void 0 : t ? Pa(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
2344
|
+
(o = s[i]) && (r = o(r) || r);
|
|
2216
2345
|
return r;
|
|
2217
|
-
},
|
|
2218
|
-
let
|
|
2219
|
-
constructor(
|
|
2220
|
-
super(), this._univerInstanceService =
|
|
2346
|
+
}, ae = (s, a) => (e, t) => a(e, t, s);
|
|
2347
|
+
let Ae = class extends Nt {
|
|
2348
|
+
constructor(s, a, e, t, r, i) {
|
|
2349
|
+
super(), this._univerInstanceService = s, this._dataValidatorRegistryService = a, this._injector = e, this._selectionManagerService = t, this._sheetInterceptorService = r, this._sheetDataValidationModel = i, this._init();
|
|
2221
2350
|
}
|
|
2222
2351
|
_init() {
|
|
2223
2352
|
this._registerValidators(), this._initCommandInterceptor();
|
|
2224
2353
|
}
|
|
2225
2354
|
_registerValidators() {
|
|
2226
2355
|
[
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2356
|
+
La,
|
|
2357
|
+
da,
|
|
2358
|
+
xa,
|
|
2359
|
+
fa,
|
|
2360
|
+
ca,
|
|
2231
2361
|
na,
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
this.disposeWithMe(this._dataValidatorRegistryService.register(a)), this.disposeWithMe(Xe(() => this._injector.delete(o)));
|
|
2362
|
+
_t,
|
|
2363
|
+
Ba,
|
|
2364
|
+
Ua
|
|
2365
|
+
].forEach((s) => {
|
|
2366
|
+
const a = this._injector.createInstance(s);
|
|
2367
|
+
this.disposeWithMe(this._dataValidatorRegistryService.register(a)), this.disposeWithMe(Ke(() => this._injector.delete(s)));
|
|
2239
2368
|
});
|
|
2240
2369
|
}
|
|
2241
2370
|
_initCommandInterceptor() {
|
|
2242
2371
|
this._sheetInterceptorService.interceptCommand({
|
|
2243
|
-
getMutations: (
|
|
2372
|
+
getMutations: (s) => {
|
|
2244
2373
|
var a;
|
|
2245
|
-
if (
|
|
2374
|
+
if (s.id === Xt.id) {
|
|
2246
2375
|
const e = this._univerInstanceService.getCurrentUnitForType(N.UNIVER_SHEET), t = e.getUnitId(), r = e.getActiveSheet();
|
|
2247
2376
|
if (!r)
|
|
2248
2377
|
throw new Error("No active sheet found");
|
|
2249
|
-
const i = r.getSheetId(),
|
|
2250
|
-
|
|
2251
|
-
const l = n.diff(this._sheetDataValidationModel.getRules(t, i)), { redoMutations: u, undoMutations:
|
|
2378
|
+
const i = r.getSheetId(), o = (a = this._selectionManagerService.getCurrentSelections()) == null ? void 0 : a.map((d) => d.range), n = this._sheetDataValidationModel.getRuleObjectMatrix(t, i).clone();
|
|
2379
|
+
o && n.removeRange(o);
|
|
2380
|
+
const l = n.diff(this._sheetDataValidationModel.getRules(t, i)), { redoMutations: u, undoMutations: c } = xe(t, i, l, this._injector, "patched");
|
|
2252
2381
|
return {
|
|
2253
|
-
undos:
|
|
2382
|
+
undos: c,
|
|
2254
2383
|
redos: u
|
|
2255
2384
|
};
|
|
2256
2385
|
}
|
|
@@ -2262,226 +2391,245 @@ let Oe = class extends Nt {
|
|
|
2262
2391
|
});
|
|
2263
2392
|
}
|
|
2264
2393
|
};
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
],
|
|
2273
|
-
var
|
|
2274
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
2275
|
-
(
|
|
2394
|
+
Ae = Ha([
|
|
2395
|
+
ae(0, D),
|
|
2396
|
+
ae(1, v(q)),
|
|
2397
|
+
ae(2, v(be)),
|
|
2398
|
+
ae(3, v(mt)),
|
|
2399
|
+
ae(4, v(ht)),
|
|
2400
|
+
ae(5, v(F))
|
|
2401
|
+
], Ae);
|
|
2402
|
+
var Wa = Object.getOwnPropertyDescriptor, $a = (s, a, e, t) => {
|
|
2403
|
+
for (var r = t > 1 ? void 0 : t ? Wa(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
2404
|
+
(o = s[i]) && (r = o(r) || r);
|
|
2276
2405
|
return r;
|
|
2277
|
-
}, Re = (
|
|
2278
|
-
let
|
|
2279
|
-
constructor(
|
|
2280
|
-
super(), this._univerInstanceService =
|
|
2406
|
+
}, Re = (s, a) => (e, t) => a(e, t, s);
|
|
2407
|
+
let Ie = class extends B {
|
|
2408
|
+
constructor(s, a, e, t) {
|
|
2409
|
+
super(), this._univerInstanceService = s, this._sheetDataValidationModel = a, this._dataValidationCacheService = e, this._lifecycleService = t, this._initRecalculate();
|
|
2281
2410
|
}
|
|
2282
2411
|
_initRecalculate() {
|
|
2283
|
-
const
|
|
2412
|
+
const s = (a) => {
|
|
2284
2413
|
if (a.length === 0)
|
|
2285
2414
|
return;
|
|
2286
2415
|
const e = this._univerInstanceService.getCurrentUnitForType(N.UNIVER_SHEET), t = e == null ? void 0 : e.getActiveSheet(), r = {};
|
|
2287
2416
|
a.flat().forEach((i) => {
|
|
2288
2417
|
r[i.unitId] || (r[i.unitId] = {}), r[i.unitId][i.subUnitId] || (r[i.unitId][i.subUnitId] = []);
|
|
2289
|
-
const
|
|
2290
|
-
n && r[i.unitId][i.subUnitId].push(...i.ranges.map((l) =>
|
|
2291
|
-
}), Object.entries(r).forEach(([i,
|
|
2292
|
-
Object.entries(
|
|
2418
|
+
const o = this._univerInstanceService.getUnit(i.unitId, N.UNIVER_SHEET), n = o == null ? void 0 : o.getSheetBySheetId(i.subUnitId);
|
|
2419
|
+
n && r[i.unitId][i.subUnitId].push(...i.ranges.map((l) => H.transformRange(l, n)));
|
|
2420
|
+
}), Object.entries(r).forEach(([i, o]) => {
|
|
2421
|
+
Object.entries(o).forEach(([n, l]) => {
|
|
2293
2422
|
(e == null ? void 0 : e.getUnitId()) === i && (t == null ? void 0 : t.getSheetId()) === n ? this.validatorRanges(i, n, l) : requestIdleCallback(() => {
|
|
2294
2423
|
this.validatorRanges(i, n, l);
|
|
2295
2424
|
});
|
|
2296
2425
|
});
|
|
2297
2426
|
});
|
|
2298
2427
|
};
|
|
2299
|
-
this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(
|
|
2428
|
+
this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(Kt(() => this._lifecycleService.lifecycle$.pipe(tt((a) => a === et.Rendered)))).subscribe(s)), this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(tt(() => this._lifecycleService.stage >= et.Rendered), Ot(20)).subscribe(s));
|
|
2300
2429
|
}
|
|
2301
|
-
async _validatorByCell(
|
|
2302
|
-
const r =
|
|
2303
|
-
if (!
|
|
2430
|
+
async _validatorByCell(s, a, e, t) {
|
|
2431
|
+
const r = s.getUnitId(), i = a.getSheetId();
|
|
2432
|
+
if (!M.isDefine(e) || !M.isDefine(t))
|
|
2304
2433
|
throw new Error(`row or col is not defined, row: ${e}, col: ${t}`);
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2434
|
+
let o = e, n = t;
|
|
2435
|
+
const l = a.getMergedCell(e, t);
|
|
2436
|
+
l && (o = l.startRow, n = l.startColumn);
|
|
2437
|
+
const u = this._sheetDataValidationModel.getRuleByLocation(r, i, o, n);
|
|
2438
|
+
return u ? new Promise((c) => {
|
|
2439
|
+
this._sheetDataValidationModel.validator(u, { unitId: r, subUnitId: i, row: o, col: n, worksheet: a, workbook: s }, (d) => {
|
|
2440
|
+
c(d);
|
|
2309
2441
|
});
|
|
2310
|
-
}) :
|
|
2442
|
+
}) : A.VALID;
|
|
2311
2443
|
}
|
|
2312
|
-
async validatorCell(
|
|
2313
|
-
const r = this._univerInstanceService.getUnit(
|
|
2444
|
+
async validatorCell(s, a, e, t) {
|
|
2445
|
+
const r = this._univerInstanceService.getUnit(s, N.UNIVER_SHEET);
|
|
2314
2446
|
if (!r)
|
|
2315
|
-
throw new Error(`cannot find current workbook, unitId: ${
|
|
2447
|
+
throw new Error(`cannot find current workbook, unitId: ${s}`);
|
|
2316
2448
|
const i = r.getSheetBySheetId(a);
|
|
2317
2449
|
if (!i)
|
|
2318
2450
|
throw new Error(`cannot find current worksheet, sheetId: ${a}`);
|
|
2319
2451
|
return this._validatorByCell(r, i, e, t);
|
|
2320
2452
|
}
|
|
2321
|
-
validatorRanges(
|
|
2453
|
+
async validatorRanges(s, a, e) {
|
|
2322
2454
|
if (!e.length)
|
|
2323
2455
|
return Promise.resolve([]);
|
|
2324
|
-
const t = this._univerInstanceService.getUnit(
|
|
2456
|
+
const t = this._univerInstanceService.getUnit(s, N.UNIVER_SHEET);
|
|
2325
2457
|
if (!t)
|
|
2326
|
-
throw new Error(`cannot find current workbook, unitId: ${
|
|
2458
|
+
throw new Error(`cannot find current workbook, unitId: ${s}`);
|
|
2327
2459
|
const r = t.getSheetBySheetId(a);
|
|
2328
2460
|
if (!r)
|
|
2329
2461
|
throw new Error(`cannot find current worksheet, sheetId: ${a}`);
|
|
2330
|
-
const
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2462
|
+
const o = this._sheetDataValidationModel.getRules(s, a).map((c) => c.ranges).flat(), n = e.map((c) => o.map((d) => ot(c, d))).flat().filter(Boolean), l = [], u = await Promise.all(
|
|
2463
|
+
n.map((c, d) => {
|
|
2464
|
+
const g = [];
|
|
2465
|
+
for (let f = c.startRow; f <= c.endRow; f++)
|
|
2466
|
+
for (let p = c.startColumn; p <= c.endColumn; p++) {
|
|
2467
|
+
g.push(this._validatorByCell(t, r, f, p));
|
|
2468
|
+
const R = r.getMergedCell(f, p);
|
|
2469
|
+
R && l.push({
|
|
2470
|
+
resultRowIndex: d,
|
|
2471
|
+
resultColIndex: g.length - 1,
|
|
2472
|
+
row: R.startRow,
|
|
2473
|
+
col: R.startColumn
|
|
2474
|
+
});
|
|
2475
|
+
}
|
|
2476
|
+
return Promise.all(g);
|
|
2477
|
+
})
|
|
2478
|
+
);
|
|
2479
|
+
return l.length && l.forEach(({ resultRowIndex: c, resultColIndex: d, row: g, col: f }) => {
|
|
2480
|
+
var p;
|
|
2481
|
+
u[c][d] === A.VALIDATING && (u[c][d] = (p = this._dataValidationCacheService.getValue(s, a, g, f)) != null ? p : A.VALID);
|
|
2482
|
+
}), u;
|
|
2337
2483
|
}
|
|
2338
|
-
async validatorWorksheet(
|
|
2339
|
-
const e = this._univerInstanceService.getUnit(
|
|
2484
|
+
async validatorWorksheet(s, a) {
|
|
2485
|
+
const e = this._univerInstanceService.getUnit(s, N.UNIVER_SHEET);
|
|
2340
2486
|
if (!e)
|
|
2341
|
-
throw new Error(`cannot find current workbook, unitId: ${
|
|
2487
|
+
throw new Error(`cannot find current workbook, unitId: ${s}`);
|
|
2342
2488
|
const t = e.getSheetBySheetId(a);
|
|
2343
2489
|
if (!t)
|
|
2344
2490
|
throw new Error(`cannot find current worksheet, sheetId: ${a}`);
|
|
2345
|
-
const r = this._sheetDataValidationModel.getRules(
|
|
2491
|
+
const r = this._sheetDataValidationModel.getRules(s, a);
|
|
2346
2492
|
return await Promise.all(
|
|
2347
2493
|
r.map((i) => Promise.all(
|
|
2348
|
-
i.ranges.map((
|
|
2494
|
+
i.ranges.map((o) => {
|
|
2349
2495
|
const n = [];
|
|
2350
|
-
return
|
|
2496
|
+
return H.foreach(o, (l, u) => {
|
|
2351
2497
|
n.push(this._validatorByCell(e, t, l, u));
|
|
2352
2498
|
}), Promise.all(n);
|
|
2353
2499
|
})
|
|
2354
2500
|
))
|
|
2355
|
-
), this._dataValidationCacheService.ensureCache(
|
|
2501
|
+
), this._dataValidationCacheService.ensureCache(s, a);
|
|
2356
2502
|
}
|
|
2357
|
-
async validatorWorkbook(
|
|
2358
|
-
const a = this._sheetDataValidationModel.getSubUnitIds(
|
|
2503
|
+
async validatorWorkbook(s) {
|
|
2504
|
+
const a = this._sheetDataValidationModel.getSubUnitIds(s), e = await Promise.all(a.map((r) => this.validatorWorksheet(s, r))), t = {};
|
|
2359
2505
|
return e.forEach((r, i) => {
|
|
2360
2506
|
t[a[i]] = r;
|
|
2361
2507
|
}), t;
|
|
2362
2508
|
}
|
|
2363
|
-
getDataValidations(
|
|
2364
|
-
const t = this._sheetDataValidationModel.getRuleObjectMatrix(
|
|
2365
|
-
return e.forEach((
|
|
2366
|
-
|
|
2509
|
+
getDataValidations(s, a, e) {
|
|
2510
|
+
const t = this._sheetDataValidationModel.getRuleObjectMatrix(s, a), r = /* @__PURE__ */ new Set();
|
|
2511
|
+
return e.forEach((o) => {
|
|
2512
|
+
H.foreach(o, (n, l) => {
|
|
2367
2513
|
const u = t.getValue(n, l);
|
|
2368
2514
|
u && r.add(u);
|
|
2369
2515
|
});
|
|
2370
|
-
}), Array.from(r).map((
|
|
2516
|
+
}), Array.from(r).map((o) => this._sheetDataValidationModel.getRuleById(s, a, o)).filter(Boolean);
|
|
2371
2517
|
}
|
|
2372
|
-
getDataValidation(
|
|
2373
|
-
return this.getDataValidations(
|
|
2518
|
+
getDataValidation(s, a, e) {
|
|
2519
|
+
return this.getDataValidations(s, a, e)[0];
|
|
2374
2520
|
}
|
|
2375
2521
|
};
|
|
2376
|
-
|
|
2377
|
-
Re(0,
|
|
2522
|
+
Ie = $a([
|
|
2523
|
+
Re(0, D),
|
|
2378
2524
|
Re(1, v(F)),
|
|
2379
2525
|
Re(2, v(Q)),
|
|
2380
|
-
Re(3, v(
|
|
2381
|
-
],
|
|
2382
|
-
var
|
|
2383
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
2384
|
-
(
|
|
2526
|
+
Re(3, v(wt))
|
|
2527
|
+
], Ie);
|
|
2528
|
+
var ka = Object.defineProperty, ja = Object.getOwnPropertyDescriptor, Qa = (s, a, e) => a in s ? ka(s, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[a] = e, Ga = (s, a, e, t) => {
|
|
2529
|
+
for (var r = t > 1 ? void 0 : t ? ja(a, e) : a, i = s.length - 1, o; i >= 0; i--)
|
|
2530
|
+
(o = s[i]) && (r = o(r) || r);
|
|
2385
2531
|
return r;
|
|
2386
|
-
}, qe = (
|
|
2387
|
-
let
|
|
2388
|
-
constructor(
|
|
2389
|
-
super(), this._config =
|
|
2390
|
-
const { ...r } =
|
|
2532
|
+
}, qe = (s, a) => (e, t) => a(e, t, s), St = (s, a, e) => Qa(s, typeof a != "symbol" ? a + "" : a, e);
|
|
2533
|
+
let De = class extends Dt {
|
|
2534
|
+
constructor(s = st, a, e, t) {
|
|
2535
|
+
super(), this._config = s, this._injector = a, this._commandService = e, this._configService = t;
|
|
2536
|
+
const { ...r } = bt(
|
|
2391
2537
|
{},
|
|
2392
|
-
|
|
2538
|
+
st,
|
|
2393
2539
|
this._config
|
|
2394
2540
|
);
|
|
2395
|
-
this._configService.setConfig(
|
|
2541
|
+
this._configService.setConfig(Na, r);
|
|
2396
2542
|
}
|
|
2397
2543
|
onStarting() {
|
|
2398
2544
|
[
|
|
2399
2545
|
[Q],
|
|
2400
|
-
[
|
|
2401
|
-
[
|
|
2402
|
-
[
|
|
2546
|
+
[le],
|
|
2547
|
+
[G],
|
|
2548
|
+
[W],
|
|
2549
|
+
[Ie],
|
|
2403
2550
|
[F],
|
|
2551
|
+
[Ae],
|
|
2552
|
+
[Fe],
|
|
2404
2553
|
[Oe],
|
|
2405
|
-
[
|
|
2406
|
-
[
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
].forEach((o) => {
|
|
2410
|
-
this._injector.add(o);
|
|
2554
|
+
[we],
|
|
2555
|
+
[Ne]
|
|
2556
|
+
].forEach((s) => {
|
|
2557
|
+
this._injector.add(s);
|
|
2411
2558
|
}), [
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
pa,
|
|
2415
|
-
fa,
|
|
2416
|
-
Sa,
|
|
2559
|
+
va,
|
|
2560
|
+
_a,
|
|
2417
2561
|
Ra,
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2562
|
+
Sa,
|
|
2563
|
+
ya,
|
|
2564
|
+
Ma,
|
|
2565
|
+
Ea
|
|
2566
|
+
].forEach((s) => {
|
|
2567
|
+
this._commandService.registerCommand(s);
|
|
2568
|
+
}), this._injector.get(Q), this._injector.get(Ie), this._injector.get(Ae), this._injector.get(Ne), this._injector.get(we);
|
|
2422
2569
|
}
|
|
2423
2570
|
onReady() {
|
|
2424
|
-
this._injector.get(
|
|
2571
|
+
this._injector.get(Oe);
|
|
2425
2572
|
}
|
|
2426
2573
|
onRendered() {
|
|
2427
|
-
this._injector.get(
|
|
2574
|
+
this._injector.get(Fe);
|
|
2428
2575
|
}
|
|
2429
2576
|
};
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
qe(1, v(
|
|
2577
|
+
St(De, "pluginName", Ca);
|
|
2578
|
+
St(De, "type", N.UNIVER_SHEET);
|
|
2579
|
+
De = Ga([
|
|
2580
|
+
At(xt),
|
|
2581
|
+
qe(1, v(be)),
|
|
2435
2582
|
qe(2, U),
|
|
2436
2583
|
qe(3, It)
|
|
2437
|
-
],
|
|
2438
|
-
function
|
|
2439
|
-
const e =
|
|
2584
|
+
], De);
|
|
2585
|
+
function ar(s) {
|
|
2586
|
+
const e = s.get(mt).getCurrentSelections().map((i) => i.range);
|
|
2440
2587
|
return {
|
|
2441
|
-
uid:
|
|
2442
|
-
type:
|
|
2588
|
+
uid: Xe(6),
|
|
2589
|
+
type: C.DECIMAL,
|
|
2443
2590
|
operator: h.EQUAL,
|
|
2444
2591
|
formula1: "100",
|
|
2445
2592
|
ranges: e != null ? e : [{ startColumn: 0, endColumn: 0, startRow: 0, endRow: 0 }]
|
|
2446
2593
|
};
|
|
2447
2594
|
}
|
|
2448
|
-
const
|
|
2595
|
+
const rr = "data-validation.custom-formula-input", ir = "data-validation.formula-input", sr = "data-validation.list-formula-input", or = "data-validation.checkbox-formula-input";
|
|
2449
2596
|
export {
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2597
|
+
va as AddSheetDataValidationCommand,
|
|
2598
|
+
ir as BASE_FORMULA_INPUT_NAME,
|
|
2599
|
+
Ve as CHECKBOX_FORMULA_1,
|
|
2600
|
+
ye as CHECKBOX_FORMULA_2,
|
|
2601
|
+
or as CHECKBOX_FORMULA_INPUT_NAME,
|
|
2602
|
+
rr as CUSTOM_FORMULA_INPUT_NAME,
|
|
2603
|
+
na as CheckboxValidator,
|
|
2604
|
+
Ea as ClearRangeDataValidationCommand,
|
|
2605
|
+
Ca as DATA_VALIDATION_PLUGIN_NAME,
|
|
2459
2606
|
Q as DataValidationCacheService,
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2607
|
+
W as DataValidationCustomFormulaService,
|
|
2608
|
+
Fe as DataValidationFormulaController,
|
|
2609
|
+
G as DataValidationFormulaService,
|
|
2610
|
+
le as DataValidationListCacheService,
|
|
2611
|
+
ca as DateValidator,
|
|
2612
|
+
sr as LIST_FORMULA_INPUT_NAME,
|
|
2613
|
+
Ba as ListMultipleValidator,
|
|
2614
|
+
_t as ListValidator,
|
|
2615
|
+
Ma as RemoveSheetAllDataValidationCommand,
|
|
2616
|
+
ya as RemoveSheetDataValidationCommand,
|
|
2469
2617
|
F as SheetDataValidationModel,
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2618
|
+
Ie as SheetsDataValidationValidatorService,
|
|
2619
|
+
De as UniverSheetsDataValidationPlugin,
|
|
2620
|
+
Sa as UpdateSheetDataValidationOptionsCommand,
|
|
2621
|
+
_a as UpdateSheetDataValidationRangeCommand,
|
|
2622
|
+
Ra as UpdateSheetDataValidationSettingCommand,
|
|
2623
|
+
ar as createDefaultNewRule,
|
|
2624
|
+
Ee as deserializeListOptions,
|
|
2625
|
+
Te as getCellValueNumber,
|
|
2626
|
+
re as getCellValueOrigin,
|
|
2627
|
+
tr as getDataValidationCellValue,
|
|
2628
|
+
xe as getDataValidationDiffMutations,
|
|
2629
|
+
_e as getFormulaCellData,
|
|
2482
2630
|
oe as getFormulaResult,
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2631
|
+
Ue as getTransformedFormula,
|
|
2632
|
+
T as isLegalFormulaResult,
|
|
2633
|
+
er as serializeListOptions,
|
|
2634
|
+
ve as transformCheckboxValue
|
|
2487
2635
|
};
|