@rpcbase/ui 0.235.0 → 0.237.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/Notifications/NotificationsDrawer.d.ts.map +1 -1
- package/dist/components/Notifications/types.d.ts +11 -2
- package/dist/components/Notifications/types.d.ts.map +1 -1
- package/dist/index16.js +247 -175
- package/dist/index16.js.map +1 -1
- package/dist/index167.js +3 -3
- package/dist/index172.js +6 -6
- package/dist/index178.js +1 -1
- package/dist/index185.js +1 -1
- package/dist/index187.js +1 -1
- package/dist/index189.js +3 -3
- package/dist/index190.js +4 -4
- package/dist/index270.js +1 -1
- package/dist/index272.js +1 -1
- package/dist/index275.js +1 -1
- package/dist/index277.js +1 -1
- package/dist/index278.js +2 -2
- package/dist/index282.js +1 -1
- package/dist/index285.js +1 -1
- package/dist/index287.js +1 -1
- package/dist/index298.js +1 -1
- package/dist/index302.js +1 -1
- package/dist/index320.js +2 -2
- package/dist/index332.js +1 -1
- package/dist/index336.js +19 -8
- package/dist/index336.js.map +1 -1
- package/dist/index337.js +28 -11
- package/dist/index337.js.map +1 -1
- package/dist/index338.js +15 -7
- package/dist/index338.js.map +1 -1
- package/dist/index339.js +8 -13
- package/dist/index339.js.map +1 -1
- package/dist/index340.js +11 -3
- package/dist/index340.js.map +1 -1
- package/dist/index341.js +8 -3
- package/dist/index341.js.map +1 -1
- package/dist/index342.js +12 -16
- package/dist/index342.js.map +1 -1
- package/dist/index343.js +3 -19
- package/dist/index343.js.map +1 -1
- package/dist/index344.js +3 -28
- package/dist/index344.js.map +1 -1
- package/dist/index345.js +16 -15
- package/dist/index345.js.map +1 -1
- package/dist/index347.js +5 -122
- package/dist/index347.js.map +1 -1
- package/dist/index348.js +121 -31
- package/dist/index348.js.map +1 -1
- package/dist/index349.js +31 -72
- package/dist/index349.js.map +1 -1
- package/dist/index350.js +70 -139
- package/dist/index350.js.map +1 -1
- package/dist/index351.js +116 -35
- package/dist/index351.js.map +1 -1
- package/dist/index352.js +56 -44
- package/dist/index352.js.map +1 -1
- package/dist/index353.js +49 -14
- package/dist/index353.js.map +1 -1
- package/dist/index354.js +15 -6
- package/dist/index354.js.map +1 -1
- package/dist/index362.js +4 -12
- package/dist/index362.js.map +1 -1
- package/dist/index363.js +11 -16
- package/dist/index363.js.map +1 -1
- package/dist/index364.js +16 -5
- package/dist/index364.js.map +1 -1
- package/dist/index365.js +6 -4
- package/dist/index365.js.map +1 -1
- package/dist/index384.js +2 -2
- package/dist/index386.js +1 -1
- package/dist/index44.js +1 -1
- package/dist/index45.js +2 -2
- package/dist/index70.js +1 -1
- package/dist/index71.js +1 -1
- package/dist/index74.js +6 -2
- package/dist/index74.js.map +1 -1
- package/dist/index75.js +8 -2
- package/dist/index75.js.map +1 -1
- package/dist/index76.js +5 -5
- package/dist/index76.js.map +1 -1
- package/dist/index77.js +2 -8
- package/dist/index77.js.map +1 -1
- package/dist/index78.js +2 -6
- package/dist/index78.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationsDrawer.d.ts","sourceRoot":"","sources":["../../../src/components/Notifications/NotificationsDrawer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgF,KAAK,OAAO,EAAE,MAAM,OAAO,CAAA;AAMlH,OAAO,KAAK,EAAoB,0BAA0B,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"NotificationsDrawer.d.ts","sourceRoot":"","sources":["../../../src/components/Notifications/NotificationsDrawer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgF,KAAK,OAAO,EAAE,MAAM,OAAO,CAAA;AAMlH,OAAO,KAAK,EAAoB,0BAA0B,EAAE,MAAM,SAAS,CAAA;AAsF3E,wBAAgB,mBAAmB,CAAC,EAClC,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,KAAU,EACV,iBAAyB,EACzB,eAAe,GAChB,EAAE;IACD,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC,CAAA;CAC7D,2CAkTA"}
|
|
@@ -15,17 +15,26 @@ export type NotificationSettings = {
|
|
|
15
15
|
topicPreferences: NotificationTopicPreference[];
|
|
16
16
|
lastDigestSentAt?: string;
|
|
17
17
|
};
|
|
18
|
+
export type NotificationDataPayload = Record<string, string>;
|
|
19
|
+
export type NotificationPlatformPayload = {
|
|
20
|
+
webpush?: Record<string, unknown>;
|
|
21
|
+
fcmOptions?: Record<string, unknown>;
|
|
22
|
+
android?: Record<string, unknown>;
|
|
23
|
+
apns?: Record<string, unknown>;
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
};
|
|
18
26
|
export type NotificationItem = {
|
|
19
27
|
id: string;
|
|
20
28
|
topic?: string;
|
|
21
29
|
title: string;
|
|
22
30
|
body?: string;
|
|
23
|
-
|
|
31
|
+
image?: string;
|
|
32
|
+
data?: NotificationDataPayload;
|
|
33
|
+
platform?: NotificationPlatformPayload;
|
|
24
34
|
createdAt: string;
|
|
25
35
|
seenAt?: string;
|
|
26
36
|
readAt?: string;
|
|
27
37
|
archivedAt?: string;
|
|
28
|
-
metadata?: Record<string, unknown>;
|
|
29
38
|
};
|
|
30
39
|
export type NotificationsRealtimeState = {
|
|
31
40
|
notifications: NotificationItem[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Notifications/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,2BAA2B,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAA;AAEpE,MAAM,MAAM,2BAA2B,GAAG;IACxC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,OAAO,CAAA;IACd,WAAW,EAAE,OAAO,CAAA;IACpB,IAAI,EAAE,OAAO,CAAA;CACd,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG;IACzC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,eAAe,EAAE,2BAA2B,CAAA;IAC5C,gBAAgB,EAAE,2BAA2B,EAAE,CAAA;IAC/C,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Notifications/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,2BAA2B,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAA;AAEpE,MAAM,MAAM,2BAA2B,GAAG;IACxC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,OAAO,CAAA;IACd,WAAW,EAAE,OAAO,CAAA;IACpB,IAAI,EAAE,OAAO,CAAA;CACd,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG;IACzC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,eAAe,EAAE,2BAA2B,CAAA;IAC5C,gBAAgB,EAAE,2BAA2B,EAAE,CAAA;IAC/C,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAE5D,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,uBAAuB,CAAA;IAC9B,QAAQ,CAAC,EAAE,2BAA2B,CAAA;IACtC,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,aAAa,EAAE,gBAAgB,EAAE,CAAA;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,OAAO,CAAA;CACf,CAAA"}
|
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 _ } from "./index28.js";
|
|
3
|
+
import { useContext as te, useState as R, useMemo as Y, useCallback as ne, useEffect as J, createContext as oe, useRef as H } from "react";
|
|
4
|
+
import { X as ie, Loader2 as re, MoreVertical as se } from "lucide-react";
|
|
5
|
+
import { cn as W } from "./index2.js";
|
|
6
|
+
import { DialogRoot as ae } from "./index34.js";
|
|
7
|
+
import { DialogPortal as ce } from "./index39.js";
|
|
8
|
+
import { DialogBackdrop as le } from "./index38.js";
|
|
9
|
+
import { DialogPopup as de } from "./index36.js";
|
|
10
|
+
import { DialogTitle as ue } from "./index40.js";
|
|
11
|
+
import { DialogClose as me } from "./index35.js";
|
|
12
|
+
const ee = (r) => {
|
|
13
|
+
const e = Date.parse(r);
|
|
14
14
|
return Number.isFinite(e) ? e : 0;
|
|
15
|
-
},
|
|
16
|
-
const e = new Date(
|
|
15
|
+
}, fe = (r) => {
|
|
16
|
+
const e = new Date(ee(r));
|
|
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(), s = String(e.getMonth() + 1).padStart(2, "0"), a = String(e.getDate()).padStart(2, "0");
|
|
19
|
+
return `${n}-${s}-${a}`;
|
|
20
|
+
}, xe = (r) => {
|
|
21
|
+
if (r === "unknown") return "Unknown date";
|
|
22
|
+
const [e, n, s] = r.split("-"), a = Number(e), c = Number(n), i = Number(s);
|
|
23
|
+
if (!Number.isFinite(a) || !Number.isFinite(c) || !Number.isFinite(i)) return "Unknown date";
|
|
24
|
+
const f = new Date(a, c - 1, i);
|
|
25
|
+
if (!Number.isFinite(f.getTime())) return "Unknown date";
|
|
26
|
+
const l = (/* @__PURE__ */ new Date()).getFullYear() !== a;
|
|
27
|
+
return f.toLocaleDateString(void 0, l ? {
|
|
28
28
|
weekday: "short",
|
|
29
29
|
month: "short",
|
|
30
30
|
day: "numeric",
|
|
@@ -34,60 +34,65 @@ const X = (s) => {
|
|
|
34
34
|
month: "short",
|
|
35
35
|
day: "numeric"
|
|
36
36
|
});
|
|
37
|
-
},
|
|
37
|
+
}, pe = (r) => {
|
|
38
|
+
const e = r.platform?.webpush;
|
|
39
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return "";
|
|
40
|
+
const n = e.fcmOptions;
|
|
41
|
+
return !n || typeof n != "object" || Array.isArray(n) ? "" : typeof n.link == "string" ? n.link : "";
|
|
42
|
+
}, Q = (r) => {
|
|
38
43
|
const e = [];
|
|
39
44
|
let n = null;
|
|
40
|
-
for (const
|
|
41
|
-
const a =
|
|
45
|
+
for (const s of r) {
|
|
46
|
+
const a = fe(s.createdAt);
|
|
42
47
|
a !== n && (n = a, e.push({
|
|
43
48
|
key: a,
|
|
44
|
-
label:
|
|
49
|
+
label: xe(a),
|
|
45
50
|
items: []
|
|
46
|
-
})), e[e.length - 1].items.push(
|
|
51
|
+
})), e[e.length - 1].items.push(s);
|
|
47
52
|
}
|
|
48
53
|
return e;
|
|
49
|
-
},
|
|
50
|
-
function
|
|
51
|
-
open:
|
|
54
|
+
}, G = () => typeof window > "u" || !("Notification" in window) ? "unsupported" : window.Notification.permission, he = oe(null);
|
|
55
|
+
function Re({
|
|
56
|
+
open: r,
|
|
52
57
|
onOpenChange: e,
|
|
53
58
|
className: n,
|
|
54
|
-
limit:
|
|
59
|
+
limit: s = 50,
|
|
55
60
|
defaultUnreadOnly: a = !1,
|
|
56
|
-
realtimeContext:
|
|
61
|
+
realtimeContext: c
|
|
57
62
|
}) {
|
|
58
|
-
const
|
|
59
|
-
unreadOnly:
|
|
60
|
-
markSeen:
|
|
63
|
+
const i = te(c ?? he), [f, h] = R([]), [l, b] = R(0), [d, x] = R(0), [v, B] = R(!1), [q, T] = R(null), [p, P] = R(a), [M, g] = R(() => G()), [O, k] = R(!1), A = i?.notifications ?? f, C = i?.unreadCount ?? l, F = i?.unseenCount ?? d, z = i?.loading ?? v, S = i?.error ? i.error instanceof Error ? i.error.message : String(i.error) : q, y = Y(() => A.slice(0, s), [s, A]), D = Y(() => y.filter((o) => !o.readAt), [y]), $ = Y(() => y.filter((o) => !!o.readAt), [y]), U = Y(() => Q(D), [D]), I = Y(() => Q($), [$]), L = ne(async ({
|
|
64
|
+
unreadOnly: o,
|
|
65
|
+
markSeen: m
|
|
61
66
|
}) => {
|
|
62
|
-
|
|
67
|
+
B(!0), T(null);
|
|
63
68
|
try {
|
|
64
|
-
const
|
|
69
|
+
const j = await fetch("/api/rb/notifications", {
|
|
65
70
|
method: "POST",
|
|
66
71
|
headers: {
|
|
67
72
|
"Content-Type": "application/json"
|
|
68
73
|
},
|
|
69
74
|
credentials: "include",
|
|
70
75
|
body: JSON.stringify({
|
|
71
|
-
limit:
|
|
72
|
-
unreadOnly:
|
|
73
|
-
markSeen:
|
|
76
|
+
limit: s,
|
|
77
|
+
unreadOnly: o,
|
|
78
|
+
markSeen: m
|
|
74
79
|
})
|
|
75
|
-
}),
|
|
76
|
-
if (!
|
|
77
|
-
|
|
80
|
+
}), u = await j.json().catch(() => null);
|
|
81
|
+
if (!j.ok || !u?.ok) {
|
|
82
|
+
T(u?.error || "Unable to load notifications.");
|
|
78
83
|
return;
|
|
79
84
|
}
|
|
80
|
-
const
|
|
81
|
-
|
|
85
|
+
const E = Array.isArray(u.notifications) ? u.notifications : [];
|
|
86
|
+
h(E), b(Number.isFinite(u.unreadCount) ? Math.max(0, Math.floor(u.unreadCount ?? 0)) : 0), x(Number.isFinite(u.unseenCount) ? Math.max(0, Math.floor(u.unseenCount ?? 0)) : 0);
|
|
82
87
|
} catch {
|
|
83
|
-
|
|
88
|
+
T("Unable to load notifications.");
|
|
84
89
|
} finally {
|
|
85
|
-
|
|
90
|
+
B(!1);
|
|
86
91
|
}
|
|
87
|
-
}, [
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
if (
|
|
92
|
+
}, [s]);
|
|
93
|
+
J(() => {
|
|
94
|
+
if (r) {
|
|
95
|
+
if (i) {
|
|
91
96
|
(async () => {
|
|
92
97
|
try {
|
|
93
98
|
await fetch("/api/rb/notifications", {
|
|
@@ -108,20 +113,53 @@ function Ne({
|
|
|
108
113
|
})();
|
|
109
114
|
return;
|
|
110
115
|
}
|
|
111
|
-
|
|
112
|
-
unreadOnly:
|
|
116
|
+
L({
|
|
117
|
+
unreadOnly: p,
|
|
113
118
|
markSeen: !0
|
|
114
119
|
});
|
|
115
120
|
}
|
|
116
|
-
}, [
|
|
117
|
-
|
|
118
|
-
unreadOnly:
|
|
121
|
+
}, [r, i, L, p]), J(() => {
|
|
122
|
+
r && (i || L({
|
|
123
|
+
unreadOnly: p,
|
|
119
124
|
markSeen: !1
|
|
120
125
|
}));
|
|
121
|
-
}, [
|
|
122
|
-
|
|
126
|
+
}, [r, i, L, p]), J(() => {
|
|
127
|
+
if (!r || (g(G()), typeof navigator > "u" || !navigator.permissions?.query)) return;
|
|
128
|
+
let o = null, m = !1;
|
|
129
|
+
const j = () => {
|
|
130
|
+
g(G());
|
|
131
|
+
};
|
|
132
|
+
try {
|
|
133
|
+
navigator.permissions.query({
|
|
134
|
+
name: "notifications"
|
|
135
|
+
}).then((u) => {
|
|
136
|
+
m || (o = u, j(), u.addEventListener("change", j));
|
|
137
|
+
}).catch(() => {
|
|
138
|
+
});
|
|
139
|
+
} catch {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
return () => {
|
|
143
|
+
m = !0, o?.removeEventListener("change", j);
|
|
144
|
+
};
|
|
145
|
+
}, [r]);
|
|
146
|
+
const K = async () => {
|
|
147
|
+
if (typeof window > "u" || !("Notification" in window)) {
|
|
148
|
+
g("unsupported");
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
k(!0);
|
|
152
|
+
try {
|
|
153
|
+
const o = await window.Notification.requestPermission();
|
|
154
|
+
g(o);
|
|
155
|
+
} catch {
|
|
156
|
+
g(G());
|
|
157
|
+
} finally {
|
|
158
|
+
k(!1);
|
|
159
|
+
}
|
|
160
|
+
}, V = async (o) => {
|
|
123
161
|
try {
|
|
124
|
-
const
|
|
162
|
+
const m = await fetch(`/api/rb/notifications/${encodeURIComponent(o)}/read`, {
|
|
125
163
|
method: "POST",
|
|
126
164
|
headers: {
|
|
127
165
|
"Content-Type": "application/json"
|
|
@@ -129,164 +167,198 @@ function Ne({
|
|
|
129
167
|
credentials: "include",
|
|
130
168
|
keepalive: !0,
|
|
131
169
|
body: "{}"
|
|
132
|
-
}),
|
|
133
|
-
if (!
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
return
|
|
139
|
-
...
|
|
140
|
-
readAt:
|
|
141
|
-
...
|
|
142
|
-
seenAt:
|
|
170
|
+
}), j = await m.json().catch(() => null);
|
|
171
|
+
if (!m.ok || !j?.ok) return;
|
|
172
|
+
const u = (/* @__PURE__ */ new Date()).toISOString();
|
|
173
|
+
if (i) return;
|
|
174
|
+
h((E) => {
|
|
175
|
+
const w = E.find((N) => N.id === o);
|
|
176
|
+
return w && !w.readAt && b((N) => Math.max(0, N - 1)), w && !w.seenAt && x((N) => Math.max(0, N - 1)), E.map((N) => N.id === o && !N.readAt ? {
|
|
177
|
+
...N,
|
|
178
|
+
readAt: u,
|
|
179
|
+
...N.seenAt ? {} : {
|
|
180
|
+
seenAt: u
|
|
143
181
|
}
|
|
144
|
-
} :
|
|
182
|
+
} : N);
|
|
145
183
|
});
|
|
146
184
|
} catch {
|
|
147
185
|
return;
|
|
148
186
|
}
|
|
149
|
-
},
|
|
187
|
+
}, X = async (o) => {
|
|
150
188
|
try {
|
|
151
|
-
const
|
|
189
|
+
const m = await fetch(`/api/rb/notifications/${encodeURIComponent(o)}/archive`, {
|
|
152
190
|
method: "POST",
|
|
153
191
|
headers: {
|
|
154
192
|
"Content-Type": "application/json"
|
|
155
193
|
},
|
|
156
194
|
credentials: "include",
|
|
157
195
|
body: "{}"
|
|
158
|
-
}),
|
|
159
|
-
if (!
|
|
160
|
-
|
|
161
|
-
const
|
|
162
|
-
return
|
|
196
|
+
}), j = await m.json().catch(() => null);
|
|
197
|
+
if (!m.ok || !j?.ok || i) return;
|
|
198
|
+
h((u) => {
|
|
199
|
+
const E = u.find((w) => w.id === o);
|
|
200
|
+
return E && !E.readAt && b((w) => Math.max(0, w - 1)), E && !E.seenAt && x((w) => Math.max(0, w - 1)), u.filter((w) => w.id !== o);
|
|
163
201
|
});
|
|
164
202
|
} catch {
|
|
165
203
|
return;
|
|
166
204
|
}
|
|
167
205
|
};
|
|
168
|
-
return /* @__PURE__ */ t.jsx(
|
|
169
|
-
/* @__PURE__ */ t.jsx(
|
|
170
|
-
/* @__PURE__ */ t.jsxs(
|
|
206
|
+
return /* @__PURE__ */ t.jsx(ae, { open: r, onOpenChange: e, children: /* @__PURE__ */ t.jsxs(ce, { children: [
|
|
207
|
+
/* @__PURE__ */ t.jsx(le, { className: "fixed inset-0 z-50 bg-black/50" }),
|
|
208
|
+
/* @__PURE__ */ t.jsxs(de, { className: W("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: [
|
|
171
209
|
/* @__PURE__ */ t.jsxs("header", { className: "flex items-center justify-between gap-2 border-b px-4 py-3", children: [
|
|
172
210
|
/* @__PURE__ */ t.jsxs("div", { className: "flex min-w-0 flex-col", children: [
|
|
173
|
-
/* @__PURE__ */ t.jsx(
|
|
174
|
-
/* @__PURE__ */ t.jsx("span", { className: "text-xs text-muted-foreground", children:
|
|
211
|
+
/* @__PURE__ */ t.jsx(ue, { className: "text-sm font-semibold", children: "Notifications" }),
|
|
212
|
+
/* @__PURE__ */ t.jsx("span", { className: "text-xs text-muted-foreground", children: C > 0 ? `${C} unread` : F > 0 ? `${F} new` : "All caught up" })
|
|
175
213
|
] }),
|
|
176
214
|
/* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
177
|
-
/* @__PURE__ */ t.jsx("button", { type: "button", onClick: () =>
|
|
178
|
-
/* @__PURE__ */ t.jsx(
|
|
215
|
+
/* @__PURE__ */ t.jsx("button", { type: "button", onClick: () => P((o) => !o), className: W("rounded-md border px-2 py-1 text-xs", p ? "bg-accent text-foreground" : "bg-background text-muted-foreground hover:bg-accent"), children: p ? "Unread" : "All" }),
|
|
216
|
+
/* @__PURE__ */ t.jsx(me, { 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(ie, { className: "h-4 w-4" }) })
|
|
179
217
|
] })
|
|
180
218
|
] }),
|
|
181
|
-
/* @__PURE__ */ t.
|
|
182
|
-
/* @__PURE__ */ t.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
/* @__PURE__ */ t.jsx("div", { className: "sticky top-
|
|
186
|
-
/* @__PURE__ */ t.jsx("div", { className: "-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
/* @__PURE__ */ t.jsx("div", { className: "sticky top-
|
|
193
|
-
/* @__PURE__ */ t.jsx("div", { className: "-
|
|
194
|
-
|
|
219
|
+
/* @__PURE__ */ t.jsxs("div", { className: "flex-1 overflow-y-auto px-4 pb-3", children: [
|
|
220
|
+
/* @__PURE__ */ t.jsx(be, { permission: M, requesting: O, onEnable: K }),
|
|
221
|
+
z ? /* @__PURE__ */ t.jsx("div", { className: "flex items-center justify-center py-10 text-muted-foreground", children: /* @__PURE__ */ t.jsx(re, { className: "h-4 w-4 animate-spin" }) }) : S ? /* @__PURE__ */ t.jsx("div", { className: "py-10 text-center text-sm text-muted-foreground", children: S }) : y.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
|
+
/* @__PURE__ */ t.jsxs("div", { children: [
|
|
223
|
+
/* @__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
|
+
U.length === 0 ? /* @__PURE__ */ t.jsx("div", { className: "py-6 text-center text-sm text-muted-foreground", children: "No unread notifications." }) : U.map((o) => /* @__PURE__ */ t.jsxs("div", { children: [
|
|
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: o.label }),
|
|
226
|
+
/* @__PURE__ */ t.jsx("div", { className: "-mx-4 flex flex-col divide-y divide-border", children: o.items.map((m) => /* @__PURE__ */ t.jsx(Z, { notification: m, onMarkRead: V, onArchive: X }, m.id)) })
|
|
227
|
+
] }, `unread:${o.key}`))
|
|
228
|
+
] }),
|
|
229
|
+
p ? null : /* @__PURE__ */ t.jsxs("div", { children: [
|
|
230
|
+
/* @__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
|
+
I.length === 0 ? /* @__PURE__ */ t.jsx("div", { className: "py-6 text-center text-sm text-muted-foreground", children: "No previous notifications." }) : I.map((o) => /* @__PURE__ */ t.jsxs("div", { children: [
|
|
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: o.label }),
|
|
233
|
+
/* @__PURE__ */ t.jsx("div", { className: "-mx-4 flex flex-col divide-y divide-border", children: o.items.map((m) => /* @__PURE__ */ t.jsx(Z, { notification: m, onMarkRead: V, onArchive: X }, m.id)) })
|
|
234
|
+
] }, `previous:${o.key}`))
|
|
235
|
+
] })
|
|
195
236
|
] })
|
|
196
|
-
] })
|
|
237
|
+
] })
|
|
197
238
|
] })
|
|
198
239
|
] }) });
|
|
199
240
|
}
|
|
200
|
-
function
|
|
201
|
-
const e =
|
|
241
|
+
function be(r) {
|
|
242
|
+
const e = _.c(13), {
|
|
243
|
+
permission: n,
|
|
244
|
+
requesting: s,
|
|
245
|
+
onEnable: a
|
|
246
|
+
} = r;
|
|
247
|
+
if (n === "granted")
|
|
248
|
+
return null;
|
|
249
|
+
if (n === "unsupported") {
|
|
250
|
+
let v;
|
|
251
|
+
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
|
+
}
|
|
253
|
+
const c = n === "denied", i = c ? "Browser notifications are blocked." : "Browser notifications are not enabled.";
|
|
254
|
+
let f;
|
|
255
|
+
e[1] !== i ? (f = /* @__PURE__ */ t.jsx("div", { className: "text-sm font-medium", children: i }), e[1] = i, e[2] = f) : f = e[2];
|
|
256
|
+
const h = c ? "Enable notifications for this site in your browser settings, then click again." : "Enable browser notifications to receive important alerts.";
|
|
257
|
+
let l;
|
|
258
|
+
e[3] !== h ? (l = /* @__PURE__ */ t.jsx("div", { className: "mt-1 text-xs text-muted-foreground", children: h }), e[3] = h, e[4] = l) : l = e[4];
|
|
259
|
+
const b = s ? "Enabling..." : "Enable browser notifications";
|
|
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];
|
|
262
|
+
let x;
|
|
263
|
+
return e[9] !== f || e[10] !== l || e[11] !== d ? (x = /* @__PURE__ */ t.jsxs("div", { className: "mt-3 rounded-md border bg-muted/40 p-3", children: [
|
|
264
|
+
f,
|
|
265
|
+
l,
|
|
266
|
+
d
|
|
267
|
+
] }), e[9] = f, e[10] = l, e[11] = d, e[12] = x) : x = e[12], x;
|
|
268
|
+
}
|
|
269
|
+
function Z(r) {
|
|
270
|
+
const e = _.c(47), {
|
|
202
271
|
notification: n,
|
|
203
|
-
onMarkRead:
|
|
272
|
+
onMarkRead: s,
|
|
204
273
|
onArchive: a
|
|
205
|
-
} =
|
|
206
|
-
let
|
|
207
|
-
|
|
274
|
+
} = r, [c, i] = R(!1), f = H(null), h = H(null), l = !n.readAt;
|
|
275
|
+
let b;
|
|
276
|
+
e[0] !== n ? (b = pe(n), e[0] = n, e[1] = b) : b = e[1];
|
|
277
|
+
const d = b;
|
|
278
|
+
let x;
|
|
279
|
+
if (e[2] !== n.createdAt) {
|
|
208
280
|
e: {
|
|
209
|
-
const
|
|
210
|
-
if (!Number.isFinite(
|
|
211
|
-
|
|
281
|
+
const U = new Date(ee(n.createdAt));
|
|
282
|
+
if (!Number.isFinite(U.getTime())) {
|
|
283
|
+
x = "";
|
|
212
284
|
break e;
|
|
213
285
|
}
|
|
214
|
-
|
|
286
|
+
x = U.toLocaleString();
|
|
215
287
|
}
|
|
216
|
-
e[
|
|
288
|
+
e[2] = n.createdAt, e[3] = x;
|
|
217
289
|
} else
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
let
|
|
221
|
-
e[
|
|
222
|
-
if (!
|
|
290
|
+
x = e[3];
|
|
291
|
+
const v = x;
|
|
292
|
+
let B, q;
|
|
293
|
+
e[4] !== c ? (B = () => {
|
|
294
|
+
if (!c)
|
|
223
295
|
return;
|
|
224
|
-
const
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
},
|
|
228
|
-
|
|
296
|
+
const U = (L) => {
|
|
297
|
+
const K = L.target;
|
|
298
|
+
K instanceof Node && (f.current?.contains(K) || h.current?.contains(K) || i(!1));
|
|
299
|
+
}, I = (L) => {
|
|
300
|
+
L.key === "Escape" && (i(!1), h.current?.focus());
|
|
229
301
|
};
|
|
230
|
-
return document.addEventListener("pointerdown",
|
|
231
|
-
document.removeEventListener("pointerdown",
|
|
302
|
+
return document.addEventListener("pointerdown", U), document.addEventListener("keydown", I), () => {
|
|
303
|
+
document.removeEventListener("pointerdown", U), document.removeEventListener("keydown", I);
|
|
232
304
|
};
|
|
233
|
-
},
|
|
234
|
-
const
|
|
235
|
-
let
|
|
236
|
-
e[
|
|
237
|
-
let
|
|
238
|
-
e[
|
|
239
|
-
|
|
240
|
-
}, e[
|
|
241
|
-
let c;
|
|
242
|
-
e[12] !== n.title ? (c = /* @__PURE__ */ t.jsx("div", { className: "truncate text-sm font-semibold", children: n.title }), e[12] = n.title, e[13] = c) : c = e[13];
|
|
305
|
+
}, q = [c], e[4] = c, e[5] = B, e[6] = q) : (B = e[5], q = e[6]), J(B, q);
|
|
306
|
+
const T = l ? "bg-primary/5" : "bg-background";
|
|
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];
|
|
243
313
|
let M;
|
|
244
|
-
e[14] !== n.
|
|
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];
|
|
317
|
+
let O;
|
|
318
|
+
e[18] !== M || e[19] !== g ? (O = /* @__PURE__ */ t.jsxs("div", { className: "min-w-0", children: [
|
|
319
|
+
M,
|
|
320
|
+
g
|
|
321
|
+
] }), e[18] = M, e[19] = g, e[20] = O) : O = e[20];
|
|
322
|
+
let k;
|
|
323
|
+
e[21] !== d ? (k = d ? /* @__PURE__ */ t.jsx("div", { className: "mt-2 truncate text-xs text-primary", children: d }) : null, e[21] = d, e[22] = k) : k = e[22];
|
|
324
|
+
let A;
|
|
325
|
+
e[23] !== v ? (A = v ? /* @__PURE__ */ t.jsx("div", { className: "mt-2 text-[11px] text-muted-foreground", children: v }) : null, e[23] = v, e[24] = A) : A = e[24];
|
|
326
|
+
let C;
|
|
327
|
+
e[25] !== O || e[26] !== k || e[27] !== A || e[28] !== P ? (C = /* @__PURE__ */ t.jsxs("button", { type: "button", className: "min-w-0 flex-1 text-left", onClick: P, children: [
|
|
328
|
+
O,
|
|
329
|
+
k,
|
|
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]);
|
|
336
|
+
let S;
|
|
337
|
+
e[32] !== c ? (S = /* @__PURE__ */ t.jsx("button", { ref: h, 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": c, onClick: F, children: z }), e[32] = c, e[33] = S) : S = e[33];
|
|
245
338
|
let y;
|
|
246
|
-
e[
|
|
247
|
-
c,
|
|
248
|
-
M
|
|
249
|
-
] }), e[16] = c, e[17] = M, e[18] = y) : y = e[18];
|
|
250
|
-
let v;
|
|
251
|
-
e[19] !== n.url ? (v = n.url ? /* @__PURE__ */ t.jsx("div", { className: "mt-2 truncate text-xs text-primary", children: n.url }) : null, e[19] = n.url, e[20] = v) : v = e[20];
|
|
252
|
-
let j;
|
|
253
|
-
e[21] !== F ? (j = F ? /* @__PURE__ */ t.jsx("div", { className: "mt-2 text-[11px] text-muted-foreground", children: F }) : null, e[21] = F, e[22] = j) : j = e[22];
|
|
254
|
-
let R;
|
|
255
|
-
e[23] !== v || e[24] !== j || e[25] !== h || e[26] !== y ? (R = /* @__PURE__ */ t.jsxs("button", { type: "button", className: "min-w-0 flex-1 text-left", onClick: h, children: [
|
|
256
|
-
y,
|
|
257
|
-
v,
|
|
258
|
-
j
|
|
259
|
-
] }), e[23] = v, e[24] = j, e[25] = h, e[26] = y, e[27] = R) : R = e[27];
|
|
260
|
-
let O, p;
|
|
261
|
-
e[28] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (O = () => {
|
|
262
|
-
o(de);
|
|
263
|
-
}, p = /* @__PURE__ */ t.jsx(ee, { className: "h-4 w-4" }), e[28] = O, e[29] = p) : (O = e[28], p = e[29]);
|
|
264
|
-
let N;
|
|
265
|
-
e[30] !== l ? (N = /* @__PURE__ */ t.jsx("button", { ref: A, 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": l, onClick: O, children: p }), e[30] = l, e[31] = N) : N = e[31];
|
|
266
|
-
let w;
|
|
267
|
-
e[32] !== f || e[33] !== l || e[34] !== n.id || e[35] !== a || e[36] !== i ? (w = l ? /* @__PURE__ */ t.jsxs("div", { ref: U, role: "menu", className: K("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: [
|
|
339
|
+
e[34] !== l || e[35] !== c || e[36] !== n.id || e[37] !== a || e[38] !== s ? (y = c ? /* @__PURE__ */ t.jsxs("div", { ref: f, role: "menu", className: W("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: [
|
|
268
340
|
/* @__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: () => {
|
|
269
|
-
|
|
341
|
+
i(!1), a(n.id);
|
|
270
342
|
}, children: "Archive" }),
|
|
271
|
-
/* @__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: !
|
|
272
|
-
|
|
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: !l, onClick: () => {
|
|
344
|
+
i(!1), s(n.id);
|
|
273
345
|
}, children: "Mark as read" })
|
|
274
|
-
] }) : null, e[
|
|
275
|
-
let
|
|
276
|
-
e[
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
] }), e[
|
|
280
|
-
let
|
|
281
|
-
return e[
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
] }), e[
|
|
346
|
+
] }) : null, e[34] = l, e[35] = c, e[36] = n.id, e[37] = a, e[38] = s, e[39] = y) : y = e[39];
|
|
347
|
+
let D;
|
|
348
|
+
e[40] !== S || e[41] !== y ? (D = /* @__PURE__ */ t.jsxs("div", { className: "relative flex items-start", children: [
|
|
349
|
+
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
|
+
D
|
|
356
|
+
] }), e[43] = C, e[44] = D, e[45] = p, e[46] = $) : $ = e[46], $;
|
|
285
357
|
}
|
|
286
|
-
function
|
|
287
|
-
return !
|
|
358
|
+
function ge(r) {
|
|
359
|
+
return !r;
|
|
288
360
|
}
|
|
289
361
|
export {
|
|
290
|
-
|
|
362
|
+
Re as NotificationsDrawer
|
|
291
363
|
};
|
|
292
364
|
//# sourceMappingURL=index16.js.map
|