mirror of
https://gitee.com/niucloud-team/niucloud-admin.git
synced 2026-01-06 04:58:10 +00:00
2 lines
16 KiB
JavaScript
2 lines
16 KiB
JavaScript
import{a as z,q as w,o as A,c as me,w as X,x as P,av as Ie,cb as Be,u as Oe,ap as xe,B as ne,ar as S,bb as V,bd as ue,b9 as Ne,s as p,p as ve,L as G,N as fe,O as Y,r as x,bG as Ae,i as ze,D as he,ag as Z,v as ce,b as be,aD as Te,bj as g,ax as D,E as ke,Y as Le,Z as He,F as ge,bn as Ce,M as de,a7 as De,b6 as je,aC as We,cc as Re,aT as Fe,ah as qe,aX as Ve,m as Ge,e as J,j as pe,y as ee,h as Ue,t as Ze,C as Ke,Q as Me}from"./entry.86379606.js";import{E as Ee}from"./el-popper.e0e1093b.js";import{T as Qe,b as Xe,t as te}from"./index.2a3f4a08.js";import{f as Ye}from"./vnode.18b2b700.js";const K=function(e,o,...n){let t;o.includes("mouse")||o.includes("click")?t="MouseEvents":o.includes("key")?t="KeyboardEvent":t="HTMLEvents";const u=document.createEvent(t);return u.initEvent(o,...n),e.dispatchEvent(u),e},Je=z({name:"ElCollapseTransition"}),et=z({...Je,setup(e){const o=w("collapse-transition"),n={beforeEnter(t){t.dataset||(t.dataset={}),t.dataset.oldPaddingTop=t.style.paddingTop,t.dataset.oldPaddingBottom=t.style.paddingBottom,t.style.maxHeight=0,t.style.paddingTop=0,t.style.paddingBottom=0},enter(t){t.dataset.oldOverflow=t.style.overflow,t.scrollHeight!==0?(t.style.maxHeight=`${t.scrollHeight}px`,t.style.paddingTop=t.dataset.oldPaddingTop,t.style.paddingBottom=t.dataset.oldPaddingBottom):(t.style.maxHeight=0,t.style.paddingTop=t.dataset.oldPaddingTop,t.style.paddingBottom=t.dataset.oldPaddingBottom),t.style.overflow="hidden"},afterEnter(t){t.style.maxHeight="",t.style.overflow=t.dataset.oldOverflow},beforeLeave(t){t.dataset||(t.dataset={}),t.dataset.oldPaddingTop=t.style.paddingTop,t.dataset.oldPaddingBottom=t.style.paddingBottom,t.dataset.oldOverflow=t.style.overflow,t.style.maxHeight=`${t.scrollHeight}px`,t.style.overflow="hidden"},leave(t){t.scrollHeight!==0&&(t.style.maxHeight=0,t.style.paddingTop=0,t.style.paddingBottom=0)},afterLeave(t){t.style.maxHeight="",t.style.overflow=t.dataset.oldOverflow,t.style.paddingTop=t.dataset.oldPaddingTop,t.style.paddingBottom=t.dataset.oldPaddingBottom}};return(t,u)=>(A(),me(xe,Ie({name:Oe(o).b()},Be(n)),{default:X(()=>[P(t.$slots,"default")]),_:3},16,["name"]))}});var Q=ne(et,[["__file","/home/runner/work/element-plus/element-plus/packages/components/collapse-transition/src/collapse-transition.vue"]]);Q.install=e=>{e.component(Q.name,Q)};const tt=Q;let nt=class{constructor(o,n){this.parent=o,this.domNode=n,this.subIndex=0,this.subIndex=0,this.init()}init(){this.subMenuItems=this.domNode.querySelectorAll("li"),this.addListeners()}gotoSubIndex(o){o===this.subMenuItems.length?o=0:o<0&&(o=this.subMenuItems.length-1),this.subMenuItems[o].focus(),this.subIndex=o}addListeners(){const o=this.parent.domNode;Array.prototype.forEach.call(this.subMenuItems,n=>{n.addEventListener("keydown",t=>{let u=!1;switch(t.code){case S.down:{this.gotoSubIndex(this.subIndex+1),u=!0;break}case S.up:{this.gotoSubIndex(this.subIndex-1),u=!0;break}case S.tab:{K(o,"mouseleave");break}case S.enter:case S.space:{u=!0,t.currentTarget.click();break}}return u&&(t.preventDefault(),t.stopPropagation()),!1})})}},ot=class{constructor(o,n){this.domNode=o,this.submenu=null,this.submenu=null,this.init(n)}init(o){this.domNode.setAttribute("tabindex","0");const n=this.domNode.querySelector(`.${o}-menu`);n&&(this.submenu=new nt(this,n)),this.addListeners()}addListeners(){this.domNode.addEventListener("keydown",o=>{let n=!1;switch(o.code){case S.down:{K(o.currentTarget,"mouseenter"),this.submenu&&this.submenu.gotoSubIndex(0),n=!0;break}case S.up:{K(o.currentTarget,"mouseenter"),this.submenu&&this.submenu.gotoSubIndex(this.submenu.subMenuItems.length-1),n=!0;break}case S.tab:{K(o.currentTarget,"mouseleave");break}case S.enter:case S.space:{n=!0,o.currentTarget.click();break}}n&&o.preventDefault()})}},at=class{constructor(o,n){this.domNode=o,this.init(n)}init(o){const n=this.domNode.childNodes;Array.from(n).forEach(t=>{t.nodeType===1&&new ot(t,o)})}};const st=z({name:"ElMenuCollapseTransition",setup(){const e=w("menu");return{listeners:{onBeforeEnter:n=>n.style.opacity="0.2",onEnter(n,t){V(n,`${e.namespace.value}-opacity-transition`),n.style.opacity="1",t()},onAfterEnter(n){ue(n,`${e.namespace.value}-opacity-transition`),n.style.opacity=""},onBeforeLeave(n){n.dataset||(n.dataset={}),Ne(n,e.m("collapse"))?(ue(n,e.m("collapse")),n.dataset.oldOverflow=n.style.overflow,n.dataset.scrollWidth=n.clientWidth.toString(),V(n,e.m("collapse"))):(V(n,e.m("collapse")),n.dataset.oldOverflow=n.style.overflow,n.dataset.scrollWidth=n.clientWidth.toString(),ue(n,e.m("collapse"))),n.style.width=`${n.scrollWidth}px`,n.style.overflow="hidden"},onLeave(n){V(n,"horizontal-collapse-transition"),n.style.width=`${n.dataset.scrollWidth}px`}}}}});function lt(e,o,n,t,u,I){return A(),me(xe,Ie({mode:"out-in"},e.listeners),{default:X(()=>[P(e.$slots,"default")]),_:3},16)}var ut=ne(st,[["render",lt],["__file","/home/runner/work/element-plus/element-plus/packages/components/menu/src/menu-collapse-transition.vue"]]);function Se(e,o){const n=p(()=>{let u=e.parent;const I=[o.value];for(;u.type.name!=="ElMenu";)u.props.index&&I.unshift(u.props.index),u=u.parent;return I});return{parentMenu:p(()=>{let u=e.parent;for(;u&&!["ElMenu","ElSubMenu"].includes(u.type.name);)u=u.parent;return u}),indexPath:n}}function rt(e){return p(()=>{const n=e.backgroundColor;return n?new Qe(n).shade(20).toString():""})}const we=(e,o)=>{const n=w("menu");return p(()=>n.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:`${o}`}))},it=ve({index:{type:String,required:!0},showTimeout:{type:Number,default:300},hideTimeout:{type:Number,default:300},popperClass:String,disabled:Boolean,popperAppendToBody:{type:Boolean,default:void 0},teleported:{type:Boolean,default:void 0},popperOffset:{type:Number,default:6},expandCloseIcon:{type:G},expandOpenIcon:{type:G},collapseCloseIcon:{type:G},collapseOpenIcon:{type:G}}),U="ElSubMenu";var ye=z({name:U,props:it,setup(e,{slots:o,expose:n}){Xe({from:"popper-append-to-body",replacement:"teleported",scope:U,version:"2.3.0",ref:"https://element-plus.org/en-US/component/menu.html#submenu-attributes"},p(()=>e.popperAppendToBody!==void 0));const t=fe(),{indexPath:u,parentMenu:I}=Se(t,p(()=>e.index)),d=w("menu"),h=w("sub-menu"),l=Y("rootMenu");l||te(U,"can not inject root menu");const m=Y(`subMenu:${I.value.uid}`);m||te(U,"can not inject sub menu");const v=x({}),M=x({});let C;const $=x(!1),oe=x(),q=x(null),B=p(()=>a.value==="horizontal"&&O.value?"bottom-start":"right-start"),L=p(()=>a.value==="horizontal"&&O.value||a.value==="vertical"&&!l.props.collapse?e.expandCloseIcon&&e.expandOpenIcon?T.value?e.expandOpenIcon:e.expandCloseIcon:Ae:e.collapseCloseIcon&&e.collapseOpenIcon?T.value?e.collapseOpenIcon:e.collapseCloseIcon:ze),O=p(()=>m.level===0),j=p(()=>{var i;const c=(i=e.teleported)!=null?i:e.popperAppendToBody;return c===void 0?O.value:c}),ae=p(()=>l.props.collapse?`${d.namespace.value}-zoom-in-left`:`${d.namespace.value}-zoom-in-top`),se=p(()=>a.value==="horizontal"&&O.value?["bottom-start","bottom-end","top-start","top-end","right-start","left-start"]:["right-start","left-start","bottom-start","bottom-end","top-start","top-end"]),T=p(()=>l.openedMenus.includes(e.index)),N=p(()=>{let i=!1;return Object.values(v.value).forEach(c=>{c.active&&(i=!0)}),Object.values(M.value).forEach(c=>{c.active&&(i=!0)}),i}),W=p(()=>l.props.backgroundColor||""),R=p(()=>l.props.activeTextColor||""),H=p(()=>l.props.textColor||""),a=p(()=>l.props.mode),s=he({index:e.index,indexPath:u,active:N}),r=p(()=>a.value!=="horizontal"?{color:H.value}:{borderBottomColor:N.value?l.props.activeTextColor?R.value:"":"transparent",color:N.value?R.value:H.value}),y=()=>{var i,c,f;return(f=(c=(i=q.value)==null?void 0:i.popperRef)==null?void 0:c.popperInstanceRef)==null?void 0:f.destroy()},b=i=>{i||y()},k=()=>{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:N.value})},E=(i,c=e.showTimeout)=>{var f;i.type!=="focus"&&(l.props.menuTrigger==="click"&&l.props.mode==="horizontal"||!l.props.collapse&&l.props.mode==="vertical"||e.disabled||(m.mouseInChild.value=!0,C==null||C(),{stop:C}=Ce(()=>{l.openMenu(e.index,u.value)},c),j.value&&((f=I.value.vnode.el)==null||f.dispatchEvent(new MouseEvent("mouseenter")))))},_=(i=!1)=>{var c,f;l.props.menuTrigger==="click"&&l.props.mode==="horizontal"||!l.props.collapse&&l.props.mode==="vertical"||(C==null||C(),m.mouseInChild.value=!1,{stop:C}=Ce(()=>!$.value&&l.closeMenu(e.index,u.value),e.hideTimeout),j.value&&i&&((c=t.parent)==null?void 0:c.type.name)==="ElSubMenu"&&((f=m.handleMouseleave)==null||f.call(m,!0)))};Z(()=>l.props.collapse,i=>b(!!i));{const i=f=>{M.value[f.index]=f},c=f=>{delete M.value[f.index]};ce(`subMenu:${t.uid}`,{addSubMenu:i,removeSubMenu:c,handleMouseleave:_,mouseInChild:$,level:m.level+1})}return n({opened:T}),be(()=>{l.addSubMenu(s),m.addSubMenu(s)}),Te(()=>{m.removeSubMenu(s),l.removeSubMenu(s)}),()=>{var i;const c=[(i=o.title)==null?void 0:i.call(o),g(ke,{class:h.e("icon-arrow"),style:{transform:T.value?e.expandCloseIcon&&e.expandOpenIcon||e.collapseCloseIcon&&e.collapseOpenIcon&&l.props.collapse?"none":"rotateZ(180deg)":"none"}},{default:()=>D(L.value)?g(t.appContext.components[L.value]):g(L.value)})],f=we(l.props,m.level+1),Pe=l.isMenuPopup?g(Ee,{ref:q,visible:T.value,effect:"light",pure:!0,offset:e.popperOffset,showArrow:!1,persistent:!0,popperClass:e.popperClass,placement:B.value,teleported:j.value,fallbackPlacements:se.value,transition:ae.value,gpuAcceleration:!1},{content:()=>{var F;return g("div",{class:[d.m(a.value),d.m("popup-container"),e.popperClass],onMouseenter:le=>E(le,100),onMouseleave:()=>_(!0),onFocus:le=>E(le,100)},[g("ul",{class:[d.b(),d.m("popup"),d.m(`popup-${B.value}`)],style:f.value},[(F=o.default)==null?void 0:F.call(o)])])},default:()=>g("div",{class:h.e("title"),style:[r.value,{backgroundColor:W.value}],onClick:k},c)}):g(ge,{},[g("div",{class:h.e("title"),style:[r.value,{backgroundColor:W.value}],ref:oe,onClick:k},c),g(tt,{},{default:()=>{var F;return Le(g("ul",{role:"menu",class:[d.b(),d.m("inline")],style:f.value},[(F=o.default)==null?void 0:F.call(o)]),[[He,T.value]])}})]);return g("li",{class:[h.b(),h.is("active",N.value),h.is("opened",T.value),h.is("disabled",e.disabled)],role:"menuitem",ariaHaspopup:!0,ariaExpanded:T.value,onMouseenter:E,onMouseleave:()=>_(!0),onFocus:E},[Pe])}}});const ct=ve({mode:{type:String,values:["horizontal","vertical"],default:"vertical"},defaultActive:{type:String,default:""},defaultOpeneds:{type:de(Array),default:()=>De([])},uniqueOpened:Boolean,router:Boolean,menuTrigger:{type:String,values:["hover","click"],default:"hover"},collapse:Boolean,backgroundColor:String,textColor:String,activeTextColor:String,collapseTransition:{type:Boolean,default:!0},ellipsis:{type:Boolean,default:!0},popperEffect:{type:String,values:["dark","light"],default:"dark"}}),re=e=>Array.isArray(e)&&e.every(o=>D(o)),dt={close:(e,o)=>D(e)&&re(o),open:(e,o)=>D(e)&&re(o),select:(e,o,n,t)=>D(e)&&re(o)&&Fe(n)&&(t===void 0||t instanceof Promise)};var pt=z({name:"ElMenu",props:ct,emits:dt,setup(e,{emit:o,slots:n,expose:t}){const u=fe(),I=u.appContext.config.globalProperties.$router,d=x(),h=w("menu"),l=w("sub-menu"),m=x(-1),v=x(e.defaultOpeneds&&!e.collapse?e.defaultOpeneds.slice(0):[]),M=x(e.defaultActive),C=x({}),$=x({}),oe=p(()=>e.mode==="horizontal"||e.mode==="vertical"&&e.collapse),q=()=>{const a=M.value&&C.value[M.value];if(!a||e.mode==="horizontal"||e.collapse)return;a.indexPath.forEach(r=>{const y=$.value[r];y&&B(r,y.indexPath)})},B=(a,s)=>{v.value.includes(a)||(e.uniqueOpened&&(v.value=v.value.filter(r=>s.includes(r))),v.value.push(a),o("open",a,s))},L=a=>{const s=v.value.indexOf(a);s!==-1&&v.value.splice(s,1)},O=(a,s)=>{L(a),o("close",a,s)},j=({index:a,indexPath:s})=>{v.value.includes(a)?O(a,s):B(a,s)},ae=a=>{(e.mode==="horizontal"||e.collapse)&&(v.value=[]);const{index:s,indexPath:r}=a;if(!(s===void 0||r===void 0))if(e.router&&I){const y=a.route||s,b=I.push(y).then(k=>(k||(M.value=s),k));o("select",s,r,{index:s,indexPath:r,route:y},b)}else M.value=s,o("select",s,r,{index:s,indexPath:r})},se=a=>{const s=C.value,r=s[a]||M.value&&s[M.value]||s[e.defaultActive];r?M.value=r.index:M.value=a},T=()=>{var a,s;if(!d.value)return-1;const r=Array.from((s=(a=d.value)==null?void 0:a.childNodes)!=null?s:[]).filter(c=>c.nodeName!=="#text"||c.nodeValue),y=64,b=Number.parseInt(getComputedStyle(d.value).paddingLeft,10),k=Number.parseInt(getComputedStyle(d.value).paddingRight,10),E=d.value.clientWidth-b-k;let _=0,i=0;return r.forEach((c,f)=>{_+=c.offsetWidth||0,_<=E-y&&(i=f+1)}),i===r.length?-1:i},N=(a,s=33.34)=>{let r;return()=>{r&&clearTimeout(r),r=setTimeout(()=>{a()},s)}};let W=!0;const R=()=>{const a=()=>{m.value=-1,qe(()=>{m.value=T()})};W?a():N(a)(),W=!1};Z(()=>e.defaultActive,a=>{C.value[a]||(M.value=""),se(a)}),Z(()=>e.collapse,a=>{a&&(v.value=[])}),Z(C.value,q);let H;je(()=>{e.mode==="horizontal"&&e.ellipsis?H=We(d,R).stop:H==null||H()});{const a=b=>{$.value[b.index]=b},s=b=>{delete $.value[b.index]};ce("rootMenu",he({props:e,openedMenus:v,items:C,subMenus:$,activeIndex:M,isMenuPopup:oe,addMenuItem:b=>{C.value[b.index]=b},removeMenuItem:b=>{delete C.value[b.index]},addSubMenu:a,removeSubMenu:s,openMenu:B,closeMenu:O,handleMenuItemClick:ae,handleSubMenuClick:j})),ce(`subMenu:${u.uid}`,{addSubMenu:a,removeSubMenu:s,mouseInChild:x(!1),level:0})}return be(()=>{e.mode==="horizontal"&&new at(u.vnode.el,h.namespace.value)}),t({open:s=>{const{indexPath:r}=$.value[s];r.forEach(y=>B(y,r))},close:L,handleResize:R}),()=>{var a,s;let r=(s=(a=n.default)==null?void 0:a.call(n))!=null?s:[];const y=[];if(e.mode==="horizontal"&&d.value){const E=Ye(r),_=m.value===-1?E:E.slice(0,m.value),i=m.value===-1?[]:E.slice(m.value);i!=null&&i.length&&e.ellipsis&&(r=_,y.push(g(ye,{index:"sub-menu-more",class:l.e("hide-arrow")},{title:()=>g(ke,{class:l.e("icon-more")},{default:()=>g(Re)}),default:()=>i})))}const b=we(e,0),k=g("ul",{key:String(e.collapse),role:"menubar",ref:d,style:b.value,class:{[h.b()]:!0,[h.m(e.mode)]:!0,[h.m("collapse")]:e.collapse}},[...r,...y]);return e.collapseTransition&&e.mode==="vertical"?g(ut,()=>k):k}}});const mt=ve({index:{type:de([String,null]),default:null},route:{type:de([String,Object])},disabled:Boolean}),vt={click:e=>D(e.index)&&Array.isArray(e.indexPath)},ie="ElMenuItem",ft=z({name:ie,components:{ElTooltip:Ee},props:mt,emits:vt,setup(e,{emit:o}){const n=fe(),t=Y("rootMenu"),u=w("menu"),I=w("menu-item");t||te(ie,"can not inject root menu");const{parentMenu:d,indexPath:h}=Se(n,Ve(e,"index")),l=Y(`subMenu:${d.value.uid}`);l||te(ie,"can not inject sub menu");const m=p(()=>e.index===t.activeIndex),v=he({index:e.index,indexPath:h,active:m}),M=()=>{e.disabled||(t.handleMenuItemClick({index:e.index,indexPath:h.value,route:e.route}),o("click",v))};return be(()=>{l.addSubMenu(v),t.addMenuItem(v)}),Te(()=>{l.removeSubMenu(v),t.removeMenuItem(v)}),{parentMenu:d,rootMenu:t,active:m,nsMenu:u,nsMenuItem:I,handleClick:M}}});function ht(e,o,n,t,u,I){const d=Ge("el-tooltip");return A(),J("li",{class:ee([e.nsMenuItem.b(),e.nsMenuItem.is("active",e.active),e.nsMenuItem.is("disabled",e.disabled)]),role:"menuitem",tabindex:"-1",onClick:o[0]||(o[0]=(...h)=>e.handleClick&&e.handleClick(...h))},[e.parentMenu.type.name==="ElMenu"&&e.rootMenu.props.collapse&&e.$slots.title?(A(),me(d,{key:0,effect:e.rootMenu.props.popperEffect,placement:"right","fallback-placements":["left"],persistent:""},{content:X(()=>[P(e.$slots,"title")]),default:X(()=>[pe("div",{class:ee(e.nsMenu.be("tooltip","trigger"))},[P(e.$slots,"default")],2)]),_:3},8,["effect"])):(A(),J(ge,{key:1},[P(e.$slots,"default"),P(e.$slots,"title")],64))],2)}var $e=ne(ft,[["render",ht],["__file","/home/runner/work/element-plus/element-plus/packages/components/menu/src/menu-item.vue"]]);const bt={title:String},gt="ElMenuItemGroup",Mt=z({name:gt,props:bt,setup(){return{ns:w("menu-item-group")}}});function yt(e,o,n,t,u,I){return A(),J("li",{class:ee(e.ns.b())},[pe("div",{class:ee(e.ns.e("title"))},[e.$slots.title?P(e.$slots,"title",{key:1}):(A(),J(ge,{key:0},[Ue(Ze(e.title),1)],64))],2),pe("ul",null,[P(e.$slots,"default")])],2)}var _e=ne(Mt,[["render",yt],["__file","/home/runner/work/element-plus/element-plus/packages/components/menu/src/menu-item-group.vue"]]);const wt=Ke(pt,{MenuItem:$e,MenuItemGroup:_e,SubMenu:ye}),$t=Me($e);Me(_e);Me(ye);export{$t as E,wt as a};
|