@univerjs/ui 0.5.2 → 0.5.3

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/cjs/facade.js CHANGED
@@ -1 +1 @@
1
- "use strict";var g=Object.defineProperty;var l=(n,e,t)=>e in n?g(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var a=(n,e,t)=>l(n,typeof e!="symbol"?e+"":e,t);const o=require("@univerjs/core"),s=require("@univerjs/ui");var b=Object.defineProperty,f=Object.getOwnPropertyDescriptor,v=(n,e,t,r)=>{for(var i=r>1?void 0:r?f(e,t):e,c=n.length-1,m;c>=0;c--)(m=n[c])&&(i=(r?m(e,t,i):m(i))||i);return r&&i&&b(e,t,i),i},u=(n,e)=>(t,r)=>e(t,r,n),d;let h=(d=class extends o.FBase{constructor(e,t,r,i){super();a(this,"_commandToRegister",new Map);a(this,"_buildingSchema");this._item=e,this._injector=t,this._commandService=r,this._menuManagerService=i;const c=typeof e.action=="string"?e.action:o.Tools.generateRandomId(12);c!==e.action&&this._commandToRegister.set(c,e.action),this._buildingSchema={menuItemFactory:()=>({id:e.id,type:s.MenuItemType.BUTTON,icon:e.icon,title:e.title,tooltip:e.tooltip,commandId:c})},typeof e.order<"u"&&(this._buildingSchema.order=e.order)}__getSchema(){return this._commandToRegister.forEach((e,t)=>{this._commandService.hasCommand(t)||this._commandService.registerCommand({id:t,type:o.CommandType.COMMAND,handler:e})}),{[this._item.id]:this._buildingSchema}}appendTo(e){const t=this.__getSchema();this._menuManagerService.mergeMenu({[e]:t})}},a(d,"RibbonStartGroup",s.RibbonStartGroup),a(d,"RibbonPosition",s.RibbonPosition),a(d,"MenuManagerPosition",s.MenuManagerPosition),d);h=v([u(1,o.Inject(o.Injector)),u(2,o.ICommandService),u(3,s.IMenuManagerService)],h);let p=class extends o.FBase{constructor(e,t,r){super();a(this,"_menuByGroups",[]);a(this,"_submenus",[]);a(this,"_buildingSchema");this._item=e,this._injector=t,this._menuManagerService=r,this._buildingSchema={menuItemFactory:()=>({id:e.id,type:s.MenuItemType.SUBITEMS,icon:e.icon,title:e.title,tooltip:e.tooltip})},typeof e.order<"u"&&(this._buildingSchema.order=e.order)}addSubmenu(e){return this._submenus.push(e),this}addSeparator(){return this._menuByGroups.push(this._submenus),this._submenus=[],this}appendTo(e){const t=this.__getSchema();this._menuManagerService.mergeMenu({[e]:t})}__getSchema(){const e={};return this.addSeparator(),this._menuByGroups.forEach((t,r)=>{const i={};t.forEach(c=>{Object.assign(i,c.__getSchema())}),e[`${this._item.id}-group-${r}`]=i}),{[this._item.id]:Object.assign(this._buildingSchema,e)}}};p=v([u(1,o.Inject(o.Injector)),u(2,s.IMenuManagerService)],p);var C=Object.defineProperty,I=Object.getOwnPropertyDescriptor,M=(n,e,t,r)=>{for(var i=r>1?void 0:r?I(e,t):e,c=n.length-1,m;c>=0;c--)(m=n[c])&&(i=(r?m(e,t,i):m(i))||i);return r&&i&&C(e,t,i),i},_=(n,e)=>(t,r)=>e(t,r,n);let S=class extends o.FBase{constructor(e,t){super();a(this,"_forceEscapeDisposable",null);this._injector=e,this._shortcutService=t}enableShortcut(){var e;(e=this._forceEscapeDisposable)==null||e.dispose(),this._forceEscapeDisposable=null}disableShortcut(){this._forceEscapeDisposable||(this._forceEscapeDisposable=this._shortcutService.forceEscape())}dispatchShortcutEvent(e){return this._shortcutService.dispatch(e)}};S=M([_(0,o.Inject(o.Injector)),_(1,s.IShortcutService)],S);class j extends o.FUniver{getURL(){return new URL(window.location.href)}getShortcut(){return this._injector.createInstance(S)}copy(){return this._commandService.executeCommand(s.CopyCommand.id)}paste(){return this._commandService.executeCommand(s.PasteCommand.id)}createMenu(e){return this._injector.createInstance(h,e)}createSubmenu(e){return this._injector.createInstance(p,e)}openSiderbar(e){return this._injector.get(s.ISidebarService).open(e)}openSidebar(e){return this.openSiderbar(e)}openDialog(e){const r=this._injector.get(s.IDialogService).open({...e,onClose:()=>{r.dispose()}});return r}getComponentManager(){return this._injector.get(s.ComponentManager)}showMessage(e){this._injector.get(s.IMessageService).show(e)}}o.FUniver.extend(j);class y extends o.FHooks{onBeforeCopy(e){return this._injector.get(o.ICommandService).beforeCommandExecuted(r=>{r.id===s.CopyCommand.id&&e()})}onCopy(e){return this._injector.get(o.ICommandService).onCommandExecuted(r=>{r.id===s.CopyCommand.id&&e()})}onBeforePaste(e){return this._injector.get(o.ICommandService).beforeCommandExecuted(r=>{r.id===s.PasteCommand.id&&e()})}onPaste(e){return this._injector.get(o.ICommandService).onCommandExecuted(r=>{(r.id===s.PasteCommand.id||r.id===s.SheetPasteShortKeyCommandName)&&e()})}}o.FHooks.extend(y);
1
+ "use strict";var g=Object.defineProperty;var l=(o,e,t)=>e in o?g(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var a=(o,e,t)=>l(o,typeof e!="symbol"?e+"":e,t);const n=require("@univerjs/core"),i=require("@univerjs/ui");var b=Object.defineProperty,I=Object.getOwnPropertyDescriptor,v=(o,e,t,r)=>{for(var s=r>1?void 0:r?I(e,t):e,c=o.length-1,u;c>=0;c--)(u=o[c])&&(s=(r?u(e,t,s):u(s))||s);return r&&s&&b(e,t,s),s},d=(o,e)=>(t,r)=>e(t,r,o),m;let h=(m=class extends n.FBase{constructor(e,t,r,s){super();a(this,"_commandToRegister",new Map);a(this,"_buildingSchema");this._item=e,this._injector=t,this._commandService=r,this._menuManagerService=s;const c=typeof e.action=="string"?e.action:n.Tools.generateRandomId(12);c!==e.action&&this._commandToRegister.set(c,e.action),this._buildingSchema={menuItemFactory:()=>({id:e.id,type:i.MenuItemType.BUTTON,icon:e.icon,title:e.title,tooltip:e.tooltip,commandId:c})},typeof e.order<"u"&&(this._buildingSchema.order=e.order)}__getSchema(){return this._commandToRegister.forEach((e,t)=>{this._commandService.hasCommand(t)||this._commandService.registerCommand({id:t,type:n.CommandType.COMMAND,handler:e})}),{[this._item.id]:this._buildingSchema}}appendTo(e){const t=this.__getSchema();this._menuManagerService.mergeMenu({[e]:t})}},a(m,"RibbonStartGroup",i.RibbonStartGroup),a(m,"RibbonPosition",i.RibbonPosition),a(m,"MenuManagerPosition",i.MenuManagerPosition),m);h=v([d(1,n.Inject(n.Injector)),d(2,n.ICommandService),d(3,i.IMenuManagerService)],h);let S=class extends n.FBase{constructor(e,t,r){super();a(this,"_menuByGroups",[]);a(this,"_submenus",[]);a(this,"_buildingSchema");this._item=e,this._injector=t,this._menuManagerService=r,this._buildingSchema={menuItemFactory:()=>({id:e.id,type:i.MenuItemType.SUBITEMS,icon:e.icon,title:e.title,tooltip:e.tooltip})},typeof e.order<"u"&&(this._buildingSchema.order=e.order)}addSubmenu(e){return this._submenus.push(e),this}addSeparator(){return this._menuByGroups.push(this._submenus),this._submenus=[],this}appendTo(e){const t=this.__getSchema();this._menuManagerService.mergeMenu({[e]:t})}__getSchema(){const e={};return this.addSeparator(),this._menuByGroups.forEach((t,r)=>{const s={};t.forEach(c=>{Object.assign(s,c.__getSchema())}),e[`${this._item.id}-group-${r}`]=s}),{[this._item.id]:Object.assign(this._buildingSchema,e)}}};S=v([d(1,n.Inject(n.Injector)),d(2,i.IMenuManagerService)],S);var f=Object.defineProperty,C=Object.getOwnPropertyDescriptor,j=(o,e,t,r)=>{for(var s=r>1?void 0:r?C(e,t):e,c=o.length-1,u;c>=0;c--)(u=o[c])&&(s=(r?u(e,t,s):u(s))||s);return r&&s&&f(e,t,s),s},_=(o,e)=>(t,r)=>e(t,r,o);let p=class extends n.FBase{constructor(e,t){super();a(this,"_forceEscapeDisposable",null);this._injector=e,this._shortcutService=t}enableShortcut(){var e;(e=this._forceEscapeDisposable)==null||e.dispose(),this._forceEscapeDisposable=null}disableShortcut(){this._forceEscapeDisposable||(this._forceEscapeDisposable=this._shortcutService.forceEscape())}dispatchShortcutEvent(e){return this._shortcutService.dispatch(e)}};p=j([_(0,n.Inject(n.Injector)),_(1,i.IShortcutService)],p);class M extends n.FUniver{getURL(){return new URL(window.location.href)}getShortcut(){return this._injector.createInstance(p)}copy(){return this._commandService.executeCommand(i.CopyCommand.id)}paste(){return this._commandService.executeCommand(i.PasteCommand.id)}createMenu(e){return this._injector.createInstance(h,e)}createSubmenu(e){return this._injector.createInstance(S,e)}openSiderbar(e){return this._injector.get(i.ISidebarService).open(e)}openSidebar(e){return this.openSiderbar(e)}openDialog(e){const r=this._injector.get(i.IDialogService).open({...e,onClose:()=>{r.dispose()}});return r}getComponentManager(){return this._injector.get(i.ComponentManager)}showMessage(e){return this._injector.get(i.IMessageService).show(e),this}setUIVisible(e,t){return this._injector.get(i.IUIPartsService).setUIVisible(e,t),this}isUIVisible(e){return this._injector.get(i.IUIPartsService).isUIVisible(e)}}n.FUniver.extend(M);class P extends n.FHooks{onBeforeCopy(e){return this._injector.get(n.ICommandService).beforeCommandExecuted(r=>{r.id===i.CopyCommand.id&&e()})}onCopy(e){return this._injector.get(n.ICommandService).onCommandExecuted(r=>{r.id===i.CopyCommand.id&&e()})}onBeforePaste(e){return this._injector.get(n.ICommandService).beforeCommandExecuted(r=>{r.id===i.PasteCommand.id&&e()})}onPaste(e){return this._injector.get(n.ICommandService).onCommandExecuted(r=>{(r.id===i.PasteCommand.id||r.id===i.SheetPasteShortKeyCommandName)&&e()})}}n.FHooks.extend(P);class y extends n.FEnum{get BuiltInUIPart(){return i.BuiltInUIPart}}n.FEnum.extend(y);