@univerjs/sheets-data-validation 0.2.13 → 0.2.15
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 +2 -2
- package/lib/es/index.js +129 -139
- package/lib/types/controllers/dv-ref-range.controller.d.ts +2 -2
- package/lib/types/models/rule-matrix.d.ts +10 -7
- package/lib/types/validators/checkbox-validator.d.ts +4 -1
- package/lib/types/validators/list-validator.d.ts +5 -2
- package/lib/umd/index.js +2 -2
- package/package.json +25 -26
package/lib/es/index.js
CHANGED
|
@@ -2,7 +2,7 @@ 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, Inject, Disposable, UniverInstanceType, DataValidationType, isFormulaString, IUniverInstanceService, ILogService,
|
|
5
|
+
import { ObjectMatrix, Range, Inject, Disposable, UniverInstanceType, DataValidationType, isFormulaString, IUniverInstanceService, ILogService, getOriginCellValue, Rectangle, Tools, OnLifecycle, LifecycleStages, DataValidationStatus, DataValidationOperator, createInternalEditorID, useDependency, LocaleService, IPermissionService, ThemeService, ICommandService, VerticalAlign, HorizontalAlign, WrapStrategy, toDisposable, DataValidationErrorStyle, UndoCommand, RedoCommand, isUnitRangesEqual, isValidRange, debounce, shallowEqual, Injector, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DisposableCollection, CommandType, BuildTextUtils, DataValidationRenderMode, numfmt, CellValueType, DEFAULT_STYLES, DocumentDataModel, DEFAULT_EMPTY_DOCUMENT_VALUE, BooleanNumber, IUndoRedoService, sequenceExecuteAsync, sequenceExecute, RxDisposable, queryObjectMatrix, isRangesEqual, Optional, DependentOn, Plugin, IConfigService } from "@univerjs/core";
|
|
6
6
|
import { DataValidationModel, DataValidatorRegistryService, UpdateRuleType, BaseDataValidator, DataValidatorRegistryScope, TWO_FORMULA_OPERATOR_COUNT as TWO_FORMULA_OPERATOR_COUNT$1, getRuleOptions, getRuleSetting, TextLengthErrorTitleMap, AddDataValidationMutation, RemoveDataValidationMutation, UpdateDataValidationMutation, UniverDataValidationPlugin } from "@univerjs/data-validation";
|
|
7
7
|
import { DataValidationModel as DataValidationModel2 } from "@univerjs/data-validation";
|
|
8
8
|
import { SheetsSelectionsService, WorksheetViewPermission, SetRangeValuesCommand, checkRangesEditablePermission, getSheetCommandTarget, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, WorkbookEditablePermission, WorksheetSetCellStylePermission, WorksheetEditPermission, RangeProtectionPermissionEditPoint, SheetInterceptorService, ClearSelectionAllCommand, RefRangeService, handleCommonDefaultRangeChangeWithEffectRefCommands, INTERCEPTOR_POINT, InterceptCellContentPriority, UniverSheetsPlugin, RemoveSheetCommand } from "@univerjs/sheets";
|
|
@@ -17,7 +17,6 @@ import { fixLineWidthByScale, Transform, Checkbox as Checkbox$1, IRenderManagerS
|
|
|
17
17
|
import dayjs from "dayjs";
|
|
18
18
|
import { IMarkSelectionService, SheetCanvasPopManagerService, IEditorBridgeService, getCurrentRangeDisable$, HoverManagerService, CellAlertManagerService, CellAlertType, COPY_TYPE, rangeToDiscreteRange, PREDEFINED_HOOK_NAME, virtualizeDiscreteRanges, getRepeatRange, ISheetClipboardService, SheetPermissionInterceptorBaseController, AutoHeightController, SheetSkeletonManagerService, UniverSheetsUIPlugin, IAutoFillService, APPLY_TYPE, getAutoFillRepeatRange } from "@univerjs/sheets-ui";
|
|
19
19
|
import { RichTextEditingMutation } from "@univerjs/docs";
|
|
20
|
-
import { getPlainTextFormDocument } from "@univerjs/docs-ui";
|
|
21
20
|
import { getPatternType, UniverSheetsNumfmtPlugin } from "@univerjs/sheets-numfmt";
|
|
22
21
|
const _DataValidationCacheService = class _DataValidationCacheService {
|
|
23
22
|
constructor() {
|
|
@@ -357,16 +356,7 @@ DataValidationFormulaService = __decorateClass$j([
|
|
|
357
356
|
__decorateParam$j(3, Inject(DataValidationModel))
|
|
358
357
|
], DataValidationFormulaService);
|
|
359
358
|
function getCellValueOrigin(cell) {
|
|
360
|
-
|
|
361
|
-
return "";
|
|
362
|
-
if (cell != null && cell.p) {
|
|
363
|
-
const body = cell == null ? void 0 : cell.p.body;
|
|
364
|
-
if (body == null)
|
|
365
|
-
return "";
|
|
366
|
-
const data = body.dataStream;
|
|
367
|
-
return (data.substring(data.length - 2, data.length) === DEFAULT_EMPTY_DOCUMENT_VALUE ? data.substring(0, data.length - 2) : data).replaceAll(DataStreamTreeTokenType.CUSTOM_RANGE_START, "").replaceAll(DataStreamTreeTokenType.CUSTOM_RANGE_END, "");
|
|
368
|
-
}
|
|
369
|
-
return cell == null ? void 0 : cell.v;
|
|
359
|
+
return getOriginCellValue(cell);
|
|
370
360
|
}
|
|
371
361
|
__name(getCellValueOrigin, "getCellValueOrigin");
|
|
372
362
|
function getStringCellValue(cell) {
|
|
@@ -376,55 +366,40 @@ function getStringCellValue(cell) {
|
|
|
376
366
|
__name(getStringCellValue, "getStringCellValue");
|
|
377
367
|
const _RuleMatrix = class _RuleMatrix {
|
|
378
368
|
constructor(value, _worksheet) {
|
|
379
|
-
__publicField(this, "
|
|
380
|
-
this._worksheet = _worksheet, this.
|
|
369
|
+
__publicField(this, "_map", /* @__PURE__ */ new Map());
|
|
370
|
+
this._worksheet = _worksheet, this._map = value;
|
|
381
371
|
}
|
|
382
372
|
addRule(rule) {
|
|
383
|
-
const ruleId = rule.uid;
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
ranges.forEach((range) => {
|
|
395
|
-
Range.foreach(Range.transformRange(range, this._worksheet), (row, col) => {
|
|
396
|
-
this.value.realDeleteValue(row, col);
|
|
397
|
-
});
|
|
373
|
+
const ruleId = rule.uid, ranges = rule.ranges.map((range) => Range.transformRange(range, this._worksheet));
|
|
374
|
+
this._map.forEach((value, key) => {
|
|
375
|
+
const newRanges = Rectangle.subtractMulti(value, ranges);
|
|
376
|
+
newRanges.length === 0 ? this._map.delete(key) : this._map.set(key, newRanges);
|
|
377
|
+
}), this._map.set(ruleId, ranges);
|
|
378
|
+
}
|
|
379
|
+
removeRange(_ranges) {
|
|
380
|
+
const ranges = _ranges.map((range) => Range.transformRange(range, this._worksheet));
|
|
381
|
+
this._map.forEach((value, key) => {
|
|
382
|
+
const newRanges = Rectangle.subtractMulti(value, ranges);
|
|
383
|
+
newRanges.length === 0 ? this._map.delete(key) : this._map.set(key, newRanges);
|
|
398
384
|
});
|
|
399
385
|
}
|
|
400
386
|
removeRule(rule) {
|
|
401
|
-
|
|
402
|
-
Range.foreach(Range.transformRange(range, this._worksheet), (row, col) => {
|
|
403
|
-
this.value.setValue(row, col, "");
|
|
404
|
-
});
|
|
405
|
-
});
|
|
387
|
+
this._map.delete(rule.uid);
|
|
406
388
|
}
|
|
407
|
-
updateRange(ruleId,
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}),
|
|
414
|
-
Range.foreach(range, (row, col) => {
|
|
415
|
-
this.value.setValue(row, col, ruleId);
|
|
416
|
-
});
|
|
417
|
-
}), oldRanges.forEach((range) => {
|
|
418
|
-
Range.foreach(range, (row, col) => {
|
|
419
|
-
this.value.getValue(row, col) === tempRuleId && this.value.realDeleteValue(row, col);
|
|
420
|
-
});
|
|
421
|
-
});
|
|
389
|
+
updateRange(ruleId, _newRanges) {
|
|
390
|
+
this._map.delete(ruleId);
|
|
391
|
+
const ranges = _newRanges.map((range) => Range.transformRange(range, this._worksheet));
|
|
392
|
+
this._map.forEach((value, key) => {
|
|
393
|
+
const newRanges = Rectangle.subtractMulti(value, ranges);
|
|
394
|
+
newRanges.length === 0 ? this._map.delete(key) : this._map.set(key, newRanges);
|
|
395
|
+
}), this._map.set(ruleId, ranges);
|
|
422
396
|
}
|
|
423
397
|
diff(rules) {
|
|
424
398
|
const mutations = [];
|
|
425
399
|
let deleteIndex = 0;
|
|
426
400
|
return rules.forEach((rule, index) => {
|
|
427
|
-
|
|
401
|
+
var _a23;
|
|
402
|
+
const newRanges = (_a23 = this._map.get(rule.uid)) != null ? _a23 : [], oldRanges = rule.ranges;
|
|
428
403
|
(newRanges.length !== oldRanges.length || newRanges.some((range, i) => !Rectangle.equals(range, oldRanges[i]))) && mutations.push({
|
|
429
404
|
type: "update",
|
|
430
405
|
ruleId: rule.uid,
|
|
@@ -441,7 +416,8 @@ const _RuleMatrix = class _RuleMatrix {
|
|
|
441
416
|
const mutations = [];
|
|
442
417
|
let deleteIndex = 0;
|
|
443
418
|
return rules.forEach((rule, index) => {
|
|
444
|
-
|
|
419
|
+
var _a23;
|
|
420
|
+
const newRanges = (_a23 = this._map.get(rule.uid)) != null ? _a23 : [], oldRanges = rule.ranges;
|
|
445
421
|
(newRanges.length !== oldRanges.length || newRanges.some((range, i) => !Rectangle.equals(range, oldRanges[i]))) && mutations.push({
|
|
446
422
|
type: "update",
|
|
447
423
|
ruleId: rule.uid,
|
|
@@ -453,7 +429,8 @@ const _RuleMatrix = class _RuleMatrix {
|
|
|
453
429
|
index: index - deleteIndex
|
|
454
430
|
}), deleteIndex++);
|
|
455
431
|
}), Array.from(additionRules).forEach((rule) => {
|
|
456
|
-
|
|
432
|
+
var _a23;
|
|
433
|
+
const newRanges = (_a23 = this._map.get(rule.uid)) != null ? _a23 : [];
|
|
457
434
|
mutations.push({
|
|
458
435
|
type: "add",
|
|
459
436
|
rule: {
|
|
@@ -464,13 +441,27 @@ const _RuleMatrix = class _RuleMatrix {
|
|
|
464
441
|
}), mutations;
|
|
465
442
|
}
|
|
466
443
|
clone() {
|
|
467
|
-
return new _RuleMatrix(new
|
|
444
|
+
return new _RuleMatrix(new Map(Tools.deepClone(Array.from(this._map.entries()))), this._worksheet);
|
|
468
445
|
}
|
|
469
446
|
getValue(row, col) {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
447
|
+
var _a23;
|
|
448
|
+
const keys = Array.from(this._map.keys());
|
|
449
|
+
for (const id of keys)
|
|
450
|
+
if (((_a23 = this._map.get(id)) != null ? _a23 : []).find((range) => range.startRow <= row && range.endRow >= row && range.startColumn <= col && range.endColumn >= col))
|
|
451
|
+
return id;
|
|
452
|
+
}
|
|
453
|
+
addRangeRules(rules) {
|
|
454
|
+
rules.forEach(({ id: ruleId, ranges }) => {
|
|
455
|
+
if (!ranges.length)
|
|
456
|
+
return;
|
|
457
|
+
let current = this._map.get(ruleId);
|
|
458
|
+
current ? (this._map.set(ruleId, Rectangle.mergeRanges([...current, ...ranges])), current = this._map.get(ruleId)) : (current = ranges, this._map.set(ruleId, current)), this._map.forEach((value, key) => {
|
|
459
|
+
if (key === ruleId)
|
|
460
|
+
return;
|
|
461
|
+
const newRanges = Rectangle.subtractMulti(value, ranges);
|
|
462
|
+
newRanges.length === 0 ? this._map.delete(key) : this._map.set(key, newRanges);
|
|
463
|
+
});
|
|
464
|
+
});
|
|
474
465
|
}
|
|
475
466
|
};
|
|
476
467
|
__name(_RuleMatrix, "RuleMatrix");
|
|
@@ -526,24 +517,27 @@ let SheetDataValidationModel = (_a3 = class extends Disposable {
|
|
|
526
517
|
if (!workbook)
|
|
527
518
|
throw new Error(`workbook not found, unitId: ${unitId}`);
|
|
528
519
|
unitMap || (unitMap = /* @__PURE__ */ new Map(), this._ruleMatrixMap.set(unitId, unitMap));
|
|
529
|
-
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
530
|
-
if (!worksheet)
|
|
531
|
-
throw new Error(`worksheet not found, unitId: ${unitId}, subUnitId: ${subUnitId}`);
|
|
532
520
|
let matrix = unitMap.get(subUnitId);
|
|
533
|
-
|
|
521
|
+
if (!matrix) {
|
|
522
|
+
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
523
|
+
if (!worksheet)
|
|
524
|
+
throw new Error(`worksheet not found, unitId: ${unitId}, subUnitId: ${subUnitId}`);
|
|
525
|
+
matrix = new RuleMatrix(/* @__PURE__ */ new Map(), worksheet), unitMap.set(subUnitId, matrix);
|
|
526
|
+
}
|
|
527
|
+
return matrix;
|
|
534
528
|
}
|
|
535
529
|
_addRuleSideEffect(unitId, subUnitId, rule) {
|
|
536
530
|
var _a23;
|
|
537
531
|
(rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE) && isReferenceString((_a23 = rule.formula1) != null ? _a23 : "") && (rule.formula1 = `=${rule.formula1}`), 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);
|
|
538
532
|
}
|
|
539
|
-
_addRule(unitId, subUnitId, rule
|
|
533
|
+
_addRule(unitId, subUnitId, rule) {
|
|
540
534
|
(Array.isArray(rule) ? rule : [rule]).forEach((item) => {
|
|
541
535
|
this._addRuleSideEffect(unitId, subUnitId, item);
|
|
542
536
|
});
|
|
543
537
|
}
|
|
544
538
|
_updateRule(unitId, subUnitId, ruleId, oldRule, payload) {
|
|
545
539
|
const ruleMatrix = this._ensureRuleMatrix(unitId, subUnitId);
|
|
546
|
-
payload.type === UpdateRuleType.RANGE ? (ruleMatrix.updateRange(ruleId,
|
|
540
|
+
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));
|
|
547
541
|
}
|
|
548
542
|
_removeRule(unitId, subUnitId, oldRule) {
|
|
549
543
|
this._ensureRuleMatrix(unitId, subUnitId).removeRule(oldRule), this._dataValidationCacheService.removeRule(unitId, subUnitId, oldRule);
|
|
@@ -1405,6 +1399,11 @@ const transformCheckboxValue = /* @__PURE__ */ __name((value) => Tools.isDefine(
|
|
|
1405
1399
|
originFormula2
|
|
1406
1400
|
};
|
|
1407
1401
|
}
|
|
1402
|
+
getExtraStyle(rule, value) {
|
|
1403
|
+
return {
|
|
1404
|
+
tb: WrapStrategy.CLIP
|
|
1405
|
+
};
|
|
1406
|
+
}
|
|
1408
1407
|
parseFormulaSync(rule, unitId, subUnitId) {
|
|
1409
1408
|
var _a23, _b;
|
|
1410
1409
|
const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = this._formulaService.getRuleFormulaResultSync(unitId, subUnitId, rule.uid), originFormula1 = isFormulaString(formula1) ? getFormulaResult((_a23 = results == null ? void 0 : results[0]) == null ? void 0 : _a23.result) : formula1, originFormula2 = isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2;
|
|
@@ -2114,11 +2113,12 @@ function ListDropDown(props) {
|
|
|
2114
2113
|
const anchorRect = RectPopup.useContext(), cellWidth = anchorRect.right - anchorRect.left;
|
|
2115
2114
|
if (useEffect(() => {
|
|
2116
2115
|
const dispose = commandService.onCommandExecuted((command) => {
|
|
2116
|
+
var _a24, _b2;
|
|
2117
2117
|
if (command.id === RichTextEditingMutation.id) {
|
|
2118
2118
|
const params = command.params, { unitId: unitId2 } = params, unit = instanceService.getUnit(unitId2, UniverInstanceType.UNIVER_DOC);
|
|
2119
2119
|
if (!unit)
|
|
2120
2120
|
return;
|
|
2121
|
-
const text =
|
|
2121
|
+
const text = BuildTextUtils.transform.getPlainText((_b2 = (_a24 = unit.getSnapshot().body) == null ? void 0 : _a24.dataStream) != null ? _b2 : "");
|
|
2122
2122
|
setEditingText(text);
|
|
2123
2123
|
}
|
|
2124
2124
|
});
|
|
@@ -2160,10 +2160,7 @@ function ListDropDown(props) {
|
|
|
2160
2160
|
v: str,
|
|
2161
2161
|
p: null,
|
|
2162
2162
|
f: null,
|
|
2163
|
-
si: null
|
|
2164
|
-
custom: {
|
|
2165
|
-
__link_url: ""
|
|
2166
|
-
}
|
|
2163
|
+
si: null
|
|
2167
2164
|
}
|
|
2168
2165
|
};
|
|
2169
2166
|
editorBridgeService.isVisible() && editorBridgeService.changeVisible({
|
|
@@ -2607,6 +2604,18 @@ const FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2Serial
|
|
|
2607
2604
|
};
|
|
2608
2605
|
__name(_DateValidator, "DateValidator");
|
|
2609
2606
|
let DateValidator = _DateValidator;
|
|
2607
|
+
const LIST_RENDER_MODE_OPTION_INPUT = "LIST_RENDER_MODE_OPTION_INPUT";
|
|
2608
|
+
function ListRenderModeInput(props) {
|
|
2609
|
+
var _a23;
|
|
2610
|
+
const { value, onChange } = props, localeService = useDependency(LocaleService);
|
|
2611
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("dataValidation.renderMode.label"), children: /* @__PURE__ */ jsxRuntimeExports.jsxs(RadioGroup, { value: `${(_a23 = value.renderMode) != null ? _a23 : DataValidationRenderMode.CUSTOM}`, onChange: /* @__PURE__ */ __name((renderMode) => onChange({ ...value, renderMode: +renderMode }), "onChange"), children: [
|
|
2612
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.CUSTOM}`, children: localeService.t("dataValidation.renderMode.chip") }),
|
|
2613
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.ARROW}`, children: localeService.t("dataValidation.renderMode.arrow") }),
|
|
2614
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.TEXT}`, children: localeService.t("dataValidation.renderMode.text") })
|
|
2615
|
+
] }) });
|
|
2616
|
+
}
|
|
2617
|
+
__name(ListRenderModeInput, "ListRenderModeInput");
|
|
2618
|
+
ListRenderModeInput.componentKey = LIST_RENDER_MODE_OPTION_INPUT;
|
|
2610
2619
|
var __defProp$c = Object.defineProperty, __getOwnPropDesc$c = Object.getOwnPropertyDescriptor, __decorateClass$c = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2611
2620
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2612
2621
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -2835,18 +2844,6 @@ DropdownWidget = __decorateClass$c([
|
|
|
2835
2844
|
__decorateParam$c(0, Inject(LocaleService)),
|
|
2836
2845
|
__decorateParam$c(1, ICommandService)
|
|
2837
2846
|
], DropdownWidget);
|
|
2838
|
-
const LIST_RENDER_MODE_OPTION_INPUT = "LIST_RENDER_MODE_OPTION_INPUT";
|
|
2839
|
-
function ListRenderModeInput(props) {
|
|
2840
|
-
var _a23;
|
|
2841
|
-
const { value, onChange } = props, localeService = useDependency(LocaleService);
|
|
2842
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("dataValidation.renderMode.label"), children: /* @__PURE__ */ jsxRuntimeExports.jsxs(RadioGroup, { value: `${(_a23 = value.renderMode) != null ? _a23 : DataValidationRenderMode.CUSTOM}`, onChange: /* @__PURE__ */ __name((renderMode) => onChange({ ...value, renderMode: +renderMode }), "onChange"), children: [
|
|
2843
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.CUSTOM}`, children: localeService.t("dataValidation.renderMode.chip") }),
|
|
2844
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.ARROW}`, children: localeService.t("dataValidation.renderMode.arrow") }),
|
|
2845
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.TEXT}`, children: localeService.t("dataValidation.renderMode.text") })
|
|
2846
|
-
] }) });
|
|
2847
|
-
}
|
|
2848
|
-
__name(ListRenderModeInput, "ListRenderModeInput");
|
|
2849
|
-
ListRenderModeInput.componentKey = LIST_RENDER_MODE_OPTION_INPUT;
|
|
2850
2847
|
function getRuleFormulaResultSet(result) {
|
|
2851
2848
|
if (!result)
|
|
2852
2849
|
return [];
|
|
@@ -2858,7 +2855,7 @@ function getRuleFormulaResultSet(result) {
|
|
|
2858
2855
|
const value = getCellValueOrigin(cell);
|
|
2859
2856
|
if (value != null) {
|
|
2860
2857
|
if (typeof value != "string" && typeof (cell == null ? void 0 : cell.s) == "object" && ((_b = (_a23 = cell.s) == null ? void 0 : _a23.n) != null && _b.pattern)) {
|
|
2861
|
-
resultSet.add(numfmt.format(cell.s.n.pattern, value));
|
|
2858
|
+
resultSet.add(numfmt.format(cell.s.n.pattern, value, { throws: !1 }));
|
|
2862
2859
|
return;
|
|
2863
2860
|
}
|
|
2864
2861
|
resultSet.add(value.toString());
|
|
@@ -2917,6 +2914,23 @@ const _ListValidator = class _ListValidator extends BaseDataValidator {
|
|
|
2917
2914
|
formula1: success ? valid ? isIntersects ? this.localeService.t("dataValidation.validFail.listIntersects") : void 0 : this.localeService.t("dataValidation.validFail.listInvalid") : this.localeService.t("dataValidation.validFail.list")
|
|
2918
2915
|
};
|
|
2919
2916
|
}
|
|
2917
|
+
getExtraStyle(rule, value, { style: defaultStyle }) {
|
|
2918
|
+
var _a23;
|
|
2919
|
+
const tb = (_a23 = defaultStyle.tb !== WrapStrategy.OVERFLOW ? defaultStyle.tb : WrapStrategy.CLIP) != null ? _a23 : WrapStrategy.WRAP;
|
|
2920
|
+
if (rule.type === DataValidationType.LIST && (rule.renderMode === DataValidationRenderMode.ARROW || rule.renderMode === DataValidationRenderMode.TEXT)) {
|
|
2921
|
+
const colorMap = this.getListWithColorMap(rule), valueStr = `${value != null ? value : ""}`, color = colorMap[valueStr];
|
|
2922
|
+
if (color)
|
|
2923
|
+
return {
|
|
2924
|
+
bg: {
|
|
2925
|
+
rgb: color
|
|
2926
|
+
},
|
|
2927
|
+
tb
|
|
2928
|
+
};
|
|
2929
|
+
}
|
|
2930
|
+
return {
|
|
2931
|
+
tb
|
|
2932
|
+
};
|
|
2933
|
+
}
|
|
2920
2934
|
parseCellValue(cellValue) {
|
|
2921
2935
|
const cellString = cellValue.toString();
|
|
2922
2936
|
return deserializeListOptions(cellString);
|
|
@@ -3311,11 +3325,11 @@ const UpdateSheetDataValidationRangeCommand = {
|
|
|
3311
3325
|
async handler(accessor, params) {
|
|
3312
3326
|
if (!params)
|
|
3313
3327
|
return !1;
|
|
3314
|
-
const { unitId, subUnitId, ranges, ruleId } = params, sheetDataValidationModel = accessor.get(SheetDataValidationModel), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService)
|
|
3315
|
-
if (!
|
|
3328
|
+
const { unitId, subUnitId, ranges, ruleId } = params, sheetDataValidationModel = accessor.get(SheetDataValidationModel), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService);
|
|
3329
|
+
if (!sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId))
|
|
3316
3330
|
return !1;
|
|
3317
|
-
const
|
|
3318
|
-
matrix.updateRange(ruleId,
|
|
3331
|
+
const matrix = sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone();
|
|
3332
|
+
matrix.updateRange(ruleId, ranges);
|
|
3319
3333
|
const diffs = matrix.diff(sheetDataValidationModel.getRules(unitId, subUnitId)), { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor);
|
|
3320
3334
|
return undoRedoService.pushUndoRedo({
|
|
3321
3335
|
undoMutations,
|
|
@@ -4129,7 +4143,7 @@ let DataValidationCopyPasteController = (_a13 = class extends Disposable {
|
|
|
4129
4143
|
return { redos: [], undos: [] };
|
|
4130
4144
|
const { unitId, subUnitId } = this._copyInfo;
|
|
4131
4145
|
if (copyInfo.unitId !== unitId || subUnitId !== copyInfo.subUnitId) {
|
|
4132
|
-
const ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(copyInfo.unitId, copyInfo.subUnitId).clone(), { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyInfo.copyRange, pastedRange]), repeatRange = getRepeatRange(vCopyRange, vPastedRange, !0), additionRules = /* @__PURE__ */ new Map();
|
|
4146
|
+
const ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(copyInfo.unitId, copyInfo.subUnitId).clone(), additionMatrix = new ObjectMatrix(), addRules = /* @__PURE__ */ new Set(), { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyInfo.copyRange, pastedRange]), repeatRange = getRepeatRange(vCopyRange, vPastedRange, !0), additionRules = /* @__PURE__ */ new Map();
|
|
4133
4147
|
repeatRange.forEach(({ startRange }) => {
|
|
4134
4148
|
var _a23;
|
|
4135
4149
|
(_a23 = this._copyInfo) == null || _a23.matrix.forValue((row, col, ruleId) => {
|
|
@@ -4144,9 +4158,11 @@ let DataValidationCopyPasteController = (_a13 = class extends Disposable {
|
|
|
4144
4158
|
), transformedRuleId = `${subUnitId}-${ruleId}`, oldRule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
|
|
4145
4159
|
!this._sheetDataValidationModel.getRuleById(copyInfo.unitId, copyInfo.subUnitId, transformedRuleId) && oldRule && additionRules.set(transformedRuleId, { ...oldRule, uid: transformedRuleId });
|
|
4146
4160
|
const { row: startRow, col: startColumn } = mapFunc(range.startRow, range.startColumn);
|
|
4147
|
-
|
|
4161
|
+
addRules.add(transformedRuleId), additionMatrix.setValue(startRow, startColumn, transformedRuleId);
|
|
4148
4162
|
});
|
|
4149
4163
|
});
|
|
4164
|
+
const additions = Array.from(addRules).map((id) => ({ id, ranges: queryObjectMatrix(additionMatrix, (value) => value === id) }));
|
|
4165
|
+
ruleMatrix.addRangeRules(additions);
|
|
4150
4166
|
const { redoMutations, undoMutations } = getDataValidationDiffMutations(
|
|
4151
4167
|
copyInfo.unitId,
|
|
4152
4168
|
copyInfo.subUnitId,
|
|
@@ -4159,7 +4175,7 @@ let DataValidationCopyPasteController = (_a13 = class extends Disposable {
|
|
|
4159
4175
|
undos: undoMutations
|
|
4160
4176
|
};
|
|
4161
4177
|
} else {
|
|
4162
|
-
const ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone(), { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyInfo.copyRange, pastedRange]);
|
|
4178
|
+
const ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone(), additionMatrix = new ObjectMatrix(), additionRules = /* @__PURE__ */ new Set(), { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyInfo.copyRange, pastedRange]);
|
|
4163
4179
|
getRepeatRange(vCopyRange, vPastedRange, !0).forEach(({ startRange }) => {
|
|
4164
4180
|
var _a23;
|
|
4165
4181
|
(_a23 = this._copyInfo) == null || _a23.matrix.forValue((row, col, ruleId) => {
|
|
@@ -4172,9 +4188,11 @@ let DataValidationCopyPasteController = (_a13 = class extends Disposable {
|
|
|
4172
4188
|
},
|
|
4173
4189
|
startRange
|
|
4174
4190
|
), { row: startRow, col: startColumn } = mapFunc(range.startRow, range.startColumn);
|
|
4175
|
-
|
|
4191
|
+
additionMatrix.setValue(startRow, startColumn, ruleId), additionRules.add(ruleId);
|
|
4176
4192
|
});
|
|
4177
4193
|
});
|
|
4194
|
+
const additions = Array.from(additionRules).map((id) => ({ id, ranges: queryObjectMatrix(additionMatrix, (value) => value === id) }));
|
|
4195
|
+
ruleMatrix.addRangeRules(additions);
|
|
4178
4196
|
const { redoMutations, undoMutations } = getDataValidationDiffMutations(
|
|
4179
4197
|
unitId,
|
|
4180
4198
|
subUnitId,
|
|
@@ -4395,7 +4413,7 @@ let DataValidationRefRangeController = (_a15 = class extends Disposable {
|
|
|
4395
4413
|
}, __name(_a15, "DataValidationRefRangeController"), _a15);
|
|
4396
4414
|
DataValidationRefRangeController = __decorateClass$6([
|
|
4397
4415
|
OnLifecycle(LifecycleStages.Starting, DataValidationRefRangeController),
|
|
4398
|
-
__decorateParam$6(0, Inject(
|
|
4416
|
+
__decorateParam$6(0, Inject(SheetDataValidationModel)),
|
|
4399
4417
|
__decorateParam$6(1, Inject(Injector)),
|
|
4400
4418
|
__decorateParam$6(2, Inject(RefRangeService)),
|
|
4401
4419
|
__decorateParam$6(3, Inject(DataValidationCustomFormulaService)),
|
|
@@ -4500,45 +4518,18 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
|
|
|
4500
4518
|
{
|
|
4501
4519
|
// must be after numfmt
|
|
4502
4520
|
priority: InterceptCellContentPriority.DATA_VALIDATION,
|
|
4503
|
-
// eslint-disable-next-line
|
|
4521
|
+
// eslint-disable-next-line complexity
|
|
4504
4522
|
handler: /* @__PURE__ */ __name((cell, pos, next) => {
|
|
4505
|
-
var _a23, _b, _c, _d
|
|
4506
|
-
const { row, col, unitId, subUnitId, workbook, worksheet } = pos,
|
|
4507
|
-
if (!skeleton)
|
|
4508
|
-
return next(cell);
|
|
4509
|
-
const styleMap = pos.workbook.getStyles(), defaultStyle = (typeof (cell == null ? void 0 : cell.s) == "string" ? styleMap.get(cell == null ? void 0 : cell.s) : cell == null ? void 0 : cell.s) || {}, ruleId = this._sheetDataValidationModel.getRuleIdByLocation(unitId, subUnitId, row, col);
|
|
4523
|
+
var _a23, _b, _c, _d;
|
|
4524
|
+
const { row, col, unitId, subUnitId, workbook, worksheet } = pos, styleMap = workbook.getStyles(), defaultStyle = (typeof (cell == null ? void 0 : cell.s) == "string" ? styleMap.get(cell == null ? void 0 : cell.s) : cell == null ? void 0 : cell.s) || {}, ruleId = this._sheetDataValidationModel.getRuleIdByLocation(unitId, subUnitId, row, col);
|
|
4510
4525
|
if (!ruleId)
|
|
4511
4526
|
return next(cell);
|
|
4512
4527
|
const rule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
|
|
4513
4528
|
if (!rule)
|
|
4514
4529
|
return next(cell);
|
|
4515
|
-
const validStatus = this._sheetDataValidationModel.validator(cell, rule, pos), validator = this._dataValidatorRegistryService.getValidatorItem(rule.type), cellOrigin = worksheet.getCellRaw(row, col), cellValue = getCellValueOrigin(cellOrigin)
|
|
4516
|
-
let extra = {};
|
|
4517
|
-
if ((rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE) && (extra = {
|
|
4518
|
-
interceptorStyle: {
|
|
4519
|
-
...cell == null ? void 0 : cell.interceptorStyle,
|
|
4520
|
-
tb: (_c = defaultStyle.tb !== WrapStrategy.OVERFLOW ? defaultStyle.tb : WrapStrategy.CLIP) != null ? _c : WrapStrategy.WRAP
|
|
4521
|
-
}
|
|
4522
|
-
}), rule.type === DataValidationType.CHECKBOX && (extra = {
|
|
4523
|
-
interceptorStyle: {
|
|
4524
|
-
...cell == null ? void 0 : cell.interceptorStyle,
|
|
4525
|
-
tb: WrapStrategy.CLIP
|
|
4526
|
-
}
|
|
4527
|
-
}), rule.type === DataValidationType.LIST && (rule.renderMode === DataValidationRenderMode.ARROW || rule.renderMode === DataValidationRenderMode.TEXT)) {
|
|
4528
|
-
const colorMap = validator.getListWithColorMap(rule), valueStr = `${(_d = getCellValueOrigin(cellOrigin)) != null ? _d : ""}`, color = colorMap[valueStr];
|
|
4529
|
-
color && (extra = {
|
|
4530
|
-
...extra,
|
|
4531
|
-
interceptorStyle: {
|
|
4532
|
-
...extra.interceptorStyle,
|
|
4533
|
-
bg: {
|
|
4534
|
-
rgb: color
|
|
4535
|
-
}
|
|
4536
|
-
}
|
|
4537
|
-
});
|
|
4538
|
-
}
|
|
4530
|
+
const validStatus = this._sheetDataValidationModel.validator(cell, rule, pos), validator = this._dataValidatorRegistryService.getValidatorItem(rule.type), cellOrigin = worksheet.getCellRaw(row, col), cellValue = getCellValueOrigin(cellOrigin), valueStr = `${(_a23 = getCellValueOrigin(cellOrigin)) != null ? _a23 : ""}`;
|
|
4539
4531
|
return next({
|
|
4540
4532
|
...cell,
|
|
4541
|
-
...extra,
|
|
4542
4533
|
dataValidation: {
|
|
4543
4534
|
ruleId,
|
|
4544
4535
|
validStatus,
|
|
@@ -4550,23 +4541,23 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
|
|
|
4550
4541
|
...validStatus === DataValidationStatus.INVALID ? INVALID_MARK : null
|
|
4551
4542
|
},
|
|
4552
4543
|
customRender: [
|
|
4553
|
-
...(
|
|
4544
|
+
...(_b = cell == null ? void 0 : cell.customRender) != null ? _b : [],
|
|
4554
4545
|
...validator != null && validator.canvasRender ? [validator.canvasRender] : []
|
|
4555
4546
|
],
|
|
4556
4547
|
fontRenderExtension: {
|
|
4557
4548
|
...cell == null ? void 0 : cell.fontRenderExtension,
|
|
4558
|
-
isSkip: ((
|
|
4549
|
+
isSkip: ((_c = cell == null ? void 0 : cell.fontRenderExtension) == null ? void 0 : _c.isSkip) || (validator == null ? void 0 : validator.skipDefaultFontRender(rule, cellValue, pos))
|
|
4559
4550
|
},
|
|
4560
4551
|
interceptorStyle: {
|
|
4561
4552
|
...cell == null ? void 0 : cell.interceptorStyle,
|
|
4562
|
-
...
|
|
4553
|
+
...validator == null ? void 0 : validator.getExtraStyle(rule, valueStr, { style: defaultStyle })
|
|
4563
4554
|
},
|
|
4564
4555
|
interceptorAutoHeight: /* @__PURE__ */ __name(() => {
|
|
4565
|
-
var _a24, _b2, _c2, _d2;
|
|
4566
|
-
const
|
|
4567
|
-
|
|
4568
|
-
return
|
|
4569
|
-
|
|
4556
|
+
var _a24, _b2, _c2, _d2, _e, _f;
|
|
4557
|
+
const skeleton = (_b2 = (_a24 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a24.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId)) == null ? void 0 : _b2.skeleton;
|
|
4558
|
+
if (!skeleton)
|
|
4559
|
+
return;
|
|
4560
|
+
const mergeCell = skeleton.worksheet.getMergedCell(row, col), info = {
|
|
4570
4561
|
data: {
|
|
4571
4562
|
...cell,
|
|
4572
4563
|
dataValidation: {
|
|
@@ -4577,7 +4568,7 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
|
|
|
4577
4568
|
}
|
|
4578
4569
|
},
|
|
4579
4570
|
style: skeleton.getsStyles().getStyleByCell(cell),
|
|
4580
|
-
primaryWithCoord: skeleton.getCellByIndex((
|
|
4571
|
+
primaryWithCoord: skeleton.getCellByIndex((_c2 = mergeCell == null ? void 0 : mergeCell.startRow) != null ? _c2 : row, (_d2 = mergeCell == null ? void 0 : mergeCell.startColumn) != null ? _d2 : col),
|
|
4581
4572
|
unitId,
|
|
4582
4573
|
subUnitId,
|
|
4583
4574
|
row,
|
|
@@ -4585,9 +4576,9 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
|
|
|
4585
4576
|
workbook,
|
|
4586
4577
|
worksheet
|
|
4587
4578
|
};
|
|
4588
|
-
return (
|
|
4579
|
+
return (_f = (_e = validator == null ? void 0 : validator.canvasRender) == null ? void 0 : _e.calcCellAutoHeight) == null ? void 0 : _f.call(_e, info);
|
|
4589
4580
|
}, "interceptorAutoHeight"),
|
|
4590
|
-
coverable: ((
|
|
4581
|
+
coverable: ((_d = cell == null ? void 0 : cell.coverable) != null ? _d : !0) && !(rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE)
|
|
4591
4582
|
});
|
|
4592
4583
|
}, "handler")
|
|
4593
4584
|
}
|
|
@@ -4714,10 +4705,7 @@ let SheetsDataValidationMobileRenderController = (_a17 = class extends RxDisposa
|
|
|
4714
4705
|
},
|
|
4715
4706
|
interceptorAutoHeight: /* @__PURE__ */ __name(() => {
|
|
4716
4707
|
var _a24, _b2, _c2, _d2;
|
|
4717
|
-
const mergeCell = skeleton.
|
|
4718
|
-
const { startColumn, startRow, endColumn, endRow } = range;
|
|
4719
|
-
return row >= startRow && col >= startColumn && row <= endRow && col <= endColumn;
|
|
4720
|
-
}), info = {
|
|
4708
|
+
const mergeCell = skeleton.worksheet.getMergedCell(row, col), info = {
|
|
4721
4709
|
data: {
|
|
4722
4710
|
...cell,
|
|
4723
4711
|
dataValidation: {
|
|
@@ -4907,8 +4895,8 @@ let DataValidationAutoFillController = (_a20 = class extends Disposable {
|
|
|
4907
4895
|
const { source: sourceRange, target: targetRange, unitId, subUnitId } = location, ruleMatrixCopy = this._dataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone(), virtualRange = virtualizeDiscreteRanges([sourceRange, targetRange]), [vSourceRange, vTargetRange] = virtualRange.ranges, { mapFunc } = virtualRange, sourceStartCell = {
|
|
4908
4896
|
row: vSourceRange.startRow,
|
|
4909
4897
|
col: vSourceRange.startColumn
|
|
4910
|
-
};
|
|
4911
|
-
|
|
4898
|
+
}, repeats = getAutoFillRepeatRange(vSourceRange, vTargetRange), additionMatrix = new ObjectMatrix(), additionRules = /* @__PURE__ */ new Set();
|
|
4899
|
+
repeats.forEach((repeat) => {
|
|
4912
4900
|
const targetStartCell = repeat.repeatStartCell, relativeRange = repeat.relativeRange, sourceRange2 = {
|
|
4913
4901
|
startRow: sourceStartCell.row,
|
|
4914
4902
|
startColumn: sourceStartCell.col,
|
|
@@ -4940,10 +4928,12 @@ let DataValidationAutoFillController = (_a20 = class extends Disposable {
|
|
|
4940
4928
|
},
|
|
4941
4929
|
targetRange2
|
|
4942
4930
|
), { row: targetRow, col: targetCol } = mapFunc(targetPositionRange.startRow, targetPositionRange.startColumn);
|
|
4943
|
-
|
|
4931
|
+
additionMatrix.setValue(targetRow, targetCol, ruleId), additionRules.add(ruleId);
|
|
4944
4932
|
}
|
|
4945
4933
|
});
|
|
4946
4934
|
});
|
|
4935
|
+
const additions = Array.from(additionRules).map((id) => ({ id, ranges: queryObjectMatrix(additionMatrix, (value) => value === id) }));
|
|
4936
|
+
ruleMatrixCopy.addRangeRules(additions);
|
|
4947
4937
|
const diffs = ruleMatrixCopy.diff(this._dataValidationModel.getRules(unitId, subUnitId)), { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, this._injector, "patched", applyType === APPLY_TYPE.ONLY_FORMAT);
|
|
4948
4938
|
return {
|
|
4949
4939
|
undos: undoMutations,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Disposable, Injector, ISheetDataValidationRule } from '@univerjs/core';
|
|
2
|
-
import { DataValidationModel } from '@univerjs/data-validation';
|
|
3
2
|
import { RefRangeService } from '@univerjs/sheets';
|
|
4
3
|
import { FormulaRefRangeService } from '@univerjs/sheets-formula';
|
|
4
|
+
import { SheetDataValidationModel } from '../models/sheet-data-validation-model';
|
|
5
5
|
import { DataValidationCustomFormulaService } from '../services/dv-custom-formula.service';
|
|
6
6
|
import { DataValidationFormulaService } from '../services/dv-formula.service';
|
|
7
7
|
export declare class DataValidationRefRangeController extends Disposable {
|
|
@@ -12,7 +12,7 @@ export declare class DataValidationRefRangeController extends Disposable {
|
|
|
12
12
|
private _dataValidationFormulaService;
|
|
13
13
|
private _formulaRefRangeService;
|
|
14
14
|
private _disposableMap;
|
|
15
|
-
constructor(_dataValidationModel:
|
|
15
|
+
constructor(_dataValidationModel: SheetDataValidationModel, _injector: Injector, _refRangeService: RefRangeService, _dataValidationCustomFormulaService: DataValidationCustomFormulaService, _dataValidationFormulaService: DataValidationFormulaService, _formulaRefRangeService: FormulaRefRangeService);
|
|
16
16
|
private _getIdWithUnitId;
|
|
17
17
|
registerRule: (unitId: string, subUnitId: string, rule: ISheetDataValidationRule) => void;
|
|
18
18
|
registerFormula(unitId: string, subUnitId: string, rule: ISheetDataValidationRule): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IRange, ISheetDataValidationRule, Worksheet
|
|
1
|
+
import { IRange, ISheetDataValidationRule, Worksheet } from '@univerjs/core';
|
|
2
2
|
export type RangeMutation = {
|
|
3
3
|
type: 'update';
|
|
4
4
|
ruleId: string;
|
|
@@ -14,15 +14,18 @@ export type RangeMutation = {
|
|
|
14
14
|
};
|
|
15
15
|
export declare class RuleMatrix {
|
|
16
16
|
private _worksheet;
|
|
17
|
-
|
|
18
|
-
constructor(value:
|
|
17
|
+
private _map;
|
|
18
|
+
constructor(value: Map<string, IRange[]>, _worksheet: Worksheet);
|
|
19
19
|
addRule(rule: ISheetDataValidationRule): void;
|
|
20
|
-
removeRange(
|
|
20
|
+
removeRange(_ranges: IRange[]): void;
|
|
21
21
|
removeRule(rule: ISheetDataValidationRule): void;
|
|
22
|
-
updateRange(ruleId: string,
|
|
22
|
+
updateRange(ruleId: string, _newRanges: IRange[]): void;
|
|
23
23
|
diff(rules: ISheetDataValidationRule[]): RangeMutation[];
|
|
24
24
|
diffWithAddition(rules: ISheetDataValidationRule[], additionRules: IterableIterator<ISheetDataValidationRule>): RangeMutation[];
|
|
25
25
|
clone(): RuleMatrix;
|
|
26
|
-
getValue(row: number, col: number): string;
|
|
27
|
-
|
|
26
|
+
getValue(row: number, col: number): string | undefined;
|
|
27
|
+
addRangeRules(rules: {
|
|
28
|
+
id: string;
|
|
29
|
+
ranges: IRange[];
|
|
30
|
+
}[]): void;
|
|
28
31
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { WrapStrategy, CellValue, DataValidationOperator, IDataValidationRule, IDataValidationRuleBase, ISheetDataValidationRule, Nullable } from '@univerjs/core';
|
|
1
2
|
import { BaseDataValidator, IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
|
|
2
|
-
import { CellValue, DataValidationOperator, IDataValidationRule, IDataValidationRuleBase, ISheetDataValidationRule, Nullable } from '@univerjs/core';
|
|
3
3
|
import { CheckboxRender } from '../widgets/checkbox-widget';
|
|
4
4
|
export declare const CHECKBOX_FORMULA_1 = 1;
|
|
5
5
|
export declare const CHECKBOX_FORMULA_2 = 0;
|
|
@@ -22,6 +22,9 @@ export declare class CheckboxValidator extends BaseDataValidator {
|
|
|
22
22
|
}): boolean;
|
|
23
23
|
validatorFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): IFormulaValidResult;
|
|
24
24
|
parseFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): Promise<ICheckboxFormulaResult>;
|
|
25
|
+
getExtraStyle(rule: IDataValidationRule, value: Nullable<CellValue>): {
|
|
26
|
+
tb: WrapStrategy;
|
|
27
|
+
};
|
|
25
28
|
parseFormulaSync(rule: IDataValidationRule, unitId: string, subUnitId: string): {
|
|
26
29
|
formula1: Nullable<CellValue>;
|
|
27
30
|
formula2: Nullable<CellValue>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IBaseDataValidationWidget, IFormulaResult, IFormulaValidResult, IValidatorCellInfo, BaseDataValidator } from '@univerjs/data-validation';
|
|
1
|
+
import { BaseDataValidator, IBaseDataValidationWidget, IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
|
|
3
2
|
import { LexerTreeBuilder } from '@univerjs/engine-formula';
|
|
3
|
+
import { CellValue, DataValidationOperator, ICellData, IDataValidationRule, ISheetDataValidationRule, IStyleData, Nullable } from '@univerjs/core';
|
|
4
4
|
import { DataValidationFormulaService } from '../services/dv-formula.service';
|
|
5
5
|
export declare function getRuleFormulaResultSet(result: Nullable<Nullable<ICellData>[][]>): string[];
|
|
6
6
|
export declare function isValidListFormula(formula: string, lexer: LexerTreeBuilder): boolean | undefined;
|
|
@@ -18,6 +18,9 @@ export declare class ListValidator extends BaseDataValidator {
|
|
|
18
18
|
optionsInput: string | undefined;
|
|
19
19
|
skipDefaultFontRender(rule: ISheetDataValidationRule): boolean;
|
|
20
20
|
validatorFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): IFormulaValidResult;
|
|
21
|
+
getExtraStyle(rule: IDataValidationRule, value: Nullable<CellValue>, { style: defaultStyle }: {
|
|
22
|
+
style: IStyleData;
|
|
23
|
+
}): Nullable<IStyleData>;
|
|
21
24
|
parseCellValue(cellValue: CellValue): string[];
|
|
22
25
|
parseFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): Promise<IFormulaResult<string[] | undefined>>;
|
|
23
26
|
isValidType(cellInfo: IValidatorCellInfo<Nullable<CellValue>>, formula: IFormulaResult<string[] | undefined>, rule: IDataValidationRule): Promise<boolean>;
|