@univerjs/sheets-data-validation-ui 0.4.1 → 0.4.2-nightly.202410291606

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/es/index.js CHANGED
@@ -5,14 +5,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "sym
5
5
  import React, { useState, forwardRef, useRef, createElement, useMemo, useEffect } from "react";
6
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, bufferDebounceTime, 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
+ import { DeviceInputEventType, IRenderManagerService, fixLineWidthByScale, Transform, Checkbox as Checkbox$1, FontCache, Shape, Rect, getFontStyleString, getDocsSkeletonPageSize, DocumentViewModel, DocumentSkeleton, Documents } from "@univerjs/engine-render";
8
9
  import { SetRangeValuesCommand, SheetsSelectionsService, getSheetCommandTarget, WorkbookEditablePermission, RangeProtectionPermissionEditPoint, WorksheetEditPermission, checkRangesEditablePermission, WorksheetSetCellStylePermission, SheetInterceptorService, INTERCEPTOR_POINT, InterceptCellContentPriority } from "@univerjs/sheets";
9
- import { SheetDataValidationModel, getCellValueOrigin, getDataValidationCellValue, deserializeListOptions, serializeListOptions, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand, RemoveSheetDataValidationCommand, UpdateSheetDataValidationOptionsCommand, createDefaultNewRule, AddSheetDataValidationCommand, RemoveSheetAllDataValidationCommand, DATA_VALIDATION_PLUGIN_NAME, getDataValidationDiffMutations, DataValidationCacheService, DataValidationFormulaController, DataValidationFormulaService, getFormulaResult, transformCheckboxValue, CHECKBOX_FORMULA_1, CHECKBOX_FORMULA_2 } from "@univerjs/sheets-data-validation";
10
+ import { SheetDataValidationModel, getCellValueOrigin, getDataValidationCellValue, deserializeListOptions, serializeListOptions, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand, RemoveSheetDataValidationCommand, UpdateSheetDataValidationOptionsCommand, createDefaultNewRule, AddSheetDataValidationCommand, RemoveSheetAllDataValidationCommand, DATA_VALIDATION_PLUGIN_NAME, getDataValidationDiffMutations, DataValidationCacheService, DataValidationFormulaController, DataValidationFormulaService, getFormulaResult, isLegalFormulaResult, transformCheckboxValue, CHECKBOX_FORMULA_1, CHECKBOX_FORMULA_2 } from "@univerjs/sheets-data-validation";
10
11
  import { getPatternType } from "@univerjs/sheets-numfmt";
12
+ import { IEditorBridgeService, SetCellEditVisibleOperation, SheetCanvasPopManagerService, SheetPermissionInterceptorBaseController, IMarkSelectionService, HoverManagerService, CellAlertManagerService, CellAlertType, IAutoFillService, APPLY_TYPE, virtualizeDiscreteRanges, getAutoFillRepeatRange, COPY_TYPE, rangeToDiscreteRange, PREDEFINED_HOOK_NAME, getRepeatRange, ISheetClipboardService, getCurrentRangeDisable$, AutoHeightController, SheetSkeletonManagerService } from "@univerjs/sheets-ui";
13
+ import { IDialogService, KeyCode, ISidebarService, useObservable, ComponentManager, IZenZoneService, useEvent, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, IMenuManagerService } from "@univerjs/ui";
11
14
  import { DataValidatorRegistryService, DataValidationModel, DataValidatorRegistryScope, TWO_FORMULA_OPERATOR_COUNT, getRuleOptions, getRuleSetting } from "@univerjs/data-validation";
12
- import { IEditorBridgeService, SheetCanvasPopManagerService, SheetPermissionInterceptorBaseController, IMarkSelectionService, HoverManagerService, CellAlertManagerService, CellAlertType, IAutoFillService, APPLY_TYPE, virtualizeDiscreteRanges, getAutoFillRepeatRange, COPY_TYPE, rangeToDiscreteRange, PREDEFINED_HOOK_NAME, getRepeatRange, ISheetClipboardService, getCurrentRangeDisable$, AutoHeightController, SheetSkeletonManagerService } from "@univerjs/sheets-ui";
13
- import { IDialogService, ISidebarService, useObservable, ComponentManager, IZenZoneService, KeyCode, useEvent, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, IMenuManagerService } from "@univerjs/ui";
14
15
  import { RichTextEditingMutation } from "@univerjs/docs";
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
17
  import { deserializeRangeWithSheet, serializeRange } from "@univerjs/engine-formula";
18
18
  import { RangeSelector } from "@univerjs/sheets-formula-ui";
