@univerjs/sheets-table-ui 1.0.0-beta.0 → 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 +312 -322
  2. package/lib/cjs/locale/ar-SA.js +1 -2
  3. package/lib/cjs/locale/ca-ES.js +1 -2
  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 +1 -2
  20. package/lib/cjs/locale/zh-TW.js +1 -2
  21. package/lib/es/index.js +315 -325
  22. package/lib/es/locale/ar-SA.js +1 -2
  23. package/lib/es/locale/ca-ES.js +1 -2
  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 +1 -2
  40. package/lib/es/locale/zh-TW.js +1 -2
  41. package/lib/index.css +187 -67
  42. package/lib/index.js +315 -325
  43. package/lib/locale/ar-SA.js +1 -2
  44. package/lib/locale/ca-ES.js +1 -2
  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 +1 -2
  61. package/lib/locale/zh-TW.js +1 -2
  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 +12 -12
package/lib/index.js CHANGED
@@ -4,9 +4,9 @@ import { ColorKit, CommandType, DependentOn, Disposable, ErrorService, ICommandS
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)";
@@ -247,7 +248,7 @@ const menuSchema = {
247
248
  //#endregion
248
249
  //#region package.json
249
250
  var name = "@univerjs/sheets-table-ui";
250
- var version = "1.0.0-beta.0";
251
+ var version = "1.0.0-beta.1";
251
252
 
252
253
  //#endregion
253
254
  //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
@@ -941,7 +942,7 @@ const SheetTableConditionPanel = (props) => {
941
942
  wrapperClassName: "!univer-h-[150px]"
942
943
  }),
943
944
  children: /* @__PURE__ */ jsxs("div", {
944
- 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),
945
946
  children: [/* @__PURE__ */ jsx("span", { children: selectType }), /* @__PURE__ */ jsx(MoreDownIcon, {})]
946
947
  })
