@burdenoff/microfe-notification 2026.1125.1 → 2026.1129.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.
Files changed (161) hide show
  1. package/dist/NotificationRoutes.d.ts +10 -0
  2. package/dist/NotificationRoutes.js +76 -71
  3. package/dist/NotificationRoutes.js.map +1 -1
  4. package/dist/components/NotificationPanel.js +0 -1
  5. package/dist/components/NotificationPanel.js.map +1 -1
  6. package/dist/generated/global-operations.d.ts +58 -3
  7. package/dist/generated/global-operations.js +31 -23
  8. package/dist/generated/global-operations.js.map +1 -1
  9. package/dist/generated/global-types.d.ts +10933 -581
  10. package/dist/graphql/global-client.js +34 -34
  11. package/dist/hooks/useNotificationAnalytics.d.ts +1 -1
  12. package/dist/hooks/useNotificationAnalytics.js.map +1 -1
  13. package/dist/hooks/useNotifications.d.ts +7 -0
  14. package/dist/hooks/useNotifications.js +1 -1
  15. package/dist/hooks/useNotifications.js.map +1 -1
  16. package/dist/index.js +9 -11
  17. package/dist/navigation-v2/NotificationArchivedV2.js +7 -8
  18. package/dist/navigation-v2/NotificationArchivedV2.js.map +1 -1
  19. package/dist/navigation-v2/NotificationInboxV2.js +8 -9
  20. package/dist/navigation-v2/NotificationInboxV2.js.map +1 -1
  21. package/dist/navigation-v2/NotificationSettingsV2.js +0 -1
  22. package/dist/navigation-v2/NotificationSettingsV2.js.map +1 -1
  23. package/dist/pages/NotificationCenterPage.js +5 -6
  24. package/dist/pages/NotificationCenterPage.js.map +1 -1
  25. package/dist/pages/NotificationHistoryAdminPage.js +9 -10
  26. package/dist/pages/NotificationHistoryAdminPage.js.map +1 -1
  27. package/dist/pages/NotificationHistoryPage.js +5 -6
  28. package/dist/pages/NotificationHistoryPage.js.map +1 -1
  29. package/dist/pages/NotificationPreferencesPage.js +0 -1
  30. package/dist/pages/NotificationPreferencesPage.js.map +1 -1
  31. package/dist/pages/NotificationTopicsPage.js +0 -1
  32. package/dist/pages/NotificationTopicsPage.js.map +1 -1
  33. package/dist/translations/en.d.ts +80 -0
  34. package/dist/types/index.d.ts +2 -1
  35. package/dist/v2/ArchivedRedirect.d.ts +1 -0
  36. package/dist/v2/ArchivedRedirect.js +14 -0
  37. package/dist/v2/ArchivedRedirect.js.map +1 -0
  38. package/dist/v2/InboxPage.d.ts +1 -0
  39. package/dist/v2/InboxPage.js +191 -0
  40. package/dist/v2/InboxPage.js.map +1 -0
  41. package/dist/v2/InboxRows.d.ts +10 -0
  42. package/dist/v2/InboxRows.js +101 -0
  43. package/dist/v2/InboxRows.js.map +1 -0
  44. package/dist/v2/KindIcon.d.ts +4 -0
  45. package/dist/v2/KindIcon.js +33 -0
  46. package/dist/v2/KindIcon.js.map +1 -0
  47. package/dist/v2/NotificationDetailPanel.d.ts +7 -0
  48. package/dist/v2/NotificationDetailPanel.js +200 -0
  49. package/dist/v2/NotificationDetailPanel.js.map +1 -0
  50. package/dist/v2/PreferencesPage.d.ts +1 -0
  51. package/dist/v2/PreferencesPage.js +139 -0
  52. package/dist/v2/PreferencesPage.js.map +1 -0
  53. package/dist/v2/__tests__/routeShapes.d.ts +13 -0
  54. package/dist/v2/model/days.d.ts +9 -0
  55. package/dist/v2/model/days.js +25 -0
  56. package/dist/v2/model/days.js.map +1 -0
  57. package/dist/v2/model/events.d.ts +17 -0
  58. package/dist/v2/model/events.js +72 -0
  59. package/dist/v2/model/events.js.map +1 -0
  60. package/dist/v2/model/icons.d.ts +6 -0
  61. package/dist/v2/model/icons.js +19 -0
  62. package/dist/v2/model/icons.js.map +1 -0
  63. package/dist/v2/model/inbox.d.ts +15 -0
  64. package/dist/v2/model/inbox.js +22 -0
  65. package/dist/v2/model/inbox.js.map +1 -0
  66. package/dist/v2/model/thing.d.ts +16 -0
  67. package/dist/v2/model/thing.js +41 -0
  68. package/dist/v2/model/thing.js.map +1 -0
  69. package/dist/v2/model/tr.d.ts +2 -0
  70. package/dist/v2/useNotificationDetail.d.ts +19 -0
  71. package/dist/v2/useNotificationDetail.js +65 -0
  72. package/dist/v2/useNotificationDetail.js.map +1 -0
  73. package/package.json +5 -2
  74. package/dist/components/index.js +0 -4
  75. package/dist/hooks/index.js +0 -8
  76. package/dist/node_modules/@apollo/client/errors/CombinedGraphQLErrors.js +0 -23
  77. package/dist/node_modules/@apollo/client/errors/CombinedGraphQLErrors.js.map +0 -1
  78. package/dist/node_modules/@apollo/client/errors/utils.js +0 -15
  79. package/dist/node_modules/@apollo/client/errors/utils.js.map +0 -1
  80. package/dist/node_modules/@apollo/client/link/core/ApolloLink.js +0 -51
  81. package/dist/node_modules/@apollo/client/link/core/ApolloLink.js.map +0 -1
  82. package/dist/node_modules/@apollo/client/link/subscriptions/index.js +0 -40
  83. package/dist/node_modules/@apollo/client/link/subscriptions/index.js.map +0 -1
  84. package/dist/node_modules/@apollo/client/link/utils/createOperation.js +0 -33
  85. package/dist/node_modules/@apollo/client/link/utils/createOperation.js.map +0 -1
  86. package/dist/node_modules/@apollo/client/utilities/caching/sizes.js +0 -5
  87. package/dist/node_modules/@apollo/client/utilities/caching/sizes.js.map +0 -1
  88. package/dist/node_modules/@apollo/client/utilities/graphql/print.js +0 -15
  89. package/dist/node_modules/@apollo/client/utilities/graphql/print.js.map +0 -1
  90. package/dist/node_modules/@apollo/client/utilities/internal/caches.js +0 -18
  91. package/dist/node_modules/@apollo/client/utilities/internal/caches.js.map +0 -1
  92. package/dist/node_modules/@apollo/client/utilities/internal/checkDocument.js +0 -20
  93. package/dist/node_modules/@apollo/client/utilities/internal/checkDocument.js.map +0 -1
  94. package/dist/node_modules/@apollo/client/utilities/internal/getMainDefinition.js +0 -16
  95. package/dist/node_modules/@apollo/client/utilities/internal/getMainDefinition.js.map +0 -1
  96. package/dist/node_modules/@apollo/client/utilities/internal/getMemoryInternals.js +0 -8
  97. package/dist/node_modules/@apollo/client/utilities/internal/getMemoryInternals.js.map +0 -1
  98. package/dist/node_modules/@apollo/client/utilities/internal/getOperationDefinition.js +0 -8
  99. package/dist/node_modules/@apollo/client/utilities/internal/getOperationDefinition.js.map +0 -1
  100. package/dist/node_modules/@apollo/client/utilities/internal/getOperationName.js +0 -7
  101. package/dist/node_modules/@apollo/client/utilities/internal/getOperationName.js.map +0 -1
  102. package/dist/node_modules/@apollo/client/utilities/internal/globals/global.js +0 -8
  103. package/dist/node_modules/@apollo/client/utilities/internal/globals/global.js.map +0 -1
  104. package/dist/node_modules/@apollo/client/utilities/internal/globals/maybe.js +0 -9
  105. package/dist/node_modules/@apollo/client/utilities/internal/globals/maybe.js.map +0 -1
  106. package/dist/node_modules/@apollo/client/utilities/internal/isNonNullObject.js +0 -7
  107. package/dist/node_modules/@apollo/client/utilities/internal/isNonNullObject.js.map +0 -1
  108. package/dist/node_modules/@apollo/client/utilities/internal/makeUniqueId.js +0 -9
  109. package/dist/node_modules/@apollo/client/utilities/internal/makeUniqueId.js.map +0 -1
  110. package/dist/node_modules/@apollo/client/utilities/internal/memoize.js +0 -22
  111. package/dist/node_modules/@apollo/client/utilities/internal/memoize.js.map +0 -1
  112. package/dist/node_modules/@apollo/client/utilities/internal/stringifyForDisplay.js +0 -9
  113. package/dist/node_modules/@apollo/client/utilities/internal/stringifyForDisplay.js.map +0 -1
  114. package/dist/node_modules/@apollo/client/utilities/invariant/index.js +0 -56
  115. package/dist/node_modules/@apollo/client/utilities/invariant/index.js.map +0 -1
  116. package/dist/node_modules/@apollo/client/version.js +0 -5
  117. package/dist/node_modules/@apollo/client/version.js.map +0 -1
  118. package/dist/node_modules/@wry/caches/lib/weak.js +0 -66
  119. package/dist/node_modules/@wry/caches/lib/weak.js.map +0 -1
  120. package/dist/node_modules/@wry/trie/lib/index.js +0 -52
  121. package/dist/node_modules/@wry/trie/lib/index.js.map +0 -1
  122. package/dist/node_modules/graphql-ws/dist/client.js +0 -279
  123. package/dist/node_modules/graphql-ws/dist/client.js.map +0 -1
  124. package/dist/node_modules/graphql-ws/dist/common-CGW11Fyb.js +0 -61
  125. package/dist/node_modules/graphql-ws/dist/common-CGW11Fyb.js.map +0 -1
  126. package/dist/node_modules/rxjs/dist/esm5/internal/NotificationFactories.js +0 -20
  127. package/dist/node_modules/rxjs/dist/esm5/internal/NotificationFactories.js.map +0 -1
  128. package/dist/node_modules/rxjs/dist/esm5/internal/Observable.js +0 -77
  129. package/dist/node_modules/rxjs/dist/esm5/internal/Observable.js.map +0 -1
  130. package/dist/node_modules/rxjs/dist/esm5/internal/Subscriber.js +0 -116
  131. package/dist/node_modules/rxjs/dist/esm5/internal/Subscriber.js.map +0 -1
  132. package/dist/node_modules/rxjs/dist/esm5/internal/Subscription.js +0 -96
  133. package/dist/node_modules/rxjs/dist/esm5/internal/Subscription.js.map +0 -1
  134. package/dist/node_modules/rxjs/dist/esm5/internal/config.js +0 -11
  135. package/dist/node_modules/rxjs/dist/esm5/internal/config.js.map +0 -1
  136. package/dist/node_modules/rxjs/dist/esm5/internal/observable/empty.js +0 -8
  137. package/dist/node_modules/rxjs/dist/esm5/internal/observable/empty.js.map +0 -1
  138. package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js +0 -15
  139. package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js.map +0 -1
  140. package/dist/node_modules/rxjs/dist/esm5/internal/symbol/observable.js +0 -7
  141. package/dist/node_modules/rxjs/dist/esm5/internal/symbol/observable.js.map +0 -1
  142. package/dist/node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js +0 -12
  143. package/dist/node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js.map +0 -1
  144. package/dist/node_modules/rxjs/dist/esm5/internal/util/arrRemove.js +0 -10
  145. package/dist/node_modules/rxjs/dist/esm5/internal/util/arrRemove.js.map +0 -1
  146. package/dist/node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js +0 -10
  147. package/dist/node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js.map +0 -1
  148. package/dist/node_modules/rxjs/dist/esm5/internal/util/errorContext.js +0 -21
  149. package/dist/node_modules/rxjs/dist/esm5/internal/util/errorContext.js.map +0 -1
  150. package/dist/node_modules/rxjs/dist/esm5/internal/util/identity.js +0 -7
  151. package/dist/node_modules/rxjs/dist/esm5/internal/util/identity.js.map +0 -1
  152. package/dist/node_modules/rxjs/dist/esm5/internal/util/isFunction.js +0 -7
  153. package/dist/node_modules/rxjs/dist/esm5/internal/util/isFunction.js.map +0 -1
  154. package/dist/node_modules/rxjs/dist/esm5/internal/util/noop.js +0 -5
  155. package/dist/node_modules/rxjs/dist/esm5/internal/util/noop.js.map +0 -1
  156. package/dist/node_modules/rxjs/dist/esm5/internal/util/pipe.js +0 -12
  157. package/dist/node_modules/rxjs/dist/esm5/internal/util/pipe.js.map +0 -1
  158. package/dist/node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js +0 -13
  159. package/dist/node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js.map +0 -1
  160. package/dist/node_modules/tslib/tslib.es6.js +0 -51
  161. package/dist/node_modules/tslib/tslib.es6.js.map +0 -1
