u-popup.js
3.3 KB
"use strict";const e=require("./props.js"),t=require("../../libs/mixin/mpMixin.js"),o=require("../../libs/mixin/mixin.js"),i=require("../../libs/function/index.js"),s=require("../../../../common/vendor.js"),n={name:"u-popup",mixins:[t.mpMixin,o.mixin,e.props],data(){return{overlayDuration:this.duration+50}},watch:{show(e,t){if(!0===e){const e=this.$children;this.retryComputedComponentRect(e)}}},computed:{transitionStyle(){const e={zIndex:this.zIndex,position:"fixed",display:"flex"};return e[this.mode]=0,"left"===this.mode||"right"===this.mode?i.deepMerge(e,{bottom:0,top:0}):"top"===this.mode||"bottom"===this.mode?i.deepMerge(e,{left:0,right:0}):"center"===this.mode?i.deepMerge(e,{alignItems:"center","justify-content":"center",top:0,left:0,right:0,bottom:0}):void 0},contentStyle(){const e={};if(i.sys(),"center"!==this.mode&&(e.flex=1),this.bgColor&&(e.backgroundColor=this.bgColor),this.round){const t=i.addUnit(this.round);"top"===this.mode?(e.borderBottomLeftRadius=t,e.borderBottomRightRadius=t):"bottom"===this.mode?(e.borderTopLeftRadius=t,e.borderTopRightRadius=t):"center"===this.mode&&(e.borderRadius=t)}return i.deepMerge(e,i.addStyle(this.customStyle))},position(){return"center"===this.mode?this.zoom?"fade-zoom":"fade":"left"===this.mode?"slide-left":"right"===this.mode?"slide-right":"bottom"===this.mode?"slide-up":"top"===this.mode?"slide-down":void 0}},emits:["open","close","click","update:show"],methods:{overlayClick(){this.closeOnClickOverlay&&(this.$emit("update:show",!1),this.$emit("close"))},close(e){this.$emit("update:show",!1),this.$emit("close")},afterEnter(){this.$emit("open")},clickHandler(){"center"===this.mode&&this.overlayClick(),this.$emit("click")},retryComputedComponentRect(e){const t=["u-calendar-month","u-album","u-collapse-item","u-dropdown","u-index-item","u-index-list","u-line-progress","u-list-item","u-rate","u-read-more","u-row","u-row-notice","u-scroll-list","u-skeleton","u-slider","u-steps-item","u-sticky","u-subsection","u-swipe-action-item","u-tabbar","u-tabs","u-tooltip"];for(let o=0;o<e.length;o++){const s=e[o],n=s.$children;t.includes(s.$options.name)&&"function"==typeof(null==s?void 0:s.init)&&i.sleep(50).then((()=>{s.init()})),n.length&&this.retryComputedComponentRect(n)}}}};if(!Array){(s.resolveComponent("u-overlay")+s.resolveComponent("u-status-bar")+s.resolveComponent("u-icon")+s.resolveComponent("u-safe-bottom")+s.resolveComponent("u-transition"))()}Math||((()=>"../u-overlay/u-overlay.js")+(()=>"../u-status-bar/u-status-bar.js")+(()=>"../u-icon/u-icon.js")+(()=>"../u-safe-bottom/u-safe-bottom.js")+(()=>"../u-transition/u-transition.js"))();const r=s._export_sfc(n,[["render",function(e,t,o,i,n,r){return s.e({a:e.overlay},e.overlay?{b:s.o(r.overlayClick),c:s.p({show:e.show,zIndex:e.zIndex,duration:n.overlayDuration,customStyle:e.overlayStyle,opacity:e.overlayOpacity})}:{},{d:e.safeAreaInsetTop},(e.safeAreaInsetTop,{}),{e:e.closeable},e.closeable?{f:s.p({name:"close",color:"#909399",size:"18",bold:!0}),g:s.o(((...e)=>r.close&&r.close(...e))),h:s.n("u-popup__content__close--"+e.closeIconPos)}:{},{i:e.safeAreaInsetBottom},(e.safeAreaInsetBottom,{}),{j:s.s(r.contentStyle),k:s.o(((...t)=>e.noop&&e.noop(...t))),l:s.o(r.afterEnter),m:s.o(r.clickHandler),n:s.p({show:e.show,customStyle:r.transitionStyle,mode:r.position,duration:e.duration}),o:s.n(e.customClass)})}],["__scopeId","data-v-3b5c92af"]]);wx.createComponent(r);