@univerjs/sheets-data-validation-ui 1.0.0-alpha.7 → 1.0.0-beta.0

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
@@ -1,12 +1,12 @@
1
- import { ComponentManager, IDialogService, IMenuManagerService, ISidebarService, IconManager, KeyCode, MenuItemType, RibbonDataGroup, RibbonInsertGroup, getMenuHiddenObservable, useDependency, useEvent, useObservable, useSidebarClick } from "@univerjs/ui";
1
+ import { ComponentManager, IDialogService, IMenuManagerService, ISidebarService, IconManager, KeyCode, MenuItemType, RibbonDataGroup, RibbonInsertGroup, UniverMobileUIPlugin, getMenuHiddenObservable, useDependency, useEvent, useObservable, useSidebarClick } from "@univerjs/ui";
2
2
  import { CellValueType, ColorKit, CommandType, DEFAULT_STYLES, DataValidationErrorStyle, DataValidationRenderMode, DataValidationStatus, DataValidationType, DependentOn, Disposable, DisposableCollection, HorizontalAlign, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, ObjectMatrix, Optional, Plugin, Range, Rectangle, RedoCommand, RxDisposable, ThemeService, UndoCommand, UniverInstanceType, VerticalAlign, WrapStrategy, bufferDebounceTime, dateKit, debounce, generateRandomId, isFormulaString, isUnitRangesEqual, merge, numfmt, queryObjectMatrix, sequenceExecute, shallowEqual, toDisposable } from "@univerjs/core";
3
- import { AUTO_FILL_APPLY_TYPE, AutoFillTools, IAutoFillService, INTERCEPTOR_POINT, InterceptCellContentPriority, RangeProtectionPermissionEditPoint, SetRangeValuesCommand, SetWorksheetActiveOperation, SheetInterceptorService, SheetPermissionCheckController, SheetsSelectionsService, VALIDATE_CELL, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, checkRangesEditablePermission, deserializeListOptions, getSheetCommandTarget, rangeToDiscreteRange, serializeListOptions } from "@univerjs/sheets";
3
+ import { AUTO_FILL_APPLY_TYPE, AutoFillTools, IAutoFillService, INTERCEPTOR_POINT, InterceptCellContentPriority, RangeProtectionPermissionEditPoint, SetRangeValuesCommand, SetWorksheetActiveOperation, SheetInterceptorService, SheetPermissionCheckController, SheetsSelectionsService, UniverSheetsPlugin, VALIDATE_CELL, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, checkRangesEditablePermission, deserializeListOptions, getSheetCommandTarget, rangeToDiscreteRange, serializeListOptions } from "@univerjs/sheets";
4
4
  import { AddSheetDataValidationCommand, BASE_FORMULA_INPUT_NAME, CHECKBOX_FORMULA_1, CHECKBOX_FORMULA_2, CHECKBOX_FORMULA_INPUT_NAME, CUSTOM_FORMULA_INPUT_NAME, ClearRangeDataValidationCommand, DATA_VALIDATION_PLUGIN_NAME, DataValidationCacheService, DataValidationFormulaController, DataValidationFormulaService, LIST_FORMULA_INPUT_NAME, RemoveSheetAllDataValidationCommand, RemoveSheetDataValidationCommand, SheetDataValidationModel, SheetsDataValidationValidatorService, UniverSheetsDataValidationPlugin, UpdateSheetDataValidationOptionsCommand, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand, createDefaultNewRule, getCellValueOrigin, getDataValidationCellValue, getDataValidationDiffMutations, getFormulaResult, isLegalFormulaResult, transformCheckboxValue } from "@univerjs/sheets-data-validation";
5
- import { DataValidationModel, DataValidatorDropdownType, DataValidatorRegistryScope, DataValidatorRegistryService, TWO_FORMULA_OPERATOR_COUNT, getRuleOptions, getRuleSetting } from "@univerjs/data-validation";
5
+ import { DataValidationModel, DataValidatorDropdownType, DataValidatorRegistryScope, DataValidatorRegistryService, TWO_FORMULA_OPERATOR_COUNT, UniverDataValidationPlugin, getRuleOptions, getRuleSetting } from "@univerjs/data-validation";
6
6
  import { BehaviorSubject, Subject, bufferTime, debounceTime, distinctUntilChanged, filter, map, of, startWith } from "rxjs";
7
- import { CURSOR_TYPE, CheckboxShape, DeviceInputEventType, DocSimpleSkeleton, FontCache, IRenderManagerService, Rect, Shape, Text, Transform, fixLineWidthByScale, getCurrentTypeOfRenderer, getFontStyleString } from "@univerjs/engine-render";
7
+ import { CURSOR_TYPE, CheckboxShape, DeviceInputEventType, DocSimpleSkeleton, FontCache, IRenderManagerService, Rect, Shape, Text, Transform, UniverRenderEnginePlugin, fixLineWidthByScale, getCurrentTypeOfRenderer, getFontStyleString } from "@univerjs/engine-render";
8
8
  import { getPatternType } from "@univerjs/sheets-numfmt";
9
- import { AutoHeightController, COPY_TYPE, CellAlertManagerService, CellAlertType, HoverManagerService, IEditorBridgeService, IMarkSelectionService, ISheetCellDropdownManagerService, ISheetClipboardService, PREDEFINED_HOOK_NAME_PASTE, SetCellEditVisibleOperation, SheetSkeletonManagerService, getCurrentRangeDisable$, getRepeatRange, virtualizeDiscreteRanges } from "@univerjs/sheets-ui";
9
+ import { AutoHeightController, COPY_TYPE, CellAlertManagerService, CellAlertType, HoverManagerService, IEditorBridgeService, IMarkSelectionService, ISheetCellDropdownManagerService, ISheetClipboardService, PREDEFINED_HOOK_NAME_PASTE, SetCellEditVisibleOperation, SheetSkeletonManagerService, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, getCurrentRangeDisable$, getRepeatRange, virtualizeDiscreteRanges } from "@univerjs/sheets-ui";
10
10
  import { Button, Checkbox, DraggableList, Dropdown, FormLayout, Input, Radio, RadioGroup, Select, Separator, borderClassName, clsx } from "@univerjs/design";
11
11
  import { createElement, useEffect, useMemo, useRef, useState } from "react";
