@rpcbase/ui 0.237.0 → 0.239.0
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/AddressAutocompleteInput/index.d.ts.map +1 -1
- package/dist/components/Notifications/NotificationsDrawer.d.ts.map +1 -1
- package/dist/helpers/useMapsLibrary.d.ts.map +1 -1
- package/dist/index151.js +4 -4
- package/dist/index156.js +1 -1
- package/dist/index157.js +1 -1
- package/dist/index16.js +228 -196
- package/dist/index16.js.map +1 -1
- package/dist/index164.js +1 -1
- package/dist/index165.js +6 -6
- package/dist/index167.js +1 -1
- package/dist/index169.js +1 -1
- package/dist/index172.js +3 -3
- package/dist/index175.js +1 -1
- package/dist/index176.js +4 -4
- package/dist/index182.js +1 -1
- package/dist/index184.js +12 -12
- package/dist/index187.js +5 -5
- package/dist/index189.js +3 -3
- package/dist/index190.js +1 -1
- package/dist/index193.js +3 -3
- package/dist/index194.js +5 -5
- package/dist/index22.js.map +1 -1
- package/dist/index256.js +14 -20
- package/dist/index256.js.map +1 -1
- package/dist/index257.js +146 -58
- package/dist/index257.js.map +1 -1
- package/dist/index258.js +30 -6
- package/dist/index258.js.map +1 -1
- package/dist/index259.js +9 -11
- package/dist/index259.js.map +1 -1
- package/dist/index260.js +44 -46
- package/dist/index260.js.map +1 -1
- package/dist/index261.js +12 -4
- package/dist/index261.js.map +1 -1
- package/dist/index262.js +43 -28
- package/dist/index262.js.map +1 -1
- package/dist/index263.js +93 -14
- package/dist/index263.js.map +1 -1
- package/dist/index264.js +86 -5
- package/dist/index264.js.map +1 -1
- package/dist/index265.js +105 -21
- package/dist/index265.js.map +1 -1
- package/dist/index266.js +51 -50
- package/dist/index266.js.map +1 -1
- package/dist/index267.js +11 -25
- package/dist/index267.js.map +1 -1
- package/dist/index268.js +37 -41
- package/dist/index268.js.map +1 -1
- package/dist/index269.js +8 -39
- package/dist/index269.js.map +1 -1
- package/dist/index270.js +117 -45
- package/dist/index270.js.map +1 -1
- package/dist/index271.js +17 -20
- package/dist/index271.js.map +1 -1
- package/dist/index272.js +14 -69
- package/dist/index272.js.map +1 -1
- package/dist/index273.js +3 -17
- package/dist/index273.js.map +1 -1
- package/dist/index274.js +36 -11
- package/dist/index274.js.map +1 -1
- package/dist/index275.js +20 -27
- package/dist/index275.js.map +1 -1
- package/dist/index276.js +9 -13
- package/dist/index276.js.map +1 -1
- package/dist/index277.js +8 -18
- package/dist/index277.js.map +1 -1
- package/dist/index278.js +20 -37
- package/dist/index278.js.map +1 -1
- package/dist/index279.js +59 -255
- package/dist/index279.js.map +1 -1
- package/dist/index280.js +6 -278
- package/dist/index280.js.map +1 -1
- package/dist/index281.js +10 -67
- package/dist/index281.js.map +1 -1
- package/dist/index282.js +47 -96
- package/dist/index282.js.map +1 -1
- package/dist/index283.js +4 -84
- package/dist/index283.js.map +1 -1
- package/dist/index284.js +29 -3
- package/dist/index284.js.map +1 -1
- package/dist/index285.js +15 -28
- package/dist/index285.js.map +1 -1
- package/dist/index286.js +5 -16
- package/dist/index286.js.map +1 -1
- package/dist/index287.js +22 -35
- package/dist/index287.js.map +1 -1
- package/dist/index288.js +51 -16
- package/dist/index288.js.map +1 -1
- package/dist/index289.js +25 -3
- package/dist/index289.js.map +1 -1
- package/dist/index290.js +41 -26
- package/dist/index290.js.map +1 -1
- package/dist/index291.js +38 -27
- package/dist/index291.js.map +1 -1
- package/dist/index292.js +45 -4
- package/dist/index292.js.map +1 -1
- package/dist/index293.js +20 -78
- package/dist/index293.js.map +1 -1
- package/dist/index294.js +65 -264
- package/dist/index294.js.map +1 -1
- package/dist/index295.js +17 -11
- package/dist/index295.js.map +1 -1
- package/dist/index296.js +11 -10
- package/dist/index296.js.map +1 -1
- package/dist/index297.js +26 -24
- package/dist/index297.js.map +1 -1
- package/dist/index298.js +13 -16
- package/dist/index298.js.map +1 -1
- package/dist/index299.js +15 -122
- package/dist/index299.js.map +1 -1
- package/dist/index3.js.map +1 -1
- package/dist/index300.js +36 -5
- package/dist/index300.js.map +1 -1
- package/dist/index301.js +260 -38
- package/dist/index301.js.map +1 -1
- package/dist/index302.js +275 -62
- package/dist/index302.js.map +1 -1
- package/dist/index303.js +68 -13
- package/dist/index303.js.map +1 -1
- package/dist/index304.js +99 -7
- package/dist/index304.js.map +1 -1
- package/dist/index305.js +83 -5
- package/dist/index305.js.map +1 -1
- package/dist/index306.js +3 -3
- package/dist/index306.js.map +1 -1
- package/dist/index307.js +29 -10
- package/dist/index307.js.map +1 -1
- package/dist/index308.js +15 -6
- package/dist/index308.js.map +1 -1
- package/dist/index309.js +34 -133
- package/dist/index309.js.map +1 -1
- package/dist/index310.js +15 -398
- package/dist/index310.js.map +1 -1
- package/dist/index311.js +3 -52
- package/dist/index311.js.map +1 -1
- package/dist/index312.js +26 -11
- package/dist/index312.js.map +1 -1
- package/dist/index313.js +27 -10
- package/dist/index313.js.map +1 -1
- package/dist/index314.js +4 -14
- package/dist/index314.js.map +1 -1
- package/dist/index315.js +75 -151
- package/dist/index315.js.map +1 -1
- package/dist/index316.js +267 -28
- package/dist/index316.js.map +1 -1
- package/dist/index317.js +11 -9
- package/dist/index317.js.map +1 -1
- package/dist/index318.js +11 -49
- package/dist/index318.js.map +1 -1
- package/dist/index319.js +25 -11
- package/dist/index319.js.map +1 -1
- package/dist/index320.js +15 -43
- package/dist/index320.js.map +1 -1
- package/dist/index321.js +119 -89
- package/dist/index321.js.map +1 -1
- package/dist/index322.js +5 -86
- package/dist/index322.js.map +1 -1
- package/dist/index323.js +39 -104
- package/dist/index323.js.map +1 -1
- package/dist/index324.js +60 -47
- package/dist/index324.js.map +1 -1
- package/dist/index325.js +13 -11
- package/dist/index325.js.map +1 -1
- package/dist/index326.js +7 -37
- package/dist/index326.js.map +1 -1
- package/dist/index327.js +5 -8
- package/dist/index327.js.map +1 -1
- package/dist/index328.js +3 -116
- package/dist/index328.js.map +1 -1
- package/dist/index329.js +10 -17
- package/dist/index329.js.map +1 -1
- package/dist/index330.js +7 -15
- package/dist/index330.js.map +1 -1
- package/dist/index331.js +133 -3
- package/dist/index331.js.map +1 -1
- package/dist/index332.js +398 -35
- package/dist/index332.js.map +1 -1
- package/dist/index333.js +52 -20
- package/dist/index333.js.map +1 -1
- package/dist/index334.js +11 -9
- package/dist/index334.js.map +1 -1
- package/dist/index335.js +11 -8
- package/dist/index335.js.map +1 -1
- package/dist/index336.js +3 -3
- package/dist/index346.js +2 -2
- package/dist/index348.js +8 -8
- package/dist/index349.js +3 -3
- package/dist/index350.js +2 -2
- package/dist/index351.js +5 -5
- package/dist/index353.js +1 -1
- package/dist/index362.js +21 -4
- package/dist/index362.js.map +1 -1
- package/dist/index363.js +4 -12
- package/dist/index363.js.map +1 -1
- package/dist/index364.js +5 -16
- package/dist/index364.js.map +1 -1
- package/dist/index365.js +11 -5
- package/dist/index365.js.map +1 -1
- package/dist/index366.js +15 -19
- package/dist/index366.js.map +1 -1
- package/dist/index367.js +19 -43
- package/dist/index367.js.map +1 -1
- package/dist/index368.js +40 -13
- package/dist/index368.js.map +1 -1
- package/dist/index369.js +17 -4
- package/dist/index369.js.map +1 -1
- package/dist/index370.js +4 -200
- package/dist/index370.js.map +1 -1
- package/dist/index371.js +197 -74
- package/dist/index371.js.map +1 -1
- package/dist/index372.js +77 -20
- package/dist/index372.js.map +1 -1
- package/dist/index374.js +3 -3
- package/dist/index375.js +1 -1
- package/dist/index376.js +3 -3
- package/dist/index378.js +2 -2
- package/dist/index380.js +1 -1
- package/dist/index381.js +2 -2
- package/dist/index407.js +1 -1
- package/dist/index49.js +28 -28
- package/dist/index50.js +21 -21
- package/dist/index51.js +1 -1
- package/dist/index52.js +8 -8
- package/dist/index53.js +2 -2
- package/dist/index55.js +17 -17
- package/dist/index56.js +4 -4
- package/dist/index57.js +3 -3
- package/dist/index58.js +7 -7
- package/dist/index59.js +4 -4
- package/dist/index60.js +12 -12
- package/dist/index61.js +2 -2
- package/dist/index62.js +2 -2
- package/package.json +1 -1
package/dist/index16.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import { j as t } from "./index30.js";
|
|
2
|
-
import { c as
|
|
3
|
-
import { useContext as
|
|
4
|
-
import { X as
|
|
5
|
-
import { cn as
|
|
6
|
-
import { DialogRoot as
|
|
7
|
-
import { DialogPortal as
|
|
8
|
-
import { DialogBackdrop as
|
|
9
|
-
import { DialogPopup as
|
|
10
|
-
import { DialogTitle as
|
|
11
|
-
import { DialogClose as
|
|
12
|
-
const
|
|
13
|
-
const e = Date.parse(
|
|
2
|
+
import { c as te } from "./index28.js";
|
|
3
|
+
import { useContext as ie, useState as U, useRef as H, useMemo as G, useCallback as re, useEffect as W, createContext as se } from "react";
|
|
4
|
+
import { X as ae, Loader2 as ce, MoreVertical as le } from "lucide-react";
|
|
5
|
+
import { cn as V } from "./index2.js";
|
|
6
|
+
import { DialogRoot as de } from "./index34.js";
|
|
7
|
+
import { DialogPortal as ue } from "./index39.js";
|
|
8
|
+
import { DialogBackdrop as me } from "./index38.js";
|
|
9
|
+
import { DialogPopup as fe } from "./index36.js";
|
|
10
|
+
import { DialogTitle as xe } from "./index40.js";
|
|
11
|
+
import { DialogClose as he } from "./index35.js";
|
|
12
|
+
const ne = (o) => {
|
|
13
|
+
const e = Date.parse(o);
|
|
14
14
|
return Number.isFinite(e) ? e : 0;
|
|
15
|
-
},
|
|
16
|
-
const e = new Date(
|
|
15
|
+
}, pe = (o) => {
|
|
16
|
+
const e = new Date(ne(o));
|
|
17
17
|
if (!Number.isFinite(e.getTime())) return "unknown";
|
|
18
|
-
const n = e.getFullYear(),
|
|
19
|
-
return `${n}-${
|
|
20
|
-
},
|
|
21
|
-
if (
|
|
22
|
-
const [e, n,
|
|
23
|
-
if (!Number.isFinite(a) || !Number.isFinite(
|
|
24
|
-
const
|
|
25
|
-
if (!Number.isFinite(
|
|
26
|
-
const
|
|
27
|
-
return
|
|
18
|
+
const n = e.getFullYear(), r = String(e.getMonth() + 1).padStart(2, "0"), a = String(e.getDate()).padStart(2, "0");
|
|
19
|
+
return `${n}-${r}-${a}`;
|
|
20
|
+
}, be = (o) => {
|
|
21
|
+
if (o === "unknown") return "Unknown date";
|
|
22
|
+
const [e, n, r] = o.split("-"), a = Number(e), y = Number(n), i = Number(r);
|
|
23
|
+
if (!Number.isFinite(a) || !Number.isFinite(y) || !Number.isFinite(i)) return "Unknown date";
|
|
24
|
+
const c = new Date(a, y - 1, i);
|
|
25
|
+
if (!Number.isFinite(c.getTime())) return "Unknown date";
|
|
26
|
+
const m = (/* @__PURE__ */ new Date()).getFullYear() !== a;
|
|
27
|
+
return c.toLocaleDateString(void 0, m ? {
|
|
28
28
|
weekday: "short",
|
|
29
29
|
month: "short",
|
|
30
30
|
day: "numeric",
|
|
@@ -34,37 +34,60 @@ const ee = (r) => {
|
|
|
34
34
|
month: "short",
|
|
35
35
|
day: "numeric"
|
|
36
36
|
});
|
|
37
|
-
},
|
|
38
|
-
const e =
|
|
39
|
-
if (
|
|
40
|
-
const n =
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
}, ge = (o) => {
|
|
38
|
+
const e = o.data?.link?.trim();
|
|
39
|
+
if (e) return e;
|
|
40
|
+
const n = o.platform?.webpush;
|
|
41
|
+
if (!n || typeof n != "object" || Array.isArray(n)) return "";
|
|
42
|
+
const r = n.fcmOptions;
|
|
43
|
+
if (!r || typeof r != "object" || Array.isArray(r)) return "";
|
|
44
|
+
const a = r.link;
|
|
45
|
+
return typeof a == "string" ? a.trim() : "";
|
|
46
|
+
}, ye = (o) => o.data?.linkMode === "merge_current_search" ? "merge_current_search" : "navigate", we = (o) => {
|
|
47
|
+
const e = ge(o);
|
|
48
|
+
return e ? {
|
|
49
|
+
link: e,
|
|
50
|
+
mode: ye(o)
|
|
51
|
+
} : null;
|
|
52
|
+
}, ve = (o) => {
|
|
53
|
+
window.history.pushState(window.history.state, "", o), window.dispatchEvent(new PopStateEvent("popstate", {
|
|
54
|
+
state: window.history.state
|
|
55
|
+
}));
|
|
56
|
+
}, Ne = (o) => {
|
|
57
|
+
if (o.mode === "merge_current_search") {
|
|
58
|
+
const e = new URL(window.location.href), n = new URL(o.link, e);
|
|
59
|
+
n.searchParams.forEach((r, a) => {
|
|
60
|
+
e.searchParams.set(a, r);
|
|
61
|
+
}), n.hash && (e.hash = n.hash), ve(`${e.pathname}${e.search}${e.hash}`);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
window.location.href = o.link;
|
|
65
|
+
}, Z = (o) => {
|
|
43
66
|
const e = [];
|
|
44
67
|
let n = null;
|
|
45
|
-
for (const
|
|
46
|
-
const a =
|
|
68
|
+
for (const r of o) {
|
|
69
|
+
const a = pe(r.createdAt);
|
|
47
70
|
a !== n && (n = a, e.push({
|
|
48
71
|
key: a,
|
|
49
|
-
label:
|
|
72
|
+
label: be(a),
|
|
50
73
|
items: []
|
|
51
|
-
})), e[e.length - 1].items.push(
|
|
74
|
+
})), e[e.length - 1].items.push(r);
|
|
52
75
|
}
|
|
53
76
|
return e;
|
|
54
|
-
},
|
|
55
|
-
function
|
|
56
|
-
open:
|
|
77
|
+
}, J = () => typeof window > "u" || !("Notification" in window) ? "unsupported" : window.Notification.permission, je = se(null);
|
|
78
|
+
function Be({
|
|
79
|
+
open: o,
|
|
57
80
|
onOpenChange: e,
|
|
58
81
|
className: n,
|
|
59
|
-
limit:
|
|
82
|
+
limit: r = 50,
|
|
60
83
|
defaultUnreadOnly: a = !1,
|
|
61
|
-
realtimeContext:
|
|
84
|
+
realtimeContext: y
|
|
62
85
|
}) {
|
|
63
|
-
const i =
|
|
64
|
-
unreadOnly:
|
|
65
|
-
markSeen:
|
|
86
|
+
const i = ie(y ?? je), [c, w] = U([]), [m, u] = U(0), [x, f] = U(0), [v, M] = U(!1), [q, L] = U(null), [h, K] = U(a), [O, p] = U(() => J()), [$, k] = U(!1), A = H(null), C = i?.notifications ?? c, R = i?.unreadCount ?? m, S = i?.unseenCount ?? x, z = i?.loading ?? v, T = i?.error ? i.error instanceof Error ? i.error.message : String(i.error) : q, b = G(() => C.slice(0, r), [r, C]), E = G(() => b.filter((s) => !s.readAt), [b]), D = G(() => b.filter((s) => !!s.readAt), [b]), F = G(() => Z(E), [E]), B = G(() => Z(D), [D]), I = re(async ({
|
|
87
|
+
unreadOnly: s,
|
|
88
|
+
markSeen: d
|
|
66
89
|
}) => {
|
|
67
|
-
|
|
90
|
+
M(!0), L(null);
|
|
68
91
|
try {
|
|
69
92
|
const j = await fetch("/api/rb/notifications", {
|
|
70
93
|
method: "POST",
|
|
@@ -73,25 +96,25 @@ function Re({
|
|
|
73
96
|
},
|
|
74
97
|
credentials: "include",
|
|
75
98
|
body: JSON.stringify({
|
|
76
|
-
limit:
|
|
77
|
-
unreadOnly:
|
|
78
|
-
markSeen:
|
|
99
|
+
limit: r,
|
|
100
|
+
unreadOnly: s,
|
|
101
|
+
markSeen: d
|
|
79
102
|
})
|
|
80
|
-
}),
|
|
81
|
-
if (!j.ok || !
|
|
82
|
-
|
|
103
|
+
}), l = await j.json().catch(() => null);
|
|
104
|
+
if (!j.ok || !l?.ok) {
|
|
105
|
+
L(l?.error || "Unable to load notifications.");
|
|
83
106
|
return;
|
|
84
107
|
}
|
|
85
|
-
const
|
|
86
|
-
|
|
108
|
+
const P = Array.isArray(l.notifications) ? l.notifications : [];
|
|
109
|
+
w(P), u(Number.isFinite(l.unreadCount) ? Math.max(0, Math.floor(l.unreadCount ?? 0)) : 0), f(Number.isFinite(l.unseenCount) ? Math.max(0, Math.floor(l.unseenCount ?? 0)) : 0);
|
|
87
110
|
} catch {
|
|
88
|
-
|
|
111
|
+
L("Unable to load notifications.");
|
|
89
112
|
} finally {
|
|
90
|
-
|
|
113
|
+
M(!1);
|
|
91
114
|
}
|
|
92
|
-
}, [
|
|
93
|
-
|
|
94
|
-
if (
|
|
115
|
+
}, [r]);
|
|
116
|
+
W(() => {
|
|
117
|
+
if (o) {
|
|
95
118
|
if (i) {
|
|
96
119
|
(async () => {
|
|
97
120
|
try {
|
|
@@ -113,53 +136,53 @@ function Re({
|
|
|
113
136
|
})();
|
|
114
137
|
return;
|
|
115
138
|
}
|
|
116
|
-
|
|
117
|
-
unreadOnly:
|
|
139
|
+
I({
|
|
140
|
+
unreadOnly: h,
|
|
118
141
|
markSeen: !0
|
|
119
142
|
});
|
|
120
143
|
}
|
|
121
|
-
}, [
|
|
122
|
-
|
|
123
|
-
unreadOnly:
|
|
144
|
+
}, [o, i, I, h]), W(() => {
|
|
145
|
+
o && (i || I({
|
|
146
|
+
unreadOnly: h,
|
|
124
147
|
markSeen: !1
|
|
125
148
|
}));
|
|
126
|
-
}, [
|
|
127
|
-
if (!
|
|
128
|
-
let
|
|
149
|
+
}, [o, i, I, h]), W(() => {
|
|
150
|
+
if (!o || (p(J()), typeof navigator > "u" || !navigator.permissions?.query)) return;
|
|
151
|
+
let s = null, d = !1;
|
|
129
152
|
const j = () => {
|
|
130
|
-
|
|
153
|
+
p(J());
|
|
131
154
|
};
|
|
132
155
|
try {
|
|
133
156
|
navigator.permissions.query({
|
|
134
157
|
name: "notifications"
|
|
135
|
-
}).then((
|
|
136
|
-
|
|
158
|
+
}).then((l) => {
|
|
159
|
+
d || (s = l, j(), l.addEventListener("change", j));
|
|
137
160
|
}).catch(() => {
|
|
138
161
|
});
|
|
139
162
|
} catch {
|
|
140
163
|
return;
|
|
141
164
|
}
|
|
142
165
|
return () => {
|
|
143
|
-
|
|
166
|
+
d = !0, s?.removeEventListener("change", j);
|
|
144
167
|
};
|
|
145
|
-
}, [
|
|
146
|
-
const
|
|
168
|
+
}, [o]);
|
|
169
|
+
const Y = async () => {
|
|
147
170
|
if (typeof window > "u" || !("Notification" in window)) {
|
|
148
|
-
|
|
171
|
+
p("unsupported");
|
|
149
172
|
return;
|
|
150
173
|
}
|
|
151
174
|
k(!0);
|
|
152
175
|
try {
|
|
153
|
-
const
|
|
154
|
-
|
|
176
|
+
const s = await window.Notification.requestPermission();
|
|
177
|
+
p(s);
|
|
155
178
|
} catch {
|
|
156
|
-
|
|
179
|
+
p(J());
|
|
157
180
|
} finally {
|
|
158
181
|
k(!1);
|
|
159
182
|
}
|
|
160
|
-
},
|
|
183
|
+
}, _ = async (s) => {
|
|
161
184
|
try {
|
|
162
|
-
const
|
|
185
|
+
const d = await fetch(`/api/rb/notifications/${encodeURIComponent(s)}/read`, {
|
|
163
186
|
method: "POST",
|
|
164
187
|
headers: {
|
|
165
188
|
"Content-Type": "application/json"
|
|
@@ -167,198 +190,207 @@ function Re({
|
|
|
167
190
|
credentials: "include",
|
|
168
191
|
keepalive: !0,
|
|
169
192
|
body: "{}"
|
|
170
|
-
}), j = await
|
|
171
|
-
if (!
|
|
172
|
-
const
|
|
193
|
+
}), j = await d.json().catch(() => null);
|
|
194
|
+
if (!d.ok || !j?.ok) return;
|
|
195
|
+
const l = (/* @__PURE__ */ new Date()).toISOString();
|
|
173
196
|
if (i) return;
|
|
174
|
-
|
|
175
|
-
const
|
|
176
|
-
return
|
|
197
|
+
w((P) => {
|
|
198
|
+
const g = P.find((N) => N.id === s);
|
|
199
|
+
return g && !g.readAt && u((N) => Math.max(0, N - 1)), g && !g.seenAt && f((N) => Math.max(0, N - 1)), P.map((N) => N.id === s && !N.readAt ? {
|
|
177
200
|
...N,
|
|
178
|
-
readAt:
|
|
201
|
+
readAt: l,
|
|
179
202
|
...N.seenAt ? {} : {
|
|
180
|
-
seenAt:
|
|
203
|
+
seenAt: l
|
|
181
204
|
}
|
|
182
205
|
} : N);
|
|
183
206
|
});
|
|
184
207
|
} catch {
|
|
185
208
|
return;
|
|
186
209
|
}
|
|
187
|
-
},
|
|
210
|
+
}, Q = async (s) => {
|
|
188
211
|
try {
|
|
189
|
-
const
|
|
212
|
+
const d = await fetch(`/api/rb/notifications/${encodeURIComponent(s)}/archive`, {
|
|
190
213
|
method: "POST",
|
|
191
214
|
headers: {
|
|
192
215
|
"Content-Type": "application/json"
|
|
193
216
|
},
|
|
194
217
|
credentials: "include",
|
|
195
218
|
body: "{}"
|
|
196
|
-
}), j = await
|
|
197
|
-
if (!
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
return
|
|
219
|
+
}), j = await d.json().catch(() => null);
|
|
220
|
+
if (!d.ok || !j?.ok || i) return;
|
|
221
|
+
w((l) => {
|
|
222
|
+
const P = l.find((g) => g.id === s);
|
|
223
|
+
return P && !P.readAt && u((g) => Math.max(0, g - 1)), P && !P.seenAt && f((g) => Math.max(0, g - 1)), l.filter((g) => g.id !== s);
|
|
201
224
|
});
|
|
202
225
|
} catch {
|
|
203
226
|
return;
|
|
204
227
|
}
|
|
228
|
+
}, X = () => {
|
|
229
|
+
e(!1), A.current?.unmount();
|
|
230
|
+
}, oe = (s) => {
|
|
231
|
+
if (s) {
|
|
232
|
+
e(!0);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
X();
|
|
205
236
|
};
|
|
206
|
-
return /* @__PURE__ */ t.jsx(
|
|
207
|
-
/* @__PURE__ */ t.jsx(
|
|
208
|
-
/* @__PURE__ */ t.jsxs(
|
|
237
|
+
return /* @__PURE__ */ t.jsx(de, { open: o, onOpenChange: oe, actionsRef: A, children: /* @__PURE__ */ t.jsxs(ue, { children: [
|
|
238
|
+
/* @__PURE__ */ t.jsx(me, { className: "fixed inset-0 z-50 bg-black/50" }),
|
|
239
|
+
/* @__PURE__ */ t.jsxs(fe, { className: V("fixed right-0 top-0 z-50 flex h-full w-full max-w-md flex-col border-l bg-background shadow-xl outline-none", n), children: [
|
|
209
240
|
/* @__PURE__ */ t.jsxs("header", { className: "flex items-center justify-between gap-2 border-b px-4 py-3", children: [
|
|
210
241
|
/* @__PURE__ */ t.jsxs("div", { className: "flex min-w-0 flex-col", children: [
|
|
211
|
-
/* @__PURE__ */ t.jsx(
|
|
212
|
-
/* @__PURE__ */ t.jsx("span", { className: "text-xs text-muted-foreground", children:
|
|
242
|
+
/* @__PURE__ */ t.jsx(xe, { className: "text-sm font-semibold", children: "Notifications" }),
|
|
243
|
+
/* @__PURE__ */ t.jsx("span", { className: "text-xs text-muted-foreground", children: R > 0 ? `${R} unread` : S > 0 ? `${S} new` : "All caught up" })
|
|
213
244
|
] }),
|
|
214
245
|
/* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
215
|
-
/* @__PURE__ */ t.jsx("button", { type: "button", onClick: () =>
|
|
216
|
-
/* @__PURE__ */ t.jsx(
|
|
246
|
+
/* @__PURE__ */ t.jsx("button", { type: "button", onClick: () => K((s) => !s), className: V("rounded-md border px-2 py-1 text-xs", h ? "bg-accent text-foreground" : "bg-background text-muted-foreground hover:bg-accent"), children: h ? "Unread" : "All" }),
|
|
247
|
+
/* @__PURE__ */ t.jsx(he, { render: /* @__PURE__ */ t.jsx("button", { type: "button", className: "inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-accent" }), children: /* @__PURE__ */ t.jsx(ae, { className: "h-4 w-4" }) })
|
|
217
248
|
] })
|
|
218
249
|
] }),
|
|
219
250
|
/* @__PURE__ */ t.jsxs("div", { className: "flex-1 overflow-y-auto px-4 pb-3", children: [
|
|
220
|
-
/* @__PURE__ */ t.jsx(
|
|
221
|
-
z ? /* @__PURE__ */ t.jsx("div", { className: "flex items-center justify-center py-10 text-muted-foreground", children: /* @__PURE__ */ t.jsx(
|
|
251
|
+
/* @__PURE__ */ t.jsx(ke, { permission: O, requesting: $, onEnable: Y }),
|
|
252
|
+
z ? /* @__PURE__ */ t.jsx("div", { className: "flex items-center justify-center py-10 text-muted-foreground", children: /* @__PURE__ */ t.jsx(ce, { className: "h-4 w-4 animate-spin" }) }) : T ? /* @__PURE__ */ t.jsx("div", { className: "py-10 text-center text-sm text-muted-foreground", children: T }) : b.length === 0 ? /* @__PURE__ */ t.jsx("div", { className: "py-10 text-center text-sm text-muted-foreground", children: "No notifications." }) : /* @__PURE__ */ t.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
222
253
|
/* @__PURE__ */ t.jsxs("div", { children: [
|
|
223
254
|
/* @__PURE__ */ t.jsx("div", { className: "sticky top-0 z-20 -mx-4 flex h-8 items-center border-b bg-background px-4 text-xs font-semibold text-muted-foreground", children: "Unread notifications" }),
|
|
224
|
-
|
|
225
|
-
/* @__PURE__ */ t.jsx("div", { className: "sticky top-8 z-10 -mx-4 flex h-7 items-center bg-background px-4 text-[11px] font-semibold text-muted-foreground", children:
|
|
226
|
-
/* @__PURE__ */ t.jsx("div", { className: "-mx-4 flex flex-col divide-y divide-border", children:
|
|
227
|
-
] }, `unread:${
|
|
255
|
+
F.length === 0 ? /* @__PURE__ */ t.jsx("div", { className: "py-6 text-center text-sm text-muted-foreground", children: "No unread notifications." }) : F.map((s) => /* @__PURE__ */ t.jsxs("div", { children: [
|
|
256
|
+
/* @__PURE__ */ t.jsx("div", { className: "sticky top-8 z-10 -mx-4 flex h-7 items-center bg-background px-4 text-[11px] font-semibold text-muted-foreground", children: s.label }),
|
|
257
|
+
/* @__PURE__ */ t.jsx("div", { className: "-mx-4 flex flex-col divide-y divide-border", children: s.items.map((d) => /* @__PURE__ */ t.jsx(ee, { notification: d, onMarkRead: _, onArchive: Q, onAction: X }, d.id)) })
|
|
258
|
+
] }, `unread:${s.key}`))
|
|
228
259
|
] }),
|
|
229
|
-
|
|
260
|
+
h ? null : /* @__PURE__ */ t.jsxs("div", { children: [
|
|
230
261
|
/* @__PURE__ */ t.jsx("div", { className: "sticky top-0 z-20 -mx-4 flex h-8 items-center border-b bg-background px-4 text-xs font-semibold text-muted-foreground", children: "Previous notifications" }),
|
|
231
|
-
|
|
232
|
-
/* @__PURE__ */ t.jsx("div", { className: "sticky top-8 z-10 -mx-4 flex h-7 items-center bg-background px-4 text-[11px] font-semibold text-muted-foreground", children:
|
|
233
|
-
/* @__PURE__ */ t.jsx("div", { className: "-mx-4 flex flex-col divide-y divide-border", children:
|
|
234
|
-
] }, `previous:${
|
|
262
|
+
B.length === 0 ? /* @__PURE__ */ t.jsx("div", { className: "py-6 text-center text-sm text-muted-foreground", children: "No previous notifications." }) : B.map((s) => /* @__PURE__ */ t.jsxs("div", { children: [
|
|
263
|
+
/* @__PURE__ */ t.jsx("div", { className: "sticky top-8 z-10 -mx-4 flex h-7 items-center bg-background px-4 text-[11px] font-semibold text-muted-foreground", children: s.label }),
|
|
264
|
+
/* @__PURE__ */ t.jsx("div", { className: "-mx-4 flex flex-col divide-y divide-border", children: s.items.map((d) => /* @__PURE__ */ t.jsx(ee, { notification: d, onMarkRead: _, onArchive: Q, onAction: X }, d.id)) })
|
|
265
|
+
] }, `previous:${s.key}`))
|
|
235
266
|
] })
|
|
236
267
|
] })
|
|
237
268
|
] })
|
|
238
269
|
] })
|
|
239
270
|
] }) });
|
|
240
271
|
}
|
|
241
|
-
function
|
|
242
|
-
const e =
|
|
272
|
+
function ke(o) {
|
|
273
|
+
const e = te.c(13), {
|
|
243
274
|
permission: n,
|
|
244
|
-
requesting:
|
|
275
|
+
requesting: r,
|
|
245
276
|
onEnable: a
|
|
246
|
-
} =
|
|
277
|
+
} = o;
|
|
247
278
|
if (n === "granted")
|
|
248
279
|
return null;
|
|
249
280
|
if (n === "unsupported") {
|
|
250
281
|
let v;
|
|
251
282
|
return e[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (v = /* @__PURE__ */ t.jsx("div", { className: "mt-3 rounded-md border bg-muted/40 p-3 text-sm text-muted-foreground", children: "Browser notifications are not supported by this browser." }), e[0] = v) : v = e[0], v;
|
|
252
283
|
}
|
|
253
|
-
const
|
|
254
|
-
let
|
|
255
|
-
e[1] !== i ? (
|
|
256
|
-
const
|
|
257
|
-
let
|
|
258
|
-
e[3] !==
|
|
259
|
-
const
|
|
260
|
-
let d;
|
|
261
|
-
e[5] !== a || e[6] !== s || e[7] !== b ? (d = /* @__PURE__ */ t.jsx("button", { type: "button", className: "mt-3 inline-flex h-8 items-center rounded-md border bg-background px-2.5 text-xs font-medium hover:bg-accent disabled:pointer-events-none disabled:opacity-50", disabled: s, onClick: a, children: b }), e[5] = a, e[6] = s, e[7] = b, e[8] = d) : d = e[8];
|
|
284
|
+
const y = n === "denied", i = y ? "Browser notifications are blocked." : "Browser notifications are not enabled.";
|
|
285
|
+
let c;
|
|
286
|
+
e[1] !== i ? (c = /* @__PURE__ */ t.jsx("div", { className: "text-sm font-medium", children: i }), e[1] = i, e[2] = c) : c = e[2];
|
|
287
|
+
const w = y ? "Enable notifications for this site in your browser settings, then click again." : "Enable browser notifications to receive important alerts.";
|
|
288
|
+
let m;
|
|
289
|
+
e[3] !== w ? (m = /* @__PURE__ */ t.jsx("div", { className: "mt-1 text-xs text-muted-foreground", children: w }), e[3] = w, e[4] = m) : m = e[4];
|
|
290
|
+
const u = r ? "Enabling..." : "Enable browser notifications";
|
|
262
291
|
let x;
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
292
|
+
e[5] !== a || e[6] !== r || e[7] !== u ? (x = /* @__PURE__ */ t.jsx("button", { type: "button", className: "mt-3 inline-flex h-8 items-center rounded-md border bg-background px-2.5 text-xs font-medium hover:bg-accent disabled:pointer-events-none disabled:opacity-50", disabled: r, onClick: a, children: u }), e[5] = a, e[6] = r, e[7] = u, e[8] = x) : x = e[8];
|
|
293
|
+
let f;
|
|
294
|
+
return e[9] !== c || e[10] !== m || e[11] !== x ? (f = /* @__PURE__ */ t.jsxs("div", { className: "mt-3 rounded-md border bg-muted/40 p-3", children: [
|
|
295
|
+
c,
|
|
296
|
+
m,
|
|
297
|
+
x
|
|
298
|
+
] }), e[9] = c, e[10] = m, e[11] = x, e[12] = f) : f = e[12], f;
|
|
268
299
|
}
|
|
269
|
-
function
|
|
270
|
-
const e =
|
|
300
|
+
function ee(o) {
|
|
301
|
+
const e = te.c(48), {
|
|
271
302
|
notification: n,
|
|
272
|
-
onMarkRead:
|
|
273
|
-
onArchive: a
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
e[0] !== n ? (b = pe(n), e[0] = n, e[1] = b) : b = e[1];
|
|
277
|
-
const d = b;
|
|
303
|
+
onMarkRead: r,
|
|
304
|
+
onArchive: a,
|
|
305
|
+
onAction: y
|
|
306
|
+
} = o, [i, c] = U(!1), w = H(null), m = H(null), u = !n.readAt;
|
|
278
307
|
let x;
|
|
308
|
+
e[0] !== n ? (x = we(n), e[0] = n, e[1] = x) : x = e[1];
|
|
309
|
+
const f = x, v = f?.link ?? "";
|
|
310
|
+
let M;
|
|
279
311
|
if (e[2] !== n.createdAt) {
|
|
280
312
|
e: {
|
|
281
|
-
const
|
|
282
|
-
if (!Number.isFinite(
|
|
283
|
-
|
|
313
|
+
const B = new Date(ne(n.createdAt));
|
|
314
|
+
if (!Number.isFinite(B.getTime())) {
|
|
315
|
+
M = "";
|
|
284
316
|
break e;
|
|
285
317
|
}
|
|
286
|
-
|
|
318
|
+
M = B.toLocaleString();
|
|
287
319
|
}
|
|
288
|
-
e[2] = n.createdAt, e[3] =
|
|
320
|
+
e[2] = n.createdAt, e[3] = M;
|
|
289
321
|
} else
|
|
290
|
-
|
|
291
|
-
const
|
|
292
|
-
let
|
|
293
|
-
e[4] !==
|
|
294
|
-
if (!
|
|
322
|
+
M = e[3];
|
|
323
|
+
const q = M;
|
|
324
|
+
let L, h;
|
|
325
|
+
e[4] !== i ? (L = () => {
|
|
326
|
+
if (!i)
|
|
295
327
|
return;
|
|
296
|
-
const
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
}, I = (
|
|
300
|
-
|
|
328
|
+
const B = (Y) => {
|
|
329
|
+
const _ = Y.target;
|
|
330
|
+
_ instanceof Node && (w.current?.contains(_) || m.current?.contains(_) || c(!1));
|
|
331
|
+
}, I = (Y) => {
|
|
332
|
+
Y.key === "Escape" && (c(!1), m.current?.focus());
|
|
301
333
|
};
|
|
302
|
-
return document.addEventListener("pointerdown",
|
|
303
|
-
document.removeEventListener("pointerdown",
|
|
334
|
+
return document.addEventListener("pointerdown", B), document.addEventListener("keydown", I), () => {
|
|
335
|
+
document.removeEventListener("pointerdown", B), document.removeEventListener("keydown", I);
|
|
304
336
|
};
|
|
305
|
-
},
|
|
306
|
-
const
|
|
307
|
-
let p;
|
|
308
|
-
e[7] !== T ? (p = W("group flex w-full gap-3 px-4 py-3 hover:bg-accent/40", T), e[7] = T, e[8] = p) : p = e[8];
|
|
309
|
-
let P;
|
|
310
|
-
e[9] !== l || e[10] !== d || e[11] !== n.id || e[12] !== s ? (P = () => {
|
|
311
|
-
l && s(n.id), d && (window.location.href = d);
|
|
312
|
-
}, e[9] = l, e[10] = d, e[11] = n.id, e[12] = s, e[13] = P) : P = e[13];
|
|
313
|
-
let M;
|
|
314
|
-
e[14] !== n.title ? (M = /* @__PURE__ */ t.jsx("div", { className: "truncate text-sm font-semibold", children: n.title }), e[14] = n.title, e[15] = M) : M = e[15];
|
|
315
|
-
let g;
|
|
316
|
-
e[16] !== n.body ? (g = n.body ? /* @__PURE__ */ t.jsx("div", { className: "mt-0.5 line-clamp-2 text-xs text-muted-foreground", children: n.body }) : null, e[16] = n.body, e[17] = g) : g = e[17];
|
|
337
|
+
}, h = [i], e[4] = i, e[5] = L, e[6] = h) : (L = e[5], h = e[6]), W(L, h);
|
|
338
|
+
const K = u ? "bg-primary/5" : "bg-background";
|
|
317
339
|
let O;
|
|
318
|
-
e[
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
340
|
+
e[7] !== K ? (O = V("group flex w-full gap-3 px-4 py-3 hover:bg-accent/40", K), e[7] = K, e[8] = O) : O = e[8];
|
|
341
|
+
let p;
|
|
342
|
+
e[9] !== f || e[10] !== u || e[11] !== n.id || e[12] !== y || e[13] !== r ? (p = () => {
|
|
343
|
+
u && r(n.id), f && (y(), Ne(f));
|
|
344
|
+
}, e[9] = f, e[10] = u, e[11] = n.id, e[12] = y, e[13] = r, e[14] = p) : p = e[14];
|
|
345
|
+
let $;
|
|
346
|
+
e[15] !== n.title ? ($ = /* @__PURE__ */ t.jsx("div", { className: "truncate text-sm font-semibold", children: n.title }), e[15] = n.title, e[16] = $) : $ = e[16];
|
|
322
347
|
let k;
|
|
323
|
-
e[
|
|
348
|
+
e[17] !== n.body ? (k = n.body ? /* @__PURE__ */ t.jsx("div", { className: "mt-0.5 line-clamp-2 text-xs text-muted-foreground", children: n.body }) : null, e[17] = n.body, e[18] = k) : k = e[18];
|
|
324
349
|
let A;
|
|
325
|
-
e[
|
|
350
|
+
e[19] !== $ || e[20] !== k ? (A = /* @__PURE__ */ t.jsxs("div", { className: "min-w-0", children: [
|
|
351
|
+
$,
|
|
352
|
+
k
|
|
353
|
+
] }), e[19] = $, e[20] = k, e[21] = A) : A = e[21];
|
|
326
354
|
let C;
|
|
327
|
-
e[
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
A
|
|
331
|
-
] }), e[25] = O, e[26] = k, e[27] = A, e[28] = P, e[29] = C) : C = e[29];
|
|
332
|
-
let F, z;
|
|
333
|
-
e[30] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (F = () => {
|
|
334
|
-
i(ge);
|
|
335
|
-
}, z = /* @__PURE__ */ t.jsx(se, { className: "h-4 w-4" }), e[30] = F, e[31] = z) : (F = e[30], z = e[31]);
|
|
355
|
+
e[22] !== v ? (C = v ? /* @__PURE__ */ t.jsx("div", { className: "mt-2 truncate text-xs text-primary", children: v }) : null, e[22] = v, e[23] = C) : C = e[23];
|
|
356
|
+
let R;
|
|
357
|
+
e[24] !== q ? (R = q ? /* @__PURE__ */ t.jsx("div", { className: "mt-2 text-[11px] text-muted-foreground", children: q }) : null, e[24] = q, e[25] = R) : R = e[25];
|
|
336
358
|
let S;
|
|
337
|
-
e[
|
|
338
|
-
|
|
339
|
-
|
|
359
|
+
e[26] !== A || e[27] !== C || e[28] !== R || e[29] !== p ? (S = /* @__PURE__ */ t.jsxs("button", { type: "button", className: "min-w-0 flex-1 text-left", onClick: p, children: [
|
|
360
|
+
A,
|
|
361
|
+
C,
|
|
362
|
+
R
|
|
363
|
+
] }), e[26] = A, e[27] = C, e[28] = R, e[29] = p, e[30] = S) : S = e[30];
|
|
364
|
+
let z, T;
|
|
365
|
+
e[31] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (z = () => {
|
|
366
|
+
c(Ae);
|
|
367
|
+
}, T = /* @__PURE__ */ t.jsx(le, { className: "h-4 w-4" }), e[31] = z, e[32] = T) : (z = e[31], T = e[32]);
|
|
368
|
+
let b;
|
|
369
|
+
e[33] !== i ? (b = /* @__PURE__ */ t.jsx("button", { ref: m, type: "button", className: "inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-accent", "aria-label": "Notification options", "aria-haspopup": "menu", "aria-expanded": i, onClick: z, children: T }), e[33] = i, e[34] = b) : b = e[34];
|
|
370
|
+
let E;
|
|
371
|
+
e[35] !== u || e[36] !== i || e[37] !== n.id || e[38] !== a || e[39] !== r ? (E = i ? /* @__PURE__ */ t.jsxs("div", { ref: w, role: "menu", className: V("absolute right-0 top-full z-50 mt-1 min-w-[10rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md", "animate-in fade-in-0 zoom-in-95"), children: [
|
|
340
372
|
/* @__PURE__ */ t.jsx("button", { type: "button", role: "menuitem", className: "relative flex w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm outline-none transition-colors hover:bg-accent focus:bg-accent focus:text-accent-foreground", onClick: () => {
|
|
341
|
-
|
|
373
|
+
c(!1), a(n.id);
|
|
342
374
|
}, children: "Archive" }),
|
|
343
|
-
/* @__PURE__ */ t.jsx("button", { type: "button", role: "menuitem", className: "relative flex w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm outline-none transition-colors hover:bg-accent focus:bg-accent focus:text-accent-foreground disabled:pointer-events-none disabled:opacity-50", disabled: !
|
|
344
|
-
|
|
375
|
+
/* @__PURE__ */ t.jsx("button", { type: "button", role: "menuitem", className: "relative flex w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm outline-none transition-colors hover:bg-accent focus:bg-accent focus:text-accent-foreground disabled:pointer-events-none disabled:opacity-50", disabled: !u, onClick: () => {
|
|
376
|
+
c(!1), r(n.id);
|
|
345
377
|
}, children: "Mark as read" })
|
|
346
|
-
] }) : null, e[
|
|
378
|
+
] }) : null, e[35] = u, e[36] = i, e[37] = n.id, e[38] = a, e[39] = r, e[40] = E) : E = e[40];
|
|
347
379
|
let D;
|
|
348
|
-
e[
|
|
380
|
+
e[41] !== b || e[42] !== E ? (D = /* @__PURE__ */ t.jsxs("div", { className: "relative flex items-start", children: [
|
|
381
|
+
b,
|
|
382
|
+
E
|
|
383
|
+
] }), e[41] = b, e[42] = E, e[43] = D) : D = e[43];
|
|
384
|
+
let F;
|
|
385
|
+
return e[44] !== S || e[45] !== D || e[46] !== O ? (F = /* @__PURE__ */ t.jsxs("div", { className: O, children: [
|
|
349
386
|
S,
|
|
350
|
-
y
|
|
351
|
-
] }), e[40] = S, e[41] = y, e[42] = D) : D = e[42];
|
|
352
|
-
let $;
|
|
353
|
-
return e[43] !== C || e[44] !== D || e[45] !== p ? ($ = /* @__PURE__ */ t.jsxs("div", { className: p, children: [
|
|
354
|
-
C,
|
|
355
387
|
D
|
|
356
|
-
] }), e[
|
|
388
|
+
] }), e[44] = S, e[45] = D, e[46] = O, e[47] = F) : F = e[47], F;
|
|
357
389
|
}
|
|
358
|
-
function
|
|
359
|
-
return !
|
|
390
|
+
function Ae(o) {
|
|
391
|
+
return !o;
|
|
360
392
|
}
|
|
361
393
|
export {
|
|
362
|
-
|
|
394
|
+
Be as NotificationsDrawer
|
|
363
395
|
};
|
|
364
396
|
//# sourceMappingURL=index16.js.map
|