import{defineComponent as w,inject as I,shallowRef as p,onBeforeUnmount as k,createVNode as o}from"vue";import"../../menu/index.mjs";import"../../spin/index.mjs";import D from"./MentionsContext.mjs";import F from"../../menu/src/Menu.mjs";import r from"../../menu/src/MenuItem.mjs";import O from"../../spin/Spin.mjs";function S(){}const B=w({compatConfig:{MODE:3},name:"DropdownMenu",props:{prefixCls:String,options:{type:Array,default:()=>[]}},setup(c,{slots:d}){const{activeIndex:m,setActiveIndex:f,selectOption:v,onFocus:y=S,loading:n}=I(D,{activeIndex:p(),loading:p(!1)});let l;const M=a=>{clearTimeout(l),l=setTimeout(()=>{y(a)})};return k(()=>{clearTimeout(l)}),()=>{const{prefixCls:a,options:t}=c,x=t[m.value]||{};return o(F,{prefixCls:`${a}-menu`,activeKey:x.value,onSelect:({key:e})=>{const i=t.find(({value:u})=>u===e);v(i)},onMousedown:M},{default:()=>[!n.value&&t.map((e,i)=>{const{value:u,disabled:C,label:s=e.value,class:g,style:b}=e;return o(r,{key:u,disabled:C,onMouseenter:()=>{f(i)},class:g,style:b},{default:()=>[d.option?.(e)??(typeof s=="function"?s(e):s)]})}),!n.value&&t.length===0?o(r,{key:"notFoundContent",disabled:!0},{default:()=>[d.notFoundContent?.()]}):null,n.value&&o(r,{key:"loading",disabled:!0},{default:()=>[o(O,{size:"small"},null)]})]})}}});export{B as default};