@@ -0,0 +1,200 @@
1
+ import { useTr as e } from "../shared/hooks/useTr.js";
2
+ import { navigateInApp as t } from "../utils/inAppNavigation.js";
3
+ import { mapBackendToMfeNotification as n } from "../hooks/useNotifications.js";
4
+ import { needsAction as r } from "./model/inbox.js";
5
+ import { KindIcon as i } from "./KindIcon.js";
6
+ import { notificationThing as a, thingFacts as o } from "./model/thing.js";
7
+ import { timeline as s } from "./model/events.js";
8
+ import { useNotificationDetail as c } from "./useNotificationDetail.js";
9
+ import { ArrowUpRight as l, CheckCircle2 as u, Clock as d, Workflow as f, XCircle as p } from "lucide-react";
10
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
11
+ import { Button as g, DetailPanel as _, IconTile as v, LoadError as y, Skeleton as b, StatusChip as x, useWhenLabels as S } from "@burdenoff/fe-libs/ui";
12
+ // src/v2/NotificationDetailPanel.tsx
13
+ function C(e) {
14
+ t(e) || window.open(e, "_blank", "noopener,noreferrer");
15
+ }
16
+ function w({ id: t, onClose: r, onMarkUnread: a, onArchive: o, onRestore: s }) {
17
+ let l = e(), { state: u, retry: d } = c(t), f = u.status === "ready" ? u.notification : null, p = f ? n(f) : null;
18
+ return /* @__PURE__ */ m(_, {
19
+ open: !!t,
20
+ onOpenChange: (e) => e ? void 0 : r(),
21
+ title: p?.title ?? l("notifications.v3.panel.loading", "Notification"),
22
+ sub: p ? /* @__PURE__ */ m(T, { notification: p }) : void 0,
23
+ tile: p ? /* @__PURE__ */ m(v, {
24
+ size: "md",
25
+ children: /* @__PURE__ */ m(i, { notification: p })
26
+ }) : void 0,
27
+ closeLabel: l("notifications.v3.panel.close", "Close"),
28
+ "data-testid": "notification-panel",
29
+ footer: p ? /* @__PURE__ */ h("div", {
30
+ className: "flex w-full flex-wrap gap-2",
31
+ children: [/* @__PURE__ */ m(g, {
32
+ variant: "outline",
33
+ onClick: () => a(p.id),
34
+ children: l("notifications.v3.markUnread", "Mark as unread")
35
+ }), p.archivedAt ? /* @__PURE__ */ m(g, {
36
+ variant: "ghost",
37
+ onClick: () => s(p.id),
38
+ children: l("notifications.v3.restore", "Move back to the inbox")
39
+ }) : /* @__PURE__ */ m(g, {
40
+ variant: "ghost",
41
+ onClick: () => o(p.id),
42
+ children: l("notifications.v3.archive", "Archive")
43
+ })]
44
+ }) : void 0,
45
+ children: u.status === "loading" ? /* @__PURE__ */ h("div", {
46
+ className: "flex flex-col gap-3",
47
+ "aria-busy": "true",
48
+ children: [
49
+ /* @__PURE__ */ m(b, { className: "h-4 w-3/4" }),
50
+ /* @__PURE__ */ m(b, { className: "h-4 w-2/3" }),
51
+ /* @__PURE__ */ m(b, { className: "h-24 w-full" })
52
+ ]
53
+ }) : u.status === "failed" ? /* @__PURE__ */ m(y, {
54
+ what: l("notifications.v3.panel.what", "This notification"),
55
+ error: u.error,
56
+ onRetry: d
57
+ }) : u.status === "missing" || !f || !p ? /* @__PURE__ */ m("p", {
58
+ className: "m-0 text-sm text-text-secondary",
59
+ children: l("notifications.v3.panel.missing", "This notification isn’t available any more. It may have been deleted.")
60
+ }) : /* @__PURE__ */ m(E, {
61
+ notification: p,
62
+ data: f
63
+ })
64
+ });
65
+ }
66
+ function T({ notification: t }) {
67
+ let n = e(), i = S();
68
+ return /* @__PURE__ */ h("span", {
69
+ className: "flex flex-wrap items-center gap-2",
70
+ children: [/* @__PURE__ */ m("time", {
71
+ dateTime: t.createdAt,
72
+ children: i.moment(t.createdAt)
73
+ }), r(t) ? /* @__PURE__ */ m(x, {
74
+ status: "warn",
75
+ children: n("notifications.v3.needsYou", "Needs you")
76
+ }) : null]
77
+ });
78
+ }
79
+ function E({ notification: t, data: n }) {
80
+ let r = e(), i = a(n.metadata), o = t.actions;
81
+ return /* @__PURE__ */ h("div", {
82
+ className: "flex flex-col gap-5",
83
+ children: [
84
+ /* @__PURE__ */ m("p", {
85
+ className: "m-0 text-sm whitespace-pre-wrap text-text-primary",
86
+ "data-testid": "panel-message",
87
+ children: t.body
88
+ }),
89
+ i ? /* @__PURE__ */ m(D, {
90
+ thing: i,
91
+ actionUrl: t.actionUrl
92
+ }) : null,
93
+ o.length > 0 || t.actionUrl && !i ? /* @__PURE__ */ h("div", {
94
+ className: "flex flex-wrap gap-2",
95
+ "data-testid": "panel-actions",
96
+ children: [o.map((e, t) => /* @__PURE__ */ m(g, {
97
+ variant: t === 0 ? "default" : "outline",
98
+ onClick: () => C(e.url),
99
+ children: e.label
100
+ }, e.id)), o.length === 0 && t.actionUrl && !i ? /* @__PURE__ */ h(g, {
101
+ onClick: () => C(t.actionUrl ?? ""),
102
+ children: [/* @__PURE__ */ m(l, { "aria-hidden": "true" }), r("notifications.v3.panel.open", "Open where it happened")]
103
+ }) : null]
104
+ }) : null,
105
+ /* @__PURE__ */ m(A, { events: n.events })
106
+ ]
107
+ });
108
+ }
109
+ function D({ thing: t, actionUrl: n }) {
110
+ let r = e(), i = S(), a = o(t, r);
111
+ return /* @__PURE__ */ h("section", {
112
+ className: "flex flex-col gap-2 rounded-lg border border-border-subtle bg-bg-sunken p-3",
113
+ "aria-label": r("notifications.v3.thing.label", "What it’s about"),
114
+ "data-testid": "panel-thing",
115
+ children: [
116
+ /* @__PURE__ */ h("div", {
117
+ className: "flex items-center gap-2",
118
+ children: [/* @__PURE__ */ m(f, {
119
+ className: "size-4 text-text-secondary",
120
+ "aria-hidden": "true"
121
+ }), /* @__PURE__ */ m("span", {
122
+ className: "text-sm font-semibold text-text-primary",
123
+ children: t.workflowName
124
+ })]
125
+ }),
126
+ a.length > 0 ? /* @__PURE__ */ m("dl", {
127
+ className: "m-0 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm",
128
+ children: a.map((e) => /* @__PURE__ */ h("div", {
129
+ className: "contents",
130
+ children: [/* @__PURE__ */ m("dt", {
131
+ className: "text-text-secondary",
132
+ children: e.label
133
+ }), /* @__PURE__ */ m("dd", {
134
+ className: "m-0 text-text-primary",
135
+ children: e.value
136
+ })]
137
+ }, e.id))
138
+ }) : null,
139
+ t.firstSeenAt ? /* @__PURE__ */ m("p", {
140
+ className: "m-0 text-xs text-text-muted",
141
+ children: r("notifications.v3.thing.firstSeen", "First seen {{when}}", { when: i.moment(t.firstSeenAt) })
142
+ }) : null,
143
+ n ? /* @__PURE__ */ m("div", { children: /* @__PURE__ */ m(g, {
144
+ size: "sm",
145
+ variant: "outline",
146
+ onClick: () => C(n),
147
+ children: r("notifications.v3.thing.openRun", "Open the run")
148
+ }) }) : null
149
+ ]
150
+ });
151
+ }
152
+ var O = {
153
+ ok: u,
154
+ bad: p,
155
+ waiting: d,
156
+ neutral: d
157
+ }, k = {
158
+ ok: "text-status-success-text",
159
+ bad: "text-status-error-text",
160
+ waiting: "text-status-warning-text",
161
+ neutral: "text-text-muted"
162
+ };
163
+ function A({ events: t }) {
164
+ let n = e(), r = S(), i = s(t, n);
165
+ return i.length === 0 ? null : /* @__PURE__ */ h("section", {
166
+ className: "flex flex-col gap-2",
167
+ "aria-label": n("notifications.v3.timeline", "What happened"),
168
+ children: [/* @__PURE__ */ m("h3", {
169
+ className: "m-0 text-xs font-medium text-text-muted",
170
+ children: n("notifications.v3.timeline", "What happened")
171
+ }), /* @__PURE__ */ m("ol", {
172
+ className: "m-0 flex list-none flex-col gap-2 p-0",
173
+ "data-testid": "panel-timeline",
174
+ children: i.map((e) => {
175
+ let t = O[e.tone];
176
+ return /* @__PURE__ */ h("li", {
177
+ className: "flex items-center gap-2 text-sm",
178
+ children: [
179
+ /* @__PURE__ */ m(t, {
180
+ className: `size-4 ${k[e.tone]}`,
181
+ "aria-hidden": "true"
182
+ }),
183
+ /* @__PURE__ */ m("span", {
184
+ className: "flex-1 text-text-primary",
185
+ children: e.words
186
+ }),
187
+ /* @__PURE__ */ m("time", {
188
+ className: "text-xs text-text-muted",
189
+ dateTime: e.at,
190
+ children: r.moment(e.at)
191
+ })
192
+ ]
193
+ }, e.id);
194
+ })
195
+ })]
196
+ });
197
+ }
198
+ export { w as NotificationDetailPanel };
199
+
200
+ //# sourceMappingURL=NotificationDetailPanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationDetailPanel.js","names":["follow","navigateInApp","url","NotificationDetailPanel","tr","useTr","useNotificationDetail","id","ready","state","notification","mapBackendToMfeNotification","DetailPanel","next","onClose","PanelSub","IconTile","KindIcon","Button","onMarkUnread","onRestore","onArchive","Skeleton","LoadError","retry","PanelBody","when","useWhenLabels","needsAction","StatusChip","thing","notificationThing","data","actions","ThingBlock","index","action","ArrowUpRight","Timeline","facts","thingFacts","Workflow","fact","actionUrl","EVENT_ICON","CheckCircle2","XCircle","Clock","EVENT_TEXT","items","timeline","events","Icon","event"],"sources":["../../src/v2/NotificationDetailPanel.tsx"],"sourcesContent":["/**\n * A notification's panel (BOFF-16785, C1; decision 10, BE3): the message, \"the thing\" it is about\n * when the sender said (a workflow, its step, the attempt, how many runs it touched, since when),\n * its actions, and its timeline from the delivery events. Mark as unread and Archive at the foot.\n */\nimport { ArrowUpRight, CheckCircle2, Clock, Workflow, XCircle } from 'lucide-react';\nimport {\n Button,\n DetailPanel,\n IconTile,\n LoadError,\n Skeleton,\n StatusChip,\n useWhenLabels,\n} from '@burdenoff/fe-libs/ui';\nimport type { Notification } from '../types';\nimport { useTr } from '../shared/hooks/useTr';\nimport { navigateInApp } from '../utils/inAppNavigation';\nimport { mapBackendToMfeNotification } from '../hooks/useNotifications';\nimport { needsAction } from './model/inbox';\nimport { KindIcon } from './KindIcon';\nimport { notificationThing, thingFacts } from './model/thing';\nimport { timeline, type EventTone } from './model/events';\nimport { useNotificationDetail, type NotificationDetailData } from './useNotificationDetail';\n\n/** Open an action's address: inside the app when it is one of ours, else in a new tab. */\nfunction follow(url: string) {\n if (!navigateInApp(url)) window.open(url, '_blank', 'noopener,noreferrer');\n}\n\nexport function NotificationDetailPanel({\n id,\n onClose,\n onMarkUnread,\n onArchive,\n onRestore,\n}: {\n id: string | null;\n onClose: () => void;\n onMarkUnread: (id: string) => void;\n onArchive: (id: string) => void;\n onRestore: (id: string) => void;\n}) {\n const tr = useTr();\n const { state, retry } = useNotificationDetail(id);\n const ready = state.status === 'ready' ? state.notification : null;\n const notification = ready ? mapBackendToMfeNotification(ready) : null;\n\n return (\n <DetailPanel\n open={Boolean(id)}\n onOpenChange={(next) => (next ? undefined : onClose())}\n title={notification?.title ?? tr('notifications.v3.panel.loading', 'Notification')}\n sub={notification ? <PanelSub notification={notification} /> : undefined}\n tile={\n notification ? (\n <IconTile size=\"md\">\n <KindIcon notification={notification} />\n </IconTile>\n ) : undefined\n }\n closeLabel={tr('notifications.v3.panel.close', 'Close')}\n data-testid=\"notification-panel\"\n footer={\n notification ? (\n <div className=\"flex w-full flex-wrap gap-2\">\n <Button variant=\"outline\" onClick={() => onMarkUnread(notification.id)}>\n {tr('notifications.v3.markUnread', 'Mark as unread')}\n </Button>\n {notification.archivedAt ? (\n <Button variant=\"ghost\" onClick={() => onRestore(notification.id)}>\n {tr('notifications.v3.restore', 'Move back to the inbox')}\n </Button>\n ) : (\n <Button variant=\"ghost\" onClick={() => onArchive(notification.id)}>\n {tr('notifications.v3.archive', 'Archive')}\n </Button>\n )}\n </div>\n ) : undefined\n }\n >\n {state.status === 'loading' ? (\n <div className=\"flex flex-col gap-3\" aria-busy=\"true\">\n <Skeleton className=\"h-4 w-3/4\" />\n <Skeleton className=\"h-4 w-2/3\" />\n <Skeleton className=\"h-24 w-full\" />\n </div>\n ) : state.status === 'failed' ? (\n <LoadError\n what={tr('notifications.v3.panel.what', 'This notification')}\n error={state.error}\n onRetry={retry}\n />\n ) : state.status === 'missing' || !ready || !notification ? (\n <p className=\"m-0 text-sm text-text-secondary\">\n {tr(\n 'notifications.v3.panel.missing',\n 'This notification isn’t available any more. It may have been deleted.'\n )}\n </p>\n ) : (\n <PanelBody notification={notification} data={ready} />\n )}\n </DetailPanel>\n );\n}\n\nfunction PanelSub({ notification }: { notification: Notification }) {\n const tr = useTr();\n const when = useWhenLabels();\n return (\n <span className=\"flex flex-wrap items-center gap-2\">\n <time dateTime={notification.createdAt}>{when.moment(notification.createdAt)}</time>\n {needsAction(notification) ? (\n <StatusChip status=\"warn\">{tr('notifications.v3.needsYou', 'Needs you')}</StatusChip>\n ) : null}\n </span>\n );\n}\n\nfunction PanelBody({\n notification,\n data,\n}: {\n notification: Notification;\n data: NotificationDetailData;\n}) {\n const tr = useTr();\n const thing = notificationThing(data.metadata);\n const actions = notification.actions;\n return (\n <div className=\"flex flex-col gap-5\">\n <p className=\"m-0 text-sm whitespace-pre-wrap text-text-primary\" data-testid=\"panel-message\">\n {notification.body}\n </p>\n {thing ? <ThingBlock thing={thing} actionUrl={notification.actionUrl} /> : null}\n {actions.length > 0 || (notification.actionUrl && !thing) ? (\n <div className=\"flex flex-wrap gap-2\" data-testid=\"panel-actions\">\n {actions.map((action, index) => (\n <Button\n key={action.id}\n variant={index === 0 ? 'default' : 'outline'}\n onClick={() => follow(action.url)}\n >\n {action.label}\n </Button>\n ))}\n {/* \"Open the run\" in the thing's block already goes there. */}\n {actions.length === 0 && notification.actionUrl && !thing ? (\n <Button onClick={() => follow(notification.actionUrl ?? '')}>\n <ArrowUpRight aria-hidden=\"true\" />\n {tr('notifications.v3.panel.open', 'Open where it happened')}\n </Button>\n ) : null}\n </div>\n ) : null}\n <Timeline events={data.events} />\n </div>\n );\n}\n\nfunction ThingBlock({\n thing,\n actionUrl,\n}: {\n thing: NonNullable<ReturnType<typeof notificationThing>>;\n actionUrl?: string;\n}) {\n const tr = useTr();\n const when = useWhenLabels();\n const facts = thingFacts(thing, tr);\n return (\n <section\n className=\"flex flex-col gap-2 rounded-lg border border-border-subtle bg-bg-sunken p-3\"\n aria-label={tr('notifications.v3.thing.label', 'What it’s about')}\n data-testid=\"panel-thing\"\n >\n <div className=\"flex items-center gap-2\">\n <Workflow className=\"size-4 text-text-secondary\" aria-hidden=\"true\" />\n <span className=\"text-sm font-semibold text-text-primary\">{thing.workflowName}</span>\n </div>\n {facts.length > 0 ? (\n <dl className=\"m-0 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm\">\n {facts.map((fact) => (\n <div key={fact.id} className=\"contents\">\n <dt className=\"text-text-secondary\">{fact.label}</dt>\n <dd className=\"m-0 text-text-primary\">{fact.value}</dd>\n </div>\n ))}\n </dl>\n ) : null}\n {thing.firstSeenAt ? (\n <p className=\"m-0 text-xs text-text-muted\">\n {tr('notifications.v3.thing.firstSeen', 'First seen {{when}}', {\n when: when.moment(thing.firstSeenAt),\n })}\n </p>\n ) : null}\n {actionUrl ? (\n <div>\n <Button size=\"sm\" variant=\"outline\" onClick={() => follow(actionUrl)}>\n {tr('notifications.v3.thing.openRun', 'Open the run')}\n </Button>\n </div>\n ) : null}\n </section>\n );\n}\n\nconst EVENT_ICON: Record<EventTone, typeof Clock> = {\n ok: CheckCircle2,\n bad: XCircle,\n waiting: Clock,\n neutral: Clock,\n};\nconst EVENT_TEXT: Record<EventTone, string> = {\n ok: 'text-status-success-text',\n bad: 'text-status-error-text',\n waiting: 'text-status-warning-text',\n neutral: 'text-text-muted',\n};\n\nfunction Timeline({ events }: { events: NotificationDetailData['events'] }) {\n const tr = useTr();\n const when = useWhenLabels();\n const items = timeline(events, tr);\n if (items.length === 0) return null;\n return (\n <section\n className=\"flex flex-col gap-2\"\n aria-label={tr('notifications.v3.timeline', 'What happened')}\n >\n <h3 className=\"m-0 text-xs font-medium text-text-muted\">\n {tr('notifications.v3.timeline', 'What happened')}\n </h3>\n <ol className=\"m-0 flex list-none flex-col gap-2 p-0\" data-testid=\"panel-timeline\">\n {items.map((event) => {\n const Icon = EVENT_ICON[event.tone];\n return (\n <li key={event.id} className=\"flex items-center gap-2 text-sm\">\n <Icon className={`size-4 ${EVENT_TEXT[event.tone]}`} aria-hidden=\"true\" />\n <span className=\"flex-1 text-text-primary\">{event.words}</span>\n <time className=\"text-xs text-text-muted\" dateTime={event.at}>\n {when.moment(event.at)}\n </time>\n </li>\n );\n })}\n </ol>\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,SAASA,EAAO,GAAa;CAC3B,AAAKC,EAAcC,CAAG,KAAG,OAAO,KAAKA,GAAK,UAAU,qBAAqB;AAC3E;AAEA,SAAgBC,EAAwB,EACtC,OACA,YACA,iBACA,cACA,gBAOC;CACD,IAAMC,IAAKC,EAAM,GACX,EAAE,UAAO,aAAUC,EAAsBC,CAAE,GAC3CC,IAAQC,EAAM,WAAW,UAAUA,EAAM,eAAe,MACxDC,IAAeF,IAAQG,EAA4BH,CAAK,IAAI;CAElE,OACE,kBAACI,GAAD;EACE,MAAM,EAAQL;EACd,eAAe,MAAUM,IAAO,KAAA,IAAYC,EAAQ;EACpD,OAAOJ,GAAc,SAASN,EAAG,kCAAkC,cAAc;EACjF,KAAKM,IAAe,kBAACK,GAAD,EAAwB,gBAAe,CAAA,IAAI,KAAA;EAC/D,MACEL,IACE,kBAACM,GAAD;GAAU,MAAK;GACb,UAAA,kBAACC,GAAD,EAAwB,gBAAe,CAAA;EAC/B,CAAA,IACR,KAAA;EAEN,YAAYb,EAAG,gCAAgC,OAA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MAAD;GAAI,WAAU;GAAwC,eAAY;GAC/D,UAAA6C,EAAM,KAAK,MAAU;IACpB,IAAMG,IAAOR,EAAWS,EAAM;IAC9B,OACE,kBAAC,MAAD;KAAmB,WAAU;KAA7B,UAAA;MACE,kBAACD,GAAD;OAAM,WAAW,UAAUJ,EAAWK,EAAM;OAAS,eAAY;MAAQ,CAAA;MACzE,kBAAC,QAAD;OAAM,WAAU;OAA4B,UAAAA,EAAM;MAAY,CAAA;MAC9D,kBAAC,QAAD;OAAM,WAAU;OAA0B,UAAUA,EAAM;OACvD,UAAA3B,EAAK,OAAO2B,EAAM,EAAE;MACjB,CAAA;KACJ;IANK,GAAAA,EAAM,EAMX;GAER,CAAC;EACC,CAAA,CACG;;AAEb"}
@@ -0,0 +1 @@
1
+ export declare function PreferencesPage(): import('react').JSX.Element;
@@ -0,0 +1,139 @@
1
+ import { useNotificationTopics as e } from "../hooks/useNotificationTopics.js";
2
+ import { preferenceKey as t, usePreferenceToggles as n } from "../hooks/usePreferenceToggles.js";
3
+ import { useTr as r } from "../shared/hooks/useTr.js";
4
+ import { useNotificationPaths as i } from "../navigation-v2/paths.js";
5
+ import { EVERYDAY_CHANNELS as a, MORE_CHANNELS as o, TYPES as s } from "../navigation-v2/settingsOptions.js";
6
+ import { useMemo as c, useState as l } from "react";
7
+ import { Bell as u, BellOff as d, Check as f, Inbox as p, Megaphone as m, Search as h, X as g } from "lucide-react";
8
+ import { useNavigate as _ } from "react-router";
9
+ import { jsx as v, jsxs as y } from "react/jsx-runtime";
10
+ import { PageHeader as b, PushOptInToggle as x } from "@burdenoff/fe-libs/chrome";
11
+ import { Button as S, Input as C, SettingRow as w, SettingsSection as T, Switch as E } from "@burdenoff/fe-libs/ui";
12
+ // src/v2/PreferencesPage.tsx
13
+ function D() {
14
+ let f = r(), g = _(), w = i(), E = n(), { topics: D, isLoading: k, isForbidden: A } = e({
15
+ type: "MARKETING",
16
+ isActive: !0
17
+ }), [j, M] = l(""), N = c(() => {
18
+ let e = j.trim().toLowerCase();
19
+ return e ? D.filter((t) => t.name.toLowerCase().includes(e) || t.description?.toLowerCase().includes(e)) : D;
20
+ }, [j, D]), P = E.preferencesByKey.get(t({ scope: "GLOBAL" }))?.enabled === !1, F = (e, n, r = {}) => /* @__PURE__ */ v(O, {
21
+ target: e,
22
+ label: n,
23
+ options: r,
24
+ toggles: E
25
+ }, t(e));
26
+ return /* @__PURE__ */ y("div", {
27
+ "data-account-pages-v2": "notification-settings",
28
+ className: "flex w-full min-w-0 flex-col",
29
+ children: [/* @__PURE__ */ v(b, {
30
+ variant: "compact",
31
+ title: f("notifications.v3.title", "Notifications"),
32
+ description: f("notifications.v3.prefs.purpose", "Choose what reaches you, and where."),
33
+ secondary: /* @__PURE__ */ y(S, {
34
+ variant: "outline",
35
+ onClick: () => g(w.inbox),
36
+ children: [/* @__PURE__ */ v(p, { "aria-hidden": "true" }), f("notifications.v3.prefs.openInbox", "Open the inbox")]
37
+ })
38
+ }), /* @__PURE__ */ y("div", {
39
+ className: "flex flex-col gap-4",
40
+ children: [
41
+ /* @__PURE__ */ v(T, {
42
+ icon: d,
43
+ title: f("notifications.v3.prefs.pauseTitle", "Pause everything"),
44
+ children: F({ scope: "GLOBAL" }, f("notifications.v3.prefs.pause", "Pause notifications"), {
45
+ description: P ? f("notifications.v3.prefs.pausedNow", "Paused. Nothing reaches you until you turn this off.") : f("notifications.v3.prefs.pauseHelp", "Stop every notification, everywhere, until you turn this off."),
46
+ inverted: !0
47
+ })
48
+ }),
49
+ /* @__PURE__ */ y(T, {
50
+ icon: u,
51
+ title: f("notifications.v3.prefs.whereTitle", "Where you hear from us"),
52
+ children: [[...a, ...o].map((e) => F({
53
+ scope: "CHANNEL",
54
+ channel: e.value
55
+ }, f(e.labelKey, e.label))), /* @__PURE__ */ v("div", {
56
+ className: "px-1 py-2",
57
+ children: /* @__PURE__ */ v(x, {})
58
+ })]
59
+ }),
60
+ /* @__PURE__ */ v(T, {
61
+ icon: p,
62
+ title: f("notifications.v3.prefs.whatTitle", "What you hear about"),
63
+ children: s.map((e) => F({
64
+ scope: "TYPE",
65
+ type: e.value
66
+ }, f(e.labelKey, e.label)))
67
+ }),
68
+ !k && !A && D.length > 0 ? /* @__PURE__ */ y(T, {
69
+ icon: m,
70
+ title: f("notifications.v3.prefs.topicsTitle", "Updates you can opt into"),
71
+ children: [D.length > 5 ? /* @__PURE__ */ y("label", {
72
+ className: "relative block px-1 py-2",
73
+ children: [
74
+ /* @__PURE__ */ v("span", {
75
+ className: "sr-only",
76
+ children: f("notifications.searchTopics", "Search topics...")
77
+ }),
78
+ /* @__PURE__ */ v(h, {
79
+ className: "pointer-events-none absolute top-1/2 left-4 size-4 -translate-y-1/2 text-text-muted",
80
+ "aria-hidden": "true"
81
+ }),
82
+ /* @__PURE__ */ v(C, {
83
+ type: "search",
84
+ className: "pl-9",
85
+ value: j,
86
+ placeholder: f("notifications.searchTopics", "Search topics..."),
87
+ onChange: (e) => M(e.target.value)
88
+ })
89
+ ]
90
+ }) : null, N.length === 0 ? /* @__PURE__ */ v("p", {
91
+ className: "m-0 px-1 py-2 text-sm text-text-secondary",
92
+ children: f("notifications.noTopicsFound", "No topics match your search")
93
+ }) : N.map((e) => F({
94
+ scope: "TOPIC",
95
+ topicId: e.id
96
+ }, e.name, { description: e.description || void 0 }))]
97
+ }) : null
98
+ ]
99
+ })]
100
+ });
101
+ }
102
+ function O({ target: e, label: n, options: i, toggles: a }) {
103
+ let o = r(), s = t(e), c = a.preferencesByKey.get(s), l = c?.enabled ?? !0, u = a.saveFeedback?.key === s ? a.saveFeedback : null, d = i.description;
104
+ if (u) {
105
+ let e = u.type === "success" ? f : g;
106
+ d = /* @__PURE__ */ y("span", {
107
+ className: `inline-flex items-center gap-1 ${u.type === "success" ? "text-status-success-text" : "text-status-error-text"}`,
108
+ role: u.type === "error" ? "alert" : "status",
109
+ children: [/* @__PURE__ */ v(e, {
110
+ className: "size-3.5",
111
+ "aria-hidden": "true"
112
+ }), u.message]
113
+ });
114
+ }
115
+ return /* @__PURE__ */ v(w, {
116
+ label: n,
117
+ description: d,
118
+ control: (t) => /* @__PURE__ */ y("span", {
119
+ className: "flex items-center gap-2",
120
+ children: [c ? /* @__PURE__ */ v(S, {
121
+ size: "sm",
122
+ variant: "ghost",
123
+ disabled: a.savingKey === s,
124
+ onClick: () => void a.resetPreference(s),
125
+ children: o("notifications.v3.prefs.useDefault", "Use default")
126
+ }) : null, /* @__PURE__ */ v(E, {
127
+ checked: i.inverted ? !l : l,
128
+ disabled: a.savingKey === s,
129
+ onCheckedChange: () => void a.togglePreference(e),
130
+ "aria-labelledby": t.labelId,
131
+ "aria-describedby": t.descriptionId,
132
+ "data-testid": `pref-${s}`
133
+ })]
134
+ })
135
+ });
136
+ }
137
+ export { D as PreferencesPage };
138
+
139
+ //# sourceMappingURL=PreferencesPage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreferencesPage.js","names":["PreferencesPage","tr","useTr","navigate","useNavigate","paths","useNotificationPaths","toggles","usePreferenceToggles","topicsLoading","useNotificationTopics","search","setSearch","useState","shownTopics","useMemo","query","topics","topic","paused","preferenceKey","row","PreferenceRow","target","PageHeader","Button","Inbox","SettingsSection","BellOff","Bell","EVERYDAY_CHANNELS","MORE_CHANNELS","channel","PushOptInToggle","TYPES","type","isForbidden","Megaphone","Search","Input","event","key","existing","enabled","feedback","description","options","Icon","Check","X","SettingRow","Switch","ids"],"sources":["../../src/v2/PreferencesPage.tsx"],"sourcesContent":["/**\n * Notification settings (BOFF-16785, C1; the mockup's `nprefs`), under fe-libs' `accountPagesV2`:\n * pause everything, where you hear from us, what you hear about, and the updates you can opt into,\n * as settings sections. Every switch makes the same calls as today's settings\n * (`usePreferenceToggles`); a choice you changed can go back to the default.\n */\nimport { useMemo, useState, type ReactNode } from 'react';\nimport { useNavigate } from 'react-router';\nimport { Bell, BellOff, Check, Inbox, Megaphone, Search, X } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport { PushOptInToggle } from '@burdenoff/fe-libs/chrome';\nimport { Button, Input, SettingRow, SettingsSection, Switch } from '@burdenoff/fe-libs/ui';\nimport { useNotificationTopics } from '../hooks';\nimport {\n preferenceKey,\n usePreferenceToggles,\n type PreferenceTarget,\n} from '../hooks/usePreferenceToggles';\nimport { useTr } from '../shared/hooks/useTr';\nimport { useNotificationPaths } from '../navigation-v2/paths';\nimport { EVERYDAY_CHANNELS, MORE_CHANNELS, TYPES } from '../navigation-v2/settingsOptions';\n\nexport function PreferencesPage() {\n const tr = useTr();\n const navigate = useNavigate();\n const paths = useNotificationPaths();\n const toggles = usePreferenceToggles();\n const {\n topics,\n isLoading: topicsLoading,\n isForbidden,\n } = useNotificationTopics({\n type: 'MARKETING',\n isActive: true,\n });\n const [search, setSearch] = useState('');\n const shownTopics = useMemo(() => {\n const query = search.trim().toLowerCase();\n if (!query) return topics;\n return topics.filter(\n (topic) =>\n topic.name.toLowerCase().includes(query) || topic.description?.toLowerCase().includes(query)\n );\n }, [search, topics]);\n const paused =\n toggles.preferencesByKey.get(preferenceKey({ scope: 'GLOBAL' }))?.enabled === false;\n\n const row = (target: PreferenceTarget, label: string, options: RowOptions = {}) => (\n <PreferenceRow\n key={preferenceKey(target)}\n target={target}\n label={label}\n options={options}\n toggles={toggles}\n />\n );\n\n return (\n <div data-account-pages-v2=\"notification-settings\" className=\"flex w-full min-w-0 flex-col\">\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.title', 'Notifications')}\n description={tr('notifications.v3.prefs.purpose', 'Choose what reaches you, and where.')}\n secondary={\n <Button variant=\"outline\" onClick={() => navigate(paths.inbox)}>\n <Inbox aria-hidden=\"true\" />\n {tr('notifications.v3.prefs.openInbox', 'Open the inbox')}\n </Button>\n }\n />\n <div className=\"flex flex-col gap-4\">\n <SettingsSection\n icon={BellOff}\n title={tr('notifications.v3.prefs.pauseTitle', 'Pause everything')}\n >\n {row({ scope: 'GLOBAL' }, tr('notifications.v3.prefs.pause', 'Pause notifications'), {\n description: paused\n ? tr(\n 'notifications.v3.prefs.pausedNow',\n 'Paused. Nothing reaches you until you turn this off.'\n )\n : tr(\n 'notifications.v3.prefs.pauseHelp',\n 'Stop every notification, everywhere, until you turn this off.'\n ),\n inverted: true,\n })}\n </SettingsSection>\n <SettingsSection\n icon={Bell}\n title={tr('notifications.v3.prefs.whereTitle', 'Where you hear from us')}\n >\n {[...EVERYDAY_CHANNELS, ...MORE_CHANNELS].map((channel) =>\n row({ scope: 'CHANNEL', channel: channel.value }, tr(channel.labelKey, channel.label))\n )}\n <div className=\"px-1 py-2\">\n <PushOptInToggle />\n </div>\n </SettingsSection>\n <SettingsSection\n icon={Inbox}\n title={tr('notifications.v3.prefs.whatTitle', 'What you hear about')}\n >\n {TYPES.map((type) =>\n row({ scope: 'TYPE', type: type.value }, tr(type.labelKey, type.label))\n )}\n </SettingsSection>\n {!topicsLoading && !isForbidden && topics.length > 0 ? (\n <SettingsSection\n icon={Megaphone}\n title={tr('notifications.v3.prefs.topicsTitle', 'Updates you can opt into')}\n >\n {topics.length > 5 ? (\n <label className=\"relative block px-1 py-2\">\n <span className=\"sr-only\">\n {tr('notifications.searchTopics', 'Search topics...')}\n </span>\n <Search\n className=\"pointer-events-none absolute top-1/2 left-4 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.searchTopics', 'Search topics...')}\n onChange={(event) => setSearch(event.target.value)}\n />\n </label>\n ) : null}\n {shownTopics.length === 0 ? (\n <p className=\"m-0 px-1 py-2 text-sm text-text-secondary\">\n {tr('notifications.noTopicsFound', 'No topics match your search')}\n </p>\n ) : (\n shownTopics.map((topic) =>\n row({ scope: 'TOPIC', topicId: topic.id }, topic.name, {\n description: topic.description || undefined,\n })\n )\n )}\n </SettingsSection>\n ) : null}\n </div>\n </div>\n );\n}\n\ninterface RowOptions {\n description?: string;\n /** \"Pause\" reads the other way round: on means delivery is off. */\n inverted?: boolean;\n}\n\nfunction PreferenceRow({\n target,\n label,\n options,\n toggles,\n}: {\n target: PreferenceTarget;\n label: string;\n options: RowOptions;\n toggles: ReturnType<typeof usePreferenceToggles>;\n}) {\n const tr = useTr();\n const key = preferenceKey(target);\n const existing = toggles.preferencesByKey.get(key);\n const enabled = existing?.enabled ?? true;\n const feedback = toggles.saveFeedback?.key === key ? toggles.saveFeedback : null;\n let description: ReactNode = options.description;\n if (feedback) {\n const Icon = feedback.type === 'success' ? Check : X;\n description = (\n <span\n className={`inline-flex items-center gap-1 ${feedback.type === 'success' ? 'text-status-success-text' : 'text-status-error-text'}`}\n role={feedback.type === 'error' ? 'alert' : 'status'}\n >\n <Icon className=\"size-3.5\" aria-hidden=\"true\" />\n {feedback.message}\n </span>\n );\n }\n return (\n <SettingRow\n label={label}\n description={description}\n control={(ids) => (\n <span className=\"flex items-center gap-2\">\n {existing ? (\n <Button\n size=\"sm\"\n variant=\"ghost\"\n disabled={toggles.savingKey === key}\n onClick={() => void toggles.resetPreference(key)}\n >\n {tr('notifications.v3.prefs.useDefault', 'Use default')}\n </Button>\n ) : null}\n <Switch\n checked={options.inverted ? !enabled : enabled}\n disabled={toggles.savingKey === key}\n onCheckedChange={() => void toggles.togglePreference(target)}\n aria-labelledby={ids.labelId}\n aria-describedby={ids.descriptionId}\n data-testid={`pref-${key}`}\n />\n </span>\n )}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;AAsBA,SAAgBA,IAAkB;CAChC,IAAMC,IAAKC,EAAM,GACXC,IAAWC,EAAY,GACvBC,IAAQC,EAAqB,GAC7BC,IAAUC,EAAqB,GAC/B,EACJ,WACA,WAAWC,GACX,mBACEC,EAAsB;EACxB,MAAM;EACN,UAAU;CACZ,CAAC,GACK,CAACC,GAAQC,KAAaC,EAAS,EAAE,GACjCC,IAAcC,QAAc;EAChC,IAAMC,IAAQL,EAAO,KAAK,CAAC,CAAC,YAAY;EAExC,OADKK,IACEC,EAAO,QACX,MACCC,EAAM,KA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C/BE,IAAWrC,EAAQ,cAAc,QAAQkC,IAAMlC,EAAQ,eAAe,MACxEsC,IAAyBC,EAAQ;CACrC,IAAIF,GAAU;EACZ,IAAMG,IAAOH,EAAS,SAAS,YAAYI,IAAQC;EACnD,IACE,kBAAC,QAAD;GACE,WAAW,kCAAkCL,EAAS,SAAS,YAAY,6BAA6B;GACxG,MAAMA,EAAS,SAAS,UAAU,UAAU;GAF9C,UAAA,CAIE,kBAACG,GAAD;IAAM,WAAU;IAAW,eAAY;GAAQ,CAAA,GAC9CH,EAAS,OACN;;CAEV;CACA,OACE,kBAACM,GAAD;EACS;EACM;EACb,UAAU,MACR,kBAAC,QAAD;GAAM,WAAU;GAAhB,UAAA,CACGR,IACC,kBAACjB,GAAD;IACE,MAAK;IACL,SAAQ;IACR,UAAUlB,EAAQ,cAAckC;IAChC,eAAe,KAAKlC,EAAQ,gBAAgBkC,CAAG;IAE9C,UAAAxC,EAAG,qCAAqC,aAAa;GAChD,CAAA,IACN,MACJ,kBAACkD,GAAD;IACE,SAASL,EAAQ,WAAW,CAACH,IAAUA;IACvC,UAAUpC,EAAQ,cAAckC;IAChC,uBAAuB,KAAKlC,EAAQ,iBAAiBgB,CAAM;IAC3D,mBAAiB6B,EAAI;IACrB,oBAAkBA,EAAI;IACtB,eAAa,QAAQX;GACtB,CAAA,CACG;;CAET,CAAA;AAEL"}
@@ -0,0 +1,13 @@
1
+ import { ReactNode } from 'react';
2
+ export interface RouteEntry {
3
+ path: string;
4
+ element: ReactNode;
5
+ }
6
+ /** An element's shape: its component, its plain props and its children, all the way down. */
7
+ export declare function shape(node: ReactNode): unknown;
8
+ /** The routes for the classic or the Navigation v2 tree, with the opt-in on, off, or absent. */
9
+ export declare function routesWith(optIn: boolean | undefined): RouteEntry[];
10
+ export declare function tableWith(optIn: boolean | undefined): {
11
+ path: string;
12
+ element: unknown;
13
+ }[];
@@ -0,0 +1,9 @@
1
+ import { Tr } from './tr';
2
+ export interface DayGroup<T> {
3
+ key: string;
4
+ label: string;
5
+ items: T[];
6
+ }
7
+ export declare function groupByDay<T extends {
8
+ createdAt: string;
9
+ }>(items: readonly T[], tr: Tr, now?: Date, locale?: string): DayGroup<T>[];
@@ -0,0 +1,25 @@
1
+ // src/v2/model/days.ts
2
+ function e(e) {
3
+ return `${e.getFullYear()}-${e.getMonth() + 1}-${e.getDate()}`;
4
+ }
5
+ function t(t, n, r = /* @__PURE__ */ new Date(), i) {
6
+ let a = e(r), o = e(new Date(r.getFullYear(), r.getMonth(), r.getDate() - 1)), s = new Intl.DateTimeFormat(i, {
7
+ day: "numeric",
8
+ month: "long",
9
+ year: "numeric"
10
+ }), c = /* @__PURE__ */ new Map(), l = [...t].sort((e, t) => Date.parse(t.createdAt) - Date.parse(e.createdAt));
11
+ for (let t of l) {
12
+ let r = new Date(t.createdAt);
13
+ if (Number.isNaN(r.getTime())) continue;
14
+ let i = e(r), l = i === a ? n("notifications.v3.today", "Today") : i === o ? n("notifications.v3.yesterday", "Yesterday") : s.format(r), u = c.get(i) ?? {
15
+ key: i,
16
+ label: l,
17
+ items: []
18
+ };
19
+ u.items.push(t), c.set(i, u);
20
+ }
21
+ return [...c.values()];
22
+ }
23
+ export { t as groupByDay };
24
+
25
+ //# sourceMappingURL=days.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"days.js","names":["dayKey","date","groupByDay","today","now","yesterday","format","locale","groups","sorted","items","b","a","item","key","label","tr","group"],"sources":["../../../src/v2/model/days.ts"],"sourcesContent":["/**\n * The inbox's day groups (BOFF-16785, C1): Today, Yesterday, then the date, newest first.\n */\nimport type { Tr } from './tr';\n\nexport interface DayGroup<T> {\n key: string;\n label: string;\n items: T[];\n}\n\nfunction dayKey(date: Date): string {\n return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;\n}\n\nexport function groupByDay<T extends { createdAt: string }>(\n items: readonly T[],\n tr: Tr,\n now: Date = new Date(),\n locale?: string\n): DayGroup<T>[] {\n const today = dayKey(now);\n const yesterday = dayKey(new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1));\n const format = new Intl.DateTimeFormat(locale, {\n day: 'numeric',\n month: 'long',\n year: 'numeric',\n });\n const groups = new Map<string, DayGroup<T>>();\n const sorted = [...items].sort((a, b) => Date.parse(b.createdAt) - Date.parse(a.createdAt));\n for (const item of sorted) {\n const date = new Date(item.createdAt);\n if (Number.isNaN(date.getTime())) continue;\n const key = dayKey(date);\n const label =\n key === today\n ? tr('notifications.v3.today', 'Today')\n : key === yesterday\n ? tr('notifications.v3.yesterday', 'Yesterday')\n : format.format(date);\n const group = groups.get(key) ?? { key, label, items: [] };\n group.items.push(item);\n groups.set(key, group);\n }\n return [...groups.values()];\n}\n"],"mappings":";AAWA,SAASA,EAAO,GAAoB;CAClC,OAAO,GAAGC,EAAK,YAAY,EAAE,GAAGA,EAAK,SAAS,IAAI,EAAE,GAAGA,EAAK,QAAQ;AACtE;AAEA,SAAgBC,EACd,GACA,GACA,oBAAY,IAAI,KAAK,GACrB,GACe;CACf,IAAMC,IAAQH,EAAOI,CAAG,GAClBC,IAAYL,EAAO,IAAI,KAAKI,EAAI,YAAY,GAAGA,EAAI,SAAS,GAAGA,EAAI,QAAQ,IAAI,CAAC,CAAC,GACjFE,IAAS,IAAI,KAAK,eAAeC,GAAQ;EAC7C,KAAK;EACL,OAAO;EACP,MAAM;CACR,CAAC,GACKC,oBAAS,IAAI,IAAyB,GACtCC,IAAS,CAAC,GAAGC,CAAK,CAAC,CAAC,MAAM,GAAG,MAAM,KAAK,MAAMC,EAAE,SAAS,IAAI,KAAK,MAAMC,EAAE,SAAS,CAAC;CAC1F,KAAK,IAAMC,KAAQJ,GAAQ;EACzB,IAAMR,IAAO,IAAI,KAAKY,EAAK,SAAS;EACpC,IAAI,OAAO,MAAMZ,EAAK,QAAQ,CAAC,GAAG;EAClC,IAAMa,IAAMd,EAAOC,CAAI,GACjBc,IACJD,MAAQX,IACJa,EAAG,0BAA0B,OAAO,IACpCF,MAAQT,IACNW,EAAG,8BAA8B,WAAW,IAC5CV,EAAO,OAAOL,CAAI,GACpBgB,IAAQT,EAAO,IAAIM,CAAG,KAAK;GAAE;GAAK;GAAO,OAAO,CAAC;EAAE;EAEzD,AADAG,EAAM,MAAM,KAAKJ,CAAI,GACrBL,EAAO,IAAIM,GAAKG,CAAK;CACvB;CACA,OAAO,CAAC,GAAGT,EAAO,OAAO,CAAC;AAC5B"}
@@ -0,0 +1,17 @@
1
+ import { Tr } from './tr';
2
+ export type EventTone = 'ok' | 'bad' | 'waiting' | 'neutral';
3
+ export interface TimelineEvent {
4
+ id: string;
5
+ at: string;
6
+ words: string;
7
+ tone: EventTone;
8
+ }
9
+ export declare function eventWords(eventType: string, tr: Tr): {
10
+ words: string;
11
+ tone: EventTone;
12
+ };
13
+ export declare function timeline(events: readonly {
14
+ id: string;
15
+ eventType: string;
16
+ timestamp: string;
17
+ }[], tr: Tr): TimelineEvent[];
@@ -0,0 +1,72 @@
1
+ // src/v2/model/events.ts
2
+ function e(e, t) {
3
+ switch (e) {
4
+ case "CREATED": return {
5
+ words: t("notifications.v3.event.created", "Created"),
6
+ tone: "neutral"
7
+ };
8
+ case "SCHEDULED": return {
9
+ words: t("notifications.v3.event.scheduled", "Scheduled"),
10
+ tone: "waiting"
11
+ };
12
+ case "TRIGGERED":
13
+ case "SENT": return {
14
+ words: t("notifications.v3.event.sent", "Sent"),
15
+ tone: "neutral"
16
+ };
17
+ case "DELIVERED": return {
18
+ words: t("notifications.v3.event.delivered", "Delivered"),
19
+ tone: "ok"
20
+ };
21
+ case "OPENED": return {
22
+ words: t("notifications.v3.event.opened", "Opened"),
23
+ tone: "ok"
24
+ };
25
+ case "CLICKED": return {
26
+ words: t("notifications.v3.event.clicked", "Its action was used"),
27
+ tone: "ok"
28
+ };
29
+ case "RETRY": return {
30
+ words: t("notifications.v3.event.retry", "Tried again"),
31
+ tone: "waiting"
32
+ };
33
+ case "FAILED": return {
34
+ words: t("notifications.v3.event.failed", "Couldn’t be delivered"),
35
+ tone: "bad"
36
+ };
37
+ case "BOUNCED": return {
38
+ words: t("notifications.v3.event.bounced", "The address didn’t accept it"),
39
+ tone: "bad"
40
+ };
41
+ case "COMPLAINED": return {
42
+ words: t("notifications.v3.event.complained", "Marked as spam"),
43
+ tone: "bad"
44
+ };
45
+ case "UNSUBSCRIBED": return {
46
+ words: t("notifications.v3.event.unsubscribed", "Unsubscribed"),
47
+ tone: "neutral"
48
+ };
49
+ case "EXPIRED": return {
50
+ words: t("notifications.v3.event.expired", "Expired"),
51
+ tone: "neutral"
52
+ };
53
+ case "CANCELLED": return {
54
+ words: t("notifications.v3.event.cancelled", "Cancelled"),
55
+ tone: "neutral"
56
+ };
57
+ default: return {
58
+ words: t("notifications.v3.event.other", "Updated"),
59
+ tone: "neutral"
60
+ };
61
+ }
62
+ }
63
+ function t(t, n) {
64
+ return [...t].filter((e) => !Number.isNaN(Date.parse(e.timestamp))).sort((e, t) => Date.parse(e.timestamp) - Date.parse(t.timestamp)).map((t) => ({
65
+ id: t.id,
66
+ at: t.timestamp,
67
+ ...e(t.eventType, n)
68
+ }));
69
+ }
70
+ export { e as eventWords, t as timeline };
71
+
72
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","names":["eventWords","eventType","tr","timeline","events","event","a","b"],"sources":["../../../src/v2/model/events.ts"],"sourcesContent":["/**\n * A notification's timeline in words (BOFF-16785, C1): each delivery event as what happened, with a\n * tone (and so an icon), oldest first.\n */\nimport type { Tr } from './tr';\n\nexport type EventTone = 'ok' | 'bad' | 'waiting' | 'neutral';\n\nexport interface TimelineEvent {\n id: string;\n at: string;\n words: string;\n tone: EventTone;\n}\n\nexport function eventWords(eventType: string, tr: Tr): { words: string; tone: EventTone } {\n switch (eventType) {\n case 'CREATED':\n return { words: tr('notifications.v3.event.created', 'Created'), tone: 'neutral' };\n case 'SCHEDULED':\n return { words: tr('notifications.v3.event.scheduled', 'Scheduled'), tone: 'waiting' };\n case 'TRIGGERED':\n case 'SENT':\n return { words: tr('notifications.v3.event.sent', 'Sent'), tone: 'neutral' };\n case 'DELIVERED':\n return { words: tr('notifications.v3.event.delivered', 'Delivered'), tone: 'ok' };\n case 'OPENED':\n return { words: tr('notifications.v3.event.opened', 'Opened'), tone: 'ok' };\n case 'CLICKED':\n return { words: tr('notifications.v3.event.clicked', 'Its action was used'), tone: 'ok' };\n case 'RETRY':\n return { words: tr('notifications.v3.event.retry', 'Tried again'), tone: 'waiting' };\n case 'FAILED':\n return { words: tr('notifications.v3.event.failed', 'Couldn’t be delivered'), tone: 'bad' };\n case 'BOUNCED':\n return {\n words: tr('notifications.v3.event.bounced', 'The address didn’t accept it'),\n tone: 'bad',\n };\n case 'COMPLAINED':\n return { words: tr('notifications.v3.event.complained', 'Marked as spam'), tone: 'bad' };\n case 'UNSUBSCRIBED':\n return { words: tr('notifications.v3.event.unsubscribed', 'Unsubscribed'), tone: 'neutral' };\n case 'EXPIRED':\n return { words: tr('notifications.v3.event.expired', 'Expired'), tone: 'neutral' };\n case 'CANCELLED':\n return { words: tr('notifications.v3.event.cancelled', 'Cancelled'), tone: 'neutral' };\n default:\n return { words: tr('notifications.v3.event.other', 'Updated'), tone: 'neutral' };\n }\n}\n\nexport function timeline(\n events: readonly { id: string; eventType: string; timestamp: string }[],\n tr: Tr\n): TimelineEvent[] {\n return [...events]\n .filter((event) => !Number.isNaN(Date.parse(event.timestamp)))\n .sort((a, b) => Date.parse(a.timestamp) - Date.parse(b.timestamp))\n .map((event) => ({ id: event.id, at: event.timestamp, ...eventWords(event.eventType, tr) }));\n}\n"],"mappings":";AAeA,SAAgBA,EAAW,GAAmB,GAA4C;CACxF,QAAQC,GAAR;EACE,KAAK,WACH,OAAO;GAAE,OAAOC,EAAG,kCAAkC,SAAS;GAAG,MAAM;EAAU;EACnF,KAAK,aACH,OAAO;GAAE,OAAOA,EAAG,oCAAoC,WAAW;GAAG,MAAM;EAAU;EACvF,KAAK;EACL,KAAK,QACH,OAAO;GAAE,OAAOA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C/F"}
@@ -0,0 +1,6 @@
1
+ import { Notification } from '../../types';
2
+ import { NotificationTone } from './inbox';
3
+ export type NotificationIconName = 'megaphone' | 'alert' | 'hand' | 'activity' | 'info';
4
+ /** The icon's colour adds to its shape, never replaces it. */
5
+ export declare const TONE_TEXT: Record<NotificationTone, string | undefined>;
6
+ export declare function notificationIconName(notification: Pick<Notification, 'type' | 'priority' | 'actions'>): NotificationIconName;
@@ -0,0 +1,19 @@
1
+ import { notificationTone as e } from "./inbox.js";
2
+ // src/v2/model/icons.ts
3
+ var t = {
4
+ bad: "alert",
5
+ warn: "hand",
6
+ accent: "activity",
7
+ neutral: "info"
8
+ }, n = {
9
+ bad: "text-status-error-text",
10
+ warn: "text-status-warning-text",
11
+ accent: void 0,
12
+ neutral: void 0
13
+ };
14
+ function r(n) {
15
+ return n.type === "MARKETING" ? "megaphone" : t[e(n)];
16
+ }
17
+ export { n as TONE_TEXT, r as notificationIconName };
18
+
19
+ //# sourceMappingURL=icons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icons.js","names":["TONE_ICON","TONE_TEXT","notificationIconName","notification","notificationTone"],"sources":["../../../src/v2/model/icons.ts"],"sourcesContent":["/**\n * A notification's icon and its colour (BOFF-16785, C1): the shape says the kind; the colour adds to\n * it, never replaces it.\n */\nimport type { Notification } from '../../types';\nimport { notificationTone, type NotificationTone } from './inbox';\n\nexport type NotificationIconName = 'megaphone' | 'alert' | 'hand' | 'activity' | 'info';\n\nconst TONE_ICON: Record<NotificationTone, NotificationIconName> = {\n bad: 'alert',\n warn: 'hand',\n accent: 'activity',\n neutral: 'info',\n};\n\n/** The icon's colour adds to its shape, never replaces it. */\nexport const TONE_TEXT: Record<NotificationTone, string | undefined> = {\n bad: 'text-status-error-text',\n warn: 'text-status-warning-text',\n accent: undefined,\n neutral: undefined,\n};\n\nexport function notificationIconName(\n notification: Pick<Notification, 'type' | 'priority' | 'actions'>\n): NotificationIconName {\n if (notification.type === 'MARKETING') return 'megaphone';\n return TONE_ICON[notificationTone(notification)];\n}\n"],"mappings":";;AASA,IAAMA,IAA4D;CAChE,KAAK;CACL,MAAM;CACN,QAAQ;CACR,SAAS;AACX,GAGaC,IAA0D;CACrE,KAAK;CACL,MAAM;CACN,QAAQ,KAAA;CACR,SAAS,KAAA;AACX;AAEA,SAAgBC,EACd,GACsB;CAEtB,OADIC,EAAa,SAAS,cAAoB,cACvCH,EAAUI,EAAiBD,CAAY;AAChD"}
@@ -0,0 +1,15 @@
1
+ import { Notification } from '../../types';
2
+ export declare const INBOX_TABS: readonly ["all", "unread", "action", "archived"];
3
+ export type InboxTab = (typeof INBOX_TABS)[number];
4
+ /** The `?tab=` value, when it names a tab; else All. */
5
+ export declare function readInboxTab(value: string | null | undefined): InboxTab;
6
+ /** It asks the person to do something: it carries action buttons. */
7
+ export declare function needsAction(notification: Pick<Notification, 'actions'>): boolean;
8
+ /**
9
+ * The tone of a notification's tile: `bad` for alerts and urgent ones, `warn` when it needs the
10
+ * person, `accent` for activity, `neutral` for everything else.
11
+ */
12
+ export type NotificationTone = 'bad' | 'warn' | 'accent' | 'neutral';
13
+ export declare function notificationTone(notification: Pick<Notification, 'type' | 'priority' | 'actions'>): NotificationTone;
14
+ /** Unread: never read, and not archived. */
15
+ export declare function isUnread(notification: Pick<Notification, 'readAt' | 'archivedAt'>): boolean;
@@ -0,0 +1,22 @@
1
+ // src/v2/model/inbox.ts
2
+ var e = [
3
+ "all",
4
+ "unread",
5
+ "action",
6
+ "archived"
7
+ ];
8
+ function t(t) {
9
+ return e.find((e) => e === t) ?? "all";
10
+ }
11
+ function n(e) {
12
+ return e.actions.length > 0;
13
+ }
14
+ function r(e) {
15
+ return e.type === "ALERT" || e.priority === "URGENT" ? "bad" : n(e) ? "warn" : e.type === "TRANSACTIONAL" ? "accent" : "neutral";
16
+ }
17
+ function i(e) {
18
+ return !e.readAt && !e.archivedAt;
19
+ }
20
+ export { e as INBOX_TABS, i as isUnread, n as needsAction, r as notificationTone, t as readInboxTab };
21
+
22
+ //# sourceMappingURL=inbox.js.map