@zealsolutions/zeal-ui 1.0.0-alpha.332 → 1.0.0-alpha.334
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/components/session/index.js +65 -0
- package/dist/components/tiptap/index.js +2959 -2879
- package/package.json +6 -2
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ref as p, openBlock as k, createElementBlock as D, createElementVNode as h, toDisplayString as E } from "vue";
|
|
2
|
+
const I = ["mousemove", "keydown", "click", "scroll", "touchstart"], M = 1e3, L = 1e3, R = 60 * 1e3;
|
|
3
|
+
function C({
|
|
4
|
+
idleMinutes: s,
|
|
5
|
+
countdownSeconds: n,
|
|
6
|
+
redirectUrl: a,
|
|
7
|
+
onKeepAlive: o,
|
|
8
|
+
isEnabled: T
|
|
9
|
+
}) {
|
|
10
|
+
const t = p(!1), u = p(n), f = s * 60 * 1e3, x = f - n * 1e3;
|
|
11
|
+
let l = Date.now(), m = 0, r = !1, c = 0, i = null, d = !1;
|
|
12
|
+
function w() {
|
|
13
|
+
if (o)
|
|
14
|
+
try {
|
|
15
|
+
o();
|
|
16
|
+
} catch {
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function g() {
|
|
20
|
+
const e = Date.now();
|
|
21
|
+
e < m || (m = e + L, l = e, r = !0, t.value && (t.value = !1));
|
|
22
|
+
}
|
|
23
|
+
function _() {
|
|
24
|
+
const e = Date.now(), v = e - l;
|
|
25
|
+
if (v >= f) {
|
|
26
|
+
d || (d = !0, y(), window.location.assign(a));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
v >= x ? (t.value = !0, u.value = Math.max(0, Math.ceil((f - v) / 1e3))) : (t.value = !1, r && o && e - c >= R && (c = e, w())), r = !1;
|
|
30
|
+
}
|
|
31
|
+
function b() {
|
|
32
|
+
!T || i || (l = Date.now(), r = !1, c = 0, d = !1, I.forEach((e) => window.addEventListener(e, g, { passive: !0 })), i = setInterval(_, M));
|
|
33
|
+
}
|
|
34
|
+
function y() {
|
|
35
|
+
i && (clearInterval(i), i = null), I.forEach((e) => window.removeEventListener(e, g));
|
|
36
|
+
}
|
|
37
|
+
function A() {
|
|
38
|
+
l = Date.now(), c = Date.now(), t.value = !1, u.value = n, w();
|
|
39
|
+
}
|
|
40
|
+
return { isWarning: t, secondsRemaining: u, stayActive: A, start: b, stop: y };
|
|
41
|
+
}
|
|
42
|
+
const S = {
|
|
43
|
+
role: "alert",
|
|
44
|
+
class: "fixed inset-x-0 top-0 z-[9999] flex items-center justify-center gap-4 bg-warning-950 px-4 py-3 text-white shadow-lg"
|
|
45
|
+
}, V = { class: "text-sm font-medium" }, N = {
|
|
46
|
+
__name: "IdleWarningBar",
|
|
47
|
+
props: {
|
|
48
|
+
secondsRemaining: { type: Number, required: !0 }
|
|
49
|
+
},
|
|
50
|
+
emits: ["stay-active"],
|
|
51
|
+
setup(s) {
|
|
52
|
+
return (n, a) => (k(), D("div", S, [
|
|
53
|
+
h("span", V, " You will be logged out in " + E(s.secondsRemaining) + " second" + E(s.secondsRemaining === 1 ? "" : "s") + " due to inactivity. ", 1),
|
|
54
|
+
h("button", {
|
|
55
|
+
type: "button",
|
|
56
|
+
class: "rounded-md bg-white/20 px-3 py-1 text-sm font-semibold hover:bg-white/30",
|
|
57
|
+
onClick: a[0] || (a[0] = (o) => n.$emit("stay-active"))
|
|
58
|
+
}, " Stay logged in ")
|
|
59
|
+
]));
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
export {
|
|
63
|
+
N as IdleWarningBar,
|
|
64
|
+
C as useIdleTimeout
|
|
65
|
+
};
|