@burdenoff/microfe-notification 2026.625.1 → 2026.626.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/components/NotificationBell.js +1 -1
- package/dist/components/NotificationBell.js.map +1 -1
- package/dist/components/NotificationCard.js +1 -1
- package/dist/components/NotificationCard.js.map +1 -1
- package/dist/pages/CreateNotificationPage.js +475 -453
- package/dist/pages/CreateNotificationPage.js.map +1 -1
- package/dist/pages/NotificationCenterPage.js +102 -94
- package/dist/pages/NotificationCenterPage.js.map +1 -1
- package/dist/pages/NotificationHistoryAdminPage.js +140 -100
- package/dist/pages/NotificationHistoryAdminPage.js.map +1 -1
- package/dist/pages/NotificationHistoryPage.js +48 -53
- package/dist/pages/NotificationHistoryPage.js.map +1 -1
- package/dist/pages/NotificationPreferencesPage.js +77 -72
- package/dist/pages/NotificationPreferencesPage.js.map +1 -1
- package/dist/pages/NotificationTemplatesPage.js +129 -102
- package/dist/pages/NotificationTemplatesPage.js.map +1 -1
- package/dist/pages/NotificationTopicsPage.js +258 -209
- package/dist/pages/NotificationTopicsPage.js.map +1 -1
- package/dist/pages/TemplateEditorPage.js +350 -319
- package/dist/pages/TemplateEditorPage.js.map +1 -1
- package/package.json +2 -2
|
@@ -58,7 +58,7 @@ function d({ onClick: d }) {
|
|
|
58
58
|
size: 20,
|
|
59
59
|
className: "text-primary"
|
|
60
60
|
}), g > 0 && /* @__PURE__ */ l("span", {
|
|
61
|
-
className: "absolute top-1 right-1 flex items-center justify-center min-w-[18px] h-[18px] px-1 text-xs font-semibold tabular-nums text-white bg-error rounded-full animate-pulse",
|
|
61
|
+
className: "absolute top-1 right-1 flex items-center justify-center min-w-[18px] h-[18px] px-1 text-xs font-semibold tabular-nums text-white bg-error rounded-full motion-safe:animate-vc-glow-pulse",
|
|
62
62
|
children: g > 99 ? "99+" : g
|
|
63
63
|
})]
|
|
64
64
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationBell.js","names":[],"sources":["../../src/components/NotificationBell.tsx"],"sourcesContent":["import { useCallback, useEffect } from 'react';\nimport { Bell } from 'lucide-react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient } from '../graphql/global-client';\nimport {\n GetMyUnreadNotificationCountDocument,\n UnreadCountUpdatedDocument,\n} from '../generated/global-operations';\nimport type {\n GetMyUnreadNotificationCountQuery,\n UnreadCountUpdatedSubscription,\n} from '../generated/global-operations';\nimport { useNotificationStore } from '../store/notificationStore';\nimport { useTr } from '../shared/hooks/useTr';\n\n/**\n * Notification bell icon with unread count badge\n *\n * This component should be placed in the global header/navbar\n *\n * @example\n * ```tsx\n * <NotificationBell onClick={() => navigate('/notifications/center')} />\n * ```\n */\nexport function NotificationBell({ onClick }: { onClick?: () => void }) {\n const tr = useTr();\n const { authToken, apiGatewayUrl, currentUser } = useNotification();\n const { unreadCount, togglePanel, setUnreadCount } = useNotificationStore();\n\n const refreshUnreadCount = useCallback(async () => {\n try {\n const client = getGlobalNotificationClient(\n apiGatewayUrl ?? undefined,\n authToken ?? undefined\n );\n const result = await client.query<GetMyUnreadNotificationCountQuery>({\n query: GetMyUnreadNotificationCountDocument,\n variables: { filter: { channel: 'IN_APP' } },\n fetchPolicy: 'network-only',\n });\n\n if (typeof result.data?.myUnreadNotificationCount === 'number') {\n setUnreadCount(result.data.myUnreadNotificationCount);\n }\n } catch {\n // Keep bell resilient; do not surface errors here.\n }\n }, [apiGatewayUrl, authToken, setUnreadCount]);\n\n useEffect(() => {\n refreshUnreadCount();\n }, [refreshUnreadCount]);\n\n useEffect(() => {\n if (!currentUser?.id) return undefined;\n\n const client = getGlobalNotificationClient(apiGatewayUrl ?? undefined, authToken ?? undefined);\n const subscription = client\n .subscribe<UnreadCountUpdatedSubscription>({\n query: UnreadCountUpdatedDocument,\n variables: { userId: currentUser.id },\n })\n .subscribe({\n next: (result) => {\n const nextCount = result.data?.unreadCountUpdated;\n if (typeof nextCount === 'number') {\n setUnreadCount(nextCount);\n }\n },\n error: () => {\n // Keep the header resilient; visibility refresh below handles recovery.\n },\n });\n\n return () => subscription.unsubscribe();\n }, [apiGatewayUrl, authToken, currentUser?.id, setUnreadCount]);\n\n useEffect(() => {\n const handleVisibilityChange = () => {\n if (document.visibilityState === 'visible') {\n refreshUnreadCount();\n }\n };\n\n document.addEventListener('visibilitychange', handleVisibilityChange);\n return () => document.removeEventListener('visibilitychange', handleVisibilityChange);\n }, [refreshUnreadCount]);\n\n const handleClick = () => {\n if (onClick) {\n onClick();\n } else {\n togglePanel();\n }\n };\n\n return (\n <button\n data-tour=\"notification-bell\"\n onClick={handleClick}\n className=\"relative inline-flex items-center justify-center p-2 rounded-md hover:bg-bg-sunken transition-all duration-150\"\n aria-label={`${tr('notifCommon.notifications', 'Notifications')}${unreadCount > 0 ? ` (${unreadCount} ${tr('notifCommon.unread', 'unread')})` : ''}`}\n >\n <Bell size={20} className=\"text-primary\" />\n {unreadCount > 0 && (\n <span className=\"absolute top-1 right-1 flex items-center justify-center min-w-[18px] h-[18px] px-1 text-xs font-semibold tabular-nums text-white bg-error rounded-full animate-pulse\">\n {unreadCount > 99 ? '99+' : unreadCount}\n </span>\n )}\n </button>\n );\n}\n"],"mappings":";;;;;;;;;AAyBA,SAAgB,EAAiB,EAAE,cAAqC;CACtE,IAAM,IAAK,GAAO,EACZ,EAAE,cAAW,kBAAe,mBAAgB,GAAiB,EAC7D,EAAE,gBAAa,gBAAa,sBAAmB,GAAsB,EAErE,IAAqB,EAAY,YAAY;AACjD,MAAI;GAKF,IAAM,IAAS,MAJA,EACb,KAAiB,KAAA,GACjB,KAAa,KAAA,EACd,CAC2B,MAAyC;IACnE,OAAO;IACP,WAAW,EAAE,QAAQ,EAAE,SAAS,UAAU,EAAE;IAC5C,aAAa;IACd,CAAC;AAEF,GAAI,OAAO,EAAO,MAAM,6BAA8B,YACpD,EAAe,EAAO,KAAK,0BAA0B;UAEjD;IAGP;EAAC;EAAe;EAAW;EAAe,CAAC;AAiD9C,QA/CA,QAAgB;AACd,KAAoB;IACnB,CAAC,EAAmB,CAAC,EAExB,QAAgB;AACd,MAAI,CAAC,GAAa,GAAI;EAGtB,IAAM,IADS,EAA4B,KAAiB,KAAA,GAAW,KAAa,KAAA,EAAU,CAE3F,UAA0C;GACzC,OAAO;GACP,WAAW,EAAE,QAAQ,EAAY,IAAI;GACtC,CAAC,CACD,UAAU;GACT,OAAO,MAAW;IAChB,IAAM,IAAY,EAAO,MAAM;AAC/B,IAAI,OAAO,KAAc,YACvB,EAAe,EAAU;;GAG7B,aAAa;GAGd,CAAC;AAEJ,eAAa,EAAa,aAAa;IACtC;EAAC;EAAe;EAAW,GAAa;EAAI;EAAe,CAAC,EAE/D,QAAgB;EACd,IAAM,UAA+B;AACnC,GAAI,SAAS,oBAAoB,aAC/B,GAAoB;;AAKxB,SADA,SAAS,iBAAiB,oBAAoB,EAAuB,QACxD,SAAS,oBAAoB,oBAAoB,EAAuB;IACpF,CAAC,EAAmB,CAAC,EAWtB,kBAAC,UAAD;EACE,aAAU;EACV,eAXsB;AACxB,GAAI,IACF,GAAS,GAET,GAAa;;EAQb,WAAU;EACV,cAAY,GAAG,EAAG,6BAA6B,gBAAgB,GAAG,IAAc,IAAI,KAAK,EAAY,GAAG,EAAG,sBAAsB,SAAS,CAAC,KAAK;YAJlJ,CAME,kBAAC,GAAD;GAAM,MAAM;GAAI,WAAU;GAAiB,CAAA,EAC1C,IAAc,KACb,kBAAC,QAAD;GAAM,WAAU;aACb,IAAc,KAAK,QAAQ;GACvB,CAAA,CAEF"}
|
|
1
|
+
{"version":3,"file":"NotificationBell.js","names":[],"sources":["../../src/components/NotificationBell.tsx"],"sourcesContent":["import { useCallback, useEffect } from 'react';\nimport { Bell } from 'lucide-react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient } from '../graphql/global-client';\nimport {\n GetMyUnreadNotificationCountDocument,\n UnreadCountUpdatedDocument,\n} from '../generated/global-operations';\nimport type {\n GetMyUnreadNotificationCountQuery,\n UnreadCountUpdatedSubscription,\n} from '../generated/global-operations';\nimport { useNotificationStore } from '../store/notificationStore';\nimport { useTr } from '../shared/hooks/useTr';\n\n/**\n * Notification bell icon with unread count badge\n *\n * This component should be placed in the global header/navbar\n *\n * @example\n * ```tsx\n * <NotificationBell onClick={() => navigate('/notifications/center')} />\n * ```\n */\nexport function NotificationBell({ onClick }: { onClick?: () => void }) {\n const tr = useTr();\n const { authToken, apiGatewayUrl, currentUser } = useNotification();\n const { unreadCount, togglePanel, setUnreadCount } = useNotificationStore();\n\n const refreshUnreadCount = useCallback(async () => {\n try {\n const client = getGlobalNotificationClient(\n apiGatewayUrl ?? undefined,\n authToken ?? undefined\n );\n const result = await client.query<GetMyUnreadNotificationCountQuery>({\n query: GetMyUnreadNotificationCountDocument,\n variables: { filter: { channel: 'IN_APP' } },\n fetchPolicy: 'network-only',\n });\n\n if (typeof result.data?.myUnreadNotificationCount === 'number') {\n setUnreadCount(result.data.myUnreadNotificationCount);\n }\n } catch {\n // Keep bell resilient; do not surface errors here.\n }\n }, [apiGatewayUrl, authToken, setUnreadCount]);\n\n useEffect(() => {\n refreshUnreadCount();\n }, [refreshUnreadCount]);\n\n useEffect(() => {\n if (!currentUser?.id) return undefined;\n\n const client = getGlobalNotificationClient(apiGatewayUrl ?? undefined, authToken ?? undefined);\n const subscription = client\n .subscribe<UnreadCountUpdatedSubscription>({\n query: UnreadCountUpdatedDocument,\n variables: { userId: currentUser.id },\n })\n .subscribe({\n next: (result) => {\n const nextCount = result.data?.unreadCountUpdated;\n if (typeof nextCount === 'number') {\n setUnreadCount(nextCount);\n }\n },\n error: () => {\n // Keep the header resilient; visibility refresh below handles recovery.\n },\n });\n\n return () => subscription.unsubscribe();\n }, [apiGatewayUrl, authToken, currentUser?.id, setUnreadCount]);\n\n useEffect(() => {\n const handleVisibilityChange = () => {\n if (document.visibilityState === 'visible') {\n refreshUnreadCount();\n }\n };\n\n document.addEventListener('visibilitychange', handleVisibilityChange);\n return () => document.removeEventListener('visibilitychange', handleVisibilityChange);\n }, [refreshUnreadCount]);\n\n const handleClick = () => {\n if (onClick) {\n onClick();\n } else {\n togglePanel();\n }\n };\n\n return (\n <button\n data-tour=\"notification-bell\"\n onClick={handleClick}\n className=\"relative inline-flex items-center justify-center p-2 rounded-md hover:bg-bg-sunken transition-all duration-150\"\n aria-label={`${tr('notifCommon.notifications', 'Notifications')}${unreadCount > 0 ? ` (${unreadCount} ${tr('notifCommon.unread', 'unread')})` : ''}`}\n >\n <Bell size={20} className=\"text-primary\" />\n {unreadCount > 0 && (\n <span className=\"absolute top-1 right-1 flex items-center justify-center min-w-[18px] h-[18px] px-1 text-xs font-semibold tabular-nums text-white bg-error rounded-full motion-safe:animate-vc-glow-pulse\">\n {unreadCount > 99 ? '99+' : unreadCount}\n </span>\n )}\n </button>\n );\n}\n"],"mappings":";;;;;;;;;AAyBA,SAAgB,EAAiB,EAAE,cAAqC;CACtE,IAAM,IAAK,GAAO,EACZ,EAAE,cAAW,kBAAe,mBAAgB,GAAiB,EAC7D,EAAE,gBAAa,gBAAa,sBAAmB,GAAsB,EAErE,IAAqB,EAAY,YAAY;AACjD,MAAI;GAKF,IAAM,IAAS,MAJA,EACb,KAAiB,KAAA,GACjB,KAAa,KAAA,EACd,CAC2B,MAAyC;IACnE,OAAO;IACP,WAAW,EAAE,QAAQ,EAAE,SAAS,UAAU,EAAE;IAC5C,aAAa;IACd,CAAC;AAEF,GAAI,OAAO,EAAO,MAAM,6BAA8B,YACpD,EAAe,EAAO,KAAK,0BAA0B;UAEjD;IAGP;EAAC;EAAe;EAAW;EAAe,CAAC;AAiD9C,QA/CA,QAAgB;AACd,KAAoB;IACnB,CAAC,EAAmB,CAAC,EAExB,QAAgB;AACd,MAAI,CAAC,GAAa,GAAI;EAGtB,IAAM,IADS,EAA4B,KAAiB,KAAA,GAAW,KAAa,KAAA,EAAU,CAE3F,UAA0C;GACzC,OAAO;GACP,WAAW,EAAE,QAAQ,EAAY,IAAI;GACtC,CAAC,CACD,UAAU;GACT,OAAO,MAAW;IAChB,IAAM,IAAY,EAAO,MAAM;AAC/B,IAAI,OAAO,KAAc,YACvB,EAAe,EAAU;;GAG7B,aAAa;GAGd,CAAC;AAEJ,eAAa,EAAa,aAAa;IACtC;EAAC;EAAe;EAAW,GAAa;EAAI;EAAe,CAAC,EAE/D,QAAgB;EACd,IAAM,UAA+B;AACnC,GAAI,SAAS,oBAAoB,aAC/B,GAAoB;;AAKxB,SADA,SAAS,iBAAiB,oBAAoB,EAAuB,QACxD,SAAS,oBAAoB,oBAAoB,EAAuB;IACpF,CAAC,EAAmB,CAAC,EAWtB,kBAAC,UAAD;EACE,aAAU;EACV,eAXsB;AACxB,GAAI,IACF,GAAS,GAET,GAAa;;EAQb,WAAU;EACV,cAAY,GAAG,EAAG,6BAA6B,gBAAgB,GAAG,IAAc,IAAI,KAAK,EAAY,GAAG,EAAG,sBAAsB,SAAS,CAAC,KAAK;YAJlJ,CAME,kBAAC,GAAD;GAAM,MAAM;GAAI,WAAU;GAAiB,CAAA,EAC1C,IAAc,KACb,kBAAC,QAAD;GAAM,WAAU;aACb,IAAc,KAAK,QAAQ;GACvB,CAAA,CAEF"}
|
|
@@ -31,7 +31,7 @@ function m({ notification: m, onMarkAsRead: h, onArchive: g, onAction: _, onClic
|
|
|
31
31
|
`,
|
|
32
32
|
onClick: E,
|
|
33
33
|
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 animate-pulse" }),
|
|
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
35
|
/* @__PURE__ */ p("div", {
|
|
36
36
|
className: "flex items-start justify-between gap-2 ml-3",
|
|
37
37
|
children: [/* @__PURE__ */ p("div", {
|
|
@@ -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 animate-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)}\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,+B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kBAAC,QAAD,EAAA,UAAM,KAAQ,CAAA;MACd,kBAAC,QAAD;OAAM,UAAU,EAAa;iBAC1B,EAAmB,EAAa,UAAU;OACtC,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"}
|
|
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)}\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,iBAAiB,EACxE,IAAW,EAAa,GAAG;GAC3B,IAAM,IAAM,EAAa;AACzB,GAAI,EAAI,WAAW,WAAW,GACvB,EAAc,EAAI,GAEvB,OAAO,KAAK,GAAK,SAAS;;IAK1B,KAAqB,GAAqB,GAAkB,MAAsB;AAKtF,EAJA,EAAE,iBAAiB,EACnB,EAAa,QAAQ,EACrB,EAAwB,GAAc,GAAiB,gBAAgB,EACvE,IAAW,EAAa,IAAI,EAAS,EACjC,EAAU,WAAW,WAAW,GAC7B,EAAc,EAAU,GAE7B,OAAO,KAAK,GAAW,SAAS;;AAIpC,QACE,kBAAC,OAAD;EACE,aAAU;EACV,WAAW;;;;UAIP,IAAW,qEAAqE,gCAAgC;UAChH,KAAqB,IAAa,6BAA6B,GAAG;;;EAGtE,SAAS;YAVX;GAaG,KACC,kBAAC,OAAD,EAAK,WAAU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