@univerjs/ui 1.0.0-alpha.6 → 1.0.0-alpha.7

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 (109) hide show
  1. package/lib/cjs/index.js +1092 -349
  2. package/lib/cjs/locale/ar-SA.js +12 -0
  3. package/lib/cjs/locale/ca-ES.js +12 -0
  4. package/lib/cjs/locale/de-DE.js +12 -0
  5. package/lib/cjs/locale/en-US.js +12 -0
  6. package/lib/cjs/locale/es-ES.js +12 -0
  7. package/lib/cjs/locale/fa-IR.js +12 -0
  8. package/lib/cjs/locale/fr-FR.js +12 -0
  9. package/lib/cjs/locale/id-ID.js +12 -0
  10. package/lib/cjs/locale/it-IT.js +12 -0
  11. package/lib/cjs/locale/ja-JP.js +12 -0
  12. package/lib/cjs/locale/ko-KR.js +12 -0
  13. package/lib/cjs/locale/pl-PL.js +12 -0
  14. package/lib/cjs/locale/pt-BR.js +12 -0
  15. package/lib/cjs/locale/ru-RU.js +12 -0
  16. package/lib/cjs/locale/sk-SK.js +12 -0
  17. package/lib/cjs/locale/vi-VN.js +12 -0
  18. package/lib/cjs/locale/zh-CN.js +12 -0
  19. package/lib/cjs/locale/zh-HK.js +12 -0
  20. package/lib/cjs/locale/zh-TW.js +12 -0
  21. package/lib/es/index.js +1092 -354
  22. package/lib/es/locale/ar-SA.js +12 -0
  23. package/lib/es/locale/ca-ES.js +12 -0
  24. package/lib/es/locale/de-DE.js +12 -0
  25. package/lib/es/locale/en-US.js +12 -0
  26. package/lib/es/locale/es-ES.js +12 -0
  27. package/lib/es/locale/fa-IR.js +12 -0
  28. package/lib/es/locale/fr-FR.js +12 -0
  29. package/lib/es/locale/id-ID.js +12 -0
  30. package/lib/es/locale/it-IT.js +12 -0
  31. package/lib/es/locale/ja-JP.js +12 -0
  32. package/lib/es/locale/ko-KR.js +12 -0
  33. package/lib/es/locale/pl-PL.js +12 -0
  34. package/lib/es/locale/pt-BR.js +12 -0
  35. package/lib/es/locale/ru-RU.js +12 -0
  36. package/lib/es/locale/sk-SK.js +12 -0
  37. package/lib/es/locale/vi-VN.js +12 -0
  38. package/lib/es/locale/zh-CN.js +12 -0
  39. package/lib/es/locale/zh-HK.js +12 -0
  40. package/lib/es/locale/zh-TW.js +12 -0
  41. package/lib/index.css +176 -6
  42. package/lib/index.js +1092 -354
  43. package/lib/locale/ar-SA.js +12 -0
  44. package/lib/locale/ca-ES.js +12 -0
  45. package/lib/locale/de-DE.js +12 -0
  46. package/lib/locale/en-US.js +12 -0
  47. package/lib/locale/es-ES.js +12 -0
  48. package/lib/locale/fa-IR.js +12 -0
  49. package/lib/locale/fr-FR.js +12 -0
  50. package/lib/locale/id-ID.js +12 -0
  51. package/lib/locale/it-IT.js +12 -0
  52. package/lib/locale/ja-JP.js +12 -0
  53. package/lib/locale/ko-KR.js +12 -0
  54. package/lib/locale/pl-PL.js +12 -0
  55. package/lib/locale/pt-BR.js +12 -0
  56. package/lib/locale/ru-RU.js +12 -0
  57. package/lib/locale/sk-SK.js +12 -0
  58. package/lib/locale/vi-VN.js +12 -0
  59. package/lib/locale/zh-CN.js +12 -0
  60. package/lib/locale/zh-HK.js +12 -0
  61. package/lib/locale/zh-TW.js +12 -0
  62. package/lib/types/commands/operations/open-feature-search.operation.d.ts +17 -0
  63. package/lib/types/controllers/feature-search/feature-search.controller.d.ts +20 -0
  64. package/lib/types/controllers/ui/ui.controller.d.ts +1 -1
  65. package/lib/types/index.d.ts +2 -3
  66. package/lib/types/locale/en-US.d.ts +12 -0
  67. package/lib/types/menu/feature-search.menu.d.ts +18 -0
  68. package/lib/types/{controllers/menus/menus.d.ts → menu/history.menu.d.ts} +2 -2
  69. package/lib/types/{controllers/shortcut-display/menu.d.ts → menu/shortcut-panel.menu.d.ts} +2 -2
  70. package/lib/types/services/contextmenu/contextmenu-host.service.d.ts +5 -1
  71. package/lib/types/services/menu/menu-manager.service.d.ts +11 -0
  72. package/lib/types/services/menu/types.d.ts +1 -0
  73. package/lib/types/services/shortcut/shortcut.service.d.ts +4 -1
  74. package/lib/types/utils/embed-boundary.d.ts +2 -0
  75. package/lib/types/views/components/feature-search/FeatureSearch.d.ts +29 -0
  76. package/lib/types/views/components/ribbon/RibbonGrid.d.ts +23 -0
  77. package/lib/types/views/components/ribbon/ToolbarItem.d.ts +10 -1
  78. package/lib/types/views/components/ribbon/ribbon-grid-layout.d.ts +27 -0
  79. package/lib/types/views/components/ribbon/ribbon-menu/RibbonGridMenu.d.ts +21 -0
  80. package/lib/types/views/components/sidebar/Sidebar.d.ts +0 -2
  81. package/lib/types/views/custom-label/CustomLabel.d.ts +1 -0
  82. package/lib/types/views/emoji-picker/EmojiPicker.d.ts +7 -3
  83. package/lib/types/views/emoji-picker/emoji-picker-utils.d.ts +1 -1
  84. package/lib/types/views/emoji-picker/index.d.ts +0 -1
  85. package/lib/types/views/index.d.ts +1 -0
  86. package/lib/types/views/symbol-picker/SymbolPicker.d.ts +31 -0
  87. package/lib/types/views/symbol-picker/index.d.ts +18 -0
  88. package/lib/types/views/symbol-picker/symbols.d.ts +23 -0
  89. package/lib/umd/index.js +13 -13
  90. package/lib/umd/locale/ar-SA.js +1 -1
  91. package/lib/umd/locale/ca-ES.js +1 -1
  92. package/lib/umd/locale/de-DE.js +1 -1
  93. package/lib/umd/locale/en-US.js +1 -1
  94. package/lib/umd/locale/es-ES.js +1 -1
  95. package/lib/umd/locale/fa-IR.js +1 -1
  96. package/lib/umd/locale/fr-FR.js +1 -1
  97. package/lib/umd/locale/id-ID.js +1 -1
  98. package/lib/umd/locale/it-IT.js +1 -1
  99. package/lib/umd/locale/ja-JP.js +1 -1
  100. package/lib/umd/locale/ko-KR.js +1 -1
  101. package/lib/umd/locale/pl-PL.js +1 -1
  102. package/lib/umd/locale/pt-BR.js +1 -1
  103. package/lib/umd/locale/ru-RU.js +1 -1
  104. package/lib/umd/locale/sk-SK.js +1 -1
  105. package/lib/umd/locale/vi-VN.js +1 -1
  106. package/lib/umd/locale/zh-CN.js +1 -1
  107. package/lib/umd/locale/zh-HK.js +1 -1
  108. package/lib/umd/locale/zh-TW.js +1 -1
  109. package/package.json +7 -7
package/lib/es/index.js CHANGED
@@ -1,13 +1,13 @@
1
- import { BaselineOffset, BorderStyleTypes, ColorKit, CommandType, DependentOn, Disposable, DocumentDataModel, DocumentFlavor, EDITOR_ACTIVATED, ErrorService, FOCUSING_FX_BAR_EDITOR, FOCUSING_UNIVER_EDITOR, ICommandService, IConfigService, IConfirmService, IContextService, ILocalStorageService, ILogService, IUndoRedoService, IUniverInstanceService, Inject, Injector, LifecycleService, LifecycleStages, LifecycleUnreachableError, LocaleService, NAMED_STYLE_MAP, NamedStyleType, Optional, Plugin, RedoCommand, ThemeService, Tools, UndoCommand, UniverInstanceType, Workbook, createIdentifier, dedupeBy, generateRandomId, getBorderStyleType, isInternalEditorID, isRealNum, merge, mergeOverrideWithDependencies, registerDependencies, remove, throttle, toDisposable, touchDependencies } from "@univerjs/core";
1
+ import { BaselineOffset, BorderStyleTypes, ColorKit, CommandType, DependentOn, Disposable, DocumentDataModel, DocumentFlavor, EDITOR_ACTIVATED, ErrorService, FOCUSING_FX_BAR_EDITOR, FOCUSING_UNIVER_EDITOR, ICommandService, IConfigService, IConfirmService, IContextService, ILocalStorageService, ILogService, IUndoRedoService, IUniverInstanceService, Inject, Injector, LifecycleService, LifecycleStages, LifecycleUnreachableError, LocaleService, NAMED_STYLE_MAP, NamedStyleType, Optional, Plugin, RedoCommand, SHEET_EDITOR_UNITS, ThemeService, Tools, UndoCommand, UniverInstanceType, Workbook, createIdentifier, dedupeBy, generateRandomId, getBorderStyleType, isInternalEditorID, isRealNum, merge, mergeOverrideWithDependencies, registerDependencies, remove, throttle, toDisposable, touchDependencies } from "@univerjs/core";
2
2
  import { BehaviorSubject, EMPTY, Observable, Subject, animationFrameScheduler, combineLatest, debounceTime, distinctUntilChanged, filter, first, fromEvent, isObservable, map, merge as merge$1, of, scan, startWith, switchMap, throttleTime } from "rxjs";
