@univerjs/sheets-data-validation-ui 0.4.0-nightly.202410131605 → 0.4.0-nightly.202410141606
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 +42 -20
- package/lib/umd/index.js +2 -2
- package/package.json +14 -13
package/lib/es/index.js
CHANGED
@@ -3,7 +3,7 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
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
5
|
import React, { useState, forwardRef, useRef, createElement, useMemo, useEffect } from "react";
|
6
|
-
import { Inject, LocaleService, Disposable, DataValidationErrorStyle, useDependency, ICommandService, numfmt, CellValueType, UniverInstanceType, toDisposable, IUniverInstanceService, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DisposableCollection, CommandType, BuildTextUtils, DataValidationRenderMode, DataValidationType, IConfigService, UndoCommand, RedoCommand, isUnitRangesEqual,
|
6
|
+
import { Inject, LocaleService, Disposable, DataValidationErrorStyle, useDependency, ICommandService, numfmt, CellValueType, UniverInstanceType, toDisposable, IUniverInstanceService, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DisposableCollection, CommandType, BuildTextUtils, DataValidationRenderMode, DataValidationType, IConfigService, UndoCommand, RedoCommand, isUnitRangesEqual, debounce, shallowEqual, Injector, DataValidationStatus, ObjectMatrix, Range, Rectangle, queryObjectMatrix, Optional, RxDisposable, InterceptorEffectEnum, sequenceExecute, createInternalEditorID, isFormulaString, Tools, ThemeService, VerticalAlign, HorizontalAlign, DEFAULT_STYLES, WrapStrategy, DocumentDataModel, DEFAULT_EMPTY_DOCUMENT_VALUE, BooleanNumber, Plugin } from "@univerjs/core";
|
7
7
|
import { Button, DatePanel, RectPopup, Scrollbar, FormLayout, RadioGroup, Radio, Checkbox, Input, Select, DraggableList } from "@univerjs/design";
|
8
8
|
import { SetRangeValuesCommand, SheetsSelectionsService, getSheetCommandTarget, WorkbookEditablePermission, RangeProtectionPermissionEditPoint, WorksheetEditPermission, checkRangesEditablePermission, WorksheetSetCellStylePermission, SheetInterceptorService, INTERCEPTOR_POINT, InterceptCellContentPriority } from "@univerjs/sheets";
|
9
9
|
import { SheetDataValidationModel, getCellValueOrigin, getDataValidationCellValue, deserializeListOptions, serializeListOptions, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand, RemoveSheetDataValidationCommand, UpdateSheetDataValidationOptionsCommand, createDefaultNewRule, AddSheetDataValidationCommand, RemoveSheetAllDataValidationCommand, DATA_VALIDATION_PLUGIN_NAME, getDataValidationDiffMutations, DataValidationFormulaController, DataValidationFormulaService, getFormulaResult, transformCheckboxValue, CHECKBOX_FORMULA_1, CHECKBOX_FORMULA_2 } from "@univerjs/sheets-data-validation";
|
@@ -14,8 +14,9 @@ import { IDialogService, ISidebarService, useObservable, ComponentManager, IZenZ
|
|
14
14
|
import { RichTextEditingMutation } from "@univerjs/docs";
|
15
15
|
import { IRenderManagerService, DeviceInputEventType, fixLineWidthByScale, Transform, Checkbox as Checkbox$1, FontCache, Shape, Rect, getFontStyleString, getDocsSkeletonPageSize, DocumentViewModel, DocumentSkeleton, Documents } from "@univerjs/engine-render";
|
16
16
|
import { filter, BehaviorSubject, distinctUntilChanged, Subject, debounceTime, bufferTime } from "rxjs";
|
17
|
-
import {
|
18
|
-
import {
|
17
|
+
import { deserializeRangeWithSheet, serializeRange } from "@univerjs/engine-formula";
|
18
|
+
import { RangeSelector } from "@univerjs/sheets-formula-ui";
|
19
|
+
import { TextEditor } from "@univerjs/docs-ui";
|
19
20
|
var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
20
21
|
function getDefaultExportFromCjs(x) {
|
21
22
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x.default : x;
|
@@ -692,7 +693,11 @@ let DataValidationPanelService = (_a2 = class extends Disposable {
|
|
692
693
|
this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(filter((sheet) => !sheet)).subscribe(() => {
|
693
694
|
this.close();
|
694
695
|
})
|
695
|
-
)
|
696
|
+
), this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe((info) => {
|
697
|
+
info.id === DATA_VALIDATION_PANEL && (info.visible || setTimeout(() => {
|
698
|
+
this._sidebarService.sidebarOptions$.next({ visible: !1 });
|
699
|
+
}));
|
700
|
+
}));
|
696
701
|
}
|
697
702
|
get activeRule() {
|
698
703
|
return this._activeRule;
|
@@ -1098,8 +1103,13 @@ const dataValidationDetail = "univer-data-validation-detail", dataValidationDeta
|
|
1098
1103
|
},
|
1099
1104
|
1e3
|
1100
1105
|
), "debounceExecuteFactory");
|
1106
|
+
function getSheetIdByName(univerInstanceService, unitId, name) {
|
1107
|
+
var _a17, _b, _c, _d;
|
1108
|
+
return unitId ? ((_b = (_a17 = univerInstanceService.getUnit(unitId)) == null ? void 0 : _a17.getSheetBySheetName(name)) == null ? void 0 : _b.getSheetId()) || "" : ((_d = (_c = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _c.getSheetBySheetName(name)) == null ? void 0 : _d.getSheetId()) || "";
|
1109
|
+
}
|
1110
|
+
__name(getSheetIdByName, "getSheetIdByName");
|
1101
1111
|
function DataValidationDetail() {
|
1102
|
-
const [key, setKey] = useState(0), dataValidationPanelService = useDependency(DataValidationPanelService), activeRuleInfo = useObservable(dataValidationPanelService.activeRule$, dataValidationPanelService.activeRule), { unitId, subUnitId, rule } = activeRuleInfo || {}, ruleId = rule.uid, validatorService = useDependency(DataValidatorRegistryService), componentManager = useDependency(ComponentManager), commandService = useDependency(ICommandService), dataValidationModel = useDependency(DataValidationModel), localeService = useDependency(LocaleService), [localRule, setLocalRule] = useState(rule), validator = validatorService.getValidatorItem(localRule.type), [showError, setShowError] = useState(!1), validators = validatorService.getValidatorsByScope(DataValidatorRegistryScope.SHEET), [localRanges, setLocalRanges] = useState(() => localRule.ranges.map((i) => ({ unitId: "", sheetId: "", range: i }))), debounceExecute = useMemo(() => debounceExecuteFactory(commandService), [commandService]), sheetSelectionService = useDependency(SheetsSelectionsService);
|
1112
|
+
const [key, setKey] = useState(0), dataValidationPanelService = useDependency(DataValidationPanelService), activeRuleInfo = useObservable(dataValidationPanelService.activeRule$, dataValidationPanelService.activeRule), { unitId, subUnitId, rule } = activeRuleInfo || {}, ruleId = rule.uid, validatorService = useDependency(DataValidatorRegistryService), univerInstanceService = useDependency(IUniverInstanceService), componentManager = useDependency(ComponentManager), commandService = useDependency(ICommandService), dataValidationModel = useDependency(DataValidationModel), localeService = useDependency(LocaleService), [localRule, setLocalRule] = useState(rule), validator = validatorService.getValidatorItem(localRule.type), [showError, setShowError] = useState(!1), validators = validatorService.getValidatorsByScope(DataValidatorRegistryScope.SHEET), [localRanges, setLocalRanges] = useState(() => localRule.ranges.map((i) => ({ unitId: "", sheetId: "", range: i }))), debounceExecute = useMemo(() => debounceExecuteFactory(commandService), [commandService]), rangeSelectorActionsRef = useRef({}), [isFocusRangeSelector, isFocusRangeSelectorSet] = useState(!1), sheetSelectionService = useDependency(SheetsSelectionsService);
|
1103
1113
|
if (useEffect(() => () => {
|
1104
1114
|
const currentSelection = sheetSelectionService.getCurrentLastSelection();
|
1105
1115
|
currentSelection && sheetSelectionService.setSelections([currentSelection]);
|
@@ -1114,7 +1124,18 @@ function DataValidationDetail() {
|
|
1114
1124
|
return null;
|
1115
1125
|
const operators = validator.operators, operatorNames = validator.operatorNames, isTwoFormula = localRule.operator ? TWO_FORMULA_OPERATOR_COUNT.includes(localRule.operator) : !1, handleOk = /* @__PURE__ */ __name(() => {
|
1116
1126
|
localRule.ranges.length && (validator.validatorFormula(localRule, unitId, subUnitId).success ? dataValidationPanelService.setActiveRule(null) : setShowError(!0));
|
1117
|
-
}, "handleOk"), handleUpdateRuleRanges = useEvent((
|
1127
|
+
}, "handleOk"), handleUpdateRuleRanges = useEvent((rangeText) => {
|
1128
|
+
const unitRanges = rangeText.split(",").map(deserializeRangeWithSheet).map((unitRange) => {
|
1129
|
+
const sheetName = unitRange.sheetName;
|
1130
|
+
if (sheetName) {
|
1131
|
+
const sheetId = getSheetIdByName(univerInstanceService, unitRange.unitId, sheetName);
|
1132
|
+
return { ...unitRange, sheetId };
|
1133
|
+
}
|
1134
|
+
return {
|
1135
|
+
...unitRange,
|
1136
|
+
sheetId: ""
|
1137
|
+
};
|
1138
|
+
});
|
1118
1139
|
if (isUnitRangesEqual(unitRanges, localRanges))
|
1119
1140
|
return;
|
1120
1141
|
setLocalRanges(unitRanges);
|
@@ -1194,8 +1215,12 @@ function DataValidationDetail() {
|
|
1194
1215
|
options: newOptions
|
1195
1216
|
}
|
1196
1217
|
));
|
1197
|
-
}, "handleUpdateRuleOptions")
|
1198
|
-
|
1218
|
+
}, "handleUpdateRuleOptions"), handlePanelClick = /* @__PURE__ */ __name((e) => {
|
1219
|
+
var _a17;
|
1220
|
+
const handleOutClick = (_a17 = rangeSelectorActionsRef.current) == null ? void 0 : _a17.handleOutClick;
|
1221
|
+
handleOutClick && handleOutClick(e, isFocusRangeSelectorSet);
|
1222
|
+
}, "handlePanelClick");
|
1223
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$3.dataValidationDetail, onClick: handlePanelClick, children: [
|
1199
1224
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1200
1225
|
FormLayout,
|
1201
1226
|
{
|
@@ -1204,16 +1229,13 @@ function DataValidationDetail() {
|
|
1204
1229
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
1205
1230
|
RangeSelector,
|
1206
1231
|
{
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
}, "onChange")
|
1215
|
-
},
|
1216
|
-
key
|
1232
|
+
unitId,
|
1233
|
+
subUnitId,
|
1234
|
+
initValue: rangeStr,
|
1235
|
+
onChange: handleUpdateRuleRanges,
|
1236
|
+
isFocus: isFocusRangeSelector,
|
1237
|
+
actions: rangeSelectorActionsRef.current
|
1238
|
+
}
|
1217
1239
|
)
|
1218
1240
|
}
|
1219
1241
|
),
|
@@ -1414,7 +1436,7 @@ const DataValidationPanel = /* @__PURE__ */ __name(() => {
|
|
1414
1436
|
}, "DataValidationPanel"), LIST_DROPDOWN_KEY = "data-validation.list.dropdown", DATE_DROPDOWN_KEY = "data-validation.date.dropdown", AddSheetDataValidationAndOpenCommand = {
|
1415
1437
|
type: CommandType.COMMAND,
|
1416
1438
|
id: "data-validation.command.addRuleAndOpen",
|
1417
|
-
|
1439
|
+
handler(accessor) {
|
1418
1440
|
const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
|
1419
1441
|
if (!target) return !1;
|
1420
1442
|
const { workbook, worksheet } = target, rule = createDefaultNewRule(accessor), commandService = accessor.get(ICommandService), unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), addParams = {
|
@@ -1422,7 +1444,7 @@ const DataValidationPanel = /* @__PURE__ */ __name(() => {
|
|
1422
1444
|
unitId,
|
1423
1445
|
subUnitId
|
1424
1446
|
};
|
1425
|
-
return
|
1447
|
+
return commandService.syncExecuteCommand(AddSheetDataValidationCommand.id, addParams) ? (commandService.syncExecuteCommand(OpenValidationPanelOperation.id, {
|
1426
1448
|
ruleId: rule.uid,
|
1427
1449
|
isAdd: !0
|
1428
1450
|
}), !0) : !1;
|