vue-infinity-stack 0.0.13 → 0.0.14
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as T, ref as a, 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 q = ["id"], F = /* @__PURE__ */ T({
|
|
3
3
|
__name: "VueInfinityStack",
|
|
4
4
|
props: {
|
|
5
5
|
uuid: { default: "" },
|
|
@@ -10,16 +10,16 @@ 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: { type: [Function, String], 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 o = f, l =
|
|
19
|
+
setup(f, { expose: I, emit: C }) {
|
|
20
|
+
const o = f, l = C, s = a(null), m = a(!0), d = a(!1), p = a(!1), r = a(`popuplayer_${b()}`), y = a(1e3);
|
|
21
21
|
let c = null;
|
|
22
|
-
function
|
|
22
|
+
function b() {
|
|
23
23
|
return Array.from(
|
|
24
24
|
{ length: 8 },
|
|
25
25
|
(e, t) => ((1 + Math.random()) * 65536 | 0).toString(16).substring(1)
|
|
@@ -45,42 +45,42 @@ const B = ["id"], P = /* @__PURE__ */ k({
|
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function g(e) {
|
|
49
49
|
var h;
|
|
50
50
|
const t = ((h = e.state) == null ? void 0 : h.id) || "", n = u().getCur(), i = n.length;
|
|
51
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(),
|
|
52
|
+
l("onClose", { isPopstate: !0 }, o.extra || {}), l("update:visible", !1), u().pop(), p.value = !0;
|
|
53
53
|
const S = document.activeElement;
|
|
54
54
|
S instanceof HTMLElement && S.blur();
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
c && clearTimeout(c), e ?
|
|
59
|
-
|
|
57
|
+
k(() => o.visible, (e) => {
|
|
58
|
+
c && clearTimeout(c), e ? d.value = !0 : c = setTimeout(() => {
|
|
59
|
+
d.value = !1, typeof o.ishasAnimation == "function" && (m.value = !0);
|
|
60
60
|
}, 300), E(() => {
|
|
61
|
-
e ?
|
|
61
|
+
e ? x() : w(), window[e ? "addEventListener" : "removeEventListener"]("popstate", g);
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
|
-
function
|
|
64
|
+
function x() {
|
|
65
65
|
window.history.pushState({ id: r.value }, ""), u().push(r.value), setTimeout(() => {
|
|
66
66
|
l("onOpen", r.value, o.extra || {});
|
|
67
67
|
}, 200);
|
|
68
68
|
}
|
|
69
69
|
function w() {
|
|
70
|
-
if (
|
|
71
|
-
|
|
70
|
+
if (p.value) {
|
|
71
|
+
p.value = !1;
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
l("onClose", { isPopstate: !1 }, o.extra || {}), u().pop(), history.back();
|
|
75
75
|
}
|
|
76
|
-
function
|
|
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
|
|
83
|
+
function A(e, t, n) {
|
|
84
84
|
for (let i = e + 1; i <= t; i++)
|
|
85
85
|
setTimeout(() => {
|
|
86
86
|
n == null || n(i);
|
|
@@ -88,38 +88,40 @@ const B = ["id"], P = /* @__PURE__ */ k({
|
|
|
88
88
|
}
|
|
89
89
|
O(() => {
|
|
90
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 =
|
|
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();
|
|
92
92
|
});
|
|
93
|
-
function
|
|
93
|
+
function v() {
|
|
94
94
|
const e = u().getCur(), t = (e == null ? void 0 : e.length) || 0;
|
|
95
95
|
t && history.go(-t);
|
|
96
96
|
}
|
|
97
97
|
return L(() => {
|
|
98
98
|
var e;
|
|
99
|
-
window.removeEventListener("popstate",
|
|
99
|
+
window.removeEventListener("popstate", g), (e = s.value) != null && e.parentNode && s.value.parentNode.removeChild(s.value);
|
|
100
100
|
}), I({
|
|
101
|
-
asyncHandler:
|
|
102
|
-
backLvBy:
|
|
103
|
-
}), (e, t) => (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
101
|
+
asyncHandler: v,
|
|
102
|
+
backLvBy: A
|
|
103
|
+
}), (e, t) => (V(), z(J, { to: e.getContainer }, [
|
|
104
|
+
M("div", {
|
|
105
|
+
style: B([{ position: "fixed", top: "0", left: "0", bottom: "0", right: "0", width: "100%", "backface-visibility": "hidden", "background-color": "#fff" }, {
|
|
106
|
+
zIndex: e.autoIndex ? y.value : e.zIndex,
|
|
107
|
+
transform: e.visible ? "translateX(0)" : "translateX(100%)",
|
|
108
|
+
transition: e.isAnimation && m.value ? "transform 0.3s" : "none"
|
|
109
|
+
}]),
|
|
110
|
+
ref_key: "popupRef",
|
|
111
|
+
ref: s,
|
|
112
|
+
class: "popup-layer",
|
|
113
|
+
id: e.uuid || r.value
|
|
114
|
+
}, [
|
|
115
|
+
d.value ? _(e.$slots, "default", { key: 0 }) : P("", !0)
|
|
116
|
+
], 12, q)
|
|
117
|
+
], 8, ["to"]));
|
|
116
118
|
}
|
|
117
|
-
}),
|
|
119
|
+
}), X = {
|
|
118
120
|
install(f) {
|
|
119
|
-
f.component("VueInfinityStack",
|
|
121
|
+
f.component("VueInfinityStack", F);
|
|
120
122
|
}
|
|
121
123
|
};
|
|
122
124
|
export {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
+
F as VueInfinityStack,
|
|
126
|
+
X as default
|
|
125
127
|
};
|
|
@@ -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 C=["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:"body"},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_${N()}`),h=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 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 v;const n=((v=e.state)==null?void 0:v.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?A():k(),window[e?"addEventListener":"removeEventListener"]("popstate",S)})});function A(){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 V(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&&I()});function I(){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: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?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,C)],8,["to"]))}}),x={install(d){d.component("VueInfinityStack",y)}};a.VueInfinityStack=y,a.default=x,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.14",
|
|
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",
|