3
3
  import { Fragment, cloneElement, createContext, createElement, forwardRef, memo, useCallback, useContext, useDeferredValue, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
4
- import { Button, ColorPicker, ConfigContext, ConfigProvider, Confirm, Dialog, Dropdown, DropdownMenu, Gallery, HoverCard, Input, InputNumber, KBD, MessageType, Messager, Popup, Toaster, Tooltip, borderBottomClassName, borderClassName, borderLeftBottomClassName, borderRightClassName, borderTopClassName, clsx, cva, divideXClassName, divideYClassName, isBrowser, message, removeMessage, render, resetButtonClassName, resizeObserverCtor, scrollbarClassName, toast, unmount } from "@univerjs/design";
4
+ import { Button, ColorPicker, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, ConfigContext, ConfigProvider, Confirm, Dialog, Dropdown, DropdownMenu, Gallery, HoverCard, Input, InputNumber, KBD, MessageType, Messager, Popup, Toaster, Tooltip, borderBottomClassName, borderClassName, borderLeftBottomClassName, borderRightClassName, borderTopClassName, clsx, cva, divideXClassName, divideYClassName, isBrowser, message, removeMessage, render, resetButtonClassName, resizeObserverCtor, scrollbarClassName, toast, unmount } from "@univerjs/design";
5
5
  import { IRenderManagerService, UniverRenderEnginePlugin, ptToPx } from "@univerjs/engine-render";
6
- import { distinctUntilChanged as distinctUntilChanged$1, map as map$1, scan as scan$1, startWith as startWith$1 } from "rxjs/operators";
6
+ import { distinctUntilChanged as distinctUntilChanged$1, map as map$1, scan as scan$1, startWith as startWith$1, switchMap as switchMap$1 } from "rxjs/operators";
7
7
  import { RediConsumer, RediContext, RediProvider, WithDependency, connectDependencies, connectInjector, useDependency, useDependency as useDependency$1, useInjector, useObservable, useUpdateBinder } from "@wendellhu/redi/react-bindings";
8
8
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
9
9
  import { createPortal } from "react-dom";
10
- import { ActivityIcon, CheckMarkIcon, CloseIcon, DatabaseIcon, ExpandIcon, EyeIcon, FoodsIcon, FunctionIcon, HomeIcon, IncreaseIcon, InfoIcon, InsertIcon, MoreDownIcon, MoreLeftIcon, MoreRightIcon, MoreVerticalIcon, NatureIcon, ObjectsIcon, PeopleIcon, PlacesIcon, RandomIcon, RecentIcon, RedoIcon, ReduceIcon, SearchIcon, ShortcutIcon, ShrinkIcon, SymbolsIcon, UndoIcon } from "@univerjs/icons";
10
+ import { ActivityIcon, CheckMarkIcon, CloseIcon, DatabaseIcon, ExpandIcon, EyeIcon, FeatureSearchIcon, FoodsIcon, FunctionIcon, HomeIcon, IncreaseIcon, InfoIcon, InsertIcon, KeyboardIcon, MoreDownIcon, MoreLeftIcon, MoreRightIcon, MoreVerticalIcon, NatureIcon, ObjectsIcon, PeopleIcon, PlacesIcon, RandomIcon, RecentIcon, RedoIcon, ReduceIcon, SearchIcon, ShortcutIcon, ShrinkIcon, SymbolsIcon, UndoIcon } from "@univerjs/icons";
11
11
 
12
12
  //#region src/utils/embed-boundary.ts
13
13
  /**
@@ -26,6 +26,7 @@ import { ActivityIcon, CheckMarkIcon, CloseIcon, DatabaseIcon, ExpandIcon, EyeIc
26
26
  * limitations under the License.
27
27
  */
28
28
  const EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = "data-embed-interaction-boundary-owner";
29
+ const EMBED_CHILD_UNIT_ID_ATTRIBUTE = "data-embed-child-unit-id";
29
30
  function getEmbedBoundaryOwner(target) {
30
31
  var _ref, _getAttributeValue;
31
32
  if (!hasClosest(target)) return;
@@ -35,6 +36,12 @@ function getEmbedBoundaryOwner(target) {
35
36
  function isEmbedBoundaryTarget(target) {
36
37
  return hasClosest(target) && target.closest(`[${"data-embed-interaction-boundary-owner"}]`) != null;
37
38
  }
39
+ function getEmbedChildUnitId(target) {
40
+ var _ref2, _getAttributeValue2;
41
+ if (!hasClosest(target)) return;
42
+ const childRuntime = target.closest(`[${EMBED_CHILD_UNIT_ID_ATTRIBUTE}]`);
43
+ return (_ref2 = (_getAttributeValue2 = getAttributeValue(target, "data-embed-child-unit-id")) !== null && _getAttributeValue2 !== void 0 ? _getAttributeValue2 : getAttributeValue(childRuntime, "data-embed-child-unit-id")) !== null && _ref2 !== void 0 ? _ref2 : void 0;
44
+ }
38
45
  function keepInteractionInsideSameEmbedBoundary(event) {
39
46
  const owner = getEmbedBoundaryOwner(event.currentTarget);
40
47
  if (!owner) return;
@@ -457,12 +464,13 @@ var ZIndexManager = class {
457
464
  //#region src/common/menu-hidden-observable.ts
458
465
  function getMenuHiddenObservable(accessor, targetUniverType, matchUnitId, needHideUnitId) {
459
466
  const univerInstanceService = accessor.get(IUniverInstanceService);
467
+ const getUnitType = (unitId) => SHEET_EDITOR_UNITS.includes(unitId) ? UniverInstanceType.UNIVER_SHEET : univerInstanceService.getUnitType(unitId);
460
468
  return new Observable((subscriber) => {
461
469
  const subscription = univerInstanceService.focused$.subscribe((unitId) => {
462
470
  if (unitId == null) return subscriber.next(true);
463
471
  if (matchUnitId && matchUnitId !== unitId) return subscriber.next(true);
464
472
  if (needHideUnitId && (Array.isArray(needHideUnitId) ? needHideUnitId.includes(unitId) : needHideUnitId === unitId)) return subscriber.next(true);
465
- const univerType = univerInstanceService.getUnitType(unitId);
473
+ const univerType = getUnitType(unitId);
466
474
  subscriber.next(univerType !== targetUniverType);
467
475
  });
468
476
  const focusedUniverInstance = univerInstanceService.getFocusedUnit();
@@ -470,7 +478,7 @@ function getMenuHiddenObservable(accessor, targetUniverType, matchUnitId, needHi
470
478
  const currentUnit = univerInstanceService.getCurrentUnitOfType(targetUniverType);
471
479
  subscriber.next(currentUnit == null);
472
480
  } else {
473
- const univerType = univerInstanceService.getUnitType(focusedUniverInstance.getUnitId());
481
+ const univerType = getUnitType(focusedUniverInstance.getUnitId());
474
482
  subscriber.next(univerType !== targetUniverType);
475
483
  }
476
484
  return () => subscription.unsubscribe();
@@ -829,6 +837,25 @@ var PlatformService = class {
829
837
  }
830
838
  };
831
839
 
840
+ //#endregion
841
+ //#region src/services/runtime-scope/ui-runtime-scope.service.ts
842
+ const IUIRuntimeScopeService = createIdentifier("ui.runtime-scope.service");
843
+ var UIRuntimeScopeService = class extends Disposable {
844
+ constructor(..._args) {
845
+ super(..._args);
846
+ _defineProperty(this, "_scopes", /* @__PURE__ */ new Map());
847
+ }
848
+ register(scope) {
849
+ this._scopes.set(scope.unitId, scope);
850
+ return toDisposable(() => {
851
+ if (this._scopes.get(scope.unitId) === scope) this._scopes.delete(scope.unitId);
852
+ });
853
+ }
854
+ get(unitId) {
855
+ return unitId ? this._scopes.get(unitId) : void 0;
856
+ }
857
+ };
858
+
832
859
  //#endregion
833
860
  //#region src/services/shortcut/shortcut.service.ts
834
861
  /**
@@ -836,11 +863,12 @@ var PlatformService = class {
836
863
  */
837
864
  const IShortcutService = createIdentifier("ui.shortcut.service");
838
865
  let ShortcutService = class ShortcutService extends Disposable {
839
- constructor(_commandService, _platformService, _contextService, _layoutService) {
866
+ constructor(_commandService, _platformService, _contextService, _runtimeScopeService, _layoutService) {
840
867
  super();
841
868
  this._commandService = _commandService;
842
869
  this._platformService = _platformService;
843
870
  this._contextService = _contextService;
871
+ this._runtimeScopeService = _runtimeScopeService;
844
872
  this._layoutService = _layoutService;
845
873
  _defineProperty(this, "_shortCutMapping", /* @__PURE__ */ new Map());
846
874
  _defineProperty(this, "_commandIDMapping", /* @__PURE__ */ new Map());
@@ -910,11 +938,13 @@ let ShortcutService = class ShortcutService extends Disposable {
910
938
  _resolveKeyboardEvent(e) {
911
939
  const candidate = this.dispatch(e);
912
940
  if (candidate) {
913
- this._commandService.executeCommand(candidate.id, candidate.staticParameters);
941
+ var _this$_getRuntimeServ, _this$_getRuntimeServ2;
942
+ (_this$_getRuntimeServ = (_this$_getRuntimeServ2 = this._getRuntimeService(e, ICommandService)) === null || _this$_getRuntimeServ2 === void 0 ? void 0 : _this$_getRuntimeServ2.executeCommand(candidate.id, candidate.staticParameters)) !== null && _this$_getRuntimeServ !== void 0 || this._commandService.executeCommand(candidate.id, candidate.staticParameters);
914
943
  e.preventDefault();
915
944
  }
916
945
  }
917
946
  dispatch(e) {
947
+ var _this$_getRuntimeServ3;
918
948
  if (this._forceEscaped || this._forceDisabled) return;
919
949
  if (this._layoutService && !this._layoutService.checkElementInCurrentContainers(e.target)) return;
920
950
  const binding = this._deriveBindingFromEvent(e);
@@ -922,12 +952,13 @@ let ShortcutService = class ShortcutService extends Disposable {
922
952
  if (this._shouldLetEmbedTextEditorHandleNativeShortcut(e, binding)) return;
923
953
  const shortcuts = this._shortCutMapping.get(binding);
924
954
  if (shortcuts === void 0) return;
955
+ const contextService = (_this$_getRuntimeServ3 = this._getRuntimeService(e, IContextService)) !== null && _this$_getRuntimeServ3 !== void 0 ? _this$_getRuntimeServ3 : this._contextService;
925
956
  return Array.from(shortcuts).sort((s1, s2) => {
926
957
  var _s2$priority, _s1$priority;
927
958
  return ((_s2$priority = s2.priority) !== null && _s2$priority !== void 0 ? _s2$priority : 0) - ((_s1$priority = s1.priority) !== null && _s1$priority !== void 0 ? _s1$priority : 0);
928
959
  }).find((s) => {
929
960
  var _s$preconditions, _s$preconditions2;
930
- return (_s$preconditions = (_s$preconditions2 = s.preconditions) === null || _s$preconditions2 === void 0 ? void 0 : _s$preconditions2.call(s, this._contextService)) !== null && _s$preconditions !== void 0 ? _s$preconditions : true;
961
+ return (_s$preconditions = (_s$preconditions2 = s.preconditions) === null || _s$preconditions2 === void 0 ? void 0 : _s$preconditions2.call(s, contextService)) !== null && _s$preconditions !== void 0 ? _s$preconditions : true;
931
962
  });
932
963
  }
933
964
  _getBindingFromItem(item) {
@@ -951,12 +982,18 @@ let ShortcutService = class ShortcutService extends Disposable {
951
982
  if (!(target instanceof HTMLElement)) return false;
952
983
  return (target.isContentEditable || target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) && isEmbedBoundaryTarget(target);
953
984
  }
985
+ _getRuntimeService(event, identifier) {
986
+ const childUnitId = getEmbedChildUnitId(event.target);
987
+ const runtimeScope = this._runtimeScopeService.get(childUnitId);
988
+ return (runtimeScope === null || runtimeScope === void 0 ? void 0 : runtimeScope.has(identifier)) ? runtimeScope.get(identifier) : void 0;
989
+ }
954
990
  };
955
991
  ShortcutService = __decorate([
956
992
  __decorateParam(0, ICommandService),
957
993
  __decorateParam(1, IPlatformService),
958
994
  __decorateParam(2, IContextService),
959
- __decorateParam(3, Optional(ILayoutService))
995
+ __decorateParam(3, IUIRuntimeScopeService),
996
+ __decorateParam(4, Optional(ILayoutService))
960
997
  ], ShortcutService);
961
998
 
962
999
  //#endregion
@@ -1072,6 +1109,7 @@ let RibbonStartGroup = /* @__PURE__ */ function(RibbonStartGroup) {
1072
1109
  RibbonStartGroup["HISTORY"] = "ribbon.start.history";
1073
1110
  RibbonStartGroup["FORMAT"] = "ribbon.start.format";
1074
1111
  RibbonStartGroup["LAYOUT"] = "ribbon.start.layout";
1112
+ RibbonStartGroup["NUMBER"] = "ribbon.start.number";
1075
1113
  RibbonStartGroup["OTHERS"] = "ribbon.start.others";
1076
1114
  return RibbonStartGroup;
1077
1115
  }({});
@@ -1150,7 +1188,8 @@ let MenuManagerService = _MenuManagerService = class MenuManagerService extends
1150
1188
  ["ribbon.start.history"]: { order: 0 },
1151
1189
  ["ribbon.start.format"]: { order: 1 },
1152
1190
  ["ribbon.start.layout"]: { order: 2 },
1153
- ["ribbon.start.others"]: { order: 3 }
1191
+ ["ribbon.start.number"]: { order: 3 },
1192
+ ["ribbon.start.others"]: { order: 4 }
1154
1193
  },
1155
1194
  ["ribbon.insert"]: {
1156
1195
  order: 1,
@@ -1298,7 +1337,8 @@ let MenuManagerService = _MenuManagerService = class MenuManagerService extends
1298
1337
  quickLayout: value.quickLayout,
1299
1338
  quickColumns: value.quickColumns,
1300
1339
  quickLayoutVariant: value.quickLayoutVariant,
1301
- tiny: value.tiny
1340
+ tiny: value.tiny,
1341
+ gridLayout: value.gridLayout
1302
1342
  };
1303
1343
  if (value.menuItemFactory) {
1304
1344
  const item = this._injector.invoke(value.menuItemFactory);
@@ -1409,6 +1449,10 @@ ShortcutPanelController = __decorate([
1409
1449
  __decorateParam(2, ICommandService)
1410
1450
  ], ShortcutPanelController);
1411
1451
 
1452
+ //#endregion
1453
+ //#region src/services/dialog/dialog.service.ts
1454
+ const IDialogService = createIdentifier("univer.ui.dialog-service");
1455
+
1412
1456
  //#endregion
1413
1457
  //#region src/services/menu/menu.ts
1414
1458
  let MenuItemType = /* @__PURE__ */ function(MenuItemType) {
@@ -1427,7 +1471,372 @@ function isMenuButtonSelectorItem(v) {
1427
1471
  }
1428
1472
 
1429
1473
  //#endregion
1430
- //#region src/controllers/menus/menus.ts
1474
+ //#region src/services/ribbon/ribbon.service.ts
1475
+ const IRibbonService = createIdentifier("univer.ribbon-service");
1476
+ function isSameHiddenMap(previous, current) {
1477
+ return previous.length === current.length && previous.every((hidden, index) => hidden === current[index]);
1478
+ }
1479
+ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
1480
+ constructor(_menuManagerService, _univerInstanceService) {
1481
+ super();
1482
+ this._menuManagerService = _menuManagerService;
1483
+ this._univerInstanceService = _univerInstanceService;
1484
+ _defineProperty(this, "_ribbon$", new BehaviorSubject([]));
1485
+ _defineProperty(this, "ribbon$", this._ribbon$.asObservable());
1486
+ _defineProperty(this, "_activatedTab$", new BehaviorSubject("ribbon.start"));
1487
+ _defineProperty(this, "activatedTab$", this._activatedTab$.asObservable());
1488
+ _defineProperty(this, "_collapsedIds$", new BehaviorSubject([]));
1489
+ _defineProperty(this, "collapsedIds$", this._collapsedIds$.asObservable());
1490
+ _defineProperty(this, "_fakeToolbarVisible$", new BehaviorSubject(false));
1491
+ _defineProperty(this, "fakeToolbarVisible$", this._fakeToolbarVisible$.asObservable());
1492
+ _defineProperty(this, "_visibleContextualTabs", /* @__PURE__ */ new Set());
1493
+ _defineProperty(this, "_contextualTabs", /* @__PURE__ */ new Set());
1494
+ _defineProperty(this, "_lastNonContextualActivatedTab", "ribbon.start");
1495
+ _defineProperty(this, "_hiddenSubscription", null);
1496
+ this._initRibbonSubscription();
1497
+ }
1498
+ setActivatedTab(tab) {
1499
+ if (!this._isContextualTab(tab)) this._lastNonContextualActivatedTab = tab;
1500
+ this._activatedTab$.next(tab);
1501
+ }
1502
+ showContextualTab(tab, options) {
1503
+ this._visibleContextualTabs.add(tab);
1504
+ this._updateRibbon();
1505
+ if (options === null || options === void 0 ? void 0 : options.activate) this.setActivatedTab(tab);
1506
+ }
1507
+ hideContextualTab(tab) {
1508
+ if (!this._visibleContextualTabs.delete(tab)) return;
1509
+ this._updateRibbon();
1510
+ }
1511
+ hideAllContextualTabs() {
1512
+ if (this._visibleContextualTabs.size === 0) return;
1513
+ this._visibleContextualTabs.clear();
1514
+ this._updateRibbon();
1515
+ }
1516
+ setCollapsedIds(ids) {
1517
+ this._collapsedIds$.next(ids);
1518
+ }
1519
+ setFakeToolbarVisible(visible) {
1520
+ this._fakeToolbarVisible$.next(visible);
1521
+ }
1522
+ _initRibbonSubscription() {
1523
+ this.disposeWithMe(combineLatest([this._menuManagerService.menuChanged$.pipe(startWith$1(void 0)), this._univerInstanceService.focused$.pipe(startWith$1(void 0), distinctUntilChanged$1())]).subscribe(() => {
1524
+ this._updateRibbon();
1525
+ }));
1526
+ }
1527
+ _updateRibbon() {
1528
+ var _this$_hiddenSubscrip;
1529
+ const ribbon = this._filterContextualTabs(this._menuManagerService.getMenuByPositionKey("ribbon"));
1530
+ const hiddenObservableMap = [];
1531
+ const hiddenKeyMap = [];
1532
+ for (const group of ribbon) if (group.children) {
1533
+ for (const item of group.children) if (item.children) for (const child of item.children) {
1534
+ var _child$item;
1535
+ if ((_child$item = child.item) === null || _child$item === void 0 ? void 0 : _child$item.hidden$) {
1536
+ hiddenObservableMap.push(child.item.hidden$);
1537
+ hiddenKeyMap.push(child.key);
1538
+ }
1539
+ }
1540
+ }
1541
+ (_this$_hiddenSubscrip = this._hiddenSubscription) === null || _this$_hiddenSubscrip === void 0 || _this$_hiddenSubscrip.unsubscribe();
1542
+ this._hiddenSubscription = null;
1543
+ if (hiddenObservableMap.length === 0) {
1544
+ this._setRibbon(ribbon);
1545
+ return;
1546
+ }
1547
+ this._hiddenSubscription = combineLatest(hiddenObservableMap.map((hidden$) => hidden$.pipe(startWith$1(false)))).pipe(distinctUntilChanged$1(isSameHiddenMap)).subscribe((hiddenMap) => {
1548
+ const newRibbon = [];
1549
+ const hiddenPathMap = hiddenMap.map((hidden, index) => {
1550
+ if (hidden) return hiddenKeyMap[index];
1551
+ return null;
1552
+ }).filter((item) => !!item);
1553
+ for (const group of ribbon) {
1554
+ var _group$children, _newGroup$children2;
1555
+ const newGroup = {
1556
+ ...group,
1557
+ children: []
1558
+ };
1559
+ if ((_group$children = group.children) === null || _group$children === void 0 ? void 0 : _group$children.length) for (const item of group.children) {
1560
+ var _item$children;
1561
+ const newItem = {
1562
+ ...item,
1563
+ children: []
1564
+ };
1565
+ let shouldAddItem = true;
1566
+ if ((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) {
1567
+ var _newItem$children2;
1568
+ for (const child of item.children) if (!hiddenPathMap.includes(child.key)) {
1569
+ var _newItem$children;
1570
+ (_newItem$children = newItem.children) === null || _newItem$children === void 0 || _newItem$children.push(child);
1571
+ }
1572
+ if ((_newItem$children2 = newItem.children) === null || _newItem$children2 === void 0 ? void 0 : _newItem$children2.every((child) => {
1573
+ var _child$children;
1574
+ return ((_child$children = child.children) === null || _child$children === void 0 ? void 0 : _child$children.length) === 0;
1575
+ })) shouldAddItem = false;
1576
+ }
1577
+ if (shouldAddItem) {
1578
+ var _newGroup$children;
1579
+ (_newGroup$children = newGroup.children) === null || _newGroup$children === void 0 || _newGroup$children.push(newItem);
1580
+ }
1581
+ }
1582
+ if (((_newGroup$children2 = newGroup.children) === null || _newGroup$children2 === void 0 ? void 0 : _newGroup$children2.length) && newGroup.children.every((item) => {
1583
+ var _item$children2;
1584
+ return (_item$children2 = item.children) === null || _item$children2 === void 0 ? void 0 : _item$children2.length;
1585
+ })) newRibbon.push(newGroup);
1586
+ }
1587
+ this._setRibbon(newRibbon);
1588
+ });
1589
+ }
1590
+ _filterContextualTabs(ribbon) {
1591
+ this._contextualTabs.clear();
1592
+ ribbon.forEach((group) => {
1593
+ if (group.contextual) this._contextualTabs.add(group.key);
1594
+ });
1595
+ return ribbon.filter((group) => !group.contextual || this._visibleContextualTabs.has(group.key));
1596
+ }
1597
+ _setRibbon(ribbon) {
1598
+ const activatedTab = this._activatedTab$.getValue();
1599
+ const activeGroup = ribbon.find((group) => group.key === activatedTab);
1600
+ if (!activeGroup && this._contextualTabs.has(activatedTab)) {
1601
+ var _ref, _ribbon$find;
1602
+ const fallbackTab = (_ref = (_ribbon$find = ribbon.find((group) => group.key === this._lastNonContextualActivatedTab && !group.contextual)) !== null && _ribbon$find !== void 0 ? _ribbon$find : ribbon.find((group) => group.key === "ribbon.start")) !== null && _ref !== void 0 ? _ref : ribbon[0];
1603
+ if (fallbackTab) this._activatedTab$.next(fallbackTab.key);
1604
+ } else if (!activeGroup && ribbon.some((group) => group.key === "ribbon.start")) {
1605
+ const fallbackTab = ribbon.find((group) => group.key === "ribbon.start");
1606
+ this._activatedTab$.next(fallbackTab.key);
1607
+ if (!fallbackTab.contextual) this._lastNonContextualActivatedTab = fallbackTab.key;
1608
+ } else if (activeGroup && !activeGroup.contextual) this._lastNonContextualActivatedTab = activeGroup.key;
1609
+ this._ribbon$.next(ribbon);
1610
+ }
1611
+ _isContextualTab(tab) {
1612
+ return this._contextualTabs.has(tab) || this._ribbon$.getValue().some((group) => group.key === tab && group.contextual);
1613
+ }
1614
+ dispose() {
1615
+ var _this$_hiddenSubscrip2;
1616
+ (_this$_hiddenSubscrip2 = this._hiddenSubscription) === null || _this$_hiddenSubscrip2 === void 0 || _this$_hiddenSubscrip2.unsubscribe();
1617
+ this._hiddenSubscription = null;
1618
+ this._ribbon$.next([]);
1619
+ this._ribbon$.complete();
1620
+ this._activatedTab$.complete();
1621
+ this._collapsedIds$.complete();
1622
+ this._fakeToolbarVisible$.complete();
1623
+ super.dispose();
1624
+ }
1625
+ };
1626
+ DesktopRibbonService = __decorate([__decorateParam(0, IMenuManagerService), __decorateParam(1, IUniverInstanceService)], DesktopRibbonService);
1627
+
1628
+ //#endregion
1629
+ //#region src/utils/di.ts
1630
+ function unwrap(o) {
1631
+ if (typeof o === "function") return o();
1632
+ return o;
1633
+ }
1634
+ function useObservableRef(observable, defaultValue) {
1635
+ const ref = useRef(defaultValue);
1636
+ useEffect(() => {
1637
+ if (observable) {
1638
+ const sub = unwrap(observable).subscribe((value) => {
1639
+ ref.current = value;
1640
+ });
1641
+ return () => sub.unsubscribe();
1642
+ }
1643
+ }, [observable]);
1644
+ return ref;
1645
+ }
1646
+
1647
+ //#endregion
1648
+ //#region src/views/components/feature-search/FeatureSearch.tsx
1649
+ const FEATURE_SEARCH_COMPONENT = "FeatureSearch";
1650
+ const FEATURE_SEARCH_DIALOG_ID = "FEATURE_SEARCH_DIALOG";
1651
+ function resolveParams(item, value) {
1652
+ const params = typeof item.params === "function" ? item.params() : item.params;
1653
+ return params !== null && params !== void 0 ? params : value === void 0 ? void 0 : { value };
1654
+ }
1655
+ function resolveOptionParams(option) {
1656
+ const params = typeof option.params === "function" ? option.params(option.value) : option.params;
1657
+ return params !== null && params !== void 0 ? params : option.value === void 0 ? void 0 : { value: option.value };
1658
+ }
1659
+ function deduplicate(items) {
1660
+ return items.filter((item, index) => items.findIndex((candidate) => candidate.commandId === item.commandId && Tools.diffValue(candidate.params, item.params)) === index);
1661
+ }
1662
+ function FeatureSearch() {
1663
+ const menuManagerService = useDependency(IMenuManagerService);
1664
+ const localeService = useDependency(LocaleService);
1665
+ const commandService = useDependency(ICommandService);
1666
+ const dialogService = useDependency(IDialogService);
1667
+ const layoutService = useDependency(ILayoutService);
1668
+ const ribbonService = useDependency(IRibbonService);
1669
+ const items = useObservable(useMemo(() => {
1670
+ function getItemTitle(item) {
1671
+ var _ref, _item$title;
1672
+ const titleKey = (_ref = (_item$title = item.title) !== null && _item$title !== void 0 ? _item$title : item.tooltip) !== null && _ref !== void 0 ? _ref : item.description;
1673
+ return titleKey ? localeService.t(titleKey) : "";
1674
+ }
1675
+ function collectCandidates(schemas, path, keyPath, ancestors = [], parentTitle) {
1676
+ return schemas.flatMap((schema, index) => {
1677
+ var _schema$title;
1678
+ const schemaTitle = localeService.t((_schema$title = schema.title) !== null && _schema$title !== void 0 ? _schema$title : "");
1679
+ const schemaPath = schemaTitle ? [...path, schemaTitle] : path;
1680
+ const schemaKeyPath = [...keyPath, `${schema.key}:${index}`];
1681
+ const result = [];
1682
+ if (schema.item) result.push({
1683
+ key: `${schemaKeyPath.join("/")}:item`,
1684
+ item: schema.item,
1685
+ path: schemaPath,
1686
+ ancestors,
1687
+ parentTitle
1688
+ });
1689
+ if (schema.headerActionItem) result.push({
1690
+ key: `${schemaKeyPath.join("/")}:header`,
1691
+ item: schema.headerActionItem,
1692
+ path: schemaPath,
1693
+ ancestors,
1694
+ parentTitle
1695
+ });
1696
+ if (schema.children) result.push(...collectCandidates(schema.children, schemaPath, schemaKeyPath, schema.item ? [...ancestors, schema.item] : ancestors, schema.item ? getItemTitle(schema.item) : parentTitle));
1697
+ return result;
1698
+ });
1699
+ }
1700
+ function observeCandidate(candidate) {
1701
+ var _item$hidden$$pipe, _item$hidden$, _item$disabled$$pipe, _item$disabled$, _item$value$$pipe, _item$value$;
1702
+ const { item } = candidate;
1703
+ const hasOptions = item.type === 1 || item.type === 2;
1704
+ const selections = hasOptions ? item.selections : void 0;
1705
+ const selections$ = isObservable(selections) ? selections.pipe(startWith$1([])) : of(selections !== null && selections !== void 0 ? selections : []);
1706
+ return combineLatest([
1707
+ candidate.ancestors.length ? combineLatest(candidate.ancestors.map((ancestor) => {
1708
+ var _ancestor$hidden$$pip, _ancestor$hidden$;
1709
+ return (_ancestor$hidden$$pip = (_ancestor$hidden$ = ancestor.hidden$) === null || _ancestor$hidden$ === void 0 ? void 0 : _ancestor$hidden$.pipe(startWith$1(true))) !== null && _ancestor$hidden$$pip !== void 0 ? _ancestor$hidden$$pip : of(false);
1710
+ })).pipe(map$1((states) => states.some(Boolean))) : of(false),
1711
+ candidate.ancestors.length ? combineLatest(candidate.ancestors.map((ancestor) => {
1712
+ var _ancestor$disabled$$p, _ancestor$disabled$;
1713
+ return (_ancestor$disabled$$p = (_ancestor$disabled$ = ancestor.disabled$) === null || _ancestor$disabled$ === void 0 ? void 0 : _ancestor$disabled$.pipe(startWith$1(true))) !== null && _ancestor$disabled$$p !== void 0 ? _ancestor$disabled$$p : of(false);
1714
+ })).pipe(map$1((states) => states.some(Boolean))) : of(false),
1715
+ (_item$hidden$$pipe = (_item$hidden$ = item.hidden$) === null || _item$hidden$ === void 0 ? void 0 : _item$hidden$.pipe(startWith$1(true))) !== null && _item$hidden$$pipe !== void 0 ? _item$hidden$$pipe : of(false),
1716
+ (_item$disabled$$pipe = (_item$disabled$ = item.disabled$) === null || _item$disabled$ === void 0 ? void 0 : _item$disabled$.pipe(startWith$1(true))) !== null && _item$disabled$$pipe !== void 0 ? _item$disabled$$pipe : of(false),
1717
+ (_item$value$$pipe = (_item$value$ = item.value$) === null || _item$value$ === void 0 ? void 0 : _item$value$.pipe(startWith$1(void 0))) !== null && _item$value$$pipe !== void 0 ? _item$value$$pipe : of(void 0),
1718
+ selections$
1719
+ ]).pipe(map$1(([ancestorHidden, ancestorDisabled, hidden, disabled, value, options]) => {
1720
+ if (ancestorHidden || ancestorDisabled || hidden || disabled) return [];
1721
+ const title = getItemTitle(item);
1722
+ const path = candidate.path.join(" / ");
1723
+ const result = [];
1724
+ if (title && item.type !== 1 && item.type !== 3) {
1725
+ var _item$description, _item$commandId;
1726
+ result.push({
1727
+ key: candidate.key,
1728
+ title,
1729
+ parentTitle: candidate.parentTitle,
1730
+ description: localeService.t((_item$description = item.description) !== null && _item$description !== void 0 ? _item$description : ""),
1731
+ path,
1732
+ commandId: (_item$commandId = item.commandId) !== null && _item$commandId !== void 0 ? _item$commandId : item.id,
1733
+ params: resolveParams(item, value),
1734
+ getParams: () => resolveParams(item, value)
1735
+ });
1736
+ }
1737
+ if (hasOptions) options.forEach((option, index) => {
1738
+ var _ref2, _ref3, _ref4, _option$commandId, _ref5, _ref6, _option$id;
1739
+ if (option.disabled || typeof option.label !== "string") return;
1740
+ const commandId = (_ref2 = (_ref3 = (_ref4 = (_option$commandId = option.commandId) !== null && _option$commandId !== void 0 ? _option$commandId : option.id) !== null && _ref4 !== void 0 ? _ref4 : item.selectionsCommandId) !== null && _ref3 !== void 0 ? _ref3 : item.commandId) !== null && _ref2 !== void 0 ? _ref2 : item.id;
1741
+ result.push({
1742
+ key: `${candidate.key}:option:${(_ref5 = (_ref6 = (_option$id = option.id) !== null && _option$id !== void 0 ? _option$id : option.commandId) !== null && _ref6 !== void 0 ? _ref6 : option.value) !== null && _ref5 !== void 0 ? _ref5 : index}`,
1743
+ title: localeService.t(option.label),
1744
+ parentTitle: title,
1745
+ description: "",
1746
+ path,
1747
+ commandId,
1748
+ params: resolveOptionParams(option),
1749
+ getParams: () => resolveOptionParams(option)
1750
+ });
1751
+ });
1752
+ return result;
1753
+ }));
1754
+ }
1755
+ return combineLatest([ribbonService.ribbon$, merge$1(of(void 0), menuManagerService.menuChanged$, localeService.localeChanged$)]).pipe(switchMap$1(([ribbon]) => {
1756
+ const candidates = [...collectCandidates(ribbon, [localeService.t("ui.featureSearch.ribbon")], ["ribbon"]), ...collectCandidates(menuManagerService.getMenuByPositionKey("contextMenu"), [localeService.t("ui.featureSearch.contextMenu")], ["contextMenu"])];
1757
+ if (candidates.length === 0) return of([]);
1758
+ return combineLatest(candidates.map(observeCandidate)).pipe(map$1((items) => deduplicate(items.flat())));
1759
+ }));
1760
+ }, [
1761
+ localeService,
1762
+ menuManagerService,
1763
+ ribbonService
1764
+ ]), []);
1765
+ async function execute(item) {
1766
+ layoutService.focus();
1767
+ if (await commandService.executeCommand(item.commandId, item.getParams())) dialogService.close(FEATURE_SEARCH_DIALOG_ID);
1768
+ }
1769
+ return /* @__PURE__ */ jsxs(Command, {
1770
+ label: localeService.t("ui.featureSearch.title"),
1771
+ loop: true,
1772
+ children: [/* @__PURE__ */ jsx(CommandInput, {
1773
+ autoFocus: true,
1774
+ placeholder: localeService.t("ui.featureSearch.placeholder")
1775
+ }), /* @__PURE__ */ jsxs(CommandList, { children: [/* @__PURE__ */ jsx(CommandEmpty, { children: localeService.t("ui.featureSearch.empty") }), /* @__PURE__ */ jsx(CommandGroup, { children: items.map((item) => {
1776
+ var _item$parentTitle;
1777
+ return /* @__PURE__ */ jsxs(CommandItem, {
1778
+ value: item.key,
1779
+ keywords: [
1780
+ (_item$parentTitle = item.parentTitle) !== null && _item$parentTitle !== void 0 ? _item$parentTitle : "",
1781
+ item.title,
1782
+ item.description,
1783
+ item.path
1784
+ ],
1785
+ onSelect: () => execute(item),
1786
+ children: [/* @__PURE__ */ jsxs("span", {
1787
+ className: "univer-flex univer-min-w-0 univer-flex-1 univer-items-center univer-gap-1",
1788
+ children: [item.parentTitle && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
1789
+ className: "univer-shrink-0",
1790
+ children: item.parentTitle
1791
+ }), /* @__PURE__ */ jsx("span", {
1792
+ className: "univer-text-gray-400",
1793
+ children: "/"
1794
+ })] }), /* @__PURE__ */ jsx("span", {
1795
+ className: "univer-truncate",
1796
+ children: item.title
1797
+ })]
1798
+ }), item.path && /* @__PURE__ */ jsx("span", {
1799
+ className: "univer-max-w-1/2 univer-truncate univer-text-xs univer-text-gray-400",
1800
+ children: item.path
1801
+ })]
1802
+ }, item.key);
1803
+ }) })] })]
1804
+ });
1805
+ }
1806
+
1807
+ //#endregion
1808
+ //#region src/commands/operations/open-feature-search.operation.ts
1809
+ const OpenFeatureSearchOperation = {
1810
+ id: "ui.operation.open-feature-search",
1811
+ type: CommandType.OPERATION,
1812
+ handler: (accessor) => {
1813
+ const dialogService = accessor.get(IDialogService);
1814
+ const localeService = accessor.get(LocaleService);
1815
+ dialogService.open({
1816
+ id: FEATURE_SEARCH_DIALOG_ID,
1817
+ width: 560,
1818
+ title: { title: localeService.t("ui.featureSearch.title") },
1819
+ children: { label: FEATURE_SEARCH_COMPONENT },
1820
+ onClose: () => dialogService.close(FEATURE_SEARCH_DIALOG_ID)
1821
+ });
1822
+ return true;
1823
+ }
1824
+ };
1825
+
1826
+ //#endregion
1827
+ //#region src/menu/feature-search.menu.ts
1828
+ function FeatureSearchMenuItemFactory() {
1829
+ return {
1830
+ id: OpenFeatureSearchOperation.id,
1831
+ title: "ui.featureSearch.title",
1832
+ tooltip: "ui.featureSearch.title",
1833
+ icon: "FeatureSearchIcon",
1834
+ type: 0
1835
+ };
1836
+ }
1837
+
1838
+ //#endregion
1839
+ //#region src/menu/history.menu.ts
1431
1840
  const undoRedoDisableFactory$ = (accessor, isUndo) => {
1432
1841
  const undoRedoService = accessor.get(IUndoRedoService);
1433
1842
  const contextService = accessor.get(IContextService);
@@ -1460,13 +1869,13 @@ function RedoMenuItemFactory(accessor) {
1460
1869
  }
1461
1870
 
1462
1871
  //#endregion
1463
- //#region src/controllers/shortcut-display/menu.ts
1872
+ //#region src/menu/shortcut-panel.menu.ts
1464
1873
  function ShortcutPanelMenuItemFactory() {
1465
1874
  return {
1466
1875
  id: ToggleShortcutPanelOperation.id,
1467
1876
  title: "ui.toggle-shortcut-panel",
1468
1877
  tooltip: "ui.toggle-shortcut-panel",
1469
- icon: "ShortcutIcon",
1878
+ icon: "KeyboardIcon",
1470
1879
  type: 0
1471
1880
  };
1472
1881
  }
@@ -1477,17 +1886,33 @@ const menuSchema = {
1477
1886
  ["ribbon.start.history"]: {
1478
1887
  [UndoCommand.id]: {
1479
1888
  order: 0,
1889
+ gridLayout: {
1890
+ row: 1,
1891
+ column: 1,
1892
+ iconSize: 18
1893
+ },
1480
1894
  menuItemFactory: UndoMenuItemFactory
1481
1895
  },
1482
1896
  [RedoCommand.id]: {
1483
1897
  order: 1,
1898
+ gridLayout: {
1899
+ row: 2,
1900
+ column: 1,
1901
+ iconSize: 18
1902
+ },
1484
1903
  menuItemFactory: RedoMenuItemFactory
1485
1904
  }
1486
1905
  },
1487
- ["ribbon.start.others"]: { [ToggleShortcutPanelOperation.id]: {
1488
- order: 1,
1489
- menuItemFactory: ShortcutPanelMenuItemFactory
1490
- } }
1906
+ ["ribbon.start.others"]: {
1907
+ [ToggleShortcutPanelOperation.id]: {
1908
+ order: 1,
1909
+ menuItemFactory: ShortcutPanelMenuItemFactory
1910
+ },
1911
+ [OpenFeatureSearchOperation.id]: {
1912
+ order: 2,
1913
+ menuItemFactory: FeatureSearchMenuItemFactory
1914
+ }
1915
+ }
1491
1916
  };
1492
1917
 
1493
1918
  //#endregion
@@ -1552,25 +1977,6 @@ var UIPartsService = class extends Disposable {
1552
1977
  }
1553
1978
  };
1554
1979
 
1555
- //#endregion
1556
- //#region src/utils/di.ts
1557
- function unwrap(o) {
1558
- if (typeof o === "function") return o();
1559
- return o;
1560
- }
1561
- function useObservableRef(observable, defaultValue) {
1562
- const ref = useRef(defaultValue);
1563
- useEffect(() => {
1564
- if (observable) {
1565
- const sub = unwrap(observable).subscribe((value) => {
1566
- ref.current = value;
1567
- });
1568
- return () => sub.unsubscribe();
1569
- }
1570
- }, [observable]);
1571
- return ref;
1572
- }
1573
-
1574
1980
  //#endregion
1575
1981
  //#region src/services/dom/canvas-dom-layer.service.ts
1576
1982
  function shouldForwardFloatDomEvents(layer) {
@@ -2167,160 +2573,6 @@ var RibbonOverrideService = class extends Disposable {
2167
2573
  }
2168
2574
  };
2169
2575
 
2170
- //#endregion
2171
- //#region src/services/ribbon/ribbon.service.ts
2172
- const IRibbonService = createIdentifier("univer.ribbon-service");
2173
- function isSameHiddenMap(previous, current) {
2174
- return previous.length === current.length && previous.every((hidden, index) => hidden === current[index]);
2175
- }
2176
- let DesktopRibbonService = class DesktopRibbonService extends Disposable {
2177
- constructor(_menuManagerService, _univerInstanceService) {
2178
- super();
2179
- this._menuManagerService = _menuManagerService;
2180
- this._univerInstanceService = _univerInstanceService;
2181
- _defineProperty(this, "_ribbon$", new BehaviorSubject([]));
2182
- _defineProperty(this, "ribbon$", this._ribbon$.asObservable());
2183
- _defineProperty(this, "_activatedTab$", new BehaviorSubject("ribbon.start"));
2184
- _defineProperty(this, "activatedTab$", this._activatedTab$.asObservable());
2185
- _defineProperty(this, "_collapsedIds$", new BehaviorSubject([]));
2186
- _defineProperty(this, "collapsedIds$", this._collapsedIds$.asObservable());
2187
- _defineProperty(this, "_fakeToolbarVisible$", new BehaviorSubject(false));
2188
- _defineProperty(this, "fakeToolbarVisible$", this._fakeToolbarVisible$.asObservable());
2189
- _defineProperty(this, "_visibleContextualTabs", /* @__PURE__ */ new Set());
2190
- _defineProperty(this, "_contextualTabs", /* @__PURE__ */ new Set());
2191
- _defineProperty(this, "_lastNonContextualActivatedTab", "ribbon.start");
2192
- _defineProperty(this, "_hiddenSubscription", null);
2193
- this._initRibbonSubscription();
2194
- }
2195
- setActivatedTab(tab) {
2196
- if (!this._isContextualTab(tab)) this._lastNonContextualActivatedTab = tab;
2197
- this._activatedTab$.next(tab);
2198
- }
2199
- showContextualTab(tab, options) {
2200
- this._visibleContextualTabs.add(tab);
2201
- this._updateRibbon();
2202
- if (options === null || options === void 0 ? void 0 : options.activate) this.setActivatedTab(tab);
2203
- }
2204
- hideContextualTab(tab) {
2205
- if (!this._visibleContextualTabs.delete(tab)) return;
2206
- this._updateRibbon();
2207
- }
2208
- hideAllContextualTabs() {
2209
- if (this._visibleContextualTabs.size === 0) return;
2210
- this._visibleContextualTabs.clear();
2211
- this._updateRibbon();
2212
- }
2213
- setCollapsedIds(ids) {
2214
- this._collapsedIds$.next(ids);
2215
- }
2216
- setFakeToolbarVisible(visible) {
2217
- this._fakeToolbarVisible$.next(visible);
2218
- }
2219
- _initRibbonSubscription() {
2220
- this.disposeWithMe(combineLatest([this._menuManagerService.menuChanged$.pipe(startWith$1(void 0)), this._univerInstanceService.focused$.pipe(startWith$1(void 0), distinctUntilChanged$1())]).subscribe(() => {
2221
- this._updateRibbon();
2222
- }));
2223
- }
2224
- _updateRibbon() {
2225
- var _this$_hiddenSubscrip;
2226
- const ribbon = this._filterContextualTabs(this._menuManagerService.getMenuByPositionKey("ribbon"));
2227
- const hiddenObservableMap = [];
2228
- const hiddenKeyMap = [];
2229
- for (const group of ribbon) if (group.children) {
2230
- for (const item of group.children) if (item.children) for (const child of item.children) {
2231
- var _child$item;
2232
- if ((_child$item = child.item) === null || _child$item === void 0 ? void 0 : _child$item.hidden$) {
2233
- hiddenObservableMap.push(child.item.hidden$);
2234
- hiddenKeyMap.push(child.key);
2235
- }
2236
- }
2237
- }
2238
- if (hiddenObservableMap.length === 0) {
2239
- this._setRibbon(ribbon);
2240
- return;
2241
- }
2242
- (_this$_hiddenSubscrip = this._hiddenSubscription) === null || _this$_hiddenSubscrip === void 0 || _this$_hiddenSubscrip.unsubscribe();
2243
- this._hiddenSubscription = combineLatest(hiddenObservableMap).pipe(startWith$1(new Array(hiddenObservableMap.length).fill(false)), distinctUntilChanged$1(isSameHiddenMap)).subscribe((hiddenMap) => {
2244
- const newRibbon = [];
2245
- const hiddenPathMap = hiddenMap.map((hidden, index) => {
2246
- if (hidden) return hiddenKeyMap[index];
2247
- return null;
2248
- }).filter((item) => !!item);
2249
- for (const group of ribbon) {
2250
- var _group$children, _newGroup$children2;
2251
- const newGroup = {
2252
- ...group,
2253
- children: []
2254
- };
2255
- if ((_group$children = group.children) === null || _group$children === void 0 ? void 0 : _group$children.length) for (const item of group.children) {
2256
- var _item$children;
2257
- const newItem = {
2258
- ...item,
2259
- children: []
2260
- };
2261
- let shouldAddItem = true;
2262
- if ((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) {
2263
- var _newItem$children2;
2264
- for (const child of item.children) if (!hiddenPathMap.includes(child.key)) {
2265
- var _newItem$children;
2266
- (_newItem$children = newItem.children) === null || _newItem$children === void 0 || _newItem$children.push(child);
2267
- }
2268
- if ((_newItem$children2 = newItem.children) === null || _newItem$children2 === void 0 ? void 0 : _newItem$children2.every((child) => {
2269
- var _child$children;
2270
- return ((_child$children = child.children) === null || _child$children === void 0 ? void 0 : _child$children.length) === 0;
2271
- })) shouldAddItem = false;
2272
- }
2273
- if (shouldAddItem) {
2274
- var _newGroup$children;
2275
- (_newGroup$children = newGroup.children) === null || _newGroup$children === void 0 || _newGroup$children.push(newItem);
2276
- }
2277
- }
2278
- if (((_newGroup$children2 = newGroup.children) === null || _newGroup$children2 === void 0 ? void 0 : _newGroup$children2.length) && newGroup.children.every((item) => {
2279
- var _item$children2;
2280
- return (_item$children2 = item.children) === null || _item$children2 === void 0 ? void 0 : _item$children2.length;
2281
- })) newRibbon.push(newGroup);
2282
- }
2283
- this._setRibbon(newRibbon);
2284
- });
2285
- }
2286
- _filterContextualTabs(ribbon) {
2287
- this._contextualTabs.clear();
2288
- ribbon.forEach((group) => {
2289
- if (group.contextual) this._contextualTabs.add(group.key);
2290
- });
2291
- return ribbon.filter((group) => !group.contextual || this._visibleContextualTabs.has(group.key));
2292
- }
2293
- _setRibbon(ribbon) {
2294
- const activatedTab = this._activatedTab$.getValue();
2295
- const activeGroup = ribbon.find((group) => group.key === activatedTab);
2296
- if (!activeGroup && this._contextualTabs.has(activatedTab)) {
2297
- var _ref, _ribbon$find;
2298
- const fallbackTab = (_ref = (_ribbon$find = ribbon.find((group) => group.key === this._lastNonContextualActivatedTab && !group.contextual)) !== null && _ribbon$find !== void 0 ? _ribbon$find : ribbon.find((group) => group.key === "ribbon.start")) !== null && _ref !== void 0 ? _ref : ribbon[0];
2299
- if (fallbackTab) this._activatedTab$.next(fallbackTab.key);
2300
- } else if (!activeGroup && ribbon.some((group) => group.key === "ribbon.start")) {
2301
- const fallbackTab = ribbon.find((group) => group.key === "ribbon.start");
2302
- this._activatedTab$.next(fallbackTab.key);
2303
- if (!fallbackTab.contextual) this._lastNonContextualActivatedTab = fallbackTab.key;
2304
- } else if (activeGroup && !activeGroup.contextual) this._lastNonContextualActivatedTab = activeGroup.key;
2305
- this._ribbon$.next(ribbon);
2306
- }
2307
- _isContextualTab(tab) {
2308
- return this._contextualTabs.has(tab) || this._ribbon$.getValue().some((group) => group.key === tab && group.contextual);
2309
- }
2310
- dispose() {
2311
- var _this$_hiddenSubscrip2;
2312
- (_this$_hiddenSubscrip2 = this._hiddenSubscription) === null || _this$_hiddenSubscrip2 === void 0 || _this$_hiddenSubscrip2.unsubscribe();
2313
- this._hiddenSubscription = null;
2314
- this._ribbon$.next([]);
2315
- this._ribbon$.complete();
2316
- this._activatedTab$.complete();
2317
- this._collapsedIds$.complete();
2318
- this._fakeToolbarVisible$.complete();
2319
- super.dispose();
2320
- }
2321
- };
2322
- DesktopRibbonService = __decorate([__decorateParam(0, IMenuManagerService), __decorateParam(1, IUniverInstanceService)], DesktopRibbonService);
2323
-
2324
2576
  //#endregion
2325
2577
  //#region src/views/components/ComponentContainer.tsx
2326
2578
  function ComponentContainer(props) {
@@ -2426,88 +2678,103 @@ function DefaultMenu({ ribbon, activatedTab, onSelectTab }) {
2426
2678
  })
2427
2679
  }),
2428
2680
  onOpenChange: setGroupSelectorVisible,
2429
- children: /* @__PURE__ */ jsxs("a", {
2430
- className: "univer-mr-2 univer-flex univer-h-7 univer-cursor-pointer univer-items-center univer-gap-1.5 univer-whitespace-nowrap !univer-rounded-full univer-bg-gray-700 univer-pl-3 univer-pr-2 univer-text-sm univer-text-white dark:!univer-bg-gray-200 dark:!univer-text-gray-800",
2431
- onClick: () => setGroupSelectorVisible(true),
2432
- children: [localeService.t(activatedTabTitle), /* @__PURE__ */ jsx(MoreDownIcon, { className: "univer-text-gray-200 dark:!univer-text-gray-500" })]
2433
- })
2434
- });
2435
- }
2436
-
2437
- //#endregion
2438
- //#region src/views/components/ribbon/ToolbarButton.tsx
2439
- /**
2440
- * Copyright 2023-present DreamNum Co., Ltd.
2441
- *
2442
- * Licensed under the Apache License, Version 2.0 (the "License");
2443
- * you may not use this file except in compliance with the License.
2444
- * You may obtain a copy of the License at
2445
- *
2446
- * http://www.apache.org/licenses/LICENSE-2.0
2447
- *
2448
- * Unless required by applicable law or agreed to in writing, software
2449
- * distributed under the License is distributed on an "AS IS" BASIS,
2450
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2451
- * See the License for the specific language governing permissions and
2452
- * limitations under the License.
2453
- */
2454
- const toolbarButtonClassName = `
2455
- univer-box-border univer-flex univer-h-6 univer-min-w-6 univer-cursor-pointer univer-items-center
2456
- univer-justify-center univer-rounded univer-border-none univer-bg-transparent univer-p-0
2457
- univer-text-gray-900 univer-outline-none univer-transition-colors univer-animate-in univer-fade-in
2458
- dark:!univer-text-white dark:hover:!univer-bg-gray-700 dark:disabled:!univer-text-gray-600
2459
- disabled:univer-cursor-not-allowed disabled:univer-text-gray-300 disabled:hover:univer-bg-transparent
2460
- hover:univer-bg-gray-100 whitespace-nowrap univer-w-max
2461
- `;
2462
- const toolbarButtonVariants = cva(toolbarButtonClassName, {
2463
- variants: {
2464
- noIcon: {
2465
- true: "univer-px-2",
2466
- false: ""
2467
- },
2468
- active: {
2469
- true: "!univer-bg-gray-200 dark:!univer-bg-gray-500",
2470
- false: ""
2681
+ children: /* @__PURE__ */ jsxs("a", {
2682
+ className: "univer-mr-2 univer-flex univer-h-7 univer-cursor-pointer univer-items-center univer-gap-1.5 univer-whitespace-nowrap !univer-rounded-full univer-bg-gray-700 univer-pl-3 univer-pr-2 univer-text-sm univer-text-white dark:!univer-bg-gray-200 dark:!univer-text-gray-800",
2683
+ onClick: () => setGroupSelectorVisible(true),
2684
+ children: [localeService.t(activatedTabTitle), /* @__PURE__ */ jsx(MoreDownIcon, { className: "univer-text-gray-200 dark:!univer-text-gray-500" })]
2685
+ })
2686
+ });
2687
+ }
2688
+
2689
+ //#endregion
2690
+ //#region src/views/components/ribbon/ribbon-menu/RibbonGridMenu.tsx
2691
+ function RibbonGridMenu({ ribbon, activatedTab, onSelectTab }) {
2692
+ const localeService = useDependency(LocaleService);
2693
+ return /* @__PURE__ */ jsx("div", {
2694
+ "data-testid": "ribbon-grid-menu",
2695
+ "data-u-comp": "ribbon-grid-menu",
2696
+ 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",
2697
+ role: "tablist",
2698
+ children: ribbon.map((group) => {
2699
+ const isActive = activatedTab === group.key;
2700
+ const title = localeService.t(group.title || group.key);
2701
+ return /* @__PURE__ */ jsx("button", {
2702
+ type: "button",
2703
+ role: "tab",
2704
+ "aria-selected": isActive,
2705
+ title,
2706
+ onClick: () => onSelectTab(group),
2707
+ className: clsx("univer-relative univer-flex univer-h-9 univer-cursor-pointer univer-items-center univer-whitespace-nowrap univer-border-0 univer-border-b-[3px] univer-bg-transparent univer-px-3 univer-text-base 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-white", isActive ? "univer-border-primary-600 univer-text-primary-700 dark:!univer-text-primary-300" : "univer-border-transparent"),
2708
+ children: title
2709
+ }, group.key);
2710
+ })
2711
+ });
2712
+ }
2713
+
2714
+ //#endregion
2715
+ //#region src/views/components/ribbon/ribbon-grid-layout.ts
2716
+ const RIBBON_GRID_ROWS = 2;
2717
+ function placeRibbonGridItems(items) {
2718
+ const occupied = /* @__PURE__ */ new Set();
2719
+ const placements = /* @__PURE__ */ new Map();
2720
+ const fallbackItems = [];
2721
+ let maxExplicitColumn = 0;
2722
+ for (const item of items) {
2723
+ var _layout$rowSpan, _layout$columnSpan, _layout$showLabel;
2724
+ const layout = item.gridLayout;
2725
+ if (!layout) {
2726
+ fallbackItems.push(item);
2727
+ continue;
2471
2728
  }
2472
- },
2473
- defaultVariants: {
2474
- noIcon: false,
2475
- active: false
2476
- }
2477
- });
2478
- /**
2479
- * Button Component
2480
- */
2481
- function ToolbarButton(props) {
2482
- const { children, className, style, disabled = false, active = false, noIcon, onClick, onDoubleClick, ...restProps } = props;
2483
- const handleClick = (e) => {
2484
- if (disabled) {
2485
- e.preventDefault();
2486
- return;
2729
+ const rowSpan = (_layout$rowSpan = layout.rowSpan) !== null && _layout$rowSpan !== void 0 ? _layout$rowSpan : 1;
2730
+ const columnSpan = (_layout$columnSpan = layout.columnSpan) !== null && _layout$columnSpan !== void 0 ? _layout$columnSpan : 1;
2731
+ const cells = getCells(layout.row, layout.column, rowSpan, columnSpan);
2732
+ if (!(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) && cells.every((cell) => !occupied.has(cell)))) {
2733
+ fallbackItems.push(item);
2734
+ continue;
2487
2735
  }
2488
- onClick && onClick(e);
2489
- };
2490
- const handleDoubleClick = (e) => {
2491
- if (disabled) {
2492
- e.preventDefault();
2493
- return;
2736
+ cells.forEach((cell) => occupied.add(cell));
2737
+ maxExplicitColumn = Math.max(maxExplicitColumn, layout.column + columnSpan - 1);
2738
+ placements.set(item, {
2739
+ item,
2740
+ row: layout.row,
2741
+ column: layout.column,
2742
+ rowSpan,
2743
+ columnSpan,
2744
+ showLabel: (_layout$showLabel = layout.showLabel) !== null && _layout$showLabel !== void 0 ? _layout$showLabel : false,
2745
+ width: layout.width,
2746
+ iconSize: layout.iconSize
2747
+ });
2748
+ }
2749
+ let fallbackRow = 1;
2750
+ let fallbackColumn = maxExplicitColumn + 1;
2751
+ for (const item of fallbackItems) {
2752
+ placements.set(item, {
2753
+ item,
2754
+ row: fallbackRow,
2755
+ column: fallbackColumn,
2756
+ rowSpan: 1,
2757
+ columnSpan: 1,
2758
+ showLabel: false
2759
+ });
2760
+ fallbackRow += 1;
2761
+ if (fallbackRow > RIBBON_GRID_ROWS) {
2762
+ fallbackRow = 1;
2763
+ fallbackColumn += 1;
2494
2764
  }
2495
- onDoubleClick && onDoubleClick(e);
2496
- };
2497
- return /* @__PURE__ */ jsx("button", {
2498
- type: "button",
2499
- className: toolbarButtonVariants({
2500
- noIcon,
2501
- active,
2502
- className
2503
- }),
2504
- style,
2505
- disabled,
2506
- onClick: handleClick,
2507
- onDoubleClick: handleDoubleClick,
2508
- ...restProps,
2509
- children
2510
- });
2765
+ }
2766
+ return items.map((item) => placements.get(item));
2767
+ }
2768
+ function getCells(row, column, rowSpan, columnSpan) {
2769
+ if (![
2770
+ row,
2771
+ column,
2772
+ rowSpan,
2773
+ columnSpan
2774
+ ].every(Number.isInteger) || Math.min(row, column, rowSpan, columnSpan) < 1) return [];
2775
+ const cells = [];
2776
+ for (let currentRow = row; currentRow < row + rowSpan; currentRow++) for (let currentColumn = column; currentColumn < column + columnSpan; currentColumn++) cells.push(`${currentRow}:${currentColumn}`);
2777
+ return cells;
2511
2778
  }
2512
2779
 
2513
2780
  //#endregion
@@ -2517,7 +2784,7 @@ function ToolbarButton(props) {
2517
2784
  * @param props
2518
2785
  */
2519
2786
  function CustomLabel(props) {
2520
- const { className, title, icon, label, value, value$ } = props;
2787
+ const { className, iconSize, title, icon, label, value, value$ } = props;
2521
2788
  const localeService = useDependency(LocaleService);
2522
2789
  const componentManager = useDependency(ComponentManager);
2523
2790
  const iconManager = useDependency(IconManager);
@@ -2537,6 +2804,10 @@ function CustomLabel(props) {
2537
2804
  const Icon = iconManager.get(realIcon);
2538
2805
  if (Icon) nodes.push(/* @__PURE__ */ jsx(Icon, {
2539
2806
  className: "univer-text-base",
2807
+ style: iconSize ? {
2808
+ width: iconSize,
2809
+ height: iconSize
2810
+ } : void 0,
2540
2811
  extend: { colorChannel1: isValid ? String(realValue) : "var(--univer-primary-600)" }
2541
2812
  }, index++));
2542
2813
  }
@@ -2607,6 +2878,82 @@ function useToolbarShortcutDisplay({ id, commandId, shortcut }) {
2607
2878
  ]), null, true);
2608
2879
  }
2609
2880
 
2881
+ //#endregion
2882
+ //#region src/views/components/ribbon/ToolbarButton.tsx
2883
+ /**
2884
+ * Copyright 2023-present DreamNum Co., Ltd.
2885
+ *
2886
+ * Licensed under the Apache License, Version 2.0 (the "License");
2887
+ * you may not use this file except in compliance with the License.
2888
+ * You may obtain a copy of the License at
2889
+ *
2890
+ * http://www.apache.org/licenses/LICENSE-2.0
2891
+ *
2892
+ * Unless required by applicable law or agreed to in writing, software
2893
+ * distributed under the License is distributed on an "AS IS" BASIS,
2894
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2895
+ * See the License for the specific language governing permissions and
2896
+ * limitations under the License.
2897
+ */
2898
+ const toolbarButtonClassName = `
2899
+ univer-box-border univer-flex univer-h-6 univer-min-w-6 univer-cursor-pointer univer-items-center
2900
+ univer-justify-center univer-rounded univer-border-none univer-bg-transparent univer-p-0
2901
+ univer-text-gray-900 univer-outline-none univer-transition-colors univer-animate-in univer-fade-in
2902
+ dark:!univer-text-white dark:hover:!univer-bg-gray-700 dark:disabled:!univer-text-gray-600
2903
+ disabled:univer-cursor-not-allowed disabled:univer-text-gray-300 disabled:hover:univer-bg-transparent
2904
+ hover:univer-bg-gray-100 whitespace-nowrap univer-w-max
2905
+ `;
2906
+ const toolbarButtonVariants = cva(toolbarButtonClassName, {
2907
+ variants: {
2908
+ noIcon: {
2909
+ true: "univer-px-2",
2910
+ false: ""
2911
+ },
2912
+ active: {
2913
+ true: "!univer-bg-gray-200 dark:!univer-bg-gray-500",
2914
+ false: ""
2915
+ }
2916
+ },
2917
+ defaultVariants: {
2918
+ noIcon: false,
2919
+ active: false
2920
+ }
2921
+ });
2922
+ /**
2923
+ * Button Component
2924
+ */
2925
+ function ToolbarButton(props) {
2926
+ const { children, className, style, disabled = false, active = false, noIcon, onClick, onDoubleClick, ...restProps } = props;
2927
+ const handleClick = (e) => {
2928
+ if (disabled) {
2929
+ e.preventDefault();
2930
+ return;
2931
+ }
2932
+ onClick && onClick(e);
2933
+ };
2934
+ const handleDoubleClick = (e) => {
2935
+ if (disabled) {
2936
+ e.preventDefault();
2937
+ return;
2938
+ }
2939
+ onDoubleClick && onDoubleClick(e);
2940
+ };
2941
+ return /* @__PURE__ */ jsx("button", {
2942
+ type: "button",
2943
+ className: toolbarButtonVariants({
2944
+ noIcon,
2945
+ active,
2946
+ className
2947
+ }),
2948
+ style,
2949
+ disabled,
2950
+ onClick: handleClick,
2951
+ onDoubleClick: handleDoubleClick,
2952
+ ...restProps,
2953
+ children
2954
+ });
2955
+ }
2956
+
2610
2957
  //#endregion
2611
2958
  //#region src/views/components/ribbon/TooltipButtonWrapper.tsx
2612
2959
  const TooltipWrapperContext = createContext({
@@ -2663,12 +3010,31 @@ const TooltipWrapper = forwardRef((props, ref) => {
2663
3010
  function DropdownWrapper(props) {
2664
3011
  const { children, overlay, disabled, align = "start" } = props;
2665
3012
  const { dropdownVisible, setDropdownVisible } = useContext(TooltipWrapperContext);
3013
+ const triggerRef = useRef(null);
3014
+ const overlayRef = useRef(null);
3015
+ useEffect(() => {
3016
+ if (disabled) setDropdownVisible(false);
3017
+ }, [disabled, setDropdownVisible]);
3018
+ useEffect(() => {
3019
+ var _triggerRef$current;
3020
+ const ownerDocument = (_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.ownerDocument;
3021
+ if (!dropdownVisible || !ownerDocument) return;
3022
+ const handlePointerDown = (event) => {
3023
+ var _triggerRef$current2, _overlayRef$current;
3024
+ const target = event.target;
3025
+ if (!target || ((_triggerRef$current2 = triggerRef.current) === null || _triggerRef$current2 === void 0 ? void 0 : _triggerRef$current2.contains(target)) || ((_overlayRef$current = overlayRef.current) === null || _overlayRef$current === void 0 ? void 0 : _overlayRef$current.contains(target))) return;
3026
+ setDropdownVisible(false);
3027
+ };
3028
+ ownerDocument.addEventListener("pointerdown", handlePointerDown, true);
3029
+ return () => ownerDocument.removeEventListener("pointerdown", handlePointerDown, true);
3030
+ }, [dropdownVisible, setDropdownVisible]);
2666
3031
  function handleVisibleChange(visible) {
2667
3032
  setDropdownVisible(visible);
2668
3033
  }
2669
3034
  return /* @__PURE__ */ jsx(Dropdown, {
2670
3035
  align,
2671
3036
  overlay: /* @__PURE__ */ jsx("div", {
3037
+ ref: overlayRef,
2672
3038
  className: "univer-grid univer-gap-2",
2673
3039
  children: overlay
2674
3040
  }),
@@ -2676,6 +3042,7 @@ function DropdownWrapper(props) {
2676
3042
  open: dropdownVisible,
2677
3043
  onOpenChange: handleVisibleChange,
2678
3044
  children: /* @__PURE__ */ jsx("div", {
3045
+ ref: triggerRef,
2679
3046
  className: "univer-h-full",
2680
3047
  onClick: (e) => e.stopPropagation(),
2681
3048
  children
@@ -2716,6 +3083,9 @@ function getOptionKey(option) {
2716
3083
  }
2717
3084
  function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled, onOptionSelect }) {
2718
3085
  const { dropdownVisible, setDropdownVisible } = useContext(TooltipWrapperContext);
3086
+ useEffect(() => {
3087
+ if (disabled) setDropdownVisible(false);
3088
+ }, [disabled, setDropdownVisible]);
2719
3089
  const menuManagerService = useDependency(IMenuManagerService);
2720
3090
  const resolveMenuItems = () => menuId ? menuManagerService.getMenuByPositionKey(menuId) : [];
2721
3091
  const menuItems = useObservable(() => menuManagerService.menuChanged$.pipe(map(resolveMenuItems), startWith(resolveMenuItems())), resolveMenuItems(), false, [menuId, menuManagerService]);
@@ -2759,11 +3129,16 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
2759
3129
  children
2760
3130
  });
2761
3131
  if (options === null || options === void 0 ? void 0 : options.length) {
3132
+ var _options$0$label;
3133
+ const isSingleCustomPanel = options.length === 1 && typeof options[0].label === "object" && ((_options$0$label = options[0].label) === null || _options$0$label === void 0 ? void 0 : _options$0$label.hoverable) === false;
2762
3134
  const items = options.map((option) => {
2763
- var _option$label3;
3135
+ var _option$label3, _option$label4;
2764
3136
  return {
2765
3137
  type: "item",
2766
- className: clsx({ "focus:univer-bg-white": typeof option.label !== "string" && ((_option$label3 = option.label) === null || _option$label3 === void 0 ? void 0 : _option$label3.hoverable) === false }),
3138
+ className: clsx({
3139
+ "focus:univer-bg-white": typeof option.label !== "string" && ((_option$label3 = option.label) === null || _option$label3 === void 0 ? void 0 : _option$label3.hoverable) === false,
3140
+ "!univer-p-0": typeof option.label !== "string" && ((_option$label4 = option.label) === null || _option$label4 === void 0 ? void 0 : _option$label4.hoverable) === false
3141
+ }),
2767
3142
  children: /* @__PURE__ */ jsx(DropdownMenuLabel, {
2768
3143
  icon: option.icon,
2769
3144
  value,
@@ -2802,6 +3177,7 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
2802
3177
  }
2803
3178
  return /* @__PURE__ */ jsx(DropdownMenu, {
2804
3179
  align: "start",
3180
+ className: clsx({ "!univer-p-0": isSingleCustomPanel }),
2805
3181
  items,
2806
3182
  disabled,
2807
3183
  open: dropdownVisible,
@@ -2939,7 +3315,8 @@ const ToolbarItem = forwardRef((props, ref) => {
2939
3315
  layoutService.focus();
2940
3316
  commandService.executeCommand(commandId, params);
2941
3317
  };
2942
- const { tooltip, shortcut, icon, title, label, id, commandId, type, slot, params } = props;
3318
+ const { tooltip, shortcut, icon, title, label, id, commandId, type, slot, params, grid, large, showLabel, iconSize, iconColor, fullWidth } = props;
3319
+ const gridLabel = title !== null && title !== void 0 ? title : tooltip;
2943
3320
  const shortcutDisplay = useToolbarShortcutDisplay({
2944
3321
  id,
2945
3322
  commandId,
@@ -2971,6 +3348,7 @@ const ToolbarItem = forwardRef((props, ref) => {
2971
3348
  const selectionsCommandId = props.selectionsCommandId;
2972
3349
  const bId = commandId !== null && commandId !== void 0 ? commandId : id;
2973
3350
  const sId = (_ref = selectionsCommandId !== null && selectionsCommandId !== void 0 ? selectionsCommandId : commandId) !== null && _ref !== void 0 ? _ref : id;
3351
+ const titleToDisplay = grid ? showLabel ? gridLabel : large ? void 0 : title : title;
2974
3352
  function handleSelect(option) {
2975
3353
  if (disabled) return;
2976
3354
  let commandId = sId;
@@ -2992,17 +3370,24 @@ const ToolbarItem = forwardRef((props, ref) => {
2992
3370
  if (menuType === 2) return /* @__PURE__ */ jsxs("div", {
2993
3371
  "data-u-command": id,
2994
3372
  "data-disabled": disabled,
2995
- className: toolbarButtonSelectorRootVariants({ disabled }),
3373
+ className: clsx(toolbarButtonSelectorRootVariants({ disabled }), {
3374
+ "univer-box-border univer-h-full univer-min-w-14 univer-flex-col !univer-pr-0": grid && large,
3375
+ "univer-box-border univer-h-full": grid && !large
3376
+ }),
2996
3377
  children: [/* @__PURE__ */ jsx("div", {
2997
- className: toolbarButtonSelectorMainVariants({
3378
+ className: clsx(toolbarButtonSelectorMainVariants({
2998
3379
  active: activated,
2999
3380
  disabled
3381
+ }), {
3382
+ "univer-h-full univer-w-full univer-flex-col univer-justify-center univer-rounded univer-px-1 univer-pb-4 [&>svg]:univer-size-8": grid && large,
3383
+ "[&>svg]:univer-size-4": grid && !large
3000
3384
  }),
3001
3385
  onClick: handleClick,
3002
3386
  children: /* @__PURE__ */ jsx(CustomLabel, {
3003
3387
  icon: iconToDisplay,
3004
- title,
3005
- value,
3388
+ iconSize,
3389
+ title: titleToDisplay,
3390
+ value: iconColor !== null && iconColor !== void 0 ? iconColor : value,
3006
3391
  label,
3007
3392
  onChange: handleSelectionsValueChange
3008
3393
  })
@@ -3014,9 +3399,12 @@ const ToolbarItem = forwardRef((props, ref) => {
3014
3399
  disabled,
3015
3400
  onOptionSelect: handleSelect,
3016
3401
  children: /* @__PURE__ */ jsx("div", {
3017
- className: toolbarButtonSelectorTriggerVariants({
3402
+ className: clsx(toolbarButtonSelectorTriggerVariants({
3018
3403
  disabled,
3019
3404
  active: activated
3405
+ }), {
3406
+ "!univer-top-auto univer-bottom-0 univer-h-4 univer-w-full univer-rounded-b univer-rounded-t-none": grid && large,
3407
+ "univer-h-full": grid && !large
3020
3408
  }),
3021
3409
  "data-disabled": disabled,
3022
3410
  children: /* @__PURE__ */ jsx(MoreDownIcon, {})
@@ -3030,31 +3418,70 @@ const ToolbarItem = forwardRef((props, ref) => {
3030
3418
  options,
3031
3419
  disabled,
3032
3420
  onOptionSelect: handleSelect,
3033
- children: /* @__PURE__ */ jsxs("div", {
3421
+ children: /* @__PURE__ */ jsx("div", {
3034
3422
  "data-u-command": id,
3035
- className: toolbarSelectorRootVariants({
3423
+ className: clsx(toolbarSelectorRootVariants({
3036
3424
  disabled,
3037
3425
  active: activated
3038
- }),
3039
- children: [/* @__PURE__ */ jsx(CustomLabel, {
3426
+ }), {
3427
+ "univer-box-border univer-h-full univer-min-w-14 univer-flex-col univer-justify-center univer-gap-1 univer-px-1.5 univer-py-1 univer-text-xs [&>svg]:univer-size-8": grid && large,
3428
+ "univer-box-border univer-h-full": grid && !large,
3429
+ "univer-bg-white dark:!univer-bg-gray-800": grid && !large && !icon,
3430
+ "[&>svg]:univer-size-4": grid && !large
3431
+ }, grid && !large && !icon && borderClassName),
3432
+ children: grid && large ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CustomLabel, {
3433
+ icon: iconToDisplay,
3434
+ iconSize
3435
+ }), /* @__PURE__ */ jsxs("div", {
3436
+ className: clsx(toolbarSelectorTriggerVariants({ disabled }), "univer-h-4 univer-justify-center univer-gap-0.5"),
3437
+ children: [/* @__PURE__ */ jsx(CustomLabel, {
3438
+ title: titleToDisplay,
3439
+ value,
3440
+ label,
3441
+ onChange: handleSelectionsValueChange
3442
+ }), /* @__PURE__ */ jsx(MoreDownIcon, {})]
3443
+ })] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CustomLabel, {
3040
3444
  icon: iconToDisplay,
3041
- title,
3445
+ iconSize,
3446
+ title: titleToDisplay,
3042
3447
  value,
3043
3448
  label,
3044
3449
  onChange: handleSelectionsValueChange
3045
3450
  }), /* @__PURE__ */ jsx("div", {
3046
- className: toolbarSelectorTriggerVariants({ disabled }),
3451
+ className: clsx(toolbarSelectorTriggerVariants({ disabled }), { "univer-ml-auto rtl:univer-ml-0 rtl:univer-mr-auto": grid && !large && !icon }),
3047
3452
  children: /* @__PURE__ */ jsx(MoreDownIcon, {})
3048
- })]
3453
+ })] })
3049
3454
  })
3050
3455
  });
3051
3456
  }
3052
3457
  function renderButtonType() {
3053
3458
  var _label$name;
3054
3459
  const isCustomComponent = componentManager.get(typeof label === "string" ? label : (_label$name = label === null || label === void 0 ? void 0 : label.name) !== null && _label$name !== void 0 ? _label$name : "");
3460
+ const buttonClassName = clsx(grid && !large && "univer-h-full univer-min-w-8 [&>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-8" : showLabel ? "univer-gap-1 univer-px-1.5 univer-text-sm" : "univer-text-sm", grid && fullWidth && isCustomComponent && "!univer-px-0");
3461
+ const buttonStyle = grid && large ? {
3462
+ textAlign: "center",
3463
+ whiteSpace: "normal"
3464
+ } : void 0;
3465
+ if (isCustomComponent) return /* @__PURE__ */ jsx("span", {
3466
+ "data-u-command": id,
3467
+ className: toolbarButtonVariants({
3468
+ noIcon: !icon,
3469
+ active: activated,
3470
+ className: buttonClassName
3471
+ }),
3472
+ style: buttonStyle,
3473
+ "aria-disabled": disabled,
3474
+ children: /* @__PURE__ */ jsx(CustomLabel, {
3475
+ className: grid && fullWidth ? "!univer-w-full" : void 0,
3476
+ title: grid && showLabel ? gridLabel : title,
3477
+ value,
3478
+ label
3479
+ })
3480
+ });
3055
3481
  return /* @__PURE__ */ jsx(ToolbarButton, {
3056
3482
  "data-u-command": id,
3057
- className: "univer-text-sm",
3483
+ className: buttonClassName,
3484
+ style: buttonStyle,
3058
3485
  noIcon: !icon,
3059
3486
  active: activated,
3060
3487
  disabled,
@@ -3064,11 +3491,11 @@ const ToolbarItem = forwardRef((props, ref) => {
3064
3491
  executeCommand((_props$commandId = props.commandId) !== null && _props$commandId !== void 0 ? _props$commandId : props.id, commandParams !== null && commandParams !== void 0 ? commandParams : typeof value === "undefined" ? void 0 : { value });
3065
3492
  },
3066
3493
  onDoubleClick: () => props.subId && executeCommand(props.subId),
3067
- children: isCustomComponent ? /* @__PURE__ */ jsx(CustomLabel, {
3068
- title,
3069
- value,
3070
- label
3071
- }) : icon ? /* @__PURE__ */ jsx(CustomLabel, { icon }) : /* @__PURE__ */ jsx(CustomLabel, { title })
3494
+ children: icon ? /* @__PURE__ */ jsx(CustomLabel, {
3495
+ icon,
3496
+ iconSize,
3497
+ title: grid && (large || showLabel) ? gridLabel : void 0
3498
+ }) : /* @__PURE__ */ jsx(CustomLabel, { title })
3072
3499
  });
3073
3500
  }
3074
3501
  function renderItem() {
@@ -3089,6 +3516,51 @@ const ToolbarItem = forwardRef((props, ref) => {
3089
3516
  });
3090
3517
  });
3091
3518
 
3519
+ //#endregion
3520
+ //#region src/views/components/ribbon/RibbonGrid.tsx
3521
+ function RibbonGrid({ groups, title, className, ...props }) {
3522
+ const localeService = useDependency(LocaleService);
3523
+ return /* @__PURE__ */ jsx("div", {
3524
+ ...props,
3525
+ "data-testid": "ribbon-grid-toolbar",
3526
+ "data-u-comp": "ribbon-grid-toolbar",
3527
+ className: clsx("univer-box-border univer-flex univer-h-[88px] univer-overflow-x-auto univer-overflow-y-hidden univer-bg-gray-50 univer-px-2 univer-text-sm dark:!univer-bg-gray-900", borderBottomClassName, scrollbarClassName, className),
3528
+ role: "toolbar",
3529
+ "aria-label": localeService.t(title),
3530
+ children: /* @__PURE__ */ jsx(ToolbarDropdownProvider, { children: groups.map((group) => {
3531
+ var _group$children;
3532
+ return /* @__PURE__ */ jsxs("div", {
3533
+ "data-u-comp": "ribbon-grid-group",
3534
+ className: "univer-relative univer-box-border univer-flex univer-min-w-16 univer-shrink-0 univer-flex-col univer-px-2",
3535
+ children: [/* @__PURE__ */ jsx("div", {
3536
+ "data-testid": "ribbon-grid-group-grid",
3537
+ className: "univer-grid univer-min-h-0 univer-flex-1 univer-grid-flow-col univer-grid-rows-2 univer-content-center univer-gap-x-1 univer-gap-y-2 univer-py-2 [&>div>span>span]:univer-h-full",
3538
+ children: placeRibbonGridItems((_group$children = group.children) !== null && _group$children !== void 0 ? _group$children : []).map((placement) => placement.item.item && /* @__PURE__ */ jsx("div", {
3539
+ className: 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"),
3540
+ style: {
3541
+ gridRow: `${placement.row} / span ${placement.rowSpan}`,
3542
+ gridColumn: `${placement.column} / span ${placement.columnSpan}`,
3543
+ width: placement.width
3544
+ },
3545
+ children: /* @__PURE__ */ jsx(ToolbarItem, {
3546
+ ...placement.item.item,
3547
+ grid: true,
3548
+ large: placement.rowSpan > 1,
3549
+ showLabel: placement.showLabel,
3550
+ iconSize: placement.iconSize,
3551
+ fullWidth: placement.width !== void 0
3552
+ })
3553
+ }, placement.item.key))
3554
+ }), /* @__PURE__ */ jsx("span", {
3555
+ "data-testid": "ribbon-grid-group-divider",
3556
+ className: clsx("univer-pointer-events-none univer-absolute univer-bottom-1.5 univer-right-0 univer-top-3.5 !univer-border-gray-300 univer-opacity-50 rtl:univer-left-0 rtl:univer-right-auto", borderRightClassName),
3557
+ "aria-hidden": "true"
3558
+ })]
3559
+ }, group.key);
3560
+ }) })
3561
+ });
3562
+ }
3563
+
3092
3564
  //#endregion
3093
3565
  //#region src/views/components/ribbon/Ribbon.tsx
3094
3566
  function Ribbon(props) {
@@ -3159,7 +3631,7 @@ function Ribbon(props) {
3159
3631
  activatedTab
3160
3632
  ]);
3161
3633
  useEffect(() => {
3162
- if (hideToolbar) {
3634
+ if (hideToolbar || ribbonType === "grid") {
3163
3635
  toolbarItemRefs.current = {};
3164
3636
  ribbonService.setCollapsedIds([]);
3165
3637
  ribbonService.setFakeToolbarVisible(false);
@@ -3199,7 +3671,8 @@ function Ribbon(props) {
3199
3671
  hideToolbar,
3200
3672
  ribbon,
3201
3673
  activatedTab,
3202
- ribbonService
3674
+ ribbonService,
3675
+ ribbonType
3203
3676
  ]);
3204
3677
  const fakeToolbar = useMemo(() => {
3205
3678
  return /* @__PURE__ */ jsx("div", {
@@ -3237,7 +3710,7 @@ function Ribbon(props) {
3237
3710
  ...embedRibbonOverrideAttributes,
3238
3711
  className: clsx("univer-relative univer-select-none", headerClassName, {
3239
3712
  "univer-hidden": toolbarOnly,
3240
- "univer-h-9": !toolbarOnly && (ribbonType === "classic" || headerMenuComponents && headerMenuComponents.size > 0)
3713
+ "univer-h-9": !toolbarOnly && (ribbonType === "classic" || ribbonType === "grid" || headerMenuComponents && headerMenuComponents.size > 0)
3241
3714
  }),
3242
3715
  children: [
3243
3716
  !toolbarOnly && (ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.placeholderTitle) && ribbon.length === 0 && /* @__PURE__ */ jsx("div", {
@@ -3252,13 +3725,23 @@ function Ribbon(props) {
3252
3725
  activatedTab,
3253
3726
  onSelectTab: handleSelectTab
3254
3727
  }),
3728
+ !toolbarOnly && ribbonType === "grid" && ribbon.length >= 1 && /* @__PURE__ */ jsx(RibbonGridMenu, {
3729
+ ribbon,
3730
+ activatedTab,
3731
+ onSelectTab: handleSelectTab
3732
+ }),
3255
3733
  headerMenu && headerMenuComponents && headerMenuComponents.size > 0 && /* @__PURE__ */ jsx("div", {
3256
3734
  className: "univer-absolute univer-right-2 univer-top-0 univer-flex univer-h-full univer-flex-row univer-items-center univer-gap-2 rtl:univer-left-2 rtl:univer-right-auto [&>*]:univer-inline-flex [&>*]:univer-h-6 [&>*]:univer-items-center [&>*]:univer-rounded [&>*]:univer-px-1 [&>*]:univer-transition-colors hover:[&>*]:univer-bg-gray-100",
3257
3735
  children: /* @__PURE__ */ jsx(ComponentContainer, { components: headerMenuComponents })
3258
3736
  })
3259
3737
  ]
3260
3738
  }),
3261
- !hideToolbar && /* @__PURE__ */ jsxs("div", {
3739
+ !hideToolbar && ribbonType === "grid" && /* @__PURE__ */ jsx(RibbonGrid, {
3740
+ ...embedRibbonOverrideAttributes,
3741
+ groups: activeGroup.allGroups,
3742
+ title: activatedTabTitle
3743
+ }),
3744
+ !hideToolbar && ribbonType !== "grid" && /* @__PURE__ */ jsxs("div", {
3262
3745
  ...embedRibbonOverrideAttributes,
3263
3746
  className: clsx("univer-box-border univer-grid univer-h-10 univer-grid-flow-col univer-items-center univer-px-3 univer-text-sm", {
3264
3747
  "univer-grid-cols-[1fr] univer-justify-center": ribbonType === "classic" || ribbon.length === 1,
@@ -3310,7 +3793,7 @@ function Ribbon(props) {
3310
3793
  })] }, activatedTab)
3311
3794
  })]
3312
3795
  }),
3313
- fakeToolbar
3796
+ ribbonType !== "grid" && fakeToolbar
3314
3797
  ] })
3315
3798
  });
3316
3799
  }
@@ -3408,25 +3891,6 @@ var ContextMenuService = class extends Disposable {
3408
3891
  }
3409
3892
  };
3410
3893
 
3411
- //#endregion
3412
- //#region src/services/runtime-scope/ui-runtime-scope.service.ts
3413
- const IUIRuntimeScopeService = createIdentifier("ui.runtime-scope.service");
3414
- var UIRuntimeScopeService = class extends Disposable {
3415
- constructor(..._args) {
3416
- super(..._args);
3417
- _defineProperty(this, "_scopes", /* @__PURE__ */ new Map());
3418
- }
3419
- register(scope) {
3420
- this._scopes.set(scope.unitId, scope);
3421
- return toDisposable(() => {
3422
- if (this._scopes.get(scope.unitId) === scope) this._scopes.delete(scope.unitId);
3423
- });
3424
- }
3425
- get(unitId) {
3426
- return unitId ? this._scopes.get(unitId) : void 0;
3427
- }
3428
- };
3429
-
3430
3894
  //#endregion
3431
3895
  //#region src/services/contextmenu/contextmenu-host.service.ts
3432
3896
  const IContextMenuHostService = createIdentifier("ui.contextmenu.host.service");
@@ -3434,31 +3898,37 @@ var ContextMenuHostService = class extends Disposable {
3434
3898
  constructor(..._args) {
3435
3899
  super(..._args);
3436
3900
  _defineProperty(this, "_menuMap", /* @__PURE__ */ new Map());
3437
- _defineProperty(this, "_activeMenuId", null);
3901
+ _defineProperty(this, "_activeMenuId$", new BehaviorSubject(null));
3902
+ _defineProperty(this, "activeMenuId$", this._activeMenuId$.asObservable());
3438
3903
  }
3439
3904
  get activeMenuId() {
3440
- return this._activeMenuId;
3905
+ return this._activeMenuId$.value;
3441
3906
  }
3442
3907
  registerMenu(menuId, hide) {
3443
3908
  this._menuMap.set(menuId, hide);
3444
3909
  return toDisposable(() => {
3445
3910
  this._menuMap.delete(menuId);
3446
- if (this._activeMenuId === menuId) this._activeMenuId = null;
3911
+ if (this.activeMenuId === menuId) this._activeMenuId$.next(null);
3447
3912
  });
3448
3913
  }
3449
3914
  activateMenu(menuId) {
3450
3915
  this.hideActiveMenu(menuId);
3451
- this._activeMenuId = menuId;
3916
+ this._activeMenuId$.next(menuId);
3452
3917
  }
3453
3918
  deactivateMenu(menuId) {
3454
- if (this._activeMenuId === menuId) this._activeMenuId = null;
3919
+ if (this.activeMenuId === menuId) this._activeMenuId$.next(null);
3455
3920
  }
3456
3921
  hideActiveMenu(exceptMenuId) {
3457
- if (!this._activeMenuId || this._activeMenuId === exceptMenuId) return;
3458
- const hide = this._menuMap.get(this._activeMenuId);
3459
- this._activeMenuId = null;
3922
+ const activeMenuId = this.activeMenuId;
3923
+ if (!activeMenuId || activeMenuId === exceptMenuId) return;
3924
+ const hide = this._menuMap.get(activeMenuId);
3925
+ this._activeMenuId$.next(null);
3460
3926
  hide === null || hide === void 0 || hide();
3461
3927
  }
3928
+ dispose() {
3929
+ this._activeMenuId$.complete();
3930
+ super.dispose();
3931
+ }
3462
3932
  };
3463
3933
 
3464
3934
  //#endregion
@@ -4432,6 +4902,9 @@ function ContextMenuMenuItem(props) {
4432
4902
  setInputValue(value);
4433
4903
  }, [value]);
4434
4904
  useEffect(() => () => clearSubmenuCloseTimer(), [clearSubmenuCloseTimer]);
4905
+ useEffect(() => {
4906
+ if (disabled) closeSubmenu();
4907
+ }, [closeSubmenu, disabled]);
4435
4908
  useEffect(() => {
4436
4909
  if (!submenuVisible) {
4437
4910
  setSubmenuPositionReady(false);
@@ -5015,7 +5488,7 @@ function Sidebar() {
5015
5488
  children: [options === null || options === void 0 ? void 0 : options.header, /* @__PURE__ */ jsx("button", {
5016
5489
  ref: closeButtonRef,
5017
5490
  type: "button",
5018
- className: "focus:univer-ring-primary-500/50 univer-cursor-pointer univer-appearance-none univer-rounded-sm univer-border-none univer-bg-transparent univer-p-0 univer-text-gray-500 focus:univer-outline-none focus:univer-ring-2 dark:!univer-text-gray-300",
5491
+ className: "focus:univer-ring-primary-500/50 univer-flex univer-size-6 univer-cursor-pointer univer-appearance-none univer-items-center univer-justify-center univer-rounded-sm univer-border-none univer-bg-transparent univer-p-0 univer-text-gray-500 focus:univer-outline-none focus:univer-ring-2 dark:!univer-text-gray-300",
5019
5492
  onClick: handleClose,
5020
5493
  "aria-label": localeService.t("ui.sidebar.close"),
5021
5494
  children: /* @__PURE__ */ jsx(CloseIcon, {})
@@ -5023,7 +5496,6 @@ function Sidebar() {
5023
5496
  }),
5024
5497
  /* @__PURE__ */ jsx("section", {
5025
5498
  className: "univer-box-border univer-cursor-default univer-px-4",
5026
- style: options === null || options === void 0 ? void 0 : options.bodyStyle,
5027
5499
  children: options === null || options === void 0 ? void 0 : options.children
5028
5500
  }),
5029
5501
  (options === null || options === void 0 ? void 0 : options.footer) && /* @__PURE__ */ jsx("footer", {
@@ -5497,7 +5969,7 @@ const IUIController = createIdentifier("univer.ui.ui-controller");
5497
5969
  //#endregion
5498
5970
  //#region package.json
5499
5971
  var name = "@univerjs/ui";
5500
- var version = "1.0.0-alpha.6";
5972
+ var version = "1.0.0-alpha.7";
5501
5973
 
5502
5974
  //#endregion
5503
5975
  //#region src/views/color-picker/interface.ts
@@ -20499,11 +20971,12 @@ function EmojiPicker(props) {
20499
20971
  };
20500
20972
  }, [localStorageService, recentStorageKey]);
20501
20973
  const handleSelect = (item, options) => {
20502
- var _extraProps$onSelect;
20974
+ var _props$onChange, _extraProps$onSelect;
20503
20975
  const nextRecents = promoteRecentEmoji(recents, item);
20504
20976
  setActiveEmoji(item.emoji);
20505
20977
  setRecents(nextRecents);
20506
20978
  writeRecents(localStorageService, recentStorageKey, nextRecents);
20979
+ (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, item.emoji);
20507
20980
  extraProps === null || extraProps === void 0 || (_extraProps$onSelect = extraProps.onSelect) === null || _extraProps$onSelect === void 0 || _extraProps$onSelect.call(extraProps, item.emoji, options);
20508
20981
  };
20509
20982
  const handleRandom = () => {
@@ -20523,7 +20996,7 @@ function EmojiPicker(props) {
20523
20996
  };
20524
20997
  return /* @__PURE__ */ jsxs("section", {
20525
20998
  "data-u-comp": EMOJI_PICKER_COMPONENT,
20526
- className: "univer-flex univer-h-[340px] univer-w-[420px] univer-flex-col univer-overflow-hidden univer-rounded-[10px] univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-900",
20999
+ className: clsx("univer-flex univer-h-[340px] univer-w-[420px] univer-flex-col univer-overflow-hidden", !props.embedded && "univer-rounded-[10px] univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-900"),
20527
21000
  children: [
20528
21001
  /* @__PURE__ */ jsxs("div", {
20529
21002
  className: "univer-flex univer-items-center univer-gap-1 univer-px-3 univer-pb-2 univer-pt-3",
@@ -20545,7 +21018,7 @@ function EmojiPicker(props) {
20545
21018
  }),
20546
21019
  /* @__PURE__ */ jsx("div", {
20547
21020
  ref: scrollRef,
20548
- className: "univer-relative univer-min-h-0 univer-flex-1 univer-overflow-y-auto univer-px-3",
21021
+ className: clsx("univer-relative univer-min-h-0 univer-flex-1 univer-overflow-y-auto univer-px-3", scrollbarClassName),
20549
21022
  onScroll: handleScroll,
20550
21023
  children: renderedSections.length ? /* @__PURE__ */ jsx("div", {
20551
21024
  className: "univer-flex univer-flex-col univer-gap-1.5 univer-pb-2",
@@ -21296,8 +21769,8 @@ function ZoomInput(props) {
21296
21769
  className: clsx("univer-flex univer-h-6 univer-w-[68px] univer-flex-shrink-0 univer-items-center univer-overflow-hidden univer-rounded-md univer-border univer-border-gray-200 univer-bg-white dark:!univer-border-gray-600 dark:!univer-bg-gray-800", className, { "univer-opacity-60": disabled }),
21297
21770
  onClick: (e) => e.stopPropagation(),
21298
21771
  children: [/* @__PURE__ */ jsx(Input, {
21299
- className: "univer-box-border univer-h-6 univer-w-[52px] univer-border-none univer-bg-transparent [&_input:focus]:!univer-ring-0 [&_input]:univer-h-6 [&_input]:univer-w-[52px] [&_input]:univer-border-none [&_input]:!univer-bg-transparent [&_input]:univer-px-1 [&_input]:univer-text-center [&_input]:univer-text-xs [&_input]:univer-tabular-nums",
21300
- inputClass: "univer-w-[52px]",
21772
+ className: "univer-box-border univer-h-6 univer-min-w-0 univer-flex-1 univer-border-none univer-bg-transparent [&_input:focus]:!univer-ring-0 [&_input]:univer-h-6 [&_input]:univer-w-full [&_input]:univer-border-none [&_input]:!univer-bg-transparent [&_input]:univer-px-1 [&_input]:univer-text-center [&_input]:univer-text-xs [&_input]:univer-tabular-nums",
21773
+ inputClass: "univer-w-full",
21301
21774
  size: "mini",
21302
21775
  value: inputValue,
21303
21776
  disabled,
@@ -21515,6 +21988,234 @@ function Slider(props) {
21515
21988
  });
21516
21989
  }
21517
21990
 
21991
+ //#endregion
21992
+ //#region src/views/symbol-picker/symbols.ts
21993
+ const SYMBOL_CATEGORIES = [
21994
+ {
21995
+ key: "mathematics",
21996
+ titleKey: "ui.symbolPicker.mathematics",
21997
+ symbols: [
21998
+ "+",
21999
+ "−",
22000
+ "×",
22001
+ "÷",
22002
+ "≠",
22003
+ "≈",
22004
+ "<",
22005
+ ">",
22006
+ "≤",
22007
+ "≥",
22008
+ "≪",
22009
+ "≫",
22010
+ "≡",
22011
+ "±",
22012
+ "%",
22013
+ "‰",
22014
+ "‱",
22015
+ "½",
22016
+ "⅓",
22017
+ "⅔",
22018
+ "¼",
22019
+ "¾",
22020
+ "¹",
22021
+ "²",
22022
+ "³",
22023
+ "ⁿ",
22024
+ "₁",
22025
+ "₂",
22026
+ "₃",
22027
+ "|a|",
22028
+ "∟",
22029
+ "∠",
22030
+ "⊿",
22031
+ "△",
22032
+ "∥",
22033
+ "⊥",
22034
+ "∫",
22035
+ "∬",
22036
+ "∭",
22037
+ "∮",
22038
+ "∯",
22039
+ "∰",
22040
+ "∝",
22041
+ "∞",
22042
+ "∼",
22043
+ "≌",
22044
+ "∈",
22045
+ "∉",
22046
+ "⊆",
22047
+ "⊂",
22048
+ "∅",
22049
+ "∩",
22050
+ "∪",
22051
+ "∧",
22052
+ "∨",
22053
+ "⋅",
22054
+ "⋮",
22055
+ "⋰",
22056
+ "⋱",
22057
+ "⋯",
22058
+ "∏",
22059
+ "∑",
22060
+ "∃",
22061
+ "∄",
22062
+ "∀",
22063
+ "∂",
22064
+ "∆",
22065
+ "⊙",
22066
+ "⊕",
22067
+ "%"
22068
+ ]
22069
+ },
22070
+ {
22071
+ key: "greek",
22072
+ titleKey: "ui.symbolPicker.greek",
22073
+ symbols: [
22074
+ "α",
22075
+ "β",
22076
+ "γ",
22077
+ "δ",
22078
+ "ε",
22079
+ "ζ",
22080
+ "η",
22081
+ "θ",
22082
+ "ι",
22083
+ "κ",
22084
+ "λ",
22085
+ "μ",
22086
+ "ν",
22087
+ "ξ",
22088
+ "ο",
22089
+ "π",
22090
+ "ρ",
22091
+ "σ",
22092
+ "τ",
22093
+ "υ",
22094
+ "φ",
22095
+ "χ",
22096
+ "ψ",
22097
+ "ω",
22098
+ "Α",
22099
+ "Β",
22100
+ "Γ",
22101
+ "Δ",
22102
+ "Ε",
22103
+ "Ζ",
22104
+ "Η",
22105
+ "Θ",
22106
+ "Ι",
22107
+ "Κ",
22108
+ "Λ",
22109
+ "Μ",
22110
+ "Ν",
22111
+ "Ξ",
22112
+ "Ο",
22113
+ "Π",
22114
+ "Ρ",
22115
+ "Σ",
22116
+ "Τ",
22117
+ "Υ",
22118
+ "Φ",
22119
+ "Χ",
22120
+ "Ψ",
22121
+ "Ω"
22122
+ ]
22123
+ },
22124
+ {
22125
+ key: "common",
22126
+ titleKey: "ui.symbolPicker.common",
22127
+ symbols: [
22128
+ "kg",
22129
+ "mm",
22130
+ "cm",
22131
+ "m²",
22132
+ "°C",
22133
+ "°",
22134
+ "§",
22135
+ "◎",
22136
+ "©",
22137
+ "®",
22138
+ "{",
22139
+ "⌜",
22140
+ "〚",
22141
+ "№",
22142
+ "$",
22143
+ "¥",
22144
+ "@",
22145
+ "&",
22146
+ "*",
22147
+ "|",
22148
+ "#",
22149
+ "※",
22150
+ "√",
22151
+ "×",
22152
+ "…",
22153
+ "①",
22154
+ "②",
22155
+ "③",
22156
+ "↑",
22157
+ "↓",
22158
+ "←",
22159
+ "→"
22160
+ ]
22161
+ }
22162
+ ];
22163
+
22164
+ //#endregion
22165
+ //#region src/views/symbol-picker/SymbolPicker.tsx
22166
+ const SYMBOL_PICKER_COMPONENT = "ui.symbol-picker";
22167
+ function SymbolPicker(props) {
22168
+ var _props$popup;
22169
+ const extraProps = (_props$popup = props.popup) === null || _props$popup === void 0 ? void 0 : _props$popup.extraProps;
22170
+ const localeService = useDependency(LocaleService);
22171
+ useObservable(localeService.currentLocale$, localeService.getCurrentLocale());
22172
+ const [activeSymbol, setActiveSymbol] = useState(extraProps === null || extraProps === void 0 ? void 0 : extraProps.activeSymbol);
22173
+ const handleSelect = (symbol) => {
22174
+ var _props$onChange, _extraProps$onSelect;
22175
+ setActiveSymbol(symbol);
22176
+ (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, symbol);
22177
+ extraProps === null || extraProps === void 0 || (_extraProps$onSelect = extraProps.onSelect) === null || _extraProps$onSelect === void 0 || _extraProps$onSelect.call(extraProps, symbol, { keepOpen: true });
22178
+ };
22179
+ return /* @__PURE__ */ jsx("section", {
22180
+ "data-u-comp": SYMBOL_PICKER_COMPONENT,
22181
+ className: clsx("univer-flex univer-h-[340px] univer-w-[420px] univer-flex-col univer-overflow-hidden", !props.embedded && "univer-rounded-[10px] univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-900", props.className),
22182
+ children: /* @__PURE__ */ jsx("div", {
22183
+ className: clsx("univer-min-h-0 univer-flex-1 univer-overflow-y-auto univer-p-4", scrollbarClassName),
22184
+ children: /* @__PURE__ */ jsx("div", {
22185
+ className: "univer-flex univer-flex-col univer-gap-5",
22186
+ children: SYMBOL_CATEGORIES.map((category) => /* @__PURE__ */ jsx(SymbolSection, {
22187
+ activeSymbol,
22188
+ category,
22189
+ onSelect: handleSelect
22190
+ }, category.key))
22191
+ })
22192
+ })
22193
+ });
22194
+ }
22195
+ function SymbolSection(props) {
22196
+ return /* @__PURE__ */ jsxs("section", {
22197
+ className: "univer-flex univer-flex-col univer-gap-2",
22198
+ children: [/* @__PURE__ */ jsx("div", {
22199
+ className: "univer-text-sm univer-font-semibold univer-text-gray-900 dark:!univer-text-gray-100",
22200
+ children: useDependency(LocaleService).t(props.category.titleKey)
22201
+ }), /* @__PURE__ */ jsx("div", {
22202
+ className: "univer-grid univer-grid-cols-10 univer-gap-1",
22203
+ children: props.category.symbols.map((symbol, index) => {
22204
+ const active = props.activeSymbol === symbol;
22205
+ return /* @__PURE__ */ jsx("button", {
22206
+ type: "button",
22207
+ "aria-label": symbol,
22208
+ "aria-pressed": active,
22209
+ title: symbol,
22210
+ className: clsx("univer-flex univer-size-8 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-lg univer-border-0 univer-bg-transparent univer-p-0 univer-text-lg univer-text-gray-900 dark:!univer-text-gray-100", active ? "univer-bg-primary-50 univer-shadow-sm dark:!univer-bg-gray-800 dark:!univer-shadow-sm" : "hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800"),
22211
+ onClick: () => props.onSelect(symbol),
22212
+ children: symbol
22213
+ }, `${props.category.key}-${symbol}-${index}`);
22214
+ })
22215
+ })]
22216
+ });
22217
+ }
22218
+
21518
22219
  //#endregion
21519
22220
  //#region src/controllers/components.controller.ts
21520
22221
  /**
@@ -21544,9 +22245,11 @@ let ComponentsController = class ComponentsController extends Disposable {
21544
22245
  this.disposeWithMe(this._iconManager.register({
21545
22246
  ExpandIcon,
21546
22247
  IncreaseIcon,
22248
+ KeyboardIcon,
21547
22249
  MoreDownIcon,
21548
22250
  RedoIcon,
21549
22251
  ReduceIcon,
22252
+ FeatureSearchIcon,
21550
22253
  ShortcutIcon,
21551
22254
  ShrinkIcon,
21552
22255
  UndoIcon
@@ -21560,7 +22263,9 @@ let ComponentsController = class ComponentsController extends Disposable {
21560
22263
  [FONT_FAMILY_ITEM_COMPONENT, FontFamilyItem],
21561
22264
  [FONT_SIZE_COMPONENT, FontSize],
21562
22265
  [COLOR_PICKER_COMPONENT, ColorPicker],
21563
- [EMOJI_PICKER_COMPONENT, EmojiPicker]
22266
+ [EMOJI_PICKER_COMPONENT, EmojiPicker],
22267
+ [SYMBOL_PICKER_COMPONENT, SymbolPicker],
22268
+ [FEATURE_SEARCH_COMPONENT, FeatureSearch]
21564
22269
  ].forEach(([key, comp]) => {
21565
22270
  this.disposeWithMe(this._componentManager.register(key, comp));
21566
22271
  });
@@ -21569,6 +22274,24 @@ let ComponentsController = class ComponentsController extends Disposable {
21569
22274
  };
21570
22275
  ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
21571
22276
 
22277
+ //#endregion
22278
+ //#region src/controllers/feature-search/feature-search.controller.ts
22279
+ const FeatureSearchShortcut = {
22280
+ id: OpenFeatureSearchOperation.id,
22281
+ binding: 4096 | 1024 | 80,
22282
+ description: "ui.featureSearch.title",
22283
+ group: "10_global-shortcut",
22284
+ groupTitle: "ui.global-shortcut"
22285
+ };
22286
+ let FeatureSearchController = class FeatureSearchController extends Disposable {
22287
+ constructor(commandService, shortcutService) {
22288
+ super();
22289
+ this.disposeWithMe(commandService.registerCommand(OpenFeatureSearchOperation));
22290
+ this.disposeWithMe(shortcutService.registerShortcut(FeatureSearchShortcut));
22291
+ }
22292
+ };
22293
+ FeatureSearchController = __decorate([__decorateParam(0, ICommandService), __decorateParam(1, IShortcutService)], FeatureSearchController);
22294
+
21572
22295
  //#endregion
21573
22296
  //#region src/views/components/ribbon/MobileRibbon.tsx
21574
22297
  const toolbarScrollOffset = 168;
@@ -21792,7 +22515,8 @@ function MobileMenu(props) {
21792
22515
  menuManagerService,
21793
22516
  menuType,
21794
22517
  onExecute: onOptionSelect,
21795
- onOpenView: openView
22518
+ onOpenView: openView,
22519
+ inheritedDisabled$: currentView === null || currentView === void 0 ? void 0 : currentView.disabled$
21796
22520
  })
21797
22521
  }), (currentView === null || currentView === void 0 ? void 0 : currentView.kind) === "options" && /* @__PURE__ */ jsx("div", {
21798
22522
  className: "univer-overflow-hidden univer-rounded-2xl univer-bg-white",
@@ -21801,6 +22525,7 @@ function MobileMenu(props) {
21801
22525
  menuItem: currentView.menuItem,
21802
22526
  options: currentView.options,
21803
22527
  currentValue: currentView.currentValue,
22528
+ inheritedDisabled$: currentView.disabled$,
21804
22529
  onExecute: onOptionSelect
21805
22530
  })
21806
22531
  })]
@@ -21808,7 +22533,7 @@ function MobileMenu(props) {
21808
22533
  });
21809
22534
  }
21810
22535
  function MobileSchemaList(props) {
21811
- const { schemas, menuManagerService, menuType, onExecute, onOpenView } = props;
22536
+ const { schemas, menuManagerService, menuType, onExecute, onOpenView, inheritedDisabled$ } = props;
21812
22537
  const localeService = useDependency(LocaleService);
21813
22538
  const hiddenGroupStates = useContextGroupHiddenStates(schemas);
21814
22539
  const visibleSchemas = useMemo(() => {
@@ -21826,6 +22551,7 @@ function MobileSchemaList(props) {
21826
22551
  menuType,
21827
22552
  onExecute,
21828
22553
  onOpenView,
22554
+ inheritedDisabled$,
21829
22555
  bordered: index !== visibleSchemas.length - 1
21830
22556
  }, schema.key);
21831
22557
  if (!((_schema$children2 = schema.children) === null || _schema$children2 === void 0 ? void 0 : _schema$children2.length)) return null;
@@ -21840,18 +22566,20 @@ function MobileSchemaList(props) {
21840
22566
  menuType,
21841
22567
  onExecute,
21842
22568
  onOpenView,
22569
+ inheritedDisabled$,
21843
22570
  bordered: childIndex !== schema.children.length - 1
21844
22571
  }, childSchema.key))]
21845
22572
  }, schema.key);
21846
22573
  }) });
21847
22574
  }
21848
22575
  function MobileSchemaRow(props) {
21849
- const { schema, menuManagerService, menuType, onExecute, onOpenView, bordered } = props;
22576
+ const { schema, menuManagerService, menuType, onExecute, onOpenView, inheritedDisabled$, bordered } = props;
21850
22577
  const interaction = useMobileSchemaInteraction({
21851
22578
  schema,
21852
22579
  menuManagerService,
21853
22580
  menuType,
21854
- onOpenView
22581
+ onOpenView,
22582
+ inheritedDisabled$
21855
22583
  });
21856
22584
  if (!interaction || interaction.hidden) return null;
21857
22585
  const { menuItem, disabled, value, currentValueText, hasSubmenu, onPress } = interaction;
@@ -21879,7 +22607,8 @@ function MobileSchemaRow(props) {
21879
22607
  });
21880
22608
  }
21881
22609
  function MobileSelectionOptionsView(props) {
21882
- const { options, menuKey, menuItem, currentValue, onExecute } = props;
22610
+ const { options, menuKey, menuItem, currentValue, inheritedDisabled$, onExecute } = props;
22611
+ const inheritedDisabled = useObservable(inheritedDisabled$, false);
21883
22612
  return /* @__PURE__ */ jsx(Fragment$1, { children: options.map((option, index) => {
21884
22613
  var _option$value;
21885
22614
  return /* @__PURE__ */ jsx(MobileSelectionOptionRow, {
@@ -21887,6 +22616,7 @@ function MobileSelectionOptionsView(props) {
21887
22616
  menuKey,
21888
22617
  menuItem,
21889
22618
  currentValue,
22619
+ disabled: inheritedDisabled,
21890
22620
  bordered: index !== options.length - 1,
21891
22621
  onExecute
21892
22622
  }, `${menuKey}-${String((_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : index)}`);
@@ -21894,15 +22624,17 @@ function MobileSelectionOptionsView(props) {
21894
22624
  }
21895
22625
  function MobileSelectionOptionRow(props) {
21896
22626
  var _option$value2;
21897
- const { option, menuKey, menuItem, currentValue, bordered, onExecute } = props;
22627
+ const { option, menuKey, menuItem, currentValue, disabled, bordered, onExecute } = props;
21898
22628
  const optionValue = useObservable(option.value$);
21899
22629
  const displayValue = (_option$value2 = option.value) !== null && _option$value2 !== void 0 ? _option$value2 : optionValue;
21900
22630
  const selected = displayValue === currentValue;
22631
+ const optionDisabled = disabled || Boolean(option.disabled);
21901
22632
  return /* @__PURE__ */ jsxs("button", {
21902
22633
  type: "button",
21903
22634
  className: clsx("univer-relative univer-flex univer-min-h-[56px] univer-w-full univer-appearance-none univer-items-center univer-gap-3 univer-border-0 univer-bg-white univer-px-4 univer-py-3 univer-text-left univer-transition-colors enabled:hover:univer-bg-gray-50 enabled:active:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-opacity-40", bordered && borderBottomClassName),
21904
- disabled: option.disabled,
22635
+ disabled: optionDisabled,
21905
22636
  onClick: () => {
22637
+ if (optionDisabled) return;
21906
22638
  onExecute === null || onExecute === void 0 || onExecute({
21907
22639
  ...option,
21908
22640
  value: displayValue,
@@ -21924,11 +22656,15 @@ function MobileSelectionOptionRow(props) {
21924
22656
  }
21925
22657
  function useMobileSchemaInteraction(props) {
21926
22658
  var _schema$children3;
21927
- const { schema, menuManagerService, menuType, onOpenView } = props;
22659
+ const { schema, menuManagerService, menuType, onOpenView, inheritedDisabled$ } = props;
21928
22660
  const localeService = useDependency(LocaleService);
21929
22661
  const menuItem = schema.item;
21930
22662
  const selectorItem = menuItem;
21931
- const disabled = useObservable(menuItem === null || menuItem === void 0 ? void 0 : menuItem.disabled$, false);
22663
+ const disabled$ = useMemo(() => {
22664
+ const sources = [inheritedDisabled$, menuItem === null || menuItem === void 0 ? void 0 : menuItem.disabled$].filter((source) => Boolean(source));
22665
+ return sources.length ? combineLatest(sources.map((source) => source.pipe(startWith$1(false)))).pipe(map((states) => states.some(Boolean))) : void 0;
22666
+ }, [inheritedDisabled$, menuItem === null || menuItem === void 0 ? void 0 : menuItem.disabled$]);
22667
+ const disabled = useObservable(disabled$, false);
21932
22668
  const hidden = useObservable(menuItem === null || menuItem === void 0 ? void 0 : menuItem.hidden$, false);
21933
22669
  const value = useObservable(menuItem === null || menuItem === void 0 ? void 0 : menuItem.value$);
21934
22670
  const selectionsFromObservable = useObservable(selectorItem && isObservable(selectorItem.selections) ? selectorItem.selections : void 0);
@@ -21950,11 +22686,13 @@ function useMobileSchemaInteraction(props) {
21950
22686
  const hasSubmenu = schemaChildren.length > 0 || selections.length > 0 || subMenuItems.length > 0;
21951
22687
  const currentValueText = typeof value === "string" || typeof value === "number" ? String(value) : "";
21952
22688
  const onPress = (onExecute) => {
22689
+ if (disabled) return;
21953
22690
  if (schemaChildren.length > 0) {
21954
22691
  onOpenView({
21955
22692
  kind: "schema",
21956
22693
  title: getMenuSchemaTitle(schema, localeService),
21957
- schemas: schemaChildren
22694
+ schemas: schemaChildren,
22695
+ disabled$
21958
22696
  });
21959
22697
  return;
21960
22698
  }
@@ -21965,7 +22703,8 @@ function useMobileSchemaInteraction(props) {
21965
22703
  options: selections,
21966
22704
  menuItem: selectorItem,
21967
22705
  menuKey: schema.key,
21968
- currentValue: value
22706
+ currentValue: value,
22707
+ disabled$
21969
22708
  });
21970
22709
  return;
21971
22710
  }
@@ -21973,7 +22712,8 @@ function useMobileSchemaInteraction(props) {
21973
22712
  onOpenView({
21974
22713
  kind: "schema",
21975
22714
  title: getMenuSchemaTitle(schema, localeService),
21976
- schemas: subMenuItems
22715
+ schemas: subMenuItems,
22716
+ disabled$
21977
22717
  });
21978
22718
  return;
21979
22719
  }
@@ -22528,7 +23268,7 @@ let BrowserClipboardService = class BrowserClipboardService extends Disposable {
22528
23268
  this._notificationService = _notificationService;
22529
23269
  }
22530
23270
  async write(text, html, customData) {
22531
- if (!this.supportClipboard) return this._legacyCopyHtml(text, html);
23271
+ if (!this.supportClipboard || typeof ClipboardItem === "undefined" || typeof navigator.clipboard.write !== "function") return this._legacyCopyHtml(text, html);
22532
23272
  try {
22533
23273
  return await navigator.clipboard.write([new ClipboardItem({
22534
23274
  [PLAIN_TEXT_CLIPBOARD_MIME_TYPE]: new Blob([text], { type: PLAIN_TEXT_CLIPBOARD_MIME_TYPE }),
@@ -22860,10 +23600,6 @@ let DesktopConfirmService = class DesktopConfirmService extends Disposable {
22860
23600
  };
22861
23601
  DesktopConfirmService = __decorate([__decorateParam(0, Inject(Injector)), __decorateParam(1, IUIPartsService)], DesktopConfirmService);
22862
23602
 
22863
- //#endregion
22864
- //#region src/services/dialog/dialog.service.ts
22865
- const IDialogService = createIdentifier("univer.ui.dialog-service");
22866
-
22867
23603
  //#endregion
22868
23604
  //#region src/views/components/dialog-part/DialogPart.tsx
22869
23605
  function DialogPart() {
@@ -23507,6 +24243,7 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends Plugin {
23507
24243
  }],
23508
24244
  [SharedController],
23509
24245
  [ErrorController],
24246
+ [FeatureSearchController],
23510
24247
  [ShortcutPanelController]
23511
24248
  ], this._config.override));
23512
24249
  touchDependencies(this._injector, [
@@ -23516,7 +24253,7 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends Plugin {
23516
24253
  ]);
23517
24254
  }
23518
24255
  onReady() {
23519
- touchDependencies(this._injector, [[SharedController]]);
24256
+ touchDependencies(this._injector, [[SharedController], [FeatureSearchController]]);
23520
24257
  }
23521
24258
  onSteady() {
23522
24259
  touchDependencies(this._injector, [[ShortcutPanelController]]);
@@ -23609,6 +24346,7 @@ let UniverUIPlugin = class UniverUIPlugin extends Plugin {
23609
24346
  }],
23610
24347
  [SharedController],
23611
24348
  [ErrorController],
24349
+ [FeatureSearchController],
23612
24350
  [ShortcutPanelController]
23613
24351
  ], this._config.override));
23614
24352
  touchDependencies(this._injector, [
@@ -23618,7 +24356,7 @@ let UniverUIPlugin = class UniverUIPlugin extends Plugin {
23618
24356
  ]);
23619
24357
  }
23620
24358
  onReady() {
23621
- touchDependencies(this._injector, [[SharedController]]);
24359
+ touchDependencies(this._injector, [[SharedController], [FeatureSearchController]]);
23622
24360
  }
23623
24361
  onSteady() {
23624
24362
  touchDependencies(this._injector, [[ShortcutPanelController]]);
@@ -24436,4 +25174,4 @@ function ProgressBar(props) {
24436
25174
  }
24437
25175
 
24438
25176
  //#endregion
24439
- export { AnchoredContextMenu, BrowserClipboardService, BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, CanvasFloatDomPreviewService, CanvasFloatDomService, CanvasPopup, CanvasPopupService, CommonLabel, ComponentContainer, ComponentManager, DesktopContextMenu as ContextMenu, ContextMenuGroup, ContextMenuHostService, ContextMenuPanel, ContextMenuPosition, ContextMenuService, CopyCommand, CopyShortcutItem, CustomLabel, CutCommand, CutShortcutItem, DISABLE_AUTO_FOCUS_KEY, DesktopBeforeCloseService, DesktopConfirmService, DesktopDialogService, DesktopGalleryService, DesktopLayoutService, DesktopLocalFileService, DesktopLocalStorageService, DesktopMessageService, DesktopNotificationService, DesktopRibbonService, DesktopSidebarService, DesktopUIController, EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, EMOJI_CATEGORIES, EMOJI_PICKER_COMPONENT, EMOJI_RECENT_LIMIT, EmojiPicker, ErrorController, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE_SVG_XML_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FloatDom, FloatDomSingle, FontFamily, FontFamilyDropdown, FontFamilyItem, FontService, FontSize, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, HeadingItem, IBeforeCloseService, ICanvasPopupService, IClipboardInterfaceService, IContextMenuHostService, IContextMenuService, IDialogService, IFontService, IGalleryService, ILayoutService, ILeftSidebarService, ILocalFileService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IRibbonOverrideService, IRibbonService, IShortcutService, ISidebarService, IUIController, IUIPartsService, IUIRuntimeScopeService, IconManager, KeyCode, MenuItemType, MenuManagerPosition, MenuManagerService, MetaKeys, MobileContextMenu, MockMessageService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, PlatformService, PrintFloatDomSingle, ProgressBar, RectPopup, RediConsumer, RediContext, RediProvider, RedoShortcutItem, Ribbon, RibbonDataGroup, RibbonFormulasGroup, RibbonInsertGroup, RibbonOthersGroup, RibbonOverrideService, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SharedController, SheetPasteShortKeyCommandName, ShortcutPanelController, ShortcutPanelService, ShortcutService, Sidebar, SingleCanvasPopup, SingleUnitUIController, Slider, ThemeSwitcherService, ToggleFullscreenOperation, ToggleShortcutPanelOperation, ToolbarButton, ToolbarItem, menuSchema as UIMenuSchema, UIPartsService, UIRuntimeScopeService, UI_PLUGIN_CONFIG_KEY, UNI_DISABLE_CHANGING_FOCUS_KEY, UndoShortcutItem, UniverMobileUIPlugin, UniverUIPlugin, WithDependency, ZIndexManager, ZoomInput, connectDependencies, connectInjector, getAllEmojis, getDefaultRecentEmojis, getEmbedBoundaryOwner, getEmojiLocaleData, getHeaderFooterMenuHiddenObservable, getLocalizedEmojiTitle, getMenuHiddenObservable, getRandomEmoji, handelExcelToJson, handelTableToJson, handleDomToJson, handlePlainToJson, handleStringToStyle, handleTableColgroup, handleTableMergeData, handleTableRowGroup, imageMimeTypeSet, isEmbedBoundaryTarget, keepInteractionInsideSameEmbedBoundary, mergeMenuConfigs, parseHtmlDocument, parseHtmlFragment, parseStoredRecentEmojis, promoteRecentEmoji, sanitizeParsedHtml, searchEmojis, splitSpanText, supportClipboardAPI, textTrim, useClickOutSide, useComponentsOfPart, useConfigValue, useDebounceFn, useDependency, useEvent, useInjector, useObservable, useObservableRef, useScrollYOverContainer, useSidebarClick, useToolbarItemStatus, useUpdateBinder, useUpdateEffect, useVirtualList };
25177
+ export { AnchoredContextMenu, BrowserClipboardService, BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, CanvasFloatDomPreviewService, CanvasFloatDomService, CanvasPopup, CanvasPopupService, CommonLabel, ComponentContainer, ComponentManager, DesktopContextMenu as ContextMenu, ContextMenuGroup, ContextMenuHostService, ContextMenuPanel, ContextMenuPosition, ContextMenuService, CopyCommand, CopyShortcutItem, CustomLabel, CutCommand, CutShortcutItem, DISABLE_AUTO_FOCUS_KEY, DesktopBeforeCloseService, DesktopConfirmService, DesktopDialogService, DesktopGalleryService, DesktopLayoutService, DesktopLocalFileService, DesktopLocalStorageService, DesktopMessageService, DesktopNotificationService, DesktopRibbonService, DesktopSidebarService, DesktopUIController, EMBED_CHILD_UNIT_ID_ATTRIBUTE, EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, EMOJI_CATEGORIES, EMOJI_PICKER_COMPONENT, EMOJI_RECENT_LIMIT, EmojiPicker, ErrorController, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE_SVG_XML_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FloatDom, FloatDomSingle, FontFamily, FontFamilyDropdown, FontFamilyItem, FontService, FontSize, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, HeadingItem, IBeforeCloseService, ICanvasPopupService, IClipboardInterfaceService, IContextMenuHostService, IContextMenuService, IDialogService, IFontService, IGalleryService, ILayoutService, ILeftSidebarService, ILocalFileService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IRibbonOverrideService, IRibbonService, IShortcutService, ISidebarService, IUIController, IUIPartsService, IUIRuntimeScopeService, IconManager, KeyCode, MenuItemType, MenuManagerPosition, MenuManagerService, MetaKeys, MobileContextMenu, MockMessageService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, PlatformService, PrintFloatDomSingle, ProgressBar, RectPopup, RediConsumer, RediContext, RediProvider, RedoShortcutItem, Ribbon, RibbonDataGroup, RibbonFormulasGroup, RibbonInsertGroup, RibbonOthersGroup, RibbonOverrideService, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SYMBOL_CATEGORIES, SYMBOL_PICKER_COMPONENT, SharedController, SheetPasteShortKeyCommandName, ShortcutPanelController, ShortcutPanelService, ShortcutService, Sidebar, SingleCanvasPopup, SingleUnitUIController, Slider, SymbolPicker, ThemeSwitcherService, ToggleFullscreenOperation, ToggleShortcutPanelOperation, ToolbarButton, ToolbarItem, menuSchema as UIMenuSchema, UIPartsService, UIRuntimeScopeService, UI_PLUGIN_CONFIG_KEY, UNI_DISABLE_CHANGING_FOCUS_KEY, UndoShortcutItem, UniverMobileUIPlugin, UniverUIPlugin, WithDependency, ZIndexManager, ZoomInput, connectDependencies, connectInjector, getAllEmojis, getDefaultRecentEmojis, getEmbedBoundaryOwner, getEmbedChildUnitId, getEmojiLocaleData, getHeaderFooterMenuHiddenObservable, getLocalizedEmojiTitle, getMenuHiddenObservable, getRandomEmoji, handelExcelToJson, handelTableToJson, handleDomToJson, handlePlainToJson, handleStringToStyle, handleTableColgroup, handleTableMergeData, handleTableRowGroup, imageMimeTypeSet, isEmbedBoundaryTarget, keepInteractionInsideSameEmbedBoundary, mergeMenuConfigs, parseHtmlDocument, parseHtmlFragment, parseStoredRecentEmojis, promoteRecentEmoji, sanitizeParsedHtml, searchEmojis, splitSpanText, supportClipboardAPI, textTrim, useClickOutSide, useComponentsOfPart, useConfigValue, useDebounceFn, useDependency, useEvent, useInjector, useObservable, useObservableRef, useScrollYOverContainer, useSidebarClick, useToolbarItemStatus, useUpdateBinder, useUpdateEffect, useVirtualList };