@univerjs/ui 0.24.0 → 0.25.0-insiders.20260608-e4336f7

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 (141) hide show
  1. package/lib/cjs/facade.js +8 -7
  2. package/lib/cjs/index.js +576 -186
  3. package/lib/cjs/locale/ar-SA.js +81 -0
  4. package/lib/cjs/locale/ca-ES.js +5 -3
  5. package/lib/cjs/locale/de-DE.js +81 -0
  6. package/lib/cjs/locale/en-US.js +5 -3
  7. package/lib/cjs/locale/es-ES.js +5 -3
  8. package/lib/cjs/locale/fa-IR.js +5 -3
  9. package/lib/cjs/locale/fr-FR.js +5 -3
  10. package/lib/cjs/locale/id-ID.js +81 -0
  11. package/lib/cjs/locale/it-IT.js +81 -0
  12. package/lib/cjs/locale/ja-JP.js +5 -3
  13. package/lib/cjs/locale/ko-KR.js +5 -3
  14. package/lib/cjs/locale/pl-PL.js +81 -0
  15. package/lib/cjs/locale/pt-BR.js +81 -0
  16. package/lib/cjs/locale/ru-RU.js +5 -3
  17. package/lib/cjs/locale/sk-SK.js +5 -3
  18. package/lib/cjs/locale/vi-VN.js +5 -3
  19. package/lib/cjs/locale/zh-CN.js +5 -3
  20. package/lib/cjs/locale/zh-HK.js +81 -0
  21. package/lib/cjs/locale/zh-TW.js +5 -3
  22. package/lib/es/facade.js +8 -7
  23. package/lib/es/index.js +577 -170
  24. package/lib/es/locale/ar-SA.js +80 -0
  25. package/lib/es/locale/ca-ES.js +5 -3
  26. package/lib/es/locale/de-DE.js +80 -0
  27. package/lib/es/locale/en-US.js +5 -3
  28. package/lib/es/locale/es-ES.js +5 -3
  29. package/lib/es/locale/fa-IR.js +5 -3
  30. package/lib/es/locale/fr-FR.js +5 -3
  31. package/lib/es/locale/id-ID.js +80 -0
  32. package/lib/es/locale/it-IT.js +80 -0
  33. package/lib/es/locale/ja-JP.js +5 -3
  34. package/lib/es/locale/ko-KR.js +5 -3
  35. package/lib/es/locale/pl-PL.js +80 -0
  36. package/lib/es/locale/pt-BR.js +80 -0
  37. package/lib/es/locale/ru-RU.js +5 -3
  38. package/lib/es/locale/sk-SK.js +5 -3
  39. package/lib/es/locale/vi-VN.js +5 -3
  40. package/lib/es/locale/zh-CN.js +5 -3
  41. package/lib/es/locale/zh-HK.js +80 -0
  42. package/lib/es/locale/zh-TW.js +5 -3
  43. package/lib/facade.js +8 -7
  44. package/lib/index.css +9 -4
  45. package/lib/index.js +577 -170
  46. package/lib/locale/ar-SA.js +80 -0
  47. package/lib/locale/ca-ES.js +5 -3
  48. package/lib/locale/de-DE.js +80 -0
  49. package/lib/locale/en-US.js +5 -3
  50. package/lib/locale/es-ES.js +5 -3
  51. package/lib/locale/fa-IR.js +5 -3
  52. package/lib/locale/fr-FR.js +5 -3
  53. package/lib/locale/id-ID.js +80 -0
  54. package/lib/locale/it-IT.js +80 -0
  55. package/lib/locale/ja-JP.js +5 -3
  56. package/lib/locale/ko-KR.js +5 -3
  57. package/lib/locale/pl-PL.js +80 -0
  58. package/lib/locale/pt-BR.js +80 -0
  59. package/lib/locale/ru-RU.js +5 -3
  60. package/lib/locale/sk-SK.js +5 -3
  61. package/lib/locale/vi-VN.js +5 -3
  62. package/lib/locale/zh-CN.js +5 -3
  63. package/lib/locale/zh-HK.js +80 -0
  64. package/lib/locale/zh-TW.js +5 -3
  65. package/lib/types/components/common-label/index.d.ts +1 -1
  66. package/lib/types/components/custom-label/CustomLabel.d.ts +1 -1
  67. package/lib/types/components/font-family/FontFamily.d.ts +1 -1
  68. package/lib/types/components/font-family/FontFamilyItem.d.ts +1 -1
  69. package/lib/types/components/font-size/FontSize.d.ts +1 -1
  70. package/lib/types/components/heading-item/index.d.ts +1 -1
  71. package/lib/types/components/menu/desktop/DesignTinyMenuGroup.d.ts +2 -1
  72. package/lib/types/components/menu/desktop/TinyMenuGroup.d.ts +6 -2
  73. package/lib/types/components/menu/mobile/MobileMenu.d.ts +1 -1
  74. package/lib/types/components/menu/mobile/MobileMenu.stories.d.ts +1 -1
  75. package/lib/types/components/message/MessageContainer.d.ts +1 -1
  76. package/lib/types/components/notification/Notification.d.ts +1 -1
  77. package/lib/types/components/notification/Notification.stories.d.ts +5 -5
  78. package/lib/types/components/progress-bar/ProgressBar.d.ts +1 -1
  79. package/lib/types/components/slider/Slider.d.ts +2 -1
  80. package/lib/types/components/slider/Slider.stories.d.ts +1 -1
  81. package/lib/types/facade/f-shortcut.d.ts +2 -1
  82. package/lib/types/facade/f-univer.d.ts +8 -4
  83. package/lib/types/index.d.ts +0 -1
  84. package/lib/types/{components/hooks/locale.d.ts → locale/ar-SA.d.ts} +3 -3
  85. package/lib/types/locale/de-DE.d.ts +18 -0
  86. package/lib/types/locale/en-US.d.ts +79 -75
  87. package/lib/types/locale/id-ID.d.ts +18 -0
  88. package/lib/types/locale/it-IT.d.ts +18 -0
  89. package/lib/types/locale/pl-PL.d.ts +18 -0
  90. package/lib/types/locale/pt-BR.d.ts +18 -0
  91. package/lib/types/locale/zh-HK.d.ts +18 -0
  92. package/lib/types/services/before-close/before-close.service.d.ts +5 -1
  93. package/lib/types/services/clipboard/clipboard-interface.service.d.ts +2 -2
  94. package/lib/types/services/menu/menu-manager.service.d.ts +1 -0
  95. package/lib/types/services/ribbon/ribbon.service.d.ts +2 -0
  96. package/lib/types/services/shortcut/shortcut.service.d.ts +8 -0
  97. package/lib/types/utils/storage-driver.d.ts +26 -0
  98. package/lib/types/views/components/confirm-part/ConfirmPart.d.ts +1 -1
  99. package/lib/types/views/components/context-menu/AnchoredContextMenu.d.ts +1 -1
  100. package/lib/types/views/components/context-menu/ContextMenu.d.ts +1 -1
  101. package/lib/types/views/components/context-menu/ContextMenuPanel.d.ts +6 -1
  102. package/lib/types/views/components/dialog-part/DialogPart.d.ts +1 -1
  103. package/lib/types/views/components/dom/FloatDom.d.ts +2 -2
  104. package/lib/types/views/components/dom/Print.d.ts +1 -1
  105. package/lib/types/views/components/gallery-part/GalleryPart.d.ts +1 -1
  106. package/lib/types/views/components/popup/CanvasPopup.d.ts +2 -2
  107. package/lib/types/views/components/popup/RectPopup.d.ts +1 -1
  108. package/lib/types/views/components/ribbon/MobileRibbon.d.ts +1 -1
  109. package/lib/types/views/components/ribbon/Ribbon.d.ts +1 -1
  110. package/lib/types/views/components/ribbon/ToolbarButton.d.ts +1 -1
  111. package/lib/types/views/components/ribbon/TooltipButtonWrapper.d.ts +2 -2
  112. package/lib/types/views/components/ribbon/ribbon-menu/ClassicMenu.d.ts +1 -1
  113. package/lib/types/views/components/ribbon/ribbon-menu/DefaultMenu.d.ts +1 -1
  114. package/lib/types/views/components/shortcut-panel/ShortcutPanel.d.ts +1 -1
  115. package/lib/types/views/components/sidebar/Sidebar.d.ts +1 -1
  116. package/lib/types/views/components/zen-zone/ZenZone.d.ts +1 -1
  117. package/lib/types/views/mobile-workbench/MobileWorkbench.d.ts +1 -1
  118. package/lib/types/views/workbench/Workbench.d.ts +2 -2
  119. package/lib/umd/facade.js +1 -1
  120. package/lib/umd/index.js +51 -43
  121. package/lib/umd/locale/ar-SA.js +1 -0
  122. package/lib/umd/locale/ca-ES.js +1 -1
  123. package/lib/umd/locale/de-DE.js +1 -0
  124. package/lib/umd/locale/en-US.js +1 -1
  125. package/lib/umd/locale/es-ES.js +1 -1
  126. package/lib/umd/locale/fa-IR.js +1 -1
  127. package/lib/umd/locale/fr-FR.js +1 -1
  128. package/lib/umd/locale/id-ID.js +1 -0
  129. package/lib/umd/locale/it-IT.js +1 -0
  130. package/lib/umd/locale/ja-JP.js +1 -1
  131. package/lib/umd/locale/ko-KR.js +1 -1
  132. package/lib/umd/locale/pl-PL.js +1 -0
  133. package/lib/umd/locale/pt-BR.js +1 -0
  134. package/lib/umd/locale/ru-RU.js +1 -1
  135. package/lib/umd/locale/sk-SK.js +1 -1
  136. package/lib/umd/locale/vi-VN.js +1 -1
  137. package/lib/umd/locale/zh-CN.js +1 -1
  138. package/lib/umd/locale/zh-HK.js +1 -0
  139. package/lib/umd/locale/zh-TW.js +1 -1
  140. package/package.json +9 -10
  141. package/LICENSE +0 -176
package/lib/index.js CHANGED
@@ -8,9 +8,8 @@ import { Button, ColorPicker, ConfigContext, ConfigProvider, Confirm, Dialog, Dr
8
8
  import { IRenderManagerService, UniverRenderEnginePlugin, ptToPx } from "@univerjs/engine-render";
9
9
  import { map as map$1, scan as scan$1, startWith as startWith$1 } from "rxjs/operators";
10
10
  import { createPortal } from "react-dom";
11
- import localforage from "localforage";
12
11
 
13
- //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
12
+ //#region \0@oxc-project+runtime@0.134.0/helpers/esm/typeof.js
14
13
  function _typeof(o) {
15
14
  "@babel/helpers - typeof";
16
15
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -21,7 +20,7 @@ function _typeof(o) {
21
20
  }
22
21
 
23
22
  //#endregion
24
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
23
+ //#region \0@oxc-project+runtime@0.134.0/helpers/esm/toPrimitive.js
25
24
  function toPrimitive(t, r) {
26
25
  if ("object" != _typeof(t) || !t) return t;
27
26
  var e = t[Symbol.toPrimitive];
@@ -34,14 +33,14 @@ function toPrimitive(t, r) {
34
33
  }
35
34
 
36
35
  //#endregion
37
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
36
+ //#region \0@oxc-project+runtime@0.134.0/helpers/esm/toPropertyKey.js
38
37
  function toPropertyKey(t) {
39
38
  var i = toPrimitive(t, "string");
40
39
  return "symbol" == _typeof(i) ? i : i + "";
41
40
  }
42
41
 
43
42
  //#endregion
44
- //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
43
+ //#region \0@oxc-project+runtime@0.134.0/helpers/esm/defineProperty.js
45
44
  function _defineProperty(e, r, t) {
46
45
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
47
46
  value: t,
@@ -110,7 +109,7 @@ const ToggleShortcutPanelOperation = {
110
109
  } else {
111
110
  shortcutPanelService.open();
112
111
  sidebarService.open({
113
- header: { title: "shortcut-panel.title" },
112
+ header: { title: "ui.shortcut-panel.title" },
114
113
  children: { label: ShortcutPanelComponentName }
115
114
  });
116
115
  }
@@ -338,9 +337,13 @@ function getMenuHiddenObservable(accessor, targetUniverType, matchUnitId, needHi
338
337
  subscriber.next(univerType !== targetUniverType);
339
338
  });
340
339
  const focusedUniverInstance = univerInstanceService.getFocusedUnit();
341
- if (focusedUniverInstance == null) return subscriber.next(true);
342
- const univerType = univerInstanceService.getUnitType(focusedUniverInstance.getUnitId());
343
- subscriber.next(univerType !== targetUniverType);
340
+ if (focusedUniverInstance == null) {
341
+ const currentUnit = univerInstanceService.getCurrentUnitOfType(targetUniverType);
342
+ subscriber.next(currentUnit == null);
343
+ } else {
344
+ const univerType = univerInstanceService.getUnitType(focusedUniverInstance.getUnitId());
345
+ subscriber.next(univerType !== targetUniverType);
346
+ }
344
347
  return () => subscription.unsubscribe();
345
348
  });
346
349
  }
@@ -354,9 +357,11 @@ function getHeaderFooterMenuHiddenObservable(accessor) {
354
357
  subscriber.next(documentFlavor !== DocumentFlavor.TRADITIONAL);
355
358
  });
356
359
  const docDataModel = univerInstanceService.getCurrentUniverDocInstance();
357
- if (docDataModel == null) return subscriber.next(true);
358
- const documentFlavor = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot().documentStyle.documentFlavor;
359
- subscriber.next(documentFlavor !== DocumentFlavor.TRADITIONAL);
360
+ if (docDataModel == null) subscriber.next(true);
361
+ else {
362
+ const documentFlavor = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot().documentStyle.documentFlavor;
363
+ subscriber.next(documentFlavor !== DocumentFlavor.TRADITIONAL);
364
+ }
360
365
  return () => subscription.unsubscribe();
