@univerjs/ui 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/lib/cjs/facade.js +10 -21
  2. package/lib/cjs/index.js +558 -516
  3. package/lib/cjs/locale/ar-SA.js +2 -4
  4. package/lib/cjs/locale/ca-ES.js +2 -4
  5. package/lib/cjs/locale/de-DE.js +2 -4
  6. package/lib/cjs/locale/en-US.js +2 -4
  7. package/lib/cjs/locale/es-ES.js +2 -4
  8. package/lib/cjs/locale/fa-IR.js +2 -4
  9. package/lib/cjs/locale/fr-FR.js +2 -4
  10. package/lib/cjs/locale/id-ID.js +2 -4
  11. package/lib/cjs/locale/it-IT.js +2 -4
  12. package/lib/cjs/locale/ja-JP.js +2 -4
  13. package/lib/cjs/locale/ko-KR.js +2 -4
  14. package/lib/cjs/locale/pl-PL.js +2 -4
  15. package/lib/cjs/locale/pt-BR.js +2 -4
  16. package/lib/cjs/locale/ru-RU.js +2 -4
  17. package/lib/cjs/locale/sk-SK.js +2 -4
  18. package/lib/cjs/locale/vi-VN.js +2 -4
  19. package/lib/cjs/locale/zh-CN.js +2 -4
  20. package/lib/cjs/locale/zh-HK.js +2 -4
  21. package/lib/cjs/locale/zh-TW.js +2 -4
  22. package/lib/es/facade.js +10 -20
  23. package/lib/es/index.js +472 -425
  24. package/lib/es/locale/ar-SA.js +2 -4
  25. package/lib/es/locale/ca-ES.js +2 -4
  26. package/lib/es/locale/de-DE.js +2 -4
  27. package/lib/es/locale/en-US.js +2 -4
  28. package/lib/es/locale/es-ES.js +2 -4
  29. package/lib/es/locale/fa-IR.js +2 -4
  30. package/lib/es/locale/fr-FR.js +2 -4
  31. package/lib/es/locale/id-ID.js +2 -4
  32. package/lib/es/locale/it-IT.js +2 -4
  33. package/lib/es/locale/ja-JP.js +2 -4
  34. package/lib/es/locale/ko-KR.js +2 -4
  35. package/lib/es/locale/pl-PL.js +2 -4
  36. package/lib/es/locale/pt-BR.js +2 -4
  37. package/lib/es/locale/ru-RU.js +2 -4
  38. package/lib/es/locale/sk-SK.js +2 -4
  39. package/lib/es/locale/vi-VN.js +2 -4
  40. package/lib/es/locale/zh-CN.js +2 -4
  41. package/lib/es/locale/zh-HK.js +2 -4
  42. package/lib/es/locale/zh-TW.js +2 -4
  43. package/lib/facade.js +10 -20
  44. package/lib/index.css +49 -14
  45. package/lib/index.js +472 -425
  46. package/lib/locale/ar-SA.js +2 -4
  47. package/lib/locale/ca-ES.js +2 -4
  48. package/lib/locale/de-DE.js +2 -4
  49. package/lib/locale/en-US.js +2 -4
  50. package/lib/locale/es-ES.js +2 -4
  51. package/lib/locale/fa-IR.js +2 -4
  52. package/lib/locale/fr-FR.js +2 -4
  53. package/lib/locale/id-ID.js +2 -4
  54. package/lib/locale/it-IT.js +2 -4
  55. package/lib/locale/ja-JP.js +2 -4
  56. package/lib/locale/ko-KR.js +2 -4
  57. package/lib/locale/pl-PL.js +2 -4
  58. package/lib/locale/pt-BR.js +2 -4
  59. package/lib/locale/ru-RU.js +2 -4
  60. package/lib/locale/sk-SK.js +2 -4
  61. package/lib/locale/vi-VN.js +2 -4
  62. package/lib/locale/zh-CN.js +2 -4
  63. package/lib/locale/zh-HK.js +2 -4
  64. package/lib/locale/zh-TW.js +2 -4
  65. package/lib/types/menu/shortcut-panel.menu.d.ts +2 -1
  66. package/lib/types/services/menu/menu-manager.service.d.ts +2 -0
  67. package/lib/types/services/menu/menu.d.ts +1 -0
  68. package/lib/types/utils/di.d.ts +6 -10
  69. package/lib/types/views/components/mobile-drawer/MobileDrawer.d.ts +1 -0
  70. package/lib/types/views/components/popup/RectPopup.d.ts +8 -6
  71. package/lib/types/views/components/ribbon/ToolbarButton.d.ts +3 -5
  72. package/lib/types/views/components/ribbon/TooltipButtonWrapper.d.ts +2 -1
  73. package/lib/types/views/components/ribbon/ribbon-grid-layout.d.ts +2 -0
  74. package/lib/types/views/components/ribbon/ribbon-menu/use-ribbon-tabs.d.ts +18 -0
  75. package/lib/types/views/custom-label/CustomLabel.d.ts +1 -0
  76. package/lib/types/views/emoji-picker/emoji-picker-utils.d.ts +2 -2
  77. package/lib/types/views/font-family/FontFamily.d.ts +1 -1
  78. package/lib/umd/index.js +23 -22
  79. package/package.json +13 -13
package/lib/cjs/index.js CHANGED
@@ -11,7 +11,7 @@ let react_dom = require("react-dom");
11
11
  let _univerjs_icons = require("@univerjs/icons");
12
12
  let _univerjs_protocol = require("@univerjs/protocol");
13
13
 
