vue-infinity-stack 0.0.13 → 0.0.15

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.
@@ -39,7 +39,7 @@ declare const _sfc_main: import("vue").DefineComponent<import("vue").ExtractProp
39
39
  default: string;
40
40
  };
41
41
  getContainer: {
42
- type: __PropType<string | (() => HTMLElement) | undefined>;
42
+ type: __PropType<string | undefined>;
43
43
  required: false;
44
44
  default: string;
45
45
  };
@@ -93,7 +93,7 @@ declare const _sfc_main: import("vue").DefineComponent<import("vue").ExtractProp
93
93
  default: string;
94
94
  };
95
95
  getContainer: {
96
- type: __PropType<string | (() => HTMLElement) | undefined>;
96
+ type: __PropType<string | undefined>;
97
97
  required: false;
98
98
  default: string;
99
99
  };
@@ -118,7 +118,7 @@ declare const _sfc_main: import("vue").DefineComponent<import("vue").ExtractProp
118
118
  storeName: string | undefined;
119
119
  extra: Record<string, any> | undefined;
120
120
  storeType: "localStorage" | "sessionStorage" | undefined;
121
- getContainer: string | (() => HTMLElement) | undefined;
121
+ getContainer: string | undefined;
122
122
  isAsync: boolean | undefined;
123
123
  ishasAnimation: (() => void) | undefined;