361
366
  });
362
367
  }
@@ -765,7 +770,7 @@ const configSymbol = Symbol(UI_PLUGIN_CONFIG_KEY);
765
770
  const defaultPluginConfig = {};
766
771
 
767
772
  //#endregion
768
- //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
773
+ //#region \0@oxc-project+runtime@0.134.0/helpers/esm/decorateParam.js
769
774
  function __decorateParam(paramIndex, decorator) {
770
775
  return function(target, key) {
771
776
  decorator(target, key, paramIndex);
@@ -773,7 +778,7 @@ function __decorateParam(paramIndex, decorator) {
773
778
  }
774
779
 
775
780
  //#endregion
776
- //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
781
+ //#region \0@oxc-project+runtime@0.134.0/helpers/esm/decorate.js
777
782
  function __decorate(decorators, target, key, desc) {
778
783
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
779
784
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -787,67 +792,67 @@ const IFontService = createIdentifier("univer.font-service");
787
792
  const DEFAULT_FONT_LIST = [
788
793
  {
789
794
  value: "Arial",
790
- label: "fontFamily.arial",
795
+ label: "ui.fontFamily.arial",
791
796
  category: "sans-serif"
792
797
  },
793
798
  {
794
799
  value: "Times New Roman",
795
- label: "fontFamily.times-new-roman",
800
+ label: "ui.fontFamily.times-new-roman",
796
801
  category: "serif"
797
802
  },
798
803
  {
799
804
  value: "Tahoma",
800
- label: "fontFamily.tahoma",
805
+ label: "ui.fontFamily.tahoma",
801
806
  category: "sans-serif"
802
807
  },
803
808
  {
804
809
  value: "Verdana",
805
- label: "fontFamily.verdana",
810
+ label: "ui.fontFamily.verdana",
806
811
  category: "sans-serif"
807
812
  },
808
813
  {
809
814
  value: "Microsoft YaHei",
810
- label: "fontFamily.microsoft-yahei",
815
+ label: "ui.fontFamily.microsoft-yahei",
811
816
  category: "sans-serif"
812
817
  },
813
818
  {
814
819
  value: "SimSun",
815
- label: "fontFamily.simsun",
820
+ label: "ui.fontFamily.simsun",
816
821
  category: "serif"
817
822
  },
818
823
  {
819
824
  value: "SimHei",
820
- label: "fontFamily.simhei",
825
+ label: "ui.fontFamily.simhei",
821
826
  category: "sans-serif"
822
827
  },
823
828
  {
824
829
  value: "Kaiti",
825
- label: "fontFamily.kaiti",
830
+ label: "ui.fontFamily.kaiti",
826
831
  category: "serif"
827
832
  },
828
833
  {
829
834
  value: "FangSong",
830
- label: "fontFamily.fangsong",
835
+ label: "ui.fontFamily.fangsong",
831
836
  category: "serif"
832
837
  },
833
838
  {
834
839
  value: "NSimSun",
835
- label: "fontFamily.nsimsun",
840
+ label: "ui.fontFamily.nsimsun",
836
841
  category: "serif"
837
842
  },
838
843
  {
839
844
  value: "STXinwei",
840
- label: "fontFamily.stxinwei",
845
+ label: "ui.fontFamily.stxinwei",
841
846
  category: "serif"
842
847
  },
843
848
  {
844
849
  value: "STXingkai",
845
- label: "fontFamily.stxingkai",
850
+ label: "ui.fontFamily.stxingkai",
846
851
  category: "serif"
847
852
  },
848
853
  {
849
854
  value: "STLiti",
850
- label: "fontFamily.stliti",
855
+ label: "ui.fontFamily.stliti",
851
856
  category: "serif"
852
857
  }
853
858
  ];
@@ -1136,7 +1141,7 @@ const FontFamilyItem = ({ id, value }) => {
1136
1141
  type: "button",
1137
1142
  onClick: () => handleSelectFont(font.value),
1138
1143
  children: [localeService.t(font.label), !fontService.isFontSupported(font.value) && /* @__PURE__ */ jsx(Tooltip, {
1139
- title: localeService.t("fontFamily.not-supported"),
1144
+ title: localeService.t("ui.fontFamily.not-supported"),
1140
1145
  children: /* @__PURE__ */ jsx(InfoIcon, { className: "univer-text-gray-300 dark:!univer-text-gray-400" })
1141
1146
  })]
1142
1147
  }) }, font.value))
@@ -1244,35 +1249,35 @@ const FONT_SIZE_LIST = [
1244
1249
  ];
1245
1250
  const HEADING_LIST = [
1246
1251
  {
1247
- label: "toolbar.heading.normal",
1252
+ label: "ui.toolbar.heading.normal",
1248
1253
  value: NamedStyleType.NORMAL_TEXT
1249
1254
  },
1250
1255
  {
1251
- label: "toolbar.heading.title",
1256
+ label: "ui.toolbar.heading.title",
1252
1257
  value: NamedStyleType.TITLE
1253
1258
  },
1254
1259
  {
1255
- label: "toolbar.heading.subTitle",
1260
+ label: "ui.toolbar.heading.subTitle",
1256
1261
  value: NamedStyleType.SUBTITLE
1257
1262
  },
1258
1263
  {
1259
- label: "toolbar.heading.1",
1264
+ label: "ui.toolbar.heading.1",
1260
1265
  value: NamedStyleType.HEADING_1
1261
1266
  },
1262
1267
  {
1263
- label: "toolbar.heading.2",
1268
+ label: "ui.toolbar.heading.2",
1264
1269
  value: NamedStyleType.HEADING_2
1265
1270
  },
1266
1271
  {
1267
- label: "toolbar.heading.3",
1272
+ label: "ui.toolbar.heading.3",
1268
1273
  value: NamedStyleType.HEADING_3
1269
1274
  },
1270
1275
  {
1271
- label: "toolbar.heading.4",
1276
+ label: "ui.toolbar.heading.4",
1272
1277
  value: NamedStyleType.HEADING_4
1273
1278
  },
1274
1279
  {
1275
- label: "toolbar.heading.5",
1280
+ label: "ui.toolbar.heading.5",
1276
1281
  value: NamedStyleType.HEADING_5
1277
1282
  }
1278
1283
  ];
@@ -1464,12 +1469,6 @@ const useVirtualList = (list, options) => {
1464
1469
  }];
1465
1470
  };
1466
1471
 
1467
- //#endregion
1468
- //#region src/components/hooks/locale.ts
1469
- function t(localeService, key, ...args) {
1470
- return localeService.t(key);
1471
- }
1472
-
1473
1472
  //#endregion
1474
1473
  //#region src/components/progress-bar/ProgressBar.tsx
1475
1474
  /**
@@ -1981,15 +1980,17 @@ function whenEditorFocusedButNotCellEditor(contextService) {
1981
1980
  }
1982
1981
  const CopyShortcutItem = {
1983
1982
  id: CopyCommand.id,
1984
- description: "shortcut.copy",
1983
+ description: "ui.shortcut.copy",
1985
1984
  group: "1_common-edit",
1985
+ groupTitle: "ui.common-edit",
1986
1986
  binding: 67 | 4096,
1987
1987
  preconditions: whenEditorFocused
1988
1988
  };
1989
1989
  const CutShortcutItem = {
1990
1990
  id: CutCommand.id,
1991
- description: "shortcut.cut",
1991
+ description: "ui.shortcut.cut",
1992
1992
  group: "1_common-edit",
1993
+ groupTitle: "ui.common-edit",
1993
1994
  binding: 88 | 4096,
1994
1995
  preconditions: whenEditorFocused
1995
1996
  };
@@ -1998,22 +1999,25 @@ const CutShortcutItem = {
1998
1999
  */
1999
2000
  const OnlyDisplayPasteShortcutItem = {
2000
2001
  id: PasteCommand.id,
2001
- description: "shortcut.paste",
2002
+ description: "ui.shortcut.paste",
2002
2003
  group: "1_common-edit",
2004
+ groupTitle: "ui.common-edit",
2003
2005
  binding: 86 | 4096,
2004
2006
  preconditions: () => false
2005
2007
  };
2006
2008
  const UndoShortcutItem = {
2007
2009
  id: UndoCommand.id,
2008
- description: "shortcut.undo",
2010
+ description: "ui.shortcut.undo",
2009
2011
  group: "1_common-edit",
2012
+ groupTitle: "ui.common-edit",
2010
2013
  binding: 90 | 4096,
2011
2014
  preconditions: whenEditorFocusedButNotCellEditor
2012
2015
  };
2013
2016
  const RedoShortcutItem = {
2014
2017
  id: RedoCommand.id,
2015
- description: "shortcut.redo",
2018
+ description: "ui.shortcut.redo",
2016
2019
  group: "1_common-edit",
2020
+ groupTitle: "ui.common-edit",
2017
2021
  binding: 89 | 4096,
2018
2022
  preconditions: whenEditorFocusedButNotCellEditor
2019
2023
  };
