@burdenoff/microfe-notification 2026.1013.2 → 2026.1023.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.
@@ -2,120 +2,119 @@ import { useNotificationAnalytics as e } from "../hooks/useNotificationAnalytics
2
2
  import { useTr as t } from "../shared/hooks/useTr.js";
3
3
  import { formatRelativeTime as n, getNotificationTypeIcon as r, getPriorityColor as i, getPriorityIcon as a, truncateText as o } from "../utils/index.js";
4
4
  import { nativeImpact as s, nativeOpenUrl as c } from "../utils/nativeBridge.js";
5
- import { ExternalLink as l, X as u } from "lucide-react";
6
- import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
5
+ import { navigateInApp as l } from "../utils/inAppNavigation.js";
6
+ import { ExternalLink as u, X as d } from "lucide-react";
7
+ import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
7
8
  //#region src/components/NotificationCard.tsx
8
- function m({ notification: m, onMarkAsRead: h, onArchive: g, onAction: _, onClick: v, showArchivedState: y = !1, compact: b = !1, analyticsSource: x = "center" }) {
9
- let S = t(), { trackNotificationOpened: C } = e(), w = !m.readAt, T = !!m.archivedAt, E = () => {
10
- C(m, x, "card"), v && v(m), w && h && h(m.id);
11
- }, D = (e) => {
12
- e.stopPropagation(), g && g(m.id);
9
+ function h({ notification: h, onMarkAsRead: g, onArchive: _, onAction: v, onClick: y, showArchivedState: b = !1, compact: x = !1, analyticsSource: S = "center" }) {
10
+ let C = t(), { trackNotificationOpened: w } = e(), T = !h.readAt, E = !!h.archivedAt, D = () => {
11
+ w(h, S, "card"), y && y(h), T && g && g(h.id);
13
12
  }, O = (e) => {
14
- if (e.stopPropagation(), s("light"), m.actionUrl) {
15
- C(m, x, "primary_action"), _?.(m.id);
16
- let e = m.actionUrl;
17
- e.startsWith("https://") ? c(e) : window.open(e, "_blank");
18
- }
19
- }, k = (e, t, n) => {
20
- e.stopPropagation(), s("light"), C(m, x, "custom_action"), _?.(m.id, t), n.startsWith("https://") ? c(n) : window.open(n, "_blank");
13
+ e.stopPropagation(), _ && _(h.id);
14
+ }, k = (e) => {
15
+ l(e) || (e.startsWith("https://") ? c(e) : window.open(e, "_blank", "noopener,noreferrer"));
16
+ }, A = (e) => {
17
+ e.stopPropagation(), s("light"), h.actionUrl && (w(h, S, "primary_action"), v?.(h.id), k(h.actionUrl));
18
+ }, j = (e, t, n) => {
19
+ e.stopPropagation(), s("light"), w(h, S, "custom_action"), v?.(h.id, t), k(n);
21
20
  };
22
- return /* @__PURE__ */ p("div", {
21
+ return /* @__PURE__ */ m("div", {
23
22
  "data-tour": "notification-card",
24
23
  className: `
25
24
  relative flex flex-col gap-2 p-4 rounded-lg border cursor-pointer
26
25
  transition-[box-shadow,border-color,opacity] duration-200 ease-in-out
27
26
  bg-gloss-card
28
- ${w ? "border-accent-primary/30 shadow-sm ring-1 ring-accent-primary/10" : "border-border-seam opacity-75"}
29
- ${y && T ? "border-dashed opacity-60" : ""}
27
+ ${T ? "border-accent-primary/30 shadow-sm ring-1 ring-accent-primary/10" : "border-border-seam opacity-75"}
28
+ ${b && E ? "border-dashed opacity-60" : ""}
30
29
  hover:shadow-[var(--shadow-pop)] hover:border-accent-primary/30 hover:opacity-100
31
30
  `,
32
- onClick: E,
31
+ onClick: D,
33
32
  children: [
34
- w && /* @__PURE__ */ f("div", { className: "absolute top-4 left-1.5 w-2.5 h-2.5 bg-accent-primary rounded-full shadow-sm shadow-accent-primary/50 motion-safe:animate-vc-glow-pulse" }),
35
- /* @__PURE__ */ p("div", {
33
+ T && /* @__PURE__ */ p("div", { className: "absolute top-4 left-1.5 w-2.5 h-2.5 bg-accent-primary rounded-full shadow-sm shadow-accent-primary/50 motion-safe:animate-vc-glow-pulse" }),
34
+ /* @__PURE__ */ m("div", {
36
35
  className: "flex items-start justify-between gap-2 ml-3",
37
- children: [/* @__PURE__ */ p("div", {
36
+ children: [/* @__PURE__ */ m("div", {
38
37
  className: "flex items-center gap-2 flex-1 min-w-0",
39
38
  children: [
40
- /* @__PURE__ */ f("span", {
39
+ /* @__PURE__ */ p("span", {
41
40
  className: "text-base",
42
41
  "aria-hidden": "true",
43
- children: r(m.type)
42
+ children: r(h.type)
44
43
  }),
45
- /* @__PURE__ */ f("h3", {
46
- className: `text-sm truncate ${w ? "font-bold text-primary" : "font-medium text-secondary"}`,
47
- children: b ? o(m.title, 60) : m.title
44
+ /* @__PURE__ */ p("h3", {
45
+ className: `text-sm truncate ${T ? "font-bold text-primary" : "font-medium text-secondary"}`,
46
+ children: x ? o(h.title, 60) : h.title
48
47
  }),
49
- /* @__PURE__ */ f("span", {
48
+ /* @__PURE__ */ p("span", {
50
49
  className: "text-xs",
51
- "aria-label": `Priority: ${m.priority}`,
52
- children: a(m.priority)
50
+ "aria-label": `Priority: ${h.priority}`,
51
+ children: a(h.priority)
53
52
  })
54
53
  ]
55
- }), g && /* @__PURE__ */ f("button", {
54
+ }), _ && /* @__PURE__ */ p("button", {
56
55
  "data-tour": "notification-archive-action",
57
- onClick: D,
56
+ onClick: O,
58
57
  className: "flex-shrink-0 p-1 hover:bg-bg-sunken rounded transition-colors duration-150",
59
- "aria-label": S("notifCommon.archiveNotification", "Archive notification"),
60
- children: /* @__PURE__ */ f(u, {
58
+ "aria-label": C("notifCommon.archiveNotification", "Archive notification"),
59
+ children: /* @__PURE__ */ p(d, {
61
60
  size: 16,
62
61
  className: "text-tertiary hover:text-secondary"
63
62
  })
64
63
  })]
65
64
  }),
66
- /* @__PURE__ */ p("div", {
65
+ /* @__PURE__ */ m("div", {
67
66
  className: "ml-3",
68
67
  children: [
69
- m.media[0]?.url && /* @__PURE__ */ f("img", {
70
- src: m.media[0].thumbnailUrl || m.media[0].url,
71
- alt: m.media[0].label || m.title,
68
+ h.media[0]?.url && /* @__PURE__ */ p("img", {
69
+ src: h.media[0].thumbnailUrl || h.media[0].url,
70
+ alt: h.media[0].label || h.title,
72
71
  className: "mb-3 h-40 w-full rounded-md object-cover border border-default"
73
72
  }),
74
- /* @__PURE__ */ f("p", {
75
- className: `text-sm text-secondary ${b ? "line-clamp-2" : ""}`,
76
- children: b ? o(m.body, 120) : m.body
73
+ /* @__PURE__ */ p("p", {
74
+ className: `text-sm text-secondary ${x ? "line-clamp-2" : ""}`,
75
+ children: x ? o(h.body, 120) : h.body
77
76
  }),
78
- m.topic && /* @__PURE__ */ f("div", {
77
+ h.topic && /* @__PURE__ */ p("div", {
79
78
  className: "mt-2 inline-flex items-center rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary",
80
- children: m.topic.name
79
+ children: h.topic.name
81
80
  })
82
81
  ]
83
82
  }),
84
- m.actions.length > 0 && !b && /* @__PURE__ */ f("div", {
83
+ h.actions.length > 0 && !x && /* @__PURE__ */ p("div", {
85
84
  className: "ml-3 flex flex-wrap gap-2",
86
- children: m.actions.map((e) => /* @__PURE__ */ f("button", {
87
- onClick: (t) => k(t, e.id, e.url),
85
+ children: h.actions.map((e) => /* @__PURE__ */ p("button", {
86
+ onClick: (t) => j(t, e.id, e.url),
88
87
  className: `rounded-md px-3 py-1.5 text-xs font-medium transition-colors ${e.style === "secondary" ? "bg-bg-sunken text-secondary hover:bg-bg-sunken/80" : e.style === "danger" ? "bg-status-error-bg-subtle text-status-error-text hover:opacity-80" : "bg-accent-primary text-white hover:opacity-90"}`,
89
88
  children: e.label
90
89
  }, e.id))
91
90
  }),
92
- /* @__PURE__ */ p("div", {
91
+ /* @__PURE__ */ m("div", {
93
92
  className: "flex items-center justify-between gap-2 ml-3",
94
- children: [/* @__PURE__ */ p("div", {
93
+ children: [/* @__PURE__ */ m("div", {
95
94
  className: "flex items-center gap-2 text-xs text-tertiary",
96
95
  children: [
97
- /* @__PURE__ */ f("span", {
98
- className: i(m.priority),
99
- children: m.priority
96
+ /* @__PURE__ */ p("span", {
97
+ className: i(h.priority),
98
+ children: h.priority
100
99
  }),
101
- y && T && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("span", { children: "•" }), /* @__PURE__ */ f("span", { children: S("notifCommon.archived", "Archived") })] }),
102
- /* @__PURE__ */ f("span", { children: "•" }),
103
- /* @__PURE__ */ f("time", {
104
- dateTime: m.createdAt,
105
- children: n(m.createdAt, S)
100
+ b && E && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("span", { children: "•" }), /* @__PURE__ */ p("span", { children: C("notifCommon.archived", "Archived") })] }),
101
+ /* @__PURE__ */ p("span", { children: "•" }),
102
+ /* @__PURE__ */ p("time", {
103
+ dateTime: h.createdAt,
104
+ children: n(h.createdAt, C)
106
105
  })
107
106
  ]
108
- }), m.actionUrl && /* @__PURE__ */ p("button", {
109
- onClick: O,
107
+ }), h.actionUrl && /* @__PURE__ */ m("button", {
108
+ onClick: A,
110
109
  className: "flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/80 transition-colors duration-150",
111
- "aria-label": S("notifCommon.openLink", "Open link"),
112
- children: [/* @__PURE__ */ f("span", { children: S("notifCommon.view", "View") }), /* @__PURE__ */ f(l, { size: 12 })]
110
+ "aria-label": C("notifCommon.openLink", "Open link"),
111
+ children: [/* @__PURE__ */ p("span", { children: C("notifCommon.view", "View") }), /* @__PURE__ */ p(u, { size: 12 })]
113
112
  })]
114
113
  })
115
114
  ]
116
115
  });
117
116
  }
118
117
  //#endregion
119
- export { m as NotificationCard };
118
+ export { h as NotificationCard };
120
119
 
121
120
  //# sourceMappingURL=NotificationCard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationCard.js","names":[],"sources":["../../src/components/NotificationCard.tsx"],"sourcesContent":["import { X, ExternalLink } from 'lucide-react';\nimport type { Notification } from '../types';\nimport { useNotificationAnalytics } from '../hooks/useNotificationAnalytics';\nimport { useTr } from '../shared/hooks/useTr';\nimport {\n formatRelativeTime,\n getPriorityColor,\n getPriorityIcon,\n getNotificationTypeIcon,\n truncateText,\n} from '../utils';\nimport { nativeImpact, nativeOpenUrl } from '../utils/nativeBridge';\n\ninterface NotificationCardProps {\n notification: Notification;\n onMarkAsRead?: (id: string) => void;\n onArchive?: (id: string) => void;\n onAction?: (notificationId: string, actionId?: string) => void;\n onClick?: (notification: Notification) => void;\n showArchivedState?: boolean;\n compact?: boolean;\n analyticsSource?: 'center' | 'panel' | 'history' | 'admin_history';\n}\n\n/**\n * Notification card component\n *\n * Displays notification information with action buttons\n */\nexport function NotificationCard({\n notification,\n onMarkAsRead,\n onArchive,\n onAction,\n onClick,\n showArchivedState = false,\n compact = false,\n analyticsSource = 'center',\n}: NotificationCardProps) {\n const tr = useTr();\n const { trackNotificationOpened } = useNotificationAnalytics();\n const isUnread = !notification.readAt;\n const isArchived = Boolean(notification.archivedAt);\n\n const handleClick = () => {\n trackNotificationOpened(notification, analyticsSource, 'card');\n if (onClick) {\n onClick(notification);\n }\n if (isUnread && onMarkAsRead) {\n onMarkAsRead(notification.id);\n }\n };\n\n const handleArchive = (e: React.MouseEvent) => {\n e.stopPropagation();\n if (onArchive) {\n onArchive(notification.id);\n }\n };\n\n const handleActionUrl = (e: React.MouseEvent) => {\n e.stopPropagation();\n nativeImpact('light');\n if (notification.actionUrl) {\n trackNotificationOpened(notification, analyticsSource, 'primary_action');\n onAction?.(notification.id);\n const url = notification.actionUrl;\n if (url.startsWith('https://')) {\n void nativeOpenUrl(url);\n } else {\n window.open(url, '_blank');\n }\n }\n };\n\n const handleActionClick = (e: React.MouseEvent, actionId: string, actionUrl: string) => {\n e.stopPropagation();\n nativeImpact('light');\n trackNotificationOpened(notification, analyticsSource, 'custom_action');\n onAction?.(notification.id, actionId);\n if (actionUrl.startsWith('https://')) {\n void nativeOpenUrl(actionUrl);\n } else {\n window.open(actionUrl, '_blank');\n }\n };\n\n return (\n <div\n data-tour=\"notification-card\"\n className={`\n relative flex flex-col gap-2 p-4 rounded-lg border cursor-pointer\n transition-[box-shadow,border-color,opacity] duration-200 ease-in-out\n bg-gloss-card\n ${isUnread ? 'border-accent-primary/30 shadow-sm ring-1 ring-accent-primary/10' : 'border-border-seam opacity-75'}\n ${showArchivedState && isArchived ? 'border-dashed opacity-60' : ''}\n hover:shadow-[var(--shadow-pop)] hover:border-accent-primary/30 hover:opacity-100\n `}\n onClick={handleClick}\n >\n {/* Unread indicator */}\n {isUnread && (\n <div className=\"absolute top-4 left-1.5 w-2.5 h-2.5 bg-accent-primary rounded-full shadow-sm shadow-accent-primary/50 motion-safe:animate-vc-glow-pulse\" />\n )}\n\n {/* Header */}\n <div className=\"flex items-start justify-between gap-2 ml-3\">\n <div className=\"flex items-center gap-2 flex-1 min-w-0\">\n <span className=\"text-base\" aria-hidden=\"true\">\n {getNotificationTypeIcon(notification.type)}\n </span>\n <h3\n className={`text-sm truncate ${isUnread ? 'font-bold text-primary' : 'font-medium text-secondary'}`}\n >\n {compact ? truncateText(notification.title, 60) : notification.title}\n </h3>\n <span className=\"text-xs\" aria-label={`Priority: ${notification.priority}`}>\n {getPriorityIcon(notification.priority)}\n </span>\n </div>\n\n {onArchive && (\n <button\n data-tour=\"notification-archive-action\"\n onClick={handleArchive}\n className=\"flex-shrink-0 p-1 hover:bg-bg-sunken rounded transition-colors duration-150\"\n aria-label={tr('notifCommon.archiveNotification', 'Archive notification')}\n >\n <X size={16} className=\"text-tertiary hover:text-secondary\" />\n </button>\n )}\n </div>\n\n {/* Body */}\n <div className=\"ml-3\">\n {notification.media[0]?.url && (\n <img\n src={notification.media[0].thumbnailUrl || notification.media[0].url}\n alt={notification.media[0].label || notification.title}\n className=\"mb-3 h-40 w-full rounded-md object-cover border border-default\"\n />\n )}\n <p className={`text-sm text-secondary ${compact ? 'line-clamp-2' : ''}`}>\n {compact ? truncateText(notification.body, 120) : notification.body}\n </p>\n {notification.topic && (\n <div className=\"mt-2 inline-flex items-center rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary\">\n {notification.topic.name}\n </div>\n )}\n </div>\n\n {notification.actions.length > 0 && !compact && (\n <div className=\"ml-3 flex flex-wrap gap-2\">\n {notification.actions.map((action) => (\n <button\n key={action.id}\n onClick={(e) => handleActionClick(e, action.id, action.url)}\n className={`rounded-md px-3 py-1.5 text-xs font-medium transition-colors ${\n action.style === 'secondary'\n ? 'bg-bg-sunken text-secondary hover:bg-bg-sunken/80'\n : action.style === 'danger'\n ? 'bg-status-error-bg-subtle text-status-error-text hover:opacity-80'\n : 'bg-accent-primary text-white hover:opacity-90'\n }`}\n >\n {action.label}\n </button>\n ))}\n </div>\n )}\n\n {/* Footer */}\n <div className=\"flex items-center justify-between gap-2 ml-3\">\n <div className=\"flex items-center gap-2 text-xs text-tertiary\">\n <span className={getPriorityColor(notification.priority)}>{notification.priority}</span>\n {showArchivedState && isArchived && (\n <>\n <span>•</span>\n <span>{tr('notifCommon.archived', 'Archived')}</span>\n </>\n )}\n <span>•</span>\n <time dateTime={notification.createdAt}>\n {formatRelativeTime(notification.createdAt, tr)}\n </time>\n </div>\n\n {notification.actionUrl && (\n <button\n onClick={handleActionUrl}\n className=\"flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/80 transition-colors duration-150\"\n aria-label={tr('notifCommon.openLink', 'Open link')}\n >\n <span>{tr('notifCommon.view', 'View')}</span>\n <ExternalLink size={12} />\n </button>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;AA6BA,SAAgB,EAAiB,EAC/B,iBACA,iBACA,cACA,aACA,YACA,uBAAoB,IACpB,aAAU,IACV,qBAAkB,YACM;CACxB,IAAM,IAAK,GAAO,EACZ,EAAE,+BAA4B,GAA0B,EACxD,IAAW,CAAC,EAAa,QACzB,IAAa,EAAQ,EAAa,YAElC,UAAoB;AAKxB,EAJA,EAAwB,GAAc,GAAiB,OAAO,EAC1D,KACF,EAAQ,EAAa,EAEnB,KAAY,KACd,EAAa,EAAa,GAAG;IAI3B,KAAiB,MAAwB;AAE7C,EADA,EAAE,iBAAiB,EACf,KACF,EAAU,EAAa,GAAG;IAIxB,KAAmB,MAAwB;AAG/C,MAFA,EAAE,iBAAiB,EACnB,EAAa,QAAQ,EACjB,EAAa,WAAW;AAE1B,GADA,EAAwB,GAAc,GAAiB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ard.js","names":[],"sources":["../../src/components/NotificationCard.tsx"],"sourcesContent":["import { X, ExternalLink } from 'lucide-react';\nimport type { Notification } from '../types';\nimport { useNotificationAnalytics } from '../hooks/useNotificationAnalytics';\nimport { useTr } from '../shared/hooks/useTr';\nimport {\n formatRelativeTime,\n getPriorityColor,\n getPriorityIcon,\n getNotificationTypeIcon,\n truncateText,\n} from '../utils';\nimport { nativeImpact, nativeOpenUrl } from '../utils/nativeBridge';\nimport { navigateInApp } from '../utils/inAppNavigation';\n\ninterface NotificationCardProps {\n notification: Notification;\n onMarkAsRead?: (id: string) => void;\n onArchive?: (id: string) => void;\n onAction?: (notificationId: string, actionId?: string) => void;\n onClick?: (notification: Notification) => void;\n showArchivedState?: boolean;\n compact?: boolean;\n analyticsSource?: 'center' | 'panel' | 'history' | 'admin_history';\n}\n\n/**\n * Notification card component\n *\n * Displays notification information with action buttons\n */\nexport function NotificationCard({\n notification,\n onMarkAsRead,\n onArchive,\n onAction,\n onClick,\n showArchivedState = false,\n compact = false,\n analyticsSource = 'center',\n}: NotificationCardProps) {\n const tr = useTr();\n const { trackNotificationOpened } = useNotificationAnalytics();\n const isUnread = !notification.readAt;\n const isArchived = Boolean(notification.archivedAt);\n\n const handleClick = () => {\n trackNotificationOpened(notification, analyticsSource, 'card');\n if (onClick) {\n onClick(notification);\n }\n if (isUnread && onMarkAsRead) {\n onMarkAsRead(notification.id);\n }\n };\n\n const handleArchive = (e: React.MouseEvent) => {\n e.stopPropagation();\n if (onArchive) {\n onArchive(notification.id);\n }\n };\n\n // A link into this app (an agent, a run, a vibe) opens in place, like the\n // shell's notification bell; only a link that leaves the app opens a new tab\n // (or the system browser on native).\n const openNotificationLink = (url: string) => {\n if (navigateInApp(url)) return;\n if (url.startsWith('https://')) {\n void nativeOpenUrl(url);\n } else {\n window.open(url, '_blank', 'noopener,noreferrer');\n }\n };\n\n const handleActionUrl = (e: React.MouseEvent) => {\n e.stopPropagation();\n nativeImpact('light');\n if (notification.actionUrl) {\n trackNotificationOpened(notification, analyticsSource, 'primary_action');\n onAction?.(notification.id);\n openNotificationLink(notification.actionUrl);\n }\n };\n\n const handleActionClick = (e: React.MouseEvent, actionId: string, actionUrl: string) => {\n e.stopPropagation();\n nativeImpact('light');\n trackNotificationOpened(notification, analyticsSource, 'custom_action');\n onAction?.(notification.id, actionId);\n openNotificationLink(actionUrl);\n };\n\n return (\n <div\n data-tour=\"notification-card\"\n className={`\n relative flex flex-col gap-2 p-4 rounded-lg border cursor-pointer\n transition-[box-shadow,border-color,opacity] duration-200 ease-in-out\n bg-gloss-card\n ${isUnread ? 'border-accent-primary/30 shadow-sm ring-1 ring-accent-primary/10' : 'border-border-seam opacity-75'}\n ${showArchivedState && isArchived ? 'border-dashed opacity-60' : ''}\n hover:shadow-[var(--shadow-pop)] hover:border-accent-primary/30 hover:opacity-100\n `}\n onClick={handleClick}\n >\n {/* Unread indicator */}\n {isUnread && (\n <div className=\"absolute top-4 left-1.5 w-2.5 h-2.5 bg-accent-primary rounded-full shadow-sm shadow-accent-primary/50 motion-safe:animate-vc-glow-pulse\" />\n )}\n\n {/* Header */}\n <div className=\"flex items-start justify-between gap-2 ml-3\">\n <div className=\"flex items-center gap-2 flex-1 min-w-0\">\n <span className=\"text-base\" aria-hidden=\"true\">\n {getNotificationTypeIcon(notification.type)}\n </span>\n <h3\n className={`text-sm truncate ${isUnread ? 'font-bold text-primary' : 'font-medium text-secondary'}`}\n >\n {compact ? truncateText(notification.title, 60) : notification.title}\n </h3>\n <span className=\"text-xs\" aria-label={`Priority: ${notification.priority}`}>\n {getPriorityIcon(notification.priority)}\n </span>\n </div>\n\n {onArchive && (\n <button\n data-tour=\"notification-archive-action\"\n onClick={handleArchive}\n className=\"flex-shrink-0 p-1 hover:bg-bg-sunken rounded transition-colors duration-150\"\n aria-label={tr('notifCommon.archiveNotification', 'Archive notification')}\n >\n <X size={16} className=\"text-tertiary hover:text-secondary\" />\n </button>\n )}\n </div>\n\n {/* Body */}\n <div className=\"ml-3\">\n {notification.media[0]?.url && (\n <img\n src={notification.media[0].thumbnailUrl || notification.media[0].url}\n alt={notification.media[0].label || notification.title}\n className=\"mb-3 h-40 w-full rounded-md object-cover border border-default\"\n />\n )}\n <p className={`text-sm text-secondary ${compact ? 'line-clamp-2' : ''}`}>\n {compact ? truncateText(notification.body, 120) : notification.body}\n </p>\n {notification.topic && (\n <div className=\"mt-2 inline-flex items-center rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary\">\n {notification.topic.name}\n </div>\n )}\n </div>\n\n {notification.actions.length > 0 && !compact && (\n <div className=\"ml-3 flex flex-wrap gap-2\">\n {notification.actions.map((action) => (\n <button\n key={action.id}\n onClick={(e) => handleActionClick(e, action.id, action.url)}\n className={`rounded-md px-3 py-1.5 text-xs font-medium transition-colors ${\n action.style === 'secondary'\n ? 'bg-bg-sunken text-secondary hover:bg-bg-sunken/80'\n : action.style === 'danger'\n ? 'bg-status-error-bg-subtle text-status-error-text hover:opacity-80'\n : 'bg-accent-primary text-white hover:opacity-90'\n }`}\n >\n {action.label}\n </button>\n ))}\n </div>\n )}\n\n {/* Footer */}\n <div className=\"flex items-center justify-between gap-2 ml-3\">\n <div className=\"flex items-center gap-2 text-xs text-tertiary\">\n <span className={getPriorityColor(notification.priority)}>{notification.priority}</span>\n {showArchivedState && isArchived && (\n <>\n <span>•</span>\n <span>{tr('notifCommon.archived', 'Archived')}</span>\n </>\n )}\n <span>•</span>\n <time dateTime={notification.createdAt}>\n {formatRelativeTime(notification.createdAt, tr)}\n </time>\n </div>\n\n {notification.actionUrl && (\n <button\n onClick={handleActionUrl}\n className=\"flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/80 transition-colors duration-150\"\n aria-label={tr('notifCommon.openLink', 'Open link')}\n >\n <span>{tr('notifCommon.view', 'View')}</span>\n <ExternalLink size={12} />\n </button>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AA8BA,SAAgB,EAAiB,EAC/B,iBACA,iBACA,cACA,aACA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AAG,wBAAwB,WAAW,EAAQ,CAAA,CACpD,EAAA,CAAA;MAEL,kBAAC,QAAD,EAAA,UAAM,KAAQ,CAAA;MACd,kBAAC,QAAD;OAAM,UAAU,EAAa;iBAC1B,EAAmB,EAAa,WAAW,EAAG;OAC1C,CAAA;MACH;QAEL,EAAa,aACZ,kBAAC,UAAD;KACE,SAAS;KACT,WAAU;KACV,cAAY,EAAG,wBAAwB,YAAY;eAHrD,CAKE,kBAAC,QAAD,EAAA,UAAO,EAAG,oBAAoB,OAAO,EAAQ,CAAA,EAC7C,kBAAC,GAAD,EAAc,MAAM,IAAM,CAAA,CACnB;OAEP;;GACF"}
@@ -0,0 +1,34 @@
1
+ //#region src/utils/inAppNavigation.ts
2
+ function e(e) {
3
+ if (typeof e != "string" || !e.startsWith("/") || e.startsWith("//") || e.startsWith("/\\")) return !1;
4
+ for (let t = 0; t < e.length; t += 1) {
5
+ let n = e.charCodeAt(t);
6
+ if (n < 32 || n === 127) return !1;
7
+ }
8
+ return !0;
9
+ }
10
+ function t(t, n) {
11
+ if (typeof t != "string" || t.length === 0) return null;
12
+ if (t.startsWith("/")) return e(t) ? t : null;
13
+ let r;
14
+ try {
15
+ r = new URL(t);
16
+ } catch {
17
+ return null;
18
+ }
19
+ if (r.origin !== n) return null;
20
+ let i = `${r.pathname || "/"}${r.search}${r.hash}`;
21
+ return e(i) ? i : null;
22
+ }
23
+ function n(e, n = globalThis.window) {
24
+ if (!n) return !1;
25
+ let r = t(e, n.location.origin);
26
+ if (r === null) return !1;
27
+ n.history.pushState(null, "", r);
28
+ let i = typeof PopStateEvent == "function" ? new PopStateEvent("popstate", { state: null }) : new Event("popstate");
29
+ return n.dispatchEvent(i), !0;
30
+ }
31
+ //#endregion
32
+ export { n as navigateInApp };
33
+
34
+ //# sourceMappingURL=inAppNavigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inAppNavigation.js","names":[],"sources":["../../src/utils/inAppNavigation.ts"],"sourcesContent":["/**\n * Same-origin, in-app navigation for notification links.\n *\n * Mirrors `@burdenoff/fe-libs/src/shared/navigation/inAppPath` (used by the\n * shell's notification bell), which is not part of fe-libs' public exports:\n * the full Notification Center page and the bell must treat a link the same\n * way — a link into this app (an agent, a run, a vibe) opens in the current\n * tab, and only a link that leaves the app opens a new one.\n */\n\n/**\n * True for a same-origin, in-app path: `/x`, `/x?y#z`. Refuses protocol-relative\n * (`//host`, `/\\host`), control characters, and anything that is not a rooted\n * path, so a notification payload can never steer the page to another origin.\n */\nexport function isSafeInAppPath(path: string): boolean {\n if (typeof path !== 'string' || !path.startsWith('/')) return false;\n if (path.startsWith('//') || path.startsWith('/\\\\')) return false;\n for (let index = 0; index < path.length; index += 1) {\n const code = path.charCodeAt(index);\n if (code < 0x20 || code === 0x7f) return false;\n }\n return true;\n}\n\n/**\n * The in-app path a link points at, or null when it leaves the app: a rooted\n * path is taken as is; an absolute URL only when its origin is `origin`.\n */\nexport function toInAppPath(url: string, origin: string): string | null {\n if (typeof url !== 'string' || url.length === 0) return null;\n if (url.startsWith('/')) return isSafeInAppPath(url) ? url : null;\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return null;\n }\n if (parsed.origin !== origin) return null;\n const path = `${parsed.pathname || '/'}${parsed.search}${parsed.hash}`;\n return isSafeInAppPath(path) ? path : null;\n}\n\n/** The window members in-app navigation uses (a seam for tests). */\nexport interface InAppNavigationWindow {\n location: { origin: string };\n history: {\n pushState: (data: unknown, unused: string, url?: string | null) => void;\n };\n dispatchEvent: (event: Event) => boolean;\n}\n\n/**\n * Navigate inside the app without a reload: push the path and announce it with\n * `popstate`, which the shell's React Router browser history and its\n * `ActiveContextProvider` both listen to. Returns false, and does nothing, when\n * `url` leaves the app — the caller then opens it in a new tab.\n */\nexport function navigateInApp(\n url: string,\n win: InAppNavigationWindow | undefined = globalThis.window\n): boolean {\n if (!win) return false;\n const path = toInAppPath(url, win.location.origin);\n if (path === null) return false;\n win.history.pushState(null, '', path);\n const event =\n typeof PopStateEvent === 'function'\n ? new PopStateEvent('popstate', { state: null })\n : new Event('popstate');\n win.dispatchEvent(event);\n return true;\n}\n"],"mappings":";AAeA,SAAgB,EAAgB,GAAuB;AAErD,KADI,OAAO,KAAS,YAAY,CAAC,EAAK,WAAW,IAAI,IACjD,EAAK,WAAW,KAAK,IAAI,EAAK,WAAW,MAAM,CAAE,QAAO;AAC5D,MAAK,IAAI,IAAQ,GAAG,IAAQ,EAAK,QAAQ,KAAS,GAAG;EACnD,IAAM,IAAO,EAAK,WAAW,EAAM;AACnC,MAAI,IAAO,MAAQ,MAAS,IAAM,QAAO;;AAE3C,QAAO;;AAOT,SAAgB,EAAY,GAAa,GAA+B;AACtE,KAAI,OAAO,KAAQ,YAAY,EAAI,WAAW,EAAG,QAAO;AACxD,KAAI,EAAI,WAAW,IAAI,CAAE,QAAO,EAAgB,EAAI,GAAG,IAAM;CAC7D,IAAI;AACJ,KAAI;AACF,MAAS,IAAI,IAAI,EAAI;SACf;AACN,SAAO;;AAET,KAAI,EAAO,WAAW,EAAQ,QAAO;CACrC,IAAM,IAAO,GAAG,EAAO,YAAY,MAAM,EAAO,SAAS,EAAO;AAChE,QAAO,EAAgB,EAAK,GAAG,IAAO;;AAkBxC,SAAgB,EACd,GACA,IAAyC,WAAW,QAC3C;AACT,KAAI,CAAC,EAAK,QAAO;CACjB,IAAM,IAAO,EAAY,GAAK,EAAI,SAAS,OAAO;AAClD,KAAI,MAAS,KAAM,QAAO;AAC1B,GAAI,QAAQ,UAAU,MAAM,IAAI,EAAK;CACrC,IAAM,IACJ,OAAO,iBAAkB,aACrB,IAAI,cAAc,YAAY,EAAE,OAAO,MAAM,CAAC,GAC9C,IAAI,MAAM,WAAW;AAE3B,QADA,EAAI,cAAc,EAAM,EACjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-notification",
3
- "version": "2026.1013.2",
3
+ "version": "2026.1023.1",
4
4
  "description": "Notification microfrontend for multi-channel notification management",
5
5
  "type": "module",
6
6
  "imports": {