@@ -529,7 +529,12 @@ function DateDropdown(props) {
529
529
  workbook,
530
530
  interceptValue: dateStr.replace("Z", "").replace("T", " "),
531
531
  t: CellValueType.NUMBER
532
- }, rule) ? (commandService.executeCommand(SetRangeValuesCommand.id, {
532
+ }, rule) ? (hideFn(), await commandService.executeCommand(SetCellEditVisibleOperation.id, {
533
+ visible: !1,
534
+ eventType: DeviceInputEventType.Keyboard,
535
+ unitId,
536
+ keycode: KeyCode.ESC
537
+ }), await commandService.executeCommand(SetRangeValuesCommand.id, {
533
538
  unitId,
534
539
  subUnitId,
535
540
  range: {
@@ -550,7 +555,7 @@ function DateDropdown(props) {
550
555
  }
551
556
  }
552
557
  }
553
- }), hideFn()) : rejectInputController.showReject(validator.getRuleFinalError(rule));
558
+ })) : rejectInputController.showReject(validator.getRuleFinalError(rule));
554
559
  }, "handleSave");
555
560
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$6.dvDateDropdown, children: [
556
561
  /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -1006,7 +1011,7 @@ function ListDropDown(props) {
1006
1011
  title: multiple ? localeService.t("dataValidation.listMultiple.dropdown") : localeService.t("dataValidation.list.dropdown"),
1007
1012
  value,
1008
1013
  multiple,
1009
- onChange: /* @__PURE__ */ __name((newValue) => {
1014
+ onChange: /* @__PURE__ */ __name(async (newValue) => {
1010
1015
  const str = serializeListOptions(newValue), params = {
1011
1016
  unitId,
1012
1017
  subUnitId,
@@ -1028,7 +1033,12 @@ function ListDropDown(props) {
1028
1033
  keycode: KeyCode.ESC,
1029
1034
  eventType: DeviceInputEventType.Keyboard,
1030
1035
  unitId
1031
- }), commandService.executeCommand(SetRangeValuesCommand.id, params), setLocalValue(str), multiple || hideFn();
1036
+ }), setLocalValue(str), multiple || hideFn(), editorBridgeService.isVisible().visible && await commandService.executeCommand(SetCellEditVisibleOperation.id, {
1037
+ visible: !1,
1038
+ eventType: DeviceInputEventType.Keyboard,
1039
+ unitId,
1040
+ keycode: KeyCode.ESC
1041
+ }), commandService.executeCommand(SetRangeValuesCommand.id, params);
1032
1042
  }, "onChange"),
1033
1043
  options,
1034
1044
  onEdit: handleEdit,
@@ -1109,7 +1119,8 @@ function getSheetIdByName(univerInstanceService, unitId, name) {
1109
1119
  }
1110
1120
  __name(getSheetIdByName, "getSheetIdByName");
1111
1121
  function DataValidationDetail() {
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);
1122
+ var _a18;
1123
+ 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]), [isRangeError, setIsRangeError] = useState(!1), rangeSelectorActionsRef = useRef({}), [isFocusRangeSelector, isFocusRangeSelectorSet] = useState(!1), sheetSelectionService = useDependency(SheetsSelectionsService);
1113
1124
  if (useEffect(() => () => {
1114
1125
  const currentSelection = sheetSelectionService.getCurrentLastSelection();
1115
1126
  currentSelection && sheetSelectionService.setSelections([currentSelection]);
@@ -1123,7 +1134,7 @@ function DataValidationDetail() {
1123
1134
  }, [commandService, dataValidationModel, ruleId, subUnitId, unitId]), !validator)
1124
1135
  return null;
1125
1136
  const operators = validator.operators, operatorNames = validator.operatorNames, isTwoFormula = localRule.operator ? TWO_FORMULA_OPERATOR_COUNT.includes(localRule.operator) : !1, handleOk = /* @__PURE__ */ __name(() => {
1126
- localRule.ranges.length && (validator.validatorFormula(localRule, unitId, subUnitId).success ? dataValidationPanelService.setActiveRule(null) : setShowError(!0));
1137
+ !localRule.ranges.length || isRangeError || (validator.validatorFormula(localRule, unitId, subUnitId).success ? dataValidationPanelService.setActiveRule(null) : setShowError(!0));
1127
1138
  }, "handleOk"), handleUpdateRuleRanges = useEvent((rangeText) => {
1128
1139
  const unitRanges = rangeText.split(",").map(deserializeRangeWithSheet).map((unitRange) => {
1129
1140
  const sheetName = unitRange.sheetName;
@@ -1216,8 +1227,8 @@ function DataValidationDetail() {
1216
1227
  }
1217
1228
  ));
1218
1229
  }, "handleUpdateRuleOptions"), handlePanelClick = /* @__PURE__ */ __name((e) => {
1219
- var _a18;
1220
- const handleOutClick = (_a18 = rangeSelectorActionsRef.current) == null ? void 0 : _a18.handleOutClick;
1230
+ var _a19;
1231
+ const handleOutClick = (_a19 = rangeSelectorActionsRef.current) == null ? void 0 : _a19.handleOutClick;
1221
1232
  handleOutClick && handleOutClick(e, isFocusRangeSelectorSet);
1222
1233
  }, "handlePanelClick");
1223
1234
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$3.dataValidationDetail, onClick: handlePanelClick, children: [
@@ -1225,7 +1236,7 @@ function DataValidationDetail() {
1225
1236
  FormLayout,
1226
1237
  {
1227
1238
  label: localeService.t("dataValidation.panel.range"),
1228
- error: localRule.ranges.length ? "" : localeService.t("dataValidation.panel.rangeError"),
1239
+ error: !localRule.ranges.length || isRangeError ? localeService.t("dataValidation.panel.rangeError") : "",
1229
1240
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1230
1241
  RangeSelector,
1231
1242
  {
@@ -1234,7 +1245,8 @@ function DataValidationDetail() {
1234
1245
  initValue: rangeStr,
1235
1246
  onChange: handleUpdateRuleRanges,
1236
1247
  isFocus: isFocusRangeSelector,
1237
- actions: rangeSelectorActionsRef.current
1248
+ actions: rangeSelectorActionsRef.current,
1249
+ onVerify: /* @__PURE__ */ __name((isValid) => setIsRangeError(!isValid), "onVerify")
1238
1250
  }
1239
1251
  )
1240
1252
  }
@@ -1290,6 +1302,20 @@ function DataValidationDetail() {
1290
1302
  },
1291
1303
  key + localRule.type
1292
1304
  ) : null,
1305
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1306
+ Checkbox,
1307
+ {
1308
+ checked: (_a18 = localRule.allowBlank) != null ? _a18 : !0,
1309
+ onChange: /* @__PURE__ */ __name(() => {
1310
+ var _a19;
1311
+ return handleUpdateRuleSetting({
1312
+ ...baseRule,
1313
+ allowBlank: !((_a19 = localRule.allowBlank) == null || _a19)
1314
+ });
1315
+ }, "onChange"),
1316
+ children: localeService.t("dataValidation.panel.allowBlank")
1317
+ }
1318
+ ) }),
1293
1319
  /* @__PURE__ */ jsxRuntimeExports.jsx(DataValidationOptions, { value: options, onChange: handleUpdateRuleOptions, extraComponent: validator.optionsInput }),