12
12
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -14,7 +14,7 @@ import { CheckboxIcon, DataValidationIcon, DatePickerIcon, DeleteIcon, DropdownL
14
14
  import { deserializeRangeWithSheet, serializeRange } from "@univerjs/engine-formula";
15
15
  import { FormulaEditor, RangeSelector } from "@univerjs/sheets-formula-ui";
16
16
 
17
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
17
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
18
18
  function _typeof(o) {
19
19
  "@babel/helpers - typeof";
20
20
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -25,7 +25,7 @@ function _typeof(o) {
25
25
  }
26
26
 
27
27
  //#endregion
28
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
28
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
29
29
  function toPrimitive(t, r) {
30
30
  if ("object" != _typeof(t) || !t) return t;
31
31
  var e = t[Symbol.toPrimitive];
@@ -38,14 +38,14 @@ function toPrimitive(t, r) {
38
38
  }
39
39
 
40
40
  //#endregion
41
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
41
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
42
42
  function toPropertyKey(t) {
43
43
  var i = toPrimitive(t, "string");
44
44
  return "symbol" == _typeof(i) ? i : i + "";
45
45
  }
46
46
 
47
47
  //#endregion
48
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
48
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
49
49
  function _defineProperty(e, r, t) {
50
50
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
51
51
  value: t,
@@ -56,7 +56,7 @@ function _defineProperty(e, r, t) {
56
56
  }
57
57
 
58
58
  //#endregion
59
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
59
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
60
60
  function __decorateParam(paramIndex, decorator) {
61
61
  return function(target, key) {
62
62
  decorator(target, key, paramIndex);
@@ -64,7 +64,7 @@ function __decorateParam(paramIndex, decorator) {
64
64
  }
65
65
 
66
66
  //#endregion
67
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
67
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
68
68
  function __decorate(decorators, target, key, desc) {
69
69
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
70
70
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -302,7 +302,7 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
302
302
  if (!(validator === null || validator === void 0 ? void 0 : validator.dropdownType)) return;
303
303
  let popupDisposable;
304
304
  const handleSave = async (date, targetPatternType) => {
305
- var _numfmt$parseDate, _cellStyle$n$pattern, _cellStyle$n;
305
+ var _numfmt$parseDate, _cellStyle$n;
306
306
  if (!date) return true;
307
307
  const newValue = date;
308
308
  const cellData = worksheet.getCell(row, col);
@@ -310,7 +310,7 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
310
310
  const serialNum = (_numfmt$parseDate = numfmt.parseDate(dateStr)) === null || _numfmt$parseDate === void 0 ? void 0 : _numfmt$parseDate.v;
311
311
  const serialTime = targetPatternType === "time" ? serialNum % 1 : serialNum;
312
312
  const cellStyle = workbook.getStyles().getStyleByCell(cellData);
313
- const format = (_cellStyle$n$pattern = cellStyle === null || cellStyle === void 0 || (_cellStyle$n = cellStyle.n) === null || _cellStyle$n === void 0 ? void 0 : _cellStyle$n.pattern) !== null && _cellStyle$n$pattern !== void 0 ? _cellStyle$n$pattern : "";
313
+ const format = (cellStyle === null || cellStyle === void 0 || (_cellStyle$n = cellStyle.n) === null || _cellStyle$n === void 0 ? void 0 : _cellStyle$n.pattern) ?? "";
314
314
  if (rule.errorStyle !== DataValidationErrorStyle.STOP || await validator.validator({
315
315
  value: serialTime,
316
316
  unitId,
@@ -361,7 +361,8 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
361
361
  switch (validator.dropdownType) {
362
362
  case DataValidatorDropdownType.DATE: {
363
363
  var _rule$bizInfo;
364
- const originDate = transformDate(getCellValueOrigin(worksheet.getCellRaw(row, col)));
364
+ const cellStr = getCellValueOrigin(worksheet.getCellRaw(row, col));
365
+ const originDate = transformDate(cellStr);
365
366
  const showTime = Boolean((_rule$bizInfo = rule.bizInfo) === null || _rule$bizInfo === void 0 ? void 0 : _rule$bizInfo.showTime);
366
367
  dropdownParam = {
367
368
  location,
@@ -375,35 +376,38 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
375
376
  };
376
377
  break;
377
378
  }
378
- case DataValidatorDropdownType.TIME:
379
+ case DataValidatorDropdownType.TIME: {
380
+ const cellStr = getCellValueOrigin(worksheet.getCellRaw(row, col));
379
381
  dropdownParam = {
380
382
  location,
381
383
  type: "datepicker",
382
384
  props: {
383
385
  onChange: (newValue) => handleSave(newValue, "time"),
384
- defaultValue: transformDate(getCellValueOrigin(worksheet.getCellRaw(row, col))),
386
+ defaultValue: transformDate(cellStr),
385
387
  patternType: "time"
386
388
  }
387
389
  };
388
390
  break;
389
- case DataValidatorDropdownType.DATETIME:
391
+ }
392
+ case DataValidatorDropdownType.DATETIME: {
393
+ const cellStr = getCellValueOrigin(worksheet.getCellRaw(row, col));
390
394
  dropdownParam = {
391
395
  location,
392
396
  type: "datepicker",
393
397
  props: {
394
398
  onChange: (newValue) => handleSave(newValue, "datetime"),
395
- defaultValue: transformDate(getCellValueOrigin(worksheet.getCellRaw(row, col))),
399
+ defaultValue: transformDate(cellStr),
396
400
  patternType: "datetime"
397
401
  }
398
402
  };
399
403
  break;
404
+ }
400
405
  case DataValidatorDropdownType.LIST:
401
406
  case DataValidatorDropdownType.MULTIPLE_LIST: {
402
- var _this$_configService$, _this$_configService$2, _this$_configService$3, _this$_configService$4;
407
+ var _this$_configService$, _this$_configService$2;
403
408
  const multiple = validator.dropdownType === DataValidatorDropdownType.MULTIPLE_LIST;
404
409
  const handleSave = async (newValue) => {
405
- var _newValue$;
406
- const str = multiple ? serializeListOptions(newValue) : (_newValue$ = newValue[0]) !== null && _newValue$ !== void 0 ? _newValue$ : "";
410
+ const str = multiple ? serializeListOptions(newValue) : newValue[0] ?? "";
407
411
  const params = {
408
412
  unitId,
409
413
  subUnitId,
@@ -450,14 +454,13 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
450
454
  onEdit: handleEdit,
451
455
  defaultValue: cellStr,
452
456
  multiple,
453
- showEdit: (_this$_configService$ = (_this$_configService$2 = this._configService.getConfig("sheets-data-validation-ui.config")) === null || _this$_configService$2 === void 0 ? void 0 : _this$_configService$2.showEditOnDropdown) !== null && _this$_configService$ !== void 0 ? _this$_configService$ : true,
454
- showSearch: (_this$_configService$3 = (_this$_configService$4 = this._configService.getConfig("sheets-data-validation-ui.config")) === null || _this$_configService$4 === void 0 ? void 0 : _this$_configService$4.showSearchOnDropdown) !== null && _this$_configService$3 !== void 0 ? _this$_configService$3 : true
457
+ showEdit: ((_this$_configService$ = this._configService.getConfig("sheets-data-validation-ui.config")) === null || _this$_configService$ === void 0 ? void 0 : _this$_configService$.showEditOnDropdown) ?? true,
458
+ showSearch: ((_this$_configService$2 = this._configService.getConfig("sheets-data-validation-ui.config")) === null || _this$_configService$2 === void 0 ? void 0 : _this$_configService$2.showSearchOnDropdown) ?? true
455
459
  }
456
460
  };
457
461
  break;
458
462
  }
459
463
  case DataValidatorDropdownType.CASCADE: {
460
- var _rule$formula;
461
464
  const handleSave = (newValue) => {
462
465
  const params = {
463
466
  unitId,
@@ -489,7 +492,7 @@ let DataValidationDropdownManagerService = class DataValidationDropdownManagerSe
489
492
  props: {
490
493
  onChange: handleSave,
491
494
  defaultValue: getDataValidationCellValue(worksheet.getCellRaw(row, col)).split("/"),
492
- options: JSON.parse((_rule$formula = rule.formula1) !== null && _rule$formula !== void 0 ? _rule$formula : "[]")
495
+ options: JSON.parse(rule.formula1 ?? "[]")
493
496
  },
494
497
  location
495
498
  };
@@ -986,12 +989,11 @@ const menuSchema = {
986
989
  //#endregion
987
990
  //#region package.json
988
991
  var name = "@univerjs/sheets-data-validation-ui";
989
- var version = "1.0.0-alpha.7";
992
+ var version = "1.0.0-beta.0";
990
993
 
991
994
  //#endregion
992
995
  //#region src/views/components/DataValidationOptions.tsx
993
996
  function DataValidationOptions(props) {
994
- var _value$errorStyle;
995
997
  const localeService = useDependency(LocaleService);
996
998
  const componentManager = useDependency(ComponentManager);
997
999
  const { value, onChange, extraComponent } = props;
@@ -1009,7 +1011,7 @@ function DataValidationOptions(props) {
1009
1011
  /* @__PURE__ */ jsx(FormLayout, {
1010
1012
  label: localeService.t("sheets-data-validation-ui.panel.invalid"),
1011
1013
  children: /* @__PURE__ */ jsxs(RadioGroup, {
1012
- value: `${(_value$errorStyle = value.errorStyle) !== null && _value$errorStyle !== void 0 ? _value$errorStyle : DataValidationErrorStyle.WARNING}`,
1014
+ value: `${value.errorStyle ?? DataValidationErrorStyle.WARNING}`,
1013
1015
  onChange: (errorStyle) => onChange({
1014
1016
  ...value,
1015
1017
  errorStyle: +errorStyle
@@ -1069,7 +1071,7 @@ function DataValidationDetail() {
1069
1071
  } });
1070
1072
  }
1071
1073
  function DataValidationDetailInner(props) {
1072
- var _validators$sort, _localRule$allowBlank;
1074
+ var _validators$sort;
1073
1075
  const [key, setKey] = useState(0);
1074
1076
  const dataValidationPanelService = useDependency(DataValidationPanelService);
1075
1077
  const { unitId, subUnitId, rule } = props.activeRuleInfo;
@@ -1081,10 +1083,7 @@ function DataValidationDetailInner(props) {
1081
1083
  const dataValidationModel = useDependency(DataValidationModel);
1082
1084
  const localeService = useDependency(LocaleService);
1083
1085
  const workbook = useObservable(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET), void 0, void 0, []);
1084
- const worksheet = useObservable(() => {
1085
- var _workbook$activeSheet;
1086
- return (_workbook$activeSheet = workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) !== null && _workbook$activeSheet !== void 0 ? _workbook$activeSheet : of(null);
1087
- }, void 0, void 0, []);
1086
+ const worksheet = useObservable(() => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? of(null), void 0, void 0, []);
1088
1087
  const [localRule, setLocalRule] = useState(rule);
1089
1088
  const validator = validatorService.getValidatorItem(localRule.type);
1090
1089
  const [showError, setShowError] = useState(false);
@@ -1332,14 +1331,11 @@ function DataValidationDetailInner(props) {
1332
1331
  ruleId
1333
1332
  }, key + localRule.type) : null,
1334
1333
  /* @__PURE__ */ jsx(FormLayout, { children: /* @__PURE__ */ jsx(Checkbox, {
1335
- checked: (_localRule$allowBlank = localRule.allowBlank) !== null && _localRule$allowBlank !== void 0 ? _localRule$allowBlank : true,
1336
- onChange: () => {
1337
- var _localRule$allowBlank2;
1338
- return handleUpdateRuleSetting({
1339
- ...baseRule,
1340
- allowBlank: !((_localRule$allowBlank2 = localRule.allowBlank) !== null && _localRule$allowBlank2 !== void 0 ? _localRule$allowBlank2 : true)
1341
- });
1342
- },
1334
+ checked: localRule.allowBlank ?? true,
1335
+ onChange: () => handleUpdateRuleSetting({
1336
+ ...baseRule,
1337
+ allowBlank: !(localRule.allowBlank ?? true)
1338
+ }),
1343
1339
  children: localeService.t("sheets-data-validation-ui.panel.allowBlank")
1344
1340
  }) }),
1345
1341
  /* @__PURE__ */ jsx(DataValidationOptions, {
@@ -1376,10 +1372,9 @@ const DataValidationItem = (props) => {
1376
1372
  const [isHover, setIsHover] = useState(false);
1377
1373
  const themeService = useDependency(ThemeService);
1378
1374
  const style = useMemo(() => {
1379
- var _themeService$getColo;
1380
1375
  const defaultColor = themeService.getColorFromTheme("primary.600");
1381
1376
  const key = themeService.getColorFromTheme("loop-color.2");
1382
- const color = (_themeService$getColo = themeService.getColorFromTheme(key)) !== null && _themeService$getColo !== void 0 ? _themeService$getColo : defaultColor;
1377
+ const color = themeService.getColorFromTheme(key) ?? defaultColor;
1383
1378
  const rgb = new ColorKit(color).toRgb();
1384
1379
  return {
1385
1380
  fill: `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, 0.1)`,
@@ -1500,23 +1495,20 @@ function DataValidationList(props) {
1500
1495
  const hasDisableRule = rulesByPermissionCheck === null || rulesByPermissionCheck === void 0 ? void 0 : rulesByPermissionCheck.some((rule) => rule.disable);
1501
1496
  return /* @__PURE__ */ jsxs("div", {
1502
1497
  className: "univer-pb-4",
1503
- children: [rulesByPermissionCheck === null || rulesByPermissionCheck === void 0 ? void 0 : rulesByPermissionCheck.map((rule) => {
1504
- var _rule$disable;
1505
- return /* @__PURE__ */ jsx(DataValidationItem, {
1506
- unitId,
1507
- subUnitId,
1508
- onClick: () => {
1509
- if (rule.disable) return;
1510
- dataValidationPanelService.setActiveRule({
1511
- unitId,
1512
- subUnitId,
1513
- rule
1514
- });
1515
- },
1516
- rule,
1517
- disable: (_rule$disable = rule.disable) !== null && _rule$disable !== void 0 ? _rule$disable : false
1518
- }, rule.uid);
1519
- }), /* @__PURE__ */ jsxs("div", {
1498
+ children: [rulesByPermissionCheck === null || rulesByPermissionCheck === void 0 ? void 0 : rulesByPermissionCheck.map((rule) => /* @__PURE__ */ jsx(DataValidationItem, {
1499
+ unitId,
1500
+ subUnitId,
1501
+ onClick: () => {
1502
+ if (rule.disable) return;
1503
+ dataValidationPanelService.setActiveRule({
1504
+ unitId,
1505
+ subUnitId,
1506
+ rule
1507
+ });
1508
+ },
1509
+ rule,
1510
+ disable: rule.disable ?? false
1511
+ }, rule.uid)), /* @__PURE__ */ jsxs("div", {
1520
1512
  className: "univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",
1521
1513
  children: [rules.length && !hasDisableRule ? /* @__PURE__ */ jsx(Button, {
1522
1514
  onClick: handleRemoveAll,
@@ -1537,10 +1529,7 @@ const DataValidationPanel = () => {
1537
1529
  const activeRule = useObservable(dataValidationPanelService.activeRule$, dataValidationPanelService.activeRule);
1538
1530
  const univerInstanceService = useDependency(IUniverInstanceService);
1539
1531
  const workbook = useObservable(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET), void 0, void 0, []);
1540
- const worksheet = useObservable(() => {
1541
- var _workbook$activeSheet;
1542
- return (_workbook$activeSheet = workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) !== null && _workbook$activeSheet !== void 0 ? _workbook$activeSheet : of(null);
1543
- }, void 0, void 0, []);
1532
+ const worksheet = useObservable(() => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? of(null), void 0, void 0, []);
1544
1533
  if (!workbook || !worksheet) return null;
1545
1534
  return activeRule && (activeRule.subUnitId === worksheet.getSheetId() || activeRule.subUnitId === dataValidationPanelService.getFocusFormulaEditorActiveRuleSubUnitId()) ? /* @__PURE__ */ jsx(DataValidationDetail, {}, activeRule.rule.uid) : /* @__PURE__ */ jsx(DataValidationList, { workbook });
1546
1535
  };
@@ -1682,27 +1671,26 @@ function CheckboxFormulaInput(props) {
1682
1671
  //#endregion
1683
1672
  //#region src/views/components/formula-input/CustomFormulaInput.tsx
1684
1673
  function CustomFormulaInput(props) {
1685
- var _value$formula;
1686
1674
  const { unitId, subUnitId, value, onChange, showError, validResult } = props;
1687
1675
  const formula1Res = showError ? validResult === null || validResult === void 0 ? void 0 : validResult.formula1 : void 0;
1688
1676
  const formulaEditorRef = useRef(null);
1689
1677
  const [isFocusFormulaEditor, setIsFocusFormulaEditor] = useState(false);
1690
1678
  useSidebarClick((e) => {
1691
1679
  var _formulaEditorRef$cur;
1692
- !((_formulaEditorRef$cur = formulaEditorRef.current) === null || _formulaEditorRef$cur === void 0) && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
1680
+ (_formulaEditorRef$cur = formulaEditorRef.current) !== null && _formulaEditorRef$cur !== void 0 && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
1693
1681
  });
1694
1682
  return /* @__PURE__ */ jsx(FormLayout, {
1695
1683
  error: formula1Res,
1696
1684
  children: /* @__PURE__ */ jsx(FormulaEditor, {
1697
1685
  ref: formulaEditorRef,
1698
1686
  className: clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent", borderClassName),
1699
- initValue: (_value$formula = value === null || value === void 0 ? void 0 : value.formula1) !== null && _value$formula !== void 0 ? _value$formula : "=",
1687
+ initValue: (value === null || value === void 0 ? void 0 : value.formula1) ?? "=",
1700
1688
  unitId,
1701
1689
  subUnitId,
1702
1690
  isFocus: isFocusFormulaEditor,
1703
1691
  isSupportAcrossSheet: true,
1704
1692
  onChange: (newValue) => {
1705
- const newFormula = (newValue !== null && newValue !== void 0 ? newValue : "").trim();
1693
+ const newFormula = (newValue ?? "").trim();
1706
1694
  if (newFormula === (value === null || value === void 0 ? void 0 : value.formula1)) return;
1707
1695
  onChange === null || onChange === void 0 || onChange({
1708
1696
  ...value,
@@ -1958,7 +1946,7 @@ function ListFormulaInput(props) {
1958
1946
  const [isFocusFormulaEditor, setIsFocusFormulaEditor] = useState(false);
1959
1947
  useSidebarClick((e) => {
1960
1948
  var _formulaEditorRef$cur;
1961
- !((_formulaEditorRef$cur = formulaEditorRef.current) === null || _formulaEditorRef$cur === void 0) && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
1949
+ (_formulaEditorRef$cur = formulaEditorRef.current) !== null && _formulaEditorRef$cur !== void 0 && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
1962
1950
  });
1963
1951
  useEffect(() => {
1964
1952
  if (isFocusFormulaEditor) dataValidationPanelService.setFocusFormulaEditorActiveRuleSubUnitId(subUnitId);
@@ -2000,7 +1988,7 @@ function ListFormulaInput(props) {
2000
1988
  isSupportAcrossSheet: true,
2001
1989
  onFocus: () => setIsFocusFormulaEditor(true),
2002
1990
  onChange: (v = "") => {
2003
- const str = (v !== null && v !== void 0 ? v : "").trim();
1991
+ const str = (v ?? "").trim();
2004
1992
  setFormulaStrCopy(str);
2005
1993
  updateFormula(str);
2006
1994
  }
@@ -2051,13 +2039,12 @@ const FORMULA_INPUTS = [
2051
2039
  //#region src/views/components/ListRenderModeInput.tsx
2052
2040
  const LIST_RENDER_MODE_OPTION_INPUT = "LIST_RENDER_MODE_OPTION_INPUT";
2053
2041
  function ListRenderModeInput(props) {
2054
- var _value$renderMode;
2055
2042
  const { value, onChange } = props;
2056
2043
  const localeService = useDependency(LocaleService);
2057
2044
  return /* @__PURE__ */ jsx(FormLayout, {
2058
2045
  label: localeService.t("sheets-data-validation-ui.renderMode.label"),
2059
2046
  children: /* @__PURE__ */ jsxs(RadioGroup, {
2060
- value: `${(_value$renderMode = value.renderMode) !== null && _value$renderMode !== void 0 ? _value$renderMode : DataValidationRenderMode.CUSTOM}`,
2047
+ value: `${value.renderMode ?? DataValidationRenderMode.CUSTOM}`,
2061
2048
  onChange: (renderMode) => onChange({
2062
2049
  ...value,
2063
2050
  renderMode: +renderMode
@@ -2343,7 +2330,7 @@ let DataValidationCopyPasteController = class DataValidationCopyPasteController
2343
2330
  rows.forEach((row, rowIndex) => {
2344
2331
  cols.forEach((col, colIndex) => {
2345
2332
  const ruleId = this._sheetDataValidationModel.getRuleIdByLocation(unitId, subUnitId, row, col);
2346
- matrix.setValue(rowIndex, colIndex, ruleId !== null && ruleId !== void 0 ? ruleId : "");
2333
+ matrix.setValue(rowIndex, colIndex, ruleId ?? "");
2347
2334
  });
2348
2335
  });
2349
2336
  }
@@ -2534,7 +2521,7 @@ let SheetsDataValidationRenderController = class SheetsDataValidationRenderContr
2534
2521
  const state = this._editorBridgeService.getEditCellState();
2535
2522
  if (state) {
2536
2523
  const { unitId, sheetId, row, column } = state;
2537
- const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
2524
+ const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
2538
2525
  if (!workbook) return;
2539
2526
  const rule = this._sheetDataValidationModel.getRuleByLocation(unitId, sheetId, row, column);
2540
2527
  if (!rule) return;
@@ -2565,32 +2552,30 @@ let SheetsDataValidationRenderController = class SheetsDataValidationRenderContr
2565
2552
  effect: InterceptorEffectEnum.Style,
2566
2553
  priority: InterceptCellContentPriority.DATA_VALIDATION,
2567
2554
  handler: (cell, pos, next) => {
2568
- var _this$_dataValidation, _cell$customRender, _cell$fontRenderExten, _validator$skipDefaul, _cell$coverable;
2555
+ var _cell$fontRenderExten, _validator$skipDefaul;
2569
2556
  const { row, col, unitId, subUnitId, workbook, worksheet } = pos;
2570
2557
  const ruleId = this._sheetDataValidationModel.getRuleIdByLocation(unitId, subUnitId, row, col);
2571
2558
  if (!ruleId) return next(cell);
2572
2559
  const rule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
2573
2560
  if (!rule) return next(cell);
2574
- const validStatus = (_this$_dataValidation = this._dataValidationCacheService.getValue(unitId, subUnitId, row, col)) !== null && _this$_dataValidation !== void 0 ? _this$_dataValidation : DataValidationStatus.VALID;
2561
+ const validStatus = this._dataValidationCacheService.getValue(unitId, subUnitId, row, col) ?? DataValidationStatus.VALID;
2575
2562
  const validator = this._dataValidatorRegistryService.getValidatorItem(rule.type);
2576
2563
  const cellOrigin = pos.rawData;
2577
2564
  let cache;
2578
2565
  const cellValue = { get value() {
2579
- var _getCellValueOrigin;
2580
2566
  if (cache !== void 0) return cache;
2581
- cache = (_getCellValueOrigin = getCellValueOrigin(cellOrigin)) !== null && _getCellValueOrigin !== void 0 ? _getCellValueOrigin : null;
2567
+ cache = getCellValueOrigin(cellOrigin) ?? null;
2582
2568
  return cache;
2583
2569
  } };
2584
2570
  const valueStr = { get value() {
2585
- var _cellValue$value;
2586
- return `${(_cellValue$value = cellValue.value) !== null && _cellValue$value !== void 0 ? _cellValue$value : ""}`;
2571
+ return `${cellValue.value ?? ""}`;
2587
2572
  } };
2588
2573
  if (!cell || cell === pos.rawData) cell = { ...pos.rawData };
2589
2574
  cell.markers = {
2590
2575
  ...cell === null || cell === void 0 ? void 0 : cell.markers,
2591
2576
  ...validStatus === DataValidationStatus.INVALID ? INVALID_MARK : null
2592
2577
  };
2593
- cell.customRender = [...(_cell$customRender = cell === null || cell === void 0 ? void 0 : cell.customRender) !== null && _cell$customRender !== void 0 ? _cell$customRender : [], ...(validator === null || validator === void 0 ? void 0 : validator.canvasRender) ? [validator.canvasRender] : []];
2578
+ cell.customRender = [...(cell === null || cell === void 0 ? void 0 : cell.customRender) ?? [], ...(validator === null || validator === void 0 ? void 0 : validator.canvasRender) ? [validator.canvasRender] : []];
2594
2579
  cell.fontRenderExtension = {
2595
2580
  ...cell === null || cell === void 0 ? void 0 : cell.fontRenderExtension,
2596
2581
  isSkip: (cell === null || cell === void 0 || (_cell$fontRenderExten = cell.fontRenderExtension) === null || _cell$fontRenderExten === void 0 ? void 0 : _cell$fontRenderExten.isSkip) || (validator === null || validator === void 0 || (_validator$skipDefaul = validator.skipDefaultFontRender) === null || _validator$skipDefaul === void 0 ? void 0 : _validator$skipDefaul.call(validator, rule, cellValue.value, pos))
@@ -2603,14 +2588,14 @@ let SheetsDataValidationRenderController = class SheetsDataValidationRenderContr
2603
2588
  } }, row, col)
2604
2589
  };
2605
2590
  cell.interceptorAutoHeight = () => {
2606
- var _this$_renderManagerS, _mergeCell$startRow, _mergeCell$startColum, _validator$canvasRend, _validator$canvasRend2;
2607
- const skeleton = (_this$_renderManagerS = this._renderManagerService.getRenderById(unitId)) === null || _this$_renderManagerS === void 0 || (_this$_renderManagerS = _this$_renderManagerS.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.skeleton;
2591
+ var _this$_renderManagerS, _validator$canvasRend, _validator$canvasRend2;
2592
+ const skeleton = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 || (_this$_renderManagerS = _this$_renderManagerS.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.skeleton;
2608
2593
  if (!skeleton) return;
2609
2594
  const mergeCell = skeleton.worksheet.getMergedCell(row, col);
2610
2595
  const info = {
2611
2596
  data: cell,
2612
- style: skeleton.getStyles().getStyleByCell(cell),
2613
- primaryWithCoord: skeleton.getCellWithCoordByIndex((_mergeCell$startRow = mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startRow) !== null && _mergeCell$startRow !== void 0 ? _mergeCell$startRow : row, (_mergeCell$startColum = mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startColumn) !== null && _mergeCell$startColum !== void 0 ? _mergeCell$startColum : col),
2597
+ style: workbook.getStyles().getStyleByCell(cell),
2598
+ primaryWithCoord: skeleton.getCellWithCoordByIndex((mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startRow) ?? row, (mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startColumn) ?? col),
2614
2599
  unitId,
2615
2600
  subUnitId,
2616
2601
  row,
@@ -2621,14 +2606,14 @@ let SheetsDataValidationRenderController = class SheetsDataValidationRenderContr
2621
2606
  return validator === null || validator === void 0 || (_validator$canvasRend = validator.canvasRender) === null || _validator$canvasRend === void 0 || (_validator$canvasRend2 = _validator$canvasRend.calcCellAutoHeight) === null || _validator$canvasRend2 === void 0 ? void 0 : _validator$canvasRend2.call(_validator$canvasRend, info);
2622
2607
  };
2623
2608
  cell.interceptorAutoWidth = () => {
2624
- var _this$_renderManagerS2, _mergeCell$startRow2, _mergeCell$startColum2, _validator$canvasRend3, _validator$canvasRend4;
2625
- const skeleton = (_this$_renderManagerS2 = this._renderManagerService.getRenderById(unitId)) === null || _this$_renderManagerS2 === void 0 || (_this$_renderManagerS2 = _this$_renderManagerS2.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _this$_renderManagerS2 === void 0 ? void 0 : _this$_renderManagerS2.skeleton;
2609
+ var _this$_renderManagerS2, _validator$canvasRend3, _validator$canvasRend4;
2610
+ const skeleton = (_this$_renderManagerS2 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS2 === void 0 || (_this$_renderManagerS2 = _this$_renderManagerS2.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _this$_renderManagerS2 === void 0 ? void 0 : _this$_renderManagerS2.skeleton;
2626
2611
  if (!skeleton) return;
2627
2612
  const mergeCell = skeleton.worksheet.getMergedCell(row, col);
2628
2613
  const info = {
2629
2614
  data: cell,
2630
- style: skeleton.getStyles().getStyleByCell(cell),
2631
- primaryWithCoord: skeleton.getCellWithCoordByIndex((_mergeCell$startRow2 = mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startRow) !== null && _mergeCell$startRow2 !== void 0 ? _mergeCell$startRow2 : row, (_mergeCell$startColum2 = mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startColumn) !== null && _mergeCell$startColum2 !== void 0 ? _mergeCell$startColum2 : col),
2615
+ style: workbook.getStyles().getStyleByCell(cell),
2616
+ primaryWithCoord: skeleton.getCellWithCoordByIndex((mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startRow) ?? row, (mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startColumn) ?? col),
2632
2617
  unitId,
2633
2618
  subUnitId,
2634
2619
  row,
@@ -2638,7 +2623,7 @@ let SheetsDataValidationRenderController = class SheetsDataValidationRenderContr
2638
2623
  };
2639
2624
  return validator === null || validator === void 0 || (_validator$canvasRend3 = validator.canvasRender) === null || _validator$canvasRend3 === void 0 || (_validator$canvasRend4 = _validator$canvasRend3.calcCellAutoWidth) === null || _validator$canvasRend4 === void 0 ? void 0 : _validator$canvasRend4.call(_validator$canvasRend3, info);
2640
2625
  };
2641
- cell.coverable = ((_cell$coverable = cell === null || cell === void 0 ? void 0 : cell.coverable) !== null && _cell$coverable !== void 0 ? _cell$coverable : true) && !(rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE);
2626
+ cell.coverable = ((cell === null || cell === void 0 ? void 0 : cell.coverable) ?? true) && !(rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE);
2642
2627
  return next(cell);
2643
2628
  }
2644
2629
  }));
@@ -2688,22 +2673,22 @@ let SheetsDataValidationMobileRenderController = class SheetsDataValidationMobil
2688
2673
  effect: InterceptorEffectEnum.Style,
2689
2674
  priority: InterceptCellContentPriority.DATA_VALIDATION,
2690
2675
  handler: (cell, pos, next) => {
2691
- var _this$_dataValidation2, _cell$customRender2, _cell$fontRenderExten2, _validator$skipDefaul2, _cell$coverable2;
2676
+ var _cell$fontRenderExten2, _validator$skipDefaul2;
2692
2677
  const { row, col, unitId, subUnitId, workbook, worksheet } = pos;
2693
2678
  const ruleId = this._sheetDataValidationModel.getRuleIdByLocation(unitId, subUnitId, row, col);
2694
2679
  if (!ruleId) return next(cell);
2695
2680
  const rule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
2696
2681
  if (!rule) return next(cell);
2697
- const validStatus = (_this$_dataValidation2 = this._dataValidationCacheService.getValue(unitId, subUnitId, row, col)) !== null && _this$_dataValidation2 !== void 0 ? _this$_dataValidation2 : DataValidationStatus.VALID;
2682
+ const validStatus = this._dataValidationCacheService.getValue(unitId, subUnitId, row, col) ?? DataValidationStatus.VALID;
2698
2683
  const validator = this._dataValidatorRegistryService.getValidatorItem(rule.type);
2699
2684
  const cellValue = getCellValueOrigin(worksheet.getCellRaw(row, col));
2700
- const valueStr = `${cellValue !== null && cellValue !== void 0 ? cellValue : ""}`;
2685
+ const valueStr = `${cellValue ?? ""}`;
2701
2686
  if (!cell || cell === pos.rawData) cell = { ...pos.rawData };
2702
2687
  cell.markers = {
2703
2688
  ...cell === null || cell === void 0 ? void 0 : cell.markers,
2704
2689
  ...validStatus === DataValidationStatus.INVALID ? INVALID_MARK : null
2705
2690
  };
2706
- cell.customRender = [...(_cell$customRender2 = cell === null || cell === void 0 ? void 0 : cell.customRender) !== null && _cell$customRender2 !== void 0 ? _cell$customRender2 : [], ...(validator === null || validator === void 0 ? void 0 : validator.canvasRender) ? [validator.canvasRender] : []];
2691
+ cell.customRender = [...(cell === null || cell === void 0 ? void 0 : cell.customRender) ?? [], ...(validator === null || validator === void 0 ? void 0 : validator.canvasRender) ? [validator.canvasRender] : []];
2707
2692
  cell.fontRenderExtension = {
2708
2693
  ...cell === null || cell === void 0 ? void 0 : cell.fontRenderExtension,
2709
2694
  isSkip: (cell === null || cell === void 0 || (_cell$fontRenderExten2 = cell.fontRenderExtension) === null || _cell$fontRenderExten2 === void 0 ? void 0 : _cell$fontRenderExten2.isSkip) || (validator === null || validator === void 0 || (_validator$skipDefaul2 = validator.skipDefaultFontRender) === null || _validator$skipDefaul2 === void 0 ? void 0 : _validator$skipDefaul2.call(validator, rule, cellValue, pos))
@@ -2716,14 +2701,14 @@ let SheetsDataValidationMobileRenderController = class SheetsDataValidationMobil
2716
2701
  } }, row, col)
2717
2702
  };
2718
2703
  cell.interceptorAutoHeight = () => {
2719
- var _this$_renderManagerS3, _mergeCell$startRow3, _mergeCell$startColum3, _validator$canvasRend5, _validator$canvasRend6;
2720
- const skeleton = (_this$_renderManagerS3 = this._renderManagerService.getRenderById(unitId)) === null || _this$_renderManagerS3 === void 0 || (_this$_renderManagerS3 = _this$_renderManagerS3.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _this$_renderManagerS3 === void 0 ? void 0 : _this$_renderManagerS3.skeleton;
2704
+ var _this$_renderManagerS3, _validator$canvasRend5, _validator$canvasRend6;
2705
+ const skeleton = (_this$_renderManagerS3 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS3 === void 0 || (_this$_renderManagerS3 = _this$_renderManagerS3.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _this$_renderManagerS3 === void 0 ? void 0 : _this$_renderManagerS3.skeleton;
2721
2706
  if (!skeleton) return;
2722
2707
  const mergeCell = skeleton.worksheet.getMergedCell(row, col);
2723
2708
  const info = {
2724
2709
  data: cell,
2725
- style: skeleton.getStyles().getStyleByCell(cell),
2726
- primaryWithCoord: skeleton.getCellWithCoordByIndex((_mergeCell$startRow3 = mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startRow) !== null && _mergeCell$startRow3 !== void 0 ? _mergeCell$startRow3 : row, (_mergeCell$startColum3 = mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startColumn) !== null && _mergeCell$startColum3 !== void 0 ? _mergeCell$startColum3 : col),
2710
+ style: workbook.getStyles().getStyleByCell(cell),
2711
+ primaryWithCoord: skeleton.getCellWithCoordByIndex((mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startRow) ?? row, (mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startColumn) ?? col),
2727
2712
  unitId,
2728
2713
  subUnitId,
2729
2714
  row,
@@ -2734,14 +2719,14 @@ let SheetsDataValidationMobileRenderController = class SheetsDataValidationMobil
2734
2719
  return validator === null || validator === void 0 || (_validator$canvasRend5 = validator.canvasRender) === null || _validator$canvasRend5 === void 0 || (_validator$canvasRend6 = _validator$canvasRend5.calcCellAutoHeight) === null || _validator$canvasRend6 === void 0 ? void 0 : _validator$canvasRend6.call(_validator$canvasRend5, info);
2735
2720
  };
2736
2721
  cell.interceptorAutoWidth = () => {
2737
- var _this$_renderManagerS4, _mergeCell$startRow4, _mergeCell$startColum4, _validator$canvasRend7, _validator$canvasRend8;
2738
- const skeleton = (_this$_renderManagerS4 = this._renderManagerService.getRenderById(unitId)) === null || _this$_renderManagerS4 === void 0 || (_this$_renderManagerS4 = _this$_renderManagerS4.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _this$_renderManagerS4 === void 0 ? void 0 : _this$_renderManagerS4.skeleton;
2722
+ var _this$_renderManagerS4, _validator$canvasRend7, _validator$canvasRend8;
2723
+ const skeleton = (_this$_renderManagerS4 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS4 === void 0 || (_this$_renderManagerS4 = _this$_renderManagerS4.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId)) === null || _this$_renderManagerS4 === void 0 ? void 0 : _this$_renderManagerS4.skeleton;
2739
2724
  if (!skeleton) return;
2740
2725
  const mergeCell = skeleton.worksheet.getMergedCell(row, col);
2741
2726
  const info = {
2742
2727
  data: cell,
2743
- style: skeleton.getStyles().getStyleByCell(cell),
2744
- primaryWithCoord: skeleton.getCellWithCoordByIndex((_mergeCell$startRow4 = mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startRow) !== null && _mergeCell$startRow4 !== void 0 ? _mergeCell$startRow4 : row, (_mergeCell$startColum4 = mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startColumn) !== null && _mergeCell$startColum4 !== void 0 ? _mergeCell$startColum4 : col),
2728
+ style: workbook.getStyles().getStyleByCell(cell),
2729
+ primaryWithCoord: skeleton.getCellWithCoordByIndex((mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startRow) ?? row, (mergeCell === null || mergeCell === void 0 ? void 0 : mergeCell.startColumn) ?? col),
2745
2730
  unitId,
2746
2731
  subUnitId,
2747
2732
  row,
@@ -2751,7 +2736,7 @@ let SheetsDataValidationMobileRenderController = class SheetsDataValidationMobil
2751
2736
  };
2752
2737
  return validator === null || validator === void 0 || (_validator$canvasRend7 = validator.canvasRender) === null || _validator$canvasRend7 === void 0 || (_validator$canvasRend8 = _validator$canvasRend7.calcCellAutoWidth) === null || _validator$canvasRend8 === void 0 ? void 0 : _validator$canvasRend8.call(_validator$canvasRend7, info);
2753
2738
  };
2754
- cell.coverable = ((_cell$coverable2 = cell === null || cell === void 0 ? void 0 : cell.coverable) !== null && _cell$coverable2 !== void 0 ? _cell$coverable2 : true) && !(rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE);
2739
+ cell.coverable = ((cell === null || cell === void 0 ? void 0 : cell.coverable) ?? true) && !(rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE);
2755
2740
  return next(cell);
2756
2741
  }
2757
2742
  }));
@@ -2813,11 +2798,10 @@ SheetsDataValidationReRenderController = __decorate([__decorateParam(1, Inject(S
2813
2798
  const MARGIN_H$2 = 6;
2814
2799
  let CheckboxRender = class CheckboxRender {
2815
2800
  _calc(cellInfo, style) {
2816
- var _style$fs, _style$fs2, _style$fs3;
2817
2801
  const { vt, ht } = style || {};
2818
2802
  const width = cellInfo.endX - cellInfo.startX - MARGIN_H$2 * 2;
2819
2803
  const height = cellInfo.endY - cellInfo.startY;
2820
- const size = ((_style$fs = style === null || style === void 0 ? void 0 : style.fs) !== null && _style$fs !== void 0 ? _style$fs : 10) * 1.6;
2804
+ const size = ((style === null || style === void 0 ? void 0 : style.fs) ?? 10) * 1.6;
2821
2805
  let widgetLeft = 0;
2822
2806
  let widgetTop = 0;
2823
2807
  switch (vt) {
@@ -2845,8 +2829,8 @@ let CheckboxRender = class CheckboxRender {
2845
2829
  return {
2846
2830
  left: cellInfo.startX + widgetLeft,
2847
2831
  top: cellInfo.startY + widgetTop,
2848
- width: ((_style$fs2 = style === null || style === void 0 ? void 0 : style.fs) !== null && _style$fs2 !== void 0 ? _style$fs2 : 10) * 1.6,
2849
- height: ((_style$fs3 = style === null || style === void 0 ? void 0 : style.fs) !== null && _style$fs3 !== void 0 ? _style$fs3 : 10) * 1.6
2832
+ width: ((style === null || style === void 0 ? void 0 : style.fs) ?? 10) * 1.6,
2833
+ height: ((style === null || style === void 0 ? void 0 : style.fs) ?? 10) * 1.6
2850
2834
  };
2851
2835
  }
2852
2836
  constructor(_commandService, _univerInstanceService, _formulaService, _themeService, _renderManagerService, _dataValidationModel) {
@@ -2858,14 +2842,12 @@ let CheckboxRender = class CheckboxRender {
2858
2842
  this._dataValidationModel = _dataValidationModel;
2859
2843
  }
2860
2844
  calcCellAutoHeight(info) {
2861
- var _style$fs4;
2862
2845
  const { style } = info;
2863
- return ((_style$fs4 = style === null || style === void 0 ? void 0 : style.fs) !== null && _style$fs4 !== void 0 ? _style$fs4 : 10) * 1.6;
2846
+ return ((style === null || style === void 0 ? void 0 : style.fs) ?? 10) * 1.6;
2864
2847
  }
2865
2848
  calcCellAutoWidth(info) {
2866
- var _style$fs5;
2867
2849
  const { style } = info;
2868
- return ((_style$fs5 = style === null || style === void 0 ? void 0 : style.fs) !== null && _style$fs5 !== void 0 ? _style$fs5 : 10) * 1.6;
2850
+ return ((style === null || style === void 0 ? void 0 : style.fs) ?? 10) * 1.6;
2869
2851
  }
2870
2852
  async _parseFormula(rule, unitId, subUnitId) {
2871
2853
  var _results$, _results$2, _results$3;
@@ -2881,7 +2863,7 @@ let CheckboxRender = class CheckboxRender {
2881
2863
  };
2882
2864
  }
2883
2865
  drawWith(ctx, info) {
2884
- var _validator$skipDefaul, _style$fs6, _style$cl$rgb, _style$cl;
2866
+ var _validator$skipDefaul, _style$cl;
2885
2867
  const { style, primaryWithCoord, unitId, subUnitId, worksheet, row, col } = info;
2886
2868
  const cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
2887
2869
  const value = getCellValueOrigin(worksheet.getCellRaw(row, col));
@@ -2919,14 +2901,14 @@ let CheckboxRender = class CheckboxRender {
2919
2901
  ctx.clip();
2920
2902
  const m = transform.getMatrix();
2921
2903
  ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
2922
- const size = ((_style$fs6 = style === null || style === void 0 ? void 0 : style.fs) !== null && _style$fs6 !== void 0 ? _style$fs6 : 10) * 1.6;
2904
+ const size = ((style === null || style === void 0 ? void 0 : style.fs) ?? 10) * 1.6;
2923
2905
  const checked = String(value) === String(formula1);
2924
2906
  const defaultColor = this._themeService.getColorFromTheme("primary.600");
2925
2907
  CheckboxShape.drawWith(ctx, {
2926
2908
  checked,
2927
2909
  width: size,
2928
2910
  height: size,
2929
- fill: (_style$cl$rgb = style === null || style === void 0 || (_style$cl = style.cl) === null || _style$cl === void 0 ? void 0 : _style$cl.rgb) !== null && _style$cl$rgb !== void 0 ? _style$cl$rgb : defaultColor
2911
+ fill: (style === null || style === void 0 || (_style$cl = style.cl) === null || _style$cl === void 0 ? void 0 : _style$cl.rgb) ?? defaultColor
2930
2912
  });
2931
2913
  ctx.restore();
2932
2914
  }
@@ -3234,7 +3216,6 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
3234
3216
  ctx.restore();
3235
3217
  }
3236
3218
  drawWith(ctx, info, skeleton, spreadsheets) {
3237
- var _ref, _getCellValueOrigin;
3238
3219
  const { primaryWithCoord, row, col, style, data, subUnitId } = info;
3239
3220
  const _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
3240
3221
  const { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = (data === null || data === void 0 ? void 0 : data.fontRenderExtension) || {};
@@ -3255,11 +3236,11 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
3255
3236
  const cellWidth = cellBounding.endX - cellBounding.startX;
3256
3237
  const cellHeight = cellBounding.endY - cellBounding.startY;
3257
3238
  const { cl } = style || {};
3258
- const color = (_ref = typeof cl === "object" ? cl === null || cl === void 0 ? void 0 : cl.rgb : cl) !== null && _ref !== void 0 ? _ref : "#000";
3259
- const fontStyle = getFontStyleString(style !== null && style !== void 0 ? style : void 0);
3239
+ const color = (typeof cl === "object" ? cl === null || cl === void 0 ? void 0 : cl.rgb : cl) ?? "#000";
3240
+ const fontStyle = getFontStyleString(style ?? void 0);
3260
3241
  const { vt: _vt, ht } = style || {};
3261
- const vt = _vt !== null && _vt !== void 0 ? _vt : VerticalAlign.MIDDLE;
3262
- const cellValue = (_getCellValueOrigin = getCellValueOrigin(data)) !== null && _getCellValueOrigin !== void 0 ? _getCellValueOrigin : "";
3242
+ const vt = _vt ?? VerticalAlign.MIDDLE;
3243
+ const cellValue = getCellValueOrigin(data) ?? "";
3263
3244
  const items = validator.parseCellValue(cellValue);
3264
3245
  const labelColorMap = validator.getListWithColorMap(rule);
3265
3246
  const layout = layoutDropdowns(items, fontStyle, cellWidth, cellHeight);
@@ -3317,7 +3298,6 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
3317
3298
  });
3318
3299
  }
3319
3300
  calcCellAutoHeight(info) {
3320
- var _getCellValueOrigin2;
3321
3301
  const { primaryWithCoord, style, data, row, col } = info;
3322
3302
  const { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = (data === null || data === void 0 ? void 0 : data.fontRenderExtension) || {};
3323
3303
  const _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
@@ -3333,11 +3313,10 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
3333
3313
  if (!validator) return;
3334
3314
  const cellWidth = cellBounding.endX - cellBounding.startX;
3335
3315
  const cellHeight = cellBounding.endY - cellBounding.startY;
3336
- const cellValue = (_getCellValueOrigin2 = getCellValueOrigin(data)) !== null && _getCellValueOrigin2 !== void 0 ? _getCellValueOrigin2 : "";
3337
- return layoutDropdowns(validator.parseCellValue(cellValue), getFontStyleString(style !== null && style !== void 0 ? style : void 0), cellWidth, cellHeight).cellAutoHeight;
3316
+ const cellValue = getCellValueOrigin(data) ?? "";
3317
+ return layoutDropdowns(validator.parseCellValue(cellValue), getFontStyleString(style ?? void 0), cellWidth, cellHeight).cellAutoHeight;
3338
3318
  }
3339
3319
  calcCellAutoWidth(info) {
3340
- var _getCellValueOrigin3;
3341
3320
  const { primaryWithCoord, style, data, row, col } = info;
3342
3321
  const { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = (data === null || data === void 0 ? void 0 : data.fontRenderExtension) || {};
3343
3322
  const _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
@@ -3353,8 +3332,8 @@ let DropdownMultipleWidget = class DropdownMultipleWidget {
3353
3332
  if (!validator) return;
3354
3333
  const cellWidth = cellBounding.endX - cellBounding.startX;
3355
3334
  const cellHeight = cellBounding.endY - cellBounding.startY;
3356
- const cellValue = (_getCellValueOrigin3 = getCellValueOrigin(data)) !== null && _getCellValueOrigin3 !== void 0 ? _getCellValueOrigin3 : "";
3357
- return layoutDropdowns(validator.parseCellValue(cellValue), getFontStyleString(style !== null && style !== void 0 ? style : void 0), cellWidth, cellHeight).calcAutoWidth;
3335
+ const cellValue = getCellValueOrigin(data) ?? "";
3336
+ return layoutDropdowns(validator.parseCellValue(cellValue), getFontStyleString(style ?? void 0), cellWidth, cellHeight).calcAutoWidth;
3358
3337
  }
3359
3338
  isHit(position, info) {
3360
3339
  const { primaryWithCoord } = info;
@@ -3507,7 +3486,6 @@ let DropdownWidget = class DropdownWidget {
3507
3486
  ctx.restore();
3508
3487
  }
3509
3488
  drawWith(ctx, info, skeleton) {
3510
- var _tb, _vt, _ht, _pd;
3511
3489
  const { primaryWithCoord, row, col, style, data, subUnitId } = info;
3512
3490
  const _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
3513
3491
  const _row = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo.startRow : row;
@@ -3530,14 +3508,13 @@ let DropdownWidget = class DropdownWidget {
3530
3508
  const map = this._ensureMap(subUnitId);
3531
3509
  const key = this._generateKey(row, col);
3532
3510
  const colorMap = validator.getListWithColorMap(rule);
3533
- const value = getCellValueOrigin(data);
3534
- const valueStr = `${value !== null && value !== void 0 ? value : ""}`;
3511
+ const valueStr = `${getCellValueOrigin(data) ?? ""}`;
3535
3512
  const activeColor = colorMap[valueStr];
3536
3513
  let { tb, vt, ht, pd } = style || {};
3537
- tb = (_tb = tb) !== null && _tb !== void 0 ? _tb : WrapStrategy.WRAP;
3538
- vt = (_vt = vt) !== null && _vt !== void 0 ? _vt : VerticalAlign.BOTTOM;
3539
- ht = (_ht = ht) !== null && _ht !== void 0 ? _ht : DEFAULT_STYLES.ht;
3540
- pd = (_pd = pd) !== null && _pd !== void 0 ? _pd : DEFAULT_STYLES.pd;
3514
+ tb = tb ?? WrapStrategy.WRAP;
3515
+ vt = vt ?? VerticalAlign.BOTTOM;
3516
+ ht = ht ?? DEFAULT_STYLES.ht;
3517
+ pd = pd ?? DEFAULT_STYLES.pd;
3541
3518
  const fontStyle = getFontStyleString(style).fontCache;
3542
3519
  if (rule.renderMode === DataValidationRenderMode.ARROW) {
3543
3520
  var _style$cl, _style$st, _style$ul;
@@ -3631,7 +3608,6 @@ let DropdownWidget = class DropdownWidget {
3631
3608
  }
3632
3609
  }
3633
3610
  calcCellAutoHeight(info) {
3634
- var _tb2;
3635
3611
  const { primaryWithCoord, style, data, row, col } = info;
3636
3612
  const _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
3637
3613
  const { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = (data === null || data === void 0 ? void 0 : data.fontRenderExtension) || {};
@@ -3645,13 +3621,12 @@ let DropdownWidget = class DropdownWidget {
3645
3621
  endY: _cellBounding.endY - downOffset
3646
3622
  };
3647
3623
  const cellWidth = cellBounding.endX - cellBounding.startX;
3648
- const value = getCellValueOrigin(data);
3649
- const valueStr = `${value !== null && value !== void 0 ? value : ""}`;
3624
+ const valueStr = `${getCellValueOrigin(data) ?? ""}`;
3650
3625
  let { tb, pd } = style || {};
3651
- const { t = DEFAULT_STYLES.pd.t, b = DEFAULT_STYLES.pd.b } = pd !== null && pd !== void 0 ? pd : {};
3652
- tb = (_tb2 = tb) !== null && _tb2 !== void 0 ? _tb2 : WrapStrategy.WRAP;
3626
+ const { t = DEFAULT_STYLES.pd.t, b = DEFAULT_STYLES.pd.b } = pd ?? {};
3627
+ tb = tb ?? WrapStrategy.WRAP;
3653
3628
  if (rule.renderMode === DataValidationRenderMode.ARROW) {
3654
- const { l = DEFAULT_STYLES.pd.l, r = DEFAULT_STYLES.pd.r } = pd !== null && pd !== void 0 ? pd : {};
3629
+ const { l = DEFAULT_STYLES.pd.l, r = DEFAULT_STYLES.pd.r } = pd ?? {};
3655
3630
  const realWidth = cellWidth - l - r - ICON_PLACE - 4;
3656
3631
  const skeleton = new DocSimpleSkeleton(valueStr, getFontStyleString(style).fontCache, Boolean(tb === WrapStrategy.WRAP), realWidth, Infinity);
3657
3632
  skeleton.calculate();
@@ -3664,7 +3639,6 @@ let DropdownWidget = class DropdownWidget {
3664
3639
  }
3665
3640
  }
3666
3641
  calcCellAutoWidth(info) {
3667
- var _tb3;
3668
3642
  const { primaryWithCoord, style, data, row, col } = info;
3669
3643
  const cellRange = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord;
3670
3644
  const { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = (data === null || data === void 0 ? void 0 : data.fontRenderExtension) || {};
@@ -3678,11 +3652,10 @@ let DropdownWidget = class DropdownWidget {
3678
3652
  endY: cellRange.endY - downOffset
3679
3653
  };
3680
3654
  const cellWidth = cellBounding.endX - cellBounding.startX;
3681
- const value = getCellValueOrigin(data);
3682
- const valueStr = `${value !== null && value !== void 0 ? value : ""}`;
3655
+ const valueStr = `${getCellValueOrigin(data) ?? ""}`;
3683
3656
  let { tb, pd } = style || {};
3684
- const { l = DEFAULT_STYLES.pd.l, r = DEFAULT_STYLES.pd.r } = pd !== null && pd !== void 0 ? pd : {};
3685
- tb = (_tb3 = tb) !== null && _tb3 !== void 0 ? _tb3 : WrapStrategy.WRAP;
3657
+ const { l = DEFAULT_STYLES.pd.l, r = DEFAULT_STYLES.pd.r } = pd ?? {};
3658
+ tb = tb ?? WrapStrategy.WRAP;
3686
3659
  let paddingAll = 26;
3687
3660
  switch (rule.renderMode) {
3688
3661
  case DataValidationRenderMode.ARROW:
@@ -3893,6 +3866,7 @@ _defineProperty(UniverSheetsDataValidationMobileUIPlugin, "packageName", name);
3893
3866
  _defineProperty(UniverSheetsDataValidationMobileUIPlugin, "version", version);
3894
3867
  _defineProperty(UniverSheetsDataValidationMobileUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
3895
3868
  UniverSheetsDataValidationMobileUIPlugin = __decorate([
3869
+ DependentOn(UniverDataValidationPlugin, UniverRenderEnginePlugin, UniverSheetsPlugin, UniverMobileUIPlugin, UniverSheetsMobileUIPlugin, UniverSheetsDataValidationPlugin),
3896
3870
  __decorateParam(1, Inject(Injector)),
3897
3871
  __decorateParam(2, ICommandService),
3898
3872
  __decorateParam(3, IConfigService)
@@ -3960,7 +3934,7 @@ _defineProperty(UniverSheetsDataValidationUIPlugin, "packageName", name);
3960
3934
  _defineProperty(UniverSheetsDataValidationUIPlugin, "version", version);
3961
3935
  _defineProperty(UniverSheetsDataValidationUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
3962
3936
  UniverSheetsDataValidationUIPlugin = __decorate([
3963
- DependentOn(UniverSheetsDataValidationPlugin),
3937
+ DependentOn(UniverDataValidationPlugin, UniverRenderEnginePlugin, UniverSheetsPlugin, UniverSheetsUIPlugin, UniverSheetsDataValidationPlugin),
3964
3938
  __decorateParam(1, Inject(Injector)),
3965
3939
  __decorateParam(2, ICommandService),
3966
3940
  __decorateParam(3, IConfigService)