124
124
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -1,5 +1,5 @@
1
- import { defineComponent as k, ref as a, watch as T, nextTick as E, onMounted as O, onBeforeUnmount as L, openBlock as z, createElementBlock as J, normalizeStyle as M, renderSlot as V, createCommentVNode as _ } from "vue";
2
- const B = ["id"], P = /* @__PURE__ */ k({
1
+ import { defineComponent as T, ref as s, watch as k, nextTick as E, onMounted as O, onBeforeUnmount as L, openBlock as V, createBlock as z, Teleport as J, createElementVNode as M, normalizeStyle as B, renderSlot as _, createCommentVNode as P } from "vue";
2
+ const H = ["id"], R = /* @__PURE__ */ T({
3
3
  __name: "VueInfinityStack",
4
4
  props: {
5
5
  uuid: { default: "" },
@@ -10,29 +10,29 @@ const B = ["id"], P = /* @__PURE__ */ k({
10
10
  storeName: { default: "historyState" },
11
11
  extra: { default: () => ({}) },
12
12
  storeType: { default: "localStorage" },
13
- getContainer: { type: [Function, String], default: "" },
13
+ getContainer: { default: "body" },
14
14
  isAsync: { type: Boolean, default: !1 },
15
15
  ishasAnimation: { type: Function, default: () => {
16
16
  } }
17
17
  },
18
18
  emits: ["update:visible", "onOpen", "onClose"],
19
- setup(f, { expose: I, emit: x }) {
20
- const o = f, l = x, s = a(null), m = a(!0), p = a(!1), d = a(!1), r = a(`popuplayer_${C()}`), y = a(1e3);
19
+ setup(f, { expose: I, emit: b }) {
20
+ const i = f, u = b, l = s(null), m = s(!0), d = s(!1), p = s(!1), a = s(`popuplayer_${x()}`), y = s(1e3);
21
21
  let c = null;
22
- function C() {
22
+ function x() {
23
23
  return Array.from(
24
24
  { length: 8 },
25
25
  (e, t) => ((1 + Math.random()) * 65536 | 0).toString(16).substring(1)
26
26
  ).join("");
27
27
  }
28
- function u() {
29
- const e = o.storeName || "historyState", t = window[o.storeType || "localStorage"], n = t.getItem(e) ? JSON.parse(t.getItem(e)) : [];
28
+ function r() {
29
+ const e = i.storeName || "historyState", t = window[i.storeType || "localStorage"], n = t.getItem(e) ? JSON.parse(t.getItem(e)) : [];
30
30
  return {
31
31
  reset() {
32
32
  (!t.getItem(e) || n.length) && t.setItem(e, JSON.stringify([]));
33
33
  },
34
- update(i) {
35
- t.setItem(e, JSON.stringify([...n, i]));
34
+ update(o) {
35
+ t.setItem(e, JSON.stringify([...n, o]));
36
36
  },
37
37
  getCur() {
38
38
  return n;
@@ -40,86 +40,87 @@ const B = ["id"], P = /* @__PURE__ */ k({
40
40
  pop() {
41
41
  n.pop(), t.setItem(e, JSON.stringify(n));
42
42
  },
43
- push(i) {
44
- t.setItem(e, JSON.stringify([...n, i]));
43
+ push(o) {
44
+ t.setItem(e, JSON.stringify([...n, o]));
45
45
  }
46
46
  };
47
47
  }
48
48
  function v(e) {
49
- var h;
50
- const t = ((h = e.state) == null ? void 0 : h.id) || "", n = u().getCur(), i = n.length;
51
- if (i && t !== n[i - 1] && n[i - 1] === r.value) {
52
- l("onClose", { isPopstate: !0 }, o.extra || {}), l("update:visible", !1), u().pop(), d.value = !0;
49
+ var g;
50
+ const t = ((g = e.state) == null ? void 0 : g.id) || "", n = r().getCur(), o = n.length;
51
+ if (o && t !== n[o - 1] && n[o - 1] === a.value) {
52
+ u("onClose", { isPopstate: !0 }, i.extra || {}), u("update:visible", !1), r().pop(), p.value = !0;
53
53
  const S = document.activeElement;
54
54
  S instanceof HTMLElement && S.blur();
55
55
  }
56
56
  }
57
- T(() => o.visible, (e) => {
58
- c && clearTimeout(c), e ? p.value = !0 : c = setTimeout(() => {
59
- p.value = !1, typeof o.ishasAnimation == "function" && (m.value = !0);
57
+ k(() => i.visible, (e) => {
58
+ c && clearTimeout(c), e ? d.value = !0 : c = setTimeout(() => {
59
+ d.value = !1, typeof i.ishasAnimation == "function" && (m.value = !0);
60
60
  }, 300), E(() => {
61
- e ? b() : w(), window[e ? "addEventListener" : "removeEventListener"]("popstate", v);
61
+ e ? w() : C(), window[e ? "addEventListener" : "removeEventListener"]("popstate", v);
62
62
  });
63
63
  });
64
- function b() {
65
- window.history.pushState({ id: r.value }, ""), u().push(r.value), setTimeout(() => {
66
- l("onOpen", r.value, o.extra || {});
64
+ function w() {
65
+ window.history.pushState({ id: a.value }, ""), r().push(a.value), setTimeout(() => {
66
+ u("onOpen", a.value, i.extra || {});
67
67
  }, 200);
68
68
  }
69
- function w() {
70
- if (d.value) {
71
- d.value = !1;
69
+ function C() {
70
+ if (p.value) {
71
+ p.value = !1;
72
72
  return;
73
73
  }
74
- l("onClose", { isPopstate: !1 }, o.extra || {}), u().pop(), history.back();
74
+ u("onClose", { isPopstate: !1 }, i.extra || {}), r().pop(), history.back();
75
75
  }
76
- function A() {
76
+ function N() {
77
77
  return Math.max(
78
78
  ...Array.from(document.querySelectorAll("*")).map(
79
79
  (e) => parseInt(window.getComputedStyle(e).zIndex) || 1
80
80
  )
81
81
  );
82
82
  }
83
- function N(e, t, n) {
84
- for (let i = e + 1; i <= t; i++)
83
+ function A(e, t, n) {
84
+ for (let o = e + 1; o <= t; o++)
85
85
  setTimeout(() => {
86
- n == null || n(i);
87
- }, i * 30);
86
+ n == null || n(o);
87
+ }, o * 30);
88
88
  }
89
89
  O(() => {
90
- let e = null;
91
- typeof o.getContainer == "function" ? e = o.getContainer() : o.getContainer && (e = document.querySelector(o.getContainer)), e == null || e.appendChild(s.value), o.autoIndex && (y.value = A()), !o.isAsync && g();
90
+ i.autoIndex && (y.value = N()), !i.isAsync && h();
92
91
  });
93
- function g() {
94
- const e = u().getCur(), t = (e == null ? void 0 : e.length) || 0;
92
+ function h() {
93
+ const e = r().getCur(), t = (e == null ? void 0 : e.length) || 0;
95
94
  t && history.go(-t);
96
95
  }
97
96
  return L(() => {
98
97
  var e;
99
- window.removeEventListener("popstate", v), (e = s.value) != null && e.parentNode && s.value.parentNode.removeChild(s.value);
98
+ window.removeEventListener("popstate", v), (e = l.value) != null && e.parentNode && l.value.parentNode.removeChild(l.value);
100
99
  }), I({
101
- asyncHandler: g,
102
- backLvBy: N
103
- }), (e, t) => (z(), J("div", {
104
- style: M([{ position: "fixed", top: "0", left: "0", bottom: "0", right: "0", width: "100%", "backface-visibility": "hidden", "background-color": "#fff" }, {
105
- zIndex: e.autoIndex ? y.value : e.zIndex,
106
- transform: e.visible ? "translateX(0)" : "translateX(100%)",
107
- transition: e.isAnimation && m.value ? "transform 0.3s" : "none"
108
- }]),
109
- ref_key: "popupRef",
110
- ref: s,
111
- class: "popup-layer",
112
- id: e.uuid || r.value
113
- }, [
114
- p.value ? V(e.$slots, "default", { key: 0 }) : _("", !0)
115
- ], 12, B));
100
+ asyncHandler: h,
101
+ backLvBy: A
102
+ }), (e, t) => (V(), z(J, { to: e.getContainer }, [
103
+ M("div", {
104
+ style: B([{ position: "fixed", top: "0", left: "0", bottom: "0", right: "0", width: "100%", "backface-visibility": "hidden", "background-color": "#fff" }, {
105
+ zIndex: e.autoIndex ? y.value : e.zIndex,
106
+ transform: e.visible ? "translateX(0)" : "translateX(100%)",
107
+ transition: e.isAnimation && m.value ? "transform 0.3s" : "none"
108
+ }]),
109
+ ref_key: "popupRef",
110
+ ref: l,
111
+ class: "popup-layer",
112
+ id: e.uuid || a.value
113
+ }, [
114
+ d.value ? _(e.$slots, "default", { key: 0 }) : P("", !0)
115
+ ], 12, H)
116
+ ], 8, ["to"]));
116
117
  }
117
- }), H = {
118
+ }), $ = {
118
119
  install(f) {
119
- f.component("VueInfinityStack", P);
120
+ f.component("VueInfinityStack", R);
120
121
  }
121
122
  };
122
123
  export {
123
- P as VueInfinityStack,
124
- H as default
124
+ R as VueInfinityStack,
125
+ $ as default
125
126
  };
@@ -1 +1 @@
1
- (function(a,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(a=typeof globalThis<"u"?globalThis:a||self,t(a.VueInfinityStack={},a.Vue))})(this,function(a,t){"use strict";const x=["id"],y=t.defineComponent({__name:"VueInfinityStack",props:{uuid:{default:""},visible:{type:Boolean},isAnimation:{type:Boolean,default:!0},zIndex:{default:1e3},autoIndex:{type:Boolean},storeName:{default:"historyState"},extra:{default:()=>({})},storeType:{default:"localStorage"},getContainer:{type:[Function,String],default:""},isAsync:{type:Boolean,default:!1},ishasAnimation:{type:Function,default:()=>{}}},emits:["update:visible","onOpen","onClose"],setup(d,{expose:w,emit:T}){const i=d,f=T,r=t.ref(null),g=t.ref(!0),p=t.ref(!1),c=t.ref(!1),u=t.ref(`popuplayer_${A()}`),h=t.ref(1e3);let m=null;function A(){return Array.from({length:8},(e,n)=>((1+Math.random())*65536|0).toString(16).substring(1)).join("")}function l(){const e=i.storeName||"historyState",n=window[i.storeType||"localStorage"],o=n.getItem(e)?JSON.parse(n.getItem(e)):[];return{reset(){(!n.getItem(e)||o.length)&&n.setItem(e,JSON.stringify([]))},update(s){n.setItem(e,JSON.stringify([...o,s]))},getCur(){return o},pop(){o.pop(),n.setItem(e,JSON.stringify(o))},push(s){n.setItem(e,JSON.stringify([...o,s]))}}}function S(e){var I;const n=((I=e.state)==null?void 0:I.id)||"",o=l().getCur(),s=o.length;if(s&&n!==o[s-1]&&o[s-1]===u.value){f("onClose",{isPopstate:!0},i.extra||{}),f("update:visible",!1),l().pop(),c.value=!0;const b=document.activeElement;b instanceof HTMLElement&&b.blur()}}t.watch(()=>i.visible,e=>{m&&clearTimeout(m),e?p.value=!0:m=setTimeout(()=>{p.value=!1,typeof i.ishasAnimation=="function"&&(g.value=!0)},300),t.nextTick(()=>{e?N():k(),window[e?"addEventListener":"removeEventListener"]("popstate",S)})});function N(){window.history.pushState({id:u.value},""),l().push(u.value),setTimeout(()=>{f("onOpen",u.value,i.extra||{})},200)}function k(){if(c.value){c.value=!1;return}f("onClose",{isPopstate:!1},i.extra||{}),l().pop(),history.back()}function O(){return Math.max(...Array.from(document.querySelectorAll("*")).map(e=>parseInt(window.getComputedStyle(e).zIndex)||1))}function E(e,n,o){for(let s=e+1;s<=n;s++)setTimeout(()=>{o==null||o(s)},s*30)}t.onMounted(()=>{let e=null;typeof i.getContainer=="function"?e=i.getContainer():i.getContainer&&(e=document.querySelector(i.getContainer)),e==null||e.appendChild(r.value),i.autoIndex&&(h.value=O()),!i.isAsync&&v()});function v(){const e=l().getCur(),n=(e==null?void 0:e.length)||0;n&&history.go(-n)}return t.onBeforeUnmount(()=>{var e;window.removeEventListener("popstate",S),(e=r.value)!=null&&e.parentNode&&r.value.parentNode.removeChild(r.value)}),w({asyncHandler:v,backLvBy:E}),(e,n)=>(t.openBlock(),t.createElementBlock("div",{style:t.normalizeStyle([{position:"fixed",top:"0",left:"0",bottom:"0",right:"0",width:"100%","backface-visibility":"hidden","background-color":"#fff"},{zIndex:e.autoIndex?h.value:e.zIndex,transform:e.visible?"translateX(0)":"translateX(100%)",transition:e.isAnimation&&g.value?"transform 0.3s":"none"}]),ref_key:"popupRef",ref:r,class:"popup-layer",id:e.uuid||u.value},[p.value?t.renderSlot(e.$slots,"default",{key:0}):t.createCommentVNode("",!0)],12,x))}}),C={install(d){d.component("VueInfinityStack",y)}};a.VueInfinityStack=y,a.default=C,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(a,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(a=typeof globalThis<"u"?globalThis:a||self,t(a.VueInfinityStack={},a.Vue))})(this,function(a,t){"use strict";const x=["id"],y=t.defineComponent({__name:"VueInfinityStack",props:{uuid:{default:""},visible:{type:Boolean},isAnimation:{type:Boolean,default:!0},zIndex:{default:1e3},autoIndex:{type:Boolean},storeName:{default:"historyState"},extra:{default:()=>({})},storeType:{default:"localStorage"},getContainer:{default:"body"},isAsync:{type:Boolean,default:!1},ishasAnimation:{type:Function,default:()=>{}}},emits:["update:visible","onOpen","onClose"],setup(d,{expose:C,emit:T}){const s=d,l=T,f=t.ref(null),h=t.ref(!0),p=t.ref(!1),c=t.ref(!1),r=t.ref(`popuplayer_${N()}`),g=t.ref(1e3);let m=null;function N(){return Array.from({length:8},(e,n)=>((1+Math.random())*65536|0).toString(16).substring(1)).join("")}function u(){const e=s.storeName||"historyState",n=window[s.storeType||"localStorage"],o=n.getItem(e)?JSON.parse(n.getItem(e)):[];return{reset(){(!n.getItem(e)||o.length)&&n.setItem(e,JSON.stringify([]))},update(i){n.setItem(e,JSON.stringify([...o,i]))},getCur(){return o},pop(){o.pop(),n.setItem(e,JSON.stringify(o))},push(i){n.setItem(e,JSON.stringify([...o,i]))}}}function S(e){var v;const n=((v=e.state)==null?void 0:v.id)||"",o=u().getCur(),i=o.length;if(i&&n!==o[i-1]&&o[i-1]===r.value){l("onClose",{isPopstate:!0},s.extra||{}),l("update:visible",!1),u().pop(),c.value=!0;const b=document.activeElement;b instanceof HTMLElement&&b.blur()}}t.watch(()=>s.visible,e=>{m&&clearTimeout(m),e?p.value=!0:m=setTimeout(()=>{p.value=!1,typeof s.ishasAnimation=="function"&&(h.value=!0)},300),t.nextTick(()=>{e?A():k(),window[e?"addEventListener":"removeEventListener"]("popstate",S)})});function A(){window.history.pushState({id:r.value},""),u().push(r.value),setTimeout(()=>{l("onOpen",r.value,s.extra||{})},200)}function k(){if(c.value){c.value=!1;return}l("onClose",{isPopstate:!1},s.extra||{}),u().pop(),history.back()}function O(){return Math.max(...Array.from(document.querySelectorAll("*")).map(e=>parseInt(window.getComputedStyle(e).zIndex)||1))}function V(e,n,o){for(let i=e+1;i<=n;i++)setTimeout(()=>{o==null||o(i)},i*30)}t.onMounted(()=>{s.autoIndex&&(g.value=O()),!s.isAsync&&I()});function I(){const e=u().getCur(),n=(e==null?void 0:e.length)||0;n&&history.go(-n)}return t.onBeforeUnmount(()=>{var e;window.removeEventListener("popstate",S),(e=f.value)!=null&&e.parentNode&&f.value.parentNode.removeChild(f.value)}),C({asyncHandler:I,backLvBy:V}),(e,n)=>(t.openBlock(),t.createBlock(t.Teleport,{to:e.getContainer},[t.createElementVNode("div",{style:t.normalizeStyle([{position:"fixed",top:"0",left:"0",bottom:"0",right:"0",width:"100%","backface-visibility":"hidden","background-color":"#fff"},{zIndex:e.autoIndex?g.value:e.zIndex,transform:e.visible?"translateX(0)":"translateX(100%)",transition:e.isAnimation&&h.value?"transform 0.3s":"none"}]),ref_key:"popupRef",ref:f,class:"popup-layer",id:e.uuid||r.value},[p.value?t.renderSlot(e.$slots,"default",{key:0}):t.createCommentVNode("",!0)],12,x)],8,["to"]))}}),w={install(d){d.component("VueInfinityStack",y)}};a.VueInfinityStack=y,a.default=w,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-infinity-stack",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "VueInfinityStack is a modern infinite stacking overlay solution designed exclusively for Vue 3, empowering simple yet elegant management of complex overlays. Whether handling simple dialogs, intricate multi-step wizards, or deeply nested user interfaces, VueInfinityStack delivers seamless and reliable management capabilities.",
5
5
  "main": "dist/vue-infinity-stack.umd.js",
6
6
  "module": "dist/vue-infinity-stack.es.js",