import{defineComponent as V,ref as u,watch as B,computed as f,createVNode as r,Fragment as E}from"vue";import M from"../_util/classNames.mjs";import{skipFlattenKey as S}from"../_util/props-util/index.mjs";import{cloneElement as c}from"../_util/vnode.mjs";import t from"../_util/vue-types/index.mjs";import D from"../vc-trigger/Trigger.mjs";import W from"./placements.mjs";const q=V({compatConfig:{MODE:3},props:{minOverlayWidthMatchTrigger:{type:Boolean,default:void 0},arrow:{type:Boolean,default:!1},prefixCls:t.string.def("rc-dropdown"),transitionName:String,overlayClassName:t.string.def(""),openClassName:String,animation:t.any,align:t.object,overlayStyle:{type:Object,default:void 0},placement:t.string.def("bottomLeft"),overlay:t.any,trigger:t.oneOfType([t.string,t.arrayOf(t.string)]).def("hover"),alignPoint:{type:Boolean,default:void 0},showAction:t.array,hideAction:t.array,getPopupContainer:Function,visible:{type:Boolean,default:void 0},defaultVisible:{type:Boolean,default:!1},mouseEnterDelay:t.number.def(.15),mouseLeaveDelay:t.number.def(.1)},emits:["visibleChange","overlayClick"],setup(n,{slots:o,emit:l,expose:d}){const i=u(!!n.visible);B(()=>n.visible,e=>{e!==void 0&&(i.value=e)});const s=u();d({triggerRef:s});const m=e=>{n.visible===void 0&&(i.value=!1),l("overlayClick",e)},p=e=>{n.visible===void 0&&(i.value=e),l("visibleChange",e)},g=()=>{const e=o.overlay?.(),a={prefixCls:`${n.prefixCls}-menu`,onClick:m};return r(E,{key:S},[n.arrow&&r("div",{class:`${n.prefixCls}-arrow`},null),c(e,a,!1)])},y=f(()=>{const{minOverlayWidthMatchTrigger:e=!n.alignPoint}=n;return e}),v=()=>{const e=o.default?.();return i.value&&e?c(e[0],{class:n.openClassName||`${n.prefixCls}-open`},!1):e},h=f(()=>!n.hideAction&&n.trigger.includes("contextmenu")?["click"]:n.hideAction);return()=>{const{prefixCls:e,arrow:a,showAction:C,overlayStyle:b,trigger:w,placement:P,align:x,getPopupContainer:A,transitionName:N,animation:O,overlayClassName:T,...k}=n;return r(D,{...k,prefixCls:e,ref:s,popupClassName:M(T,{[`${e}-show-arrow`]:a}),popupStyle:b,builtinPlacements:W,action:w,showAction:C,hideAction:h.value||[],popupPlacement:P,popupAlign:x,popupTransitionName:N,popupAnimation:O,popupVisible:i.value,stretch:y.value?"minWidth":"",onPopupVisibleChange:p,getPopupContainer:A},{popup:g,default:v})}}});export{q as default};
