index.59f99230.js 4.0 KB

1
  1. import{A as q,y as B,z as Z,w as b,T as J,r as O,d as L,c as i,U as p,n as E,f as D,J as _,L as R,S as W,p as Q,F as X,C as ee,D as oe,G as ne,q as te,V as ae,W as se,t as le}from"./index.fdb8061e.js";import{n as k,t as y,q as $,v as ce,y as K,c as F,a as re,w as H,m as C,f as ie,P as ue,H as de,I as fe}from"./index.555136dd.js";import{c as ve}from"./index.d6266256.js";const ye={show:Boolean,zIndex:k,overlay:y,duration:k,teleport:[String,Object],lockScroll:y,lazyRender:y,beforeClose:Function,overlayStyle:Object,overlayClass:$,transitionAppear:Boolean,closeOnClickOverlay:y};let h=0;const A="van-overflow-hidden";function me(e,o){const t=ce(),l=d=>{t.move(d);const S=t.deltaY.value>0?"10":"01",w=J(d.target,e.value),{scrollHeight:f,offsetHeight:I,scrollTop:m}=w;let v="11";m===0?v=I>=f?"00":"01":m+I>=f&&(v="10"),v!=="11"&&t.isVertical()&&!(parseInt(v,2)&parseInt(S,2))&&K(d,!0)},a=()=>{document.addEventListener("touchstart",t.start),document.addEventListener("touchmove",l,{passive:!1}),h||document.body.classList.add(A),h++},s=()=>{h&&(document.removeEventListener("touchstart",t.start),document.removeEventListener("touchmove",l),h--,h||document.body.classList.remove(A))},c=()=>o()&&a(),u=()=>o()&&s();q(c),B(u),Z(u),b(o,d=>{d?a():s()})}function M(e){const o=O(!1);return b(e,t=>{t&&(o.value=t)},{immediate:!0}),t=>()=>o.value?t():null}const[he,we]=F("overlay"),Ie={show:Boolean,zIndex:k,duration:k,className:$,lockScroll:y,lazyRender:y,customStyle:Object};var Pe=L({name:he,props:Ie,setup(e,{slots:o}){const t=M(()=>e.show||!e.lazyRender),l=s=>{K(s,!0)},a=t(()=>{var s;const c=E(re(e.zIndex),e.customStyle);return D(e.duration)&&(c.animationDuration=`${e.duration}s`),_(i("div",{style:c,class:[we(),e.className],onTouchmove:e.lockScroll?l:W},[(s=o.default)==null?void 0:s.call(o)]),[[R,e.show]])});return()=>i(p,{name:"van-fade",appear:!0},{default:a})}});const ke=H(Pe),Se=E({},ye,{round:Boolean,position:C("center"),closeIcon:C("cross"),closeable:Boolean,transition:String,iconPrefix:String,closeOnPopstate:Boolean,closeIconPosition:C("top-right"),safeAreaInsetTop:Boolean,safeAreaInsetBottom:Boolean}),[xe,T]=F("popup");let g=2e3;var Ce=L({name:xe,inheritAttrs:!1,props:Se,emits:["open","close","opened","closed","keydown","update:show","click-overlay","click-close-icon"],setup(e,{emit:o,attrs:t,slots:l}){let a,s;const c=O(),u=O(),d=M(()=>e.show||!e.lazyRender),S=Q(()=>{const n={zIndex:c.value};if(D(e.duration)){const r=e.position==="center"?"animationDuration":"transitionDuration";n[r]=`${e.duration}s`}return n}),w=()=>{a||(e.zIndex!==void 0&&(g=+e.zIndex),a=!0,c.value=++g,o("open"))},f=()=>{a&&ve(e.beforeClose,{done(){a=!1,o("close"),o("update:show",!1)}})},I=n=>{o("click-overlay",n),e.closeOnClickOverlay&&f()},m=()=>{if(e.overlay)return i(ke,{show:e.show,class:e.overlayClass,zIndex:c.value,duration:e.duration,customStyle:e.overlayStyle,onClick:I},{default:l["overlay-content"]})},v=n=>{o("click-close-icon",n),f()},N=()=>{if(e.closeable)return i(fe,{role:"button",tabindex:0,name:e.closeIcon,class:[T("close-icon",e.closeIconPosition),de],classPrefix:e.iconPrefix,onClick:v},null)},j=()=>o("opened"),G=()=>o("closed"),U=n=>o("keydown",n),V=d(()=>{var n;const{round:r,position:P,safeAreaInsetTop:x,safeAreaInsetBottom:Y}=e;return _(i("div",le({ref:u,style:S.value,class:[T({round:r,[P]:P}),{"van-safe-area-top":x,"van-safe-area-bottom":Y}],onKeydown:U},t),[(n=l.default)==null?void 0:n.call(l),N()]),[[R,e.show]])}),z=()=>{const{position:n,transition:r,transitionAppear:P}=e,x=n==="center"?"van-fade":`van-popup-slide-${n}`;return i(p,{name:r||x,appear:P,onAfterEnter:j,onAfterLeave:G},{default:V})};return b(()=>e.show,n=>{n&&!a&&(w(),t.tabindex===0&&X(()=>{var r;(r=u.value)==null||r.focus()})),!n&&a&&(a=!1,o("close"))}),ie({popupRef:u}),me(u,()=>e.show&&e.lockScroll),ee("popstate",()=>{e.closeOnPopstate&&(f(),s=!1)}),oe(()=>{e.show&&w()}),ne(()=>{s&&(o("update:show",!0),s=!1)}),B(()=>{e.show&&e.teleport&&(f(),s=!0)}),te(ue,()=>e.show),()=>e.teleport?i(ae,{to:e.teleport},{default:()=>[m(),z()]}):i(se,null,[m(),z()])}});const Ae=H(Ce);export{Ae as P};