| 1 |
- import{G as K,H as ae,y as b,r as x,d as E,c as r,I as H,w as U,v as F,a as se,z as le,o as G,E as ce,J as ie,T as re,F as ue,m as _,C as de,K as fe,l as ve,g as me}from"./index-8a0f036f.js";import{n as S,t as g,d as L,O as ye,M as he,v as V,c as D,C as Y,e as T,g as ke,r as N,w as Z,f as I,I as q,p as Ce,P as Oe,k as we,i as ge}from"./index-2ba849e8.js";import{u as J}from"./axios-f188f3b2.js";import{u as Ie}from"./index-15d62f81.js";import{P as be}from"./use-placeholder-fc22e4a6.js";import{c as Se}from"./interceptor-5b788f10.js";import{H as pe}from"./use-route-fb40b442.js";import{L as Pe}from"./index-ccc25d6f.js";let xe=2e3;const Te=()=>++xe,W={show:Boolean,zIndex:S,overlay:g,duration:S,teleport:[String,Object],lockScroll:g,lazyRender:g,beforeClose:Function,overlayStyle:Object,overlayClass:L,transitionAppear:Boolean,closeOnClickOverlay:g},lt=Object.keys(W);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))&&V(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),b(t,f=>{f?a():u()})}function Q(e){const t=x(!1);return b(e,o=>{o&&(t.value=o)},{immediate:!0}),o=>()=>t.value?o():null}const[ze,Le]=D("overlay"),Ae={show:Boolean,zIndex:S,duration:S,className:L,lockScroll:g,lazyRender:g,customStyle:Object};var Ee=E({name:ze,props:Ae,setup(e,{slots:t}){const o=x(),c=Q(()=>e.show||!e.lazyRender),n=a=>{e.lockScroll&&V(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:[Le(),e.className]},[(a=t.default)==null?void 0:a.call(t)]),[[F,e.show]])});return Y("touchmove",n,{target:o}),()=>r(H,{name:"van-fade",appear:!0},{default:i})}});const _e=Z(Ee),De=T({},W,{round:Boolean,position:I("center"),closeIcon:I("cross"),closeable:Boolean,transition:String,iconPrefix:String,closeOnPopstate:Boolean,closeIconPosition:I("top-right"),safeAreaInsetTop:Boolean,safeAreaInsetBottom:Boolean}),[Ne,$]=D("popup");var Re=E({name:Ne,inheritAttrs:!1,props:De,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&&Se(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(_e,{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),pe],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:A,safeAreaInsetBottom:ne}=e;return U(r("div",_({ref:u,style:v.value,role:"dialog",tabindex:0,class:[$({round:k,[B]:B}),{"van-safe-area-top":A,"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,A=s==="center"?"van-fade":`van-popup-slide-${s}`;return r(H,{name:k||A,appear:B,onAfterEnter:X,onAfterLeave:ee},{default:oe})};return b(()=>e.show,s=>{s&&!n&&(f(),o.tabindex===0&&le(()=>{var k;(k=u.value)==null||k.focus()})),!s&&n&&(n=!1,t("close"))}),J({popupRef:u}),Be(u,()=>e.show&&e.lockScroll),Y("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(be,()=>e.show),()=>e.teleport?r(re,{to:e.teleport},{default:()=>[h(),R()]}):r(ue,null,[h(),R()])}});const Me=Z(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]=D("toast"),Ke=["show","overlay","teleport","transition","overlayClass","overlayStyle","closeOnClickOverlay"],He={icon:String,show:Boolean,type:I("text"),overlay:Boolean,message:S,iconSize:S,duration:Oe(2e3),position:I("middle"),teleport:[String,Object],wordBreak:String,className:L,iconPrefix:String,transition:I("van-fade"),loadingType:String,forbidClick:Boolean,overlayClass:L,overlayStyle:Object,closeOnClick:Boolean,closeOnClickOverlay:Boolean};var Ue=E({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 b(()=>[e.show,e.forbidClick],i),b(()=>[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,_({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},Ce(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 J({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 Ve={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=[],Ye=!1,j=T({},Ve);const Ze=new Map;function qe(e){return ge(e)?e:{message:e}}function Je(){const{instance:e,unmount:t}=Ge({setup(){const o=x(""),{open:c,state:n,close:i,toggle:a}=Fe(),u=()=>{},y=()=>r(Ue,_(n,{onClosed:u,"onUpdate:show":a}),null);return b(o,v=>{n.message=v}),me().render=y,{open:c,close:i,message:o}}});return e}function We(){if(!z.length||Ye){const e=Je();z.push(e)}return z[z.length-1]}function ct(e={}){if(!we)return{};const t=We(),o=qe(e);return t.open(T({},j,Ze.get(o.type||j.type),o)),t}export{_e as O,Me as P,ct as a,lt as b,Ge as m,W as p,Ue as s,Fe as u};
|