@univerjs/sheets-data-validation 0.6.10 → 0.7.0-beta.1
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 +93 -94
- package/lib/index.js +93 -94
- package/lib/umd/index.js +1 -1
- package/package.json +9 -10
package/lib/es/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var vt = Object.defineProperty;
|
|
2
2
|
var Rt = (o, a, e) => a in o ? vt(o, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[a] = e;
|
|
3
3
|
var m = (o, a, e) => Rt(o, typeof a != "symbol" ? a + "" : a, e);
|
|
4
|
-
import { Inject as R, ICommandService as U, IUniverInstanceService as O, Disposable as
|
|
4
|
+
import { Inject as R, ICommandService as U, IUniverInstanceService as O, Disposable as W, ObjectMatrix as Se, UniverInstanceType as N, Range as b, Rectangle as A, isFormulaString as S, DataValidationType as T, getOriginCellValue as St, RBush as Vt, debounce as Mt, Tools as V, DataValidationStatus as D, WrapStrategy as Re, DataValidationOperator as h, numfmt as H, dayjs as it, DataValidationRenderMode as xe, CommandType as z, IUndoRedoService as Z, sequenceExecute as Ie, isRangesEqual as ot, generateRandomId as yt, toDisposable as qe, IPermissionService as Et, Injector as Ge, CellValueType as Tt, RxDisposable as Ft, LifecycleService as Nt, LifecycleStages as Ze, bufferDebounceTime as Ct, DependentOn as Ot, IConfigService as wt, Plugin as At, merge as It } from "@univerjs/core";
|
|
5
5
|
import { DataValidationModel as Ye, DataValidatorRegistryService as q, UpdateRuleType as y, BaseDataValidator as G, TextLengthErrorTitleMap as Dt, AddDataValidationMutation as L, RemoveDataValidationMutation as I, UpdateDataValidationMutation as E, getRuleSetting as bt, getRuleOptions as Lt, UniverDataValidationPlugin as Ut } from "@univerjs/data-validation";
|
|
6
|
-
import { SetRangeValuesMutation as se, RemoveSheetMutation as st, getSheetCommandTarget as Xe, SetRangeValuesUndoMutationFactory as nt, WorksheetViewPermission as
|
|
6
|
+
import { SetRangeValuesMutation as se, RemoveSheetMutation as st, getSheetCommandTarget as Xe, SetRangeValuesUndoMutationFactory as nt, WorksheetViewPermission as Bt, RefRangeService as xt, handleCommonDefaultRangeChangeWithEffectRefCommands as Ht, SheetInterceptorService as lt, RemoveSheetCommand as Pt, SheetsSelectionsService as ut, ClearSelectionAllCommand as Wt } from "@univerjs/sheets";
|
|
7
7
|
import { Subject as Qe, bufferWhen as $t, filter as Je } from "rxjs";
|
|
8
8
|
import { RegisterOtherFormulaService as dt, FormulaRefRangeService as ct } from "@univerjs/sheets-formula";
|
|
9
9
|
import { ERROR_TYPE_SET as kt, LexerTreeBuilder as Y, isReferenceString as ht, sequenceNodeType as jt, deserializeRangeWithSheet as Qt, deserializeRangeWithSheetWithCache as qt, operatorToken as Gt } from "@univerjs/engine-formula";
|
|
@@ -13,7 +13,7 @@ var Xt = Object.getOwnPropertyDescriptor, Kt = (o, a, e, t) => {
|
|
|
13
13
|
(s = o[i]) && (r = s(r) || r);
|
|
14
14
|
return r;
|
|
15
15
|
}, et = (o, a) => (e, t) => a(e, t, o);
|
|
16
|
-
let Q = class extends
|
|
16
|
+
let Q = class extends W {
|
|
17
17
|
constructor(a, e) {
|
|
18
18
|
super();
|
|
19
19
|
m(this, "_cacheMatrix", /* @__PURE__ */ new Map());
|
|
@@ -104,7 +104,7 @@ var zt = Object.getOwnPropertyDescriptor, Zt = (o, a, e, t) => {
|
|
|
104
104
|
(s = o[i]) && (r = s(r) || r);
|
|
105
105
|
return r;
|
|
106
106
|
}, re = (o, a) => (e, t) => a(e, t, o);
|
|
107
|
-
let
|
|
107
|
+
let P = class extends W {
|
|
108
108
|
constructor(a, e, t, r, i) {
|
|
109
109
|
super();
|
|
110
110
|
/**
|
|
@@ -230,19 +230,19 @@ let H = class extends P {
|
|
|
230
230
|
r && this._registerOtherFormulaService.markFormulaDirty(a, e, r.formulaId), i && this._registerOtherFormulaService.markFormulaDirty(a, e, i.formulaId);
|
|
231
231
|
}
|
|
232
232
|
};
|
|
233
|
-
|
|
233
|
+
P = Zt([
|
|
234
234
|
re(0, O),
|
|
235
235
|
re(1, R(dt)),
|
|
236
236
|
re(2, R(Ye)),
|
|
237
237
|
re(3, R(Q)),
|
|
238
238
|
re(4, R(q))
|
|
239
|
-
],
|
|
239
|
+
], P);
|
|
240
240
|
var Jt = Object.getOwnPropertyDescriptor, ea = (o, a, e, t) => {
|
|
241
241
|
for (var r = t > 1 ? void 0 : t ? Jt(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
242
242
|
(s = o[i]) && (r = s(r) || r);
|
|
243
243
|
return r;
|
|
244
244
|
}, ie = (o, a) => (e, t) => a(e, t, o);
|
|
245
|
-
let K = class extends
|
|
245
|
+
let K = class extends W {
|
|
246
246
|
constructor(a, e, t, r, i) {
|
|
247
247
|
super();
|
|
248
248
|
m(this, "_formulaRuleMap", /* @__PURE__ */ new Map());
|
|
@@ -339,7 +339,7 @@ function mt(o) {
|
|
|
339
339
|
class Ke {
|
|
340
340
|
constructor(a, e, t, r, i = !1) {
|
|
341
341
|
m(this, "_map");
|
|
342
|
-
m(this, "_tree", new
|
|
342
|
+
m(this, "_tree", new Vt());
|
|
343
343
|
m(this, "_dirty", !0);
|
|
344
344
|
m(this, "_buildTree", () => {
|
|
345
345
|
if (!this._dirty || this._disableTree)
|
|
@@ -358,7 +358,7 @@ class Ke {
|
|
|
358
358
|
});
|
|
359
359
|
}), this._tree.load(a), this._dirty = !1;
|
|
360
360
|
});
|
|
361
|
-
m(this, "_debonceBuildTree",
|
|
361
|
+
m(this, "_debonceBuildTree", Mt(this._buildTree, 0));
|
|
362
362
|
this._unitId = e, this._subUnitId = t, this._univerInstanceService = r, this._disableTree = i, this._map = a, this._buildTree();
|
|
363
363
|
}
|
|
364
364
|
get _worksheet() {
|
|
@@ -458,7 +458,7 @@ class Ke {
|
|
|
458
458
|
}
|
|
459
459
|
clone() {
|
|
460
460
|
return new Ke(
|
|
461
|
-
new Map(
|
|
461
|
+
new Map(V.deepClone(Array.from(this._map.entries()))),
|
|
462
462
|
this._unitId,
|
|
463
463
|
this._subUnitId,
|
|
464
464
|
this._univerInstanceService,
|
|
@@ -482,7 +482,7 @@ var ta = Object.getOwnPropertyDescriptor, aa = (o, a, e, t) => {
|
|
|
482
482
|
(s = o[i]) && (r = s(r) || r);
|
|
483
483
|
return r;
|
|
484
484
|
}, X = (o, a) => (e, t) => a(e, t, o);
|
|
485
|
-
let F = class extends
|
|
485
|
+
let F = class extends W {
|
|
486
486
|
constructor(a, e, t, r, i, s, n) {
|
|
487
487
|
super();
|
|
488
488
|
m(this, "_ruleMatrixMap", /* @__PURE__ */ new Map());
|
|
@@ -598,8 +598,8 @@ let F = class extends P {
|
|
|
598
598
|
t: g == null ? void 0 : g.t
|
|
599
599
|
},
|
|
600
600
|
a
|
|
601
|
-
).then((
|
|
602
|
-
const f =
|
|
601
|
+
).then((M) => {
|
|
602
|
+
const f = M ? D.VALID : D.INVALID, w = _.getValue(i, r);
|
|
603
603
|
f === D.VALID ? _.realDeleteValue(i, r) : _.setValue(i, r, f), u(f, v !== w);
|
|
604
604
|
}), D.VALIDATING) : (u(v != null ? v : D.VALID, !1), v != null ? v : D.VALID);
|
|
605
605
|
} else
|
|
@@ -636,14 +636,14 @@ F = aa([
|
|
|
636
636
|
X(2, R(q)),
|
|
637
637
|
X(3, R(Q)),
|
|
638
638
|
X(4, R(K)),
|
|
639
|
-
X(5, R(
|
|
639
|
+
X(5, R(P)),
|
|
640
640
|
X(6, U)
|
|
641
641
|
], F);
|
|
642
|
-
const
|
|
642
|
+
const Ve = 1, Me = 0;
|
|
643
643
|
function tt(o, a) {
|
|
644
|
-
return
|
|
644
|
+
return V.isBlank(o) ? a.t("dataValidation.validFail.value") : S(o) ? a.t("dataValidation.validFail.primitive") : "";
|
|
645
645
|
}
|
|
646
|
-
const pe = (o) =>
|
|
646
|
+
const pe = (o) => V.isDefine(o) && String(o).toLowerCase() === "true" ? "1" : String(o).toLowerCase() === "false" ? "0" : o;
|
|
647
647
|
class ra extends G {
|
|
648
648
|
constructor() {
|
|
649
649
|
super(...arguments);
|
|
@@ -661,7 +661,7 @@ class ra extends G {
|
|
|
661
661
|
}
|
|
662
662
|
validatorFormula(e, t, r) {
|
|
663
663
|
const { formula1: i, formula2: s } = e, n = i === s;
|
|
664
|
-
if (
|
|
664
|
+
if (V.isBlank(i) && V.isBlank(s))
|
|
665
665
|
return {
|
|
666
666
|
success: !0
|
|
667
667
|
};
|
|
@@ -680,7 +680,7 @@ class ra extends G {
|
|
|
680
680
|
}
|
|
681
681
|
async parseFormula(e, t, r) {
|
|
682
682
|
var c, g, p, _;
|
|
683
|
-
const { formula1: i =
|
|
683
|
+
const { formula1: i = Ve, formula2: s = Me } = e, n = await this._formulaService.getRuleFormulaResult(t, r, e.uid), l = S(i) ? oe((g = (c = n == null ? void 0 : n[0]) == null ? void 0 : c.result) == null ? void 0 : g[0][0]) : i, u = S(s) ? oe((_ = (p = n == null ? void 0 : n[1]) == null ? void 0 : p.result) == null ? void 0 : _[0][0]) : s, d = C(String(l)) && C(String(u));
|
|
684
684
|
return {
|
|
685
685
|
formula1: pe(l),
|
|
686
686
|
formula2: pe(u),
|
|
@@ -696,7 +696,7 @@ class ra extends G {
|
|
|
696
696
|
}
|
|
697
697
|
parseFormulaSync(e, t, r) {
|
|
698
698
|
var c, g, p, _;
|
|
699
|
-
const { formula1: i =
|
|
699
|
+
const { formula1: i = Ve, formula2: s = Me } = e, n = this._formulaService.getRuleFormulaResultSync(t, r, e.uid), l = S(i) ? oe((g = (c = n == null ? void 0 : n[0]) == null ? void 0 : c.result) == null ? void 0 : g[0][0]) : i, u = S(s) ? oe((_ = (p = n == null ? void 0 : n[1]) == null ? void 0 : p.result) == null ? void 0 : _[0][0]) : s, d = C(String(l)) && C(String(u));
|
|
700
700
|
return {
|
|
701
701
|
formula1: pe(l),
|
|
702
702
|
formula2: pe(u),
|
|
@@ -707,7 +707,7 @@ class ra extends G {
|
|
|
707
707
|
}
|
|
708
708
|
async isValidType(e, t, r) {
|
|
709
709
|
const { value: i, unitId: s, subUnitId: n } = e, { formula1: l, formula2: u, originFormula1: d, originFormula2: c } = await this.parseFormula(r, s, n);
|
|
710
|
-
return !
|
|
710
|
+
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 : ""));
|
|
711
711
|
}
|
|
712
712
|
generateRuleErrorMessage(e) {
|
|
713
713
|
return this.localeService.t("dataValidation.checkbox.error");
|
|
@@ -774,8 +774,8 @@ const He = (o) => {
|
|
|
774
774
|
return;
|
|
775
775
|
if (typeof o == "number" || !Number.isNaN(+o))
|
|
776
776
|
return +o;
|
|
777
|
-
const a = (e =
|
|
778
|
-
return
|
|
777
|
+
const a = (e = H.parseDate(o)) == null ? void 0 : e.v;
|
|
778
|
+
return V.isDefine(a) ? a : (t = H.parseDate(it(o).format("YYYY-MM-DD HH:mm:ss"))) == null ? void 0 : t.v;
|
|
779
779
|
};
|
|
780
780
|
class sa extends G {
|
|
781
781
|
constructor() {
|
|
@@ -794,7 +794,7 @@ class sa extends G {
|
|
|
794
794
|
h.NOT_EQUAL
|
|
795
795
|
]);
|
|
796
796
|
m(this, "scopes", ["sheet"]);
|
|
797
|
-
m(this, "_customFormulaService", this.injector.get(
|
|
797
|
+
m(this, "_customFormulaService", this.injector.get(P));
|
|
798
798
|
m(this, "_lexerTreeBuilder", this.injector.get(Y));
|
|
799
799
|
}
|
|
800
800
|
async parseFormula(e, t, r, i, s) {
|
|
@@ -807,10 +807,10 @@ class sa extends G {
|
|
|
807
807
|
}
|
|
808
808
|
async isValidType(e) {
|
|
809
809
|
const { interceptValue: t, value: r } = e;
|
|
810
|
-
return typeof r == "number" && typeof t == "string" ?
|
|
810
|
+
return typeof r == "number" && typeof t == "string" ? !!H.parseDate(t) : typeof t == "string" ? !!H.parseDate(t) : !1;
|
|
811
811
|
}
|
|
812
812
|
_validatorSingleFormula(e) {
|
|
813
|
-
return !
|
|
813
|
+
return !V.isBlank(e) && (S(e) || !Number.isNaN(+e) || !!(e && H.parseDate(e)));
|
|
814
814
|
}
|
|
815
815
|
validatorFormula(e, t, r) {
|
|
816
816
|
const i = e.operator;
|
|
@@ -839,12 +839,12 @@ class sa extends G {
|
|
|
839
839
|
return u;
|
|
840
840
|
let d;
|
|
841
841
|
if (!Number.isNaN(+u))
|
|
842
|
-
d =
|
|
842
|
+
d = H.dateFromSerial(+u);
|
|
843
843
|
else {
|
|
844
|
-
const g = (c =
|
|
844
|
+
const g = (c = H.parseDate(u)) == null ? void 0 : c.v;
|
|
845
845
|
if (g == null)
|
|
846
846
|
return "";
|
|
847
|
-
d =
|
|
847
|
+
d = H.dateFromSerial(g);
|
|
848
848
|
}
|
|
849
849
|
return it(`${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");
|
|
850
850
|
};
|
|
@@ -891,13 +891,12 @@ const ye = {
|
|
|
891
891
|
NONE: "dataValidation.errorMsg.legal"
|
|
892
892
|
};
|
|
893
893
|
function Ee(o) {
|
|
894
|
-
|
|
895
|
-
return typeof o == "string" ? ((o.startsWith("¥") || o.startsWith("$")) && (a = o.slice(1)), +a) : +o;
|
|
894
|
+
return +o;
|
|
896
895
|
}
|
|
897
896
|
class na extends G {
|
|
898
897
|
constructor() {
|
|
899
898
|
super(...arguments);
|
|
900
|
-
m(this, "_customFormulaService", this.injector.get(
|
|
899
|
+
m(this, "_customFormulaService", this.injector.get(P));
|
|
901
900
|
m(this, "id", T.DECIMAL);
|
|
902
901
|
m(this, "_lexerTreeBuilder", this.injector.get(Y));
|
|
903
902
|
m(this, "title", "dataValidation.decimal.title");
|
|
@@ -915,7 +914,7 @@ class na extends G {
|
|
|
915
914
|
m(this, "scopes", ["sheet"]);
|
|
916
915
|
}
|
|
917
916
|
_isFormulaOrNumber(e) {
|
|
918
|
-
return !
|
|
917
|
+
return !V.isBlank(e) && (S(e) || !Number.isNaN(+e));
|
|
919
918
|
}
|
|
920
919
|
async isValidType(e, t, r) {
|
|
921
920
|
const { value: i } = e;
|
|
@@ -945,7 +944,7 @@ class na extends G {
|
|
|
945
944
|
return {
|
|
946
945
|
success: !0
|
|
947
946
|
};
|
|
948
|
-
const s =
|
|
947
|
+
const s = V.isDefine(e.formula1) && this._isFormulaOrNumber(e.formula1), n = V.isDefine(e.formula2) && this._isFormulaOrNumber(e.formula2), l = De.includes(i), u = this.localeService.t("dataValidation.validFail.number");
|
|
949
948
|
return l ? {
|
|
950
949
|
success: s && n,
|
|
951
950
|
formula1: s ? void 0 : u,
|
|
@@ -973,7 +972,7 @@ function Pe(o) {
|
|
|
973
972
|
const r = ne(t);
|
|
974
973
|
if (r != null) {
|
|
975
974
|
if (typeof r != "string" && typeof (t == null ? void 0 : t.s) == "object" && ((s = (i = t.s) == null ? void 0 : i.n) != null && s.pattern)) {
|
|
976
|
-
a.add(
|
|
975
|
+
a.add(H.format(t.s.n.pattern, r, { throws: !1 }));
|
|
977
976
|
return;
|
|
978
977
|
}
|
|
979
978
|
C(r.toString()) && a.add(r.toString());
|
|
@@ -1015,11 +1014,11 @@ class gt extends G {
|
|
|
1015
1014
|
m(this, "title", "dataValidation.list.title");
|
|
1016
1015
|
m(this, "operators", []);
|
|
1017
1016
|
m(this, "scopes", ["sheet"]);
|
|
1018
|
-
m(this, "skipDefaultFontRender", (e) => e.renderMode !==
|
|
1017
|
+
m(this, "skipDefaultFontRender", (e) => e.renderMode !== xe.TEXT);
|
|
1019
1018
|
}
|
|
1020
1019
|
validatorFormula(e, t, r) {
|
|
1021
1020
|
var u, d, c;
|
|
1022
|
-
const i = !
|
|
1021
|
+
const i = !V.isBlank(e.formula1), s = ua((u = e.formula1) != null ? u : "", this._lexer), n = (c = (d = this._univerInstanceService.getUnit(t, N.UNIVER_SHEET)) == null ? void 0 : d.getSheetBySheetId(r)) == null ? void 0 : c.getName(), l = da(e, n != null ? n : "");
|
|
1023
1022
|
return {
|
|
1024
1023
|
success: !!(i && s && !l),
|
|
1025
1024
|
formula1: i ? s ? l ? this.localeService.t("dataValidation.validFail.listIntersects") : void 0 : this.localeService.t("dataValidation.validFail.listInvalid") : this.localeService.t("dataValidation.validFail.list")
|
|
@@ -1028,7 +1027,7 @@ class gt extends G {
|
|
|
1028
1027
|
getExtraStyle(e, t, { style: r }) {
|
|
1029
1028
|
var s;
|
|
1030
1029
|
const i = (s = r.tb !== Re.OVERFLOW ? r.tb : Re.CLIP) != null ? s : Re.WRAP;
|
|
1031
|
-
if (e.type === T.LIST && (e.renderMode ===
|
|
1030
|
+
if (e.type === T.LIST && (e.renderMode === xe.ARROW || e.renderMode === xe.TEXT)) {
|
|
1032
1031
|
const n = this.getListWithColorMap(e), l = `${t != null ? t : ""}`, u = n[l];
|
|
1033
1032
|
if (u)
|
|
1034
1033
|
return {
|
|
@@ -1113,10 +1112,10 @@ class ca extends G {
|
|
|
1113
1112
|
h.NOT_EQUAL
|
|
1114
1113
|
]);
|
|
1115
1114
|
m(this, "scopes", ["sheet"]);
|
|
1116
|
-
m(this, "_customFormulaService", this.injector.get(
|
|
1115
|
+
m(this, "_customFormulaService", this.injector.get(P));
|
|
1117
1116
|
}
|
|
1118
1117
|
_isFormulaOrInt(e) {
|
|
1119
|
-
return !
|
|
1118
|
+
return !V.isBlank(e) && (S(e) || !Number.isNaN(+e) && Number.isInteger(+e));
|
|
1120
1119
|
}
|
|
1121
1120
|
validatorFormula(e, t, r) {
|
|
1122
1121
|
const i = e.operator;
|
|
@@ -1124,7 +1123,7 @@ class ca extends G {
|
|
|
1124
1123
|
return {
|
|
1125
1124
|
success: !1
|
|
1126
1125
|
};
|
|
1127
|
-
const s =
|
|
1126
|
+
const s = V.isDefine(e.formula1) && this._isFormulaOrInt(e.formula1), n = V.isDefine(e.formula2) && this._isFormulaOrInt(e.formula2), l = De.includes(i), u = this.localeService.t("dataValidation.validFail.number");
|
|
1128
1127
|
return l ? {
|
|
1129
1128
|
success: s && n,
|
|
1130
1129
|
formula1: s ? void 0 : u,
|
|
@@ -1164,7 +1163,7 @@ class ca extends G {
|
|
|
1164
1163
|
}
|
|
1165
1164
|
function _t(o) {
|
|
1166
1165
|
var e, t;
|
|
1167
|
-
return o ? o.p ? !((t = (e = o.p.body) == null ? void 0 : e.dataStream) != null ? t : "").slice(0, -2).trim() :
|
|
1166
|
+
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;
|
|
1168
1167
|
}
|
|
1169
1168
|
function Le(o, a, e, t, r = "command", i = !0) {
|
|
1170
1169
|
const s = t.get(Y), n = t.get(q), l = [], u = [], d = t.get(F), c = t.get(O), g = Xe(c, { unitId: o, subUnitId: a });
|
|
@@ -1175,11 +1174,11 @@ function Le(o, a, e, t, r = "command", i = !0) {
|
|
|
1175
1174
|
};
|
|
1176
1175
|
const { worksheet: p } = g, _ = new Se();
|
|
1177
1176
|
let v = !1;
|
|
1178
|
-
function
|
|
1179
|
-
i && f.forEach((
|
|
1180
|
-
b.foreach(
|
|
1181
|
-
const
|
|
1182
|
-
(_t(
|
|
1177
|
+
function M(f, w) {
|
|
1178
|
+
i && f.forEach(($) => {
|
|
1179
|
+
b.foreach($, (B, k) => {
|
|
1180
|
+
const x = p.getCellRaw(B, k), J = mt(x);
|
|
1181
|
+
(_t(x) || J === w) && !(x != null && x.p) && (v = !0, _.setValue(B, k, {
|
|
1183
1182
|
v: w,
|
|
1184
1183
|
p: null
|
|
1185
1184
|
}));
|
|
@@ -1210,7 +1209,7 @@ function Le(o, a, e, t, r = "command", i = !0) {
|
|
|
1210
1209
|
break;
|
|
1211
1210
|
case "update": {
|
|
1212
1211
|
if (de(f.rule.type, n)) {
|
|
1213
|
-
const
|
|
1212
|
+
const $ = f.oldRanges[0].startRow, B = f.oldRanges[0].startColumn, k = f.newRanges[0].startRow, x = f.newRanges[0].startColumn, J = k - $, ce = x - B, he = S(f.rule.formula1) ? s.moveFormulaRefOffset(f.rule.formula1, ce, J) : f.rule.formula1, me = S(f.rule.formula2) ? s.moveFormulaRefOffset(f.rule.formula2, ce, J) : f.rule.formula2;
|
|
1214
1213
|
he !== f.rule.formula1 || me !== f.rule.formula2 || !ot(f.newRanges, f.oldRanges) ? (l.push({
|
|
1215
1214
|
id: E.id,
|
|
1216
1215
|
params: {
|
|
@@ -1294,8 +1293,8 @@ function Le(o, a, e, t, r = "command", i = !0) {
|
|
|
1294
1293
|
});
|
|
1295
1294
|
const w = d.getRuleById(o, a, f.ruleId);
|
|
1296
1295
|
if (w && w.type === T.CHECKBOX) {
|
|
1297
|
-
const
|
|
1298
|
-
|
|
1296
|
+
const B = d.getValidator(T.CHECKBOX).parseFormulaSync(w, o, a);
|
|
1297
|
+
M(f.newRanges, B.formula2);
|
|
1299
1298
|
}
|
|
1300
1299
|
break;
|
|
1301
1300
|
}
|
|
@@ -1317,8 +1316,8 @@ function Le(o, a, e, t, r = "command", i = !0) {
|
|
|
1317
1316
|
source: r
|
|
1318
1317
|
}
|
|
1319
1318
|
}), f.rule.type === T.CHECKBOX) {
|
|
1320
|
-
const
|
|
1321
|
-
|
|
1319
|
+
const $ = d.getValidator(T.CHECKBOX).parseFormulaSync(f.rule, o, a);
|
|
1320
|
+
M(f.rule.ranges, $.originFormula2);
|
|
1322
1321
|
}
|
|
1323
1322
|
break;
|
|
1324
1323
|
}
|
|
@@ -1430,22 +1429,22 @@ const ha = {
|
|
|
1430
1429
|
type: y.SETTING,
|
|
1431
1430
|
payload: bt(c)
|
|
1432
1431
|
}
|
|
1433
|
-
},
|
|
1432
|
+
}, M = [{
|
|
1434
1433
|
id: E.id,
|
|
1435
1434
|
params: v
|
|
1436
1435
|
}];
|
|
1437
1436
|
if (u.type === T.CHECKBOX) {
|
|
1438
|
-
const w = c.ranges,
|
|
1439
|
-
if (
|
|
1440
|
-
const
|
|
1437
|
+
const w = c.ranges, $ = o.get(O), B = Xe($, { unitId: s, subUnitId: n });
|
|
1438
|
+
if (B) {
|
|
1439
|
+
const k = new Se(), { worksheet: x } = B, { formula2: J = Me, formula1: ce = Ve } = c, { formula2: he = Me, formula1: me = Ve } = u;
|
|
1441
1440
|
let Ue = !1;
|
|
1442
1441
|
if (w.forEach((ge) => {
|
|
1443
|
-
b.foreach(ge, (ae,
|
|
1444
|
-
const
|
|
1445
|
-
(_t(
|
|
1442
|
+
b.foreach(ge, (ae, Be) => {
|
|
1443
|
+
const j = x.getCellRaw(ae, Be), ze = mt(j);
|
|
1444
|
+
(_t(j) || ze === String(J)) && !(j != null && j.p) ? (k.setValue(ae, Be, {
|
|
1446
1445
|
v: he,
|
|
1447
1446
|
p: null
|
|
1448
|
-
}), Ue = !0) : ze === String(ce) && !(
|
|
1447
|
+
}), Ue = !0) : ze === String(ce) && !(j != null && j.p) && (k.setValue(ae, Be, {
|
|
1449
1448
|
v: me,
|
|
1450
1449
|
p: null
|
|
1451
1450
|
}), Ue = !0);
|
|
@@ -1456,20 +1455,20 @@ const ha = {
|
|
|
1456
1455
|
params: {
|
|
1457
1456
|
unitId: s,
|
|
1458
1457
|
subUnitId: n,
|
|
1459
|
-
cellValue:
|
|
1458
|
+
cellValue: k.getData()
|
|
1460
1459
|
}
|
|
1461
1460
|
}, ae = {
|
|
1462
1461
|
id: se.id,
|
|
1463
1462
|
params: nt(o, ge.params)
|
|
1464
1463
|
};
|
|
1465
|
-
_.push(ge),
|
|
1464
|
+
_.push(ge), M.push(ae);
|
|
1466
1465
|
}
|
|
1467
1466
|
}
|
|
1468
1467
|
}
|
|
1469
1468
|
return Ie(_, e).result ? (t.pushUndoRedo({
|
|
1470
1469
|
unitID: s,
|
|
1471
1470
|
redoMutations: _,
|
|
1472
|
-
undoMutations:
|
|
1471
|
+
undoMutations: M
|
|
1473
1472
|
}), !0) : !1;
|
|
1474
1473
|
}
|
|
1475
1474
|
}, _a = {
|
|
@@ -1606,12 +1605,12 @@ const ha = {
|
|
|
1606
1605
|
}), i.executeCommand(I.id, a), !0;
|
|
1607
1606
|
}
|
|
1608
1607
|
}, Sa = "sheets-data-validation.config", rt = {};
|
|
1609
|
-
var
|
|
1610
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
1608
|
+
var Va = Object.getOwnPropertyDescriptor, Ma = (o, a, e, t) => {
|
|
1609
|
+
for (var r = t > 1 ? void 0 : t ? Va(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
1611
1610
|
(s = o[i]) && (r = s(r) || r);
|
|
1612
1611
|
return r;
|
|
1613
1612
|
}, We = (o, a) => (e, t) => a(e, t, o);
|
|
1614
|
-
let Te = class extends
|
|
1613
|
+
let Te = class extends W {
|
|
1615
1614
|
constructor(a, e, t) {
|
|
1616
1615
|
super();
|
|
1617
1616
|
m(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
@@ -1748,7 +1747,7 @@ let Te = class extends P {
|
|
|
1748
1747
|
}));
|
|
1749
1748
|
}
|
|
1750
1749
|
};
|
|
1751
|
-
Te =
|
|
1750
|
+
Te = Ma([
|
|
1752
1751
|
We(0, R(F)),
|
|
1753
1752
|
We(1, R(ct)),
|
|
1754
1753
|
We(2, R(q))
|
|
@@ -1758,7 +1757,7 @@ var pt = /* @__PURE__ */ ((o) => (o[o.View = 0] = "View", o[o.Edit = 1] = "Edit"
|
|
|
1758
1757
|
(s = o[i]) && (r = s(r) || r);
|
|
1759
1758
|
return r;
|
|
1760
1759
|
}, $e = (o, a) => (e, t) => a(e, t, o);
|
|
1761
|
-
let Fe = class extends
|
|
1760
|
+
let Fe = class extends W {
|
|
1762
1761
|
constructor(o, a, e) {
|
|
1763
1762
|
super(), this._univerInstanceService = o, this._permissionService = a, this._lexerTreeBuilder = e;
|
|
1764
1763
|
}
|
|
@@ -1778,14 +1777,14 @@ let Fe = class extends P {
|
|
|
1778
1777
|
if (u = l.getSheetBySheetName(n.sheetName), !u)
|
|
1779
1778
|
return !1;
|
|
1780
1779
|
const v = u == null ? void 0 : u.getSheetId();
|
|
1781
|
-
if (!this._permissionService.getPermissionPoint(new
|
|
1780
|
+
if (!this._permissionService.getPermissionPoint(new Bt(d, v).id)) return !1;
|
|
1782
1781
|
}
|
|
1783
1782
|
if (!u)
|
|
1784
1783
|
return !1;
|
|
1785
1784
|
const { startRow: c, endRow: g, startColumn: p, endColumn: _ } = n.range;
|
|
1786
1785
|
for (let v = c; v <= g; v++)
|
|
1787
|
-
for (let
|
|
1788
|
-
const f = (t = (e = u.getCell(v,
|
|
1786
|
+
for (let M = p; M <= _; M++) {
|
|
1787
|
+
const f = (t = (e = u.getCell(v, M)) == null ? void 0 : e.selectionProtection) == null ? void 0 : t[0];
|
|
1789
1788
|
if ((f == null ? void 0 : f[pt.View]) === !1)
|
|
1790
1789
|
return !1;
|
|
1791
1790
|
}
|
|
@@ -1803,7 +1802,7 @@ var Ta = Object.getOwnPropertyDescriptor, Fa = (o, a, e, t) => {
|
|
|
1803
1802
|
(s = o[i]) && (r = s(r) || r);
|
|
1804
1803
|
return r;
|
|
1805
1804
|
}, ee = (o, a) => (e, t) => a(e, t, o);
|
|
1806
|
-
let Ne = class extends
|
|
1805
|
+
let Ne = class extends W {
|
|
1807
1806
|
constructor(a, e, t, r, i, s) {
|
|
1808
1807
|
super();
|
|
1809
1808
|
m(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
@@ -1852,7 +1851,7 @@ let Ne = class extends P {
|
|
|
1852
1851
|
}
|
|
1853
1852
|
},
|
|
1854
1853
|
source: "patched"
|
|
1855
|
-
},
|
|
1854
|
+
}, M = [
|
|
1856
1855
|
{
|
|
1857
1856
|
id: E.id,
|
|
1858
1857
|
params: _
|
|
@@ -1863,7 +1862,7 @@ let Ne = class extends P {
|
|
|
1863
1862
|
params: v
|
|
1864
1863
|
}
|
|
1865
1864
|
];
|
|
1866
|
-
return { redos:
|
|
1865
|
+
return { redos: M, undos: f };
|
|
1867
1866
|
}, l = this._dataValidationFormulaService.getRuleFormulaInfo(a, e, r);
|
|
1868
1867
|
if (l) {
|
|
1869
1868
|
const [d, c] = l;
|
|
@@ -1903,7 +1902,7 @@ let Ne = class extends P {
|
|
|
1903
1902
|
payload: g
|
|
1904
1903
|
},
|
|
1905
1904
|
source: "patched"
|
|
1906
|
-
}, v = [{ id: E.id, params: _ }],
|
|
1905
|
+
}, v = [{ id: E.id, params: _ }], M = [{
|
|
1907
1906
|
id: E.id,
|
|
1908
1907
|
params: {
|
|
1909
1908
|
unitId: a,
|
|
@@ -1916,10 +1915,10 @@ let Ne = class extends P {
|
|
|
1916
1915
|
source: "patched"
|
|
1917
1916
|
}
|
|
1918
1917
|
}];
|
|
1919
|
-
return { redos: v, undos:
|
|
1918
|
+
return { redos: v, undos: M };
|
|
1920
1919
|
} else {
|
|
1921
|
-
const _ = { unitId: a, subUnitId: e, ruleId: t.uid }, v = [{ id: I.id, params: _ }],
|
|
1922
|
-
return { redos: v, undos:
|
|
1920
|
+
const _ = { unitId: a, subUnitId: e, ruleId: t.uid }, v = [{ id: I.id, params: _ }], M = va(this._injector, _);
|
|
1921
|
+
return { redos: v, undos: M };
|
|
1923
1922
|
}
|
|
1924
1923
|
}, i = [];
|
|
1925
1924
|
t.ranges.forEach((u) => {
|
|
@@ -1966,7 +1965,7 @@ let Ne = class extends P {
|
|
|
1966
1965
|
Ne = Fa([
|
|
1967
1966
|
ee(0, R(F)),
|
|
1968
1967
|
ee(1, R(Ge)),
|
|
1969
|
-
ee(2, R(
|
|
1968
|
+
ee(2, R(xt)),
|
|
1970
1969
|
ee(3, R(K)),
|
|
1971
1970
|
ee(4, R(ct)),
|
|
1972
1971
|
ee(5, R(q))
|
|
@@ -1976,7 +1975,7 @@ var Na = Object.getOwnPropertyDescriptor, Ca = (o, a, e, t) => {
|
|
|
1976
1975
|
(s = o[i]) && (r = s(r) || r);
|
|
1977
1976
|
return r;
|
|
1978
1977
|
}, ke = (o, a) => (e, t) => a(e, t, o);
|
|
1979
|
-
let Ce = class extends
|
|
1978
|
+
let Ce = class extends W {
|
|
1980
1979
|
constructor(o, a, e) {
|
|
1981
1980
|
super(), this._sheetInterceptorService = o, this._univerInstanceService = a, this._sheetDataValidationModel = e, this._initSheetChange();
|
|
1982
1981
|
}
|
|
@@ -2065,7 +2064,7 @@ class wa extends G {
|
|
|
2065
2064
|
m(this, "operators", []);
|
|
2066
2065
|
m(this, "scopes", ["sheet"]);
|
|
2067
2066
|
m(this, "order", 60);
|
|
2068
|
-
m(this, "_customFormulaService", this.injector.get(
|
|
2067
|
+
m(this, "_customFormulaService", this.injector.get(P));
|
|
2069
2068
|
m(this, "_lexerTreeBuilder", this.injector.get(Y));
|
|
2070
2069
|
}
|
|
2071
2070
|
validatorFormula(e, t, r) {
|
|
@@ -2085,7 +2084,7 @@ class wa extends G {
|
|
|
2085
2084
|
}
|
|
2086
2085
|
async isValidType(e, t, r) {
|
|
2087
2086
|
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;
|
|
2088
|
-
return C(String(d)) &&
|
|
2087
|
+
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;
|
|
2089
2088
|
}
|
|
2090
2089
|
generateRuleErrorMessage(e) {
|
|
2091
2090
|
return this.localeService.t("dataValidation.custom.error");
|
|
@@ -2107,7 +2106,7 @@ class Aa extends gt {
|
|
|
2107
2106
|
class Ia extends G {
|
|
2108
2107
|
constructor() {
|
|
2109
2108
|
super(...arguments);
|
|
2110
|
-
m(this, "_customFormulaService", this.injector.get(
|
|
2109
|
+
m(this, "_customFormulaService", this.injector.get(P));
|
|
2111
2110
|
m(this, "_lexerTreeBuilder", this.injector.get(Y));
|
|
2112
2111
|
m(this, "id", T.WHOLE);
|
|
2113
2112
|
m(this, "title", "dataValidation.whole.title");
|
|
@@ -2125,7 +2124,7 @@ class Ia extends G {
|
|
|
2125
2124
|
m(this, "scopes", ["sheet"]);
|
|
2126
2125
|
}
|
|
2127
2126
|
_isFormulaOrInt(e) {
|
|
2128
|
-
return !
|
|
2127
|
+
return !V.isBlank(e) && (S(e) || !Number.isNaN(+e) && Number.isInteger(+e));
|
|
2129
2128
|
}
|
|
2130
2129
|
async isValidType(e, t, r) {
|
|
2131
2130
|
const { value: i } = e, s = Ee(i);
|
|
@@ -2155,7 +2154,7 @@ class Ia extends G {
|
|
|
2155
2154
|
return {
|
|
2156
2155
|
success: !0
|
|
2157
2156
|
};
|
|
2158
|
-
const s =
|
|
2157
|
+
const s = V.isDefine(e.formula1) && this._isFormulaOrInt(e.formula1), n = V.isDefine(e.formula2) && this._isFormulaOrInt(e.formula2), l = De.includes(i), u = this.localeService.t("dataValidation.validFail.number");
|
|
2159
2158
|
return l ? {
|
|
2160
2159
|
success: s && n,
|
|
2161
2160
|
formula1: s ? void 0 : u,
|
|
@@ -2237,7 +2236,7 @@ var La = Object.getOwnPropertyDescriptor, Ua = (o, a, e, t) => {
|
|
|
2237
2236
|
(s = o[i]) && (r = s(r) || r);
|
|
2238
2237
|
return r;
|
|
2239
2238
|
}, ve = (o, a) => (e, t) => a(e, t, o);
|
|
2240
|
-
let we = class extends
|
|
2239
|
+
let we = class extends W {
|
|
2241
2240
|
constructor(o, a, e, t) {
|
|
2242
2241
|
super(), this._univerInstanceService = o, this._sheetDataValidationModel = a, this._dataValidationCacheService = e, this._lifecycleService = t, this._initRecalculate();
|
|
2243
2242
|
}
|
|
@@ -2262,7 +2261,7 @@ let we = class extends P {
|
|
|
2262
2261
|
}
|
|
2263
2262
|
async _validatorByCell(o, a, e, t) {
|
|
2264
2263
|
const r = o.getUnitId(), i = a.getSheetId();
|
|
2265
|
-
if (!
|
|
2264
|
+
if (!V.isDefine(e) || !V.isDefine(t))
|
|
2266
2265
|
throw new Error(`row or col is not defined, row: ${e}, col: ${t}`);
|
|
2267
2266
|
const s = this._sheetDataValidationModel.getRuleByLocation(r, i, e, t);
|
|
2268
2267
|
return s ? new Promise((n) => {
|
|
@@ -2336,8 +2335,8 @@ we = Ua([
|
|
|
2336
2335
|
ve(2, R(Q)),
|
|
2337
2336
|
ve(3, R(Nt))
|
|
2338
2337
|
], we);
|
|
2339
|
-
var
|
|
2340
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
2338
|
+
var Ba = Object.defineProperty, xa = Object.getOwnPropertyDescriptor, Ha = (o, a, e) => a in o ? Ba(o, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[a] = e, Pa = (o, a, e, t) => {
|
|
2339
|
+
for (var r = t > 1 ? void 0 : t ? xa(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
2341
2340
|
(s = o[i]) && (r = s(r) || r);
|
|
2342
2341
|
return r;
|
|
2343
2342
|
}, je = (o, a) => (e, t) => a(e, t, o), ft = (o, a, e) => Ha(o, typeof a != "symbol" ? a + "" : a, e);
|
|
@@ -2355,7 +2354,7 @@ let Ae = class extends At {
|
|
|
2355
2354
|
[
|
|
2356
2355
|
[Q],
|
|
2357
2356
|
[K],
|
|
2358
|
-
[
|
|
2357
|
+
[P],
|
|
2359
2358
|
[we],
|
|
2360
2359
|
[F],
|
|
2361
2360
|
[Oe],
|
|
@@ -2395,7 +2394,7 @@ Ae = Pa([
|
|
|
2395
2394
|
function Ka(o) {
|
|
2396
2395
|
const e = o.get(ut).getCurrentSelections().map((i) => i.range);
|
|
2397
2396
|
return {
|
|
2398
|
-
uid:
|
|
2397
|
+
uid: V.generateRandomId(6),
|
|
2399
2398
|
type: T.DECIMAL,
|
|
2400
2399
|
operator: h.EQUAL,
|
|
2401
2400
|
formula1: "100",
|
|
@@ -2406,15 +2405,15 @@ const za = "data-validation.custom-formula-input", Za = "data-validation.formula
|
|
|
2406
2405
|
export {
|
|
2407
2406
|
ma as AddSheetDataValidationCommand,
|
|
2408
2407
|
Za as BASE_FORMULA_INPUT_NAME,
|
|
2409
|
-
|
|
2410
|
-
|
|
2408
|
+
Ve as CHECKBOX_FORMULA_1,
|
|
2409
|
+
Me as CHECKBOX_FORMULA_2,
|
|
2411
2410
|
er as CHECKBOX_FORMULA_INPUT_NAME,
|
|
2412
2411
|
za as CUSTOM_FORMULA_INPUT_NAME,
|
|
2413
2412
|
ra as CheckboxValidator,
|
|
2414
2413
|
pa as ClearRangeDataValidationCommand,
|
|
2415
2414
|
Yt as DATA_VALIDATION_PLUGIN_NAME,
|
|
2416
2415
|
Q as DataValidationCacheService,
|
|
2417
|
-
|
|
2416
|
+
P as DataValidationCustomFormulaService,
|
|
2418
2417
|
Fe as DataValidationFormulaController,
|
|
2419
2418
|
K as DataValidationFormulaService,
|
|
2420
2419
|
sa as DateValidator,
|