import{defineComponent as D,shallowRef as c,computed as a,watch as O,onBeforeUnmount as S,createVNode as x}from"vue";import j from"../../_util/classNames.mjs";import l from"../../_util/raf.mjs";import{getTransitionProps as w}from"../../_util/transition.mjs";import B from"../../vc-trigger/Trigger.mjs";import"../../_util/vue-types/index.mjs";import{useInjectMenu as z,useInjectForceRender as E}from"./hooks/useMenuContext.mjs";import{placementsRtl as F,placements as I}from"./placements.mjs";const L={horizontal:"bottomLeft",vertical:"rightTop","vertical-left":"rightTop","vertical-right":"leftTop"},K=D({compatConfig:{MODE:3},name:"PopupTrigger",inheritAttrs:!1,props:{prefixCls:String,mode:String,visible:Boolean,popupClassName:String,popupOffset:Array,disabled:Boolean,onVisibleChange:Function},slots:Object,emits:["visibleChange"],setup(o,{slots:i,emit:f}){const p=c(!1),{getPopupContainer:v,rtl:r,subMenuOpenDelay:g,subMenuCloseDelay:d,builtinPlacements:u,triggerSubMenuAction:b,forceSubMenuRender:C,motion:h,defaultMotions:s,rootClassName:P}=z(),M=E(),R=a(()=>r.value?{...F,...u.value}:{...I,...u.value}),T=a(()=>L[o.mode]),n=c();O(()=>o.visible,e=>{l.cancel(n.value),n.value=l(()=>{p.value=e})},{immediate:!0}),S(()=>{l.cancel(n.value)});const y=e=>{f("visibleChange",e)},N=a(()=>{const e=h.value||s.value?.[o.mode]||s.value?.other,t=typeof e=="function"?e():e;return t?w(t.name,{css:!0}):void 0});return()=>{const{prefixCls:e,popupClassName:t,mode:V,popupOffset:m,disabled:A}=o;return x(B,{prefixCls:e,popupClassName:j(`${e}-popup`,{[`${e}-rtl`]:r.value},t,P.value),stretch:V==="horizontal"?"minWidth":null,getPopupContainer:v.value,builtinPlacements:R.value,popupPlacement:T.value,popupVisible:p.value,popupAlign:m&&{offset:m},action:A?[]:[b.value],mouseEnterDelay:g.value,mouseLeaveDelay:d.value,onPopupVisibleChange:y,forceRender:M||C.value,popupAnimation:N.value},{popup:i.popup,default:i.default})}}});export{K as default};
