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