el-dropdown-item-2802814a.js 15 KB

1
  1. import{aB as me,aC as J,cg as ge,bF as I,aF as P,d as G,r as F,aS as E,e as k,aq as N,c9 as be,aI as A,a as _,M as ee,bp as we,aE as $,ch as S,h,o as B,j as z,w as g,i as C,aJ as he,ci as ye,cj as ne,am as Ie,q as oe,b3 as Ee,ck as ke,aR as Fe,cl as Ce,aN as te,cm as Re,cn as Te,ak as le,aD as U,bj as _e,bZ as Se,co as xe,ay as Be,bQ as De,c as j,aL as $e,ai as H,Z as W,l as Y,cp as re,cq as Ke,cr as Me,k as Pe,N as Ge,b8 as Z,F as Le,cs as ae,ct as ze,cu as ie,cv as Oe,cw as Ae,cx as He,av as Ne,cy as je,cz as qe,aG as Je,aK as se}from"./index-03f5d926.js";const Ue=me({style:{type:J([String,Array,Object])},currentTabId:{type:J(String)},defaultCurrentTabId:String,loop:Boolean,dir:{type:String,values:["ltr","rtl"],default:"ltr"},orientation:{type:J(String)},onBlur:Function,onFocus:Function,onMousedown:Function}),{ElCollection:We,ElCollectionItem:Ye,COLLECTION_INJECTION_KEY:Q,COLLECTION_ITEM_INJECTION_KEY:Ze}=ge("RovingFocusGroup"),V=Symbol("elRovingFocusGroup"),de=Symbol("elRovingFocusGroupItem"),Qe={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"},Ve=(e,n,c)=>{const a=((d,u)=>{if(u!=="rtl")return d;switch(d){case I.right:return I.left;case I.left:return I.right;default:return d}})(e.key,c);if(!(n==="vertical"&&[I.left,I.right].includes(a)||n==="horizontal"&&[I.up,I.down].includes(a)))return Qe[a]},X=e=>{const{activeElement:n}=document;for(const c of e)if(c===n||(c.focus(),n!==document.activeElement))return},ue="currentTabIdChange",ce="rovingFocusGroup.entryFocus",Xe={bubbles:!1,cancelable:!0},en=G({name:"ElRovingFocusGroupImpl",inheritAttrs:!1,props:Ue,emits:[ue,"entryFocus"],setup(e,{emit:n}){var c;const a=F((c=e.currentTabId||e.defaultCurrentTabId)!=null?c:null),d=F(!1),u=F(!1),i=F(null),{getItems:r}=E(Q,void 0),v=k(()=>[{outline:"none"},e.style]),b=S(l=>{var s;(s=e.onMousedown)==null||s.call(e,l)},()=>{u.value=!0}),w=S(l=>{var s;(s=e.onFocus)==null||s.call(e,l)},l=>{const s=!_(u),{target:f,currentTarget:y}=l;if(f===y&&s&&!_(d)){const K=new Event(ce,Xe);if(y==null||y.dispatchEvent(K),!K.defaultPrevented){const R=r().filter(m=>m.focusable),x=[R.find(m=>m.active),R.find(m=>m.id===_(a)),...R].filter(Boolean).map(m=>m.ref);X(x)}}u.value=!1}),t=S(l=>{var s;(s=e.onBlur)==null||s.call(e,l)},()=>{d.value=!1});N(V,{currentTabbedId:be(a),loop:A(e,"loop"),tabIndex:k(()=>_(d)?-1:0),rovingFocusGroupRef:i,rovingFocusGroupRootStyle:v,orientation:A(e,"orientation"),dir:A(e,"dir"),onItemFocus:l=>{n(ue,l)},onItemShiftTab:()=>{d.value=!0},onBlur:t,onFocus:w,onMousedown:b}),ee(()=>e.currentTabId,l=>{a.value=l??null}),we(i,ce,(...l)=>{n("entryFocus",...l)})}});var nn=P(G({name:"ElRovingFocusGroup",components:{ElFocusGroupCollection:We,ElRovingFocusGroupImpl:P(en,[["render",function(e,n,c,a,d,u){return $(e.$slots,"default")}],["__file","/home/runner/work/element-plus/element-plus/packages/components/roving-focus-group/src/roving-focus-group-impl.vue"]])}}),[["render",function(e,n,c,a,d,u){const i=h("el-roving-focus-group-impl"),r=h("el-focus-group-collection");return B(),z(r,null,{default:g(()=>[C(i,he(ye(e.$attrs)),{default:g(()=>[$(e.$slots,"default")]),_:3},16)]),_:3})}],["__file","/home/runner/work/element-plus/element-plus/packages/components/roving-focus-group/src/roving-focus-group.vue"]]),on=P(G({components:{ElRovingFocusCollectionItem:Ye},props:{focusable:{type:Boolean,default:!0},active:{type:Boolean,default:!1}},emits:["mousedown","focus","keydown"],setup(e,{emit:n}){const{currentTabbedId:c,loop:a,onItemFocus:d,onItemShiftTab:u}=E(V,void 0),{getItems:i}=E(Q,void 0),r=ne(),v=F(null),b=S(s=>{n("mousedown",s)},s=>{e.focusable?d(_(r)):s.preventDefault()}),w=S(s=>{n("focus",s)},()=>{d(_(r))}),t=S(s=>{n("keydown",s)},s=>{const{key:f,shiftKey:y,target:K,currentTarget:R}=s;if(f===I.tab&&y)return void u();if(K!==R)return;const x=Ve(s);if(x){s.preventDefault();let o=i().filter(p=>p.focusable).map(p=>p.ref);switch(x){case"last":o.reverse();break;case"prev":case"next":{x==="prev"&&o.reverse();const p=o.indexOf(R);o=a.value?(D=p+1,(m=o).map((T,M)=>m[(M+D)%m.length])):o.slice(p+1);break}}Ie(()=>{X(o)})}var m,D}),l=k(()=>c.value===_(r));return N(de,{rovingFocusGroupItemRef:v,tabIndex:k(()=>_(l)?0:-1),handleMousedown:b,handleFocus:w,handleKeydown:t}),{id:r,handleKeydown:t,handleFocus:w,handleMousedown:b}}}),[["render",function(e,n,c,a,d,u){const i=h("el-roving-focus-collection-item");return B(),z(i,{id:e.id,focusable:e.focusable,active:e.active},{default:g(()=>[$(e.$slots,"default")]),_:3},8,["id","focusable","active"])}],["__file","/home/runner/work/element-plus/element-plus/packages/components/roving-focus-group/src/roving-focus-item.vue"]]);const q=Symbol("elDropdown"),{ButtonGroup:tn}=oe;var ln=P(G({name:"ElDropdown",components:{ElButton:oe,ElButtonGroup:tn,ElScrollbar:Ee,ElDropdownCollection:ke,ElTooltip:Fe,ElRovingFocusGroup:nn,ElOnlyChild:Ce,ElIcon:te,ArrowDown:Re},props:Te,emits:["visible-change","click","command"],setup(e,{emit:n}){const c=le(),a=U("dropdown"),{t:d}=_e(),u=F(),i=F(),r=F(null),v=F(null),b=F(null),w=F(null),t=F(!1),l=[I.enter,I.space,I.down],s=k(()=>({maxHeight:Se(e.maxHeight)})),f=k(()=>[a.m(m.value)]),y=k(()=>xe(e.trigger)),K=ne().value,R=k(()=>e.id||K);function x(){var o;(o=r.value)==null||o.onClose()}ee([u,y],([o,p],[T])=>{var M,O,L;(M=T==null?void 0:T.$el)!=null&&M.removeEventListener&&T.$el.removeEventListener("pointerenter",D),(O=o==null?void 0:o.$el)!=null&&O.removeEventListener&&o.$el.removeEventListener("pointerenter",D),(L=o==null?void 0:o.$el)!=null&&L.addEventListener&&p.includes("hover")&&o.$el.addEventListener("pointerenter",D)},{immediate:!0}),Be(()=>{var o,p;(p=(o=u.value)==null?void 0:o.$el)!=null&&p.removeEventListener&&u.value.$el.removeEventListener("pointerenter",D)});const m=De();function D(){var o,p;(p=(o=u.value)==null?void 0:o.$el)==null||p.focus()}return N(q,{contentRef:v,role:k(()=>e.role),triggerId:R,isUsingKeyboard:t,onItemEnter:function(){},onItemLeave:function(){const o=_(v);y.value.includes("hover")&&(o==null||o.focus()),w.value=null}}),N("elDropdown",{instance:c,dropdownSize:m,handleClick:function(){x()},commandHandler:function(...o){n("command",...o)},trigger:A(e,"trigger"),hideOnClick:A(e,"hideOnClick")}),{t:d,ns:a,scrollbar:b,wrapStyle:s,dropdownTriggerKls:f,dropdownSize:m,triggerId:R,triggerKeys:l,currentTabId:w,handleCurrentTabIdChange:function(o){w.value=o},handlerMainButtonClick:o=>{n("click",o)},handleEntryFocus:function(o){t.value||(o.preventDefault(),o.stopImmediatePropagation())},handleClose:x,handleOpen:function(){var o;(o=r.value)==null||o.onOpen()},handleBeforeShowTooltip:function(){n("visible-change",!0)},handleShowTooltip:function(o){(o==null?void 0:o.type)==="keydown"&&v.value.focus()},handleBeforeHideTooltip:function(){n("visible-change",!1)},onFocusAfterTrapped:o=>{var p,T;o.preventDefault(),(T=(p=v.value)==null?void 0:p.focus)==null||T.call(p,{preventScroll:!0})},popperRef:r,contentRef:v,triggeringElementRef:u,referenceElementRef:i}}}),[["render",function(e,n,c,a,d,u){var i;const r=h("el-dropdown-collection"),v=h("el-roving-focus-group"),b=h("el-scrollbar"),w=h("el-only-child"),t=h("el-tooltip"),l=h("el-button"),s=h("arrow-down"),f=h("el-icon"),y=h("el-button-group");return B(),j("div",{class:W([e.ns.b(),e.ns.is("disabled",e.disabled)])},[C(t,{ref:"popperRef",role:e.role,effect:e.effect,"fallback-placements":["bottom","top"],"popper-options":e.popperOptions,"gpu-acceleration":!1,"hide-after":e.trigger==="hover"?e.hideTimeout:0,"manual-mode":!0,placement:e.placement,"popper-class":[e.ns.e("popper"),e.popperClass],"reference-element":(i=e.referenceElementRef)==null?void 0:i.$el,trigger:e.trigger,"trigger-keys":e.triggerKeys,"trigger-target-el":e.contentRef,"show-after":e.trigger==="hover"?e.showTimeout:0,"stop-popper-mouse-event":!1,"virtual-ref":e.triggeringElementRef,"virtual-triggering":e.splitButton,disabled:e.disabled,transition:`${e.ns.namespace.value}-zoom-in-top`,teleported:e.teleported,pure:"",persistent:"",onBeforeShow:e.handleBeforeShowTooltip,onShow:e.handleShowTooltip,onBeforeHide:e.handleBeforeHideTooltip},$e({content:g(()=>[C(b,{ref:"scrollbar","wrap-style":e.wrapStyle,tag:"div","view-class":e.ns.e("list")},{default:g(()=>[C(v,{loop:e.loop,"current-tab-id":e.currentTabId,orientation:"horizontal",onCurrentTabIdChange:e.handleCurrentTabIdChange,onEntryFocus:e.handleEntryFocus},{default:g(()=>[C(r,null,{default:g(()=>[$(e.$slots,"dropdown")]),_:3})]),_:3},8,["loop","current-tab-id","onCurrentTabIdChange","onEntryFocus"])]),_:3},8,["wrap-style","view-class"])]),_:2},[e.splitButton?void 0:{name:"default",fn:g(()=>[C(w,{id:e.triggerId,ref:"triggeringElementRef",role:"button",tabindex:e.tabindex},{default:g(()=>[$(e.$slots,"default")]),_:3},8,["id","tabindex"])])}]),1032,["role","effect","popper-options","hide-after","placement","popper-class","reference-element","trigger","trigger-keys","trigger-target-el","show-after","virtual-ref","virtual-triggering","disabled","transition","teleported","onBeforeShow","onShow","onBeforeHide"]),e.splitButton?(B(),z(y,{key:0},{default:g(()=>[C(l,H({ref:"referenceElementRef"},e.buttonProps,{size:e.dropdownSize,type:e.type,disabled:e.disabled,tabindex:e.tabindex,onClick:e.handlerMainButtonClick}),{default:g(()=>[$(e.$slots,"default")]),_:3},16,["size","type","disabled","tabindex","onClick"]),C(l,H({id:e.triggerId,ref:"triggeringElementRef"},e.buttonProps,{role:"button",size:e.dropdownSize,type:e.type,class:e.ns.e("caret-button"),disabled:e.disabled,tabindex:e.tabindex,"aria-label":e.t("el.dropdown.toggleDropdown")}),{default:g(()=>[C(f,{class:W(e.ns.e("icon"))},{default:g(()=>[C(s)]),_:1},8,["class"])]),_:1},16,["id","size","type","class","disabled","tabindex","aria-label"])]),_:3})):Y("v-if",!0)],2)}],["__file","/home/runner/work/element-plus/element-plus/packages/components/dropdown/src/dropdown.vue"]]);const rn=G({name:"DropdownItemImpl",components:{ElIcon:te},props:re,emits:["pointermove","pointerleave","click","clickimpl"],setup(e,{emit:n}){const c=U("dropdown"),{role:a}=E(q,void 0),{collectionItemRef:d}=E(Ke,void 0),{collectionItemRef:u}=E(Ze,void 0),{rovingFocusGroupItemRef:i,tabIndex:r,handleFocus:v,handleKeydown:b,handleMousedown:w}=E(de,void 0),t=ae(d,u,i),l=k(()=>a.value==="menu"?"menuitem":a.value==="navigation"?"link":"button"),s=S(f=>{const{code:y}=f;if(y===I.enter||y===I.space)return f.preventDefault(),f.stopImmediatePropagation(),n("clickimpl",f),!0},b);return{ns:c,itemRef:t,dataset:{[Me]:""},role:l,tabIndex:r,handleFocus:v,handleKeydown:s,handleMousedown:w}}}),an=["aria-disabled","tabindex","role"],pe=()=>{const e=E("elDropdown",{}),n=k(()=>e==null?void 0:e.dropdownSize);return{elDropdown:e,_elDropdownSize:n}},sn=G({name:"ElDropdownItem",components:{ElDropdownCollectionItem:ze,ElRovingFocusItem:on,ElDropdownItemImpl:P(rn,[["render",function(e,n,c,a,d,u){const i=h("el-icon");return B(),j(Le,null,[e.divided?(B(),j("li",H({key:0,role:"separator",class:e.ns.bem("menu","item","divided")},e.$attrs),null,16)):Y("v-if",!0),Pe("li",H({ref:e.itemRef},{...e.dataset,...e.$attrs},{"aria-disabled":e.disabled,class:[e.ns.be("menu","item"),e.ns.is("disabled",e.disabled)],tabindex:e.tabIndex,role:e.role,onClick:n[0]||(n[0]=r=>e.$emit("clickimpl",r)),onFocus:n[1]||(n[1]=(...r)=>e.handleFocus&&e.handleFocus(...r)),onKeydown:n[2]||(n[2]=Z((...r)=>e.handleKeydown&&e.handleKeydown(...r),["self"])),onMousedown:n[3]||(n[3]=(...r)=>e.handleMousedown&&e.handleMousedown(...r)),onPointermove:n[4]||(n[4]=r=>e.$emit("pointermove",r)),onPointerleave:n[5]||(n[5]=r=>e.$emit("pointerleave",r))}),[e.icon?(B(),z(i,{key:0},{default:g(()=>[(B(),z(Ge(e.icon)))]),_:1})):Y("v-if",!0),$(e.$slots,"default")],16,an)],64)}],["__file","/home/runner/work/element-plus/element-plus/packages/components/dropdown/src/dropdown-item-impl.vue"]])},inheritAttrs:!1,props:re,emits:["pointermove","pointerleave","click"],setup(e,{emit:n,attrs:c}){const{elDropdown:a}=pe(),d=le(),u=F(null),i=k(()=>{var t,l;return(l=(t=_(u))==null?void 0:t.textContent)!=null?l:""}),{onItemEnter:r,onItemLeave:v}=E(q,void 0),b=S(t=>(n("pointermove",t),t.defaultPrevented),ie(t=>{if(e.disabled)return void v(t);const l=t.currentTarget;l===document.activeElement||l.contains(document.activeElement)||(r(t),t.defaultPrevented||l==null||l.focus())})),w=S(t=>(n("pointerleave",t),t.defaultPrevented),ie(t=>{v(t)}));return{handleClick:S(t=>{if(!e.disabled)return n("click",t),t.type!=="keydown"&&t.defaultPrevented},t=>{var l,s,f;e.disabled?t.stopImmediatePropagation():((l=a==null?void 0:a.hideOnClick)!=null&&l.value&&((s=a.handleClick)==null||s.call(a)),(f=a.commandHandler)==null||f.call(a,e.command,d,t))}),handlePointerMove:b,handlePointerLeave:w,textContent:i,propsAndAttrs:k(()=>({...e,...c}))}}});var ve=P(sn,[["render",function(e,n,c,a,d,u){var i;const r=h("el-dropdown-item-impl"),v=h("el-roving-focus-item"),b=h("el-dropdown-collection-item");return B(),z(b,{disabled:e.disabled,"text-value":(i=e.textValue)!=null?i:e.textContent},{default:g(()=>[C(v,{focusable:!e.disabled},{default:g(()=>[C(r,H(e.propsAndAttrs,{onPointerleave:e.handlePointerLeave,onPointermove:e.handlePointerMove,onClickimpl:e.handleClick}),{default:g(()=>[$(e.$slots,"default")]),_:3},16,["onPointerleave","onPointermove","onClickimpl"])]),_:3},8,["focusable"])]),_:3},8,["disabled","text-value"])}],["__file","/home/runner/work/element-plus/element-plus/packages/components/dropdown/src/dropdown-item.vue"]]);const dn=G({name:"ElDropdownMenu",props:Oe,setup(e){const n=U("dropdown"),{_elDropdownSize:c}=pe(),a=c.value,{focusTrapRef:d,onKeydown:u}=E(Ae,void 0),{contentRef:i,role:r,triggerId:v}=E(q,void 0),{collectionRef:b,getItems:w}=E(He,void 0),{rovingFocusGroupRef:t,rovingFocusGroupRootStyle:l,tabIndex:s,onBlur:f,onFocus:y,onMousedown:K}=E(V,void 0),{collectionRef:R}=E(Q,void 0),x=k(()=>[n.b("menu"),n.bm("menu",a==null?void 0:a.value)]),m=ae(i,b,d,t,R),D=S(o=>{var p;(p=e.onKeydown)==null||p.call(e,o)},o=>{const{currentTarget:p,code:T,target:M}=o;if(p.contains(M),I.tab===T&&o.stopImmediatePropagation(),o.preventDefault(),M!==_(i)||!je.includes(T))return;const O=w().filter(L=>!L.disabled).map(L=>L.ref);qe.includes(T)&&O.reverse(),X(O)});return{size:a,rovingFocusGroupRootStyle:l,tabIndex:s,dropdownKls:x,role:r,triggerId:v,dropdownListWrapperRef:m,handleKeydown:o=>{D(o),u(o)},onBlur:f,onFocus:y,onMousedown:K}}}),un=["role","aria-labelledby"];var fe=P(dn,[["render",function(e,n,c,a,d,u){return B(),j("ul",{ref:e.dropdownListWrapperRef,class:W(e.dropdownKls),style:Ne(e.rovingFocusGroupRootStyle),tabindex:-1,role:e.role,"aria-labelledby":e.triggerId,onBlur:n[0]||(n[0]=(...i)=>e.onBlur&&e.onBlur(...i)),onFocus:n[1]||(n[1]=(...i)=>e.onFocus&&e.onFocus(...i)),onKeydown:n[2]||(n[2]=Z((...i)=>e.handleKeydown&&e.handleKeydown(...i),["self"])),onMousedown:n[3]||(n[3]=Z((...i)=>e.onMousedown&&e.onMousedown(...i),["self"]))},[$(e.$slots,"default")],46,un)}],["__file","/home/runner/work/element-plus/element-plus/packages/components/dropdown/src/dropdown-menu.vue"]]);const cn=Je(ln,{DropdownItem:ve,DropdownMenu:fe}),pn=se(ve),vn=se(fe);export{pn as E,vn as a,cn as b};