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