@imengyu/vue3-context-menu
Version:
A context menu component for Vue3
3 lines (2 loc) • 38.4 kB
JavaScript
(function(F,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(F=typeof globalThis<"u"?globalThis:F||self,e(F["vue3-context-menu"]={},F.Vue))})(this,function(F,e){"use strict";let J=null;function Ee(){return J!==null}function $e(t){J&&Ce(),J=t}function ge(t){t===J&&(J=null)}function Ce(){J&&(J.closeMenu(),J=null)}const A={defaultDirection:"br",defaultMinWidth:100,defaultMaxWidth:600,defaultZindex:100,defaultZoom:1,defaultAdjustPadding:{x:0,y:10},defaultSubMenuOpenDelay:200};function V(t,o){let r=t.offsetTop;return t.offsetParent!=null&&t.offsetParent!=o&&(r-=t.offsetParent.scrollTop,r+=V(t.offsetParent,o)),r}function L(t,o){let r=t.offsetLeft;return t.offsetParent!=null&&t.offsetParent!=o&&(r-=t.offsetParent.scrollLeft,r+=L(t.offsetParent,o)),r}function Ne(t,o,r,s){return{x:L(t,s)+o,y:V(t,s)+r}}const ue="mx-menu-default-container",Te="mx-menu-container-";let je=0;function be(t){const{getContainer:o,zIndex:r}=t;if(o){const p=typeof o=="function"?o():o;if(p){let n=p.getAttribute("id");return n||(n=Te+je++,p.setAttribute("id",n)),{eleId:n,container:p,isNew:!1}}}let s=document.getElementById(ue);return s||(s=document.createElement("div"),s.setAttribute("id",ue),s.setAttribute("class","mx-menu-ghost-host fullscreen"),document.body.appendChild(s)),s.style.zIndex=(r==null?void 0:r.toString())||A.defaultZindex.toString(),{eleId:ue,container:s,isNew:!0}}function Le(t){let o=0;for(let r=0;r<t.length;r++){const s=t.charCodeAt(r);o=(o<<5)-o+s,o|=0}return o}function ye(t){return typeof t=="number"?`${t}px`:t}const K=e.defineComponent({props:{vnode:{type:null},data:{type:null,default:null}},setup(t){const{vnode:o,data:r}=e.toRefs(t);return()=>typeof o.value=="function"?o.value(r.value):o.value}});function Fe(t,o){const r={...t};return delete r[o],r}var ze=Object.defineProperty,Ae=(t,o,r)=>o in t?ze(t,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[o]=r,ke=(t,o,r)=>Ae(t,typeof o!="symbol"?o+"":o,r);class Me{constructor(o,r){ke(this,"x",0),ke(this,"y",0),this.x=o||0,this.y=r||0}set(o,r){this.x=o,this.y=r}substract(o){this.x-=o.x,this.y-=o.y}}function xe(t){const{onDown:o,onMove:r,onUp:s}=t,p=new Me,n=new Me;let v;function d(C){C.stopPropagation(),n.set(C.x,C.y),n.substract(p),r(p,n,C,v)}function g(C){s(C,v),p.set(0,0),document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",g)}return(C,k)=>o(C,k)?(v=k,p.set(C.x,C.y),document.addEventListener("mousemove",d),document.addEventListener("mouseup",g),C.stopPropagation(),!0):!1}function Ve(t,o){let r=0;return{start(){r>0&&clearInterval(r),r=setInterval(()=>{r=0,o()},t)},stop(){r>0&&(clearInterval(r),r=0)}}}const te=[],Se=Ve(100,()=>{for(const t of te)t()});function De(t,o,r,s){let p=0,n=0;function v(){t.value&&(o&&p!==t.value.offsetWidth&&o(t.value.offsetWidth),r&&n!==t.value.offsetHeight&&r(t.value.offsetHeight),s&&(p!==t.value.offsetWidth||n!==t.value.offsetHeight)&&s(t.value.offsetWidth,t.value.offsetHeight),p=t.value.offsetWidth,n=t.value.offsetHeight)}return{startResizeChecker(){Se.start(),te.push(v)},stopResizeChecker(){const d=te.indexOf(v);d>=0&&te.splice(d,1),te.length===0&&Se.stop()}}}const ve=140,Ke=70,Ye=e.defineComponent({__name:"ScrollRect",props:{scroll:{type:String,default:"both"},scrollBarAlwaysShow:{type:Boolean,default:!1},scrollBarBackgroundClickable:{type:Boolean,default:!1},height:{type:Number,default:void 0},width:{type:Number,default:void 0},maxHeight:{type:Number,default:void 0},maxWidth:{type:Number,default:void 0},containerClass:{type:String,default:""},containerStyle:{type:null}},emits:["scroll","resized"],setup(t,{expose:o,emit:r}){const s=t,p=r,n=e.ref(),v=e.ref(),d=e.ref(),g=e.ref(),C=e.ref(),k=e.ref(),w=e.ref(!1),P=e.computed(()=>s.scroll==="horizontal"||s.scroll==="both"),H=e.computed(()=>s.scroll==="vertical"||s.scroll==="both"),b=e.reactive({show:!1,size:0,sizeRaw:0,pos:0}),h=e.reactive({show:!1,size:0,sizeRaw:0,pos:0});let y=0,f=0,i=0,M=0,x=null;const B={attributes:!0,childList:!0};function I(){if(n.value){if(b.show){const c=n.value.offsetWidth/n.value.scrollWidth;b.sizeRaw=c*n.value.offsetWidth,b.size=c*100,b.pos=n.value.scrollLeft/(n.value.scrollWidth-n.value.offsetWidth)*(100-b.size),c>=1&&(b.show=!1)}if(h.show){const c=n.value.offsetHeight/n.value.scrollHeight;h.sizeRaw=c*n.value.offsetHeight,h.size=c*100,h.pos=n.value.scrollTop/(n.value.scrollHeight-n.value.offsetHeight)*(100-h.size),c>=1&&(h.show=!1)}p("scroll",n.value.scrollLeft,n.value.scrollTop)}}function u(c=!1){if(!n.value)return;let l=P.value,m=H.value;const O=l&&(y!==n.value.scrollWidth||i!==n.value.offsetWidth),a=H&&(f!==n.value.scrollHeight||M!==n.value.offsetHeight);if(!c&&!O&&!a)return;const U=window.getComputedStyle(n.value);(U.overflow==="hidden"||U.overflowX==="hidden")&&(l=!1),(U.overflow==="hidden"||U.overflowY==="hidden")&&(m=!1),b.show=l,h.show=m,I(),i=n.value.offsetWidth,M=n.value.offsetHeight,y=n.value.scrollWidth,f=n.value.scrollHeight,p("resized",y,f)}function _(c){var l;s.scroll=="horizontal"&&(c.deltaMode==0&&((l=n.value)==null||l.scrollTo({left:n.value.scrollLeft+(c.deltaY>0?ve:-140),behavior:"smooth"})),c.preventDefault(),c.stopPropagation())}function R(c){var l;c.deltaMode==0&&((l=n.value)==null||l.scrollTo({left:n.value.scrollLeft+(c.deltaY>0?ve:-140),behavior:"smooth"}),c.preventDefault(),c.stopPropagation())}function E(c){var l;c.deltaMode==0&&((l=n.value)==null||l.scrollTo({top:n.value.scrollTop+(c.deltaY>0?Ke:-70),behavior:"smooth"}),c.preventDefault(),c.stopPropagation())}let T=0,Z=0,$=0,S=0;const N=xe({onDown(c){return!d.value||!C.value?!1:(T=c.offsetX,Z=c.x-c.offsetX-C.value.offsetLeft,c.preventDefault(),w.value=!0,!0)},onMove(c,l,m){n.value&&d.value&&(G(m.x-T-Z),m.preventDefault(),m.stopPropagation())},onUp(){w.value=!1}}),j=xe({onDown(c){return!g.value||!k.value?!1:($=c.offsetY,S=c.y-c.offsetY-k.value.offsetTop,c.preventDefault(),w.value=!0,!0)},onMove(c,l,m){n.value&&g.value&&(Y(m.y-$-S),m.preventDefault(),m.stopPropagation())},onUp(){w.value=!1}});function D(c){n.value&&(n.value.scrollLeft=c/100*(n.value.scrollWidth-n.value.offsetWidth))}function z(c){n.value&&(n.value.scrollLeft=c/100*(n.value.scrollHeight-n.value.offsetHeight))}function G(c){n.value&&(n.value.scrollLeft=c/(n.value.offsetWidth-b.sizeRaw)*(n.value.scrollWidth-n.value.offsetWidth))}function Y(c){n.value&&(n.value.scrollTop=c/(n.value.offsetHeight-h.sizeRaw)*(n.value.scrollHeight-n.value.offsetHeight))}function Q(c){s.scrollBarBackgroundClickable&&G(c.offsetX-b.sizeRaw/2)}function W(c){s.scrollBarBackgroundClickable&&Y(c.offsetY-h.sizeRaw/2)}const{startResizeChecker:ne,stopResizeChecker:Oe}=De(n,()=>u(),()=>u());return e.onMounted(()=>{e.nextTick(()=>{setTimeout(()=>u(!0),200),u(!0),ne(),x=new MutationObserver(()=>u()),x.observe(n.value,B)})}),e.onBeforeUnmount(()=>{Oe(),x&&(x.disconnect(),x=null)}),o({refreshScrollState(){u(!0)},getScrollContainer(){return n.value},scrollTo(c,l){var m;(m=n.value)==null||m.scrollTo(c,l)},scrollToTop(){var c;(c=n.value)==null||c.scrollTo(0,0)},scrollToBottom(){var c;(c=n.value)==null||c.scrollTo(n.value.scrollWidth,n.value.scrollHeight)}}),(c,l)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"scrollrect",ref:v,class:e.normalizeClass(["vue-scroll-rect",t.scrollBarAlwaysShow?"always-show-scrollbar":"",t.scrollBarBackgroundClickable?"background-clickable":"",w.value?"dragging":""]),style:e.normalizeStyle({width:t.width?`${t.width}px`:void 0,height:t.height?`${t.height}px`:void 0}),onWheel:_},[e.createElementVNode("div",{ref_key:"container",ref:n,class:e.normalizeClass(["scroll-content",t.scroll,t.containerClass]),style:e.normalizeStyle({maxWidth:t.maxWidth?`${t.maxWidth}px`:void 0,maxHeight:t.maxHeight?`${t.maxHeight}px`:void 0,...t.containerStyle}),onScroll:I},[e.renderSlot(c.$slots,"default")],38),b.show?e.renderSlot(c.$slots,"scrollBarX",{key:0,scrollBarValue:b,onScroll:D},()=>[e.createElementVNode("div",{ref_key:"scrollBarRefX",ref:d,class:"scrollbar horizontal",onClick:Q,onWheel:R},[e.createElementVNode("div",{class:"thumb",ref_key:"scrollBarThumbRefX",ref:C,style:e.normalizeStyle({left:`${b.pos}%`,width:`${b.size}%`}),onMousedown:l[0]||(l[0]=(...m)=>e.unref(N)&&e.unref(N)(...m)),onWheel:R},null,36)],544)]):e.createCommentVNode("",!0),h.show?e.renderSlot(c.$slots,"scrollBarY",{key:1,scrollBarValue:h,onScroll:z},()=>[h.show?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"scrollBarRefY",ref:g,class:"scrollbar vertical",onClick:W,onWheel:E},[e.createElementVNode("div",{class:"thumb",ref_key:"scrollBarThumbRefY",ref:k,style:e.normalizeStyle({top:`${h.pos}%`,height:`${h.size}%`}),onMousedown:l[1]||(l[1]=(...m)=>e.unref(j)&&e.unref(j)(...m)),onWheel:E},null,36)],544)):e.createCommentVNode("",!0)]):e.createCommentVNode("",!0)],38))}}),re=(t,o)=>{const r=t.__vccOpts||t;for(const[s,p]of o)r[s]=p;return r},Ue={},Xe={class:"mx-checked-mark","aria-hidden":"true",viewBox:"0 0 1024 1024"},Ze=[e.createElementVNode("path",{d:"M129.3,428.6L52,512l345,372.5l575-620.8l-69.5-75L400.4,718.2L129.3,428.6z"},null,-1)];function Ge(t,o){return e.openBlock(),e.createElementBlock("svg",Xe,Ze)}const qe=re(Ue,[["render",Ge]]),Je={},Qe={class:"mx-right-arrow","aria-hidden":"true",viewBox:"0 0 1024 1024"},et=[e.createElementVNode("path",{d:"M307.018 49.445c11.517 0 23.032 4.394 31.819 13.18L756.404 480.18c8.439 8.438 13.181 19.885 13.181 31.82s-4.741 23.38-13.181 31.82L338.838 961.376c-17.574 17.573-46.065 17.573-63.64-0.001-17.573-17.573-17.573-46.065 0.001-63.64L660.944 512 275.198 126.265c-17.574-17.573-17.574-46.066-0.001-63.64C283.985 53.839 295.501 49.445 307.018 49.445z"},null,-1)];function tt(t,o){return e.openBlock(),e.createElementBlock("svg",Qe,et)}const nt=re(Je,[["render",tt]]),ot={class:"mx-item-row"},lt=["xlink:href"],st={key:1,class:"label"},rt={class:"mx-item-row"},at={class:"mx-shortcut"},ae=e.defineComponent({__name:"ContextMenuItem",props:{disabled:{type:Boolean,default:!1},hidden:{type:Boolean,default:!1},customRender:{type:Function,default:null},customClass:{type:String,default:""},clickHandler:{type:Function,default:null},label:{type:[String,Object,Function],default:""},icon:{type:[String,Object,Function],default:""},iconFontClass:{type:String,default:"iconfont"},checked:{type:Boolean,default:!1},shortcut:{type:String,default:""},svgIcon:{type:String,default:""},svgProps:{type:Object,default:null},preserveIconWidth:{type:Boolean,default:!0},showRightArrow:{type:Boolean,default:!1},hasChildren:{type:Boolean,default:!1},clickClose:{type:Boolean,default:!0},clickableWhenHasChildren:{type:Boolean,default:!1},rawMenuItem:{type:Object,default:void 0}},emits:["click","subMenuOpen","subMenuClose"],setup(t,{expose:o,emit:r}){const s=t,p=r,{clickHandler:n,clickClose:v,clickableWhenHasChildren:d,disabled:g,hidden:C,label:k,icon:w,iconFontClass:P,showRightArrow:H,shortcut:b,hasChildren:h}=e.toRefs(s),y=e.ref(!1),f=e.ref(!1),i=e.ref(),M=e.inject("globalOptions"),x=e.inject("globalHasSlot"),B=e.inject("globalRenderSlot"),I=e.inject("globalCloseMenu"),u=e.inject("menuContext"),_=e.computed(()=>typeof k.value=="string"?k.value:typeof k.value=="function"?Le(k.value.toString()):"MenuItem[unknow]");e.provide("MenuItemName",_);const R={getSubMenuInstance:()=>{},showSubMenu:()=>y.value?(u.markActiveMenuItem(R,!0),!0):h.value?(T(),!0):!1,hideSubMenu:()=>{u.closeOtherSubMenu()},isDisabledOrHidden:()=>g.value||C.value,getElement:()=>i.value,focus:()=>f.value=!0,blur:()=>f.value=!1,click:E};e.provide("menuItemInstance",R),e.onMounted(()=>{u.isMenuItemDataCollectedFlag()?e.nextTick(()=>{let S=0;const N=u.getElement();if(N){let j=0;for(let D=0;D<N.children.length;D++){const z=N.children[D];if(z.getAttribute("data-type")==="ContextMenuItem"){if(z===i.value){S=j;break}j++}}}u.addChildMenuItem(R,S)}):u.addChildMenuItem(R)}),e.onBeforeUnmount(()=>{u.removeChildMenuItem(R)});function E(S){if(!g.value){if(S){const N=S.target;if(N.classList.contains("mx-context-no-clickable")||M.value.ignoreClickClassName&&N.classList.contains(M.value.ignoreClickClassName))return;if(M.value.clickCloseClassName&&N.classList.contains(M.value.clickCloseClassName)){S.stopPropagation(),I(s.rawMenuItem);return}}h.value?d.value?(typeof n.value=="function"&&n.value(S),p("click",S)):y.value||T():(typeof n.value=="function"&&n.value(S),p("click",S),v.value&&I(s.rawMenuItem))}}function T(S){f.value=!1,g.value||(u.markActiveMenuItem(R),h.value?(S||u.markThisOpenedByKeyBoard(),u.openSubMenuWithDelay(()=>{u.addOpenedSubMenu(Z),y.value=!0,e.nextTick(()=>p("subMenuOpen",R))},i.value)):(u.cancelPendingOpen(),u.closeOtherSubMenu()))}function Z(){f.value=!1,y.value=!1,p("subMenuClose",R)}function $(){return{disabled:g.value,label:k.value,icon:w.value,iconFontClass:P.value,showRightArrow:H.value,clickClose:v.value,clickableWhenHasChildren:d.value,shortcut:b.value,theme:M.value.theme,isOpen:y,hasChildren:h,onClick:E,onMouseEnter:T,closeMenu:I}}return o(R),(S,N)=>{var j;return e.unref(C)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",e.mergeProps({key:0,class:"mx-context-menu-item-wrapper",ref_key:"menuItemRef",ref:i,"data-type":"ContextMenuItem"},{...S.$attrs,...((j=t.rawMenuItem)==null?void 0:j.attrs)||{}}),[e.unref(x)("itemRender")?(e.openBlock(),e.createBlock(e.unref(K),{key:0,vnode:()=>e.unref(B)("itemRender",$())},null,8,["vnode"])):t.customRender?(e.openBlock(),e.createBlock(e.unref(K),{key:1,vnode:t.customRender,data:$()},null,8,["vnode","data"])):(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["mx-context-menu-item",e.unref(g)?"disabled":"",f.value?"keyboard-focus":"",t.customClass?" "+t.customClass:"",y.value?"open":""]),onClick:E,onMouseenter:T},[e.renderSlot(S.$slots,"default",{},()=>[e.createElementVNode("div",ot,[e.createElementVNode("div",{class:e.normalizeClass(["mx-icon-placeholder",t.preserveIconWidth?"preserve-width":""])},[e.renderSlot(S.$slots,"icon",{},()=>[e.unref(x)("itemIconRender")?(e.openBlock(),e.createBlock(e.unref(K),{key:0,vnode:()=>e.unref(B)("itemIconRender",$())},null,8,["vnode"])):typeof t.svgIcon=="string"&&t.svgIcon?(e.openBlock(),e.createElementBlock("svg",e.mergeProps({key:1,class:"icon svg"},t.svgProps),[e.createElementVNode("use",{"xlink:href":t.svgIcon},null,8,lt)],16)):typeof e.unref(w)!="string"?(e.openBlock(),e.createBlock(e.unref(K),{key:2,vnode:e.unref(w),data:e.unref(w)},null,8,["vnode","data"])):typeof e.unref(w)=="string"&&e.unref(w)!==""?(e.openBlock(),e.createElementBlock("i",{key:3,class:e.normalizeClass(e.unref(w)+" icon "+e.unref(P)+" "+e.unref(M).iconFontClass)},null,2)):e.createCommentVNode("",!0)]),t.checked?e.renderSlot(S.$slots,"check",{key:0},()=>[e.unref(x)("itemCheckRender")?(e.openBlock(),e.createBlock(e.unref(K),{key:0,vnode:()=>e.unref(B)("itemCheckRender",$())},null,8,["vnode"])):e.createCommentVNode("",!0),e.createVNode(qe)]):e.createCommentVNode("",!0)],2),e.renderSlot(S.$slots,"label",{},()=>[e.unref(x)("itemLabelRender")?(e.openBlock(),e.createBlock(e.unref(K),{key:0,vnode:()=>e.unref(B)("itemLabelRender",$())},null,8,["vnode"])):typeof e.unref(k)=="string"?(e.openBlock(),e.createElementBlock("span",st,e.toDisplayString(e.unref(k)),1)):(e.openBlock(),e.createBlock(e.unref(K),{key:2,vnode:e.unref(k),data:e.unref(k)},null,8,["vnode","data"]))])]),e.createElementVNode("div",rt,[e.unref(b)||S.$slots.shortcut?e.renderSlot(S.$slots,"shortcut",{key:0},()=>[e.unref(x)("itemShortcutRender")?(e.openBlock(),e.createBlock(e.unref(K),{key:0,vnode:()=>e.unref(B)("itemShortcutRender",$())},null,8,["vnode"])):e.createCommentVNode("",!0),e.createElementVNode("span",at,e.toDisplayString(e.unref(b)),1)]):e.createCommentVNode("",!0),e.unref(H)?e.renderSlot(S.$slots,"rightArrow",{key:1},()=>[e.unref(x)("itemRightArrowRender")?(e.openBlock(),e.createBlock(e.unref(K),{key:0,vnode:()=>e.unref(B)("itemRightArrowRender",$())},null,8,["vnode"])):e.createCommentVNode("",!0),e.createVNode(nt)]):e.createCommentVNode("",!0)])])],34)),e.renderSlot(S.$slots,"submenu",{context:R,show:y.value})],16))}}}),it=e.defineComponent({name:"ContextMenuSperator",components:{VNodeRender:K},setup(){const t=e.inject("globalHasSlot"),o=e.inject("globalRenderSlot");return{globalHasSlot:t,globalRenderSlot:o}}}),ct={key:1,class:"mx-context-menu-item-sperator mx-context-no-clickable"};function ut(t,o,r,s,p,n){const v=e.resolveComponent("VNodeRender");return t.globalHasSlot("separatorRender")?(e.openBlock(),e.createBlock(v,{key:0,vnode:()=>t.globalRenderSlot("separatorRender",{})},null,8,["vnode"])):(e.openBlock(),e.createElementBlock("div",ct))}const ee=re(it,[["render",ut]]),de=e.defineComponent({__name:"ContextSubMenu",props:{items:{type:Object,default:null},show:{type:Boolean,default:!1},destroyOnClose:{type:Boolean,default:!0},maxHeight:{type:Number,default:0},maxWidth:{type:[String,Number],default:0},minWidth:{type:[String,Number],default:0},adjustPosition:{type:Boolean,default:!0},direction:{type:String,default:"br"},parentMenuItemContext:{type:Object,default:null}},emits:["closeAnimFinished"],setup(t,{expose:o,emit:r}){const s=t,p=r,n=e.ref(!1),v=e.inject("globalGetMenuHostId",""),d=e.inject("menuContext"),g=e.inject("globalOptions");e.inject("globalHasSlot"),e.inject("globalRenderSlot");const C=e.ref("UnknowOrRoot"),k=e.inject("MenuItemName",C),{zIndex:w,getParentWidth:P,getParentHeight:H,getZoom:b}=d,{adjustPosition:h}=e.toRefs(s),y=e.ref(),f=e.ref(),i=e.ref(),M=[],x=e.inject("globalSetCurrentSubMenu"),B=[];let I=null,u=0,_=0;function R(){I&&I.blur()}function E(l,m){if(l){for(let O=m!==void 0?m:0;O<B.length;O++)if(!B[O].isDisabledOrHidden()){T(O);break}}else for(let O=m!==void 0?m:B.length-1;O>=0;O--)if(!B[O].isDisabledOrHidden()){T(O);break}}function T(l){if(I&&R(),l!==void 0&&(I=B[Math.max(0,Math.min(l,B.length-1))]),!I)return;I.focus();const m=I.getElement();m&&m.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"})}function Z(){x($)}const $={el:i,name:k,isTopLevel:()=>d.getParentContext()===null,closeSelfAndActiveParent:()=>{const l=j.getParentContext();if(l){l.closeOtherSubMenu();const m=l.getSubMenuInstanceContext();if(m)return m.focusCurrentItem(),!0}return!1},closeCurrentSubMenu:()=>{var l;return(l=j.getParentContext())==null?void 0:l.closeOtherSubMenu()},moveCurrentItemFirst:()=>E(!0),moveCurrentItemLast:()=>E(!1),moveCurrentItemDown:()=>E(!0,I?B.indexOf(I)+1:0),moveCurrentItemUp:()=>E(!1,I?B.indexOf(I)-1:0),focusCurrentItem:()=>T(),openCurrentItemSubMenu:()=>I?I==null?void 0:I.showSubMenu():!1,triggerCurrentItemClick:l=>I==null?void 0:I.click(l)};let S=!1,N=!1;const j={zIndex:w+1,container:d.container,adjustPadding:g.value.adjustPadding||A.defaultAdjustPadding,getParentWidth:()=>{var l;return((l=i.value)==null?void 0:l.offsetWidth)||0},getParentHeight:()=>{var l;return((l=i.value)==null?void 0:l.offsetHeight)||0},getPositon:()=>[W.value.x,W.value.y],getZoom:()=>g.value.zoom||A.defaultZoom,addOpenedSubMenu(l){M.push(l)},closeOtherSubMenu(){M.forEach(l=>l()),M.splice(0,M.length),x($)},checkCloseOtherSubMenuTimeOut(){return u?(clearTimeout(u),u=0,!0):!1},closeOtherSubMenuWithTimeOut(){u=setTimeout(()=>{u=0,this.closeOtherSubMenu()},200)},openSubMenuWithDelay(l,m){_&&(clearTimeout(_),_=0);const O=g.value.subMenuOpenDelay??A.defaultSubMenuOpenDelay,a=M.length>0;O===0||!a?(this.closeOtherSubMenu(),l()):_=setTimeout(()=>{_=0,m.matches(":hover")&&(this.closeOtherSubMenu(),l())},O)},cancelPendingOpen(){_&&(clearTimeout(_),_=0)},addChildMenuItem:(l,m)=>{m===void 0?B.push(l):B.splice(m,0,l)},removeChildMenuItem:l=>{B.splice(B.indexOf(l),1),l.getSubMenuInstance=()=>{}},markActiveMenuItem:(l,m=!1)=>{R(),I=l,m&&T()},markThisOpenedByKeyBoard:()=>{S=!0},isOpenedByKeyBoardFlag:()=>S?(S=!1,!0):!1,isMenuItemDataCollectedFlag:()=>N,getElement:()=>i.value||null,getParentContext:()=>d,getSubMenuInstanceContext:()=>$};e.provide("menuContext",j);const D={getChildItem:l=>B[l],getMenuDimensions:()=>f.value?{width:f.value.offsetWidth,height:f.value.offsetHeight}:{width:0,height:0},getSubmenuRoot:()=>f.value,getMenu:()=>i.value,getScrollValue:()=>{var l,m;return((m=(l=y.value)==null?void 0:l.getScrollContainer())==null?void 0:m.scrollTop)||0},setScrollValue:l=>{var m;return(m=y.value)==null?void 0:m.scrollTo(0,l)},getScrollHeight:()=>G.value,adjustPosition:()=>{ne()},getMaxHeight:()=>Y.value,getPosition:()=>W.value,setPosition:(l,m)=>{W.value.x=l,W.value.y=m}},z=e.inject("menuItemInstance",void 0);z&&(z.getSubMenuInstance=()=>D);const G=e.ref(0),Y=e.ref(0),Q=e.ref(!1),W=e.ref({x:0,y:0});function ne(){e.nextTick(()=>{var O;const l=i.value,m=f.value;if(l&&m&&y.value){const{container:a}=d,U=(P==null?void 0:P())??0,q=(H==null?void 0:H())??0,X=getComputedStyle(m),ie=parseFloat(X.paddingLeft),ce=parseFloat(X.paddingTop),he=q>0?ce:0,kt=document.documentElement.scrollHeight/b(),Mt=document.documentElement.scrollWidth/b(),xt=Math.min(Mt,a.offsetWidth),_e=Math.min(kt,a.offsetHeight);let me=L(l,a),pe=V(l,a);if(s.direction.includes("l")?W.value.x-=l.offsetWidth+ie:s.direction.includes("r")?W.value.x+=U+ie:(W.value.x+=U/2,W.value.x-=(l.offsetWidth+ie)/2),s.direction.includes("t")){const oe=(O=s.parentMenuItemContext)==null?void 0:O.getElement();oe&&(W.value.y+=oe.offsetHeight),W.value.y-=(l.offsetHeight+ce)/b()}else s.direction.includes("b")?W.value.y-=ce/b():W.value.y-=l.offsetHeight/2/b();e.nextTick(()=>{var He,Pe;me=L(l,a),pe=V(l,a);const oe=((Pe=(He=y.value)==null?void 0:He.getScrollContainer())==null?void 0:Pe.scrollHeight)||0,St=s.maxHeight;G.value=s.maxHeight?Math.min(oe,s.maxHeight):oe;const vt=me+l.offsetWidth-xt,Re=pe+G.value+he*2-_e;if(Q.value=Re>0,h.value&&vt>0){const le=U+l.offsetWidth-ie,se=me;le>se?W.value.x-=se:W.value.x-=le}if(Q.value){if(h.value){const le=Re,se=pe;le>se?W.value.y-=se-he:W.value.y-=le-he}Y.value=_e-(W.value.y+ce)}else Y.value=St||0})}})}function Oe(){}function c(){var m;const l=(m=s.parentMenuItemContext)==null?void 0:m.getElement();if(l){const O=L(l,d.container),a=V(l,d.container);W.value.x=O,W.value.y=a}else{const[O,a]=d.getPositon();W.value.x=O,W.value.y=a}e.nextTick(()=>{var O;x($),(O=i.value)==null||O.focus({preventScroll:!0}),d.isOpenedByKeyBoardFlag()&&e.nextTick(()=>E(!0)),N=!0}),ne()}return e.watch(()=>s.show,l=>{l?c():void 0}),e.onMounted(()=>{n.value=!0,s.show?c():ne()}),e.onBeforeUnmount(()=>{n.value=!1,z&&(z.getSubMenuInstance=()=>{})}),o(D),(l,m)=>{const O=e.resolveComponent("ContextSubMenu",!0);return n.value?(e.openBlock(),e.createBlock(e.Teleport,{key:0,to:`#${e.unref(v)}`},[e.createVNode(e.Transition,e.mergeProps({appear:""},e.unref(g).menuTransitionProps||{duration:10},{onAfterLeave:m[0]||(m[0]=a=>p("closeAnimFinished"))}),{default:e.withCtx(()=>[!t.destroyOnClose||t.show?e.withDirectives((e.openBlock(),e.createElementBlock("div",e.mergeProps({key:0,ref_key:"submenuRoot",ref:f},l.$attrs,{class:["mx-context-menu",e.unref(g).customClass?e.unref(g).customClass:"",e.unref(g).theme??""],style:{maxWidth:t.maxWidth?e.unref(ye)(t.maxWidth):`${e.unref(A).defaultMaxWidth}px`,minWidth:t.minWidth?e.unref(ye)(t.minWidth):`${e.unref(A).defaultMinWidth}px`,zIndex:e.unref(w),left:`${W.value.x}px`,top:`${W.value.y}px`},"data-type":"ContextSubMenu",onClick:Z}),[e.createVNode(e.unref(Ye),{ref_key:"scrollRectRef",ref:y,scroll:"vertical",maxHeight:Y.value,containerClass:"mx-context-menu-scroll"},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(["mx-context-menu-items"]),ref_key:"menu",ref:i},[e.renderSlot(l.$slots,"default",{},()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.items,(a,U)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:U},[a.hidden!==!0&&a.divided==="up"?(e.openBlock(),e.createBlock(ee,{key:0})):e.createCommentVNode("",!0),a.hidden!==!0&&a.divided==="self"?(e.openBlock(),e.createBlock(ee,{key:1})):(e.openBlock(),e.createBlock(ae,{key:2,clickHandler:a.onClick?q=>a.onClick(q):void 0,disabled:typeof a.disabled=="object"?a.disabled.value:a.disabled,hidden:typeof a.hidden=="object"?a.hidden.value:a.hidden,icon:a.icon,iconFontClass:a.iconFontClass,svgIcon:a.svgIcon,svgProps:a.svgProps,label:a.label,customRender:a.customRender,customClass:a.customClass,checked:typeof a.checked=="object"?a.checked.value:a.checked,shortcut:a.shortcut,clickClose:a.clickClose,clickableWhenHasChildren:a.clickableWhenHasChildren,preserveIconWidth:a.preserveIconWidth!==void 0?a.preserveIconWidth:e.unref(g).preserveIconWidth,showRightArrow:a.children&&a.children.length>0,hasChildren:a.children&&a.children.length>0,rawMenuItem:a,onSubMenuOpen:q=>{var X;return(X=a.onSubMenuOpen)==null?void 0:X.call(a,q)},onSubMenuClose:q=>{var X;return(X=a.onSubMenuClose)==null?void 0:X.call(a,q)}},e.createSlots({_:2},[a.children&&a.children.length>0?{name:"submenu",fn:e.withCtx(({context:q,show:X})=>[e.createVNode(O,{show:X,destroyOnClose:t.destroyOnClose,parentMenuItemContext:q,items:a.children,maxWidth:a.maxWidth,minWidth:a.minWidth,maxHeight:a.maxHeight,adjustPosition:a.adjustSubMenuPosition!==void 0?a.adjustSubMenuPosition:e.unref(g).adjustPosition,direction:a.direction!==void 0?a.direction:e.unref(g).direction},null,8,["show","destroyOnClose","parentMenuItemContext","items","maxWidth","minWidth","maxHeight","adjustPosition","direction"])]),key:"0"}:void 0]),1032,["clickHandler","disabled","hidden","icon","iconFontClass","svgIcon","svgProps","label","customRender","customClass","checked","shortcut","clickClose","clickableWhenHasChildren","preserveIconWidth","showRightArrow","hasChildren","rawMenuItem","onSubMenuOpen","onSubMenuClose"])),a.hidden!==!0&&(a.divided==="down"||a.divided===!0)?(e.openBlock(),e.createBlock(ee,{key:3})):e.createCommentVNode("",!0)],64))),128))])],512)]),_:3},8,["maxHeight"])],16)),[[e.vShow,t.show]]):e.createCommentVNode("",!0)]),_:3},16)],8,["to"])):e.createCommentVNode("",!0)}}}),It="",we=e.defineComponent({__name:"ContextSubMenuWrapper",props:{options:{type:Object,default:null},show:{type:null,default:null},destroyOnClose:{type:Boolean,default:!0},container:{type:Object,default:null},isFullScreenContainer:{type:Boolean,default:!0}},emits:["close","closeAnimFinished"],setup(t,{expose:o,emit:r}){const s=t,p=r,n=e.useSlots(),v=e.ref(),{options:d,show:g,destroyOnClose:C,container:k}=e.toRefs(s);e.onMounted(()=>{g.value&&H()}),e.onBeforeUnmount(()=>{f()}),e.watch(g,u=>{u?H():(ge(w),f())});const w={closeMenu:b,isClosed:h,getMenuRef:()=>v.value,getMenuDimensions:()=>{var u;return((u=v.value)==null?void 0:u.getMenuDimensions())??{width:0,height:0}}};let P=!1;function H(){y(),$e(w)}function b(u){P=!0,p("close",u),d.value.menuTransitionProps||p("closeAnimFinished"),ge(w)}function h(){return P}function y(){setTimeout(()=>{document.addEventListener("click",B,!0),document.addEventListener("contextmenu",B,!0),document.addEventListener("scroll",x,!0),!s.isFullScreenContainer&&k.value&&k.value.addEventListener("scroll",x,!0),d.value.keyboardControl!==!1&&document.addEventListener("keydown",M,!0)},50)}function f(){document.removeEventListener("contextmenu",B,!0),document.removeEventListener("click",B,!0),document.removeEventListener("scroll",x,!0),!s.isFullScreenContainer&&k.value&&k.value.removeEventListener("scroll",x,!0),d.value.keyboardControl!==!1&&document.removeEventListener("keydown",M,!0)}const i=e.ref();e.provide("globalSetCurrentSubMenu",u=>i.value=u),e.provide("globalGetMenuHostId",k.value.id);function M(u){var R,E,T,Z,$,S,N,j,D,z,G,Y,Q;let _=!0;switch(u.key){case"Escape":{((R=i.value)==null?void 0:R.isTopLevel())===!1?(E=i.value)==null||E.closeCurrentSubMenu():b();break}case"ArrowDown":(T=i.value)==null||T.moveCurrentItemDown();break;case"ArrowUp":(Z=i.value)==null||Z.moveCurrentItemUp();break;case"Home":($=i.value)==null||$.moveCurrentItemFirst();break;case"End":(S=i.value)==null||S.moveCurrentItemLast();break;case"ArrowLeft":{(N=i.value)!=null&&N.closeSelfAndActiveParent()||(D=(j=d.value).onKeyFocusMoveLeft)==null||D.call(j);break}case"ArrowRight":(z=i.value)!=null&&z.openCurrentItemSubMenu()||(Y=(G=d.value).onKeyFocusMoveRight)==null||Y.call(G);break;case"Enter":(Q=i.value)==null||Q.triggerCurrentItemClick(u);break;default:_=!1;break}_&&i.value&&(u.stopPropagation(),u.preventDefault())}function x(u){d.value.closeWhenScroll!==!1&&I(u.target,null)}function B(u){I(u.target,u)}function I(u,_){var R,E;for(;u;){if(u.classList&&u.classList.contains("mx-context-menu"))return;u=u.parentNode}_?d.value.clickCloseOnOutside!==!1?(f(),b()):(E=(R=d.value).onClickOnOutside)==null||E.call(R,_):(f(),b())}return e.provide("globalOptions",d),e.provide("globalCloseMenu",b),e.provide("globalIsFullScreenContainer",s.isFullScreenContainer),e.provide("globalHasSlot",u=>n[u]!==void 0),e.provide("globalRenderSlot",(u,_)=>e.renderSlot(n,u,{..._},()=>[e.h("span","Render slot failed")],!1)),e.provide("menuContext",{zIndex:d.value.zIndex||A.defaultZindex,container:k.value,adjustPadding:{x:0,y:0},getZoom:()=>d.value.zoom||A.defaultZoom,getParentWidth:()=>0,getParentHeight:()=>0,getPositon:()=>[d.value.x,d.value.y],closeOtherSubMenuWithTimeOut:()=>{},checkCloseOtherSubMenuTimeOut:()=>!1,openSubMenuWithDelay:u=>u(),cancelPendingOpen:()=>{},addOpenedSubMenu:()=>{},closeOtherSubMenu:()=>{},getParentContext:()=>null,getSubMenuInstanceContext:()=>null,getElement:()=>null,addChildMenuItem:()=>{},removeChildMenuItem:()=>{},markActiveMenuItem:()=>{},markThisOpenedByKeyBoard:()=>{},isOpenedByKeyBoardFlag:()=>!1,isMenuItemDataCollectedFlag:()=>!1}),o(w),(u,_)=>(e.openBlock(),e.createBlock(de,{ref_key:"submenuInstance",ref:v,show:e.unref(g),destroyOnClose:e.unref(C),items:e.unref(d).items,adjustPosition:e.unref(d).adjustPosition,maxWidth:e.unref(d).maxWidth||e.unref(A).defaultMaxWidth,minWidth:e.unref(d).minWidth||e.unref(A).defaultMinWidth,maxHeight:e.unref(d).maxHeight,direction:e.unref(d).direction||e.unref(A).defaultDirection,onCloseAnimFinished:_[0]||(_[0]=R=>p("closeAnimFinished"))},{default:e.withCtx(()=>[e.renderSlot(u.$slots,"default")]),_:3},8,["show","destroyOnClose","items","adjustPosition","maxWidth","minWidth","maxHeight","direction"]))}}),Wt="",Be=e.defineComponent({__name:"ContextMenu",props:{options:{type:Object,default:null},show:{type:Boolean,default:!1},destroyOnClose:{type:Boolean,default:!0}},emits:["update:show","close"],setup(t,{expose:o,emit:r}){const s=r,p=t,{options:n,show:v,destroyOnClose:d}=e.toRefs(p),{isNew:g,container:C,eleId:k}=be(n.value),w=e.ref(null),P=e.useSlots();function H(b){var h,y;s("update:show",!1),s("close"),(y=(h=n.value).onClose)==null||y.call(h,b)}return o({closeMenu:()=>s("update:show",!1),isClosed:()=>!v.value,getMenuRef:()=>{var b;return(b=w.value)==null?void 0:b.getMenuRef()},getMenuDimensions:()=>{var b;return((b=w.value)==null?void 0:b.getMenuDimensions())??{width:0,height:0}}}),(b,h)=>(e.openBlock(),e.createBlock(e.Teleport,{to:`#${e.unref(k)}`},[e.createVNode(we,{ref_key:"menuRef",ref:w,options:e.unref(n),show:e.unref(v),destroyOnClose:e.unref(d),container:e.unref(C),isFullScreenContainer:!e.unref(g),onClose:H},e.createSlots({_:2},[e.renderList(e.unref(P),(y,f)=>({name:f,fn:e.withCtx(i=>[e.renderSlot(b.$slots,f,e.normalizeProps(e.guardReactiveProps(i)))])}))]),1032,["options","show","destroyOnClose","container","isFullScreenContainer"])],8,["to"]))}}),Ie=e.defineComponent({name:"ContextMenuGroup",props:{disabled:{type:Boolean,default:!1},hidden:{type:Boolean,default:!1},clickHandler:{type:Function,default:null},label:{type:String,default:""},icon:{type:String,default:""},iconFontClass:{type:String,default:"iconfont"},checked:{type:Boolean,default:!1},shortcut:{type:String,default:""},svgIcon:{type:String,default:""},svgProps:{type:Object,default:null},preserveIconWidth:{type:Boolean,default:!0},showRightArrow:{type:Boolean,default:!1},clickClose:{type:Boolean,default:!0},adjustSubMenuPosition:{type:Boolean,default:void 0},maxHeight:{type:[String,Number],default:0},maxWidth:{type:[String,Number],default:0},minWidth:{type:[String,Number],default:0}},setup(t,o){const r=e.inject("globalOptions"),{adjustSubMenuPosition:s,maxWidth:p,minWidth:n,maxHeight:v}=e.toRefs(t),d=typeof s.value<"u"?s.value:r.value.adjustPosition,g=e.ref(),C=e.ref();return o.expose({getSubMenuRef:()=>g.value,getMenuItemRef:()=>C.value}),()=>e.h(ae,{...t,ref:C,showRightArrow:!0,maxWidth:void 0,minWidth:void 0,maxHeight:void 0,adjustSubMenuPosition:void 0,hasChildren:typeof o.slots.default!==void 0},o.slots.default?{submenu:k=>e.h(de,{ref:g,show:k.show,maxWidth:p.value,minWidth:n.value,maxHeight:v.value,adjustPosition:d,parentMenuItemContext:k.context},{default:o.slots.default}),...Fe(o.slots,"default")}:o.slots)}});function dt(t,o,r,s){const p=e.ref(!0),n=e.h(we,{options:t,show:p,container:o,isFullScreenContainer:!r,onCloseAnimFinished:()=>{e.render(null,o)},onClose:v=>{var d;(d=t.onClose)==null||d.call(t,v),p.value=!1}},s);return e.render(n,o),n.component}function We(t,o){const r=be(t);return dt(t,r.container,r.isNew,o).exposed}const fe={install(t){t.config.globalProperties.$contextmenu=We,t.component("ContextMenu",Be),t.component("ContextMenuItem",ae),t.component("ContextMenuGroup",Ie),t.component("ContextMenuSperator",ee),t.component("ContextMenuSeparator",ee),t.component("ContextSubMenu",de)},showContextMenu(t,o){return We(t,o)},isAnyContextMenuOpen(){return Ee()},closeContextMenu:Ce,transformMenuPosition:Ne},ft={},ht={class:"mx-menu-bar-icon-menu",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"200",height:"200"},mt=[e.createElementVNode("path",{d:"M133.310936 296.552327l757.206115 0c19.781623 0 35.950949-16.169326 35.950949-35.950949 0-19.781623-15.997312-35.950949-35.950949-35.950949L133.310936 224.650428c-19.781623 0-35.950949 16.169326-35.950949 35.950949C97.359987 280.383 113.529313 296.552327 133.310936 296.552327z"},null,-1),e.createElementVNode("path",{d:"M890.51705 476.135058 133.310936 476.135058c-19.781623 0-35.950949 16.169326-35.950949 35.950949 0 19.781623 16.169326 35.950949 35.950949 35.950949l757.206115 0c19.781623 0 35.950949-16.169326 35.950949-35.950949C926.467999 492.304384 910.298673 476.135058 890.51705 476.135058z"},null,-1),e.createElementVNode("path",{d:"M890.51705 727.447673 133.310936 727.447673c-19.781623 0-35.950949 15.997312-35.950949 35.950949s16.169326 35.950949 35.950949 35.950949l757.206115 0c19.781623 0 35.950949-15.997312 35.950949-35.950949S910.298673 727.447673 890.51705 727.447673z"},null,-1)];function pt(t,o){return e.openBlock(),e.createElementBlock("svg",ht,mt)}const gt=re(ft,[["render",pt]]),Ct=["onClick","onMouseenter"],bt=e.defineComponent({__name:"MenuBar",props:{options:{type:Object,default:null}},setup(t){const o=t,r=e.ref(),s=e.ref(!1),p=e.ref([]),n=e.ref(null);function v(){s.value=!0}function d(){s.value=!1}e.onMounted(()=>{p.value=o.options.items||[]}),e.watch(()=>o.options,()=>{p.value=o.options.items||[]});let g=null,C=-1;function k(){C<p.value.length-1?C++:C=0,H(C,p.value[C])}function w(){C>0?C--:C=p.value.length-1,H(C,p.value[C])}function P(f){const i=o.options.barPopDirection??"bl";let M=0,x=0;return i.startsWith("b")?x=V(f)+f.offsetHeight:i.startsWith("t")?x=V(f):x=V(f)+f.offsetHeight/2,i.endsWith("l")?M=L(f):i.startsWith("r")?M=L(f)+f.offsetWidth:M=L(f)+f.offsetWidth/2,{x:M,y:x+5}}function H(f,i){var x;if(C=f,!i.children)return;g&&(g.closeMenu(),g=null,s.value=!0),n.value=i;const M=(x=r.value)==null?void 0:x.children[f];if(M){const{x:B,y:I}=P(M);g=fe.showContextMenu({...o.options,items:i.children,x:B,y:I,onKeyFocusMoveLeft(){w()},onKeyFocusMoveRight(){k()},onClose(){n.value==i&&(s.value=!1,n.value=null),typeof i.onSubMenuClose=="function"&&i.onSubMenuClose(void 0)}}),g&&typeof i.onSubMenuOpen=="function"&&i.onSubMenuOpen(void 0)}}function b(){C=0;const f=r.value;if(f){const{x:i,y:M}=P(f);g=fe.showContextMenu({...o.options,x:i,y:M})}}function h(f,i){i?(s.value=!0,H(f,i),i.onClick&&(i.clickableWhenHasChildren===!0&&i.children&&i.children.length>0||!i.children||i.children.length===0)&&i.onClick()):b()}function y(f,i){s.value&&H(f,i)}return(f,i)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["mx-menu-bar",t.options.theme??"",t.options.mini?"mini":""]),onFocus:v,onBlur:d},[e.renderSlot(f.$slots,"prefix"),t.options.mini?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"menuBarContent",ref:r,class:"mx-menu-bar-content"},[e.createElementVNode("div",{class:"mx-menu-bar-item",onClick:i[0]||(i[0]=M=>h(0,null))},[e.createVNode(gt)])],512)):(e.openBlock(),e.createElementBlock("div",{key:1,ref_key:"menuBarContent",ref:r,class:"mx-menu-bar-content"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(M,x)=>(e.openBlock(),e.createElementBlock("div",{key:x,class:e.normalizeClass(["mx-menu-bar-item",M==n.value?"active":""]),onClick:B=>h(x,M),onMouseenter:B=>y(x,M)},e.toDisplayString(M.label),43,Ct))),128))],512)),e.renderSlot(f.$slots,"suffix")],34))}}),Ht="",yt=e.defineComponent({__name:"MenuTrigger",props:{trigger:{type:String,default:"click"},position:{type:String,default:"bl"},offset:{type:Number,default:5},disabled:{type:Boolean,default:!1}},emits:["show","hide"],setup(t,{expose:o,emit:r}){const s=t,p=r,n=e.ref(),v=e.ref(),d=e.ref(!1),g=e.ref({x:0,y:0}),C=e.computed(()=>({x:g.value.x,y:g.value.y,direction:s.position}));function k(){const h=v.value,y=s.position;let f=0,i=0;return y.startsWith("b")?i=V(h)+h.offsetHeight+s.offset:y.startsWith("t")?i=V(h)-s.offset:i=V(h)+h.offsetHeight/2,y.startsWith("t")||y.startsWith("b")?y.includes("l")?f=L(h)+h.offsetWidth:y.includes("r")?f=L(h):f=L(h)+h.offsetWidth/2:y.includes("l")?f=L(h):y.includes("r")?f=L(h)+h.offsetWidth:f=L(h)+h.offsetWidth/2,{x:f,y:i}}function w(){if(s.disabled)return;const h=k();g.value=h,d.value=!0,p("show",C.value)}function P(){d.value=!1,p("hide")}function H(h,y){s.disabled||s.trigger===h&&(h==="click"&&d.value?P():w())}function b(){s.trigger==="hover"&&(d.value||w())}return o({show:w,hide:P}),(h,y)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"wrapperRef",ref:n,class:"mx-menu-trigger",onMouseenter:b,onClick:y[0]||(y[0]=f=>H("click"))},[e.createElementVNode("div",{ref_key:"triggerRef",ref:v,class:"mx-menu-trigger-content"},[e.renderSlot(h.$slots,"default")],512),e.renderSlot(h.$slots,"menu",{options:C.value,show:d.value,onClose:()=>d.value=!1})],544))}}),Pt="";F.ContextMenu=Be,F.ContextMenuGroup=Ie,F.ContextMenuItem=ae,F.ContextMenuSeparator=ee,F.MenuBar=bt,F.MenuTrigger=yt,F.default=fe,Object.defineProperties(F,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
//# sourceMappingURL=vue3-context-menu.umd.js.map