UNPKG

@soei/pop

Version:

Vue组件, 弹出展示框 <Pop dark .../>

2 lines (1 loc) 1.84 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("@soei/util"),r=require("vue");const f=(t,n)=>{const s=t.__vccOpts||t;for(const[o,e]of n)s[o]=e;return s},l={props:{visible:{type:Boolean,default:!1},inset:{type:Array,default:()=>["","","",""]},height:{type:[String,Number],default:"100%"},width:{type:[String,Number],default:"100%"},duration:{type:String,default:"0.3s"},delay:{type:String,default:"0s"}},data(){return{task:[],t:"",r:"",b:"",l:"",offsetcenter:"100%"}},watch:{visible(t){this.change(t)}},mounted(){this.$set||(this.$set=(s,o,e)=>{s[o]=e});let t=i.each(this.$refs.pop.attributes,(s,o,e)=>{if(e.test(o.name))return o.name.match(e)},/^(?:([lr])([bt])|([bt])([lr]))$/)||"tl",n=this.inset;this.offsetcenter=/100%\s*-/.test(this.height)?"100%":i.format("100% / 2 - ({height})",this),i.each(t[0].split(""),(s,o,e,h,c,a)=>{a=i.format(h,+n[s]),/l|r/.test(o)&&(c=i.format(c,e.width),e.task.push({key:o,to:a,from:c}),e.$set(e,o,a))},this,"?{+[0],px,}","calc(0px - (?))"),this.change(this.visible),this.$forceUpdate()},methods:{change(t){i.each(this.task,(n,s,o)=>{this.$set(this,s.key,s[o])},t?"to":"from")}}},u=()=>{r.useCssVars(t=>({"5fcbbb92":t.duration,36864080:t.delay,"766ffc6a":t.offsetcenter,"8c9d9aec":t.height}))},p=l.setup;l.setup=p?(t,n)=>(u(),p(t,n)):u;const _={class:"pop-content"};function g(t,n,s,o,e,h){return r.openBlock(),r.createElementBlock("div",{ref:"pop",class:"pop",style:r.normalizeStyle({top:e.t,right:e.r,bottom:e.b,left:e.l,height:`calc(${s.height})`,width:`calc(${s.width})`})},[r.createElementVNode("div",_,[r.renderSlot(t.$slots,"default",{},void 0,!0)])],4)}const d=f(l,[["render",g],["__scopeId","data-v-d620f79e"]]),m=[d],y={install(t){m.forEach(n=>{t.component("s-"+n.name.toLowerCase(),n)})}};exports.Pop=d;exports.default=y;