1294
1320
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$3.dataValidationDetailButtons, children: [
1295
1321
  /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: styles$3.dataValidationDetailButton, onClick: handleDelete, children: localeService.t("dataValidation.panel.removeRule") }),
@@ -1675,7 +1701,8 @@ let DataValidationCopyPasteController = (_a6 = class extends Disposable {
1675
1701
  copyInfo.subUnitId,
1676
1702
  ruleMatrix.diffWithAddition(this._sheetDataValidationModel.getRules(copyInfo.unitId, copyInfo.subUnitId), additionRules.values()),
1677
1703
  this._injector,
1678
- "patched"
1704
+ "patched",
1705
+ !1
1679
1706
  );
1680
1707
  return {
1681
1708
  redos: redoMutations,
@@ -1705,7 +1732,8 @@ let DataValidationCopyPasteController = (_a6 = class extends Disposable {
1705
1732
  subUnitId,
1706
1733
  ruleMatrix.diff(this._sheetDataValidationModel.getRules(unitId, subUnitId)),
1707
1734
  this._injector,
1708
- "patched"
1735
+ "patched",
1736
+ !1
1709
1737
  );
1710
1738
  return {
1711
1739
  redos: redoMutations,
@@ -1941,6 +1969,32 @@ let SheetsDataValidationRenderController = (_a8 = class extends RxDisposable {
1941
1969
  };
1942
1970
  return (_f2 = (_e2 = validator == null ? void 0 : validator.canvasRender) == null ? void 0 : _e2.calcCellAutoHeight) == null ? void 0 : _f2.call(_e2, info);
1943
1971
  }, "interceptorAutoHeight"),
1972
+ interceptorAutoWidth: /* @__PURE__ */ __name(() => {
1973
+ var _a19, _b2, _c2, _d2, _e2, _f2;
1974
+ const skeleton = (_b2 = (_a19 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a19.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId)) == null ? void 0 : _b2.skeleton;
1975
+ if (!skeleton)
1976
+ return;
1977
+ const mergeCell = skeleton.worksheet.getMergedCell(row, col), info = {
1978
+ data: {
1979
+ ...cell,
1980
+ dataValidation: {
1981
+ ruleId,
1982
+ validStatus,
1983
+ rule,
1984
+ validator
1985
+ }
1986
+ },
1987
+ style: skeleton.getsStyles().getStyleByCell(cell),
1988
+ primaryWithCoord: skeleton.getCellByIndex((_c2 = mergeCell == null ? void 0 : mergeCell.startRow) != null ? _c2 : row, (_d2 = mergeCell == null ? void 0 : mergeCell.startColumn) != null ? _d2 : col),
1989
+ unitId,
1990
+ subUnitId,
1991
+ row,
1992
+ col,
1993
+ workbook,
1994
+ worksheet
1995
+ };
1996
+ return (_f2 = (_e2 = validator == null ? void 0 : validator.canvasRender) == null ? void 0 : _e2.calcCellAutoWidth) == null ? void 0 : _f2.call(_e2, info);
1997
+ }, "interceptorAutoWidth"),
1944
1998
  coverable: ((_f = cell == null ? void 0 : cell.coverable) != null ? _f : !0) && !(rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE)
1945
1999
  });
1946
2000
  }, "handler")
