@univerjs/sheets-data-validation 0.2.14 → 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 +128 -135
- 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
|
});
|
|
@@ -2604,6 +2604,18 @@ const FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2Serial
|
|
|
2604
2604
|
};
|
|
2605
2605
|
__name(_DateValidator, "DateValidator");
|
|
2606
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;
|
|
2607
2619
|
var __defProp$c = Object.defineProperty, __getOwnPropDesc$c = Object.getOwnPropertyDescriptor, __decorateClass$c = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2608
2620
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2609
2621
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -2832,18 +2844,6 @@ DropdownWidget = __decorateClass$c([
|
|
|
2832
2844
|
__decorateParam$c(0, Inject(LocaleService)),
|
|
2833
2845
|
__decorateParam$c(1, ICommandService)
|
|
2834
2846
|
], DropdownWidget);
|
|
2835
|
-
const LIST_RENDER_MODE_OPTION_INPUT = "LIST_RENDER_MODE_OPTION_INPUT";
|
|
2836
|
-
function ListRenderModeInput(props) {
|
|
2837
|
-
var _a23;
|
|
2838
|
-
const { value, onChange } = props, localeService = useDependency(LocaleService);
|
|
2839
|
-
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: [
|
|
2840
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.CUSTOM}`, children: localeService.t("dataValidation.renderMode.chip") }),
|
|
2841
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.ARROW}`, children: localeService.t("dataValidation.renderMode.arrow") }),
|
|
2842
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.TEXT}`, children: localeService.t("dataValidation.renderMode.text") })
|
|
2843
|
-
] }) });
|
|
2844
|
-
}
|
|
2845
|
-
__name(ListRenderModeInput, "ListRenderModeInput");
|
|
2846
|
-
ListRenderModeInput.componentKey = LIST_RENDER_MODE_OPTION_INPUT;
|
|
2847
2847
|
function getRuleFormulaResultSet(result) {
|
|
2848
2848
|
if (!result)
|
|
2849
2849
|
return [];
|
|
@@ -2855,7 +2855,7 @@ function getRuleFormulaResultSet(result) {
|
|
|
2855
2855
|
const value = getCellValueOrigin(cell);
|
|
2856
2856
|
if (value != null) {
|
|
2857
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)) {
|
|
2858
|
-
resultSet.add(numfmt.format(cell.s.n.pattern, value));
|
|
2858
|
+
resultSet.add(numfmt.format(cell.s.n.pattern, value, { throws: !1 }));
|
|
2859
2859
|
return;
|
|
2860
2860
|
}
|
|
2861
2861
|
resultSet.add(value.toString());
|
|
@@ -2914,6 +2914,23 @@ const _ListValidator = class _ListValidator extends BaseDataValidator {
|
|
|
2914
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")
|
|
2915
2915
|
};
|
|
2916
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
|
+
}
|
|
2917
2934
|
parseCellValue(cellValue) {
|
|
2918
2935
|
const cellString = cellValue.toString();
|
|
2919
2936
|
return deserializeListOptions(cellString);
|
|
@@ -3308,11 +3325,11 @@ const UpdateSheetDataValidationRangeCommand = {
|
|
|
3308
3325
|
async handler(accessor, params) {
|
|
3309
3326
|
if (!params)
|
|
3310
3327
|
return !1;
|
|
3311
|
-
const { unitId, subUnitId, ranges, ruleId } = params, sheetDataValidationModel = accessor.get(SheetDataValidationModel), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService)
|
|
3312
|
-
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))
|
|
3313
3330
|
return !1;
|
|
3314
|
-
const
|
|
3315
|
-
matrix.updateRange(ruleId,
|
|
3331
|
+
const matrix = sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone();
|
|
3332
|
+
matrix.updateRange(ruleId, ranges);
|
|
3316
3333
|
const diffs = matrix.diff(sheetDataValidationModel.getRules(unitId, subUnitId)), { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor);
|
|
3317
3334
|
return undoRedoService.pushUndoRedo({
|
|
3318
3335
|
undoMutations,
|
|
@@ -4126,7 +4143,7 @@ let DataValidationCopyPasteController = (_a13 = class extends Disposable {
|
|
|
4126
4143
|
return { redos: [], undos: [] };
|
|
4127
4144
|
const { unitId, subUnitId } = this._copyInfo;
|
|
4128
4145
|
if (copyInfo.unitId !== unitId || subUnitId !== copyInfo.subUnitId) {
|
|
4129
|
-
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();
|
|
4130
4147
|
repeatRange.forEach(({ startRange }) => {
|
|
4131
4148
|
var _a23;
|
|
4132
4149
|
(_a23 = this._copyInfo) == null || _a23.matrix.forValue((row, col, ruleId) => {
|
|
@@ -4141,9 +4158,11 @@ let DataValidationCopyPasteController = (_a13 = class extends Disposable {
|
|
|
4141
4158
|
), transformedRuleId = `${subUnitId}-${ruleId}`, oldRule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
|
|
4142
4159
|
!this._sheetDataValidationModel.getRuleById(copyInfo.unitId, copyInfo.subUnitId, transformedRuleId) && oldRule && additionRules.set(transformedRuleId, { ...oldRule, uid: transformedRuleId });
|
|
4143
4160
|
const { row: startRow, col: startColumn } = mapFunc(range.startRow, range.startColumn);
|
|
4144
|
-
|
|
4161
|
+
addRules.add(transformedRuleId), additionMatrix.setValue(startRow, startColumn, transformedRuleId);
|
|
4145
4162
|
});
|
|
4146
4163
|
});
|
|
4164
|
+
const additions = Array.from(addRules).map((id) => ({ id, ranges: queryObjectMatrix(additionMatrix, (value) => value === id) }));
|
|
4165
|
+
ruleMatrix.addRangeRules(additions);
|
|
4147
4166
|
const { redoMutations, undoMutations } = getDataValidationDiffMutations(
|
|
4148
4167
|
copyInfo.unitId,
|
|
4149
4168
|
copyInfo.subUnitId,
|
|
@@ -4156,7 +4175,7 @@ let DataValidationCopyPasteController = (_a13 = class extends Disposable {
|
|
|
4156
4175
|
undos: undoMutations
|
|
4157
4176
|
};
|
|
4158
4177
|
} else {
|
|
4159
|
-
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]);
|
|
4160
4179
|
getRepeatRange(vCopyRange, vPastedRange, !0).forEach(({ startRange }) => {
|
|
4161
4180
|
var _a23;
|
|
4162
4181
|
(_a23 = this._copyInfo) == null || _a23.matrix.forValue((row, col, ruleId) => {
|
|
@@ -4169,9 +4188,11 @@ let DataValidationCopyPasteController = (_a13 = class extends Disposable {
|
|
|
4169
4188
|
},
|
|
4170
4189
|
startRange
|
|
4171
4190
|
), { row: startRow, col: startColumn } = mapFunc(range.startRow, range.startColumn);
|
|
4172
|
-
|
|
4191
|
+
additionMatrix.setValue(startRow, startColumn, ruleId), additionRules.add(ruleId);
|
|
4173
4192
|
});
|
|
4174
4193
|
});
|
|
4194
|
+
const additions = Array.from(additionRules).map((id) => ({ id, ranges: queryObjectMatrix(additionMatrix, (value) => value === id) }));
|
|
4195
|
+
ruleMatrix.addRangeRules(additions);
|
|
4175
4196
|
const { redoMutations, undoMutations } = getDataValidationDiffMutations(
|
|
4176
4197
|
unitId,
|
|
4177
4198
|
subUnitId,
|
|
@@ -4392,7 +4413,7 @@ let DataValidationRefRangeController = (_a15 = class extends Disposable {
|
|
|
4392
4413
|
}, __name(_a15, "DataValidationRefRangeController"), _a15);
|
|
4393
4414
|
DataValidationRefRangeController = __decorateClass$6([
|
|
4394
4415
|
OnLifecycle(LifecycleStages.Starting, DataValidationRefRangeController),
|
|
4395
|
-
__decorateParam$6(0, Inject(
|
|
4416
|
+
__decorateParam$6(0, Inject(SheetDataValidationModel)),
|
|
4396
4417
|
__decorateParam$6(1, Inject(Injector)),
|
|
4397
4418
|
__decorateParam$6(2, Inject(RefRangeService)),
|
|
4398
4419
|
__decorateParam$6(3, Inject(DataValidationCustomFormulaService)),
|
|
@@ -4497,45 +4518,18 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
|
|
|
4497
4518
|
{
|
|
4498
4519
|
// must be after numfmt
|
|
4499
4520
|
priority: InterceptCellContentPriority.DATA_VALIDATION,
|
|
4500
|
-
// eslint-disable-next-line
|
|
4521
|
+
// eslint-disable-next-line complexity
|
|
4501
4522
|
handler: /* @__PURE__ */ __name((cell, pos, next) => {
|
|
4502
|
-
var _a23, _b, _c, _d
|
|
4503
|
-
const { row, col, unitId, subUnitId, workbook, worksheet } = pos,
|
|
4504
|
-
if (!skeleton)
|
|
4505
|
-
return next(cell);
|
|
4506
|
-
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);
|
|
4507
4525
|
if (!ruleId)
|
|
4508
4526
|
return next(cell);
|
|
4509
4527
|
const rule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
|
|
4510
4528
|
if (!rule)
|
|
4511
4529
|
return next(cell);
|
|
4512
|
-
const validStatus = this._sheetDataValidationModel.validator(cell, rule, pos), validator = this._dataValidatorRegistryService.getValidatorItem(rule.type), cellOrigin = worksheet.getCellRaw(row, col), cellValue = getCellValueOrigin(cellOrigin)
|
|
4513
|
-
let extra = {};
|
|
4514
|
-
if ((rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE) && (extra = {
|
|
4515
|
-
interceptorStyle: {
|
|
4516
|
-
...cell == null ? void 0 : cell.interceptorStyle,
|
|
4517
|
-
tb: (_c = defaultStyle.tb !== WrapStrategy.OVERFLOW ? defaultStyle.tb : WrapStrategy.CLIP) != null ? _c : WrapStrategy.WRAP
|
|
4518
|
-
}
|
|
4519
|
-
}), rule.type === DataValidationType.CHECKBOX && (extra = {
|
|
4520
|
-
interceptorStyle: {
|
|
4521
|
-
...cell == null ? void 0 : cell.interceptorStyle,
|
|
4522
|
-
tb: WrapStrategy.CLIP
|
|
4523
|
-
}
|
|
4524
|
-
}), rule.type === DataValidationType.LIST && (rule.renderMode === DataValidationRenderMode.ARROW || rule.renderMode === DataValidationRenderMode.TEXT)) {
|
|
4525
|
-
const colorMap = validator.getListWithColorMap(rule), valueStr = `${(_d = getCellValueOrigin(cellOrigin)) != null ? _d : ""}`, color = colorMap[valueStr];
|
|
4526
|
-
color && (extra = {
|
|
4527
|
-
...extra,
|
|
4528
|
-
interceptorStyle: {
|
|
4529
|
-
...extra.interceptorStyle,
|
|
4530
|
-
bg: {
|
|
4531
|
-
rgb: color
|
|
4532
|
-
}
|
|
4533
|
-
}
|
|
4534
|
-
});
|
|
4535
|
-
}
|
|
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 : ""}`;
|
|
4536
4531
|
return next({
|
|
4537
4532
|
...cell,
|
|
4538
|
-
...extra,
|
|
4539
4533
|
dataValidation: {
|
|
4540
4534
|
ruleId,
|
|
4541
4535
|
validStatus,
|
|
@@ -4547,23 +4541,23 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
|
|
|
4547
4541
|
...validStatus === DataValidationStatus.INVALID ? INVALID_MARK : null
|
|
4548
4542
|
},
|
|
4549
4543
|
customRender: [
|
|
4550
|
-
...(
|
|
4544
|
+
...(_b = cell == null ? void 0 : cell.customRender) != null ? _b : [],
|
|
4551
4545
|
...validator != null && validator.canvasRender ? [validator.canvasRender] : []
|
|
4552
4546
|
],
|
|
4553
4547
|
fontRenderExtension: {
|
|
4554
4548
|
...cell == null ? void 0 : cell.fontRenderExtension,
|
|
4555
|
-
isSkip: ((
|
|
4549
|
+
isSkip: ((_c = cell == null ? void 0 : cell.fontRenderExtension) == null ? void 0 : _c.isSkip) || (validator == null ? void 0 : validator.skipDefaultFontRender(rule, cellValue, pos))
|
|
4556
4550
|
},
|
|
4557
4551
|
interceptorStyle: {
|
|
4558
4552
|
...cell == null ? void 0 : cell.interceptorStyle,
|
|
4559
|
-
...
|
|
4553
|
+
...validator == null ? void 0 : validator.getExtraStyle(rule, valueStr, { style: defaultStyle })
|
|
4560
4554
|
},
|
|
4561
4555
|
interceptorAutoHeight: /* @__PURE__ */ __name(() => {
|
|
4562
|
-
var _a24, _b2, _c2, _d2;
|
|
4563
|
-
const
|
|
4564
|
-
|
|
4565
|
-
return
|
|
4566
|
-
|
|
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 = {
|
|
4567
4561
|
data: {
|
|
4568
4562
|
...cell,
|
|
4569
4563
|
dataValidation: {
|
|
@@ -4574,7 +4568,7 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
|
|
|
4574
4568
|
}
|
|
4575
4569
|
},
|
|
4576
4570
|
style: skeleton.getsStyles().getStyleByCell(cell),
|
|
4577
|
-
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),
|
|
4578
4572
|
unitId,
|
|
4579
4573
|
subUnitId,
|
|
4580
4574
|
row,
|
|
@@ -4582,9 +4576,9 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
|
|
|
4582
4576
|
workbook,
|
|
4583
4577
|
worksheet
|
|
4584
4578
|
};
|
|
4585
|
-
return (
|
|
4579
|
+
return (_f = (_e = validator == null ? void 0 : validator.canvasRender) == null ? void 0 : _e.calcCellAutoHeight) == null ? void 0 : _f.call(_e, info);
|
|
4586
4580
|
}, "interceptorAutoHeight"),
|
|
4587
|
-
coverable: ((
|
|
4581
|
+
coverable: ((_d = cell == null ? void 0 : cell.coverable) != null ? _d : !0) && !(rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE)
|
|
4588
4582
|
});
|
|
4589
4583
|
}, "handler")
|
|
4590
4584
|
}
|
|
@@ -4711,10 +4705,7 @@ let SheetsDataValidationMobileRenderController = (_a17 = class extends RxDisposa
|
|
|
4711
4705
|
},
|
|
4712
4706
|
interceptorAutoHeight: /* @__PURE__ */ __name(() => {
|
|
4713
4707
|
var _a24, _b2, _c2, _d2;
|
|
4714
|
-
const mergeCell = skeleton.
|
|
4715
|
-
const { startColumn, startRow, endColumn, endRow } = range;
|
|
4716
|
-
return row >= startRow && col >= startColumn && row <= endRow && col <= endColumn;
|
|
4717
|
-
}), info = {
|
|
4708
|
+
const mergeCell = skeleton.worksheet.getMergedCell(row, col), info = {
|
|
4718
4709
|
data: {
|
|
4719
4710
|
...cell,
|
|
4720
4711
|
dataValidation: {
|
|
@@ -4904,8 +4895,8 @@ let DataValidationAutoFillController = (_a20 = class extends Disposable {
|
|
|
4904
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 = {
|
|
4905
4896
|
row: vSourceRange.startRow,
|
|
4906
4897
|
col: vSourceRange.startColumn
|
|
4907
|
-
};
|
|
4908
|
-
|
|
4898
|
+
}, repeats = getAutoFillRepeatRange(vSourceRange, vTargetRange), additionMatrix = new ObjectMatrix(), additionRules = /* @__PURE__ */ new Set();
|
|
4899
|
+
repeats.forEach((repeat) => {
|
|
4909
4900
|
const targetStartCell = repeat.repeatStartCell, relativeRange = repeat.relativeRange, sourceRange2 = {
|
|
4910
4901
|
startRow: sourceStartCell.row,
|
|
4911
4902
|
startColumn: sourceStartCell.col,
|
|
@@ -4937,10 +4928,12 @@ let DataValidationAutoFillController = (_a20 = class extends Disposable {
|
|
|
4937
4928
|
},
|
|
4938
4929
|
targetRange2
|
|
4939
4930
|
), { row: targetRow, col: targetCol } = mapFunc(targetPositionRange.startRow, targetPositionRange.startColumn);
|
|
4940
|
-
|
|
4931
|
+
additionMatrix.setValue(targetRow, targetCol, ruleId), additionRules.add(ruleId);
|
|
4941
4932
|
}
|
|
4942
4933
|
});
|
|
4943
4934
|
});
|
|
4935
|
+
const additions = Array.from(additionRules).map((id) => ({ id, ranges: queryObjectMatrix(additionMatrix, (value) => value === id) }));
|
|
4936
|
+
ruleMatrixCopy.addRangeRules(additions);
|
|
4944
4937
|
const diffs = ruleMatrixCopy.diff(this._dataValidationModel.getRules(unitId, subUnitId)), { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, this._injector, "patched", applyType === APPLY_TYPE.ONLY_FORMAT);
|
|
4945
4938
|
return {
|
|
4946
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>;
|