| 1 |
- import{m as I,u as B}from"./mount-component-8daea98e.js";import{c as z,y as T,z as k,n as v,a1 as N,G as w,I as M,k as L,e as O,N as j,i as U}from"./index-e9453d64.js";import{P as G}from"./index-c1d3cef3.js";import{L as V}from"./index-856231c7.js";import{d as q,w as p,o as D,G as H,c as a,m as b,r as _,g as A}from"./index-ddf66cb5.js";let d=0;function E(e){e?(d||document.body.classList.add("van-toast--unclickable"),d++):d&&(d--,d||document.body.classList.remove("van-toast--unclickable"))}const[F,i]=z("toast"),J=["show","overlay","teleport","transition","overlayClass","overlayStyle","closeOnClickOverlay","zIndex"],K={icon:String,show:Boolean,type:k("text"),overlay:Boolean,message:v,iconSize:v,duration:N(2e3),position:k("middle"),teleport:[String,Object],wordBreak:String,className:w,iconPrefix:String,transition:k("van-fade"),loadingType:String,forbidClick:Boolean,overlayClass:w,overlayStyle:Object,closeOnClick:Boolean,closeOnClickOverlay:Boolean,zIndex:v};var Q=q({name:F,props:K,emits:["update:show"],setup(e,{emit:l,slots:o}){let u,s=!1;const c=()=>{const n=e.show&&e.forbidClick;s!==n&&(s=n,E(s))},r=n=>l("update:show",n),g=()=>{e.closeOnClick&&r(!1)},f=()=>clearTimeout(u),m=()=>{const{icon:n,type:t,iconSize:C,iconPrefix:P,loadingType:x}=e;if(n||t==="success"||t==="fail")return a(M,{name:n||t,size:C,class:i("icon"),classPrefix:P},null);if(t==="loading")return a(V,{class:i("loading"),size:C,type:x},null)},S=()=>{const{type:n,message:t}=e;if(o.message)return a("div",{class:i("text")},[o.message()]);if(L(t)&&t!=="")return n==="html"?a("div",{key:0,class:i("text"),innerHTML:String(t)},null):a("div",{class:i("text")},[t])};return p(()=>[e.show,e.forbidClick],c),p(()=>[e.show,e.type,e.message,e.duration],()=>{f(),e.show&&e.duration>0&&(u=setTimeout(()=>{r(!1)},e.duration))}),D(c),H(c),()=>a(G,b({class:[i([e.position,e.wordBreak==="normal"?"break-normal":e.wordBreak,{[e.type]:!e.icon}]),e.className],lockScroll:!1,onClick:g,onClosed:f,"onUpdate:show":r},T(e,J)),{default:()=>[m(),S()]})}});const R={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 y=[],W=!1,h=O({},R);const X=new Map;function Y(e){return U(e)?e:{message:e}}function Z(){const{instance:e,unmount:l}=I({setup(){const o=_(""),{open:u,state:s,close:c,toggle:r}=B(),g=()=>{},f=()=>a(Q,b(s,{onClosed:g,"onUpdate:show":r}),null);return p(o,m=>{s.message=m}),A().render=f,{open:u,close:c,message:o}}});return e}function $(){if(!y.length||W){const e=Z();y.push(e)}return y[y.length-1]}function ie(e={}){if(!j)return{};const l=$(),o=Y(e);return l.open(O({},h,X.get(o.type||h.type),o)),l}export{Q as a,ie as s};
|