@@ -2598,12 +2652,18 @@ let CheckboxRender = (_a11 = class {
2598
2652
  const { style } = info;
2599
2653
  return ((_a18 = style == null ? void 0 : style.fs) != null ? _a18 : 10) * 1.6;
2600
2654
  }
2655
+ calcCellAutoWidth(info) {
2656
+ var _a18;
2657
+ const { style } = info;
2658
+ return ((_a18 = style == null ? void 0 : style.fs) != null ? _a18 : 10) * 1.6;
2659
+ }
2601
2660
  async _parseFormula(rule, unitId, subUnitId) {
2602
- var _a18, _b;
2603
- const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid);
2661
+ var _a18, _b, _c;
2662
+ const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), formulaResult1 = getFormulaResult((_a18 = results == null ? void 0 : results[0]) == null ? void 0 : _a18.result), formulaResult2 = getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result), isFormulaValid = isLegalFormulaResult(String(formulaResult1)) && isLegalFormulaResult(String(formulaResult2));
2604
2663
  return {
2605
- formula1: isFormulaString(formula1) ? getFormulaResult((_a18 = results == null ? void 0 : results[0]) == null ? void 0 : _a18.result) : formula1,
2606
- formula2: isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2
2664
+ formula1: isFormulaString(formula1) ? getFormulaResult((_c = results == null ? void 0 : results[0]) == null ? void 0 : _c.result) : formula1,
2665
+ formula2: isFormulaString(formula2) ? formulaResult2 : formula2,
2666
+ isFormulaValid
2607
2667
  };
2608
2668
  }
