acdr-ui/dist/build/mp-weixin/node-modules/wot-design-uni/components/wd-popup/wd-popup.js

2 lines
3.4 KiB
JavaScript

"use strict";var e=Object.defineProperty,t=Object.defineProperties,a=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,r=(t,a,o)=>a in t?e(t,a,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[a]=o;const i=require("../../../../common/vendor.js");if(!Array){(i.resolveComponent("wd-overlay")+i.resolveComponent("wd-icon"))()}Math||((()=>"../wd-overlay/wd-overlay.js")+(()=>"../wd-icon/wd-icon.js"))();const s=i.defineComponent((u=((e,t)=>{for(var a in t||(t={}))n.call(t,a)&&r(e,a,t[a]);if(o)for(var a of o(t))l.call(t,a)&&r(e,a,t[a]);return e})({},{name:"wd-popup",options:{virtualHost:!0,addGlobalClass:!0,styleIsolation:"shared"}}),c={props:i.popupProps,emits:["update:modelValue","before-enter","enter","before-leave","leave","after-leave","after-enter","click-modal","close"],setup(e,{emit:t}){const a=e,o=t,n=e=>e?{enter:`wd-${e}-enter wd-${e}-enter-active`,"enter-to":`wd-${e}-enter-to wd-${e}-enter-active`,leave:`wd-${e}-leave wd-${e}-leave-active`,"leave-to":`wd-${e}-leave-to wd-${e}-leave-active`}:{enter:"enter-class enter-active-class","enter-to":"enter-to-class enter-active-class",leave:"leave-class leave-active-class","leave-to":"leave-to-class leave-active-class"},l=i.ref(!1),r=i.ref(!1),s=i.ref(""),u=i.ref(!1),c=i.ref(300),v=i.ref(""),d=i.ref(0),p=i.ref(""),m=i.computed((()=>`z-index: ${a.zIndex}; padding-bottom: ${d.value}px; -webkit-transition-duration: ${c.value}ms; transition-duration: ${c.value}ms; ${r.value||!a.hideWhenClose?"":"display: none;"} ${a.customStyle}`)),f=i.computed((()=>`wd-popup wd-popup--${a.position} ${a.customClass||""} ${v.value||""}`));function w(){const e=n(a.transition||a.position),t="none"===a.transition?0:i.isObj(a.duration)?a.duration.enter:a.duration;s.value="enter",o("before-enter"),i.requestAnimationFrame((()=>{o("enter"),v.value=e.enter,c.value=t,i.requestAnimationFrame((()=>{l.value=!0,r.value=!0,i.requestAnimationFrame((()=>{u.value=!1,v.value=e["enter-to"]}))}))}))}function b(){u.value||(u.value=!0,"leave"===s.value?o("after-leave"):"enter"===s.value&&o("after-enter"),!a.modelValue&&r.value&&(r.value=!1))}function y(){const{transition:e,position:t}=a;p.value=e||t}function $(){o("click-modal"),a.closeOnClickModal&&j()}function j(){o("close"),o("update:modelValue",!1)}function O(){}return i.onBeforeMount((()=>{if(y(),a.safeAreaInsetBottom){const{safeArea:e,screenHeight:t,safeAreaInsets:a}=i.index.getSystemInfoSync();d.value=e?t-(e.bottom||0):0}a.modelValue&&w()})),i.watch((()=>a.modelValue),(e=>{e?w():function(){if(!r.value)return;const e=n(a.transition||a.position),t="none"===a.transition?0:i.isObj(a.duration)?a.duration.leave:a.duration;s.value="leave",o("before-leave"),i.requestAnimationFrame((()=>{o("leave"),v.value=e.leave,c.value=t,i.requestAnimationFrame((()=>{u.value=!1;const t=setTimeout((()=>{b(),clearTimeout(t)}),c.value);v.value=e["leave-to"]}))}))}()}),{deep:!0,immediate:!0}),i.watch([()=>a.position,()=>a.transition],(()=>{y()}),{deep:!0,immediate:!0}),(e,t)=>i.e({a:e.modal},e.modal?{b:i.o($),c:i.o(O),d:i.p({show:e.modelValue,"z-index":e.zIndex,"lock-scroll":e.lockScroll,duration:e.duration,"custom-style":e.modalStyle})}:{},{e:!e.lazyRender||l.value},!e.lazyRender||l.value?i.e({f:e.closable},e.closable?{g:i.o(j),h:i.p({"custom-class":"wd-popup__close",name:"add"})}:{},{i:i.n(f.value),j:i.s(m.value),k:i.o(b)}):{})}},t(u,a(c))));var u,c;const v=i._export_sfc(s,[["__scopeId","data-v-22422fc7"]]);wx.createComponent(v);