vue-infinity-stack 0.0.14 → 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 |
|
|
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 |
|
|
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 |
|
|
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 T, ref as
|
|
2
|
-
const
|
|
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 q = ["id"], F = /* @__PURE__ */ T({
|
|
|
10
10
|
storeName: { default: "historyState" },
|
|
11
11
|
extra: { default: () => ({}) },
|
|
12
12
|
storeType: { default: "localStorage" },
|
|
13
|
-
getContainer: {
|
|
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:
|
|
20
|
-
const
|
|
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
|
|
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
|
|
29
|
-
const 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(
|
|
35
|
-
t.setItem(e, JSON.stringify([...n,
|
|
34
|
+
update(o) {
|
|
35
|
+
t.setItem(e, JSON.stringify([...n, o]));
|
|
36
36
|
},
|
|
37
37
|
getCur() {
|
|
38
38
|
return n;
|
|
@@ -40,38 +40,38 @@ const q = ["id"], F = /* @__PURE__ */ T({
|
|
|
40
40
|
pop() {
|
|
41
41
|
n.pop(), t.setItem(e, JSON.stringify(n));
|
|
42
42
|
},
|
|
43
|
-
push(
|
|
44
|
-
t.setItem(e, JSON.stringify([...n,
|
|
43
|
+
push(o) {
|
|
44
|
+
t.setItem(e, JSON.stringify([...n, o]));
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
var
|
|
50
|
-
const t = ((
|
|
51
|
-
if (
|
|
52
|
-
|
|
48
|
+
function v(e) {
|
|
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
|
-
k(() =>
|
|
57
|
+
k(() => i.visible, (e) => {
|
|
58
58
|
c && clearTimeout(c), e ? d.value = !0 : c = setTimeout(() => {
|
|
59
|
-
d.value = !1, typeof
|
|
59
|
+
d.value = !1, typeof i.ishasAnimation == "function" && (m.value = !0);
|
|
60
60
|
}, 300), E(() => {
|
|
61
|
-
e ?
|
|
61
|
+
e ? w() : C(), window[e ? "addEventListener" : "removeEventListener"]("popstate", v);
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
|
-
function
|
|
65
|
-
window.history.pushState({ id:
|
|
66
|
-
|
|
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
|
|
69
|
+
function C() {
|
|
70
70
|
if (p.value) {
|
|
71
71
|
p.value = !1;
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
u("onClose", { isPopstate: !1 }, i.extra || {}), r().pop(), history.back();
|
|
75
75
|
}
|
|
76
76
|
function N() {
|
|
77
77
|
return Math.max(
|
|
@@ -81,24 +81,23 @@ const q = ["id"], F = /* @__PURE__ */ T({
|
|
|
81
81
|
);
|
|
82
82
|
}
|
|
83
83
|
function A(e, t, n) {
|
|
84
|
-
for (let
|
|
84
|
+
for (let o = e + 1; o <= t; o++)
|
|
85
85
|
setTimeout(() => {
|
|
86
|
-
n == null || n(
|
|
87
|
-
},
|
|
86
|
+
n == null || n(o);
|
|
87
|
+
}, o * 30);
|
|
88
88
|
}
|
|
89
89
|
O(() => {
|
|
90
|
-
|
|
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 = N()), !o.isAsync && v();
|
|
90
|
+
i.autoIndex && (y.value = N()), !i.isAsync && h();
|
|
92
91
|
});
|
|
93
|
-
function
|
|
94
|
-
const e =
|
|
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",
|
|
98
|
+
window.removeEventListener("popstate", v), (e = l.value) != null && e.parentNode && l.value.parentNode.removeChild(l.value);
|
|
100
99
|
}), I({
|
|
101
|
-
asyncHandler:
|
|
100
|
+
asyncHandler: h,
|
|
102
101
|
backLvBy: A
|
|
103
102
|
}), (e, t) => (V(), z(J, { to: e.getContainer }, [
|
|
104
103
|
M("div", {
|
|
@@ -108,20 +107,20 @@ const q = ["id"], F = /* @__PURE__ */ T({
|
|
|
108
107
|
transition: e.isAnimation && m.value ? "transform 0.3s" : "none"
|
|
109
108
|
}]),
|
|
110
109
|
ref_key: "popupRef",
|
|
111
|
-
ref:
|
|
110
|
+
ref: l,
|
|
112
111
|
class: "popup-layer",
|
|
113
|
-
id: e.uuid ||
|
|
112
|
+
id: e.uuid || a.value
|
|
114
113
|
}, [
|
|
115
114
|
d.value ? _(e.$slots, "default", { key: 0 }) : P("", !0)
|
|
116
|
-
], 12,
|
|
115
|
+
], 12, H)
|
|
117
116
|
], 8, ["to"]));
|
|
118
117
|
}
|
|
119
|
-
}),
|
|
118
|
+
}), $ = {
|
|
120
119
|
install(f) {
|
|
121
|
-
f.component("VueInfinityStack",
|
|
120
|
+
f.component("VueInfinityStack", R);
|
|
122
121
|
}
|
|
123
122
|
};
|
|
124
123
|
export {
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
R as VueInfinityStack,
|
|
125
|
+
$ as default
|
|
127
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
|
|
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.
|
|
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",
|