Files
yshop-pro-uniapp/unpackage/dist/build/h5/assets/uv-popup.e5d0df45.js
2023-11-14 17:21:03 +08:00

2 lines
7.8 KiB
JavaScript

var t,e;import{_ as o}from"./uv-transition.4f5b62a8.js";import{x as s,y as i,g as n,o as a,c as r,w as l,j as p,p as u,n as h,A as d,d as c,v as m,a as f,m as y}from"./index-3714412c.js";import{r as g}from"./useRouter.f44141c1.js";import{_ as b}from"./_plugin-vue_export-helper.1b428a4d.js";import{_ as v}from"./uv-status-bar.b515a02d.js";import{_ as k}from"./uv-icon.c593f91d.js";const w=b({name:"uv-overlay",emits:["click"],mixins:[s,i,{props:{show:{type:Boolean,default:!1},zIndex:{type:[String,Number],default:10070},duration:{type:[String,Number],default:300},opacity:{type:[String,Number],default:.5},...null==(e=null==(t=uni.$uv)?void 0:t.props)?void 0:e.overlay}}],watch:{show(t){document.querySelector("body").style.overflow=t?"hidden":""}},computed:{overlayStyle(){const t={position:"fixed",top:0,left:0,right:0,zIndex:this.zIndex,bottom:0,"background-color":`rgba(0, 0, 0, ${this.opacity})`};return this.$uv.deepMerge(t,this.$uv.addStyle(this.customStyle))}},methods:{clickHandler(){this.$emit("click")},clear(){}}},[["render",function(t,e,s,i,h,d){const c=g(n("uv-transition"),o);return a(),r(c,{show:t.show,mode:"fade","custom-class":"uv-overlay",duration:t.duration,"custom-style":d.overlayStyle,onClick:d.clickHandler,onTouchmove:u(d.clear,["stop","prevent"])},{default:l((()=>[p(t.$slots,"default",{},void 0,!0)])),_:3},8,["show","duration","custom-style","onClick","onTouchmove"])}],["__scopeId","data-v-0c47b2a6"]]);const x=b({name:"uv-safe-bottom",mixins:[s,i],data:()=>({safeAreaBottomHeight:0,isNvue:!1}),computed:{style(){return this.$uv.deepMerge({},this.$uv.addStyle(this.customStyle))}},mounted(){}},[["render",function(t,e,o,s,i,n){const l=c;return a(),r(l,{class:h(["uv-safe-bottom",[!i.isNvue&&"uv-safe-area-inset-bottom"]]),style:d([n.style])},null,8,["style","class"])}],["__scopeId","data-v-e97e85dd"]]);const C=b({name:"uv-popup",components:{keypress:{name:"Keypress",props:{disable:{type:Boolean,default:!1}},mounted(){const t={esc:["Esc","Escape"],tab:"Tab",enter:"Enter",space:[" ","Spacebar"],up:["Up","ArrowUp"],left:["Left","ArrowLeft"],right:["Right","ArrowRight"],down:["Down","ArrowDown"],delete:["Backspace","Delete","Del"]};document.addEventListener("keyup",(e=>{if(this.disable)return;const o=Object.keys(t).find((o=>{const s=e.key,i=t[o];return i===s||Array.isArray(i)&&i.includes(s)}));o&&setTimeout((()=>{this.$emit(o,{})}),0)}))},render:()=>{}}},mixins:[s,i],emits:["change","maskClick"],props:{mode:{type:String,default:"center"},duration:{type:[String,Number],default:300},zIndex:{type:[String,Number],default:10075},bgColor:{type:String,default:"#ffffff"},safeArea:{type:Boolean,default:!0},overlay:{type:Boolean,default:!0},closeOnClickOverlay:{type:Boolean,default:!0},overlayOpacity:{type:[Number,String],default:.4},overlayStyle:{type:[Object,String],default:""},safeAreaInsetBottom:{type:Boolean,default:!0},safeAreaInsetTop:{type:Boolean,default:!1},closeable:{type:Boolean,default:!1},closeIconPos:{type:String,default:"top-right"},zoom:{type:Boolean,default:!0},round:{type:[Number,String],default:0}},watch:{type:{handler:function(t){this.config[t]&&this[this.config[t]](!0)},immediate:!0},isDesktop:{handler:function(t){this.config[t]&&this[this.config[this.mode]](!0)},immediate:!0},showPopup(t){document.getElementsByTagName("body")[0].style.overflow=t?"hidden":"visible"}},data(){return{ani:[],showPopup:!1,showTrans:!1,popupWidth:0,popupHeight:0,config:{top:"top",bottom:"bottom",center:"center",left:"left",right:"right",message:"top",dialog:"center",share:"bottom"},transitionStyle:{position:"fixed",left:0,right:0},maskShow:!0,mkclick:!0,popupClass:this.isDesktop?"fixforpc-top":"top"}},computed:{isDesktop(){return this.popupWidth>=500&&this.popupHeight>=500},bg(){return""===this.bgColor||"none"===this.bgColor||this.$uv.getPx(this.round)>0?"transparent":this.bgColor},contentStyle(){const t={};if(this.bgColor&&(t.backgroundColor=this.bg),this.round){const e=this.$uv.addUnit(this.round);t.backgroundColor=this.bgColor,"top"===this.mode?(t.borderBottomLeftRadius=e,t.borderBottomRightRadius=e):"bottom"===this.mode?(t.borderTopLeftRadius=e,t.borderTopRightRadius=e):"center"===this.mode&&(t.borderRadius=e)}return this.$uv.deepMerge(t,this.$uv.addStyle(this.customStyle))}},unmounted(){this.setH5Visible()},created(){this.messageChild=null,this.clearPropagation=!1},methods:{setH5Visible(){document.getElementsByTagName("body")[0].style.overflow="visible"},closeMask(){this.maskShow=!1},clear(t){t.stopPropagation(),this.clearPropagation=!0},open(t){if(this.showPopup)return;if(t&&-1!==["top","center","bottom","left","right","message","dialog","share"].indexOf(t)||(t=this.mode),!this.config[t])return this.$uv.error(`缺少类型:${t}`);this[this.config[t]](),this.$emit("change",{show:!0,type:t})},close(t){this.showTrans=!1,this.$emit("change",{show:!1,type:this.mode}),clearTimeout(this.timer),this.timer=setTimeout((()=>{this.showPopup=!1}),300)},touchstart(){this.clearPropagation=!1},onTap(){this.clearPropagation?this.clearPropagation=!1:(this.$emit("maskClick"),this.closeOnClickOverlay&&this.close())},top(t){this.popupClass=this.isDesktop?"fixforpc-top":"top",this.ani=["slide-top"],this.transitionStyle={position:"fixed",zIndex:this.zIndex,left:0,right:0,backgroundColor:this.bg},t||(this.showPopup=!0,this.showTrans=!0,this.$nextTick((()=>{this.messageChild&&"message"===this.mode&&this.messageChild.timerClose()})))},bottom(t){this.popupClass="bottom",this.ani=["slide-bottom"],this.transitionStyle={position:"fixed",zIndex:this.zIndex,left:0,right:0,bottom:0,backgroundColor:this.bg},t||(this.showPopup=!0,this.showTrans=!0)},center(t){this.popupClass="center",this.ani=this.zoom?["zoom-in","fade"]:["fade"],this.transitionStyle={position:"fixed",zIndex:this.zIndex,display:"flex",flexDirection:"column",bottom:0,left:0,right:0,top:0,justifyContent:"center",alignItems:"center"},t||(this.showPopup=!0,this.showTrans=!0)},left(t){this.popupClass="left",this.ani=["slide-left"],this.transitionStyle={position:"fixed",zIndex:this.zIndex,left:0,bottom:0,top:0,backgroundColor:this.bg,display:"flex",flexDirection:"column"},t||(this.showPopup=!0,this.showTrans=!0)},right(t){this.popupClass="right",this.ani=["slide-right"],this.transitionStyle={position:"fixed",zIndex:this.zIndex,bottom:0,right:0,top:0,backgroundColor:this.bg,display:"flex",flexDirection:"column"},t||(this.showPopup=!0,this.showTrans=!0)}}},[["render",function(t,e,s,i,b,C){const S=g(n("uv-overlay"),w),_=g(n("uv-status-bar"),v),I=g(n("uv-safe-bottom"),x),T=g(n("uv-icon"),k),z=c,$=g(n("uv-transition"),o),P=m("keypress");return b.showPopup?(a(),r(z,{key:0,class:h(["uv-popup",[b.popupClass,C.isDesktop?"fixforpc-z-index":""]]),style:d([{zIndex:s.zIndex}])},{default:l((()=>[f(z,{onTouchstart:C.touchstart},{default:l((()=>[b.maskShow&&s.overlay?(a(),r(S,{key:"1",show:b.showTrans,duration:s.duration,"custom-style":s.overlayStyle,opacity:s.overlayOpacity,zIndex:s.zIndex,onClick:C.onTap},null,8,["show","duration","custom-style","opacity","zIndex","onClick"])):y("",!0),f($,{key:"2",mode:b.ani,name:"content","custom-style":b.transitionStyle,duration:s.duration,show:b.showTrans,onClick:C.onTap},{default:l((()=>[f(z,{class:h(["uv-popup__content",[b.popupClass]]),style:d([C.contentStyle]),onClick:C.clear},{default:l((()=>[s.safeAreaInsetTop?(a(),r(_,{key:0})):y("",!0),p(t.$slots,"default",{},void 0,!0),s.safeAreaInsetBottom?(a(),r(I,{key:1})):y("",!0),s.closeable?(a(),r(z,{key:2,onClick:u(C.close,["stop"]),class:h(["uv-popup__content__close",["uv-popup__content__close--"+s.closeIconPos]]),"hover-class":"uv-popup__content__close--hover","hover-stay-time":"150"},{default:l((()=>[f(T,{name:"close",color:"#909399",size:"18",bold:""})])),_:1},8,["onClick","class"])):y("",!0)])),_:3},8,["style","class","onClick"])])),_:3},8,["mode","custom-style","duration","show","onClick"])])),_:3},8,["onTouchstart"]),b.maskShow?(a(),r(P,{key:0,onEsc:C.onTap},null,8,["onEsc"])):y("",!0)])),_:3},8,["class","style"])):y("",!0)}],["__scopeId","data-v-c9cfab44"]]);export{C as _};