vant/v3/assets/index.e11757c0.js
2024-04-20 08:49:23 +00:00

2 lines
7.7 KiB
JavaScript

import{c as M,b as W,M as j,i as H,Y as K,n as Y,r as L,R as Q,u as Z,v as q,a as G}from"./use-translate.d2900b8c.js";import{t as B,n as J,c as X,m as ee,w as F,b as te,u as U}from"./with-install.19a35764.js";import{H as oe}from"./constant.80c6de18.js";import{u as le}from"./use-id.46df47b7.js";import{z as I,C as b,D as T,e as o,H as ne,j as ae,v as ue,Q as ie,S as se,r as re,o as de,a as ce,w as c,B as t,d as pe,h as me,t as ve,F as fe}from"./vue-libs.b44bc779.js";import{u as Ce}from"./use-expose.c942d5f8.js";import{C as Ve,V as z}from"./index.bbd81525.js";import{I as we}from"./index.b70c9b40.js";import{P as xe}from"./index.e6e790ed.js";import{V as _}from"./index.fd5fe6e1.js";import{V as be}from"./index.8e37fe56.js";import"./use-route.82f2be69.js";import"./interceptor.f0c85874.js";import"./use-touch.04ca7093.js";import"./use-lazy-render.f712e85e.js";import"./on-popup-reopen.138c77eb.js";import"./index.d46e53a8.js";import"./index.4e4daaac.js";const[N,E]=M("dropdown-menu"),ge={overlay:B,zIndex:J,duration:X(.2),direction:ee("down"),activeColor:String,closeOnClickOutside:B,closeOnClickOverlay:B},$=Symbol(N),ye=I({name:N,props:ge,setup(a,{slots:u}){const v=le(),i=b(),p=b(),r=b(0),{children:s,linkChildren:V}=W($),w=j(i),g=T(()=>s.some(e=>e.state.showWrapper)),y=T(()=>{if(g.value&&H(a.zIndex))return{zIndex:+a.zIndex+1}}),l=()=>{a.closeOnClickOutside&&s.forEach(e=>{e.toggle(!1)})},f=()=>{if(p.value){const e=L(p);a.direction==="down"?r.value=e.bottom:r.value=Q.value-e.top}},n=()=>{g.value&&f()},A=e=>{s.forEach((d,m)=>{m===e?(f(),d.toggle()):d.state.showPopup&&d.toggle(!1,{immediate:!0})})},D=(e,d)=>{const{showPopup:m}=e.state,{disabled:x,titleClass:O}=e;return o("div",{id:`${v}-${d}`,role:"button",tabindex:x?void 0:0,class:[E("item",{disabled:x}),{[oe]:!x}],onClick:()=>{x||A(d)}},[o("span",{class:[E("title",{down:m===(a.direction==="down"),active:m}),O],style:{color:m?a.activeColor:""}},[o("div",{class:"van-ellipsis"},[e.renderTitle()])])])};return V({id:v,props:a,offset:r}),K(i,l),Y("scroll",n,{target:w,passive:!0}),()=>{var e;return o("div",{ref:i,class:E()},[o("div",{ref:p,style:y.value,class:E("bar",{opened:g.value})},[s.map(D)]),(e=u.default)==null?void 0:e.call(u)])}}}),Oe=F(ye),k=Oe;function ke(a){return typeof a=="function"||Object.prototype.toString.call(a)==="[object Object]"&&!ie(a)}const[De,h]=M("dropdown-item"),Pe={title:String,options:te(),disabled:Boolean,teleport:[String,Object],lazyRender:B,modelValue:U,titleClass:U},Ee=I({name:De,props:Pe,emits:["open","opened","close","closed","change","update:modelValue"],setup(a,{emit:u,slots:v}){const i=ne({showPopup:!1,transition:!0,showWrapper:!1}),{parent:p,index:r}=Z($);if(!p)return;const s=e=>()=>u(e),V=s("open"),w=s("close"),g=s("opened"),y=()=>{i.showWrapper=!1,u("closed")},l=e=>{a.teleport&&e.stopPropagation()},f=(e=!i.showPopup,d={})=>{e!==i.showPopup&&(i.showPopup=e,i.transition=!d.immediate,e&&(i.showWrapper=!0))},n=()=>{if(v.title)return v.title();if(a.title)return a.title;const e=a.options.find(d=>d.value===a.modelValue);return e?e.text:""},A=e=>{const{activeColor:d}=p.props,m=e.value===a.modelValue,x=()=>{i.showPopup=!1,e.value!==a.modelValue&&(u("update:modelValue",e.value),u("change",e.value))},O=()=>{if(m)return o(we,{class:h("icon"),color:d,name:"success"},null)};return o(Ve,{role:"menuitem",key:e.value,icon:e.icon,title:e.text,class:h("option",{active:m}),style:{color:m?d:""},tabindex:m?0:-1,clickable:!0,onClick:x},{value:O})},D=()=>{const{offset:e}=p,{zIndex:d,overlay:m,duration:x,direction:O,closeOnClickOverlay:R}=p.props,S=q(d);return O==="down"?S.top=`${e.value}px`:S.bottom=`${e.value}px`,ae(o("div",{style:S,class:h([O]),onClick:l},[o(xe,{show:i.showPopup,"onUpdate:show":P=>i.showPopup=P,role:"menu",class:h("content"),overlay:m,position:O==="down"?"top":"bottom",duration:i.transition?x:0,lazyRender:a.lazyRender,overlayStyle:{position:"absolute"},"aria-labelledby":`${p.id}-${r.value}`,closeOnClickOverlay:R,onOpen:V,onClose:w,onOpened:g,onClosed:y},{default:()=>{var P;return[a.options.map(A),(P=v.default)==null?void 0:P.call(v)]}})]),[[ue,i.showWrapper]])};return Ce({state:i,toggle:f,renderTitle:n}),()=>{if(a.teleport){let e;return o(se,{to:a.teleport},ke(e=D())?e:{default:()=>[e]})}return D()}}}),he=F(Ee),C=he,Be={style:{padding:"5px 16px"}},Qe=I({__name:"index",setup(a){const u=G({"zh-CN":{disableMenu:"\u7981\u7528\u83DC\u5355",switchTitle1:"\u5305\u90AE",switchTitle2:"\u56E2\u8D2D",itemTitle:"\u7B5B\u9009",expandDirection:"\u5411\u4E0A\u5C55\u5F00",customContent:"\u81EA\u5B9A\u4E49\u83DC\u5355\u5185\u5BB9",customActiveColor:"\u81EA\u5B9A\u4E49\u9009\u4E2D\u6001\u989C\u8272",option1:[{text:"\u5168\u90E8\u5546\u54C1",value:0},{text:"\u65B0\u6B3E\u5546\u54C1",value:1},{text:"\u6D3B\u52A8\u5546\u54C1",value:2}],option2:[{text:"\u9ED8\u8BA4\u6392\u5E8F",value:"a"},{text:"\u597D\u8BC4\u6392\u5E8F",value:"b"},{text:"\u9500\u91CF\u6392\u5E8F",value:"c"}]},"en-US":{disableMenu:"Disable Menu",switchTitle1:"Title",switchTitle2:"Title",itemTitle:"Title",expandDirection:"Expand Direction",customContent:"Custom Content",customActiveColor:"Custom Active Color",option1:[{text:"Option1",value:0},{text:"Option2",value:1},{text:"Option3",value:2}],option2:[{text:"Option A",value:"a"},{text:"Option B",value:"b"},{text:"Option C",value:"c"}]}}),v=b(),i=b(!0),p=b(!1),r=b(0),s=b("a"),V=T(()=>u("option1")),w=T(()=>u("option2")),g=()=>{var y;(y=v.value)==null||y.toggle()};return(y,l)=>{const f=re("demo-block");return de(),ce(fe,null,[o(f,{title:t(u)("basicUsage")},{default:c(()=>[o(t(k),null,{default:c(()=>[o(t(C),{modelValue:r.value,"onUpdate:modelValue":l[0]||(l[0]=n=>r.value=n),options:t(V)},null,8,["modelValue","options"]),o(t(C),{modelValue:s.value,"onUpdate:modelValue":l[1]||(l[1]=n=>s.value=n),options:t(w)},null,8,["modelValue","options"])]),_:1})]),_:1},8,["title"]),o(f,{title:t(u)("customContent")},{default:c(()=>[o(t(k),null,{default:c(()=>[o(t(C),{modelValue:r.value,"onUpdate:modelValue":l[2]||(l[2]=n=>r.value=n),options:t(V)},null,8,["modelValue","options"]),o(t(C),{title:t(u)("itemTitle"),ref_key:"item",ref:v},{default:c(()=>[o(t(z),{center:"",title:t(u)("switchTitle1")},{"right-icon":c(()=>[o(t(_),{modelValue:i.value,"onUpdate:modelValue":l[3]||(l[3]=n=>i.value=n),size:"24","active-color":"#ee0a24"},null,8,["modelValue"])]),_:1},8,["title"]),o(t(z),{center:"",title:t(u)("switchTitle2")},{"right-icon":c(()=>[o(t(_),{modelValue:p.value,"onUpdate:modelValue":l[4]||(l[4]=n=>p.value=n),size:"24","active-color":"#ee0a24"},null,8,["modelValue"])]),_:1},8,["title"]),pe("div",Be,[o(t(be),{type:"danger",block:"",round:"",style:{height:"40px"},onClick:g},{default:c(()=>[me(ve(t(u)("confirm")),1)]),_:1})])]),_:1},8,["title"])]),_:1})]),_:1},8,["title"]),o(f,{title:t(u)("customActiveColor")},{default:c(()=>[o(t(k),{"active-color":"#1989fa"},{default:c(()=>[o(t(C),{modelValue:r.value,"onUpdate:modelValue":l[5]||(l[5]=n=>r.value=n),options:t(V)},null,8,["modelValue","options"]),o(t(C),{modelValue:s.value,"onUpdate:modelValue":l[6]||(l[6]=n=>s.value=n),options:t(w)},null,8,["modelValue","options"])]),_:1})]),_:1},8,["title"]),o(f,{title:t(u)("expandDirection")},{default:c(()=>[o(t(k),{direction:"up"},{default:c(()=>[o(t(C),{modelValue:r.value,"onUpdate:modelValue":l[7]||(l[7]=n=>r.value=n),options:t(V)},null,8,["modelValue","options"]),o(t(C),{modelValue:s.value,"onUpdate:modelValue":l[8]||(l[8]=n=>s.value=n),options:t(w)},null,8,["modelValue","options"])]),_:1})]),_:1},8,["title"]),o(f,{title:t(u)("disableMenu")},{default:c(()=>[o(t(k),null,{default:c(()=>[o(t(C),{modelValue:r.value,"onUpdate:modelValue":l[9]||(l[9]=n=>r.value=n),disabled:"",options:t(V)},null,8,["modelValue","options"]),o(t(C),{modelValue:s.value,"onUpdate:modelValue":l[10]||(l[10]=n=>s.value=n),disabled:"",options:t(w)},null,8,["modelValue","options"])]),_:1})]),_:1},8,["title"])],64)}}});export{Qe as default};