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