@univerjs/sheets-data-validation 0.4.0-alpha.1 → 0.4.0-experimental.d7288c0-20241017
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +207 -151
- package/lib/types/index.d.ts +1 -2
- package/lib/types/models/sheet-data-validation-model.d.ts +11 -3
- package/lib/types/services/dv-cache.service.d.ts +13 -2
- package/lib/types/services/dv-custom-formula.service.d.ts +3 -3
- package/lib/types/services/dv-formula.service.d.ts +2 -2
- package/lib/types/services/dv-validator-service.d.ts +6 -4
- package/lib/umd/index.js +1 -1
- package/package.json +8 -8
- package/LICENSE +0 -176
package/lib/es/index.js
CHANGED
|
@@ -2,16 +2,41 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
-
import { ObjectMatrix, Range,
|
|
5
|
+
import { Inject, ICommandService, Disposable, ObjectMatrix, Range, Injector, UniverInstanceType, DataValidationType, isFormulaString, IUniverInstanceService, getOriginCellValue, debounce, Rectangle, Tools, DataValidationStatus, WrapStrategy, DataValidationOperator, numfmt, DataValidationRenderMode, CommandType, IUndoRedoService, sequenceExecute, CellValueType, RxDisposable, toDisposable, IPermissionService, isRangesEqual, LifecycleService, LifecycleStages, bufferDebounceTime, DependentOn, Plugin, IConfigService } from "@univerjs/core";
|
|
6
6
|
import { DataValidationModel, DataValidatorRegistryService, UpdateRuleType, BaseDataValidator, TextLengthErrorTitleMap, AddDataValidationMutation, RemoveDataValidationMutation, UpdateDataValidationMutation, getRuleSetting, getRuleOptions, UniverDataValidationPlugin } from "@univerjs/data-validation";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { Subject } from "rxjs";
|
|
7
|
+
import { SetRangeValuesMutation, RemoveSheetMutation, getSheetCommandTarget, SetRangeValuesUndoMutationFactory, SheetsSelectionsService, SheetInterceptorService, ClearSelectionAllCommand, WorksheetViewPermission, RefRangeService, handleCommonDefaultRangeChangeWithEffectRefCommands, RemoveSheetCommand } from "@univerjs/sheets";
|
|
8
|
+
import { Subject, bufferWhen, filter } from "rxjs";
|
|
10
9
|
import { LexerTreeBuilder, isReferenceString, sequenceNodeType, deserializeRangeWithSheet, ERROR_TYPE_SET } from "@univerjs/engine-formula";
|
|
11
10
|
import { RegisterOtherFormulaService, FormulaRefRangeService } from "@univerjs/sheets-formula";
|
|
12
|
-
const DATA_VALIDATION_PLUGIN_NAME = "SHEET_DATA_VALIDATION_PLUGIN"
|
|
13
|
-
|
|
11
|
+
const DATA_VALIDATION_PLUGIN_NAME = "SHEET_DATA_VALIDATION_PLUGIN";
|
|
12
|
+
var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor, __decorateClass$9 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
13
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
14
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
15
|
+
return kind && result && __defProp$9(target, key, result), result;
|
|
16
|
+
}, "__decorateClass$9"), __decorateParam$9 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$9"), _a;
|
|
17
|
+
let DataValidationCacheService = (_a = class extends Disposable {
|
|
18
|
+
constructor(_commandService) {
|
|
19
|
+
super();
|
|
14
20
|
__publicField(this, "_cacheMatrix", /* @__PURE__ */ new Map());
|
|
21
|
+
__publicField(this, "_dirtyRanges$", new Subject());
|
|
22
|
+
__publicField(this, "dirtyRanges$", this._dirtyRanges$.asObservable());
|
|
23
|
+
this._commandService = _commandService, this._initDirtyRanges();
|
|
24
|
+
}
|
|
25
|
+
_initDirtyRanges() {
|
|
26
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
|
|
27
|
+
if (commandInfo.id === SetRangeValuesMutation.id) {
|
|
28
|
+
const { cellValue, unitId, subUnitId } = commandInfo.params;
|
|
29
|
+
if (cellValue) {
|
|
30
|
+
const range = new ObjectMatrix(cellValue).getDataRange();
|
|
31
|
+
if (range.endRow === -1) return;
|
|
32
|
+
this._dirtyRanges$.next({
|
|
33
|
+
unitId,
|
|
34
|
+
subUnitId,
|
|
35
|
+
ranges: [range]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
15
40
|
}
|
|
16
41
|
_ensureCache(unitId, subUnitId) {
|
|
17
42
|
let unitMap = this._cacheMatrix.get(unitId);
|
|
@@ -45,7 +70,7 @@ const DATA_VALIDATION_PLUGIN_NAME = "SHEET_DATA_VALIDATION_PLUGIN", _DataValidat
|
|
|
45
70
|
const item = cache.getValue(row, col);
|
|
46
71
|
item && item.temp === !0 && cache.realDeleteValue(row, col);
|
|
47
72
|
});
|
|
48
|
-
});
|
|
73
|
+
}), this._dirtyRanges$.next({ unitId, subUnitId, ranges: [...oldRanges, ...newRanges] });
|
|
49
74
|
}
|
|
50
75
|
markRangeDirty(unitId, subUnitId, ranges) {
|
|
51
76
|
const cache = this._ensureCache(unitId, subUnitId);
|
|
@@ -53,10 +78,10 @@ const DATA_VALIDATION_PLUGIN_NAME = "SHEET_DATA_VALIDATION_PLUGIN", _DataValidat
|
|
|
53
78
|
Range.foreach(range, (row, col) => {
|
|
54
79
|
cache.setValue(row, col, void 0);
|
|
55
80
|
});
|
|
56
|
-
});
|
|
81
|
+
}), this._dirtyRanges$.next({ unitId, subUnitId, ranges });
|
|
57
82
|
}
|
|
58
83
|
markCellDirty(unitId, subUnitId, row, col) {
|
|
59
|
-
this._ensureCache(unitId, subUnitId).setValue(row, col, void 0);
|
|
84
|
+
this._ensureCache(unitId, subUnitId).setValue(row, col, void 0), this._dirtyRanges$.next({ unitId, subUnitId, ranges: [{ startRow: row, startColumn: col, endRow: row, endColumn: col }] });
|
|
60
85
|
}
|
|
61
86
|
_deleteRange(unitId, subUnitId, ranges) {
|
|
62
87
|
const cache = this._ensureCache(unitId, subUnitId);
|
|
@@ -64,7 +89,7 @@ const DATA_VALIDATION_PLUGIN_NAME = "SHEET_DATA_VALIDATION_PLUGIN", _DataValidat
|
|
|
64
89
|
Range.foreach(range, (row, col) => {
|
|
65
90
|
cache.realDeleteValue(row, col);
|
|
66
91
|
});
|
|
67
|
-
});
|
|
92
|
+
}), this._dirtyRanges$.next({ unitId, subUnitId, ranges });
|
|
68
93
|
}
|
|
69
94
|
getValue(unitId, subUnitId, row, col) {
|
|
70
95
|
return this._ensureCache(unitId, subUnitId).getValue(row, col);
|
|
@@ -72,9 +97,10 @@ const DATA_VALIDATION_PLUGIN_NAME = "SHEET_DATA_VALIDATION_PLUGIN", _DataValidat
|
|
|
72
97
|
setValue(unitId, subUnitId, row, col, value) {
|
|
73
98
|
return this._ensureCache(unitId, subUnitId).setValue(row, col, value);
|
|
74
99
|
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
|
|
100
|
+
}, __name(_a, "DataValidationCacheService"), _a);
|
|
101
|
+
DataValidationCacheService = __decorateClass$9([
|
|
102
|
+
__decorateParam$9(0, Inject(ICommandService))
|
|
103
|
+
], DataValidationCacheService);
|
|
78
104
|
var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
79
105
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
80
106
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -84,9 +110,9 @@ function transformFormula(lexerTreeBuilder, formula, originRow, originCol, targe
|
|
|
84
110
|
return lexerTreeBuilder.moveFormulaRefOffset(formula, targetCol - originCol, targetRow - originRow);
|
|
85
111
|
}
|
|
86
112
|
__name(transformFormula, "transformFormula");
|
|
87
|
-
var
|
|
88
|
-
let DataValidationCustomFormulaService = (
|
|
89
|
-
constructor(_instanceSrv, _registerOtherFormulaService, _lexerTreeBuilder, _dataValidationModel, _dataValidationCacheService,
|
|
113
|
+
var _a2;
|
|
114
|
+
let DataValidationCustomFormulaService = (_a2 = class extends Disposable {
|
|
115
|
+
constructor(_instanceSrv, _registerOtherFormulaService, _lexerTreeBuilder, _dataValidationModel, _dataValidationCacheService, _injector) {
|
|
90
116
|
super();
|
|
91
117
|
__publicField(this, "_formulaMap", /* @__PURE__ */ new Map());
|
|
92
118
|
/**
|
|
@@ -97,7 +123,7 @@ let DataValidationCustomFormulaService = (_a = class extends Disposable {
|
|
|
97
123
|
* reflect of formulaId to cell, only store transformable formula
|
|
98
124
|
*/
|
|
99
125
|
__publicField(this, "_formulaCellMap", /* @__PURE__ */ new Map());
|
|
100
|
-
this._instanceSrv = _instanceSrv, this._registerOtherFormulaService = _registerOtherFormulaService, this._lexerTreeBuilder = _lexerTreeBuilder, this._dataValidationModel = _dataValidationModel, this._dataValidationCacheService = _dataValidationCacheService, this.
|
|
126
|
+
this._instanceSrv = _instanceSrv, this._registerOtherFormulaService = _registerOtherFormulaService, this._lexerTreeBuilder = _lexerTreeBuilder, this._dataValidationModel = _dataValidationModel, this._dataValidationCacheService = _dataValidationCacheService, this._injector = _injector, this._initFormulaResultHandler();
|
|
101
127
|
}
|
|
102
128
|
_initFormulaResultHandler() {
|
|
103
129
|
this.disposeWithMe(this._registerOtherFormulaService.formulaResult$.subscribe((resultMap) => {
|
|
@@ -107,8 +133,8 @@ let DataValidationCustomFormulaService = (_a = class extends Disposable {
|
|
|
107
133
|
for (const subUnitId in unitMap) {
|
|
108
134
|
const results = unitMap[subUnitId], { formulaCellMap, ruleFormulaMap } = this._ensureMaps(unitId, subUnitId);
|
|
109
135
|
results.forEach((result) => {
|
|
110
|
-
var
|
|
111
|
-
const ruleInfo = ruleFormulaMap.get((
|
|
136
|
+
var _a12, _b;
|
|
137
|
+
const ruleInfo = ruleFormulaMap.get((_a12 = result.extra) == null ? void 0 : _a12.ruleId), cellInfo = formulaCellMap.get(result.formulaId), rule = this._dataValidationModel.getRuleById(unitId, subUnitId, (_b = result.extra) == null ? void 0 : _b.ruleId);
|
|
112
138
|
rule && ruleInfo && !ruleInfo.isTransformable && this._dataValidationCacheService.markRangeDirty(unitId, subUnitId, rule.ranges), cellInfo && this._dataValidationCacheService.markCellDirty(unitId, subUnitId, cellInfo.row, cellInfo.column);
|
|
113
139
|
});
|
|
114
140
|
}
|
|
@@ -186,8 +212,8 @@ let DataValidationCustomFormulaService = (_a = class extends Disposable {
|
|
|
186
212
|
});
|
|
187
213
|
}), newRanges.forEach((range) => {
|
|
188
214
|
Range.foreach(range, (row, col) => {
|
|
189
|
-
var
|
|
190
|
-
const oldValue = (
|
|
215
|
+
var _a12;
|
|
216
|
+
const oldValue = (_a12 = formulaMap.getValue(row, col)) != null ? _a12 : {};
|
|
191
217
|
if (oldValue.ruleId !== ruleId) {
|
|
192
218
|
const oldRuleFormula = ruleFormulaMap.get(oldValue.ruleId);
|
|
193
219
|
if (oldRuleFormula != null && oldRuleFormula.isTransformable && deleteFormulaIdList.add(oldValue.formulaId), isTransformable) {
|
|
@@ -226,21 +252,21 @@ let DataValidationCustomFormulaService = (_a = class extends Disposable {
|
|
|
226
252
|
const { ruleFormulaMap } = this._ensureMaps(unitId, subUnitId);
|
|
227
253
|
return ruleFormulaMap.get(ruleId);
|
|
228
254
|
}
|
|
229
|
-
}, __name(
|
|
255
|
+
}, __name(_a2, "DataValidationCustomFormulaService"), _a2);
|
|
230
256
|
DataValidationCustomFormulaService = __decorateClass$8([
|
|
231
257
|
__decorateParam$8(0, IUniverInstanceService),
|
|
232
258
|
__decorateParam$8(1, Inject(RegisterOtherFormulaService)),
|
|
233
259
|
__decorateParam$8(2, Inject(LexerTreeBuilder)),
|
|
234
260
|
__decorateParam$8(3, Inject(DataValidationModel)),
|
|
235
261
|
__decorateParam$8(4, Inject(DataValidationCacheService)),
|
|
236
|
-
__decorateParam$8(5,
|
|
262
|
+
__decorateParam$8(5, Inject(Injector))
|
|
237
263
|
], DataValidationCustomFormulaService);
|
|
238
264
|
var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
239
265
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
240
266
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
241
267
|
return kind && result && __defProp$7(target, key, result), result;
|
|
242
|
-
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"),
|
|
243
|
-
let DataValidationFormulaService = (
|
|
268
|
+
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a3;
|
|
269
|
+
let DataValidationFormulaService = (_a3 = class extends Disposable {
|
|
244
270
|
constructor(_instanceService, _registerOtherFormulaService, _dataValidationCacheService, _dataValidationModel) {
|
|
245
271
|
super();
|
|
246
272
|
__publicField(this, "_formulaRuleMap", /* @__PURE__ */ new Map());
|
|
@@ -254,8 +280,8 @@ let DataValidationFormulaService = (_a2 = class extends Disposable {
|
|
|
254
280
|
for (const subUnitId in unitMap) {
|
|
255
281
|
const results = unitMap[subUnitId], formulaMap = this._ensureRuleFormulaMap(unitId, subUnitId);
|
|
256
282
|
results.forEach((result) => {
|
|
257
|
-
var
|
|
258
|
-
if (formulaMap.get((
|
|
283
|
+
var _a12, _b;
|
|
284
|
+
if (formulaMap.get((_a12 = result.extra) == null ? void 0 : _a12.ruleId)) {
|
|
259
285
|
const rule = this._dataValidationModel.getRuleById(unitId, subUnitId, (_b = result.extra) == null ? void 0 : _b.ruleId);
|
|
260
286
|
rule && this._dataValidationCacheService.markRangeDirty(unitId, subUnitId, rule.ranges);
|
|
261
287
|
}
|
|
@@ -339,7 +365,7 @@ let DataValidationFormulaService = (_a2 = class extends Disposable {
|
|
|
339
365
|
getRuleFormulaInfo(unitId, subUnitId, ruleId) {
|
|
340
366
|
return this._ensureRuleFormulaMap(unitId, subUnitId).get(ruleId);
|
|
341
367
|
}
|
|
342
|
-
}, __name(
|
|
368
|
+
}, __name(_a3, "DataValidationFormulaService"), _a3);
|
|
343
369
|
DataValidationFormulaService = __decorateClass$7([
|
|
344
370
|
__decorateParam$7(0, IUniverInstanceService),
|
|
345
371
|
__decorateParam$7(1, Inject(RegisterOtherFormulaService)),
|
|
@@ -351,12 +377,12 @@ function getCellValueOrigin(cell) {
|
|
|
351
377
|
}
|
|
352
378
|
__name(getCellValueOrigin, "getCellValueOrigin");
|
|
353
379
|
function getStringCellValue(cell) {
|
|
354
|
-
var
|
|
355
|
-
return String((
|
|
380
|
+
var _a12;
|
|
381
|
+
return String((_a12 = getCellValueOrigin(cell)) != null ? _a12 : "");
|
|
356
382
|
}
|
|
357
383
|
__name(getStringCellValue, "getStringCellValue");
|
|
358
|
-
var
|
|
359
|
-
const Interval = (
|
|
384
|
+
var _a4;
|
|
385
|
+
const Interval = (_a4 = class {
|
|
360
386
|
/**
|
|
361
387
|
* Accept two comparable values and creates new instance of interval
|
|
362
388
|
* Predicate Interval.comparable_less(low, high) supposed to return true on these values
|
|
@@ -371,7 +397,7 @@ const Interval = (_a3 = class {
|
|
|
371
397
|
* @returns {Interval}
|
|
372
398
|
*/
|
|
373
399
|
clone() {
|
|
374
|
-
return new
|
|
400
|
+
return new _a4(this.low, this.high);
|
|
375
401
|
}
|
|
376
402
|
/**
|
|
377
403
|
* Propery max returns clone of this interval
|
|
@@ -418,7 +444,7 @@ const Interval = (_a3 = class {
|
|
|
418
444
|
* @returns {Interval}
|
|
419
445
|
*/
|
|
420
446
|
merge(other_interval) {
|
|
421
|
-
return new
|
|
447
|
+
return new _a4(
|
|
422
448
|
this.low === void 0 ? other_interval.low : this.low < other_interval.low ? this.low : other_interval.low,
|
|
423
449
|
this.high === void 0 ? other_interval.high : this.high > other_interval.high ? this.high : other_interval.high
|
|
424
450
|
);
|
|
@@ -447,7 +473,7 @@ const Interval = (_a3 = class {
|
|
|
447
473
|
static comparable_less_than(val1, val2) {
|
|
448
474
|
return val1 < val2;
|
|
449
475
|
}
|
|
450
|
-
}, __name(
|
|
476
|
+
}, __name(_a4, "Interval"), _a4), RB_TREE_COLOR_RED = 0, RB_TREE_COLOR_BLACK = 1, _Node = class _Node {
|
|
451
477
|
constructor(key = void 0, value = void 0, left = null, right = null, parent = null, color = RB_TREE_COLOR_BLACK) {
|
|
452
478
|
if (this.left = left, this.right = right, this.parent = parent, this.color = color, this.item = { key, value }, key && key instanceof Array && key.length === 2 && !Number.isNaN(key[0]) && !Number.isNaN(key[1])) {
|
|
453
479
|
let [low, high] = key;
|
|
@@ -780,8 +806,8 @@ const _RuleMatrix = class _RuleMatrix {
|
|
|
780
806
|
this._unitId = _unitId, this._subUnitId = _subUnitId, this._univerInstanceService = _univerInstanceService, this._disableTree = _disableTree, this._map = value, this._buildTree();
|
|
781
807
|
}
|
|
782
808
|
get _worksheet() {
|
|
783
|
-
var
|
|
784
|
-
return (
|
|
809
|
+
var _a12;
|
|
810
|
+
return (_a12 = this._univerInstanceService.getUnit(this._unitId, UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a12.getSheetBySheetId(this._subUnitId);
|
|
785
811
|
}
|
|
786
812
|
addRule(rule) {
|
|
787
813
|
if (!this._worksheet)
|
|
@@ -831,8 +857,8 @@ const _RuleMatrix = class _RuleMatrix {
|
|
|
831
857
|
const mutations = [];
|
|
832
858
|
let deleteIndex = 0;
|
|
833
859
|
return rules.forEach((rule, index) => {
|
|
834
|
-
var
|
|
835
|
-
const newRanges = (
|
|
860
|
+
var _a12;
|
|
861
|
+
const newRanges = (_a12 = this._map.get(rule.uid)) != null ? _a12 : [], oldRanges = rule.ranges;
|
|
836
862
|
newRanges.length !== 0 && (newRanges.length !== oldRanges.length || newRanges.some((range, i) => !Rectangle.equals(range, oldRanges[i]))) && mutations.push({
|
|
837
863
|
type: "update",
|
|
838
864
|
ruleId: rule.uid,
|
|
@@ -849,8 +875,8 @@ const _RuleMatrix = class _RuleMatrix {
|
|
|
849
875
|
const mutations = [];
|
|
850
876
|
let deleteIndex = 0;
|
|
851
877
|
return rules.forEach((rule, index) => {
|
|
852
|
-
var
|
|
853
|
-
const newRanges = (
|
|
878
|
+
var _a12;
|
|
879
|
+
const newRanges = (_a12 = this._map.get(rule.uid)) != null ? _a12 : [], oldRanges = rule.ranges;
|
|
854
880
|
newRanges.length !== 0 && (newRanges.length !== oldRanges.length || newRanges.some((range, i) => !Rectangle.equals(range, oldRanges[i]))) && mutations.push({
|
|
855
881
|
type: "update",
|
|
856
882
|
ruleId: rule.uid,
|
|
@@ -862,8 +888,8 @@ const _RuleMatrix = class _RuleMatrix {
|
|
|
862
888
|
index: index - deleteIndex
|
|
863
889
|
}), deleteIndex++);
|
|
864
890
|
}), Array.from(additionRules).forEach((rule) => {
|
|
865
|
-
var
|
|
866
|
-
const newRanges = (
|
|
891
|
+
var _a12;
|
|
892
|
+
const newRanges = (_a12 = this._map.get(rule.uid)) != null ? _a12 : [];
|
|
867
893
|
mutations.push({
|
|
868
894
|
type: "add",
|
|
869
895
|
rule: {
|
|
@@ -898,8 +924,8 @@ var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPrope
|
|
|
898
924
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
899
925
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
900
926
|
return kind && result && __defProp$6(target, key, result), result;
|
|
901
|
-
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"),
|
|
902
|
-
let SheetDataValidationModel = (
|
|
927
|
+
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a5;
|
|
928
|
+
let SheetDataValidationModel = (_a5 = class extends Disposable {
|
|
903
929
|
constructor(_dataValidationModel, _univerInstanceService, _dataValidatorRegistryService, _dataValidationCacheService, _dataValidationFormulaService, _dataValidationCustomFormulaService, _commandService) {
|
|
904
930
|
super();
|
|
905
931
|
__publicField(this, "_ruleMatrixMap", /* @__PURE__ */ new Map());
|
|
@@ -960,7 +986,7 @@ let SheetDataValidationModel = (_a4 = class extends Disposable {
|
|
|
960
986
|
return matrix || (matrix = new RuleMatrix(/* @__PURE__ */ new Map(), unitId, subUnitId, this._univerInstanceService), unitMap.set(subUnitId, matrix)), matrix;
|
|
961
987
|
}
|
|
962
988
|
_addRuleSideEffect(unitId, subUnitId, rule) {
|
|
963
|
-
this._ensureRuleMatrix(unitId, subUnitId).addRule(rule), this._dataValidationCacheService.addRule(unitId, subUnitId, rule), this._dataValidationFormulaService.addRule(unitId, subUnitId, rule.uid, rule.formula1, rule.formula2), this._dataValidationCustomFormulaService.addRule(unitId, subUnitId, rule);
|
|
989
|
+
this._ensureRuleMatrix(unitId, subUnitId).addRule(rule), this._dataValidationCacheService.addRule(unitId, subUnitId, rule), this._dataValidationFormulaService.addRule(unitId, subUnitId, rule.uid, rule.formula1, rule.formula2), rule.type === DataValidationType.CUSTOM && this._dataValidationCustomFormulaService.addRule(unitId, subUnitId, rule);
|
|
964
990
|
}
|
|
965
991
|
_addRule(unitId, subUnitId, rule) {
|
|
966
992
|
(Array.isArray(rule) ? rule : [rule]).forEach((item) => {
|
|
@@ -969,10 +995,13 @@ let SheetDataValidationModel = (_a4 = class extends Disposable {
|
|
|
969
995
|
}
|
|
970
996
|
_updateRule(unitId, subUnitId, ruleId, oldRule, payload) {
|
|
971
997
|
const ruleMatrix = this._ensureRuleMatrix(unitId, subUnitId);
|
|
972
|
-
payload.type === UpdateRuleType.RANGE ? (ruleMatrix.updateRange(ruleId, payload.payload), this._dataValidationCacheService.updateRuleRanges(unitId, subUnitId, ruleId, payload.payload, oldRule.ranges), this._dataValidationCustomFormulaService.updateRuleRanges(unitId, subUnitId, ruleId, oldRule.ranges, payload.payload)) : payload.type === UpdateRuleType.SETTING && (this._dataValidationCacheService.markRangeDirty(unitId, subUnitId, oldRule.ranges), this._dataValidationFormulaService.updateRuleFormulaText(unitId, subUnitId, ruleId, payload.payload.formula1, payload.payload.formula2), this._dataValidationCustomFormulaService.updateRuleFormula(unitId, subUnitId, ruleId, oldRule.ranges, payload.payload.formula1)
|
|
998
|
+
payload.type === UpdateRuleType.RANGE ? (ruleMatrix.updateRange(ruleId, payload.payload), this._dataValidationCacheService.updateRuleRanges(unitId, subUnitId, ruleId, payload.payload, oldRule.ranges), oldRule.type === DataValidationType.CUSTOM && this._dataValidationCustomFormulaService.updateRuleRanges(unitId, subUnitId, ruleId, oldRule.ranges, payload.payload)) : payload.type === UpdateRuleType.SETTING && (this._dataValidationCacheService.markRangeDirty(unitId, subUnitId, oldRule.ranges), this._dataValidationFormulaService.updateRuleFormulaText(unitId, subUnitId, ruleId, payload.payload.formula1, payload.payload.formula2), oldRule.type === DataValidationType.CUSTOM ? this._dataValidationCustomFormulaService.updateRuleFormula(unitId, subUnitId, ruleId, oldRule.ranges, payload.payload.formula1) : payload.payload.type === DataValidationType.CUSTOM && this._dataValidationCustomFormulaService.addRule(unitId, subUnitId, {
|
|
999
|
+
...oldRule,
|
|
1000
|
+
...payload.payload
|
|
1001
|
+
}));
|
|
973
1002
|
}
|
|
974
1003
|
_removeRule(unitId, subUnitId, oldRule) {
|
|
975
|
-
this._ensureRuleMatrix(unitId, subUnitId).removeRule(oldRule), this._dataValidationCacheService.removeRule(unitId, subUnitId, oldRule);
|
|
1004
|
+
this._ensureRuleMatrix(unitId, subUnitId).removeRule(oldRule), this._dataValidationCacheService.removeRule(unitId, subUnitId, oldRule), oldRule.type === DataValidationType.CUSTOM && this._dataValidationCustomFormulaService.deleteByRuleId(unitId, subUnitId, oldRule.uid);
|
|
976
1005
|
}
|
|
977
1006
|
getValidator(type) {
|
|
978
1007
|
return this._dataValidatorRegistryService.getValidatorItem(type);
|
|
@@ -985,22 +1014,26 @@ let SheetDataValidationModel = (_a4 = class extends Disposable {
|
|
|
985
1014
|
if (ruleId)
|
|
986
1015
|
return this._dataValidationModel.getRuleById(unitId, subUnitId, ruleId);
|
|
987
1016
|
}
|
|
988
|
-
validator(
|
|
989
|
-
const { col, row, unitId, subUnitId, worksheet } = pos, ruleId = rule.uid, onCompete = /* @__PURE__ */ __name((status, changed) => {
|
|
1017
|
+
validator(rule, pos, _onCompete) {
|
|
1018
|
+
const { col, row, unitId, subUnitId, worksheet } = pos, ruleId = rule.uid, formula1 = rule.formula1, formula2 = rule.formula2, onCompete = /* @__PURE__ */ __name((status, changed) => {
|
|
990
1019
|
_onCompete && _onCompete(status, changed), changed && this._validStatusChange$.next({
|
|
991
1020
|
unitId,
|
|
992
1021
|
subUnitId,
|
|
993
1022
|
ruleId: rule.uid,
|
|
994
|
-
status
|
|
1023
|
+
status,
|
|
1024
|
+
row,
|
|
1025
|
+
col
|
|
995
1026
|
});
|
|
996
|
-
}, "onCompete"), validator = this.getValidator(rule.type), cellRaw = worksheet.getCellRaw(row, col), cellValue = getCellValueOrigin(cellRaw), interceptValue = getCellValueOrigin(cell);
|
|
1027
|
+
}, "onCompete"), cell = worksheet.getCellValueOnly(row, col), validator = this.getValidator(rule.type), cellRaw = worksheet.getCellRaw(row, col), cellValue = getCellValueOrigin(cellRaw), interceptValue = getCellValueOrigin(cell);
|
|
997
1028
|
if (validator) {
|
|
998
1029
|
const cache = this._dataValidationCacheService.ensureCache(unitId, subUnitId), current = cache.getValue(row, col);
|
|
999
|
-
return !current || current.value !== cellValue || current.interceptValue !== interceptValue || current.ruleId !== ruleId ? (cache.setValue(row, col, {
|
|
1030
|
+
return !current || current.value !== cellValue || current.interceptValue !== interceptValue || current.ruleId !== ruleId || current.formula1 !== formula1 || current.formula2 !== formula2 ? (cache.setValue(row, col, {
|
|
1000
1031
|
value: cellValue,
|
|
1001
1032
|
interceptValue,
|
|
1002
1033
|
status: DataValidationStatus.VALIDATING,
|
|
1003
|
-
ruleId
|
|
1034
|
+
ruleId,
|
|
1035
|
+
formula1: formula1 || "",
|
|
1036
|
+
formula2: formula2 || ""
|
|
1004
1037
|
}), validator.validator(
|
|
1005
1038
|
{
|
|
1006
1039
|
value: cellValue,
|
|
@@ -1020,7 +1053,9 @@ let SheetDataValidationModel = (_a4 = class extends Disposable {
|
|
|
1020
1053
|
value: cellValue,
|
|
1021
1054
|
status: realStatus,
|
|
1022
1055
|
ruleId,
|
|
1023
|
-
interceptValue
|
|
1056
|
+
interceptValue,
|
|
1057
|
+
formula1: formula1 || "",
|
|
1058
|
+
formula2: formula2 || ""
|
|
1024
1059
|
}), onCompete(realStatus, !0);
|
|
1025
1060
|
}), DataValidationStatus.VALIDATING) : (onCompete(current.status, !1), current.status);
|
|
1026
1061
|
} else
|
|
@@ -1057,7 +1092,7 @@ let SheetDataValidationModel = (_a4 = class extends Disposable {
|
|
|
1057
1092
|
getAll() {
|
|
1058
1093
|
return this._dataValidationModel.getAll();
|
|
1059
1094
|
}
|
|
1060
|
-
}, __name(
|
|
1095
|
+
}, __name(_a5, "SheetDataValidationModel"), _a5);
|
|
1061
1096
|
SheetDataValidationModel = __decorateClass$6([
|
|
1062
1097
|
__decorateParam$6(0, Inject(DataValidationModel)),
|
|
1063
1098
|
__decorateParam$6(1, IUniverInstanceService),
|
|
@@ -1068,13 +1103,13 @@ SheetDataValidationModel = __decorateClass$6([
|
|
|
1068
1103
|
__decorateParam$6(6, ICommandService)
|
|
1069
1104
|
], SheetDataValidationModel);
|
|
1070
1105
|
function getFormulaResult(result) {
|
|
1071
|
-
var
|
|
1072
|
-
return (_b = (
|
|
1106
|
+
var _a12, _b;
|
|
1107
|
+
return (_b = (_a12 = result == null ? void 0 : result[0]) == null ? void 0 : _a12[0]) == null ? void 0 : _b.v;
|
|
1073
1108
|
}
|
|
1074
1109
|
__name(getFormulaResult, "getFormulaResult");
|
|
1075
1110
|
function getFormulaCellData(result) {
|
|
1076
|
-
var
|
|
1077
|
-
return (
|
|
1111
|
+
var _a12;
|
|
1112
|
+
return (_a12 = result == null ? void 0 : result[0]) == null ? void 0 : _a12[0];
|
|
1078
1113
|
}
|
|
1079
1114
|
__name(getFormulaCellData, "getFormulaCellData");
|
|
1080
1115
|
const CHECKBOX_FORMULA_1 = 1, CHECKBOX_FORMULA_2 = 0;
|
|
@@ -1115,8 +1150,8 @@ const transformCheckboxValue = /* @__PURE__ */ __name((value) => Tools.isDefine(
|
|
|
1115
1150
|
};
|
|
1116
1151
|
}
|
|
1117
1152
|
async parseFormula(rule, unitId, subUnitId) {
|
|
1118
|
-
var
|
|
1119
|
-
const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), originFormula1 = isFormulaString(formula1) ? getFormulaResult((
|
|
1153
|
+
var _a12, _b;
|
|
1154
|
+
const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), originFormula1 = isFormulaString(formula1) ? getFormulaResult((_a12 = results == null ? void 0 : results[0]) == null ? void 0 : _a12.result) : formula1, originFormula2 = isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2;
|
|
1120
1155
|
return {
|
|
1121
1156
|
formula1: transformCheckboxValue(originFormula1),
|
|
1122
1157
|
formula2: transformCheckboxValue(originFormula2),
|
|
@@ -1130,8 +1165,8 @@ const transformCheckboxValue = /* @__PURE__ */ __name((value) => Tools.isDefine(
|
|
|
1130
1165
|
};
|
|
1131
1166
|
}
|
|
1132
1167
|
parseFormulaSync(rule, unitId, subUnitId) {
|
|
1133
|
-
var
|
|
1134
|
-
const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = this._formulaService.getRuleFormulaResultSync(unitId, subUnitId, rule.uid), originFormula1 = isFormulaString(formula1) ? getFormulaResult((
|
|
1168
|
+
var _a12, _b;
|
|
1169
|
+
const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = this._formulaService.getRuleFormulaResultSync(unitId, subUnitId, rule.uid), originFormula1 = isFormulaString(formula1) ? getFormulaResult((_a12 = results == null ? void 0 : results[0]) == null ? void 0 : _a12.result) : formula1, originFormula2 = isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2;
|
|
1135
1170
|
return {
|
|
1136
1171
|
formula1: transformCheckboxValue(originFormula1),
|
|
1137
1172
|
formula2: transformCheckboxValue(originFormula2),
|
|
@@ -1178,8 +1213,8 @@ var dayjs_min = { exports: {} };
|
|
|
1178
1213
|
return { M: c, y: h, w: o, d: a, D: d, h: u, m: s, s: i, ms: r, Q: f }[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
|
|
1179
1214
|
}, "p"), u: /* @__PURE__ */ __name(function(t2) {
|
|
1180
1215
|
return t2 === void 0;
|
|
1181
|
-
}, "u") }, g = "en",
|
|
1182
|
-
|
|
1216
|
+
}, "u") }, g = "en", D2 = {};
|
|
1217
|
+
D2[g] = M;
|
|
1183
1218
|
var p = "$isDayjsObject", S = /* @__PURE__ */ __name(function(t2) {
|
|
1184
1219
|
return t2 instanceof _ || !(!t2 || !t2[p]);
|
|
1185
1220
|
}, "S"), w = /* @__PURE__ */ __name(function t2(e2, n2, r2) {
|
|
@@ -1187,12 +1222,12 @@ var dayjs_min = { exports: {} };
|
|
|
1187
1222
|
if (!e2) return g;
|
|
1188
1223
|
if (typeof e2 == "string") {
|
|
1189
1224
|
var s2 = e2.toLowerCase();
|
|
1190
|
-
|
|
1225
|
+
D2[s2] && (i2 = s2), n2 && (D2[s2] = n2, i2 = s2);
|
|
1191
1226
|
var u2 = e2.split("-");
|
|
1192
1227
|
if (!i2 && u2.length > 1) return t2(u2[0]);
|
|
1193
1228
|
} else {
|
|
1194
1229
|
var a2 = e2.name;
|
|
1195
|
-
|
|
1230
|
+
D2[a2] = e2, i2 = a2;
|
|
1196
1231
|
}
|
|
1197
1232
|
return !r2 && i2 && (g = i2), i2 || !r2 && g;
|
|
1198
1233
|
}, "t"), O = /* @__PURE__ */ __name(function(t2, e2) {
|
|
@@ -1257,8 +1292,8 @@ var dayjs_min = { exports: {} };
|
|
|
1257
1292
|
case c:
|
|
1258
1293
|
return r2 ? l2(1, M3) : l2(0, M3 + 1);
|
|
1259
1294
|
case o:
|
|
1260
|
-
var g2 = this.$locale().weekStart || 0,
|
|
1261
|
-
return l2(r2 ? m3 -
|
|
1295
|
+
var g2 = this.$locale().weekStart || 0, D3 = (y2 < g2 ? y2 + 7 : y2) - g2;
|
|
1296
|
+
return l2(r2 ? m3 - D3 : m3 + (6 - D3), M3);
|
|
1262
1297
|
case a:
|
|
1263
1298
|
case d:
|
|
1264
1299
|
return $2(v2 + "Hours", 0);
|
|
@@ -1368,18 +1403,18 @@ var dayjs_min = { exports: {} };
|
|
|
1368
1403
|
}, m2.utcOffset = function() {
|
|
1369
1404
|
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
|
|
1370
1405
|
}, m2.diff = function(r2, d2, l2) {
|
|
1371
|
-
var $2, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3,
|
|
1406
|
+
var $2, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D3 = /* @__PURE__ */ __name(function() {
|
|
1372
1407
|
return b.m(y2, m3);
|
|
1373
1408
|
}, "D");
|
|
1374
1409
|
switch (M3) {
|
|
1375
1410
|
case h:
|
|
1376
|
-
$2 =
|
|
1411
|
+
$2 = D3() / 12;
|
|
1377
1412
|
break;
|
|
1378
1413
|
case c:
|
|
1379
|
-
$2 =
|
|
1414
|
+
$2 = D3();
|
|
1380
1415
|
break;
|
|
1381
1416
|
case f:
|
|
1382
|
-
$2 =
|
|
1417
|
+
$2 = D3() / 3;
|
|
1383
1418
|
break;
|
|
1384
1419
|
case o:
|
|
1385
1420
|
$2 = (g2 - v2) / 6048e5;
|
|
@@ -1403,7 +1438,7 @@ var dayjs_min = { exports: {} };
|
|
|
1403
1438
|
}, m2.daysInMonth = function() {
|
|
1404
1439
|
return this.endOf(c).$D;
|
|
1405
1440
|
}, m2.$locale = function() {
|
|
1406
|
-
return
|
|
1441
|
+
return D2[this.$L];
|
|
1407
1442
|
}, m2.locale = function(t2, e2) {
|
|
1408
1443
|
if (!t2) return this.$L;
|
|
1409
1444
|
var n2 = this.clone(), r2 = w(t2, e2, !0);
|
|
@@ -1428,7 +1463,7 @@ var dayjs_min = { exports: {} };
|
|
|
1428
1463
|
return t2.$i || (t2(e2, _, O), t2.$i = !0), O;
|
|
1429
1464
|
}, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
|
|
1430
1465
|
return O(1e3 * t2);
|
|
1431
|
-
}, O.en =
|
|
1466
|
+
}, O.en = D2[g], O.Ls = D2, O.p = {}, O;
|
|
1432
1467
|
});
|
|
1433
1468
|
})(dayjs_min);
|
|
1434
1469
|
var dayjs_minExports = dayjs_min.exports;
|
|
@@ -1465,12 +1500,12 @@ const DateOperatorTitleMap = {
|
|
|
1465
1500
|
DataValidationOperator.BETWEEN,
|
|
1466
1501
|
DataValidationOperator.NOT_BETWEEN
|
|
1467
1502
|
], FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2SerialNumber = /* @__PURE__ */ __name((value) => {
|
|
1468
|
-
var
|
|
1503
|
+
var _a12, _b;
|
|
1469
1504
|
if (value == null || typeof value == "boolean")
|
|
1470
1505
|
return;
|
|
1471
1506
|
if (typeof value == "number" || !Number.isNaN(+value))
|
|
1472
1507
|
return +value;
|
|
1473
|
-
const v = (
|
|
1508
|
+
const v = (_a12 = numfmt.parseDate(value)) == null ? void 0 : _a12.v;
|
|
1474
1509
|
return Tools.isDefine(v) ? v : (_b = numfmt.parseDate(dayjs(value).format("YYYY-MM-DD HH:mm:ss"))) == null ? void 0 : _b.v;
|
|
1475
1510
|
}, "transformDate2SerialNumber"), _DateValidator = class _DateValidator extends BaseDataValidator {
|
|
1476
1511
|
constructor() {
|
|
@@ -1491,18 +1526,18 @@ const DateOperatorTitleMap = {
|
|
|
1491
1526
|
__publicField(this, "_formulaService", this.injector.get(DataValidationFormulaService));
|
|
1492
1527
|
}
|
|
1493
1528
|
async parseFormula(rule, unitId, subUnitId) {
|
|
1494
|
-
var
|
|
1529
|
+
var _a12, _b;
|
|
1495
1530
|
const results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
|
|
1496
1531
|
return {
|
|
1497
|
-
formula1: transformDate2SerialNumber(isFormulaString(formula1) ? getFormulaResult((
|
|
1532
|
+
formula1: transformDate2SerialNumber(isFormulaString(formula1) ? getFormulaResult((_a12 = results == null ? void 0 : results[0]) == null ? void 0 : _a12.result) : formula1),
|
|
1498
1533
|
formula2: transformDate2SerialNumber(isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2)
|
|
1499
1534
|
};
|
|
1500
1535
|
}
|
|
1501
1536
|
parseFormulaSync(rule, unitId, subUnitId) {
|
|
1502
|
-
var
|
|
1537
|
+
var _a12, _b;
|
|
1503
1538
|
const results = this._formulaService.getRuleFormulaResultSync(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
|
|
1504
1539
|
return {
|
|
1505
|
-
formula1: transformDate2SerialNumber(isFormulaString(formula1) ? getFormulaResult((
|
|
1540
|
+
formula1: transformDate2SerialNumber(isFormulaString(formula1) ? getFormulaResult((_a12 = results == null ? void 0 : results[0]) == null ? void 0 : _a12.result) : formula1),
|
|
1506
1541
|
formula2: transformDate2SerialNumber(isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2)
|
|
1507
1542
|
};
|
|
1508
1543
|
}
|
|
@@ -1535,14 +1570,14 @@ const DateOperatorTitleMap = {
|
|
|
1535
1570
|
}
|
|
1536
1571
|
normalizeFormula(rule, _unitId, _subUnitId) {
|
|
1537
1572
|
const { formula1, formula2, bizInfo } = rule, normlizeSingleFormula = /* @__PURE__ */ __name((formula) => {
|
|
1538
|
-
var
|
|
1573
|
+
var _a12;
|
|
1539
1574
|
if (!formula)
|
|
1540
1575
|
return formula;
|
|
1541
1576
|
let date;
|
|
1542
1577
|
if (!Number.isNaN(+formula))
|
|
1543
1578
|
date = numfmt.dateFromSerial(+formula);
|
|
1544
1579
|
else {
|
|
1545
|
-
const res = (
|
|
1580
|
+
const res = (_a12 = numfmt.parseDate(formula)) == null ? void 0 : _a12.v;
|
|
1546
1581
|
if (res == null)
|
|
1547
1582
|
return "";
|
|
1548
1583
|
date = numfmt.dateFromSerial(res);
|
|
@@ -1603,15 +1638,15 @@ const DateOperatorTitleMap = {
|
|
|
1603
1638
|
return this.operators.map((operator) => this.localeService.t(DateOperatorNameMap[operator]));
|
|
1604
1639
|
}
|
|
1605
1640
|
generateRuleName(rule) {
|
|
1606
|
-
var
|
|
1641
|
+
var _a12, _b;
|
|
1607
1642
|
if (!rule.operator)
|
|
1608
1643
|
return this.titleStr;
|
|
1609
|
-
const ruleName = this.localeService.t(DateOperatorTitleMap[rule.operator]).replace(FORMULA1$1, (
|
|
1644
|
+
const ruleName = this.localeService.t(DateOperatorTitleMap[rule.operator]).replace(FORMULA1$1, (_a12 = rule.formula1) != null ? _a12 : "").replace(FORMULA2$1, (_b = rule.formula2) != null ? _b : "");
|
|
1610
1645
|
return `${this.titleStr} ${ruleName}`;
|
|
1611
1646
|
}
|
|
1612
1647
|
generateRuleErrorMessage(rule) {
|
|
1613
|
-
var
|
|
1614
|
-
return rule.operator ? `${this.localeService.t(DateOperatorErrorTitleMap[rule.operator]).replace(FORMULA1$1, (
|
|
1648
|
+
var _a12, _b;
|
|
1649
|
+
return rule.operator ? `${this.localeService.t(DateOperatorErrorTitleMap[rule.operator]).replace(FORMULA1$1, (_a12 = rule.formula1) != null ? _a12 : "").replace(FORMULA2$1, (_b = rule.formula2) != null ? _b : "")}` : this.titleStr;
|
|
1615
1650
|
}
|
|
1616
1651
|
};
|
|
1617
1652
|
__name(_DateValidator, "DateValidator");
|
|
@@ -1657,10 +1692,10 @@ const _DecimalValidator = class _DecimalValidator extends BaseDataValidator {
|
|
|
1657
1692
|
return formula == null ? Number.NaN : +formula;
|
|
1658
1693
|
}
|
|
1659
1694
|
async parseFormula(rule, unitId, subUnitId) {
|
|
1660
|
-
var
|
|
1695
|
+
var _a12, _b, _c, _d, _e, _f, _g, _h;
|
|
1661
1696
|
const formulaInfo = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
|
|
1662
1697
|
return {
|
|
1663
|
-
formula1: this._parseNumber(isFormulaString(formula1) ? (_d = (_c = (_b = (
|
|
1698
|
+
formula1: this._parseNumber(isFormulaString(formula1) ? (_d = (_c = (_b = (_a12 = formulaInfo == null ? void 0 : formulaInfo[0]) == null ? void 0 : _a12.result) == null ? void 0 : _b[0]) == null ? void 0 : _c[0]) == null ? void 0 : _d.v : formula1),
|
|
1664
1699
|
formula2: this._parseNumber(isFormulaString(formula2) ? (_h = (_g = (_f = (_e = formulaInfo == null ? void 0 : formulaInfo[1]) == null ? void 0 : _e.result) == null ? void 0 : _f[0]) == null ? void 0 : _g[0]) == null ? void 0 : _h.v : formula2)
|
|
1665
1700
|
};
|
|
1666
1701
|
}
|
|
@@ -1741,10 +1776,10 @@ function getRuleFormulaResultSet(result) {
|
|
|
1741
1776
|
return result.forEach(
|
|
1742
1777
|
(row) => {
|
|
1743
1778
|
row.forEach((cell) => {
|
|
1744
|
-
var
|
|
1779
|
+
var _a12, _b;
|
|
1745
1780
|
const value = getCellValueOrigin(cell);
|
|
1746
1781
|
if (value != null) {
|
|
1747
|
-
if (typeof value != "string" && typeof (cell == null ? void 0 : cell.s) == "object" && ((_b = (
|
|
1782
|
+
if (typeof value != "string" && typeof (cell == null ? void 0 : cell.s) == "object" && ((_b = (_a12 = cell.s) == null ? void 0 : _a12.n) != null && _b.pattern)) {
|
|
1748
1783
|
resultSet.add(numfmt.format(cell.s.n.pattern, value, { throws: !1 }));
|
|
1749
1784
|
return;
|
|
1750
1785
|
}
|
|
@@ -1791,16 +1826,16 @@ const _ListValidator = class _ListValidator extends BaseDataValidator {
|
|
|
1791
1826
|
__publicField(this, "skipDefaultFontRender", /* @__PURE__ */ __name((rule) => rule.renderMode !== DataValidationRenderMode.TEXT, "skipDefaultFontRender"));
|
|
1792
1827
|
}
|
|
1793
1828
|
validatorFormula(rule, unitId, subUnitId) {
|
|
1794
|
-
var
|
|
1795
|
-
const success = !Tools.isBlank(rule.formula1), valid = isValidListFormula((
|
|
1829
|
+
var _a12, _b, _c;
|
|
1830
|
+
const success = !Tools.isBlank(rule.formula1), valid = isValidListFormula((_a12 = rule.formula1) != null ? _a12 : "", this._lexer), sheetName = (_c = (_b = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _b.getSheetBySheetId(subUnitId)) == null ? void 0 : _c.getName(), isIntersects = isRuleIntersects(rule, sheetName != null ? sheetName : "");
|
|
1796
1831
|
return {
|
|
1797
1832
|
success: !!(success && valid && !isIntersects),
|
|
1798
1833
|
formula1: success ? valid ? isIntersects ? this.localeService.t("dataValidation.validFail.listIntersects") : void 0 : this.localeService.t("dataValidation.validFail.listInvalid") : this.localeService.t("dataValidation.validFail.list")
|
|
1799
1834
|
};
|
|
1800
1835
|
}
|
|
1801
1836
|
getExtraStyle(rule, value, { style: defaultStyle }) {
|
|
1802
|
-
var
|
|
1803
|
-
const tb = (
|
|
1837
|
+
var _a12;
|
|
1838
|
+
const tb = (_a12 = defaultStyle.tb !== WrapStrategy.OVERFLOW ? defaultStyle.tb : WrapStrategy.CLIP) != null ? _a12 : WrapStrategy.WRAP;
|
|
1804
1839
|
if (rule.type === DataValidationType.LIST && (rule.renderMode === DataValidationRenderMode.ARROW || rule.renderMode === DataValidationRenderMode.TEXT)) {
|
|
1805
1840
|
const colorMap = this.getListWithColorMap(rule), valueStr = `${value != null ? value : ""}`, color = colorMap[valueStr];
|
|
1806
1841
|
if (color)
|
|
@@ -1820,10 +1855,10 @@ const _ListValidator = class _ListValidator extends BaseDataValidator {
|
|
|
1820
1855
|
return deserializeListOptions(cellString);
|
|
1821
1856
|
}
|
|
1822
1857
|
async parseFormula(rule, unitId, subUnitId) {
|
|
1823
|
-
var
|
|
1858
|
+
var _a12;
|
|
1824
1859
|
const { formula1 = "" } = rule, results = await this.formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid);
|
|
1825
1860
|
return {
|
|
1826
|
-
formula1: isFormulaString(formula1) ? getRuleFormulaResultSet((
|
|
1861
|
+
formula1: isFormulaString(formula1) ? getRuleFormulaResultSet((_a12 = results == null ? void 0 : results[0]) == null ? void 0 : _a12.result) : deserializeListOptions(formula1),
|
|
1827
1862
|
formula2: void 0
|
|
1828
1863
|
};
|
|
1829
1864
|
}
|
|
@@ -1838,8 +1873,8 @@ const _ListValidator = class _ListValidator extends BaseDataValidator {
|
|
|
1838
1873
|
return this.localeService.t("dataValidation.list.error");
|
|
1839
1874
|
}
|
|
1840
1875
|
getList(rule, currentUnitId, currentSubUnitId) {
|
|
1841
|
-
var
|
|
1842
|
-
const { formula1 = "" } = rule, univerInstanceService = this.injector.get(IUniverInstanceService), workbook = (
|
|
1876
|
+
var _a12, _b, _c;
|
|
1877
|
+
const { formula1 = "" } = rule, univerInstanceService = this.injector.get(IUniverInstanceService), workbook = (_a12 = currentUnitId ? univerInstanceService.getUniverSheetInstance(currentUnitId) : void 0) != null ? _a12 : univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
1843
1878
|
if (!workbook) return [];
|
|
1844
1879
|
const worksheet = (_b = currentSubUnitId ? workbook.getSheetBySheetId(currentSubUnitId) : void 0) != null ? _b : workbook.getActiveSheet();
|
|
1845
1880
|
if (!worksheet) return [];
|
|
@@ -1847,8 +1882,8 @@ const _ListValidator = class _ListValidator extends BaseDataValidator {
|
|
|
1847
1882
|
return isFormulaString(formula1) ? getRuleFormulaResultSet((_c = results == null ? void 0 : results[0]) == null ? void 0 : _c.result) : deserializeListOptions(formula1);
|
|
1848
1883
|
}
|
|
1849
1884
|
async getListAsync(rule, currentUnitId, currentSubUnitId) {
|
|
1850
|
-
var
|
|
1851
|
-
const { formula1 = "" } = rule, univerInstanceService = this.injector.get(IUniverInstanceService), workbook = (
|
|
1885
|
+
var _a12, _b, _c;
|
|
1886
|
+
const { formula1 = "" } = rule, univerInstanceService = this.injector.get(IUniverInstanceService), workbook = (_a12 = currentUnitId ? univerInstanceService.getUniverSheetInstance(currentUnitId) : void 0) != null ? _a12 : univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
1852
1887
|
if (!workbook) return [];
|
|
1853
1888
|
const worksheet = (_b = currentSubUnitId ? workbook.getSheetBySheetId(currentSubUnitId) : void 0) != null ? _b : workbook.getActiveSheet();
|
|
1854
1889
|
if (!worksheet) return [];
|
|
@@ -1912,10 +1947,10 @@ const FORMULA1 = "{FORMULA1}", FORMULA2 = "{FORMULA2}", _TextLengthValidator = c
|
|
|
1912
1947
|
return !Number.isNaN(formula);
|
|
1913
1948
|
}
|
|
1914
1949
|
async parseFormula(rule, unitId, subUnitId) {
|
|
1915
|
-
var
|
|
1950
|
+
var _a12, _b, _c, _d, _e, _f, _g, _h;
|
|
1916
1951
|
const formulaInfo = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
|
|
1917
1952
|
return {
|
|
1918
|
-
formula1: this._parseNumber(isFormulaString(formula1) ? (_d = (_c = (_b = (
|
|
1953
|
+
formula1: this._parseNumber(isFormulaString(formula1) ? (_d = (_c = (_b = (_a12 = formulaInfo == null ? void 0 : formulaInfo[0]) == null ? void 0 : _a12.result) == null ? void 0 : _b[0]) == null ? void 0 : _c[0]) == null ? void 0 : _d.v : formula1),
|
|
1919
1954
|
formula2: this._parseNumber(isFormulaString(formula2) ? (_h = (_g = (_f = (_e = formulaInfo == null ? void 0 : formulaInfo[1]) == null ? void 0 : _e.result) == null ? void 0 : _f[0]) == null ? void 0 : _g[0]) == null ? void 0 : _h.v : formula2)
|
|
1920
1955
|
};
|
|
1921
1956
|
}
|
|
@@ -1968,15 +2003,15 @@ const FORMULA1 = "{FORMULA1}", FORMULA2 = "{FORMULA2}", _TextLengthValidator = c
|
|
|
1968
2003
|
return this._isValidFormula(formula1) ? cellValue <= formula1 : !1;
|
|
1969
2004
|
}
|
|
1970
2005
|
generateRuleErrorMessage(rule) {
|
|
1971
|
-
var
|
|
1972
|
-
return rule.operator ? `${this.localeService.t(TextLengthErrorTitleMap[rule.operator]).replace(FORMULA1, (
|
|
2006
|
+
var _a12, _b;
|
|
2007
|
+
return rule.operator ? `${this.localeService.t(TextLengthErrorTitleMap[rule.operator]).replace(FORMULA1, (_a12 = rule.formula1) != null ? _a12 : "").replace(FORMULA2, (_b = rule.formula2) != null ? _b : "")}` : this.titleStr;
|
|
1973
2008
|
}
|
|
1974
2009
|
};
|
|
1975
2010
|
__name(_TextLengthValidator, "TextLengthValidator");
|
|
1976
2011
|
let TextLengthValidator = _TextLengthValidator;
|
|
1977
2012
|
function isBlankCell(cellData) {
|
|
1978
|
-
var
|
|
1979
|
-
return cellData ? cellData.p ? !((_b = (
|
|
2013
|
+
var _a12, _b;
|
|
2014
|
+
return cellData ? cellData.p ? !((_b = (_a12 = cellData.p.body) == null ? void 0 : _a12.dataStream) != null ? _b : "").slice(0, -2).trim() : Tools.isBlank(cellData.v) : !0;
|
|
1980
2015
|
}
|
|
1981
2016
|
__name(isBlankCell, "isBlankCell");
|
|
1982
2017
|
function getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor, source = "command", fillDefaultValue = !0) {
|
|
@@ -2098,7 +2133,7 @@ __name(getDataValidationDiffMutations, "getDataValidationDiffMutations");
|
|
|
2098
2133
|
const UpdateSheetDataValidationRangeCommand = {
|
|
2099
2134
|
type: CommandType.COMMAND,
|
|
2100
2135
|
id: "sheet.command.updateDataValidationRuleRange",
|
|
2101
|
-
|
|
2136
|
+
handler(accessor, params) {
|
|
2102
2137
|
if (!params)
|
|
2103
2138
|
return !1;
|
|
2104
2139
|
const { unitId, subUnitId, ranges, ruleId } = params, sheetDataValidationModel = accessor.get(SheetDataValidationModel), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService);
|
|
@@ -2111,12 +2146,12 @@ const UpdateSheetDataValidationRangeCommand = {
|
|
|
2111
2146
|
undoMutations,
|
|
2112
2147
|
redoMutations,
|
|
2113
2148
|
unitID: unitId
|
|
2114
|
-
}),
|
|
2149
|
+
}), sequenceExecute(redoMutations, commandService), !0;
|
|
2115
2150
|
}
|
|
2116
2151
|
}, AddSheetDataValidationCommand = {
|
|
2117
2152
|
type: CommandType.COMMAND,
|
|
2118
2153
|
id: "sheet.command.addDataValidation",
|
|
2119
|
-
|
|
2154
|
+
handler(accessor, params) {
|
|
2120
2155
|
if (!params)
|
|
2121
2156
|
return !1;
|
|
2122
2157
|
const { unitId, subUnitId, rule } = params, sheetDataValidationModel = accessor.get(SheetDataValidationModel), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), matrix = sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone();
|
|
@@ -2140,7 +2175,7 @@ const UpdateSheetDataValidationRangeCommand = {
|
|
|
2140
2175
|
unitID: unitId,
|
|
2141
2176
|
redoMutations,
|
|
2142
2177
|
undoMutations
|
|
2143
|
-
}),
|
|
2178
|
+
}), sequenceExecute(redoMutations, commandService), !0;
|
|
2144
2179
|
}
|
|
2145
2180
|
}, UpdateSheetDataValidationSettingCommand = {
|
|
2146
2181
|
type: CommandType.COMMAND,
|
|
@@ -2436,10 +2471,10 @@ const _WholeValidator = class _WholeValidator extends BaseDataValidator {
|
|
|
2436
2471
|
return formula == null ? Number.NaN : +formula;
|
|
2437
2472
|
}
|
|
2438
2473
|
async parseFormula(rule, unitId, subUnitId) {
|
|
2439
|
-
var
|
|
2474
|
+
var _a12, _b, _c, _d, _e, _f, _g, _h;
|
|
2440
2475
|
const formulaInfo = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
|
|
2441
2476
|
return {
|
|
2442
|
-
formula1: this._parseNumber(isFormulaString(formula1) ? (_d = (_c = (_b = (
|
|
2477
|
+
formula1: this._parseNumber(isFormulaString(formula1) ? (_d = (_c = (_b = (_a12 = formulaInfo == null ? void 0 : formulaInfo[0]) == null ? void 0 : _a12.result) == null ? void 0 : _b[0]) == null ? void 0 : _c[0]) == null ? void 0 : _d.v : formula1),
|
|
2443
2478
|
formula2: this._parseNumber(isFormulaString(formula2) ? (_h = (_g = (_f = (_e = formulaInfo == null ? void 0 : formulaInfo[1]) == null ? void 0 : _e.result) == null ? void 0 : _f[0]) == null ? void 0 : _g[0]) == null ? void 0 : _h.v : formula2)
|
|
2444
2479
|
};
|
|
2445
2480
|
}
|
|
@@ -2504,8 +2539,8 @@ var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPrope
|
|
|
2504
2539
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2505
2540
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2506
2541
|
return kind && result && __defProp$5(target, key, result), result;
|
|
2507
|
-
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"),
|
|
2508
|
-
let DataValidationController = (
|
|
2542
|
+
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a6;
|
|
2543
|
+
let DataValidationController = (_a6 = class extends RxDisposable {
|
|
2509
2544
|
constructor(_univerInstanceService, _dataValidatorRegistryService, _injector, _selectionManagerService, _sheetInterceptorService, _sheetDataValidationModel) {
|
|
2510
2545
|
super(), this._univerInstanceService = _univerInstanceService, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._injector = _injector, this._selectionManagerService = _selectionManagerService, this._sheetInterceptorService = _sheetInterceptorService, this._sheetDataValidationModel = _sheetDataValidationModel, this._init();
|
|
2511
2546
|
}
|
|
@@ -2530,12 +2565,12 @@ let DataValidationController = (_a5 = class extends RxDisposable {
|
|
|
2530
2565
|
_initCommandInterceptor() {
|
|
2531
2566
|
this._sheetInterceptorService.interceptCommand({
|
|
2532
2567
|
getMutations: /* @__PURE__ */ __name((commandInfo) => {
|
|
2533
|
-
var
|
|
2568
|
+
var _a12;
|
|
2534
2569
|
if (commandInfo.id === ClearSelectionAllCommand.id) {
|
|
2535
2570
|
const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), unitId = workbook.getUnitId(), worksheet = workbook.getActiveSheet();
|
|
2536
2571
|
if (!worksheet)
|
|
2537
2572
|
throw new Error("No active sheet found");
|
|
2538
|
-
const subUnitId = worksheet.getSheetId(), selections = (
|
|
2573
|
+
const subUnitId = worksheet.getSheetId(), selections = (_a12 = this._selectionManagerService.getCurrentSelections()) == null ? void 0 : _a12.map((s) => s.range), ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone();
|
|
2539
2574
|
selections && ruleMatrix.removeRange(selections);
|
|
2540
2575
|
const diffs = ruleMatrix.diff(this._sheetDataValidationModel.getRules(unitId, subUnitId)), { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, this._injector, "patched");
|
|
2541
2576
|
return {
|
|
@@ -2550,7 +2585,7 @@ let DataValidationController = (_a5 = class extends RxDisposable {
|
|
|
2550
2585
|
}, "getMutations")
|
|
2551
2586
|
});
|
|
2552
2587
|
}
|
|
2553
|
-
}, __name(
|
|
2588
|
+
}, __name(_a6, "DataValidationController"), _a6);
|
|
2554
2589
|
DataValidationController = __decorateClass$5([
|
|
2555
2590
|
__decorateParam$5(0, IUniverInstanceService),
|
|
2556
2591
|
__decorateParam$5(1, Inject(DataValidatorRegistryService)),
|
|
@@ -2559,17 +2594,17 @@ DataValidationController = __decorateClass$5([
|
|
|
2559
2594
|
__decorateParam$5(4, Inject(SheetInterceptorService)),
|
|
2560
2595
|
__decorateParam$5(5, Inject(SheetDataValidationModel))
|
|
2561
2596
|
], DataValidationController);
|
|
2562
|
-
var
|
|
2597
|
+
var D = /* @__PURE__ */ ((E) => (E[E.View = 0] = "View", E[E.Edit = 1] = "Edit", E[E.ManageCollaborator = 2] = "ManageCollaborator", E[E.Print = 3] = "Print", E[E.Duplicate = 4] = "Duplicate", E[E.Comment = 5] = "Comment", E[E.Copy = 6] = "Copy", E[E.Share = 7] = "Share", E[E.Export = 8] = "Export", E[E.MoveWorksheet = 9] = "MoveWorksheet", E[E.DeleteWorksheet = 10] = "DeleteWorksheet", E[E.HideWorksheet = 11] = "HideWorksheet", E[E.RenameWorksheet = 12] = "RenameWorksheet", E[E.CreateWorksheet = 13] = "CreateWorksheet", E[E.SetWorksheetStyle = 14] = "SetWorksheetStyle", E[E.EditWorksheetCell = 15] = "EditWorksheetCell", E[E.InsertHyperlink = 16] = "InsertHyperlink", E[E.Sort = 17] = "Sort", E[E.Filter = 18] = "Filter", E[E.PivotTable = 19] = "PivotTable", E[E.FloatImg = 20] = "FloatImg", E[E.History = 21] = "History", E[E.RwHgtClWdt = 22] = "RwHgtClWdt", E[E.ViemRwHgtClWdt = 23] = "ViemRwHgtClWdt", E[E.ViewFilter = 24] = "ViewFilter", E[E.MoveSheet = 25] = "MoveSheet", E[E.DeleteSheet = 26] = "DeleteSheet", E[E.HideSheet = 27] = "HideSheet", E[E.CopySheet = 28] = "CopySheet", E[E.RenameSheet = 29] = "RenameSheet", E[E.CreateSheet = 30] = "CreateSheet", E[E.SelectProtectedCells = 31] = "SelectProtectedCells", E[E.SelectUnProtectedCells = 32] = "SelectUnProtectedCells", E[E.SetCellStyle = 33] = "SetCellStyle", E[E.SetCellValue = 34] = "SetCellValue", E[E.SetRowStyle = 35] = "SetRowStyle", E[E.SetColumnStyle = 36] = "SetColumnStyle", E[E.InsertRow = 37] = "InsertRow", E[E.InsertColumn = 38] = "InsertColumn", E[E.DeleteRow = 39] = "DeleteRow", E[E.DeleteColumn = 40] = "DeleteColumn", E[E.EditExtraObject = 41] = "EditExtraObject", E[E.Delete = 42] = "Delete", E[E.RecoverHistory = 43] = "RecoverHistory", E[E.ViewHistory = 44] = "ViewHistory", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(D || {}), __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2563
2598
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2564
2599
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2565
2600
|
return kind && result && __defProp$4(target, key, result), result;
|
|
2566
|
-
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"),
|
|
2567
|
-
let DataValidationFormulaController = (
|
|
2601
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a7;
|
|
2602
|
+
let DataValidationFormulaController = (_a7 = class extends Disposable {
|
|
2568
2603
|
constructor(_univerInstanceService, _permissionService, _lexerTreeBuilder) {
|
|
2569
2604
|
super(), this._univerInstanceService = _univerInstanceService, this._permissionService = _permissionService, this._lexerTreeBuilder = _lexerTreeBuilder;
|
|
2570
2605
|
}
|
|
2571
2606
|
getFormulaRefCheck(formulaString) {
|
|
2572
|
-
var
|
|
2607
|
+
var _a12, _b;
|
|
2573
2608
|
const sequenceNodes = this._lexerTreeBuilder.sequenceNodesBuilder(formulaString);
|
|
2574
2609
|
if (!sequenceNodes)
|
|
2575
2610
|
return !0;
|
|
@@ -2591,14 +2626,14 @@ let DataValidationFormulaController = (_a6 = class extends Disposable {
|
|
|
2591
2626
|
const { startRow, endRow, startColumn, endColumn } = sequenceGrid.range;
|
|
2592
2627
|
for (let i2 = startRow; i2 <= endRow; i2++)
|
|
2593
2628
|
for (let j = startColumn; j <= endColumn; j++) {
|
|
2594
|
-
const permission = (_b = (
|
|
2595
|
-
if ((permission == null ? void 0 : permission[
|
|
2629
|
+
const permission = (_b = (_a12 = targetSheet.getCell(i2, j)) == null ? void 0 : _a12.selectionProtection) == null ? void 0 : _b[0];
|
|
2630
|
+
if ((permission == null ? void 0 : permission[D.View]) === !1)
|
|
2596
2631
|
return !1;
|
|
2597
2632
|
}
|
|
2598
2633
|
}
|
|
2599
2634
|
return !0;
|
|
2600
2635
|
}
|
|
2601
|
-
}, __name(
|
|
2636
|
+
}, __name(_a7, "DataValidationFormulaController"), _a7);
|
|
2602
2637
|
DataValidationFormulaController = __decorateClass$4([
|
|
2603
2638
|
__decorateParam$4(0, IUniverInstanceService),
|
|
2604
2639
|
__decorateParam$4(1, IPermissionService),
|
|
@@ -2608,8 +2643,8 @@ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPrope
|
|
|
2608
2643
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2609
2644
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2610
2645
|
return kind && result && __defProp$3(target, key, result), result;
|
|
2611
|
-
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"),
|
|
2612
|
-
let DataValidationRefRangeController = (
|
|
2646
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a8;
|
|
2647
|
+
let DataValidationRefRangeController = (_a8 = class extends Disposable {
|
|
2613
2648
|
constructor(_dataValidationModel, _injector, _refRangeService, _dataValidationCustomFormulaService, _dataValidationFormulaService, _formulaRefRangeService) {
|
|
2614
2649
|
super();
|
|
2615
2650
|
__publicField(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
@@ -2623,8 +2658,8 @@ let DataValidationRefRangeController = (_a7 = class extends Disposable {
|
|
|
2623
2658
|
}
|
|
2624
2659
|
// eslint-disable-next-line max-lines-per-function
|
|
2625
2660
|
registerFormula(unitId, subUnitId, rule) {
|
|
2626
|
-
var
|
|
2627
|
-
const ruleId = rule.uid, id = this._getIdWithUnitId(unitId, subUnitId, ruleId), disposeSet = (
|
|
2661
|
+
var _a12;
|
|
2662
|
+
const ruleId = rule.uid, id = this._getIdWithUnitId(unitId, subUnitId, ruleId), disposeSet = (_a12 = this._disposableMap.get(id)) != null ? _a12 : /* @__PURE__ */ new Set(), handleFormulaChange = /* @__PURE__ */ __name((type, formulaString) => {
|
|
2628
2663
|
const oldRule = this._dataValidationModel.getRuleById(unitId, subUnitId, ruleId);
|
|
2629
2664
|
if (!oldRule)
|
|
2630
2665
|
return { redos: [], undos: [] };
|
|
@@ -2701,7 +2736,7 @@ let DataValidationRefRangeController = (_a7 = class extends Disposable {
|
|
|
2701
2736
|
}
|
|
2702
2737
|
}
|
|
2703
2738
|
register(unitId, subUnitId, rule) {
|
|
2704
|
-
var
|
|
2739
|
+
var _a12;
|
|
2705
2740
|
const handleRangeChange = /* @__PURE__ */ __name((commandInfo) => {
|
|
2706
2741
|
const oldRanges = [...rule.ranges], resultRanges = oldRanges.map((range) => handleCommonDefaultRangeChangeWithEffectRefCommands(range, commandInfo)).filter((range) => !!range).flat();
|
|
2707
2742
|
if (isRangesEqual(resultRanges, oldRanges))
|
|
@@ -2739,7 +2774,7 @@ let DataValidationRefRangeController = (_a7 = class extends Disposable {
|
|
|
2739
2774
|
const disposable = this._refRangeService.registerRefRange(range, handleRangeChange, unitId, subUnitId);
|
|
2740
2775
|
disposeList.push(() => disposable.dispose());
|
|
2741
2776
|
});
|
|
2742
|
-
const id = this._getIdWithUnitId(unitId, subUnitId, rule.uid), current = (
|
|
2777
|
+
const id = this._getIdWithUnitId(unitId, subUnitId, rule.uid), current = (_a12 = this._disposableMap.get(id)) != null ? _a12 : /* @__PURE__ */ new Set();
|
|
2743
2778
|
current.add(() => disposeList.forEach((dispose) => dispose())), this._disposableMap.set(id, current);
|
|
2744
2779
|
}
|
|
2745
2780
|
_initRefRange() {
|
|
@@ -2775,7 +2810,7 @@ let DataValidationRefRangeController = (_a7 = class extends Disposable {
|
|
|
2775
2810
|
}), this._disposableMap.clear();
|
|
2776
2811
|
}));
|
|
2777
2812
|
}
|
|
2778
|
-
}, __name(
|
|
2813
|
+
}, __name(_a8, "DataValidationRefRangeController"), _a8);
|
|
2779
2814
|
DataValidationRefRangeController = __decorateClass$3([
|
|
2780
2815
|
__decorateParam$3(0, Inject(SheetDataValidationModel)),
|
|
2781
2816
|
__decorateParam$3(1, Inject(Injector)),
|
|
@@ -2788,8 +2823,8 @@ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPrope
|
|
|
2788
2823
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2789
2824
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2790
2825
|
return kind && result && __defProp$2(target, key, result), result;
|
|
2791
|
-
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"),
|
|
2792
|
-
let SheetDataValidationSheetController = (
|
|
2826
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a9;
|
|
2827
|
+
let SheetDataValidationSheetController = (_a9 = class extends Disposable {
|
|
2793
2828
|
constructor(_sheetInterceptorService, _univerInstanceService, _sheetDataValidationModel) {
|
|
2794
2829
|
super(), this._sheetInterceptorService = _sheetInterceptorService, this._univerInstanceService = _univerInstanceService, this._sheetDataValidationModel = _sheetDataValidationModel, this._initSheetChange();
|
|
2795
2830
|
}
|
|
@@ -2797,12 +2832,12 @@ let SheetDataValidationSheetController = (_a8 = class extends Disposable {
|
|
|
2797
2832
|
this.disposeWithMe(
|
|
2798
2833
|
this._sheetInterceptorService.interceptCommand({
|
|
2799
2834
|
getMutations: /* @__PURE__ */ __name((commandInfo) => {
|
|
2800
|
-
var
|
|
2835
|
+
var _a12;
|
|
2801
2836
|
if (commandInfo.id === RemoveSheetCommand.id) {
|
|
2802
2837
|
const params = commandInfo.params, unitId = params.unitId || this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getUnitId(), workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
|
|
2803
2838
|
if (!workbook)
|
|
2804
2839
|
return { redos: [], undos: [] };
|
|
2805
|
-
const subUnitId = params.subUnitId || ((
|
|
2840
|
+
const subUnitId = params.subUnitId || ((_a12 = workbook.getActiveSheet()) == null ? void 0 : _a12.getSheetId());
|
|
2806
2841
|
if (!subUnitId)
|
|
2807
2842
|
return { redos: [], undos: [] };
|
|
2808
2843
|
const rules = this._sheetDataValidationModel.getRules(unitId, subUnitId);
|
|
@@ -2835,7 +2870,7 @@ let SheetDataValidationSheetController = (_a8 = class extends Disposable {
|
|
|
2835
2870
|
})
|
|
2836
2871
|
);
|
|
2837
2872
|
}
|
|
2838
|
-
}, __name(
|
|
2873
|
+
}, __name(_a9, "SheetDataValidationSheetController"), _a9);
|
|
2839
2874
|
SheetDataValidationSheetController = __decorateClass$2([
|
|
2840
2875
|
__decorateParam$2(0, Inject(SheetInterceptorService)),
|
|
2841
2876
|
__decorateParam$2(1, Inject(IUniverInstanceService)),
|
|
@@ -2845,10 +2880,29 @@ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPrope
|
|
|
2845
2880
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2846
2881
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2847
2882
|
return kind && result && __defProp$1(target, key, result), result;
|
|
2848
|
-
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"),
|
|
2849
|
-
let SheetsDataValidationValidatorService = (
|
|
2850
|
-
constructor(_univerInstanceService, _sheetDataValidationModel, _dataValidationCacheService) {
|
|
2851
|
-
this._univerInstanceService = _univerInstanceService, this._sheetDataValidationModel = _sheetDataValidationModel, this._dataValidationCacheService = _dataValidationCacheService;
|
|
2883
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a10;
|
|
2884
|
+
let SheetsDataValidationValidatorService = (_a10 = class extends Disposable {
|
|
2885
|
+
constructor(_univerInstanceService, _sheetDataValidationModel, _dataValidationCacheService, _lifecycleService) {
|
|
2886
|
+
super(), this._univerInstanceService = _univerInstanceService, this._sheetDataValidationModel = _sheetDataValidationModel, this._dataValidationCacheService = _dataValidationCacheService, this._lifecycleService = _lifecycleService, this._initRecalculate();
|
|
2887
|
+
}
|
|
2888
|
+
_initRecalculate() {
|
|
2889
|
+
const handleDirtyRanges = /* @__PURE__ */ __name((ranges) => {
|
|
2890
|
+
if (ranges.length === 0)
|
|
2891
|
+
return;
|
|
2892
|
+
const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), worksheet = workbook == null ? void 0 : workbook.getActiveSheet(), map = {};
|
|
2893
|
+
ranges.flat().forEach((range) => {
|
|
2894
|
+
map[range.unitId] || (map[range.unitId] = {}), map[range.unitId][range.subUnitId] || (map[range.unitId][range.subUnitId] = []);
|
|
2895
|
+
const workbook2 = this._univerInstanceService.getUnit(range.unitId, UniverInstanceType.UNIVER_SHEET), worksheet2 = workbook2 == null ? void 0 : workbook2.getSheetBySheetId(range.subUnitId);
|
|
2896
|
+
worksheet2 && map[range.unitId][range.subUnitId].push(...range.ranges.map((range2) => Range.transformRange(range2, worksheet2)));
|
|
2897
|
+
}), Object.entries(map).forEach(([unitId, subUnitMap]) => {
|
|
2898
|
+
Object.entries(subUnitMap).forEach(([subUnitId, ranges2]) => {
|
|
2899
|
+
(workbook == null ? void 0 : workbook.getUnitId()) === unitId && (worksheet == null ? void 0 : worksheet.getSheetId()) === subUnitId ? this.validatorRanges(unitId, subUnitId, ranges2) : requestIdleCallback(() => {
|
|
2900
|
+
this.validatorRanges(unitId, subUnitId, ranges2);
|
|
2901
|
+
});
|
|
2902
|
+
});
|
|
2903
|
+
});
|
|
2904
|
+
}, "handleDirtyRanges");
|
|
2905
|
+
this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(bufferWhen(() => this._lifecycleService.lifecycle$.pipe(filter((stage) => stage === LifecycleStages.Rendered)))).subscribe(handleDirtyRanges)), this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(filter(() => this._lifecycleService.stage >= LifecycleStages.Rendered), bufferDebounceTime(20)).subscribe(handleDirtyRanges));
|
|
2852
2906
|
}
|
|
2853
2907
|
async validatorCell(unitId, subUnitId, row, col) {
|
|
2854
2908
|
const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
|
|
@@ -2859,9 +2913,11 @@ let SheetsDataValidationValidatorService = (_a9 = class {
|
|
|
2859
2913
|
throw new Error(`cannot find current worksheet, sheetId: ${subUnitId}`);
|
|
2860
2914
|
if (!Tools.isDefine(row) || !Tools.isDefine(col))
|
|
2861
2915
|
throw new Error(`row or col is not defined, row: ${row}, col: ${col}`);
|
|
2862
|
-
const
|
|
2916
|
+
const rule = this._sheetDataValidationModel.getRuleByLocation(unitId, subUnitId, row, col);
|
|
2863
2917
|
return rule ? new Promise((resolve) => {
|
|
2864
|
-
this._sheetDataValidationModel.validator(
|
|
2918
|
+
this._sheetDataValidationModel.validator(rule, { unitId, subUnitId, row, col, worksheet, workbook }, (status) => {
|
|
2919
|
+
resolve(status);
|
|
2920
|
+
});
|
|
2865
2921
|
}) : DataValidationStatus.VALID;
|
|
2866
2922
|
}
|
|
2867
2923
|
validatorRanges(unitId, subUnitId, ranges) {
|
|
@@ -2899,18 +2955,19 @@ let SheetsDataValidationValidatorService = (_a9 = class {
|
|
|
2899
2955
|
getDataValidation(unitId, subUnitId, ranges) {
|
|
2900
2956
|
return this.getDataValidations(unitId, subUnitId, ranges)[0];
|
|
2901
2957
|
}
|
|
2902
|
-
}, __name(
|
|
2958
|
+
}, __name(_a10, "SheetsDataValidationValidatorService"), _a10);
|
|
2903
2959
|
SheetsDataValidationValidatorService = __decorateClass$1([
|
|
2904
2960
|
__decorateParam$1(0, IUniverInstanceService),
|
|
2905
2961
|
__decorateParam$1(1, Inject(SheetDataValidationModel)),
|
|
2906
|
-
__decorateParam$1(2, Inject(DataValidationCacheService))
|
|
2962
|
+
__decorateParam$1(2, Inject(DataValidationCacheService)),
|
|
2963
|
+
__decorateParam$1(3, Inject(LifecycleService))
|
|
2907
2964
|
], SheetsDataValidationValidatorService);
|
|
2908
2965
|
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2909
2966
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2910
2967
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2911
2968
|
return kind && result && __defProp2(target, key, result), result;
|
|
2912
|
-
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField"),
|
|
2913
|
-
let UniverSheetsDataValidationPlugin = (
|
|
2969
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField"), _a11;
|
|
2970
|
+
let UniverSheetsDataValidationPlugin = (_a11 = class extends Plugin {
|
|
2914
2971
|
constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
|
|
2915
2972
|
super(), this._config = _config, this._injector = _injector, this._commandService = _commandService, this._configService = _configService;
|
|
2916
2973
|
const { ...rest } = this._config;
|
|
@@ -2939,7 +2996,7 @@ let UniverSheetsDataValidationPlugin = (_a10 = class extends Plugin {
|
|
|
2939
2996
|
ClearRangeDataValidationCommand
|
|
2940
2997
|
].forEach((command) => {
|
|
2941
2998
|
this._commandService.registerCommand(command);
|
|
2942
|
-
}), this._injector.get(DataValidationRefRangeController);
|
|
2999
|
+
}), this._injector.get(DataValidationCacheService), this._injector.get(SheetsDataValidationValidatorService), this._injector.get(DataValidationRefRangeController);
|
|
2943
3000
|
}
|
|
2944
3001
|
onReady() {
|
|
2945
3002
|
this._injector.get(SheetDataValidationSheetController);
|
|
@@ -2947,7 +3004,7 @@ let UniverSheetsDataValidationPlugin = (_a10 = class extends Plugin {
|
|
|
2947
3004
|
onRendered() {
|
|
2948
3005
|
this._injector.get(DataValidationController), this._injector.get(DataValidationFormulaController);
|
|
2949
3006
|
}
|
|
2950
|
-
}, __name(
|
|
3007
|
+
}, __name(_a11, "UniverSheetsDataValidationPlugin"), _a11);
|
|
2951
3008
|
__publicField2(UniverSheetsDataValidationPlugin, "pluginName", DATA_VALIDATION_PLUGIN_NAME);
|
|
2952
3009
|
__publicField2(UniverSheetsDataValidationPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
2953
3010
|
UniverSheetsDataValidationPlugin = __decorateClass([
|
|
@@ -2978,7 +3035,6 @@ export {
|
|
|
2978
3035
|
DataValidationCustomFormulaService,
|
|
2979
3036
|
DataValidationFormulaController,
|
|
2980
3037
|
DataValidationFormulaService,
|
|
2981
|
-
DataValidationModel2 as DataValidationModel,
|
|
2982
3038
|
DateValidator,
|
|
2983
3039
|
ListMultipleValidator,
|
|
2984
3040
|
ListValidator,
|