import{m as u,l as T,C as S,h as B,o as l,c as f,b as p,F as b,k as y,t as x,i as N,n as g,H as h,e as k,a as D,j as L,r as V,a0 as z,S as E}from"./app-13978987.js";const F={class:"relative flex max-w-min flex-col"},I={__name:"FloatingDropdown",props:{btnType:{type:String,default:"text"},btnText:{type:String,default:"Toggle"},iconName:{type:String,default:"bx:dots-horizontal-rounded"},btnClass:{type:String,default:"btn"},iconClass:{type:String,default:"text-2xl"},position:{type:String,default:"right"},activeClass:{type:String,default:"text-primary-500"}},setup(t,{expose:w}){const o=t,n=u(!1),i=u(null),r=u(null),a=u(o.position),C={right:"right-1",left:"left-1"},m=()=>{n.value=!n.value,E(()=>{if(r.value){const e=i.value.getBoundingClientRect(),s=r.value.offsetWidth,c=e.left,d=window.innerWidth-e.right;c<s&&d<s?a.value=o.position:o.position==="right"&&c<s?a.value="left":o.position==="left"&&d<s?a.value="right":a.value=o.position}})};w({toggleDropdown:m});const v=e=>{n.value&&!r.value.contains(e.target)&&!i.value.contains(e.target)&&e.target!==i.value&&(n.value=!1)};return T(()=>{document.addEventListener("click",v)}),S(()=>{document.removeEventListener("click",v)}),(e,s)=>{const c=B("Icon");return l(),f("div",F,[p("button",{ref_key:"dropdownBtn",ref:i,type:"button",onClick:m,class:g(["max-w-max",[n.value?t.activeClass:"",t.btnClass]])},[t.btnText&&t.btnType==="text"?(l(),f(b,{key:0},[y(x(t.btnText),1)],64)):t.btnText&&t.btnType==="icon"?(l(),N(c,{key:1,class:g(t.iconClass),icon:t.iconName},null,8,["class","icon"])):t.btnType==="slot"?h(e.$slots,"btnContent",{key:2},()=>[y(x(t.btnText),1)]):k("",!0)],2),D(z,{name:"slide-bottom"},{default:L(()=>[n.value?(l(),f("div",{key:0,ref_key:"dropdownContent",ref:r,class:g([C[a.value]||"right-0","absolute right-0 top-full z-[500] mt-1 min-w-max overflow-hidden whitespace-nowrap rounded-md border bg-slate-50 shadow-lg dark:border-secondary-700 dark:bg-dark-800"])},[h(e.$slots,"default",{},()=>[(l(),f(b,null,V(10,d=>p("p",{key:d},"Dropdown Contents")),64))])],2)):k("",!0)]),_:3})])}}};export{I as _};
