2 lines
6.8 KiB
JavaScript
2 lines
6.8 KiB
JavaScript
import{_ as t}from"./uv-overlay.6fe03ce8.js";import{Y as e,Z as o,o as s,j as i,m as a,y as n,B as r,G as l,H as p,E as h,w as u,h as d,z as c,a0 as m,Q as f}from"./index-9bec188e.js";import{_ as y}from"./uv-status-bar.6dc37cad.js";import{_ as g}from"./_plugin-vue_export-helper.1b428a4d.js";import{_ as b}from"./uv-icon.27c7246d.js";import{_ as v}from"./uv-transition.b971e856.js";const k=g({name:"uv-safe-bottom",mixins:[e,o],data:()=>({safeAreaBottomHeight:0,isNvue:!1}),computed:{style(){return this.$uv.deepMerge({},this.$uv.addStyle(this.customStyle))}},mounted(){}},[["render",function(t,e,o,l,p,h){const u=r;return s(),i(u,{class:a(["uv-safe-bottom",[!p.isNvue&&"uv-safe-area-inset-bottom"]]),style:n([h.style])},null,8,["style","class"])}],["__scopeId","data-v-e97e85dd"]]);const w=g({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:[e,o],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(e,o,g,w,x,C){const _=l(p("uv-overlay"),t),S=l(p("uv-status-bar"),y),T=l(p("uv-safe-bottom"),k),I=l(p("uv-icon"),b),z=r,P=l(p("uv-transition"),v),B=h("keypress");return x.showPopup?(s(),i(z,{key:0,class:a(["uv-popup",[x.popupClass,C.isDesktop?"fixforpc-z-index":""]]),style:n([{zIndex:g.zIndex}])},{default:u((()=>[d(z,{onTouchstart:C.touchstart},{default:u((()=>[x.maskShow&&g.overlay?(s(),i(_,{key:"1",show:x.showTrans,duration:g.duration,"custom-style":g.overlayStyle,opacity:g.overlayOpacity,zIndex:g.zIndex,onClick:C.onTap},null,8,["show","duration","custom-style","opacity","zIndex","onClick"])):c("",!0),d(P,{key:"2",mode:x.ani,name:"content","custom-style":x.transitionStyle,duration:g.duration,show:x.showTrans,onClick:C.onTap},{default:u((()=>[d(z,{class:a(["uv-popup__content",[x.popupClass]]),style:n([C.contentStyle]),onClick:C.clear},{default:u((()=>[g.safeAreaInsetTop?(s(),i(S,{key:0})):c("",!0),m(e.$slots,"default",{},void 0,!0),g.safeAreaInsetBottom?(s(),i(T,{key:1})):c("",!0),g.closeable?(s(),i(z,{key:2,onClick:f(C.close,["stop"]),class:a(["uv-popup__content__close",["uv-popup__content__close--"+g.closeIconPos]]),"hover-class":"uv-popup__content__close--hover","hover-stay-time":"150"},{default:u((()=>[d(I,{name:"close",color:"#909399",size:"18",bold:""})])),_:1},8,["onClick","class"])):c("",!0)])),_:3},8,["style","class","onClick"])])),_:3},8,["mode","custom-style","duration","show","onClick"])])),_:3},8,["onTouchstart"]),x.maskShow?(s(),i(B,{key:0,onEsc:C.onTap},null,8,["onEsc"])):c("",!0)])),_:3},8,["class","style"])):c("",!0)}],["__scopeId","data-v-c9cfab44"]]);export{w as _};
|