@nivaro/react 0.3.83 → 0.3.84

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,97 @@
1
+ import { jsx as t, jsxs as s } from "react/jsx-runtime";
2
+ import { LogOut as m, X as h } from "lucide-react";
3
+ import { useState as f, useEffect as g } from "react";
4
+ import { useOptionalNivaroClient as b } from "../context.js";
5
+ import { get as N, del as u } from "../lib/commands.js";
6
+ import { readSignOutNote as d, clearSignOutNote as v, parseSignOutNote as w, sameSignOutNote as O, signOutNoteHeading as x, SIGN_OUT_NOTE_WINDOW_EVENT as c, SIGN_OUT_NOTE_KEY as y } from "../lib/sign-out-note.js";
7
+ function I() {
8
+ const [e, n] = f(() => d());
9
+ return g(() => {
10
+ const i = () => n(d()), r = (o) => {
11
+ o.key === y && i();
12
+ };
13
+ return window.addEventListener(c, i), window.addEventListener("storage", r), () => {
14
+ window.removeEventListener(c, i), window.removeEventListener("storage", r);
15
+ };
16
+ }, []), e ? /* @__PURE__ */ t(
17
+ "div",
18
+ {
19
+ role: "alert",
20
+ "data-sign-out-note": !0,
21
+ className: "fixed inset-x-0 top-0 z-[60] border-b-4 border-[#92400e] bg-[#fbbf24] px-4 py-5 text-[#111827] shadow-xl sm:px-8 sm:py-7",
22
+ children: /* @__PURE__ */ s("div", { className: "mx-auto flex max-w-5xl items-start gap-4", children: [
23
+ /* @__PURE__ */ t(m, { className: "mt-1 h-8 w-8 shrink-0 sm:h-10 sm:w-10", strokeWidth: 2.25, "aria-hidden": !0 }),
24
+ /* @__PURE__ */ s("div", { className: "min-w-0", children: [
25
+ /* @__PURE__ */ t("p", { className: "text-[15px] font-semibold uppercase tracking-wide sm:text-[17px]", children: x(e) }),
26
+ /* @__PURE__ */ t("p", { className: "mt-1.5 break-words text-[22px] font-bold leading-snug sm:text-[30px]", children: e.message })
27
+ ] })
28
+ ] })
29
+ }
30
+ ) : null;
31
+ }
32
+ function W() {
33
+ const e = b(), [n, i] = f(null);
34
+ if (g(() => {
35
+ if (!e) return;
36
+ let o = !0;
37
+ const p = d();
38
+ return v(), e.request(N("/security/my/sign-out-note")).then((a) => {
39
+ if (!o) return;
40
+ const l = w(a == null ? void 0 : a.data);
41
+ if (l) {
42
+ if (O(l, p)) {
43
+ e.request(u("/security/my/sign-out-note")).catch(() => {
44
+ });
45
+ return;
46
+ }
47
+ i(l);
48
+ }
49
+ }).catch(() => {
50
+ }), () => {
51
+ o = !1;
52
+ };
53
+ }, [e]), !n) return null;
54
+ const r = () => {
55
+ i(null), e && e.request(u("/security/my/sign-out-note")).catch(() => {
56
+ });
57
+ };
58
+ return /* @__PURE__ */ t(
59
+ "div",
60
+ {
61
+ role: "alertdialog",
62
+ "aria-labelledby": "sign-out-note-heading",
63
+ "data-sign-out-note-after": !0,
64
+ className: "fixed inset-x-0 top-0 z-[70] border-b-4 border-[#92400e] bg-[#fbbf24] px-4 py-4 text-[#111827] shadow-xl sm:px-8",
65
+ children: /* @__PURE__ */ s("div", { className: "mx-auto flex max-w-5xl items-start gap-4", children: [
66
+ /* @__PURE__ */ t(m, { className: "mt-0.5 h-7 w-7 shrink-0", strokeWidth: 2.25, "aria-hidden": !0 }),
67
+ /* @__PURE__ */ s("div", { className: "min-w-0 flex-1", children: [
68
+ /* @__PURE__ */ t(
69
+ "p",
70
+ {
71
+ id: "sign-out-note-heading",
72
+ className: "text-[13px] font-semibold uppercase tracking-wide",
73
+ children: x(n)
74
+ }
75
+ ),
76
+ /* @__PURE__ */ t("p", { className: "mt-1 break-words text-[20px] font-bold leading-snug", children: n.message })
77
+ ] }),
78
+ /* @__PURE__ */ s(
79
+ "button",
80
+ {
81
+ type: "button",
82
+ onClick: r,
83
+ className: "inline-flex shrink-0 items-center gap-1.5 rounded-lg bg-[#111827] px-3 py-2 text-[13px] font-semibold text-white hover:bg-[#1f2937] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#111827] focus-visible:ring-offset-2 focus-visible:ring-offset-[#fbbf24]",
84
+ children: [
85
+ /* @__PURE__ */ t(h, { className: "h-4 w-4", "aria-hidden": !0 }),
86
+ " Got it"
87
+ ]
88
+ }
89
+ )
90
+ ] })
91
+ }
92
+ );
93
+ }
94
+ export {
95
+ W as SignOutNoteAfterSignIn,
96
+ I as SignOutNoteBanner
97
+ };