2609
2669
  drawWith(ctx, info) {
@@ -2737,7 +2797,7 @@ function getDropdownItemSize(text, fontStyle) {
2737
2797
  }
2738
2798
  __name(getDropdownItemSize, "getDropdownItemSize");
2739
2799
  function layoutDropdowns(items, fontStyle, cellWidth, cellHeight) {
2740
- const contentWidth = cellWidth - ICON_PLACE$1 - CELL_PADDING_H, contentHeight = cellHeight - CELL_PADDING_V * 2, textLayout = items.map((item) => ({
2800
+ const cellPaddingH = ICON_PLACE$1 + CELL_PADDING_H * 2, widthAvailableForContent = cellWidth - cellPaddingH, heightAvailableForContent = cellHeight - CELL_PADDING_V * 2, textLayout = items.map((item) => ({
2741
2801
  layout: getDropdownItemSize(item, fontStyle),
2742
2802
  text: item
2743
2803
  }));
@@ -2745,7 +2805,7 @@ function layoutDropdowns(items, fontStyle, cellWidth, cellHeight) {
2745
2805
  const lines = [];
2746
2806
  textLayout.forEach((item) => {
2747
2807
  const { layout } = item, { width, height } = layout;
2748
- !currentLine || currentLine.width + width + MARGIN_H$1 > contentWidth ? (currentLine = {
2808
+ !currentLine || currentLine.width + width + MARGIN_H$1 > widthAvailableForContent ? (currentLine = {
2749
2809
  width,
2750
2810
  height,
2751
2811
  items: [{
@@ -2757,15 +2817,16 @@ function layoutDropdowns(items, fontStyle, cellWidth, cellHeight) {
2757
2817
  left: currentLine.width + MARGIN_H$1
2758
2818
  }), currentLine.width = currentLine.width + width + MARGIN_H$1);
2759
2819
  });
2760
- let totalHeight = 0;
2820
+ let totalHeight = 0, maxLineWidth = 0;
2761
2821
  return lines.forEach((line, index) => {
2762
- index === lines.length - 1 ? totalHeight += line.height : totalHeight += line.height + MARGIN_V$1;
2822
+ maxLineWidth = Math.max(maxLineWidth, line.width), index === lines.length - 1 ? totalHeight += line.height : totalHeight += line.height + MARGIN_V$1;
2763
2823
  }), {
2764
2824
  lines,
2765
2825
  totalHeight,
2766
- contentWidth,
2767
- contentHeight,
2768
- cellAutoHeight: totalHeight + CELL_PADDING_V * 2
2826
+ contentWidth: widthAvailableForContent,
2827
+ contentHeight: heightAvailableForContent,
2828
+ cellAutoHeight: totalHeight + CELL_PADDING_V * 2,
2829
+ calcAutoWidth: maxLineWidth + cellPaddingH
2769
2830
  };
2770
2831
  }
2771
2832
  __name(layoutDropdowns, "layoutDropdowns");
@@ -2877,6 +2938,19 @@ let DropdownMultipleWidget = (_a13 = class {
2877
2938
  const cellWidth = cellBounding.endX - cellBounding.startX, cellHeight = cellBounding.endY - cellBounding.startY, cellValue = (_a18 = getCellValueOrigin(data)) != null ? _a18 : "", { validator: _validator } = validation, items = _validator.parseCellValue(cellValue), fontStyle = getFontStyleString(style != null ? style : void 0);
2878
2939
  return layoutDropdowns(items, fontStyle, cellWidth, cellHeight).cellAutoHeight;
2879
2940
  }
2941
+ calcCellAutoWidth(info) {
2942
+ var _a18;
2943
+ const { primaryWithCoord, style, data } = info, fontRenderExtension = data.fontRenderExtension, { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = fontRenderExtension || {}, _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, cellBounding = {
2944
+ startX: _cellBounding.startX + leftOffset,
2945
+ endX: _cellBounding.endX - rightOffset,
2946
+ startY: _cellBounding.startY + topOffset,
2947
+ endY: _cellBounding.endY - downOffset
2948
+ }, validation = data.dataValidation;
2949
+ if (!validation)
2950
+ return;
2951
+ const cellWidth = cellBounding.endX - cellBounding.startX, cellHeight = cellBounding.endY - cellBounding.startY, cellValue = (_a18 = getCellValueOrigin(data)) != null ? _a18 : "", { validator: _validator } = validation, items = _validator.parseCellValue(cellValue), fontStyle = getFontStyleString(style != null ? style : void 0);
2952
+ return layoutDropdowns(items, fontStyle, cellWidth, cellHeight).calcAutoWidth;
2953
+ }
2880
2954
  isHit(position, info) {
2881
2955
  const { primaryWithCoord } = info, cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, { endX } = cellBounding, { x } = position;
2882
2956
  return x >= endX - ICON_PLACE$1 && x <= endX;
@@ -2901,6 +2975,7 @@ const _ListMultipleValidatorView = class _ListMultipleValidatorView extends Base
2901
2975
  super(...arguments);
2902
2976
  __publicField(this, "id", DataValidationType.LIST_MULTIPLE);
2903
2977
  __publicField(this, "canvasRender", this.injector.createInstance(DropdownMultipleWidget));
2978
+ __publicField(this, "dropdown", LIST_DROPDOWN_KEY);
2904
2979
  }
2905
2980
  };
2906
2981
  __name(_ListMultipleValidatorView, "ListMultipleValidatorView");
@@ -2910,7 +2985,7 @@ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPrope
2910
2985
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2911
2986
  return kind && result && __defProp$3(target, key, result), result;
2912
2987
  }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3");
2913
- const PADDING_H = 4, ICON_SIZE = 4, ICON_PLACE = 14, MARGIN_H = 6, MARGIN_V = 4, DROP_DOWN_ICON_COLOR = "#565656", downPath = new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");
2988
+ const PADDING_H = 4, ICON_SIZE = 4, ICON_PLACE = 14, MARGIN_H = 6, MARGIN_V = 4, RADIUS_BG = 8, DROP_DOWN_ICON_COLOR = "#565656", downPath = new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");
2914
2989
  function convertToDocumentData(text, style) {
2915
2990
  const contentLength = text.length;
2916
2991
  return {
@@ -3074,7 +3149,7 @@ let DropdownWidget = (_a14 = class {
3074
3149
  width: rectWidth,
3075
3150
  height: rectHeight,
3076
3151
  fill: (activeItem == null ? void 0 : activeItem.color) || DROP_DOWN_DEFAULT_COLOR,
3077
- radius: 8
3152
+ radius: RADIUS_BG
3078
3153
  }), ctx.save(), ctx.translateWithPrecision(PADDING_H, 0), ctx.beginPath(), ctx.rect(0, 0, realWidth, fontHeight), ctx.clip(), ctx.translateWithPrecision(paddingLeft, 0), documents.render(ctx), ctx.restore(), ctx.translateWithPrecision(realWidth + PADDING_H + 4, (fontHeight - ICON_SIZE) / 2), ctx.fillStyle = DROP_DOWN_ICON_COLOR, ctx.fill(downPath), ctx.restore(), map.set(key, {
3079
3154
  left: cellBounding.startX + MARGIN_H + skeleton.rowHeaderWidth,
3080
3155
  top: cellBounding.startY + paddingTop + skeleton.columnHeaderHeight,
@@ -3110,6 +3185,33 @@ let DropdownWidget = (_a14 = class {
3110
3185
  return fontHeight + MARGIN_V * 2;
3111
3186
  }
3112
3187
  }
3188
+ calcCellAutoWidth(info) {
3189
+ var _a18;
3190
+ const { primaryWithCoord, style, data } = info, cellRange = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, fontRenderExtension = data.fontRenderExtension, { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = fontRenderExtension || {}, rule = (_a18 = data.dataValidation) == null ? void 0 : _a18.rule;
3191
+ if (!rule || rule.renderMode === DataValidationRenderMode.TEXT) return;
3192
+ const cellBounding = {
3193
+ startX: cellRange.startX + leftOffset,
3194
+ endX: cellRange.endX - rightOffset,
3195
+ startY: cellRange.startY + topOffset,
3196
+ endY: cellRange.endY - downOffset
3197
+ }, cellWidth = cellBounding.endX - cellBounding.startX, value = getCellValueOrigin(data), valueStr = `${value != null ? value : ""}`;
3198
+ let { tb, pd } = style || {};
3199
+ const { l: l2 = DEFAULT_STYLES.pd.l, r: r2 = DEFAULT_STYLES.pd.r } = pd != null ? pd : {};
3200
+ tb = tb != null ? tb : WrapStrategy.WRAP;
3201
+ let paddingAll = MARGIN_H * 2 + ICON_PLACE;
3202
+ switch (rule.renderMode) {
3203
+ case DataValidationRenderMode.ARROW:
3204
+ paddingAll = ICON_PLACE + MARGIN_H * 2 + r2 + l2;
3205
+ break;
3206
+ case DataValidationRenderMode.CUSTOM:
3207
+ paddingAll = ICON_PLACE + MARGIN_H * 2 + PADDING_H * 2 + r2 + l2 + RADIUS_BG / 2 + 1;
3208
+ break;
3209
+ default:
3210
+ paddingAll = ICON_PLACE + MARGIN_H * 2 + PADDING_H * 2 + r2 + l2 + RADIUS_BG / 2 + 1;
3211
+ }
3212
+ const widthForTextLayout = cellWidth - paddingAll, { documentSkeleton, docModel } = createDocuments(valueStr, this._localeService, style);
3213
+ return tb === WrapStrategy.WRAP && docModel.updateDocumentDataPageSize(Math.max(widthForTextLayout, 1)), documentSkeleton.calculate(), documentSkeleton.getActualSize(), getDocsSkeletonPageSize(documentSkeleton).width + paddingAll;
3214
+ }
3113
3215
  isHit(position, info) {
3114
3216
  const { data, subUnitId, row, col } = info, dropdownInfo = this._ensureMap(subUnitId).get(this._generateKey(row, col)), validation = data.dataValidation;
3115
3217
  if (!validation || !dropdownInfo || validation.rule.renderMode === DataValidationRenderMode.TEXT)
@@ -34,7 +34,8 @@
34
34
  "rejectInput": "Reject input",
35
35
  "messageInfo": "Helper message",
36
36
  "showInfo": "Show help text for a selected cell",
37
- "rangeError": "Ranges are not legal"
37
+ "rangeError": "Ranges are not legal",
38
+ "allowBlank": "Allow blank values"
38
39
  },
39
40
  "operators": {
40
41
  "between": "between",
@@ -66,6 +67,10 @@
66
67
  "notEqual": "Value must be not equal to {FORMULA1}",
67
68
  "notBetween": "Value must be not between {FORMULA1} and {FORMULA2}"
68
69
  },
70
+ "any": {
71
+ "title": "Any value",
72
+ "error": "The content of this cell violates the validation rule"
73
+ },
69
74
  "date": {
70
75
  "title": "Date",
71
76
  "operators": {
@@ -145,7 +150,8 @@
145
150
  "custom": {
146
151
  "title": "Custom formula",
147
152
  "error": "This cell's contents violate its validation rule",
148
- "validFail": "Please input a valid formula"
153
+ "validFail": "Please input a valid formula",
154
+ "ruleName": "Custom formula is {FORMULA1}"
149
155
  },
150
156
  "alert": {
151
157
  "title": "Error",
@@ -34,7 +34,8 @@
34
34
  "rejectInput": "رد ورودی",
35
35
  "messageInfo": "پیام راهنما",
36
36
  "showInfo": "نمایش متن راهنما برای یک سلول انتخاب شده",
37
- "rangeError": "محدوده‌ها نامعتبر هستند"
37
+ "rangeError": "محدوده‌ها نامعتبر هستند",
38
+ "allowBlank": "رد سلول خالی"
38
39
  },
39
40
  "operators": {
40
41
  "between": "بین",
@@ -66,6 +67,10 @@
66
67
  "notEqual": "مقدار باید برابر نیست با {FORMULA1}",
67
68
  "notBetween": "مقدار باید بین {FORMULA1} و {FORMULA2} نباشد"
68
69
  },
70
+ "any": {
71
+ "title": "هر مقدار",
72
+ "error": "محتوای این سلول نقض قانون اعتبارسنجی است"
73
+ },
69
74
  "date": {
70
75
  "title": "تاریخ",
71
76
  "operators": {
@@ -143,9 +148,10 @@
143
148
  "unchecked": "مقدار انتخاب نشده"
144
149
  },
145
150
  "custom": {
146
- "title": "فرمول سفارشی",
151
+ "title": "فرمول سفارشی ",
147
152
  "error": "محتوای این سلول با قانون اعتبارسنجی آن نقض می‌شود",
148
- "validFail": "لطفا یک فرمول معتبر وارد کنید"
153
+ "validFail": "لطفا یک فرمول معتبر وارد کنید",
154
+ "ruleName": "فرمول سفارشی {FORMULA1}"
149
155
  },
150
156
  "alert": {
151
157
  "title": "خطا",
@@ -34,7 +34,8 @@
34
34
  "showWarning": "Показать предупреждение",
35
35
  "rejectInput": "Отклонить ввод",
36
36
  "messageInfo": "Сообщение помощи",
37
- "showInfo": "Показать текст помощи для выбранной ячейки"
37
+ "showInfo": "Показать текст помощи для выбранной ячейки",
38
+ "allowBlank": "Игнорировать пустые значения"
38
39
  },
39
40
  "operators": {
40
41
  "between": "между",
@@ -66,6 +67,10 @@
66
67
  "notEqual": "Значение должно быть не равно {FORMULA1}",
67
68
  "notBetween": "Значение должно быть не между {FORMULA1} и {FORMULA2}"
68
69
  },
70
+ "any": {
71
+ "title": "Любое значение",
72
+ "error": "Содержимое этой ячейки нарушает правило проверки"
73
+ },
69
74
  "date": {
70
75
  "title": "Дата",
71
76
  "operators": {
@@ -145,7 +150,8 @@
145
150
  "custom": {
146
151
  "title": "Пользовательская формула",
147
152
  "error": "Содержимое этой ячейки нарушает правило проверки",
148
- "validFail": "Пожалуйста, введите допустимую формулу"
153
+ "validFail": "Пожалуйста, введите допустимую формулу",
154
+ "ruleName": "Пользовательская формула {FORMULA1}"
149
155
  },
150
156
  "alert": {
151
157
  "title": "Ошибка",
@@ -34,7 +34,8 @@
34
34
  "showWarning": "Hiển thị cảnh báo",
35
35
  "rejectInput": "Từ chối đầu vào",
36
36
  "messageInfo": "Thông báo",
37
- "showInfo": "Hiển thị thông báo cho ô đã chọn"
37
+ "showInfo": "Hiển thị thông báo cho ô đã chọn",
38
+ "allowBlank": "Bỏ qua giá trị rỗng"
38
39
  },
39
40
  "operators": {
40
41
  "between": "Giữa",
@@ -66,6 +67,10 @@
66
67
  "notEqual": "Giá trị phải không bằng {FORMULA1}",
67
68
  "notBetween": "Giá trị phải không nằm giữa {FORMULA1} và {FORMULA2}"
68
69
  },
70
+ "any": {
71
+ "title": "Bất kỳ giá trị",
72
+ "error": "Nội dung của ô này vi phạm quy tắc xác thực"
73
+ },
69
74
  "date": {
70
75
  "title": "Ngày",
71
76
  "operators": {
@@ -145,7 +150,8 @@
145
150
  "custom": {
146
151
  "title": "Công thức tùy chỉnh",
147
152
  "error": "Nội dung của ô này vi phạm quy tắc xác thực",
148
- "validFail": "Vui lòng nhập một công thức hợp lệ"
153
+ "validFail": "Vui lòng nhập một công thức hợp lệ",
154
+ "ruleName": "Công thức tùy chỉnh {FORMULA1}"
149
155
  },
150
156
  "alert": {
151
157
  "title": "Thông báo",
@@ -34,7 +34,8 @@
34
34
  "showWarning": "显示警告",
35
35
  "rejectInput": "拒绝输入",
36
36
  "messageInfo": "文字提示",
37
- "showInfo": "显示所选单元格的提示文字"
37
+ "showInfo": "显示所选单元格的提示文字",
38
+ "allowBlank": "忽略空值"
38
39
  },
39
40
  "operators": {
40
41
  "between": "介于",
@@ -66,6 +67,10 @@
66
67
  "notEqual": "值必须不等于 {FORMULA1}",
67
68
  "notBetween": "值必须在 {FORMULA1} 和 {FORMULA2} 范围之外"
68
69
  },
70
+ "any": {
71
+ "title": "任意值",
72
+ "error": "此单元格的内容违反了验证规则"
73
+ },
69
74
  "date": {
70
75
  "title": "日期",
71
76
  "operators": {
@@ -145,7 +150,8 @@
145
150
  "custom": {
146
151
  "title": "自定义公式",
147
152
  "error": "此单元格的内容违反了验证规则",
148
- "validFail": "请输入合法的公式"
153
+ "validFail": "请输入合法的公式",
154
+ "ruleName": "自定义公式 {FORMULA1}"
149
155
  },
150
156
  "alert": {
151
157
  "title": "提示",
@@ -34,7 +34,8 @@
34
34
  "showWarning": "顯示警告",
35
35
  "rejectInput": "拒絕輸入",
36
36
  "messageInfo": "文字提示",
37
- "showInfo": "顯示所選單元格的提示文字"
37
+ "showInfo": "顯示所選單元格的提示文字",
38
+ "allowBlank": "忽略空值"
38
39
  },
39
40
  "operators": {
40
41
  "between": "介於",
@@ -66,6 +67,10 @@
66
67
  "notEqual": "值必須不等於 {FORMULA1}",
67
68
  "notBetween": "值必須在 {FORMULA1} 和 {FORMULA2} 範圍之外"
68
69
  },
70
+ "any": {
71
+ "title": "任意值",
72
+ "error": "此儲存格的內容違反了驗證規則"
73
+ },
69
74
  "date": {
70
75
  "title": "日期",
71
76
  "operators": {
@@ -145,7 +150,8 @@
145
150
  "custom": {
146
151
  "title": "自訂公式",
147
152
  "error": "此儲存格的內容違反了驗證規則",
148
- "validFail": "請輸入合法的公式"
153
+ "validFail": "請輸入合法的公式",
154
+ "ruleName": "自訂公式 {FORMULA1}"
149
155
  },
150
156
  "alert": {
151
157
  "title": "提示",
@@ -50,6 +50,7 @@ declare const locale: {
50
50
  rejectInput: string;
51
51
  messageInfo: string;
52
52
  showInfo: string;
53
+ allowBlank: string;
53
54
  };
54
55
  operators: {
55
56
  between: string;
@@ -81,6 +82,10 @@ declare const locale: {
81
82
  notEqual: string;
82
83
  notBetween: string;
83
84
  };
85
+ any: {
86
+ title: string;
87
+ error: string;
88
+ };
84
89
  date: {
85
90
  title: string;
86
91
  operators: {
@@ -161,6 +166,7 @@ declare const locale: {
161
166
  title: string;
162
167
  error: string;
163
168
  validFail: string;
169
+ ruleName: string;
164
170
  };
165
171
  alert: {
166
172
  title: string;
@@ -4,4 +4,5 @@ import { BaseSheetDataValidatorView } from './sheet-validator-view';
4
4
  export declare class ListMultipleValidatorView extends BaseSheetDataValidatorView {
5
5
  id: DataValidationType;
6
6
  canvasRender: DropdownMultipleWidget;
7
+ dropdown: string | undefined;
7
8
  }
@@ -9,6 +9,7 @@ export declare class CheckboxRender implements IBaseDataValidationWidget {
9
9
  private _calc;
10
10
  constructor(_commandService: ICommandService, _formulaService: DataValidationFormulaService, _themeService: ThemeService);
11
11
  calcCellAutoHeight(info: ICellRenderContext): number | undefined;
12
+ calcCellAutoWidth(info: ICellRenderContext): number | undefined;
12
13
  private _parseFormula;
13
14
  drawWith(ctx: UniverRenderingContext2D, info: ICellRenderContext): void;
14
15
  isHit(evt: {
@@ -11,6 +11,7 @@ export declare class DropdownMultipleWidget implements IBaseDataValidationWidget
11
11
  private _drawDownIcon;
12
12
  drawWith(ctx: UniverRenderingContext2D, info: ICellRenderContext, skeleton: SpreadsheetSkeleton, spreadsheets: Spreadsheet): void;
13
13
  calcCellAutoHeight(info: ICellRenderContext): number | undefined;
14
+ calcCellAutoWidth(info: ICellRenderContext): number | undefined;
14
15
  isHit(position: {
15
16
  x: number;
16
17
  y: number;
@@ -20,6 +20,7 @@ export declare class DropdownWidget implements IBaseDataValidationWidget {
20
20
  private _drawDownIcon;
21
21
  drawWith(ctx: UniverRenderingContext2D, info: ICellRenderContext, skeleton: SpreadsheetSkeleton): void;
22
22
  calcCellAutoHeight(info: ICellRenderContext): number | undefined;
23
+ calcCellAutoWidth(info: ICellRenderContext): number | undefined;
23
24
  isHit(position: {
24
25
  x: number;
25
26
  y: number;
@@ -34,4 +34,5 @@ export declare function layoutDropdowns(items: string[], fontStyle: IDocumentSke
34
34
  contentWidth: number;
35
35
  contentHeight: number;
36
36
  cellAutoHeight: number;
37
+ calcAutoWidth: number;
37
38
  };