vue-popup-plus 1.1.0 → 1.1.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.
@@ -6,6 +6,10 @@ import { version } from '../package.json';
6
6
 
7
7
  declare type Animation_2 = IAnimations[keyof IAnimations];
8
8
 
9
+ export declare interface ComponentCustomProperties {
10
+ $popup: IController;
11
+ }
12
+
9
13
  /**
10
14
  * 组件注入键类型
11
15
  */
@@ -237,7 +241,7 @@ declare class InstanceId implements IInstanceId {
237
241
  constructor(seed: number);
238
242
  }
239
243
 
240
- declare interface IPluginWrappedController extends IController {
244
+ export declare interface IPluginWrappedController extends IController {
241
245
  /**
242
246
  * 原型属性
243
247
  * - 可在插件的 `install` 方法中扩展方法或属性
@@ -523,10 +527,3 @@ export declare function usePopup(): IController;
523
527
  export { version }
524
528
 
525
529
  export { }
526
-
527
-
528
- declare module 'vue' {
529
- interface ComponentCustomProperties {
530
- $popup: IController;
531
- }
532
- }
@@ -4673,7 +4673,7 @@ class qu {
4673
4673
  this.config.autoDisableScroll && (document.body.style.overflow = this.#s);
4674
4674
  }
4675
4675
  }
4676
- const Qu = "1.1.0";
4676
+ const Qu = "1.1.2";
4677
4677
  function ei(e) {
4678
4678
  return Gu(e).controller;
4679
4679
  }
@@ -9,4 +9,4 @@ Only state can be modified.`);u[0]="$state",fe=!1,o.set(s,u,o.state.value),fe=!0
9
9
  state: () => new MyClass()
10
10
  Found in store "${S.$id}".`),p&&s&&n.hydrate&&n.hydrate(S.$state,p),_=!0,v=!0,S}/*! #__NO_SIDE_EFFECTS__ */function Zs(e,t,n){let o;const r=typeof t=="function";o=r?n:t;function s(u,a){const c=i.hasInjectionContext();if(u=(process.env.NODE_ENV==="test"&&Ae&&Ae._testing?null:u)||(c?i.inject(oo,null):null),u&&Se(u),process.env.NODE_ENV!=="production"&&!Ae)throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?
11
11
  See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.
12
- This will fail in production.`);u=Ae,u._s.has(e)||(r?Et(e,t,o,u):vo(e,o,u),process.env.NODE_ENV!=="production"&&(s._pinia=u));const _=u._s.get(e);if(process.env.NODE_ENV!=="production"&&a){const v="__hot:"+e,d=r?Et(v,t,o,u,!0):vo(v,B({},o),u,!0);a._hotUpdate(d),delete u.state.value[v],u._s.delete(v)}if(process.env.NODE_ENV!=="production"&&X){const v=i.getCurrentInstance();if(v&&v.proxy&&!a){const d=v.proxy,O="_pStores"in d?d._pStores:d._pStores={};O[e]=_}}return _}return s.$id=e,s}const ht="vue-popup-plus",Te={INSTANCE_ID:Symbol(`${ht}-instance-id`),COMPUTED_VIEW_STYLE:Symbol(`${ht}-computed-view-style`)},Ce={INSTANCE_STORE:Symbol(`${ht}-instance-store`)};function Js(e){return new Promise(t=>{setTimeout(t,e)})}const Qs=i.defineComponent({name:"PopupMask",__name:"PopupMask",setup(e){const t=i.inject(Te.INSTANCE_ID),n=i.inject(Ce.INSTANCE_STORE),o=i.computed(()=>({zIndex:n.zIndex}));function r(){n.maskClickCloseEnabled&&To().destroy(t)}return(s,u)=>(i.openBlock(),i.createElementBlock("div",{class:"popup-mask",style:i.normalizeStyle(o.value),onClick:r},null,4))}}),Oo=(e,t)=>{const n=e.__vccOpts||e;for(const[o,r]of t)n[o]=r;return n},eu=Oo(Qs,[["__scopeId","data-v-ab1ad98c"]]),tu=Oo(i.defineComponent({name:"PopupView",__name:"PopupView",setup(e){const t=i.ref(),n=i.inject(Te.INSTANCE_ID),o=i.inject(Ce.INSTANCE_STORE),r=i.ref(0),s=i.ref(0),u=i.computed(()=>typeof o.component=="function"?i.defineAsyncComponent(o.component):o.component),a=i.computed(()=>o.viewTranslateOverflow?o.viewTranslateX:o.viewTranslateX>0?Math.min(o.viewTranslateX,(window.innerWidth-r.value)/2):Math.max(o.viewTranslateX,-(window.innerWidth-r.value)/2)),c=i.computed(()=>o.viewTranslateOverflow?o.viewTranslateY:o.viewTranslateY>0?Math.min(o.viewTranslateY,(window.innerHeight-s.value)/2):Math.max(o.viewTranslateY,-(window.innerHeight-s.value)/2)),_=i.computed(()=>({width:O(o.width),maxWidth:O(o.maxWidth),minWidth:O(o.minWidth),height:O(o.height),maxHeight:O(o.maxHeight),minHeight:O(o.minHeight),transform:`translate(${a.value}px, ${c.value}px)`})),v=i.computed(()=>({width:r.value,height:s.value,zIndex:o.zIndex,translateX:a.value,translateY:c.value}));i.provide(Te.COMPUTED_VIEW_STYLE,v),i.onMounted(()=>{window.setTimeout(d,o.animationDuration)}),i.onUpdated(()=>{d()});async function d(){await i.nextTick();const f=t.value?.getBoundingClientRect();f&&(r.value=f.width,s.value=f.height)}function O(f){return typeof f=="number"?`${f}px`:f}return(f,p)=>(i.openBlock(),i.createElementBlock("div",{class:"popup-view-wrapper",style:i.normalizeStyle({zIndex:i.unref(o).zIndex})},[i.createElementVNode("div",{class:"popup-view",style:i.normalizeStyle(_.value),ref_key:"popupViewRef",ref:t},[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(u.value),i.mergeProps({key:`${i.unref(n).name}-component`},i.unref(o).componentProps),null,16))],4)],4))}}),[["__scopeId","data-v-bf79c330"]]),Ao=i.defineComponent({name:"PopupAnimation",__name:"PopupAnimation",props:{type:{},duration:{}},setup(e){i.useCssVars(u=>({"2a185d84":s.value}));const t=i.inject(Ce.INSTANCE_STORE),n=i.ref(!1),o=i.computed(()=>`vue-popup-plus-animation vue-popup-plus-animation-enter-${e.type}`),r=i.computed(()=>`vue-popup-plus-animation vue-popup-plus-animation-leave-${e.type}`),s=i.computed(()=>`${e.duration}ms`);return i.onMounted(()=>{n.value=!0}),(u,a)=>(i.openBlock(),i.createBlock(i.Transition,{"enter-active-class":o.value,"leave-active-class":r.value},{default:i.withCtx(()=>[n.value&&!i.unref(t).isBeforeUnmount?i.renderSlot(u.$slots,"default",{key:0,style:i.normalizeStyle({animationDuration:`${u.duration}ms`})}):i.createCommentVNode("",!0)]),_:3},8,["enter-active-class","leave-active-class"]))}}),nu=i.defineComponent({name:"Popup",__name:"Popup",setup(e){const t=i.inject(Ce.INSTANCE_STORE);return(n,o)=>(i.openBlock(),i.createElementBlock(i.Fragment,null,[i.unref(t).mask?(i.openBlock(),i.createBlock(Ao,{key:0,duration:i.unref(t).animationDuration,type:i.unref(t).maskAnimation},{default:i.withCtx(()=>[i.createVNode(eu)]),_:1},8,["duration","type"])):i.createCommentVNode("",!0),i.createVNode(Ao,{duration:i.unref(t).animationDuration,type:i.unref(t).viewAnimation},{default:i.withCtx(()=>[i.createVNode(tu)]),_:1},8,["duration","type"])],64))}}),ou=(e,{component:t,...n})=>Zs(e.name,{state:()=>({...n,component:i.markRaw(t),isBeforeUnmount:!1})})();class ru{#n;get seed(){return this.#n}get name(){return`vue-popup-instance-${this.seed}`}constructor(t){this.#n=t}}class be{static#n;#o;#t;#e;get id(){return this.#o}constructor(t,n){this.#o=new ru(t),this.#t=i.createApp(nu),this.#t.provide(Te.INSTANCE_ID,this.id),be.#n=be.#n||Gs(),this.#t.use(be.#n),this.#e=ou(this.#o,n),this.#t.provide(Ce.INSTANCE_STORE,this.#e)}mount(){return this.#t.mount(this.#e.el),this.#e.onMounted(),this.id}async unmount(t){this.#e.isBeforeUnmount=!0,await Js(this.#e.animationDuration),this.#t.unmount(),this.#e.onUnmounted(t)}updateStore(t){this.#e.$patch(n=>{Object.assign(n,t)})}}class $e extends Error{constructor(t){super(t)}toString(){return`vue-popup-plus error: ${this.message}`}}class su{NONE="none";FADE="fade";SCALE_ENLARGE="scale-enlarge";SCALE_SHRINK="scale-shrink";FLY_TOP="fly-top";FLY_LEFT="fly-left";FLY_RIGHT="fly-right";FLY_BOTTOM="fly-bottom";constructor(){}}const re=new su,uu=e=>e,iu=e=>new Proxy(e,{set(t,n,o){throw new $e(`${n} 是只读属性,不能被覆盖`)},get(t,n){return n==="customProperties"?au(e):n==="customAnimations"?lu():e[n]}});function au(e){return new Proxy({},{set:(t,n,o)=>{if(n in e)throw new $e(`定义插件扩展属性 ${n} 时失败,${n} 是只读属性,不能被覆盖`);return e.__proto__[n]=o,!0},get:(t,n)=>{if(n in e)return e.__proto__[n]}})}function lu(e){return new Proxy({},{set:(t,n,o)=>{if(n in re)throw new $e(`定义插件扩展动画类型 ${n} 时失败,${n} 是只读属性,不能被覆盖`);return re.__proto__[n]=o,!0},get:(t,n)=>{if(n in re)return re.__proto__[n]}})}const cu={componentProps:{},onMounted:()=>{},onUnmounted:()=>{},mask:!0,maskClickCloseEnabled:!1,autoHideWindowScroll:!0,width:"auto",maxWidth:"auto",minWidth:"auto",height:"auto",maxHeight:"auto",minHeight:"auto",viewTranslateX:0,viewTranslateY:0,viewTranslateOverflow:!1,animationDuration:100,maskAnimation:re.FADE,viewAnimation:re.FADE};class fu{_core;constructor(t){this._core=t}install(t){t.config.globalProperties[this._core.config.prototypeName]=this}use(t){if(!this._core.addPlugin(t))throw new $e(`使用插件 ${t.name} 失败,已存在同名插件 ${t.name}`);t.install(iu(this),this._core.config)}render({el:t,zIndex:n,...o}){t=t||document.body.appendChild(document.createElement("div")),n=n??this._core.config.zIndex++;const r=new be(this._core.seed,{...cu,...o,zIndex:n,el:t});return this._core.addInstance(r),r.mount(),r.id}update(t,n){const o=this._core.getInstance(t);o&&o.updateStore(n)}async destroy(t,n){const o=this._core.getInstance(t);o&&(await o.unmount(n),this._core.removeInstance(o))}}let So;function du(e){return new pu(e)}function _u(){return So}class pu{#n=1;#o={};#t;#e;#r={};#s="";get seed(){return this.#n++}get config(){return this.#e}get controller(){return this.#t}constructor({zIndex:t=1e3,prototypeName:n="$popup",autoDisableScroll:o=!0,debugMode:r=!1}={}){this.#e={zIndex:t,prototypeName:n,autoDisableScroll:o,debugMode:r},this.#t=new fu(this),So=this}addInstance(t){this.#o[t.id.name]=t,this.#u()}getInstance(t){return this.#o[t.name]}removeInstance(t){delete this.#o[t.id.name],Object.keys(this.#o).length===0&&this.#i()}addPlugin(t){return this.getPlugin(t.name)?!1:(this.#r[t.name]=t,!0)}getPlugin(t){return this.#r[t]}removePlugin(t){delete this.#r[t]}#u(){this.config.autoDisableScroll&&document.body.style.overflow!=="hidden"&&(this.#s=document.body.style.overflow,document.body.style.overflow="hidden")}#i(){this.config.autoDisableScroll&&(document.body.style.overflow=this.#s)}}const Eu="1.1.0";function hu(e){return du(e).controller}function To(){return _u().controller}L.POPUP_ANIMATIONS=re,L.POPUP_COMPONENT_INJECTS=Te,L.createPopup=hu,L.definePlugin=uu,L.usePopup=To,L.version=Eu,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})}));
12
+ This will fail in production.`);u=Ae,u._s.has(e)||(r?Et(e,t,o,u):vo(e,o,u),process.env.NODE_ENV!=="production"&&(s._pinia=u));const _=u._s.get(e);if(process.env.NODE_ENV!=="production"&&a){const v="__hot:"+e,d=r?Et(v,t,o,u,!0):vo(v,B({},o),u,!0);a._hotUpdate(d),delete u.state.value[v],u._s.delete(v)}if(process.env.NODE_ENV!=="production"&&X){const v=i.getCurrentInstance();if(v&&v.proxy&&!a){const d=v.proxy,O="_pStores"in d?d._pStores:d._pStores={};O[e]=_}}return _}return s.$id=e,s}const ht="vue-popup-plus",Te={INSTANCE_ID:Symbol(`${ht}-instance-id`),COMPUTED_VIEW_STYLE:Symbol(`${ht}-computed-view-style`)},Ce={INSTANCE_STORE:Symbol(`${ht}-instance-store`)};function Js(e){return new Promise(t=>{setTimeout(t,e)})}const Qs=i.defineComponent({name:"PopupMask",__name:"PopupMask",setup(e){const t=i.inject(Te.INSTANCE_ID),n=i.inject(Ce.INSTANCE_STORE),o=i.computed(()=>({zIndex:n.zIndex}));function r(){n.maskClickCloseEnabled&&To().destroy(t)}return(s,u)=>(i.openBlock(),i.createElementBlock("div",{class:"popup-mask",style:i.normalizeStyle(o.value),onClick:r},null,4))}}),Oo=(e,t)=>{const n=e.__vccOpts||e;for(const[o,r]of t)n[o]=r;return n},eu=Oo(Qs,[["__scopeId","data-v-ab1ad98c"]]),tu=Oo(i.defineComponent({name:"PopupView",__name:"PopupView",setup(e){const t=i.ref(),n=i.inject(Te.INSTANCE_ID),o=i.inject(Ce.INSTANCE_STORE),r=i.ref(0),s=i.ref(0),u=i.computed(()=>typeof o.component=="function"?i.defineAsyncComponent(o.component):o.component),a=i.computed(()=>o.viewTranslateOverflow?o.viewTranslateX:o.viewTranslateX>0?Math.min(o.viewTranslateX,(window.innerWidth-r.value)/2):Math.max(o.viewTranslateX,-(window.innerWidth-r.value)/2)),c=i.computed(()=>o.viewTranslateOverflow?o.viewTranslateY:o.viewTranslateY>0?Math.min(o.viewTranslateY,(window.innerHeight-s.value)/2):Math.max(o.viewTranslateY,-(window.innerHeight-s.value)/2)),_=i.computed(()=>({width:O(o.width),maxWidth:O(o.maxWidth),minWidth:O(o.minWidth),height:O(o.height),maxHeight:O(o.maxHeight),minHeight:O(o.minHeight),transform:`translate(${a.value}px, ${c.value}px)`})),v=i.computed(()=>({width:r.value,height:s.value,zIndex:o.zIndex,translateX:a.value,translateY:c.value}));i.provide(Te.COMPUTED_VIEW_STYLE,v),i.onMounted(()=>{window.setTimeout(d,o.animationDuration)}),i.onUpdated(()=>{d()});async function d(){await i.nextTick();const f=t.value?.getBoundingClientRect();f&&(r.value=f.width,s.value=f.height)}function O(f){return typeof f=="number"?`${f}px`:f}return(f,p)=>(i.openBlock(),i.createElementBlock("div",{class:"popup-view-wrapper",style:i.normalizeStyle({zIndex:i.unref(o).zIndex})},[i.createElementVNode("div",{class:"popup-view",style:i.normalizeStyle(_.value),ref_key:"popupViewRef",ref:t},[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(u.value),i.mergeProps({key:`${i.unref(n).name}-component`},i.unref(o).componentProps),null,16))],4)],4))}}),[["__scopeId","data-v-bf79c330"]]),Ao=i.defineComponent({name:"PopupAnimation",__name:"PopupAnimation",props:{type:{},duration:{}},setup(e){i.useCssVars(u=>({"2a185d84":s.value}));const t=i.inject(Ce.INSTANCE_STORE),n=i.ref(!1),o=i.computed(()=>`vue-popup-plus-animation vue-popup-plus-animation-enter-${e.type}`),r=i.computed(()=>`vue-popup-plus-animation vue-popup-plus-animation-leave-${e.type}`),s=i.computed(()=>`${e.duration}ms`);return i.onMounted(()=>{n.value=!0}),(u,a)=>(i.openBlock(),i.createBlock(i.Transition,{"enter-active-class":o.value,"leave-active-class":r.value},{default:i.withCtx(()=>[n.value&&!i.unref(t).isBeforeUnmount?i.renderSlot(u.$slots,"default",{key:0,style:i.normalizeStyle({animationDuration:`${u.duration}ms`})}):i.createCommentVNode("",!0)]),_:3},8,["enter-active-class","leave-active-class"]))}}),nu=i.defineComponent({name:"Popup",__name:"Popup",setup(e){const t=i.inject(Ce.INSTANCE_STORE);return(n,o)=>(i.openBlock(),i.createElementBlock(i.Fragment,null,[i.unref(t).mask?(i.openBlock(),i.createBlock(Ao,{key:0,duration:i.unref(t).animationDuration,type:i.unref(t).maskAnimation},{default:i.withCtx(()=>[i.createVNode(eu)]),_:1},8,["duration","type"])):i.createCommentVNode("",!0),i.createVNode(Ao,{duration:i.unref(t).animationDuration,type:i.unref(t).viewAnimation},{default:i.withCtx(()=>[i.createVNode(tu)]),_:1},8,["duration","type"])],64))}}),ou=(e,{component:t,...n})=>Zs(e.name,{state:()=>({...n,component:i.markRaw(t),isBeforeUnmount:!1})})();class ru{#n;get seed(){return this.#n}get name(){return`vue-popup-instance-${this.seed}`}constructor(t){this.#n=t}}class be{static#n;#o;#t;#e;get id(){return this.#o}constructor(t,n){this.#o=new ru(t),this.#t=i.createApp(nu),this.#t.provide(Te.INSTANCE_ID,this.id),be.#n=be.#n||Gs(),this.#t.use(be.#n),this.#e=ou(this.#o,n),this.#t.provide(Ce.INSTANCE_STORE,this.#e)}mount(){return this.#t.mount(this.#e.el),this.#e.onMounted(),this.id}async unmount(t){this.#e.isBeforeUnmount=!0,await Js(this.#e.animationDuration),this.#t.unmount(),this.#e.onUnmounted(t)}updateStore(t){this.#e.$patch(n=>{Object.assign(n,t)})}}class $e extends Error{constructor(t){super(t)}toString(){return`vue-popup-plus error: ${this.message}`}}class su{NONE="none";FADE="fade";SCALE_ENLARGE="scale-enlarge";SCALE_SHRINK="scale-shrink";FLY_TOP="fly-top";FLY_LEFT="fly-left";FLY_RIGHT="fly-right";FLY_BOTTOM="fly-bottom";constructor(){}}const re=new su,uu=e=>e,iu=e=>new Proxy(e,{set(t,n,o){throw new $e(`${n} 是只读属性,不能被覆盖`)},get(t,n){return n==="customProperties"?au(e):n==="customAnimations"?lu():e[n]}});function au(e){return new Proxy({},{set:(t,n,o)=>{if(n in e)throw new $e(`定义插件扩展属性 ${n} 时失败,${n} 是只读属性,不能被覆盖`);return e.__proto__[n]=o,!0},get:(t,n)=>{if(n in e)return e.__proto__[n]}})}function lu(e){return new Proxy({},{set:(t,n,o)=>{if(n in re)throw new $e(`定义插件扩展动画类型 ${n} 时失败,${n} 是只读属性,不能被覆盖`);return re.__proto__[n]=o,!0},get:(t,n)=>{if(n in re)return re.__proto__[n]}})}const cu={componentProps:{},onMounted:()=>{},onUnmounted:()=>{},mask:!0,maskClickCloseEnabled:!1,autoHideWindowScroll:!0,width:"auto",maxWidth:"auto",minWidth:"auto",height:"auto",maxHeight:"auto",minHeight:"auto",viewTranslateX:0,viewTranslateY:0,viewTranslateOverflow:!1,animationDuration:100,maskAnimation:re.FADE,viewAnimation:re.FADE};class fu{_core;constructor(t){this._core=t}install(t){t.config.globalProperties[this._core.config.prototypeName]=this}use(t){if(!this._core.addPlugin(t))throw new $e(`使用插件 ${t.name} 失败,已存在同名插件 ${t.name}`);t.install(iu(this),this._core.config)}render({el:t,zIndex:n,...o}){t=t||document.body.appendChild(document.createElement("div")),n=n??this._core.config.zIndex++;const r=new be(this._core.seed,{...cu,...o,zIndex:n,el:t});return this._core.addInstance(r),r.mount(),r.id}update(t,n){const o=this._core.getInstance(t);o&&o.updateStore(n)}async destroy(t,n){const o=this._core.getInstance(t);o&&(await o.unmount(n),this._core.removeInstance(o))}}let So;function du(e){return new pu(e)}function _u(){return So}class pu{#n=1;#o={};#t;#e;#r={};#s="";get seed(){return this.#n++}get config(){return this.#e}get controller(){return this.#t}constructor({zIndex:t=1e3,prototypeName:n="$popup",autoDisableScroll:o=!0,debugMode:r=!1}={}){this.#e={zIndex:t,prototypeName:n,autoDisableScroll:o,debugMode:r},this.#t=new fu(this),So=this}addInstance(t){this.#o[t.id.name]=t,this.#u()}getInstance(t){return this.#o[t.name]}removeInstance(t){delete this.#o[t.id.name],Object.keys(this.#o).length===0&&this.#i()}addPlugin(t){return this.getPlugin(t.name)?!1:(this.#r[t.name]=t,!0)}getPlugin(t){return this.#r[t]}removePlugin(t){delete this.#r[t]}#u(){this.config.autoDisableScroll&&document.body.style.overflow!=="hidden"&&(this.#s=document.body.style.overflow,document.body.style.overflow="hidden")}#i(){this.config.autoDisableScroll&&(document.body.style.overflow=this.#s)}}const Eu="1.1.2";function hu(e){return du(e).controller}function To(){return _u().controller}L.POPUP_ANIMATIONS=re,L.POPUP_COMPONENT_INJECTS=Te,L.createPopup=hu,L.definePlugin=uu,L.usePopup=To,L.version=Eu,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-popup-plus",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "keywords": [
5
5
  "vue",
6
6
  "vue3",