@univerjs/sheets-data-validation 1.3.1 → 1.5.0
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/README.md +6 -5
- package/lib/cjs/facade.js +16 -27
- package/lib/cjs/index.js +216 -221
- package/lib/cjs/locale/ar-SA.js +1 -2
- package/lib/cjs/locale/ca-ES.js +1 -2
- package/lib/cjs/locale/de-DE.js +1 -2
- package/lib/cjs/locale/en-US.js +1 -2
- package/lib/cjs/locale/es-ES.js +1 -2
- package/lib/cjs/locale/fa-IR.js +1 -2
- package/lib/cjs/locale/fr-FR.js +1 -2
- package/lib/cjs/locale/id-ID.js +1 -2
- package/lib/cjs/locale/it-IT.js +1 -2
- package/lib/cjs/locale/ja-JP.js +1 -2
- package/lib/cjs/locale/ko-KR.js +1 -2
- package/lib/cjs/locale/pl-PL.js +1 -2
- package/lib/cjs/locale/pt-BR.js +1 -2
- package/lib/cjs/locale/ru-RU.js +1 -2
- package/lib/cjs/locale/sk-SK.js +1 -2
- package/lib/cjs/locale/vi-VN.js +1 -2
- package/lib/cjs/locale/zh-CN.js +1 -2
- package/lib/cjs/locale/zh-HK.js +1 -2
- package/lib/cjs/locale/zh-TW.js +1 -2
- package/lib/es/facade.js +16 -27
- package/lib/es/index.js +216 -221
- package/lib/es/locale/ar-SA.js +1 -2
- package/lib/es/locale/ca-ES.js +1 -2
- package/lib/es/locale/de-DE.js +1 -2
- package/lib/es/locale/en-US.js +1 -2
- package/lib/es/locale/es-ES.js +1 -2
- package/lib/es/locale/fa-IR.js +1 -2
- package/lib/es/locale/fr-FR.js +1 -2
- package/lib/es/locale/id-ID.js +1 -2
- package/lib/es/locale/it-IT.js +1 -2
- package/lib/es/locale/ja-JP.js +1 -2
- package/lib/es/locale/ko-KR.js +1 -2
- package/lib/es/locale/pl-PL.js +1 -2
- package/lib/es/locale/pt-BR.js +1 -2
- package/lib/es/locale/ru-RU.js +1 -2
- package/lib/es/locale/sk-SK.js +1 -2
- package/lib/es/locale/vi-VN.js +1 -2
- package/lib/es/locale/zh-CN.js +1 -2
- package/lib/es/locale/zh-HK.js +1 -2
- package/lib/es/locale/zh-TW.js +1 -2
- package/lib/facade.js +16 -27
- package/lib/index.js +216 -221
- package/lib/locale/ar-SA.js +1 -2
- package/lib/locale/ca-ES.js +1 -2
- package/lib/locale/de-DE.js +1 -2
- package/lib/locale/en-US.js +1 -2
- package/lib/locale/es-ES.js +1 -2
- package/lib/locale/fa-IR.js +1 -2
- package/lib/locale/fr-FR.js +1 -2
- package/lib/locale/id-ID.js +1 -2
- package/lib/locale/it-IT.js +1 -2
- package/lib/locale/ja-JP.js +1 -2
- package/lib/locale/ko-KR.js +1 -2
- package/lib/locale/pl-PL.js +1 -2
- package/lib/locale/pt-BR.js +1 -2
- package/lib/locale/ru-RU.js +1 -2
- package/lib/locale/sk-SK.js +1 -2
- package/lib/locale/vi-VN.js +1 -2
- package/lib/locale/zh-CN.js +1 -2
- package/lib/locale/zh-HK.js +1 -2
- package/lib/locale/zh-TW.js +1 -2
- package/lib/types/facade/f-range.d.ts +5 -1
- package/lib/types/models/rule-matrix.d.ts +13 -0
- package/lib/types/services/dv-formula.service.d.ts +7 -3
- package/lib/types/services/dv-list-cache.service.d.ts +4 -3
- package/lib/types/validators/decimal-validator.d.ts +1 -1
- package/lib/types/validators/text-length-validator.d.ts +1 -1
- package/lib/types/validators/whole-validator.d.ts +1 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +12 -12
package/lib/cjs/index.js
CHANGED
|
@@ -7,7 +7,7 @@ let rxjs = require("rxjs");
|
|
|
7
7
|
let _univerjs_protocol = require("@univerjs/protocol");
|
|
8
8
|
let _univerjs_sheets_formula = require("@univerjs/sheets-formula");
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// src/utils/range.ts
|
|
11
11
|
function getRangeInWorksheet(range, worksheet) {
|
|
12
12
|
const maxRows = worksheet.getMaxRows();
|
|
13
13
|
const maxColumns = worksheet.getMaxColumns();
|
|
@@ -35,8 +35,7 @@ function getRangesInWorksheet(ranges, worksheet) {
|
|
|
35
35
|
return effectiveRanges;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
38
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
|
|
40
39
|
function _typeof(o) {
|
|
41
40
|
"@babel/helpers - typeof";
|
|
42
41
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -46,28 +45,25 @@ function _typeof(o) {
|
|
|
46
45
|
}, _typeof(o);
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
function toPrimitive(t, r) {
|
|
48
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
|
|
49
|
+
function toPrimitive(t, e) {
|
|
52
50
|
if ("object" != _typeof(t) || !t) return t;
|
|
53
|
-
var
|
|
54
|
-
if (void 0 !==
|
|
55
|
-
var i =
|
|
51
|
+
var r;
|
|
52
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
53
|
+
var i = r.call(t, e || "default");
|
|
56
54
|
if ("object" != _typeof(i)) return i;
|
|
57
55
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
58
56
|
}
|
|
59
|
-
return ("string" ===
|
|
57
|
+
return ("string" === e ? String : Number)(t);
|
|
60
58
|
}
|
|
61
59
|
|
|
62
|
-
|
|
63
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
60
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
|
|
64
61
|
function toPropertyKey(t) {
|
|
65
62
|
var i = toPrimitive(t, "string");
|
|
66
63
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
67
64
|
}
|
|
68
65
|
|
|
69
|
-
|
|
70
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
66
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
|
|
71
67
|
function _defineProperty(e, r, t) {
|
|
72
68
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
73
69
|
value: t,
|
|
@@ -77,16 +73,14 @@ function _defineProperty(e, r, t) {
|
|
|
77
73
|
}) : e[r] = t, e;
|
|
78
74
|
}
|
|
79
75
|
|
|
80
|
-
|
|
81
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
76
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
|
|
82
77
|
function __decorateParam(paramIndex, decorator) {
|
|
83
78
|
return function(target, key) {
|
|
84
79
|
decorator(target, key, paramIndex);
|
|
85
80
|
};
|
|
86
81
|
}
|
|
87
82
|
|
|
88
|
-
|
|
89
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
83
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
|
|
90
84
|
function __decorate(decorators, target, key, desc) {
|
|
91
85
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
92
86
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -94,8 +88,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
94
88
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
95
89
|
}
|
|
96
90
|
|
|
97
|
-
|
|
98
|
-
//#region src/services/dv-cache.service.ts
|
|
91
|
+
// src/services/dv-cache.service.ts
|
|
99
92
|
let DataValidationCacheService = class DataValidationCacheService extends _univerjs_core.Disposable {
|
|
100
93
|
constructor(_commandService, _univerInstanceService, _sheetDataValidationModel) {
|
|
101
94
|
super();
|
|
@@ -205,8 +198,7 @@ DataValidationCacheService = __decorate([
|
|
|
205
198
|
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_data_validation.DataValidationModel))
|
|
206
199
|
], DataValidationCacheService);
|
|
207
200
|
|
|
208
|
-
|
|
209
|
-
//#region src/utils/formula.ts
|
|
201
|
+
// src/utils/formula.ts
|
|
210
202
|
function getFormulaResult(result) {
|
|
211
203
|
var _result$;
|
|
212
204
|
return result === null || result === void 0 || (_result$ = result[0]) === null || _result$ === void 0 || (_result$ = _result$[0]) === null || _result$ === void 0 ? void 0 : _result$.v;
|
|
@@ -226,8 +218,7 @@ function shouldOffsetFormulaByRange(type, validatorRegistryService) {
|
|
|
226
218
|
return (validator === null || validator === void 0 ? void 0 : validator.offsetFormulaByRange) ?? false;
|
|
227
219
|
}
|
|
228
220
|
|
|
229
|
-
|
|
230
|
-
//#region src/services/dv-custom-formula.service.ts
|
|
221
|
+
// src/services/dv-custom-formula.service.ts
|
|
231
222
|
let DataValidationCustomFormulaService = class DataValidationCustomFormulaService extends _univerjs_core.Disposable {
|
|
232
223
|
constructor(_instanceSrv, _registerOtherFormulaService, _dataValidationModel, _dataValidationCacheService, _validatorRegistryService) {
|
|
233
224
|
super();
|
|
@@ -418,142 +409,19 @@ DataValidationCustomFormulaService = __decorate([
|
|
|
418
409
|
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_data_validation.DataValidatorRegistryService))
|
|
419
410
|
], DataValidationCustomFormulaService);
|
|
420
411
|
|
|
421
|
-
|
|
422
|
-
//#region src/utils/get-cell-data-origin.ts
|
|
423
|
-
function getCellValueOrigin(cell) {
|
|
424
|
-
return (0, _univerjs_core.getOriginCellValue)(cell);
|
|
425
|
-
}
|
|
426
|
-
function getStringCellValue(cell) {
|
|
427
|
-
return String(getCellValueOrigin(cell) ?? "");
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
//#endregion
|
|
431
|
-
//#region src/services/dv-list-cache.service.ts
|
|
432
|
-
let DataValidationListCacheService = class DataValidationListCacheService extends _univerjs_core.Disposable {
|
|
433
|
-
constructor(_injector, _dataValidationModel) {
|
|
434
|
-
super();
|
|
435
|
-
this._injector = _injector;
|
|
436
|
-
this._dataValidationModel = _dataValidationModel;
|
|
437
|
-
_defineProperty(this, "_cache", /* @__PURE__ */ new Map());
|
|
438
|
-
this._initRuleChangeListener();
|
|
439
|
-
}
|
|
440
|
-
_initRuleChangeListener() {
|
|
441
|
-
this.disposeWithMe(this._dataValidationModel.ruleChange$.subscribe((change) => {
|
|
442
|
-
if (change.type === "remove" || change.type === "update") this.markRuleDirty(change.unitId, change.subUnitId, change.rule.uid);
|
|
443
|
-
}));
|
|
444
|
-
}
|
|
445
|
-
/**
|
|
446
|
-
* Get cached list data or compute and cache it if not exists.
|
|
447
|
-
*/
|
|
448
|
-
getOrCompute(unitId, subUnitId, rule) {
|
|
449
|
-
const cached = this.getCache(unitId, subUnitId, rule.uid);
|
|
450
|
-
if (cached) return cached;
|
|
451
|
-
const results = this._injector.get(DataValidationFormulaService).getRuleFormulaResultSync(unitId, subUnitId, rule.uid);
|
|
452
|
-
return this.computeAndCache(unitId, subUnitId, rule, results);
|
|
453
|
-
}
|
|
454
|
-
_ensureCache(unitId, subUnitId) {
|
|
455
|
-
let unitMap = this._cache.get(unitId);
|
|
456
|
-
if (!unitMap) {
|
|
457
|
-
unitMap = /* @__PURE__ */ new Map();
|
|
458
|
-
this._cache.set(unitId, unitMap);
|
|
459
|
-
}
|
|
460
|
-
let subUnitMap = unitMap.get(subUnitId);
|
|
461
|
-
if (!subUnitMap) {
|
|
462
|
-
subUnitMap = /* @__PURE__ */ new Map();
|
|
463
|
-
unitMap.set(subUnitId, subUnitMap);
|
|
464
|
-
}
|
|
465
|
-
return subUnitMap;
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* Get cached list data for a rule. Returns undefined if not cached.
|
|
469
|
-
*/
|
|
470
|
-
getCache(unitId, subUnitId, ruleId) {
|
|
471
|
-
var _this$_cache$get;
|
|
472
|
-
return (_this$_cache$get = this._cache.get(unitId)) === null || _this$_cache$get === void 0 || (_this$_cache$get = _this$_cache$get.get(subUnitId)) === null || _this$_cache$get === void 0 ? void 0 : _this$_cache$get.get(ruleId);
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* Set cache for a rule.
|
|
476
|
-
*/
|
|
477
|
-
setCache(unitId, subUnitId, ruleId, item) {
|
|
478
|
-
this._ensureCache(unitId, subUnitId).set(ruleId, item);
|
|
479
|
-
}
|
|
480
|
-
/**
|
|
481
|
-
* Mark a rule's cache as dirty (invalidate it).
|
|
482
|
-
* Called when formula results change.
|
|
483
|
-
*/
|
|
484
|
-
markRuleDirty(unitId, subUnitId, ruleId) {
|
|
485
|
-
var _this$_cache$get2;
|
|
486
|
-
(_this$_cache$get2 = this._cache.get(unitId)) === null || _this$_cache$get2 === void 0 || (_this$_cache$get2 = _this$_cache$get2.get(subUnitId)) === null || _this$_cache$get2 === void 0 || _this$_cache$get2.delete(ruleId);
|
|
487
|
-
}
|
|
488
|
-
/**
|
|
489
|
-
* Clear all caches.
|
|
490
|
-
*/
|
|
491
|
-
clear() {
|
|
492
|
-
this._cache.clear();
|
|
493
|
-
}
|
|
494
|
-
/**
|
|
495
|
-
* Compute list data from formula result and cache it.
|
|
496
|
-
*/
|
|
497
|
-
computeAndCache(unitId, subUnitId, rule, formulaResult) {
|
|
498
|
-
var _formulaResult$;
|
|
499
|
-
const { formula1 = "", formula2 = "" } = rule;
|
|
500
|
-
const list = (0, _univerjs_core.isFormulaString)(formula1) ? this._getRuleFormulaResultSet(formulaResult === null || formulaResult === void 0 || (_formulaResult$ = formulaResult[0]) === null || _formulaResult$ === void 0 || (_formulaResult$ = _formulaResult$.result) === null || _formulaResult$ === void 0 || (_formulaResult$ = _formulaResult$[0]) === null || _formulaResult$ === void 0 ? void 0 : _formulaResult$[0]) : (0, _univerjs_sheets.deserializeListOptions)(formula1);
|
|
501
|
-
const colorList = formula2.split(",");
|
|
502
|
-
const listWithColor = list.map((label, i) => ({
|
|
503
|
-
label,
|
|
504
|
-
color: colorList[i] || ""
|
|
505
|
-
}));
|
|
506
|
-
const colorMap = {};
|
|
507
|
-
for (const item of listWithColor) if (item.color) colorMap[item.label] = item.color;
|
|
508
|
-
const cacheItem = {
|
|
509
|
-
list,
|
|
510
|
-
listWithColor,
|
|
511
|
-
colorMap,
|
|
512
|
-
set: new Set(list)
|
|
513
|
-
};
|
|
514
|
-
this.setCache(unitId, subUnitId, rule.uid, cacheItem);
|
|
515
|
-
return cacheItem;
|
|
516
|
-
}
|
|
517
|
-
/**
|
|
518
|
-
* Extract string list from formula result cells.
|
|
519
|
-
*/
|
|
520
|
-
_getRuleFormulaResultSet(result) {
|
|
521
|
-
if (!result) return [];
|
|
522
|
-
const resultSet = /* @__PURE__ */ new Set();
|
|
523
|
-
for (let i = 0, rowLen = result.length; i < rowLen; i++) {
|
|
524
|
-
const row = result[i];
|
|
525
|
-
if (!row) continue;
|
|
526
|
-
for (let j = 0, colLen = row.length; j < colLen; j++) {
|
|
527
|
-
const cell = row[j];
|
|
528
|
-
const value = getCellValueOrigin(cell);
|
|
529
|
-
if (value !== null && value !== void 0) {
|
|
530
|
-
var _cell$s;
|
|
531
|
-
if (typeof value !== "string" && typeof (cell === null || cell === void 0 ? void 0 : cell.s) === "object" && ((_cell$s = cell.s) === null || _cell$s === void 0 || (_cell$s = _cell$s.n) === null || _cell$s === void 0 ? void 0 : _cell$s.pattern)) {
|
|
532
|
-
resultSet.add(_univerjs_core.numfmt.format(cell.s.n.pattern, value, { throws: false }));
|
|
533
|
-
continue;
|
|
534
|
-
}
|
|
535
|
-
const valueStr = typeof value === "string" ? value : String(value);
|
|
536
|
-
if (isLegalFormulaResult(valueStr)) resultSet.add(valueStr);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
return [...resultSet];
|
|
541
|
-
}
|
|
542
|
-
};
|
|
543
|
-
DataValidationListCacheService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_data_validation.DataValidationModel))], DataValidationListCacheService);
|
|
544
|
-
|
|
545
|
-
//#endregion
|
|
546
|
-
//#region src/services/dv-formula.service.ts
|
|
412
|
+
// src/services/dv-formula.service.ts
|
|
547
413
|
let DataValidationFormulaService = class DataValidationFormulaService extends _univerjs_core.Disposable {
|
|
548
|
-
constructor(_instanceService, _registerOtherFormulaService, _dataValidationCacheService, _dataValidationModel, _validatorRegistryService
|
|
414
|
+
constructor(_instanceService, _registerOtherFormulaService, _dataValidationCacheService, _dataValidationModel, _validatorRegistryService) {
|
|
549
415
|
super();
|
|
550
416
|
this._instanceService = _instanceService;
|
|
551
417
|
this._registerOtherFormulaService = _registerOtherFormulaService;
|
|
552
418
|
this._dataValidationCacheService = _dataValidationCacheService;
|
|
553
419
|
this._dataValidationModel = _dataValidationModel;
|
|
554
420
|
this._validatorRegistryService = _validatorRegistryService;
|
|
555
|
-
this._listCacheService = _listCacheService;
|
|
556
421
|
_defineProperty(this, "_formulaRuleMap", /* @__PURE__ */ new Map());
|
|
422
|
+
_defineProperty(this, "_ruleFormulaResultChanged$", new rxjs.Subject());
|
|
423
|
+
_defineProperty(this, "ruleFormulaResultChanged$", this._ruleFormulaResultChanged$.asObservable());
|
|
424
|
+
this.disposeWithMe(() => this._ruleFormulaResultChanged$.complete());
|
|
557
425
|
this._initFormulaResultHandler();
|
|
558
426
|
}
|
|
559
427
|
_initFormulaResultHandler() {
|
|
@@ -570,7 +438,11 @@ let DataValidationFormulaService = class DataValidationFormulaService extends _u
|
|
|
570
438
|
if (ruleId && formulaMap.get(ruleId)) {
|
|
571
439
|
const rule = this._dataValidationModel.getRuleById(unitId, subUnitId, ruleId);
|
|
572
440
|
if (rule) {
|
|
573
|
-
this.
|
|
441
|
+
this._ruleFormulaResultChanged$.next({
|
|
442
|
+
unitId,
|
|
443
|
+
subUnitId,
|
|
444
|
+
ruleId
|
|
445
|
+
});
|
|
574
446
|
this._dataValidationCacheService.markRangeDirty(unitId, subUnitId, rule.ranges);
|
|
575
447
|
}
|
|
576
448
|
}
|
|
@@ -648,12 +520,18 @@ DataValidationFormulaService = __decorate([
|
|
|
648
520
|
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_engine_formula.RegisterOtherFormulaService)),
|
|
649
521
|
__decorateParam(2, (0, _univerjs_core.Inject)(DataValidationCacheService)),
|
|
650
522
|
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_data_validation.DataValidationModel)),
|
|
651
|
-
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_data_validation.DataValidatorRegistryService))
|
|
652
|
-
__decorateParam(5, (0, _univerjs_core.Inject)(DataValidationListCacheService))
|
|
523
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_data_validation.DataValidatorRegistryService))
|
|
653
524
|
], DataValidationFormulaService);
|
|
654
525
|
|
|
655
|
-
|
|
656
|
-
|
|
526
|
+
// src/utils/get-cell-data-origin.ts
|
|
527
|
+
function getCellValueOrigin(cell) {
|
|
528
|
+
return (0, _univerjs_core.getOriginCellValue)(cell);
|
|
529
|
+
}
|
|
530
|
+
function getStringCellValue(cell) {
|
|
531
|
+
return String(getCellValueOrigin(cell) ?? "");
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// src/models/rule-matrix.ts
|
|
657
535
|
var RuleMatrix = class RuleMatrix {
|
|
658
536
|
constructor(value, _unitId, _subUnitId, _univerInstanceService, _disableTree = false) {
|
|
659
537
|
this._unitId = _unitId;
|
|
@@ -692,13 +570,14 @@ var RuleMatrix = class RuleMatrix {
|
|
|
692
570
|
_addRule(ruleId, _ranges) {
|
|
693
571
|
if (!this._worksheet) return;
|
|
694
572
|
const ranges = _univerjs_core.Rectangle.mergeRanges(_ranges.map((range) => _univerjs_core.Range.transformRange(range, this._worksheet)));
|
|
573
|
+
const ruleRanges = this._withInputRangeType(ranges, _ranges);
|
|
695
574
|
this._map.forEach((value, key) => {
|
|
696
575
|
const newRanges = _univerjs_core.Rectangle.subtractMulti(value, ranges);
|
|
697
576
|
if (newRanges.length === 0) this._map.delete(key);
|
|
698
577
|
else this._map.set(key, newRanges);
|
|
699
578
|
});
|
|
700
579
|
this._dirty = true;
|
|
701
|
-
this._map.set(ruleId,
|
|
580
|
+
this._map.set(ruleId, ruleRanges);
|
|
702
581
|
this._debonceBuildTree();
|
|
703
582
|
}
|
|
704
583
|
addRule(rule) {
|
|
@@ -728,6 +607,35 @@ var RuleMatrix = class RuleMatrix {
|
|
|
728
607
|
this._removeRule(ruleId);
|
|
729
608
|
this._addRule(ruleId, _newRanges);
|
|
730
609
|
}
|
|
610
|
+
/**
|
|
611
|
+
* The matrix stores concrete coordinates, while the rule keeps its semantic range type (a whole
|
|
612
|
+
* column/row). `Range.transformRange` and `Rectangle.mergeRanges` rebuild ranges from bounds only,
|
|
613
|
+
* so the type of the ranges handed to the matrix has to be carried over explicitly.
|
|
614
|
+
*/
|
|
615
|
+
_withInputRangeType(ranges, inputRanges) {
|
|
616
|
+
var _inputRanges$;
|
|
617
|
+
const rangeType = (_inputRanges$ = inputRanges[0]) === null || _inputRanges$ === void 0 ? void 0 : _inputRanges$.rangeType;
|
|
618
|
+
if (!rangeType || !inputRanges.every((range) => range.rangeType === rangeType)) return ranges;
|
|
619
|
+
return ranges.map((range) => ({
|
|
620
|
+
...range,
|
|
621
|
+
rangeType
|
|
622
|
+
}));
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* A rule range that the matrix rebuilt from coordinates keeps its type when the rebuilt range
|
|
626
|
+
* still covers exactly the same cells as the rule's own range. This is what makes an auto fill
|
|
627
|
+
* or a paste that only rewrites cells inside the rule a no-op instead of a downgrade: the
|
|
628
|
+
* intermediate subtract/add steps drop the type, but the net coverage is unchanged.
|
|
629
|
+
*/
|
|
630
|
+
_keepRuleRangeType(ranges, ruleRanges) {
|
|
631
|
+
return ranges.map((range) => {
|
|
632
|
+
const source = ruleRanges.find((item) => item.rangeType && item.startRow === range.startRow && item.endRow === range.endRow && item.startColumn === range.startColumn && item.endColumn === range.endColumn);
|
|
633
|
+
return source ? {
|
|
634
|
+
...range,
|
|
635
|
+
rangeType: source.rangeType
|
|
636
|
+
} : range;
|
|
637
|
+
});
|
|
638
|
+
}
|
|
731
639
|
addRangeRules(rules) {
|
|
732
640
|
rules.forEach(({ id: ruleId, ranges }) => {
|
|
733
641
|
if (!ranges.length) return;
|
|
@@ -753,7 +661,7 @@ var RuleMatrix = class RuleMatrix {
|
|
|
753
661
|
const mutations = [];
|
|
754
662
|
let deleteIndex = 0;
|
|
755
663
|
rules.forEach((rule, index) => {
|
|
756
|
-
const newRanges = this._map.get(rule.uid) ?? [];
|
|
664
|
+
const newRanges = this._keepRuleRangeType(this._map.get(rule.uid) ?? [], rule.ranges);
|
|
757
665
|
const oldRanges = rule.ranges;
|
|
758
666
|
if (newRanges.length !== 0 && (newRanges.length !== oldRanges.length || newRanges.some((range, i) => !_univerjs_core.Rectangle.equals(range, oldRanges[i])))) mutations.push({
|
|
759
667
|
type: "update",
|
|
@@ -777,7 +685,7 @@ var RuleMatrix = class RuleMatrix {
|
|
|
777
685
|
const mutations = [];
|
|
778
686
|
let deleteIndex = 0;
|
|
779
687
|
rules.forEach((rule, index) => {
|
|
780
|
-
const newRanges = this._map.get(rule.uid) ?? [];
|
|
688
|
+
const newRanges = this._keepRuleRangeType(this._map.get(rule.uid) ?? [], rule.ranges);
|
|
781
689
|
const oldRanges = rule.ranges;
|
|
782
690
|
if (newRanges.length !== 0 && (newRanges.length !== oldRanges.length || newRanges.some((range, i) => !_univerjs_core.Rectangle.equals(range, oldRanges[i])))) mutations.push({
|
|
783
691
|
type: "update",
|
|
@@ -796,7 +704,7 @@ var RuleMatrix = class RuleMatrix {
|
|
|
796
704
|
}
|
|
797
705
|
});
|
|
798
706
|
Array.from(additionRules).forEach((rule) => {
|
|
799
|
-
const newRanges = this._map.get(rule.uid) ?? [];
|
|
707
|
+
const newRanges = this._keepRuleRangeType(this._map.get(rule.uid) ?? [], rule.ranges);
|
|
800
708
|
mutations.push({
|
|
801
709
|
type: "add",
|
|
802
710
|
rule: {
|
|
@@ -822,8 +730,7 @@ var RuleMatrix = class RuleMatrix {
|
|
|
822
730
|
}
|
|
823
731
|
};
|
|
824
732
|
|
|
825
|
-
|
|
826
|
-
//#region src/models/sheet-data-validation-model.ts
|
|
733
|
+
// src/models/sheet-data-validation-model.ts
|
|
827
734
|
let SheetDataValidationModel = class SheetDataValidationModel extends _univerjs_core.Disposable {
|
|
828
735
|
constructor(_dataValidationModel, _univerInstanceService, _dataValidatorRegistryService, _dataValidationCacheService, _dataValidationFormulaService, _dataValidationCustomFormulaService, _commandService) {
|
|
829
736
|
super();
|
|
@@ -1021,8 +928,7 @@ SheetDataValidationModel = __decorate([
|
|
|
1021
928
|
__decorateParam(6, _univerjs_core.ICommandService)
|
|
1022
929
|
], SheetDataValidationModel);
|
|
1023
930
|
|
|
1024
|
-
|
|
1025
|
-
//#region src/types/const/operator-text-map.ts
|
|
931
|
+
// src/types/const/operator-text-map.ts
|
|
1026
932
|
/**
|
|
1027
933
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1028
934
|
*
|
|
@@ -1081,8 +987,7 @@ const TextLengthErrorTitleMap = {
|
|
|
1081
987
|
[_univerjs_core.DataValidationOperator.NOT_EQUAL]: "sheets-data-validation.textLength.errorMsg.notEqual"
|
|
1082
988
|
};
|
|
1083
989
|
|
|
1084
|
-
|
|
1085
|
-
//#region src/validators/base-sheet-validator.ts
|
|
990
|
+
// src/validators/base-sheet-validator.ts
|
|
1086
991
|
const FORMULA1$1 = "{FORMULA1}";
|
|
1087
992
|
const FORMULA2$1 = "{FORMULA2}";
|
|
1088
993
|
const TYPE = "{TYPE}";
|
|
@@ -1101,8 +1006,7 @@ var BaseSheetValidator = class extends _univerjs_data_validation.BaseDataValidat
|
|
|
1101
1006
|
}
|
|
1102
1007
|
};
|
|
1103
1008
|
|
|
1104
|
-
|
|
1105
|
-
//#region src/validators/checkbox-validator.ts
|
|
1009
|
+
// src/validators/checkbox-validator.ts
|
|
1106
1010
|
const CHECKBOX_FORMULA_1 = 1;
|
|
1107
1011
|
const CHECKBOX_FORMULA_2 = 0;
|
|
1108
1012
|
function getFailMessage(formula, localeService) {
|
|
@@ -1192,8 +1096,7 @@ var CheckboxValidator = class extends BaseSheetValidator {
|
|
|
1192
1096
|
}
|
|
1193
1097
|
};
|
|
1194
1098
|
|
|
1195
|
-
|
|
1196
|
-
//#region src/common/date-text-map.ts
|
|
1099
|
+
// src/common/date-text-map.ts
|
|
1197
1100
|
/**
|
|
1198
1101
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1199
1102
|
*
|
|
@@ -1252,8 +1155,7 @@ const DateOperatorErrorTitleMap = {
|
|
|
1252
1155
|
NONE: "sheets-data-validation.date.errorMsg.legal"
|
|
1253
1156
|
};
|
|
1254
1157
|
|
|
1255
|
-
|
|
1256
|
-
//#region src/types/const/two-formula-operators.ts
|
|
1158
|
+
// src/types/const/two-formula-operators.ts
|
|
1257
1159
|
/**
|
|
1258
1160
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1259
1161
|
*
|
|
@@ -1271,8 +1173,7 @@ const DateOperatorErrorTitleMap = {
|
|
|
1271
1173
|
*/
|
|
1272
1174
|
const TWO_FORMULA_OPERATOR_COUNT = [_univerjs_core.DataValidationOperator.BETWEEN, _univerjs_core.DataValidationOperator.NOT_BETWEEN];
|
|
1273
1175
|
|
|
1274
|
-
|
|
1275
|
-
//#region src/validators/const.ts
|
|
1176
|
+
// src/validators/const.ts
|
|
1276
1177
|
/**
|
|
1277
1178
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1278
1179
|
*
|
|
@@ -1291,8 +1192,7 @@ const TWO_FORMULA_OPERATOR_COUNT = [_univerjs_core.DataValidationOperator.BETWEE
|
|
|
1291
1192
|
const FORMULA1 = "{FORMULA1}";
|
|
1292
1193
|
const FORMULA2 = "{FORMULA2}";
|
|
1293
1194
|
|
|
1294
|
-
|
|
1295
|
-
//#region src/validators/util.ts
|
|
1195
|
+
// src/validators/util.ts
|
|
1296
1196
|
function getDataValidationCellValue(cellData) {
|
|
1297
1197
|
const cellValue = getCellValueOrigin(cellData);
|
|
1298
1198
|
if (cellValue === void 0 || cellValue === null) return "";
|
|
@@ -1310,8 +1210,7 @@ function getTransformedFormula(lexerTreeBuilder, rule, position) {
|
|
|
1310
1210
|
};
|
|
1311
1211
|
}
|
|
1312
1212
|
|
|
1313
|
-
|
|
1314
|
-
//#region src/validators/date-validator.ts
|
|
1213
|
+
// src/validators/date-validator.ts
|
|
1315
1214
|
const transformDate2SerialNumber = (value, options = {}) => {
|
|
1316
1215
|
var _numfmt$parseDate;
|
|
1317
1216
|
if (value === void 0 || value === null || typeof value === "boolean") return;
|
|
@@ -1429,8 +1328,7 @@ var DateValidator = class extends BaseSheetValidator {
|
|
|
1429
1328
|
}
|
|
1430
1329
|
};
|
|
1431
1330
|
|
|
1432
|
-
|
|
1433
|
-
//#region src/validators/decimal-validator.ts
|
|
1331
|
+
// src/validators/decimal-validator.ts
|
|
1434
1332
|
function getCellValueNumber(cellValue) {
|
|
1435
1333
|
return +cellValue;
|
|
1436
1334
|
}
|
|
@@ -1507,8 +1405,124 @@ var DecimalValidator = class extends BaseSheetValidator {
|
|
|
1507
1405
|
}
|
|
1508
1406
|
};
|
|
1509
1407
|
|
|
1510
|
-
|
|
1511
|
-
|
|
1408
|
+
// src/services/dv-list-cache.service.ts
|
|
1409
|
+
let DataValidationListCacheService = class DataValidationListCacheService extends _univerjs_core.Disposable {
|
|
1410
|
+
constructor(_formulaService, _dataValidationModel) {
|
|
1411
|
+
super();
|
|
1412
|
+
this._formulaService = _formulaService;
|
|
1413
|
+
this._dataValidationModel = _dataValidationModel;
|
|
1414
|
+
_defineProperty(this, "_cache", /* @__PURE__ */ new Map());
|
|
1415
|
+
this.disposeWithMe(this._formulaService.ruleFormulaResultChanged$.subscribe(({ unitId, subUnitId, ruleId }) => {
|
|
1416
|
+
this.markRuleDirty(unitId, subUnitId, ruleId);
|
|
1417
|
+
}));
|
|
1418
|
+
this._initRuleChangeListener();
|
|
1419
|
+
}
|
|
1420
|
+
_initRuleChangeListener() {
|
|
1421
|
+
this.disposeWithMe(this._dataValidationModel.ruleChange$.subscribe((change) => {
|
|
1422
|
+
if (change.type === "remove" || change.type === "update") this.markRuleDirty(change.unitId, change.subUnitId, change.rule.uid);
|
|
1423
|
+
}));
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* Get cached list data or compute and cache it if not exists.
|
|
1427
|
+
*/
|
|
1428
|
+
getOrCompute(unitId, subUnitId, rule) {
|
|
1429
|
+
const cached = this.getCache(unitId, subUnitId, rule.uid);
|
|
1430
|
+
if (cached) return cached;
|
|
1431
|
+
const results = this._formulaService.getRuleFormulaResultSync(unitId, subUnitId, rule.uid);
|
|
1432
|
+
return this.computeAndCache(unitId, subUnitId, rule, results);
|
|
1433
|
+
}
|
|
1434
|
+
_ensureCache(unitId, subUnitId) {
|
|
1435
|
+
let unitMap = this._cache.get(unitId);
|
|
1436
|
+
if (!unitMap) {
|
|
1437
|
+
unitMap = /* @__PURE__ */ new Map();
|
|
1438
|
+
this._cache.set(unitId, unitMap);
|
|
1439
|
+
}
|
|
1440
|
+
let subUnitMap = unitMap.get(subUnitId);
|
|
1441
|
+
if (!subUnitMap) {
|
|
1442
|
+
subUnitMap = /* @__PURE__ */ new Map();
|
|
1443
|
+
unitMap.set(subUnitId, subUnitMap);
|
|
1444
|
+
}
|
|
1445
|
+
return subUnitMap;
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1448
|
+
* Get cached list data for a rule. Returns undefined if not cached.
|
|
1449
|
+
*/
|
|
1450
|
+
getCache(unitId, subUnitId, ruleId) {
|
|
1451
|
+
var _this$_cache$get;
|
|
1452
|
+
return (_this$_cache$get = this._cache.get(unitId)) === null || _this$_cache$get === void 0 || (_this$_cache$get = _this$_cache$get.get(subUnitId)) === null || _this$_cache$get === void 0 ? void 0 : _this$_cache$get.get(ruleId);
|
|
1453
|
+
}
|
|
1454
|
+
/**
|
|
1455
|
+
* Set cache for a rule.
|
|
1456
|
+
*/
|
|
1457
|
+
setCache(unitId, subUnitId, ruleId, item) {
|
|
1458
|
+
this._ensureCache(unitId, subUnitId).set(ruleId, item);
|
|
1459
|
+
}
|
|
1460
|
+
/**
|
|
1461
|
+
* Mark a rule's cache as dirty (invalidate it).
|
|
1462
|
+
* Called when formula results change.
|
|
1463
|
+
*/
|
|
1464
|
+
markRuleDirty(unitId, subUnitId, ruleId) {
|
|
1465
|
+
var _this$_cache$get2;
|
|
1466
|
+
(_this$_cache$get2 = this._cache.get(unitId)) === null || _this$_cache$get2 === void 0 || (_this$_cache$get2 = _this$_cache$get2.get(subUnitId)) === null || _this$_cache$get2 === void 0 || _this$_cache$get2.delete(ruleId);
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Clear all caches.
|
|
1470
|
+
*/
|
|
1471
|
+
clear() {
|
|
1472
|
+
this._cache.clear();
|
|
1473
|
+
}
|
|
1474
|
+
/**
|
|
1475
|
+
* Compute list data from formula result and cache it.
|
|
1476
|
+
*/
|
|
1477
|
+
computeAndCache(unitId, subUnitId, rule, formulaResult) {
|
|
1478
|
+
var _formulaResult$;
|
|
1479
|
+
const { formula1 = "", formula2 = "" } = rule;
|
|
1480
|
+
const list = (0, _univerjs_core.isFormulaString)(formula1) ? this._getRuleFormulaResultSet(formulaResult === null || formulaResult === void 0 || (_formulaResult$ = formulaResult[0]) === null || _formulaResult$ === void 0 || (_formulaResult$ = _formulaResult$.result) === null || _formulaResult$ === void 0 || (_formulaResult$ = _formulaResult$[0]) === null || _formulaResult$ === void 0 ? void 0 : _formulaResult$[0]) : (0, _univerjs_sheets.deserializeListOptions)(formula1);
|
|
1481
|
+
const colorList = formula2.split(",");
|
|
1482
|
+
const listWithColor = list.map((label, i) => ({
|
|
1483
|
+
label,
|
|
1484
|
+
color: colorList[i] || ""
|
|
1485
|
+
}));
|
|
1486
|
+
const colorMap = {};
|
|
1487
|
+
for (const item of listWithColor) if (item.color) colorMap[item.label] = item.color;
|
|
1488
|
+
const cacheItem = {
|
|
1489
|
+
list,
|
|
1490
|
+
listWithColor,
|
|
1491
|
+
colorMap,
|
|
1492
|
+
set: new Set(list)
|
|
1493
|
+
};
|
|
1494
|
+
this.setCache(unitId, subUnitId, rule.uid, cacheItem);
|
|
1495
|
+
return cacheItem;
|
|
1496
|
+
}
|
|
1497
|
+
/**
|
|
1498
|
+
* Extract string list from formula result cells.
|
|
1499
|
+
*/
|
|
1500
|
+
_getRuleFormulaResultSet(result) {
|
|
1501
|
+
if (!result) return [];
|
|
1502
|
+
const resultSet = /* @__PURE__ */ new Set();
|
|
1503
|
+
for (let i = 0, rowLen = result.length; i < rowLen; i++) {
|
|
1504
|
+
const row = result[i];
|
|
1505
|
+
if (!row) continue;
|
|
1506
|
+
for (let j = 0, colLen = row.length; j < colLen; j++) {
|
|
1507
|
+
const cell = row[j];
|
|
1508
|
+
const value = getCellValueOrigin(cell);
|
|
1509
|
+
if (value !== null && value !== void 0) {
|
|
1510
|
+
var _cell$s;
|
|
1511
|
+
if (typeof value !== "string" && typeof (cell === null || cell === void 0 ? void 0 : cell.s) === "object" && ((_cell$s = cell.s) === null || _cell$s === void 0 || (_cell$s = _cell$s.n) === null || _cell$s === void 0 ? void 0 : _cell$s.pattern)) {
|
|
1512
|
+
resultSet.add(_univerjs_core.numfmt.format(cell.s.n.pattern, value, { throws: false }));
|
|
1513
|
+
continue;
|
|
1514
|
+
}
|
|
1515
|
+
const valueStr = typeof value === "string" ? value : String(value);
|
|
1516
|
+
if (isLegalFormulaResult(valueStr)) resultSet.add(valueStr);
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
return [...resultSet];
|
|
1521
|
+
}
|
|
1522
|
+
};
|
|
1523
|
+
DataValidationListCacheService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(DataValidationFormulaService)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_data_validation.DataValidationModel))], DataValidationListCacheService);
|
|
1524
|
+
|
|
1525
|
+
// src/validators/list-validator.ts
|
|
1512
1526
|
function getRuleFormulaResultSet(result) {
|
|
1513
1527
|
if (!result) return [];
|
|
1514
1528
|
const resultSet = /* @__PURE__ */ new Set();
|
|
@@ -1654,8 +1668,7 @@ var ListValidator = class extends BaseSheetValidator {
|
|
|
1654
1668
|
}
|
|
1655
1669
|
};
|
|
1656
1670
|
|
|
1657
|
-
|
|
1658
|
-
//#region src/validators/text-length-validator.ts
|
|
1671
|
+
// src/validators/text-length-validator.ts
|
|
1659
1672
|
var TextLengthValidator = class extends BaseSheetValidator {
|
|
1660
1673
|
constructor(..._args) {
|
|
1661
1674
|
super(..._args);
|
|
@@ -1728,8 +1741,7 @@ var TextLengthValidator = class extends BaseSheetValidator {
|
|
|
1728
1741
|
}
|
|
1729
1742
|
};
|
|
1730
1743
|
|
|
1731
|
-
|
|
1732
|
-
//#region src/commands/commands/data-validation.command.ts
|
|
1744
|
+
// src/commands/commands/data-validation.command.ts
|
|
1733
1745
|
function isBlankCell(cellData) {
|
|
1734
1746
|
var _cellData$p$body;
|
|
1735
1747
|
if (!cellData) return true;
|
|
@@ -2285,8 +2297,7 @@ const RemoveSheetDataValidationCommand = {
|
|
|
2285
2297
|
}
|
|
2286
2298
|
};
|
|
2287
2299
|
|
|
2288
|
-
|
|
2289
|
-
//#region src/common/const.ts
|
|
2300
|
+
// src/common/const.ts
|
|
2290
2301
|
/**
|
|
2291
2302
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
2292
2303
|
*
|
|
@@ -2304,8 +2315,7 @@ const RemoveSheetDataValidationCommand = {
|
|
|
2304
2315
|
*/
|
|
2305
2316
|
const DATA_VALIDATION_PLUGIN_NAME = "SHEET_DATA_VALIDATION_PLUGIN";
|
|
2306
2317
|
|
|
2307
|
-
|
|
2308
|
-
//#region src/controllers/dv-formula.controller.ts
|
|
2318
|
+
// src/controllers/dv-formula.controller.ts
|
|
2309
2319
|
let DataValidationFormulaController = class DataValidationFormulaController extends _univerjs_core.Disposable {
|
|
2310
2320
|
constructor(_univerInstanceService, _permissionService, _lexerTreeBuilder) {
|
|
2311
2321
|
super();
|
|
@@ -2349,13 +2359,11 @@ DataValidationFormulaController = __decorate([
|
|
|
2349
2359
|
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_engine_formula.LexerTreeBuilder))
|
|
2350
2360
|
], DataValidationFormulaController);
|
|
2351
2361
|
|
|
2352
|
-
|
|
2353
|
-
//#region package.json
|
|
2362
|
+
// package.json
|
|
2354
2363
|
var name = "@univerjs/sheets-data-validation";
|
|
2355
|
-
var version = "1.
|
|
2364
|
+
var version = "1.5.0";
|
|
2356
2365
|
|
|
2357
|
-
|
|
2358
|
-
//#region src/config/config.ts
|
|
2366
|
+
// src/config/config.ts
|
|
2359
2367
|
/**
|
|
2360
2368
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
2361
2369
|
*
|
|
@@ -2375,8 +2383,7 @@ const SHEETS_DATA_VALIDATION_PLUGIN_CONFIG_KEY = "sheets-data-validation.config"
|
|
|
2375
2383
|
const configSymbol = Symbol(SHEETS_DATA_VALIDATION_PLUGIN_CONFIG_KEY);
|
|
2376
2384
|
const defaultPluginConfig = {};
|
|
2377
2385
|
|
|
2378
|
-
|
|
2379
|
-
//#region src/controllers/dv-formula-ref-range.controller.ts
|
|
2386
|
+
// src/controllers/dv-formula-ref-range.controller.ts
|
|
2380
2387
|
let DataValidationFormulaRefRangeController = class DataValidationFormulaRefRangeController extends _univerjs_core.Disposable {
|
|
2381
2388
|
constructor(_dataValidationModel, _formulaRefRangeService, _validatorRegistryService) {
|
|
2382
2389
|
super();
|
|
@@ -2530,8 +2537,7 @@ DataValidationFormulaRefRangeController = __decorate([
|
|
|
2530
2537
|
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_data_validation.DataValidatorRegistryService))
|
|
2531
2538
|
], DataValidationFormulaRefRangeController);
|
|
2532
2539
|
|
|
2533
|
-
|
|
2534
|
-
//#region src/controllers/dv-ref-range.controller.ts
|
|
2540
|
+
// src/controllers/dv-ref-range.controller.ts
|
|
2535
2541
|
let DataValidationRefRangeController = class DataValidationRefRangeController extends _univerjs_core.Disposable {
|
|
2536
2542
|
constructor(_dataValidationModel, _injector, _refRangeService, _dataValidationFormulaService, _formulaRefRangeService, _validatorRegistryService) {
|
|
2537
2543
|
super();
|
|
@@ -2727,8 +2733,7 @@ DataValidationRefRangeController = __decorate([
|
|
|
2727
2733
|
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_data_validation.DataValidatorRegistryService))
|
|
2728
2734
|
], DataValidationRefRangeController);
|
|
2729
2735
|
|
|
2730
|
-
|
|
2731
|
-
//#region src/controllers/dv-sheet.controller.ts
|
|
2736
|
+
// src/controllers/dv-sheet.controller.ts
|
|
2732
2737
|
let SheetDataValidationSheetController = class SheetDataValidationSheetController extends _univerjs_core.Disposable {
|
|
2733
2738
|
constructor(_sheetInterceptorService, _univerInstanceService, _sheetDataValidationModel) {
|
|
2734
2739
|
super();
|
|
@@ -2831,8 +2836,7 @@ SheetDataValidationSheetController = __decorate([
|
|
|
2831
2836
|
__decorateParam(2, (0, _univerjs_core.Inject)(SheetDataValidationModel))
|
|
2832
2837
|
], SheetDataValidationSheetController);
|
|
2833
2838
|
|
|
2834
|
-
|
|
2835
|
-
//#region src/validators/any-validator.ts
|
|
2839
|
+
// src/validators/any-validator.ts
|
|
2836
2840
|
var AnyValidator = class extends BaseSheetValidator {
|
|
2837
2841
|
constructor(..._args) {
|
|
2838
2842
|
super(..._args);
|
|
@@ -2861,8 +2865,7 @@ var AnyValidator = class extends BaseSheetValidator {
|
|
|
2861
2865
|
}
|
|
2862
2866
|
};
|
|
2863
2867
|
|
|
2864
|
-
|
|
2865
|
-
//#region src/validators/custom-validator.ts
|
|
2868
|
+
// src/validators/custom-validator.ts
|
|
2866
2869
|
var CustomFormulaValidator = class extends BaseSheetValidator {
|
|
2867
2870
|
constructor(..._args) {
|
|
2868
2871
|
super(..._args);
|
|
@@ -2912,8 +2915,7 @@ var CustomFormulaValidator = class extends BaseSheetValidator {
|
|
|
2912
2915
|
}
|
|
2913
2916
|
};
|
|
2914
2917
|
|
|
2915
|
-
|
|
2916
|
-
//#region src/validators/list-multiple-validator.ts
|
|
2918
|
+
// src/validators/list-multiple-validator.ts
|
|
2917
2919
|
/**
|
|
2918
2920
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
2919
2921
|
*
|
|
@@ -2941,8 +2943,7 @@ var ListMultipleValidator = class extends ListValidator {
|
|
|
2941
2943
|
}
|
|
2942
2944
|
};
|
|
2943
2945
|
|
|
2944
|
-
|
|
2945
|
-
//#region src/validators/whole-validator.ts
|
|
2946
|
+
// src/validators/whole-validator.ts
|
|
2946
2947
|
var WholeValidator = class extends BaseSheetValidator {
|
|
2947
2948
|
constructor(..._args) {
|
|
2948
2949
|
super(..._args);
|
|
@@ -3019,8 +3020,7 @@ var WholeValidator = class extends BaseSheetValidator {
|
|
|
3019
3020
|
}
|
|
3020
3021
|
};
|
|
3021
3022
|
|
|
3022
|
-
|
|
3023
|
-
//#region src/controllers/dv.controller.ts
|
|
3023
|
+
// src/controllers/dv.controller.ts
|
|
3024
3024
|
let DataValidationController = class DataValidationController extends _univerjs_core.RxDisposable {
|
|
3025
3025
|
constructor(_univerInstanceService, _dataValidatorRegistryService, _injector, _selectionManagerService, _sheetInterceptorService, _sheetDataValidationModel) {
|
|
3026
3026
|
super();
|
|
@@ -3088,8 +3088,7 @@ DataValidationController = __decorate([
|
|
|
3088
3088
|
__decorateParam(5, (0, _univerjs_core.Inject)(SheetDataValidationModel))
|
|
3089
3089
|
], DataValidationController);
|
|
3090
3090
|
|
|
3091
|
-
|
|
3092
|
-
//#region src/services/dv-validator.service.ts
|
|
3091
|
+
// src/services/dv-validator.service.ts
|
|
3093
3092
|
let SheetsDataValidationValidatorService = class SheetsDataValidationValidatorService extends _univerjs_core.Disposable {
|
|
3094
3093
|
constructor(_univerInstanceService, _sheetDataValidationModel, _dataValidationCacheService, _lifecycleService) {
|
|
3095
3094
|
super();
|
|
@@ -3254,8 +3253,7 @@ SheetsDataValidationValidatorService = __decorate([
|
|
|
3254
3253
|
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_core.LifecycleService))
|
|
3255
3254
|
], SheetsDataValidationValidatorService);
|
|
3256
3255
|
|
|
3257
|
-
|
|
3258
|
-
//#region src/plugin.ts
|
|
3256
|
+
// src/plugin.ts
|
|
3259
3257
|
let UniverSheetsDataValidationPlugin = class UniverSheetsDataValidationPlugin extends _univerjs_core.Plugin {
|
|
3260
3258
|
constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
|
|
3261
3259
|
super();
|
|
@@ -3317,8 +3315,7 @@ UniverSheetsDataValidationPlugin = __decorate([
|
|
|
3317
3315
|
__decorateParam(3, _univerjs_core.IConfigService)
|
|
3318
3316
|
], UniverSheetsDataValidationPlugin);
|
|
3319
3317
|
|
|
3320
|
-
|
|
3321
|
-
//#region src/utils/create.ts
|
|
3318
|
+
// src/utils/create.ts
|
|
3322
3319
|
function createDefaultNewRule(accessor) {
|
|
3323
3320
|
const currentRanges = accessor.get(_univerjs_sheets.SheetsSelectionsService).getCurrentSelections().map((s) => s.range);
|
|
3324
3321
|
return {
|
|
@@ -3335,14 +3332,12 @@ function createDefaultNewRule(accessor) {
|
|
|
3335
3332
|
};
|
|
3336
3333
|
}
|
|
3337
3334
|
|
|
3338
|
-
|
|
3339
|
-
//#region src/index.ts
|
|
3335
|
+
// src/index.ts
|
|
3340
3336
|
const CUSTOM_FORMULA_INPUT_NAME = "sheets-data-validation.custom-formula-input";
|
|
3341
3337
|
const BASE_FORMULA_INPUT_NAME = "sheets-data-validation.formula-input";
|
|
3342
3338
|
const LIST_FORMULA_INPUT_NAME = "sheets-data-validation.list-formula-input";
|
|
3343
3339
|
const CHECKBOX_FORMULA_INPUT_NAME = "sheets-data-validation.checkbox-formula-input";
|
|
3344
3340
|
|
|
3345
|
-
//#endregion
|
|
3346
3341
|
exports.AddSheetDataValidationCommand = AddSheetDataValidationCommand;
|
|
3347
3342
|
exports.BASE_FORMULA_INPUT_NAME = BASE_FORMULA_INPUT_NAME;
|
|
3348
3343
|
exports.CHECKBOX_FORMULA_1 = CHECKBOX_FORMULA_1;
|