1 |
- import{j as $,v as y,t as T,an as N,n as j,d as V,aG as H,i as D,ac as q,aD as B,E as z,ax as K,u as M,aj as Y,g as r,Y as F,aq as G,ar as L,O as U,ae as Z,aH as J,q as Q,x as E,aI as X,ay as ee,az as te,P as oe,m as ne,ao as ae,I as se,D as W}from"./index-071fe22e.js";import{C as le}from"./index-02fc6d53.js";const[A,h]=$("dropdown-menu"),re={overlay:y,zIndex:T,duration:N(.2),direction:j("down"),activeColor:String,closeOnClickOutside:y,closeOnClickOverlay:y},R=Symbol(A);var ie=V({name:A,props:re,setup(t,{slots:i}){const c=H(),u=D(),n=D(),l=D(0),{children:d,linkChildren:p}=q(R),g=B(u),f=z(()=>d.some(o=>o.state.showWrapper)),O=z(()=>{if(f.value&&K(t.zIndex))return{zIndex:+t.zIndex+1}}),b=()=>{t.closeOnClickOutside&&d.forEach(o=>{o.toggle(!1)})},w=()=>{if(n.value){const o=F(n);t.direction==="down"?l.value=o.bottom:l.value=G.value-o.top}},k=()=>{f.value&&w()},x=o=>{d.forEach((e,a)=>{a===o?e.toggle():e.state.showPopup&&e.toggle(!1,{immediate:!0})})},I=(o,e)=>{const{showPopup:a}=o.state,{disabled:s,titleClass:v}=o;return r("div",{id:`${c}-${e}`,role:"button",tabindex:s?void 0:0,class:[h("item",{disabled:s}),{[L]:!s}],onClick:()=>{s||x(e)}},[r("span",{class:[h("title",{down:a===(t.direction==="down"),active:a}),v],style:{color:a?t.activeColor:""}},[r("div",{class:"van-ellipsis"},[o.renderTitle()])])])};return p({id:c,props:t,offset:l,updateOffset:w}),M(u,b),Y("scroll",k,{target:g,passive:!0}),()=>{var o;return r("div",{ref:u,class:h()},[r("div",{ref:n,style:O.value,class:h("bar",{opened:f.value})},[d.map(I)]),(o=i.default)==null?void 0:o.call(i)])}}});const[ce,P]=$("dropdown-item"),de={title:String,options:Q(),disabled:Boolean,teleport:[String,Object],lazyRender:y,modelValue:E,titleClass:E};var ue=V({name:ce,inheritAttrs:!1,props:de,emits:["open","opened","close","closed","change","update:modelValue"],setup(t,{emit:i,slots:c,attrs:u}){const n=U({showPopup:!1,transition:!0,showWrapper:!1}),{parent:l,index:d}=Z(R);if(!l)return;const p=e=>()=>i(e),g=p("open"),f=p("close"),O=p("opened"),b=()=>{n.showWrapper=!1,i("closed")},w=e=>{t.teleport&&e.stopPropagation()},k=(e=!n.showPopup,a={})=>{e!==n.showPopup&&(n.showPopup=e,n.transition=!a.immediate,e&&(l.updateOffset(),n.showWrapper=!0))},x=()=>{if(c.title)return c.title();if(t.title)return t.title;const e=t.options.find(a=>a.value===t.modelValue);return e?e.text:""},I=e=>{const{activeColor:a}=l.props,s=e.value===t.modelValue,v=()=>{n.showPopup=!1,e.value!==t.modelValue&&(i("update:modelValue",e.value),i("change",e.value))},m=()=>{if(s)return r(se,{class:P("icon"),color:a,name:"success"},null)};return r(le,{role:"menuitem",key:e.value,icon:e.icon,title:e.text,class:P("option",{active:s}),style:{color:s?a:""},tabindex:s?0:-1,clickable:!0,onClick:v},{value:m})},o=()=>{const{offset:e}=l,{zIndex:a,overlay:s,duration:v,direction:m,closeOnClickOverlay:_}=l.props,S=X(a);return m==="down"?S.top=`${e.value}px`:S.bottom=`${e.value}px`,ee(r("div",ne({style:S,class:P([m]),onClick:w},u),[r(oe,{show:n.showPopup,"onUpdate:show":C=>n.showPopup=C,role:"menu",class:P("content"),overlay:s,position:m==="down"?"top":"bottom",duration:n.transition?v:0,lazyRender:t.lazyRender,overlayStyle:{position:"absolute"},"aria-labelledby":`${l.id}-${d.value}`,closeOnClickOverlay:_,onOpen:g,onClose:f,onOpened:O,onClosed:b},{default:()=>{var C;return[t.options.map(I),(C=c.default)==null?void 0:C.call(c)]}})]),[[te,n.showWrapper]])};return ae({state:n,toggle:k,renderTitle:x}),()=>t.teleport?r(J,{to:t.teleport},{default:()=>[o()]}):o()}});const ve=W(ue),me=W(ie);export{me as D,ve as a};
|