@zealsolutions/zeal-ui 1.0.0-alpha.333 → 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.
|
@@ -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
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zealsolutions/zeal-ui",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.334",
|
|
4
4
|
"description": "UI library for Zeal Solutions",
|
|
5
5
|
"author": "Zeal Solutions",
|
|
6
6
|
"license": "ISC",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"./modals": "./dist/components/modals/index",
|
|
39
39
|
"./navigation": "./dist/components/navigation/index",
|
|
40
40
|
"./overlays": "./dist/components/overlays/index",
|
|
41
|
+
"./session": "./dist/components/session/index",
|
|
41
42
|
"./tiptap": "./dist/components/tiptap/index",
|
|
42
43
|
"./tooltips": "./dist/components/tooltips/index",
|
|
43
44
|
"./transitions": "./dist/components/transitions/index",
|
|
@@ -50,6 +51,7 @@
|
|
|
50
51
|
"build": "vite build",
|
|
51
52
|
"build:publish": "npm run build && npm publish",
|
|
52
53
|
"preview": "vite preview",
|
|
54
|
+
"test": "vitest run",
|
|
53
55
|
"storybook": "storybook dev -p 6006",
|
|
54
56
|
"build-storybook": "storybook build",
|
|
55
57
|
"chromatic": "npx chromatic --project-token=chpt_368bf7fc8d469c1"
|
|
@@ -106,8 +108,10 @@
|
|
|
106
108
|
"@whitespace/storybook-addon-html": "^6.1.1",
|
|
107
109
|
"autoprefixer": "^10.4.19",
|
|
108
110
|
"chromatic": "^11.3.1",
|
|
111
|
+
"jsdom": "^25.0.0",
|
|
109
112
|
"storybook": "^8.1.11",
|
|
110
113
|
"vite": "^5.2.8",
|
|
111
|
-
"vite-plugin-vue-devtools": "^7.0.25"
|
|
114
|
+
"vite-plugin-vue-devtools": "^7.0.25",
|
|
115
|
+
"vitest": "^3.0.0"
|
|
112
116
|
}
|
|
113
117
|
}
|