| 1 |
- import{a9 as T,cM as Z,_ as pe,f as D,D as O,o as z,m as Ce,w as Y,ar as A,bN as _e,bm as Pe,aG as J,aJ as ue,aI as Be,L as v,cN as Ae,Y as me,ba as G,ce as ze,K as X,av as ee,r as S,an as Le,J as je,j as ve,a4 as K,a3 as ce,a6 as fe,aQ as Se,F as g,aR as j,G as xe,ak as ke,aq as De,Q as he,U as be,cO as Ie,Z as de,bs as We,cP as Re,aL as qe,aj as Fe,bi as Ve,az as Ge,bo as ye,a7 as Ue,c5 as He,M as Je,c as U,a as te,O as ne,d as Qe,t as Te,aS as Ze,aT as Me,aW as Ke,b as Ye,k as Xe}from"./entry.3f0fea75.js";import{_ as et}from"./index.d3a28d81.js";import{E as Ee,C as tt}from"./index.5397a07d.js";let nt=class{constructor(n,t){this.parent=n,this.domNode=t,this.subIndex=0,this.subIndex=0,this.init()}init(){this.subMenuItems=this.domNode.querySelectorAll("li"),this.addListeners()}gotoSubIndex(n){n===this.subMenuItems.length?n=0:n<0&&(n=this.subMenuItems.length-1),this.subMenuItems[n].focus(),this.subIndex=n}addListeners(){const n=this.parent.domNode;Array.prototype.forEach.call(this.subMenuItems,t=>{t.addEventListener("keydown",r=>{let u=!1;switch(r.code){case T.down:{this.gotoSubIndex(this.subIndex+1),u=!0;break}case T.up:{this.gotoSubIndex(this.subIndex-1),u=!0;break}case T.tab:{Z(n,"mouseleave");break}case T.enter:case T.space:{u=!0,r.currentTarget.click();break}}return u&&(r.preventDefault(),r.stopPropagation()),!1})})}},ot=class{constructor(n,t){this.domNode=n,this.submenu=null,this.submenu=null,this.init(t)}init(n){this.domNode.setAttribute("tabindex","0");const t=this.domNode.querySelector(`.${n}-menu`);t&&(this.submenu=new nt(this,t)),this.addListeners()}addListeners(){this.domNode.addEventListener("keydown",n=>{let t=!1;switch(n.code){case T.down:{Z(n.currentTarget,"mouseenter"),this.submenu&&this.submenu.gotoSubIndex(0),t=!0;break}case T.up:{Z(n.currentTarget,"mouseenter"),this.submenu&&this.submenu.gotoSubIndex(this.submenu.subMenuItems.length-1),t=!0;break}case T.tab:{Z(n.currentTarget,"mouseleave");break}case T.enter:case T.space:{t=!0,n.currentTarget.click();break}}t&&n.preventDefault()})}},at=class{constructor(n,t){this.domNode=n,this.init(t)}init(n){const t=this.domNode.childNodes;Array.from(t).forEach(r=>{r.nodeType===1&&new ot(r,n)})}};const st=D({name:"ElMenuCollapseTransition",setup(){const e=O("menu");return{listeners:{onBeforeEnter:t=>t.style.opacity="0.2",onEnter(t,r){J(t,`${e.namespace.value}-opacity-transition`),t.style.opacity="1",r()},onAfterEnter(t){ue(t,`${e.namespace.value}-opacity-transition`),t.style.opacity=""},onBeforeLeave(t){t.dataset||(t.dataset={}),Be(t,e.m("collapse"))?(ue(t,e.m("collapse")),t.dataset.oldOverflow=t.style.overflow,t.dataset.scrollWidth=t.clientWidth.toString(),J(t,e.m("collapse"))):(J(t,e.m("collapse")),t.dataset.oldOverflow=t.style.overflow,t.dataset.scrollWidth=t.clientWidth.toString(),ue(t,e.m("collapse"))),t.style.width=`${t.scrollWidth}px`,t.style.overflow="hidden"},onLeave(t){J(t,"horizontal-collapse-transition"),t.style.width=`${t.dataset.scrollWidth}px`}}}}});function lt(e,n,t,r,u,h){return z(),Ce(Pe,_e({mode:"out-in"},e.listeners),{default:Y(()=>[A(e.$slots,"default")]),_:3},16)}var ut=pe(st,[["render",lt],["__file","menu-collapse-transition.vue"]]);function Oe(e,n){const t=v(()=>{let u=e.parent;const h=[n.value];for(;u.type.name!=="ElMenu";)u.props.index&&h.unshift(u.props.index),u=u.parent;return h});return{parentMenu:v(()=>{let u=e.parent;for(;u&&!["ElMenu","ElSubMenu"].includes(u.type.name);)u=u.parent;return u}),indexPath:t}}function rt(e){return v(()=>{const t=e.backgroundColor;return t?new Ae(t).shade(20).toString():""})}const $e=(e,n)=>{const t=O("menu");return v(()=>t.cssVarBlock({"text-color":e.textColor||"","hover-text-color":e.textColor||"","bg-color":e.backgroundColor||"","hover-bg-color":rt(e).value||"","active-color":e.activeTextColor||"",level:`${n}`}))},it=me({index:{type:String,required:!0},showTimeout:Number,hideTimeout:Number,popperClass:String,disabled:Boolean,popperAppendToBody:{type:Boolean,default:void 0},teleported:{type:Boolean,default:void 0},popperOffset:Number,expandCloseIcon:{type:G},expandOpenIcon:{type:G},collapseCloseIcon:{type:G},collapseOpenIcon:{type:G}}),Q="ElSubMenu";var ge=D({name:Q,props:it,setup(e,{slots:n,expose:t}){ze({from:"popper-append-to-body",replacement:"teleported",scope:Q,version:"2.3.0",ref:"https://element-plus.org/en-US/component/menu.html#submenu-attributes"},v(()=>e.popperAppendToBody!==void 0));const r=be(),{indexPath:u,parentMenu:h}=Oe(r,v(()=>e.index)),d=O("menu"),M=O("sub-menu"),l=X("rootMenu");l||ee(Q,"can not inject root menu");const p=X(`subMenu:${h.value.uid}`);p||ee(Q,"can not inject sub menu");const f=S({}),I=S({});let C;const E=S(!1),oe=S(),H=S(null),w=v(()=>_.value==="horizontal"&&N.value?"bottom-start":"right-start"),L=v(()=>_.value==="horizontal"&&N.value||_.value==="vertical"&&!l.props.collapse?e.expandCloseIcon&&e.expandOpenIcon?k.value?e.expandOpenIcon:e.expandCloseIcon:Le:e.collapseCloseIcon&&e.collapseOpenIcon?k.value?e.collapseOpenIcon:e.collapseCloseIcon:je),N=v(()=>p.level===0),W=v(()=>{var a;const c=(a=e.teleported)!=null?a:e.popperAppendToBody;return c===void 0?N.value:c}),ae=v(()=>l.props.collapse?`${d.namespace.value}-zoom-in-left`:`${d.namespace.value}-zoom-in-top`),se=v(()=>_.value==="horizontal"&&N.value?["bottom-start","bottom-end","top-start","top-end","right-start","left-start"]:["right-start","right","right-end","left-start","bottom-start","bottom-end","top-start","top-end"]),k=v(()=>l.openedMenus.includes(e.index)),R=v(()=>{let a=!1;return Object.values(f.value).forEach(c=>{c.active&&(a=!0)}),Object.values(I.value).forEach(c=>{c.active&&(a=!0)}),a}),_=v(()=>l.props.mode),P=ve({index:e.index,indexPath:u,active:R}),q=$e(l.props,p.level+1),F=v(()=>{var a;return(a=e.popperOffset)!=null?a:l.props.popperOffset}),V=v(()=>{var a;return(a=e.popperClass)!=null?a:l.props.popperClass}),o=v(()=>{var a;return(a=e.showTimeout)!=null?a:l.props.showTimeout}),s=v(()=>{var a;return(a=e.hideTimeout)!=null?a:l.props.hideTimeout}),i=()=>{var a,c,m;return(m=(c=(a=H.value)==null?void 0:a.popperRef)==null?void 0:c.popperInstanceRef)==null?void 0:m.destroy()},y=a=>{a||i()},b=()=>{l.props.menuTrigger==="hover"&&l.props.mode==="horizontal"||l.props.collapse&&l.props.mode==="vertical"||e.disabled||l.handleSubMenuClick({index:e.index,indexPath:u.value,active:R.value})},x=(a,c=o.value)=>{var m;if(a.type!=="focus"){if(l.props.menuTrigger==="click"&&l.props.mode==="horizontal"||!l.props.collapse&&l.props.mode==="vertical"||e.disabled){p.mouseInChild.value=!0;return}p.mouseInChild.value=!0,C==null||C(),{stop:C}=Ie(()=>{l.openMenu(e.index,u.value)},c),W.value&&((m=h.value.vnode.el)==null||m.dispatchEvent(new MouseEvent("mouseenter")))}},$=(a=!1)=>{var c;if(l.props.menuTrigger==="click"&&l.props.mode==="horizontal"||!l.props.collapse&&l.props.mode==="vertical"){p.mouseInChild.value=!1;return}C==null||C(),p.mouseInChild.value=!1,{stop:C}=Ie(()=>!E.value&&l.closeMenu(e.index,u.value),s.value),W.value&&a&&((c=p.handleMouseleave)==null||c.call(p,!0))};K(()=>l.props.collapse,a=>y(!!a));{const a=m=>{I.value[m.index]=m},c=m=>{delete I.value[m.index]};ce(`subMenu:${r.uid}`,{addSubMenu:a,removeSubMenu:c,handleMouseleave:$,mouseInChild:E,level:p.level+1})}return t({opened:k}),fe(()=>{l.addSubMenu(P),p.addSubMenu(P)}),Se(()=>{p.removeSubMenu(P),l.removeSubMenu(P)}),()=>{var a;const c=[(a=n.title)==null?void 0:a.call(n),g(xe,{class:M.e("icon-arrow"),style:{transform:k.value?e.expandCloseIcon&&e.expandOpenIcon||e.collapseCloseIcon&&e.collapseOpenIcon&&l.props.collapse?"none":"rotateZ(180deg)":"none"}},{default:()=>j(L.value)?g(r.appContext.components[L.value]):g(L.value)})],m=l.isMenuPopup?g(Ee,{ref:H,visible:k.value,effect:"light",pure:!0,offset:F.value,showArrow:!1,persistent:!0,popperClass:V.value,placement:w.value,teleported:W.value,fallbackPlacements:se.value,transition:ae.value,gpuAcceleration:!1},{content:()=>{var B;return g("div",{class:[d.m(_.value),d.m("popup-container"),V.value],onMouseenter:le=>x(le,100),onMouseleave:()=>$(!0),onFocus:le=>x(le,100)},[g("ul",{class:[d.b(),d.m("popup"),d.m(`popup-${w.value}`)],style:q.value},[(B=n.default)==null?void 0:B.call(n)])])},default:()=>g("div",{class:M.e("title"),onClick:b},c)}):g(he,{},[g("div",{class:M.e("title"),ref:oe,onClick:b},c),g(et,{},{default:()=>{var B;return ke(g("ul",{role:"menu",class:[d.b(),d.m("inline")],style:q.value},[(B=n.default)==null?void 0:B.call(n)]),[[De,k.value]])}})]);return g("li",{class:[M.b(),M.is("active",R.value),M.is("opened",k.value),M.is("disabled",e.disabled)],role:"menuitem",ariaHaspopup:!0,ariaExpanded:k.value,onMouseenter:x,onMouseleave:()=>$(),onFocus:x},[m])}}});const ct=me({mode:{type:String,values:["horizontal","vertical"],default:"vertical"},defaultActive:{type:String,default:""},defaultOpeneds:{type:de(Array),default:()=>We([])},uniqueOpened:Boolean,router:Boolean,menuTrigger:{type:String,values:["hover","click"],default:"hover"},collapse:Boolean,backgroundColor:String,textColor:String,activeTextColor:String,closeOnClickOutside:Boolean,collapseTransition:{type:Boolean,default:!0},ellipsis:{type:Boolean,default:!0},popperOffset:{type:Number,default:6},ellipsisIcon:{type:G,default:()=>Re},popperEffect:{type:String,values:["dark","light"],default:"dark"},popperClass:String,showTimeout:{type:Number,default:300},hideTimeout:{type:Number,default:300}}),re=e=>Array.isArray(e)&&e.every(n=>j(n)),dt={close:(e,n)=>j(e)&&re(n),open:(e,n)=>j(e)&&re(n),select:(e,n,t,r)=>j(e)&&re(n)&&Ge(t)&&(r===void 0||r instanceof Promise)};var pt=D({name:"ElMenu",props:ct,emits:dt,setup(e,{emit:n,slots:t,expose:r}){const u=be(),h=u.appContext.config.globalProperties.$router,d=S(),M=O("menu"),l=O("sub-menu"),p=S(-1),f=S(e.defaultOpeneds&&!e.collapse?e.defaultOpeneds.slice(0):[]),I=S(e.defaultActive),C=S({}),E=S({}),oe=v(()=>e.mode==="horizontal"||e.mode==="vertical"&&e.collapse),H=()=>{const o=I.value&&C.value[I.value];if(!o||e.mode==="horizontal"||e.collapse)return;o.indexPath.forEach(i=>{const y=E.value[i];y&&w(i,y.indexPath)})},w=(o,s)=>{f.value.includes(o)||(e.uniqueOpened&&(f.value=f.value.filter(i=>s.includes(i))),f.value.push(o),n("open",o,s))},L=o=>{const s=f.value.indexOf(o);s!==-1&&f.value.splice(s,1)},N=(o,s)=>{L(o),n("close",o,s)},W=({index:o,indexPath:s})=>{f.value.includes(o)?N(o,s):w(o,s)},ae=o=>{(e.mode==="horizontal"||e.collapse)&&(f.value=[]);const{index:s,indexPath:i}=o;if(!(ye(s)||ye(i)))if(e.router&&h){const y=o.route||s,b=h.push(y).then(x=>(x||(I.value=s),x));n("select",s,i,{index:s,indexPath:i,route:y},b)}else I.value=s,n("select",s,i,{index:s,indexPath:i})},se=o=>{const s=C.value,i=s[o]||I.value&&s[I.value]||s[e.defaultActive];i?I.value=i.index:I.value=o},k=()=>{var o,s;if(!d.value)return-1;const i=Array.from((s=(o=d.value)==null?void 0:o.childNodes)!=null?s:[]).filter(m=>m.nodeName!=="#comment"&&(m.nodeName!=="#text"||m.nodeValue)),y=64,b=Number.parseInt(getComputedStyle(d.value).paddingLeft,10),x=Number.parseInt(getComputedStyle(d.value).paddingRight,10),$=d.value.clientWidth-b-x;let a=0,c=0;return i.forEach((m,B)=>{a+=m.offsetWidth||0,a<=$-y&&(c=B+1)}),c===i.length?-1:c},R=o=>E.value[o].indexPath,_=(o,s=33.34)=>{let i;return()=>{i&&clearTimeout(i),i=setTimeout(()=>{o()},s)}};let P=!0;const q=()=>{const o=()=>{p.value=-1,Ue(()=>{p.value=k()})};P?o():_(o)(),P=!1};K(()=>e.defaultActive,o=>{C.value[o]||(I.value=""),se(o)}),K(()=>e.collapse,o=>{o&&(f.value=[])}),K(C.value,H);let F;qe(()=>{e.mode==="horizontal"&&e.ellipsis?F=Fe(d,q).stop:F==null||F()});const V=S(!1);{const o=b=>{E.value[b.index]=b},s=b=>{delete E.value[b.index]};ce("rootMenu",ve({props:e,openedMenus:f,items:C,subMenus:E,activeIndex:I,isMenuPopup:oe,addMenuItem:b=>{C.value[b.index]=b},removeMenuItem:b=>{delete C.value[b.index]},addSubMenu:o,removeSubMenu:s,openMenu:w,closeMenu:N,handleMenuItemClick:ae,handleSubMenuClick:W})),ce(`subMenu:${u.uid}`,{addSubMenu:o,removeSubMenu:s,mouseInChild:V,level:0})}return fe(()=>{e.mode==="horizontal"&&new at(u.vnode.el,M.namespace.value)}),r({open:s=>{const{indexPath:i}=E.value[s];i.forEach(y=>w(y,i))},close:L,handleResize:q}),()=>{var o,s;let i=(s=(o=t.default)==null?void 0:o.call(t))!=null?s:[];const y=[];if(e.mode==="horizontal"&&d.value){const a=Ve(i),c=p.value===-1?a:a.slice(0,p.value),m=p.value===-1?[]:a.slice(p.value);m!=null&&m.length&&e.ellipsis&&(i=c,y.push(g(ge,{index:"sub-menu-more",class:l.e("hide-arrow"),popperOffset:e.popperOffset},{title:()=>g(xe,{class:l.e("icon-more")},{default:()=>g(e.ellipsisIcon)}),default:()=>m})))}const b=$e(e,0),x=e.closeOnClickOutside?[[tt,()=>{f.value.length&&(V.value||(f.value.forEach(a=>n("close",a,R(a))),f.value=[]))}]]:[],$=ke(g("ul",{key:String(e.collapse),role:"menubar",ref:d,style:b.value,class:{[M.b()]:!0,[M.m(e.mode)]:!0,[M.m("collapse")]:e.collapse}},[...i,...y]),x);return e.collapseTransition&&e.mode==="vertical"?g(ut,()=>$):$}}});const mt=me({index:{type:de([String,null]),default:null},route:{type:de([String,Object])},disabled:Boolean}),vt={click:e=>j(e.index)&&Array.isArray(e.indexPath)},ie="ElMenuItem",ft=D({name:ie,components:{ElTooltip:Ee},props:mt,emits:vt,setup(e,{emit:n}){const t=be(),r=X("rootMenu"),u=O("menu"),h=O("menu-item");r||ee(ie,"can not inject root menu");const{parentMenu:d,indexPath:M}=Oe(t,He(e,"index")),l=X(`subMenu:${d.value.uid}`);l||ee(ie,"can not inject sub menu");const p=v(()=>e.index===r.activeIndex),f=ve({index:e.index,indexPath:M,active:p}),I=()=>{e.disabled||(r.handleMenuItemClick({index:e.index,indexPath:M.value,route:e.route}),n("click",f))};return fe(()=>{l.addSubMenu(f),r.addMenuItem(f)}),Se(()=>{l.removeSubMenu(f),r.removeMenuItem(f)}),{parentMenu:d,rootMenu:r,active:p,nsMenu:u,nsMenuItem:h,handleClick:I}}});function ht(e,n,t,r,u,h){const d=Je("el-tooltip");return z(),U("li",{class:ne([e.nsMenuItem.b(),e.nsMenuItem.is("active",e.active),e.nsMenuItem.is("disabled",e.disabled)]),role:"menuitem",tabindex:"-1",onClick:n[0]||(n[0]=(...M)=>e.handleClick&&e.handleClick(...M))},[e.parentMenu.type.name==="ElMenu"&&e.rootMenu.props.collapse&&e.$slots.title?(z(),Ce(d,{key:0,effect:e.rootMenu.props.popperEffect,placement:"right","fallback-placements":["left"],persistent:""},{content:Y(()=>[A(e.$slots,"title")]),default:Y(()=>[te("div",{class:ne(e.nsMenu.be("tooltip","trigger"))},[A(e.$slots,"default")],2)]),_:3},8,["effect"])):(z(),U(he,{key:1},[A(e.$slots,"default"),A(e.$slots,"title")],64))],2)}var we=pe(ft,[["render",ht],["__file","menu-item.vue"]]);const bt={title:String},Mt="ElMenuItemGroup",gt=D({name:Mt,props:bt,setup(){return{ns:O("menu-item-group")}}});function It(e,n,t,r,u,h){return z(),U("li",{class:ne(e.ns.b())},[te("div",{class:ne(e.ns.e("title"))},[e.$slots.title?A(e.$slots,"title",{key:1}):(z(),U(he,{key:0},[Qe(Te(e.title),1)],64))],2),te("ul",null,[A(e.$slots,"default")])],2)}var Ne=pe(gt,[["render",It],["__file","menu-item-group.vue"]]);const Ot=Ze(pt,{MenuItem:we,MenuItemGroup:Ne,SubMenu:ge}),yt=Me(we);Me(Ne);const $t=Me(ge),wt=D({__name:"index",props:{menuItem:{type:Object,default:()=>({})},routePath:{type:String,required:!0}},setup(e){const n=e,t=Ke();v(()=>!!(n.menuItem.children??[]).filter(h=>!(h!=null&&h.hidden)).length);const r=()=>{t.push({path:"/condition"})};return(u,h)=>(z(),U("div",null,[Ye(Xe(yt),{index:e.menuItem.path},{title:Y(()=>[te("span",{onClick:r},Te(e.menuItem.name),1)]),_:1},8,["index"])]))}});export{yt as E,wt as _,$t as a,Ot as b,ct as m};
|