@burdenoff/microfe-notification 2026.1202.1 → 2026.1203.1
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/v2/InboxPage.js +111 -109
- package/dist/v2/InboxPage.js.map +1 -1
- package/dist/v2/InboxRows.js +50 -45
- package/dist/v2/InboxRows.js.map +1 -1
- package/dist/v2/NotificationDetailPanel.js +97 -93
- package/dist/v2/NotificationDetailPanel.js.map +1 -1
- package/dist/v2/PreferencesPage.js +75 -74
- package/dist/v2/PreferencesPage.js.map +1 -1
- package/dist/v2/admin/TemplateEditor.js +58 -55
- package/dist/v2/admin/TemplateEditor.js.map +1 -1
- package/dist/v2/admin/TemplatesPage.js +96 -93
- package/dist/v2/admin/TemplatesPage.js.map +1 -1
- package/dist/v2/admin/TopicDialog.js +66 -65
- package/dist/v2/admin/TopicDialog.js.map +1 -1
- package/dist/v2/admin/TopicsPage.js +85 -82
- package/dist/v2/admin/TopicsPage.js.map +1 -1
- package/dist/v2/admin/useTemplateDraft.js +73 -72
- package/dist/v2/admin/useTemplateDraft.js.map +1 -1
- package/dist/v2/send/SendNotificationDialog.js +53 -51
- package/dist/v2/send/SendNotificationDialog.js.map +1 -1
- package/dist/v2/useNeedsConnection.d.ts +29 -0
- package/dist/v2/useNeedsConnection.js +51 -0
- package/dist/v2/useNeedsConnection.js.map +1 -0
- package/package.json +1 -1
package/dist/v2/InboxPage.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { useNotifications as e } from "../hooks/useNotifications.js";
|
|
2
2
|
import { useTr as t } from "../shared/hooks/useTr.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
3
|
+
import { useConnectionGate as n, useNeedsConnection as r, waitingButton as i } from "./useNeedsConnection.js";
|
|
4
|
+
import { useNotificationPaths as a } from "../navigation-v2/paths.js";
|
|
5
|
+
import { holdsAdminToolPermission as o, useAdminTools as ee } from "../navigation-v2/useAdminTools.js";
|
|
6
|
+
import { INBOX_TABS as s, isUnread as c, needsAction as l, readInboxTab as u } from "./model/inbox.js";
|
|
7
|
+
import { InboxRows as d } from "./InboxRows.js";
|
|
8
|
+
import { NotificationDetailPanel as f } from "./NotificationDetailPanel.js";
|
|
9
|
+
import { useMarkUnread as p } from "./useNotificationDetail.js";
|
|
10
|
+
import { SendNotificationDialog as m } from "./send/SendNotificationDialog.js";
|
|
11
|
+
import { StaleHint as te } from "./StaleHint.js";
|
|
12
|
+
import { SEND_PARAM as h } from "./send/sendModel.js";
|
|
13
|
+
import { useMemo as g } from "react";
|
|
14
|
+
import { usePermissions as _ } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
15
|
+
import { CheckCheck as v, Search as y } from "lucide-react";
|
|
16
|
+
import { Navigate as b, useNavigate as x, useSearchParams as S } from "react-router";
|
|
17
|
+
import { jsx as C, jsxs as w } from "react/jsx-runtime";
|
|
18
|
+
import { PageHeader as T } from "@burdenoff/fe-libs/chrome";
|
|
19
|
+
import { Button as E, EmptyState as D, Input as O, LoadError as k, PageTabs as A, WorkspacePage as j, useNotify as M } from "@burdenoff/fe-libs/ui";
|
|
19
20
|
// src/v2/InboxPage.tsx
|
|
20
|
-
var
|
|
21
|
+
var N = {
|
|
21
22
|
all: {
|
|
22
23
|
archived: !1,
|
|
23
24
|
channel: "IN_APP"
|
|
@@ -35,155 +36,156 @@ var M = {
|
|
|
35
36
|
archived: !0,
|
|
36
37
|
channel: "IN_APP"
|
|
37
38
|
}
|
|
38
|
-
},
|
|
39
|
-
function
|
|
39
|
+
}, P = { channel: "IN_APP" };
|
|
40
|
+
function F(e, t) {
|
|
40
41
|
return e === "send" ? t.send : e === "templates" ? t.templates : e === "topics" ? t.topics : e === "history" ? t.deliveryLog : null;
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
-
let e =
|
|
44
|
-
return
|
|
45
|
-
to:
|
|
43
|
+
function I() {
|
|
44
|
+
let e = a(), [t] = S(), n = F(t.get("tab"), e);
|
|
45
|
+
return n ? /* @__PURE__ */ C(b, {
|
|
46
|
+
to: n,
|
|
46
47
|
replace: !0
|
|
47
|
-
}) : /* @__PURE__ */
|
|
48
|
+
}) : /* @__PURE__ */ C(L, {});
|
|
48
49
|
}
|
|
49
|
-
function
|
|
50
|
-
let
|
|
51
|
-
baseFilter:
|
|
52
|
-
unreadFilter:
|
|
53
|
-
}),
|
|
54
|
-
let t = new URLSearchParams(
|
|
55
|
-
e ? t.set("open", e) : t.delete("open"),
|
|
56
|
-
},
|
|
57
|
-
let t = new URLSearchParams(
|
|
58
|
-
e ? t.set(
|
|
59
|
-
},
|
|
60
|
-
let e =
|
|
61
|
-
await
|
|
62
|
-
title:
|
|
50
|
+
function L() {
|
|
51
|
+
let b = t(), D = r(), F = n(), I = x(), L = M(), z = a(), { tools: B } = ee(), { hasPermission: V, isLoading: H } = _(), [U, W] = S(), G = U.get("send") === "1" && !H && o("send", V), K = u(U.get("tab")), q = U.get("open"), J = e({
|
|
52
|
+
baseFilter: N[K],
|
|
53
|
+
unreadFilter: P
|
|
54
|
+
}), Y = p(), X = g(() => K === "action" ? J.notifications.filter(l) : J.notifications, [J.notifications, K]), Z = J.notificationFilter.search ?? "", Q = (e) => {
|
|
55
|
+
let t = new URLSearchParams(U);
|
|
56
|
+
e ? t.set("open", e) : t.delete("open"), W(t);
|
|
57
|
+
}, $ = (e) => {
|
|
58
|
+
let t = new URLSearchParams(U);
|
|
59
|
+
e ? t.set(h, "1") : t.delete(h), W(t);
|
|
60
|
+
}, ne = async () => {
|
|
61
|
+
let e = J.allNotifications.filter(c).map((e) => e.id), t = e.length >= J.unreadCount;
|
|
62
|
+
await J.markAllAsRead(), L({
|
|
63
|
+
title: b("notifications.v3.markedAll", "Marked {{count}} as read", { count: J.unreadCount || e.length }),
|
|
63
64
|
tone: "success",
|
|
64
65
|
undo: t && e.length > 0 ? async () => {
|
|
65
|
-
|
|
66
|
+
if (F()) throw Error("Undo needs a connection");
|
|
67
|
+
await Y(e), await J.refetch();
|
|
66
68
|
} : void 0
|
|
67
69
|
});
|
|
68
|
-
},
|
|
69
|
-
all:
|
|
70
|
-
unread:
|
|
71
|
-
action:
|
|
72
|
-
archived:
|
|
70
|
+
}, re = {
|
|
71
|
+
all: b("notifications.v3.tab.all", "All"),
|
|
72
|
+
unread: b("notifications.v3.tab.unread", "Unread"),
|
|
73
|
+
action: b("notifications.v3.tab.action", "Needs action"),
|
|
74
|
+
archived: b("notifications.v3.tab.archived", "Archived")
|
|
73
75
|
};
|
|
74
|
-
return /* @__PURE__ */
|
|
75
|
-
/* @__PURE__ */
|
|
76
|
+
return /* @__PURE__ */ w(j, { children: [
|
|
77
|
+
/* @__PURE__ */ C(T, {
|
|
76
78
|
variant: "compact",
|
|
77
|
-
title:
|
|
78
|
-
description:
|
|
79
|
-
primary: /* @__PURE__ */
|
|
79
|
+
title: b("notifications.v3.title", "Notifications"),
|
|
80
|
+
description: b("notifications.v3.purpose", "Everything that needs you, and everything you were told."),
|
|
81
|
+
primary: /* @__PURE__ */ w(E, {
|
|
80
82
|
variant: "outline",
|
|
81
|
-
|
|
82
|
-
onClick: () => void
|
|
83
|
+
...i(D, J.unreadCount === 0),
|
|
84
|
+
onClick: () => void ne(),
|
|
83
85
|
"data-testid": "inbox-mark-all",
|
|
84
|
-
children: [/* @__PURE__ */
|
|
86
|
+
children: [/* @__PURE__ */ C(v, { "aria-hidden": "true" }), b("notifications.v3.markAll", "Mark all as read")]
|
|
85
87
|
}),
|
|
86
88
|
settings: {
|
|
87
|
-
label:
|
|
88
|
-
onClick: () =>
|
|
89
|
+
label: b("notifications.v3.settings", "Notification settings"),
|
|
90
|
+
onClick: () => I(z.preferences)
|
|
89
91
|
},
|
|
90
|
-
more:
|
|
92
|
+
more: B.map((e) => e.id === "send" ? {
|
|
91
93
|
id: e.id,
|
|
92
|
-
label:
|
|
93
|
-
onSelect: () =>
|
|
94
|
+
label: b("notifications.v3.send.title", "Send a notification"),
|
|
95
|
+
onSelect: () => $(!0)
|
|
94
96
|
} : {
|
|
95
97
|
id: e.id,
|
|
96
98
|
label: e.label,
|
|
97
|
-
onSelect: () =>
|
|
99
|
+
onSelect: () => I(e.href)
|
|
98
100
|
})
|
|
99
101
|
}),
|
|
100
|
-
/* @__PURE__ */
|
|
101
|
-
ariaLabel:
|
|
102
|
-
activeId:
|
|
103
|
-
tabs:
|
|
102
|
+
/* @__PURE__ */ C(A, {
|
|
103
|
+
ariaLabel: b("notifications.v3.title", "Notifications"),
|
|
104
|
+
activeId: K,
|
|
105
|
+
tabs: s.map((e) => ({
|
|
104
106
|
id: e,
|
|
105
|
-
label:
|
|
107
|
+
label: re[e],
|
|
106
108
|
href: `?tab=${e}`,
|
|
107
|
-
badge: e === "unread" &&
|
|
109
|
+
badge: e === "unread" && J.unreadCount > 0 ? J.unreadCount : void 0
|
|
108
110
|
}))
|
|
109
111
|
}),
|
|
110
|
-
/* @__PURE__ */
|
|
111
|
-
/* @__PURE__ */
|
|
112
|
+
/* @__PURE__ */ C(te, { loadedAt: J.dataUpdatedAt }),
|
|
113
|
+
/* @__PURE__ */ w("div", {
|
|
112
114
|
className: "flex flex-col gap-3",
|
|
113
115
|
children: [
|
|
114
|
-
/* @__PURE__ */
|
|
116
|
+
/* @__PURE__ */ w("label", {
|
|
115
117
|
className: "relative block max-w-md",
|
|
116
118
|
children: [
|
|
117
|
-
/* @__PURE__ */
|
|
119
|
+
/* @__PURE__ */ C("span", {
|
|
118
120
|
className: "sr-only",
|
|
119
|
-
children:
|
|
121
|
+
children: b("notifications.v3.search", "Search notifications")
|
|
120
122
|
}),
|
|
121
|
-
/* @__PURE__ */
|
|
123
|
+
/* @__PURE__ */ C(y, {
|
|
122
124
|
className: "pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-text-muted",
|
|
123
125
|
"aria-hidden": "true"
|
|
124
126
|
}),
|
|
125
|
-
/* @__PURE__ */
|
|
127
|
+
/* @__PURE__ */ C(O, {
|
|
126
128
|
type: "search",
|
|
127
129
|
className: "pl-9",
|
|
128
|
-
value:
|
|
129
|
-
placeholder:
|
|
130
|
-
onChange: (e) =>
|
|
130
|
+
value: Z,
|
|
131
|
+
placeholder: b("notifications.v3.search", "Search notifications"),
|
|
132
|
+
onChange: (e) => J.updateFilter({ search: e.target.value }),
|
|
131
133
|
"data-testid": "inbox-search"
|
|
132
134
|
})
|
|
133
135
|
]
|
|
134
136
|
}),
|
|
135
|
-
|
|
136
|
-
what:
|
|
137
|
-
error:
|
|
138
|
-
onRetry: () => void
|
|
139
|
-
}) : !
|
|
140
|
-
tab:
|
|
141
|
-
searching: !!
|
|
142
|
-
}) : /* @__PURE__ */
|
|
143
|
-
notifications:
|
|
144
|
-
loading:
|
|
137
|
+
J.error && X.length === 0 ? /* @__PURE__ */ C(k, {
|
|
138
|
+
what: b("notifications.v3.title", "Notifications"),
|
|
139
|
+
error: J.error,
|
|
140
|
+
onRetry: () => void J.refetch()
|
|
141
|
+
}) : !J.isLoading && X.length === 0 ? /* @__PURE__ */ C(R, {
|
|
142
|
+
tab: K,
|
|
143
|
+
searching: !!Z.trim()
|
|
144
|
+
}) : /* @__PURE__ */ C(d, {
|
|
145
|
+
notifications: X,
|
|
146
|
+
loading: J.isLoading && X.length === 0,
|
|
145
147
|
onOpen: (e) => {
|
|
146
|
-
|
|
147
|
-
let t =
|
|
148
|
-
t &&
|
|
148
|
+
Q(e);
|
|
149
|
+
let t = X.find((t) => t.id === e);
|
|
150
|
+
t && c(t) && !D.waiting && J.markAsRead(e);
|
|
149
151
|
},
|
|
150
|
-
onMarkRead: (e) => void
|
|
151
|
-
onMarkUnread: (e) => void
|
|
152
|
-
onArchive: (e) => void
|
|
153
|
-
onRestore: (e) => void
|
|
152
|
+
onMarkRead: (e) => void J.markAsRead(e),
|
|
153
|
+
onMarkUnread: (e) => void Y([e]).then(() => J.refetch()),
|
|
154
|
+
onArchive: (e) => void J.archiveNotification(e),
|
|
155
|
+
onRestore: (e) => void J.unarchiveNotification(e)
|
|
154
156
|
}),
|
|
155
|
-
|
|
157
|
+
J.hasMore ? /* @__PURE__ */ C("div", {
|
|
156
158
|
className: "flex justify-center",
|
|
157
|
-
children: /* @__PURE__ */
|
|
159
|
+
children: /* @__PURE__ */ C(E, {
|
|
158
160
|
variant: "ghost",
|
|
159
|
-
busy:
|
|
160
|
-
onClick: () => void
|
|
161
|
+
busy: J.isLoadingMore,
|
|
162
|
+
onClick: () => void J.loadMore(),
|
|
161
163
|
"data-testid": "inbox-more",
|
|
162
|
-
children:
|
|
164
|
+
children: b("notifications.v3.more", "Show more")
|
|
163
165
|
})
|
|
164
166
|
}) : null
|
|
165
167
|
]
|
|
166
168
|
}),
|
|
167
|
-
/* @__PURE__ */
|
|
168
|
-
id:
|
|
169
|
-
onClose: () =>
|
|
169
|
+
/* @__PURE__ */ C(f, {
|
|
170
|
+
id: q,
|
|
171
|
+
onClose: () => Q(null),
|
|
170
172
|
inboxActions: {
|
|
171
|
-
markUnread: (e) => void
|
|
173
|
+
markUnread: (e) => void Y([e]).then(() => J.refetch()),
|
|
172
174
|
archive: (e) => {
|
|
173
|
-
|
|
175
|
+
J.archiveNotification(e), Q(null);
|
|
174
176
|
},
|
|
175
|
-
restore: (e) => void
|
|
177
|
+
restore: (e) => void J.unarchiveNotification(e)
|
|
176
178
|
}
|
|
177
179
|
}),
|
|
178
|
-
/* @__PURE__ */
|
|
179
|
-
open:
|
|
180
|
-
onClose: () =>
|
|
180
|
+
/* @__PURE__ */ C(m, {
|
|
181
|
+
open: G,
|
|
182
|
+
onClose: () => $(!1)
|
|
181
183
|
})
|
|
182
184
|
] });
|
|
183
185
|
}
|
|
184
|
-
function
|
|
186
|
+
function R({ tab: e, searching: n }) {
|
|
185
187
|
let r = t();
|
|
186
|
-
if (n) return /* @__PURE__ */
|
|
188
|
+
if (n) return /* @__PURE__ */ C(D, {
|
|
187
189
|
kind: "no-results",
|
|
188
190
|
title: r("notifications.v3.empty.searchTitle", "No notifications match"),
|
|
189
191
|
description: r("notifications.v3.empty.searchBody", "Try other words.")
|
|
@@ -194,12 +196,12 @@ function L({ tab: e, searching: n }) {
|
|
|
194
196
|
action: [r("notifications.v3.empty.actionTitle", "Nothing waiting for you"), r("notifications.v3.empty.actionBody", "Approvals and requests show up here.")],
|
|
195
197
|
archived: [r("notifications.v3.empty.archivedTitle", "Nothing archived"), r("notifications.v3.empty.archivedBody", "Archive a notification to keep it out of the way. It stays here.")]
|
|
196
198
|
}[e];
|
|
197
|
-
return /* @__PURE__ */
|
|
199
|
+
return /* @__PURE__ */ C(D, {
|
|
198
200
|
kind: e === "archived" ? "first-use" : "all-done",
|
|
199
201
|
title: i,
|
|
200
202
|
description: a
|
|
201
203
|
});
|
|
202
204
|
}
|
|
203
|
-
export {
|
|
205
|
+
export { I as InboxPage };
|
|
204
206
|
|
|
205
207
|
//# sourceMappingURL=InboxPage.js.map
|
package/dist/v2/InboxPage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InboxPage.js","names":["Inbox","TAB_FILTERS","UNREAD_FILTER","oldTabTarget","tab","paths","InboxPage","useNotificationPaths","params","useSearchParams","target","Navigate","Inbox$1","tr","useTr","navigate","useNavigate","notify","useNotify","useAdminTools","permissionsLoading","usePermissions","setParams","sendOpen","holdsAdminToolPermission","hasPermission","readInboxTab","openId","inbox","useNotifications","markUnread","useMarkUnread","shown","useMemo","needsAction","search","open","next","id","showSend","show","SEND_PARAM","markAll","unreadIds","isUnread","n","everyOne","tabLabel","WorkspacePage","PageHeader","Button","CheckCheck","tools","tool","PageTabs","INBOX_TABS","StaleHint","Search","Input","event","LoadError","InboxEmpty","InboxRows","notification","NotificationDetailPanel","SendNotificationDialog","searching","EmptyState","title","description"],"sources":["../../src/v2/InboxPage.tsx"],"sourcesContent":["/**\n * Notifications (BOFF-16785, C1; the mockup's `notif`), under fe-libs' `accountPagesV2`: the inbox\n * at the list width, tabs All · Unread · Needs action · Archived (`?tab=`), compact rows grouped by\n * day, \"Mark all as read\" with Undo, the settings under the gear and, for admins, Send a\n * notification (a dialog, `?send=1`), Templates, Topics and the Delivery log in ⋯. A row opens its panel (`?open=<id>`, decision 10). The same\n * queries as the inbox today (`useNotifications`).\n */\nimport { useMemo } from 'react';\nimport { Navigate, useNavigate, useSearchParams } from 'react-router';\nimport { CheckCheck, Search } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport {\n Button,\n EmptyState,\n Input,\n LoadError,\n PageTabs,\n WorkspacePage,\n useNotify,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotifications } from '../hooks';\nimport type { NotificationFilter } from '../types';\nimport { useTr } from '../shared/hooks/useTr';\nimport { useNotificationPaths } from '../navigation-v2/paths';\nimport { holdsAdminToolPermission, useAdminTools } from '../navigation-v2/useAdminTools';\nimport { INBOX_TABS, isUnread, needsAction, readInboxTab, type InboxTab } from './model/inbox';\nimport { InboxRows } from './InboxRows';\nimport { NotificationDetailPanel } from './NotificationDetailPanel';\nimport { useMarkUnread } from './useNotificationDetail';\nimport { SendNotificationDialog } from './send/SendNotificationDialog';\nimport { StaleHint } from './StaleHint';\nimport { SEND_PARAM } from './send/sendModel';\n\n/** What each tab asks the service for: the in-app inbox, archived or not, unread or not. */\nconst TAB_FILTERS: Record<InboxTab, Partial<NotificationFilter>> = {\n all: { archived: false, channel: 'IN_APP' },\n unread: { archived: false, channel: 'IN_APP', isRead: false },\n action: { archived: false, channel: 'IN_APP' },\n archived: { archived: true, channel: 'IN_APP' },\n};\nconst UNREAD_FILTER = { channel: 'IN_APP' };\n\n/** Where today's `?tab=` values still go (the round-1 landing's links). */\nfunction oldTabTarget(\n tab: string | null,\n paths: ReturnType<typeof useNotificationPaths>\n): string | null {\n if (tab === 'send') return paths.send;\n if (tab === 'templates') return paths.templates;\n if (tab === 'topics') return paths.topics;\n if (tab === 'history') return paths.deliveryLog;\n return null;\n}\n\nexport function InboxPage() {\n const paths = useNotificationPaths();\n const [params] = useSearchParams();\n const target = oldTabTarget(params.get('tab'), paths);\n if (target) return <Navigate to={target} replace />;\n return <Inbox />;\n}\n\nfunction Inbox() {\n const tr = useTr();\n const navigate = useNavigate();\n const notify = useNotify();\n const paths = useNotificationPaths();\n const { tools } = useAdminTools();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const [params, setParams] = useSearchParams();\n // Send a notification (C2b): a dialog over the inbox, for whoever may send.\n const sendOpen =\n params.get(SEND_PARAM) === '1' &&\n !permissionsLoading &&\n holdsAdminToolPermission('send', hasPermission);\n const tab = readInboxTab(params.get('tab'));\n const openId = params.get('open');\n const inbox = useNotifications({ baseFilter: TAB_FILTERS[tab], unreadFilter: UNREAD_FILTER });\n const markUnread = useMarkUnread();\n const shown = useMemo(\n () => (tab === 'action' ? inbox.notifications.filter(needsAction) : inbox.notifications),\n [inbox.notifications, tab]\n );\n const search = inbox.notificationFilter.search ?? '';\n\n const open = (id: string | null) => {\n const next = new URLSearchParams(params);\n if (id) next.set('open', id);\n else next.delete('open');\n setParams(next);\n };\n\n const showSend = (show: boolean) => {\n const next = new URLSearchParams(params);\n if (show) next.set(SEND_PARAM, '1');\n else next.delete(SEND_PARAM);\n setParams(next);\n };\n\n const markAll = async () => {\n // Undo can only bring back what's loaded: offer it when every unread one is on the page.\n const unreadIds = inbox.allNotifications.filter(isUnread).map((n) => n.id);\n const everyOne = unreadIds.length >= inbox.unreadCount;\n await inbox.markAllAsRead();\n notify({\n title: tr('notifications.v3.markedAll', 'Marked {{count}} as read', {\n count: inbox.unreadCount || unreadIds.length,\n }),\n tone: 'success',\n undo:\n everyOne && unreadIds.length > 0\n ? async () => {\n await markUnread(unreadIds);\n await inbox.refetch();\n }\n : undefined,\n });\n };\n\n const tabLabel: Record<InboxTab, string> = {\n all: tr('notifications.v3.tab.all', 'All'),\n unread: tr('notifications.v3.tab.unread', 'Unread'),\n action: tr('notifications.v3.tab.action', 'Needs action'),\n archived: tr('notifications.v3.tab.archived', 'Archived'),\n };\n\n return (\n <WorkspacePage>\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.title', 'Notifications')}\n description={tr(\n 'notifications.v3.purpose',\n 'Everything that needs you, and everything you were told.'\n )}\n primary={\n <Button\n variant=\"outline\"\n disabled={inbox.unreadCount === 0}\n onClick={() => void markAll()}\n data-testid=\"inbox-mark-all\"\n >\n <CheckCheck aria-hidden=\"true\" />\n {tr('notifications.v3.markAll', 'Mark all as read')}\n </Button>\n }\n settings={{\n label: tr('notifications.v3.settings', 'Notification settings'),\n onClick: () => navigate(paths.preferences),\n }}\n more={tools.map((tool) =>\n tool.id === 'send'\n ? {\n id: tool.id,\n label: tr('notifications.v3.send.title', 'Send a notification'),\n onSelect: () => showSend(true),\n }\n : { id: tool.id, label: tool.label, onSelect: () => navigate(tool.href) }\n )}\n />\n <PageTabs\n ariaLabel={tr('notifications.v3.title', 'Notifications')}\n activeId={tab}\n tabs={INBOX_TABS.map((id) => ({\n id,\n label: tabLabel[id],\n href: `?tab=${id}`,\n badge: id === 'unread' && inbox.unreadCount > 0 ? inbox.unreadCount : undefined,\n }))}\n />\n <StaleHint loadedAt={inbox.dataUpdatedAt} />\n <div className=\"flex flex-col gap-3\">\n <label className=\"relative block max-w-md\">\n <span className=\"sr-only\">{tr('notifications.v3.search', 'Search notifications')}</span>\n <Search\n className=\"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-text-muted\"\n aria-hidden=\"true\"\n />\n <Input\n type=\"search\"\n className=\"pl-9\"\n value={search}\n placeholder={tr('notifications.v3.search', 'Search notifications')}\n onChange={(event) => inbox.updateFilter({ search: event.target.value })}\n data-testid=\"inbox-search\"\n />\n </label>\n {inbox.error && shown.length === 0 ? (\n <LoadError\n what={tr('notifications.v3.title', 'Notifications')}\n error={inbox.error}\n onRetry={() => void inbox.refetch()}\n />\n ) : !inbox.isLoading && shown.length === 0 ? (\n <InboxEmpty tab={tab} searching={Boolean(search.trim())} />\n ) : (\n <InboxRows\n notifications={shown}\n loading={inbox.isLoading && shown.length === 0}\n onOpen={(id) => {\n open(id);\n const notification = shown.find((n) => n.id === id);\n if (notification && isUnread(notification)) void inbox.markAsRead(id);\n }}\n onMarkRead={(id) => void inbox.markAsRead(id)}\n onMarkUnread={(id) => void markUnread([id]).then(() => inbox.refetch())}\n onArchive={(id) => void inbox.archiveNotification(id)}\n onRestore={(id) => void inbox.unarchiveNotification(id)}\n />\n )}\n {inbox.hasMore ? (\n <div className=\"flex justify-center\">\n <Button\n variant=\"ghost\"\n busy={inbox.isLoadingMore}\n onClick={() => void inbox.loadMore()}\n data-testid=\"inbox-more\"\n >\n {tr('notifications.v3.more', 'Show more')}\n </Button>\n </div>\n ) : null}\n </div>\n <NotificationDetailPanel\n id={openId}\n onClose={() => open(null)}\n inboxActions={{\n markUnread: (id) => void markUnread([id]).then(() => inbox.refetch()),\n archive: (id) => {\n void inbox.archiveNotification(id);\n open(null);\n },\n restore: (id) => void inbox.unarchiveNotification(id),\n }}\n />\n <SendNotificationDialog open={sendOpen} onClose={() => showSend(false)} />\n </WorkspacePage>\n );\n}\n\nfunction InboxEmpty({ tab, searching }: { tab: InboxTab; searching: boolean }) {\n const tr = useTr();\n if (searching) {\n return (\n <EmptyState\n kind=\"no-results\"\n title={tr('notifications.v3.empty.searchTitle', 'No notifications match')}\n description={tr('notifications.v3.empty.searchBody', 'Try other words.')}\n />\n );\n }\n const words: Record<InboxTab, [string, string]> = {\n all: [\n tr('notifications.v3.empty.allTitle', 'You’re all caught up'),\n tr('notifications.v3.empty.allBody', 'New notifications show up here and on the bell.'),\n ],\n unread: [\n tr('notifications.v3.empty.unreadTitle', 'Nothing unread'),\n tr('notifications.v3.empty.allBody', 'New notifications show up here and on the bell.'),\n ],\n action: [\n tr('notifications.v3.empty.actionTitle', 'Nothing waiting for you'),\n tr('notifications.v3.empty.actionBody', 'Approvals and requests show up here.'),\n ],\n archived: [\n tr('notifications.v3.empty.archivedTitle', 'Nothing archived'),\n tr(\n 'notifications.v3.empty.archivedBody',\n 'Archive a notification to keep it out of the way. It stays here.'\n ),\n ],\n };\n const [title, description] = words[tab];\n return (\n <EmptyState\n kind={tab === 'archived' ? 'first-use' : 'all-done'}\n title={title}\n description={description}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmCA,IAAMC,IAA6D;CACjE,KAAK;EAAE,UAAU;EAAO,SAAS;CAAS;CAC1C,QAAQ;EAAE,UAAU;EAAO,SAAS;EAAU,QAAQ;CAAM;CAC5D,QAAQ;EAAE,UAAU;EAAO,SAAS;CAAS;CAC7C,UAAU;EAAE,UAAU;EAAM,SAAS;CAAS;AAChD,GACMC,IAAgB,EAAE,SAAS,SAAS;AAG1C,SAASC,EACP,GACA,GACe;CAKf,OAJIC,MAAQ,SAAeC,EAAM,OAC7BD,MAAQ,cAAoBC,EAAM,YAClCD,MAAQ,WAAiBC,EAAM,SAC/BD,MAAQ,YAAkBC,EAAM,cAC7B;AACT;AAEA,SAAgBC,IAAY;CAC1B,IAAMD,IAAQE,EAAqB,GAC7B,CAACC,KAAUC,EAAgB,GAC3BC,IAASP,EAAaK,EAAO,IAAI,KAAK,GAAGH,CAAK;CAEpD,OADIK,IAAe,kBAACC,GAAD;EAAU,IAAID;EAAQ,SAAA;CAAS,CAAA,IAC3C,kBAACV,GAAD,CAAQ,CAAA;AACjB;AAEA,SAASA,IAAQ;CACf,IAAMa,IAAKC,EAAM,GACXC,IAAWC,EAAY,GACvBC,IAASC,EAAU,GACnBb,IAAQE,EAAqB,GAC7B,EAAE,aAAUY,EAAc,GAC1B,EAAE,kBAAe,WAAWC,MAAuBC,EAAe,GAClE,CAACb,GAAQc,KAAab,EAA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,MAAO,KAAKN,EAAW,CAACQ,CAAE,CAAC,CAAC,CAAC,WAAWV,EAAM,QAAQ,CAAC;IACpE,UAAU,MAAO;KAEf,AADAA,EAAW,oBAAoBU,CAAE,GACjCF,EAAK,IAAI;IACX;IACA,UAAU,MAAO,KAAKR,EAAM,sBAAsBU,CAAE;GACtD;EACD,CAAA;EACD,kBAAC2B,GAAD;GAAwB,MAAM1C;GAAU,eAAegB,EAAS,EAAK;EAAI,CAAA;CAC5D,EAAA,CAAA;AAEnB;AAEA,SAASsB,EAAW,EAAE,QAAK,gBAAoD;CAC7E,IAAMhD,IAAKC,EAAM;CACjB,IAAIoD,GACF,OACE,kBAACC,GAAD;EACE,MAAK;EACL,OAAOtD,EAAG,sCAAsC,wBAAwB;EACxE,aAAaA,EAAG,qCAAqC,kBAAkB;CACxE,CAAA;CAwBL,IAAM,CAACuD,GAAOC,KAAe;EApB3B,KAAK,CACHxD,EAAG,mCAAmC,sBAAsB,GAC5DA,EAAG,kCAAkC,iDAAiD,CACxF;EACA,QAAQ,CACNA,EAAG,sCAAsC,gBAAgB,GACzDA,EAAG,kCAAkC,iDAAiD,CACxF;EACA,QAAQ,CACNA,EAAG,sCAAsC,yBAAyB,GAClEA,EAAG,qCAAqC,sCAAsC,CAChF;EACA,UAAU,CACRA,EAAG,wCAAwC,kBAAkB,GAC7DA,EACE,uCACA,kEACF,CACF;CAE2B,EAAMT;CACnC,OACE,kBAAC+D,GAAD;EACE,MAAM/D,MAAQ,aAAa,cAAc;EAClC;EACM;CACd,CAAA;AAEL"}
|
|
1
|
+
{"version":3,"file":"InboxPage.js","names":["Inbox","TAB_FILTERS","UNREAD_FILTER","oldTabTarget","tab","paths","InboxPage","useNotificationPaths","params","useSearchParams","target","Navigate","Inbox$1","tr","useTr","connection","useNeedsConnection","gate","useConnectionGate","navigate","useNavigate","notify","useNotify","useAdminTools","permissionsLoading","usePermissions","setParams","sendOpen","holdsAdminToolPermission","hasPermission","readInboxTab","openId","inbox","useNotifications","markUnread","useMarkUnread","shown","useMemo","needsAction","search","open","next","id","showSend","show","SEND_PARAM","markAll","unreadIds","isUnread","n","everyOne","tabLabel","WorkspacePage","PageHeader","Button","waitingButton","CheckCheck","tools","tool","PageTabs","INBOX_TABS","StaleHint","Search","Input","event","LoadError","InboxEmpty","InboxRows","notification","NotificationDetailPanel","SendNotificationDialog","searching","EmptyState","title","description"],"sources":["../../src/v2/InboxPage.tsx"],"sourcesContent":["/**\n * Notifications (BOFF-16785, C1; the mockup's `notif`), under fe-libs' `accountPagesV2`: the inbox\n * at the list width, tabs All · Unread · Needs action · Archived (`?tab=`), compact rows grouped by\n * day, \"Mark all as read\" with Undo, the settings under the gear and, for admins, Send a\n * notification (a dialog, `?send=1`), Templates, Topics and the Delivery log in ⋯. A row opens its panel (`?open=<id>`, decision 10). The same\n * queries as the inbox today (`useNotifications`).\n */\nimport { useMemo } from 'react';\nimport { Navigate, useNavigate, useSearchParams } from 'react-router';\nimport { CheckCheck, Search } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport {\n Button,\n EmptyState,\n Input,\n LoadError,\n PageTabs,\n WorkspacePage,\n useNotify,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotifications } from '../hooks';\nimport type { NotificationFilter } from '../types';\nimport { useTr } from '../shared/hooks/useTr';\nimport { useConnectionGate, useNeedsConnection, waitingButton } from './useNeedsConnection';\nimport { useNotificationPaths } from '../navigation-v2/paths';\nimport { holdsAdminToolPermission, useAdminTools } from '../navigation-v2/useAdminTools';\nimport { INBOX_TABS, isUnread, needsAction, readInboxTab, type InboxTab } from './model/inbox';\nimport { InboxRows } from './InboxRows';\nimport { NotificationDetailPanel } from './NotificationDetailPanel';\nimport { useMarkUnread } from './useNotificationDetail';\nimport { SendNotificationDialog } from './send/SendNotificationDialog';\nimport { StaleHint } from './StaleHint';\nimport { SEND_PARAM } from './send/sendModel';\n\n/** What each tab asks the service for: the in-app inbox, archived or not, unread or not. */\nconst TAB_FILTERS: Record<InboxTab, Partial<NotificationFilter>> = {\n all: { archived: false, channel: 'IN_APP' },\n unread: { archived: false, channel: 'IN_APP', isRead: false },\n action: { archived: false, channel: 'IN_APP' },\n archived: { archived: true, channel: 'IN_APP' },\n};\nconst UNREAD_FILTER = { channel: 'IN_APP' };\n\n/** Where today's `?tab=` values still go (the round-1 landing's links). */\nfunction oldTabTarget(\n tab: string | null,\n paths: ReturnType<typeof useNotificationPaths>\n): string | null {\n if (tab === 'send') return paths.send;\n if (tab === 'templates') return paths.templates;\n if (tab === 'topics') return paths.topics;\n if (tab === 'history') return paths.deliveryLog;\n return null;\n}\n\nexport function InboxPage() {\n const paths = useNotificationPaths();\n const [params] = useSearchParams();\n const target = oldTabTarget(params.get('tab'), paths);\n if (target) return <Navigate to={target} replace />;\n return <Inbox />;\n}\n\nfunction Inbox() {\n const tr = useTr();\n const connection = useNeedsConnection();\n const gate = useConnectionGate();\n const navigate = useNavigate();\n const notify = useNotify();\n const paths = useNotificationPaths();\n const { tools } = useAdminTools();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const [params, setParams] = useSearchParams();\n // Send a notification (C2b): a dialog over the inbox, for whoever may send.\n const sendOpen =\n params.get(SEND_PARAM) === '1' &&\n !permissionsLoading &&\n holdsAdminToolPermission('send', hasPermission);\n const tab = readInboxTab(params.get('tab'));\n const openId = params.get('open');\n const inbox = useNotifications({ baseFilter: TAB_FILTERS[tab], unreadFilter: UNREAD_FILTER });\n const markUnread = useMarkUnread();\n const shown = useMemo(\n () => (tab === 'action' ? inbox.notifications.filter(needsAction) : inbox.notifications),\n [inbox.notifications, tab]\n );\n const search = inbox.notificationFilter.search ?? '';\n\n const open = (id: string | null) => {\n const next = new URLSearchParams(params);\n if (id) next.set('open', id);\n else next.delete('open');\n setParams(next);\n };\n\n const showSend = (show: boolean) => {\n const next = new URLSearchParams(params);\n if (show) next.set(SEND_PARAM, '1');\n else next.delete(SEND_PARAM);\n setParams(next);\n };\n\n const markAll = async () => {\n // Undo can only bring back what's loaded: offer it when every unread one is on the page.\n const unreadIds = inbox.allNotifications.filter(isUnread).map((n) => n.id);\n const everyOne = unreadIds.length >= inbox.unreadCount;\n await inbox.markAllAsRead();\n notify({\n title: tr('notifications.v3.markedAll', 'Marked {{count}} as read', {\n count: inbox.unreadCount || unreadIds.length,\n }),\n tone: 'success',\n undo:\n everyOne && unreadIds.length > 0\n ? async () => {\n // Undo writes too: offline under the opt-in it is declined, with the note, and the\n // toast says it couldn't undo (BOFF-18043).\n if (gate()) throw new Error('Undo needs a connection');\n await markUnread(unreadIds);\n await inbox.refetch();\n }\n : undefined,\n });\n };\n\n const tabLabel: Record<InboxTab, string> = {\n all: tr('notifications.v3.tab.all', 'All'),\n unread: tr('notifications.v3.tab.unread', 'Unread'),\n action: tr('notifications.v3.tab.action', 'Needs action'),\n archived: tr('notifications.v3.tab.archived', 'Archived'),\n };\n\n return (\n <WorkspacePage>\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.title', 'Notifications')}\n description={tr(\n 'notifications.v3.purpose',\n 'Everything that needs you, and everything you were told.'\n )}\n primary={\n <Button\n variant=\"outline\"\n {...waitingButton(connection, inbox.unreadCount === 0)}\n onClick={() => void markAll()}\n data-testid=\"inbox-mark-all\"\n >\n <CheckCheck aria-hidden=\"true\" />\n {tr('notifications.v3.markAll', 'Mark all as read')}\n </Button>\n }\n settings={{\n label: tr('notifications.v3.settings', 'Notification settings'),\n onClick: () => navigate(paths.preferences),\n }}\n more={tools.map((tool) =>\n tool.id === 'send'\n ? {\n id: tool.id,\n label: tr('notifications.v3.send.title', 'Send a notification'),\n onSelect: () => showSend(true),\n }\n : { id: tool.id, label: tool.label, onSelect: () => navigate(tool.href) }\n )}\n />\n <PageTabs\n ariaLabel={tr('notifications.v3.title', 'Notifications')}\n activeId={tab}\n tabs={INBOX_TABS.map((id) => ({\n id,\n label: tabLabel[id],\n href: `?tab=${id}`,\n badge: id === 'unread' && inbox.unreadCount > 0 ? inbox.unreadCount : undefined,\n }))}\n />\n <StaleHint loadedAt={inbox.dataUpdatedAt} />\n <div className=\"flex flex-col gap-3\">\n <label className=\"relative block max-w-md\">\n <span className=\"sr-only\">{tr('notifications.v3.search', 'Search notifications')}</span>\n <Search\n className=\"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-text-muted\"\n aria-hidden=\"true\"\n />\n <Input\n type=\"search\"\n className=\"pl-9\"\n value={search}\n placeholder={tr('notifications.v3.search', 'Search notifications')}\n onChange={(event) => inbox.updateFilter({ search: event.target.value })}\n data-testid=\"inbox-search\"\n />\n </label>\n {inbox.error && shown.length === 0 ? (\n <LoadError\n what={tr('notifications.v3.title', 'Notifications')}\n error={inbox.error}\n onRetry={() => void inbox.refetch()}\n />\n ) : !inbox.isLoading && shown.length === 0 ? (\n <InboxEmpty tab={tab} searching={Boolean(search.trim())} />\n ) : (\n <InboxRows\n notifications={shown}\n loading={inbox.isLoading && shown.length === 0}\n onOpen={(id) => {\n open(id);\n const notification = shown.find((n) => n.id === id);\n // Offline under the opt-in, opening still opens, but marking it read waits: the row\n // stays unread rather than sending a write that can't land (BOFF-18043).\n if (notification && isUnread(notification) && !connection.waiting)\n void inbox.markAsRead(id);\n }}\n onMarkRead={(id) => void inbox.markAsRead(id)}\n onMarkUnread={(id) => void markUnread([id]).then(() => inbox.refetch())}\n onArchive={(id) => void inbox.archiveNotification(id)}\n onRestore={(id) => void inbox.unarchiveNotification(id)}\n />\n )}\n {inbox.hasMore ? (\n <div className=\"flex justify-center\">\n <Button\n variant=\"ghost\"\n busy={inbox.isLoadingMore}\n onClick={() => void inbox.loadMore()}\n data-testid=\"inbox-more\"\n >\n {tr('notifications.v3.more', 'Show more')}\n </Button>\n </div>\n ) : null}\n </div>\n <NotificationDetailPanel\n id={openId}\n onClose={() => open(null)}\n inboxActions={{\n markUnread: (id) => void markUnread([id]).then(() => inbox.refetch()),\n archive: (id) => {\n void inbox.archiveNotification(id);\n open(null);\n },\n restore: (id) => void inbox.unarchiveNotification(id),\n }}\n />\n <SendNotificationDialog open={sendOpen} onClose={() => showSend(false)} />\n </WorkspacePage>\n );\n}\n\nfunction InboxEmpty({ tab, searching }: { tab: InboxTab; searching: boolean }) {\n const tr = useTr();\n if (searching) {\n return (\n <EmptyState\n kind=\"no-results\"\n title={tr('notifications.v3.empty.searchTitle', 'No notifications match')}\n description={tr('notifications.v3.empty.searchBody', 'Try other words.')}\n />\n );\n }\n const words: Record<InboxTab, [string, string]> = {\n all: [\n tr('notifications.v3.empty.allTitle', 'You’re all caught up'),\n tr('notifications.v3.empty.allBody', 'New notifications show up here and on the bell.'),\n ],\n unread: [\n tr('notifications.v3.empty.unreadTitle', 'Nothing unread'),\n tr('notifications.v3.empty.allBody', 'New notifications show up here and on the bell.'),\n ],\n action: [\n tr('notifications.v3.empty.actionTitle', 'Nothing waiting for you'),\n tr('notifications.v3.empty.actionBody', 'Approvals and requests show up here.'),\n ],\n archived: [\n tr('notifications.v3.empty.archivedTitle', 'Nothing archived'),\n tr(\n 'notifications.v3.empty.archivedBody',\n 'Archive a notification to keep it out of the way. It stays here.'\n ),\n ],\n };\n const [title, description] = words[tab];\n return (\n <EmptyState\n kind={tab === 'archived' ? 'first-use' : 'all-done'}\n title={title}\n description={description}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoCA,IAAMC,IAA6D;CACjE,KAAK;EAAE,UAAU;EAAO,SAAS;CAAS;CAC1C,QAAQ;EAAE,UAAU;EAAO,SAAS;EAAU,QAAQ;CAAM;CAC5D,QAAQ;EAAE,UAAU;EAAO,SAAS;CAAS;CAC7C,UAAU;EAAE,UAAU;EAAM,SAAS;CAAS;AAChD,GACMC,IAAgB,EAAE,SAAS,SAAS;AAG1C,SAASC,EACP,GACA,GACe;CAKf,OAJIC,MAAQ,SAAeC,EAAM,OAC7BD,MAAQ,cAAoBC,EAAM,YAClCD,MAAQ,WAAiBC,EAAM,SAC/BD,MAA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AkC,iDAAiD,CACxF;EACA,QAAQ,CACNA,EAAG,sCAAsC,gBAAgB,GACzDA,EAAG,kCAAkC,iDAAiD,CACxF;EACA,QAAQ,CACNA,EAAG,sCAAsC,yBAAyB,GAClEA,EAAG,qCAAqC,sCAAsC,CAChF;EACA,UAAU,CACRA,EAAG,wCAAwC,kBAAkB,GAC7DA,EACE,uCACA,kEACF,CACF;CAE2B,EAAMT;CACnC,OACE,kBAACoE,GAAD;EACE,MAAMpE,MAAQ,aAAa,cAAc;EAClC;EACM;CACd,CAAA;AAEL"}
|
package/dist/v2/InboxRows.js
CHANGED
|
@@ -1,92 +1,97 @@
|
|
|
1
1
|
import { useTr as e } from "../shared/hooks/useTr.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { useNeedsConnection as t, waitingItem as n } from "./useNeedsConnection.js";
|
|
3
|
+
import { isUnread as r, needsAction as i } from "./model/inbox.js";
|
|
4
|
+
import { KindIcon as a } from "./KindIcon.js";
|
|
5
|
+
import { groupByDay as o } from "./model/days.js";
|
|
6
|
+
import { Circle as s, CircleDot as c } from "lucide-react";
|
|
7
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
8
|
+
import { ActionMenu as d, IconTile as f, Skeleton as p, useWhenLabels as m } from "@burdenoff/fe-libs/ui";
|
|
8
9
|
// src/v2/InboxRows.tsx
|
|
9
|
-
function
|
|
10
|
-
let
|
|
11
|
-
if (
|
|
10
|
+
function h({ notifications: h, loading: g, onOpen: _, onMarkRead: v, onMarkUnread: y, onArchive: b, onRestore: x }) {
|
|
11
|
+
let S = e(), C = t(), w = m();
|
|
12
|
+
if (g) return /* @__PURE__ */ l("div", {
|
|
12
13
|
className: "flex flex-col gap-2",
|
|
13
14
|
"aria-busy": "true",
|
|
14
15
|
"data-testid": "inbox-loading",
|
|
15
|
-
children: Array.from({ length: 6 }, (e, t) => /* @__PURE__ */
|
|
16
|
+
children: Array.from({ length: 6 }, (e, t) => /* @__PURE__ */ l(p, { className: "h-14 w-full rounded-lg" }, t))
|
|
16
17
|
});
|
|
17
|
-
let
|
|
18
|
-
return /* @__PURE__ */
|
|
18
|
+
let T = o(h, S);
|
|
19
|
+
return /* @__PURE__ */ l("div", {
|
|
19
20
|
className: "flex flex-col gap-4",
|
|
20
21
|
"data-testid": "inbox-rows",
|
|
21
|
-
children:
|
|
22
|
+
children: T.map((e) => /* @__PURE__ */ u("section", {
|
|
22
23
|
"aria-label": e.label,
|
|
23
24
|
className: "flex flex-col gap-1",
|
|
24
|
-
children: [/* @__PURE__ */
|
|
25
|
+
children: [/* @__PURE__ */ l("h2", {
|
|
25
26
|
className: "m-0 px-1 text-xs font-medium text-text-muted",
|
|
26
27
|
children: e.label
|
|
27
|
-
}), /* @__PURE__ */
|
|
28
|
+
}), /* @__PURE__ */ l("ul", {
|
|
28
29
|
className: "m-0 flex list-none flex-col divide-y divide-border-subtle overflow-hidden rounded-lg border border-border-subtle bg-bg-surface p-0",
|
|
29
30
|
children: e.items.map((e) => {
|
|
30
|
-
let
|
|
31
|
-
return /* @__PURE__ */
|
|
31
|
+
let t = r(e);
|
|
32
|
+
return /* @__PURE__ */ u("li", {
|
|
32
33
|
className: "flex items-center gap-3 px-3 py-2.5",
|
|
33
34
|
"data-row-id": e.id,
|
|
34
|
-
"data-unread":
|
|
35
|
+
"data-unread": t || void 0,
|
|
35
36
|
children: [
|
|
36
|
-
/* @__PURE__ */
|
|
37
|
-
className:
|
|
37
|
+
/* @__PURE__ */ l("span", {
|
|
38
|
+
className: t ? "text-accent-primary" : "text-transparent",
|
|
38
39
|
role: "img",
|
|
39
|
-
"aria-label":
|
|
40
|
-
children:
|
|
40
|
+
"aria-label": t ? S("notifications.v3.unread", "Unread") : S("notifications.v3.read", "Read"),
|
|
41
|
+
children: l(t ? c : s, {
|
|
41
42
|
className: "size-3",
|
|
42
43
|
"aria-hidden": "true"
|
|
43
44
|
})
|
|
44
45
|
}),
|
|
45
|
-
/* @__PURE__ */
|
|
46
|
+
/* @__PURE__ */ l(f, {
|
|
46
47
|
size: "sm",
|
|
47
|
-
children: /* @__PURE__ */
|
|
48
|
+
children: /* @__PURE__ */ l(a, { notification: e })
|
|
48
49
|
}),
|
|
49
|
-
/* @__PURE__ */
|
|
50
|
+
/* @__PURE__ */ u("button", {
|
|
50
51
|
type: "button",
|
|
51
52
|
className: "min-w-0 flex-1 cursor-pointer border-0 bg-transparent p-0 text-left",
|
|
52
|
-
onClick: () =>
|
|
53
|
+
onClick: () => _(e.id),
|
|
53
54
|
"data-testid": "inbox-open",
|
|
54
|
-
children: [/* @__PURE__ */
|
|
55
|
-
className: `block truncate text-sm ${
|
|
55
|
+
children: [/* @__PURE__ */ l("span", {
|
|
56
|
+
className: `block truncate text-sm ${t ? "font-semibold text-text-primary" : "text-text-primary"}`,
|
|
56
57
|
children: e.title
|
|
57
|
-
}), /* @__PURE__ */
|
|
58
|
+
}), /* @__PURE__ */ l("span", {
|
|
58
59
|
className: "block truncate text-xs text-text-secondary",
|
|
59
60
|
children: e.body
|
|
60
61
|
})]
|
|
61
62
|
}),
|
|
62
|
-
|
|
63
|
+
i(e) ? /* @__PURE__ */ l("span", {
|
|
63
64
|
className: "hidden text-xs font-medium text-status-warning-text sm:inline",
|
|
64
|
-
children:
|
|
65
|
+
children: S("notifications.v3.needsYou", "Needs you")
|
|
65
66
|
}) : null,
|
|
66
|
-
/* @__PURE__ */
|
|
67
|
+
/* @__PURE__ */ l("time", {
|
|
67
68
|
className: "shrink-0 text-xs text-text-muted",
|
|
68
69
|
dateTime: e.createdAt,
|
|
69
|
-
children:
|
|
70
|
+
children: w.moment(e.createdAt)
|
|
70
71
|
}),
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
+
/* @__PURE__ */ l(d, {
|
|
72
73
|
placement: "row",
|
|
73
|
-
label:
|
|
74
|
-
items: [
|
|
74
|
+
label: S("notifications.v3.actionsFor", "Actions for {{title}}", { title: e.title }),
|
|
75
|
+
items: [t ? {
|
|
75
76
|
id: "read",
|
|
76
|
-
label:
|
|
77
|
-
|
|
77
|
+
label: S("notifications.v3.markRead", "Mark as read"),
|
|
78
|
+
...n(C),
|
|
79
|
+
onSelect: () => v(e.id)
|
|
78
80
|
} : {
|
|
79
81
|
id: "unread",
|
|
80
|
-
label:
|
|
81
|
-
|
|
82
|
+
label: S("notifications.v3.markUnread", "Mark as unread"),
|
|
83
|
+
...n(C),
|
|
84
|
+
onSelect: () => y(e.id)
|
|
82
85
|
}, e.archivedAt ? {
|
|
83
86
|
id: "restore",
|
|
84
|
-
label:
|
|
85
|
-
|
|
87
|
+
label: S("notifications.v3.restore", "Move back to the inbox"),
|
|
88
|
+
...n(C),
|
|
89
|
+
onSelect: () => x(e.id)
|
|
86
90
|
} : {
|
|
87
91
|
id: "archive",
|
|
88
|
-
label:
|
|
89
|
-
|
|
92
|
+
label: S("notifications.v3.archive", "Archive"),
|
|
93
|
+
...n(C),
|
|
94
|
+
onSelect: () => b(e.id)
|
|
90
95
|
}]
|
|
91
96
|
})
|
|
92
97
|
]
|
|
@@ -96,6 +101,6 @@ function p({ notifications: p, loading: m, onOpen: h, onMarkRead: g, onMarkUnrea
|
|
|
96
101
|
}, e.key))
|
|
97
102
|
});
|
|
98
103
|
}
|
|
99
|
-
export {
|
|
104
|
+
export { h as InboxRows };
|
|
100
105
|
|
|
101
106
|
//# sourceMappingURL=InboxRows.js.map
|
package/dist/v2/InboxRows.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InboxRows.js","names":["InboxRows","tr","useTr","when","useWhenLabels","loading","Skeleton","index","groups","groupByDay","notifications","group","unread","isUnread","notification","jsx","CircleDot","Circle","IconTile","KindIcon","onOpen","needsAction","ActionMenu","onMarkRead","onMarkUnread","onRestore","onArchive"],"sources":["../../src/v2/InboxRows.tsx"],"sourcesContent":["/**\n * The inbox's rows (BOFF-16785, C1): grouped by day, each one line of plain words with an icon per\n * kind (never colour alone), an unread dot that says so, the time, and ⋯ (read or unread, archive\n * or restore). The row opens the notification's panel.\n */\nimport { Circle, CircleDot } from 'lucide-react';\nimport { ActionMenu, IconTile, Skeleton, useWhenLabels } from '@burdenoff/fe-libs/ui';\nimport type { Notification } from '../types';\nimport { useTr } from '../shared/hooks/useTr';\nimport { isUnread, needsAction } from './model/inbox';\nimport { KindIcon } from './KindIcon';\nimport { groupByDay } from './model/days';\n\nexport function InboxRows({\n notifications,\n loading,\n onOpen,\n onMarkRead,\n onMarkUnread,\n onArchive,\n onRestore,\n}: {\n notifications: readonly Notification[];\n loading: boolean;\n onOpen: (id: string) => void;\n onMarkRead: (id: string) => void;\n onMarkUnread: (id: string) => void;\n onArchive: (id: string) => void;\n onRestore: (id: string) => void;\n}) {\n const tr = useTr();\n const when = useWhenLabels();\n if (loading) {\n return (\n <div className=\"flex flex-col gap-2\" aria-busy=\"true\" data-testid=\"inbox-loading\">\n {Array.from({ length: 6 }, (_, index) => (\n <Skeleton key={index} className=\"h-14 w-full rounded-lg\" />\n ))}\n </div>\n );\n }\n const groups = groupByDay(notifications, tr);\n return (\n <div className=\"flex flex-col gap-4\" data-testid=\"inbox-rows\">\n {groups.map((group) => (\n <section key={group.key} aria-label={group.label} className=\"flex flex-col gap-1\">\n <h2 className=\"m-0 px-1 text-xs font-medium text-text-muted\">{group.label}</h2>\n <ul className=\"m-0 flex list-none flex-col divide-y divide-border-subtle overflow-hidden rounded-lg border border-border-subtle bg-bg-surface p-0\">\n {group.items.map((notification) => {\n const unread = isUnread(notification);\n return (\n <li\n key={notification.id}\n className=\"flex items-center gap-3 px-3 py-2.5\"\n data-row-id={notification.id}\n data-unread={unread || undefined}\n >\n <span\n className={unread ? 'text-accent-primary' : 'text-transparent'}\n role=\"img\"\n aria-label={\n unread\n ? tr('notifications.v3.unread', 'Unread')\n : tr('notifications.v3.read', 'Read')\n }\n >\n {unread ? (\n <CircleDot className=\"size-3\" aria-hidden=\"true\" />\n ) : (\n <Circle className=\"size-3\" aria-hidden=\"true\" />\n )}\n </span>\n <IconTile size=\"sm\">\n <KindIcon notification={notification} />\n </IconTile>\n <button\n type=\"button\"\n className=\"min-w-0 flex-1 cursor-pointer border-0 bg-transparent p-0 text-left\"\n onClick={() => onOpen(notification.id)}\n data-testid=\"inbox-open\"\n >\n <span\n className={`block truncate text-sm ${unread ? 'font-semibold text-text-primary' : 'text-text-primary'}`}\n >\n {notification.title}\n </span>\n <span className=\"block truncate text-xs text-text-secondary\">\n {notification.body}\n </span>\n </button>\n {needsAction(notification) ? (\n <span className=\"hidden text-xs font-medium text-status-warning-text sm:inline\">\n {tr('notifications.v3.needsYou', 'Needs you')}\n </span>\n ) : null}\n <time\n className=\"shrink-0 text-xs text-text-muted\"\n dateTime={notification.createdAt}\n >\n {when.moment(notification.createdAt)}\n </time>\n <ActionMenu\n placement=\"row\"\n label={tr('notifications.v3.actionsFor', 'Actions for {{title}}', {\n title: notification.title,\n })}\n items={[\n unread\n ? {\n id: 'read',\n label: tr('notifications.v3.markRead', 'Mark as read'),\n onSelect: () => onMarkRead(notification.id),\n }\n : {\n id: 'unread',\n label: tr('notifications.v3.markUnread', 'Mark as unread'),\n onSelect: () => onMarkUnread(notification.id),\n },\n notification.archivedAt\n ? {\n id: 'restore',\n label: tr('notifications.v3.restore', 'Move back to the inbox'),\n onSelect: () => onRestore(notification.id),\n }\n : {\n id: 'archive',\n label: tr('notifications.v3.archive', 'Archive'),\n onSelect: () => onArchive(notification.id),\n },\n ]}\n />\n </li>\n );\n })}\n </ul>\n </section>\n ))}\n </div>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"InboxRows.js","names":["InboxRows","tr","useTr","connection","useNeedsConnection","when","useWhenLabels","loading","Skeleton","index","groups","groupByDay","notifications","group","unread","isUnread","notification","jsx","CircleDot","Circle","IconTile","KindIcon","onOpen","needsAction","ActionMenu","waitingItem","onMarkRead","onMarkUnread","onRestore","onArchive"],"sources":["../../src/v2/InboxRows.tsx"],"sourcesContent":["/**\n * The inbox's rows (BOFF-16785, C1): grouped by day, each one line of plain words with an icon per\n * kind (never colour alone), an unread dot that says so, the time, and ⋯ (read or unread, archive\n * or restore). The row opens the notification's panel.\n */\nimport { Circle, CircleDot } from 'lucide-react';\nimport { ActionMenu, IconTile, Skeleton, useWhenLabels } from '@burdenoff/fe-libs/ui';\nimport type { Notification } from '../types';\nimport { useTr } from '../shared/hooks/useTr';\nimport { useNeedsConnection, waitingItem } from './useNeedsConnection';\nimport { isUnread, needsAction } from './model/inbox';\nimport { KindIcon } from './KindIcon';\nimport { groupByDay } from './model/days';\n\nexport function InboxRows({\n notifications,\n loading,\n onOpen,\n onMarkRead,\n onMarkUnread,\n onArchive,\n onRestore,\n}: {\n notifications: readonly Notification[];\n loading: boolean;\n onOpen: (id: string) => void;\n onMarkRead: (id: string) => void;\n onMarkUnread: (id: string) => void;\n onArchive: (id: string) => void;\n onRestore: (id: string) => void;\n}) {\n const tr = useTr();\n const connection = useNeedsConnection();\n const when = useWhenLabels();\n if (loading) {\n return (\n <div className=\"flex flex-col gap-2\" aria-busy=\"true\" data-testid=\"inbox-loading\">\n {Array.from({ length: 6 }, (_, index) => (\n <Skeleton key={index} className=\"h-14 w-full rounded-lg\" />\n ))}\n </div>\n );\n }\n const groups = groupByDay(notifications, tr);\n return (\n <div className=\"flex flex-col gap-4\" data-testid=\"inbox-rows\">\n {groups.map((group) => (\n <section key={group.key} aria-label={group.label} className=\"flex flex-col gap-1\">\n <h2 className=\"m-0 px-1 text-xs font-medium text-text-muted\">{group.label}</h2>\n <ul className=\"m-0 flex list-none flex-col divide-y divide-border-subtle overflow-hidden rounded-lg border border-border-subtle bg-bg-surface p-0\">\n {group.items.map((notification) => {\n const unread = isUnread(notification);\n return (\n <li\n key={notification.id}\n className=\"flex items-center gap-3 px-3 py-2.5\"\n data-row-id={notification.id}\n data-unread={unread || undefined}\n >\n <span\n className={unread ? 'text-accent-primary' : 'text-transparent'}\n role=\"img\"\n aria-label={\n unread\n ? tr('notifications.v3.unread', 'Unread')\n : tr('notifications.v3.read', 'Read')\n }\n >\n {unread ? (\n <CircleDot className=\"size-3\" aria-hidden=\"true\" />\n ) : (\n <Circle className=\"size-3\" aria-hidden=\"true\" />\n )}\n </span>\n <IconTile size=\"sm\">\n <KindIcon notification={notification} />\n </IconTile>\n <button\n type=\"button\"\n className=\"min-w-0 flex-1 cursor-pointer border-0 bg-transparent p-0 text-left\"\n onClick={() => onOpen(notification.id)}\n data-testid=\"inbox-open\"\n >\n <span\n className={`block truncate text-sm ${unread ? 'font-semibold text-text-primary' : 'text-text-primary'}`}\n >\n {notification.title}\n </span>\n <span className=\"block truncate text-xs text-text-secondary\">\n {notification.body}\n </span>\n </button>\n {needsAction(notification) ? (\n <span className=\"hidden text-xs font-medium text-status-warning-text sm:inline\">\n {tr('notifications.v3.needsYou', 'Needs you')}\n </span>\n ) : null}\n <time\n className=\"shrink-0 text-xs text-text-muted\"\n dateTime={notification.createdAt}\n >\n {when.moment(notification.createdAt)}\n </time>\n <ActionMenu\n placement=\"row\"\n label={tr('notifications.v3.actionsFor', 'Actions for {{title}}', {\n title: notification.title,\n })}\n items={[\n unread\n ? {\n id: 'read',\n label: tr('notifications.v3.markRead', 'Mark as read'),\n ...waitingItem(connection),\n onSelect: () => onMarkRead(notification.id),\n }\n : {\n id: 'unread',\n label: tr('notifications.v3.markUnread', 'Mark as unread'),\n ...waitingItem(connection),\n onSelect: () => onMarkUnread(notification.id),\n },\n notification.archivedAt\n ? {\n id: 'restore',\n label: tr('notifications.v3.restore', 'Move back to the inbox'),\n ...waitingItem(connection),\n onSelect: () => onRestore(notification.id),\n }\n : {\n id: 'archive',\n label: tr('notifications.v3.archive', 'Archive'),\n ...waitingItem(connection),\n onSelect: () => onArchive(notification.id),\n },\n ]}\n />\n </li>\n );\n })}\n </ul>\n </section>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAcA,SAAgBA,EAAU,EACxB,kBACA,YACA,WACA,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