@@ -2150,6 +2154,7 @@ let MenuManagerService = class MenuManagerService extends Disposable {
2150
2154
  ["ribbon"]: {
2151
2155
  ["ribbon.start"]: {
2152
2156
  order: 0,
2157
+ title: "ui.ribbon.start",
2153
2158
  ["ribbon.start.history"]: { order: 0 },
2154
2159
  ["ribbon.start.format"]: { order: 1 },
2155
2160
  ["ribbon.start.layout"]: { order: 2 },
@@ -2157,17 +2162,20 @@ let MenuManagerService = class MenuManagerService extends Disposable {
2157
2162
  },
2158
2163
  ["ribbon.insert"]: {
2159
2164
  order: 1,
2165
+ title: "ui.ribbon.insert",
2160
2166
  ["ribbon.insert.edit"]: { order: 0 },
2161
2167
  ["ribbon.insert.media"]: { order: 1 },
2162
2168
  ["ribbon.insert.others"]: { order: 2 }
2163
2169
  },
2164
2170
  ["ribbon.formulas"]: {
2165
2171
  order: 2,
2172
+ title: "ui.ribbon.formulas",
2166
2173
  ["ribbon.formulas.basic"]: { order: 0 },
2167
2174
  ["ribbon.formulas.others"]: { order: 1 }
2168
2175
  },
2169
2176
  ["ribbon.data"]: {
2170
2177
  order: 3,
2178
+ title: "ui.ribbon.data",
2171
2179
  ["ribbon.data.formulas"]: { order: 0 },
2172
2180
  ["ribbon.data.rules"]: { order: 1 },
2173
2181
  ["ribbon.data.organization"]: { order: 2 },
@@ -2175,12 +2183,14 @@ let MenuManagerService = class MenuManagerService extends Disposable {
2175
2183
  },
2176
2184
  ["ribbon.view"]: {
2177
2185
  order: 4,
2186
+ title: "ui.ribbon.view",
2178
2187
  ["ribbon.view.display"]: { order: 0 },
2179
2188
  ["ribbon.view.Visibility"]: { order: 0 },
2180
2189
  ["ribbon.view.others"]: { order: 0 }
2181
2190
  },
2182
2191
  ["ribbon.others"]: {
2183
2192
  order: 5,
2193
+ title: "ui.ribbon.others",
2184
2194
  ["ribbon.others.others"]: { order: 0 }
2185
2195
  }
2186
2196
  },
@@ -2275,7 +2285,8 @@ let MenuManagerService = class MenuManagerService extends Disposable {
2275
2285
  order: value.order,
2276
2286
  title: value.title,
2277
2287
  contextual: value.contextual,
2278
- quickLayout: value.quickLayout
2288
+ quickLayout: value.quickLayout,
2289
+ tiny: value.tiny
2279
2290
  };
2280
2291
  if (value.menuItemFactory) {
2281
2292
  const item = this._injector.invoke(value.menuItemFactory);
@@ -2293,7 +2304,7 @@ let MenuManagerService = class MenuManagerService extends Disposable {
2293
2304
  if (menuItem.item || menuItem.children) result.push(menuItem);
2294
2305
  }
2295
2306
  }
2296
- return result;
2307
+ return result.sort((a, b) => normalizeMenuOrder(a.order) - normalizeMenuOrder(b.order));
2297
2308
  }
2298
2309
  /**
2299
2310
  * Get menu schema by position key
@@ -2334,6 +2345,9 @@ let MenuManagerService = class MenuManagerService extends Disposable {
2334
2345
  }
2335
2346
  };
2336
2347
  MenuManagerService = __decorate([__decorateParam(0, Inject(Injector)), __decorateParam(1, IConfigService)], MenuManagerService);
2348
+ function normalizeMenuOrder(order) {
2349
+ return order !== null && order !== void 0 ? order : 0;
2350
+ }
2337
2351
 
2338
2352
  //#endregion
2339
2353
  //#region src/views/components/shortcut-panel/ShortcutPanel.tsx
@@ -2363,6 +2377,7 @@ function ShortcutPanel() {
2363
2377
  const updateShortcuts = useCallback(() => {
2364
2378
  const shortcutGroups = /* @__PURE__ */ new Map();
2365
2379
  const shortcuts = shortcutService.getAllShortcuts().filter((item) => !!item.group);
2380
+ const groupTitles = /* @__PURE__ */ new Map();
2366
2381
  for (const shortcut of shortcuts) {
2367
2382
  var _shortcut$description;
2368
2383
  const group = shortcut.group;
@@ -2370,16 +2385,18 @@ function ShortcutPanel() {
2370
2385
  title: localeService.t((_shortcut$description = shortcut.description) !== null && _shortcut$description !== void 0 ? _shortcut$description : shortcut.id),
2371
2386
  shortcut: shortcutService.getShortcutDisplay(shortcut)
2372
2387
  };
2373
- if (!/\d+_[a-zA-Z0-9]/.test(group)) throw new Error(`[ShortcutPanel]: Invalid shortcut group: ${group}!`);
2388
+ if (!/^\d+_/.test(group)) throw new Error(`[ShortcutPanel]: Invalid shortcut group: ${group}!`);
2389
+ if (!shortcut.groupTitle) throw new Error(`[ShortcutPanel]: Shortcut group "${group}" must provide a groupTitle!`);
2390
+ if (!groupTitles.has(group)) groupTitles.set(group, shortcut.groupTitle);
2374
2391
  if (!shortcutGroups.has(group)) shortcutGroups.set(group, []);
2375
2392
  shortcutGroups.get(group).push(shortcutItem);
2376
2393
  }
2377
2394
  setShortcutItems(Array.from(shortcutGroups.entries()).map(([name, items]) => {
2378
2395
  const groupSequence = name.split("_")[0];
2379
- const groupName = name.slice(groupSequence.length + 1);
2396
+ const localeKey = groupTitles.get(name);
2380
2397
  return {
2381
2398
  sequence: +groupSequence,
2382
- name: localeService.t(groupName),
2399
+ name: localeService.t(localeKey),
2383
2400
  items: dedupeBy(items, (item) => item.title + item.shortcut)
2384
2401
  };
2385
2402
  }).sort((a, b) => a.sequence - b.sequence));
@@ -2416,8 +2433,9 @@ function ShortcutPanel() {
2416
2433
  const ToggleShortcutPanelShortcut = {
2417
2434
  id: ToggleShortcutPanelOperation.id,
2418
2435
  binding: 4096 | 220,
2419
- description: "shortcut.shortcut-panel",
2420
- group: "10_global-shortcut"
2436
+ description: "ui.shortcut.shortcut-panel",
2437
+ group: "10_global-shortcut",
2438
+ groupTitle: "ui.global-shortcut"
2421
2439
  };
2422
2440
  let ShortcutPanelController = class ShortcutPanelController extends Disposable {
2423
2441
  constructor(injector, componentManager, shortcutService, _menuManagerService, commandService) {
@@ -2468,7 +2486,7 @@ function UndoMenuItemFactory(accessor) {
2468
2486
  type: 0,
2469
2487
  icon: "UndoIcon",
2470
2488
  title: "Undo",
2471
- tooltip: "toolbar.undo",
2489
+ tooltip: "ui.shortcut.undo",
2472
2490
  disabled$: undoRedoDisableFactory$(accessor, true)
2473
2491
  };
2474
2492
  }
@@ -2478,7 +2496,7 @@ function RedoMenuItemFactory(accessor) {
2478
2496
  type: 0,
2479
2497
  icon: "RedoIcon",
2480
2498
  title: "Redo",
2481
- tooltip: "toolbar.redo",
2499
+ tooltip: "ui.shortcut.redo",
2482
2500
  disabled$: undoRedoDisableFactory$(accessor, false)
2483
2501
  };
2484
2502
  }
@@ -2488,8 +2506,8 @@ function RedoMenuItemFactory(accessor) {
2488
2506
  function ShortcutPanelMenuItemFactory() {
2489
2507
  return {
2490
2508
  id: ToggleShortcutPanelOperation.id,
2491
- title: "toggle-shortcut-panel",
2492
- tooltip: "toggle-shortcut-panel",
2509
+ title: "ui.toggle-shortcut-panel",
2510
+ tooltip: "ui.toggle-shortcut-panel",
2493
2511
  icon: "ShortcutIcon",
2494
2512
  type: 0
2495
2513
  };
@@ -3039,6 +3057,7 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
3039
3057
  _defineProperty(this, "_visibleContextualTabs", /* @__PURE__ */ new Set());
3040
3058
  _defineProperty(this, "_contextualTabs", /* @__PURE__ */ new Set());
3041
3059
  _defineProperty(this, "_lastNonContextualActivatedTab", "ribbon.start");
3060
+ _defineProperty(this, "_hiddenSubscription", null);
3042
3061
  this._initRibbonSubscription();
3043
3062
  }
3044
3063
  setActivatedTab(tab) {
@@ -3071,6 +3090,7 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
3071
3090
  }));
3072
3091
  }
3073
3092
  _updateRibbon() {
3093
+ var _this$_hiddenSubscrip;
3074
3094
  const ribbon = this._filterContextualTabs(this._menuManagerService.getMenuByPositionKey("ribbon"));
3075
3095
  const hiddenObservableMap = [];
3076
3096
  const hiddenKeyMap = [];
@@ -3087,7 +3107,8 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
3087
3107
  this._setRibbon(ribbon);
3088
3108
  return;
3089
3109
  }
3090
- combineLatest(hiddenObservableMap).pipe(startWith$1(new Array(hiddenObservableMap.length).fill(false))).subscribe((hiddenMap) => {
3110
+ (_this$_hiddenSubscrip = this._hiddenSubscription) === null || _this$_hiddenSubscrip === void 0 || _this$_hiddenSubscrip.unsubscribe();
3111
+ this._hiddenSubscription = combineLatest(hiddenObservableMap).pipe(startWith$1(new Array(hiddenObservableMap.length).fill(false))).subscribe((hiddenMap) => {
3091
3112
  const newRibbon = [];
3092
3113
  const hiddenPathMap = hiddenMap.map((hidden, index) => {
3093
3114
  if (hidden) return hiddenKeyMap[index];
@@ -3128,7 +3149,7 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
3128
3149
  })) newRibbon.push(newGroup);
3129
3150
  }
3130
3151
  this._setRibbon(newRibbon);
3131
- }).unsubscribe();
3152
+ });
3132
3153
  }
3133
3154
  _filterContextualTabs(ribbon) {
3134
3155
  this._contextualTabs.clear();
@@ -3144,12 +3165,27 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
3144
3165
  var _ref, _ribbon$find;
3145
3166
  const fallbackTab = (_ref = (_ribbon$find = ribbon.find((group) => group.key === this._lastNonContextualActivatedTab && !group.contextual)) !== null && _ribbon$find !== void 0 ? _ribbon$find : ribbon.find((group) => group.key === "ribbon.start")) !== null && _ref !== void 0 ? _ref : ribbon[0];
3146
3167
  if (fallbackTab) this._activatedTab$.next(fallbackTab.key);
3168
+ } else if (!activeGroup && ribbon.some((group) => group.key === "ribbon.start")) {
3169
+ const fallbackTab = ribbon.find((group) => group.key === "ribbon.start");
3170
+ this._activatedTab$.next(fallbackTab.key);
3171
+ if (!fallbackTab.contextual) this._lastNonContextualActivatedTab = fallbackTab.key;
3147
3172
  } else if (activeGroup && !activeGroup.contextual) this._lastNonContextualActivatedTab = activeGroup.key;
3148
3173
  this._ribbon$.next(ribbon);
3149
3174
  }
3150
3175
  _isContextualTab(tab) {
3151
3176
  return this._contextualTabs.has(tab) || this._ribbon$.getValue().some((group) => group.key === tab && group.contextual);
3152
3177
  }
3178
+ dispose() {
3179
+ var _this$_hiddenSubscrip2;
3180
+ (_this$_hiddenSubscrip2 = this._hiddenSubscription) === null || _this$_hiddenSubscrip2 === void 0 || _this$_hiddenSubscrip2.unsubscribe();
3181
+ this._hiddenSubscription = null;
3182
+ this._ribbon$.next([]);
3183
+ this._ribbon$.complete();
3184
+ this._activatedTab$.complete();
3185
+ this._collapsedIds$.complete();
3186
+ this._fakeToolbarVisible$.complete();
3187
+ super.dispose();
3188
+ }
3153
3189
  };
3154
3190
  DesktopRibbonService = __decorate([__decorateParam(0, IMenuManagerService), __decorateParam(1, IUniverInstanceService)], DesktopRibbonService);
3155
3191
 
@@ -3192,14 +3228,14 @@ function ClassicMenu({ ribbon, activatedTab, onSelectTab }) {
3192
3228
  return /* @__PURE__ */ jsx("div", {
3193
3229
  className: "univer-flex univer-size-full univer-items-center univer-justify-center univer-gap-1 univer-overflow-x-auto univer-rounded-md univer-bg-gray-50 univer-px-3 dark:!univer-bg-gray-900",
3194
3230
  role: "tablist",
3195
- "aria-label": localeService.t("ribbon.menu"),
3231
+ "aria-label": localeService.t("ui.ribbon.menu"),
3196
3232
  children: ribbon.map((group) => {
3197
3233
  const isActive = activatedTab === group.key;
3198
3234
  return /* @__PURE__ */ jsx("button", {
3199
3235
  type: "button",
3200
3236
  role: "tab",
3201
3237
  "aria-selected": isActive,
3202
- title: localeService.t(group.key),
3238
+ title: localeService.t(group.title || group.key),
3203
3239
  onClick: () => onSelectTab(group),
3204
3240
  className: clsx("univer-focus:outline-none univer-focus:ring-2 univer-focus:ring-primary-500 dark:!univer-focus:ring-primary-300 univer-flex univer-cursor-pointer univer-appearance-none univer-items-center univer-gap-1 univer-rounded-sm univer-border-none univer-px-2 univer-py-1 univer-text-sm univer-transition-colors", isActive ? `
3205
3241
  univer-bg-primary-50 univer-font-semibold univer-text-primary-600 univer-shadow-sm
@@ -3210,7 +3246,7 @@ function ClassicMenu({ ribbon, activatedTab, onSelectTab }) {
3210
3246
  univer-bg-transparent univer-text-gray-700
3211
3247
  dark:!univer-text-gray-200
3212
3248
  `),
3213
- children: localeService.t(group.key)
3249
+ children: localeService.t(group.title || group.key)
3214
3250
  }, group.key);
3215
3251
  })
3216
3252
  });
@@ -3227,7 +3263,9 @@ const iconMap = {
3227
3263
  ["ribbon.others"]: MoreFunctionIcon
3228
3264
  };
3229
3265
  function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
3266
+ var _ribbon$find;
3230
3267
  const localeService = useDependency(LocaleService);
3268
+ const activatedTabTitle = ((_ribbon$find = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find === void 0 ? void 0 : _ribbon$find.title) || activatedTab;
3231
3269
  const [groupSelectorVisible, setGroupSelectorVisible] = useState(false);
3232
3270
  function handleSelectTab(tab) {
3233
3271
  onSelectTab(tab);
@@ -3254,10 +3292,10 @@ function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
3254
3292
  className: "univer-flex univer-flex-col",
3255
3293
  children: [/* @__PURE__ */ jsx("strong", {
3256
3294
  className: "univer-text-sm univer-font-semibold univer-text-gray-800 dark:!univer-text-gray-200",
3257
- children: localeService.t(group.key)
3295
+ children: localeService.t(group.title || group.key)
3258
3296
  }), /* @__PURE__ */ jsx("span", {
3259
3297
  className: "univer-text-xs univer-text-gray-400",
3260
- children: localeService.t(`${group.key}Desc`)
3298
+ children: localeService.t(`${group.title || group.key}Desc`)
3261
3299
  })]
3262
3300
  })]
3263
3301
  }, group.key);
@@ -3267,7 +3305,7 @@ function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
3267
3305
  children: /* @__PURE__ */ jsxs("a", {
3268
3306
  className: "univer-mr-2 univer-flex univer-h-7 univer-cursor-pointer univer-items-center univer-gap-1.5 univer-whitespace-nowrap !univer-rounded-full univer-bg-gray-700 univer-pl-3 univer-pr-2 univer-text-sm univer-text-white dark:!univer-bg-gray-200 dark:!univer-text-gray-800",
3269
3307
  onClick: () => setGroupSelectorVisible(true),
3270
- children: [localeService.t(activatedTab), /* @__PURE__ */ jsx(MoreDownIcon, { className: "univer-text-gray-200 dark:!univer-text-gray-500" })]
3308
+ children: [localeService.t(activatedTabTitle), /* @__PURE__ */ jsx(MoreDownIcon, { className: "univer-text-gray-200 dark:!univer-text-gray-500" })]
3271
3309
  })
3272
3310
  });
3273
3311
  }
@@ -3358,8 +3396,13 @@ function useToolbarItemStatus(menuItem) {
3358
3396
  disabled$ && subscriptions.push(disabled$.subscribe((disabled) => setDisabled(disabled)));
3359
3397
  hidden$ && subscriptions.push(hidden$.subscribe((hidden) => setHidden(hidden)));
3360
3398
  activated$ && subscriptions.push(activated$.subscribe((activated) => setActivated(activated)));
3361
- value$ && subscriptions.push(value$.subscribe((value) => setValue(value)));
3362
- selectionsValue$ && subscriptions.push(selectionsValue$.subscribe((value) => setSelectionsValue(value)));
3399
+ value$ && subscriptions.push(value$.subscribe((value) => {
3400
+ setValue(value);
3401
+ }));
3402
+ selectionsValue$ && subscriptions.push(selectionsValue$.subscribe((value) => {
3403
+ setSelectionsValue(value);
3404
+ setValue(value);
3405
+ }));
3363
3406
  return () => subscriptions.forEach((subscription) => subscription.unsubscribe());
3364
3407
  }, [
3365
3408
  activated$,
@@ -3489,6 +3532,10 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
3489
3532
  function handleVisibleChange(visible) {
3490
3533
  setDropdownVisible(visible);
3491
3534
  }
3535
+ function handleOptionSelect(option) {
3536
+ onOptionSelect(option);
3537
+ setDropdownVisible(false);
3538
+ }
3492
3539
  useEffect(() => {
3493
3540
  const subscriptions = [];
3494
3541
  menuItems.forEach((item) => {
@@ -3527,7 +3574,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
3527
3574
  overlay: options.map((option, index) => /* @__PURE__ */ jsx(Label, {
3528
3575
  value,
3529
3576
  option,
3530
- onOptionSelect
3577
+ onOptionSelect: handleOptionSelect
3531
3578
  }, index)),
3532
3579
  children
3533
3580
  });
@@ -3541,15 +3588,16 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
3541
3588
  icon: option.icon,
3542
3589
  value,
3543
3590
  option,
3544
- onOptionSelect
3591
+ onOptionSelect: handleOptionSelect
3545
3592
  }),
3546
3593
  disabled: option.disabled,
3547
3594
  onSelect: () => {
3548
3595
  if (typeof option.value === "undefined") return;
3549
- onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({ ...option });
3596
+ handleOptionSelect({ ...option });
3550
3597
  }
3551
3598
  };
