@univerjs/sheets-table-ui 1.0.0-alpha.8 → 1.0.0-beta.1

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.
Files changed (88) hide show
  1. package/lib/cjs/index.js +342 -359
  2. package/lib/cjs/locale/ar-SA.js +1 -2
  3. package/lib/cjs/locale/ca-ES.js +4 -5
  4. package/lib/cjs/locale/de-DE.js +1 -2
  5. package/lib/cjs/locale/en-US.js +1 -2
  6. package/lib/cjs/locale/es-ES.js +1 -2
  7. package/lib/cjs/locale/fa-IR.js +1 -2
  8. package/lib/cjs/locale/fr-FR.js +1 -2
  9. package/lib/cjs/locale/id-ID.js +1 -2
  10. package/lib/cjs/locale/it-IT.js +1 -2
  11. package/lib/cjs/locale/ja-JP.js +1 -2
  12. package/lib/cjs/locale/ko-KR.js +1 -2
  13. package/lib/cjs/locale/pl-PL.js +1 -2
  14. package/lib/cjs/locale/pt-BR.js +1 -2
  15. package/lib/cjs/locale/ru-RU.js +1 -2
  16. package/lib/cjs/locale/sk-SK.js +1 -2
  17. package/lib/cjs/locale/vi-VN.js +1 -2
  18. package/lib/cjs/locale/zh-CN.js +1 -2
  19. package/lib/cjs/locale/zh-HK.js +14 -15
  20. package/lib/cjs/locale/zh-TW.js +14 -15
  21. package/lib/es/index.js +346 -363
  22. package/lib/es/locale/ar-SA.js +1 -2
  23. package/lib/es/locale/ca-ES.js +4 -5
  24. package/lib/es/locale/de-DE.js +1 -2
  25. package/lib/es/locale/en-US.js +1 -2
  26. package/lib/es/locale/es-ES.js +1 -2
  27. package/lib/es/locale/fa-IR.js +1 -2
  28. package/lib/es/locale/fr-FR.js +1 -2
  29. package/lib/es/locale/id-ID.js +1 -2
  30. package/lib/es/locale/it-IT.js +1 -2
  31. package/lib/es/locale/ja-JP.js +1 -2
  32. package/lib/es/locale/ko-KR.js +1 -2
  33. package/lib/es/locale/pl-PL.js +1 -2
  34. package/lib/es/locale/pt-BR.js +1 -2
  35. package/lib/es/locale/ru-RU.js +1 -2
  36. package/lib/es/locale/sk-SK.js +1 -2
  37. package/lib/es/locale/vi-VN.js +1 -2
  38. package/lib/es/locale/zh-CN.js +1 -2
  39. package/lib/es/locale/zh-HK.js +14 -15
  40. package/lib/es/locale/zh-TW.js +14 -15
  41. package/lib/index.css +187 -67
  42. package/lib/index.js +346 -363
  43. package/lib/locale/ar-SA.js +1 -2
  44. package/lib/locale/ca-ES.js +4 -5
  45. package/lib/locale/de-DE.js +1 -2
  46. package/lib/locale/en-US.js +1 -2
  47. package/lib/locale/es-ES.js +1 -2
  48. package/lib/locale/fa-IR.js +1 -2
  49. package/lib/locale/fr-FR.js +1 -2
  50. package/lib/locale/id-ID.js +1 -2
  51. package/lib/locale/it-IT.js +1 -2
  52. package/lib/locale/ja-JP.js +1 -2
  53. package/lib/locale/ko-KR.js +1 -2
  54. package/lib/locale/pl-PL.js +1 -2
  55. package/lib/locale/pt-BR.js +1 -2
  56. package/lib/locale/ru-RU.js +1 -2
  57. package/lib/locale/sk-SK.js +1 -2
  58. package/lib/locale/vi-VN.js +1 -2
  59. package/lib/locale/zh-CN.js +1 -2
  60. package/lib/locale/zh-HK.js +14 -15
  61. package/lib/locale/zh-TW.js +14 -15
  62. package/lib/types/const.d.ts +1 -0
  63. package/lib/types/controllers/sheet-table-controls-render.controller.d.ts +6 -2
  64. package/lib/types/locale/en-US.d.ts +1 -2
  65. package/lib/types/views/components/SheetTableMenu.d.ts +29 -0
  66. package/lib/types/views/widgets/table-controls-util.d.ts +1 -7
  67. package/lib/types/views/widgets/table-controls.shape.d.ts +1 -9
  68. package/lib/umd/index.js +1 -1
  69. package/lib/umd/locale/ar-SA.js +1 -1
  70. package/lib/umd/locale/ca-ES.js +1 -1
  71. package/lib/umd/locale/de-DE.js +1 -1
  72. package/lib/umd/locale/en-US.js +1 -1
  73. package/lib/umd/locale/es-ES.js +1 -1
  74. package/lib/umd/locale/fa-IR.js +1 -1
  75. package/lib/umd/locale/fr-FR.js +1 -1
  76. package/lib/umd/locale/id-ID.js +1 -1
  77. package/lib/umd/locale/it-IT.js +1 -1
  78. package/lib/umd/locale/ja-JP.js +1 -1
  79. package/lib/umd/locale/ko-KR.js +1 -1
  80. package/lib/umd/locale/pl-PL.js +1 -1
  81. package/lib/umd/locale/pt-BR.js +1 -1
  82. package/lib/umd/locale/ru-RU.js +1 -1
  83. package/lib/umd/locale/sk-SK.js +1 -1
  84. package/lib/umd/locale/vi-VN.js +1 -1
  85. package/lib/umd/locale/zh-CN.js +1 -1
  86. package/lib/umd/locale/zh-HK.js +1 -1
  87. package/lib/umd/locale/zh-TW.js +1 -1
  88. package/package.json +14 -14
package/lib/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { AddSheetTableCommand, AddTableThemeCommand, DeleteSheetTableCommand, RemoveTableThemeCommand, SHEET_TABLE_CUSTOM_THEME_PREFIX, SetSheetTableCommand, SetSheetTableFilterCommand, SheetTableInsertColCommand, SheetTableInsertColumnAtCommand, SheetTableInsertRowAtCommand, SheetTableInsertRowCommand, SheetTableRemoveColCommand, SheetTableRemoveColumnAtCommand, SheetTableRemoveRowCommand, SheetTableService, SheetsTableController, SheetsTableSortStateEnum, TABLE_FILTER_EMPTY_VALUE, TableColumnFilterTypeEnum, TableConditionTypeEnum, TableDateCompareTypeEnum, TableManager, TableNumberCompareTypeEnum, TableStringCompareTypeEnum, UniverSheetsTablePlugin, customEmptyThemeWithBorderStyle, getExistingNamesSet, isConditionFilter, isManualTableFilter, processStyleWithBorderStyle, validateSheetTableName } from "@univerjs/sheets-table";
2
- import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IDialogService, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonDataGroup, UniverUIPlugin, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
2
+ import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IDialogService, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonDataGroup, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
3
3
  import { ColorKit, CommandType, DependentOn, Disposable, ErrorService, ICommandService, IConfigService, IContextService, IPermissionService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, ObjectMatrix, Plugin, Rectangle, RxDisposable, UniverInstanceType, VerticalAlign, cellToRange, fromCallback, merge, registerDependencies, toDisposable, touchDependencies } from "@univerjs/core";
4
4
  import { INTERCEPTOR_POINT, RangeThemeStyle, SelectRangeCommand, SetRangeThemeMutation, SetRangeValuesMutation, SetSelectionsOperation, SetVerticalTextAlignCommand, SheetInterceptorService, SheetRangeThemeModel, SheetsSelectionsService, UniverSheetsPlugin, WorkbookEditablePermission, WorkbookPermissionService, expandToContinuousRange, getPrimaryForRange, getSheetCommandTarget, isSingleCellSelection } from "@univerjs/sheets";
5
5
  import { ExpandSelectionCommand, ISheetSelectionRenderService, MoveSelectionCommand, MoveSelectionEnterAndTabCommand, SHEET_VIEW_KEY, SelectAllCommand, SetScrollOperation, SetZoomRatioOperation, SheetCanvasPopManagerService, SheetSkeletonManagerService, UniverSheetsUIPlugin, getCoordByCell, getCurrentRangeDisable$, getTransformCoord } from "@univerjs/sheets-ui";
6
6
  import { Subject, distinctUntilChanged, filter, map, merge as merge$1, of, startWith, switchMap, takeUntil } from "rxjs";
7
- import { CURSOR_TYPE, DEFAULT_FONTFACE_PLANE, IRenderManagerService, Rect, Shape, UniverRenderEnginePlugin } from "@univerjs/engine-render";
8
- import { AscendingIcon, DeleteColumnDoubleIcon, DescendingIcon, DownIcon, LeftInsertColumnDoubleIcon, MoreDownIcon, RightInsertColumnDoubleIcon, TableIcon } from "@univerjs/icons";
9
- import { Button, ButtonGroup, CascaderList, Checkbox, ColorPicker, DatePicker, DateRangePicker, Dropdown, Input, InputNumber, Segmented, Select, borderClassName, clsx, scrollbarClassName } from "@univerjs/design";
7
+ import { CURSOR_TYPE, DEFAULT_FONTFACE_PLANE, IRenderManagerService, Shape, UniverRenderEnginePlugin } from "@univerjs/engine-render";
8
+ import { AscendingIcon, CloseIcon, DeleteColumnDoubleIcon, DescendingIcon, DownIcon, IncreaseIcon, LeftInsertColumnDoubleIcon, MoreDownIcon, RightInsertColumnDoubleIcon, TableIcon } from "@univerjs/icons";
9
+ import { Button, ButtonGroup, CascaderList, Checkbox, ColorPicker, DatePicker, DateRangePicker, Dropdown, DropdownMenu, Input, InputNumber, Segmented, Select, borderClassName, clsx, scrollbarClassName } from "@univerjs/design";
10
10
  import { SortRangeCommand, SortType } from "@univerjs/sheets-sort";
11
11
  import { useCallback, useEffect, useMemo, useState } from "react";
12
12
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -37,6 +37,7 @@ const SHEET_TABLE_RENAME_DIALOG = "SHEET_TABLE_RENAME_DIALOG";
37
37
  const SHEET_TABLE_RENAME_DIALOG_ID = "SHEET_TABLE_RENAME_DIALOG_ID";
38
38
  const SHEET_TABLE_THEME_PANEL_ID = "SHEET_TABLE_THEME_PANEL_ID";
39
39
  const SHEET_TABLE_THEME_PANEL = "SHEET_TABLE_THEME_PANEL";
40
+ const SHEET_TABLE_MENU = "SHEET_TABLE_MENU";
40
41
  const TABLE_CUSTOM_NAME_PREFIX = "table-custom-";
41
42
  const TABLE_DEFAULT_NAME_PREFIX = "table-default-";
42
43
  const TABLE_DEFAULT_BG_COLOR = "rgb(255, 255, 255)";