14
- //#region src/utils/embed-boundary.ts
14
+ // src/utils/embed-boundary.ts
15
15
  /**
16
16
  * Copyright 2023-present DreamNum Co., Ltd.
17
17
  *
@@ -55,8 +55,7 @@ function getAttributeValue(target, name) {
55
55
  return typeof getAttribute === "function" ? getAttribute.call(target, name) ?? void 0 : void 0;
56
56
  }
57
57
 
58
- //#endregion
59
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
58
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
60
59
  function _typeof(o) {
61
60
  "@babel/helpers - typeof";
62
61
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -66,8 +65,7 @@ function _typeof(o) {
66
65
  }, _typeof(o);
67
66
  }
68
67
 
69
- //#endregion
70
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
68
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
71
69
  function toPrimitive(t, r) {
72
70
  if ("object" != _typeof(t) || !t) return t;
73
71
  var e = t[Symbol.toPrimitive];
@@ -79,15 +77,13 @@ function toPrimitive(t, r) {
79
77
  return ("string" === r ? String : Number)(t);
80
78
  }
81
79
 
82
- //#endregion
83
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
80
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
84
81
  function toPropertyKey(t) {
85
82
  var i = toPrimitive(t, "string");
86
83
  return "symbol" == _typeof(i) ? i : i + "";
87
84
  }
88
85
 
89
- //#endregion
90
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
86
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
91
87
  function _defineProperty(e, r, t) {
92
88
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
93
89
  value: t,
@@ -97,16 +93,14 @@ function _defineProperty(e, r, t) {
97
93
  }) : e[r] = t, e;
98
94
  }
99
95
 
100
- //#endregion
101
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
96
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
102
97
  function __decorateParam(paramIndex, decorator) {
103
98
  return function(target, key) {
104
99
  decorator(target, key, paramIndex);
105
100
  };
106
101
  }
107
102
 
108
- //#endregion
109
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
103
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
110
104
  function __decorate(decorators, target, key, desc) {
111
105
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
112
106
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -114,8 +108,7 @@ function __decorate(decorators, target, key, desc) {
114
108
  return c > 3 && r && Object.defineProperty(target, key, r), r;
115
109
  }
116
110
 
117
- //#endregion
118
- //#region src/services/layout/layout.service.ts
111
+ // src/services/layout/layout.service.ts
119
112
  const FOCUSING_UNIVER = "FOCUSING_UNIVER";
120
113
  const givingBackFocusElements = [
121
114
  "app-layout",
@@ -224,8 +217,7 @@ function getFocusUnitIdFromElement(target) {
224
217
  return target.dataset.uUnitId;
225
218
  }
226
219
 
227
- //#endregion
228
- //#region src/commands/operations/toggle-fullscreen.operation.ts
220
+ // src/commands/operations/toggle-fullscreen.operation.ts
229
221
  const ToggleFullscreenOperation = {
230
222
  id: "base-ui.operation.toggle-fullscreen",
231
223
  type: _univerjs_core.CommandType.OPERATION,
@@ -248,8 +240,7 @@ const ToggleFullscreenOperation = {
248
240
  }
249
241
  };
250
242
 
251
- //#endregion
252
- //#region src/services/shortcut/shortcut-panel.service.ts
243
+ // src/services/shortcut/shortcut-panel.service.ts
253
244
  /**
254
245
  * Copyright 2023-present DreamNum Co., Ltd.
255
246
  *
@@ -287,13 +278,11 @@ var ShortcutPanelService = class extends _univerjs_core.Disposable {
287
278
  }
288
279
  };
289
280
 
290
- //#endregion
291
- //#region src/services/sidebar/sidebar.service.ts
281
+ // src/services/sidebar/sidebar.service.ts
292
282
  const ILeftSidebarService = (0, _univerjs_core.createIdentifier)("ui.left-sidebar.service");
293
283
  const ISidebarService = (0, _univerjs_core.createIdentifier)("ui.sidebar.service");
294
284
 
295
- //#endregion
296
- //#region src/commands/operations/toggle-shortcut-panel.operation.ts
285
+ // src/commands/operations/toggle-shortcut-panel.operation.ts
297
286
  const ShortcutPanelComponentName = "ShortcutPanel";
298
287
  const ToggleShortcutPanelOperation = {
299
288
  id: "base-ui.operation.toggle-shortcut-panel",
@@ -316,8 +305,7 @@ const ToggleShortcutPanelOperation = {
316
305
  }
317
306
  };
318
307
 
319
- //#endregion
320
- //#region src/common/component-manager.ts
308
+ // src/common/component-manager.ts
321
309
  let ComponentManager = class ComponentManager extends _univerjs_core.Disposable {
322
310
  constructor(_logService) {
323
311
  super();
@@ -383,8 +371,7 @@ let ComponentManager = class ComponentManager extends _univerjs_core.Disposable
383
371
  };
384
372
  ComponentManager = __decorate([__decorateParam(0, (0, _univerjs_core.Optional)(_univerjs_core.ILogService))], ComponentManager);
385
373
 
386
- //#endregion
387
- //#region src/common/icon-manager.ts
374
+ // src/common/icon-manager.ts
388
375
  const EmptyIcon = () => null;
389
376
  let IconManager = class IconManager extends _univerjs_core.Disposable {
390
377
  constructor(_logService) {
@@ -440,8 +427,7 @@ let IconManager = class IconManager extends _univerjs_core.Disposable {
440
427
  };
441
428
  IconManager = __decorate([__decorateParam(0, _univerjs_core.ILogService)], IconManager);
442
429
 
443
- //#endregion
444
- //#region src/common/z-index-manager.ts
430
+ // src/common/z-index-manager.ts
445
431
  /**
446
432
  * Copyright 2023-present DreamNum Co., Ltd.
447
433
  *
@@ -479,8 +465,7 @@ var ZIndexManager = class {
479
465
  }
480
466
  };
481
467
 
482
- //#endregion
483
- //#region src/common/menu-hidden-observable.ts
468
+ // src/common/menu-hidden-observable.ts
484
469
  function getMenuHiddenObservable(accessor, targetUniverType, matchUnitId, needHideUnitId) {
485
470
  const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
486
471
  const getUnitType = (unitId) => _univerjs_core.SHEET_EDITOR_UNITS.includes(unitId) ? _univerjs_core.UniverInstanceType.UNIVER_SHEET : univerInstanceService.getUnitType(unitId);
@@ -522,8 +507,7 @@ function getHeaderFooterMenuHiddenObservable(accessor) {
522
507
  });
523
508
  }
524
509
 
525
- //#endregion
526
- //#region src/common/menu-merge-configs.ts
510
+ // src/common/menu-merge-configs.ts
527
511
  function mergeMenuConfigs(baseConfig, additionalConfig) {
528
512
  if (!additionalConfig || !baseConfig) return baseConfig;
529
513
  [
@@ -552,8 +536,7 @@ function updateReactiveProperty(baseConfig, key, value) {
552
536
  }
553
537
  }
554
538
 
555
- //#endregion
556
- //#region src/services/menu/menu.ts
539
+ // src/services/menu/menu.ts
557
540
  let MenuItemType = /* @__PURE__ */ function(MenuItemType) {
558
541
  /** Button style menu item. */
559
542
  MenuItemType[MenuItemType["BUTTON"] = 0] = "BUTTON";
@@ -569,8 +552,7 @@ function isMenuButtonSelectorItem(v) {
569
552
  return v.type === 2;
570
553
  }
571
554
 
572
- //#endregion
573
- //#region src/services/workbench/workbench.service.ts
555
+ // src/services/workbench/workbench.service.ts
574
556
  const IWorkbenchService = (0, _univerjs_core.createIdentifier)("univer.ui.workbench.service");
575
557
  let WorkbenchService = class WorkbenchService extends _univerjs_core.Disposable {
576
558
  constructor(univerInstanceService) {
@@ -625,8 +607,7 @@ function isWorkbenchRootUnit(unitId, options) {
625
607
  return !(0, _univerjs_core.isInternalEditorID)(unitId) && !(options === null || options === void 0 ? void 0 : options.skipAutoRender) && !(options === null || options === void 0 ? void 0 : options.embeddedRender);
626
608
  }
627
609
 
628
- //#endregion
629
- //#region src/common/object-permission-menu.ts
610
+ // src/common/object-permission-menu.ts
630
611
  function objectPermissionMenuItemFactory(accessor, id, unitType, objectType) {
631
612
  const instances = accessor.get(_univerjs_core.IUniverInstanceService);
632
613
  const state$ = (0, rxjs.combineLatest)([accessor.get(IWorkbenchService).rootUnitType$, instances.getCurrentTypeOfUnit$(unitType)]).pipe((0, rxjs.switchMap)(([rootType, model]) => {
@@ -660,14 +641,12 @@ function objectPermissionMenuItemFactory(accessor, id, unitType, objectType) {
660
641
  };
661
642
  }
662
643
 
663
- //#endregion
664
- //#region src/config/config.ts
644
+ // src/config/config.ts
665
645
  const UI_PLUGIN_CONFIG_KEY = "ui.config";
666
646
  const configSymbol = Symbol(UI_PLUGIN_CONFIG_KEY);
667
647
  const defaultPluginConfig = {};
668
648
 
669
- //#endregion
670
- //#region src/const.ts
649
+ // src/const.ts
671
650
  /**
672
651
  * Copyright 2023-present DreamNum Co., Ltd.
673
652
  *
@@ -689,12 +668,10 @@ const defaultPluginConfig = {};
689
668
  const UNI_DISABLE_CHANGING_FOCUS_KEY = "UNI_DISABLE_CHANGING_FOCUS";
690
669
  const MOBILE_UI_MODE = "MOBILE_UI_MODE";
691
670
 
692
- //#endregion
693
- //#region src/services/message/message.service.ts
671
+ // src/services/message/message.service.ts
694
672
  const IMessageService = (0, _univerjs_core.createIdentifier)("ui.message.service");
695
673
 
696
- //#endregion
697
- //#region src/controllers/error/error.controller.ts
674
+ // src/controllers/error/error.controller.ts
698
675
  const PERMISSION_MESSAGE_ID = "ui.permission-denied";
699
676
  const PERMISSION_MESSAGE_DURATION = 3e3;
700
677
  let ErrorController = class ErrorController extends _univerjs_core.Disposable {
@@ -739,8 +716,7 @@ ErrorController = __decorate([
739
716
  __decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService))
740
717
  ], ErrorController);
741
718
 
742
- //#endregion
743
- //#region src/services/clipboard/clipboard.command.ts
719
+ // src/services/clipboard/clipboard.command.ts
744
720
  const CopyCommandName = "univer.command.copy";
745
721
  const CopyCommand = {
746
722
  id: CopyCommandName,
@@ -773,8 +749,7 @@ const PasteCommand = {
773
749
  };
774
750
  const SheetPasteShortKeyCommandName = "sheet.command.paste-by-short-key";
775
751
 
776
- //#endregion
777
- //#region src/services/shortcut/keycode.ts
752
+ // src/services/shortcut/keycode.ts
778
753
  /**
779
754
  * Copyright 2023-present DreamNum Co., Ltd.
780
755
  *
@@ -944,15 +919,13 @@ let MetaKeys = /* @__PURE__ */ function(MetaKeys) {
944
919
  return MetaKeys;
945
920
  }({});
946
921
 
947
- //#endregion
948
- //#region src/common/lifecycle.ts
922
+ // src/common/lifecycle.ts
949
923
  function fromGlobalEvent(type, listener, options) {
950
924
  window.addEventListener(type, listener, options);
951
925
  return (0, _univerjs_core.toDisposable)(() => window.removeEventListener(type, listener, options));
952
926
  }
953
927
 
954
- //#endregion
955
- //#region src/services/platform/platform.service.ts
928
+ // src/services/platform/platform.service.ts
956
929
  /**
957
930
  * Copyright 2023-present DreamNum Co., Ltd.
958
931
  *
@@ -981,8 +954,7 @@ var PlatformService = class {
981
954
  }
982
955
  };
983
956
 
984
- //#endregion
985
- //#region src/services/runtime-scope/ui-runtime-scope.service.ts
957
+ // src/services/runtime-scope/ui-runtime-scope.service.ts
986
958
  const IUIRuntimeScopeService = (0, _univerjs_core.createIdentifier)("ui.runtime-scope.service");
987
959
  var UIRuntimeScopeService = class extends _univerjs_core.Disposable {
988
960
  constructor(..._args) {
@@ -1000,8 +972,7 @@ var UIRuntimeScopeService = class extends _univerjs_core.Disposable {
1000
972
  }
1001
973
  };
1002
974
 
1003
- //#endregion
1004
- //#region src/services/shortcut/shortcut.service.ts
975
+ // src/services/shortcut/shortcut.service.ts
1005
976
  const MENU_NAVIGATION_KEYS = /* @__PURE__ */ new Set([
1006
977
  13,
1007
978
  32,
@@ -1162,8 +1133,7 @@ ShortcutService = __decorate([
1162
1133
  __decorateParam(4, (0, _univerjs_core.Optional)(ILayoutService))
1163
1134
  ], ShortcutService);
1164
1135
 
1165
- //#endregion
1166
- //#region src/controllers/shared-shortcut.controller.ts
1136
+ // src/controllers/shared-shortcut.controller.ts
1167
1137
  function whenEditorFocused(contextService) {
1168
1138
  return contextService.getContextValue(_univerjs_core.FOCUSING_UNIVER_EDITOR);
1169
1139
  }
@@ -1257,8 +1227,7 @@ let SharedController = class SharedController extends _univerjs_core.Disposable
1257
1227
  };
1258
1228
  SharedController = __decorate([__decorateParam(0, IShortcutService), __decorateParam(1, _univerjs_core.ICommandService)], SharedController);
1259
1229
 
1260
- //#endregion
1261
- //#region src/services/menu/types.ts
1230
+ // src/services/menu/types.ts
1262
1231
  /**
1263
1232
  * Copyright 2023-present DreamNum Co., Ltd.
1264
1233
  *
@@ -1360,8 +1329,7 @@ let ContextMenuGroup = /* @__PURE__ */ function(ContextMenuGroup) {
1360
1329
  return ContextMenuGroup;
1361
1330
  }({});
1362
1331
 
1363
- //#endregion
1364
- //#region src/services/menu/menu-manager.service.ts
1332
+ // src/services/menu/menu-manager.service.ts
1365
1333
  var _MenuManagerService;
1366
1334
  const IMenuManagerService = (0, _univerjs_core.createIdentifier)("univer.menu-manager-service");
1367
1335
  let MenuManagerService = _MenuManagerService = class MenuManagerService extends _univerjs_core.Disposable {
@@ -1679,8 +1647,7 @@ function mergeMenuSchemaNode(target, source) {
1679
1647
  return result;
1680
1648
  }
1681
1649
 
1682
- //#endregion
1683
- //#region src/controllers/shortcut-display/shortcut-panel.controller.ts
1650
+ // src/controllers/shortcut-display/shortcut-panel.controller.ts
1684
1651
  const ToggleShortcutPanelShortcut = {
1685
1652
  id: ToggleShortcutPanelOperation.id,
1686
1653
  binding: 4096 | 220,
@@ -1702,12 +1669,10 @@ ShortcutPanelController = __decorate([
1702
1669
  __decorateParam(2, _univerjs_core.ICommandService)
1703
1670
  ], ShortcutPanelController);
1704
1671
 
1705
- //#endregion
1706
- //#region src/services/dialog/dialog.service.ts
1672
+ // src/services/dialog/dialog.service.ts
1707
1673
  const IDialogService = (0, _univerjs_core.createIdentifier)("univer.ui.dialog-service");
1708
1674
 
1709
- //#endregion
1710
- //#region src/services/ribbon/ribbon.service.ts
1675
+ // src/services/ribbon/ribbon.service.ts
1711
1676
  const IRibbonService = (0, _univerjs_core.createIdentifier)("univer.ribbon-service");
1712
1677
  function isSameHiddenMap(previous, current) {
1713
1678
  return previous.length === current.length && previous.every((hidden, index) => hidden === current[index]);
@@ -1871,12 +1836,44 @@ let DesktopRibbonService = class DesktopRibbonService extends _univerjs_core.Dis
1871
1836
  };
1872
1837
  DesktopRibbonService = __decorate([__decorateParam(0, IMenuManagerService), __decorateParam(1, _univerjs_core.IUniverInstanceService)], DesktopRibbonService);
1873
1838
 
1874
- //#endregion
1875
- //#region src/utils/di.ts
1839
+ // src/utils/di.ts
1876
1840
  function unwrap(o) {
1877
1841
  if (typeof o === "function") return o();
1878
1842
  return o;
1879
1843
  }
1844
+ function useObservable(observable, defaultValue, shouldHaveSyncValue, deps) {
1845
+ if (typeof observable === "function" && !deps) throw new Error("Expected deps to be provided when observable is a function!");
1846
+ const dependencies = deps ?? [observable];
1847
+ const stateRef = (0, react.useRef)(void 0);
1848
+ const previous = stateRef.current;
1849
+ if (!previous || dependencies.length !== previous.dependencies.length || dependencies.some((value, index) => !Object.is(value, previous.dependencies[index]))) {
1850
+ var _state$source;
1851
+ const state = {
1852
+ dependencies: [...dependencies],
1853
+ source: observable ? unwrap(observable) : null,
1854
+ value: observable && previous ? previous.value : defaultValue,
1855
+ hasSyncValue: false
1856
+ };
1857
+ const subscription = (_state$source = state.source) === null || _state$source === void 0 ? void 0 : _state$source.subscribe((value) => {
1858
+ state.value = value;
1859
+ state.hasSyncValue = true;
1860
+ });
1861
+ subscription === null || subscription === void 0 || subscription.unsubscribe();
1862
+ stateRef.current = state;
1863
+ }
1864
+ const state = stateRef.current;
1865
+ const [, refresh] = (0, react.useReducer)((revision) => revision + 1, 0);
1866
+ (0, react.useLayoutEffect)(() => {
1867
+ var _state$source2;
1868
+ const subscription = (_state$source2 = state.source) === null || _state$source2 === void 0 ? void 0 : _state$source2.subscribe((value) => {
1869
+ state.value = value;
1870
+ refresh();
1871
+ });
1872
+ return () => subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe();
1873
+ }, [state]);
1874
+ if (shouldHaveSyncValue && !state.hasSyncValue) throw new Error("Expected a synchronous value from the observable.");
1875
+ return state.value;
1876
+ }
1880
1877
  function useObservableRef(observable, defaultValue) {
1881
1878
  const ref = (0, react.useRef)(defaultValue);
1882
1879
  (0, react.useEffect)(() => {
@@ -1890,8 +1887,7 @@ function useObservableRef(observable, defaultValue) {
1890
1887
  return ref;
1891
1888
  }
1892
1889
 
1893
- //#endregion
1894
- //#region src/views/components/feature-search/FeatureSearch.tsx
1890
+ // src/views/components/feature-search/FeatureSearch.tsx
1895
1891
  /**
1896
1892
  * Copyright 2023-present DreamNum Co., Ltd.
1897
1893
  *
@@ -2017,7 +2013,7 @@ function FeatureSearch() {
2017
2013
  menuManagerService,
2018
2014
  ribbonService
2019
2015
  ]);
2020
- const items = (0, _wendellhu_redi_react_bindings.useObservable)(items$, []);
2016
+ const items = useObservable(items$, []);
2021
2017
  async function execute(item) {
2022
2018
  layoutService.focus();
2023
2019
  if (await commandService.executeCommand(item.commandId, item.getParams())) dialogService.close(FEATURE_SEARCH_DIALOG_ID);
@@ -2057,8 +2053,7 @@ function FeatureSearch() {
2057
2053
  });
2058
2054
  }
2059
2055
 
2060
- //#endregion
2061
- //#region src/commands/operations/open-feature-search.operation.ts
2056
+ // src/commands/operations/open-feature-search.operation.ts
2062
2057
  const OpenFeatureSearchOperation = {
2063
2058
  id: "ui.operation.open-feature-search",
2064
2059
  type: _univerjs_core.CommandType.OPERATION,
@@ -2076,8 +2071,7 @@ const OpenFeatureSearchOperation = {
2076
2071
  }
2077
2072
  };
2078
2073
 
2079
- //#endregion
2080
- //#region src/services/format-painter/format-painter-canvas.ts
2074
+ // src/services/format-painter/format-painter-canvas.ts
2081
2075
  const FORMAT_PAINTER_CURSOR_CSS = `
2082
2076
  /* Keep the brush visible while the render engine updates its usual object/text cursors. */
2083
2077
  canvas[data-format-painter="available"] {
@@ -2155,8 +2149,7 @@ function bindFormatPainterCanvas(canvas, session, options) {
2155
2149
  } };
2156
2150
  }
2157
2151
 
2158
- //#endregion
2159
- //#region src/services/format-painter/format-painter-session.service.ts
2152
+ // src/services/format-painter/format-painter-session.service.ts
2160
2153
  /** One local interaction session; domain commands retain ownership of persisted formatting. */
2161
2154
  var FormatPainterSessionService = class extends _univerjs_core.Disposable {
2162
2155
  constructor(..._args) {
@@ -2263,8 +2256,7 @@ var FormatPainterSessionService = class extends _univerjs_core.Disposable {
2263
2256
  }
2264
2257
  };
2265
2258
 
2266
- //#endregion
2267
- //#region src/controllers/format-painter.controller.ts
2259
+ // src/controllers/format-painter.controller.ts
2268
2260
  const ActivateFormatPainterOperation = {
2269
2261
  id: "ui.operation.activate-format-painter",
2270
2262
  type: _univerjs_core.CommandType.OPERATION,
@@ -2330,8 +2322,7 @@ FormatPainterController = __decorate([
2330
2322
  __decorateParam(3, _univerjs_core.IUniverInstanceService)
2331
2323
  ], FormatPainterController);
2332
2324
 
2333
- //#endregion
2334
- //#region src/menu/feature-search.menu.ts
2325
+ // src/menu/feature-search.menu.ts
2335
2326
  function FeatureSearchMenuItemFactory() {
2336
2327
  return {
2337
2328
  id: OpenFeatureSearchOperation.id,
@@ -2342,8 +2333,7 @@ function FeatureSearchMenuItemFactory() {
2342
2333
  };
2343
2334
  }
2344
2335
 
2345
- //#endregion
2346
- //#region src/menu/format-painter.menu.ts
2336
+ // src/menu/format-painter.menu.ts
2347
2337
  function FormatPainterMenuItemFactory(accessor) {
2348
2338
  const session = accessor.get(FormatPainterSessionService);
2349
2339
  return {
@@ -2369,8 +2359,7 @@ function ClearFormattingMenuItemFactory(accessor) {
2369
2359
  };
2370
2360
  }
2371
2361
 
2372
- //#endregion
2373
- //#region src/menu/history.menu.ts
2362
+ // src/menu/history.menu.ts
2374
2363
  const undoRedoDisableFactory$ = (accessor, isUndo) => {
2375
2364
  const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
2376
2365
  const contextService = accessor.get(_univerjs_core.IContextService);
@@ -2402,10 +2391,14 @@ function RedoMenuItemFactory(accessor) {
2402
2391
  };
2403
2392
  }
2404
2393
 
2405
- //#endregion
2406
- //#region src/menu/shortcut-panel.menu.ts
2407
- function ShortcutPanelMenuItemFactory() {
2394
+ // src/menu/shortcut-panel.menu.ts
2395
+ function ShortcutPanelMenuItemFactory(accessor) {
2396
+ const sidebarService = accessor.get(ISidebarService);
2408
2397
  return {
2398
+ activated$: (0, rxjs.defer)(() => sidebarService.sidebarOptions$.pipe((0, rxjs.startWith)(sidebarService.options), (0, rxjs.map)((options) => {
2399
+ var _options$children;
2400
+ return options.visible === true && ((_options$children = options.children) === null || _options$children === void 0 ? void 0 : _options$children.label) === "ShortcutPanel";
2401
+ }), (0, rxjs.distinctUntilChanged)())),
2409
2402
  id: ToggleShortcutPanelOperation.id,
2410
2403
  title: "ui.toggle-shortcut-panel",
2411
2404
  tooltip: "ui.toggle-shortcut-panel",
@@ -2414,8 +2407,7 @@ function ShortcutPanelMenuItemFactory() {
2414
2407
  };
2415
2408
  }
2416
2409
 
2417
- //#endregion
2418
- //#region src/menu/schema.ts
2410
+ // src/menu/schema.ts
2419
2411
  const menuSchema = {
2420
2412
  ["ribbon.start.history"]: {
2421
2413
  [ActivateFormatPainterOperation.id]: {
@@ -2467,8 +2459,7 @@ const menuSchema = {
2467
2459
  }
2468
2460
  };
2469
2461
 
2470
- //#endregion
2471
- //#region src/services/parts/parts.service.ts
2462
+ // src/services/parts/parts.service.ts
2472
2463
  let BuiltInUIPart = /* @__PURE__ */ function(BuiltInUIPart) {
2473
2464
  BuiltInUIPart["GLOBAL"] = "global";
2474
2465
  BuiltInUIPart["HEADER"] = "header";
@@ -2564,8 +2555,7 @@ var UIPartsService = class extends _univerjs_core.Disposable {
2564
2555
  }
2565
2556
  };
2566
2557
 
2567
- //#endregion
2568
- //#region src/services/dom/canvas-dom-layer.service.ts
2558
+ // src/services/dom/canvas-dom-layer.service.ts
2569
2559
  function shouldForwardFloatDomEvents(layer) {
2570
2560
  return layer.eventPassThrough !== false;
2571
2561
  }
@@ -2664,8 +2654,7 @@ var CanvasFloatDomPreviewService = class extends _univerjs_core.Disposable {
2664
2654
  }
2665
2655
  };
2666
2656
 
2667
- //#endregion
2668
- //#region src/views/components/dom/float-dom-layout.ts
2657
+ // src/views/components/dom/float-dom-layout.ts
2669
2658
  const LEGACY_WRAPPER_INSET = 2;
2670
2659
  const LEGACY_CONTENT_INSET = 4;
2671
2660
  function resolveFloatDomLayout(position, contentBox) {
@@ -2691,8 +2680,7 @@ function resolveFloatDomLayout(position, contentBox) {
2691
2680
  };
2692
2681
  }
2693
2682
 
2694
- //#endregion
2695
- //#region src/views/components/dom/FloatDom.tsx
2683
+ // src/views/components/dom/FloatDom.tsx
2696
2684
  function applyFloatDomLayout(wrapper, inner, layout) {
2697
2685
  const { wrapper: wrapperLayout, inner: innerLayout } = layout;
2698
2686
  const wrapperStyle = wrapper.style;
@@ -2731,7 +2719,7 @@ function FloatDomSingleContent(props) {
2731
2719
  var _layer$contentBox, _layer$contentBox2;
2732
2720
  const { layer, id, Component } = props;
2733
2721
  const univerInstanceService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IUniverInstanceService);
2734
- const position = (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => layer.position$.pipe((0, rxjs.first)()), [layer.position$]));
2722
+ const position = useObservable((0, react.useMemo)(() => layer.position$.pipe((0, rxjs.first)()), [layer.position$]));
2735
2723
  const domRef = (0, react.useRef)(null);
2736
2724
  const innerDomRef = (0, react.useRef)(null);
2737
2725
  const layerProps = (0, react.useMemo)(() => ({
@@ -2838,8 +2826,8 @@ function FloatDomSingleContent(props) {
2838
2826
  const FloatDom = ({ unitId }) => {
2839
2827
  const instanceService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IUniverInstanceService);
2840
2828
  const domLayerService = (0, _wendellhu_redi_react_bindings.useDependency)(CanvasFloatDomService);
2841
- const layers = (0, _wendellhu_redi_react_bindings.useObservable)(domLayerService.domLayers$);
2842
- const currentUnitId = resolveFloatDomCurrentUnitId(unitId, (0, _wendellhu_redi_react_bindings.useObservable)(instanceService.focused$));
2829
+ const layers = useObservable(domLayerService.domLayers$);
2830
+ const currentUnitId = resolveFloatDomCurrentUnitId(unitId, useObservable(instanceService.focused$));
2843
2831
  (0, react.useEffect)(() => {
2844
2832
  if (typeof unitId !== "string") return;
2845
2833
  const disposable = domLayerService.registerScopedRenderRoot(unitId);
@@ -2872,8 +2860,7 @@ function resolveFloatDomOverflow(props) {
2872
2860
  };
2873
2861
  }
2874
2862
 
2875
- //#endregion
2876
- //#region src/services/popup/canvas-popup.service.ts
2863
+ // src/services/popup/canvas-popup.service.ts
2877
2864
  const ICanvasPopupService = (0, _univerjs_core.createIdentifier)("ui.popup.service");
2878
2865
  var CanvasPopupService = class extends _univerjs_core.Disposable {
2879
2866
  constructor(..._args) {
@@ -2919,8 +2906,7 @@ var CanvasPopupService = class extends _univerjs_core.Disposable {
2919
2906
  }
2920
2907
  };
2921
2908
 
2922
- //#endregion
2923
- //#region src/views/hooks/event.ts
2909
+ // src/views/hooks/event.ts
2924
2910
  /**
2925
2911
  * Copyright 2023-present DreamNum Co., Ltd.
2926
2912
  *
@@ -2945,8 +2931,7 @@ function useEvent(func) {
2945
2931
  }), []);
2946
2932
  }
2947
2933
 
2948
- //#endregion
2949
- //#region src/views/components/popup/RectPopup.tsx
2934
+ // src/views/components/popup/RectPopup.tsx
2950
2935
  const RectPopupContext = (0, react.createContext)({ current: void 0 });
2951
2936
  const RectPopupDirectionContext = (0, react.createContext)("vertical");
2952
2937
  /** The popup should have a minimum edge to the boundary. */
@@ -3109,7 +3094,7 @@ function RectPopup(props) {
3109
3094
  };
3110
3095
  }, [contextMenuFn]);
3111
3096
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
3112
- const dir = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$);
3097
+ const dir = useObservable(localeService.direction$);
3113
3098
  const ele = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [mask && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3114
3099
  "data-u-comp": "rect-popup-mask",
3115
3100
  className: "univer-fixed univer-inset-0 univer-z-[100]",
@@ -3145,8 +3130,7 @@ RectPopup.calcPopupPosition = calcPopupPosition;
3145
3130
  RectPopup.useContext = () => (0, react.useContext)(RectPopupContext);
3146
3131
  RectPopup.useDirection = () => (0, react.useContext)(RectPopupDirectionContext);
3147
3132
 
3148
- //#endregion
3149
- //#region src/views/components/popup/CanvasPopup.tsx
3133
+ // src/views/components/popup/CanvasPopup.tsx
3150
3134
  const SingleCanvasPopup = ({ popup, children }) => {
3151
3135
  const anchorRect$ = (0, react.useMemo)(() => popup.anchorRect$.pipe((0, rxjs.throttleTime)(0, rxjs.animationFrameScheduler), (0, rxjs.map)((anchorRect) => {
3152
3136
  const { bottom, left, right, top } = anchorRect;
@@ -3168,7 +3152,7 @@ const SingleCanvasPopup = ({ popup, children }) => {
3168
3152
  }, [popup.excludeRects$]);
3169
3153
  const excludeRectsRef = useObservableRef(excludeRects$, popup.excludeRects);
3170
3154
  const { boundaryInsets, canvasElement, constrainToCanvas = false, hideOnInvisible = true, hiddenType = "destroy" } = popup;
3171
- const hidden = (0, _wendellhu_redi_react_bindings.useObservable)(hideOnInvisible ? () => (0, rxjs.combineLatest)([anchorRect$, hiddenRects$]).pipe((0, rxjs.map)(([rectWithOffset, hiddenRects]) => {
3155
+ const hidden = useObservable(hideOnInvisible ? () => (0, rxjs.combineLatest)([anchorRect$, hiddenRects$]).pipe((0, rxjs.map)(([rectWithOffset, hiddenRects]) => {
3172
3156
  const { top, left, bottom, right } = canvasElement.getBoundingClientRect();
3173
3157
  const insetTop = constrainToCanvas ? (boundaryInsets === null || boundaryInsets === void 0 ? void 0 : boundaryInsets.top) ?? 0 : 0;
3174
3158
  const insetLeft = constrainToCanvas ? (boundaryInsets === null || boundaryInsets === void 0 ? void 0 : boundaryInsets.left) ?? 0 : 0;
@@ -3215,7 +3199,7 @@ const SingleCanvasPopup = ({ popup, children }) => {
3215
3199
  };
3216
3200
  function CanvasPopup() {
3217
3201
  const popupService = (0, _wendellhu_redi_react_bindings.useDependency)(ICanvasPopupService);
3218
- return (0, _wendellhu_redi_react_bindings.useObservable)(popupService.popups$, void 0, true).map(([key, popup]) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SingleCanvasPopup, {
3202
+ return useObservable(popupService.popups$, void 0, true).map(([key, popup]) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SingleCanvasPopup, {
3219
3203
  popup,
3220
3204
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CanvasPopupContent, { popup })
3221
3205
  }, key));
@@ -3231,8 +3215,7 @@ function CanvasPopupContent({ popup }) {
3231
3215
  }) : content;
3232
3216
  }
3233
3217
 
3234
- //#endregion
3235
- //#region src/services/ribbon/ribbon-override.service.ts
3218
+ // src/services/ribbon/ribbon-override.service.ts
3236
3219
  const IRibbonOverrideService = (0, _univerjs_core.createIdentifier)("univer.ribbon-override-service");
3237
3220
  var RibbonOverrideService = class extends _univerjs_core.Disposable {
3238
3221
  constructor(..._args) {
@@ -3258,8 +3241,7 @@ var RibbonOverrideService = class extends _univerjs_core.Disposable {
3258
3241
  }
3259
3242
  };
3260
3243
 
3261
- //#endregion
3262
- //#region src/views/components/ComponentContainer.tsx
3244
+ // src/views/components/ComponentContainer.tsx
3263
3245
  function ComponentContainer(props) {
3264
3246
  const { components, fallback, sharedProps } = props;
3265
3247
  if (!components || components.size === 0) return fallback ?? null;
@@ -3281,9 +3263,9 @@ function useComponentsOfPart(part, injector) {
3281
3263
  const injectedUIPartsService = (0, _wendellhu_redi_react_bindings.useDependency)(IUIPartsService);
3282
3264
  const uiPartsService = (injector === null || injector === void 0 ? void 0 : injector.get(IUIPartsService)) ?? injectedUIPartsService;
3283
3265
  const uiVisibleChange$ = (0, react.useMemo)(() => uiPartsService.uiVisibleChange$.pipe((0, rxjs.filter)((ui) => ui.ui === part)), [part, uiPartsService]);
3284
- const changeInfo = (0, _wendellhu_redi_react_bindings.useObservable)(uiVisibleChange$);
3266
+ const changeInfo = useObservable(uiVisibleChange$);
3285
3267
  const updateCounterRef = (0, react.useRef)(0);
3286
- const componentPartUpdateCount = (0, _wendellhu_redi_react_bindings.useObservable)(() => uiPartsService.componentRegistered$.pipe((0, rxjs.filter)((key) => key === part), (0, rxjs.debounceTime)(200), (0, rxjs.map)(() => updateCounterRef.current += 1), (0, rxjs.startWith)(updateCounterRef.current += 1)), void 0, void 0, [
3268
+ const componentPartUpdateCount = useObservable(() => uiPartsService.componentRegistered$.pipe((0, rxjs.filter)((key) => key === part), (0, rxjs.debounceTime)(200), (0, rxjs.map)(() => updateCounterRef.current += 1), (0, rxjs.startWith)(updateCounterRef.current += 1)), void 0, void 0, [
3287
3269
  uiPartsService,
3288
3270
  part,
3289
3271
  changeInfo
@@ -3291,8 +3273,37 @@ function useComponentsOfPart(part, injector) {
3291
3273
  return (0, react.useMemo)(() => uiPartsService.isUIVisible(part) ? uiPartsService.getComponents(part) : /* @__PURE__ */ new Set(), [componentPartUpdateCount]);
3292
3274
  }
3293
3275
 
3294
- //#endregion
3295
- //#region src/views/components/ribbon/ribbon-menu/ClassicMenu.tsx
3276
+ // src/views/components/ribbon/ribbon-menu/use-ribbon-tabs.ts
3277
+ function useRibbonTabs(ribbon, onSelectTab) {
3278
+ const { direction } = (0, react.useContext)(_univerjs_design.ConfigContext);
3279
+ return (event) => {
3280
+ const tabs = Array.from(event.currentTarget.querySelectorAll("[role=\"tab\"]"));
3281
+ const index = tabs.indexOf(event.target);
3282
+ if (index < 0) return;
3283
+ let next;
3284
+ switch (event.key) {
3285
+ case "Home":
3286
+ next = 0;
3287
+ break;
3288
+ case "End":
3289
+ next = tabs.length - 1;
3290
+ break;
3291
+ case "ArrowLeft":
3292
+ next = (index + (direction === "rtl" ? 1 : -1) + tabs.length) % tabs.length;
3293
+ break;
3294
+ case "ArrowRight":
3295
+ next = (index + (direction === "rtl" ? -1 : 1) + tabs.length) % tabs.length;
3296
+ break;
3297
+ default: return;
3298
+ }
3299
+ event.preventDefault();
3300
+ event.stopPropagation();
3301
+ tabs[next].focus();
3302
+ onSelectTab(ribbon[next]);
3303
+ };
3304
+ }
3305
+
3306
+ // src/views/components/ribbon/ribbon-menu/ClassicMenu.tsx
3296
3307
  /**
3297
3308
  * Copyright 2023-present DreamNum Co., Ltd.
3298
3309
  *
@@ -3310,15 +3321,18 @@ function useComponentsOfPart(part, injector) {
3310
3321
  */
3311
3322
  function ClassicMenu({ ribbon, activatedTab, onSelectTab }) {
3312
3323
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
3324
+ const handleKeyDown = useRibbonTabs(ribbon, onSelectTab);
3313
3325
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3314
3326
  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",
3315
3327
  role: "tablist",
3328
+ onKeyDown: handleKeyDown,
3316
3329
  children: ribbon.map((group) => {
3317
3330
  const isActive = activatedTab === group.key;
3318
3331
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3319
3332
  type: "button",
3320
3333
  role: "tab",
3321
3334
  "aria-selected": isActive,
3335
+ tabIndex: isActive ? 0 : -1,
3322
3336
  title: localeService.t(group.title || group.key),
3323
3337
  onClick: () => onSelectTab(group),
3324
3338
  className: (0, _univerjs_design.clsx)("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 focus:univer-outline-none focus:univer-ring-2 focus:univer-ring-primary-500 dark:focus:!univer-ring-primary-300", isActive ? "univer-bg-primary-50 univer-font-semibold univer-text-primary-600 univer-shadow-sm dark:!univer-bg-primary-900 dark:!univer-text-primary-300" : "univer-bg-transparent univer-text-gray-700 hover:univer-bg-gray-100 dark:!univer-text-gray-200 dark:hover:!univer-bg-gray-700"),
@@ -3328,8 +3342,7 @@ function ClassicMenu({ ribbon, activatedTab, onSelectTab }) {
3328
3342
  });
3329
3343
  }
3330
3344
 
3331
- //#endregion
3332
- //#region src/views/components/ribbon/ribbon-menu/DefaultMenu.tsx
3345
+ // src/views/components/ribbon/ribbon-menu/DefaultMenu.tsx
3333
3346
  const iconMap = {
3334
3347
  ["ribbon.start"]: _univerjs_icons.HomeIcon,
3335
3348
  ["ribbon.insert"]: _univerjs_icons.InsertIcon,
@@ -3391,15 +3404,31 @@ function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
3391
3404
  });
3392
3405
  }
3393
3406
 
3394
- //#endregion
3395
- //#region src/views/components/ribbon/ribbon-menu/RibbonGridMenu.tsx
3407
+ // src/views/components/ribbon/ribbon-menu/RibbonGridMenu.tsx
3408
+ /**
3409
+ * Copyright 2023-present DreamNum Co., Ltd.
3410
+ *
3411
+ * Licensed under the Apache License, Version 2.0 (the "License");
3412
+ * you may not use this file except in compliance with the License.
3413
+ * You may obtain a copy of the License at
3414
+ *
3415
+ * http://www.apache.org/licenses/LICENSE-2.0
3416
+ *
3417
+ * Unless required by applicable law or agreed to in writing, software
3418
+ * distributed under the License is distributed on an "AS IS" BASIS,
3419
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3420
+ * See the License for the specific language governing permissions and
3421
+ * limitations under the License.
3422
+ */
3396
3423
  function RibbonGridMenu({ ribbon, activatedTab, onSelectTab }) {
3397
3424
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
3425
+ const handleKeyDown = useRibbonTabs(ribbon, onSelectTab);
3398
3426
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3399
3427
  "data-testid": "ribbon-grid-menu",
3400
3428
  "data-u-comp": "ribbon-grid-menu",
3401
3429
  className: "univer-flex univer-h-full univer-items-end univer-justify-start univer-overflow-x-auto univer-bg-gray-50 univer-px-2 dark:!univer-bg-gray-900",
3402
3430
  role: "tablist",
3431
+ onKeyDown: handleKeyDown,
3403
3432
  children: ribbon.map((group) => {
3404
3433
  const isActive = activatedTab === group.key;
3405
3434
  const title = localeService.t(group.title || group.key);
@@ -3407,6 +3436,7 @@ function RibbonGridMenu({ ribbon, activatedTab, onSelectTab }) {
3407
3436
  type: "button",
3408
3437
  role: "tab",
3409
3438
  "aria-selected": isActive,
3439
+ tabIndex: isActive ? 0 : -1,
3410
3440
  title,
3411
3441
  onClick: () => onSelectTab(group),
3412
3442
  className: (0, _univerjs_design.clsx)("univer-relative univer-flex univer-h-8 univer-cursor-pointer univer-items-center univer-whitespace-nowrap univer-border-0 univer-border-b-[3px] univer-bg-transparent univer-px-3 univer-text-sm univer-font-semibold univer-text-gray-700 univer-transition-colors hover:univer-text-gray-900 focus-visible:univer-outline-none focus-visible:univer-ring-2 focus-visible:univer-ring-inset focus-visible:univer-ring-primary-500 dark:!univer-text-gray-200 dark:hover:!univer-text-gray-0", isActive ? "univer-border-primary-600 univer-text-primary-700 dark:!univer-text-primary-300" : "univer-border-transparent"),
@@ -3416,8 +3446,7 @@ function RibbonGridMenu({ ribbon, activatedTab, onSelectTab }) {
3416
3446
  });
3417
3447
  }
3418
3448
 
3419
- //#endregion
3420
- //#region src/views/components/ribbon/ribbon-grid-layout.ts
3449
+ // src/views/components/ribbon/ribbon-grid-layout.ts
3421
3450
  const RIBBON_GRID_ROWS = 2;
3422
3451
  function placeRibbonGridItems(items) {
3423
3452
  const occupied = /* @__PURE__ */ new Set();
@@ -3445,6 +3474,7 @@ function placeRibbonGridItems(items) {
3445
3474
  columnSpan,
3446
3475
  showLabel: layout.showLabel ?? false,
3447
3476
  width: layout.width,
3477
+ minWidth: layout.minWidth,
3448
3478
  iconSize: layout.iconSize
3449
3479
  };
3450
3480
  if (cells.some((cell) => occupied.has(cell))) {
@@ -3470,13 +3500,25 @@ function placeRibbonGridItems(items) {
3470
3500
  columnSpan,
3471
3501
  showLabel: (layout === null || layout === void 0 ? void 0 : layout.showLabel) ?? false,
3472
3502
  width: layout === null || layout === void 0 ? void 0 : layout.width,
3503
+ minWidth: layout === null || layout === void 0 ? void 0 : layout.minWidth,
3473
3504
  iconSize: layout === null || layout === void 0 ? void 0 : layout.iconSize
3474
3505
  });
3475
3506
  }
3476
- return items.map((item) => placements.get(item));
3507
+ return items.map((item) => placements.get(item)).sort((a, b) => a.row - b.row || a.column - b.column);
3477
3508
  }
3478
3509
  function isValidGridGeometry(layout, rowSpan, cells) {
3479
- return cells.length > 0 && layout.row + rowSpan - 1 <= RIBBON_GRID_ROWS && (layout.width === void 0 || Number.isFinite(layout.width) && layout.width > 0) && (layout.iconSize === void 0 || Number.isFinite(layout.iconSize) && layout.iconSize > 0);
3510
+ return cells.length > 0 && layout.row + rowSpan - 1 <= RIBBON_GRID_ROWS && (layout.width === void 0 || Number.isFinite(layout.width) && layout.width > 0) && (layout.minWidth === void 0 || Number.isFinite(layout.minWidth) && layout.minWidth > 0 && layout.minWidth <= (layout.width ?? 0)) && (layout.iconSize === void 0 || Number.isFinite(layout.iconSize) && layout.iconSize > 0);
3511
+ }
3512
+ function groupRibbonOverflowItems(items) {
3513
+ const placements = placeRibbonGridItems(items);
3514
+ const groups = [];
3515
+ placements.forEach((placement, index) => {
3516
+ var _placement$item$item, _previous$item$item;
3517
+ const previous = placements[index - 1];
3518
+ if (!previous || placement.row !== previous.row || Boolean((_placement$item$item = placement.item.item) === null || _placement$item$item === void 0 ? void 0 : _placement$item$item.icon) !== Boolean((_previous$item$item = previous.item.item) === null || _previous$item$item === void 0 ? void 0 : _previous$item$item.icon)) groups.push([]);
3519
+ groups[groups.length - 1].push(placement.item);
3520
+ });
3521
+ return groups;
3480
3522
  }
3481
3523
  function findFirstAvailableCells(occupied, rowSpan, columnSpan) {
3482
3524
  for (let column = 1;; column++) for (let row = 1; row + rowSpan - 1 <= RIBBON_GRID_ROWS; row++) {
@@ -3500,8 +3542,7 @@ function getCells(row, column, rowSpan, columnSpan) {
3500
3542
  return cells;
3501
3543
  }
3502
3544
 
3503
- //#endregion
3504
- //#region src/views/components/ribbon/ToolbarButton.tsx
3545
+ // src/views/components/ribbon/ToolbarButton.tsx
3505
3546
  /**
3506
3547
  * Copyright 2023-present DreamNum Co., Ltd.
3507
3548
  *
@@ -3523,7 +3564,8 @@ univer-justify-center univer-rounded univer-border-none univer-bg-transparent un
3523
3564
  univer-text-gray-900 univer-outline-none univer-transition-colors univer-animate-in univer-fade-in
3524
3565
  dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-700 dark:disabled:!univer-text-gray-600
3525
3566
  disabled:univer-cursor-not-allowed disabled:univer-text-gray-300 disabled:hover:univer-bg-transparent
3526
- hover:univer-bg-gray-100 whitespace-nowrap univer-w-max
3567
+ hover:univer-bg-gray-100 univer-whitespace-nowrap univer-w-max
3568
+ focus-visible:univer-ring-2 focus-visible:univer-ring-inset focus-visible:univer-ring-primary-600
3527
3569
  [&_svg]:univer-shrink-0
3528
3570
  `;
3529
3571
  const toolbarButtonVariants = (0, _univerjs_design.cva)(toolbarButtonClassName, {
@@ -3577,8 +3619,7 @@ function ToolbarButton(props) {
3577
3619
  });
3578
3620
  }
3579
3621
 
3580
- //#endregion
3581
- //#region src/views/custom-label/CustomLabel.tsx
3622
+ // src/views/custom-label/CustomLabel.tsx
3582
3623
  /**
3583
3624
  * The component to render toolbar item label and menu item label.
3584
3625
  * @param props
@@ -3588,9 +3629,9 @@ function CustomLabel(props) {
3588
3629
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
3589
3630
  const componentManager = (0, _wendellhu_redi_react_bindings.useDependency)(ComponentManager);
3590
3631
  const iconManager = (0, _wendellhu_redi_react_bindings.useDependency)(IconManager);
3591
- const subscribedValue = (0, _wendellhu_redi_react_bindings.useObservable)(value$ ?? null, value);
3632
+ const subscribedValue = useObservable(value$ ?? null, value);
3592
3633
  const observableIcon = (0, rxjs.isObservable)(icon) ? icon : null;
3593
- const subscribedIcon = (0, _wendellhu_redi_react_bindings.useObservable)(observableIcon, "");
3634
+ const subscribedIcon = useObservable(observableIcon, "");
3594
3635
  const realIcon = (0, rxjs.isObservable)(icon) ? subscribedIcon : icon ?? "";
3595
3636
  const nodes = [];
3596
3637
  let index = 0;
@@ -3638,8 +3679,7 @@ function CustomLabel(props) {
3638
3679
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: nodes });
3639
3680
  }
3640
3681
 
3641
- //#endregion
3642
- //#region src/views/components/ribbon/hook.ts
3682
+ // src/views/components/ribbon/hook.ts
3643
3683
  /**
3644
3684
  * Subscribe to a menu item's status change and return the latest status.
3645
3685
  * @param menuItem The menu item
@@ -3655,16 +3695,16 @@ function useToolbarItemStatus(menuItem) {
3655
3695
  selectionsValue$ = selections === null || selections === void 0 || (_selections$ = selections[0]) === null || _selections$ === void 0 ? void 0 : _selections$.value$;
3656
3696
  }
3657
3697
  }
3658
- const disabled = (0, _wendellhu_redi_react_bindings.useObservable)(disabled$ ?? null, false);
3659
- const activated = (0, _wendellhu_redi_react_bindings.useObservable)(activated$ ?? null, false);
3660
- const hidden = (0, _wendellhu_redi_react_bindings.useObservable)(hidden$ ?? null, false);
3698
+ const disabled = useObservable(disabled$ ?? null, false);
3699
+ const activated = useObservable(activated$ ?? null, false);
3700
+ const hidden = useObservable(hidden$ ?? null, false);
3661
3701
  const valueObservable = (0, react.useMemo)(() => (0, rxjs.merge)(value$ ?? rxjs.EMPTY, selectionsValue$ ?? rxjs.EMPTY), [selectionsValue$, value$]);
3662
3702
  return {
3663
3703
  disabled,
3664
- value: (0, _wendellhu_redi_react_bindings.useObservable)(valueObservable),
3704
+ value: useObservable(valueObservable),
3665
3705
  activated,
3666
3706
  hidden,
3667
- selectionsValue: (0, _wendellhu_redi_react_bindings.useObservable)(selectionsValue$ ?? null)
3707
+ selectionsValue: useObservable(selectionsValue$ ?? null)
3668
3708
  };
3669
3709
  }
3670
3710
  function useToolbarShortcutDisplay({ id, commandId, shortcut }) {
@@ -3675,11 +3715,10 @@ function useToolbarShortcutDisplay({ id, commandId, shortcut }) {
3675
3715
  shortcutService,
3676
3716
  shortcutCommandId
3677
3717
  ]);
3678
- return (0, _wendellhu_redi_react_bindings.useObservable)(shortcut$, null, true);
3718
+ return useObservable(shortcut$, null, true);
3679
3719
  }
3680
3720
 
3681
- //#endregion
3682
- //#region src/services/font.service.ts
3721
+ // src/services/font.service.ts
3683
3722
  const IFontService = (0, _univerjs_core.createIdentifier)("univer.font-service");
3684
3723
  let FontCategory = /* @__PURE__ */ function(FontCategory) {
3685
3724
  FontCategory["SANS_SERIF"] = "sans-serif";
@@ -3970,22 +4009,20 @@ let FontService = class FontService {
3970
4009
  };
3971
4010
  FontService = __decorate([__decorateParam(0, _univerjs_core.IConfigService)], FontService);
3972
4011
 
3973
- //#endregion
3974
- //#region src/views/font-family/use-font-list.ts
4012
+ // src/views/font-family/use-font-list.ts
3975
4013
  function useFontList() {
3976
4014
  const fontService = (0, _wendellhu_redi_react_bindings.useDependency)(IFontService);
3977
4015
  return {
3978
- fonts: (0, _wendellhu_redi_react_bindings.useObservable)(fontService.fonts$, fontService.getFonts()),
4016
+ fonts: useObservable(fontService.fonts$, fontService.getFonts()),
3979
4017
  fontService
3980
4018
  };
3981
4019
  }
3982
4020
 
3983
- //#endregion
3984
- //#region src/views/font-family/FontFamilyItem.tsx
4021
+ // src/views/font-family/FontFamilyItem.tsx
3985
4022
  const FONT_FAMILY_ITEM_COMPONENT = "UI_FONT_FAMILY_ITEM_COMPONENT";
3986
4023
  const FontFamilyItem = ({ value, onChange }) => {
3987
4024
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
3988
- const direction = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$, localeService.getDirection());
4025
+ const direction = useObservable(localeService.direction$, localeService.getDirection());
3989
4026
  const { fonts, fontService } = useFontList();
3990
4027
  function handleSelectFont(nextValue) {
3991
4028
  onChange(nextValue);
@@ -4007,12 +4044,20 @@ const FontFamilyItem = ({ value, onChange }) => {
4007
4044
  });
4008
4045
  };
4009
4046
 
4010
- //#endregion
4011
- //#region src/views/components/ribbon/TooltipButtonWrapper.tsx
4047
+ // src/views/components/ribbon/TooltipButtonWrapper.tsx
4012
4048
  const TooltipWrapperContext = (0, react.createContext)({
4013
4049
  dropdownVisible: false,
4014
- setDropdownVisible: (_visible) => {}
4050
+ setDropdownVisible: (_visible) => {},
4051
+ restoreTriggerFocus: (_event) => {}
4015
4052
  });
4053
+ function ToolbarDropdownButton(props) {
4054
+ const { dropdownVisible } = (0, react.useContext)(TooltipWrapperContext);
4055
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4056
+ ...props,
4057
+ type: "button",
4058
+ "aria-expanded": dropdownVisible
4059
+ });
4060
+ }
4016
4061
  const ToolbarDropdownContext = (0, react.createContext)(null);
4017
4062
  /**
4018
4063
  * Keeps toolbar tooltips controlled while a related popup opens and closes.
@@ -4047,17 +4092,38 @@ function ToolbarDropdownProvider(props) {
4047
4092
  const TooltipWrapper = (0, react.forwardRef)((props, ref) => {
4048
4093
  const { children, dropdownKey, ...tooltipProps } = props;
4049
4094
  const spanRef = (0, react.useRef)(null);
4095
+ const triggerFocusRef = (0, react.useRef)(null);
4050
4096
  const [localDropdownVisible, setLocalDropdownVisible] = (0, react.useState)(false);
4051
4097
  const toolbarDropdownContext = (0, react.useContext)(ToolbarDropdownContext);
4052
4098
  const dropdownVisible = dropdownKey && toolbarDropdownContext ? toolbarDropdownContext.openDropdownKey === dropdownKey : localDropdownVisible;
4053
4099
  const handleChangeDropdownVisible = (0, react.useCallback)((visible) => {
4100
+ if (visible) {
4101
+ var _spanRef$current, _spanRef$current2;
4102
+ const active = (_spanRef$current = spanRef.current) === null || _spanRef$current === void 0 ? void 0 : _spanRef$current.ownerDocument.activeElement;
4103
+ triggerFocusRef.current = active instanceof HTMLElement && ((_spanRef$current2 = spanRef.current) === null || _spanRef$current2 === void 0 ? void 0 : _spanRef$current2.contains(active)) ? active : null;
4104
+ }
4054
4105
  if (dropdownKey && toolbarDropdownContext) toolbarDropdownContext.setOpenDropdownKey(visible ? dropdownKey : null);
4055
4106
  else setLocalDropdownVisible(visible);
4056
4107
  }, [dropdownKey, toolbarDropdownContext]);
4108
+ const restoreTriggerFocus = (0, react.useCallback)((event) => {
4109
+ const trigger = triggerFocusRef.current;
4110
+ triggerFocusRef.current = null;
4111
+ if (!(trigger === null || trigger === void 0 ? void 0 : trigger.isConnected)) return;
4112
+ const active = trigger.ownerDocument.activeElement;
4113
+ if (active === trigger.ownerDocument.body || event.target instanceof HTMLElement && event.target.contains(active)) {
4114
+ event.preventDefault();
4115
+ trigger.focus({ preventScroll: true });
4116
+ }
4117
+ }, []);
4057
4118
  const contextValue = (0, react.useMemo)(() => ({
4058
4119
  dropdownVisible,
4059
- setDropdownVisible: handleChangeDropdownVisible
4060
- }), [dropdownVisible, handleChangeDropdownVisible]);
4120
+ setDropdownVisible: handleChangeDropdownVisible,
4121
+ restoreTriggerFocus
4122
+ }), [
4123
+ dropdownVisible,
4124
+ handleChangeDropdownVisible,
4125
+ restoreTriggerFocus
4126
+ ]);
4061
4127
  (0, react.useImperativeHandle)(ref, () => ({ el: spanRef.current }));
4062
4128
  const content = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4063
4129
  ref: spanRef,
@@ -4075,7 +4141,7 @@ const TooltipWrapper = (0, react.forwardRef)((props, ref) => {
4075
4141
  function DropdownWrapper(props) {
4076
4142
  const { children, overlay, disabled, align, dropdownComponent: DropdownComponent = _univerjs_design.Dropdown } = props;
4077
4143
  const { direction } = (0, react.useContext)(_univerjs_design.ConfigContext);
4078
- const { dropdownVisible, setDropdownVisible } = (0, react.useContext)(TooltipWrapperContext);
4144
+ const { dropdownVisible, setDropdownVisible, restoreTriggerFocus } = (0, react.useContext)(TooltipWrapperContext);
4079
4145
  const triggerRef = (0, react.useRef)(null);
4080
4146
  const overlayRef = (0, react.useRef)(null);
4081
4147
  (0, react.useEffect)(() => {
@@ -4112,6 +4178,7 @@ function DropdownWrapper(props) {
4112
4178
  disabled,
4113
4179
  open: dropdownVisible,
4114
4180
  onOpenChange: handleVisibleChange,
4181
+ onCloseAutoFocus: restoreTriggerFocus,
4115
4182
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4116
4183
  ref: triggerRef,
4117
4184
  className: "univer-h-full",
@@ -4153,7 +4220,7 @@ function DropdownMenuLabel({ icon, value, option, preserveStrokeWidth, onOptionS
4153
4220
  });
4154
4221
  }
4155
4222
  function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled, preserveStrokeWidth, onOptionSelect, dropdownComponent, dropdownMenuComponent: DropdownMenuComponent = _univerjs_design.DropdownMenu }) {
4156
- const { dropdownVisible, setDropdownVisible } = (0, react.useContext)(TooltipWrapperContext);
4223
+ const { dropdownVisible, setDropdownVisible, restoreTriggerFocus } = (0, react.useContext)(TooltipWrapperContext);
4157
4224
  const shortcutService = (0, _wendellhu_redi_react_bindings.useDependency)(IShortcutService);
4158
4225
  const contextService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IContextService);
4159
4226
  const instanceService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IUniverInstanceService);
@@ -4201,7 +4268,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
4201
4268
  ]);
4202
4269
  const menuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
4203
4270
  const resolveMenuItems = () => menuId ? menuManagerService.getMenuByPositionKey(menuId) : [];
4204
- const menuItems = (0, _wendellhu_redi_react_bindings.useObservable)(() => menuManagerService.menuChanged$.pipe((0, rxjs.map)(resolveMenuItems), (0, rxjs.startWith)(resolveMenuItems())), resolveMenuItems(), false, [menuId, menuManagerService]);
4271
+ const menuItems = useObservable(() => menuManagerService.menuChanged$.pipe((0, rxjs.map)(resolveMenuItems), (0, rxjs.startWith)(resolveMenuItems())), resolveMenuItems(), false, [menuId, menuManagerService]);
4205
4272
  const hiddenStates$ = (0, react.useMemo)(() => {
4206
4273
  const itemStates = menuItems.map((item) => {
4207
4274
  var _item$item;
@@ -4215,7 +4282,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
4215
4282
  [key]: hidden
4216
4283
  }), {}), (0, rxjs.startWith)({})) : (0, rxjs.of)({});
4217
4284
  }, [menuItems]);
4218
- const hiddenStates = (0, _wendellhu_redi_react_bindings.useObservable)(hiddenStates$, {});
4285
+ const hiddenStates = useObservable(hiddenStates$, {});
4219
4286
  const filteredMenuItems = (0, react.useMemo)(() => {
4220
4287
  return menuItems.filter((item) => {
4221
4288
  var _item$key;
@@ -4254,6 +4321,10 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
4254
4321
  if (activeElement === document.body || focusInClosingMenu) layoutService.focus();
4255
4322
  return;
4256
4323
  }
4324
+ if (!editorFocus) {
4325
+ restoreTriggerFocus(event);
4326
+ return;
4327
+ }
4257
4328
  if (!(editorFocus === null || editorFocus === void 0 ? void 0 : editorFocus.element.isConnected) || getEmbedBoundaryOwner(editorFocus.element) !== editorFocus.owner) return;
4258
4329
  const activeElement = editorFocus.element.ownerDocument.activeElement;
4259
4330
  const focusInClosingMenu = event.target instanceof HTMLElement && event.target.contains(activeElement);
@@ -4421,17 +4492,16 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
4421
4492
  }
4422
4493
  }
4423
4494
 
4424
- //#endregion
4425
- //#region src/views/components/ribbon/ToolbarItem.tsx
4495
+ // src/views/components/ribbon/ToolbarItem.tsx
4426
4496
  const toolbarDisabledClassName = "univer-pointer-events-none univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-600";
4427
- const toolbarButtonSelectorRootVariants = (0, _univerjs_design.cva)("univer-toolbar-button-selector-root univer-animate-in univer-fade-in univer-group univer-relative univer-flex univer-h-6 univer-cursor-pointer univer-items-center univer-rounded univer-pr-5 univer-text-sm univer-transition-colors hover:univer-bg-gray-100 rtl:univer-pl-5 rtl:univer-pr-0 dark:hover:!univer-bg-gray-700", {
4497
+ const toolbarButtonSelectorRootVariants = (0, _univerjs_design.cva)("univer-toolbar-button-selector-root univer-animate-in univer-fade-in univer-group univer-relative univer-flex univer-h-7 univer-cursor-pointer univer-items-center univer-rounded univer-pr-6 univer-text-sm univer-transition-colors hover:univer-bg-gray-100 rtl:univer-pl-6 rtl:univer-pr-0 dark:hover:!univer-bg-gray-700", {
4428
4498
  variants: { disabled: {
4429
4499
  true: toolbarDisabledClassName,
4430
4500
  false: "univer-text-gray-900 dark:!univer-text-gray-0"
4431
4501
  } },
4432
4502
  defaultVariants: { disabled: false }
4433
4503
  });
4434
- const toolbarButtonSelectorMainVariants = (0, _univerjs_design.cva)("univer-toolbar-button-selector-main univer-relative univer-z-[1] univer-flex univer-h-full univer-items-center univer-rounded-l univer-px-1 univer-transition-colors hover:univer-bg-gray-200 rtl:univer-rounded-l-none rtl:univer-rounded-r dark:hover:!univer-bg-gray-600", {
4504
+ const toolbarButtonSelectorMainVariants = (0, _univerjs_design.cva)("univer-toolbar-button-selector-main univer-relative univer-z-[1] univer-flex univer-h-full univer-min-w-7 univer-items-center univer-justify-center univer-rounded-l univer-px-1 univer-transition-colors hover:univer-bg-gray-200 rtl:univer-rounded-l-none rtl:univer-rounded-r dark:hover:!univer-bg-gray-600", {
4435
4505
  variants: {
4436
4506
  active: {
4437
4507
  true: "univer-bg-gray-200 dark:!univer-bg-gray-500",
@@ -4452,7 +4522,7 @@ const toolbarButtonSelectorMainVariants = (0, _univerjs_design.cva)("univer-tool
4452
4522
  disabled: false
4453
4523
  }
4454
4524
  });
4455
- const toolbarButtonSelectorTriggerVariants = (0, _univerjs_design.cva)("univer-toolbar-button-selector-trigger univer-absolute univer-right-0 univer-top-0 univer-box-border univer-flex univer-h-6 univer-w-5 univer-items-center univer-justify-center univer-rounded-r univer-transition-colors hover:univer-bg-gray-200 rtl:univer-left-0 rtl:univer-right-auto rtl:univer-rounded-l rtl:univer-rounded-r-none dark:hover:!univer-bg-gray-600", {
4525
+ const toolbarButtonSelectorTriggerVariants = (0, _univerjs_design.cva)("univer-toolbar-button-selector-trigger univer-absolute univer-right-0 univer-top-0 univer-box-border univer-flex univer-h-7 univer-w-6 univer-items-center univer-justify-center univer-rounded-r univer-transition-colors hover:univer-bg-gray-200 rtl:univer-left-0 rtl:univer-right-auto rtl:univer-rounded-l rtl:univer-rounded-r-none dark:hover:!univer-bg-gray-600", {
4456
4526
  variants: {
4457
4527
  disabled: {
4458
4528
  true: toolbarDisabledClassName,
@@ -4473,7 +4543,7 @@ const toolbarButtonSelectorTriggerVariants = (0, _univerjs_design.cva)("univer-t
4473
4543
  active: false
4474
4544
  }
4475
4545
  });
4476
- const toolbarSelectorRootVariants = (0, _univerjs_design.cva)("univer-toolbar-selector-root univer-animate-in univer-fade-in univer-relative univer-flex univer-h-6 univer-cursor-pointer univer-items-center univer-gap-2 univer-whitespace-nowrap univer-rounded univer-px-1 univer-transition-colors hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700", {
4546
+ const toolbarSelectorRootVariants = (0, _univerjs_design.cva)("univer-toolbar-selector-root univer-animate-in univer-fade-in univer-relative univer-flex univer-h-7 univer-cursor-pointer univer-items-center univer-gap-1 univer-whitespace-nowrap univer-rounded univer-px-1 univer-transition-colors focus-within:univer-ring-2 focus-within:univer-ring-inset focus-within:univer-ring-primary-600 hover:univer-bg-gray-100 focus-visible:univer-outline-none focus-visible:univer-ring-2 focus-visible:univer-ring-inset focus-visible:univer-ring-primary-600 dark:hover:!univer-bg-gray-700", {
4477
4547
  variants: {
4478
4548
  disabled: {
4479
4549
  true: toolbarDisabledClassName,
@@ -4528,7 +4598,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
4528
4598
  subscribe.next(selections);
4529
4599
  });
4530
4600
  }, [selections]);
4531
- const options = (0, _wendellhu_redi_react_bindings.useObservable)(selections$);
4601
+ const options = useObservable(selections$);
4532
4602
  const icon$ = (0, react.useMemo)(() => {
4533
4603
  if ((0, rxjs.isObservable)(icon)) return icon;
4534
4604
  else return new rxjs.Observable((subscribe) => {
@@ -4541,13 +4611,14 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
4541
4611
  options,
4542
4612
  value
4543
4613
  ]);
4544
- const iconToDisplay = (0, _wendellhu_redi_react_bindings.useObservable)(icon$, void 0, true);
4614
+ const iconToDisplay = useObservable(icon$, void 0, true);
4545
4615
  function renderSelectorType(menuType) {
4546
4616
  const selectionsCommandId = props.selectionsCommandId;
4547
4617
  const bId = commandId ?? id;
4548
4618
  const sId = selectionsCommandId ?? commandId ?? id;
4549
4619
  const customLabelName = typeof label === "string" ? label : (label === null || label === void 0 ? void 0 : label.name) ?? "";
4550
4620
  const hasCustomLabel = Boolean(componentManager.get(customLabelName));
4621
+ const SelectorTrigger = hasCustomLabel ? ToolbarDropdownButton : "div";
4551
4622
  let titleToDisplay = grid ? showLabel ? gridLabel : large ? void 0 : title : title;
4552
4623
  if (overflow) titleToDisplay = hasCustomLabel || iconToDisplay && !showLabel ? void 0 : gridLabel;
4553
4624
  const selectorAriaLabel = tooltip ? localeService.t(tooltip) : typeof title === "string" ? localeService.t(title) : void 0;
@@ -4660,12 +4731,15 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
4660
4731
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4661
4732
  className: (0, _univerjs_design.clsx)(toolbarSelectorTriggerVariants({ disabled }), "univer-h-4 univer-justify-center univer-gap-0.5"),
4662
4733
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
4734
+ ariaLabel: selectorAriaLabel,
4663
4735
  title: titleToDisplay,
4664
4736
  value,
4665
4737
  label,
4666
4738
  onChange: handleSelectionsValueChange
4667
4739
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { preserveStrokeWidth })]
4668
4740
  })] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
4741
+ ariaLabel: selectorAriaLabel,
4742
+ className: fullWidth && hasCustomLabel ? "!univer-w-auto univer-min-w-0 univer-flex-1" : void 0,
4669
4743
  icon: iconToDisplay,
4670
4744
  iconSize,
4671
4745
  preserveStrokeWidth,
@@ -4673,8 +4747,11 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
4673
4747
  value,
4674
4748
  label,
4675
4749
  onChange: handleSelectionsValueChange
4676
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4677
- className: (0, _univerjs_design.clsx)(toolbarSelectorTriggerVariants({ disabled }), { "univer-ml-auto rtl:univer-ml-0 rtl:univer-mr-auto": grid && !large && !icon }),
4750
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectorTrigger, {
4751
+ disabled: hasCustomLabel ? disabled : void 0,
4752
+ "aria-label": hasCustomLabel ? selectorAriaLabel : void 0,
4753
+ "aria-haspopup": hasCustomLabel ? slot ? "dialog" : "menu" : void 0,
4754
+ className: (0, _univerjs_design.clsx)(toolbarSelectorTriggerVariants({ disabled }), { "univer-ml-auto rtl:univer-ml-0 rtl:univer-mr-auto": grid && !large && !icon }, "univer-w-6 univer-shrink-0 univer-justify-center", hasCustomLabel && "univer-h-7 univer-cursor-pointer univer-rounded univer-border-0 univer-bg-transparent univer-p-0 univer-text-inherit focus-visible:univer-outline-none focus-visible:univer-ring-2 focus-visible:univer-ring-inset focus-visible:univer-ring-primary-600"),
4678
4755
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { preserveStrokeWidth })
4679
4756
  })] })
4680
4757
  })
@@ -4683,7 +4760,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
4683
4760
  function renderButtonType() {
4684
4761
  const isCustomComponent = componentManager.get(typeof label === "string" ? label : (label === null || label === void 0 ? void 0 : label.name) ?? "");
4685
4762
  const buttonAriaLabel = tooltip ? localeService.t(tooltip) : typeof title === "string" ? localeService.t(title) : void 0;
4686
- const buttonClassName = (0, _univerjs_design.clsx)(grid && !large && "[&>svg]:univer-size-4", grid && large ? "univer-h-full univer-min-w-14 univer-flex-col univer-gap-1 univer-px-1.5 univer-py-1 univer-text-xs [&>svg]:univer-size-6" : showLabel ? "univer-gap-1 univer-px-1.5 univer-text-sm" : "univer-text-sm", grid && fullWidth && isCustomComponent && "!univer-px-0", overflow && "!univer-h-auto univer-min-h-7 univer-w-full univer-justify-start univer-gap-1.5 univer-whitespace-normal univer-px-1.5 univer-py-1 univer-text-start univer-text-xs focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600");
4763
+ const buttonClassName = (0, _univerjs_design.clsx)(grid && !large && "univer-min-w-7 [&>svg]:univer-size-4", grid && large ? "univer-h-full univer-min-w-14 univer-flex-col univer-gap-1 univer-px-1.5 univer-py-1 univer-text-xs [&>svg]:univer-size-6" : showLabel ? "univer-gap-1 univer-px-1.5 univer-text-sm" : "univer-text-sm", grid && fullWidth && isCustomComponent && "!univer-px-0", overflow && "!univer-h-auto univer-min-h-7 univer-w-full univer-justify-start univer-gap-1.5 univer-whitespace-normal univer-px-1.5 univer-py-1 univer-text-start univer-text-xs focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600");
4687
4764
  const buttonStyle = grid && large ? {
4688
4765
  textAlign: "center",
4689
4766
  whiteSpace: "normal"
@@ -4748,8 +4825,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
4748
4825
  });
4749
4826
  });
4750
4827
 
4751
- //#endregion
4752
- //#region src/views/components/ribbon/RibbonOverflow.tsx
4828
+ // src/views/components/ribbon/RibbonOverflow.tsx
4753
4829
  /**
4754
4830
  * Copyright 2023-present DreamNum Co., Ltd.
4755
4831
  *
@@ -4826,21 +4902,24 @@ function RibbonOverflow({ groups, grid = false }) {
4826
4902
  children: localeService.t(group.title)
4827
4903
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4828
4904
  className: "univer-flex univer-flex-wrap univer-items-center univer-gap-1",
4829
- children: (group.children ?? [group]).map((child) => {
4830
- var _child$gridLayout, _child$gridLayout2;
4831
- return child.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4832
- className: "univer-min-w-0 univer-max-w-full [&>span]:univer-block [&>span]:univer-h-full",
4833
- style: { width: child.item.label && !child.item.icon ? (_child$gridLayout = child.gridLayout) === null || _child$gridLayout === void 0 ? void 0 : _child$gridLayout.width : void 0 },
4834
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, {
4835
- ...child.item,
4836
- grid: true,
4837
- showLabel: (_child$gridLayout2 = child.gridLayout) === null || _child$gridLayout2 === void 0 ? void 0 : _child$gridLayout2.showLabel,
4838
- fullWidth: true,
4839
- overflow: true,
4840
- preserveStrokeWidth: true
4841
- })
4842
- }, child.key);
4843
- })
4905
+ children: (grid ? groupRibbonOverflowItems(group.children ?? [group]) : [group.children ?? [group]]).filter((items) => items.length > 0).map((items) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4906
+ className: "univer-flex univer-max-w-full univer-flex-wrap univer-items-center univer-gap-1",
4907
+ children: items.map((child) => {
4908
+ var _child$gridLayout, _child$gridLayout2, _child$gridLayout3;
4909
+ return child.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4910
+ className: "univer-min-w-0 univer-max-w-full [&>span]:univer-block [&>span]:univer-h-full",
4911
+ style: { maxWidth: child.item.label && !child.item.icon ? ((_child$gridLayout = child.gridLayout) === null || _child$gridLayout === void 0 ? void 0 : _child$gridLayout.minWidth) ?? ((_child$gridLayout2 = child.gridLayout) === null || _child$gridLayout2 === void 0 ? void 0 : _child$gridLayout2.width) : void 0 },
4912
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, {
4913
+ ...child.item,
4914
+ grid: true,
4915
+ showLabel: (_child$gridLayout3 = child.gridLayout) === null || _child$gridLayout3 === void 0 ? void 0 : _child$gridLayout3.showLabel,
4916
+ fullWidth: true,
4917
+ overflow: true,
4918
+ preserveStrokeWidth: true
4919
+ })
4920
+ }, child.key);
4921
+ })
4922
+ }, items[0].key))
4844
4923
  })]
4845
4924
  }, group.key))
4846
4925
  }) }),
@@ -4868,8 +4947,7 @@ function RibbonOverflow({ groups, grid = false }) {
4868
4947
  });
4869
4948
  }
4870
4949
 
4871
- //#endregion
4872
- //#region src/views/components/ribbon/RibbonGrid.tsx
4950
+ // src/views/components/ribbon/RibbonGrid.tsx
4873
4951
  function RibbonGrid({ groups, title, className, ...props }) {
4874
4952
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
4875
4953
  const containerRef = (0, react.useRef)(null);
@@ -4880,14 +4958,22 @@ function RibbonGrid({ groups, title, className, ...props }) {
4880
4958
  const container = containerRef.current;
4881
4959
  if (!container) return;
4882
4960
  const measure = () => {
4883
- var _moreRef$current;
4884
4961
  const style = getComputedStyle(container);
4885
- const availableWidth = container.clientWidth - Number.parseFloat(style.paddingLeft || "0") - Number.parseFloat(style.paddingRight || "0");
4886
- const widths = groups.map((group) => {
4887
- var _groupsRef$current$ge;
4888
- return ((_groupsRef$current$ge = groupsRef.current.get(group.key)) === null || _groupsRef$current$ge === void 0 ? void 0 : _groupsRef$current$ge.getBoundingClientRect().width) ?? 0;
4889
- });
4890
- const limit = widths.reduce((sum, width) => sum + width, 0) <= availableWidth ? availableWidth : availableWidth - (((_moreRef$current = moreRef.current) === null || _moreRef$current === void 0 ? void 0 : _moreRef$current.getBoundingClientRect().width) ?? 0);
4962
+ const availableWidth = Number.parseFloat(style.width) - [
4963
+ style.paddingLeft,
4964
+ style.paddingRight,
4965
+ style.borderLeftWidth,
4966
+ style.borderRightWidth
4967
+ ].reduce((sum, width) => sum + Number.parseFloat(width || "0"), 0);
4968
+ const getWidth = (element) => element ? Number.parseFloat(getComputedStyle(element).width) || 0 : 0;
4969
+ const getWidths = () => groups.map((group) => getWidth(groupsRef.current.get(group.key)));
4970
+ container.style.setProperty("--ribbon-grid-density", "0");
4971
+ let widths = getWidths();
4972
+ if (widths.reduce((sum, width) => sum + width, 0) > availableWidth) {
4973
+ container.style.setProperty("--ribbon-grid-density", "1");
4974
+ widths = getWidths();
4975
+ }
4976
+ const limit = widths.reduce((sum, width) => sum + width, 0) <= availableWidth ? availableWidth : availableWidth - getWidth(moreRef.current);
4891
4977
  let used = 0;
4892
4978
  let count = 0;
4893
4979
  for (const width of widths) {
@@ -4897,6 +4983,7 @@ function RibbonGrid({ groups, title, className, ...props }) {
4897
4983
  }
4898
4984
  setVisibleGroupCount(count);
4899
4985
  };
4986
+ measure();
4900
4987
  const observer = new ResizeObserver(measure);
4901
4988
  observer.observe(container);
4902
4989
  groupsRef.current.forEach((element) => observer.observe(element));
@@ -4924,16 +5011,18 @@ function RibbonGrid({ groups, title, className, ...props }) {
4924
5011
  "data-u-comp": "ribbon-grid-group",
4925
5012
  "data-group-key": group.key,
4926
5013
  "aria-hidden": index >= visibleGroupCount || void 0,
5014
+ style: { paddingInline: "calc(8px - 2px * var(--ribbon-grid-density, 0))" },
4927
5015
  className: (0, _univerjs_design.clsx)("univer-relative univer-box-border univer-flex univer-w-max univer-shrink-0 univer-flex-col univer-px-2", index >= visibleGroupCount && "univer-pointer-events-none univer-invisible univer-absolute"),
4928
5016
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4929
5017
  "data-testid": "ribbon-grid-group-grid",
4930
- className: "univer-grid univer-min-h-0 univer-flex-1 univer-grid-flow-col univer-grid-rows-[repeat(2,1.5rem)] univer-content-center univer-gap-2 univer-py-2 [&>div>span>span]:univer-h-full",
5018
+ className: "univer-grid univer-min-h-0 univer-flex-1 univer-grid-flow-col univer-grid-rows-[repeat(2,1.75rem)] univer-content-center univer-gap-y-0 univer-py-2 [&>div>span>span]:univer-h-full",
5019
+ style: { columnGap: "calc(8px - 4px * var(--ribbon-grid-density, 0))" },
4931
5020
  children: placements.map((placement) => placement.item.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4932
5021
  className: (0, _univerjs_design.clsx)("univer-flex univer-items-stretch [&>span>button]:univer-h-full [&>span]:univer-h-full", placement.width && "[&>span>span]:univer-w-full [&>span]:univer-w-full [&_[data-u-command]]:univer-w-full"),
4933
5022
  style: {
4934
5023
  gridRow: `${placement.row} / span ${placement.rowSpan}`,
4935
5024
  gridColumn: `${placement.column} / span ${placement.columnSpan}`,
4936
- width: placement.width
5025
+ width: placement.minWidth === void 0 ? placement.width : `calc(${placement.width}px - ${placement.width - placement.minWidth}px * var(--ribbon-grid-density, 0))`
4937
5026
  },
4938
5027
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, {
4939
5028
  ...placement.item.item,
@@ -4964,22 +5053,21 @@ function RibbonGrid({ groups, title, className, ...props }) {
4964
5053
  });
4965
5054
  }
4966
5055
 
4967
- //#endregion
4968
- //#region src/views/components/ribbon/Ribbon.tsx
5056
+ // src/views/components/ribbon/Ribbon.tsx
4969
5057
  function Ribbon(props) {
4970
5058
  const { ribbonType, headerMenuComponents, headerMenu = true, toolbarOnly = false, headerClassName } = props;
4971
5059
  const defaultRibbonService = (0, _wendellhu_redi_react_bindings.useDependency)(IRibbonService);
4972
5060
  const ribbonOverrideService = (0, _wendellhu_redi_react_bindings.useDependency)(IRibbonOverrideService);
4973
5061
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
4974
- const ribbonOverride = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonOverrideService.override$, ribbonOverrideService.getOverride());
5062
+ const ribbonOverride = useObservable(ribbonOverrideService.override$, ribbonOverrideService.getOverride());
4975
5063
  const ribbonService = (ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.ribbonService) ?? defaultRibbonService;
4976
5064
  const containerRef = (0, react.useRef)(null);
4977
5065
  const availableWidthRef = (0, react.useRef)(0);
4978
5066
  const toolbarItemsRef = (0, react.useRef)({});
4979
- const ribbonData = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonService.ribbon$, []);
4980
- const activatedTab = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonService.activatedTab$, "ribbon.start");
4981
- const collapsedIds = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonService.collapsedIds$, []);
4982
- const fakeToolbarVisible = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonService.fakeToolbarVisible$, false);
5067
+ const ribbonData = useObservable(ribbonService.ribbon$, []);
5068
+ const activatedTab = useObservable(ribbonService.activatedTab$, "ribbon.start");
5069
+ const collapsedIds = useObservable(ribbonService.collapsedIds$, []);
5070
+ const fakeToolbarVisible = useObservable(ribbonService.fakeToolbarVisible$, false);
4983
5071
  const hideToolbar = (ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.hideToolbar) === true;
4984
5072
  const ribbon = (0, react.useMemo)(() => {
4985
5073
  if (ribbonType === "simple") {
@@ -5212,8 +5300,7 @@ function RibbonOverrideConfigProvider(props) {
5212
5300
  });
5213
5301
  }
5214
5302
 
5215
- //#endregion
5216
- //#region src/services/theme-switcher/theme-switcher.service.ts
5303
+ // src/services/theme-switcher/theme-switcher.service.ts
5217
5304
  var ThemeSwitcherService = class extends _univerjs_core.Disposable {
5218
5305
  constructor(..._args) {
5219
5306
  super(..._args);
@@ -5246,8 +5333,7 @@ var ThemeSwitcherService = class extends _univerjs_core.Disposable {
5246
5333
  }
5247
5334
  };
5248
5335
 
5249
- //#endregion
5250
- //#region src/services/contextmenu/contextmenu.service.ts
5336
+ // src/services/contextmenu/contextmenu.service.ts
5251
5337
  const IContextMenuService = (0, _univerjs_core.createIdentifier)("ui.contextmenu.service");
5252
5338
  var ContextMenuService = class extends _univerjs_core.Disposable {
5253
5339
  constructor(..._args) {
@@ -5282,8 +5368,7 @@ var ContextMenuService = class extends _univerjs_core.Disposable {
5282
5368
  }
5283
5369
  };
5284
5370
 
5285
- //#endregion
5286
- //#region src/services/contextmenu/contextmenu-host.service.ts
5371
+ // src/services/contextmenu/contextmenu-host.service.ts
5287
5372
  const IContextMenuHostService = (0, _univerjs_core.createIdentifier)("ui.contextmenu.host.service");
5288
5373
  var ContextMenuHostService = class extends _univerjs_core.Disposable {
5289
5374
  constructor(..._args) {
@@ -5322,8 +5407,7 @@ var ContextMenuHostService = class extends _univerjs_core.Disposable {
5322
5407
  }
5323
5408
  };
5324
5409
 
5325
- //#endregion
5326
- //#region src/views/hooks/prevent-browser-zoom.ts
5410
+ // src/views/hooks/prevent-browser-zoom.ts
5327
5411
  /**
5328
5412
  * Copyright 2023-present DreamNum Co., Ltd.
5329
5413
  *
@@ -5368,8 +5452,7 @@ function preventBrowserZoomInContainers(containers) {
5368
5452
  };
5369
5453
  }
5370
5454
 
5371
- //#endregion
5372
- //#region src/views/menu/desktop/DesignTinyMenuGroup.tsx
5455
+ // src/views/menu/desktop/DesignTinyMenuGroup.tsx
5373
5456
  /**
5374
5457
  * Copyright 2023-present DreamNum Co., Ltd.
5375
5458
  *
@@ -5496,8 +5579,7 @@ function DesignTinyMenuGroup({ items, columns, sizeVariant = "default", layoutVa
5496
5579
  });
5497
5580
  }
5498
5581
 
5499
- //#endregion
5500
- //#region src/views/menu/desktop/TinyMenuGroup.tsx
5582
+ // src/views/menu/desktop/TinyMenuGroup.tsx
5501
5583
  /**
5502
5584
  * Copyright 2023-present DreamNum Co., Ltd.
5503
5585
  *
@@ -5548,9 +5630,9 @@ function QuickTileMenuItem(props) {
5548
5630
  const iconManager = (0, _wendellhu_redi_react_bindings.useDependency)(IconManager);
5549
5631
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
5550
5632
  const menuItem = menuSchema.item;
5551
- const disabled = (0, _wendellhu_redi_react_bindings.useObservable)(menuItem === null || menuItem === void 0 ? void 0 : menuItem.disabled$, false);
5552
- const hidden = (0, _wendellhu_redi_react_bindings.useObservable)(menuItem === null || menuItem === void 0 ? void 0 : menuItem.hidden$, false);
5553
- const activated = (0, _wendellhu_redi_react_bindings.useObservable)(menuItem === null || menuItem === void 0 ? void 0 : menuItem.activated$, false);
5633
+ const disabled = useObservable(menuItem === null || menuItem === void 0 ? void 0 : menuItem.disabled$, false);
5634
+ const hidden = useObservable(menuItem === null || menuItem === void 0 ? void 0 : menuItem.hidden$, false);
5635
+ const activated = useObservable(menuItem === null || menuItem === void 0 ? void 0 : menuItem.activated$, false);
5554
5636
  if (!menuItem || hidden) return null;
5555
5637
  const Icon = menuItem.icon ? iconManager.get(menuItem.icon) : null;
5556
5638
  const active = resolveMenuItemActiveState(menuItem.id, activated, activeItemIds);
@@ -5594,8 +5676,8 @@ function UITinyMenuGroup(props) {
5594
5676
  var _child$item3;
5595
5677
  return (((_child$item3 = child.item) === null || _child$item3 === void 0 ? void 0 : _child$item3.hidden$) ?? (0, rxjs.of)(false)).pipe((0, rxjs.startWith)(false));
5596
5678
  })).pipe((0, rxjs.map)((states) => children.flatMap((child, index) => states[index] ? [getTinyMenuChildStateKey(child)] : []))) : (0, rxjs.of)([]), [children]);
5597
- const activeItems = (0, _wendellhu_redi_react_bindings.useObservable)(activeItems$, []);
5598
- const hiddenItems = (0, _wendellhu_redi_react_bindings.useObservable)(hiddenItems$, []);
5679
+ const activeItems = useObservable(activeItems$, []);
5680
+ const hiddenItems = useObservable(hiddenItems$, []);
5599
5681
  const visibleChildren = (0, react.useMemo)(() => getVisibleTinyMenuChildren(item.children ?? [], [...hiddenItems, ...hiddenItemIds]), [
5600
5682
  hiddenItemIds,
5601
5683
  hiddenItems,
@@ -5648,8 +5730,7 @@ function UIQuickTileMenuGroup(props) {
5648
5730
  });
5649
5731
  }
5650
5732
 
5651
- //#endregion
5652
- //#region src/views/components/context-menu/ContextMenuPanel.tsx
5733
+ // src/views/components/context-menu/ContextMenuPanel.tsx
5653
5734
  const menuViewportPadding = 8;
5654
5735
  const submenuOverlapOffset = 2;
5655
5736
  const submenuVisualGap = 20;
@@ -5747,7 +5828,7 @@ const contextMenuSubmenuPanelVariants = (0, _univerjs_design.cva)("univer-overfl
5747
5828
  } },
5748
5829
  defaultVariants: { sizeVariant: "default" }
5749
5830
  });
5750
- const contextMenuItemVariants = (0, _univerjs_design.cva)("univer-relative univer-flex univer-border-none univer-bg-transparent univer-text-left univer-text-gray-900 dark:!univer-text-gray-0", {
5831
+ const contextMenuItemVariants = (0, _univerjs_design.cva)("univer-relative univer-flex univer-border-none univer-bg-transparent univer-text-left univer-text-gray-900 rtl:!univer-text-right dark:!univer-text-gray-0", {
5751
5832
  variants: {
5752
5833
  sizeVariant: {
5753
5834
  default: "",
@@ -5760,7 +5841,11 @@ const contextMenuItemVariants = (0, _univerjs_design.cva)("univer-relative unive
5760
5841
  },
5761
5842
  disabled: {
5762
5843
  true: "univer-cursor-not-allowed univer-opacity-60",
5763
- false: "univer-cursor-pointer focus:univer-bg-gray-50 focus:univer-outline-none dark:focus:!univer-bg-gray-600"
5844
+ false: "univer-cursor-pointer focus:univer-outline-none focus-visible:univer-ring-2 focus-visible:univer-ring-inset focus-visible:univer-ring-primary-500"
5845
+ },
5846
+ submenuOpen: {
5847
+ true: "univer-bg-gray-50 dark:!univer-bg-gray-600",
5848
+ false: ""
5764
5849
  },
5765
5850
  hoverSuppressed: {
5766
5851
  true: "",
@@ -5994,7 +6079,7 @@ function ContextMenuPanel(props) {
5994
6079
  });
5995
6080
  const [hoverSuppressed, setHoverSuppressed] = (0, react.useState)(suppressHoverUntilPointerMove);
5996
6081
  const menuSchemaVersion$ = (0, react.useMemo)(() => menuManagerService.menuChanged$.pipe((0, rxjs.startWith)(void 0), (0, rxjs.scan)((version) => version + 1, 0)), [menuManagerService]);
5997
- const menuSchemaVersion = (0, _wendellhu_redi_react_bindings.useObservable)(menuSchemaVersion$, 0);
6082
+ const menuSchemaVersion = useObservable(menuSchemaVersion$, 0);
5998
6083
  const menuItems = (0, react.useMemo)(() => menuType ? menuManagerService.getMenuByPositionKey(menuType) : [], [
5999
6084
  menuManagerService,
6000
6085
  menuType,
@@ -6085,7 +6170,7 @@ function ContextMenuPanel(props) {
6085
6170
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6086
6171
  ref: setMenuElement,
6087
6172
  tabIndex: -1,
6088
- className: (0, _univerjs_design.clsx)(getContextMenuPanelClassName(sizeVariant), _univerjs_design.borderClassName, _univerjs_design.scrollbarClassName, hoverSuppressed && "univer-context-menu-hover-suppressed", className),
6173
+ className: (0, _univerjs_design.clsx)(getContextMenuPanelClassName(sizeVariant), _univerjs_design.borderClassName, _univerjs_design.scrollbarClassName, hoverSuppressed && "[&_button:hover:not(:focus)]:!univer-bg-transparent", className),
6089
6174
  style: { maxHeight: maxMenuHeight },
6090
6175
  onKeyDown: handleKeyDown,
6091
6176
  onPointerMove: () => {
@@ -6115,6 +6200,7 @@ function ContextMenuMenu(props) {
6115
6200
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
6116
6201
  const hiddenGroupStates = useContextGroupHiddenStates$1(menuSchemas);
6117
6202
  const [activeSubmenuKey, setActiveSubmenuKey] = (0, react.useState)(null);
6203
+ const pointerGraceRef = (0, react.useRef)(null);
6118
6204
  const visibleSchemas = (0, react.useMemo)(() => {
6119
6205
  return menuSchemas.filter((item) => {
6120
6206
  if (!hasRenderableContextMenuSchema(item)) return false;
@@ -6166,6 +6252,7 @@ function ContextMenuMenu(props) {
6166
6252
  rootMenuElement,
6167
6253
  activeSubmenuKey,
6168
6254
  setActiveSubmenuKey,
6255
+ pointerGraceRef,
6169
6256
  onOptionSelect,
6170
6257
  maxMenuHeight,
6171
6258
  hiddenItemIds,
@@ -6187,6 +6274,7 @@ function ContextMenuMenu(props) {
6187
6274
  rootMenuElement,
6188
6275
  activeSubmenuKey,
6189
6276
  setActiveSubmenuKey,
6277
+ pointerGraceRef,
6190
6278
  activeItemIds,
6191
6279
  hiddenItemIds,
6192
6280
  hoverSuppressed,
@@ -6209,6 +6297,7 @@ function ContextMenuMenu(props) {
6209
6297
  rootMenuElement,
6210
6298
  activeSubmenuKey,
6211
6299
  setActiveSubmenuKey,
6300
+ pointerGraceRef,
6212
6301
  activeItemIds,
6213
6302
  hiddenItemIds,
6214
6303
  hoverSuppressed,
@@ -6238,6 +6327,7 @@ function ContextMenuMenu(props) {
6238
6327
  rootMenuElement,
6239
6328
  activeSubmenuKey,
6240
6329
  setActiveSubmenuKey,
6330
+ pointerGraceRef,
6241
6331
  activeItemIds,
6242
6332
  hiddenItemIds,
6243
6333
  hoverSuppressed,
@@ -6253,15 +6343,15 @@ function ContextMenuMenu(props) {
6253
6343
  }
6254
6344
  }
6255
6345
  function ContextMenuMenuItem(props) {
6256
- const { menuKey, menuItem, menuManagerService, menuSessionVersion, submenuPortalContainer, rootMenuElement, maxMenuHeight, activeSubmenuKey, setActiveSubmenuKey, activeItemIds, hiddenItemIds = [], hoverSuppressed = false, compact = false, headerAction = false, sizeVariant, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect } = props;
6346
+ const { menuKey, menuItem, menuManagerService, menuSessionVersion, submenuPortalContainer, rootMenuElement, maxMenuHeight, activeSubmenuKey, setActiveSubmenuKey, pointerGraceRef, activeItemIds, hiddenItemIds = [], hoverSuppressed = false, compact = false, headerAction = false, sizeVariant, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect } = props;
6257
6347
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
6258
- const direction = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$);
6259
- const disabled = (0, _wendellhu_redi_react_bindings.useObservable)(menuItem.disabled$, false);
6260
- const activated = (0, _wendellhu_redi_react_bindings.useObservable)(menuItem.activated$, false);
6261
- const hidden = (0, _wendellhu_redi_react_bindings.useObservable)(menuItem.hidden$, false);
6262
- const value = (0, _wendellhu_redi_react_bindings.useObservable)(menuItem.value$);
6348
+ const direction = useObservable(localeService.direction$);
6349
+ const disabled = useObservable(menuItem.disabled$, false);
6350
+ const activated = useObservable(menuItem.activated$, false);
6351
+ const hidden = useObservable(menuItem.hidden$, false);
6352
+ const value = useObservable(menuItem.value$);
6263
6353
  const selectorItem = menuItem;
6264
- const selectionsFromObservable = (0, _wendellhu_redi_react_bindings.useObservable)((0, rxjs.isObservable)(selectorItem.selections) ? selectorItem.selections : void 0);
6354
+ const selectionsFromObservable = useObservable((0, rxjs.isObservable)(selectorItem.selections) ? selectorItem.selections : void 0);
6265
6355
  const [inputValue, setInputValue] = (0, react.useState)(value);
6266
6356
  const [submenuPosition, setSubmenuPosition] = (0, react.useState)({
6267
6357
  left: 0,
@@ -6274,6 +6364,7 @@ function ContextMenuMenuItem(props) {
6274
6364
  const menuButtonRef = (0, react.useRef)(null);
6275
6365
  const submenuElementRef = (0, react.useRef)(null);
6276
6366
  const submenuCloseTimerRef = (0, react.useRef)(null);
6367
+ const pendingHoverActionRef = (0, react.useRef)(null);
6277
6368
  const submenuId = (0, react.useId)();
6278
6369
  const selections = (0, react.useMemo)(() => {
6279
6370
  if (menuItem.type !== 1 && menuItem.type !== 2) return [];
@@ -6299,10 +6390,14 @@ function ContextMenuMenuItem(props) {
6299
6390
  const submenuVisible = hasSubmenu && activeSubmenuKey === menuKey;
6300
6391
  const selectionsCommandId = selectorItem.selectionsCommandId;
6301
6392
  const clearSubmenuCloseTimer = (0, react.useCallback)(() => {
6302
- if (submenuCloseTimerRef.current == null) return;
6303
- clearTimeout(submenuCloseTimerRef.current);
6304
- submenuCloseTimerRef.current = null;
6305
- }, []);
6393
+ var _pointerGraceRef$curr;
6394
+ if (submenuCloseTimerRef.current != null) {
6395
+ clearTimeout(submenuCloseTimerRef.current);
6396
+ submenuCloseTimerRef.current = null;
6397
+ }
6398
+ pendingHoverActionRef.current = null;
6399
+ if (((_pointerGraceRef$curr = pointerGraceRef.current) === null || _pointerGraceRef$curr === void 0 ? void 0 : _pointerGraceRef$curr.menuKey) === menuKey) pointerGraceRef.current = null;
6400
+ }, [menuKey, pointerGraceRef]);
6306
6401
  const closeSubmenu = (0, react.useCallback)(() => {
6307
6402
  clearSubmenuCloseTimer();
6308
6403
  setActiveSubmenuKey((currentKey) => currentKey === menuKey ? null : currentKey);
@@ -6315,8 +6410,10 @@ function ContextMenuMenuItem(props) {
6315
6410
  clearSubmenuCloseTimer();
6316
6411
  submenuCloseTimerRef.current = setTimeout(() => {
6317
6412
  var _submenuElementRef$cu;
6318
- submenuCloseTimerRef.current = null;
6319
- if (!((_submenuElementRef$cu = submenuElementRef.current) === null || _submenuElementRef$cu === void 0 ? void 0 : _submenuElementRef$cu.contains(document.activeElement))) closeSubmenu();
6413
+ const pendingHoverAction = pendingHoverActionRef.current;
6414
+ clearSubmenuCloseTimer();
6415
+ if (pendingHoverAction) pendingHoverAction();
6416
+ else if (!((_submenuElementRef$cu = submenuElementRef.current) === null || _submenuElementRef$cu === void 0 ? void 0 : _submenuElementRef$cu.contains(document.activeElement))) closeSubmenu();
6320
6417
  }, 500);
6321
6418
  }, [clearSubmenuCloseTimer, closeSubmenu]);
6322
6419
  (0, react.useEffect)(() => {
@@ -6324,8 +6421,12 @@ function ContextMenuMenuItem(props) {
6324
6421
  }, [value]);
6325
6422
  (0, react.useEffect)(() => () => clearSubmenuCloseTimer(), [clearSubmenuCloseTimer]);
6326
6423
  (0, react.useEffect)(() => {
6327
- if (disabled) closeSubmenu();
6328
- }, [closeSubmenu, disabled]);
6424
+ if (disabled || !submenuVisible) closeSubmenu();
6425
+ }, [
6426
+ closeSubmenu,
6427
+ disabled,
6428
+ submenuVisible
6429
+ ]);
6329
6430
  (0, react.useEffect)(() => {
6330
6431
  const submenuElement = submenuElementRef.current;
6331
6432
  if (!submenuVisible || !submenuElement) return;
@@ -6395,11 +6496,27 @@ function ContextMenuMenuItem(props) {
6395
6496
  clearSubmenuCloseTimer();
6396
6497
  setActiveSubmenuKey((currentKey) => currentKey === menuKey ? null : currentKey);
6397
6498
  };
6499
+ const onPointerHover = (event) => {
6500
+ if (hoverSuppressed || hasSubmenu && disabled) return;
6501
+ const applyHover = () => {
6502
+ clearSubmenuCloseTimer();
6503
+ setKeyboardSubmenuFocusRequested(false);
6504
+ setActiveSubmenuKey(hasSubmenu ? menuKey : null);
6505
+ };
6506
+ const pointerGrace = pointerGraceRef.current;
6507
+ if (pointerGrace && pointerGrace.menuKey !== menuKey && pointerGrace.contains(event)) {
6508
+ pointerGrace.deferHover(applyHover);
6509
+ return;
6510
+ }
6511
+ pointerGrace === null || pointerGrace === void 0 || pointerGrace.cancel();
6512
+ applyHover();
6513
+ };
6398
6514
  const itemClassName = contextMenuItemVariants({
6399
6515
  sizeVariant,
6400
6516
  variant: compact ? headerAction ? "compactHeaderAction" : "compact" : "default",
6401
6517
  disabled,
6402
- hoverSuppressed,
6518
+ hoverSuppressed: hoverSuppressed || activeSubmenuKey !== null && !submenuVisible,
6519
+ submenuOpen: submenuVisible,
6403
6520
  active: resolveMenuItemActiveState(menuItem.id, activated, activeItemIds)
6404
6521
  });
6405
6522
  const contentNode = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
@@ -6419,27 +6536,38 @@ function ContextMenuMenuItem(props) {
6419
6536
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6420
6537
  ref: menuItemElementRef,
6421
6538
  className: "univer-relative",
6422
- onMouseEnter: () => {
6423
- clearSubmenuCloseTimer();
6424
- if (hasSubmenu && !disabled && !hoverSuppressed) {
6425
- setKeyboardSubmenuFocusRequested(false);
6426
- setSubmenuPositionReady(false);
6427
- setActiveSubmenuKey(menuKey);
6428
- return;
6429
- }
6430
- if (!hasSubmenu && !hoverSuppressed) setActiveSubmenuKey(null);
6431
- },
6539
+ onMouseEnter: onPointerHover,
6540
+ onMouseMove: onPointerHover,
6432
6541
  onMouseLeave: (event) => {
6433
- if (hasSubmenu) {
6434
- var _submenuElementRef$cu3, _submenuElementRef$cu4;
6542
+ if (submenuVisible) {
6543
+ var _submenuElementRef$cu3, _submenuElementRef$cu4, _submenuElementRef$cu5;
6435
6544
  if ((_submenuElementRef$cu3 = submenuElementRef.current) === null || _submenuElementRef$cu3 === void 0 ? void 0 : _submenuElementRef$cu3.contains(document.activeElement)) return;
6436
- const nextTarget = event.relatedTarget;
6545
+ const nextTarget = event.relatedTarget instanceof Node ? event.relatedTarget : null;
6437
6546
  if (nextTarget && ((_submenuElementRef$cu4 = submenuElementRef.current) === null || _submenuElementRef$cu4 === void 0 ? void 0 : _submenuElementRef$cu4.contains(nextTarget))) return;
6438
6547
  if (isContextMenuPointerLeaveTarget(nextTarget, menuItemElementRef.current, rootMenuElement)) {
6439
6548
  closeSubmenu();
6440
6549
  return;
6441
6550
  }
6442
6551
  scheduleSubmenuClose();
6552
+ const submenuRect = (_submenuElementRef$cu5 = submenuElementRef.current) === null || _submenuElementRef$cu5 === void 0 || (_submenuElementRef$cu5 = _submenuElementRef$cu5.firstElementChild) === null || _submenuElementRef$cu5 === void 0 ? void 0 : _submenuElementRef$cu5.getBoundingClientRect();
6553
+ if (submenuRect) {
6554
+ const { clientX: originX, clientY: originY } = event;
6555
+ const edgeX = submenuPlacement === "right" ? submenuRect.left : submenuRect.right;
6556
+ pointerGraceRef.current = {
6557
+ menuKey,
6558
+ contains: ({ clientX, clientY }) => {
6559
+ const progress = (clientX - originX) / (edgeX - originX);
6560
+ return progress >= 0 && progress <= 1 && clientY >= originY + (submenuRect.top - originY) * progress && clientY <= originY + (submenuRect.bottom - originY) * progress;
6561
+ },
6562
+ deferHover: (action) => {
6563
+ pendingHoverActionRef.current = action;
6564
+ },
6565
+ cancel: clearSubmenuCloseTimer
6566
+ };
6567
+ }
6568
+ } else {
6569
+ var _pointerGraceRef$curr2;
6570
+ (_pointerGraceRef$curr2 = pointerGraceRef.current) === null || _pointerGraceRef$curr2 === void 0 || _pointerGraceRef$curr2.deferHover(null);
6443
6571
  }
6444
6572
  },
6445
6573
  children: [renderAsContainer ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -6460,21 +6588,23 @@ function ContextMenuMenuItem(props) {
6460
6588
  "aria-expanded": hasSubmenu ? submenuVisible : void 0,
6461
6589
  "aria-controls": hasSubmenu ? submenuId : void 0,
6462
6590
  onKeyDown: (event) => {
6591
+ var _pointerGraceRef$curr3;
6463
6592
  const openDirection = direction === "rtl" ? "ArrowLeft" : "ArrowRight";
6464
6593
  if (!hasSubmenu || event.key !== openDirection) return;
6465
6594
  event.preventDefault();
6466
6595
  event.stopPropagation();
6596
+ (_pointerGraceRef$curr3 = pointerGraceRef.current) === null || _pointerGraceRef$curr3 === void 0 || _pointerGraceRef$curr3.cancel();
6467
6597
  clearSubmenuCloseTimer();
6468
6598
  setKeyboardSubmenuFocusRequested(true);
6469
- setSubmenuPositionReady(false);
6470
6599
  setActiveSubmenuKey(menuKey);
6471
6600
  },
6472
6601
  onClick: (event) => {
6602
+ var _pointerGraceRef$curr4;
6603
+ (_pointerGraceRef$curr4 = pointerGraceRef.current) === null || _pointerGraceRef$curr4 === void 0 || _pointerGraceRef$curr4.cancel();
6473
6604
  clearSubmenuCloseTimer();
6474
6605
  if (hasSubmenu) {
6475
6606
  if (headerAction) {
6476
6607
  setKeyboardSubmenuFocusRequested(event.detail === 0);
6477
- setSubmenuPositionReady(false);
6478
6608
  setActiveSubmenuKey(menuKey);
6479
6609
  return;
6480
6610
  }
@@ -6490,7 +6620,6 @@ function ContextMenuMenuItem(props) {
6490
6620
  return;
6491
6621
  }
6492
6622
  setKeyboardSubmenuFocusRequested(event.detail === 0);
6493
- setSubmenuPositionReady(false);
6494
6623
  setActiveSubmenuKey(menuKey);
6495
6624
  return;
6496
6625
  }
@@ -6530,9 +6659,9 @@ function ContextMenuMenuItem(props) {
6530
6659
  onMenuPointerEnter === null || onMenuPointerEnter === void 0 || onMenuPointerEnter();
6531
6660
  },
6532
6661
  onMouseLeave: (event) => {
6533
- var _submenuElementRef$cu5, _menuItemElementRef$c;
6534
- if ((_submenuElementRef$cu5 = submenuElementRef.current) === null || _submenuElementRef$cu5 === void 0 ? void 0 : _submenuElementRef$cu5.contains(document.activeElement)) return;
6535
- const nextTarget = event.relatedTarget;
6662
+ var _submenuElementRef$cu6, _menuItemElementRef$c;
6663
+ if ((_submenuElementRef$cu6 = submenuElementRef.current) === null || _submenuElementRef$cu6 === void 0 ? void 0 : _submenuElementRef$cu6.contains(document.activeElement)) return;
6664
+ const nextTarget = event.relatedTarget instanceof Node ? event.relatedTarget : null;
6536
6665
  if (nextTarget && ((_menuItemElementRef$c = menuItemElementRef.current) === null || _menuItemElementRef$c === void 0 ? void 0 : _menuItemElementRef$c.contains(nextTarget))) return;
6537
6666
  if (isContextMenuPointerLeaveTarget(nextTarget, menuItemElementRef.current, rootMenuElement)) {
6538
6667
  closeSubmenu();
@@ -6561,7 +6690,7 @@ function ContextMenuMenuItem(props) {
6561
6690
  const optionSelected = typeof inputValue !== "undefined" && String(inputValue) === String(option.value);
6562
6691
  const optionSelectable = !isNonSelectableLabel(option.label);
6563
6692
  const optionHoverable = !isNonHoverableLabel(option.label);
6564
- const optionClassName = (0, _univerjs_design.clsx)("univer-text-gray-900 dark:!univer-text-gray-0", optionSelectable ? sizeVariant === "paragraph-t" ? "univer-relative univer-box-border univer-flex univer-min-h-10 univer-w-full univer-items-center univer-rounded-lg univer-border-none univer-bg-transparent univer-px-3 univer-text-left univer-text-base" : "univer-relative univer-box-border univer-flex univer-min-h-8 univer-w-full univer-items-center univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm" : "univer-relative univer-box-border univer-block univer-w-full univer-border-none univer-bg-transparent univer-p-0", option.disabled ? "univer-cursor-not-allowed univer-opacity-60" : optionHoverable && "univer-cursor-pointer hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-600");
6693
+ const optionClassName = (0, _univerjs_design.clsx)("univer-text-gray-900 dark:!univer-text-gray-0", optionSelectable ? sizeVariant === "paragraph-t" ? "univer-relative univer-box-border univer-flex univer-min-h-10 univer-w-full univer-items-center univer-rounded-lg univer-border-none univer-bg-transparent univer-px-3 univer-text-left univer-text-base rtl:!univer-text-right" : "univer-relative univer-box-border univer-flex univer-min-h-8 univer-w-full univer-items-center univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm rtl:!univer-text-right" : "univer-relative univer-box-border univer-block univer-w-full univer-border-none univer-bg-transparent univer-p-0", option.disabled ? "univer-cursor-not-allowed univer-opacity-60" : optionHoverable && "univer-cursor-pointer hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-600");
6565
6694
  const optionContentNode = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [optionSelectable && optionSelected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CheckMarkIcon, { className: (0, _univerjs_design.clsx)("univer-absolute univer-left-0 univer-text-primary-600", sizeVariant === "paragraph-t" ? "univer-size-5" : "univer-size-4") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6566
6695
  className: (0, _univerjs_design.clsx)(getContextMenuContentClassName(sizeVariant), optionSelectable && optionSelected && "univer-pl-4"),
6567
6696
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
@@ -6633,11 +6762,10 @@ function useContextGroupHiddenStates$1(menuSchemas) {
6633
6762
  [key]: hidden
6634
6763
  }), {}), (0, rxjs.startWith)({})) : (0, rxjs.of)({});
6635
6764
  }, [menuSchemas]);
6636
- return (0, _wendellhu_redi_react_bindings.useObservable)(hiddenStates$, {});
6765
+ return useObservable(hiddenStates$, {});
6637
6766
  }
6638
6767
 
6639
- //#endregion
6640
- //#region src/views/components/context-menu/AnchoredContextMenu.tsx
6768
+ // src/views/components/context-menu/AnchoredContextMenu.tsx
6641
6769
  function AnchoredContextMenu(props) {
6642
6770
  const { hostId, visible, anchorRect, menuType, anchorVertical = "bottom", autoFocus, menuOffset = 0, menuManagerService, layoutService, onRequestClose, onOptionSelect } = props;
6643
6771
  const contentRef = (0, react.useRef)(null);
@@ -6752,8 +6880,7 @@ function AnchoredContextMenu(props) {
6752
6880
  });
6753
6881
  }
6754
6882
 
6755
- //#endregion
6756
- //#region src/views/components/context-menu/ContextMenu.tsx
6883
+ // src/views/components/context-menu/ContextMenu.tsx
6757
6884
  const DESKTOP_CONTEXT_MENU_HOST_ID = "desktop-context-menu";
6758
6885
  function DesktopContextMenu() {
6759
6886
  const [visible, setVisible] = (0, react.useState)(false);
@@ -6822,8 +6949,7 @@ function DesktopContextMenu() {
6822
6949
  });
6823
6950
  }
6824
6951
 
6825
- //#endregion
6826
- //#region src/views/components/sidebar/Sidebar.tsx
6952
+ // src/views/components/sidebar/Sidebar.tsx
6827
6953
  function renderSidebarOptions(options) {
6828
6954
  if (!options) return null;
6829
6955
  const { children, footer, header, ...rest } = options;
@@ -6844,7 +6970,7 @@ const MAX_SIDEBAR_WIDTH = 800;
6844
6970
  function Sidebar() {
6845
6971
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
6846
6972
  const sidebarService = (0, _wendellhu_redi_react_bindings.useDependency)(ISidebarService);
6847
- const sidebarOptions = (0, _wendellhu_redi_react_bindings.useObservable)(sidebarService.sidebarOptions$);
6973
+ const sidebarOptions = useObservable(sidebarService.sidebarOptions$);
6848
6974
  const scrollRef = (0, react.useRef)(null);
6849
6975
  const sidebarRef = (0, react.useRef)(null);
6850
6976
  const closeButtonRef = (0, react.useRef)(null);
@@ -7010,8 +7136,7 @@ function Sidebar() {
7010
7136
  });
7011
7137
  }
7012
7138
 
7013
- //#endregion
7014
- //#region src/views/components/workbench-skeleton/WorkbenchSkeleton.tsx
7139
+ // src/views/components/workbench-skeleton/WorkbenchSkeleton.tsx
7015
7140
  function WorkbenchSkeleton({ darkMode, direction, overlay = false }) {
7016
7141
  const shimmerClassName = `
7017
7142
  univer-animate-pulse univer-bg-gray-100 motion-reduce:univer-animate-none
@@ -7099,8 +7224,7 @@ function WorkbenchSkeleton({ darkMode, direction, overlay = false }) {
7099
7224
  });
7100
7225
  }
7101
7226
 
7102
- //#endregion
7103
- //#region src/views/hooks/layout.ts
7227
+ // src/views/hooks/layout.ts
7104
7228
  /**
7105
7229
  * These hooks are used for browser layout
7106
7230
  * Prefer to client-side
@@ -7142,11 +7266,10 @@ function useScrollYOverContainer(element, container) {
7142
7266
  }
7143
7267
  function useConfigValue(configKey) {
7144
7268
  const configService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IConfigService);
7145
- return (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => configService.subscribeConfigValue$(configKey), [configService]), configService.getConfig(configKey));
7269
+ return useObservable((0, react.useMemo)(() => configService.subscribeConfigValue$(configKey), [configService]), configService.getConfig(configKey));
7146
7270
  }
7147
7271
 
7148
- //#endregion
7149
- //#region src/views/hooks/update-effect.ts
7272
+ // src/views/hooks/update-effect.ts
7150
7273
  /**
7151
7274
  * Copyright 2023-present DreamNum Co., Ltd.
7152
7275
  *
@@ -7170,8 +7293,7 @@ const useUpdateEffect = (effect, deps) => {
7170
7293
  }, deps);
7171
7294
  };
7172
7295
 
7173
- //#endregion
7174
- //#region src/views/hooks/use-click-out-side.ts
7296
+ // src/views/hooks/use-click-out-side.ts
7175
7297
  function useClickOutSide(ref, opts) {
7176
7298
  const handler = useEvent(opts.handler);
7177
7299
  (0, react.useEffect)(() => {
@@ -7185,8 +7307,7 @@ function useClickOutSide(ref, opts) {
7185
7307
  }, [handler, ref]);
7186
7308
  }
7187
7309
 
7188
- //#endregion
7189
- //#region src/views/hooks/use-debounce.ts
7310
+ // src/views/hooks/use-debounce.ts
7190
7311
  /**
7191
7312
  * Copyright 2023-present DreamNum Co., Ltd.
7192
7313
  *
@@ -7212,8 +7333,7 @@ function useDebounceFn(fn, delay = 300) {
7212
7333
  }, [fn, delay]);
7213
7334
  }
7214
7335
 
7215
- //#endregion
7216
- //#region src/views/hooks/virtual-list.ts
7336
+ // src/views/hooks/virtual-list.ts
7217
7337
  const isNumber = (value) => typeof value === "number";
7218
7338
  function useLatest(value) {
7219
7339
  const ref = (0, react.useRef)(value);
@@ -7343,8 +7463,7 @@ const useVirtualList = (list, options) => {
7343
7463
  }];
7344
7464
  };
7345
7465
 
7346
- //#endregion
7347
- //#region src/views/workbench/Workbench.tsx
7466
+ // src/views/workbench/Workbench.tsx
7348
7467
  function DesktopWorkbench(props) {
7349
7468
  const uiConfig = useConfigValue(UI_PLUGIN_CONFIG_KEY);
7350
7469
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DesktopWorkbenchContent, {
@@ -7377,8 +7496,8 @@ function DesktopWorkbenchContent(props) {
7377
7496
  const leftSidebarComponents = useComponentsOfPart("left-sidebar");
7378
7497
  const globalComponents = useComponentsOfPart("global");
7379
7498
  const toolbarComponents = useComponentsOfPart("toolbar");
7380
- const lifecycleStage = (0, _wendellhu_redi_react_bindings.useObservable)(lifecycleService.lifecycle$, lifecycleService.stage);
7381
- const externalSkeletonVisible = (0, _wendellhu_redi_react_bindings.useObservable)(workbenchService.skeletonVisible$, void 0, true);
7499
+ const lifecycleStage = useObservable(lifecycleService.lifecycle$, lifecycleService.stage);
7500
+ const externalSkeletonVisible = useObservable(workbenchService.skeletonVisible$, void 0, true);
7382
7501
  const ready = lifecycleStage >= _univerjs_core.LifecycleStages.Ready;
7383
7502
  const popupRootId = (uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.popupRootId) ?? "univer-popup-portal";
7384
7503
  (0, react.useLayoutEffect)(() => {
@@ -7389,7 +7508,7 @@ function DesktopWorkbenchContent(props) {
7389
7508
  sub.unsubscribe();
7390
7509
  };
7391
7510
  }, []);
7392
- const darkMode = (0, _wendellhu_redi_react_bindings.useObservable)(themeService.darkMode$, themeService.darkMode);
7511
+ const darkMode = useObservable(themeService.darkMode$, themeService.darkMode);
7393
7512
  (0, react.useLayoutEffect)(() => {
7394
7513
  if (darkMode) document.documentElement.classList.add("univer-dark");
7395
7514
  else document.documentElement.classList.remove("univer-dark");
@@ -7397,8 +7516,8 @@ function DesktopWorkbenchContent(props) {
7397
7516
  (0, react.useEffect)(() => {
7398
7517
  if (ready && contentRef.current) onRendered === null || onRendered === void 0 || onRendered(contentRef.current);
7399
7518
  }, [ready, onRendered]);
7400
- const locale = (0, _wendellhu_redi_react_bindings.useObservable)(() => localeService.localeChanged$.pipe((0, rxjs.map)(() => localeService.getLocales())), localeService.getLocales(), false, [localeService]);
7401
- const direction = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$, localeService.getDirection());
7519
+ const locale = useObservable(() => localeService.localeChanged$.pipe((0, rxjs.map)(() => localeService.getLocales())), localeService.getLocales(), false, [localeService]);
7520
+ const direction = useObservable(localeService.direction$, localeService.getDirection());
7402
7521
  const portalContainer = (0, react.useMemo)(() => document.createElement("div"), []);
7403
7522
  (0, react.useEffect)(() => {
7404
7523
  document.body.appendChild(portalContainer);
@@ -7493,8 +7612,7 @@ function FloatingContainer() {
7493
7612
  return (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentContainer, { components: floatingComponents }, "floating"), mountContainer);
7494
7613
  }
7495
7614
 
7496
- //#endregion
7497
- //#region src/controllers/ui/ui-shared.controller.ts
7615
+ // src/controllers/ui/ui-shared.controller.ts
7498
7616
  const STEADY_TIMEOUT = 3e3;
7499
7617
  /**
7500
7618
  * @ignore
@@ -7576,8 +7694,7 @@ var SingleUnitUIController = class extends _univerjs_core.Disposable {
7576
7694
  }
7577
7695
  };
7578
7696
 
7579
- //#endregion
7580
- //#region src/controllers/ui/ui-desktop.controller.ts
7697
+ // src/controllers/ui/ui-desktop.controller.ts
7581
7698
  let DesktopUIController = class DesktopUIController extends SingleUnitUIController {
7582
7699
  constructor(_config, injector, lifecycleService, renderManagerService, layoutService, instanceService, menuManagerService, uiPartsService) {
7583
7700
  super(injector, instanceService, layoutService, lifecycleService, renderManagerService);
@@ -7631,17 +7748,14 @@ function createContainer$1(id) {
7631
7748
  return element;
7632
7749
  }
7633
7750
 
7634
- //#endregion
7635
- //#region src/controllers/ui/ui.controller.ts
7751
+ // src/controllers/ui/ui.controller.ts
7636
7752
  const IUIController = (0, _univerjs_core.createIdentifier)("univer.ui.ui-controller");
7637
7753
 
7638
- //#endregion
7639
- //#region package.json
7754
+ // package.json
7640
7755
  var name = "@univerjs/ui";
7641
- var version = "1.3.0";
7756
+ var version = "1.4.0";
7642
7757
 
7643
- //#endregion
7644
- //#region src/views/color-picker/interface.ts
7758
+ // src/views/color-picker/interface.ts
7645
7759
  /**
7646
7760
  * Copyright 2023-present DreamNum Co., Ltd.
7647
7761
  *
@@ -7659,8 +7773,7 @@ var version = "1.3.0";
7659
7773
  */
7660
7774
  const COLOR_PICKER_COMPONENT = "UI_COLOR_PICKER_COMPONENT";
7661
7775
 
7662
- //#endregion
7663
- //#region src/views/CommonLabel.tsx
7776
+ // src/views/CommonLabel.tsx
7664
7777
  /**
7665
7778
  * Copyright 2023-present DreamNum Co., Ltd.
7666
7779
  *
@@ -7691,8 +7804,7 @@ const CommonLabel = (props) => {
7691
7804
  };
7692
7805
  const COMMON_LABEL_COMPONENT = "UI_PLUGIN_COMMON_LABEL_COMPONENT";
7693
7806
 
7694
- //#endregion
7695
- //#region src/views/emoji-picker/emojis.generated.ts
7807
+ // src/views/emoji-picker/emojis.generated.ts
7696
7808
  const emojis = {
7697
7809
  "frequent": [
7698
7810
  {
@@ -23112,8 +23224,7 @@ const emojis = {
23112
23224
  ]
23113
23225
  };
23114
23226
 
23115
- //#endregion
23116
- //#region src/views/emoji-picker/emoji-picker-utils.ts
23227
+ // src/views/emoji-picker/emoji-picker-utils.ts
23117
23228
  const EMOJI_SKIN_TONES = [
23118
23229
  "",
23119
23230
  "🏻",
@@ -23278,8 +23389,7 @@ function getEmojiFamilies() {
23278
23389
  return EMOJI_CATEGORIES.flatMap((category) => emojis[category.key]);
23279
23390
  }
23280
23391
 
23281
- //#endregion
23282
- //#region src/views/emoji-picker/EmojiPicker.tsx
23392
+ // src/views/emoji-picker/EmojiPicker.tsx
23283
23393
  const EMOJI_PICKER_COMPONENT = "ui.emoji-picker";
23284
23394
  const RECENTS_STORAGE_KEY = "univer.ui.recent-emojis";
23285
23395
  const SKIN_TONE_STORAGE_KEY = "univer.ui.emoji-skin-tone";
@@ -23294,7 +23404,7 @@ function EmojiPicker(props) {
23294
23404
  const extraProps = (_props$popup = props.popup) === null || _props$popup === void 0 ? void 0 : _props$popup.extraProps;
23295
23405
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
23296
23406
  const localStorageService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.ILocalStorageService);
23297
- const currentLocale = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.currentLocale$, localeService.getCurrentLocale());
23407
+ const currentLocale = useObservable(localeService.currentLocale$, localeService.getCurrentLocale());
23298
23408
  const scrollRef = (0, react.useRef)(void 0);
23299
23409
  const pendingSectionRef = (0, react.useRef)(null);
23300
23410
  const skinToneChangedRef = (0, react.useRef)(false);
@@ -23671,8 +23781,7 @@ function CategoryIcon(props) {
23671
23781
  }
23672
23782
  }
23673
23783
 
23674
- //#endregion
23675
- //#region src/views/emoji-picker/MobileEmojiPicker.tsx
23784
+ // src/views/emoji-picker/MobileEmojiPicker.tsx
23676
23785
  function MobileEmojiPicker(props) {
23677
23786
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EmojiPicker, {
23678
23787
  ...props,
@@ -23680,11 +23789,10 @@ function MobileEmojiPicker(props) {
23680
23789
  });
23681
23790
  }
23682
23791
 
23683
- //#endregion
23684
- //#region src/views/font-family/FontFamily.tsx
23792
+ // src/views/font-family/FontFamily.tsx
23685
23793
  const FONT_FAMILY_COMPONENT = "UI_FONT_FAMILY_COMPONENT";
23686
- const FontFamily = ({ className, disabled: disabledProp, value, disabled$, onChange }) => {
23687
- const disabledObservableValue = (0, _wendellhu_redi_react_bindings.useObservable)(disabled$);
23794
+ const FontFamily = ({ className, disabled: disabledProp, value, disabled$, onChange, ariaLabel }) => {
23795
+ const disabledObservableValue = useObservable(disabled$);
23688
23796
  const disabled = Boolean(disabledProp || disabledObservableValue);
23689
23797
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
23690
23798
  const { fonts } = useFontList();
@@ -23743,7 +23851,8 @@ const FontFamily = ({ className, disabled: disabledProp, value, disabled$, onCha
23743
23851
  className: (0, _univerjs_design.clsx)("univer-w-32 univer-truncate univer-text-sm", className),
23744
23852
  style: { fontFamily: value },
23745
23853
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
23746
- className: "univer-block univer-h-6 univer-border-none univer-bg-transparent univer-leading-6 univer-text-gray-900 focus:univer-outline-none dark:!univer-text-gray-0 [&_input:focus]:!univer-ring-0 [&_input]:univer-h-6 [&_input]:univer-w-7 [&_input]:univer-border-none [&_input]:!univer-bg-transparent [&_input]:univer-p-0 [&_input]:univer-text-sm",
23854
+ "aria-label": ariaLabel,
23855
+ className: "univer-block univer-h-6 univer-w-full univer-min-w-0 univer-border-none univer-bg-transparent univer-leading-6 univer-text-gray-900 focus:univer-outline-none dark:!univer-text-gray-0 [&_input:focus]:!univer-ring-0 [&_input]:univer-h-6 [&_input]:univer-w-7 [&_input]:univer-border-none [&_input]:!univer-bg-transparent [&_input]:univer-p-0 [&_input]:univer-text-sm",
23747
23856
  type: "text",
23748
23857
  value: inputValue,
23749
23858
  onPointerDown: (event) => event.stopPropagation(),
@@ -23755,11 +23864,10 @@ const FontFamily = ({ className, disabled: disabledProp, value, disabled$, onCha
23755
23864
  });
23756
23865
  };
23757
23866
 
23758
- //#endregion
23759
- //#region src/views/font-size/FontSize.tsx
23867
+ // src/views/font-size/FontSize.tsx
23760
23868
  const FontSize = (props) => {
23761
- const { value, min, max, onChange, disabled$ } = props;
23762
- const disabled = (0, _wendellhu_redi_react_bindings.useObservable)(disabled$);
23869
+ const { value, min, max, onChange, disabled$, ariaLabel } = props;
23870
+ const disabled = useObservable(disabled$);
23763
23871
  const [draft, setDraft] = (0, react.useState)(null);
23764
23872
  const inputValue = draft !== null && draft.source === value ? draft.value : Number(value ?? 0);
23765
23873
  if (draft !== null && draft.source !== value) setDraft(null);
@@ -23787,6 +23895,7 @@ const FontSize = (props) => {
23787
23895
  className: "univer-h-6 univer-w-7 univer-text-sm",
23788
23896
  onPointerDown: (event) => event.stopPropagation(),
23789
23897
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
23898
+ "aria-label": ariaLabel,
23790
23899
  className: "univer-block univer-h-6 univer-border-none univer-bg-transparent univer-leading-6 [&_input:focus]:!univer-ring-0 [&_input]:univer-h-6 [&_input]:univer-w-7 [&_input]:univer-border-none [&_input]:!univer-bg-transparent [&_input]:univer-p-0 [&_input]:univer-text-sm",
23791
23900
  value: inputValue,
23792
23901
  controls: false,
@@ -23798,8 +23907,7 @@ const FontSize = (props) => {
23798
23907
  });
23799
23908
  };
23800
23909
 
23801
- //#endregion
23802
- //#region src/views/font-size/interface.ts
23910
+ // src/views/font-size/interface.ts
23803
23911
  const FONT_SIZE_LIST = [
23804
23912
  {
23805
23913
  label: "9",
@@ -23898,8 +24006,7 @@ const HEADING_LIST = [
23898
24006
  ];
23899
24007
  const FONT_SIZE_COMPONENT = "UI_FONT_SIZE_COMPONENT";
23900
24008
 
23901
- //#endregion
23902
- //#region src/views/HeadingItem.tsx
24009
+ // src/views/HeadingItem.tsx
23903
24010
  const HeadingItem = (props) => {
23904
24011
  var _style$cl;
23905
24012
  const { value, text } = props;
@@ -23916,8 +24023,7 @@ const HeadingItem = (props) => {
23916
24023
  };
23917
24024
  const HEADING_ITEM_COMPONENT = "UI_COMPONENT_HEADING_ITEM";
23918
24025
 
23919
- //#endregion
23920
- //#region src/views/symbol-picker/symbols.ts
24026
+ // src/views/symbol-picker/symbols.ts
23921
24027
  const SYMBOL_CATEGORIES = [
23922
24028
  {
23923
24029
  key: "mathematics",
@@ -24089,14 +24195,13 @@ const SYMBOL_CATEGORIES = [
24089
24195
  }
24090
24196
  ];
24091
24197
 
24092
- //#endregion
24093
- //#region src/views/symbol-picker/SymbolPicker.tsx
24198
+ // src/views/symbol-picker/SymbolPicker.tsx
24094
24199
  const SYMBOL_PICKER_COMPONENT = "ui.symbol-picker";
24095
24200
  function SymbolPicker(props) {
24096
24201
  var _props$popup;
24097
24202
  const extraProps = (_props$popup = props.popup) === null || _props$popup === void 0 ? void 0 : _props$popup.extraProps;
24098
24203
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
24099
- (0, _wendellhu_redi_react_bindings.useObservable)(localeService.currentLocale$, localeService.getCurrentLocale());
24204
+ useObservable(localeService.currentLocale$, localeService.getCurrentLocale());
24100
24205
  const [activeSymbol, setActiveSymbol] = (0, react.useState)(extraProps === null || extraProps === void 0 ? void 0 : extraProps.activeSymbol);
24101
24206
  const handleSelect = (symbol) => {
24102
24207
  var _props$onChange, _extraProps$onSelect;
@@ -24145,8 +24250,7 @@ function SymbolSection(props) {
24145
24250
  });
24146
24251
  }
24147
24252
 
24148
- //#endregion
24149
- //#region src/controllers/mobile/components.controller.ts
24253
+ // src/controllers/mobile/components.controller.ts
24150
24254
  /**
24151
24255
  * Copyright 2023-present DreamNum Co., Ltd.
24152
24256
  *
@@ -24199,8 +24303,7 @@ let MobileComponentsController = class MobileComponentsController extends _unive
24199
24303
  };
24200
24304
  MobileComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(IconManager))], MobileComponentsController);
24201
24305
 
24202
- //#endregion
24203
- //#region src/menu/mobile-schema.ts
24306
+ // src/menu/mobile-schema.ts
24204
24307
  const mobileMenuSchema = { ["ribbon.start.history"]: {
24205
24308
  [_univerjs_core.UndoCommand.id]: {
24206
24309
  order: 0,
@@ -24222,8 +24325,7 @@ const mobileMenuSchema = { ["ribbon.start.history"]: {
24222
24325
  }
24223
24326
  } };
24224
24327
 
24225
- //#endregion
24226
- //#region src/views/components/ribbon/MobileToolbarItem.tsx
24328
+ // src/views/components/ribbon/MobileToolbarItem.tsx
24227
24329
  const MobileToolbarItem = (0, react.forwardRef)((props, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, {
24228
24330
  ...props,
24229
24331
  ref,
@@ -24234,16 +24336,15 @@ const MobileToolbarItem = (0, react.forwardRef)((props, ref) => /* @__PURE__ */
24234
24336
  dropdownMenuComponent: _univerjs_design.MobileDropdownMenu
24235
24337
  }));
24236
24338
 
24237
- //#endregion
24238
- //#region src/views/components/ribbon/MobileRibbon.tsx
24339
+ // src/views/components/ribbon/MobileRibbon.tsx
24239
24340
  const toolbarScrollOffset = 168;
24240
24341
  function MobileRibbon(props) {
24241
24342
  const { headerMenuComponents, headerMenu = true } = props;
24242
24343
  const ribbonService = (0, _wendellhu_redi_react_bindings.useDependency)(IRibbonService);
24243
24344
  const workbenchService = (0, _wendellhu_redi_react_bindings.useDependency)(IWorkbenchService);
24244
- const ribbon = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonService.ribbon$, []);
24245
- const activatedTab = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonService.activatedTab$, "ribbon.start");
24246
- const rootUnitType = (0, _wendellhu_redi_react_bindings.useObservable)(workbenchService.rootUnitType$, null, true);
24345
+ const ribbon = useObservable(ribbonService.ribbon$, []);
24346
+ const activatedTab = useObservable(ribbonService.activatedTab$, "ribbon.start");
24347
+ const rootUnitType = useObservable(workbenchService.rootUnitType$, null, true);
24247
24348
  if (rootUnitType === _univerjs_core.UniverInstanceType.UNIVER_SHEET || rootUnitType === _univerjs_core.UniverInstanceType.UNIVER_DOC) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileCompactTopBar, {
24248
24349
  ribbon,
24249
24350
  headerMenu,
@@ -24501,8 +24602,7 @@ function MobileCompactTopBar(props) {
24501
24602
  }), moreMenu] });
24502
24603
  }
24503
24604
 
24504
- //#endregion
24505
- //#region src/views/menu/mobile/MobileMenu.tsx
24605
+ // src/views/menu/mobile/MobileMenu.tsx
24506
24606
  function MobileMenu(props) {
24507
24607
  var _props$schemas;
24508
24608
  const schemaKey = ((_props$schemas = props.schemas) === null || _props$schemas === void 0 ? void 0 : _props$schemas.map((schema) => schema.key).join("|")) ?? "";
@@ -24517,7 +24617,7 @@ function MobileMenuContent(props) {
24517
24617
  const menuSchemaVersion$ = (0, react.useMemo)(() => {
24518
24618
  return menuManagerService.menuChanged$.pipe((0, rxjs_operators.scan)((version) => version + 1, 0), (0, rxjs_operators.startWith)(0));
24519
24619
  }, [menuManagerService]);
24520
- (0, _wendellhu_redi_react_bindings.useObservable)(menuSchemaVersion$, 0);
24620
+ useObservable(menuSchemaVersion$, 0);
24521
24621
  const menuSchemas = providedSchemas ?? (menuType ? menuManagerService.getMenuByPositionKey(menuType) : []);
24522
24622
  const currentView = viewStack[viewStack.length - 1] ?? null;
24523
24623
  const closeView = (0, react.useCallback)(() => setViewStack((stack) => stack.slice(0, -1)), []);
@@ -24689,8 +24789,8 @@ function MobileContextMenuItem(props) {
24689
24789
  }
24690
24790
  function MobileContextMenuOption(props) {
24691
24791
  const { option, menuKey, menuItem, currentValue, inheritedDisabled$, onExecute } = props;
24692
- const inheritedDisabled = (0, _wendellhu_redi_react_bindings.useObservable)(inheritedDisabled$, false);
24693
- const observableValue = (0, _wendellhu_redi_react_bindings.useObservable)(option.value$);
24792
+ const inheritedDisabled = useObservable(inheritedDisabled$, false);
24793
+ const observableValue = useObservable(option.value$);
24694
24794
  const displayValue = option.value ?? observableValue;
24695
24795
  const disabled = inheritedDisabled || Boolean(option.disabled);
24696
24796
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
@@ -24874,7 +24974,7 @@ function MobileSchemaRow(props) {
24874
24974
  }
24875
24975
  function MobileSelectionOptionsView(props) {
24876
24976
  const { options, menuKey, menuItem, currentValue, inheritedDisabled$, onExecute } = props;
24877
- const inheritedDisabled = (0, _wendellhu_redi_react_bindings.useObservable)(inheritedDisabled$, false);
24977
+ const inheritedDisabled = useObservable(inheritedDisabled$, false);
24878
24978
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: options.map((option, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileSelectionOptionRow, {
24879
24979
  option,
24880
24980
  menuKey,
@@ -24888,7 +24988,7 @@ function MobileSelectionOptionsView(props) {
24888
24988
  function MobileSelectionOptionRow(props) {
24889
24989
  const { option, menuKey, menuItem, currentValue, disabled, bordered, onExecute } = props;
24890
24990
  const componentManager = (0, _wendellhu_redi_react_bindings.useDependency)(ComponentManager);
24891
- const optionValue = (0, _wendellhu_redi_react_bindings.useObservable)(option.value$);
24991
+ const optionValue = useObservable(option.value$);
24892
24992
  const displayValue = option.value ?? optionValue;
24893
24993
  const selected = displayValue === currentValue;
24894
24994
  const optionDisabled = disabled || Boolean(option.disabled);
@@ -24948,14 +25048,14 @@ function useMobileSchemaInteraction(props) {
24948
25048
  const sources = [inheritedDisabled$, menuItem === null || menuItem === void 0 ? void 0 : menuItem.disabled$].filter((source) => Boolean(source));
24949
25049
  return sources.length ? (0, rxjs.combineLatest)(sources.map((source) => source.pipe((0, rxjs_operators.startWith)(false)))).pipe((0, rxjs.map)((states) => states.some(Boolean))) : void 0;
24950
25050
  }, [inheritedDisabled$, menuItem === null || menuItem === void 0 ? void 0 : menuItem.disabled$]);
24951
- const disabled = (0, _wendellhu_redi_react_bindings.useObservable)(disabled$, false);
24952
- const hidden = (0, _wendellhu_redi_react_bindings.useObservable)(menuItem === null || menuItem === void 0 ? void 0 : menuItem.hidden$, false);
24953
- const activated = (0, _wendellhu_redi_react_bindings.useObservable)(menuItem === null || menuItem === void 0 ? void 0 : menuItem.activated$, false);
24954
- const value = (0, _wendellhu_redi_react_bindings.useObservable)(menuItem === null || menuItem === void 0 ? void 0 : menuItem.value$);
24955
- const selectionsFromObservable = (0, _wendellhu_redi_react_bindings.useObservable)(selectorItem && (0, rxjs.isObservable)(selectorItem.selections) ? selectorItem.selections : void 0);
25051
+ const disabled = useObservable(disabled$, false);
25052
+ const hidden = useObservable(menuItem === null || menuItem === void 0 ? void 0 : menuItem.hidden$, false);
25053
+ const activated = useObservable(menuItem === null || menuItem === void 0 ? void 0 : menuItem.activated$, false);
25054
+ const value = useObservable(menuItem === null || menuItem === void 0 ? void 0 : menuItem.value$);
25055
+ const selectionsFromObservable = useObservable(selectorItem && (0, rxjs.isObservable)(selectorItem.selections) ? selectorItem.selections : void 0);
24956
25056
  const schemaChildren = (0, react.useMemo)(() => schema.children ?? [], [schema.children]);
24957
25057
  const visibleSchemaChildren$ = (0, react.useMemo)(() => getVisibleSchemaCount$(schemaChildren), [schemaChildren]);
24958
- const visibleSchemaChildren = (0, _wendellhu_redi_react_bindings.useObservable)(visibleSchemaChildren$, schemaChildren.length);
25058
+ const visibleSchemaChildren = useObservable(visibleSchemaChildren$, schemaChildren.length);
24959
25059
  const selections = (0, react.useMemo)(() => {
24960
25060
  if (!selectorItem || (menuItem === null || menuItem === void 0 ? void 0 : menuItem.type) !== 1 && (menuItem === null || menuItem === void 0 ? void 0 : menuItem.type) !== 2) return [];
24961
25061
  if (selectionsFromObservable) return selectionsFromObservable;
@@ -25063,7 +25163,7 @@ function useContextGroupHiddenStates(menuSchemas) {
25063
25163
  [key]: hidden
25064
25164
  }), {}), (0, rxjs_operators.startWith)({})) : (0, rxjs.of)({});
25065
25165
  }, [menuSchemas]);
25066
- return (0, _wendellhu_redi_react_bindings.useObservable)(hiddenStates$, {});
25166
+ return useObservable(hiddenStates$, {});
25067
25167
  }
25068
25168
  function getLeafItemSchemas(schemas) {
25069
25169
  return schemas.reduce((acc, schema) => {
@@ -25074,8 +25174,7 @@ function getLeafItemSchemas(schemas) {
25074
25174
  }, []);
25075
25175
  }
25076
25176
 
25077
- //#endregion
25078
- //#region src/views/mobile-workbench/MobileCanvasLayout.tsx
25177
+ // src/views/mobile-workbench/MobileCanvasLayout.tsx
25079
25178
  const MobileCanvasLayoutContext = (0, react.createContext)(null);
25080
25179
  function MobileCanvasLayoutProvider({ children }) {
25081
25180
  const [panels, setPanels] = (0, react.useState)([]);
@@ -25248,8 +25347,7 @@ function useMobileCanvasViewport(options) {
25248
25347
  ]);
25249
25348
  }
25250
25349
 
25251
- //#endregion
25252
- //#region src/views/components/mobile-drawer/MobileDrawerCoordinator.tsx
25350
+ // src/views/components/mobile-drawer/MobileDrawerCoordinator.tsx
25253
25351
  const MobileDrawerCoordinatorContext = (0, react.createContext)(null);
25254
25352
  function MobileDrawerCoordinatorProvider(props) {
25255
25353
  const entriesRef = (0, react.useRef)([]);
@@ -25297,14 +25395,14 @@ function MobileDrawerCoordinatorProvider(props) {
25297
25395
  });
25298
25396
  }
25299
25397
 
25300
- //#endregion
25301
- //#region src/views/components/mobile-drawer/MobileDrawer.tsx
25398
+ // src/views/components/mobile-drawer/MobileDrawer.tsx
25302
25399
  function assignDrawerRef(ref, element) {
25303
25400
  if (typeof ref === "function") ref(element);
25304
25401
  else if (ref) ref.current = element;
25305
25402
  }
25306
25403
  const MOBILE_DRAWER_COMPACT_PERCENT = 40;
25307
25404
  const MOBILE_DRAWER_EXPANDED_PERCENT = 80;
25405
+ const MOBILE_DIALOG_MAX_PERCENT = 60;
25308
25406
  const MobileDrawerLayoutContext = (0, react.createContext)("modal");
25309
25407
  function resolveMobileDrawerRelease(params) {
25310
25408
  const { snap, deltaY, durationMs, percent } = params;
@@ -25316,7 +25414,7 @@ function resolveMobileDrawerRelease(params) {
25316
25414
  }
25317
25415
  function MobileDrawer(props) {
25318
25416
  var _globalThis$CSS;
25319
- const { snap, expandLabel, collapseLabel, onSnapChange, onClose, children, header, floatingActions, componentName = "mobile-drawer", panelRef, contentRef, layerRef, openMode = "replace", panelClassName, contentClassName, footer, role, ariaLabel, layout: requestedLayout } = props;
25417
+ const { snap, expandLabel, collapseLabel, onSnapChange, onClose, children, header, floatingActions, componentName = "mobile-drawer", panelRef, contentRef, layerRef, openMode = "replace", panelClassName, contentClassName, footer, role, ariaLabel, layout: requestedLayout, autoHeight = false } = props;
25320
25418
  const coordinator = (0, react.useContext)(MobileDrawerCoordinatorContext);
25321
25419
  const registerDrawer = coordinator === null || coordinator === void 0 ? void 0 : coordinator.register;
25322
25420
  const unregisterDrawer = coordinator === null || coordinator === void 0 ? void 0 : coordinator.unregister;
@@ -25359,6 +25457,7 @@ function MobileDrawer(props) {
25359
25457
  const dragRef = (0, react.useRef)(null);
25360
25458
  const drawerPercent = dragPercent ?? (snap === "compact" ? MOBILE_DRAWER_COMPACT_PERCENT : MOBILE_DRAWER_EXPANDED_PERCENT);
25361
25459
  const keyboardLayout = (0, _univerjs_design.useMobileKeyboardViewportLayout)(panelElementRef);
25460
+ const contentMaxHeight = keyboardLayout ? `min(${MOBILE_DIALOG_MAX_PERCENT}${viewportHeightUnit}, ${keyboardLayout.availableHeight}px)` : `${MOBILE_DIALOG_MAX_PERCENT}${viewportHeightUnit}`;
25362
25461
  (0, react.useLayoutEffect)(() => {
25363
25462
  if (!registerDrawer || !unregisterDrawer) return;
25364
25463
  registerDrawer(drawerId, openMode, () => onCloseRef.current());
@@ -25466,13 +25565,15 @@ function MobileDrawer(props) {
25466
25565
  "data-snap": snap,
25467
25566
  className: (0, _univerjs_design.clsx)("univer-absolute univer-inset-x-0 univer-bottom-0 univer-z-20 univer-flex univer-flex-col univer-overflow-hidden univer-rounded-t-[24px] univer-bg-gray-50 univer-shadow-2xl univer-transition-[height] univer-duration-200 dark:!univer-bg-gray-900 [&_input]:!univer-text-base [&_select]:!univer-text-base [&_textarea]:!univer-text-base", "univer-pointer-events-auto", dragPercent != null && "!univer-transition-none", panelClassName),
25468
25567
  style: {
25469
- height: `${drawerPercent}${viewportHeightUnit}`,
25568
+ height: autoHeight ? "auto" : `${drawerPercent}${viewportHeightUnit}`,
25569
+ maxHeight: autoHeight ? contentMaxHeight : void 0,
25570
+ bottom: autoHeight ? keyboardLayout === null || keyboardLayout === void 0 ? void 0 : keyboardLayout.bottom : void 0,
25470
25571
  paddingBottom: "env(safe-area-inset-bottom, 0px)"
25471
25572
  },
25472
25573
  children: [
25473
25574
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
25474
- className: "univer-relative univer-flex univer-h-14 univer-shrink-0 univer-items-end univer-bg-gray-0 dark:!univer-bg-gray-800",
25475
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
25575
+ className: (0, _univerjs_design.clsx)("univer-relative univer-flex univer-shrink-0 univer-items-end univer-bg-gray-0 dark:!univer-bg-gray-800", autoHeight ? "univer-h-12" : "univer-h-14"),
25576
+ children: [!autoHeight && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
25476
25577
  type: "button",
25477
25578
  "aria-label": snap === "compact" ? expandLabel : collapseLabel,
25478
25579
  className: (0, _univerjs_design.clsx)(_univerjs_design.resetButtonClassName, "univer-absolute univer-left-1/2 univer-top-0 univer-z-10 univer-flex univer-h-6 univer-w-16 -univer-translate-x-1/2 univer-touch-none univer-items-center univer-justify-center"),
@@ -25497,8 +25598,8 @@ function MobileDrawer(props) {
25497
25598
  }),
25498
25599
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
25499
25600
  ref: contentRef,
25500
- className: (0, _univerjs_design.clsx)("univer-flex-1 univer-overflow-y-auto univer-overflow-x-hidden univer-p-3", _univerjs_design.scrollbarClassName, contentClassName),
25501
- style: { paddingBottom: keyboardLayout ? `calc(0.75rem + ${keyboardLayout.bottom}px)` : void 0 },
25601
+ className: (0, _univerjs_design.clsx)("univer-overflow-y-auto univer-overflow-x-hidden univer-p-3", autoHeight ? "univer-min-h-0 univer-flex-initial" : "univer-flex-1", _univerjs_design.scrollbarClassName, contentClassName),
25602
+ style: { paddingBottom: !autoHeight && keyboardLayout ? `calc(0.75rem + ${keyboardLayout.bottom}px)` : void 0 },
25502
25603
  children
25503
25604
  }),
25504
25605
  footer
@@ -25508,8 +25609,7 @@ function MobileDrawer(props) {
25508
25609
  });
25509
25610
  }
25510
25611
 
25511
- //#endregion
25512
- //#region src/views/menu/mobile/MobileMenuDrawer.tsx
25612
+ // src/views/menu/mobile/MobileMenuDrawer.tsx
25513
25613
  function MobileMenuDrawer(props) {
25514
25614
  if (!props.visible) return null;
25515
25615
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileMenuDrawerContent, { ...props });
@@ -25520,7 +25620,7 @@ function MobileMenuDrawerContent(props) {
25520
25620
  const [drawerSnap, setDrawerSnap] = (0, react.useState)("compact");
25521
25621
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
25522
25622
  const rootMenuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
25523
- const direction = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$);
25623
+ const direction = useObservable(localeService.direction$);
25524
25624
  const { mountContainer } = (0, react.useContext)(_univerjs_design.ConfigContext);
25525
25625
  const layerRef = (0, react.useRef)(null);
25526
25626
  if (!mountContainer) return null;
@@ -25582,8 +25682,7 @@ function MobileMenuDrawerContent(props) {
25582
25682
  }), mountContainer);
25583
25683
  }
25584
25684
 
25585
- //#endregion
25586
- //#region src/views/components/context-menu/MobileContextMenu.tsx
25685
+ // src/views/components/context-menu/MobileContextMenu.tsx
25587
25686
  const MOBILE_CONTEXT_MENU_HOST_ID = "mobile-context-menu";
25588
25687
  const MOBILE_CONTEXT_MENU_POINTER_SIZE = 8;
25589
25688
  const MOBILE_CONTEXT_MENU_POINTER_EDGE_GAP = 12;
@@ -25770,12 +25869,11 @@ function MobileContextMenu() {
25770
25869
  });
25771
25870
  }
25772
25871
 
25773
- //#endregion
25774
- //#region src/views/components/sidebar/MobileSidebar.tsx
25872
+ // src/views/components/sidebar/MobileSidebar.tsx
25775
25873
  function MobileSidebar() {
25776
25874
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
25777
25875
  const sidebarService = (0, _wendellhu_redi_react_bindings.useDependency)(ISidebarService);
25778
- const sidebarOptions = (0, _wendellhu_redi_react_bindings.useObservable)(sidebarService.sidebarOptions$);
25876
+ const sidebarOptions = useObservable(sidebarService.sidebarOptions$);
25779
25877
  const layerRef = (0, react.useRef)(null);
25780
25878
  const scrollRef = (0, react.useRef)(null);
25781
25879
  const closeButtonRef = (0, react.useRef)(null);
@@ -25853,8 +25951,7 @@ function MobileSidebar() {
25853
25951
  });
25854
25952
  }
25855
25953
 
25856
- //#endregion
25857
- //#region src/views/mobile-workbench/mobile-keyboard-inset-context.ts
25954
+ // src/views/mobile-workbench/mobile-keyboard-inset-context.ts
25858
25955
  /**
25859
25956
  * Copyright 2023-present DreamNum Co., Ltd.
25860
25957
  *
@@ -25872,8 +25969,7 @@ function MobileSidebar() {
25872
25969
  */
25873
25970
  const MobileKeyboardInsetContext = (0, react.createContext)(0);
25874
25971
 
25875
- //#endregion
25876
- //#region src/views/mobile-workbench/MobileWorkbench.tsx
25972
+ // src/views/mobile-workbench/MobileWorkbench.tsx
25877
25973
  const MOBILE_KEYBOARD_THRESHOLD = 80;
25878
25974
  function resolveMobileKeyboardInset(stableHeight, visibleBottom, baselineInset) {
25879
25975
  const keyboardInset = Math.max(0, Math.round(stableHeight - visibleBottom) - baselineInset);
@@ -25909,15 +26005,15 @@ function MobileWorkbench(props) {
25909
26005
  const leftSidebarComponents = useComponentsOfPart("left-sidebar");
25910
26006
  const globalComponents = useComponentsOfPart("global");
25911
26007
  const toolbarComponents = useComponentsOfPart("toolbar");
25912
- const darkMode = (0, _wendellhu_redi_react_bindings.useObservable)(themeService.darkMode$, themeService.darkMode);
25913
- const lifecycleStage = (0, _wendellhu_redi_react_bindings.useObservable)(lifecycleService.lifecycle$, lifecycleService.stage);
25914
- const externalSkeletonVisible = (0, _wendellhu_redi_react_bindings.useObservable)(workbenchService.skeletonVisible$, void 0, true);
26008
+ const darkMode = useObservable(themeService.darkMode$, themeService.darkMode);
26009
+ const lifecycleStage = useObservable(lifecycleService.lifecycle$, lifecycleService.stage);
26010
+ const externalSkeletonVisible = useObservable(workbenchService.skeletonVisible$, void 0, true);
25915
26011
  const ready = lifecycleStage >= _univerjs_core.LifecycleStages.Ready;
25916
26012
  (0, react.useEffect)(() => {
25917
26013
  if (ready && contentRef.current) onRendered === null || onRendered === void 0 || onRendered(contentRef.current);
25918
26014
  }, [ready, onRendered]);
25919
- const locale = (0, _wendellhu_redi_react_bindings.useObservable)(() => localeService.localeChanged$.pipe((0, rxjs.map)(() => localeService.getLocales())), localeService.getLocales(), false, [localeService]);
25920
- const direction = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$, localeService.getDirection());
26015
+ const locale = useObservable(() => localeService.localeChanged$.pipe((0, rxjs.map)(() => localeService.getLocales())), localeService.getLocales(), false, [localeService]);
26016
+ const direction = useObservable(localeService.direction$, localeService.getDirection());
25921
26017
  const portalContainer = (0, react.useMemo)(() => document.createElement("div"), []);
25922
26018
  (0, react.useLayoutEffect)(() => {
25923
26019
  const sub = themeService.currentTheme$.subscribe((theme) => {
@@ -26115,8 +26211,7 @@ function MobileWorkbench(props) {
26115
26211
  });
26116
26212
  }
26117
26213
 
26118
- //#endregion
26119
- //#region src/controllers/ui/ui-mobile.controller.ts
26214
+ // src/controllers/ui/ui-mobile.controller.ts
26120
26215
  let MobileUIController = class MobileUIController extends SingleUnitUIController {
26121
26216
  constructor(_config, injector, lifecycleService, renderManagerService, layoutService, instanceService, menuManagerService, uiPartsService) {
26122
26217
  super(injector, instanceService, layoutService, lifecycleService, renderManagerService);
@@ -26170,12 +26265,10 @@ function createContainer(id) {
26170
26265
  return element;
26171
26266
  }
26172
26267
 
26173
- //#endregion
26174
- //#region src/services/notification/notification.service.ts
26268
+ // src/services/notification/notification.service.ts
26175
26269
  const INotificationService = (0, _univerjs_core.createIdentifier)("ui.notification.service");
26176
26270
 
26177
- //#endregion
26178
- //#region src/services/before-close/before-close.service.ts
26271
+ // src/services/before-close/before-close.service.ts
26179
26272
  const IBeforeCloseService = (0, _univerjs_core.createIdentifier)("univer.ui.before-close-service");
26180
26273
  let DesktopBeforeCloseService = class DesktopBeforeCloseService extends _univerjs_core.Disposable {
26181
26274
  constructor(_notificationService, _localeService) {
@@ -26231,8 +26324,7 @@ let DesktopBeforeCloseService = class DesktopBeforeCloseService extends _univerj
26231
26324
  };
26232
26325
  DesktopBeforeCloseService = __decorate([__decorateParam(0, INotificationService), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService))], DesktopBeforeCloseService);
26233
26326
 
26234
- //#endregion
26235
- //#region src/utils/html.ts
26327
+ // src/utils/html.ts
26236
26328
  function sanitizeParsedHtml(root, options) {
26237
26329
  root.querySelectorAll(options.strippedSelector).forEach((element) => element.remove());
26238
26330
  root.querySelectorAll("*").forEach((element) => {
@@ -26250,8 +26342,7 @@ function parseHtmlDocument(html, options) {
26250
26342
  return doc;
26251
26343
  }
26252
26344
 
26253
- //#endregion
26254
- //#region src/services/clipboard/clipboard-utils.ts
26345
+ // src/services/clipboard/clipboard-utils.ts
26255
26346
  /**
26256
26347
  * Copyright 2023-present DreamNum Co., Ltd.
26257
26348
  *
@@ -26277,8 +26368,7 @@ function supportClipboardAPI() {
26277
26368
  return typeof navigator.clipboard !== "undefined" && typeof navigator.clipboard.readText !== "undefined";
26278
26369
  }
26279
26370
 
26280
- //#endregion
26281
- //#region src/services/clipboard/clipboard-interface.service.ts
26371
+ // src/services/clipboard/clipboard-interface.service.ts
26282
26372
  const PLAIN_TEXT_CLIPBOARD_MIME_TYPE = "text/plain";
26283
26373
  const HTML_CLIPBOARD_MIME_TYPE = "text/html";
26284
26374
  const FILE_PNG_CLIPBOARD_MIME_TYPE = "image/png";
@@ -26629,8 +26719,7 @@ function select(element) {
26629
26719
  return selection.toString();
26630
26720
  }
26631
26721
 
26632
- //#endregion
26633
- //#region src/views/components/confirm-part/MobileConfirmPart.tsx
26722
+ // src/views/components/confirm-part/MobileConfirmPart.tsx
26634
26723
  function MobileContextConfirm(props) {
26635
26724
  const { children, onClose, onConfirm } = props;
26636
26725
  const [hooks] = (0, react.useState)({});
@@ -26662,7 +26751,7 @@ function MobileContextConfirm(props) {
26662
26751
  }
26663
26752
  function MobileConfirmPart() {
26664
26753
  const confirmService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IConfirmService);
26665
- return (0, _wendellhu_redi_react_bindings.useObservable)(confirmService.confirmOptions$, []).map((options) => {
26754
+ return useObservable(confirmService.confirmOptions$, []).map((options) => {
26666
26755
  const { children, title, ...restProps } = options;
26667
26756
  const confirmProps = restProps;
26668
26757
  for (const key of ["children", "title"]) {
@@ -26677,8 +26766,7 @@ function MobileConfirmPart() {
26677
26766
  }, options.id));
26678
26767
  }
26679
26768
 
26680
- //#endregion
26681
- //#region src/services/confirm/mobile-confirm.service.ts
26769
+ // src/services/confirm/mobile-confirm.service.ts
26682
26770
  let MobileConfirmService = class MobileConfirmService extends _univerjs_core.Disposable {
26683
26771
  constructor(_injector, uiPartsService) {
26684
26772
  super();
@@ -26732,8 +26820,7 @@ let MobileConfirmService = class MobileConfirmService extends _univerjs_core.Dis
26732
26820
  };
26733
26821
  MobileConfirmService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, IUIPartsService)], MobileConfirmService);
26734
26822
 
26735
- //#endregion
26736
- //#region src/views/components/dialog-part/MobileDialogPart.tsx
26823
+ // src/views/components/dialog-part/MobileDialogPart.tsx
26737
26824
  function toMobileDialogOptions(options) {
26738
26825
  const { children, title, footer, ...rest } = options;
26739
26826
  return {
@@ -26747,7 +26834,7 @@ function MobileDialogPart() {
26747
26834
  const dialogService = (0, _wendellhu_redi_react_bindings.useDependency)(IDialogService);
26748
26835
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
26749
26836
  const { locale } = (0, react.useContext)(_univerjs_design.ConfigContext);
26750
- const dialogOptions = (0, _wendellhu_redi_react_bindings.useObservable)(dialogService.getDialogs$(), []);
26837
+ const dialogOptions = useObservable(dialogService.getDialogs$(), []);
26751
26838
  const options = (0, react.useMemo)(() => {
26752
26839
  const activeDialogs = dialogOptions.filter((item) => item.open !== false);
26753
26840
  const active = activeDialogs[activeDialogs.length - 1];
@@ -26794,6 +26881,7 @@ function MobileDialogPart() {
26794
26881
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileDrawer, {
26795
26882
  layerRef,
26796
26883
  layout: options.layout,
26884
+ autoHeight: options.layout !== "canvas",
26797
26885
  componentName: "mobile-dialog-drawer",
26798
26886
  snap: (snapOverride === null || snapOverride === void 0 ? void 0 : snapOverride.id) === options.id ? snapOverride.snap : defaultSnap,
26799
26887
  expandLabel: localeService.t("ui.sidebar.resize"),
@@ -26828,8 +26916,7 @@ function MobileDialogPart() {
26828
26916
  });
26829
26917
  }
26830
26918
 
26831
- //#endregion
26832
- //#region src/views/components/dialog-part/DialogPart.tsx
26919
+ // src/views/components/dialog-part/DialogPart.tsx
26833
26920
  function DialogItem(props) {
26834
26921
  const dialogRef = (0, react.useRef)(null);
26835
26922
  const openRef = (0, react.useRef)(false);
@@ -26865,7 +26952,7 @@ function DialogItem(props) {
26865
26952
  }
26866
26953
  function DialogPart() {
26867
26954
  const dialogService = (0, _wendellhu_redi_react_bindings.useDependency)(IDialogService);
26868
- const dialogOptions = (0, _wendellhu_redi_react_bindings.useObservable)(dialogService.getDialogs$(), []);
26955
+ const dialogOptions = useObservable(dialogService.getDialogs$(), []);
26869
26956
  const attrs = (0, react.useMemo)(() => dialogOptions.map((options) => {
26870
26957
  const { children, title, footer, ...restProps } = options;
26871
26958
  const dialogProps = restProps;
@@ -26886,8 +26973,7 @@ function DialogPart() {
26886
26973
  return attrs === null || attrs === void 0 ? void 0 : attrs.map((options) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DialogItem, { ...options }, options.id));
26887
26974
  }
26888
26975
 
26889
- //#endregion
26890
- //#region src/services/dialog/desktop-dialog.service.ts
26976
+ // src/services/dialog/desktop-dialog.service.ts
26891
26977
  let DesktopDialogService = class DesktopDialogService extends _univerjs_core.Disposable {
26892
26978
  constructor(_injector, _uiPartsService) {
26893
26979
  super();
@@ -26941,8 +27027,7 @@ let DesktopDialogService = class DesktopDialogService extends _univerjs_core.Dis
26941
27027
  };
26942
27028
  DesktopDialogService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, IUIPartsService)], DesktopDialogService);
26943
27029
 
26944
- //#endregion
26945
- //#region src/services/dialog/mobile-dialog.service.ts
27030
+ // src/services/dialog/mobile-dialog.service.ts
26946
27031
  /**
26947
27032
  * Copyright 2023-present DreamNum Co., Ltd.
26948
27033
  *
@@ -26973,12 +27058,10 @@ let MobileDialogService = class MobileDialogService extends DesktopDialogService
26973
27058
  };
26974
27059
  MobileDialogService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, IUIPartsService)], MobileDialogService);
26975
27060
 
26976
- //#endregion
26977
- //#region src/services/gallery/gallery.service.ts
27061
+ // src/services/gallery/gallery.service.ts
26978
27062
  const IGalleryService = (0, _univerjs_core.createIdentifier)("univer.ui.gallery-service");
26979
27063
 
26980
- //#endregion
26981
- //#region src/views/components/gallery-part/GalleryPart.tsx
27064
+ // src/views/components/gallery-part/GalleryPart.tsx
26982
27065
  /**
26983
27066
  * Copyright 2023-present DreamNum Co., Ltd.
26984
27067
  *
@@ -26996,13 +27079,12 @@ const IGalleryService = (0, _univerjs_core.createIdentifier)("univer.ui.gallery-
26996
27079
  */
26997
27080
  function GalleryPart() {
26998
27081
  const galleryService = (0, _wendellhu_redi_react_bindings.useDependency)(IGalleryService);
26999
- const gallery = (0, _wendellhu_redi_react_bindings.useObservable)(galleryService.gallery$);
27082
+ const gallery = useObservable(galleryService.gallery$);
27000
27083
  if (!gallery) return null;
27001
27084
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Gallery, { ...gallery });
27002
27085
  }
27003
27086
 
27004
- //#endregion
27005
- //#region src/services/gallery/desktop-gallery.service.ts
27087
+ // src/services/gallery/desktop-gallery.service.ts
27006
27088
  let DesktopGalleryService = class DesktopGalleryService extends _univerjs_core.Disposable {
27007
27089
  constructor(_injector, _uiPartsService) {
27008
27090
  super();
@@ -27035,8 +27117,7 @@ let DesktopGalleryService = class DesktopGalleryService extends _univerjs_core.D
27035
27117
  };
27036
27118
  DesktopGalleryService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, IUIPartsService)], DesktopGalleryService);
27037
27119
 
27038
- //#endregion
27039
- //#region src/services/local-file/desktop-local-file.service.ts
27120
+ // src/services/local-file/desktop-local-file.service.ts
27040
27121
  var DesktopLocalFileService = class extends _univerjs_core.Disposable {
27041
27122
  openFile(options) {
27042
27123
  return new Promise((resolve) => {
@@ -27059,8 +27140,7 @@ var DesktopLocalFileService = class extends _univerjs_core.Disposable {
27059
27140
  }
27060
27141
  };
27061
27142
 
27062
- //#endregion
27063
- //#region src/services/local-file/local-file.service.ts
27143
+ // src/services/local-file/local-file.service.ts
27064
27144
  /**
27065
27145
  * Copyright 2023-present DreamNum Co., Ltd.
27066
27146
  *
@@ -27081,8 +27161,7 @@ var DesktopLocalFileService = class extends _univerjs_core.Disposable {
27081
27161
  */
27082
27162
  const ILocalFileService = (0, _univerjs_core.createIdentifier)("univer-ui.local-file.service");
27083
27163
 
27084
- //#endregion
27085
- //#region src/utils/storage-driver.ts
27164
+ // src/utils/storage-driver.ts
27086
27165
  /**
27087
27166
  * Copyright 2023-present DreamNum Co., Ltd.
27088
27167
  *
@@ -27300,8 +27379,7 @@ function createDriver() {
27300
27379
  }
27301
27380
  const browserStorage = createDriver();
27302
27381
 
27303
- //#endregion
27304
- //#region src/services/local-storage/local-storage.service.ts
27382
+ // src/services/local-storage/local-storage.service.ts
27305
27383
  var DesktopLocalStorageService = class {
27306
27384
  getItem(key) {
27307
27385
  return browserStorage.getItem(key);
@@ -27326,8 +27404,7 @@ var DesktopLocalStorageService = class {
27326
27404
  }
27327
27405
  };
27328
27406
 
27329
- //#endregion
27330
- //#region src/views/message/MessageContainer.tsx
27407
+ // src/views/message/MessageContainer.tsx
27331
27408
  /**
27332
27409
  * Copyright 2023-present DreamNum Co., Ltd.
27333
27410
  *
@@ -27346,16 +27423,15 @@ var DesktopLocalStorageService = class {
27346
27423
  function MessageContainer() {
27347
27424
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
27348
27425
  const themeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.ThemeService);
27349
- const darkMode = (0, _wendellhu_redi_react_bindings.useObservable)(themeService.darkMode$);
27350
- const direction = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$);
27426
+ const darkMode = useObservable(themeService.darkMode$);
27427
+ const direction = useObservable(localeService.direction$);
27351
27428
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Messager, {
27352
27429
  theme: darkMode ? "dark" : "light",
27353
27430
  dir: direction
27354
27431
  });
27355
27432
  }
27356
27433
 
27357
- //#endregion
27358
- //#region src/services/message/desktop-message.service.ts
27434
+ // src/services/message/desktop-message.service.ts
27359
27435
  let messageId = 0;
27360
27436
  let DesktopMessageService = class DesktopMessageService extends _univerjs_core.Disposable {
27361
27437
  constructor(_injector, _uiPartsService) {
@@ -27387,13 +27463,12 @@ let DesktopMessageService = class DesktopMessageService extends _univerjs_core.D
27387
27463
  };
27388
27464
  DesktopMessageService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, IUIPartsService)], DesktopMessageService);
27389
27465
 
27390
- //#endregion
27391
- //#region src/views/notification/Notification.tsx
27466
+ // src/views/notification/Notification.tsx
27392
27467
  function Notification() {
27393
27468
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
27394
27469
  const themeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.ThemeService);
27395
- const darkMode = (0, _wendellhu_redi_react_bindings.useObservable)(themeService.darkMode$);
27396
- const direction = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$);
27470
+ const darkMode = useObservable(themeService.darkMode$);
27471
+ const direction = useObservable(localeService.direction$);
27397
27472
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Toaster, {
27398
27473
  theme: darkMode ? "dark" : "light",
27399
27474
  dir: direction
@@ -27415,8 +27490,7 @@ const notification = {
27415
27490
  dismiss: (id) => _univerjs_design.toast.dismiss(id)
27416
27491
  };
27417
27492
 
27418
- //#endregion
27419
- //#region src/services/notification/desktop-notification.service.ts
27493
+ // src/services/notification/desktop-notification.service.ts
27420
27494
  let DesktopNotificationService = class DesktopNotificationService extends _univerjs_core.Disposable {
27421
27495
  constructor(_injector, _uiPartsService) {
27422
27496
  super();
@@ -27434,8 +27508,7 @@ let DesktopNotificationService = class DesktopNotificationService extends _unive
27434
27508
  };
27435
27509
  DesktopNotificationService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, IUIPartsService)], DesktopNotificationService);
27436
27510
 
27437
- //#endregion
27438
- //#region src/services/presence/unit-presence-ui-adapter.service.ts
27511
+ // src/services/presence/unit-presence-ui-adapter.service.ts
27439
27512
  const IUnitPresenceUIAdapterRegistry = (0, _univerjs_core.createIdentifier)("ui.unit-presence-adapter-registry");
27440
27513
  const EMPTY_ADAPTERS = Object.freeze([]);
27441
27514
  var UnitPresenceUIAdapterRegistry = class extends _univerjs_core.Disposable {
@@ -27471,8 +27544,7 @@ var UnitPresenceUIAdapterRegistry = class extends _univerjs_core.Disposable {
27471
27544
  }
27472
27545
  };
27473
27546
 
27474
- //#endregion
27475
- //#region src/services/sidebar/desktop-sidebar.service.ts
27547
+ // src/services/sidebar/desktop-sidebar.service.ts
27476
27548
  var DesktopSidebarService = class extends _univerjs_core.Disposable {
27477
27549
  constructor(..._args) {
27478
27550
  super(..._args);
@@ -27542,8 +27614,7 @@ var DesktopSidebarService = class extends _univerjs_core.Disposable {
27542
27614
  }
27543
27615
  };
27544
27616
 
27545
- //#endregion
27546
- //#region src/services/undo-redo/undo-redo-group.service.ts
27617
+ // src/services/undo-redo/undo-redo-group.service.ts
27547
27618
  /**
27548
27619
  * Copyright 2023-present DreamNum Co., Ltd.
27549
27620
  *
@@ -27597,8 +27668,7 @@ let UndoRedoGroupService = class UndoRedoGroupService {
27597
27668
  };
27598
27669
  UndoRedoGroupService = __decorate([__decorateParam(0, _univerjs_core.IUndoRedoService)], UndoRedoGroupService);
27599
27670
 
27600
- //#endregion
27601
- //#region src/mobile-plugin.ts
27671
+ // src/mobile-plugin.ts
27602
27672
  const DISABLE_AUTO_FOCUS_KEY$1 = "DISABLE_AUTO_FOCUS";
27603
27673
  let UniverMobileUIPlugin = class UniverMobileUIPlugin extends _univerjs_core.Plugin {
27604
27674
  constructor(_config = defaultPluginConfig, _contextService, _injector, _configService) {
@@ -27699,8 +27769,7 @@ UniverMobileUIPlugin = __decorate([
27699
27769
  __decorateParam(3, _univerjs_core.IConfigService)
27700
27770
  ], UniverMobileUIPlugin);
27701
27771
 
27702
- //#endregion
27703
- //#region src/views/components/shortcut-panel/ShortcutPanel.tsx
27772
+ // src/views/components/shortcut-panel/ShortcutPanel.tsx
27704
27773
  /**
27705
27774
  * Copyright 2023-present DreamNum Co., Ltd.
27706
27775
  *
@@ -27722,7 +27791,7 @@ UniverMobileUIPlugin = __decorate([
27722
27791
  function ShortcutPanel() {
27723
27792
  const shortcutService = (0, _wendellhu_redi_react_bindings.useDependency)(IShortcutService);
27724
27793
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
27725
- const currentLocale = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.currentLocale$);
27794
+ const currentLocale = useObservable(localeService.currentLocale$);
27726
27795
  const [shortcutItems, setShortcutItems] = (0, react.useState)([]);
27727
27796
  const updateShortcuts = (0, react.useCallback)(() => {
27728
27797
  const shortcutGroups = /* @__PURE__ */ new Map();
@@ -27778,13 +27847,12 @@ function ShortcutPanel() {
27778
27847
  });
27779
27848
  }
27780
27849
 
27781
- //#endregion
27782
- //#region src/views/font-family/FontFamilyDropdown.tsx
27850
+ // src/views/font-family/FontFamilyDropdown.tsx
27783
27851
  function FontFamilyDropdown(props) {
27784
27852
  const { value, onChange, ariaLabel, className, disabled: disabledProp, disabled$, inputClassName, popupClassName, popupDataComponent, title, onMouseDown, onPointerDown } = props;
27785
27853
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
27786
- const direction = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$, localeService.getDirection());
27787
- const disabledObservableValue = (0, _wendellhu_redi_react_bindings.useObservable)(disabled$);
27854
+ const direction = useObservable(localeService.direction$, localeService.getDirection());
27855
+ const disabledObservableValue = useObservable(disabled$);
27788
27856
  const disabled = Boolean(disabledProp || disabledObservableValue);
27789
27857
  const [open, setOpen] = (0, react.useState)(false);
27790
27858
  const popupDataAttributes = popupDataComponent ? { "data-u-comp": popupDataComponent } : void 0;
@@ -27826,8 +27894,7 @@ function FontFamilyDropdown(props) {
27826
27894
  });
27827
27895
  }
27828
27896
 
27829
- //#endregion
27830
- //#region src/views/slider/ZoomInput.tsx
27897
+ // src/views/slider/ZoomInput.tsx
27831
27898
  function ZoomInput(props) {
27832
27899
  const iconManager = (0, _wendellhu_redi_react_bindings.useDependency)(IconManager);
27833
27900
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
@@ -27920,8 +27987,7 @@ function ZoomInput(props) {
27920
27987
  });
27921
27988
  }
27922
27989
 
27923
- //#endregion
27924
- //#region src/views/slider/Slider.tsx
27990
+ // src/views/slider/Slider.tsx
27925
27991
  const SLIDER_WIDTH = 116;
27926
27992
  const DRAG_COMMIT_INTERVAL = 50;
27927
27993
  /**
@@ -27931,7 +27997,7 @@ function Slider(props) {
27931
27997
  const iconManager = (0, _wendellhu_redi_react_bindings.useDependency)(IconManager);
27932
27998
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
27933
27999
  const { value, min = 0, max = 400, disabled = false, resetPoint = 100, shortcuts, onChange } = props;
27934
- const isRtl = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$, localeService.getDirection()) === "rtl";
28000
+ const isRtl = useObservable(localeService.direction$, localeService.getDirection()) === "rtl";
27935
28001
  const sliderInnerRailRef = (0, react.useRef)(null);
27936
28002
  const dragValueRef = (0, react.useRef)(value);
27937
28003
  const pendingDragValueRef = (0, react.useRef)(null);
@@ -28151,8 +28217,7 @@ function Slider(props) {
28151
28217
  });
28152
28218
  }
28153
28219
 
28154
- //#endregion
28155
- //#region src/views/object-permission/ObjectPermissionMembers.tsx
28220
+ // src/views/object-permission/ObjectPermissionMembers.tsx
28156
28221
  function ObjectPermissionMembers({ unitId, value, disabled, onChange }) {
28157
28222
  var _authz$getCfgEnableOb;
28158
28223
  const locale = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
@@ -28301,8 +28366,7 @@ function ObjectPermissionMembers({ unitId, value, disabled, onChange }) {
28301
28366
  });
28302
28367
  }
28303
28368
 
28304
- //#endregion
28305
- //#region src/views/object-permission/ObjectPermissionButton.tsx
28369
+ // src/views/object-permission/ObjectPermissionButton.tsx
28306
28370
  const OBJECT_PERMISSION_DIALOG = "ui.object-permission-dialog";
28307
28371
  /** Mount outside transient toolbars and context menus, retaining the original target until close. */
28308
28372
  function openObjectPermissionDialog(accessor, props) {
@@ -28330,7 +28394,7 @@ function openObjectPermissionDialog(accessor, props) {
28330
28394
  function ObjectPermissionButton(props) {
28331
28395
  const permissions = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.ObjectPermissionService);
28332
28396
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
28333
- (0, _wendellhu_redi_react_bindings.useObservable)(permissions.changed$, 0);
28397
+ useObservable(permissions.changed$, 0);
28334
28398
  const [open, setOpen] = (0, react.useState)(false);
28335
28399
  if (!permissions.supports(props.target)) return null;
28336
28400
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.StateIconButton, {
@@ -28356,9 +28420,9 @@ function ObjectPermissionDialog({ target, name, commandId, actions = DEFAULT_ACT
28356
28420
  const commandService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.ICommandService);
28357
28421
  const instances = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IUniverInstanceService);
28358
28422
  const users = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.UserManagerService);
28359
- const currentUser = (0, _wendellhu_redi_react_bindings.useObservable)(users.currentUser$, users.getCurrentUser());
28423
+ const currentUser = useObservable(users.currentUser$, users.getCurrentUser());
28360
28424
  const [policy, setPolicy] = (0, react.useState)(null);
28361
- (0, _wendellhu_redi_react_bindings.useObservable)(permissions.changed$, 0);
28425
+ useObservable(permissions.changed$, 0);
28362
28426
  const canView = permissions.canView(target);
28363
28427
  const [canManage, setCanManage] = (0, react.useState)(false);
28364
28428
  const [canDelete, setCanDelete] = (0, react.useState)(false);
@@ -28599,8 +28663,7 @@ function ObjectPermissionDialog({ target, name, commandId, actions = DEFAULT_ACT
28599
28663
  });
28600
28664
  }
28601
28665
 
28602
- //#endregion
28603
- //#region src/views/object-permission/ObjectPermissionPanel.tsx
28666
+ // src/views/object-permission/ObjectPermissionPanel.tsx
28604
28667
  const OBJECT_PERMISSION_PANEL = "ui.object-permission-panel";
28605
28668
  function openObjectPermissionPanel(accessor, props) {
28606
28669
  if (!accessor.get(_univerjs_core.ObjectPermissionService).canView(props.target)) return false;
@@ -28623,7 +28686,7 @@ function ObjectPermissionPanelButton(props) {
28623
28686
  const permissions = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.ObjectPermissionService);
28624
28687
  const accessor = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.Injector);
28625
28688
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
28626
- (0, _wendellhu_redi_react_bindings.useObservable)(permissions.changed$, 0);
28689
+ useObservable(permissions.changed$, 0);
28627
28690
  if (!permissions.supports(props.target)) return null;
28628
28691
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
28629
28692
  variant: "ghost",
@@ -28642,7 +28705,7 @@ function ObjectPermissionPanel({ unitId, getTargets, expandable }) {
28642
28705
  const [query, setQuery] = (0, react.useState)("");
28643
28706
  const [expanded, setExpanded] = (0, react.useState)(false);
28644
28707
  const [limit, setLimit] = (0, react.useState)(50);
28645
- (0, _wendellhu_redi_react_bindings.useObservable)(permissions.changed$, 0);
28708
+ useObservable(permissions.changed$, 0);
28646
28709
  const instances = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IUniverInstanceService);
28647
28710
  const sidebar = (0, _wendellhu_redi_react_bindings.useDependency)(ISidebarService);
28648
28711
  (0, react.useEffect)(() => {
@@ -28732,8 +28795,7 @@ function ObjectPermissionPanel({ unitId, getTargets, expandable }) {
28732
28795
  });
28733
28796
  }
28734
28797
 
28735
- //#endregion
28736
- //#region src/controllers/components.controller.ts
28798
+ // src/controllers/components.controller.ts
28737
28799
  /**
28738
28800
  * Copyright 2023-present DreamNum Co., Ltd.
28739
28801
  *
@@ -28795,8 +28857,7 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
28795
28857
  };
28796
28858
  ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(IconManager))], ComponentsController);
28797
28859
 
28798
- //#endregion
28799
- //#region src/controllers/feature-search/feature-search.controller.ts
28860
+ // src/controllers/feature-search/feature-search.controller.ts
28800
28861
  const FeatureSearchShortcut = {
28801
28862
  id: OpenFeatureSearchOperation.id,
28802
28863
  binding: 4096 | 1024 | 80,
@@ -28813,8 +28874,7 @@ let FeatureSearchController = class FeatureSearchController extends _univerjs_co
28813
28874
  };
28814
28875
  FeatureSearchController = __decorate([__decorateParam(0, _univerjs_core.ICommandService), __decorateParam(1, IShortcutService)], FeatureSearchController);
28815
28876
 
28816
- //#endregion
28817
- //#region src/views/components/confirm-part/ConfirmPart.tsx
28877
+ // src/views/components/confirm-part/ConfirmPart.tsx
28818
28878
  const ContextConfirm = (props) => {
28819
28879
  const { children, onClose, onConfirm } = props;
28820
28880
  const [hooks] = (0, react.useState)({});
@@ -28846,7 +28906,7 @@ const ContextConfirm = (props) => {
28846
28906
  };
28847
28907
  function ConfirmPart() {
28848
28908
  const confirmService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IConfirmService);
28849
- const props = (0, _wendellhu_redi_react_bindings.useObservable)(confirmService.confirmOptions$, []).map((options) => {
28909
+ const props = useObservable(confirmService.confirmOptions$, []).map((options) => {
28850
28910
  const { children, title, ...restProps } = options;
28851
28911
  const confirmProps = restProps;
28852
28912
  for (const key of ["children", "title"]) {
@@ -28862,8 +28922,7 @@ function ConfirmPart() {
28862
28922
  }, index));
28863
28923
  }
28864
28924
 
28865
- //#endregion
28866
- //#region src/services/confirm/desktop-confirm.service.ts
28925
+ // src/services/confirm/desktop-confirm.service.ts
28867
28926
  let DesktopConfirmService = class DesktopConfirmService extends _univerjs_core.Disposable {
28868
28927
  constructor(_injector, _uiPartsService) {
28869
28928
  super();
@@ -28916,8 +28975,7 @@ let DesktopConfirmService = class DesktopConfirmService extends _univerjs_core.D
28916
28975
  };
28917
28976
  DesktopConfirmService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, IUIPartsService)], DesktopConfirmService);
28918
28977
 
28919
- //#endregion
28920
- //#region src/plugin.ts
28978
+ // src/plugin.ts
28921
28979
  const DISABLE_AUTO_FOCUS_KEY = "DISABLE_AUTO_FOCUS";
28922
28980
  let UniverUIPlugin = class UniverUIPlugin extends _univerjs_core.Plugin {
28923
28981
  constructor(_config = defaultPluginConfig, _contextService, _injector, _configService) {
@@ -29025,8 +29083,7 @@ UniverUIPlugin = __decorate([
29025
29083
  __decorateParam(3, _univerjs_core.IConfigService)
29026
29084
  ], UniverUIPlugin);
29027
29085
 
29028
- //#endregion
29029
- //#region src/services/message/__tests__/mock-message.service.ts
29086
+ // src/services/message/__tests__/mock-message.service.ts
29030
29087
  /**
29031
29088
  * This is a mocked message service for testing purposes.
29032
29089
  *
@@ -29042,8 +29099,7 @@ var MockMessageService = class {
29042
29099
  getContainer() {}
29043
29100
  };
29044
29101
 
29045
- //#endregion
29046
- //#region src/services/sidebar/hooks/use-sidebar-click.ts
29102
+ // src/services/sidebar/hooks/use-sidebar-click.ts
29047
29103
  /**
29048
29104
  * Copyright 2023-present DreamNum Co., Ltd.
29049
29105
  *
@@ -29074,8 +29130,7 @@ const useSidebarClick = (cb) => {
29074
29130
  }, [cb, container]);
29075
29131
  };
29076
29132
 
29077
- //#endregion
29078
- //#region src/utils/util.ts
29133
+ // src/utils/util.ts
29079
29134
  /**
29080
29135
  * Copyright 2023-present DreamNum Co., Ltd.
29081
29136
  *
@@ -29096,8 +29151,7 @@ function textTrim(x) {
29096
29151
  return x.replace(/^\s+|\s+$/gm, "");
29097
29152
  }
29098
29153
 
29099
- //#endregion
29100
- //#region src/utils/cell.ts
29154
+ // src/utils/cell.ts
29101
29155
  const PX_TO_PT_RATIO = .75;
29102
29156
  const MAX_FONT_SIZE = 78;
29103
29157
  const MIN_FONT_SIZE = 9;
@@ -29668,8 +29722,7 @@ function extractFontFamily(styleStr) {
29668
29722
  return matches ? (matches[1] || matches[2] || matches[3]).trim() : null;
29669
29723
  }
29670
29724
 
29671
- //#endregion
29672
- //#region src/utils/mobile-canvas-gesture.ts
29725
+ // src/utils/mobile-canvas-gesture.ts
29673
29726
  /** Routes touch browsing separately from the canvas's existing object manipulation. */
29674
29727
  var MobileCanvasGesture = class extends _univerjs_core.Disposable {
29675
29728
  constructor(_canvas, _options) {
@@ -29883,8 +29936,7 @@ var MobileCanvasGesture = class extends _univerjs_core.Disposable {
29883
29936
  }
29884
29937
  };
29885
29938
 
29886
- //#endregion
29887
- //#region src/views/components/dom/Print.tsx
29939
+ // src/views/components/dom/Print.tsx
29888
29940
  const PrintFloatDomSingle = (0, react.memo)((props) => {
29889
29941
  const { layer } = props;
29890
29942
  return typeof layer.componentKey === "string" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RegisteredPrintFloatDomSingle, {
@@ -29966,8 +30018,7 @@ function PrintFloatDomSingleContent(props) {
29966
30018
  });
29967
30019
  }
29968
30020
 
29969
- //#endregion
29970
- //#region src/views/components/hover-track/HoverTrack.tsx
30021
+ // src/views/components/hover-track/HoverTrack.tsx
29971
30022
  const HOVER_TRACK_HOST_CLASS_NAME = "univer-group/hover-track";
29972
30023
  const HOVER_TRACK_MASK = "linear-gradient(currentColor 0 0) content-box, linear-gradient(currentColor 0 0)";
29973
30024
  const HOVER_TRACK_MASK_STYLE = {
@@ -29986,8 +30037,7 @@ function HoverTrack(props) {
29986
30037
  });
29987
30038
  }
29988
30039
 
29989
- //#endregion
29990
- //#region src/views/components/mobile-zoom-indicator/mobile-zoom-indicator.ts
30040
+ // src/views/components/mobile-zoom-indicator/mobile-zoom-indicator.ts
29991
30041
  /**
29992
30042
  * Copyright 2023-present DreamNum Co., Ltd.
29993
30043
  *
@@ -30065,11 +30115,10 @@ var MobileZoomIndicator = class extends _univerjs_core.Disposable {
30065
30115
  }
30066
30116
  };
30067
30117
 
30068
- //#endregion
30069
- //#region src/views/font-family/MobileFontFamilyDropdown.tsx
30118
+ // src/views/font-family/MobileFontFamilyDropdown.tsx
30070
30119
  function MobileFontFamilyDropdown(props) {
30071
30120
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
30072
- const disabled = (0, _wendellhu_redi_react_bindings.useObservable)(props.disabled$);
30121
+ const disabled = useObservable(props.disabled$);
30073
30122
  const { fonts } = useFontList();
30074
30123
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileSelect, {
30075
30124
  "aria-label": props.ariaLabel,
@@ -30084,8 +30133,7 @@ function MobileFontFamilyDropdown(props) {
30084
30133
  });
30085
30134
  }
30086
30135
 
30087
- //#endregion
30088
- //#region src/views/progress-bar/ProgressBar.tsx
30136
+ // src/views/progress-bar/ProgressBar.tsx
30089
30137
  /**
30090
30138
  * Copyright 2023-present DreamNum Co., Ltd.
30091
30139
  *
@@ -30173,7 +30221,6 @@ function ProgressBar(props) {
30173
30221
  });
30174
30222
  }
30175
30223
 
30176
- //#endregion
30177
30224
  exports.AnchoredContextMenu = AnchoredContextMenu;
30178
30225
  Object.defineProperty(exports, "BrowserClipboardService", {
30179
30226
  enumerable: true,
@@ -30537,12 +30584,7 @@ Object.defineProperty(exports, "useInjector", {
30537
30584
  });
30538
30585
  exports.useMobileCanvasPanel = useMobileCanvasPanel;
30539
30586
  exports.useMobileCanvasViewport = useMobileCanvasViewport;
30540
- Object.defineProperty(exports, "useObservable", {
30541
- enumerable: true,
30542
- get: function () {
30543
- return _wendellhu_redi_react_bindings.useObservable;
30544
- }
30545
- });
30587
+ exports.useObservable = useObservable;
30546
30588
  exports.useObservableRef = useObservableRef;
30547
30589
  exports.useScrollYOverContainer = useScrollYOverContainer;
30548
30590
  exports.useSidebarClick = useSidebarClick;