@univerjs/sheets-data-validation 0.10.6 → 0.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +394 -235
- package/lib/es/index.js +111 -110
- package/lib/facade.js +394 -235
- package/lib/index.js +111 -110
- package/lib/types/facade/f-range.d.ts +19 -1
- package/lib/types/facade/f-workbook.d.ts +28 -1
- package/lib/types/facade/f-worksheet.d.ts +18 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +8 -8
package/lib/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var m = (o, a, e) =>
|
|
4
|
-
import { Inject as
|
|
1
|
+
var St = Object.defineProperty;
|
|
2
|
+
var Et = (o, a, e) => a in o ? St(o, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[a] = e;
|
|
3
|
+
var m = (o, a, e) => Et(o, typeof a != "symbol" ? a + "" : a, e);
|
|
4
|
+
import { Inject as v, ICommandService as B, IUniverInstanceService as w, Disposable as W, ObjectMatrix as Se, getIntersectRange as it, UniverInstanceType as C, Range as b, Rectangle as I, isFormulaString as S, DataValidationType as T, getOriginCellValue as Vt, RBush as Mt, debounce as yt, Tools as E, DataValidationStatus as N, WrapStrategy as ve, DataValidationOperator as h, numfmt as H, dayjs as ot, DataValidationRenderMode as He, CommandType as z, IUndoRedoService as Z, sequenceExecute as De, isRangesEqual as st, IPermissionService as Tt, generateRandomId as nt, toDisposable as Ye, Injector as Xe, CellValueType as Ft, RxDisposable as Ct, LifecycleService as Ot, LifecycleStages as Je, bufferDebounceTime as wt, DependentOn as At, IConfigService as It, Plugin as Dt, merge as Nt } from "@univerjs/core";
|
|
5
5
|
import { DataValidationModel as Ne, DataValidatorRegistryService as q, UpdateRuleType as M, BaseDataValidator as G, TextLengthErrorTitleMap as bt, AddDataValidationMutation as L, RemoveDataValidationMutation as D, UpdateDataValidationMutation as y, getRuleSetting as Lt, getRuleOptions as Bt, UniverDataValidationPlugin as Ut } from "@univerjs/data-validation";
|
|
6
|
-
import { ERROR_TYPE_SET as xt, LexerTreeBuilder as Y, isReferenceString as
|
|
7
|
-
import { SetRangeValuesMutation as se, RemoveSheetMutation as
|
|
6
|
+
import { ERROR_TYPE_SET as xt, LexerTreeBuilder as Y, isReferenceString as lt, sequenceNodeType as Ht, deserializeRangeWithSheet as Pt, deserializeRangeWithSheetWithCache as Wt, operatorToken as $t } from "@univerjs/engine-formula";
|
|
7
|
+
import { SetRangeValuesMutation as se, RemoveSheetMutation as ut, getSheetCommandTarget as Ke, SetRangeValuesUndoMutationFactory as dt, WorksheetViewPermission as kt, RefRangeService as jt, handleCommonDefaultRangeChangeWithEffectRefCommands as Qt, SheetInterceptorService as ct, RemoveSheetCommand as qt, SheetsSelectionsService as ht, ClearSelectionAllCommand as Gt } from "@univerjs/sheets";
|
|
8
8
|
import { Subject as Ge, bufferWhen as Yt, filter as et } from "rxjs";
|
|
9
|
-
import { RegisterOtherFormulaService as
|
|
9
|
+
import { RegisterOtherFormulaService as mt, FormulaRefRangeService as gt } from "@univerjs/sheets-formula";
|
|
10
10
|
var Xt = Object.getOwnPropertyDescriptor, Kt = (o, a, e, t) => {
|
|
11
11
|
for (var r = t > 1 ? void 0 : t ? Xt(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
12
12
|
(s = o[i]) && (r = s(r) || r);
|
|
@@ -27,7 +27,7 @@ let Q = class extends W {
|
|
|
27
27
|
if (e) {
|
|
28
28
|
const i = new Se(e).getDataRange();
|
|
29
29
|
if (i.endRow === -1) return;
|
|
30
|
-
const l = this._sheetDataValidationModel.getRules(t, r).map((u) => u.ranges).flat().map((u) =>
|
|
30
|
+
const l = this._sheetDataValidationModel.getRules(t, r).map((u) => u.ranges).flat().map((u) => it(u, i)).filter(Boolean);
|
|
31
31
|
l.length && this.markRangeDirty(t, r, l, !0);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -36,7 +36,7 @@ let Q = class extends W {
|
|
|
36
36
|
_initSheetRemove() {
|
|
37
37
|
this.disposeWithMe(this._commandService.onCommandExecuted((a) => {
|
|
38
38
|
var e;
|
|
39
|
-
if (a.id ===
|
|
39
|
+
if (a.id === ut.id) {
|
|
40
40
|
const { unitId: t, subUnitId: r } = a.params;
|
|
41
41
|
(e = this._cacheMatrix.get(t)) == null || e.delete(r);
|
|
42
42
|
}
|
|
@@ -80,9 +80,9 @@ let Q = class extends W {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
Q = Kt([
|
|
83
|
-
Pe(0,
|
|
84
|
-
Pe(1,
|
|
85
|
-
Pe(2,
|
|
83
|
+
Pe(0, v(B)),
|
|
84
|
+
Pe(1, v(w)),
|
|
85
|
+
Pe(2, v(Ne))
|
|
86
86
|
], Q);
|
|
87
87
|
function oe(o) {
|
|
88
88
|
var a, e;
|
|
@@ -233,10 +233,10 @@ let P = class extends W {
|
|
|
233
233
|
};
|
|
234
234
|
P = Zt([
|
|
235
235
|
re(0, w),
|
|
236
|
-
re(1,
|
|
237
|
-
re(2,
|
|
238
|
-
re(3,
|
|
239
|
-
re(4,
|
|
236
|
+
re(1, v(mt)),
|
|
237
|
+
re(2, v(Ne)),
|
|
238
|
+
re(3, v(Q)),
|
|
239
|
+
re(4, v(q))
|
|
240
240
|
], P);
|
|
241
241
|
var Jt = Object.getOwnPropertyDescriptor, ea = (o, a, e, t) => {
|
|
242
242
|
for (var r = t > 1 ? void 0 : t ? Jt(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
@@ -325,15 +325,15 @@ let K = class extends W {
|
|
|
325
325
|
};
|
|
326
326
|
K = ea([
|
|
327
327
|
ie(0, w),
|
|
328
|
-
ie(1,
|
|
329
|
-
ie(2,
|
|
330
|
-
ie(3,
|
|
331
|
-
ie(4,
|
|
328
|
+
ie(1, v(mt)),
|
|
329
|
+
ie(2, v(Q)),
|
|
330
|
+
ie(3, v(Ne)),
|
|
331
|
+
ie(4, v(q))
|
|
332
332
|
], K);
|
|
333
333
|
function ne(o) {
|
|
334
334
|
return Vt(o);
|
|
335
335
|
}
|
|
336
|
-
function
|
|
336
|
+
function _t(o) {
|
|
337
337
|
var a;
|
|
338
338
|
return String((a = ne(o)) != null ? a : "");
|
|
339
339
|
}
|
|
@@ -502,7 +502,7 @@ let F = class extends W {
|
|
|
502
502
|
})
|
|
503
503
|
), this.disposeWithMe(
|
|
504
504
|
this._commandService.onCommandExecuted((a) => {
|
|
505
|
-
if (a.id ===
|
|
505
|
+
if (a.id === ut.id) {
|
|
506
506
|
const { unitId: e, subUnitId: t } = a.params, r = this._ruleMatrixMap.get(e);
|
|
507
507
|
r && r.delete(t);
|
|
508
508
|
}
|
|
@@ -574,8 +574,8 @@ let F = class extends W {
|
|
|
574
574
|
return this._dataValidationModel.getRuleById(a, e, i);
|
|
575
575
|
}
|
|
576
576
|
validator(a, e, t) {
|
|
577
|
-
const { col: r, row: i, unitId: s, subUnitId: n, worksheet: l } = e, u = (_,
|
|
578
|
-
t && t(_,
|
|
577
|
+
const { col: r, row: i, unitId: s, subUnitId: n, worksheet: l } = e, u = (_, R) => {
|
|
578
|
+
t && t(_, R), R && this._validStatusChange$.next({
|
|
579
579
|
unitId: s,
|
|
580
580
|
subUnitId: n,
|
|
581
581
|
ruleId: a.uid,
|
|
@@ -585,8 +585,8 @@ let F = class extends W {
|
|
|
585
585
|
});
|
|
586
586
|
}, d = l.getCellValueOnly(i, r), c = this.getValidator(a.type), g = l.getCellRaw(i, r), p = ne(g);
|
|
587
587
|
if (c) {
|
|
588
|
-
const _ = this._dataValidationCacheService.ensureCache(s, n),
|
|
589
|
-
return
|
|
588
|
+
const _ = this._dataValidationCacheService.ensureCache(s, n), R = _.getValue(i, r);
|
|
589
|
+
return R == null ? (_.setValue(i, r, N.VALIDATING), c.validator(
|
|
590
590
|
{
|
|
591
591
|
value: p,
|
|
592
592
|
unitId: s,
|
|
@@ -601,8 +601,8 @@ let F = class extends W {
|
|
|
601
601
|
a
|
|
602
602
|
).then((V) => {
|
|
603
603
|
const f = V ? N.VALID : N.INVALID, A = _.getValue(i, r);
|
|
604
|
-
f === N.VALID ? _.realDeleteValue(i, r) : _.setValue(i, r, f), u(f,
|
|
605
|
-
}), N.VALIDATING) : (u(
|
|
604
|
+
f === N.VALID ? _.realDeleteValue(i, r) : _.setValue(i, r, f), u(f, R !== A);
|
|
605
|
+
}), N.VALIDATING) : (u(R != null ? R : N.VALID, !1), R != null ? R : N.VALID);
|
|
606
606
|
} else
|
|
607
607
|
return u(N.VALID, !1), N.VALID;
|
|
608
608
|
}
|
|
@@ -632,12 +632,12 @@ let F = class extends W {
|
|
|
632
632
|
}
|
|
633
633
|
};
|
|
634
634
|
F = aa([
|
|
635
|
-
X(0,
|
|
635
|
+
X(0, v(Ne)),
|
|
636
636
|
X(1, w),
|
|
637
|
-
X(2,
|
|
638
|
-
X(3,
|
|
639
|
-
X(4,
|
|
640
|
-
X(5,
|
|
637
|
+
X(2, v(q)),
|
|
638
|
+
X(3, v(Q)),
|
|
639
|
+
X(4, v(K)),
|
|
640
|
+
X(5, v(P)),
|
|
641
641
|
X(6, B)
|
|
642
642
|
], F);
|
|
643
643
|
const Ee = 1, Ve = 0;
|
|
@@ -692,7 +692,7 @@ class ra extends G {
|
|
|
692
692
|
}
|
|
693
693
|
getExtraStyle(e, t) {
|
|
694
694
|
return {
|
|
695
|
-
tb:
|
|
695
|
+
tb: ve.CLIP
|
|
696
696
|
};
|
|
697
697
|
}
|
|
698
698
|
parseFormulaSync(e, t, r) {
|
|
@@ -776,7 +776,7 @@ const We = (o) => {
|
|
|
776
776
|
if (typeof o == "number" || !Number.isNaN(+o))
|
|
777
777
|
return +o;
|
|
778
778
|
const a = (e = H.parseDate(o)) == null ? void 0 : e.v;
|
|
779
|
-
return E.isDefine(a) ? a : (t = H.parseDate(
|
|
779
|
+
return E.isDefine(a) ? a : (t = H.parseDate(ot(o).format("YYYY-MM-DD HH:mm:ss"))) == null ? void 0 : t.v;
|
|
780
780
|
};
|
|
781
781
|
class sa extends G {
|
|
782
782
|
constructor() {
|
|
@@ -847,7 +847,7 @@ class sa extends G {
|
|
|
847
847
|
return "";
|
|
848
848
|
d = H.dateFromSerial(g);
|
|
849
849
|
}
|
|
850
|
-
return
|
|
850
|
+
return ot(`${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");
|
|
851
851
|
};
|
|
852
852
|
return {
|
|
853
853
|
formula1: S(i) ? i : l(`${i}`),
|
|
@@ -989,21 +989,21 @@ const la = [
|
|
|
989
989
|
"offset"
|
|
990
990
|
];
|
|
991
991
|
function ua(o, a) {
|
|
992
|
-
if (!S(o) ||
|
|
992
|
+
if (!S(o) || lt(o.slice(1)))
|
|
993
993
|
return !0;
|
|
994
994
|
const t = a.sequenceNodesBuilder(o);
|
|
995
995
|
return t && t.some((r) => typeof r == "object" && r.nodeType === Ht.FUNCTION && la.indexOf(r.token.toLowerCase()) > -1);
|
|
996
996
|
}
|
|
997
997
|
function da(o, a) {
|
|
998
998
|
const { formula1: e = "", ranges: t } = o;
|
|
999
|
-
if (
|
|
999
|
+
if (lt(e.slice(1))) {
|
|
1000
1000
|
const i = Pt(e.slice(1));
|
|
1001
1001
|
if ((!i.sheetName || i.sheetName === a) && t.some((s) => I.intersects(s, i.range)))
|
|
1002
1002
|
return !0;
|
|
1003
1003
|
}
|
|
1004
1004
|
return !1;
|
|
1005
1005
|
}
|
|
1006
|
-
class
|
|
1006
|
+
class pt extends G {
|
|
1007
1007
|
constructor() {
|
|
1008
1008
|
super(...arguments);
|
|
1009
1009
|
m(this, "formulaService", this.injector.get(K));
|
|
@@ -1027,7 +1027,7 @@ class _t extends G {
|
|
|
1027
1027
|
}
|
|
1028
1028
|
getExtraStyle(e, t, { style: r }) {
|
|
1029
1029
|
var s;
|
|
1030
|
-
const i = (s = r.tb !==
|
|
1030
|
+
const i = (s = r.tb !== ve.OVERFLOW ? r.tb : ve.CLIP) != null ? s : ve.WRAP;
|
|
1031
1031
|
if (e.type === T.LIST && (e.renderMode === He.ARROW || e.renderMode === He.TEXT)) {
|
|
1032
1032
|
const n = this.getListWithColorMap(e), l = `${t != null ? t : ""}`, u = n[l];
|
|
1033
1033
|
if (u)
|
|
@@ -1067,22 +1067,22 @@ class _t extends G {
|
|
|
1067
1067
|
return this.localeService.t("dataValidation.list.error");
|
|
1068
1068
|
}
|
|
1069
1069
|
getList(e, t, r) {
|
|
1070
|
-
var g, p, _,
|
|
1070
|
+
var g, p, _, R;
|
|
1071
1071
|
const { formula1: i = "" } = e, s = this.injector.get(w), n = (g = t ? s.getUniverSheetInstance(t) : void 0) != null ? g : s.getCurrentUnitForType(C.UNIVER_SHEET);
|
|
1072
1072
|
if (!n) return [];
|
|
1073
1073
|
const l = (p = r ? n.getSheetBySheetId(r) : void 0) != null ? p : n.getActiveSheet();
|
|
1074
1074
|
if (!l) return [];
|
|
1075
1075
|
const u = n.getUnitId(), d = l.getSheetId(), c = this.formulaService.getRuleFormulaResultSync(u, d, e.uid);
|
|
1076
|
-
return S(i) ? $e((
|
|
1076
|
+
return S(i) ? $e((R = (_ = c == null ? void 0 : c[0]) == null ? void 0 : _.result) == null ? void 0 : R[0][0]) : fe(i);
|
|
1077
1077
|
}
|
|
1078
1078
|
async getListAsync(e, t, r) {
|
|
1079
|
-
var g, p, _,
|
|
1079
|
+
var g, p, _, R;
|
|
1080
1080
|
const { formula1: i = "" } = e, s = this.injector.get(w), n = (g = t ? s.getUniverSheetInstance(t) : void 0) != null ? g : s.getCurrentUnitForType(C.UNIVER_SHEET);
|
|
1081
1081
|
if (!n) return [];
|
|
1082
1082
|
const l = (p = r ? n.getSheetBySheetId(r) : void 0) != null ? p : n.getActiveSheet();
|
|
1083
1083
|
if (!l) return [];
|
|
1084
1084
|
const u = n.getUnitId(), d = l.getSheetId(), c = await this.formulaService.getRuleFormulaResult(u, d, e.uid);
|
|
1085
|
-
return S(i) ? $e((
|
|
1085
|
+
return S(i) ? $e((R = (_ = c == null ? void 0 : c[0]) == null ? void 0 : _.result) == null ? void 0 : R[0][0]) : fe(i);
|
|
1086
1086
|
}
|
|
1087
1087
|
getListWithColor(e, t, r) {
|
|
1088
1088
|
const i = this.getList(e, t, r), s = (e.formula2 || "").split(",");
|
|
@@ -1162,7 +1162,7 @@ class ca extends G {
|
|
|
1162
1162
|
return `${this.localeService.t(bt[e.operator]).replace(le, r != null ? r : "").replace(ue, i != null ? i : "")}`;
|
|
1163
1163
|
}
|
|
1164
1164
|
}
|
|
1165
|
-
function
|
|
1165
|
+
function ft(o) {
|
|
1166
1166
|
var e, t;
|
|
1167
1167
|
return o ? o.p ? !((t = (e = o.p.body) == null ? void 0 : e.dataStream) != null ? t : "").slice(0, -2).trim() : E.isBlank(o.v) : !0;
|
|
1168
1168
|
}
|
|
@@ -1174,12 +1174,12 @@ function Be(o, a, e, t, r = "command", i = !0) {
|
|
|
1174
1174
|
undoMutations: u
|
|
1175
1175
|
};
|
|
1176
1176
|
const { worksheet: p } = g, _ = new Se();
|
|
1177
|
-
let
|
|
1177
|
+
let R = !1;
|
|
1178
1178
|
function V(f, A) {
|
|
1179
1179
|
i && f.forEach(($) => {
|
|
1180
1180
|
b.foreach($, (U, k) => {
|
|
1181
|
-
const x = p.getCellRaw(U, k), J =
|
|
1182
|
-
(
|
|
1181
|
+
const x = p.getCellRaw(U, k), J = _t(x);
|
|
1182
|
+
(ft(x) || J === A) && !(x != null && x.p) && (R = !0, _.setValue(U, k, {
|
|
1183
1183
|
v: A,
|
|
1184
1184
|
p: null
|
|
1185
1185
|
}));
|
|
@@ -1211,7 +1211,7 @@ function Be(o, a, e, t, r = "command", i = !0) {
|
|
|
1211
1211
|
case "update": {
|
|
1212
1212
|
if (de(f.rule.type, n)) {
|
|
1213
1213
|
const $ = f.oldRanges[0].startRow, U = f.oldRanges[0].startColumn, k = f.newRanges[0].startRow, x = f.newRanges[0].startColumn, J = k - $, ce = x - U, 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
|
-
he !== f.rule.formula1 || me !== f.rule.formula2 || !
|
|
1214
|
+
he !== f.rule.formula1 || me !== f.rule.formula2 || !st(f.newRanges, f.oldRanges) ? (l.push({
|
|
1215
1215
|
id: y.id,
|
|
1216
1216
|
params: {
|
|
1217
1217
|
unitId: o,
|
|
@@ -1323,7 +1323,7 @@ function Be(o, a, e, t, r = "command", i = !0) {
|
|
|
1323
1323
|
break;
|
|
1324
1324
|
}
|
|
1325
1325
|
}
|
|
1326
|
-
}),
|
|
1326
|
+
}), R) {
|
|
1327
1327
|
const f = {
|
|
1328
1328
|
id: se.id,
|
|
1329
1329
|
params: {
|
|
@@ -1333,7 +1333,7 @@ function Be(o, a, e, t, r = "command", i = !0) {
|
|
|
1333
1333
|
}
|
|
1334
1334
|
}, A = {
|
|
1335
1335
|
id: se.id,
|
|
1336
|
-
params:
|
|
1336
|
+
params: dt(t, f.params)
|
|
1337
1337
|
};
|
|
1338
1338
|
l.push(f), u.push(A);
|
|
1339
1339
|
}
|
|
@@ -1422,7 +1422,7 @@ const ha = {
|
|
|
1422
1422
|
}, _ = [{
|
|
1423
1423
|
id: y.id,
|
|
1424
1424
|
params: p
|
|
1425
|
-
}],
|
|
1425
|
+
}], R = {
|
|
1426
1426
|
unitId: s,
|
|
1427
1427
|
subUnitId: n,
|
|
1428
1428
|
ruleId: l,
|
|
@@ -1432,7 +1432,7 @@ const ha = {
|
|
|
1432
1432
|
}
|
|
1433
1433
|
}, V = [{
|
|
1434
1434
|
id: y.id,
|
|
1435
|
-
params:
|
|
1435
|
+
params: R
|
|
1436
1436
|
}];
|
|
1437
1437
|
if (u.type === T.CHECKBOX) {
|
|
1438
1438
|
const A = c.ranges, $ = o.get(w), U = Ke($, { unitId: s, subUnitId: n });
|
|
@@ -1441,8 +1441,8 @@ const ha = {
|
|
|
1441
1441
|
let Ue = !1;
|
|
1442
1442
|
if (A.forEach((ge) => {
|
|
1443
1443
|
b.foreach(ge, (ae, xe) => {
|
|
1444
|
-
const j = x.getCellRaw(ae, xe), Ze =
|
|
1445
|
-
(
|
|
1444
|
+
const j = x.getCellRaw(ae, xe), Ze = _t(j);
|
|
1445
|
+
(ft(j) || Ze === String(J)) && !(j != null && j.p) ? (k.setValue(ae, xe, {
|
|
1446
1446
|
v: he,
|
|
1447
1447
|
p: null
|
|
1448
1448
|
}), Ue = !0) : Ze === String(ce) && !(j != null && j.p) && (k.setValue(ae, xe, {
|
|
@@ -1460,7 +1460,7 @@ const ha = {
|
|
|
1460
1460
|
}
|
|
1461
1461
|
}, ae = {
|
|
1462
1462
|
id: se.id,
|
|
1463
|
-
params:
|
|
1463
|
+
params: dt(o, ge.params)
|
|
1464
1464
|
};
|
|
1465
1465
|
_.push(ge), V.push(ae);
|
|
1466
1466
|
}
|
|
@@ -1554,7 +1554,7 @@ const ha = {
|
|
|
1554
1554
|
unitID: e
|
|
1555
1555
|
}), r.executeCommand(D.id, l), !0;
|
|
1556
1556
|
}
|
|
1557
|
-
},
|
|
1557
|
+
}, Ra = (o, a) => {
|
|
1558
1558
|
const e = o.get(F), { unitId: t, subUnitId: r, ruleId: i, source: s } = a;
|
|
1559
1559
|
if (Array.isArray(i)) {
|
|
1560
1560
|
const l = i.map((u) => e.getRuleById(t, r, u)).filter(Boolean);
|
|
@@ -1579,7 +1579,7 @@ const ha = {
|
|
|
1579
1579
|
index: e.getRuleIndex(t, r, i)
|
|
1580
1580
|
}
|
|
1581
1581
|
}];
|
|
1582
|
-
},
|
|
1582
|
+
}, va = {
|
|
1583
1583
|
type: z.COMMAND,
|
|
1584
1584
|
id: "sheet.command.remove-data-validation-rule",
|
|
1585
1585
|
handler(o, a) {
|
|
@@ -1606,7 +1606,7 @@ const ha = {
|
|
|
1606
1606
|
}), i.executeCommand(D.id, a), !0;
|
|
1607
1607
|
}
|
|
1608
1608
|
}, Sa = "SHEET_DATA_VALIDATION_PLUGIN";
|
|
1609
|
-
var
|
|
1609
|
+
var Rt = /* @__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))(Rt || {}), Ea = Object.getOwnPropertyDescriptor, Va = (o, a, e, t) => {
|
|
1610
1610
|
for (var r = t > 1 ? void 0 : t ? Ea(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
1611
1611
|
(s = o[i]) && (r = s(r) || r);
|
|
1612
1612
|
return r;
|
|
@@ -1630,16 +1630,16 @@ let Te = class extends W {
|
|
|
1630
1630
|
if (n.sheetName) {
|
|
1631
1631
|
if (u = l.getSheetBySheetName(n.sheetName), !u)
|
|
1632
1632
|
return !1;
|
|
1633
|
-
const
|
|
1634
|
-
if (!this._permissionService.getPermissionPoint(new kt(d,
|
|
1633
|
+
const R = u == null ? void 0 : u.getSheetId();
|
|
1634
|
+
if (!this._permissionService.getPermissionPoint(new kt(d, R).id)) return !1;
|
|
1635
1635
|
}
|
|
1636
1636
|
if (!u)
|
|
1637
1637
|
return !1;
|
|
1638
1638
|
const { startRow: c, endRow: g, startColumn: p, endColumn: _ } = n.range;
|
|
1639
|
-
for (let
|
|
1639
|
+
for (let R = c; R <= g; R++)
|
|
1640
1640
|
for (let V = p; V <= _; V++) {
|
|
1641
|
-
const f = (t = (e = u.getCell(
|
|
1642
|
-
if ((f == null ? void 0 : f[
|
|
1641
|
+
const f = (t = (e = u.getCell(R, V)) == null ? void 0 : e.selectionProtection) == null ? void 0 : t[0];
|
|
1642
|
+
if ((f == null ? void 0 : f[Rt.View]) === !1)
|
|
1643
1643
|
return !1;
|
|
1644
1644
|
}
|
|
1645
1645
|
}
|
|
@@ -1649,7 +1649,7 @@ let Te = class extends W {
|
|
|
1649
1649
|
Te = Va([
|
|
1650
1650
|
ke(0, w),
|
|
1651
1651
|
ke(1, Tt),
|
|
1652
|
-
ke(2,
|
|
1652
|
+
ke(2, v(Y))
|
|
1653
1653
|
], Te);
|
|
1654
1654
|
const Ma = "sheets-data-validation.config", rt = {};
|
|
1655
1655
|
var ya = Object.getOwnPropertyDescriptor, Ta = (o, a, e, t) => {
|
|
@@ -1728,7 +1728,7 @@ let Fe = class extends W {
|
|
|
1728
1728
|
}
|
|
1729
1729
|
});
|
|
1730
1730
|
for (let p = 1; p < u.length; p++) {
|
|
1731
|
-
const _ = u[p],
|
|
1731
|
+
const _ = u[p], R = nt();
|
|
1732
1732
|
d.push({
|
|
1733
1733
|
id: L.id,
|
|
1734
1734
|
params: {
|
|
@@ -1736,7 +1736,7 @@ let Fe = class extends W {
|
|
|
1736
1736
|
subUnitId: e,
|
|
1737
1737
|
rule: {
|
|
1738
1738
|
...t,
|
|
1739
|
-
uid:
|
|
1739
|
+
uid: R,
|
|
1740
1740
|
formula1: _.formulas[0],
|
|
1741
1741
|
formula2: _.formulas[1],
|
|
1742
1742
|
ranges: _.ranges
|
|
@@ -1748,7 +1748,7 @@ let Fe = class extends W {
|
|
|
1748
1748
|
params: {
|
|
1749
1749
|
unitId: a,
|
|
1750
1750
|
subUnitId: e,
|
|
1751
|
-
ruleId:
|
|
1751
|
+
ruleId: R,
|
|
1752
1752
|
source: "patched"
|
|
1753
1753
|
}
|
|
1754
1754
|
});
|
|
@@ -1795,9 +1795,9 @@ let Fe = class extends W {
|
|
|
1795
1795
|
}
|
|
1796
1796
|
};
|
|
1797
1797
|
Fe = Ta([
|
|
1798
|
-
je(0,
|
|
1799
|
-
je(1,
|
|
1800
|
-
je(2,
|
|
1798
|
+
je(0, v(F)),
|
|
1799
|
+
je(1, v(gt)),
|
|
1800
|
+
je(2, v(q))
|
|
1801
1801
|
], Fe);
|
|
1802
1802
|
var Fa = Object.getOwnPropertyDescriptor, Ca = (o, a, e, t) => {
|
|
1803
1803
|
for (var r = t > 1 ? void 0 : t ? Fa(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
@@ -1840,7 +1840,7 @@ let Ce = class extends W {
|
|
|
1840
1840
|
}
|
|
1841
1841
|
},
|
|
1842
1842
|
source: "patched"
|
|
1843
|
-
},
|
|
1843
|
+
}, R = {
|
|
1844
1844
|
unitId: a,
|
|
1845
1845
|
subUnitId: e,
|
|
1846
1846
|
ruleId: t.uid,
|
|
@@ -1861,7 +1861,7 @@ let Ce = class extends W {
|
|
|
1861
1861
|
], f = [
|
|
1862
1862
|
{
|
|
1863
1863
|
id: y.id,
|
|
1864
|
-
params:
|
|
1864
|
+
params: R
|
|
1865
1865
|
}
|
|
1866
1866
|
];
|
|
1867
1867
|
return { redos: V, undos: f };
|
|
@@ -1892,7 +1892,7 @@ let Ce = class extends W {
|
|
|
1892
1892
|
var l;
|
|
1893
1893
|
const r = (u) => {
|
|
1894
1894
|
const d = [...t.ranges], g = d.map((_) => Qt(_, u)).filter((_) => !!_).flat();
|
|
1895
|
-
if (
|
|
1895
|
+
if (st(g, d))
|
|
1896
1896
|
return { redos: [], undos: [] };
|
|
1897
1897
|
if (g.length) {
|
|
1898
1898
|
const _ = {
|
|
@@ -1904,7 +1904,7 @@ let Ce = class extends W {
|
|
|
1904
1904
|
payload: g
|
|
1905
1905
|
},
|
|
1906
1906
|
source: "patched"
|
|
1907
|
-
},
|
|
1907
|
+
}, R = [{ id: y.id, params: _ }], V = [{
|
|
1908
1908
|
id: y.id,
|
|
1909
1909
|
params: {
|
|
1910
1910
|
unitId: a,
|
|
@@ -1917,10 +1917,10 @@ let Ce = class extends W {
|
|
|
1917
1917
|
source: "patched"
|
|
1918
1918
|
}
|
|
1919
1919
|
}];
|
|
1920
|
-
return { redos:
|
|
1920
|
+
return { redos: R, undos: V };
|
|
1921
1921
|
} else {
|
|
1922
|
-
const _ = { unitId: a, subUnitId: e, ruleId: t.uid },
|
|
1923
|
-
return { redos:
|
|
1922
|
+
const _ = { unitId: a, subUnitId: e, ruleId: t.uid }, R = [{ id: D.id, params: _ }], V = Ra(this._injector, _);
|
|
1923
|
+
return { redos: R, undos: V };
|
|
1924
1924
|
}
|
|
1925
1925
|
}, i = [];
|
|
1926
1926
|
t.ranges.forEach((u) => {
|
|
@@ -1965,12 +1965,12 @@ let Ce = class extends W {
|
|
|
1965
1965
|
}
|
|
1966
1966
|
};
|
|
1967
1967
|
Ce = Ca([
|
|
1968
|
-
ee(0,
|
|
1969
|
-
ee(1,
|
|
1970
|
-
ee(2,
|
|
1971
|
-
ee(3,
|
|
1972
|
-
ee(4,
|
|
1973
|
-
ee(5,
|
|
1968
|
+
ee(0, v(F)),
|
|
1969
|
+
ee(1, v(Xe)),
|
|
1970
|
+
ee(2, v(jt)),
|
|
1971
|
+
ee(3, v(K)),
|
|
1972
|
+
ee(4, v(gt)),
|
|
1973
|
+
ee(5, v(q))
|
|
1974
1974
|
], Ce);
|
|
1975
1975
|
var Oa = Object.getOwnPropertyDescriptor, wa = (o, a, e, t) => {
|
|
1976
1976
|
for (var r = t > 1 ? void 0 : t ? Oa(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
@@ -2025,9 +2025,9 @@ let Oe = class extends W {
|
|
|
2025
2025
|
}
|
|
2026
2026
|
};
|
|
2027
2027
|
Oe = wa([
|
|
2028
|
-
Qe(0,
|
|
2029
|
-
Qe(1,
|
|
2030
|
-
Qe(2,
|
|
2028
|
+
Qe(0, v(ct)),
|
|
2029
|
+
Qe(1, v(w)),
|
|
2030
|
+
Qe(2, v(F))
|
|
2031
2031
|
], Oe);
|
|
2032
2032
|
class Aa extends G {
|
|
2033
2033
|
constructor() {
|
|
@@ -2096,7 +2096,7 @@ class Ia extends G {
|
|
|
2096
2096
|
return this.localeService.t("dataValidation.custom.ruleName").replace("{FORMULA1}", (t = e.formula1) != null ? t : "");
|
|
2097
2097
|
}
|
|
2098
2098
|
}
|
|
2099
|
-
class Da extends
|
|
2099
|
+
class Da extends pt {
|
|
2100
2100
|
constructor() {
|
|
2101
2101
|
super(...arguments);
|
|
2102
2102
|
m(this, "id", T.LIST_MULTIPLE);
|
|
@@ -2193,7 +2193,7 @@ let we = class extends Ct {
|
|
|
2193
2193
|
ca,
|
|
2194
2194
|
sa,
|
|
2195
2195
|
ra,
|
|
2196
|
-
|
|
2196
|
+
pt,
|
|
2197
2197
|
Da,
|
|
2198
2198
|
Ia
|
|
2199
2199
|
].forEach((o) => {
|
|
@@ -2227,17 +2227,17 @@ let we = class extends Ct {
|
|
|
2227
2227
|
};
|
|
2228
2228
|
we = La([
|
|
2229
2229
|
te(0, w),
|
|
2230
|
-
te(1,
|
|
2231
|
-
te(2,
|
|
2232
|
-
te(3,
|
|
2233
|
-
te(4,
|
|
2234
|
-
te(5,
|
|
2230
|
+
te(1, v(q)),
|
|
2231
|
+
te(2, v(Xe)),
|
|
2232
|
+
te(3, v(ht)),
|
|
2233
|
+
te(4, v(ct)),
|
|
2234
|
+
te(5, v(F))
|
|
2235
2235
|
], we);
|
|
2236
2236
|
var Ba = Object.getOwnPropertyDescriptor, Ua = (o, a, e, t) => {
|
|
2237
2237
|
for (var r = t > 1 ? void 0 : t ? Ba(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
2238
2238
|
(s = o[i]) && (r = s(r) || r);
|
|
2239
2239
|
return r;
|
|
2240
|
-
},
|
|
2240
|
+
}, Re = (o, a) => (e, t) => a(e, t, o);
|
|
2241
2241
|
let Ae = class extends W {
|
|
2242
2242
|
constructor(o, a, e, t) {
|
|
2243
2243
|
super(), this._univerInstanceService = o, this._sheetDataValidationModel = a, this._dataValidationCacheService = e, this._lifecycleService = t, this._initRecalculate();
|
|
@@ -2290,11 +2290,12 @@ let Ae = class extends W {
|
|
|
2290
2290
|
const r = t.getSheetBySheetId(a);
|
|
2291
2291
|
if (!r)
|
|
2292
2292
|
throw new Error(`cannot find current worksheet, sheetId: ${a}`);
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2293
|
+
const s = this._sheetDataValidationModel.getRules(o, a).map((l) => l.ranges).flat(), n = e.map((l) => s.map((u) => it(l, u))).flat().filter(Boolean);
|
|
2294
|
+
return Promise.all(n.map((l) => {
|
|
2295
|
+
const u = [];
|
|
2296
|
+
return b.foreach(l, (d, c) => {
|
|
2297
|
+
u.push(this._validatorByCell(t, r, d, c));
|
|
2298
|
+
}), Promise.all(u);
|
|
2298
2299
|
}));
|
|
2299
2300
|
}
|
|
2300
2301
|
async validatorWorksheet(o, a) {
|
|
@@ -2332,10 +2333,10 @@ let Ae = class extends W {
|
|
|
2332
2333
|
}
|
|
2333
2334
|
};
|
|
2334
2335
|
Ae = Ua([
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2336
|
+
Re(0, w),
|
|
2337
|
+
Re(1, v(F)),
|
|
2338
|
+
Re(2, v(Q)),
|
|
2339
|
+
Re(3, v(Ot))
|
|
2339
2340
|
], Ae);
|
|
2340
2341
|
var xa = Object.defineProperty, Ha = Object.getOwnPropertyDescriptor, Pa = (o, a, e) => a in o ? xa(o, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[a] = e, Wa = (o, a, e, t) => {
|
|
2341
2342
|
for (var r = t > 1 ? void 0 : t ? Ha(a, e) : a, i = o.length - 1, s; i >= 0; i--)
|
|
@@ -2371,7 +2372,7 @@ let Ie = class extends Dt {
|
|
|
2371
2372
|
ha,
|
|
2372
2373
|
ga,
|
|
2373
2374
|
_a,
|
|
2374
|
-
|
|
2375
|
+
va,
|
|
2375
2376
|
fa,
|
|
2376
2377
|
pa
|
|
2377
2378
|
].forEach((o) => {
|
|
@@ -2389,14 +2390,14 @@ vt(Ie, "pluginName", Sa);
|
|
|
2389
2390
|
vt(Ie, "type", C.UNIVER_SHEET);
|
|
2390
2391
|
Ie = Wa([
|
|
2391
2392
|
At(Ut),
|
|
2392
|
-
qe(1,
|
|
2393
|
+
qe(1, v(Xe)),
|
|
2393
2394
|
qe(2, B),
|
|
2394
2395
|
qe(3, It)
|
|
2395
2396
|
], Ie);
|
|
2396
2397
|
function za(o) {
|
|
2397
|
-
const e = o.get(
|
|
2398
|
+
const e = o.get(ht).getCurrentSelections().map((i) => i.range);
|
|
2398
2399
|
return {
|
|
2399
|
-
uid:
|
|
2400
|
+
uid: nt(6),
|
|
2400
2401
|
type: T.DECIMAL,
|
|
2401
2402
|
operator: h.EQUAL,
|
|
2402
2403
|
formula1: "100",
|
|
@@ -2421,9 +2422,9 @@ export {
|
|
|
2421
2422
|
sa as DateValidator,
|
|
2422
2423
|
er as LIST_FORMULA_INPUT_NAME,
|
|
2423
2424
|
Da as ListMultipleValidator,
|
|
2424
|
-
|
|
2425
|
+
pt as ListValidator,
|
|
2425
2426
|
fa as RemoveSheetAllDataValidationCommand,
|
|
2426
|
-
|
|
2427
|
+
va as RemoveSheetDataValidationCommand,
|
|
2427
2428
|
F as SheetDataValidationModel,
|
|
2428
2429
|
Ae as SheetsDataValidationValidatorService,
|
|
2429
2430
|
Ie as UniverSheetsDataValidationPlugin,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Nullable, DataValidationStatus } from '@univerjs/core';
|
|
2
|
+
import { IDataValidationError } from './f-workbook';
|
|
2
3
|
import { FRange } from '@univerjs/sheets/facade';
|
|
3
4
|
import { FDataValidation } from './f-data-validation';
|
|
4
5
|
/**
|
|
@@ -123,6 +124,20 @@ export interface IFRangeDataValidationMixin {
|
|
|
123
124
|
* ```
|
|
124
125
|
*/
|
|
125
126
|
getValidatorStatus(): Promise<DataValidationStatus[][]>;
|
|
127
|
+
/**
|
|
128
|
+
* Get data validation errors for a specific range in current worksheet.
|
|
129
|
+
* @returns A promise that resolves to an array of validation errors in the specified range.
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
133
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
134
|
+
* const fRange = fWorksheet.getRange('A1:B10');
|
|
135
|
+
* const errors = await fRange.getDataValidationErrorAsync();
|
|
136
|
+
*
|
|
137
|
+
* console.log(errors);
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
getDataValidationErrorAsync(): Promise<IDataValidationError[]>;
|
|
126
141
|
}
|
|
127
142
|
/**
|
|
128
143
|
* @ignore
|
|
@@ -132,6 +147,9 @@ export declare class FRangeDataValidationMixin extends FRange implements IFRange
|
|
|
132
147
|
getDataValidation(): Nullable<FDataValidation>;
|
|
133
148
|
getDataValidations(): FDataValidation[];
|
|
134
149
|
getValidatorStatus(): Promise<DataValidationStatus[][]>;
|
|
150
|
+
getDataValidationErrorAsync(): Promise<IDataValidationError[]>;
|
|
151
|
+
private _collectValidationErrorsForRange;
|
|
152
|
+
private _createDataValidationError;
|
|
135
153
|
}
|
|
136
154
|
declare module '@univerjs/sheets/facade' {
|
|
137
155
|
interface FRange extends IFRangeDataValidationMixin {
|