@univerjs/ui 1.0.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -55,7 +55,7 @@ function getAttributeValue(target, name) {
55
55
  }
56
56
 
57
57
  //#endregion
58
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
58
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
59
59
  function _typeof(o) {
60
60
  "@babel/helpers - typeof";
61
61
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -66,7 +66,7 @@ function _typeof(o) {
66
66
  }
67
67
 
68
68
  //#endregion
69
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
69
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
70
70
  function toPrimitive(t, r) {
71
71
  if ("object" != _typeof(t) || !t) return t;
72
72
  var e = t[Symbol.toPrimitive];
@@ -79,14 +79,14 @@ function toPrimitive(t, r) {
79
79
  }
80
80
 
81
81
  //#endregion
82
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
82
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
83
83
  function toPropertyKey(t) {
84
84
  var i = toPrimitive(t, "string");
85
85
  return "symbol" == _typeof(i) ? i : i + "";
86
86
  }
87
87
 
88
88
  //#endregion
89
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
89
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
90
90
  function _defineProperty(e, r, t) {
91
91
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
92
92
  value: t,
@@ -97,7 +97,7 @@ function _defineProperty(e, r, t) {
97
97
  }
98
98
 
99
99
  //#endregion
100
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
100
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
101
101
  function __decorateParam(paramIndex, decorator) {
102
102
  return function(target, key) {
103
103
  decorator(target, key, paramIndex);
@@ -105,7 +105,7 @@ function __decorateParam(paramIndex, decorator) {
105
105
  }
106
106
 
107
107
  //#endregion
108
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
108
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
109
109
  function __decorate(decorators, target, key, desc) {
110
110
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
111
111
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -307,7 +307,8 @@ const ToggleShortcutPanelOperation = {
307
307
  shortcutPanelService.open();
308
308
  sidebarService.open({
309
309
  header: { title: "ui.shortcut-panel.title" },
310
- children: { label: ShortcutPanelComponentName }
310
+ children: { label: ShortcutPanelComponentName },
311
+ onClose: () => shortcutPanelService.close()
311
312
  });
312
313
  }
313
314
  return true;
@@ -1673,27 +1674,33 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
1673
1674
  this._initRibbonSubscription();
1674
1675
  }
1675
1676
  setActivatedTab(tab) {
1677
+ if (this._disposed) return;
1676
1678
  if (!this._isContextualTab(tab)) this._lastNonContextualActivatedTab = tab;
1677
1679
  this._activatedTab$.next(tab);
1678
1680
  }
1679
1681
  showContextualTab(tab, options) {
1682
+ if (this._disposed) return;
1680
1683
  this._visibleContextualTabs.add(tab);
1681
1684
  this._updateRibbon();
1682
1685
  if (options === null || options === void 0 ? void 0 : options.activate) this.setActivatedTab(tab);
1683
1686
  }
1684
1687
  hideContextualTab(tab) {
1688
+ if (this._disposed) return;
1685
1689
  if (!this._visibleContextualTabs.delete(tab)) return;
1686
1690
  this._updateRibbon();
1687
1691
  }
1688
1692
  hideAllContextualTabs() {
1693
+ if (this._disposed) return;
1689
1694
  if (this._visibleContextualTabs.size === 0) return;
1690
1695
  this._visibleContextualTabs.clear();
1691
1696
  this._updateRibbon();
1692
1697
  }
1693
1698
  setCollapsedIds(ids) {
1699
+ if (this._disposed) return;
1694
1700
  this._collapsedIds$.next(ids);
1695
1701
  }
1696
1702
  setFakeToolbarVisible(visible) {
1703
+ if (this._disposed) return;
1697
1704
  this._fakeToolbarVisible$.next(visible);
1698
1705
  }
1699
1706
  _initRibbonSubscription() {
@@ -1703,15 +1710,16 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
1703
1710
  }
1704
1711
  _updateRibbon() {
1705
1712
  var _this$_hiddenSubscrip;
1713
+ if (this._disposed) return;
1706
1714
  const ribbon = this._filterContextualTabs(this._menuManagerService.getMenuByPositionKey("ribbon"));
1707
1715
  const hiddenObservableMap = [];
1708
- const hiddenKeyMap = [];
1716
+ const menusWithHiddenState = [];
1709
1717
  for (const group of ribbon) if (group.children) {
1710
1718
  for (const item of group.children) if (item.children) for (const child of item.children) {
1711
1719
  var _child$item;
1712
1720
  if ((_child$item = child.item) === null || _child$item === void 0 ? void 0 : _child$item.hidden$) {
1713
1721
  hiddenObservableMap.push(child.item.hidden$);
1714
- hiddenKeyMap.push(child.key);
1722
+ menusWithHiddenState.push(child);
1715
1723
  }
1716
1724
  }
1717
1725
  }
@@ -1723,10 +1731,7 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
1723
1731
  }
1724
1732
  this._hiddenSubscription = combineLatest(hiddenObservableMap.map((hidden$) => hidden$.pipe(startWith$1(false)))).pipe(distinctUntilChanged$1(isSameHiddenMap)).subscribe((hiddenMap) => {
1725
1733
  const newRibbon = [];
1726
- const hiddenPathMap = hiddenMap.map((hidden, index) => {
1727
- if (hidden) return hiddenKeyMap[index];
1728
- return null;
1729
- }).filter((item) => !!item);
1734
+ const hiddenMenus = new Set(menusWithHiddenState.filter((_, index) => hiddenMap[index]));
1730
1735
  for (const group of ribbon) {
1731
1736
  var _group$children, _newGroup$children2;
1732
1737
  const newGroup = {
@@ -1742,7 +1747,7 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
1742
1747
  let shouldAddItem = true;
1743
1748
  if ((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) {
1744
1749
  var _newItem$children2;
1745
- for (const child of item.children) if (!hiddenPathMap.includes(child.key)) {
1750
+ for (const child of item.children) if (!hiddenMenus.has(child)) {
1746
1751
  var _newItem$children;
1747
1752
  (_newItem$children = newItem.children) === null || _newItem$children === void 0 || _newItem$children.push(child);
1748
1753
  }
@@ -1763,6 +1768,10 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
1763
1768
  }
1764
1769
  this._setRibbon(newRibbon);
1765
1770
  });
1771
+ if (this._disposed) {
1772
+ this._hiddenSubscription.unsubscribe();
1773
+ this._hiddenSubscription = null;
1774
+ }
1766
1775
  }
1767
1776
  _filterContextualTabs(ribbon) {
1768
1777
  this._contextualTabs.clear();
@@ -1789,6 +1798,10 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
1789
1798
  }
1790
1799
  dispose() {
1791
1800
  var _this$_hiddenSubscrip2;
1801
+ if (this._disposed) return;
1802
+ super.dispose();
1803
+ this._visibleContextualTabs.clear();
1804
+ this._contextualTabs.clear();
1792
1805
  (_this$_hiddenSubscrip2 = this._hiddenSubscription) === null || _this$_hiddenSubscrip2 === void 0 || _this$_hiddenSubscrip2.unsubscribe();
1793
1806
  this._hiddenSubscription = null;
1794
1807
  this._ribbon$.next([]);
@@ -1796,7 +1809,6 @@ let DesktopRibbonService = class DesktopRibbonService extends Disposable {
1796
1809
  this._activatedTab$.complete();
1797
1810
  this._collapsedIds$.complete();
1798
1811
  this._fakeToolbarVisible$.complete();
1799
- super.dispose();
1800
1812
  }
1801
1813
  };
1802
1814
  DesktopRibbonService = __decorate([__decorateParam(0, IMenuManagerService), __decorateParam(1, IUniverInstanceService)], DesktopRibbonService);
@@ -4050,7 +4062,7 @@ const toolbarSelectorRootVariants = cva("univer-toolbar-selector-root univer-ani
4050
4062
  false: "univer-text-gray-900 dark:!univer-text-gray-0"
4051
4063
  },
4052
4064
  active: {
4053
- true: "univer-bg-gray-200",
4065
+ true: "univer-bg-gray-200 dark:!univer-bg-gray-500",
4054
4066
  false: ""
4055
4067
  }
4056
4068
  },
@@ -4321,7 +4333,7 @@ function RibbonGrid({ groups, title, className, ...props }) {
4321
4333
  const placements = placeRibbonGridItems(group.children ?? []);
4322
4334
  return /* @__PURE__ */ jsxs("div", {
4323
4335
  "data-u-comp": "ribbon-grid-group",
4324
- className: "univer-relative univer-box-border univer-flex univer-min-w-16 univer-shrink-0 univer-flex-col univer-px-2",
4336
+ className: "univer-relative univer-box-border univer-flex univer-shrink-0 univer-flex-col univer-px-2",
4325
4337
  children: [/* @__PURE__ */ jsx("div", {
4326
4338
  "data-testid": "ribbon-grid-group-grid",
4327
4339
  className: "univer-grid univer-min-h-0 univer-flex-1 univer-grid-flow-col univer-grid-rows-[repeat(2,1.5rem)] univer-content-center univer-gap-2 univer-py-2 [&>div>span>span]:univer-h-full",
@@ -4740,52 +4752,6 @@ var ContextMenuHostService = class extends Disposable {
4740
4752
  }
4741
4753
  };
4742
4754
 
4743
- //#endregion
4744
- //#region src/views/hooks/layout.ts
4745
- /**
4746
- * These hooks are used for browser layout
4747
- * Prefer to client-side
4748
- */
4749
- /**
4750
- * Allow the element to scroll when its height over the container height
4751
- * @param element
4752
- * Container means the window view that the element displays in.
4753
- * Recommend pass the sheet mountContainer as container
4754
- * @param container
4755
- */
4756
- function useScrollYOverContainer(element, container) {
4757
- const updater = useEvent(() => {
4758
- if (!element || !container) return;
4759
- const elStyle = element.style;
4760
- const { y, height } = element.getBoundingClientRect();
4761
- const containerRect = container.getBoundingClientRect();
4762
- const scrolled = element.scrollHeight > height;
4763
- const isOverViewport = y < 0 || y + height > containerRect.height;
4764
- if (!isOverViewport && !scrolled) {
4765
- elStyle.overflowY = "";
4766
- elStyle.maxHeight = "";
4767
- return;
4768
- }
4769
- if (isOverViewport) {
4770
- elStyle.overflowY = "auto";
4771
- elStyle.maxHeight = y < 0 ? `${element.scrollHeight + y}px` : `${containerRect.height - y}px`;
4772
- }
4773
- });
4774
- useEffect(() => {
4775
- if (!isBrowser() || !element || !container) return;
4776
- updater();
4777
- const resizeObserver = new ResizeObserver(updater);
4778
- resizeObserver.observe(element);
4779
- return () => {
4780
- resizeObserver.disconnect();
4781
- };
4782
- }, [element, container]);
4783
- }
4784
- function useConfigValue(configKey) {
4785
- const configService = useDependency(IConfigService);
4786
- return useObservable(useMemo(() => configService.subscribeConfigValue$(configKey), [configService]), configService.getConfig(configKey));
4787
- }
4788
-
4789
4755
  //#endregion
4790
4756
  //#region src/views/hooks/prevent-browser-zoom.ts
4791
4757
  /**
@@ -5451,7 +5417,6 @@ function ContextMenuPanel(props) {
5451
5417
  menuSessionVersion
5452
5418
  ]);
5453
5419
  const submenuPortalContainer = ((_layoutService$rootCo = layoutService.rootContainerElement) === null || _layoutService$rootCo === void 0 || (_layoutService$rootCo = _layoutService$rootCo.ownerDocument) === null || _layoutService$rootCo === void 0 ? void 0 : _layoutService$rootCo.body) ?? (typeof document !== "undefined" ? document.body : null);
5454
- useScrollYOverContainer(menuElement, layoutService.rootContainerElement);
5455
5420
  useEffect(() => {
5456
5421
  if (!menuElement) return;
5457
5422
  return preventBrowserZoomInContainers([menuElement]);
@@ -6543,6 +6508,52 @@ function WorkbenchSkeleton({ darkMode, direction, overlay = false }) {
6543
6508
  });
6544
6509
  }
6545
6510
 
6511
+ //#endregion
6512
+ //#region src/views/hooks/layout.ts
6513
+ /**
6514
+ * These hooks are used for browser layout
6515
+ * Prefer to client-side
6516
+ */
6517
+ /**
6518
+ * Allow the element to scroll when its height over the container height
6519
+ * @param element
6520
+ * Container means the window view that the element displays in.
6521
+ * Recommend pass the sheet mountContainer as container
6522
+ * @param container
6523
+ */
6524
+ function useScrollYOverContainer(element, container) {
6525
+ const updater = useEvent(() => {
6526
+ if (!element || !container) return;
6527
+ const elStyle = element.style;
6528
+ const { y, height } = element.getBoundingClientRect();
6529
+ const containerRect = container.getBoundingClientRect();
6530
+ const scrolled = element.scrollHeight > height;
6531
+ const isOverViewport = y < 0 || y + height > containerRect.height;
6532
+ if (!isOverViewport && !scrolled) {
6533
+ elStyle.overflowY = "";
6534
+ elStyle.maxHeight = "";
6535
+ return;
6536
+ }
6537
+ if (isOverViewport) {
6538
+ elStyle.overflowY = "auto";
6539
+ elStyle.maxHeight = y < 0 ? `${element.scrollHeight + y}px` : `${containerRect.height - y}px`;
6540
+ }
6541
+ });
6542
+ useEffect(() => {
6543
+ if (!isBrowser() || !element || !container) return;
6544
+ updater();
6545
+ const resizeObserver = new ResizeObserver(updater);
6546
+ resizeObserver.observe(element);
6547
+ return () => {
6548
+ resizeObserver.disconnect();
6549
+ };
6550
+ }, [element, container]);
6551
+ }
6552
+ function useConfigValue(configKey) {
6553
+ const configService = useDependency(IConfigService);
6554
+ return useObservable(useMemo(() => configService.subscribeConfigValue$(configKey), [configService]), configService.getConfig(configKey));
6555
+ }
6556
+
6546
6557
  //#endregion
6547
6558
  //#region src/views/hooks/update-effect.ts
6548
6559
  /**
@@ -7024,7 +7035,7 @@ const IUIController = createIdentifier("univer.ui.ui-controller");
7024
7035
  //#endregion
7025
7036
  //#region package.json
7026
7037
  var name = "@univerjs/ui";
7027
- var version = "1.0.4";
7038
+ var version = "1.1.0";
7028
7039
 
7029
7040
  //#endregion
7030
7041
  //#region src/views/color-picker/interface.ts
@@ -24547,7 +24558,7 @@ function MobileSchemaRow(props) {
24547
24558
  if (disabled) return;
24548
24559
  onExecute === null || onExecute === void 0 || onExecute({
24549
24560
  commandId: menuItem.commandId,
24550
- value: nextValue,
24561
+ value: typeof value === "number" && isRealNum(nextValue) ? Number(nextValue) : nextValue,
24551
24562
  id: menuItem.id,
24552
24563
  label: schema.key,
24553
24564
  params: menuItem.params
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(require("@univerjs/core"),require("@univerjs/core/facade"),require("@univerjs/engine-render"),require("@univerjs/ui")):typeof define==`function`&&define.amd?define([`@univerjs/core`,`@univerjs/core/facade`,`@univerjs/engine-render`,`@univerjs/ui`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCore,e.UniverCoreFacade,e.UniverEngineRender,e.UniverUi))})(this,function(e,t,n,r){function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){return function(n,r){t(n,r,e)}}function l(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var u=class extends t.FBase{appendTo(e){let t=typeof e==`string`?e.split(`|`):e,n=t.length,r={},i=r,a=this.__getSchema();t.forEach((e,t)=>{t===n-1?i[e]=a:i[e]={},i=i[e]}),this._menuManagerService.mergeMenu(r)}};let d=class extends u{constructor(t,n,i,a){super(),this._item=t,this._injector=n,this._commandService=i,this._menuManagerService=a,s(this,`_commandToRegister`,new Map),s(this,`_buildingSchema`,void 0);let o=typeof t.action==`string`?t.action:(0,e.generateRandomId)(12);o!==t.action&&this._commandToRegister.set(o,t.action),this._buildingSchema={menuItemFactory:()=>({id:t.id,type:r.MenuItemType.BUTTON,icon:t.icon,title:t.title,tooltip:t.tooltip,commandId:o})},t.order!==void 0&&(this._buildingSchema.order=t.order),t.gridLayout&&(this._buildingSchema.gridLayout=t.gridLayout)}__getSchema(){return this._commandToRegister.forEach((t,n)=>{this._commandService.hasCommand(n)||this._commandService.registerCommand({id:n,type:e.CommandType.COMMAND,handler:t})}),{[this._item.id]:this._buildingSchema}}};s(d,`RibbonStartGroup`,r.RibbonStartGroup),s(d,`RibbonPosition`,r.RibbonPosition),s(d,`MenuManagerPosition`,r.MenuManagerPosition),d=l([c(1,(0,e.Inject)(e.Injector)),c(2,e.ICommandService),c(3,r.IMenuManagerService)],d);let f=class extends u{constructor(e,t,n){super(),this._item=e,this._injector=t,this._menuManagerService=n,s(this,`_menuByGroups`,[]),s(this,`_submenus`,[]),s(this,`_buildingSchema`,void 0),this._buildingSchema={menuItemFactory:()=>({id:e.id,type:r.MenuItemType.SUBITEMS,icon:e.icon,title:e.title,tooltip:e.tooltip})},e.order!==void 0&&(this._buildingSchema.order=e.order),e.gridLayout&&(this._buildingSchema.gridLayout=e.gridLayout)}addSubmenu(e){return this._submenus.push(e),this}addSeparator(){return this._menuByGroups.push(this._submenus),this._submenus=[],this}__getSchema(){let e={};return this.addSeparator(),this._menuByGroups.forEach((t,n)=>{let r={};t.forEach(e=>{Object.assign(r,e.__getSchema())}),e[`${this._item.id}-group-${n}`]=r}),{[this._item.id]:Object.assign(this._buildingSchema,e)}}};f=l([c(1,(0,e.Inject)(e.Injector)),c(2,r.IMenuManagerService)],f);let p=class extends t.FBase{constructor(e,t,n,r){super(),this._injector=e,this._renderManagerService=t,this._univerInstanceService=n,this._shortcutService=r,s(this,`_forceDisableDisposable`,null)}enableShortcut(){var e;return(e=this._forceDisableDisposable)==null||e.dispose(),this._forceDisableDisposable=null,this}disableShortcut(){return this._forceDisableDisposable||=this._shortcutService.forceDisable(),this}triggerShortcut(t){let n=this._univerInstanceService.getCurrentUnitOfType(e.UniverInstanceType.UNIVER_SHEET);if(!n)return;let r=this._renderManagerService.getRenderUnitById(n.getUnitId());if(r)return r.engine.getCanvasElement().dispatchEvent(t),this._shortcutService.dispatch(t)}dispatchShortcutEvent(e){return this._shortcutService.dispatch(e)}};p=l([c(0,(0,e.Inject)(e.Injector)),c(1,(0,e.Inject)(n.IRenderManagerService)),c(2,e.IUniverInstanceService),c(3,r.IShortcutService)],p);var m=class extends t.FUniver{getURL(){return new URL(window.location.href)}getShortcut(){return this._injector.createInstance(p)}copy(){return this._commandService.executeCommand(r.CopyCommand.id)}paste(){return this._commandService.executeCommand(r.PasteCommand.id)}createMenu(e){return this._injector.createInstance(d,e)}createSubmenu(e){return this._injector.createInstance(f,e)}updateMenuConfig(e){return this._injector.get(r.IMenuManagerService).updateMenuConfig(e),this}openSidebar(e){return this._injector.get(r.ISidebarService).open(e)}openDialog(e){let t=this._injector.get(r.IDialogService).open({...e,onClose:()=>{t.dispose()}});return t}getComponentManager(){return this._injector.get(r.ComponentManager)}showMessage(e){return this._injector.get(r.IMessageService).show(e),this}setRibbonType(t){return this._injector.get(e.IConfigService).setConfig(r.UI_PLUGIN_CONFIG_KEY,{ribbonType:t},{merge:!0}),this}setUIVisible(e,t){return this._injector.get(r.IUIPartsService).setUIVisible(e,t),this}isUIVisible(e){return this._injector.get(r.IUIPartsService).isUIVisible(e)}registerUIPart(e,t){return this._injector.get(r.IUIPartsService).registerComponent(e,()=>(0,r.connectInjector)(t,this._injector))}registerComponent(e,t,n){let i=this._injector.get(r.ComponentManager);return this.disposeWithMe(i.register(e,t,{...n,override:(n==null?void 0:n.override)??!0}))}setCurrent(e){if(!this._injector.get(n.IRenderManagerService).getRenderUnitById(e))throw Error(`Unit not found`);this._univerInstanceService.setCurrentUnitForType(e)}addFonts(e){let t=this._injector.get(r.IFontService);e.forEach(e=>{t.addFont(e)})}};t.FUniver.extend(m);var h=class extends t.FEnum{get BuiltInUIPart(){return r.BuiltInUIPart}get KeyCode(){return r.KeyCode}};t.FEnum.extend(h)});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(require("@univerjs/core"),require("@univerjs/core/facade"),require("@univerjs/engine-render"),require("@univerjs/ui")):typeof define==`function`&&define.amd?define([`@univerjs/core`,`@univerjs/core/facade`,`@univerjs/engine-render`,`@univerjs/ui`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCore,e.UniverCoreFacade,e.UniverEngineRender,e.UniverUi))})(this,function(e,t,n,r){function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){return function(n,r){t(n,r,e)}}function l(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var u=class extends t.FBase{appendTo(e){let t=typeof e==`string`?e.split(`|`):e,n=t.length,r={},i=r,a=this.__getSchema();t.forEach((e,t)=>{t===n-1?i[e]=a:i[e]={},i=i[e]}),this._menuManagerService.mergeMenu(r)}};let d=class extends u{constructor(t,n,i,a){super(),this._item=t,this._injector=n,this._commandService=i,this._menuManagerService=a,s(this,`_commandToRegister`,/* @__PURE__ */ new Map),s(this,`_buildingSchema`,void 0);let o=typeof t.action==`string`?t.action:(0,e.generateRandomId)(12);o!==t.action&&this._commandToRegister.set(o,t.action),this._buildingSchema={menuItemFactory:()=>({id:t.id,type:r.MenuItemType.BUTTON,icon:t.icon,title:t.title,tooltip:t.tooltip,commandId:o})},t.order!==void 0&&(this._buildingSchema.order=t.order),t.gridLayout&&(this._buildingSchema.gridLayout=t.gridLayout)}__getSchema(){return this._commandToRegister.forEach((t,n)=>{this._commandService.hasCommand(n)||this._commandService.registerCommand({id:n,type:e.CommandType.COMMAND,handler:t})}),{[this._item.id]:this._buildingSchema}}};s(d,`RibbonStartGroup`,r.RibbonStartGroup),s(d,`RibbonPosition`,r.RibbonPosition),s(d,`MenuManagerPosition`,r.MenuManagerPosition),d=l([c(1,(0,e.Inject)(e.Injector)),c(2,e.ICommandService),c(3,r.IMenuManagerService)],d);let f=class extends u{constructor(e,t,n){super(),this._item=e,this._injector=t,this._menuManagerService=n,s(this,`_menuByGroups`,[]),s(this,`_submenus`,[]),s(this,`_buildingSchema`,void 0),this._buildingSchema={menuItemFactory:()=>({id:e.id,type:r.MenuItemType.SUBITEMS,icon:e.icon,title:e.title,tooltip:e.tooltip})},e.order!==void 0&&(this._buildingSchema.order=e.order),e.gridLayout&&(this._buildingSchema.gridLayout=e.gridLayout)}addSubmenu(e){return this._submenus.push(e),this}addSeparator(){return this._menuByGroups.push(this._submenus),this._submenus=[],this}__getSchema(){let e={};return this.addSeparator(),this._menuByGroups.forEach((t,n)=>{let r={};t.forEach(e=>{Object.assign(r,e.__getSchema())}),e[`${this._item.id}-group-${n}`]=r}),{[this._item.id]:Object.assign(this._buildingSchema,e)}}};f=l([c(1,(0,e.Inject)(e.Injector)),c(2,r.IMenuManagerService)],f);let p=class extends t.FBase{constructor(e,t,n,r){super(),this._injector=e,this._renderManagerService=t,this._univerInstanceService=n,this._shortcutService=r,s(this,`_forceDisableDisposable`,null)}enableShortcut(){var e;return(e=this._forceDisableDisposable)==null||e.dispose(),this._forceDisableDisposable=null,this}disableShortcut(){return this._forceDisableDisposable||=this._shortcutService.forceDisable(),this}triggerShortcut(t){let n=this._univerInstanceService.getCurrentUnitOfType(e.UniverInstanceType.UNIVER_SHEET);if(!n)return;let r=this._renderManagerService.getRenderUnitById(n.getUnitId());if(r)return r.engine.getCanvasElement().dispatchEvent(t),this._shortcutService.dispatch(t)}dispatchShortcutEvent(e){return this._shortcutService.dispatch(e)}};p=l([c(0,(0,e.Inject)(e.Injector)),c(1,(0,e.Inject)(n.IRenderManagerService)),c(2,e.IUniverInstanceService),c(3,r.IShortcutService)],p);var m=class extends t.FUniver{getURL(){return new URL(window.location.href)}getShortcut(){return this._injector.createInstance(p)}copy(){return this._commandService.executeCommand(r.CopyCommand.id)}paste(){return this._commandService.executeCommand(r.PasteCommand.id)}createMenu(e){return this._injector.createInstance(d,e)}createSubmenu(e){return this._injector.createInstance(f,e)}updateMenuConfig(e){return this._injector.get(r.IMenuManagerService).updateMenuConfig(e),this}openSidebar(e){return this._injector.get(r.ISidebarService).open(e)}openDialog(e){let t=this._injector.get(r.IDialogService).open({...e,onClose:()=>{t.dispose()}});return t}getComponentManager(){return this._injector.get(r.ComponentManager)}showMessage(e){return this._injector.get(r.IMessageService).show(e),this}setRibbonType(t){return this._injector.get(e.IConfigService).setConfig(r.UI_PLUGIN_CONFIG_KEY,{ribbonType:t},{merge:!0}),this}setUIVisible(e,t){return this._injector.get(r.IUIPartsService).setUIVisible(e,t),this}isUIVisible(e){return this._injector.get(r.IUIPartsService).isUIVisible(e)}registerUIPart(e,t){return this._injector.get(r.IUIPartsService).registerComponent(e,()=>(0,r.connectInjector)(t,this._injector))}registerComponent(e,t,n){let i=this._injector.get(r.ComponentManager);return this.disposeWithMe(i.register(e,t,{...n,override:(n==null?void 0:n.override)??!0}))}setCurrent(e){if(!this._injector.get(n.IRenderManagerService).getRenderUnitById(e))throw Error(`Unit not found`);this._univerInstanceService.setCurrentUnitForType(e)}addFonts(e){let t=this._injector.get(r.IFontService);e.forEach(e=>{t.addFont(e)})}};t.FUniver.extend(m);var h=class extends t.FEnum{get BuiltInUIPart(){return r.BuiltInUIPart}get KeyCode(){return r.KeyCode}};t.FEnum.extend(h)});