| 1 |
- import{r as m,R as j,M as se,w as S,d as E,c as u,L as U,i as F,v as H,a as le,B as ce,o as X,x as ie,U as re,T as ue,F as de,m as D,I as fe,V as ve,s as me,g as ye}from"./index-df5648cd.js";import{n as P,t as I,k as A,$ as M,a0 as he,Z as ke,D as V,c as _,K as Z,e as T,g as Ce,A as N,w as G,l as b,H as Oe,I as q,p as ge,a1 as we,v as Ie,i as be}from"./index-f74a9797.js";import{u as W}from"./use-expose-8ee00450.js";import{P as Se,c as Pe}from"./on-popup-reopen-80498ca6.js";import{L as pe}from"./index-3ba5f77a.js";let xe=2e3;const Te=()=>++xe,J={show:Boolean,zIndex:P,overlay:I,duration:P,teleport:[String,Object],lockScroll:I,lazyRender:I,beforeClose:Function,overlayStyle:Object,overlayClass:A,transitionAppear:Boolean,closeOnClickOverlay:I},st=Object.keys(J);function ze(e,t){return e>t?"horizontal":t>e?"vertical":""}function Be(){const e=m(0),t=m(0),o=m(0),l=m(0),n=m(0),s=m(0),a=m(""),c=m(!0),h=()=>a.value==="vertical",y=()=>a.value==="horizontal",f=()=>{o.value=0,l.value=0,n.value=0,s.value=0,a.value="",c.value=!0};return{move:v=>{const k=v.touches[0];o.value=(k.clientX<0?0:k.clientX)-e.value,l.value=k.clientY-t.value,n.value=Math.abs(o.value),s.value=Math.abs(l.value);const C=10;(!a.value||n.value<C&&s.value<C)&&(a.value=ze(n.value,s.value)),c.value&&(n.value>M||s.value>M)&&(c.value=!1)},start:v=>{f(),e.value=v.touches[0].clientX,t.value=v.touches[0].clientY},reset:f,startX:e,startY:t,deltaX:o,deltaY:l,offsetX:n,offsetY:s,direction:a,isVertical:h,isHorizontal:y,isTap:c}}let p=0;const $="van-overflow-hidden";function Ae(e,t){const o=Be(),l="01",n="10",s=f=>{o.move(f);const i=o.deltaY.value>0?n:l,d=ke(f.target,e.value),{scrollHeight:v,offsetHeight:k,scrollTop:C}=d;let O="11";C===0?O=k>=v?"00":"01":C+k>=v&&(O="10"),O!=="11"&&o.isVertical()&&!(parseInt(O,2)&parseInt(i,2))&&V(f,!0)},a=()=>{document.addEventListener("touchstart",o.start),document.addEventListener("touchmove",s,{passive:!1}),p||document.body.classList.add($),p++},c=()=>{p&&(document.removeEventListener("touchstart",o.start),document.removeEventListener("touchmove",s),p--,p||document.body.classList.remove($))},h=()=>t()&&a(),y=()=>t()&&c();he(h),j(y),se(y),S(t,f=>{f?a():c()})}function Q(e){const t=m(!1);return S(e,o=>{o&&(t.value=o)},{immediate:!0}),o=>()=>t.value?o():null}const[Le,Ee]=_("overlay"),De={show:Boolean,zIndex:P,duration:P,className:A,lockScroll:I,lazyRender:I,customStyle:Object};var _e=E({name:Le,props:De,setup(e,{slots:t}){const o=m(),l=Q(()=>e.show||!e.lazyRender),n=a=>{e.lockScroll&&V(a,!0)},s=l(()=>{var a;const c=T(Ce(e.zIndex),e.customStyle);return N(e.duration)&&(c.animationDuration=`${e.duration}s`),F(u("div",{ref:o,style:c,class:[Ee(),e.className]},[(a=t.default)==null?void 0:a.call(t)]),[[H,e.show]])});return Z("touchmove",n,{target:o}),()=>u(U,{name:"van-fade",appear:!0},{default:s})}});const Ne=G(_e),Re=T({},J,{round:Boolean,position:b("center"),closeIcon:b("cross"),closeable:Boolean,transition:String,iconPrefix:String,closeOnPopstate:Boolean,closeIconPosition:b("top-right"),safeAreaInsetTop:Boolean,safeAreaInsetBottom:Boolean}),[Me,K]=_("popup");var $e=E({name:Me,inheritAttrs:!1,props:Re,emits:["open","close","opened","closed","keydown","update:show","clickOverlay","clickCloseIcon"],setup(e,{emit:t,attrs:o,slots:l}){let n,s;const a=m(),c=m(),h=Q(()=>e.show||!e.lazyRender),y=le(()=>{const r={zIndex:a.value};if(N(e.duration)){const g=e.position==="center"?"animationDuration":"transitionDuration";r[g]=`${e.duration}s`}return r}),f=()=>{n||(n=!0,a.value=e.zIndex!==void 0?+e.zIndex:Te(),t("open"))},i=()=>{n&&Pe(e.beforeClose,{done(){n=!1,t("close"),t("update:show",!1)}})},d=r=>{t("clickOverlay",r),e.closeOnClickOverlay&&i()},v=()=>{if(e.overlay)return u(Ne,{show:e.show,class:e.overlayClass,zIndex:a.value,duration:e.duration,customStyle:e.overlayStyle,role:e.closeOnClickOverlay?"button":void 0,tabindex:e.closeOnClickOverlay?0:void 0,onClick:d},{default:l["overlay-content"]})},k=r=>{t("clickCloseIcon",r),i()},C=()=>{if(e.closeable)return u(q,{role:"button",tabindex:0,name:e.closeIcon,class:[K("close-icon",e.closeIconPosition),Oe],classPrefix:e.iconPrefix,onClick:k},null)};let O;const ee=()=>{O&&clearTimeout(O),O=setTimeout(()=>{t("opened")})},te=()=>t("closed"),oe=r=>t("keydown",r),ne=h(()=>{var r;const{round:g,position:z,safeAreaInsetTop:L,safeAreaInsetBottom:ae}=e;return F(u("div",D({ref:c,style:y.value,role:"dialog",tabindex:0,class:[K({round:g,[z]:z}),{"van-safe-area-top":L,"van-safe-area-bottom":ae}],onKeydown:oe},o),[(r=l.default)==null?void 0:r.call(l),C()]),[[H,e.show]])}),R=()=>{const{position:r,transition:g,transitionAppear:z}=e,L=r==="center"?"van-fade":`van-popup-slide-${r}`;return u(U,{name:g||L,appear:z,onAfterEnter:ee,onAfterLeave:te},{default:ne})};return S(()=>e.show,r=>{r&&!n&&(f(),o.tabindex===0&&ce(()=>{var g;(g=c.value)==null||g.focus()})),!r&&n&&(n=!1,t("close"))}),W({popupRef:c}),Ae(c,()=>e.show&&e.lockScroll),Z("popstate",()=>{e.closeOnPopstate&&(i(),s=!1)}),X(()=>{e.show&&f()}),ie(()=>{s&&(t("update:show",!0),s=!1)}),j(()=>{e.show&&e.teleport&&(i(),s=!0)}),re(Se,()=>e.show),()=>e.teleport?u(ue,{to:e.teleport},{default:()=>[v(),R()]}):u(de,null,[v(),R()])}});const Ke=G($e);let x=0;function Ye(e){e?(x||document.body.classList.add("van-toast--unclickable"),x++):x&&(x--,x||document.body.classList.remove("van-toast--unclickable"))}const[je,w]=_("toast"),Ue=["show","overlay","teleport","transition","overlayClass","overlayStyle","closeOnClickOverlay"],Fe={icon:String,show:Boolean,type:b("text"),overlay:Boolean,message:P,iconSize:P,duration:we(2e3),position:b("middle"),teleport:[String,Object],wordBreak:String,className:A,iconPrefix:String,transition:b("van-fade"),loadingType:String,forbidClick:Boolean,overlayClass:A,overlayStyle:Object,closeOnClick:Boolean,closeOnClickOverlay:Boolean};var He=E({name:je,props:Fe,emits:["update:show"],setup(e,{emit:t,slots:o}){let l,n=!1;const s=()=>{const i=e.show&&e.forbidClick;n!==i&&(n=i,Ye(n))},a=i=>t("update:show",i),c=()=>{e.closeOnClick&&a(!1)},h=()=>clearTimeout(l),y=()=>{const{icon:i,type:d,iconSize:v,iconPrefix:k,loadingType:C}=e;if(i||d==="success"||d==="fail")return u(q,{name:i||d,size:v,class:w("icon"),classPrefix:k},null);if(d==="loading")return u(pe,{class:w("loading"),size:v,type:C},null)},f=()=>{const{type:i,message:d}=e;if(o.message)return u("div",{class:w("text")},[o.message()]);if(N(d)&&d!=="")return i==="html"?u("div",{key:0,class:w("text"),innerHTML:String(d)},null):u("div",{class:w("text")},[d])};return S(()=>[e.show,e.forbidClick],s),S(()=>[e.show,e.type,e.message,e.duration],()=>{h(),e.show&&e.duration>0&&(l=setTimeout(()=>{a(!1)},e.duration))}),X(s),fe(s),()=>u(Ke,D({class:[w([e.position,e.wordBreak==="normal"?"break-normal":e.wordBreak,{[e.type]:!e.icon}]),e.className],lockScroll:!1,onClick:c,onClosed:h,"onUpdate:show":a},ge(e,Ue)),{default:()=>[y(),f()]})}});function Xe(){const e=me({show:!1}),t=n=>{e.show=n},o=n=>{T(e,n,{transitionAppear:!0}),t(!0)},l=()=>t(!1);return W({open:o,close:l,toggle:t}),{open:o,close:l,state:e,toggle:t}}function Ve(e){const t=ve(e),o=document.createElement("div");return document.body.appendChild(o),{instance:t.mount(o),unmount(){t.unmount(),document.body.removeChild(o)}}}const Ze={icon:"",type:"text",message:"",className:"",overlay:!1,onClose:void 0,onOpened:void 0,duration:2e3,teleport:"body",iconSize:void 0,iconPrefix:void 0,position:"middle",transition:"van-fade",forbidClick:!1,loadingType:void 0,overlayClass:"",overlayStyle:void 0,closeOnClick:!1,closeOnClickOverlay:!1};let B=[],Ge=!1,Y=T({},Ze);const qe=new Map;function We(e){return be(e)?e:{message:e}}function Je(){const{instance:e,unmount:t}=Ve({setup(){const o=m(""),{open:l,state:n,close:s,toggle:a}=Xe(),c=()=>{},h=()=>u(He,D(n,{onClosed:c,"onUpdate:show":a}),null);return S(o,y=>{n.message=y}),ye().render=h,{open:l,close:s,message:o}}});return e}function Qe(){if(!B.length||Ge){const e=Je();B.push(e)}return B[B.length-1]}function lt(e={}){if(!Ie)return{};const t=Qe(),o=We(e);return t.open(T({},Y,qe.get(o.type||Y.type),o)),t}export{Ne as O,Ke as P,st as a,Be as b,Ve as m,J as p,lt as s,Xe as u};
|