vue-popup-plus 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vue-popup-plus.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var a=document.createElement("style");a.appendChild(document.createTextNode(".vue-popup-plus-animation{animation-timing-function:linear;animation-duration:var(--v6e614cc2)}.popup-frame[data-v-5a4614b0]{display:flex;flex-direction:column;position:fixed;inset:0;pointer-events:none}.popup-mask[data-v-c4c8c95e]{position:fixed;inset:0;background-color:var(--popup-color-mask)}.popup-mask.is-blur[data-v-c4c8c95e]{-webkit-backdrop-filter:blur(15px) saturate(180%);backdrop-filter:blur(15px) saturate(180%)}.popup-view[data-v-bbc1055f]{position:relative;pointer-events:auto}.vue-popup-plus-animation-enter-fade{animation-name:vue-popup-plus-animation-enter-fade}.vue-popup-plus-animation-leave-fade{animation-name:vue-popup-plus-animation-leave-fade}.vue-popup-plus-animation-enter-scale-enlarge{animation-name:vue-popup-plus-animation-enter-scale-enlarge}.vue-popup-plus-animation-leave-scale-enlarge{animation-name:vue-popup-plus-animation-leave-scale-enlarge}.vue-popup-plus-animation-enter-scale-reduce{animation-name:vue-popup-plus-animation-enter-scale-reduce}.vue-popup-plus-animation-leave-scale-reduce{animation-name:vue-popup-plus-animation-leave-scale-reduce}.vue-popup-plus-animation-enter-fly-top{animation-name:vue-popup-plus-animation-enter-fly-top}.vue-popup-plus-animation-leave-fly-top{animation-name:vue-popup-plus-animation-leave-fly-top}.vue-popup-plus-animation-enter-fly-left{animation-name:vue-popup-plus-animation-enter-fly-left}.vue-popup-plus-animation-leave-fly-left{animation-name:vue-popup-plus-animation-leave-fly-left}.vue-popup-plus-animation-enter-fly-right{animation-name:vue-popup-plus-animation-enter-fly-right}.vue-popup-plus-animation-leave-fly-right{animation-name:vue-popup-plus-animation-leave-fly-right}.vue-popup-plus-animation-enter-fly-bottom{animation-name:vue-popup-plus-animation-enter-fly-bottom}.vue-popup-plus-animation-leave-fly-bottom{animation-name:vue-popup-plus-animation-leave-fly-bottom}@-moz-keyframes vue-popup-plus-animation-enter-fade{0%{opacity:0}to{opacity:1}}@-webkit-keyframes vue-popup-plus-animation-enter-fade{0%{opacity:0}to{opacity:1}}@-o-keyframes vue-popup-plus-animation-enter-fade{0%{opacity:0}to{opacity:1}}@keyframes vue-popup-plus-animation-enter-fade{0%{opacity:0}to{opacity:1}}@-moz-keyframes vue-popup-plus-animation-leave-fade{0%{opacity:1}to{opacity:0}}@-webkit-keyframes vue-popup-plus-animation-leave-fade{0%{opacity:1}to{opacity:0}}@-o-keyframes vue-popup-plus-animation-leave-fade{0%{opacity:1}to{opacity:0}}@keyframes vue-popup-plus-animation-leave-fade{0%{opacity:1}to{opacity:0}}@-moz-keyframes vue-popup-plus-animation-enter-scale-enlarge{0%{transform:scale(0)}to{transform:scale(1)}}@-webkit-keyframes vue-popup-plus-animation-enter-scale-enlarge{0%{transform:scale(0)}to{transform:scale(1)}}@-o-keyframes vue-popup-plus-animation-enter-scale-enlarge{0%{transform:scale(0)}to{transform:scale(1)}}@keyframes vue-popup-plus-animation-enter-scale-enlarge{0%{transform:scale(0)}to{transform:scale(1)}}@-moz-keyframes vue-popup-plus-animation-leave-scale-enlarge{0%{transform:scale(1)}to{transform:scale(0)}}@-webkit-keyframes vue-popup-plus-animation-leave-scale-enlarge{0%{transform:scale(1)}to{transform:scale(0)}}@-o-keyframes vue-popup-plus-animation-leave-scale-enlarge{0%{transform:scale(1)}to{transform:scale(0)}}@keyframes vue-popup-plus-animation-leave-scale-enlarge{0%{transform:scale(1)}to{transform:scale(0)}}@-moz-keyframes vue-popup-plus-animation-enter-scale-reduce{0%{transform:scale(5)}to{transform:scale(1)}}@-webkit-keyframes vue-popup-plus-animation-enter-scale-reduce{0%{transform:scale(5)}to{transform:scale(1)}}@-o-keyframes vue-popup-plus-animation-enter-scale-reduce{0%{transform:scale(5)}to{transform:scale(1)}}@keyframes vue-popup-plus-animation-enter-scale-reduce{0%{transform:scale(5)}to{transform:scale(1)}}@-moz-keyframes vue-popup-plus-animation-leave-scale-reduce{0%{transform:scale(1)}to{transform:scale(5)}}@-webkit-keyframes vue-popup-plus-animation-leave-scale-reduce{0%{transform:scale(1)}to{transform:scale(5)}}@-o-keyframes vue-popup-plus-animation-leave-scale-reduce{0%{transform:scale(1)}to{transform:scale(5)}}@keyframes vue-popup-plus-animation-leave-scale-reduce{0%{transform:scale(1)}to{transform:scale(5)}}@-moz-keyframes vue-popup-plus-animation-enter-fly-top{0%{transform:translateY(-100vh)}to{transform:translateY(0)}}@-webkit-keyframes vue-popup-plus-animation-enter-fly-top{0%{transform:translateY(-100vh)}to{transform:translateY(0)}}@-o-keyframes vue-popup-plus-animation-enter-fly-top{0%{transform:translateY(-100vh)}to{transform:translateY(0)}}@keyframes vue-popup-plus-animation-enter-fly-top{0%{transform:translateY(-100vh)}to{transform:translateY(0)}}@-moz-keyframes vue-popup-plus-animation-leave-fly-top{0%{transform:translateY(0)}to{transform:translateY(-100vh)}}@-webkit-keyframes vue-popup-plus-animation-leave-fly-top{0%{transform:translateY(0)}to{transform:translateY(-100vh)}}@-o-keyframes vue-popup-plus-animation-leave-fly-top{0%{transform:translateY(0)}to{transform:translateY(-100vh)}}@keyframes vue-popup-plus-animation-leave-fly-top{0%{transform:translateY(0)}to{transform:translateY(-100vh)}}@-moz-keyframes vue-popup-plus-animation-enter-fly-left{0%{transform:translate(-100vw)}to{transform:translate(0)}}@-webkit-keyframes vue-popup-plus-animation-enter-fly-left{0%{transform:translate(-100vw)}to{transform:translate(0)}}@-o-keyframes vue-popup-plus-animation-enter-fly-left{0%{transform:translate(-100vw)}to{transform:translate(0)}}@keyframes vue-popup-plus-animation-enter-fly-left{0%{transform:translate(-100vw)}to{transform:translate(0)}}@-moz-keyframes vue-popup-plus-animation-leave-fly-left{0%{transform:translate(0)}to{transform:translate(-100vw)}}@-webkit-keyframes vue-popup-plus-animation-leave-fly-left{0%{transform:translate(0)}to{transform:translate(-100vw)}}@-o-keyframes vue-popup-plus-animation-leave-fly-left{0%{transform:translate(0)}to{transform:translate(-100vw)}}@keyframes vue-popup-plus-animation-leave-fly-left{0%{transform:translate(0)}to{transform:translate(-100vw)}}@-moz-keyframes vue-popup-plus-animation-enter-fly-right{0%{transform:translate(100vw)}to{transform:translate(0)}}@-webkit-keyframes vue-popup-plus-animation-enter-fly-right{0%{transform:translate(100vw)}to{transform:translate(0)}}@-o-keyframes vue-popup-plus-animation-enter-fly-right{0%{transform:translate(100vw)}to{transform:translate(0)}}@keyframes vue-popup-plus-animation-enter-fly-right{0%{transform:translate(100vw)}to{transform:translate(0)}}@-moz-keyframes vue-popup-plus-animation-leave-fly-right{0%{transform:translate(0)}to{transform:translate(100vw)}}@-webkit-keyframes vue-popup-plus-animation-leave-fly-right{0%{transform:translate(0)}to{transform:translate(100vw)}}@-o-keyframes vue-popup-plus-animation-leave-fly-right{0%{transform:translate(0)}to{transform:translate(100vw)}}@keyframes vue-popup-plus-animation-leave-fly-right{0%{transform:translate(0)}to{transform:translate(100vw)}}@-moz-keyframes vue-popup-plus-animation-enter-fly-bottom{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@-webkit-keyframes vue-popup-plus-animation-enter-fly-bottom{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@-o-keyframes vue-popup-plus-animation-enter-fly-bottom{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes vue-popup-plus-animation-enter-fly-bottom{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@-moz-keyframes vue-popup-plus-animation-leave-fly-bottom{0%{transform:translateY(0)}to{transform:translateY(100vh)}}@-webkit-keyframes vue-popup-plus-animation-leave-fly-bottom{0%{transform:translateY(0)}to{transform:translateY(100vh)}}@-o-keyframes vue-popup-plus-animation-leave-fly-bottom{0%{transform:translateY(0)}to{transform:translateY(100vh)}}@keyframes vue-popup-plus-animation-leave-fly-bottom{0%{transform:translateY(0)}to{transform:translateY(100vh)}}:root{--popup-color-mask: rgba(0,0,0,.45);--popup-color-mask-dark-lite: rgba(0,0,0,.45);--popup-color-mask-dark: rgba(0,0,0,.45);--popup-color-mask-dark-most: rgba(0,0,0,.45);--popup-color-mask-light-lite: rgba(26,26,26,.45);--popup-color-mask-light: rgba(64,64,64,.45);--popup-color-mask-light-most: rgba(153,153,153,.45)}.dark{--popup-color-mask: rgba(75,75,75,.45);--popup-color-mask-dark-lite: rgba(68,68,68,.45);--popup-color-mask-dark: rgba(56,56,56,.45);--popup-color-mask-dark-most: rgba(30,30,30,.45);--popup-color-mask-light-lite: rgba(93,93,93,.45);--popup-color-mask-light: rgba(120,120,120,.45);--popup-color-mask-light-most: rgba(183,183,183,.45)}")),document.head.appendChild(a)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
-
(function(u,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],n):(u=typeof globalThis<"u"?globalThis:u||self,n(u.VuePopupPlus={},u.Vue))})(this,(function(u,n){"use strict";function b(o){const e=Object.prototype.toString.call(o).match(/\s+(\w+)/);return e?e[1]:"Null"}function M(o=0){return new Promise(e=>{window.setTimeout(e,o)})}const T="vue-popup-plus",C={INSTANCE_ID:Symbol(`${T}-instance-id`),COMPUTED_VIEW_STYLE:Symbol(`${T}-computed-view-style`)},P={CORE:Symbol(`${T}-core`),INSTANCE_STORE:Symbol(`${T}-instance-store`)},B="http://vue-popup-plus.styzy.cn",O=n.defineComponent({name:"PopupAnimation",__name:"PopupAnimation",props:{type:{},duration:{}},setup(o){n.useCssVars(l=>({v6e614cc2:a.value}));const e=n.inject(P.INSTANCE_STORE),r=n.ref(!1),t=n.computed(()=>`vue-popup-plus-animation vue-popup-plus-animation-enter-${o.type}`),s=n.computed(()=>`vue-popup-plus-animation vue-popup-plus-animation-leave-${o.type}`),a=n.computed(()=>`${o.duration}ms`);return n.onMounted(()=>{r.value=!0}),(l,h)=>(n.openBlock(),n.createBlock(n.Transition,{"enter-active-class":t.value,"leave-active-class":s.value},{default:n.withCtx(()=>[r.value&&!n.unref(e).isBeforeUnmount.value?n.renderSlot(l.$slots,"default",{key:0,style:n.normalizeStyle({animationDuration:`${o.duration}ms`})}):n.createCommentVNode("",!0)]),_:3},8,["enter-active-class","leave-active-class"]))}}),L=n.defineComponent({name:"PopupFrame",__name:"PopupFrame",props:{placement:{},zIndex:{}},setup(o){const e=n.computed(()=>({alignItems:o.placement.includes("left")?"flex-start":o.placement.includes("right")?"flex-end":"center",justifyContent:o.placement.includes("top")?"flex-start":o.placement.includes("bottom")?"flex-end":"center",zIndex:o.zIndex}));return(r,t)=>(n.openBlock(),n.createElementBlock("div",{class:"popup-frame",style:n.normalizeStyle(e.value)},[n.renderSlot(r.$slots,"default",{},void 0,!0)],4))}}),x=(o,e)=>{const r=o.__vccOpts||o;for(const[t,s]of e)r[t]=s;return r},W=x(L,[["__scopeId","data-v-5a4614b0"]]),F=x(n.defineComponent({name:"PopupMask",__name:"PopupMask",setup(o){const e=n.inject(C.INSTANCE_ID),r=n.inject(P.INSTANCE_STORE);function t(){r.maskClickClose&&V().destroy(e)}return(s,a)=>(n.openBlock(),n.createElementBlock("div",{class:n.normalizeClass(["popup-mask",{"is-blur":n.unref(r).maskBlur.value}]),style:n.normalizeStyle({zIndex:n.unref(r).zIndex.value}),onClick:t},null,6))}}),[["__scopeId","data-v-c4c8c95e"]]),U=x(n.defineComponent({name:"PopupView",__name:"PopupView",setup(o){const e=n.ref(),r=n.inject(C.INSTANCE_ID),t=n.inject(P.INSTANCE_STORE),s=n.ref(0),a=n.ref(0),l=n.computed(()=>typeof t.component=="function"?n.defineAsyncComponent(t.component):t.component),h=n.computed(()=>{const p=Math.ceil(window.innerWidth-s.value);return t.placement.value.includes("left")?[0,p]:t.placement.value.includes("right")?[-p,0]:[-(p/2),p/2]}),g=n.computed(()=>{const p=Math.ceil(window.innerHeight-a.value);return t.placement.value.includes("top")?[0,p]:t.placement.value.includes("bottom")?[-p,0]:[-(p/2),p/2]}),y=n.computed(()=>t.viewTranslateOverflow.value?t.viewTranslateX.value:Math.max(Math.min(t.viewTranslateX.value,h.value[1]),h.value[0])),I=n.computed(()=>t.viewTranslateOverflow.value?t.viewTranslateY.value:Math.max(Math.min(t.viewTranslateY.value,g.value[1]),g.value[0])),ce=n.computed(()=>({width:w(t.width.value),maxWidth:w(t.maxWidth.value),minWidth:w(t.minWidth.value),height:w(t.height.value),maxHeight:w(t.maxHeight.value),minHeight:w(t.minHeight.value),transform:`translate(${y.value}px, ${I.value}px)`})),le=n.computed(()=>({width:s.value,height:a.value,zIndex:t.zIndex.value,translateX:y.value,translateY:I.value}));n.provide(C.COMPUTED_VIEW_STYLE,le),n.onMounted(()=>{window.setTimeout(A,t.animationDuration.value)}),n.onUpdated(()=>{A()});async function A(){await n.nextTick();const p=e.value?.getBoundingClientRect();p&&(s.value=p.width,a.value=p.height)}function w(p){return typeof p=="number"?`${p}px`:p}return(p,me)=>(n.openBlock(),n.createElementBlock("div",{class:"popup-view",style:n.normalizeStyle(ce.value),ref_key:"popupViewRef",ref:e},[(n.openBlock(),n.createBlock(n.resolveDynamicComponent(l.value),n.mergeProps({key:`${n.unref(r).name}-component`},n.unref(t).componentProps),null,16))],4))}}),[["__scopeId","data-v-bbc1055f"]]),z={class:"popup-instance"},$=n.defineComponent({name:"PopupInstance",__name:"PopupInstance",props:{store:{}},setup(o){return n.provide(C.INSTANCE_ID,o.store.id),n.provide(P.INSTANCE_STORE,o.store),(e,r)=>(n.openBlock(),n.createBlock(n.Teleport,{to:o.store.appendTo},[n.createElementVNode("div",z,[o.store.mask?(n.openBlock(),n.createBlock(O,{key:0,duration:o.store.animationDuration.value,type:o.store.maskAnimation.value},{default:n.withCtx(()=>[n.createVNode(F)]),_:1},8,["duration","type"])):n.createCommentVNode("",!0),n.createVNode(W,{placement:o.store.placement.value,zIndex:o.store.zIndex.value},{default:n.withCtx(()=>[n.createVNode(O,{duration:o.store.animationDuration.value,type:o.store.viewAnimation.value},{default:n.withCtx(()=>[n.createVNode(U)]),_:1},8,["duration","type"])]),_:1},8,["placement","zIndex"])])],8,["to"]))}}),j=(o,{component:e,componentProps:r,onMounted:t,onUnmounted:s,appendTo:a,mask:l,maskClickClose:h,disableScroll:g,...y})=>({id:o,parentElement:Y(a),appendTo:a,mask:l,maskClickClose:h,disableScroll:g,component:e,componentProps:r,onMounted:t,onUnmounted:s,isBeforeUnmount:n.ref(!1),...n.toRefs(n.reactive(y))});function Y(o){return typeof o=="string"&&(o=document.querySelector(o)||document.body),o}class H{_seed;get seed(){return this._seed}get name(){return`vue-popup-plus-instance-${this.seed}`}constructor(e){this._seed=e}}var k=(o=>(o.ROOT_COMPONENT="RootComponent",o.APP="App",o.VNODE="VNode",o))(k||{});class q{#n;_id;_store;renderType;#e;#o;#t;get id(){return this._id}get store(){return this._store}constructor(e,r){this.#n=e,this._id=new H(e.seed),this._store=j(this._id,r),this.renderType=e.isRootComponentRegistered?"RootComponent":e.config.debugMode?"App":"VNode"}mount(){return this.renderType==="App"?(this.#t=document.createElement("div"),this.#e=n.createApp($,{store:this._store}),this.#e._context.components=this.#n.app._context.components,this.#e._context.provides=this.#n.app._context.provides,this.#e._context.config=this.#n.app._context.config,this.#e._context.directives=this.#n.app._context.directives,this.#e._context.mixins=this.#n.app._context.mixins,this.#e.mount(this.#t),this._store.parentElement.appendChild(this.#t)):this.renderType==="VNode"&&(this.#t=document.createElement("div"),this.#o=n.createVNode($,{store:this._store}),this.#o.appContext=this.#n.app._context,this.#o.appContext.components.Popup=$,n.render(this.#o,this.#t),this._store.parentElement.appendChild(this.#t)),this.#n.addInstance(this),this._store.onMounted(),this.id}async unmount(e){this._store.isBeforeUnmount.value=!0,await M(this._store.animationDuration.value),this.renderType==="App"?(this.#e.unmount(),this._store.parentElement.removeChild(this.#t)):this.renderType==="VNode"&&(n.render(null,this.#t),this._store.parentElement.removeChild(this.#t)),this.#n.removeInstance(this),this._store.onUnmounted(e)}update(e){for(const r in e){const t=r,s=e[t]===void 0?this._store[t].value:e[t];this._store[t].value=s}}}class G{get NONE(){return"none"}get FADE(){return"fade"}get SCALE_ENLARGE(){return"scale-enlarge"}get SCALE_REDUCE(){return"scale-reduce"}get FLY_TOP(){return"fly-top"}get FLY_LEFT(){return"fly-left"}get FLY_RIGHT(){return"fly-right"}get FLY_BOTTOM(){return"fly-bottom"}constructor(){}}const _=new G,E="1.5.0",i={Success:"success",Info:"info",Warning:"warning",Error:"error"},c={Default:"default",Data:"data"};class m{namespace="VuePopupPlus";type;caller;message;group;get hasCaller(){return!!this.caller}get hasGroup(){return!!this.group.length}constructor({type:e=i.Info,caller:r="",message:t="",group:s=[]}={}){this.type=e,this.caller=r,this.message=t,this.group=s,this.group.unshift({type:c.Default,message:`核心版本: ${E}`}),this.hasCaller&&this.group.unshift({type:c.Default,message:`调用者: ${this.caller}`})}}const d=o=>{const e=R();e?.config.debugMode&&e.config.logHandler(o)},D=o=>{const e=S({printer:console.groupCollapsed,type:o.type,hasPrefix:!0}),r=S({printer:console.log,type:o.type,isGroupContent:!0}),t=S({printer:X(o.type),type:o.type,hasPrefix:!0}),s=`${o.namespace} ${o.type.toUpperCase()}`,a=o.message;o.hasGroup?(e(s,a),o.group?.forEach((l,h)=>{h===0&&o.hasCaller?r(l.message,""):l.type===void 0||l.type===c.Default?r(l.message):l.type===c.Data&&(r(`${l.dataName} : ${l.dataType??"any"} ( ${b(l.dataValue)} )`),console.dir(l.dataValue))}),console.groupEnd()):t(s,a)};function X(o){switch(o){case i.Success:return console.log;case i.Info:default:return console.log;case i.Warning:return console.warn;case i.Error:return console.error}}const J={[i.Success]:"#4caf50",[i.Info]:"#3499fe",[i.Warning]:"#e6a23c",[i.Error]:"#f56c6c"},S=function({printer:o,type:e,hasPrefix:r=!1,isGroupContent:t=!1}){const s=J[e],a=`color: #FFFFFF;background-color: ${s};padding: 4px 8px;margin-right: 6px;border-radius: 4px;font-weight: 700;`,l=`background-color: ${s}22;padding: 4px 8px;border-radius: 4px;font-weight: 400;`,h=`color: ${s};background-color: ${s}22;padding: 4px 8px;border-radius: 4px;font-weight: 400;`;return r?(g,y,I="")=>{o(`%c${g}%c${y}`,a,(t?h:l)+I)}:(g,y="")=>{o(`%c${g}`,(t?h:l)+y)}};class f extends Error{constructor({namespace:e,caller:r,message:t}){super(),this.message=`[${e} error] ${r}: ${t}`}}const K=o=>o,Q=o=>new Proxy(o,{set(e,r,t){const s=new m({caller:"definePlugin()",message:`${r} 是只读属性,不能被覆盖`});throw d(s),new f(s)},get(e,r){return r==="customProperties"?Z(o):r==="customAnimations"?ee():o[r]}});function Z(o){return new Proxy({},{set:(e,r,t)=>{if(r in o){const s=new m({caller:"definePlugin()",message:`定义插件扩展属性 ${r} 时失败,${r} 是只读属性,不能被覆盖`});throw d(s),new f(s)}return o.__proto__[r]=t,!0},get:(e,r)=>{if(r in o)return o.__proto__[r]}})}function ee(o){return new Proxy({},{set:(e,r,t)=>{if(r in _){const s=new m({caller:"definePlugin()",message:`定义插件扩展动画类型 ${r} 时失败,${r} 是只读属性,不能被覆盖`});throw d(s),new f(s)}return _.__proto__[r]=t,!0},get:(e,r)=>{if(r in _)return _.__proto__[r]}})}const te={appendTo:document.body,mask:!0,maskClickClose:!1,disableScroll:!0,componentProps:{},onMounted:()=>{},onUnmounted:()=>{},width:"auto",maxWidth:"auto",minWidth:"auto",height:"auto",maxHeight:"auto",minHeight:"auto",placement:"center",viewTranslateX:0,viewTranslateY:0,viewTranslateOverflow:!1,viewAnimation:_.FADE,maskAnimation:_.FADE,maskBlur:!0,animationDuration:100};class ne{_core;get isInstalled(){return!!this._core.app}get version(){return E}constructor(e){this._core=e}install(e){e.config.globalProperties[this._core.config.prototypeName]=this,this._core.app=e,e.provide(P.CORE,this._core)}use(e,r){const t=new m({type:i.Success,caller:"popup.use()",group:[{type:c.Default,message:`插件名称: ${e.name}`},{type:c.Default,message:`插件作者: ${e.author??"未知(可能存在安全风险)"}`},{type:c.Default,message:`插件要求最低核心版本: ${e.requiredCoreVersion?.min??"-"}`},{type:c.Default,message:`插件要求最高核心版本: ${e.requiredCoreVersion?.max??"-"}`}]});if(!this._core.addPlugin(e)){t.type=i.Error,t.message=`注册插件 ${e.name} 失败,已存在同名插件 ${e.name}`,d(t);return}const s=e.requiredCoreVersion?.min||e.requiredCoreVersion?.max;if(s)if(oe(e))t.group.push({type:c.Default,message:"插件版本校验: 通过"});else{t.type=i.Error,t.message=`注册插件 ${e.name} 失败,未通过核心版本校验`,t.group.push({type:c.Default,message:"插件版本校验: 未通过"}),d(t);return}else t.group.push({type:c.Default,message:"插件版本校验: 未校验(可能存在兼容性问题)"});t.group.push({type:c.Data,dataName:"插件注册选项",dataValue:r,dataType:"PluginOption"}),e.install(Q(this),this._core.config,r);const a=e.author!==void 0;!s||!a?(t.type=i.Warning,t.message=`注册插件 ${e.name} 成功,但可能存在风险`):(t.type=i.Success,t.message=`注册插件 ${e.name} 成功`),d(t)}render({zIndex:e,...r}){const t=new m({type:i.Info,caller:"popup.render()"});if(!this.isInstalled)throw t.type=i.Error,t.message="渲染弹出层失败,请先调用 app.use() 注册插件",d(t),new f(t);e=e??this._core.config.zIndex++;const s={...te,...r,zIndex:e},a=new q(this._core,s);return a.mount(),a.renderType!==k.ROOT_COMPONENT&&d(new m({type:i.Warning,caller:"popup.render()",message:`渲染弹出层 ${a.id.name} 未使用 PopupRoot 根组件渲染,无法同步应用上下文`,group:[{type:c.Default,message:"修复建议:使用 PopupRoot 根组件包裹 App 组件以同步应用上下文"},{type:c.Default,message:`帮助文档:${B}/guide/initialization.html#同步应用上下文`}]})),t.message=`渲染弹出层 ${a.id.name} 成功`,t.group.push({type:c.Default,message:`渲染方式:${a.renderType}`}),t.group.push({type:c.Data,dataName:"instanceId",dataValue:a.id,dataType:"InstanceId"}),t.group.push({type:c.Data,dataName:"options",dataValue:arguments[0],dataType:"RenderOption"}),t.group.push({type:c.Data,dataName:"mergedOptions",dataValue:s,dataType:"RenderOption"}),d(t),a.id}update(e,r){const t=new m({type:i.Info,caller:"popup.update()"});if(!this.isInstalled)throw t.type=i.Error,t.message="更新弹出层失败,请先调用 app.use() 注册插件",d(t),new f(t);const s=this._core.getInstance(e);s&&(s.update(r),t.message=`更新弹出层 ${s.id.name} 成功`,t.group.push({type:c.Data,dataName:"instanceId",dataValue:s.id,dataType:"InstanceId"}),t.group.push({type:c.Data,dataName:"options",dataValue:r,dataType:"UpdateOption"}),d(t))}async destroy(e,r){const t=new m({type:i.Info,caller:"popup.destroy()"});if(!this.isInstalled)throw t.type=i.Error,t.message="销毁弹出层失败,请先调用 app.use() 注册插件",d(t),new f(t);const s=this._core.getInstance(e);if(!s){t.type=i.Warning,t.message=`销毁弹出层 ${e.name} 失败,弹出层不存在`,d(t);return}await s.unmount(r),t.message=`销毁弹出层 ${s.id.name} 成功`,t.group.push({type:c.Data,dataName:"instanceId",dataValue:s.id,dataType:"InstanceId"}),t.group.push({type:c.Data,dataName:"payload",dataValue:r,dataType:"any"}),d(t)}}function oe(o){const{requiredCoreVersion:e}=o,{min:r,max:t}=e??{};return!(r&&E<r||t&&E>t)}const N="PopupRoot",re=n.defineComponent({PopupRootComponentName:N,__name:"PopupRoot",setup(o){const e=n.inject(P.CORE);if(!e){const t=new m({type:i.Error,caller:"PopupRoot",message:"根组件初始化失败,请先调用 createPopup() 方法"});throw d(t),new f(t)}const r=e?.instances||{};return n.onBeforeMount(()=>{e?.registerRootComponent()}),n.onBeforeUnmount(()=>{e?.unregisterRootComponent()}),(t,s)=>(n.openBlock(),n.createElementBlock(n.Fragment,null,[n.renderSlot(t.$slots,"default"),(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(n.unref(r),a=>(n.openBlock(),n.createBlock($,{key:a.id.name,store:a.store},null,8,["store"]))),128))],64))}});let v=null;function se(o){return new ae(o)}function R(){return v}class ae{app;#n=1;#e=n.reactive({});#o;#t;#s={};#a="";#r=0;get seed(){return this.#n++}get config(){return this.#t}get controller(){return this.#o}get instances(){return this.#e}get isRootComponentRegistered(){return this.#r>0}constructor({zIndex:e=1e3,prototypeName:r="$popup",autoDisableScroll:t=!0,logHandler:s=D,debugMode:a=!1}={}){this.#t={zIndex:e,prototypeName:r,autoDisableScroll:t,logHandler:s,debugMode:a},this.#o=new ne(this),v=this}registerRootComponent(){if(this.#r>0){const e=new m({caller:"core",type:i.Warning,message:`检测到同时存在 ${this.#r+1} 个 ${N} 根组件实例`,group:[{type:c.Default,message:`修改建议:${N} 根组件同一时刻应当只存在一个实例,请移除多余的 ${N} 根组件`}]});d(e)}this.#r++}unregisterRootComponent(){this.#r--}addInstance(e){this.#e[e.id.name]=n.markRaw(e),this.config.autoDisableScroll&&e.store.disableScroll&&this.#i()}getInstance(e){return this.#e[e.name]}removeInstance(e){delete this.#e[e.id.name],Object.values(this.#e).filter(r=>r.store.disableScroll).length===0&&this.#c()}addPlugin(e){return this.getPlugin(e.name)?!1:(this.#s[e.name]=e,!0)}getPlugin(e){return this.#s[e]}removePlugin(e){delete this.#s[e]}#i(){document.body.style.overflow!=="hidden"&&(this.#a=document.body.style.overflow,document.body.style.overflow="hidden")}#c(){this.config.autoDisableScroll&&(document.body.style.overflow=this.#a)}}function ie(o){return se(o).controller}function V(){const o=R();if(!o){const e=new m({type:i.Error,caller:"usePopup()",message:"调用 usePopup() 前请先调用 createPopup() 创建弹出层控制器实例"});throw D(e),new f(e)}return o.controller}u.Log=m,u.LogGroupItemType=c,u.LogType=i,u.POPUP_ANIMATIONS=_,u.POPUP_COMPONENT_INJECTS=C,u.PopupError=f,u.PopupRoot=re,u.createPopup=ie,u.definePlugin=K,u.printLog=d,u.usePopup=V,u.version=E,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
|
|
2
|
+
(function(u,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],n):(u=typeof globalThis<"u"?globalThis:u||self,n(u.VuePopupPlus={},u.Vue))})(this,(function(u,n){"use strict";function b(o){const e=Object.prototype.toString.call(o).match(/\s+(\w+)/);return e?e[1]:"Null"}function M(o=0){return new Promise(e=>{window.setTimeout(e,o)})}const T="vue-popup-plus",C={INSTANCE_ID:Symbol(`${T}-instance-id`),COMPUTED_VIEW_STYLE:Symbol(`${T}-computed-view-style`)},P={CORE:Symbol(`${T}-core`),INSTANCE_STORE:Symbol(`${T}-instance-store`)},B="http://vue-popup-plus.styzy.cn",O=n.defineComponent({name:"PopupAnimation",__name:"PopupAnimation",props:{type:{},duration:{}},setup(o){n.useCssVars(l=>({v6e614cc2:a.value}));const e=n.inject(P.INSTANCE_STORE),r=n.ref(!1),t=n.computed(()=>`vue-popup-plus-animation vue-popup-plus-animation-enter-${o.type}`),s=n.computed(()=>`vue-popup-plus-animation vue-popup-plus-animation-leave-${o.type}`),a=n.computed(()=>`${o.duration}ms`);return n.onMounted(()=>{r.value=!0}),(l,h)=>(n.openBlock(),n.createBlock(n.Transition,{"enter-active-class":t.value,"leave-active-class":s.value},{default:n.withCtx(()=>[r.value&&!n.unref(e).isBeforeUnmount.value?n.renderSlot(l.$slots,"default",{key:0,style:n.normalizeStyle({animationDuration:`${o.duration}ms`})}):n.createCommentVNode("",!0)]),_:3},8,["enter-active-class","leave-active-class"]))}}),L=n.defineComponent({name:"PopupFrame",__name:"PopupFrame",props:{placement:{},zIndex:{}},setup(o){const e=n.computed(()=>({alignItems:o.placement.includes("left")?"flex-start":o.placement.includes("right")?"flex-end":"center",justifyContent:o.placement.includes("top")?"flex-start":o.placement.includes("bottom")?"flex-end":"center",zIndex:o.zIndex}));return(r,t)=>(n.openBlock(),n.createElementBlock("div",{class:"popup-frame",style:n.normalizeStyle(e.value)},[n.renderSlot(r.$slots,"default",{},void 0,!0)],4))}}),x=(o,e)=>{const r=o.__vccOpts||o;for(const[t,s]of e)r[t]=s;return r},W=x(L,[["__scopeId","data-v-5a4614b0"]]),F=x(n.defineComponent({name:"PopupMask",__name:"PopupMask",setup(o){const e=n.inject(C.INSTANCE_ID),r=n.inject(P.INSTANCE_STORE);function t(){r.maskClickClose&&V().destroy(e)}return(s,a)=>(n.openBlock(),n.createElementBlock("div",{class:n.normalizeClass(["popup-mask",{"is-blur":n.unref(r).maskBlur.value}]),style:n.normalizeStyle({zIndex:n.unref(r).zIndex.value}),onClick:t},null,6))}}),[["__scopeId","data-v-c4c8c95e"]]),U=x(n.defineComponent({name:"PopupView",__name:"PopupView",setup(o){const e=n.ref(),r=n.inject(C.INSTANCE_ID),t=n.inject(P.INSTANCE_STORE),s=n.ref(0),a=n.ref(0),l=n.computed(()=>typeof t.component=="function"?n.defineAsyncComponent(t.component):t.component),h=n.computed(()=>{const p=Math.ceil(window.innerWidth-s.value);return t.placement.value.includes("left")?[0,p]:t.placement.value.includes("right")?[-p,0]:[-(p/2),p/2]}),g=n.computed(()=>{const p=Math.ceil(window.innerHeight-a.value);return t.placement.value.includes("top")?[0,p]:t.placement.value.includes("bottom")?[-p,0]:[-(p/2),p/2]}),y=n.computed(()=>t.viewTranslateOverflow.value?t.viewTranslateX.value:Math.max(Math.min(t.viewTranslateX.value,h.value[1]),h.value[0])),I=n.computed(()=>t.viewTranslateOverflow.value?t.viewTranslateY.value:Math.max(Math.min(t.viewTranslateY.value,g.value[1]),g.value[0])),ce=n.computed(()=>({width:w(t.width.value),maxWidth:w(t.maxWidth.value),minWidth:w(t.minWidth.value),height:w(t.height.value),maxHeight:w(t.maxHeight.value),minHeight:w(t.minHeight.value),transform:`translate(${y.value}px, ${I.value}px)`})),le=n.computed(()=>({width:s.value,height:a.value,zIndex:t.zIndex.value,translateX:y.value,translateY:I.value}));n.provide(C.COMPUTED_VIEW_STYLE,le),n.onMounted(()=>{window.setTimeout(A,t.animationDuration.value)}),n.onUpdated(()=>{A()});async function A(){await n.nextTick();const p=e.value?.getBoundingClientRect();p&&(s.value=p.width,a.value=p.height)}function w(p){return typeof p=="number"?`${p}px`:p}return(p,me)=>(n.openBlock(),n.createElementBlock("div",{class:"popup-view",style:n.normalizeStyle(ce.value),ref_key:"popupViewRef",ref:e},[(n.openBlock(),n.createBlock(n.resolveDynamicComponent(l.value),n.mergeProps({key:`${n.unref(r).name}-component`},n.unref(t).componentProps),null,16))],4))}}),[["__scopeId","data-v-bbc1055f"]]),z={class:"popup-instance"},$=n.defineComponent({name:"PopupInstance",__name:"PopupInstance",props:{store:{}},setup(o){return n.provide(C.INSTANCE_ID,o.store.id),n.provide(P.INSTANCE_STORE,o.store),(e,r)=>(n.openBlock(),n.createBlock(n.Teleport,{to:o.store.appendTo},[n.createElementVNode("div",z,[o.store.mask?(n.openBlock(),n.createBlock(O,{key:0,duration:o.store.animationDuration.value,type:o.store.maskAnimation.value},{default:n.withCtx(()=>[n.createVNode(F)]),_:1},8,["duration","type"])):n.createCommentVNode("",!0),n.createVNode(W,{placement:o.store.placement.value,zIndex:o.store.zIndex.value},{default:n.withCtx(()=>[n.createVNode(O,{duration:o.store.animationDuration.value,type:o.store.viewAnimation.value},{default:n.withCtx(()=>[n.createVNode(U)]),_:1},8,["duration","type"])]),_:1},8,["placement","zIndex"])])],8,["to"]))}}),j=(o,{component:e,componentProps:r,onMounted:t,onUnmounted:s,appendTo:a,mask:l,maskClickClose:h,disableScroll:g,...y})=>({id:o,parentElement:Y(a),appendTo:a,mask:l,maskClickClose:h,disableScroll:g,component:e,componentProps:r,onMounted:t,onUnmounted:s,isBeforeUnmount:n.ref(!1),...n.toRefs(n.reactive(y))});function Y(o){return typeof o=="string"&&(o=document.querySelector(o)||document.body),o}class H{_seed;get seed(){return this._seed}get name(){return`vue-popup-plus-instance-${this.seed}`}constructor(e){this._seed=e}}var k=(o=>(o.ROOT_COMPONENT="RootComponent",o.APP="App",o.VNODE="VNode",o))(k||{});class q{#n;_id;_store;renderType;#e;#o;#t;get id(){return this._id}get store(){return this._store}constructor(e,r){this.#n=e,this._id=new H(e.seed),this._store=j(this._id,r),this.renderType=e.isRootComponentRegistered?"RootComponent":e.config.debugMode?"App":"VNode"}mount(){return this.renderType==="App"?(this.#t=document.createElement("div"),this.#e=n.createApp($,{store:this._store}),this.#e._context.components=this.#n.app._context.components,this.#e._context.provides=this.#n.app._context.provides,this.#e._context.config=this.#n.app._context.config,this.#e._context.directives=this.#n.app._context.directives,this.#e._context.mixins=this.#n.app._context.mixins,this.#e.mount(this.#t),this._store.parentElement.appendChild(this.#t)):this.renderType==="VNode"&&(this.#t=document.createElement("div"),this.#o=n.createVNode($,{store:this._store}),this.#o.appContext=this.#n.app._context,this.#o.appContext.components.Popup=$,n.render(this.#o,this.#t),this._store.parentElement.appendChild(this.#t)),this.#n.addInstance(this),this._store.onMounted(),this.id}async unmount(e){this._store.isBeforeUnmount.value=!0,await M(this._store.animationDuration.value),this.renderType==="App"?(this.#e.unmount(),this._store.parentElement.removeChild(this.#t)):this.renderType==="VNode"&&(n.render(null,this.#t),this._store.parentElement.removeChild(this.#t)),this.#n.removeInstance(this),this._store.onUnmounted(e)}update(e){for(const r in e){const t=r,s=e[t]===void 0?this._store[t].value:e[t];this._store[t].value=s}}}class G{get NONE(){return"none"}get FADE(){return"fade"}get SCALE_ENLARGE(){return"scale-enlarge"}get SCALE_REDUCE(){return"scale-reduce"}get FLY_TOP(){return"fly-top"}get FLY_LEFT(){return"fly-left"}get FLY_RIGHT(){return"fly-right"}get FLY_BOTTOM(){return"fly-bottom"}constructor(){}}const _=new G,E="1.5.2",i={Success:"success",Info:"info",Warning:"warning",Error:"error"},c={Default:"default",Data:"data"};class m{namespace="VuePopupPlus";type;caller;message;group;get hasCaller(){return!!this.caller}get hasGroup(){return!!this.group.length}constructor({type:e=i.Info,caller:r="",message:t="",group:s=[]}={}){this.type=e,this.caller=r,this.message=t,this.group=s,this.group.unshift({type:c.Default,message:`核心版本: ${E}`}),this.hasCaller&&this.group.unshift({type:c.Default,message:`调用者: ${this.caller}`})}}const d=o=>{const e=R();e?.config.debugMode&&e.config.logHandler(o)},D=o=>{const e=S({printer:console.groupCollapsed,type:o.type,hasPrefix:!0}),r=S({printer:console.log,type:o.type,isGroupContent:!0}),t=S({printer:X(o.type),type:o.type,hasPrefix:!0}),s=`${o.namespace} ${o.type.toUpperCase()}`,a=o.message;o.hasGroup?(e(s,a),o.group?.forEach((l,h)=>{h===0&&o.hasCaller?r(l.message,""):l.type===void 0||l.type===c.Default?r(l.message):l.type===c.Data&&(r(`${l.dataName} : ${l.dataType??"any"} ( ${b(l.dataValue)} )`),console.dir(l.dataValue))}),console.groupEnd()):t(s,a)};function X(o){switch(o){case i.Success:return console.log;case i.Info:default:return console.log;case i.Warning:return console.warn;case i.Error:return console.error}}const J={[i.Success]:"#4caf50",[i.Info]:"#3499fe",[i.Warning]:"#e6a23c",[i.Error]:"#f56c6c"},S=function({printer:o,type:e,hasPrefix:r=!1,isGroupContent:t=!1}){const s=J[e],a=`color: #FFFFFF;background-color: ${s};padding: 4px 8px;margin-right: 6px;border-radius: 4px;font-weight: 700;`,l=`background-color: ${s}22;padding: 4px 8px;border-radius: 4px;font-weight: 400;`,h=`color: ${s};background-color: ${s}22;padding: 4px 8px;border-radius: 4px;font-weight: 400;`;return r?(g,y,I="")=>{o(`%c${g}%c${y}`,a,(t?h:l)+I)}:(g,y="")=>{o(`%c${g}`,(t?h:l)+y)}};class f extends Error{constructor({namespace:e,caller:r,message:t}){super(),this.message=`[${e} error] ${r}: ${t}`}}const K=o=>o,Q=o=>new Proxy(o,{set(e,r,t){const s=new m({caller:"definePlugin()",message:`${r} 是只读属性,不能被覆盖`});throw d(s),new f(s)},get(e,r){return r==="customProperties"?Z(o):r==="customAnimations"?ee():o[r]}});function Z(o){return new Proxy({},{set:(e,r,t)=>{if(r in o){const s=new m({caller:"definePlugin()",message:`定义插件扩展属性 ${r} 时失败,${r} 是只读属性,不能被覆盖`});throw d(s),new f(s)}return o.__proto__[r]=t,!0},get:(e,r)=>{if(r in o)return o.__proto__[r]}})}function ee(o){return new Proxy({},{set:(e,r,t)=>{if(r in _){const s=new m({caller:"definePlugin()",message:`定义插件扩展动画类型 ${r} 时失败,${r} 是只读属性,不能被覆盖`});throw d(s),new f(s)}return _.__proto__[r]=t,!0},get:(e,r)=>{if(r in _)return _.__proto__[r]}})}const te={appendTo:document.body,mask:!0,maskClickClose:!1,disableScroll:!0,componentProps:{},onMounted:()=>{},onUnmounted:()=>{},width:"auto",maxWidth:"auto",minWidth:"auto",height:"auto",maxHeight:"auto",minHeight:"auto",placement:"center",viewTranslateX:0,viewTranslateY:0,viewTranslateOverflow:!1,viewAnimation:_.FADE,maskAnimation:_.FADE,maskBlur:!0,animationDuration:100};class ne{_core;get isInstalled(){return!!this._core.app}get version(){return E}constructor(e){this._core=e}install(e){e.config.globalProperties[this._core.config.prototypeName]=this,this._core.app=e,e.provide(P.CORE,this._core)}use(e,r){const t=new m({type:i.Success,caller:"popup.use()",group:[{type:c.Default,message:`插件名称: ${e.name}`},{type:c.Default,message:`插件作者: ${e.author??"未知(可能存在安全风险)"}`},{type:c.Default,message:`插件要求最低核心版本: ${e.requiredCoreVersion?.min??"-"}`},{type:c.Default,message:`插件要求最高核心版本: ${e.requiredCoreVersion?.max??"-"}`}]});if(!this._core.addPlugin(e)){t.type=i.Error,t.message=`注册插件 ${e.name} 失败,已存在同名插件 ${e.name}`,d(t);return}const s=e.requiredCoreVersion?.min||e.requiredCoreVersion?.max;if(s)if(oe(e))t.group.push({type:c.Default,message:"插件版本校验: 通过"});else{t.type=i.Error,t.message=`注册插件 ${e.name} 失败,未通过核心版本校验`,t.group.push({type:c.Default,message:"插件版本校验: 未通过"}),d(t);return}else t.group.push({type:c.Default,message:"插件版本校验: 未校验(可能存在兼容性问题)"});t.group.push({type:c.Data,dataName:"插件注册选项",dataValue:r,dataType:"PluginOption"}),e.install(Q(this),this._core.config,r);const a=e.author!==void 0;!s||!a?(t.type=i.Warning,t.message=`注册插件 ${e.name} 成功,但可能存在风险`):(t.type=i.Success,t.message=`注册插件 ${e.name} 成功`),d(t)}render({zIndex:e,...r}){const t=new m({type:i.Info,caller:"popup.render()"});if(!this.isInstalled)throw t.type=i.Error,t.message="渲染弹出层失败,请先调用 app.use() 注册插件",d(t),new f(t);e=e??this._core.config.zIndex++;const s={...te,...r,zIndex:e},a=new q(this._core,s);return a.mount(),a.renderType!==k.ROOT_COMPONENT&&d(new m({type:i.Warning,caller:"popup.render()",message:`渲染弹出层 ${a.id.name} 未使用 PopupRoot 根组件渲染,无法同步应用上下文`,group:[{type:c.Default,message:"修复建议:使用 PopupRoot 根组件包裹 App 组件以同步应用上下文"},{type:c.Default,message:`帮助文档:${B}/guide/initialization.html#同步应用上下文`}]})),t.message=`渲染弹出层 ${a.id.name} 成功`,t.group.push({type:c.Default,message:`渲染方式:${a.renderType}`}),t.group.push({type:c.Data,dataName:"instanceId",dataValue:a.id,dataType:"InstanceId"}),t.group.push({type:c.Data,dataName:"options",dataValue:arguments[0],dataType:"RenderOption"}),t.group.push({type:c.Data,dataName:"mergedOptions",dataValue:s,dataType:"RenderOption"}),d(t),a.id}update(e,r){const t=new m({type:i.Info,caller:"popup.update()"});if(!this.isInstalled)throw t.type=i.Error,t.message="更新弹出层失败,请先调用 app.use() 注册插件",d(t),new f(t);const s=this._core.getInstance(e);s&&(s.update(r),t.message=`更新弹出层 ${s.id.name} 成功`,t.group.push({type:c.Data,dataName:"instanceId",dataValue:s.id,dataType:"InstanceId"}),t.group.push({type:c.Data,dataName:"options",dataValue:r,dataType:"UpdateOption"}),d(t))}async destroy(e,r){const t=new m({type:i.Info,caller:"popup.destroy()"});if(!this.isInstalled)throw t.type=i.Error,t.message="销毁弹出层失败,请先调用 app.use() 注册插件",d(t),new f(t);const s=this._core.getInstance(e);if(!s){t.type=i.Warning,t.message=`销毁弹出层 ${e.name} 失败,弹出层不存在`,d(t);return}await s.unmount(r),t.message=`销毁弹出层 ${s.id.name} 成功`,t.group.push({type:c.Data,dataName:"instanceId",dataValue:s.id,dataType:"InstanceId"}),t.group.push({type:c.Data,dataName:"payload",dataValue:r,dataType:"any"}),d(t)}}function oe(o){const{requiredCoreVersion:e}=o,{min:r,max:t}=e??{};return!(r&&E<r||t&&E>t)}const N="PopupRoot",re=n.defineComponent({PopupRootComponentName:N,__name:"PopupRoot",setup(o){const e=n.inject(P.CORE);if(!e){const t=new m({type:i.Error,caller:"PopupRoot",message:"根组件初始化失败,请先调用 createPopup() 方法"});throw d(t),new f(t)}const r=e?.instances||{};return n.onBeforeMount(()=>{e?.registerRootComponent()}),n.onBeforeUnmount(()=>{e?.unregisterRootComponent()}),(t,s)=>(n.openBlock(),n.createElementBlock(n.Fragment,null,[n.renderSlot(t.$slots,"default"),(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(n.unref(r),a=>(n.openBlock(),n.createBlock($,{key:a.id.name,store:a.store},null,8,["store"]))),128))],64))}});let v=null;function se(o){return new ae(o)}function R(){return v}class ae{app;#n=1;#e=n.reactive({});#o;#t;#s={};#a="";#r=0;get seed(){return this.#n++}get config(){return this.#t}get controller(){return this.#o}get instances(){return this.#e}get isRootComponentRegistered(){return this.#r>0}constructor({zIndex:e=1e3,prototypeName:r="$popup",autoDisableScroll:t=!0,logHandler:s=D,debugMode:a=!1}={}){this.#t={zIndex:e,prototypeName:r,autoDisableScroll:t,logHandler:s,debugMode:a},this.#o=new ne(this),v=this}registerRootComponent(){if(this.#r>0){const e=new m({caller:"core",type:i.Warning,message:`检测到同时存在 ${this.#r+1} 个 ${N} 根组件实例`,group:[{type:c.Default,message:`修改建议:${N} 根组件同一时刻应当只存在一个实例,请移除多余的 ${N} 根组件`}]});d(e)}this.#r++}unregisterRootComponent(){this.#r--}addInstance(e){this.#e[e.id.name]=n.markRaw(e),this.config.autoDisableScroll&&e.store.disableScroll&&this.#i()}getInstance(e){return this.#e[e.name]}removeInstance(e){delete this.#e[e.id.name],Object.values(this.#e).filter(r=>r.store.disableScroll).length===0&&this.#c()}addPlugin(e){return this.getPlugin(e.name)?!1:(this.#s[e.name]=e,!0)}getPlugin(e){return this.#s[e]}removePlugin(e){delete this.#s[e]}#i(){document.body.style.overflow!=="hidden"&&(this.#a=document.body.style.overflow,document.body.style.overflow="hidden")}#c(){this.config.autoDisableScroll&&(document.body.style.overflow=this.#a)}}function ie(o){return se(o).controller}function V(){const o=R();if(!o){const e=new m({type:i.Error,caller:"usePopup()",message:"调用 usePopup() 前请先调用 createPopup() 创建弹出层控制器实例"});throw D(e),new f(e)}return o.controller}u.Log=m,u.LogGroupItemType=c,u.LogType=i,u.POPUP_ANIMATIONS=_,u.POPUP_COMPONENT_INJECTS=C,u.PopupError=f,u.PopupRoot=re,u.createPopup=ie,u.definePlugin=K,u.printLog=d,u.usePopup=V,u.version=E,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
|