947
948
  }), /* @__PURE__ */ jsxs("div", {
@@ -949,7 +950,7 @@ const SheetTableConditionPanel = (props) => {
949
950
  children: [
950
951
  subComponentType === "Input" && /* @__PURE__ */ jsx(Fragment, { children: conditionInfo.type === TableConditionTypeEnum.String ? /* @__PURE__ */ jsx(Input, {
951
952
  className: "univer-w-full",
952
- placeholder: "请输入",
953
+ placeholder: localeService.t("sheets-table-ui.filter.input-values-placeholder"),
953
954
  value: conditionInfo.info.string,
954
955
  onChange: (v) => handleConditionInfo({ string: v })
955
956
  }) : /* @__PURE__ */ jsx(InputNumber, {
@@ -1274,14 +1275,14 @@ function SheetTableFilterPanel() {
1274
1275
  };
1275
1276
  const workbookEditableId = new WorkbookEditablePermission(unitId).id;
1276
1277
  return /* @__PURE__ */ jsxs("div", {
1277
- 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",
1278
1279
  children: [
1279
1280
  ((_permissionService$ge = permissionService.getPermissionPoint(workbookEditableId)) === null || _permissionService$ge === void 0 ? void 0 : _permissionService$ge.value) && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
1280
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",
1281
1282
  children: [
1282
1283
  /* @__PURE__ */ jsxs("button", {
1283
1284
  type: "button",
1284
- 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",
1285
1286
  onClick: () => insertColumn("left"),
1286
1287
  children: [/* @__PURE__ */ jsx(LeftInsertColumnDoubleIcon, {
1287
1288
  className: "univer-size-5",
@@ -1290,7 +1291,7 @@ function SheetTableFilterPanel() {
1290
1291
  }),
1291
1292
  /* @__PURE__ */ jsxs("button", {
1292
1293
  type: "button",
1293
- 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",
1294
1295
  onClick: () => insertColumn("right"),
1295
1296
  children: [/* @__PURE__ */ jsx(RightInsertColumnDoubleIcon, {
1296
1297
  className: "univer-size-5",
@@ -1299,7 +1300,7 @@ function SheetTableFilterPanel() {
1299
1300
  }),
1300
1301
  /* @__PURE__ */ jsxs("button", {
1301
1302
  type: "button",
1302
- 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",
1303
1304
  disabled: !canDeleteColumn,
1304
1305
  onClick: deleteColumn,
1305
1306
  children: [/* @__PURE__ */ jsx(DeleteColumnDoubleIcon, {
@@ -1360,20 +1361,68 @@ function SheetTableFilterPanel() {
1360
1361
  disabled: tableFilter === void 0,
1361
1362
  onClick: onClearFilter,
1362
1363
  children: localeService.t("sheets-table-ui.filter.clear-filter")
1363
- }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Button, {
1364
- className: "univer-mr-2",
1365
- onClick: onCancel,
1366
- children: localeService.t("sheets-table-ui.filter.cancel")
1367
- }), /* @__PURE__ */ jsx(Button, {
1368
- variant: "primary",
1369
- onClick: onApply,
1370
- children: localeService.t("sheets-table-ui.filter.confirm")
1371
- })] })]
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
+ })]
1372
1375
  })
1373
1376
  ]
1374
1377
  });
1375
1378
  }
1376
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
+
1377
1426
  //#endregion
1378
1427
  //#region src/views/components/SheetTableRenameDialog.tsx
1379
1428
  function SheetTableRenameDialog(props) {
@@ -1601,7 +1650,7 @@ const SheetTableThemePanel = (props) => {
1601
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)";
1602
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)";
1603
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)";
1604
- const [hoverCustomId, setHoverCustomId] = useState(null);
1653
+ const direction = useObservable(localeService.direction$, localeService.getDirection());
1605
1654
  const handleThemeChange = (theme) => {
1606
1655
  commandService.executeCommand(SetSheetTableCommand.id, {
1607
1656
  unitId,
@@ -1647,237 +1696,192 @@ const SheetTableThemePanel = (props) => {
1647
1696
  const firstRowBgIsDark = new ColorKit(firstRowBg).isDark();
1648
1697
  const secondRowBgIsDark = new ColorKit(secondRowBg).isDark();
1649
1698
  const lastRowBgIsDark = new ColorKit(lastRowBg).isDark();
1650
- return /* @__PURE__ */ jsxs("div", { children: [
1651
- /* @__PURE__ */ jsx("h5", { children: localeService.t("sheets-table-ui.defaultStyle") }),
1652
- /* @__PURE__ */ jsx("div", {
1653
- className: "univer-flex univer-gap-2",
1654
- children: defaultRangeThemes.map((item) => {
1655
- var _rangeThemeItem$getHe, _rangeThemeItem$getFi, _rangeThemeItem$getSe, _rangeThemeItem$getLa;
1656
- const rangeThemeItem = rangeThemeModel.getDefaultRangeThemeStyle(item);
1657
- 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)";
1658
- 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)";
1659
- 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)";
1660
- 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)";
1661
- return /* @__PURE__ */ jsxs("div", {
1662
- 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 }),
1663
- onClick: () => handleThemeChange(item),
1664
- children: [
1665
- /* @__PURE__ */ jsx("div", { style: {
1666
- background: headerRowBg,
1667
- border: `${headerRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
1668
- } }),
1669
- /* @__PURE__ */ jsx("div", { style: {
1670
- background: firstRowBg,
1671
- border: `${firstRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
1672
- } }),
1673
- /* @__PURE__ */ jsx("div", { style: {
1674
- background: secondRowBg,
1675
- border: `${secondRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
1676
- } }),
1677
- /* @__PURE__ */ jsx("div", { style: {
1678
- background: lastRowBg,
1679
- border: `${lastRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
1680
- } })
1681
- ]
1682
- }, item);
1683
- })
1684
- }),
1685
- /* @__PURE__ */ jsx("h5", { children: localeService.t("sheets-table-ui.customStyle") }),
1686
- /* @__PURE__ */ jsxs("div", {
1687
- className: clsx("univer-w-full univer-rounded-sm", borderClassName),
1688
- children: [/* @__PURE__ */ jsxs("div", {
1689
- className: "univer-flex univer-flex-wrap univer-gap-2 univer-p-2",
1690
- children: [/* @__PURE__ */ jsx("div", {
1691
- className: clsx("univer-h-10 univer-w-8 univer-cursor-pointer univer-p-px univer-text-center univer-leading-10", borderClassName),
1692
- onClick: handleAddCustomTheme,
1693
- children: "+"
1694
- }), customRangeThemes.map((item) => {
1695
- var _rangeThemeItem$getHe2, _rangeThemeItem$getFi2, _rangeThemeItem$getSe2, _rangeThemeItem$getLa2;
1696
- const rangeThemeItem = rangeThemeModel.getCustomRangeThemeStyle(unitId, item);
1697
- 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;
1698
- 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;
1699
- 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;
1700
- 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;
1701
- return /* @__PURE__ */ jsxs("div", {
1702
- 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 }),
1703
1777
  onClick: () => handleThemeChange(item),
1704
- onMouseEnter: () => setHoverCustomId(item),
1705
- onMouseLeave: () => setHoverCustomId(null),
1706
- children: [
1707
- /* @__PURE__ */ jsx("div", {
1708
- className: "univer-box-border univer-h-2.5",
1709
- style: {
1710
- background: headerRowBg ?? "none",
1711
- border: `${headerRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
1712
- }
1713
- }),
1714
- /* @__PURE__ */ jsx("div", {
1715
- className: "univer-box-border univer-h-2.5",
1716
- style: {
1717
- background: firstRowBg ?? "none",
1718
- border: `${firstRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
1719
- }
1720
- }),
1721
- /* @__PURE__ */ jsx("div", {
1722
- className: "univer-box-border univer-h-2.5",
1723
- style: {
1724
- background: secondRowBg ?? "none",
1725
- border: `${secondRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
1726
- }
1727
- }),
1728
- /* @__PURE__ */ jsx("div", {
1729
- className: "univer-box-border univer-h-2.5",
1730
- style: {
1731
- background: lastRowBg ?? "none",
1732
- border: `${lastRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
1733
- }
1734
- }),
1735
- /* @__PURE__ */ jsx("div", {
1736
- 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]",
1737
- style: { display: hoverCustomId === item ? "block" : "none" },
1738
- onClick: (e) => {
1739
- e.stopPropagation();
1740
- removeCustomTheme(item);
1741
- },
1742
- children: "x"
1743
- })
1744
- ]
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))
1745
1785
  }, item);
1746
- })]
1747
- }), customSelected && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", { className: "univer-h-px univer-w-full univer-bg-gray-200" }), /* @__PURE__ */ jsxs("div", {
1748
- className: "univer-flex univer-flex-col univer-gap-2 univer-p-2",
1749
- children: [
1750
- /* @__PURE__ */ jsxs("div", {
1751
- className: "univer-flex univer-h-9 univer-gap-2",
1752
- children: [/* @__PURE__ */ jsx("div", {
1753
- className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
1754
- "univer-text-white": headerBgIsDark,
1755
- "univer-text-gray-900": !headerBgIsDark
1756
- }),
1757
- style: { background: headerBg },
1758
- children: localeService.t("sheets-table-ui.header")
1759
- }), /* @__PURE__ */ jsx(Dropdown, {
1760
- overlay: /* @__PURE__ */ jsx("div", {
1761
- className: "univer-p-2",
1762
- children: /* @__PURE__ */ jsx(ColorPicker, {
1763
- value: headerBg,
1764
- onChange: (val) => {
1765
- const headerRowStyle = processStyleWithBorderStyle("headerRowStyle", {
1766
- bg: { rgb: val },
1767
- cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
1768
- });
1769
- setCustomTheme(table.getTableStyleId(), { headerRowStyle });
1770
- }
1771
- })
1772
- }),
1773
- children: /* @__PURE__ */ jsxs("div", {
1774
- className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
1775
- children: [/* @__PURE__ */ jsx("div", {
1776
- className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName, {
1777
- "univer-text-white": headerBgIsDark,
1778
- "univer-text-gray-900": !headerBgIsDark
1779
- }),
1780
- style: { background: headerBg }
1781
- }), /* @__PURE__ */ jsx(DownIcon, { className: "univer-size-2" })]
1782
- })
1783
- })]
1784
- }),
1785
- /* @__PURE__ */ jsxs("div", {
1786
- className: "univer-flex univer-h-9 univer-gap-2",
1787
- children: [/* @__PURE__ */ jsx("div", {
1788
- className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
1789
- "univer-text-white": firstRowBgIsDark,
1790
- "univer-text-gray-900": !firstRowBgIsDark
1791
- }),
1792
- style: { background: firstRowBg },
1793
- children: localeService.t("sheets-table-ui.firstLine")
1794
- }), /* @__PURE__ */ jsx(Dropdown, {
1795
- overlay: /* @__PURE__ */ jsx("div", {
1796
- className: "univer-p-2",
1797
- children: /* @__PURE__ */ jsx(ColorPicker, {
1798
- value: firstRowBg,
1799
- onChange: (val) => {
1800
- setCustomTheme(table.getTableStyleId(), { firstRowStyle: {
1801
- bg: { rgb: val },
1802
- cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
1803
- } });
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
1804
1828
  }
1805
- })
1806
- }),
1807
- children: /* @__PURE__ */ jsxs("div", {
1808
- className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
1809
- children: [/* @__PURE__ */ jsx("div", {
1810
- className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName),
1811
- style: { background: firstRowBg }
1812
- }), /* @__PURE__ */ jsx(DownIcon, { className: "univer-size-2" })]
1813
- })
1814
- })]
1815
- }),
1816
- /* @__PURE__ */ jsxs("div", {
1817
- 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",
1818
1851
  children: [/* @__PURE__ */ jsx("div", {
1819
- className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
1820
- "univer-text-white": secondRowBgIsDark,
1821
- "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
1822
1855
  }),
1823
- style: { background: secondRowBg },
1824
- children: localeService.t("sheets-table-ui.secondLine")
1825
- }), /* @__PURE__ */ jsx(Dropdown, {
1826
- overlay: /* @__PURE__ */ jsx("div", {
1827
- className: "univer-p-2",
1828
- children: /* @__PURE__ */ jsx(ColorPicker, {
1829
- value: secondRowBg,
1830
- onChange: (val) => setCustomTheme(table.getTableStyleId(), { secondRowStyle: {
1831
- bg: { rgb: val },
1832
- cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
1833
- } })
1834
- })
1835
- }),
1836
- children: /* @__PURE__ */ jsxs("div", {
1837
- className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
1838
- children: [/* @__PURE__ */ jsx("div", {
1839
- className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName),
1840
- style: { background: secondRowBg }
1841
- }), /* @__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
1842
1860
  })
1843
- })]
1844
- }),
1845
- /* @__PURE__ */ jsxs("div", {
1846
- className: "univer-flex univer-h-9 univer-gap-2",
1847
- children: [/* @__PURE__ */ jsx("div", {
1848
- className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
1849
- "univer-text-white": lastRowBgIsDark,
1850
- "univer-text-gray-900": !lastRowBgIsDark
1851
- }),
1852
- style: { background: lastRowBg },
1853
- children: localeService.t("sheets-table-ui.footer")
1854
1861
  }), /* @__PURE__ */ jsx(Dropdown, {
1855
1862
  overlay: /* @__PURE__ */ jsx("div", {
1863
+ dir: direction,
1856
1864
  className: "univer-p-2",
1857
1865
  children: /* @__PURE__ */ jsx(ColorPicker, {
1858
- value: lastRowBg,
1859
- onChange: (val) => {
1860
- const lastRowStyle = processStyleWithBorderStyle("lastRowStyle", {
1861
- bg: { rgb: val },
1862
- cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
1863
- });
1864
- setCustomTheme(table.getTableStyleId(), { lastRowStyle });
1865
- }
1866
+ value: new ColorKit(row.background).toHexString(),
1867
+ onChange: row.onChange
1866
1868
  })
1867
1869
  }),
1868
- children: /* @__PURE__ */ jsxs("div", {
1869
- className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
1870
- children: [/* @__PURE__ */ jsx("div", {
1871
- className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName),
1872
- style: { background: lastRowBg }
1873
- }), /* @__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" })]
1874
1878
  })
1875
1879
  })]
1876
- })
1877
- ]
1878
- })] })]
1879
- })
1880
- ] });
1880
+ }, row.key))
1881
+ })
1882
+ ]
1883
+ })]
1884
+ });
1881
1885
  };
1882
1886
 
1883
1887
  //#endregion
@@ -1906,7 +1910,11 @@ let ComponentsController = class ComponentsController extends Disposable {
1906
1910
  this._registerIcons();
1907
1911
  }
1908
1912
  _registerComponents() {
1909
- [[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]) => {
1910
1918
  this.disposeWithMe(this._componentManager.register(key, comp));
1911
1919
  });
1912
1920
  [[TABLE_SELECTOR_DIALOG, SheetTableSelector], [SHEET_TABLE_THEME_PANEL, SheetTableThemePanel]].forEach(([key, comp]) => {
@@ -1921,14 +1929,6 @@ ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)),
1921
1929
 
1922
1930
  //#endregion
1923
1931
  //#region src/views/widgets/table-controls-util.ts
1924
- const TABLE_CONTROL_MENU_WIDTH = 168;
1925
- const TABLE_CONTROL_MENU_ITEM_HEIGHT = 32;
1926
- const TABLE_CONTROL_MENU_ACTIONS = [
1927
- "rename",
1928
- "update-range",
1929
- "set-theme",
1930
- "delete"
1931
- ];
1932
1932
  function isPointInTableControlRegion(region, x, y) {
1933
1933
  return x >= region.left && x <= region.left + region.width && y >= region.top && y <= region.top + region.height;
1934
1934
  }
@@ -1936,17 +1936,6 @@ function hitTestTableControl(regions, x, y) {
1936
1936
  for (let i = regions.length - 1; i >= 0; i--) if (isPointInTableControlRegion(regions[i], x, y)) return regions[i];
1937
1937
  return null;
1938
1938
  }
1939
- function buildTableMenuRegions(tableId, left, top) {
1940
- return TABLE_CONTROL_MENU_ACTIONS.map((action, index) => ({
1941
- type: "menu-item",
1942
- tableId,
1943
- action,
1944
- left,
1945
- top: top + index * 32,
1946
- width: 168,
1947
- height: 32
1948
- }));
1949
- }
1950
1939
  function buildCenteredPlusSegments(centerX, centerY, size) {
1951
1940
  const halfSize = size / 2;
1952
1941
  return [{
@@ -1972,9 +1961,6 @@ const ANCHOR_OFFSET_Y = 0;
1972
1961
  const ANCHOR_BORDER = "rgba(0, 0, 0, 0.22)";
1973
1962
  const ANCHOR_DIVIDER = "rgba(0, 0, 0, 0.20)";
1974
1963
  const ANCHOR_TOGGLE_BG_ACTIVE = "rgba(0, 0, 0, 0.12)";
1975
- const MENU_RADIUS = 8;
1976
- const MENU_BORDER = "#d9dee7";
1977
- const MENU_HOVER_BG = "#f1f3f4";
1978
1964
  const INSERT_BUTTON_VISUAL_SIZE = 18;
1979
1965
  const INSERT_BUTTON_PLUS_SIZE = 8;
1980
1966
  var SheetTableControlsShape = class extends Shape {
@@ -1990,21 +1976,11 @@ var SheetTableControlsShape = class extends Shape {
1990
1976
  _defineProperty(this, "_openedMenuTableId", null);
1991
1977
  _defineProperty(this, "_hoveredRegion", null);
1992
1978
  _defineProperty(this, "_hoveredInsertRegion", null);
1993
- _defineProperty(this, "_menuLabels", {
1994
- rename: "Rename table",
1995
- "update-range": "Update range",
1996
- "set-theme": "Set theme",
1997
- delete: "Remove table"
1998
- });
1999
1979
  }
2000
1980
  setItems(items) {
2001
1981
  this._items = items;
2002
1982
  this.makeDirty(true);
2003
1983
  }
2004
- setMenuLabels(labels) {
2005
- this._menuLabels = labels;
2006
- this.makeDirty(true);
2007
- }
2008
1984
  setOpenedMenuTableId(tableId) {
2009
1985
  if (this._openedMenuTableId === tableId) return;
2010
1986
  this._openedMenuTableId = tableId;
@@ -2013,6 +1989,9 @@ var SheetTableControlsShape = class extends Shape {
2013
1989
  getOpenedMenuTableId() {
2014
1990
  return this._openedMenuTableId;
2015
1991
  }
1992
+ getAnchorRegion(tableId) {
1993
+ return this._regions.find((region) => region.type === "anchor-main" && region.tableId === tableId) ?? null;
1994
+ }
2016
1995
  setHoveredRegion(region) {
2017
1996
  if (this._hoveredRegion === region) return;
2018
1997
  this._hoveredRegion = region;
@@ -2092,7 +2071,6 @@ var SheetTableControlsShape = class extends Shape {
2092
2071
  height: 28
2093
2072
  });
2094
2073
  this._regions.push(toggleRegion);
2095
- if (this._openedMenuTableId === item.tableId) this._drawMenu(ctx, item.tableId, left, top + 28);
2096
2074
  }
2097
2075
  _drawAnchorToggle(ctx, anchorWidth, color, active) {
2098
2076
  const toggleLeft = anchorWidth - ANCHOR_TOGGLE_WIDTH;
@@ -2153,34 +2131,6 @@ var SheetTableControlsShape = class extends Shape {
2153
2131
  ctx.fill();
2154
2132
  ctx.restore();
2155
2133
  }
2156
- _drawMenu(ctx, tableId, left, top) {
2157
- const regions = buildTableMenuRegions(tableId, left, top);
2158
- ctx.save();
2159
- ctx.translateWithPrecision(left, top);
2160
- Rect.drawWith(ctx, {
2161
- width: 168,
2162
- height: regions.length * 32,
2163
- radius: MENU_RADIUS,
2164
- fill: "#fff",
2165
- stroke: MENU_BORDER
2166
- });
2167
- ctx.restore();
2168
- for (const region of regions) {
2169
- if (this._isSameRegion(this._hoveredRegion, region)) {
2170
- ctx.save();
2171
- ctx.fillStyle = MENU_HOVER_BG;
2172
- ctx.fillRectByPrecision(region.left, region.top, region.width, region.height);
2173
- ctx.restore();
2174
- }
2175
- ctx.save();
2176
- ctx.font = `12px ${DEFAULT_FONTFACE_PLANE}`;
2177
- ctx.fillStyle = region.action === "delete" ? "#d92d20" : "#344054";
2178
- ctx.textAlign = "left";
2179
- ctx.fillText(this._menuLabels[region.action], region.left + 12, region.top + region.height / 2);
2180
- ctx.restore();
2181
- }
2182
- this._regions.push(...regions);
2183
- }
2184
2134
  _drawInsertButton(ctx, region, fill) {
2185
2135
  const centerX = region.left + region.width / 2;
2186
2136
  const centerY = region.top + region.height / 2;
@@ -2204,7 +2154,7 @@ var SheetTableControlsShape = class extends Shape {
2204
2154
  ctx.restore();
2205
2155
  }
2206
2156
  _isSameRegion(a, b) {
2207
- 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);
2208
2158
  }
2209
2159
  };
2210
2160
 
@@ -2225,7 +2175,7 @@ function isSameTopGap(left, right) {
2225
2175
  return left.size === right.size && left.color === right.color && left.stripeColor === right.stripeColor;
2226
2176
  }
2227
2177
  let SheetTableControlsRenderController = class SheetTableControlsRenderController extends Disposable {
2228
- 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) {
2229
2179
  super();
2230
2180
  this._context = _context;
2231
2181
  this._injector = _injector;
@@ -2241,8 +2191,10 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
2241
2191
  this._localeService = _localeService;
2242
2192
  this._dialogService = _dialogService;
2243
2193
  this._sidebarService = _sidebarService;
2194
+ this._sheetCanvasPopupService = _sheetCanvasPopupService;
2244
2195
  _defineProperty(this, "_shape", void 0);
2245
2196
  _defineProperty(this, "_topGapBaseBySkeleton", /* @__PURE__ */ new WeakMap());
2197
+ _defineProperty(this, "_menuPopup", null);
2246
2198
  this._shape = new SheetTableControlsShape("SheetTableControlsShape", () => this._sheetSkeletonManagerService.getCurrentSkeleton() || null);
2247
2199
  this._initShape();
2248
2200
  this._initRefresh();
@@ -2252,6 +2204,7 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
2252
2204
  var _this$_context$compon;
2253
2205
  this._context.scene.addObjects([this._shape], TABLE_CONTROLS_LAYER_INDEX);
2254
2206
  this.disposeWithMe(toDisposable(() => {
2207
+ this._closeFloatingControls();
2255
2208
  this._context.scene.removeObjects([this._shape]);
2256
2209
  }));
2257
2210
  this.disposeWithMe(this._shape.onPointerMove$.subscribeEvent((evt, state) => {
@@ -2298,12 +2251,6 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
2298
2251
  return;
2299
2252
  }
2300
2253
  this._syncTopTableGap(skeleton);
2301
- this._shape.setMenuLabels({
2302
- rename: this._localeService.t("sheets-table-ui.rename"),
2303
- "update-range": this._localeService.t("sheets-table-ui.updateRange"),
2304
- "set-theme": this._localeService.t("sheets-table-ui.setTheme"),
2305
- delete: this._localeService.t("sheets-table-ui.removeTable")
2306
- });
2307
2254
  const unitId = this._context.unit.getUnitId();
2308
2255
  const subUnitId = worksheet.getSheetId();
2309
2256
  const items = this._tableManager.getTablesBySubunitId(unitId, subUnitId).map((table) => {
@@ -2367,7 +2314,7 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
2367
2314
  const unitId = this._context.unit.getUnitId();
2368
2315
  const subUnitId = worksheet.getSheetId();
2369
2316
  if (hit.type === "anchor-menu-toggle" || hit.type === "anchor-main") {
2370
- this._shape.setOpenedMenuTableId(this._shape.getOpenedMenuTableId() === hit.tableId ? null : hit.tableId);
2317
+ this._toggleTableMenu(unitId, subUnitId, hit.tableId);
2371
2318
  return;
2372
2319
  }
2373
2320
  if (hit.type === "insert-row") {
@@ -2390,28 +2337,65 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
2390
2337
  count: 1
2391
2338
  });
2392
2339
  this._closeFloatingControls();
2340
+ }
2341
+ }
2342
+ _toggleTableMenu(unitId, subUnitId, tableId) {
2343
+ if (this._shape.getOpenedMenuTableId() === tableId) {
2344
+ this._closeFloatingControls();
2393
2345
  return;
2394
2346
  }
2395
- if (hit.type !== "menu-item") return;
2396
- 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) {
2397
2384
  case "rename":
2398
- this._openRenameDialog(unitId, hit.tableId);
2399
- break;
2400
- case "update-range":
2401
- this._openRangeSelector(unitId, subUnitId, hit.tableId);
2385
+ this._openRenameDialog(unitId, tableId);
2402
2386
  break;
2387
+ case "update-range": return this._openRangeSelector(unitId, subUnitId, tableId);
2403
2388
  case "set-theme":
2404
- this._openThemePanel(unitId, subUnitId, hit.tableId);
2389
+ this._openThemePanel(unitId, subUnitId, tableId);
2405
2390
  break;
2406
2391
  case "delete":
2407
2392
  this._commandService.executeCommand(DeleteSheetTableCommand.id, {
2408
- tableId: hit.tableId,
2393
+ tableId,
2409
2394
  subUnitId,
2410
2395
  unitId
2411
2396
  });
2412
2397
  break;
2413
2398
  }
2414
- this._closeFloatingControls();
2415
2399
  }
2416
2400
  _openRenameDialog(unitId, tableId) {
2417
2401
  this._dialogService.open({
@@ -2448,13 +2432,15 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
2448
2432
  this._sidebarService.open({
2449
2433
  id: SHEET_TABLE_THEME_PANEL_ID,
2450
2434
  header: { title: this._localeService.t("sheets-table-ui.tableStyle") },
2451
- children: {
2452
- label: SHEET_TABLE_THEME_PANEL,
2453
- oldConfig: table.getTableConfig(),
2454
- unitId,
2455
- subUnitId,
2456
- tableId
2457
- },
2435
+ children: { label: {
2436
+ name: SHEET_TABLE_THEME_PANEL,
2437
+ props: {
2438
+ oldConfig: table.getTableConfig(),
2439
+ unitId,
2440
+ subUnitId,
2441
+ tableId
2442
+ }
2443
+ } },
2458
2444
  width: 330
2459
2445
  });
2460
2446
  }
@@ -2534,6 +2520,9 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
2534
2520
  this._selectionRenderService.resetSelectionsByModelData(this._sheetsSelectionsService.getCurrentSelections());
2535
2521
  }
2536
2522
  _closeFloatingControls() {
2523
+ const menuPopup = this._menuPopup;
2524
+ this._menuPopup = null;
2525
+ menuPopup === null || menuPopup === void 0 || menuPopup.dispose();
2537
2526
  this._shape.setOpenedMenuTableId(null);
2538
2527
  this._shape.setHoveredInsertRegion(null);
2539
2528
  this._shape.setHoveredRegion(null);
@@ -2560,7 +2549,8 @@ SheetTableControlsRenderController = __decorate([
2560
2549
  __decorateParam(10, Inject(SheetTableThemeUIController)),
2561
2550
  __decorateParam(11, Inject(LocaleService)),
2562
2551
  __decorateParam(12, IDialogService),
2563
- __decorateParam(13, ISidebarService)
2552
+ __decorateParam(13, ISidebarService),
2553
+ __decorateParam(14, Inject(SheetCanvasPopManagerService))
2564
2554
  ], SheetTableControlsRenderController);
2565
2555
 
2566
2556
  //#endregion