@univerjs/sheets-data-validation 0.2.8 → 0.2.9
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 +94 -77
- package/lib/types/index.d.ts +1 -0
- package/lib/types/models/sheet-data-validation-manager.d.ts +3 -3
- package/lib/types/services/dropdown-manager.service.d.ts +5 -2
- package/lib/types/services/dv-cache.service.d.ts +1 -0
- package/lib/types/services/dv-custom-formula.service.d.ts +3 -2
- package/lib/types/utils/formula.d.ts +1 -0
- package/lib/types/validators/date-validator.d.ts +2 -2
- package/lib/types/validators/decimal-validator.d.ts +3 -1
- package/lib/types/validators/text-length-validator.d.ts +3 -1
- package/lib/types/validators/whole-validator.d.ts +3 -1
- package/lib/umd/index.js +1 -1
- package/package.json +24 -24
- package/lib/types/utils/date.d.ts +0 -17
package/lib/es/index.js
CHANGED
|
@@ -2,10 +2,10 @@ 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 { DEFAULT_EMPTY_DOCUMENT_VALUE, useDependency, Inject, Disposable, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DisposableCollection, IUniverInstanceService,
|
|
5
|
+
import { DEFAULT_EMPTY_DOCUMENT_VALUE, useDependency, Inject, Disposable, UniverInstanceType, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DisposableCollection, IUniverInstanceService, toDisposable, CommandType, ICommandService, ObjectMatrix, Range, isFormulaString, ThemeService, VerticalAlign, HorizontalAlign, createInternalEditorID, LocaleService, OnLifecycle, LifecycleStages, IPermissionService, DataValidationType, Tools, DataValidationOperator, DataValidationErrorStyle, UndoCommand, RedoCommand, isUnitRangesEqual, isValidRange, debounce, shallowEqual, Injector, DataValidationRenderMode, numfmt, CellValueType, DEFAULT_STYLES, WrapStrategy, DocumentDataModel, BooleanNumber, Rectangle, IUndoRedoService, sequenceExecuteAsync, sequenceExecute, Optional, RxDisposable, DataValidationStatus, ILogService, isRangesEqual, queryObjectMatrix, IResourceManagerService, DependentOn, Plugin } from "@univerjs/core";
|
|
6
6
|
import { DataValidatorRegistryService, DataValidationModel, BaseDataValidator, DataValidatorRegistryScope, TWO_FORMULA_OPERATOR_COUNT as TWO_FORMULA_OPERATOR_COUNT$1, getRuleOptions, getRuleSetting, RemoveDataValidationCommand, createDefaultNewRule, RemoveAllDataValidationCommand, TextLengthErrorTitleMap, AddDataValidationMutation, RemoveDataValidationMutation, UpdateRuleType, UpdateDataValidationMutation, removeDataValidationUndoFactory, DataValidationManager, AddDataValidationCommand, UniverDataValidationPlugin } from "@univerjs/data-validation";
|
|
7
7
|
import { DataValidationModel as DataValidationModel2, RemoveDataValidationCommand as RemoveDataValidationCommand2 } from "@univerjs/data-validation";
|
|
8
|
-
import { getSheetCommandTarget, SetRangeValuesCommand, WorksheetViewPermission, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, WorkbookEditablePermission, WorksheetSetCellStylePermission, WorksheetEditPermission, RangeProtectionPermissionEditPoint, SheetInterceptorService, INTERCEPTOR_POINT,
|
|
8
|
+
import { SheetsSelectionsService, getSheetCommandTarget, SetRangeValuesCommand, WorksheetViewPermission, checkRangesEditablePermission, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, WorkbookEditablePermission, WorksheetSetCellStylePermission, WorksheetEditPermission, RangeProtectionPermissionEditPoint, SheetInterceptorService, INTERCEPTOR_POINT, InterceptCellContentPriority, ClearSelectionAllCommand, RefRangeService, handleCommonDefaultRangeChangeWithEffectRefCommands, UniverSheetsPlugin } from "@univerjs/sheets";
|
|
9
9
|
import { SheetCanvasPopManagerService, IMarkSelectionService, IEditorBridgeService, getCurrentRangeDisable$, AutoHeightController, SheetSkeletonManagerService, HoverManagerService, CellAlertManagerService, CellAlertType, IAutoFillService, APPLY_TYPE, virtualizeDiscreteRanges, getAutoFillRepeatRange, COPY_TYPE, rangeToDiscreteRange, PREDEFINED_HOOK_NAME, getRepeatRange, ISheetClipboardService, SheetPermissionInterceptorBaseController, UniverSheetsUIPlugin } from "@univerjs/sheets-ui";
|
|
10
10
|
import { useObservable, ComponentManager, IZenZoneService, ISidebarService, TextEditor, useEvent, RangeSelector, KeyCode, IDialogService, MenuItemType, MenuPosition, MenuGroup, getMenuHiddenObservable, IMenuService } from "@univerjs/ui";
|
|
11
11
|
import { IRenderManagerService, fixLineWidthByScale, Transform, Checkbox, DeviceInputEventType, getDocsSkeletonPageSize, Rect, DocumentViewModel, DocumentSkeleton, Documents, FontCache, Shape, getFontStyleString } from "@univerjs/engine-render";
|
|
@@ -14,7 +14,7 @@ import React, { forwardRef, useRef, createElement, useState, useMemo, useEffect
|
|
|
14
14
|
import { RegisterOtherFormulaService, FormulaRefRangeService } from "@univerjs/sheets-formula";
|
|
15
15
|
import { FormLayout, Input, RadioGroup, Radio, DraggableList, Select, Checkbox as Checkbox$1, Button, RectPopup, Scrollbar, DatePanel } from "@univerjs/design";
|
|
16
16
|
import cs from "clsx";
|
|
17
|
-
import { LexerTreeBuilder, deserializeRangeWithSheet, serializeRange, isReferenceString, sequenceNodeType,
|
|
17
|
+
import { LexerTreeBuilder, deserializeRangeWithSheet, serializeRange, isReferenceString, sequenceNodeType, ERROR_TYPE_SET } from "@univerjs/engine-formula";
|
|
18
18
|
import dayjs from "dayjs";
|
|
19
19
|
import { RichTextEditingMutation, getPlainTextFormDocument } from "@univerjs/docs";
|
|
20
20
|
function getCellValueOrigin(cell) {
|
|
@@ -91,14 +91,14 @@ var __defProp$j = Object.defineProperty, __getOwnPropDesc$j = Object.getOwnPrope
|
|
|
91
91
|
return kind && result && __defProp$j(target, key, result), result;
|
|
92
92
|
}, "__decorateClass$j"), __decorateParam$j = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$j"), _a;
|
|
93
93
|
let DataValidationDropdownManagerService = (_a = class extends Disposable {
|
|
94
|
-
constructor(_canvasPopupManagerService, _univerInstanceService, _dataValidatorRegistryService, _zenZoneService, _renderManagerService, _dataValidationModel) {
|
|
94
|
+
constructor(_canvasPopupManagerService, _univerInstanceService, _dataValidatorRegistryService, _zenZoneService, _renderManagerService, _dataValidationModel, _sheetsSelectionsService) {
|
|
95
95
|
super();
|
|
96
96
|
__publicField(this, "_activeDropdown");
|
|
97
97
|
__publicField(this, "_activeDropdown$", new Subject());
|
|
98
98
|
__publicField(this, "_currentPopup", null);
|
|
99
99
|
__publicField(this, "activeDropdown$", this._activeDropdown$.asObservable());
|
|
100
100
|
__publicField(this, "_zenVisible", !1);
|
|
101
|
-
this._canvasPopupManagerService = _canvasPopupManagerService, this._univerInstanceService = _univerInstanceService, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._zenZoneService = _zenZoneService, this._renderManagerService = _renderManagerService, this._dataValidationModel = _dataValidationModel, this._init(), this.disposeWithMe(() => {
|
|
101
|
+
this._canvasPopupManagerService = _canvasPopupManagerService, this._univerInstanceService = _univerInstanceService, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._zenZoneService = _zenZoneService, this._renderManagerService = _renderManagerService, this._dataValidationModel = _dataValidationModel, this._sheetsSelectionsService = _sheetsSelectionsService, this._init(), this._initSelectionChange(), this.disposeWithMe(() => {
|
|
102
102
|
this._activeDropdown$.complete();
|
|
103
103
|
});
|
|
104
104
|
}
|
|
@@ -110,6 +110,24 @@ let DataValidationDropdownManagerService = (_a = class extends Disposable {
|
|
|
110
110
|
this._zenVisible = visible, visible && this.hideDropdown();
|
|
111
111
|
}));
|
|
112
112
|
}
|
|
113
|
+
_getDropdownByCell(unitId, subUnitId, row, col) {
|
|
114
|
+
const workbook = unitId ? this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET) : this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
115
|
+
if (!workbook)
|
|
116
|
+
return;
|
|
117
|
+
const worksheet = subUnitId ? workbook.getSheetBySheetId(subUnitId) : workbook.getActiveSheet();
|
|
118
|
+
if (!worksheet)
|
|
119
|
+
return;
|
|
120
|
+
const rule = this._dataValidationModel.ensureManager(workbook.getUnitId(), worksheet.getSheetId()).getRuleByLocation(row, col);
|
|
121
|
+
if (!rule)
|
|
122
|
+
return;
|
|
123
|
+
const validator = this._dataValidatorRegistryService.getValidatorItem(rule.type);
|
|
124
|
+
return validator == null ? void 0 : validator.dropdown;
|
|
125
|
+
}
|
|
126
|
+
_initSelectionChange() {
|
|
127
|
+
this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe((selections) => {
|
|
128
|
+
selections && selections.every((selection) => !(selection.primary && this._getDropdownByCell(selection.primary.unitId, selection.primary.sheetId, selection.primary.actualRow, selection.primary.actualColumn))) && this.hideDropdown();
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
113
131
|
showDropdown(param, closeOnOutSide = !0) {
|
|
114
132
|
const { location } = param, { row, col } = location;
|
|
115
133
|
if (this._currentPopup && this._currentPopup.dispose(), this._zenVisible)
|
|
@@ -141,7 +159,7 @@ let DataValidationDropdownManagerService = (_a = class extends Disposable {
|
|
|
141
159
|
this._activeDropdown && (this._currentPopup && this._currentPopup.dispose(), this._currentPopup = null, this._activeDropdown = null, this._activeDropdown$.next(null));
|
|
142
160
|
}
|
|
143
161
|
showDataValidationDropdown(unitId, subUnitId, row, col, onHide) {
|
|
144
|
-
const workbook = this._univerInstanceService.
|
|
162
|
+
const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
|
|
145
163
|
if (!workbook)
|
|
146
164
|
return;
|
|
147
165
|
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
@@ -175,7 +193,8 @@ DataValidationDropdownManagerService = __decorateClass$j([
|
|
|
175
193
|
__decorateParam$j(2, Inject(DataValidatorRegistryService)),
|
|
176
194
|
__decorateParam$j(3, IZenZoneService),
|
|
177
195
|
__decorateParam$j(4, IRenderManagerService),
|
|
178
|
-
__decorateParam$j(5, Inject(DataValidationModel))
|
|
196
|
+
__decorateParam$j(5, Inject(DataValidationModel)),
|
|
197
|
+
__decorateParam$j(6, Inject(SheetsSelectionsService))
|
|
179
198
|
], DataValidationDropdownManagerService);
|
|
180
199
|
var __defProp$i = Object.defineProperty, __getOwnPropDesc$i = Object.getOwnPropertyDescriptor, __decorateClass$i = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
181
200
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$i(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -464,6 +483,11 @@ function getFormulaResult(result) {
|
|
|
464
483
|
return (_b = (_a22 = result == null ? void 0 : result[0]) == null ? void 0 : _a22[0]) == null ? void 0 : _b.v;
|
|
465
484
|
}
|
|
466
485
|
__name(getFormulaResult, "getFormulaResult");
|
|
486
|
+
function getFormulaCellData(result) {
|
|
487
|
+
var _a22;
|
|
488
|
+
return (_a22 = result == null ? void 0 : result[0]) == null ? void 0 : _a22[0];
|
|
489
|
+
}
|
|
490
|
+
__name(getFormulaCellData, "getFormulaCellData");
|
|
467
491
|
var __defProp$g = Object.defineProperty, __getOwnPropDesc$g = Object.getOwnPropertyDescriptor, __decorateClass$g = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
468
492
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
469
493
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -777,7 +801,7 @@ function getDataValidationCellValue(cellData) {
|
|
|
777
801
|
}
|
|
778
802
|
__name(getDataValidationCellValue, "getDataValidationCellValue");
|
|
779
803
|
const DATA_VALIDATION_PLUGIN_NAME = "SHEET_DATA_VALIDATION_PLUGIN", DROP_DOWN_DEFAULT_COLOR = "#ECECEC";
|
|
780
|
-
var
|
|
804
|
+
var L = /* @__PURE__ */ ((E) => (E[E.View = 0] = "View", E[E.Edit = 1] = "Edit", E[E.ManageCollaborator = 2] = "ManageCollaborator", E[E.Print = 3] = "Print", E[E.Duplicate = 4] = "Duplicate", E[E.Comment = 5] = "Comment", E[E.Copy = 6] = "Copy", E[E.Share = 7] = "Share", E[E.Export = 8] = "Export", E[E.MoveWorksheet = 9] = "MoveWorksheet", E[E.DeleteWorksheet = 10] = "DeleteWorksheet", E[E.HideWorksheet = 11] = "HideWorksheet", E[E.RenameWorksheet = 12] = "RenameWorksheet", E[E.CreateWorksheet = 13] = "CreateWorksheet", E[E.SetWorksheetStyle = 14] = "SetWorksheetStyle", E[E.EditWorksheetCell = 15] = "EditWorksheetCell", E[E.InsertHyperlink = 16] = "InsertHyperlink", E[E.Sort = 17] = "Sort", E[E.Filter = 18] = "Filter", E[E.PivotTable = 19] = "PivotTable", E[E.FloatImg = 20] = "FloatImg", E[E.History = 21] = "History", E[E.RwHgtClWdt = 22] = "RwHgtClWdt", E[E.ViemRwHgtClWdt = 23] = "ViemRwHgtClWdt", E[E.ViewFilter = 24] = "ViewFilter", E[E.MoveSheet = 25] = "MoveSheet", E[E.DeleteSheet = 26] = "DeleteSheet", E[E.HideSheet = 27] = "HideSheet", E[E.CopySheet = 28] = "CopySheet", E[E.RenameSheet = 29] = "RenameSheet", E[E.CreateSheet = 30] = "CreateSheet", E[E.SelectProtectedCells = 31] = "SelectProtectedCells", E[E.SelectUnProtectedCells = 32] = "SelectUnProtectedCells", E[E.SetCellStyle = 33] = "SetCellStyle", E[E.SetCellValue = 34] = "SetCellValue", E[E.SetRowStyle = 35] = "SetRowStyle", E[E.SetColumnStyle = 36] = "SetColumnStyle", E[E.InsertRow = 37] = "InsertRow", E[E.InsertColumn = 38] = "InsertColumn", E[E.DeleteRow = 39] = "DeleteRow", E[E.DeleteColumn = 40] = "DeleteColumn", E[E.EditExtraObject = 41] = "EditExtraObject", E[E.Delete = 42] = "Delete", E[E.RecoverHistory = 43] = "RecoverHistory", E[E.ViewHistory = 44] = "ViewHistory", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(L || {}), __defProp$f = Object.defineProperty, __getOwnPropDesc$f = Object.getOwnPropertyDescriptor, __decorateClass$f = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
781
805
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
782
806
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
783
807
|
return kind && result && __defProp$f(target, key, result), result;
|
|
@@ -810,7 +834,7 @@ let DataValidationFormulaController = (_a5 = class extends Disposable {
|
|
|
810
834
|
for (let i2 = startRow; i2 <= endRow; i2++)
|
|
811
835
|
for (let j = startColumn; j <= endColumn; j++) {
|
|
812
836
|
const permission = (_b = (_a22 = targetSheet.getCell(i2, j)) == null ? void 0 : _a22.selectionProtection) == null ? void 0 : _b[0];
|
|
813
|
-
if ((permission == null ? void 0 : permission[
|
|
837
|
+
if ((permission == null ? void 0 : permission[L.View]) === !1)
|
|
814
838
|
return !1;
|
|
815
839
|
}
|
|
816
840
|
}
|
|
@@ -1196,12 +1220,7 @@ let CheckboxValidator = _CheckboxValidator;
|
|
|
1196
1220
|
const TWO_FORMULA_OPERATOR_COUNT = [
|
|
1197
1221
|
DataValidationOperator.BETWEEN,
|
|
1198
1222
|
DataValidationOperator.NOT_BETWEEN
|
|
1199
|
-
]
|
|
1200
|
-
function excelSerialToUnixTimestamp(excelSerial) {
|
|
1201
|
-
return new Date((excelSerial - 25569) * 86400).getTime();
|
|
1202
|
-
}
|
|
1203
|
-
__name(excelSerialToUnixTimestamp, "excelSerialToUnixTimestamp");
|
|
1204
|
-
const timestamp2SerialTime = /* @__PURE__ */ __name((timestamp) => timestamp / 86400 + 25569, "timestamp2SerialTime"), dataValidationOptionsButton = "univer-data-validation-options-button", dataValidationOptionsButtonIcon = "univer-data-validation-options-button-icon", styles$5 = {
|
|
1223
|
+
], dataValidationOptionsButton = "univer-data-validation-options-button", dataValidationOptionsButtonIcon = "univer-data-validation-options-button-icon", styles$5 = {
|
|
1205
1224
|
dataValidationOptionsButton,
|
|
1206
1225
|
dataValidationOptionsButtonIcon
|
|
1207
1226
|
};
|
|
@@ -1540,21 +1559,8 @@ function DataValidationListWithWorkbook(props) {
|
|
|
1540
1559
|
subUnitId
|
|
1541
1560
|
});
|
|
1542
1561
|
}, "handleRemoveAll"), rulesByPermissionCheck = (/* @__PURE__ */ __name((rules2) => {
|
|
1543
|
-
const
|
|
1544
|
-
return rules2.map((rule) => {
|
|
1545
|
-
const { ranges } = rule;
|
|
1546
|
-
return (ranges == null ? void 0 : ranges.some((range) => {
|
|
1547
|
-
var _a22, _b;
|
|
1548
|
-
const { startRow, startColumn, endRow, endColumn } = range;
|
|
1549
|
-
for (let row = startRow; row <= endRow; row++)
|
|
1550
|
-
for (let col = startColumn; col <= endColumn; col++) {
|
|
1551
|
-
const permission = (_b = (_a22 = worksheet2 == null ? void 0 : worksheet2.getCell(row, col)) == null ? void 0 : _a22.selectionProtection) == null ? void 0 : _b[0];
|
|
1552
|
-
if ((permission == null ? void 0 : permission[P.Edit]) === !1 || (permission == null ? void 0 : permission[P.View]) === !1)
|
|
1553
|
-
return !0;
|
|
1554
|
-
}
|
|
1555
|
-
return !1;
|
|
1556
|
-
})) ? { ...rule, disable: !0 } : { ...rule };
|
|
1557
|
-
});
|
|
1562
|
+
const workbook2 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), worksheet2 = workbook2.getActiveSheet(), unitId2 = workbook2.getUnitId(), subUnitId2 = worksheet2.getSheetId();
|
|
1563
|
+
return rules2.map((rule) => checkRangesEditablePermission(injector, unitId2, subUnitId2, rule.ranges) ? { ...rule } : { ...rule, disable: !0 });
|
|
1558
1564
|
}, "getDvRulesByPermissionCorrect"))(rules), hasDisableRule = rulesByPermissionCheck == null ? void 0 : rulesByPermissionCheck.some((rule) => rule.disable);
|
|
1559
1565
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
1560
1566
|
rulesByPermissionCheck == null ? void 0 : rulesByPermissionCheck.map((rule) => {
|
|
@@ -1793,12 +1799,14 @@ let DataValidationRejectInputController = (_a6 = class extends Disposable {
|
|
|
1793
1799
|
if (!validator || await validator.validator(
|
|
1794
1800
|
{
|
|
1795
1801
|
value: getCellValueOrigin(cell),
|
|
1802
|
+
interceptValue: getCellValueOrigin(cell),
|
|
1796
1803
|
row,
|
|
1797
1804
|
column: col,
|
|
1798
1805
|
unitId,
|
|
1799
1806
|
subUnitId,
|
|
1800
1807
|
worksheet,
|
|
1801
|
-
workbook
|
|
1808
|
+
workbook,
|
|
1809
|
+
t: cell == null ? void 0 : cell.t
|
|
1802
1810
|
},
|
|
1803
1811
|
rule
|
|
1804
1812
|
))
|
|
@@ -1873,10 +1881,8 @@ dayjs.extend(utc);
|
|
|
1873
1881
|
const transformDate = /* @__PURE__ */ __name((value) => {
|
|
1874
1882
|
if (value == null || typeof value == "boolean")
|
|
1875
1883
|
return;
|
|
1876
|
-
if (typeof value == "number" || !Number.isNaN(+value))
|
|
1877
|
-
|
|
1878
|
-
return dayjs(date2);
|
|
1879
|
-
}
|
|
1884
|
+
if (typeof value == "number" || !Number.isNaN(+value))
|
|
1885
|
+
return dayjs(numfmt.format("yyyy-MM-dd HH:mm:ss", value));
|
|
1880
1886
|
const date = dayjs(value);
|
|
1881
1887
|
if (date.isValid())
|
|
1882
1888
|
return date;
|
|
@@ -1887,9 +1893,10 @@ function DateDropdown(props) {
|
|
|
1887
1893
|
if (!cellData || !rule || !validator)
|
|
1888
1894
|
return;
|
|
1889
1895
|
const handleSave = /* @__PURE__ */ __name(async () => {
|
|
1896
|
+
var _a23;
|
|
1890
1897
|
if (!date)
|
|
1891
1898
|
return;
|
|
1892
|
-
const dateStr =
|
|
1899
|
+
const dateStr = date.format(showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD 00:00:00"), serialTime = (_a23 = numfmt.parseDate(dateStr)) == null ? void 0 : _a23.v;
|
|
1893
1900
|
rule.errorStyle !== DataValidationErrorStyle.STOP || await validator.validator({
|
|
1894
1901
|
value: serialTime,
|
|
1895
1902
|
unitId,
|
|
@@ -1897,7 +1904,9 @@ function DateDropdown(props) {
|
|
|
1897
1904
|
row,
|
|
1898
1905
|
column: col,
|
|
1899
1906
|
worksheet,
|
|
1900
|
-
workbook
|
|
1907
|
+
workbook,
|
|
1908
|
+
interceptValue: dateStr.replace("Z", "").replace("T", " "),
|
|
1909
|
+
t: CellValueType.NUMBER
|
|
1901
1910
|
}, rule) ? (commandService.executeCommand(SetRangeValuesCommand.id, {
|
|
1902
1911
|
unitId,
|
|
1903
1912
|
subUnitId,
|
|
@@ -1933,7 +1942,8 @@ function DateDropdown(props) {
|
|
|
1933
1942
|
}, "onSelect"),
|
|
1934
1943
|
onPanelChange: /* @__PURE__ */ __name((value) => {
|
|
1935
1944
|
setLocalDate(value);
|
|
1936
|
-
}, "onPanelChange")
|
|
1945
|
+
}, "onPanelChange"),
|
|
1946
|
+
disabledDate: /* @__PURE__ */ __name((current) => !numfmt.parseDate(current.format("YYYY-MM-DD")), "disabledDate")
|
|
1937
1947
|
}
|
|
1938
1948
|
),
|
|
1939
1949
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.dvDateDropdownBtns, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "small", type: "primary", onClick: handleSave, disabled: !date.isValid(), children: localeService.t("dataValidation.alert.ok") }) })
|
|
@@ -1993,12 +2003,13 @@ function DateShowTimeOption(props) {
|
|
|
1993
2003
|
__name(DateShowTimeOption, "DateShowTimeOption");
|
|
1994
2004
|
DateShowTimeOption.componentKey = DATE_SHOW_TIME_OPTION;
|
|
1995
2005
|
const FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2SerialNumber = /* @__PURE__ */ __name((value) => {
|
|
2006
|
+
var _a22;
|
|
1996
2007
|
if (value == null || typeof value == "boolean")
|
|
1997
2008
|
return;
|
|
1998
2009
|
if (typeof value == "number" || !Number.isNaN(+value))
|
|
1999
2010
|
return +value;
|
|
2000
|
-
const dateStr = `${dayjs(value).format("YYYY-MM-DD HH:mm:ss")
|
|
2001
|
-
return
|
|
2011
|
+
const dateStr = `${dayjs(value).format("YYYY-MM-DD HH:mm:ss")}`;
|
|
2012
|
+
return (_a22 = numfmt.parseDate(dateStr)) == null ? void 0 : _a22.v;
|
|
2002
2013
|
}, "transformDate2SerialNumber"), _DateValidator = class _DateValidator extends BaseDataValidator {
|
|
2003
2014
|
constructor() {
|
|
2004
2015
|
super(...arguments);
|
|
@@ -2037,8 +2048,8 @@ const FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2Serial
|
|
|
2037
2048
|
};
|
|
2038
2049
|
}
|
|
2039
2050
|
async isValidType(info) {
|
|
2040
|
-
const {
|
|
2041
|
-
return typeof interceptValue == "string"
|
|
2051
|
+
const { interceptValue } = info;
|
|
2052
|
+
return typeof interceptValue == "string" ? !!numfmt.parseDate(interceptValue) : !1;
|
|
2042
2053
|
}
|
|
2043
2054
|
_validatorSingleFormula(formula) {
|
|
2044
2055
|
return !Tools.isBlank(formula) && (isFormulaString(formula) || !Number.isNaN(+formula) || !!formula && dayjs(formula).isValid());
|
|
@@ -2212,6 +2223,7 @@ function calcPadding(cellWidth, cellHeight, fontWidth, fontHeight, vt, ht, margi
|
|
|
2212
2223
|
paddingTop = realMargin;
|
|
2213
2224
|
break;
|
|
2214
2225
|
}
|
|
2226
|
+
paddingTop = Math.max(MARGIN_V$1, paddingTop);
|
|
2215
2227
|
let paddingLeft = 0;
|
|
2216
2228
|
switch (ht) {
|
|
2217
2229
|
case HorizontalAlign.CENTER:
|
|
@@ -2221,7 +2233,7 @@ function calcPadding(cellWidth, cellHeight, fontWidth, fontHeight, vt, ht, margi
|
|
|
2221
2233
|
paddingLeft = cellWidth - fontWidth;
|
|
2222
2234
|
break;
|
|
2223
2235
|
}
|
|
2224
|
-
return {
|
|
2236
|
+
return paddingLeft = Math.max(MARGIN_H$1, paddingLeft), {
|
|
2225
2237
|
paddingLeft,
|
|
2226
2238
|
paddingTop
|
|
2227
2239
|
};
|
|
@@ -3128,7 +3140,8 @@ let SheetsDataValidationRenderController = (_a8 = class extends RxDisposable {
|
|
|
3128
3140
|
this._sheetInterceptorService.intercept(
|
|
3129
3141
|
INTERCEPTOR_POINT.CELL_CONTENT,
|
|
3130
3142
|
{
|
|
3131
|
-
|
|
3143
|
+
// must be after numfmt
|
|
3144
|
+
priority: InterceptCellContentPriority.DATA_VALIDATION,
|
|
3132
3145
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
3133
3146
|
handler: /* @__PURE__ */ __name((cell, pos, next) => {
|
|
3134
3147
|
var _a22, _b, _c, _d, _e, _f;
|
|
@@ -3144,7 +3157,7 @@ let SheetsDataValidationRenderController = (_a8 = class extends RxDisposable {
|
|
|
3144
3157
|
const rule = manager.getRuleById(ruleId);
|
|
3145
3158
|
if (!rule)
|
|
3146
3159
|
return next(cell);
|
|
3147
|
-
const
|
|
3160
|
+
const validStatus = this._dataValidationModel.validator(rule, pos, cell), validator = this._dataValidatorRegistryService.getValidatorItem(rule.type), cellValue = getCellValueOrigin(cell);
|
|
3148
3161
|
let extra = {};
|
|
3149
3162
|
if ((rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE) && (extra = {
|
|
3150
3163
|
interceptorStyle: {
|
|
@@ -3284,7 +3297,7 @@ let SheetsDataValidationMobileRenderController = (_a9 = class extends RxDisposab
|
|
|
3284
3297
|
this._sheetInterceptorService.intercept(
|
|
3285
3298
|
INTERCEPTOR_POINT.CELL_CONTENT,
|
|
3286
3299
|
{
|
|
3287
|
-
priority:
|
|
3300
|
+
priority: InterceptCellContentPriority.DATA_VALIDATION,
|
|
3288
3301
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
3289
3302
|
handler: /* @__PURE__ */ __name((cell, pos, next) => {
|
|
3290
3303
|
var _a22, _b, _c, _d, _e;
|
|
@@ -3300,7 +3313,7 @@ let SheetsDataValidationMobileRenderController = (_a9 = class extends RxDisposab
|
|
|
3300
3313
|
const rule = manager.getRuleById(ruleId);
|
|
3301
3314
|
if (!rule)
|
|
3302
3315
|
return next(cell);
|
|
3303
|
-
const
|
|
3316
|
+
const validStatus = this._dataValidationModel.validator(rule, pos, cell), validator = this._dataValidatorRegistryService.getValidatorItem(rule.type), cellValue = getCellValueOrigin(cell);
|
|
3304
3317
|
let extra = {};
|
|
3305
3318
|
if ((rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE) && (extra = {
|
|
3306
3319
|
interceptorStyle: {
|
|
@@ -3413,9 +3426,14 @@ var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPrope
|
|
|
3413
3426
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
3414
3427
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
3415
3428
|
return kind && result && __defProp$b(target, key, result), result;
|
|
3416
|
-
}, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b")
|
|
3429
|
+
}, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b");
|
|
3430
|
+
function transformFormula(lexerTreeBuilder, formula, originRow, originCol, targetRow, targetCol) {
|
|
3431
|
+
return lexerTreeBuilder.moveFormulaRefOffset(formula, targetCol - originCol, targetRow - originRow);
|
|
3432
|
+
}
|
|
3433
|
+
__name(transformFormula, "transformFormula");
|
|
3434
|
+
var _a10;
|
|
3417
3435
|
let DataValidationCustomFormulaService = (_a10 = class extends Disposable {
|
|
3418
|
-
constructor(_instanceSrv, _registerOtherFormulaService, _lexerTreeBuilder, _dataValidationModel, _dataValidationCacheService) {
|
|
3436
|
+
constructor(_instanceSrv, _registerOtherFormulaService, _lexerTreeBuilder, _dataValidationModel, _dataValidationCacheService, _logService) {
|
|
3419
3437
|
super();
|
|
3420
3438
|
__publicField(this, "_formulaMap", /* @__PURE__ */ new Map());
|
|
3421
3439
|
/**
|
|
@@ -3426,7 +3444,7 @@ let DataValidationCustomFormulaService = (_a10 = class extends Disposable {
|
|
|
3426
3444
|
* reflect of formulaId to cell, only store transformable formula
|
|
3427
3445
|
*/
|
|
3428
3446
|
__publicField(this, "_formulaCellMap", /* @__PURE__ */ new Map());
|
|
3429
|
-
this._instanceSrv = _instanceSrv, this._registerOtherFormulaService = _registerOtherFormulaService, this._lexerTreeBuilder = _lexerTreeBuilder, this._dataValidationModel = _dataValidationModel, this._dataValidationCacheService = _dataValidationCacheService, this._initFormulaResultHandler();
|
|
3447
|
+
this._instanceSrv = _instanceSrv, this._registerOtherFormulaService = _registerOtherFormulaService, this._lexerTreeBuilder = _lexerTreeBuilder, this._dataValidationModel = _dataValidationModel, this._dataValidationCacheService = _dataValidationCacheService, this._logService = _logService, this._initFormulaResultHandler();
|
|
3430
3448
|
}
|
|
3431
3449
|
_initFormulaResultHandler() {
|
|
3432
3450
|
this.disposeWithMe(this._registerOtherFormulaService.formulaResult$.subscribe((resultMap) => {
|
|
@@ -3473,12 +3491,9 @@ let DataValidationCustomFormulaService = (_a10 = class extends Disposable {
|
|
|
3473
3491
|
const { formulaMap, ruleFormulaMap, formulaCellMap } = this._ensureMaps(unitId, subUnitId);
|
|
3474
3492
|
if (!formula)
|
|
3475
3493
|
return;
|
|
3476
|
-
const
|
|
3477
|
-
this._lexerTreeBuilder,
|
|
3478
|
-
formula
|
|
3479
|
-
), originRow = ranges[0].startRow, originCol = ranges[0].startColumn;
|
|
3494
|
+
const originRow = ranges[0].startRow, originCol = ranges[0].startColumn;
|
|
3480
3495
|
let originFormulaId;
|
|
3481
|
-
|
|
3496
|
+
ranges.forEach((range) => {
|
|
3482
3497
|
Range.foreach(range, (row, column) => {
|
|
3483
3498
|
const relativeFormula = transformFormula(
|
|
3484
3499
|
this._lexerTreeBuilder,
|
|
@@ -3494,20 +3509,12 @@ let DataValidationCustomFormulaService = (_a10 = class extends Disposable {
|
|
|
3494
3509
|
ruleId
|
|
3495
3510
|
}), formulaCellMap.set(formulaId, { row, column });
|
|
3496
3511
|
});
|
|
3497
|
-
})
|
|
3498
|
-
Range.foreach(range, (row, col) => {
|
|
3499
|
-
formulaMap.setValue(row, col, {
|
|
3500
|
-
formulaId: originFormulaId,
|
|
3501
|
-
// formulaText: formula,
|
|
3502
|
-
ruleId
|
|
3503
|
-
});
|
|
3504
|
-
});
|
|
3505
|
-
})), ruleFormulaMap.set(ruleId, {
|
|
3512
|
+
}), ruleFormulaMap.set(ruleId, {
|
|
3506
3513
|
formula,
|
|
3507
3514
|
originCol,
|
|
3508
3515
|
originRow,
|
|
3509
|
-
|
|
3510
|
-
|
|
3516
|
+
formulaId: originFormulaId,
|
|
3517
|
+
isTransformable: !0
|
|
3511
3518
|
});
|
|
3512
3519
|
}
|
|
3513
3520
|
addRule(unitId, subUnitId, rule) {
|
|
@@ -3533,7 +3540,6 @@ let DataValidationCustomFormulaService = (_a10 = class extends Disposable {
|
|
|
3533
3540
|
if (oldRuleFormula != null && oldRuleFormula.isTransformable && deleteFormulaIdList.add(oldValue.formulaId), isTransformable) {
|
|
3534
3541
|
const relativeText = transformFormula(this._lexerTreeBuilder, formula, originRow, originCol, row, col), formulaId2 = this._registerFormula(unitId, subUnitId, ruleId, relativeText);
|
|
3535
3542
|
formulaMap.setValue(row, col, {
|
|
3536
|
-
// formulaText: relativeText,
|
|
3537
3543
|
ruleId,
|
|
3538
3544
|
formulaId: formulaId2
|
|
3539
3545
|
}), formulaCellMap.set(formulaId2, { row, column: col });
|
|
@@ -3573,8 +3579,13 @@ DataValidationCustomFormulaService = __decorateClass$b([
|
|
|
3573
3579
|
__decorateParam$b(1, Inject(RegisterOtherFormulaService)),
|
|
3574
3580
|
__decorateParam$b(2, Inject(LexerTreeBuilder)),
|
|
3575
3581
|
__decorateParam$b(3, Inject(DataValidationModel)),
|
|
3576
|
-
__decorateParam$b(4, Inject(DataValidationCacheService))
|
|
3582
|
+
__decorateParam$b(4, Inject(DataValidationCacheService)),
|
|
3583
|
+
__decorateParam$b(5, ILogService)
|
|
3577
3584
|
], DataValidationCustomFormulaService);
|
|
3585
|
+
function isLegalFormulaResult(res) {
|
|
3586
|
+
return !ERROR_TYPE_SET.has(res);
|
|
3587
|
+
}
|
|
3588
|
+
__name(isLegalFormulaResult, "isLegalFormulaResult");
|
|
3578
3589
|
const _CustomFormulaValidator = class _CustomFormulaValidator extends BaseDataValidator {
|
|
3579
3590
|
constructor() {
|
|
3580
3591
|
super(...arguments);
|
|
@@ -3599,8 +3610,8 @@ const _CustomFormulaValidator = class _CustomFormulaValidator extends BaseDataVa
|
|
|
3599
3610
|
};
|
|
3600
3611
|
}
|
|
3601
3612
|
async isValidType(cellInfo, _formula, _rule) {
|
|
3602
|
-
const { column, row, unitId, subUnitId } = cellInfo, result = await this._customFormulaService.getCellFormulaValue(unitId, subUnitId, row, column);
|
|
3603
|
-
return
|
|
3613
|
+
const { column, row, unitId, subUnitId } = cellInfo, result = await this._customFormulaService.getCellFormulaValue(unitId, subUnitId, row, column), cellData = getFormulaCellData(result == null ? void 0 : result.result), formulaResult = cellData == null ? void 0 : cellData.v;
|
|
3614
|
+
return Tools.isDefine(formulaResult) && formulaResult !== "" ? cellData.t === CellValueType.BOOLEAN ? !!formulaResult : typeof formulaResult == "boolean" ? formulaResult : typeof formulaResult == "number" ? !!formulaResult : typeof formulaResult == "string" ? isLegalFormulaResult(formulaResult) : !!formulaResult : !1;
|
|
3604
3615
|
}
|
|
3605
3616
|
generateRuleErrorMessage(rule) {
|
|
3606
3617
|
return this.localeService.t("dataValidation.custom.error");
|
|
@@ -4561,12 +4572,13 @@ const _SheetDataValidationManager = class _SheetDataValidationManager extends Da
|
|
|
4561
4572
|
if (ruleId)
|
|
4562
4573
|
return this.getRuleById(ruleId);
|
|
4563
4574
|
}
|
|
4564
|
-
validator(
|
|
4565
|
-
const { col, row, unitId, subUnitId } = pos, ruleId = rule.uid, validator = this.getValidator(rule.type);
|
|
4575
|
+
validator(cell, rule, pos, onCompete) {
|
|
4576
|
+
const { col, row, unitId, subUnitId, worksheet } = pos, ruleId = rule.uid, validator = this.getValidator(rule.type), cellRaw = worksheet.getCellRaw(row, col), cellValue = getCellValueOrigin(cellRaw), interceptValue = getCellValueOrigin(cell);
|
|
4566
4577
|
if (validator) {
|
|
4567
4578
|
const current = this._cache.getValue(row, col);
|
|
4568
|
-
return !current || current.value !== cellValue ? (this._cache.setValue(row, col, {
|
|
4579
|
+
return !current || current.value !== cellValue || current.interceptValue !== interceptValue || current.ruleId !== ruleId ? (this._cache.setValue(row, col, {
|
|
4569
4580
|
value: cellValue,
|
|
4581
|
+
interceptValue,
|
|
4570
4582
|
status: DataValidationStatus.VALIDATING,
|
|
4571
4583
|
ruleId
|
|
4572
4584
|
}), validator.validator(
|
|
@@ -4577,7 +4589,9 @@ const _SheetDataValidationManager = class _SheetDataValidationManager extends Da
|
|
|
4577
4589
|
row,
|
|
4578
4590
|
column: col,
|
|
4579
4591
|
worksheet: pos.worksheet,
|
|
4580
|
-
workbook: pos.workbook
|
|
4592
|
+
workbook: pos.workbook,
|
|
4593
|
+
interceptValue: getCellValueOrigin(cell),
|
|
4594
|
+
t: cellRaw == null ? void 0 : cellRaw.t
|
|
4581
4595
|
},
|
|
4582
4596
|
rule
|
|
4583
4597
|
).then((status) => {
|
|
@@ -4585,7 +4599,8 @@ const _SheetDataValidationManager = class _SheetDataValidationManager extends Da
|
|
|
4585
4599
|
this._cache.setValue(row, col, {
|
|
4586
4600
|
value: cellValue,
|
|
4587
4601
|
status: realStatus,
|
|
4588
|
-
ruleId
|
|
4602
|
+
ruleId,
|
|
4603
|
+
interceptValue
|
|
4589
4604
|
}), onCompete(realStatus, !0);
|
|
4590
4605
|
}), DataValidationStatus.VALIDATING) : (onCompete(current.status, !1), current.status);
|
|
4591
4606
|
} else
|
|
@@ -4678,9 +4693,11 @@ let SheetsDataValidationValidatorService = (_a19 = class {
|
|
|
4678
4693
|
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
4679
4694
|
if (!worksheet)
|
|
4680
4695
|
throw new Error(`cannot find current worksheet, sheetId: ${subUnitId}`);
|
|
4681
|
-
|
|
4696
|
+
if (!Tools.isDefine(row) || !Tools.isDefine(col))
|
|
4697
|
+
throw new Error(`row or col is not defined, row: ${row}, col: ${col}`);
|
|
4698
|
+
const manager = this._dataValidationModel.ensureManager(unitId, subUnitId), cell = worksheet.getCell(row, col), rule = manager.getRuleByLocation(row, col);
|
|
4682
4699
|
return rule ? new Promise((resolve) => {
|
|
4683
|
-
manager.validator(
|
|
4700
|
+
manager.validator(cell, rule, { unitId, subUnitId, row, col, worksheet, workbook }, resolve);
|
|
4684
4701
|
}) : DataValidationStatus.VALID;
|
|
4685
4702
|
}
|
|
4686
4703
|
validatorRanges(unitId, subUnitId, ranges) {
|
package/lib/types/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
export { UniverSheetsDataValidationPlugin } from './plugin';
|
|
17
17
|
export { UniverSheetsDataValidationMobilePlugin } from './mobile-plugin';
|
|
18
18
|
export { DataValidationCacheService } from './services/dv-cache.service';
|
|
19
|
+
export type { IDataValidationResCache } from './services/dv-cache.service';
|
|
19
20
|
export { DataValidationFormulaService } from './services/dv-formula.service';
|
|
20
21
|
export { DataValidationCustomFormulaService } from './services/dv-custom-formula.service';
|
|
21
22
|
export { DATA_VALIDATION_PLUGIN_NAME } from './common/const';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ICellDataForSheetInterceptor, Injector, ISheetDataValidationRule, Nullable, DataValidationStatus, DataValidationType } from '@univerjs/core';
|
|
2
2
|
import { DataValidationManager, IUpdateRulePayload } from '@univerjs/data-validation';
|
|
3
3
|
import { ISheetLocation } from '@univerjs/sheets';
|
|
4
4
|
import { RuleMatrix } from './rule-matrix';
|
|
@@ -18,10 +18,10 @@ export declare class SheetDataValidationManager extends DataValidationManager<IS
|
|
|
18
18
|
addRule(rule: ISheetDataValidationRule | ISheetDataValidationRule[], index?: number): void;
|
|
19
19
|
updateRule(ruleId: string, payload: IUpdateRulePayload): ISheetDataValidationRule;
|
|
20
20
|
removeRule(ruleId: string): void;
|
|
21
|
-
getValidator(type: DataValidationType): import('@univerjs/data-validation').BaseDataValidator<CellValue> | undefined;
|
|
21
|
+
getValidator(type: DataValidationType): import('@univerjs/data-validation').BaseDataValidator<import('@univerjs/core').CellValue> | undefined;
|
|
22
22
|
getRuleIdByLocation(row: number, col: number): string | undefined;
|
|
23
23
|
getRuleByLocation(row: number, col: number): ISheetDataValidationRule | undefined;
|
|
24
|
-
validator(
|
|
24
|
+
validator(cell: Nullable<ICellDataForSheetInterceptor>, rule: ISheetDataValidationRule, pos: ISheetLocation, onCompete: (status: DataValidationStatus, changed: boolean) => void): DataValidationStatus;
|
|
25
25
|
getRuleErrorMsg(ruleId: string): string;
|
|
26
26
|
getRuleObjectMatrix(): RuleMatrix;
|
|
27
27
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Nullable, Disposable, IUniverInstanceService } from '@univerjs/core';
|
|
2
|
-
import { ISheetLocation } from '@univerjs/sheets';
|
|
2
|
+
import { ISheetLocation, SheetsSelectionsService } from '@univerjs/sheets';
|
|
3
3
|
import { SheetCanvasPopManagerService } from '@univerjs/sheets-ui';
|
|
4
4
|
import { DataValidationModel, DataValidatorRegistryService } from '@univerjs/data-validation';
|
|
5
5
|
import { IZenZoneService } from '@univerjs/ui';
|
|
@@ -22,14 +22,17 @@ export declare class DataValidationDropdownManagerService extends Disposable {
|
|
|
22
22
|
private readonly _zenZoneService;
|
|
23
23
|
private readonly _renderManagerService;
|
|
24
24
|
private readonly _dataValidationModel;
|
|
25
|
+
private readonly _sheetsSelectionsService;
|
|
25
26
|
private _activeDropdown;
|
|
26
27
|
private _activeDropdown$;
|
|
27
28
|
private _currentPopup;
|
|
28
29
|
activeDropdown$: import('rxjs').Observable<Nullable<IDropdownParam>>;
|
|
29
30
|
private _zenVisible;
|
|
30
31
|
get activeDropdown(): Nullable<IDropdownParam>;
|
|
31
|
-
constructor(_canvasPopupManagerService: SheetCanvasPopManagerService, _univerInstanceService: IUniverInstanceService, _dataValidatorRegistryService: DataValidatorRegistryService, _zenZoneService: IZenZoneService, _renderManagerService: IRenderManagerService, _dataValidationModel: DataValidationModel);
|
|
32
|
+
constructor(_canvasPopupManagerService: SheetCanvasPopManagerService, _univerInstanceService: IUniverInstanceService, _dataValidatorRegistryService: DataValidatorRegistryService, _zenZoneService: IZenZoneService, _renderManagerService: IRenderManagerService, _dataValidationModel: DataValidationModel, _sheetsSelectionsService: SheetsSelectionsService);
|
|
32
33
|
private _init;
|
|
34
|
+
private _getDropdownByCell;
|
|
35
|
+
private _initSelectionChange;
|
|
33
36
|
showDropdown(param: IDropdownParam, closeOnOutSide?: boolean): void;
|
|
34
37
|
hideDropdown(): void;
|
|
35
38
|
showDataValidationDropdown(unitId: string, subUnitId: string, row: number, col: number, onHide?: () => void): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ObjectMatrix, CellValue, DataValidationStatus, IRange, ISheetDataValidationRule, Nullable } from '@univerjs/core';
|
|
2
2
|
export interface IDataValidationResCache {
|
|
3
3
|
value: Nullable<CellValue>;
|
|
4
|
+
interceptValue: Nullable<CellValue>;
|
|
4
5
|
status: DataValidationStatus;
|
|
5
6
|
ruleId: string;
|
|
6
7
|
temp?: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IRange, ISheetDataValidationRule, Disposable, IUniverInstanceService } from '@univerjs/core';
|
|
1
|
+
import { IRange, ISheetDataValidationRule, Disposable, ILogService, 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';
|
|
@@ -16,6 +16,7 @@ export declare class DataValidationCustomFormulaService extends Disposable {
|
|
|
16
16
|
private _lexerTreeBuilder;
|
|
17
17
|
private readonly _dataValidationModel;
|
|
18
18
|
private readonly _dataValidationCacheService;
|
|
19
|
+
private readonly _logService;
|
|
19
20
|
private _formulaMap;
|
|
20
21
|
/**
|
|
21
22
|
* Map of origin formula of rule
|
|
@@ -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(_instanceSrv: IUniverInstanceService, _registerOtherFormulaService: RegisterOtherFormulaService, _lexerTreeBuilder: LexerTreeBuilder, _dataValidationModel: DataValidationModel, _dataValidationCacheService: DataValidationCacheService);
|
|
29
|
+
constructor(_instanceSrv: IUniverInstanceService, _registerOtherFormulaService: RegisterOtherFormulaService, _lexerTreeBuilder: LexerTreeBuilder, _dataValidationModel: DataValidationModel, _dataValidationCacheService: DataValidationCacheService, _logService: ILogService);
|
|
29
30
|
private _initFormulaResultHandler;
|
|
30
31
|
private _ensureMaps;
|
|
31
32
|
private _registerFormula;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { ICellData, Nullable } from '@univerjs/core';
|
|
2
2
|
export declare function getFormulaResult(result: Nullable<Nullable<ICellData>[][]>): Nullable<import('@univerjs/core').CellValue>;
|
|
3
|
+
export declare function getFormulaCellData(result: Nullable<Nullable<ICellData>[][]>): Nullable<ICellData>;
|
|
@@ -11,8 +11,8 @@ export declare class DateValidator extends BaseDataValidator<number> {
|
|
|
11
11
|
private _formulaService;
|
|
12
12
|
parseFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): Promise<IFormulaResult<number | undefined>>;
|
|
13
13
|
parseFormulaSync(rule: IDataValidationRule, unitId: string, subUnitId: string): {
|
|
14
|
-
formula1:
|
|
15
|
-
formula2:
|
|
14
|
+
formula1: any;
|
|
15
|
+
formula2: any;
|
|
16
16
|
};
|
|
17
17
|
isValidType(info: IValidatorCellInfo): Promise<boolean>;
|
|
18
18
|
private _validatorSingleFormula;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataValidationOperator, CellValue, IDataValidationRule } from '@univerjs/core';
|
|
1
|
+
import { DataValidationOperator, CellValue, IDataValidationRule, Nullable } from '@univerjs/core';
|
|
2
2
|
import { IFormulaResult, IFormulaValidResult, IValidatorCellInfo, BaseDataValidator } from '@univerjs/data-validation';
|
|
3
3
|
export declare function getCellValueNumber(cellValue: CellValue): number;
|
|
4
4
|
export declare class DecimalValidator extends BaseDataValidator<number> {
|
|
@@ -13,12 +13,14 @@ export declare class DecimalValidator extends BaseDataValidator<number> {
|
|
|
13
13
|
isValidType(cellInfo: IValidatorCellInfo<CellValue>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
|
|
14
14
|
transform(cellInfo: IValidatorCellInfo<CellValue>, formula: IFormulaResult, rule: IDataValidationRule): {
|
|
15
15
|
value: number;
|
|
16
|
+
interceptValue: Nullable<CellValue>;
|
|
16
17
|
row: number;
|
|
17
18
|
column: number;
|
|
18
19
|
unitId: string;
|
|
19
20
|
subUnitId: string;
|
|
20
21
|
worksheet: import('@univerjs/core').Worksheet;
|
|
21
22
|
workbook: import('@univerjs/core').Workbook;
|
|
23
|
+
t: Nullable<import('@univerjs/protocol').CellValueType>;
|
|
22
24
|
};
|
|
23
25
|
private _parseNumber;
|
|
24
26
|
parseFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): Promise<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataValidationOperator, CellValue, IDataValidationRule, IDataValidationRuleBase } from '@univerjs/core';
|
|
1
|
+
import { DataValidationOperator, CellValue, IDataValidationRule, IDataValidationRuleBase, Nullable } from '@univerjs/core';
|
|
2
2
|
import { IFormulaResult, IFormulaValidResult, IValidatorCellInfo, BaseDataValidator } from '@univerjs/data-validation';
|
|
3
3
|
export declare class TextLengthValidator extends BaseDataValidator<number> {
|
|
4
4
|
id: string;
|
|
@@ -14,12 +14,14 @@ export declare class TextLengthValidator extends BaseDataValidator<number> {
|
|
|
14
14
|
parseFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): Promise<IFormulaResult<any>>;
|
|
15
15
|
transform(cellInfo: IValidatorCellInfo<CellValue>, _formula: IFormulaResult, _rule: IDataValidationRule): {
|
|
16
16
|
value: number;
|
|
17
|
+
interceptValue: Nullable<CellValue>;
|
|
17
18
|
row: number;
|
|
18
19
|
column: number;
|
|
19
20
|
unitId: string;
|
|
20
21
|
subUnitId: string;
|
|
21
22
|
worksheet: import('@univerjs/core').Worksheet;
|
|
22
23
|
workbook: import('@univerjs/core').Workbook;
|
|
24
|
+
t: Nullable<import('@univerjs/protocol').CellValueType>;
|
|
23
25
|
};
|
|
24
26
|
isValidType(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
|
|
25
27
|
validatorIsEqual(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataValidationOperator, CellValue, IDataValidationRule, IDataValidationRuleBase } from '@univerjs/core';
|
|
1
|
+
import { DataValidationOperator, CellValue, IDataValidationRule, IDataValidationRuleBase, Nullable } from '@univerjs/core';
|
|
2
2
|
import { IFormulaResult, IFormulaValidResult, IValidatorCellInfo, BaseDataValidator } from '@univerjs/data-validation';
|
|
3
3
|
export declare class WholeValidator extends BaseDataValidator<number> {
|
|
4
4
|
private _formulaService;
|
|
@@ -12,12 +12,14 @@ export declare class WholeValidator extends BaseDataValidator<number> {
|
|
|
12
12
|
isValidType(cellInfo: IValidatorCellInfo<CellValue>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
|
|
13
13
|
transform(cellInfo: IValidatorCellInfo<CellValue>, formula: IFormulaResult, rule: IDataValidationRule): {
|
|
14
14
|
value: number;
|
|
15
|
+
interceptValue: Nullable<CellValue>;
|
|
15
16
|
row: number;
|
|
16
17
|
column: number;
|
|
17
18
|
unitId: string;
|
|
18
19
|
subUnitId: string;
|
|
19
20
|
worksheet: import('@univerjs/core').Worksheet;
|
|
20
21
|
workbook: import('@univerjs/core').Workbook;
|
|
22
|
+
t: Nullable<import('@univerjs/protocol').CellValueType>;
|
|
21
23
|
};
|
|
22
24
|
private _parseNumber;
|
|
23
25
|
parseFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): Promise<{
|