@@ -49,14 +50,13 @@ const OpenTableSelectorOperation = {
49
50
  type: CommandType.OPERATION,
50
51
  id: "sheet.operation.open-table-selector",
51
52
  async handler(accessor) {
52
- var _lastSelection$range;
53
53
  const univerInstanceService = accessor.get(IUniverInstanceService);
54
54
  const commandService = accessor.get(ICommandService);
55
55
  const target = getSheetCommandTarget(univerInstanceService);
56
56
  if (!target) return false;
57
57
  const { unitId, subUnitId, worksheet } = target;
58
58
  const lastSelection = accessor.get(SheetsSelectionsService).getCurrentLastSelection();
59
- const range = (_lastSelection$range = lastSelection === null || lastSelection === void 0 ? void 0 : lastSelection.range) !== null && _lastSelection$range !== void 0 ? _lastSelection$range : {
59
+ const range = (lastSelection === null || lastSelection === void 0 ? void 0 : lastSelection.range) ?? {
60
60
  startRow: 0,
61
61
  endRow: 0,
62
62
  startColumn: 0,
@@ -248,7 +248,7 @@ const menuSchema = {
248
248
  //#endregion
249
249
  //#region package.json
250
250
  var name = "@univerjs/sheets-table-ui";
251
- var version = "1.0.0-alpha.8";
251
+ var version = "1.0.0-beta.1";
252
252
 
253
253
  //#endregion
254
254
  //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
@@ -899,7 +899,7 @@ function getInitConditionInfo(tableFilter) {
899
899
  //#endregion
900
900
  //#region src/views/components/SheetTableConditionPanel.tsx
901
901
  const SheetTableConditionPanel = (props) => {
902
- var _conditionInfo$info$d, _conditionInfo$info$d2, _conditionInfo$info$d3, _conditionInfo$info$d4, _conditionInfo$info$d5, _conditionInfo$info$n, _conditionInfo$info$n3, _conditionInfo$info$d6;
902
+ var _conditionInfo$info$d, _conditionInfo$info$d2, _conditionInfo$info$n, _conditionInfo$info$n3;
903
903
  const { conditionInfo, onChange } = props;
904
904
  const localeService = useDependency(LocaleService);
905
905
  const [conditionVisible, setConditionVisible] = useState(false);
@@ -907,13 +907,12 @@ const SheetTableConditionPanel = (props) => {
907
907
  const cascaderOptions = getCascaderListOptions(injector);
908
908
  const handleConditionInfo = (info, type, compare) => {
909
909
  onChange({
910
- type: type !== null && type !== void 0 ? type : conditionInfo.type,
911
- compare: compare !== null && compare !== void 0 ? compare : conditionInfo.compare,
910
+ type: type ?? conditionInfo.type,
911
+ compare: compare ?? conditionInfo.compare,
912
912
  info
913
913
  });
914
914
  };
915
915
  const handleChange = (value) => {
916
- var _ref;
917
916
  const type = value[0];
918
917
  const compare = value[1];
919
918
  if (compare) setConditionVisible(false);
@@ -924,7 +923,7 @@ const SheetTableConditionPanel = (props) => {
924
923
  else info.dateRange = [/* @__PURE__ */ new Date(), /* @__PURE__ */ new Date()];
925
924
  else if (type === TableConditionTypeEnum.Number) info.number = 0;
926
925
  else if (type === TableConditionTypeEnum.String) info.string = "";
927
- handleConditionInfo(info, value[0], (_ref = value[1]) !== null && _ref !== void 0 ? _ref : TableStringCompareTypeEnum.Equal);
926
+ handleConditionInfo(info, value[0], value[1] ?? TableStringCompareTypeEnum.Equal);
928
927
  };
929
928
  const subComponentType = getSubComponentType(conditionInfo.type, conditionInfo.compare);
930
929
  let selectType = "";
@@ -943,7 +942,7 @@ const SheetTableConditionPanel = (props) => {
943
942
  wrapperClassName: "!univer-h-[150px]"
944
943
  }),
945
944
  children: /* @__PURE__ */ jsxs("div", {
946
- className: clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-2 univer-text-sm univer-transition-colors univer-duration-200 hover:univer-border-primary-600 focus:univer-border-primary-600 focus:univer-outline-none focus:univer-ring-2 dark:!univer-bg-gray-700 dark:!univer-text-white", borderClassName),
945
+ className: clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-gray-0 univer-px-2 univer-text-sm univer-transition-colors univer-duration-200 hover:univer-border-primary-600 focus:univer-border-primary-600 focus:univer-outline-none focus:univer-ring-2 dark:!univer-bg-gray-700 dark:!univer-text-gray-0", borderClassName),
947
946
  children: [/* @__PURE__ */ jsx("span", { children: selectType }), /* @__PURE__ */ jsx(MoreDownIcon, {})]
948
947
  })
949
948
  }), /* @__PURE__ */ jsxs("div", {
@@ -951,7 +950,7 @@ const SheetTableConditionPanel = (props) => {
951
950
  children: [
952
951
  subComponentType === "Input" && /* @__PURE__ */ jsx(Fragment, { children: conditionInfo.type === TableConditionTypeEnum.String ? /* @__PURE__ */ jsx(Input, {
953
952
  className: "univer-w-full",
954
- placeholder: "请输入",
953
+ placeholder: localeService.t("sheets-table-ui.filter.input-values-placeholder"),
955
954
  value: conditionInfo.info.string,
956
955
  onChange: (v) => handleConditionInfo({ string: v })
957
956
  }) : /* @__PURE__ */ jsx(InputNumber, {
@@ -966,7 +965,7 @@ const SheetTableConditionPanel = (props) => {
966
965
  id: "univer-table-date-picker-wrapper",
967
966
  children: /* @__PURE__ */ jsx(DatePicker, {
968
967
  className: "univer-w-full",
969
- value: (_conditionInfo$info$d = conditionInfo.info.date) !== null && _conditionInfo$info$d !== void 0 ? _conditionInfo$info$d : /* @__PURE__ */ new Date(),
968
+ value: conditionInfo.info.date ?? /* @__PURE__ */ new Date(),
970
969
  onValueChange: (v) => handleConditionInfo({ date: v })
971
970
  })
972
971
  }),
@@ -974,7 +973,7 @@ const SheetTableConditionPanel = (props) => {
974
973
  id: "univer-table-date-range-wrapper",
975
974
  children: /* @__PURE__ */ jsx(DateRangePicker, {
976
975
  className: "univer-w-full",
977
- value: [(_conditionInfo$info$d2 = (_conditionInfo$info$d3 = conditionInfo.info.dateRange) === null || _conditionInfo$info$d3 === void 0 ? void 0 : _conditionInfo$info$d3[0]) !== null && _conditionInfo$info$d2 !== void 0 ? _conditionInfo$info$d2 : /* @__PURE__ */ new Date(), (_conditionInfo$info$d4 = (_conditionInfo$info$d5 = conditionInfo.info.dateRange) === null || _conditionInfo$info$d5 === void 0 ? void 0 : _conditionInfo$info$d5[1]) !== null && _conditionInfo$info$d4 !== void 0 ? _conditionInfo$info$d4 : /* @__PURE__ */ new Date()],
976
+ value: [((_conditionInfo$info$d = conditionInfo.info.dateRange) === null || _conditionInfo$info$d === void 0 ? void 0 : _conditionInfo$info$d[0]) ?? /* @__PURE__ */ new Date(), ((_conditionInfo$info$d2 = conditionInfo.info.dateRange) === null || _conditionInfo$info$d2 === void 0 ? void 0 : _conditionInfo$info$d2[1]) ?? /* @__PURE__ */ new Date()],
978
977
  onValueChange: (v) => {
979
978
  if (v) handleConditionInfo({ dateRange: v });
980
979
  else handleConditionInfo({});
@@ -1011,7 +1010,7 @@ const SheetTableConditionPanel = (props) => {
1011
1010
  }),
1012
1011
  !!(subComponentType === "Select") && /* @__PURE__ */ jsx(Select, {
1013
1012
  className: "univer-w-full",
1014
- value: (_conditionInfo$info$d6 = conditionInfo.info.dateSelect) !== null && _conditionInfo$info$d6 !== void 0 ? _conditionInfo$info$d6 : conditionDateOptions[0].value,
1013
+ value: conditionInfo.info.dateSelect ?? conditionDateOptions[0].value,
1015
1014
  options: conditionDateOptions,
1016
1015
  onChange: (v) => handleConditionInfo({ dateSelect: v })
1017
1016
  })
@@ -1024,8 +1023,7 @@ const SheetTableConditionPanel = (props) => {
1024
1023
  const getCheckedItemCount = (map, checkedItemSet) => {
1025
1024
  let count = 0;
1026
1025
  checkedItemSet.forEach((item) => {
1027
- var _map$get;
1028
- count += (_map$get = map.get(item)) !== null && _map$get !== void 0 ? _map$get : 0;
1026
+ count += map.get(item) ?? 0;
1029
1027
  });
1030
1028
  return count;
1031
1029
  };
@@ -1277,14 +1275,14 @@ function SheetTableFilterPanel() {
1277
1275
  };
1278
1276
  const workbookEditableId = new WorkbookEditablePermission(unitId).id;
1279
1277
  return /* @__PURE__ */ jsxs("div", {
1280
- className: "univer-box-border univer-flex univer-w-[400px] univer-flex-col univer-rounded-[10px] univer-bg-white univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700",
1278
+ className: "univer-box-border univer-flex univer-w-[400px] univer-flex-col univer-rounded-[10px] univer-bg-gray-0 univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700",
1281
1279
  children: [
1282
1280
  ((_permissionService$ge = permissionService.getPermissionPoint(workbookEditableId)) === null || _permissionService$ge === void 0 ? void 0 : _permissionService$ge.value) && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
1283
1281
  className: "-univer-mx-4 -univer-mt-2 univer-mb-3 univer-border-0 univer-border-b univer-border-solid univer-border-gray-200 univer-py-1",
1284
1282
  children: [
1285
1283
  /* @__PURE__ */ jsxs("button", {
1286
1284
  type: "button",
1287
- className: "univer-box-border univer-flex univer-h-10 univer-w-full univer-cursor-pointer univer-items-center univer-gap-3 univer-border-none univer-bg-transparent univer-px-4 univer-text-left univer-text-sm univer-text-gray-900 hover:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-text-gray-400 dark:!univer-text-white dark:hover:!univer-bg-gray-600",
1285
+ className: "univer-box-border univer-flex univer-h-10 univer-w-full univer-cursor-pointer univer-items-center univer-gap-3 univer-border-none univer-bg-transparent univer-px-4 univer-text-left univer-text-sm univer-text-gray-900 hover:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-text-gray-400 dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-600",
1288
1286
  onClick: () => insertColumn("left"),
1289
1287
  children: [/* @__PURE__ */ jsx(LeftInsertColumnDoubleIcon, {
1290
1288
  className: "univer-size-5",
@@ -1293,7 +1291,7 @@ function SheetTableFilterPanel() {
1293
1291
  }),
1294
1292
  /* @__PURE__ */ jsxs("button", {
1295
1293
  type: "button",
1296
- className: "univer-box-border univer-flex univer-h-10 univer-w-full univer-cursor-pointer univer-items-center univer-gap-3 univer-border-none univer-bg-transparent univer-px-4 univer-text-left univer-text-sm univer-text-gray-900 hover:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-text-gray-400 dark:!univer-text-white dark:hover:!univer-bg-gray-600",
1294
+ className: "univer-box-border univer-flex univer-h-10 univer-w-full univer-cursor-pointer univer-items-center univer-gap-3 univer-border-none univer-bg-transparent univer-px-4 univer-text-left univer-text-sm univer-text-gray-900 hover:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-text-gray-400 dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-600",
1297
1295
  onClick: () => insertColumn("right"),
1298
1296
  children: [/* @__PURE__ */ jsx(RightInsertColumnDoubleIcon, {
1299
1297
  className: "univer-size-5",
@@ -1302,7 +1300,7 @@ function SheetTableFilterPanel() {
1302
1300
  }),
1303
1301
  /* @__PURE__ */ jsxs("button", {
1304
1302
  type: "button",
1305
- className: "univer-box-border univer-flex univer-h-10 univer-w-full univer-cursor-pointer univer-items-center univer-gap-3 univer-border-none univer-bg-transparent univer-px-4 univer-text-left univer-text-sm univer-text-gray-900 hover:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-text-gray-400 dark:!univer-text-white dark:hover:!univer-bg-gray-600",
1303
+ className: "univer-box-border univer-flex univer-h-10 univer-w-full univer-cursor-pointer univer-items-center univer-gap-3 univer-border-none univer-bg-transparent univer-px-4 univer-text-left univer-text-sm univer-text-gray-900 hover:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-text-gray-400 dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-600",
1306
1304
  disabled: !canDeleteColumn,
1307
1305
  onClick: deleteColumn,
1308
1306
  children: [/* @__PURE__ */ jsx(DeleteColumnDoubleIcon, {
@@ -1363,24 +1361,71 @@ function SheetTableFilterPanel() {
1363
1361
  disabled: tableFilter === void 0,
1364
1362
  onClick: onClearFilter,
1365
1363
  children: localeService.t("sheets-table-ui.filter.clear-filter")
1366
- }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Button, {
1367
- className: "univer-mr-2",
1368
- onClick: onCancel,
1369
- children: localeService.t("sheets-table-ui.filter.cancel")
1370
- }), /* @__PURE__ */ jsx(Button, {
1371
- variant: "primary",
1372
- onClick: onApply,
1373
- children: localeService.t("sheets-table-ui.filter.confirm")
1374
- })] })]
1364
+ }), /* @__PURE__ */ jsxs("div", {
1365
+ className: "univer-flex univer-gap-x-2",
1366
+ children: [/* @__PURE__ */ jsx(Button, {
1367
+ onClick: onCancel,
1368
+ children: localeService.t("sheets-table-ui.filter.cancel")
1369
+ }), /* @__PURE__ */ jsx(Button, {
1370
+ variant: "primary",
1371
+ onClick: onApply,
1372
+ children: localeService.t("sheets-table-ui.filter.confirm")
1373
+ })]
1374
+ })]
1375
1375
  })
1376
1376
  ]
1377
1377
  });
1378
1378
  }
1379
1379
 
1380
+ //#endregion
1381
+ //#region src/views/components/SheetTableMenu.tsx
1382
+ function SheetTableMenu({ popup }) {
1383
+ const menu = popup.extraProps;
1384
+ if (!menu) return null;
1385
+ return /* @__PURE__ */ jsx(DropdownMenu, {
1386
+ align: "start",
1387
+ className: "univer-min-w-40",
1388
+ items: [
1389
+ {
1390
+ type: "item",
1391
+ children: menu.labels.rename,
1392
+ onSelect: () => menu.onSelect("rename")
1393
+ },
1394
+ {
1395
+ type: "item",
1396
+ children: menu.labels["update-range"],
1397
+ onSelect: () => menu.onSelect("update-range")
1398
+ },
1399
+ {
1400
+ type: "item",
1401
+ children: menu.labels["set-theme"],
1402
+ onSelect: () => menu.onSelect("set-theme")
1403
+ },
1404
+ {
1405
+ type: "item",
1406
+ children: menu.labels.delete,
1407
+ variant: "destructive",
1408
+ onSelect: () => menu.onSelect("delete")
1409
+ }
1410
+ ],
1411
+ open: true,
1412
+ sideOffset: 0,
1413
+ onOpenChange: (open) => {
1414
+ if (!open) menu.onClose();
1415
+ },
1416
+ children: /* @__PURE__ */ jsx("button", {
1417
+ type: "button",
1418
+ "aria-label": menu.tableName,
1419
+ className: "univer-block univer-h-px univer-opacity-0",
1420
+ style: { width: menu.anchorWidth },
1421
+ tabIndex: -1
1422
+ })
1423
+ });
1424
+ }
1425
+
1380
1426
  //#endregion
1381
1427
  //#region src/views/components/SheetTableRenameDialog.tsx
1382
1428
  function SheetTableRenameDialog(props) {
1383
- var _table$getDisplayName;
1384
1429
  const { unitId, tableId, onClose } = props;
1385
1430
  const localeService = useDependency(LocaleService);
1386
1431
  const commandService = useDependency(ICommandService);
@@ -1388,7 +1433,7 @@ function SheetTableRenameDialog(props) {
1388
1433
  const univerInstanceService = useDependency(IUniverInstanceService);
1389
1434
  const definedNamesService = useDependency(IDefinedNamesService);
1390
1435
  const table = tableManager.getTableById(unitId, tableId);
1391
- const [value, setValue] = useState((_table$getDisplayName = table === null || table === void 0 ? void 0 : table.getDisplayName()) !== null && _table$getDisplayName !== void 0 ? _table$getDisplayName : "");
1436
+ const [value, setValue] = useState((table === null || table === void 0 ? void 0 : table.getDisplayName()) ?? "");
1392
1437
  const [error, setError] = useState("");
1393
1438
  const existingNames = useMemo(() => {
1394
1439
  const names = getExistingNamesSet(unitId, {
@@ -1576,7 +1621,7 @@ SheetTableThemeUIController = __decorate([__decorateParam(0, Inject(ICommandServ
1576
1621
  //#endregion
1577
1622
  //#region src/views/components/SheetTableThemePanel.tsx
1578
1623
  const SheetTableThemePanel = (props) => {
1579
- var _customStyle$getHeade, _customStyle$getHeade2, _customStyle$getFirst, _customStyle$getFirst2, _customStyle$getSecon, _customStyle$getSecon2, _customStyle$getLastR, _customStyle$getLastR2;
1624
+ var _customStyle$getHeade, _customStyle$getFirst, _customStyle$getSecon, _customStyle$getLastR;
1580
1625
  const { unitId, subUnitId, tableId } = props;
1581
1626
  const commandService = useDependency(ICommandService);
1582
1627
  const localeService = useDependency(LocaleService);
@@ -1601,11 +1646,11 @@ const SheetTableThemePanel = (props) => {
1601
1646
  const customSelected = customRangeThemes.find((item) => item === selectedTheme);
1602
1647
  const customStyleName = customSelected || customRangeThemes[0];
1603
1648
  const customStyle = rangeThemeModel.getCustomRangeThemeStyle(unitId, customStyleName);
1604
- const headerBg = (_customStyle$getHeade = customStyle === null || customStyle === void 0 || (_customStyle$getHeade2 = customStyle.getHeaderRowStyle()) === null || _customStyle$getHeade2 === void 0 || (_customStyle$getHeade2 = _customStyle$getHeade2.bg) === null || _customStyle$getHeade2 === void 0 ? void 0 : _customStyle$getHeade2.rgb) !== null && _customStyle$getHeade !== void 0 ? _customStyle$getHeade : TABLE_DEFAULT_BG_COLOR;
1605
- const firstRowBg = (_customStyle$getFirst = customStyle === null || customStyle === void 0 || (_customStyle$getFirst2 = customStyle.getFirstRowStyle()) === null || _customStyle$getFirst2 === void 0 || (_customStyle$getFirst2 = _customStyle$getFirst2.bg) === null || _customStyle$getFirst2 === void 0 ? void 0 : _customStyle$getFirst2.rgb) !== null && _customStyle$getFirst !== void 0 ? _customStyle$getFirst : TABLE_DEFAULT_BG_COLOR;
1606
- const secondRowBg = (_customStyle$getSecon = customStyle === null || customStyle === void 0 || (_customStyle$getSecon2 = customStyle.getSecondRowStyle()) === null || _customStyle$getSecon2 === void 0 || (_customStyle$getSecon2 = _customStyle$getSecon2.bg) === null || _customStyle$getSecon2 === void 0 ? void 0 : _customStyle$getSecon2.rgb) !== null && _customStyle$getSecon !== void 0 ? _customStyle$getSecon : TABLE_DEFAULT_BG_COLOR;
1607
- const lastRowBg = (_customStyle$getLastR = customStyle === null || customStyle === void 0 || (_customStyle$getLastR2 = customStyle.getLastRowStyle()) === null || _customStyle$getLastR2 === void 0 || (_customStyle$getLastR2 = _customStyle$getLastR2.bg) === null || _customStyle$getLastR2 === void 0 ? void 0 : _customStyle$getLastR2.rgb) !== null && _customStyle$getLastR !== void 0 ? _customStyle$getLastR : TABLE_DEFAULT_BG_COLOR;
1608
- const [hoverCustomId, setHoverCustomId] = useState(null);
1649
+ const headerBg = (customStyle === null || customStyle === void 0 || (_customStyle$getHeade = customStyle.getHeaderRowStyle()) === null || _customStyle$getHeade === void 0 || (_customStyle$getHeade = _customStyle$getHeade.bg) === null || _customStyle$getHeade === void 0 ? void 0 : _customStyle$getHeade.rgb) ?? "rgb(255, 255, 255)";
1650
+ const firstRowBg = (customStyle === null || customStyle === void 0 || (_customStyle$getFirst = customStyle.getFirstRowStyle()) === null || _customStyle$getFirst === void 0 || (_customStyle$getFirst = _customStyle$getFirst.bg) === null || _customStyle$getFirst === void 0 ? void 0 : _customStyle$getFirst.rgb) ?? "rgb(255, 255, 255)";
1651
+ const secondRowBg = (customStyle === null || customStyle === void 0 || (_customStyle$getSecon = customStyle.getSecondRowStyle()) === null || _customStyle$getSecon === void 0 || (_customStyle$getSecon = _customStyle$getSecon.bg) === null || _customStyle$getSecon === void 0 ? void 0 : _customStyle$getSecon.rgb) ?? "rgb(255, 255, 255)";
1652
+ const lastRowBg = (customStyle === null || customStyle === void 0 || (_customStyle$getLastR = customStyle.getLastRowStyle()) === null || _customStyle$getLastR === void 0 || (_customStyle$getLastR = _customStyle$getLastR.bg) === null || _customStyle$getLastR === void 0 ? void 0 : _customStyle$getLastR.rgb) ?? "rgb(255, 255, 255)";
1653
+ const direction = useObservable(localeService.direction$, localeService.getDirection());
1609
1654
  const handleThemeChange = (theme) => {
1610
1655
  commandService.executeCommand(SetSheetTableCommand.id, {
1611
1656
  unitId,
@@ -1651,237 +1696,192 @@ const SheetTableThemePanel = (props) => {
1651
1696
  const firstRowBgIsDark = new ColorKit(firstRowBg).isDark();
1652
1697
  const secondRowBgIsDark = new ColorKit(secondRowBg).isDark();
1653
1698
  const lastRowBgIsDark = new ColorKit(lastRowBg).isDark();
1654
- return /* @__PURE__ */ jsxs("div", { children: [
1655
- /* @__PURE__ */ jsx("h5", { children: localeService.t("sheets-table-ui.defaultStyle") }),
1656
- /* @__PURE__ */ jsx("div", {
1657
- className: "univer-flex univer-gap-2",
1658
- children: defaultRangeThemes.map((item) => {
1659
- var _rangeThemeItem$getHe, _rangeThemeItem$getFi, _rangeThemeItem$getSe, _rangeThemeItem$getLa;
1660
- const rangeThemeItem = rangeThemeModel.getDefaultRangeThemeStyle(item);
1661
- const headerRowBg = (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getHe = rangeThemeItem.getHeaderRowStyle()) === null || _rangeThemeItem$getHe === void 0 || (_rangeThemeItem$getHe = _rangeThemeItem$getHe.bg) === null || _rangeThemeItem$getHe === void 0 ? void 0 : _rangeThemeItem$getHe.rgb) || "rgb(255, 255, 255)";
1662
- const firstRowBg = (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getFi = rangeThemeItem.getFirstRowStyle()) === null || _rangeThemeItem$getFi === void 0 || (_rangeThemeItem$getFi = _rangeThemeItem$getFi.bg) === null || _rangeThemeItem$getFi === void 0 ? void 0 : _rangeThemeItem$getFi.rgb) || "rgb(255, 255, 255)";
1663
- const secondRowBg = (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getSe = rangeThemeItem.getSecondRowStyle()) === null || _rangeThemeItem$getSe === void 0 || (_rangeThemeItem$getSe = _rangeThemeItem$getSe.bg) === null || _rangeThemeItem$getSe === void 0 ? void 0 : _rangeThemeItem$getSe.rgb) || "rgb(255, 255, 255)";
1664
- const lastRowBg = (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getLa = rangeThemeItem.getLastRowStyle()) === null || _rangeThemeItem$getLa === void 0 || (_rangeThemeItem$getLa = _rangeThemeItem$getLa.bg) === null || _rangeThemeItem$getLa === void 0 ? void 0 : _rangeThemeItem$getLa.rgb) || "rgb(255, 255, 255)";
1665
- return /* @__PURE__ */ jsxs("div", {
1666
- className: clsx("univer-h-10 univer-w-8 univer-cursor-pointer univer-border univer-border-solid univer-border-gray-200 univer-p-px [&>div]:univer-box-border [&>div]:univer-h-2.5", { "univer-border-blue-500": item === themeConfig.theme }),
1667
- onClick: () => handleThemeChange(item),
1668
- children: [
1669
- /* @__PURE__ */ jsx("div", { style: {
1670
- background: headerRowBg,
1671
- border: `${headerRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
1672
- } }),
1673
- /* @__PURE__ */ jsx("div", { style: {
1674
- background: firstRowBg,
1675
- border: `${firstRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
1676
- } }),
1677
- /* @__PURE__ */ jsx("div", { style: {
1678
- background: secondRowBg,
1679
- border: `${secondRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
1680
- } }),
1681
- /* @__PURE__ */ jsx("div", { style: {
1682
- background: lastRowBg,
1683
- border: `${lastRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
1684
- } })
1685
- ]
1686
- }, item);
1687
- })
1688
- }),
1689
- /* @__PURE__ */ jsx("h5", { children: localeService.t("sheets-table-ui.customStyle") }),
1690
- /* @__PURE__ */ jsxs("div", {
1691
- className: clsx("univer-w-full univer-rounded-sm", borderClassName),
1692
- children: [/* @__PURE__ */ jsxs("div", {
1693
- className: "univer-flex univer-flex-wrap univer-gap-2 univer-p-2",
1694
- children: [/* @__PURE__ */ jsx("div", {
1695
- className: clsx("univer-h-10 univer-w-8 univer-cursor-pointer univer-p-px univer-text-center univer-leading-10", borderClassName),
1696
- onClick: handleAddCustomTheme,
1697
- children: "+"
1698
- }), customRangeThemes.map((item) => {
1699
- var _rangeThemeItem$getHe2, _rangeThemeItem$getFi2, _rangeThemeItem$getSe2, _rangeThemeItem$getLa2;
1700
- const rangeThemeItem = rangeThemeModel.getCustomRangeThemeStyle(unitId, item);
1701
- const headerRowBg = rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getHe2 = rangeThemeItem.getHeaderRowStyle()) === null || _rangeThemeItem$getHe2 === void 0 || (_rangeThemeItem$getHe2 = _rangeThemeItem$getHe2.bg) === null || _rangeThemeItem$getHe2 === void 0 ? void 0 : _rangeThemeItem$getHe2.rgb;
1702
- const firstRowBg = rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getFi2 = rangeThemeItem.getFirstRowStyle()) === null || _rangeThemeItem$getFi2 === void 0 || (_rangeThemeItem$getFi2 = _rangeThemeItem$getFi2.bg) === null || _rangeThemeItem$getFi2 === void 0 ? void 0 : _rangeThemeItem$getFi2.rgb;
1703
- const secondRowBg = rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getSe2 = rangeThemeItem.getSecondRowStyle()) === null || _rangeThemeItem$getSe2 === void 0 || (_rangeThemeItem$getSe2 = _rangeThemeItem$getSe2.bg) === null || _rangeThemeItem$getSe2 === void 0 ? void 0 : _rangeThemeItem$getSe2.rgb;
1704
- const lastRowBg = rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getLa2 = rangeThemeItem.getLastRowStyle()) === null || _rangeThemeItem$getLa2 === void 0 || (_rangeThemeItem$getLa2 = _rangeThemeItem$getLa2.bg) === null || _rangeThemeItem$getLa2 === void 0 ? void 0 : _rangeThemeItem$getLa2.rgb;
1705
- return /* @__PURE__ */ jsxs("div", {
1706
- className: clsx("univer-relative univer-h-10 univer-w-8 univer-cursor-pointer univer-border univer-border-solid univer-border-gray-200 univer-p-px", { "univer-border-blue-500": item === themeConfig.theme }),
1699
+ const customThemeRows = [
1700
+ {
1701
+ key: "header",
1702
+ label: localeService.t("sheets-table-ui.header"),
1703
+ background: headerBg,
1704
+ isDark: headerBgIsDark,
1705
+ onChange: (value) => {
1706
+ const headerRowStyle = processStyleWithBorderStyle("headerRowStyle", {
1707
+ bg: { rgb: value },
1708
+ cl: { rgb: new ColorKit(value).isDark() ? "#fff" : "#000" }
1709
+ });
1710
+ setCustomTheme(table.getTableStyleId(), { headerRowStyle });
1711
+ }
1712
+ },
1713
+ {
1714
+ key: "first-row",
1715
+ label: localeService.t("sheets-table-ui.firstLine"),
1716
+ background: firstRowBg,
1717
+ isDark: firstRowBgIsDark,
1718
+ onChange: (value) => {
1719
+ setCustomTheme(table.getTableStyleId(), { firstRowStyle: {
1720
+ bg: { rgb: value },
1721
+ cl: { rgb: new ColorKit(value).isDark() ? "#fff" : "#000" }
1722
+ } });
1723
+ }
1724
+ },
1725
+ {
1726
+ key: "second-row",
1727
+ label: localeService.t("sheets-table-ui.secondLine"),
1728
+ background: secondRowBg,
1729
+ isDark: secondRowBgIsDark,
1730
+ onChange: (value) => {
1731
+ setCustomTheme(table.getTableStyleId(), { secondRowStyle: {
1732
+ bg: { rgb: value },
1733
+ cl: { rgb: new ColorKit(value).isDark() ? "#fff" : "#000" }
1734
+ } });
1735
+ }
1736
+ },
1737
+ {
1738
+ key: "last-row",
1739
+ label: localeService.t("sheets-table-ui.footer"),
1740
+ background: lastRowBg,
1741
+ isDark: lastRowBgIsDark,
1742
+ onChange: (value) => {
1743
+ const lastRowStyle = processStyleWithBorderStyle("lastRowStyle", {
1744
+ bg: { rgb: value },
1745
+ cl: { rgb: new ColorKit(value).isDark() ? "#fff" : "#000" }
1746
+ });
1747
+ setCustomTheme(table.getTableStyleId(), { lastRowStyle });
1748
+ }
1749
+ }
1750
+ ];
1751
+ return /* @__PURE__ */ jsxs("div", {
1752
+ dir: direction,
1753
+ className: "univer-flex univer-flex-col univer-gap-5 univer-pb-4",
1754
+ children: [/* @__PURE__ */ jsxs("section", {
1755
+ className: "univer-flex univer-flex-col univer-gap-2",
1756
+ children: [/* @__PURE__ */ jsx("h5", {
1757
+ className: "univer-m-0 univer-text-xs univer-font-medium univer-text-gray-500 dark:!univer-text-gray-300",
1758
+ children: localeService.t("sheets-table-ui.defaultStyle")
1759
+ }), /* @__PURE__ */ jsx("div", {
1760
+ className: "univer-grid univer-grid-cols-6 univer-gap-2",
1761
+ children: defaultRangeThemes.map((item) => {
1762
+ var _rangeThemeItem$getHe, _rangeThemeItem$getFi, _rangeThemeItem$getSe, _rangeThemeItem$getLa;
1763
+ const rangeThemeItem = rangeThemeModel.getDefaultRangeThemeStyle(item);
1764
+ const rowBackgrounds = [
1765
+ (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getHe = rangeThemeItem.getHeaderRowStyle()) === null || _rangeThemeItem$getHe === void 0 || (_rangeThemeItem$getHe = _rangeThemeItem$getHe.bg) === null || _rangeThemeItem$getHe === void 0 ? void 0 : _rangeThemeItem$getHe.rgb) || "rgb(255, 255, 255)",
1766
+ (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getFi = rangeThemeItem.getFirstRowStyle()) === null || _rangeThemeItem$getFi === void 0 || (_rangeThemeItem$getFi = _rangeThemeItem$getFi.bg) === null || _rangeThemeItem$getFi === void 0 ? void 0 : _rangeThemeItem$getFi.rgb) || "rgb(255, 255, 255)",
1767
+ (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getSe = rangeThemeItem.getSecondRowStyle()) === null || _rangeThemeItem$getSe === void 0 || (_rangeThemeItem$getSe = _rangeThemeItem$getSe.bg) === null || _rangeThemeItem$getSe === void 0 ? void 0 : _rangeThemeItem$getSe.rgb) || "rgb(255, 255, 255)",
1768
+ (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getLa = rangeThemeItem.getLastRowStyle()) === null || _rangeThemeItem$getLa === void 0 || (_rangeThemeItem$getLa = _rangeThemeItem$getLa.bg) === null || _rangeThemeItem$getLa === void 0 ? void 0 : _rangeThemeItem$getLa.rgb) || "rgb(255, 255, 255)"
1769
+ ];
1770
+ const selected = item === themeConfig.theme;
1771
+ return /* @__PURE__ */ jsx("button", {
1772
+ type: "button",
1773
+ title: item,
1774
+ "aria-label": item,
1775
+ "aria-pressed": selected,
1776
+ className: clsx("univer-flex univer-h-12 univer-w-full univer-cursor-pointer univer-flex-col univer-overflow-hidden univer-rounded-lg univer-bg-gray-0 univer-p-1 univer-shadow-sm univer-transition-all hover:univer-border-gray-400 hover:univer-shadow-md focus:univer-outline-none focus:univer-ring-2 focus:univer-ring-primary-200 dark:!univer-bg-gray-800", borderClassName, { "!univer-border-primary-500 univer-ring-2 univer-ring-primary-100": selected }),
1707
1777
  onClick: () => handleThemeChange(item),
1708
- onMouseEnter: () => setHoverCustomId(item),
1709
- onMouseLeave: () => setHoverCustomId(null),
1710
- children: [
1711
- /* @__PURE__ */ jsx("div", {
1712
- className: "univer-box-border univer-h-2.5",
1713
- style: {
1714
- background: headerRowBg !== null && headerRowBg !== void 0 ? headerRowBg : TABLE_BORDER_NONE,
1715
- border: `${headerRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
1716
- }
1717
- }),
1718
- /* @__PURE__ */ jsx("div", {
1719
- className: "univer-box-border univer-h-2.5",
1720
- style: {
1721
- background: firstRowBg !== null && firstRowBg !== void 0 ? firstRowBg : TABLE_BORDER_NONE,
1722
- border: `${firstRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
1723
- }
1724
- }),
1725
- /* @__PURE__ */ jsx("div", {
1726
- className: "univer-box-border univer-h-2.5",
1727
- style: {
1728
- background: secondRowBg !== null && secondRowBg !== void 0 ? secondRowBg : TABLE_BORDER_NONE,
1729
- border: `${secondRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
1730
- }
1731
- }),
1732
- /* @__PURE__ */ jsx("div", {
1733
- className: "univer-box-border univer-h-2.5",
1734
- style: {
1735
- background: lastRowBg !== null && lastRowBg !== void 0 ? lastRowBg : TABLE_BORDER_NONE,
1736
- border: `${lastRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
1737
- }
1738
- }),
1739
- /* @__PURE__ */ jsx("div", {
1740
- className: "univer-absolute univer-right-[-3px] univer-top-[-3px] univer-size-3 univer-rounded-md univer-bg-gray-200 univer-text-center univer-text-xs univer-leading-[10px]",
1741
- style: { display: hoverCustomId === item ? "block" : "none" },
1742
- onClick: (e) => {
1743
- e.stopPropagation();
1744
- removeCustomTheme(item);
1745
- },
1746
- children: "x"
1747
- })
1748
- ]
1778
+ children: rowBackgrounds.map((background, index) => /* @__PURE__ */ jsx("span", {
1779
+ className: "univer-min-h-0 univer-w-full univer-flex-1",
1780
+ style: {
1781
+ background,
1782
+ border: background ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT
1783
+ }
1784
+ }, index))
1749
1785
  }, item);
1750
- })]
1751
- }), customSelected && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", { className: "univer-h-px univer-w-full univer-bg-gray-200" }), /* @__PURE__ */ jsxs("div", {
1752
- className: "univer-flex univer-flex-col univer-gap-2 univer-p-2",
1753
- children: [
1754
- /* @__PURE__ */ jsxs("div", {
1755
- className: "univer-flex univer-h-9 univer-gap-2",
1756
- children: [/* @__PURE__ */ jsx("div", {
1757
- className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
1758
- "univer-text-white": headerBgIsDark,
1759
- "univer-text-gray-900": !headerBgIsDark
1760
- }),
1761
- style: { background: headerBg },
1762
- children: localeService.t("sheets-table-ui.header")
1763
- }), /* @__PURE__ */ jsx(Dropdown, {
1764
- overlay: /* @__PURE__ */ jsx("div", {
1765
- className: "univer-p-2",
1766
- children: /* @__PURE__ */ jsx(ColorPicker, {
1767
- value: headerBg,
1768
- onChange: (val) => {
1769
- const headerRowStyle = processStyleWithBorderStyle("headerRowStyle", {
1770
- bg: { rgb: val },
1771
- cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
1772
- });
1773
- setCustomTheme(table.getTableStyleId(), { headerRowStyle });
1774
- }
1775
- })
1776
- }),
1777
- children: /* @__PURE__ */ jsxs("div", {
1778
- className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
1779
- children: [/* @__PURE__ */ jsx("div", {
1780
- className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName, {
1781
- "univer-text-white": headerBgIsDark,
1782
- "univer-text-gray-900": !headerBgIsDark
1783
- }),
1784
- style: { background: headerBg }
1785
- }), /* @__PURE__ */ jsx(DownIcon, { className: "univer-size-2" })]
1786
- })
1787
- })]
1788
- }),
1789
- /* @__PURE__ */ jsxs("div", {
1790
- className: "univer-flex univer-h-9 univer-gap-2",
1791
- children: [/* @__PURE__ */ jsx("div", {
1792
- className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
1793
- "univer-text-white": firstRowBgIsDark,
1794
- "univer-text-gray-900": !firstRowBgIsDark
1795
- }),
1796
- style: { background: firstRowBg },
1797
- children: localeService.t("sheets-table-ui.firstLine")
1798
- }), /* @__PURE__ */ jsx(Dropdown, {
1799
- overlay: /* @__PURE__ */ jsx("div", {
1800
- className: "univer-p-2",
1801
- children: /* @__PURE__ */ jsx(ColorPicker, {
1802
- value: firstRowBg,
1803
- onChange: (val) => {
1804
- setCustomTheme(table.getTableStyleId(), { firstRowStyle: {
1805
- bg: { rgb: val },
1806
- cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
1807
- } });
1786
+ })
1787
+ })]
1788
+ }), /* @__PURE__ */ jsxs("section", {
1789
+ className: "univer-flex univer-flex-col univer-gap-2",
1790
+ children: [
1791
+ /* @__PURE__ */ jsx("h5", {
1792
+ className: "univer-m-0 univer-text-xs univer-font-medium univer-text-gray-500 dark:!univer-text-gray-300",
1793
+ children: localeService.t("sheets-table-ui.customStyle")
1794
+ }),
1795
+ /* @__PURE__ */ jsxs("div", {
1796
+ className: "univer-grid univer-grid-cols-5 univer-gap-2 univer-rounded-lg univer-bg-gray-50 univer-p-2 dark:!univer-bg-gray-800",
1797
+ children: [/* @__PURE__ */ jsx("button", {
1798
+ type: "button",
1799
+ "data-u-comp": "sheet-table-theme-add",
1800
+ "aria-label": localeService.t("sheets-table-ui.setTheme"),
1801
+ className: "univer-flex univer-h-12 univer-w-full univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-lg univer-border univer-border-dashed univer-border-gray-300 univer-bg-gray-0 univer-p-0 univer-text-gray-500 univer-transition-colors hover:univer-border-primary-500 hover:univer-text-primary-600 focus:univer-outline-none focus:univer-ring-2 focus:univer-ring-primary-200 dark:!univer-border-gray-600 dark:!univer-bg-gray-900 dark:!univer-text-gray-300",
1802
+ onClick: handleAddCustomTheme,
1803
+ children: /* @__PURE__ */ jsx(IncreaseIcon, { className: "univer-size-4" })
1804
+ }), customRangeThemes.map((item) => {
1805
+ var _rangeThemeItem$getHe2, _rangeThemeItem$getFi2, _rangeThemeItem$getSe2, _rangeThemeItem$getLa2;
1806
+ const rangeThemeItem = rangeThemeModel.getCustomRangeThemeStyle(unitId, item);
1807
+ const rowBackgrounds = [
1808
+ rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getHe2 = rangeThemeItem.getHeaderRowStyle()) === null || _rangeThemeItem$getHe2 === void 0 || (_rangeThemeItem$getHe2 = _rangeThemeItem$getHe2.bg) === null || _rangeThemeItem$getHe2 === void 0 ? void 0 : _rangeThemeItem$getHe2.rgb,
1809
+ rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getFi2 = rangeThemeItem.getFirstRowStyle()) === null || _rangeThemeItem$getFi2 === void 0 || (_rangeThemeItem$getFi2 = _rangeThemeItem$getFi2.bg) === null || _rangeThemeItem$getFi2 === void 0 ? void 0 : _rangeThemeItem$getFi2.rgb,
1810
+ rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getSe2 = rangeThemeItem.getSecondRowStyle()) === null || _rangeThemeItem$getSe2 === void 0 || (_rangeThemeItem$getSe2 = _rangeThemeItem$getSe2.bg) === null || _rangeThemeItem$getSe2 === void 0 ? void 0 : _rangeThemeItem$getSe2.rgb,
1811
+ rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getLa2 = rangeThemeItem.getLastRowStyle()) === null || _rangeThemeItem$getLa2 === void 0 || (_rangeThemeItem$getLa2 = _rangeThemeItem$getLa2.bg) === null || _rangeThemeItem$getLa2 === void 0 ? void 0 : _rangeThemeItem$getLa2.rgb
1812
+ ];
1813
+ const selected = item === themeConfig.theme;
1814
+ return /* @__PURE__ */ jsxs("div", {
1815
+ className: "univer-group univer-relative univer-h-12 univer-min-w-0",
1816
+ children: [/* @__PURE__ */ jsx("button", {
1817
+ type: "button",
1818
+ title: item,
1819
+ "aria-label": item,
1820
+ "aria-pressed": selected,
1821
+ className: clsx("univer-flex univer-size-full univer-cursor-pointer univer-flex-col univer-overflow-hidden univer-rounded-lg univer-bg-gray-0 univer-p-1 univer-shadow-sm univer-transition-all hover:univer-border-gray-400 hover:univer-shadow-md focus:univer-outline-none focus:univer-ring-2 focus:univer-ring-primary-200 dark:!univer-bg-gray-900", borderClassName, { "!univer-border-primary-500 univer-ring-2 univer-ring-primary-100": selected }),
1822
+ onClick: () => handleThemeChange(item),
1823
+ children: rowBackgrounds.map((background, index) => /* @__PURE__ */ jsx("span", {
1824
+ className: "univer-min-h-0 univer-w-full univer-flex-1",
1825
+ style: {
1826
+ background: background ?? "none",
1827
+ border: background ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT
1808
1828
  }
1809
- })
1810
- }),
1811
- children: /* @__PURE__ */ jsxs("div", {
1812
- className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
1813
- children: [/* @__PURE__ */ jsx("div", {
1814
- className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName),
1815
- style: { background: firstRowBg }
1816
- }), /* @__PURE__ */ jsx(DownIcon, { className: "univer-size-2" })]
1817
- })
1818
- })]
1819
- }),
1820
- /* @__PURE__ */ jsxs("div", {
1821
- className: "univer-flex univer-h-9 univer-gap-2",
1829
+ }, index))
1830
+ }), /* @__PURE__ */ jsx("button", {
1831
+ type: "button",
1832
+ "data-u-comp": "sheet-table-theme-remove",
1833
+ "aria-label": `${localeService.t("sheets-table-ui.customStyle")} ${item}`,
1834
+ className: clsx("univer-absolute univer-right-[-6px] univer-top-[-6px] univer-z-10 univer-flex univer-size-5 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-border univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-p-0 univer-text-gray-500 univer-shadow-sm univer-transition-all hover:univer-border-red-200 hover:univer-bg-red-50 hover:univer-text-red-600 focus:univer-opacity-100 focus:univer-outline-none focus:univer-ring-2 focus:univer-ring-primary-200 rtl:univer-left-[-6px] rtl:univer-right-auto dark:!univer-border-gray-600 dark:!univer-bg-gray-900", {
1835
+ "univer-opacity-100": selected,
1836
+ "univer-opacity-0 group-focus-within:univer-opacity-100 group-hover:univer-opacity-100": !selected
1837
+ }),
1838
+ onClick: (event) => {
1839
+ event.stopPropagation();
1840
+ removeCustomTheme(item);
1841
+ },
1842
+ children: /* @__PURE__ */ jsx(CloseIcon, { className: "univer-size-3" })
1843
+ })]
1844
+ }, item);
1845
+ })]
1846
+ }),
1847
+ customSelected && /* @__PURE__ */ jsx("div", {
1848
+ className: "univer-flex univer-flex-col univer-gap-2 univer-rounded-lg univer-bg-gray-50 univer-p-3 dark:!univer-bg-gray-800",
1849
+ children: customThemeRows.map((row) => /* @__PURE__ */ jsxs("div", {
1850
+ className: "univer-flex univer-h-10 univer-min-w-0 univer-gap-2",
1822
1851
  children: [/* @__PURE__ */ jsx("div", {
1823
- className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
1824
- "univer-text-white": secondRowBgIsDark,
1825
- "univer-text-gray-900": !secondRowBgIsDark
1852
+ className: clsx("univer-flex univer-min-w-0 univer-flex-1 univer-items-center univer-rounded-md univer-px-3 univer-text-sm univer-font-medium rtl:univer-text-right", borderClassName, {
1853
+ "univer-text-gray-0": row.isDark,
1854
+ "univer-text-gray-900": !row.isDark
1826
1855
  }),
1827
- style: { background: secondRowBg },
1828
- children: localeService.t("sheets-table-ui.secondLine")
1829
- }), /* @__PURE__ */ jsx(Dropdown, {
1830
- overlay: /* @__PURE__ */ jsx("div", {
1831
- className: "univer-p-2",
1832
- children: /* @__PURE__ */ jsx(ColorPicker, {
1833
- value: secondRowBg,
1834
- onChange: (val) => setCustomTheme(table.getTableStyleId(), { secondRowStyle: {
1835
- bg: { rgb: val },
1836
- cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
1837
- } })
1838
- })
1839
- }),
1840
- children: /* @__PURE__ */ jsxs("div", {
1841
- className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
1842
- children: [/* @__PURE__ */ jsx("div", {
1843
- className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName),
1844
- style: { background: secondRowBg }
1845
- }), /* @__PURE__ */ jsx(DownIcon, { className: "univer-size-2" })]
1856
+ style: { background: row.background },
1857
+ children: /* @__PURE__ */ jsx("span", {
1858
+ className: "univer-truncate",
1859
+ children: row.label
1846
1860
  })
1847
- })]
1848
- }),
1849
- /* @__PURE__ */ jsxs("div", {
1850
- className: "univer-flex univer-h-9 univer-gap-2",
1851
- children: [/* @__PURE__ */ jsx("div", {
1852
- className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
1853
- "univer-text-white": lastRowBgIsDark,
1854
- "univer-text-gray-900": !lastRowBgIsDark
1855
- }),
1856
- style: { background: lastRowBg },
1857
- children: localeService.t("sheets-table-ui.footer")
1858
1861
  }), /* @__PURE__ */ jsx(Dropdown, {
1859
1862
  overlay: /* @__PURE__ */ jsx("div", {
1863
+ dir: direction,
1860
1864
  className: "univer-p-2",
1861
1865
  children: /* @__PURE__ */ jsx(ColorPicker, {
1862
- value: lastRowBg,
1863
- onChange: (val) => {
1864
- const lastRowStyle = processStyleWithBorderStyle("lastRowStyle", {
1865
- bg: { rgb: val },
1866
- cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
1867
- });
1868
- setCustomTheme(table.getTableStyleId(), { lastRowStyle });
1869
- }
1866
+ value: new ColorKit(row.background).toHexString(),
1867
+ onChange: row.onChange
1870
1868
  })
1871
1869
  }),
1872
- children: /* @__PURE__ */ jsxs("div", {
1873
- className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
1874
- children: [/* @__PURE__ */ jsx("div", {
1875
- className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName),
1876
- style: { background: lastRowBg }
1877
- }), /* @__PURE__ */ jsx(DownIcon, { className: "univer-size-2" })]
1870
+ children: /* @__PURE__ */ jsxs("button", {
1871
+ type: "button",
1872
+ "aria-label": `${row.label} ${localeService.t("sheets-table-ui.setTheme")}`,
1873
+ className: clsx("univer-flex univer-h-10 univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-md univer-bg-gray-0 univer-px-2 univer-text-gray-600 univer-transition-colors hover:univer-bg-gray-100 focus:univer-outline-none focus:univer-ring-2 focus:univer-ring-primary-200 dark:!univer-bg-gray-900 dark:!univer-text-gray-300", borderClassName),
1874
+ children: [/* @__PURE__ */ jsx("span", {
1875
+ className: clsx("univer-size-4 univer-rounded-full", borderClassName),
1876
+ style: { background: row.background }
1877
+ }), /* @__PURE__ */ jsx(DownIcon, { className: "univer-size-3" })]
1878
1878
  })
1879
1879
  })]
1880
- })
1881
- ]
1882
- })] })]
1883
- })
1884
- ] });
1880
+ }, row.key))
1881
+ })
1882
+ ]
1883
+ })]
1884
+ });
1885
1885
  };
1886
1886
 
1887
1887
  //#endregion
@@ -1910,7 +1910,11 @@ let ComponentsController = class ComponentsController extends Disposable {
1910
1910
  this._registerIcons();
1911
1911
  }
1912
1912
  _registerComponents() {
1913
- [[SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, SheetTableFilterPanel], [SHEET_TABLE_RENAME_DIALOG, SheetTableRenameDialog]].forEach(([key, comp]) => {
1913
+ [
1914
+ [SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, SheetTableFilterPanel],
1915
+ [SHEET_TABLE_MENU, SheetTableMenu],
1916
+ [SHEET_TABLE_RENAME_DIALOG, SheetTableRenameDialog]
1917
+ ].forEach(([key, comp]) => {
1914
1918
  this.disposeWithMe(this._componentManager.register(key, comp));
1915
1919
  });
1916
1920
  [[TABLE_SELECTOR_DIALOG, SheetTableSelector], [SHEET_TABLE_THEME_PANEL, SheetTableThemePanel]].forEach(([key, comp]) => {
@@ -1925,14 +1929,6 @@ ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)),
1925
1929
 
1926
1930
  //#endregion
1927
1931
  //#region src/views/widgets/table-controls-util.ts
1928
- const TABLE_CONTROL_MENU_WIDTH = 168;
1929
- const TABLE_CONTROL_MENU_ITEM_HEIGHT = 32;
1930
- const TABLE_CONTROL_MENU_ACTIONS = [
1931
- "rename",
1932
- "update-range",
1933
- "set-theme",
1934
- "delete"
1935
- ];
1936
1932
  function isPointInTableControlRegion(region, x, y) {
1937
1933
  return x >= region.left && x <= region.left + region.width && y >= region.top && y <= region.top + region.height;
1938
1934
  }
@@ -1940,17 +1936,6 @@ function hitTestTableControl(regions, x, y) {
1940
1936
  for (let i = regions.length - 1; i >= 0; i--) if (isPointInTableControlRegion(regions[i], x, y)) return regions[i];
1941
1937
  return null;
1942
1938
  }
1943
- function buildTableMenuRegions(tableId, left, top) {
1944
- return TABLE_CONTROL_MENU_ACTIONS.map((action, index) => ({
1945
- type: "menu-item",
1946
- tableId,
1947
- action,
1948
- left,
1949
- top: top + index * 32,
1950
- width: 168,
1951
- height: 32
1952
- }));
1953
- }
1954
1939
  function buildCenteredPlusSegments(centerX, centerY, size) {
1955
1940
  const halfSize = size / 2;
1956
1941
  return [{
@@ -1976,9 +1961,6 @@ const ANCHOR_OFFSET_Y = 0;
1976
1961
  const ANCHOR_BORDER = "rgba(0, 0, 0, 0.22)";
1977
1962
  const ANCHOR_DIVIDER = "rgba(0, 0, 0, 0.20)";
1978
1963
  const ANCHOR_TOGGLE_BG_ACTIVE = "rgba(0, 0, 0, 0.12)";
1979
- const MENU_RADIUS = 8;
1980
- const MENU_BORDER = "#d9dee7";
1981
- const MENU_HOVER_BG = "#f1f3f4";
1982
1964
  const INSERT_BUTTON_VISUAL_SIZE = 18;
1983
1965
  const INSERT_BUTTON_PLUS_SIZE = 8;
1984
1966
  var SheetTableControlsShape = class extends Shape {
@@ -1994,21 +1976,11 @@ var SheetTableControlsShape = class extends Shape {
1994
1976
  _defineProperty(this, "_openedMenuTableId", null);
1995
1977
  _defineProperty(this, "_hoveredRegion", null);
1996
1978
  _defineProperty(this, "_hoveredInsertRegion", null);
1997
- _defineProperty(this, "_menuLabels", {
1998
- rename: "Rename table",
1999
- "update-range": "Update range",
2000
- "set-theme": "Set theme",
2001
- delete: "Remove table"
2002
- });
2003
1979
  }
2004
1980
  setItems(items) {
2005
1981
  this._items = items;
2006
1982
  this.makeDirty(true);
2007
1983
  }
2008
- setMenuLabels(labels) {
2009
- this._menuLabels = labels;
2010
- this.makeDirty(true);
2011
- }
2012
1984
  setOpenedMenuTableId(tableId) {
2013
1985
  if (this._openedMenuTableId === tableId) return;
2014
1986
  this._openedMenuTableId = tableId;
@@ -2017,6 +1989,9 @@ var SheetTableControlsShape = class extends Shape {
2017
1989
  getOpenedMenuTableId() {
2018
1990
  return this._openedMenuTableId;
2019
1991
  }
1992
+ getAnchorRegion(tableId) {
1993
+ return this._regions.find((region) => region.type === "anchor-main" && region.tableId === tableId) ?? null;
1994
+ }
2020
1995
  setHoveredRegion(region) {
2021
1996
  if (this._hoveredRegion === region) return;
2022
1997
  this._hoveredRegion = region;
@@ -2055,12 +2030,11 @@ var SheetTableControlsShape = class extends Shape {
2055
2030
  ctx.textBaseline = "middle";
2056
2031
  for (const item of this._items) this._drawAnchor(ctx, skeleton, item);
2057
2032
  if (this._hoveredInsertRegion) {
2058
- var _item$fill;
2059
2033
  const item = this._items.find((renderItem) => {
2060
2034
  var _this$_hoveredInsertR;
2061
2035
  return renderItem.tableId === ((_this$_hoveredInsertR = this._hoveredInsertRegion) === null || _this$_hoveredInsertR === void 0 ? void 0 : _this$_hoveredInsertR.tableId);
2062
2036
  });
2063
- this._drawInsertButton(ctx, this._hoveredInsertRegion, (_item$fill = item === null || item === void 0 ? void 0 : item.fill) !== null && _item$fill !== void 0 ? _item$fill : "#355bb7");
2037
+ this._drawInsertButton(ctx, this._hoveredInsertRegion, (item === null || item === void 0 ? void 0 : item.fill) ?? "#355bb7");
2064
2038
  this._regions.push(this._hoveredInsertRegion);
2065
2039
  }
2066
2040
  ctx.restore();
@@ -2097,7 +2071,6 @@ var SheetTableControlsShape = class extends Shape {
2097
2071
  height: 28
2098
2072
  });
2099
2073
  this._regions.push(toggleRegion);
2100
- if (this._openedMenuTableId === item.tableId) this._drawMenu(ctx, item.tableId, left, top + 28);
2101
2074
  }
2102
2075
  _drawAnchorToggle(ctx, anchorWidth, color, active) {
2103
2076
  const toggleLeft = anchorWidth - ANCHOR_TOGGLE_WIDTH;
@@ -2158,34 +2131,6 @@ var SheetTableControlsShape = class extends Shape {
2158
2131
  ctx.fill();
2159
2132
  ctx.restore();
2160
2133
  }
2161
- _drawMenu(ctx, tableId, left, top) {
2162
- const regions = buildTableMenuRegions(tableId, left, top);
2163
- ctx.save();
2164
- ctx.translateWithPrecision(left, top);
2165
- Rect.drawWith(ctx, {
2166
- width: 168,
2167
- height: regions.length * 32,
2168
- radius: MENU_RADIUS,
2169
- fill: "#fff",
2170
- stroke: MENU_BORDER
2171
- });
2172
- ctx.restore();
2173
- for (const region of regions) {
2174
- if (this._isSameRegion(this._hoveredRegion, region)) {
2175
- ctx.save();
2176
- ctx.fillStyle = MENU_HOVER_BG;
2177
- ctx.fillRectByPrecision(region.left, region.top, region.width, region.height);
2178
- ctx.restore();
2179
- }
2180
- ctx.save();
2181
- ctx.font = `12px ${DEFAULT_FONTFACE_PLANE}`;
2182
- ctx.fillStyle = region.action === "delete" ? "#d92d20" : "#344054";
2183
- ctx.textAlign = "left";
2184
- ctx.fillText(this._menuLabels[region.action], region.left + 12, region.top + region.height / 2);
2185
- ctx.restore();
2186
- }
2187
- this._regions.push(...regions);
2188
- }
2189
2134
  _drawInsertButton(ctx, region, fill) {
2190
2135
  const centerX = region.left + region.width / 2;
2191
2136
  const centerY = region.top + region.height / 2;
@@ -2209,7 +2154,7 @@ var SheetTableControlsShape = class extends Shape {
2209
2154
  ctx.restore();
2210
2155
  }
2211
2156
  _isSameRegion(a, b) {
2212
- return Boolean(a && a.type === b.type && a.tableId === b.tableId && a.action === b.action && a.index === b.index);
2157
+ return Boolean(a && a.type === b.type && a.tableId === b.tableId && a.index === b.index);
2213
2158
  }
2214
2159
  };
2215
2160
 
@@ -2230,7 +2175,7 @@ function isSameTopGap(left, right) {
2230
2175
  return left.size === right.size && left.color === right.color && left.stripeColor === right.stripeColor;
2231
2176
  }
2232
2177
  let SheetTableControlsRenderController = class SheetTableControlsRenderController extends Disposable {
2233
- constructor(_context, _injector, _sheetSkeletonManagerService, _commandService, _tableManager, _rangeThemeModel, _workbookPermissionService, _permissionService, _sheetsSelectionsService, _selectionRenderService, _sheetTableThemeUIController, _localeService, _dialogService, _sidebarService) {
2178
+ constructor(_context, _injector, _sheetSkeletonManagerService, _commandService, _tableManager, _rangeThemeModel, _workbookPermissionService, _permissionService, _sheetsSelectionsService, _selectionRenderService, _sheetTableThemeUIController, _localeService, _dialogService, _sidebarService, _sheetCanvasPopupService) {
2234
2179
  super();
2235
2180
  this._context = _context;
2236
2181
  this._injector = _injector;
@@ -2246,17 +2191,20 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
2246
2191
  this._localeService = _localeService;
2247
2192
  this._dialogService = _dialogService;
2248
2193
  this._sidebarService = _sidebarService;
2194
+ this._sheetCanvasPopupService = _sheetCanvasPopupService;
2249
2195
  _defineProperty(this, "_shape", void 0);
2250
2196
  _defineProperty(this, "_topGapBaseBySkeleton", /* @__PURE__ */ new WeakMap());
2197
+ _defineProperty(this, "_menuPopup", null);
2251
2198
  this._shape = new SheetTableControlsShape("SheetTableControlsShape", () => this._sheetSkeletonManagerService.getCurrentSkeleton() || null);
2252
2199
  this._initShape();
2253
2200
  this._initRefresh();
2254
2201
  this._refresh();
2255
2202
  }
2256
2203
  _initShape() {
2257
- var _this$_context$compon, _this$_context$compon2;
2204
+ var _this$_context$compon;
2258
2205
  this._context.scene.addObjects([this._shape], TABLE_CONTROLS_LAYER_INDEX);
2259
2206
  this.disposeWithMe(toDisposable(() => {
2207
+ this._closeFloatingControls();
2260
2208
  this._context.scene.removeObjects([this._shape]);
2261
2209
  }));
2262
2210
  this.disposeWithMe(this._shape.onPointerMove$.subscribeEvent((evt, state) => {
@@ -2268,11 +2216,11 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
2268
2216
  this.disposeWithMe(this._shape.onPointerDown$.subscribeEvent((evt, state) => {
2269
2217
  this._handlePointerDown(evt, state);
2270
2218
  }));
2271
- this.disposeWithMe((_this$_context$compon = (_this$_context$compon2 = this._context.components.get(SHEET_VIEW_KEY.MAIN)) === null || _this$_context$compon2 === void 0 ? void 0 : _this$_context$compon2.onPointerMove$.subscribeEvent((evt) => {
2219
+ this.disposeWithMe(((_this$_context$compon = this._context.components.get(SHEET_VIEW_KEY.MAIN)) === null || _this$_context$compon === void 0 ? void 0 : _this$_context$compon.onPointerMove$.subscribeEvent((evt) => {
2272
2220
  const point = this._getLocalPoint(evt);
2273
2221
  const insertRegion = this._getInsertRegionFromPoint(point.x, point.y);
2274
2222
  this._shape.setHoveredInsertRegion(insertRegion);
2275
- })) !== null && _this$_context$compon !== void 0 ? _this$_context$compon : toDisposable(() => {}));
2223
+ })) ?? toDisposable(() => {}));
2276
2224
  }
2277
2225
  _initRefresh() {
2278
2226
  const commandExecuted$ = fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(filter(([command]) => {
@@ -2303,23 +2251,17 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
2303
2251
  return;
2304
2252
  }
2305
2253
  this._syncTopTableGap(skeleton);
2306
- this._shape.setMenuLabels({
2307
- rename: this._localeService.t("sheets-table-ui.rename"),
2308
- "update-range": this._localeService.t("sheets-table-ui.updateRange"),
2309
- "set-theme": this._localeService.t("sheets-table-ui.setTheme"),
2310
- delete: this._localeService.t("sheets-table-ui.removeTable")
2311
- });
2312
2254
  const unitId = this._context.unit.getUnitId();
2313
2255
  const subUnitId = worksheet.getSheetId();
2314
2256
  const items = this._tableManager.getTablesBySubunitId(unitId, subUnitId).map((table) => {
2315
- var _rangeTheme$getHeader, _rangeTheme$getHeader2, _rangeTheme$getHeader3, _rangeTheme$getHeader4;
2257
+ var _rangeTheme$getHeader, _rangeTheme$getHeader2;
2316
2258
  const rangeTheme = this._rangeThemeModel.getRangeThemeStyle(unitId, table.getTableStyleId());
2317
2259
  return {
2318
2260
  tableId: table.getId(),
2319
2261
  tableName: table.getDisplayName(),
2320
2262
  range: table.getRange(),
2321
- fill: (_rangeTheme$getHeader = rangeTheme === null || rangeTheme === void 0 || (_rangeTheme$getHeader2 = rangeTheme.getHeaderRowStyle()) === null || _rangeTheme$getHeader2 === void 0 || (_rangeTheme$getHeader2 = _rangeTheme$getHeader2.bg) === null || _rangeTheme$getHeader2 === void 0 ? void 0 : _rangeTheme$getHeader2.rgb) !== null && _rangeTheme$getHeader !== void 0 ? _rangeTheme$getHeader : "rgb(53,91,183)",
2322
- text: (_rangeTheme$getHeader3 = rangeTheme === null || rangeTheme === void 0 || (_rangeTheme$getHeader4 = rangeTheme.getHeaderRowStyle()) === null || _rangeTheme$getHeader4 === void 0 || (_rangeTheme$getHeader4 = _rangeTheme$getHeader4.cl) === null || _rangeTheme$getHeader4 === void 0 ? void 0 : _rangeTheme$getHeader4.rgb) !== null && _rangeTheme$getHeader3 !== void 0 ? _rangeTheme$getHeader3 : "rgb(255,255,255)"
2263
+ fill: (rangeTheme === null || rangeTheme === void 0 || (_rangeTheme$getHeader = rangeTheme.getHeaderRowStyle()) === null || _rangeTheme$getHeader === void 0 || (_rangeTheme$getHeader = _rangeTheme$getHeader.bg) === null || _rangeTheme$getHeader === void 0 ? void 0 : _rangeTheme$getHeader.rgb) ?? "rgb(53,91,183)",
2264
+ text: (rangeTheme === null || rangeTheme === void 0 || (_rangeTheme$getHeader2 = rangeTheme.getHeaderRowStyle()) === null || _rangeTheme$getHeader2 === void 0 || (_rangeTheme$getHeader2 = _rangeTheme$getHeader2.cl) === null || _rangeTheme$getHeader2 === void 0 ? void 0 : _rangeTheme$getHeader2.rgb) ?? "rgb(255,255,255)"
2323
2265
  };
2324
2266
  });
2325
2267
  this._shape.setItems(items);
@@ -2336,7 +2278,7 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
2336
2278
  const point = this._getLocalPoint(evt);
2337
2279
  const hit = this._shape.hitTest(point.x, point.y);
2338
2280
  const insertRegion = this._isInsertHit(hit) ? hit : hit ? null : this._getInsertRegionFromPoint(point.x, point.y);
2339
- const activeHit = hit !== null && hit !== void 0 ? hit : insertRegion;
2281
+ const activeHit = hit ?? insertRegion;
2340
2282
  this._shape.setHoveredRegion(this._isInsertHit(hit) ? null : hit);
2341
2283
  this._shape.setHoveredInsertRegion(insertRegion);
2342
2284
  if (activeHit) {
@@ -2354,10 +2296,9 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
2354
2296
  this._context.scene.resetCursor();
2355
2297
  }
2356
2298
  _handlePointerDown(evt, state) {
2357
- var _this$_shape$hitTest;
2358
2299
  if (evt.button === 2) return;
2359
2300
  const point = this._getLocalPoint(evt);
2360
- const hit = (_this$_shape$hitTest = this._shape.hitTest(point.x, point.y)) !== null && _this$_shape$hitTest !== void 0 ? _this$_shape$hitTest : this._getInsertRegionFromPoint(point.x, point.y);
2301
+ const hit = this._shape.hitTest(point.x, point.y) ?? this._getInsertRegionFromPoint(point.x, point.y);
2361
2302
  if (!hit) {
2362
2303
  this._closeFloatingControls();
2363
2304
  return;
@@ -2373,7 +2314,7 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
2373
2314
  const unitId = this._context.unit.getUnitId();
2374
2315
  const subUnitId = worksheet.getSheetId();
2375
2316
  if (hit.type === "anchor-menu-toggle" || hit.type === "anchor-main") {
2376
- this._shape.setOpenedMenuTableId(this._shape.getOpenedMenuTableId() === hit.tableId ? null : hit.tableId);
2317
+ this._toggleTableMenu(unitId, subUnitId, hit.tableId);
2377
2318
  return;
2378
2319
  }
2379
2320
  if (hit.type === "insert-row") {
@@ -2396,28 +2337,65 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
2396
2337
  count: 1
2397
2338
  });
2398
2339
  this._closeFloatingControls();
2340
+ }
2341
+ }
2342
+ _toggleTableMenu(unitId, subUnitId, tableId) {
2343
+ if (this._shape.getOpenedMenuTableId() === tableId) {
2344
+ this._closeFloatingControls();
2399
2345
  return;
2400
2346
  }
2401
- if (hit.type !== "menu-item") return;
2402
- switch (hit.action) {
2347
+ const table = this._tableManager.getTableById(unitId, tableId);
2348
+ const anchor = this._shape.getAnchorRegion(tableId);
2349
+ if (!table || !anchor) return;
2350
+ this._closeFloatingControls();
2351
+ this._shape.setOpenedMenuTableId(tableId);
2352
+ const range = table.getRange();
2353
+ this._menuPopup = this._sheetCanvasPopupService.attachPopupByPosition({
2354
+ left: anchor.left,
2355
+ right: anchor.left + anchor.width,
2356
+ top: anchor.top,
2357
+ bottom: anchor.top + anchor.height
2358
+ }, {
2359
+ componentKey: "SHEET_TABLE_MENU",
2360
+ direction: "bottom-left",
2361
+ extraProps: {
2362
+ anchorWidth: anchor.width,
2363
+ tableName: table.getDisplayName(),
2364
+ labels: {
2365
+ rename: this._localeService.t("sheets-table-ui.rename"),
2366
+ "update-range": this._localeService.t("sheets-table-ui.updateRange"),
2367
+ "set-theme": this._localeService.t("sheets-table-ui.setTheme"),
2368
+ delete: this._localeService.t("sheets-table-ui.removeTable")
2369
+ },
2370
+ onSelect: (action) => this._handleTableMenuAction(action, unitId, subUnitId, tableId),
2371
+ onClose: () => this._closeFloatingControls()
2372
+ }
2373
+ }, {
2374
+ unitId,
2375
+ subUnitId,
2376
+ row: range.startRow,
2377
+ col: range.startColumn
2378
+ }) ?? null;
2379
+ if (!this._menuPopup) this._shape.setOpenedMenuTableId(null);
2380
+ }
2381
+ _handleTableMenuAction(action, unitId, subUnitId, tableId) {
2382
+ this._closeFloatingControls();
2383
+ switch (action) {
2403
2384
  case "rename":
2404
- this._openRenameDialog(unitId, hit.tableId);
2405
- break;
2406
- case "update-range":
2407
- this._openRangeSelector(unitId, subUnitId, hit.tableId);
2385
+ this._openRenameDialog(unitId, tableId);
2408
2386
  break;
2387
+ case "update-range": return this._openRangeSelector(unitId, subUnitId, tableId);
2409
2388
  case "set-theme":
2410
- this._openThemePanel(unitId, subUnitId, hit.tableId);
2389
+ this._openThemePanel(unitId, subUnitId, tableId);
2411
2390
  break;
2412
2391
  case "delete":
2413
2392
  this._commandService.executeCommand(DeleteSheetTableCommand.id, {
2414
- tableId: hit.tableId,
2393
+ tableId,
2415
2394
  subUnitId,
2416
2395
  unitId
2417
2396
  });
2418
2397
  break;
2419
2398
  }
2420
- this._closeFloatingControls();
2421
2399
  }
2422
2400
  _openRenameDialog(unitId, tableId) {
2423
2401
  this._dialogService.open({
@@ -2454,13 +2432,15 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
2454
2432
  this._sidebarService.open({
2455
2433
  id: SHEET_TABLE_THEME_PANEL_ID,
2456
2434
  header: { title: this._localeService.t("sheets-table-ui.tableStyle") },
2457
- children: {
2458
- label: SHEET_TABLE_THEME_PANEL,
2459
- oldConfig: table.getTableConfig(),
2460
- unitId,
2461
- subUnitId,
2462
- tableId
2463
- },
2435
+ children: { label: {
2436
+ name: SHEET_TABLE_THEME_PANEL,
2437
+ props: {
2438
+ oldConfig: table.getTableConfig(),
2439
+ unitId,
2440
+ subUnitId,
2441
+ tableId
2442
+ }
2443
+ } },
2464
2444
  width: 330
2465
2445
  });
2466
2446
  }
@@ -2514,12 +2494,11 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
2514
2494
  const previousTopGap = rowGaps[TABLE_CONTROL_GAP_ROW] ? { ...rowGaps[TABLE_CONTROL_GAP_ROW] } : null;
2515
2495
  let shouldSync = false;
2516
2496
  if (hasTopTable) {
2517
- var _baseGap$size;
2518
2497
  if (!this._topGapBaseBySkeleton.has(skeleton)) this._topGapBaseBySkeleton.set(skeleton, rowGaps[TABLE_CONTROL_GAP_ROW] ? { ...rowGaps[TABLE_CONTROL_GAP_ROW] } : null);
2519
2498
  const baseGap = this._topGapBaseBySkeleton.get(skeleton);
2520
2499
  rowGaps[TABLE_CONTROL_GAP_ROW] = {
2521
- ...baseGap !== null && baseGap !== void 0 ? baseGap : rowGaps[TABLE_CONTROL_GAP_ROW],
2522
- size: ((_baseGap$size = baseGap === null || baseGap === void 0 ? void 0 : baseGap.size) !== null && _baseGap$size !== void 0 ? _baseGap$size : 0) + 32
2500
+ ...baseGap ?? rowGaps[TABLE_CONTROL_GAP_ROW],
2501
+ size: ((baseGap === null || baseGap === void 0 ? void 0 : baseGap.size) ?? 0) + 32
2523
2502
  };
2524
2503
  shouldSync = true;
2525
2504
  } else if (this._topGapBaseBySkeleton.has(skeleton)) {
@@ -2541,6 +2520,9 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
2541
2520
  this._selectionRenderService.resetSelectionsByModelData(this._sheetsSelectionsService.getCurrentSelections());
2542
2521
  }
2543
2522
  _closeFloatingControls() {
2523
+ const menuPopup = this._menuPopup;
2524
+ this._menuPopup = null;
2525
+ menuPopup === null || menuPopup === void 0 || menuPopup.dispose();
2544
2526
  this._shape.setOpenedMenuTableId(null);
2545
2527
  this._shape.setHoveredInsertRegion(null);
2546
2528
  this._shape.setHoveredRegion(null);
@@ -2567,7 +2549,8 @@ SheetTableControlsRenderController = __decorate([
2567
2549
  __decorateParam(10, Inject(SheetTableThemeUIController)),
2568
2550
  __decorateParam(11, Inject(LocaleService)),
2569
2551
  __decorateParam(12, IDialogService),
2570
- __decorateParam(13, ISidebarService)
2552
+ __decorateParam(13, ISidebarService),
2553
+ __decorateParam(14, Inject(SheetCanvasPopManagerService))
2571
2554
  ], SheetTableControlsRenderController);
2572
2555
 
2573
2556
  //#endregion
@@ -2740,12 +2723,12 @@ let SheetsTableFilterButtonRenderController = class SheetsTableFilterButtonRende
2740
2723
  const worksheet = workbook.getSheetBySheetId(worksheetId);
2741
2724
  if (!worksheet) return;
2742
2725
  for (const { range, states, tableId } of tableFilterRanges) {
2743
- var _this$_rangeThemeMode, _headerStyle$cl$rgb, _headerStyle$cl, _headerStyle$bg$rgb, _headerStyle$bg;
2726
+ var _this$_rangeThemeMode, _headerStyle$cl, _headerStyle$bg;
2744
2727
  const { startRow, startColumn, endColumn } = range;
2745
2728
  const table = this._tableManager.getTableById(unitId, tableId);
2746
2729
  const headerStyle = table ? (_this$_rangeThemeMode = this._rangeThemeModel.getRangeThemeStyle(unitId, table.getTableStyleId())) === null || _this$_rangeThemeMode === void 0 ? void 0 : _this$_rangeThemeMode.getHeaderRowStyle() : null;
2747
- const iconColor = (_headerStyle$cl$rgb = headerStyle === null || headerStyle === void 0 || (_headerStyle$cl = headerStyle.cl) === null || _headerStyle$cl === void 0 ? void 0 : _headerStyle$cl.rgb) !== null && _headerStyle$cl$rgb !== void 0 ? _headerStyle$cl$rgb : "#fff";
2748
- const hoverIconColor = (_headerStyle$bg$rgb = headerStyle === null || headerStyle === void 0 || (_headerStyle$bg = headerStyle.bg) === null || _headerStyle$bg === void 0 ? void 0 : _headerStyle$bg.rgb) !== null && _headerStyle$bg$rgb !== void 0 ? _headerStyle$bg$rgb : "#202124";
2730
+ const iconColor = (headerStyle === null || headerStyle === void 0 || (_headerStyle$cl = headerStyle.cl) === null || _headerStyle$cl === void 0 ? void 0 : _headerStyle$cl.rgb) ?? "#fff";
2731
+ const hoverIconColor = (headerStyle === null || headerStyle === void 0 || (_headerStyle$bg = headerStyle.bg) === null || _headerStyle$bg === void 0 ? void 0 : _headerStyle$bg.rgb) ?? "#202124";
2749
2732
  this._interceptCellContent(unitId, worksheetId, range);
2750
2733
  for (let col = startColumn; col <= endColumn; col++) {
2751
2734
  const key = `sheets-table-filter-button-${startRow}-${col}`;
@@ -3016,7 +2999,7 @@ _defineProperty(UniverSheetsTableUIPlugin, "packageName", name);
3016
2999
  _defineProperty(UniverSheetsTableUIPlugin, "version", version);
3017
3000
  _defineProperty(UniverSheetsTableUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
3018
3001
  UniverSheetsTableUIPlugin = __decorate([
3019
- DependentOn(UniverRenderEnginePlugin, UniverSheetsPlugin, UniverUIPlugin, UniverSheetsTablePlugin, UniverSheetsUIPlugin),
3002
+ DependentOn(UniverRenderEnginePlugin, UniverSheetsPlugin, UniverSheetsTablePlugin, UniverSheetsUIPlugin),
3020
3003
  __decorateParam(1, Inject(Injector)),
3021
3004
  __decorateParam(2, Inject(ICommandService)),
3022
3005
  __decorateParam(3, IConfigService),