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