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