3552
3599
  });
3600
+ if (filteredMenuItems.length) items.push({ type: "separator" });
3553
3601
  for (const menuItem of filteredMenuItems) {
3554
3602
  if (!menuItem.item) continue;
3555
3603
  const { title, id, commandId, icon } = menuItem.item;
@@ -3565,7 +3613,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
3565
3613
  } }
3566
3614
  }),
3567
3615
  onSelect: () => {
3568
- onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
3616
+ handleOptionSelect({
3569
3617
  commandId,
3570
3618
  id
3571
3619
  });
@@ -3598,7 +3646,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
3598
3646
  } }
3599
3647
  }),
3600
3648
  onSelect: () => {
3601
- onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
3649
+ handleOptionSelect({
3602
3650
  commandId,
3603
3651
  id
3604
3652
  });
@@ -3624,7 +3672,7 @@ const ToolbarItem = forwardRef((props, ref) => {
3624
3672
  const commandService = useDependency(ICommandService);
3625
3673
  const layoutService = useDependency(ILayoutService);
3626
3674
  const componentManager = useDependency(ComponentManager);
3627
- const { value, hidden, disabled, activated, selectionsValue } = useToolbarItemStatus(props);
3675
+ const { value, hidden, disabled, activated } = useToolbarItemStatus(props);
3628
3676
  const executeCommand = (commandId, params) => {
3629
3677
  layoutService.focus();
3630
3678
  commandService.executeCommand(commandId, params);
@@ -3685,7 +3733,7 @@ const ToolbarItem = forwardRef((props, ref) => {
3685
3733
  children: /* @__PURE__ */ jsx(CustomLabel, {
3686
3734
  icon: iconToDisplay,
3687
3735
  title,
3688
- value: selectionsValue !== null && selectionsValue !== void 0 ? selectionsValue : value,
3736
+ value,
3689
3737
  label,
3690
3738
  onChange: handleSelectionsValueChange
3691
3739
  })
@@ -3804,13 +3852,17 @@ function Ribbon(props) {
3804
3852
  }
3805
3853
  return ribbonData;
3806
3854
  }, [ribbonType, ribbonData]);
3855
+ const activatedTabTitle = useMemo(() => {
3856
+ var _ribbon$find;
3857
+ return ((_ribbon$find = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find === void 0 ? void 0 : _ribbon$find.title) || activatedTab;
3858
+ }, [ribbon, activatedTab]);
3807
3859
  const handleSelectTab = useCallback((group) => {
3808
3860
  toolbarItemRefs.current = {};
3809
3861
  ribbonService.setActivatedTab(group.key);
3810
3862
  }, []);
3811
3863
  const activeGroup = useMemo(() => {
3812
- var _ribbon$find$children, _ribbon$find;
3813
- const allGroups = (_ribbon$find$children = (_ribbon$find = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find === void 0 ? void 0 : _ribbon$find.children) !== null && _ribbon$find$children !== void 0 ? _ribbon$find$children : [];
3864
+ var _ribbon$find$children, _ribbon$find2;
3865
+ const allGroups = (_ribbon$find$children = (_ribbon$find2 = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find2 === void 0 ? void 0 : _ribbon$find2.children) !== null && _ribbon$find$children !== void 0 ? _ribbon$find$children : [];
3814
3866
  const visibleGroups = [];
3815
3867
  const hiddenGroups = [];
3816
3868
  for (const item of allGroups) if (item.children) {
@@ -3840,14 +3892,14 @@ function Ribbon(props) {
3840
3892
  for (const entry of entries) {
3841
3893
  ribbonService.setFakeToolbarVisible(true);
3842
3894
  timer = requestAnimationFrame(() => {
3843
- var _ribbon$find$children2, _ribbon$find2;
3895
+ var _ribbon$find$children2, _ribbon$find3;
3844
3896
  const { width: avaliableWidth } = entry.contentRect;
3845
3897
  const sortedToolbarItems = Object.values(toolbarItemRefs.current).sort((a, b) => {
3846
3898
  return a.order - b.order || a.groupOrder - b.groupOrder || a.itemOrder - b.itemOrder;
3847
3899
  });
3848
3900
  const newCollapsedIds = [];
3849
3901
  let totalWidth = 32;
3850
- const gapWidth = (((_ribbon$find$children2 = (_ribbon$find2 = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find2 === void 0 ? void 0 : _ribbon$find2.children) !== null && _ribbon$find$children2 !== void 0 ? _ribbon$find$children2 : []).length - 1) * 8;
3902
+ const gapWidth = (((_ribbon$find$children2 = (_ribbon$find3 = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find3 === void 0 ? void 0 : _ribbon$find3.children) !== null && _ribbon$find$children2 !== void 0 ? _ribbon$find$children2 : []).length - 1) * 8;
3851
3903
  totalWidth += gapWidth;
3852
3904
  for (const { el, key } of sortedToolbarItems) {
3853
3905
  const { width } = el.getBoundingClientRect();
@@ -3872,7 +3924,7 @@ function Ribbon(props) {
3872
3924
  children: activeGroup.allGroups.map((groupItem, index) => {
3873
3925
  var _groupItem$children, _groupItem$children2;
3874
3926
  return (((_groupItem$children = groupItem.children) === null || _groupItem$children === void 0 ? void 0 : _groupItem$children.length) || groupItem.item) && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", {
3875
- className: "univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2",
3927
+ className: "\n univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2\n empty:univer-hidden\n ",
3876
3928
  children: groupItem.children && ((_groupItem$children2 = groupItem.children) === null || _groupItem$children2 === void 0 ? void 0 : _groupItem$children2.map((child) => child.item && /* @__PURE__ */ jsx(ToolbarItem, {
3877
3929
  ...child.item,
3878
3930
  ref: (ref) => {
@@ -3893,7 +3945,7 @@ function Ribbon(props) {
3893
3945
  /* @__PURE__ */ jsxs("div", {
3894
3946
  "data-u-comp": "ribbon-header-menu",
3895
3947
  className: clsx("univer-relative univer-select-none", { "univer-h-9": ribbonType === "classic" || headerMenuComponents && headerMenuComponents.size > 0 }),
3896
- children: [ribbonType === "classic" && ribbon.length > 1 && /* @__PURE__ */ jsx(ClassicMenu, {
3948
+ children: [ribbonType === "classic" && ribbon.length >= 1 && /* @__PURE__ */ jsx(ClassicMenu, {
3897
3949
  ribbon,
3898
3950
  activatedTab,
3899
3951
  onSelectTab: handleSelectTab
@@ -3904,11 +3956,10 @@ function Ribbon(props) {
3904
3956
  }),
3905
3957
  /* @__PURE__ */ jsxs("div", {
3906
3958
  className: clsx("univer-box-border univer-grid univer-h-10 univer-grid-flow-col univer-items-center univer-px-3 univer-text-sm", {
3907
- "univer-grid-cols-[1fr] univer-justify-center": ribbonType === "classic",
3908
- "univer-grid-cols-[auto,1fr]": ribbon.length > 1 && ribbonType !== "classic",
3909
- "univer-grid-cols-none": ribbon.length === 1
3959
+ "univer-grid-cols-[1fr] univer-justify-center": ribbonType === "classic" || ribbon.length === 1,
3960
+ "univer-grid-cols-[auto,1fr]": ribbon.length > 1 && ribbonType !== "classic"
3910
3961
  }, borderBottomClassName),
3911
- children: [ribbonType === "collapsed" && ribbon.length > 1 && /* @__PURE__ */ jsx(DefaultMenu, {
3962
+ children: [ribbonType === "collapsed" && ribbon.length >= 1 && /* @__PURE__ */ jsx(DefaultMenu, {
3912
3963
  ribbon,
3913
3964
  activatedTab,
3914
3965
  onSelectTab: handleSelectTab
@@ -3917,11 +3968,11 @@ function Ribbon(props) {
3917
3968
  ref: containerRef,
3918
3969
  className: clsx("univer-flex univer-overflow-hidden", divideXClassName, { "univer-justify-center": ribbonType === "classic" }),
3919
3970
  role: "toolbar",
3920
- "aria-label": localeService.t(activatedTab),
3971
+ "aria-label": localeService.t(activatedTabTitle),
3921
3972
  children: [activeGroup.visibleGroups.map((groupItem) => {
3922
3973
  var _groupItem$children3, _groupItem$children4;
3923
3974
  return (((_groupItem$children3 = groupItem.children) === null || _groupItem$children3 === void 0 ? void 0 : _groupItem$children3.length) || groupItem.item) && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", {
3924
- className: "univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2",
3975
+ className: "\n univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2\n empty:univer-hidden\n ",
3925
3976
  children: groupItem.children && ((_groupItem$children4 = groupItem.children) === null || _groupItem$children4 === void 0 ? void 0 : _groupItem$children4.map((child) => child.item && /* @__PURE__ */ jsx(ToolbarItem, { ...child.item }, child.key)))
3926
3977
  }) }, groupItem.key);
3927
3978
  }), collapsedIds.length > 0 && /* @__PURE__ */ jsx("div", {
@@ -3949,7 +4000,7 @@ function Ribbon(props) {
3949
4000
  children: /* @__PURE__ */ jsx("button", {
3950
4001
  type: "button",
3951
4002
  className: toolbarButtonClassName,
3952
- "aria-label": localeService.t("ribbon.more"),
4003
+ "aria-label": localeService.t("ui.ribbon.more"),
3953
4004
  "aria-haspopup": "true",
3954
4005
  children: /* @__PURE__ */ jsx(MoreFunctionIcon, {})
3955
4006
  })
@@ -4074,7 +4125,7 @@ function DesignTinyMenuGroup({ items }) {
4074
4125
  const ele = /* @__PURE__ */ jsx("div", {
4075
4126
  className: clsx("univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-md hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-900", { "univer-bg-gray-50 dark:!univer-bg-gray-900": item.active }, item.className),
4076
4127
  onClick: () => item.onClick(),
4077
- children: /* @__PURE__ */ jsx(item.Icon, { className: "univer-size-4 univer-text-gray-900 dark:!univer-text-gray-200" })
4128
+ children: /* @__PURE__ */ jsx(item.Icon, { className: clsx("univer-size-4 univer-text-gray-900 dark:!univer-text-gray-200", item.iconClassName) })
4078
4129
  }, item.key);
4079
4130
  return item.tooltip ? /* @__PURE__ */ jsx(Tooltip, {
4080
4131
  title: item.tooltip,
@@ -4086,8 +4137,21 @@ function DesignTinyMenuGroup({ items }) {
4086
4137
 
4087
4138
  //#endregion
4088
4139
  //#region src/components/menu/desktop/TinyMenuGroup.tsx
4140
+ const EMPTY_HIDDEN_ITEM_IDS = [];
4141
+ function resolveMenuItemActiveState(itemId, observableActive, activeItemIds) {
4142
+ if (activeItemIds) return Boolean(itemId && activeItemIds.includes(itemId));
4143
+ return observableActive;
4144
+ }
4145
+ function getTinyMenuChildStateKey(child) {
4146
+ var _child$item$id, _child$item;
4147
+ return (_child$item$id = (_child$item = child.item) === null || _child$item === void 0 ? void 0 : _child$item.id) !== null && _child$item$id !== void 0 ? _child$item$id : child.key;
4148
+ }
4149
+ function getVisibleTinyMenuChildren(children, hiddenItemKeys) {
4150
+ const hiddenSet = new Set(hiddenItemKeys);
4151
+ return children.filter((child) => !hiddenSet.has(getTinyMenuChildStateKey(child)));
4152
+ }
4089
4153
  function QuickTileMenuItem(props) {
4090
- const { menuSchema, onOptionSelect } = props;
4154
+ const { menuSchema, activeItemIds, onOptionSelect } = props;
4091
4155
  const componentManager = useDependency(ComponentManager);
4092
4156
  const localeService = useDependency(LocaleService);
4093
4157
  const menuItem = menuSchema.item;
@@ -4102,7 +4166,7 @@ function QuickTileMenuItem(props) {
4102
4166
  univer-cursor-pointer
4103
4167
  hover:univer-bg-gray-50
4104
4168
  dark:hover:!univer-bg-gray-600
4105
- `, activated && `
4169
+ `, resolveMenuItemActiveState(menuItem.id, activated, activeItemIds) && `
4106
4170
  univer-bg-primary-50 univer-text-primary-700 univer-ring-1 univer-ring-primary-600
4107
4171
  dark:!univer-bg-primary-900 dark:!univer-text-primary-100
4108
4172
  `),
@@ -4127,20 +4191,21 @@ function QuickTileMenuItem(props) {
4127
4191
  });
4128
4192
  }
4129
4193
  function UITinyMenuGroup(props) {
4130
- const { item, onOptionSelect } = props;
4194
+ const { item, activeItemIds, hiddenItemIds = EMPTY_HIDDEN_ITEM_IDS, onOptionSelect } = props;
4131
4195
  const [activeItems, setActiveItems] = useState([]);
4196
+ const [hiddenItems, setHiddenItems] = useState([]);
4132
4197
  const componentManager = useDependency(ComponentManager);
4133
4198
  const localeService = useDependency(LocaleService);
4134
4199
  useEffect(() => {
4135
4200
  if (!item.children) return;
4136
4201
  const observables = item.children.map((child) => {
4137
- var _child$item$activated, _child$item;
4138
- return convertObservableToBehaviorSubject((_child$item$activated = (_child$item = child.item) === null || _child$item === void 0 ? void 0 : _child$item.activated$) !== null && _child$item$activated !== void 0 ? _child$item$activated : of(false), false);
4202
+ var _child$item$activated, _child$item2;
4203
+ return convertObservableToBehaviorSubject((_child$item$activated = (_child$item2 = child.item) === null || _child$item2 === void 0 ? void 0 : _child$item2.activated$) !== null && _child$item$activated !== void 0 ? _child$item$activated : of(false), false);
4139
4204
  });
4140
4205
  const subscription = combineLatest(observables).subscribe((activedArr) => {
4141
4206
  const actived = activedArr.map((actived, index) => ({
4142
4207
  actived,
4143
- item: item.children[index].item.id
4208
+ item: getTinyMenuChildStateKey(item.children[index])
4144
4209
  })).filter((actived) => actived.actived);
4145
4210
  if (actived.length === 0) setActiveItems([]);
4146
4211
  else setActiveItems(actived.map((actived) => actived.item));
@@ -4152,34 +4217,65 @@ function UITinyMenuGroup(props) {
4152
4217
  });
4153
4218
  };
4154
4219
  }, [item]);
4220
+ useEffect(() => {
4221
+ if (!item.children) return;
4222
+ const observables = item.children.map((child) => {
4223
+ var _child$item$hidden$, _child$item3;
4224
+ return convertObservableToBehaviorSubject((_child$item$hidden$ = (_child$item3 = child.item) === null || _child$item3 === void 0 ? void 0 : _child$item3.hidden$) !== null && _child$item$hidden$ !== void 0 ? _child$item$hidden$ : of(false), false);
4225
+ });
4226
+ const subscription = combineLatest(observables).subscribe((hiddenArr) => {
4227
+ const hidden = hiddenArr.map((hidden, index) => ({
4228
+ hidden,
4229
+ item: getTinyMenuChildStateKey(item.children[index])
4230
+ })).filter((hidden) => hidden.hidden);
4231
+ if (hidden.length === 0) setHiddenItems([]);
4232
+ else setHiddenItems(hidden.map((hidden) => hidden.item));
4233
+ });
4234
+ return () => {
4235
+ subscription.unsubscribe();
4236
+ observables.forEach((observable) => {
4237
+ observable.complete();
4238
+ });
4239
+ };
4240
+ }, [item]);
4241
+ const visibleChildren = useMemo(() => {
4242
+ var _item$children;
4243
+ return getVisibleTinyMenuChildren((_item$children = item.children) !== null && _item$children !== void 0 ? _item$children : [], [...hiddenItems, ...hiddenItemIds]);
4244
+ }, [
4245
+ hiddenItemIds,
4246
+ hiddenItems,
4247
+ item.children
4248
+ ]);
4155
4249
  if (!item.children) return null;
4156
- return /* @__PURE__ */ jsx(DesignTinyMenuGroup, { items: item.children.map((child) => {
4157
- var _child$item$id2, _child$item7;
4250
+ return /* @__PURE__ */ jsx(DesignTinyMenuGroup, { items: visibleChildren.map((child) => {
4251
+ var _child$item9, _child$item10, _child$item$id3, _child$item11;
4158
4252
  return {
4159
4253
  key: child.key,
4160
4254
  onClick: () => {
4161
- var _child$item$id, _child$item2, _child$item3, _child$item4, _child$item5, _child$item6;
4255
+ var _child$item$id2, _child$item4, _child$item5, _child$item6, _child$item7, _child$item8;
4162
4256
  onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
4163
- label: (_child$item$id = (_child$item2 = child.item) === null || _child$item2 === void 0 ? void 0 : _child$item2.id) !== null && _child$item$id !== void 0 ? _child$item$id : child.key,
4164
- commandId: (_child$item3 = child.item) === null || _child$item3 === void 0 ? void 0 : _child$item3.commandId,
4165
- id: (_child$item4 = child.item) === null || _child$item4 === void 0 ? void 0 : _child$item4.id,
4166
- tooltip: ((_child$item5 = child.item) === null || _child$item5 === void 0 ? void 0 : _child$item5.tooltip) && localeService.t((_child$item6 = child.item) === null || _child$item6 === void 0 ? void 0 : _child$item6.tooltip)
4257
+ label: (_child$item$id2 = (_child$item4 = child.item) === null || _child$item4 === void 0 ? void 0 : _child$item4.id) !== null && _child$item$id2 !== void 0 ? _child$item$id2 : child.key,
4258
+ commandId: (_child$item5 = child.item) === null || _child$item5 === void 0 ? void 0 : _child$item5.commandId,
4259
+ id: (_child$item6 = child.item) === null || _child$item6 === void 0 ? void 0 : _child$item6.id,
4260
+ tooltip: ((_child$item7 = child.item) === null || _child$item7 === void 0 ? void 0 : _child$item7.tooltip) && localeService.t((_child$item8 = child.item) === null || _child$item8 === void 0 ? void 0 : _child$item8.tooltip)
4167
4261
  });
4168
4262
  },
4169
4263
  className: "",
4264
+ iconClassName: ((_child$item9 = child.item) === null || _child$item9 === void 0 ? void 0 : _child$item9.icon) === "TextTypeIcon" ? "!univer-size-3.5" : void 0,
4170
4265
  Icon: componentManager.get(child.item.icon),
4171
- active: activeItems.includes((_child$item$id2 = (_child$item7 = child.item) === null || _child$item7 === void 0 ? void 0 : _child$item7.id) !== null && _child$item$id2 !== void 0 ? _child$item$id2 : "")
4266
+ active: resolveMenuItemActiveState((_child$item10 = child.item) === null || _child$item10 === void 0 ? void 0 : _child$item10.id, activeItems.includes((_child$item$id3 = (_child$item11 = child.item) === null || _child$item11 === void 0 ? void 0 : _child$item11.id) !== null && _child$item$id3 !== void 0 ? _child$item$id3 : ""), activeItemIds)
4172
4267
  };
4173
4268
  }) });
4174
4269
  }
4175
4270
  function UIQuickTileMenuGroup(props) {
4176
- var _item$children;
4177
- const { item, onOptionSelect } = props;
4178
- if (!((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length)) return null;
4271
+ var _item$children2;
4272
+ const { item, activeItemIds, hiddenItemIds = EMPTY_HIDDEN_ITEM_IDS, onOptionSelect } = props;
4273
+ if (!((_item$children2 = item.children) === null || _item$children2 === void 0 ? void 0 : _item$children2.length)) return null;
4179
4274
  return /* @__PURE__ */ jsx("div", {
4180
4275
  className: "univer-item-center univer-grid univer-grid-cols-3 univer-gap-1.5 univer-py-1",
4181
- children: item.children.map((menuSchema) => /* @__PURE__ */ jsx(QuickTileMenuItem, {
4276
+ children: getVisibleTinyMenuChildren(item.children, hiddenItemIds).map((menuSchema) => /* @__PURE__ */ jsx(QuickTileMenuItem, {
4182
4277
  menuSchema,
4278
+ activeItemIds,
4183
4279
  onOptionSelect
4184
4280
  }, menuSchema.key))
4185
4281
  });
@@ -4191,6 +4287,7 @@ const contentClassName = "univer-inline-flex univer-items-center univer-gap-2";
4191
4287
  const menuViewportPadding = 8;
4192
4288
  const submenuOverlapOffset = 2;
4193
4289
  const submenuVisualGap = 20;
4290
+ const CONTEXT_MENU_SUBMENU_CLOSE_DELAY = 500;
4194
4291
  const CONTEXT_MENU_SUBMENU_PORTAL_ATTR = "data-u-context-menu-submenu";
4195
4292
  function isNonSelectableLabel(label) {
4196
4293
  return typeof label === "object" && (label === null || label === void 0 ? void 0 : label.selectable) === false;
@@ -4198,9 +4295,15 @@ function isNonSelectableLabel(label) {
4198
4295
  function isNonHoverableLabel(label) {
4199
4296
  return typeof label === "object" && (label === null || label === void 0 ? void 0 : label.hoverable) === false;
4200
4297
  }
4298
+ function hasRenderableContextMenuSchema(menuSchema) {
4299
+ var _menuSchema$children;
4300
+ if (menuSchema.item) return true;
4301
+ if (!((_menuSchema$children = menuSchema.children) === null || _menuSchema$children === void 0 ? void 0 : _menuSchema$children.length)) return false;
4302
+ return menuSchema.children.some((childSchema) => Boolean(childSchema.item));
4303
+ }
4201
4304
  function ContextMenuPanel(props) {
4202
4305
  var _layoutService$rootCo, _layoutService$rootCo2;
4203
- const { menuType, menuSessionVersion = 0, className, onOptionSelect } = props;
4306
+ const { menuType, menuSessionVersion = 0, className, activeItemIds, hiddenItemIds, onOptionSelect } = props;
4204
4307
  const menuManagerService = useDependency(IMenuManagerService);
4205
4308
  const layoutService = useDependency(ILayoutService);
4206
4309
  const [menuElement, setMenuElement] = useState(null);
@@ -4244,23 +4347,26 @@ function ContextMenuPanel(props) {
4244
4347
  menuSchemas: menuItems,
4245
4348
  menuSessionVersion,
4246
4349
  submenuPortalContainer,
4350
+ activeItemIds,
4351
+ hiddenItemIds,
4247
4352
  onOptionSelect,
4248
4353
  maxMenuHeight
4249
4354
  })
4250
4355
  });
4251
4356
  }
4252
4357
  function ContextMenuMenu(props) {
4253
- const { menuSchemas, menuSessionVersion, submenuPortalContainer, onOptionSelect, maxMenuHeight } = props;
4358
+ const { menuSchemas, menuSessionVersion, submenuPortalContainer, activeItemIds, hiddenItemIds, onOptionSelect, maxMenuHeight } = props;
4254
4359
  const localeService = useDependency(LocaleService);
4255
4360
  const hiddenGroupStates = useContextGroupHiddenStates$1(menuSchemas);
4256
4361
  const visibleSchemas = useMemo(() => {
4257
4362
  return menuSchemas.filter((item) => {
4363
+ if (!hasRenderableContextMenuSchema(item)) return false;
4258
4364
  if (!item.children) return true;
4259
4365
  return !hiddenGroupStates[item.key];
4260
4366
  });
4261
4367
  }, [hiddenGroupStates, menuSchemas]);
4262
4368
  return /* @__PURE__ */ jsx(Fragment$1, { children: visibleSchemas.map((menuSchema, index) => {
4263
- var _menuSchema$children;
4369
+ var _menuSchema$children2;
4264
4370
  const hasSeparator = index !== visibleSchemas.length - 1;
4265
4371
  if (menuSchema.item) return /* @__PURE__ */ jsx(ContextMenuMenuItem, {
4266
4372
  menuKey: menuSchema.key,
@@ -4268,19 +4374,38 @@ function ContextMenuMenu(props) {
4268
4374
  menuSessionVersion,
4269
4375
  submenuPortalContainer,
4270
4376
  onOptionSelect,
4271
- maxMenuHeight
4377
+ maxMenuHeight,
4378
+ hiddenItemIds
4272
4379
  }, menuSchema.key);
4273
- if (!((_menuSchema$children = menuSchema.children) === null || _menuSchema$children === void 0 ? void 0 : _menuSchema$children.length)) return null;
4380
+ if (!((_menuSchema$children2 = menuSchema.children) === null || _menuSchema$children2 === void 0 ? void 0 : _menuSchema$children2.length)) return null;
4274
4381
  if (menuSchema.quickLayout) return /* @__PURE__ */ jsx("div", {
4275
4382
  className: clsx("univer-py-1", hasSeparator && borderBottomClassName),
4276
4383
  children: menuSchema.quickLayout === "tile" ? /* @__PURE__ */ jsx(UIQuickTileMenuGroup, {
4277
4384
  item: menuSchema,
4385
+ activeItemIds,
4386
+ hiddenItemIds,
4278
4387
  onOptionSelect
4279
4388
  }) : /* @__PURE__ */ jsx(UITinyMenuGroup, {
4280
4389
  item: menuSchema,
4390
+ activeItemIds,
4391
+ hiddenItemIds,
4281
4392
  onOptionSelect
4282
4393
  })
4283
4394
  }, menuSchema.key);
4395
+ if (menuSchema.tiny) return /* @__PURE__ */ jsx("div", {
4396
+ className: clsx("univer-flex univer-items-center univer-gap-1 univer-py-1", hasSeparator && borderBottomClassName),
4397
+ children: menuSchema.children.map((childSchema) => childSchema.item && /* @__PURE__ */ jsx(ContextMenuMenuItem, {
4398
+ menuKey: childSchema.key,
4399
+ menuItem: childSchema.item,
4400
+ menuSessionVersion,
4401
+ submenuPortalContainer,
4402
+ activeItemIds,
4403
+ hiddenItemIds,
4404
+ onOptionSelect,
4405
+ maxMenuHeight,
4406
+ compact: true
4407
+ }, childSchema.key))
4408
+ }, menuSchema.key);
4284
4409
  return /* @__PURE__ */ jsxs("div", {
4285
4410
  className: clsx("univer-grid univer-gap-1 univer-py-1", hasSeparator && borderBottomClassName),
4286
4411
  children: [menuSchema.title && /* @__PURE__ */ jsx("strong", {
@@ -4291,6 +4416,8 @@ function ContextMenuMenu(props) {
4291
4416
  menuItem: childSchema.item,
4292
4417
  menuSessionVersion,
4293
4418
  submenuPortalContainer,
4419
+ activeItemIds,
4420
+ hiddenItemIds,
4294
4421
  onOptionSelect,
4295
4422
  maxMenuHeight
4296
4423
  }, childSchema.key))]
@@ -4298,8 +4425,9 @@ function ContextMenuMenu(props) {
4298
4425
  }) });
4299
4426
  }
4300
4427
  function ContextMenuMenuItem(props) {
4301
- const { menuKey, menuItem, menuSessionVersion, submenuPortalContainer, onOptionSelect, maxMenuHeight } = props;
4302
- const direction = useObservable(useDependency(LocaleService).direction$);
4428
+ const { menuKey, menuItem, menuSessionVersion, submenuPortalContainer, activeItemIds, hiddenItemIds = [], compact = false, onOptionSelect, maxMenuHeight } = props;
4429
+ const localeService = useDependency(LocaleService);
4430
+ const direction = useObservable(localeService.direction$);
4303
4431
  const menuManagerService = useDependency(IMenuManagerService);
4304
4432
  const disabled = useObservable(menuItem.disabled$, false);
4305
4433
  const activated = useObservable(menuItem.activated$, false);
@@ -4317,6 +4445,7 @@ function ContextMenuMenuItem(props) {
4317
4445
  const [submenuPlacement, setSubmenuPlacement] = useState("right");
4318
4446
  const menuItemElementRef = useRef(null);
4319
4447
  const submenuElementRef = useRef(null);
4448
+ const submenuCloseTimerRef = useRef(null);
4320
4449
  const selections = useMemo(() => {
4321
4450
  if (menuItem.type !== 1 && menuItem.type !== 2) return [];
4322
4451
  if (selectionsFromObservable) return selectionsFromObservable;
@@ -4338,9 +4467,23 @@ function ContextMenuMenuItem(props) {
4338
4467
  const hasSelectionSubmenu = selections.length > 0;
4339
4468
  const hasSubItemSubmenu = subMenuItems.length > 0;
4340
4469
  const hasSubmenu = hasSelectionSubmenu || hasSubItemSubmenu;
4470
+ const selectionsCommandId = selectorItem.selectionsCommandId;
4471
+ const clearSubmenuCloseTimer = useCallback(() => {
4472
+ if (submenuCloseTimerRef.current == null) return;
4473
+ clearTimeout(submenuCloseTimerRef.current);
4474
+ submenuCloseTimerRef.current = null;
4475
+ }, []);
4476
+ const scheduleSubmenuClose = useCallback(() => {
4477
+ clearSubmenuCloseTimer();
4478
+ submenuCloseTimerRef.current = setTimeout(() => {
4479
+ submenuCloseTimerRef.current = null;
4480
+ setSubmenuVisible(false);
4481
+ }, 500);
4482
+ }, [clearSubmenuCloseTimer]);
4341
4483
  useEffect(() => {
4342
4484
  setInputValue(value);
4343
4485
  }, [value]);
4486
+ useEffect(() => () => clearSubmenuCloseTimer(), [clearSubmenuCloseTimer]);
4344
4487
  useEffect(() => {
4345
4488
  if (!submenuVisible) {
4346
4489
  setSubmenuPositionReady(false);
@@ -4377,19 +4520,30 @@ function ContextMenuMenuItem(props) {
4377
4520
  hasSelectionSubmenu,
4378
4521
  hasSubItemSubmenu
4379
4522
  ]);
4380
- if (hidden) return null;
4523
+ const hiddenById = menuItem.id != null && hiddenItemIds.includes(menuItem.id) || hiddenItemIds.includes(menuKey);
4524
+ if (hidden || hiddenById) return null;
4381
4525
  const onChange = (v) => {
4382
4526
  setInputValue(isRealNum(v) && typeof v === "string" ? Number.parseInt(v) : v);
4383
4527
  };
4384
4528
  const onSubmenuOptionSelect = (option) => {
4385
4529
  onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect(option);
4530
+ clearSubmenuCloseTimer();
4386
4531
  setSubmenuVisible(false);
4387
4532
  };
4388
- const itemClassName = clsx("univer-relative univer-flex univer-min-h-8 univer-w-full univer-items-center univer-justify-between univer-gap-3 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm dark:!univer-text-white", disabled ? "univer-cursor-not-allowed univer-opacity-60" : `
4533
+ const itemClassName = clsx(compact ? `
4534
+ univer-relative univer-flex univer-size-8 univer-items-center univer-justify-center univer-rounded-md
4535
+ univer-border-none univer-bg-transparent univer-p-0 univer-text-left univer-text-sm
4536
+ dark:!univer-text-white
4537
+ ` : `
4538
+ univer-relative univer-flex univer-min-h-8 univer-w-full univer-items-center univer-justify-between
4539
+ univer-gap-3 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left
4540
+ univer-text-sm
4541
+ dark:!univer-text-white
4542
+ `, disabled ? "univer-cursor-not-allowed univer-opacity-60" : `
4389
4543
  univer-cursor-pointer
4390
4544
  hover:univer-bg-gray-50
4391
4545
  dark:hover:!univer-bg-gray-600
4392
- `, activated && `
4546
+ `, resolveMenuItemActiveState(menuItem.id, activated, activeItemIds) && `
4393
4547
  univer-bg-gray-200
4394
4548
  dark:!univer-bg-gray-600
4395
4549
  `);
@@ -4397,7 +4551,7 @@ function ContextMenuMenuItem(props) {
4397
4551
  className: contentClassName,
4398
4552
  children: [/* @__PURE__ */ jsx(CustomLabel, {
4399
4553
  value: inputValue,
4400
- title: menuItem.title,
4554
+ title: compact ? void 0 : menuItem.title,
4401
4555
  label: menuItem.label,
4402
4556
  icon: menuItem.icon,
4403
4557
  onChange
@@ -4413,6 +4567,7 @@ function ContextMenuMenuItem(props) {
4413
4567
  ref: menuItemElementRef,
4414
4568
  className: "univer-relative",
4415
4569
  onMouseEnter: () => {
4570
+ clearSubmenuCloseTimer();
4416
4571
  if (hasSubmenu && !disabled) {
4417
4572
  setSubmenuPositionReady(false);
4418
4573
  setSubmenuVisible(true);
@@ -4423,7 +4578,7 @@ function ContextMenuMenuItem(props) {
4423
4578
  var _submenuElementRef$cu;
4424
4579
  const nextTarget = event.relatedTarget;
4425
4580
  if (nextTarget && ((_submenuElementRef$cu = submenuElementRef.current) === null || _submenuElementRef$cu === void 0 ? void 0 : _submenuElementRef$cu.contains(nextTarget))) return;
4426
- setSubmenuVisible(false);
4581
+ scheduleSubmenuClose();
4427
4582
  }
4428
4583
  },
4429
4584
  children: [renderAsContainer ? /* @__PURE__ */ jsxs("div", {
@@ -4434,8 +4589,21 @@ function ContextMenuMenuItem(props) {
4434
4589
  type: "button",
4435
4590
  className: interactiveItemClassName,
4436
4591
  disabled,
4592
+ title: compact && typeof menuItem.tooltip === "string" ? localeService.t(menuItem.tooltip) : void 0,
4437
4593
  onClick: () => {
4594
+ clearSubmenuCloseTimer();
4438
4595
  if (hasSubmenu) {
4596
+ if (canExecuteItem) {
4597
+ const item = menuItem;
4598
+ onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
4599
+ commandId: item.commandId,
4600
+ params: item.params,
4601
+ value: inputValue,
4602
+ id: item.id,
4603
+ label: menuKey
4604
+ });
4605
+ return;
4606
+ }
4439
4607
  setSubmenuPositionReady(false);
4440
4608
  setSubmenuVisible(true);
4441
4609
  return;
@@ -4444,12 +4612,13 @@ function ContextMenuMenuItem(props) {
4444
4612
  const item = menuItem;
4445
4613
  onOptionSelect === null || onOptionSelect === void 0 || onOptionSelect({
4446
4614
  commandId: item.commandId,
4615
+ params: item.params,
4447
4616
  value: inputValue,
4448
4617
  id: item.id,
4449
4618
  label: menuKey
4450
4619
  });
4451
4620
  },
4452
- children: [contentNode, hasSubmenu && /* @__PURE__ */ jsx(MoreIcon, { className: "univer-size-3.5 univer-text-gray-400 dark:!univer-text-gray-200" })]
4621
+ children: [contentNode, hasSubmenu && !compact && /* @__PURE__ */ jsx(MoreIcon, { className: "univer-size-3.5 univer-text-gray-400 dark:!univer-text-gray-200" })]
4453
4622
  }), hasSubmenu && submenuVisible && (submenuPortalContainer ? createPortal(/* @__PURE__ */ jsx("div", {
4454
4623
  ref: submenuElementRef,
4455
4624
  dir: direction,
@@ -4465,11 +4634,12 @@ function ContextMenuMenuItem(props) {
4465
4634
  visibility: submenuPositionReady ? "visible" : "hidden",
4466
4635
  pointerEvents: submenuPositionReady ? "auto" : "none"
4467
4636
  },
4637
+ onMouseEnter: clearSubmenuCloseTimer,
4468
4638
  onMouseLeave: (event) => {
4469
4639
  var _menuItemElementRef$c;
4470
4640
  const nextTarget = event.relatedTarget;
4471
4641
  if (nextTarget && ((_menuItemElementRef$c = menuItemElementRef.current) === null || _menuItemElementRef$c === void 0 ? void 0 : _menuItemElementRef$c.contains(nextTarget))) return;
4472
- setSubmenuVisible(false);
4642
+ scheduleSubmenuClose();
4473
4643
  },
4474
4644
  onWheel: (event) => event.stopPropagation(),
4475
4645
  children: /* @__PURE__ */ jsxs("div", {
@@ -4498,12 +4668,13 @@ function ContextMenuMenuItem(props) {
4498
4668
  label: option.label,
4499
4669
  icon: option.icon,
4500
4670
  onChange: (optionValue) => {
4671
+ var _option$commandId;
4501
4672
  onSubmenuOptionSelect === null || onSubmenuOptionSelect === void 0 || onSubmenuOptionSelect({
4502
4673
  ...option,
4503
4674
  value: optionValue,
4504
4675
  id: menuItem.id,
4505
4676
  label: menuKey,
4506
- commandId: option.commandId
4677
+ commandId: (_option$commandId = option.commandId) !== null && _option$commandId !== void 0 ? _option$commandId : selectionsCommandId
4507
4678
  });
4508
4679
  }
4509
4680
  })
@@ -4513,11 +4684,12 @@ function ContextMenuMenuItem(props) {
4513
4684
  className: optionClassName,
4514
4685
  disabled: option.disabled,
4515
4686
  onClick: () => {
4687
+ var _option$commandId2;
4516
4688
  onSubmenuOptionSelect === null || onSubmenuOptionSelect === void 0 || onSubmenuOptionSelect({
4517
4689
  ...option,
4518
4690
  id: menuItem.id,
4519
4691
  label: menuKey,
4520
- commandId: option.commandId
4692
+ commandId: (_option$commandId2 = option.commandId) !== null && _option$commandId2 !== void 0 ? _option$commandId2 : selectionsCommandId
4521
4693
  });
4522
4694
  },
4523
4695
  children: optionContentNode
@@ -4531,6 +4703,8 @@ function ContextMenuMenuItem(props) {
4531
4703
  menuSchemas: subMenuItems,
4532
4704
  menuSessionVersion,
4533
4705
  submenuPortalContainer,
4706
+ activeItemIds,
4707
+ hiddenItemIds,
4534
4708
  onOptionSelect: onSubmenuOptionSelect,
4535
4709
  maxMenuHeight
4536
4710
  })]
@@ -4542,8 +4716,8 @@ function useContextGroupHiddenStates$1(menuSchemas) {
4542
4716
  const [hiddenStates, setHiddenStates] = useState({});
4543
4717
  useEffect(() => {
4544
4718
  const subscriptions = menuSchemas.map((menuSchema) => {
4545
- var _menuSchema$children2;
4546
- if (!((_menuSchema$children2 = menuSchema.children) === null || _menuSchema$children2 === void 0 ? void 0 : _menuSchema$children2.length)) return null;
4719
+ var _menuSchema$children3;
4720
+ if (!((_menuSchema$children3 = menuSchema.children) === null || _menuSchema$children3 === void 0 ? void 0 : _menuSchema$children3.length)) return null;
4547
4721
  return combineLatest(menuSchema.children.map((childSchema) => {
4548
4722
  var _childSchema$item$hid, _childSchema$item;
4549
4723
  return (_childSchema$item$hid = (_childSchema$item = childSchema.item) === null || _childSchema$item === void 0 ? void 0 : _childSchema$item.hidden$) !== null && _childSchema$item$hid !== void 0 ? _childSchema$item$hid : of(false);
@@ -4712,7 +4886,9 @@ function DesktopContextMenu() {
4712
4886
  onRequestClose: handleClose,
4713
4887
  onOptionSelect: (params) => {
4714
4888
  const { label: id, commandId, value } = params;
4715
- if (commandService) commandService.executeCommand(commandId !== null && commandId !== void 0 ? commandId : id, { value });
4889
+ const rawParams = typeof params.params === "function" ? params.params() : params.params;
4890
+ const commandParams = typeof rawParams === "undefined" ? { value } : rawParams;
4891
+ if (commandService) commandService.executeCommand(commandId !== null && commandId !== void 0 ? commandId : id, commandParams);
4716
4892
  injector.get(ILayoutService).focus();
4717
4893
  handleClose();
4718
4894
  }
@@ -5251,7 +5427,7 @@ const IUIController = createIdentifier("univer.ui.ui-controller");
5251
5427
  //#endregion
5252
5428
  //#region package.json
5253
5429
  var name = "@univerjs/ui";
5254
- var version = "0.24.0";
5430
+ var version = "0.25.0-insiders.20260608-e4336f7";
5255
5431
 
5256
5432
  //#endregion
5257
5433
  //#region src/views/components/ribbon/MobileRibbon.tsx
@@ -5319,7 +5495,7 @@ function MobileRibbon(props) {
5319
5495
  const container = toolbarScrollRef.current;
5320
5496
  if (!container) return;
5321
5497
  container.scrollBy({
5322
- left: direction === "left" ? -toolbarScrollOffset : toolbarScrollOffset,
5498
+ left: direction === "left" ? -168 : toolbarScrollOffset,
5323
5499
  behavior: "smooth"
5324
5500
  });
5325
5501
  }
@@ -5360,7 +5536,7 @@ function MobileRibbon(props) {
5360
5536
  dark:!univer-text-gray-200
5361
5537
  `),
5362
5538
  onClick: () => selectTab(index),
5363
- children: [localeService.t(group.key), active && /* @__PURE__ */ jsx("span", { className: "\n univer-absolute univer-bottom-0 univer-left-1/2 univer-h-0.5 univer-w-8\n -univer-translate-x-1/2 univer-rounded-full univer-bg-primary-600\n dark:!univer-bg-primary-400\n " })]
5539
+ children: [localeService.t(group.title || group.key), active && /* @__PURE__ */ jsx("span", { className: "\n univer-absolute univer-bottom-0 univer-left-1/2 univer-h-0.5 univer-w-8\n -univer-translate-x-1/2 univer-rounded-full univer-bg-primary-600\n dark:!univer-bg-primary-400\n " })]
5364
5540
  }, group.key);
5365
5541
  })
5366
5542
  }),
@@ -5781,8 +5957,8 @@ function MobileContextMenu() {
5781
5957
  }
5782
5958
  const sheetTitle = useMemo(() => {
5783
5959
  switch (menuType) {
5784
- case "contextMenu.rowHeader": return localeService.t("row");
5785
- case "contextMenu.colHeader": return localeService.t("column");
5960
+ case "contextMenu.rowHeader": return localeService.t("ui.row");
5961
+ case "contextMenu.colHeader": return localeService.t("ui.column");
5786
5962
  default: return "";
5787
5963
  }
5788
5964
  }, [localeService, menuType]);
@@ -5792,7 +5968,7 @@ function MobileContextMenu() {
5792
5968
  className: "univer-fixed univer-inset-0 univer-z-[1080] univer-flex univer-items-end",
5793
5969
  children: [/* @__PURE__ */ jsx("button", {
5794
5970
  type: "button",
5795
- "aria-label": localeService.t("rangeSelector.cancel"),
5971
+ "aria-label": localeService.t("ui.rangeSelector.cancel"),
5796
5972
  className: "univer-absolute univer-inset-0 univer-bg-[rgba(15,23,42,0.32)] univer-backdrop-blur-[2px]",
5797
5973
  onClick: handleClose
5798
5974
  }), /* @__PURE__ */ jsxs("section", {
@@ -5813,7 +5989,7 @@ function MobileContextMenu() {
5813
5989
  })
5814
5990
  }), /* @__PURE__ */ jsx("button", {
5815
5991
  type: "button",
5816
- "aria-label": localeService.t("rangeSelector.cancel"),
5992
+ "aria-label": localeService.t("ui.rangeSelector.cancel"),
5817
5993
  className: "\n univer-flex univer-size-8 univer-shrink-0 univer-appearance-none univer-items-center\n univer-justify-center univer-rounded-full univer-border-0 univer-bg-white univer-p-0\n univer-leading-none univer-text-gray-600 univer-shadow-sm univer-outline-none\n univer-ring-0 univer-transition-colors\n hover:univer-bg-gray-100\n active:univer-bg-gray-200\n ",
5818
5994
  style: { margin: 0 },
5819
5995
  onClick: handleClose,
@@ -6039,13 +6215,40 @@ const INotificationService = createIdentifier("ui.notification.service");
6039
6215
  //#endregion
6040
6216
  //#region src/services/before-close/before-close.service.ts
6041
6217
  const IBeforeCloseService = createIdentifier("univer.ui.before-close-service");
6042
- let DesktopBeforeCloseService = class DesktopBeforeCloseService {
6218
+ let DesktopBeforeCloseService = class DesktopBeforeCloseService extends Disposable {
6043
6219
  constructor(_notificationService) {
6220
+ super();
6044
6221
  this._notificationService = _notificationService;
6045
6222
  _defineProperty(this, "_beforeUnloadCallbacks", []);
6046
6223
  _defineProperty(this, "_onCloseCallbacks", []);
6224
+ _defineProperty(this, "_beforeUnloadHandler", void 0);
6225
+ _defineProperty(this, "_unloadHandler", void 0);
6226
+ this._beforeUnloadHandler = (_event) => {
6227
+ let event = _event;
6228
+ const message = this._beforeUnloadCallbacks.map((callback) => callback()).filter((m) => !!m).join("\n");
6229
+ if (message) {
6230
+ this._notificationService.show({
6231
+ type: "error",
6232
+ title: "Some changes are not saved",
6233
+ content: message
6234
+ });
6235
+ if (typeof event === "undefined") event = window.event;
6236
+ event.returnValue = message;
6237
+ return message;
6238
+ }
6239
+ };
6240
+ this._unloadHandler = () => {
6241
+ this._onCloseCallbacks.forEach((callback) => callback());
6242
+ };
6047
6243
  this._init();
6048
6244
  }
6245
+ dispose() {
6246
+ window.removeEventListener("beforeunload", this._beforeUnloadHandler);
6247
+ window.removeEventListener("unload", this._unloadHandler);
6248
+ this._beforeUnloadCallbacks = [];
6249
+ this._onCloseCallbacks = [];
6250
+ super.dispose();
6251
+ }
6049
6252
  registerBeforeClose(callback) {
6050
6253
  this._beforeUnloadCallbacks.push(callback);
6051
6254
  return { dispose: () => {
@@ -6059,23 +6262,8 @@ let DesktopBeforeCloseService = class DesktopBeforeCloseService {
6059
6262
  } };
6060
6263
  }
6061
6264
  _init() {
6062
- window.addEventListener("beforeunload", (_event) => {
6063
- let event = _event;
6064
- const message = this._beforeUnloadCallbacks.map((callback) => callback()).filter((m) => !!m).join("\n");
6065
- if (message) {
6066
- this._notificationService.show({
6067
- type: "error",
6068
- title: "Some changes are not saved",
6069
- content: message
6070
- });
6071
- if (typeof event === "undefined") event = window.event;
6072
- event.returnValue = message;
6073
- return message;
6074
- }
6075
- });
6076
- window.addEventListener("unload", () => {
6077
- this._onCloseCallbacks.forEach((callback) => callback());
6078
- });
6265
+ window.addEventListener("beforeunload", this._beforeUnloadHandler);
6266
+ window.addEventListener("unload", this._unloadHandler);
6079
6267
  }
6080
6268
  };
6081
6269
  DesktopBeforeCloseService = __decorate([__decorateParam(0, INotificationService)], DesktopBeforeCloseService);
@@ -6263,14 +6451,25 @@ let BrowserClipboardService = class BrowserClipboardService extends Disposable {
6263
6451
  this._logService = _logService;
6264
6452
  this._notificationService = _notificationService;
6265
6453
  }
6266
- async write(text, html) {
6267
- if (!this.supportClipboard) return this._legacyCopyHtml(html);
6454
+ async write(text, html, customData) {
6455
+ if (!this.supportClipboard) return this._legacyCopyHtml(text, html);
6268
6456
  try {
6269
6457
  return await navigator.clipboard.write([new ClipboardItem({
6270
6458
  [PLAIN_TEXT_CLIPBOARD_MIME_TYPE]: new Blob([text], { type: PLAIN_TEXT_CLIPBOARD_MIME_TYPE }),
6271
- [HTML_CLIPBOARD_MIME_TYPE]: new Blob([html], { type: HTML_CLIPBOARD_MIME_TYPE })
6459
+ [HTML_CLIPBOARD_MIME_TYPE]: new Blob([html], { type: HTML_CLIPBOARD_MIME_TYPE }),
6460
+ ...Object.fromEntries(Object.entries(customData !== null && customData !== void 0 ? customData : {}).map(([type, value]) => [type, new Blob([value], { type })]))
6272
6461
  })]);
6273
6462
  } catch (error) {
6463
+ if (customData && Object.keys(customData).length) try {
6464
+ return await navigator.clipboard.write([new ClipboardItem({
6465
+ [PLAIN_TEXT_CLIPBOARD_MIME_TYPE]: new Blob([text], { type: PLAIN_TEXT_CLIPBOARD_MIME_TYPE }),
6466
+ [HTML_CLIPBOARD_MIME_TYPE]: new Blob([html], { type: HTML_CLIPBOARD_MIME_TYPE })
6467
+ })]);
6468
+ } catch (fallbackError) {
6469
+ this._logService.error("[BrowserClipboardService]", fallbackError);
6470
+ this._showClipboardAuthenticationNotification();
6471
+ return;
6472
+ }
6274
6473
  this._logService.error("[BrowserClipboardService]", error);
6275
6474
  this._showClipboardAuthenticationNotification();
6276
6475
  }
@@ -6304,17 +6503,34 @@ let BrowserClipboardService = class BrowserClipboardService extends Disposable {
6304
6503
  return "";
6305
6504
  }
6306
6505
  }
6307
- _legacyCopyHtml(html) {
6506
+ _legacyCopyHtml(text, html) {
6308
6507
  const activeElement = document.activeElement;
6309
- const container = createCopyHtmlContainer();
6310
- document.body.appendChild(container);
6311
- container.replaceChildren(sanitizeHtmlForClipboard(html));
6508
+ const sanitizedHtml = serializeSanitizedHtmlForClipboard(html);
6509
+ let handledByClipboardEvent = false;
6510
+ const onCopy = (event) => {
6511
+ if (!event.clipboardData) return;
6512
+ event.preventDefault();
6513
+ event.clipboardData.setData(PLAIN_TEXT_CLIPBOARD_MIME_TYPE, text);
6514
+ event.clipboardData.setData(HTML_CLIPBOARD_MIME_TYPE, sanitizedHtml);
6515
+ handledByClipboardEvent = true;
6516
+ };
6517
+ document.addEventListener("copy", onCopy);
6312
6518
  try {
6313
- select(container);
6314
6519
  document.execCommand("copy");
6520
+ if (!handledByClipboardEvent) {
6521
+ const container = createCopyHtmlContainer();
6522
+ document.body.appendChild(container);
6523
+ container.innerHTML = sanitizedHtml;
6524
+ try {
6525
+ select(container);
6526
+ document.execCommand("copy");
6527
+ } finally {
6528
+ document.body.removeChild(container);
6529
+ }
6530
+ }
6315
6531
  } finally {
6532
+ document.removeEventListener("copy", onCopy);
6316
6533
  if (activeElement instanceof HTMLElement) activeElement.focus();
6317
- document.body.removeChild(container);
6318
6534
  }
6319
6535
  }
6320
6536
  _legacyCopyText(text) {
@@ -6334,8 +6550,8 @@ let BrowserClipboardService = class BrowserClipboardService extends Disposable {
6334
6550
  var _this$_notificationSe;
6335
6551
  (_this$_notificationSe = this._notificationService) === null || _this$_notificationSe === void 0 || _this$_notificationSe.show({
6336
6552
  type: "warning",
6337
- title: this._localeService.t("clipboard.authentication.title"),
6338
- content: this._localeService.t("clipboard.authentication.content")
6553
+ title: this._localeService.t("ui.clipboard.authentication.title"),
6554
+ content: this._localeService.t("ui.clipboard.authentication.content")
6339
6555
  });
6340
6556
  }
6341
6557
  };
@@ -6372,6 +6588,11 @@ function sanitizeHtmlForClipboard(html) {
6372
6588
  });
6373
6589
  return fragment;
6374
6590
  }
6591
+ function serializeSanitizedHtmlForClipboard(html) {
6592
+ const container = document.createElement("div");
6593
+ container.appendChild(sanitizeHtmlForClipboard(html));
6594
+ return container.innerHTML;
6595
+ }
6375
6596
  function sanitizeHtmlNode(node) {
6376
6597
  if (node.nodeType === Node.TEXT_NODE) {
6377
6598
  var _node$textContent;
@@ -6768,29 +6989,215 @@ var DesktopLocalFileService = class extends Disposable {
6768
6989
  */
6769
6990
  const ILocalFileService = createIdentifier("univer-ui.local-file.service");
6770
6991
 
6992
+ //#endregion
6993
+ //#region src/utils/storage-driver.ts
6994
+ /**
6995
+ * Copyright 2023-present DreamNum Co., Ltd.
6996
+ *
6997
+ * Licensed under the Apache License, Version 2.0 (the "License");
6998
+ * you may not use this file except in compliance with the License.
6999
+ * You may obtain a copy of the License at
7000
+ *
7001
+ * http://www.apache.org/licenses/LICENSE-2.0
7002
+ *
7003
+ * Unless required by applicable law or agreed to in writing, software
7004
+ * distributed under the License is distributed on an "AS IS" BASIS,
7005
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7006
+ * See the License for the specific language governing permissions and
7007
+ * limitations under the License.
7008
+ */
7009
+ const DB_NAME = "UniverLocalStorage";
7010
+ const STORE_NAME = "kv";
7011
+ const DB_VERSION = 1;
7012
+ var IndexedDBDriver = class {
7013
+ constructor() {
7014
+ _defineProperty(this, "_db", void 0);
7015
+ this._db = this._init();
7016
+ }
7017
+ _init() {
7018
+ return new Promise((resolve, reject) => {
7019
+ const req = indexedDB.open(DB_NAME, DB_VERSION);
7020
+ req.onerror = () => reject(req.error);
7021
+ req.onsuccess = () => resolve(req.result);
7022
+ req.onupgradeneeded = () => {
7023
+ req.result.createObjectStore(STORE_NAME);
7024
+ };
7025
+ });
7026
+ }
7027
+ _store(mode) {
7028
+ return this._db.then((db) => {
7029
+ return db.transaction(STORE_NAME, mode).objectStore(STORE_NAME);
7030
+ });
7031
+ }
7032
+ async getItem(key) {
7033
+ const store = await this._store("readonly");
7034
+ return new Promise((resolve, reject) => {
7035
+ const req = store.get(key);
7036
+ req.onsuccess = () => {
7037
+ var _req$result;
7038
+ return resolve((_req$result = req.result) !== null && _req$result !== void 0 ? _req$result : null);
7039
+ };
7040
+ req.onerror = () => reject(req.error);
7041
+ });
7042
+ }
7043
+ async setItem(key, value) {
7044
+ const store = await this._store("readwrite");
7045
+ return new Promise((resolve, reject) => {
7046
+ const req = store.put(value, key);
7047
+ req.onsuccess = () => resolve(value);
7048
+ req.onerror = () => reject(req.error);
7049
+ });
7050
+ }
7051
+ async removeItem(key) {
7052
+ const store = await this._store("readwrite");
7053
+ return new Promise((resolve, reject) => {
7054
+ const req = store.delete(key);
7055
+ req.onsuccess = () => resolve();
7056
+ req.onerror = () => reject(req.error);
7057
+ });
7058
+ }
7059
+ async clear() {
7060
+ const store = await this._store("readwrite");
7061
+ return new Promise((resolve, reject) => {
7062
+ const req = store.clear();
7063
+ req.onsuccess = () => resolve();
7064
+ req.onerror = () => reject(req.error);
7065
+ });
7066
+ }
7067
+ async key(index) {
7068
+ const store = await this._store("readonly");
7069
+ return new Promise((resolve, reject) => {
7070
+ const req = store.openCursor();
7071
+ let i = 0;
7072
+ req.onsuccess = () => {
7073
+ const cursor = req.result;
7074
+ if (!cursor) return resolve(null);
7075
+ if (i === index) return resolve(cursor.key);
7076
+ i++;
7077
+ cursor.continue();
7078
+ };
7079
+ req.onerror = () => reject(req.error);
7080
+ });
7081
+ }
7082
+ async keys() {
7083
+ const store = await this._store("readonly");
7084
+ return new Promise((resolve, reject) => {
7085
+ const req = store.openCursor();
7086
+ const keys = [];
7087
+ req.onsuccess = () => {
7088
+ const cursor = req.result;
7089
+ if (!cursor) return resolve(keys);
7090
+ keys.push(cursor.key);
7091
+ cursor.continue();
7092
+ };
7093
+ req.onerror = () => reject(req.error);
7094
+ });
7095
+ }
7096
+ async iterate(iteratee) {
7097
+ const store = await this._store("readonly");
7098
+ return new Promise((resolve, reject) => {
7099
+ const req = store.openCursor();
7100
+ let i = 1;
7101
+ let result = void 0;
7102
+ req.onsuccess = () => {
7103
+ const cursor = req.result;
7104
+ if (!cursor) return resolve(result);
7105
+ result = iteratee(cursor.value, cursor.key, i++);
7106
+ if (result !== void 0) return resolve(result);
7107
+ cursor.continue();
7108
+ };
7109
+ req.onerror = () => reject(req.error);
7110
+ });
7111
+ }
7112
+ };
7113
+ var LocalStorageDriver = class {
7114
+ constructor() {
7115
+ _defineProperty(this, "_prefix", `${DB_NAME}/`);
7116
+ }
7117
+ _key(key) {
7118
+ return this._prefix + key;
7119
+ }
7120
+ _rawKey(key) {
7121
+ return key.startsWith(this._prefix) ? key.slice(this._prefix.length) : key;
7122
+ }
7123
+ async getItem(key) {
7124
+ try {
7125
+ const item = localStorage.getItem(this._key(key));
7126
+ return item ? JSON.parse(item) : null;
7127
+ } catch {
7128
+ return null;
7129
+ }
7130
+ }
7131
+ async setItem(key, value) {
7132
+ localStorage.setItem(this._key(key), JSON.stringify(value));
7133
+ return value;
7134
+ }
7135
+ async removeItem(key) {
7136
+ localStorage.removeItem(this._key(key));
7137
+ }
7138
+ async clear() {
7139
+ const toRemove = [];
7140
+ for (let i = 0; i < localStorage.length; i++) {
7141
+ const k = localStorage.key(i);
7142
+ if (k.startsWith(this._prefix)) toRemove.push(k);
7143
+ }
7144
+ toRemove.forEach((k) => localStorage.removeItem(k));
7145
+ }
7146
+ async key(index) {
7147
+ var _keys$index;
7148
+ return (_keys$index = this._keys()[index]) !== null && _keys$index !== void 0 ? _keys$index : null;
7149
+ }
7150
+ async keys() {
7151
+ return this._keys();
7152
+ }
7153
+ _keys() {
7154
+ const keys = [];
7155
+ for (let i = 0; i < localStorage.length; i++) {
7156
+ const k = localStorage.key(i);
7157
+ if (k.startsWith(this._prefix)) keys.push(this._rawKey(k));
7158
+ }
7159
+ return keys;
7160
+ }
7161
+ async iterate(iteratee) {
7162
+ const keys = this._keys();
7163
+ for (let i = 0; i < keys.length; i++) {
7164
+ const key = keys[i];
7165
+ const result = iteratee(await this.getItem(key), key, i + 1);
7166
+ if (result !== void 0) return result;
7167
+ }
7168
+ }
7169
+ };
7170
+ function createDriver() {
7171
+ try {
7172
+ if (typeof indexedDB !== "undefined") return new IndexedDBDriver();
7173
+ } catch {}
7174
+ return new LocalStorageDriver();
7175
+ }
7176
+ const browserStorage = createDriver();
7177
+
6771
7178
  //#endregion
6772
7179
  //#region src/services/local-storage/local-storage.service.ts
6773
7180
  var DesktopLocalStorageService = class {
6774
7181
  getItem(key) {
6775
- return localforage.getItem(key);
7182
+ return browserStorage.getItem(key);
6776
7183
  }
6777
7184
  setItem(key, value) {
6778
- return localforage.setItem(key, value);
7185
+ return browserStorage.setItem(key, value);
6779
7186
  }
6780
7187
  removeItem(key) {
6781
- return localforage.removeItem(key);
7188
+ return browserStorage.removeItem(key);
6782
7189
  }
6783
7190
  clear() {
6784
- return localforage.clear();
7191
+ return browserStorage.clear();
6785
7192
  }
6786
7193
  key(index) {
6787
- return localforage.key(index);
7194
+ return browserStorage.key(index);
6788
7195
  }
6789
7196
  keys() {
6790
- return localforage.keys();
7197
+ return browserStorage.keys();
6791
7198
  }
6792
7199
  iterate(iteratee) {
6793
- return localforage.iterate(iteratee);
7200
+ return browserStorage.iterate(iteratee);
6794
7201
  }
6795
7202
  };
6796
7203
 
@@ -7911,4 +8318,4 @@ const PrintFloatDomSingle = memo((props) => {
7911
8318
  });
7912
8319
 
7913
8320
  //#endregion
7914
- export { AnchoredContextMenu, BrowserClipboardService, BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, CanvasFloatDomService, CanvasPopup, CanvasPopupService, CommonLabel, ComponentContainer, ComponentManager, DesktopContextMenu as ContextMenu, ContextMenuGroup, ContextMenuHostService, ContextMenuPanel, ContextMenuPosition, ContextMenuService, CopyCommand, CopyShortcutItem, CustomLabel, CutCommand, CutShortcutItem, DISABLE_AUTO_FOCUS_KEY, DesktopBeforeCloseService, DesktopConfirmService, DesktopDialogService, DesktopGalleryService, DesktopLayoutService, DesktopLocalFileService, DesktopLocalStorageService, DesktopMessageService, DesktopNotificationService, DesktopRibbonService, DesktopSidebarService, DesktopUIController, DesktopZenZoneService, ErrorController, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE_SVG_XML_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FloatDom, FloatDomSingle, FontFamily, FontFamilyItem, FontSize, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, HeadingItem, IBeforeCloseService, ICanvasPopupService, IClipboardInterfaceService, IContextMenuHostService, IContextMenuService, IDialogService, IFontService, IGalleryService, ILayoutService, ILeftSidebarService, ILocalFileService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IRibbonService, IShortcutService, ISidebarService, IUIController, IUIPartsService, IZenZoneService, KeyCode, MenuItemType, MenuManagerPosition, MenuManagerService, MetaKeys, MobileContextMenu, MockMessageService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, PlatformService, PrintFloatDomSingle, ProgressBar, RectPopup, RediConsumer, RediContext, RediProvider, RedoShortcutItem, Ribbon, RibbonDataGroup, RibbonFormulasGroup, RibbonInsertGroup, RibbonOthersGroup, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SharedController, SheetPasteShortKeyCommandName, ShortcutPanelController, ShortcutPanelService, ShortcutService, Sidebar, SingleCanvasPopup, SingleUnitUIController, Slider, ThemeSwitcherService, ToggleShortcutPanelOperation, ToolbarButton, ToolbarItem, menuSchema as UIMenuSchema, UIPartsService, UI_PLUGIN_CONFIG_KEY, UNI_DISABLE_CHANGING_FOCUS_KEY, UndoShortcutItem, UniverMobileUIPlugin, UniverUIPlugin, WithDependency, ZIndexManager, ZenZone, connectDependencies, connectInjector, getHeaderFooterMenuHiddenObservable, getMenuHiddenObservable, handelExcelToJson, handelTableToJson, handleDomToJson, handlePlainToJson, handleStringToStyle, handleTableColgroup, handleTableMergeData, handleTableRowGroup, imageMimeTypeSet, mergeMenuConfigs, parseHtmlDocument, parseHtmlFragment, sanitizeParsedHtml, splitSpanText, supportClipboardAPI, t, textTrim, useClickOutSide, useComponentsOfPart, useConfigValue, useDebounceFn, useDependency, useEvent, useInjector, useObservable, useObservableRef, useScrollYOverContainer, useSidebarClick, useToolbarItemStatus, useUpdateBinder, useUpdateEffect, useVirtualList };
8321
+ export { AnchoredContextMenu, BrowserClipboardService, BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, CanvasFloatDomService, CanvasPopup, CanvasPopupService, CommonLabel, ComponentContainer, ComponentManager, DesktopContextMenu as ContextMenu, ContextMenuGroup, ContextMenuHostService, ContextMenuPanel, ContextMenuPosition, ContextMenuService, CopyCommand, CopyShortcutItem, CustomLabel, CutCommand, CutShortcutItem, DISABLE_AUTO_FOCUS_KEY, DesktopBeforeCloseService, DesktopConfirmService, DesktopDialogService, DesktopGalleryService, DesktopLayoutService, DesktopLocalFileService, DesktopLocalStorageService, DesktopMessageService, DesktopNotificationService, DesktopRibbonService, DesktopSidebarService, DesktopUIController, DesktopZenZoneService, ErrorController, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE_SVG_XML_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FloatDom, FloatDomSingle, FontFamily, FontFamilyItem, FontSize, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, HeadingItem, IBeforeCloseService, ICanvasPopupService, IClipboardInterfaceService, IContextMenuHostService, IContextMenuService, IDialogService, IFontService, IGalleryService, ILayoutService, ILeftSidebarService, ILocalFileService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IRibbonService, IShortcutService, ISidebarService, IUIController, IUIPartsService, IZenZoneService, KeyCode, MenuItemType, MenuManagerPosition, MenuManagerService, MetaKeys, MobileContextMenu, MockMessageService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, PlatformService, PrintFloatDomSingle, ProgressBar, RectPopup, RediConsumer, RediContext, RediProvider, RedoShortcutItem, Ribbon, RibbonDataGroup, RibbonFormulasGroup, RibbonInsertGroup, RibbonOthersGroup, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SharedController, SheetPasteShortKeyCommandName, ShortcutPanelController, ShortcutPanelService, ShortcutService, Sidebar, SingleCanvasPopup, SingleUnitUIController, Slider, ThemeSwitcherService, ToggleShortcutPanelOperation, ToolbarButton, ToolbarItem, menuSchema as UIMenuSchema, UIPartsService, UI_PLUGIN_CONFIG_KEY, UNI_DISABLE_CHANGING_FOCUS_KEY, UndoShortcutItem, UniverMobileUIPlugin, UniverUIPlugin, WithDependency, ZIndexManager, ZenZone, connectDependencies, connectInjector, getHeaderFooterMenuHiddenObservable, getMenuHiddenObservable, handelExcelToJson, handelTableToJson, handleDomToJson, handlePlainToJson, handleStringToStyle, handleTableColgroup, handleTableMergeData, handleTableRowGroup, imageMimeTypeSet, mergeMenuConfigs, parseHtmlDocument, parseHtmlFragment, sanitizeParsedHtml, splitSpanText, supportClipboardAPI, textTrim, useClickOutSide, useComponentsOfPart, useConfigValue, useDebounceFn, useDependency, useEvent, useInjector, useObservable, useObservableRef, useScrollYOverContainer, useSidebarClick, useToolbarItemStatus, useUpdateBinder, useUpdateEffect, useVirtualList };