@univerjs/sheets-data-validation 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +59 -46
- package/lib/locale/en-US.json +2 -1
- package/lib/locale/ru-RU.json +1 -0
- package/lib/locale/vi-VN.json +1 -0
- package/lib/locale/zh-CN.json +1 -0
- package/lib/locale/zh-TW.json +1 -0
- package/lib/types/locale/zh-CN.d.ts +1 -0
- package/lib/types/services/dropdown-manager.service.d.ts +1 -0
- package/lib/types/services/dv-custom-formula.service.d.ts +3 -2
- package/lib/types/services/dv-formula.service.d.ts +3 -2
- package/lib/umd/index.js +1 -1
- package/package.json +25 -25
package/lib/es/index.js
CHANGED
|
@@ -354,25 +354,26 @@ var __defProp$i = Object.defineProperty, __getOwnPropDesc$i = Object.getOwnPrope
|
|
|
354
354
|
return kind && result && __defProp$i(target, key, result), result;
|
|
355
355
|
}, "__decorateClass$i"), __decorateParam$i = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$i"), _a3;
|
|
356
356
|
let DataValidationFormulaService = (_a3 = class extends Disposable {
|
|
357
|
-
constructor(_registerOtherFormulaService, _dataValidationCacheService, _dataValidationModel) {
|
|
357
|
+
constructor(_instanceService, _registerOtherFormulaService, _dataValidationCacheService, _dataValidationModel) {
|
|
358
358
|
super();
|
|
359
359
|
__publicField(this, "_formulaRuleMap", /* @__PURE__ */ new Map());
|
|
360
|
-
this._registerOtherFormulaService = _registerOtherFormulaService, this._dataValidationCacheService = _dataValidationCacheService, this._dataValidationModel = _dataValidationModel, this._initFormulaResultHandler();
|
|
360
|
+
this._instanceService = _instanceService, this._registerOtherFormulaService = _registerOtherFormulaService, this._dataValidationCacheService = _dataValidationCacheService, this._dataValidationModel = _dataValidationModel, this._initFormulaResultHandler();
|
|
361
361
|
}
|
|
362
362
|
_initFormulaResultHandler() {
|
|
363
363
|
this.disposeWithMe(this._registerOtherFormulaService.formulaResult$.subscribe((resultMap) => {
|
|
364
364
|
for (const unitId in resultMap) {
|
|
365
365
|
const unitMap = resultMap[unitId];
|
|
366
|
-
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
366
|
+
if (this._instanceService.getUnitType(unitId) === UniverInstanceType.UNIVER_SHEET)
|
|
367
|
+
for (const subUnitId in unitMap) {
|
|
368
|
+
const results = unitMap[subUnitId], formulaMap = this._ensureRuleFormulaMap(unitId, subUnitId), manager = this._dataValidationModel.ensureManager(unitId, subUnitId);
|
|
369
|
+
results.forEach((result) => {
|
|
370
|
+
var _a23, _b;
|
|
371
|
+
if (formulaMap.get((_a23 = result.extra) == null ? void 0 : _a23.ruleId)) {
|
|
372
|
+
const rule = manager.getRuleById((_b = result.extra) == null ? void 0 : _b.ruleId);
|
|
373
|
+
rule && this._dataValidationCacheService.markRangeDirty(unitId, subUnitId, rule.ranges);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
}
|
|
376
377
|
}
|
|
377
378
|
}));
|
|
378
379
|
}
|
|
@@ -453,9 +454,10 @@ let DataValidationFormulaService = (_a3 = class extends Disposable {
|
|
|
453
454
|
}
|
|
454
455
|
}, __name(_a3, "DataValidationFormulaService"), _a3);
|
|
455
456
|
DataValidationFormulaService = __decorateClass$i([
|
|
456
|
-
__decorateParam$i(0,
|
|
457
|
-
__decorateParam$i(1, Inject(
|
|
458
|
-
__decorateParam$i(2, Inject(
|
|
457
|
+
__decorateParam$i(0, IUniverInstanceService),
|
|
458
|
+
__decorateParam$i(1, Inject(RegisterOtherFormulaService)),
|
|
459
|
+
__decorateParam$i(2, Inject(DataValidationCacheService)),
|
|
460
|
+
__decorateParam$i(3, Inject(DataValidationModel))
|
|
459
461
|
], DataValidationFormulaService);
|
|
460
462
|
function getFormulaResult(result) {
|
|
461
463
|
var _a23, _b;
|
|
@@ -1275,7 +1277,7 @@ function DataValidationDetail() {
|
|
|
1275
1277
|
}, [commandService, dataValidationModel, ruleId, subUnitId, unitId]), !validator)
|
|
1276
1278
|
return null;
|
|
1277
1279
|
const operators = validator.operators, operatorNames = validator.operatorNames, isTwoFormula = localRule.operator ? TWO_FORMULA_OPERATOR_COUNT$1.includes(localRule.operator) : !1, handleOk = /* @__PURE__ */ __name(() => {
|
|
1278
|
-
validator.validatorFormula(localRule, unitId, subUnitId).success ? dataValidationPanelService.setActiveRule(null) : setShowError(!0);
|
|
1280
|
+
localRule.ranges.length && (validator.validatorFormula(localRule, unitId, subUnitId).success ? dataValidationPanelService.setActiveRule(null) : setShowError(!0));
|
|
1279
1281
|
}, "handleOk"), handleUpdateRuleRanges = useEvent((unitRanges) => {
|
|
1280
1282
|
if (isUnitRangesEqual(unitRanges, localRanges))
|
|
1281
1283
|
return;
|
|
@@ -1358,20 +1360,27 @@ function DataValidationDetail() {
|
|
|
1358
1360
|
));
|
|
1359
1361
|
}, "handleUpdateRuleOptions");
|
|
1360
1362
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
1361
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1362
|
-
|
|
1363
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1364
|
+
FormLayout,
|
|
1363
1365
|
{
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1366
|
+
label: localeService.t("dataValidation.panel.range"),
|
|
1367
|
+
error: localRule.ranges.length ? "" : localeService.t("dataValidation.panel.rangeError"),
|
|
1368
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1369
|
+
RangeSelector,
|
|
1370
|
+
{
|
|
1371
|
+
className: styles$4.dataValidationDetailFormItem,
|
|
1372
|
+
value: rangeStr,
|
|
1373
|
+
id: createInternalEditorID("data-validation-detail"),
|
|
1374
|
+
openForSheetUnitId: unitId,
|
|
1375
|
+
openForSheetSubUnitId: subUnitId,
|
|
1376
|
+
onChange: /* @__PURE__ */ __name((newRange) => {
|
|
1377
|
+
newRange.some((i) => !isValidRange(i.range) || i.range.endColumn < i.range.startColumn || i.range.endRow < i.range.startRow) || handleUpdateRuleRanges(newRange);
|
|
1378
|
+
}, "onChange")
|
|
1379
|
+
},
|
|
1380
|
+
key
|
|
1381
|
+
)
|
|
1382
|
+
}
|
|
1383
|
+
),
|
|
1375
1384
|
/* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("dataValidation.panel.type"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1376
1385
|
Select,
|
|
1377
1386
|
{
|
|
@@ -3027,8 +3036,9 @@ let SheetsDataValidationRenderController = (_a8 = class extends RxDisposable {
|
|
|
3027
3036
|
}
|
|
3028
3037
|
_initDropdown() {
|
|
3029
3038
|
this._editorBridgeService && this.disposeWithMe(this._editorBridgeService.visible$.subscribe((visible) => {
|
|
3039
|
+
var _a23;
|
|
3030
3040
|
if (!visible.visible) {
|
|
3031
|
-
this._dropdownManagerService.hideDropdown();
|
|
3041
|
+
((_a23 = this._dropdownManagerService.activeDropdown) == null ? void 0 : _a23.trigger) === "editor-bridge" && this._dropdownManagerService.hideDropdown();
|
|
3032
3042
|
return;
|
|
3033
3043
|
}
|
|
3034
3044
|
const state = this._editorBridgeService.getEditCellState();
|
|
@@ -3059,7 +3069,8 @@ let SheetsDataValidationRenderController = (_a8 = class extends RxDisposable {
|
|
|
3059
3069
|
},
|
|
3060
3070
|
componentKey: validator.dropdown,
|
|
3061
3071
|
onHide: /* @__PURE__ */ __name(() => {
|
|
3062
|
-
}, "onHide")
|
|
3072
|
+
}, "onHide"),
|
|
3073
|
+
trigger: "editor-bridge"
|
|
3063
3074
|
},
|
|
3064
3075
|
!1
|
|
3065
3076
|
);
|
|
@@ -3410,7 +3421,7 @@ var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPrope
|
|
|
3410
3421
|
return kind && result && __defProp$b(target, key, result), result;
|
|
3411
3422
|
}, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b"), _a11;
|
|
3412
3423
|
let DataValidationCustomFormulaService = (_a11 = class extends Disposable {
|
|
3413
|
-
constructor(_registerOtherFormulaService, _lexerTreeBuilder, _dataValidationModel, _dataValidationCacheService) {
|
|
3424
|
+
constructor(_instanceSrv, _registerOtherFormulaService, _lexerTreeBuilder, _dataValidationModel, _dataValidationCacheService) {
|
|
3414
3425
|
super();
|
|
3415
3426
|
__publicField(this, "_formulaMap", /* @__PURE__ */ new Map());
|
|
3416
3427
|
/**
|
|
@@ -3421,20 +3432,21 @@ let DataValidationCustomFormulaService = (_a11 = class extends Disposable {
|
|
|
3421
3432
|
* reflect of formulaId to cell, only store transformable formula
|
|
3422
3433
|
*/
|
|
3423
3434
|
__publicField(this, "_formulaCellMap", /* @__PURE__ */ new Map());
|
|
3424
|
-
this._registerOtherFormulaService = _registerOtherFormulaService, this._lexerTreeBuilder = _lexerTreeBuilder, this._dataValidationModel = _dataValidationModel, this._dataValidationCacheService = _dataValidationCacheService, this._initFormulaResultHandler();
|
|
3435
|
+
this._instanceSrv = _instanceSrv, this._registerOtherFormulaService = _registerOtherFormulaService, this._lexerTreeBuilder = _lexerTreeBuilder, this._dataValidationModel = _dataValidationModel, this._dataValidationCacheService = _dataValidationCacheService, this._initFormulaResultHandler();
|
|
3425
3436
|
}
|
|
3426
3437
|
_initFormulaResultHandler() {
|
|
3427
3438
|
this.disposeWithMe(this._registerOtherFormulaService.formulaResult$.subscribe((resultMap) => {
|
|
3428
3439
|
for (const unitId in resultMap) {
|
|
3429
3440
|
const unitMap = resultMap[unitId];
|
|
3430
|
-
|
|
3431
|
-
const
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3441
|
+
if (this._instanceSrv.getUnitType(unitId) === UniverInstanceType.UNIVER_SHEET)
|
|
3442
|
+
for (const subUnitId in unitMap) {
|
|
3443
|
+
const results = unitMap[subUnitId], { formulaCellMap, ruleFormulaMap } = this._ensureMaps(unitId, subUnitId), manager = this._dataValidationModel.ensureManager(unitId, subUnitId);
|
|
3444
|
+
results.forEach((result) => {
|
|
3445
|
+
var _a23, _b;
|
|
3446
|
+
const ruleInfo = ruleFormulaMap.get((_a23 = result.extra) == null ? void 0 : _a23.ruleId), cellInfo = formulaCellMap.get(result.formulaId), rule = manager.getRuleById((_b = result.extra) == null ? void 0 : _b.ruleId);
|
|
3447
|
+
rule && ruleInfo && !ruleInfo.isTransformable && this._dataValidationCacheService.markRangeDirty(unitId, subUnitId, rule.ranges), cellInfo && this._dataValidationCacheService.markCellDirty(unitId, subUnitId, cellInfo.row, cellInfo.column);
|
|
3448
|
+
});
|
|
3449
|
+
}
|
|
3438
3450
|
}
|
|
3439
3451
|
}));
|
|
3440
3452
|
}
|
|
@@ -3563,10 +3575,11 @@ let DataValidationCustomFormulaService = (_a11 = class extends Disposable {
|
|
|
3563
3575
|
}
|
|
3564
3576
|
}, __name(_a11, "DataValidationCustomFormulaService"), _a11);
|
|
3565
3577
|
DataValidationCustomFormulaService = __decorateClass$b([
|
|
3566
|
-
__decorateParam$b(0,
|
|
3567
|
-
__decorateParam$b(1, Inject(
|
|
3568
|
-
__decorateParam$b(2, Inject(
|
|
3569
|
-
__decorateParam$b(3, Inject(
|
|
3578
|
+
__decorateParam$b(0, IUniverInstanceService),
|
|
3579
|
+
__decorateParam$b(1, Inject(RegisterOtherFormulaService)),
|
|
3580
|
+
__decorateParam$b(2, Inject(LexerTreeBuilder)),
|
|
3581
|
+
__decorateParam$b(3, Inject(DataValidationModel)),
|
|
3582
|
+
__decorateParam$b(4, Inject(DataValidationCacheService))
|
|
3570
3583
|
], DataValidationCustomFormulaService);
|
|
3571
3584
|
const _CustomFormulaValidator = class _CustomFormulaValidator extends BaseDataValidator {
|
|
3572
3585
|
constructor() {
|
|
@@ -4206,7 +4219,7 @@ let DataValidationRefRangeController = (_a15 = class extends Disposable {
|
|
|
4206
4219
|
}
|
|
4207
4220
|
}, __name(_a15, "DataValidationRefRangeController"), _a15);
|
|
4208
4221
|
DataValidationRefRangeController = __decorateClass$7([
|
|
4209
|
-
OnLifecycle(LifecycleStages.
|
|
4222
|
+
OnLifecycle(LifecycleStages.Starting, DataValidationRefRangeController),
|
|
4210
4223
|
__decorateParam$7(0, Inject(DataValidationModel)),
|
|
4211
4224
|
__decorateParam$7(1, Inject(Injector)),
|
|
4212
4225
|
__decorateParam$7(2, Inject(RefRangeService)),
|
package/lib/locale/en-US.json
CHANGED
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"showWarning": "Show warning",
|
|
34
34
|
"rejectInput": "Reject input",
|
|
35
35
|
"messageInfo": "Helper message",
|
|
36
|
-
"showInfo": "Show help text for a selected cell"
|
|
36
|
+
"showInfo": "Show help text for a selected cell",
|
|
37
|
+
"rangeError": "Ranges are not legal"
|
|
37
38
|
},
|
|
38
39
|
"operators": {
|
|
39
40
|
"between": "between",
|
package/lib/locale/ru-RU.json
CHANGED
package/lib/locale/vi-VN.json
CHANGED
package/lib/locale/zh-CN.json
CHANGED
package/lib/locale/zh-TW.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IRange, ISheetDataValidationRule, Disposable } from '@univerjs/core';
|
|
1
|
+
import { IRange, ISheetDataValidationRule, Disposable, IUniverInstanceService } from '@univerjs/core';
|
|
2
2
|
import { LexerTreeBuilder } from '@univerjs/engine-formula';
|
|
3
3
|
import { DataValidationModel } from '@univerjs/data-validation';
|
|
4
4
|
import { RegisterOtherFormulaService } from '@univerjs/sheets-formula';
|
|
@@ -12,6 +12,7 @@ interface IFormulaData {
|
|
|
12
12
|
formulaId?: string;
|
|
13
13
|
}
|
|
14
14
|
export declare class DataValidationCustomFormulaService extends Disposable {
|
|
15
|
+
private readonly _instanceSrv;
|
|
15
16
|
private _registerOtherFormulaService;
|
|
16
17
|
private _lexerTreeBuilder;
|
|
17
18
|
private readonly _dataValidationModel;
|
|
@@ -25,7 +26,7 @@ export declare class DataValidationCustomFormulaService extends Disposable {
|
|
|
25
26
|
* reflect of formulaId to cell, only store transformable formula
|
|
26
27
|
*/
|
|
27
28
|
private _formulaCellMap;
|
|
28
|
-
constructor(_registerOtherFormulaService: RegisterOtherFormulaService, _lexerTreeBuilder: LexerTreeBuilder, _dataValidationModel: DataValidationModel, _dataValidationCacheService: DataValidationCacheService);
|
|
29
|
+
constructor(_instanceSrv: IUniverInstanceService, _registerOtherFormulaService: RegisterOtherFormulaService, _lexerTreeBuilder: LexerTreeBuilder, _dataValidationModel: DataValidationModel, _dataValidationCacheService: DataValidationCacheService);
|
|
29
30
|
private _initFormulaResultHandler;
|
|
30
31
|
private _ensureMaps;
|
|
31
32
|
private _registerFormula;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { Nullable, Disposable } from '@univerjs/core';
|
|
1
|
+
import { Nullable, Disposable, IUniverInstanceService } from '@univerjs/core';
|
|
2
2
|
import { DataValidationModel } from '@univerjs/data-validation';
|
|
3
3
|
import { IFormulaInfo, IOtherFormulaResult, RegisterOtherFormulaService } from '@univerjs/sheets-formula';
|
|
4
4
|
import { DataValidationCacheService } from './dv-cache.service';
|
|
5
5
|
|
|
6
6
|
export declare class DataValidationFormulaService extends Disposable {
|
|
7
|
+
private readonly _instanceService;
|
|
7
8
|
private _registerOtherFormulaService;
|
|
8
9
|
private readonly _dataValidationCacheService;
|
|
9
10
|
private readonly _dataValidationModel;
|
|
10
11
|
private _formulaRuleMap;
|
|
11
|
-
constructor(_registerOtherFormulaService: RegisterOtherFormulaService, _dataValidationCacheService: DataValidationCacheService, _dataValidationModel: DataValidationModel);
|
|
12
|
+
constructor(_instanceService: IUniverInstanceService, _registerOtherFormulaService: RegisterOtherFormulaService, _dataValidationCacheService: DataValidationCacheService, _dataValidationModel: DataValidationModel);
|
|
12
13
|
private _initFormulaResultHandler;
|
|
13
14
|
private _ensureRuleFormulaMap;
|
|
14
15
|
addRule(unitId: string, subUnitId: string, ruleId: string, formula1: string | undefined, formula2: string | undefined): void;
|