@univerjs/sheets-data-validation 0.15.2 → 0.15.3-insiders.20260131-b9b8805
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/es/facade.js +236 -220
- package/lib/es/index.js +4 -4
- package/lib/facade.js +236 -220
- package/lib/index.js +4 -4
- package/lib/umd/facade.js +1 -1
- package/package.json +8 -8
- package/LICENSE +0 -176
package/lib/facade.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var v = (f, t, e) =>
|
|
1
|
+
var q = Object.defineProperty;
|
|
2
|
+
var $ = (f, t, e) => t in f ? q(f, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : f[t] = e;
|
|
3
|
+
var v = (f, t, e) => $(f, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import { DataValidationType as n, generateRandomId as N, DataValidationErrorStyle as U, DataValidationOperator as g, IUniverInstanceService as P, ICommandService as b, DataValidationStatus as A, CanceledError as D, toDisposable as p } from "@univerjs/core";
|
|
5
|
-
import { UpdateSheetDataValidationSettingCommand as R, UpdateSheetDataValidationOptionsCommand as T, UpdateSheetDataValidationRangeCommand as B, RemoveSheetDataValidationCommand as L, ClearRangeDataValidationCommand as G, AddSheetDataValidationCommand as
|
|
6
|
-
import { FRange as
|
|
5
|
+
import { UpdateSheetDataValidationSettingCommand as R, UpdateSheetDataValidationOptionsCommand as T, UpdateSheetDataValidationRangeCommand as B, RemoveSheetDataValidationCommand as L, ClearRangeDataValidationCommand as G, AddSheetDataValidationCommand as M, SheetsDataValidationValidatorService as S, SheetDataValidationModel as V, RemoveSheetAllDataValidationCommand as j } from "@univerjs/sheets-data-validation";
|
|
6
|
+
import { FRange as O, FWorkbook as H, FWorksheet as W } from "@univerjs/sheets/facade";
|
|
7
7
|
import { DataValidationModel as y, getRuleOptions as Q } from "@univerjs/data-validation";
|
|
8
8
|
import { serializeRangeToRefString as z } from "@univerjs/engine-formula";
|
|
9
|
-
import { FUniver as
|
|
9
|
+
import { FUniver as F, FEventName as K } from "@univerjs/core/facade";
|
|
10
10
|
import { filter as x } from "rxjs";
|
|
11
11
|
class C {
|
|
12
12
|
constructor(t) {
|
|
@@ -440,8 +440,8 @@ class C {
|
|
|
440
440
|
* fRange.setDataValidation(rule);
|
|
441
441
|
* ```
|
|
442
442
|
*/
|
|
443
|
-
requireNumberBetween(t, e,
|
|
444
|
-
return this._rule.formula1 = `${t}`, this._rule.formula2 = `${e}`, this._rule.operator = g.BETWEEN, this._rule.type =
|
|
443
|
+
requireNumberBetween(t, e, i) {
|
|
444
|
+
return this._rule.formula1 = `${t}`, this._rule.formula2 = `${e}`, this._rule.operator = g.BETWEEN, this._rule.type = i ? n.WHOLE : n.DECIMAL, this;
|
|
445
445
|
}
|
|
446
446
|
/**
|
|
447
447
|
* Sets the data validation rule to require a number equal to the given value.
|
|
@@ -597,8 +597,8 @@ class C {
|
|
|
597
597
|
* fRange.setDataValidation(rule);
|
|
598
598
|
* ```
|
|
599
599
|
*/
|
|
600
|
-
requireNumberNotBetween(t, e,
|
|
601
|
-
return this._rule.formula1 = `${t}`, this._rule.formula2 = `${e}`, this._rule.operator = g.NOT_BETWEEN, this._rule.type =
|
|
600
|
+
requireNumberNotBetween(t, e, i) {
|
|
601
|
+
return this._rule.formula1 = `${t}`, this._rule.formula2 = `${e}`, this._rule.operator = g.NOT_BETWEEN, this._rule.type = i ? n.WHOLE : n.DECIMAL, this;
|
|
602
602
|
}
|
|
603
603
|
/**
|
|
604
604
|
* Sets the data validation rule to require a number not equal to the given value.
|
|
@@ -651,8 +651,8 @@ class C {
|
|
|
651
651
|
* fRange.setDataValidation(rule);
|
|
652
652
|
* ```
|
|
653
653
|
*/
|
|
654
|
-
requireValueInList(t, e,
|
|
655
|
-
return this._rule.type = e ? n.LIST_MULTIPLE : n.LIST, this._rule.formula1 = t.join(","), this._rule.formula2 = void 0, this._rule.showDropDown =
|
|
654
|
+
requireValueInList(t, e, i) {
|
|
655
|
+
return this._rule.type = e ? n.LIST_MULTIPLE : n.LIST, this._rule.formula1 = t.join(","), this._rule.formula2 = void 0, this._rule.showDropDown = i != null ? i : !0, this;
|
|
656
656
|
}
|
|
657
657
|
/**
|
|
658
658
|
* Sets a data validation rule that requires the user to enter a value within a specific range.
|
|
@@ -686,12 +686,12 @@ class C {
|
|
|
686
686
|
* cell.setDataValidation(rule);
|
|
687
687
|
* ```
|
|
688
688
|
*/
|
|
689
|
-
requireValueInRange(t, e,
|
|
689
|
+
requireValueInRange(t, e, i) {
|
|
690
690
|
return this._rule.type = e ? n.LIST_MULTIPLE : n.LIST, this._rule.formula1 = `=${z({
|
|
691
691
|
unitId: t.getUnitId(),
|
|
692
692
|
sheetName: t.getSheetName(),
|
|
693
693
|
range: t.getRange()
|
|
694
|
-
})}`, this._rule.formula2 = void 0, this._rule.showDropDown =
|
|
694
|
+
})}`, this._rule.formula2 = void 0, this._rule.showDropDown = i != null ? i : !0, this;
|
|
695
695
|
}
|
|
696
696
|
/**
|
|
697
697
|
* Sets whether to allow invalid data and configures the error style.
|
|
@@ -781,11 +781,11 @@ class C {
|
|
|
781
781
|
}
|
|
782
782
|
}
|
|
783
783
|
class w {
|
|
784
|
-
constructor(t, e,
|
|
784
|
+
constructor(t, e, i) {
|
|
785
785
|
v(this, "rule");
|
|
786
786
|
v(this, "_worksheet");
|
|
787
787
|
v(this, "_injector");
|
|
788
|
-
this._injector =
|
|
788
|
+
this._injector = i, this.rule = t, this._worksheet = e;
|
|
789
789
|
}
|
|
790
790
|
/**
|
|
791
791
|
* Gets whether invalid data is allowed based on the error style value
|
|
@@ -935,7 +935,7 @@ class w {
|
|
|
935
935
|
if (!this.getApplied())
|
|
936
936
|
return [];
|
|
937
937
|
const t = this._injector.get(P).getUnit(this._worksheet.getUnitId());
|
|
938
|
-
return this.rule.ranges.map((e) => this._injector.createInstance(
|
|
938
|
+
return this.rule.ranges.map((e) => this._injector.createInstance(O, t, this._worksheet, e));
|
|
939
939
|
}
|
|
940
940
|
/**
|
|
941
941
|
* Gets the unit ID of the worksheet
|
|
@@ -992,7 +992,7 @@ class w {
|
|
|
992
992
|
* );
|
|
993
993
|
* ```
|
|
994
994
|
*/
|
|
995
|
-
setCriteria(t, e,
|
|
995
|
+
setCriteria(t, e, i = !0) {
|
|
996
996
|
if (this.getApplied() && !this._injector.get(b).syncExecuteCommand(R.id, {
|
|
997
997
|
unitId: this.getUnitId(),
|
|
998
998
|
subUnitId: this.getSheetId(),
|
|
@@ -1002,11 +1002,11 @@ class w {
|
|
|
1002
1002
|
formula1: e[1],
|
|
1003
1003
|
formula2: e[2],
|
|
1004
1004
|
type: this.rule.type,
|
|
1005
|
-
allowBlank:
|
|
1005
|
+
allowBlank: i
|
|
1006
1006
|
}
|
|
1007
1007
|
}))
|
|
1008
1008
|
throw new Error("setCriteria failed");
|
|
1009
|
-
return this.rule.operator = e[0], this.rule.formula1 = e[1], this.rule.formula2 = e[2], this.rule.type = t, this.rule.allowBlank =
|
|
1009
|
+
return this.rule.operator = e[0], this.rule.formula1 = e[1], this.rule.formula2 = e[2], this.rule.type = t, this.rule.allowBlank = i, this;
|
|
1010
1010
|
}
|
|
1011
1011
|
/**
|
|
1012
1012
|
* Set the options for the data validation rule
|
|
@@ -1103,7 +1103,7 @@ class w {
|
|
|
1103
1103
|
}) : !1;
|
|
1104
1104
|
}
|
|
1105
1105
|
}
|
|
1106
|
-
class X extends
|
|
1106
|
+
class X extends O {
|
|
1107
1107
|
setDataValidation(t) {
|
|
1108
1108
|
if (!t)
|
|
1109
1109
|
return this._commandService.syncExecuteCommand(G.id, {
|
|
@@ -1119,7 +1119,7 @@ class X extends M {
|
|
|
1119
1119
|
ranges: [this._range]
|
|
1120
1120
|
}
|
|
1121
1121
|
};
|
|
1122
|
-
return this._commandService.syncExecuteCommand(
|
|
1122
|
+
return this._commandService.syncExecuteCommand(M.id, e), this;
|
|
1123
1123
|
}
|
|
1124
1124
|
getDataValidation() {
|
|
1125
1125
|
const e = this._injector.get(S).getDataValidation(
|
|
@@ -1147,11 +1147,11 @@ class X extends M {
|
|
|
1147
1147
|
const t = this._workbook.getUnitId(), e = this._worksheet.getSheetId();
|
|
1148
1148
|
return this._collectValidationErrorsForRange(t, e, [this._range]);
|
|
1149
1149
|
}
|
|
1150
|
-
async _collectValidationErrorsForRange(t, e,
|
|
1151
|
-
if (!
|
|
1150
|
+
async _collectValidationErrorsForRange(t, e, i) {
|
|
1151
|
+
if (!i.length)
|
|
1152
1152
|
return [];
|
|
1153
|
-
const r = this._injector.get(S),
|
|
1154
|
-
for (const o of
|
|
1153
|
+
const r = this._injector.get(S), a = this._worksheet, h = a.getName(), s = [];
|
|
1154
|
+
for (const o of i) {
|
|
1155
1155
|
const d = [];
|
|
1156
1156
|
for (let u = o.startRow; u <= o.endRow; u++)
|
|
1157
1157
|
for (let l = o.startColumn; l <= o.endColumn; l++)
|
|
@@ -1161,7 +1161,7 @@ class X extends M {
|
|
|
1161
1161
|
if (await r.validatorCell(t, e, u, l) !== A.VALID) {
|
|
1162
1162
|
const m = this._injector.get(V).getRuleByLocation(t, e, u, l);
|
|
1163
1163
|
if (m) {
|
|
1164
|
-
const k = ((c =
|
|
1164
|
+
const k = ((c = a.getCell(u, l)) == null ? void 0 : c.v) || null, I = this._createDataValidationError(
|
|
1165
1165
|
h,
|
|
1166
1166
|
u,
|
|
1167
1167
|
l,
|
|
@@ -1179,19 +1179,19 @@ class X extends M {
|
|
|
1179
1179
|
}
|
|
1180
1180
|
return s;
|
|
1181
1181
|
}
|
|
1182
|
-
_createDataValidationError(t, e,
|
|
1182
|
+
_createDataValidationError(t, e, i, r, a) {
|
|
1183
1183
|
return {
|
|
1184
1184
|
sheetName: t,
|
|
1185
1185
|
row: e,
|
|
1186
|
-
column:
|
|
1186
|
+
column: i,
|
|
1187
1187
|
ruleId: r.uid,
|
|
1188
|
-
inputValue:
|
|
1188
|
+
inputValue: a,
|
|
1189
1189
|
rule: r
|
|
1190
1190
|
};
|
|
1191
1191
|
}
|
|
1192
1192
|
}
|
|
1193
|
-
|
|
1194
|
-
class J extends
|
|
1193
|
+
O.extend(X);
|
|
1194
|
+
class J extends F {
|
|
1195
1195
|
/**
|
|
1196
1196
|
* @deprecated use `univerAPI.newDataValidation()` as instead.
|
|
1197
1197
|
* @returns {FDataValidationBuilder} A new instance of the FDataValidationBuilder class
|
|
@@ -1208,159 +1208,175 @@ class J extends q {
|
|
|
1208
1208
|
// eslint-disable-next-line max-lines-per-function
|
|
1209
1209
|
_initialize(t) {
|
|
1210
1210
|
const e = t.get(b);
|
|
1211
|
-
this.
|
|
1212
|
-
this.
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
const { workbook: l, worksheet: c } = u, _ = new w(s, c.getSheet(), this._injector);
|
|
1218
|
-
this.fireEvent(this.Event.SheetDataValidationChanged, {
|
|
1219
|
-
origin: r,
|
|
1220
|
-
worksheet: c,
|
|
1221
|
-
workbook: l,
|
|
1222
|
-
changeType: d,
|
|
1223
|
-
oldRule: o,
|
|
1224
|
-
rule: _
|
|
1225
|
-
});
|
|
1226
|
-
}) : { dispose: () => {
|
|
1227
|
-
} }
|
|
1228
|
-
), this.registerEventHandler(
|
|
1229
|
-
this.Event.SheetDataValidatorStatusChanged,
|
|
1230
|
-
() => t.has(V) ? t.get(V).validStatusChange$.subscribe((r) => {
|
|
1231
|
-
const { unitId: i, subUnitId: h, ruleId: s, status: o, row: d, col: u } = r, l = this.getSheetTarget(i, h);
|
|
1232
|
-
if (!l)
|
|
1233
|
-
return;
|
|
1234
|
-
const { workbook: c, worksheet: _ } = l, E = _.getDataValidation(s);
|
|
1235
|
-
E && this.fireEvent(this.Event.SheetDataValidatorStatusChanged, {
|
|
1236
|
-
workbook: c,
|
|
1237
|
-
worksheet: _,
|
|
1238
|
-
row: d,
|
|
1239
|
-
column: u,
|
|
1240
|
-
rule: E,
|
|
1241
|
-
status: o
|
|
1242
|
-
});
|
|
1243
|
-
}) : { dispose: () => {
|
|
1244
|
-
} }
|
|
1245
|
-
), this.registerEventHandler(
|
|
1246
|
-
this.Event.BeforeSheetDataValidationAdd,
|
|
1247
|
-
() => e.beforeCommandExecuted((a) => {
|
|
1248
|
-
if (a.id === O.id) {
|
|
1249
|
-
const r = a.params, i = this.getSheetTarget(r.unitId, r.subUnitId);
|
|
1250
|
-
if (!i)
|
|
1251
|
-
return;
|
|
1252
|
-
const { workbook: h, worksheet: s } = i, o = {
|
|
1253
|
-
worksheet: s,
|
|
1254
|
-
workbook: h,
|
|
1255
|
-
rule: r.rule
|
|
1256
|
-
};
|
|
1257
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationAdd, o), o.cancel)
|
|
1258
|
-
throw new D();
|
|
1259
|
-
}
|
|
1260
|
-
})
|
|
1261
|
-
), this.registerEventHandler(
|
|
1262
|
-
this.Event.BeforeSheetDataValidationCriteriaUpdate,
|
|
1263
|
-
() => e.beforeCommandExecuted((a) => {
|
|
1264
|
-
if (a.id === R.id) {
|
|
1265
|
-
const r = a.params, i = this.getSheetTarget(r.unitId, r.subUnitId);
|
|
1266
|
-
if (!i)
|
|
1267
|
-
return;
|
|
1268
|
-
const { workbook: h, worksheet: s } = i, o = s.getDataValidation(r.ruleId);
|
|
1269
|
-
if (!o)
|
|
1270
|
-
return;
|
|
1271
|
-
const d = {
|
|
1272
|
-
worksheet: s,
|
|
1273
|
-
workbook: h,
|
|
1274
|
-
rule: o,
|
|
1275
|
-
ruleId: r.ruleId,
|
|
1276
|
-
newCriteria: r.setting
|
|
1277
|
-
};
|
|
1278
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationCriteriaUpdate, d), d.cancel)
|
|
1279
|
-
throw new D();
|
|
1280
|
-
}
|
|
1281
|
-
})
|
|
1282
|
-
), this.registerEventHandler(
|
|
1283
|
-
this.Event.BeforeSheetDataValidationRangeUpdate,
|
|
1284
|
-
() => e.beforeCommandExecuted((a) => {
|
|
1285
|
-
if (a.id === B.id) {
|
|
1286
|
-
const r = a.params, i = this.getSheetTarget(r.unitId, r.subUnitId);
|
|
1287
|
-
if (!i)
|
|
1288
|
-
return;
|
|
1289
|
-
const { workbook: h, worksheet: s } = i, o = s.getDataValidation(r.ruleId);
|
|
1290
|
-
if (!o)
|
|
1291
|
-
return;
|
|
1292
|
-
const d = {
|
|
1293
|
-
worksheet: s,
|
|
1294
|
-
workbook: h,
|
|
1295
|
-
rule: o,
|
|
1296
|
-
ruleId: r.ruleId,
|
|
1297
|
-
newRanges: r.ranges
|
|
1298
|
-
};
|
|
1299
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationRangeUpdate, d), d.cancel)
|
|
1300
|
-
throw new D();
|
|
1301
|
-
}
|
|
1302
|
-
})
|
|
1303
|
-
), this.registerEventHandler(
|
|
1304
|
-
this.Event.BeforeSheetDataValidationOptionsUpdate,
|
|
1305
|
-
() => e.beforeCommandExecuted((a) => {
|
|
1306
|
-
if (a.id === T.id) {
|
|
1307
|
-
const r = a.params, i = this.getSheetTarget(r.unitId, r.subUnitId);
|
|
1308
|
-
if (!i)
|
|
1309
|
-
return;
|
|
1310
|
-
const { workbook: h, worksheet: s } = i, o = s.getDataValidation(r.ruleId);
|
|
1311
|
-
if (!o)
|
|
1312
|
-
return;
|
|
1313
|
-
const d = {
|
|
1314
|
-
worksheet: s,
|
|
1315
|
-
workbook: h,
|
|
1316
|
-
rule: o,
|
|
1317
|
-
ruleId: r.ruleId,
|
|
1318
|
-
newOptions: r.options
|
|
1319
|
-
};
|
|
1320
|
-
if (this.fireEvent(this.Event.BeforeSheetDataValidationOptionsUpdate, d), d.cancel)
|
|
1321
|
-
throw new D();
|
|
1322
|
-
}
|
|
1323
|
-
})
|
|
1324
|
-
), this.registerEventHandler(
|
|
1325
|
-
this.Event.BeforeSheetDataValidationDelete,
|
|
1326
|
-
() => e.beforeCommandExecuted((a) => {
|
|
1327
|
-
if (a.id === L.id) {
|
|
1328
|
-
const r = a.params, i = this.getSheetTarget(r.unitId, r.subUnitId);
|
|
1329
|
-
if (!i)
|
|
1330
|
-
return;
|
|
1331
|
-
const { workbook: h, worksheet: s } = i, o = s.getDataValidation(r.ruleId);
|
|
1332
|
-
if (!o)
|
|
1211
|
+
this.disposeWithMe(
|
|
1212
|
+
this.registerEventHandler(
|
|
1213
|
+
this.Event.SheetDataValidationChanged,
|
|
1214
|
+
() => t.has(V) ? t.get(V).ruleChange$.subscribe((r) => {
|
|
1215
|
+
const { unitId: a, subUnitId: h, rule: s, oldRule: o, type: d } = r, u = this.getSheetTarget(a, h);
|
|
1216
|
+
if (!u)
|
|
1333
1217
|
return;
|
|
1334
|
-
const
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1218
|
+
const { workbook: l, worksheet: c } = u, _ = new w(s, c.getSheet(), this._injector);
|
|
1219
|
+
this.fireEvent(this.Event.SheetDataValidationChanged, {
|
|
1220
|
+
origin: r,
|
|
1221
|
+
worksheet: c,
|
|
1222
|
+
workbook: l,
|
|
1223
|
+
changeType: d,
|
|
1224
|
+
oldRule: o,
|
|
1225
|
+
rule: _
|
|
1226
|
+
});
|
|
1227
|
+
}) : { dispose: () => {
|
|
1228
|
+
} }
|
|
1229
|
+
)
|
|
1230
|
+
), this.disposeWithMe(
|
|
1231
|
+
this.registerEventHandler(
|
|
1232
|
+
this.Event.SheetDataValidatorStatusChanged,
|
|
1233
|
+
() => t.has(V) ? t.get(V).validStatusChange$.subscribe((r) => {
|
|
1234
|
+
const { unitId: a, subUnitId: h, ruleId: s, status: o, row: d, col: u } = r, l = this.getSheetTarget(a, h);
|
|
1235
|
+
if (!l)
|
|
1350
1236
|
return;
|
|
1351
|
-
const { workbook:
|
|
1352
|
-
|
|
1353
|
-
workbook:
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1237
|
+
const { workbook: c, worksheet: _ } = l, E = _.getDataValidation(s);
|
|
1238
|
+
E && this.fireEvent(this.Event.SheetDataValidatorStatusChanged, {
|
|
1239
|
+
workbook: c,
|
|
1240
|
+
worksheet: _,
|
|
1241
|
+
row: d,
|
|
1242
|
+
column: u,
|
|
1243
|
+
rule: E,
|
|
1244
|
+
status: o
|
|
1245
|
+
});
|
|
1246
|
+
}) : { dispose: () => {
|
|
1247
|
+
} }
|
|
1248
|
+
)
|
|
1249
|
+
), this.disposeWithMe(
|
|
1250
|
+
this.registerEventHandler(
|
|
1251
|
+
this.Event.BeforeSheetDataValidationAdd,
|
|
1252
|
+
() => e.beforeCommandExecuted((i) => {
|
|
1253
|
+
if (i.id === M.id) {
|
|
1254
|
+
const r = i.params, a = this.getSheetTarget(r.unitId, r.subUnitId);
|
|
1255
|
+
if (!a)
|
|
1256
|
+
return;
|
|
1257
|
+
const { workbook: h, worksheet: s } = a, o = {
|
|
1258
|
+
worksheet: s,
|
|
1259
|
+
workbook: h,
|
|
1260
|
+
rule: r.rule
|
|
1261
|
+
};
|
|
1262
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationAdd, o), o.cancel)
|
|
1263
|
+
throw new D();
|
|
1264
|
+
}
|
|
1265
|
+
})
|
|
1266
|
+
)
|
|
1267
|
+
), this.disposeWithMe(
|
|
1268
|
+
this.registerEventHandler(
|
|
1269
|
+
this.Event.BeforeSheetDataValidationCriteriaUpdate,
|
|
1270
|
+
() => e.beforeCommandExecuted((i) => {
|
|
1271
|
+
if (i.id === R.id) {
|
|
1272
|
+
const r = i.params, a = this.getSheetTarget(r.unitId, r.subUnitId);
|
|
1273
|
+
if (!a)
|
|
1274
|
+
return;
|
|
1275
|
+
const { workbook: h, worksheet: s } = a, o = s.getDataValidation(r.ruleId);
|
|
1276
|
+
if (!o)
|
|
1277
|
+
return;
|
|
1278
|
+
const d = {
|
|
1279
|
+
worksheet: s,
|
|
1280
|
+
workbook: h,
|
|
1281
|
+
rule: o,
|
|
1282
|
+
ruleId: r.ruleId,
|
|
1283
|
+
newCriteria: r.setting
|
|
1284
|
+
};
|
|
1285
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationCriteriaUpdate, d), d.cancel)
|
|
1286
|
+
throw new D();
|
|
1287
|
+
}
|
|
1288
|
+
})
|
|
1289
|
+
)
|
|
1290
|
+
), this.disposeWithMe(
|
|
1291
|
+
this.registerEventHandler(
|
|
1292
|
+
this.Event.BeforeSheetDataValidationRangeUpdate,
|
|
1293
|
+
() => e.beforeCommandExecuted((i) => {
|
|
1294
|
+
if (i.id === B.id) {
|
|
1295
|
+
const r = i.params, a = this.getSheetTarget(r.unitId, r.subUnitId);
|
|
1296
|
+
if (!a)
|
|
1297
|
+
return;
|
|
1298
|
+
const { workbook: h, worksheet: s } = a, o = s.getDataValidation(r.ruleId);
|
|
1299
|
+
if (!o)
|
|
1300
|
+
return;
|
|
1301
|
+
const d = {
|
|
1302
|
+
worksheet: s,
|
|
1303
|
+
workbook: h,
|
|
1304
|
+
rule: o,
|
|
1305
|
+
ruleId: r.ruleId,
|
|
1306
|
+
newRanges: r.ranges
|
|
1307
|
+
};
|
|
1308
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationRangeUpdate, d), d.cancel)
|
|
1309
|
+
throw new D();
|
|
1310
|
+
}
|
|
1311
|
+
})
|
|
1312
|
+
)
|
|
1313
|
+
), this.disposeWithMe(
|
|
1314
|
+
this.registerEventHandler(
|
|
1315
|
+
this.Event.BeforeSheetDataValidationOptionsUpdate,
|
|
1316
|
+
() => e.beforeCommandExecuted((i) => {
|
|
1317
|
+
if (i.id === T.id) {
|
|
1318
|
+
const r = i.params, a = this.getSheetTarget(r.unitId, r.subUnitId);
|
|
1319
|
+
if (!a)
|
|
1320
|
+
return;
|
|
1321
|
+
const { workbook: h, worksheet: s } = a, o = s.getDataValidation(r.ruleId);
|
|
1322
|
+
if (!o)
|
|
1323
|
+
return;
|
|
1324
|
+
const d = {
|
|
1325
|
+
worksheet: s,
|
|
1326
|
+
workbook: h,
|
|
1327
|
+
rule: o,
|
|
1328
|
+
ruleId: r.ruleId,
|
|
1329
|
+
newOptions: r.options
|
|
1330
|
+
};
|
|
1331
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationOptionsUpdate, d), d.cancel)
|
|
1332
|
+
throw new D();
|
|
1333
|
+
}
|
|
1334
|
+
})
|
|
1335
|
+
)
|
|
1336
|
+
), this.disposeWithMe(
|
|
1337
|
+
this.registerEventHandler(
|
|
1338
|
+
this.Event.BeforeSheetDataValidationDelete,
|
|
1339
|
+
() => e.beforeCommandExecuted((i) => {
|
|
1340
|
+
if (i.id === L.id) {
|
|
1341
|
+
const r = i.params, a = this.getSheetTarget(r.unitId, r.subUnitId);
|
|
1342
|
+
if (!a)
|
|
1343
|
+
return;
|
|
1344
|
+
const { workbook: h, worksheet: s } = a, o = s.getDataValidation(r.ruleId);
|
|
1345
|
+
if (!o)
|
|
1346
|
+
return;
|
|
1347
|
+
const d = {
|
|
1348
|
+
worksheet: s,
|
|
1349
|
+
workbook: h,
|
|
1350
|
+
rule: o,
|
|
1351
|
+
ruleId: r.ruleId
|
|
1352
|
+
};
|
|
1353
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationDelete, d), d.cancel)
|
|
1354
|
+
throw new D();
|
|
1355
|
+
}
|
|
1356
|
+
})
|
|
1357
|
+
)
|
|
1358
|
+
), this.disposeWithMe(
|
|
1359
|
+
this.registerEventHandler(
|
|
1360
|
+
this.Event.BeforeSheetDataValidationDeleteAll,
|
|
1361
|
+
() => e.beforeCommandExecuted((i) => {
|
|
1362
|
+
if (i.id === j.id) {
|
|
1363
|
+
const r = i.params, a = this.getSheetTarget(r.unitId, r.subUnitId);
|
|
1364
|
+
if (!a)
|
|
1365
|
+
return;
|
|
1366
|
+
const { workbook: h, worksheet: s } = a, o = {
|
|
1367
|
+
worksheet: s,
|
|
1368
|
+
workbook: h,
|
|
1369
|
+
rules: s.getDataValidations()
|
|
1370
|
+
};
|
|
1371
|
+
if (this.fireEvent(this.Event.BeforeSheetDataValidationDeleteAll, o), o.cancel)
|
|
1372
|
+
throw new D();
|
|
1373
|
+
}
|
|
1374
|
+
})
|
|
1375
|
+
)
|
|
1360
1376
|
);
|
|
1361
1377
|
}
|
|
1362
1378
|
}
|
|
1363
|
-
|
|
1379
|
+
F.extend(J);
|
|
1364
1380
|
class Y extends H {
|
|
1365
1381
|
_initialize() {
|
|
1366
1382
|
Object.defineProperty(this, "_dataValidationModel", {
|
|
@@ -1373,28 +1389,28 @@ class Y extends H {
|
|
|
1373
1389
|
return this._injector.get(S).validatorWorkbook(this._workbook.getUnitId());
|
|
1374
1390
|
}
|
|
1375
1391
|
async getAllDataValidationErrorAsync() {
|
|
1376
|
-
const t = this._workbook.getUnitId(), e = this._dataValidationModel.getSubUnitIds(t),
|
|
1392
|
+
const t = this._workbook.getUnitId(), e = this._dataValidationModel.getSubUnitIds(t), i = [];
|
|
1377
1393
|
for (const r of e) {
|
|
1378
|
-
const
|
|
1379
|
-
|
|
1394
|
+
const a = await this._collectValidationErrorsForSheet(t, r);
|
|
1395
|
+
i.push(...a);
|
|
1380
1396
|
}
|
|
1381
|
-
return
|
|
1397
|
+
return i;
|
|
1382
1398
|
}
|
|
1383
1399
|
async _collectValidationErrorsForSheet(t, e) {
|
|
1384
|
-
const
|
|
1385
|
-
if (!
|
|
1400
|
+
const i = this._dataValidationModel.getRules(t, e);
|
|
1401
|
+
if (!i.length)
|
|
1386
1402
|
return [];
|
|
1387
|
-
const r =
|
|
1403
|
+
const r = i.flatMap((a) => a.ranges);
|
|
1388
1404
|
return this._collectValidationErrorsForRange(t, e, r);
|
|
1389
1405
|
}
|
|
1390
|
-
async _collectValidationErrorsForRange(t, e,
|
|
1391
|
-
if (!
|
|
1406
|
+
async _collectValidationErrorsForRange(t, e, i) {
|
|
1407
|
+
if (!i.length)
|
|
1392
1408
|
return [];
|
|
1393
1409
|
const r = this._injector.get(S), h = this._workbook.getSheetBySheetId(e);
|
|
1394
1410
|
if (!h)
|
|
1395
1411
|
throw new Error(`Cannot find worksheet with sheetId: ${e}`);
|
|
1396
1412
|
const s = h.getName(), o = [];
|
|
1397
|
-
for (const d of
|
|
1413
|
+
for (const d of i) {
|
|
1398
1414
|
const u = [];
|
|
1399
1415
|
for (let l = d.startRow; l <= d.endRow; l++)
|
|
1400
1416
|
for (let c = d.startColumn; c <= d.endColumn; c++)
|
|
@@ -1422,13 +1438,13 @@ class Y extends H {
|
|
|
1422
1438
|
}
|
|
1423
1439
|
return o;
|
|
1424
1440
|
}
|
|
1425
|
-
_createDataValidationError(t, e,
|
|
1441
|
+
_createDataValidationError(t, e, i, r, a) {
|
|
1426
1442
|
return {
|
|
1427
1443
|
sheetName: t,
|
|
1428
1444
|
row: e,
|
|
1429
|
-
column:
|
|
1445
|
+
column: i,
|
|
1430
1446
|
ruleId: r.uid,
|
|
1431
|
-
inputValue:
|
|
1447
|
+
inputValue: a,
|
|
1432
1448
|
rule: r
|
|
1433
1449
|
};
|
|
1434
1450
|
}
|
|
@@ -1440,74 +1456,74 @@ class Y extends H {
|
|
|
1440
1456
|
return p(this._dataValidationModel.validStatusChange$.pipe(x((e) => e.unitId === this._workbook.getUnitId())).subscribe(t));
|
|
1441
1457
|
}
|
|
1442
1458
|
onBeforeAddDataValidation(t) {
|
|
1443
|
-
return p(this._commandService.beforeCommandExecuted((e,
|
|
1459
|
+
return p(this._commandService.beforeCommandExecuted((e, i) => {
|
|
1444
1460
|
const r = e.params;
|
|
1445
|
-
if (e.id ===
|
|
1461
|
+
if (e.id === M.id) {
|
|
1446
1462
|
if (r.unitId !== this._workbook.getUnitId())
|
|
1447
1463
|
return;
|
|
1448
|
-
if (t(r,
|
|
1464
|
+
if (t(r, i) === !1)
|
|
1449
1465
|
throw new Error("Command is stopped by the hook onBeforeAddDataValidation");
|
|
1450
1466
|
}
|
|
1451
1467
|
}));
|
|
1452
1468
|
}
|
|
1453
1469
|
onBeforeUpdateDataValidationCriteria(t) {
|
|
1454
|
-
return p(this._commandService.beforeCommandExecuted((e,
|
|
1470
|
+
return p(this._commandService.beforeCommandExecuted((e, i) => {
|
|
1455
1471
|
const r = e.params;
|
|
1456
1472
|
if (e.id === R.id) {
|
|
1457
1473
|
if (r.unitId !== this._workbook.getUnitId())
|
|
1458
1474
|
return;
|
|
1459
|
-
if (t(r,
|
|
1475
|
+
if (t(r, i) === !1)
|
|
1460
1476
|
throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationCriteria");
|
|
1461
1477
|
}
|
|
1462
1478
|
}));
|
|
1463
1479
|
}
|
|
1464
1480
|
onBeforeUpdateDataValidationRange(t) {
|
|
1465
|
-
return p(this._commandService.beforeCommandExecuted((e,
|
|
1481
|
+
return p(this._commandService.beforeCommandExecuted((e, i) => {
|
|
1466
1482
|
const r = e.params;
|
|
1467
1483
|
if (e.id === B.id) {
|
|
1468
1484
|
if (r.unitId !== this._workbook.getUnitId())
|
|
1469
1485
|
return;
|
|
1470
|
-
if (t(r,
|
|
1486
|
+
if (t(r, i) === !1)
|
|
1471
1487
|
throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationRange");
|
|
1472
1488
|
}
|
|
1473
1489
|
}));
|
|
1474
1490
|
}
|
|
1475
1491
|
onBeforeUpdateDataValidationOptions(t) {
|
|
1476
|
-
return p(this._commandService.beforeCommandExecuted((e,
|
|
1492
|
+
return p(this._commandService.beforeCommandExecuted((e, i) => {
|
|
1477
1493
|
const r = e.params;
|
|
1478
1494
|
if (e.id === T.id) {
|
|
1479
1495
|
if (r.unitId !== this._workbook.getUnitId())
|
|
1480
1496
|
return;
|
|
1481
|
-
if (t(r,
|
|
1497
|
+
if (t(r, i) === !1)
|
|
1482
1498
|
throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationOptions");
|
|
1483
1499
|
}
|
|
1484
1500
|
}));
|
|
1485
1501
|
}
|
|
1486
1502
|
onBeforeDeleteDataValidation(t) {
|
|
1487
|
-
return p(this._commandService.beforeCommandExecuted((e,
|
|
1503
|
+
return p(this._commandService.beforeCommandExecuted((e, i) => {
|
|
1488
1504
|
const r = e.params;
|
|
1489
1505
|
if (e.id === L.id) {
|
|
1490
1506
|
if (r.unitId !== this._workbook.getUnitId())
|
|
1491
1507
|
return;
|
|
1492
|
-
if (t(r,
|
|
1508
|
+
if (t(r, i) === !1)
|
|
1493
1509
|
throw new Error("Command is stopped by the hook onBeforeDeleteDataValidation");
|
|
1494
1510
|
}
|
|
1495
1511
|
}));
|
|
1496
1512
|
}
|
|
1497
1513
|
onBeforeDeleteAllDataValidation(t) {
|
|
1498
|
-
return p(this._commandService.beforeCommandExecuted((e,
|
|
1514
|
+
return p(this._commandService.beforeCommandExecuted((e, i) => {
|
|
1499
1515
|
const r = e.params;
|
|
1500
1516
|
if (e.id === j.id) {
|
|
1501
1517
|
if (r.unitId !== this._workbook.getUnitId())
|
|
1502
1518
|
return;
|
|
1503
|
-
if (t(r,
|
|
1519
|
+
if (t(r, i) === !1)
|
|
1504
1520
|
throw new Error("Command is stopped by the hook onBeforeDeleteAllDataValidation");
|
|
1505
1521
|
}
|
|
1506
1522
|
}));
|
|
1507
1523
|
}
|
|
1508
1524
|
}
|
|
1509
1525
|
H.extend(Y);
|
|
1510
|
-
class Z extends
|
|
1526
|
+
class Z extends W {
|
|
1511
1527
|
getDataValidations() {
|
|
1512
1528
|
return this._injector.get(y).getRules(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((e) => new w(e, this._worksheet, this._injector));
|
|
1513
1529
|
}
|
|
@@ -1521,8 +1537,8 @@ class Z extends F {
|
|
|
1521
1537
|
return this.getValidatorStatus();
|
|
1522
1538
|
}
|
|
1523
1539
|
getDataValidation(t) {
|
|
1524
|
-
const
|
|
1525
|
-
return
|
|
1540
|
+
const i = this._injector.get(y).getRuleById(this._workbook.getUnitId(), this._worksheet.getSheetId(), t);
|
|
1541
|
+
return i ? new w(i, this._worksheet, this._injector) : null;
|
|
1526
1542
|
}
|
|
1527
1543
|
async getAllDataValidationErrorAsync() {
|
|
1528
1544
|
const t = this._workbook.getUnitId(), e = this._worksheet.getSheetId();
|
|
@@ -1532,14 +1548,14 @@ class Z extends F {
|
|
|
1532
1548
|
const r = this._injector.get(y).getRules(t, e);
|
|
1533
1549
|
if (!r.length)
|
|
1534
1550
|
return [];
|
|
1535
|
-
const
|
|
1536
|
-
return this._collectValidationErrorsForRange(t, e,
|
|
1551
|
+
const a = r.flatMap((h) => h.ranges);
|
|
1552
|
+
return this._collectValidationErrorsForRange(t, e, a);
|
|
1537
1553
|
}
|
|
1538
|
-
async _collectValidationErrorsForRange(t, e,
|
|
1539
|
-
if (!
|
|
1554
|
+
async _collectValidationErrorsForRange(t, e, i) {
|
|
1555
|
+
if (!i.length)
|
|
1540
1556
|
return [];
|
|
1541
|
-
const r = this._injector.get(S),
|
|
1542
|
-
for (const o of
|
|
1557
|
+
const r = this._injector.get(S), a = this._worksheet, h = a.getName(), s = [];
|
|
1558
|
+
for (const o of i) {
|
|
1543
1559
|
const d = [];
|
|
1544
1560
|
for (let u = o.startRow; u <= o.endRow; u++)
|
|
1545
1561
|
for (let l = o.startColumn; l <= o.endColumn; l++)
|
|
@@ -1549,7 +1565,7 @@ class Z extends F {
|
|
|
1549
1565
|
if (await r.validatorCell(t, e, u, l) !== A.VALID) {
|
|
1550
1566
|
const m = this._injector.get(V).getRuleByLocation(t, e, u, l);
|
|
1551
1567
|
if (m) {
|
|
1552
|
-
const k = ((c =
|
|
1568
|
+
const k = ((c = a.getCell(u, l)) == null ? void 0 : c.v) || null, I = this._createDataValidationError(
|
|
1553
1569
|
h,
|
|
1554
1570
|
u,
|
|
1555
1571
|
l,
|
|
@@ -1567,18 +1583,18 @@ class Z extends F {
|
|
|
1567
1583
|
}
|
|
1568
1584
|
return s;
|
|
1569
1585
|
}
|
|
1570
|
-
_createDataValidationError(t, e,
|
|
1586
|
+
_createDataValidationError(t, e, i, r, a) {
|
|
1571
1587
|
return {
|
|
1572
1588
|
sheetName: t,
|
|
1573
1589
|
row: e,
|
|
1574
|
-
column:
|
|
1590
|
+
column: i,
|
|
1575
1591
|
ruleId: r.uid,
|
|
1576
|
-
inputValue:
|
|
1592
|
+
inputValue: a,
|
|
1577
1593
|
rule: r
|
|
1578
1594
|
};
|
|
1579
1595
|
}
|
|
1580
1596
|
}
|
|
1581
|
-
|
|
1597
|
+
W.extend(Z);
|
|
1582
1598
|
class tt {
|
|
1583
1599
|
get SheetDataValidationChanged() {
|
|
1584
1600
|
return "SheetDataValidationChanged";
|