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