@burdenoff/microfe-notification 2026.601.1 → 2026.624.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/FeatureDisabledPage.js +1 -1
- package/dist/components/FeatureDisabledPage.js.map +1 -1
- package/dist/components/NotificationBell.js +1 -1
- package/dist/components/NotificationBell.js.map +1 -1
- package/dist/components/NotificationCard.js +4 -4
- package/dist/components/NotificationCard.js.map +1 -1
- package/dist/components/NotificationPanel.js +1 -1
- package/dist/components/NotificationPanel.js.map +1 -1
- package/dist/components/RecipientSelector.js +8 -8
- package/dist/components/RecipientSelector.js.map +1 -1
- package/dist/components/TemplatePreview.js +6 -6
- package/dist/components/TemplatePreview.js.map +1 -1
- package/dist/pages/CreateNotificationPage.js +1 -1
- package/dist/pages/CreateNotificationPage.js.map +1 -1
- package/dist/pages/NotificationHistoryAdminPage.js +5 -5
- package/dist/pages/NotificationHistoryAdminPage.js.map +1 -1
- package/dist/pages/NotificationHistoryPage.js +1 -1
- package/dist/pages/NotificationHistoryPage.js.map +1 -1
- package/dist/pages/NotificationPreferencesPage.js +3 -3
- package/dist/pages/NotificationPreferencesPage.js.map +1 -1
- package/dist/pages/NotificationTemplatesPage.js +3 -3
- package/dist/pages/NotificationTemplatesPage.js.map +1 -1
- package/dist/pages/NotificationTopicsPage.js +4 -4
- package/dist/pages/NotificationTopicsPage.js.map +1 -1
- package/dist/pages/TemplateEditorPage.js +7 -7
- package/dist/pages/TemplateEditorPage.js.map +1 -1
- package/dist/utils/index.js +2 -2
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ function r({ title: r, description: i }) {
|
|
|
8
8
|
className: "max-w-md rounded-xl border border-default bg-surface p-6 text-center shadow-sm",
|
|
9
9
|
children: [
|
|
10
10
|
/* @__PURE__ */ t("div", {
|
|
11
|
-
className: "mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-
|
|
11
|
+
className: "mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-bg-sunken text-secondary",
|
|
12
12
|
children: /* @__PURE__ */ t(e, {
|
|
13
13
|
size: 22,
|
|
14
14
|
"aria-hidden": "true"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureDisabledPage.js","names":[],"sources":["../../src/components/FeatureDisabledPage.tsx"],"sourcesContent":["import { Lock } from 'lucide-react';\n\ninterface FeatureDisabledPageProps {\n title: string;\n description: string;\n}\n\nexport function FeatureDisabledPage({ title, description }: FeatureDisabledPageProps) {\n return (\n <div className=\"flex min-h-64 items-center justify-center p-6\">\n <div className=\"max-w-md rounded-xl border border-default bg-surface p-6 text-center shadow-sm\">\n <div className=\"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-
|
|
1
|
+
{"version":3,"file":"FeatureDisabledPage.js","names":[],"sources":["../../src/components/FeatureDisabledPage.tsx"],"sourcesContent":["import { Lock } from 'lucide-react';\n\ninterface FeatureDisabledPageProps {\n title: string;\n description: string;\n}\n\nexport function FeatureDisabledPage({ title, description }: FeatureDisabledPageProps) {\n return (\n <div className=\"flex min-h-64 items-center justify-center p-6\">\n <div className=\"max-w-md rounded-xl border border-default bg-surface p-6 text-center shadow-sm\">\n <div className=\"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-bg-sunken text-secondary\">\n <Lock size={22} aria-hidden=\"true\" />\n </div>\n <h1 className=\"text-lg font-semibold text-primary\">{title}</h1>\n <p className=\"mt-2 text-sm leading-6 text-secondary\">{description}</p>\n </div>\n </div>\n );\n}\n"],"mappings":";;;AAOA,SAAgB,EAAoB,EAAE,UAAO,kBAAyC;AACpF,QACE,kBAAC,OAAD;EAAK,WAAU;YACb,kBAAC,OAAD;GAAK,WAAU;aAAf;IACE,kBAAC,OAAD;KAAK,WAAU;eACb,kBAAC,GAAD;MAAM,MAAM;MAAI,eAAY;MAAS,CAAA;KACjC,CAAA;IACN,kBAAC,MAAD;KAAI,WAAU;eAAsC;KAAW,CAAA;IAC/D,kBAAC,KAAD;KAAG,WAAU;eAAyC;KAAgB,CAAA;IAClE;;EACF,CAAA"}
|
|
@@ -52,7 +52,7 @@ function d({ onClick: d }) {
|
|
|
52
52
|
onClick: () => {
|
|
53
53
|
d ? d() : _();
|
|
54
54
|
},
|
|
55
|
-
className: "relative inline-flex items-center justify-center p-2 rounded-md hover:bg-
|
|
55
|
+
className: "relative inline-flex items-center justify-center p-2 rounded-md hover:bg-bg-sunken transition-all duration-150",
|
|
56
56
|
"aria-label": `${f("notifCommon.notifications", "Notifications")}${g > 0 ? ` (${g} ${f("notifCommon.unread", "unread")})` : ""}`,
|
|
57
57
|
children: [/* @__PURE__ */ l(c, {
|
|
58
58
|
size: 20,
|
|
@@ -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-
|
|
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 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"}
|
|
@@ -26,7 +26,7 @@ function m({ notification: m, onMarkAsRead: h, onArchive: g, onAction: _, onClic
|
|
|
26
26
|
transition-all duration-200 ease-in-out
|
|
27
27
|
${w ? "bg-accent-subtle/5 border-accent-primary/20 shadow-sm ring-1 ring-accent-primary/10" : "bg-surface border-default opacity-75"}
|
|
28
28
|
${y && T ? "border-dashed opacity-60" : ""}
|
|
29
|
-
hover:bg-
|
|
29
|
+
hover:bg-bg-sunken hover:shadow-md hover:opacity-100
|
|
30
30
|
`,
|
|
31
31
|
onClick: E,
|
|
32
32
|
children: [
|
|
@@ -54,7 +54,7 @@ function m({ notification: m, onMarkAsRead: h, onArchive: g, onAction: _, onClic
|
|
|
54
54
|
}), g && /* @__PURE__ */ f("button", {
|
|
55
55
|
"data-tour": "notification-archive-action",
|
|
56
56
|
onClick: D,
|
|
57
|
-
className: "flex-shrink-0 p-1 hover:bg-
|
|
57
|
+
className: "flex-shrink-0 p-1 hover:bg-bg-sunken rounded transition-colors duration-150",
|
|
58
58
|
"aria-label": S("notifCommon.archiveNotification", "Archive notification"),
|
|
59
59
|
children: /* @__PURE__ */ f(u, {
|
|
60
60
|
size: 16,
|
|
@@ -75,7 +75,7 @@ function m({ notification: m, onMarkAsRead: h, onArchive: g, onAction: _, onClic
|
|
|
75
75
|
children: b ? o(m.body, 120) : m.body
|
|
76
76
|
}),
|
|
77
77
|
m.topic && /* @__PURE__ */ f("div", {
|
|
78
|
-
className: "mt-2 inline-flex items-center rounded-full bg-
|
|
78
|
+
className: "mt-2 inline-flex items-center rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary",
|
|
79
79
|
children: m.topic.name
|
|
80
80
|
})
|
|
81
81
|
]
|
|
@@ -84,7 +84,7 @@ function m({ notification: m, onMarkAsRead: h, onArchive: g, onAction: _, onClic
|
|
|
84
84
|
className: "ml-3 flex flex-wrap gap-2",
|
|
85
85
|
children: m.actions.map((e) => /* @__PURE__ */ f("button", {
|
|
86
86
|
onClick: (t) => k(t, e.id, e.url),
|
|
87
|
-
className: `rounded-md px-3 py-1.5 text-xs font-medium transition-colors ${e.style === "secondary" ? "bg-
|
|
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"}`,
|
|
88
88
|
children: e.label
|
|
89
89
|
}, e.id))
|
|
90
90
|
}),
|
|
@@ -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-all duration-200 ease-in-out\n ${isUnread ? 'bg-accent-subtle/5 border-accent-primary/20 shadow-sm ring-1 ring-accent-primary/10' : 'bg-surface border-default opacity-75'}\n ${showArchivedState && isArchived ? 'border-dashed opacity-60' : ''}\n hover:bg-
|
|
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-all duration-200 ease-in-out\n ${isUnread ? 'bg-accent-subtle/5 border-accent-primary/20 shadow-sm ring-1 ring-accent-primary/10' : 'bg-surface border-default opacity-75'}\n ${showArchivedState && isArchived ? 'border-dashed opacity-60' : ''}\n hover:bg-bg-sunken hover:shadow-md 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":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A,UAAA,CACE,kBAAC,QAAD,EAAA,UAAM,KAAQ,CAAA,EACd,kBAAC,QAAD,EAAA,UAAO,EAAG,wBAAwB,WAAW,EAAQ,CAAA,CACpD,EAAA,CAAA;MAEL,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"}
|
|
@@ -45,7 +45,7 @@ function l({ onViewAll: l }) {
|
|
|
45
45
|
children: u("notifCommon.markAllRead", "Mark all read")
|
|
46
46
|
}), /* @__PURE__ */ s("button", {
|
|
47
47
|
onClick: f,
|
|
48
|
-
className: "p-1 hover:bg-
|
|
48
|
+
className: "p-1 hover:bg-bg-sunken rounded transition-colors duration-150",
|
|
49
49
|
"aria-label": u("notifCommon.closePanel", "Close panel"),
|
|
50
50
|
children: /* @__PURE__ */ s(a, {
|
|
51
51
|
size: 16,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationPanel.js","names":[],"sources":["../../src/components/NotificationPanel.tsx"],"sourcesContent":["import { X, Bell } from 'lucide-react';\nimport { useNotificationStore } from '../store/notificationStore';\nimport { useNotifications } from '../hooks';\nimport { NotificationCard } from './NotificationCard';\nimport { useTr } from '../shared/hooks/useTr';\n\ninterface NotificationPanelProps {\n onViewAll?: () => void;\n}\n\n/**\n * Notification dropdown panel\n *\n * Quick view of recent notifications that appears when clicking the bell icon\n */\nexport function NotificationPanel({ onViewAll }: NotificationPanelProps) {\n const tr = useTr();\n const { isPanelOpen, togglePanel } = useNotificationStore();\n const {\n notifications,\n unreadCount,\n markAsRead,\n markAllAsRead,\n archiveNotification,\n recordAction,\n } = useNotifications();\n\n if (!isPanelOpen) return null;\n\n // Show only the 5 most recent notifications\n const recentNotifications = notifications.slice(0, 5);\n\n return (\n <>\n {/* Backdrop */}\n <div className=\"fixed inset-0 z-40\" onClick={togglePanel} aria-hidden=\"true\" />\n\n {/* Panel */}\n <div\n data-tour=\"notification-panel\"\n className=\"absolute right-0 top-full mt-2 w-96 max-h-[600px] bg-surface border border-default rounded-lg shadow-lg z-50 overflow-hidden flex flex-col animate-in fade-in slide-in-from-top-2 duration-200\"\n >\n {/* Header */}\n <div className=\"flex items-center justify-between p-4 border-b border-default\">\n <div className=\"flex items-center gap-2\">\n <Bell size={20} className=\"text-primary\" />\n <h2 className=\"text-base font-semibold text-primary\">\n {tr('notifCommon.notifications', 'Notifications')}\n </h2>\n {unreadCount > 0 && (\n <span className=\"px-2 py-0.5 text-xs font-semibold text-white bg-primary-500 rounded-full\">\n {unreadCount}\n </span>\n )}\n </div>\n\n <div className=\"flex items-center gap-2\">\n {unreadCount > 0 && (\n <button\n data-tour=\"notification-panel-mark-all-read\"\n onClick={markAllAsRead}\n className=\"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors duration-150\"\n >\n {tr('notifCommon.markAllRead', 'Mark all read')}\n </button>\n )}\n <button\n onClick={togglePanel}\n className=\"p-1 hover:bg-
|
|
1
|
+
{"version":3,"file":"NotificationPanel.js","names":[],"sources":["../../src/components/NotificationPanel.tsx"],"sourcesContent":["import { X, Bell } from 'lucide-react';\nimport { useNotificationStore } from '../store/notificationStore';\nimport { useNotifications } from '../hooks';\nimport { NotificationCard } from './NotificationCard';\nimport { useTr } from '../shared/hooks/useTr';\n\ninterface NotificationPanelProps {\n onViewAll?: () => void;\n}\n\n/**\n * Notification dropdown panel\n *\n * Quick view of recent notifications that appears when clicking the bell icon\n */\nexport function NotificationPanel({ onViewAll }: NotificationPanelProps) {\n const tr = useTr();\n const { isPanelOpen, togglePanel } = useNotificationStore();\n const {\n notifications,\n unreadCount,\n markAsRead,\n markAllAsRead,\n archiveNotification,\n recordAction,\n } = useNotifications();\n\n if (!isPanelOpen) return null;\n\n // Show only the 5 most recent notifications\n const recentNotifications = notifications.slice(0, 5);\n\n return (\n <>\n {/* Backdrop */}\n <div className=\"fixed inset-0 z-40\" onClick={togglePanel} aria-hidden=\"true\" />\n\n {/* Panel */}\n <div\n data-tour=\"notification-panel\"\n className=\"absolute right-0 top-full mt-2 w-96 max-h-[600px] bg-surface border border-default rounded-lg shadow-lg z-50 overflow-hidden flex flex-col animate-in fade-in slide-in-from-top-2 duration-200\"\n >\n {/* Header */}\n <div className=\"flex items-center justify-between p-4 border-b border-default\">\n <div className=\"flex items-center gap-2\">\n <Bell size={20} className=\"text-primary\" />\n <h2 className=\"text-base font-semibold text-primary\">\n {tr('notifCommon.notifications', 'Notifications')}\n </h2>\n {unreadCount > 0 && (\n <span className=\"px-2 py-0.5 text-xs font-semibold text-white bg-primary-500 rounded-full\">\n {unreadCount}\n </span>\n )}\n </div>\n\n <div className=\"flex items-center gap-2\">\n {unreadCount > 0 && (\n <button\n data-tour=\"notification-panel-mark-all-read\"\n onClick={markAllAsRead}\n className=\"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors duration-150\"\n >\n {tr('notifCommon.markAllRead', 'Mark all read')}\n </button>\n )}\n <button\n onClick={togglePanel}\n className=\"p-1 hover:bg-bg-sunken rounded transition-colors duration-150\"\n aria-label={tr('notifCommon.closePanel', 'Close panel')}\n >\n <X size={16} className=\"text-tertiary\" />\n </button>\n </div>\n </div>\n\n {/* Notifications list */}\n <div className=\"flex-1 overflow-y-auto\">\n {recentNotifications.length > 0 ? (\n <div className=\"flex flex-col gap-2 p-2\">\n {recentNotifications.map((notification) => (\n <NotificationCard\n key={notification.id}\n notification={notification}\n onMarkAsRead={markAsRead}\n onArchive={archiveNotification}\n onAction={recordAction}\n compact\n analyticsSource=\"panel\"\n />\n ))}\n </div>\n ) : (\n <div className=\"flex flex-col items-center justify-center p-8 text-center animate-in fade-in duration-300\">\n <Bell size={48} className=\"text-tertiary mb-4\" />\n <p className=\"text-sm text-secondary\">\n {tr('notifCommon.noNotifications', 'No notifications')}\n </p>\n <p className=\"text-xs text-tertiary mt-1\">\n {tr('notifCommon.allCaughtUp', \"You're all caught up!\")}\n </p>\n </div>\n )}\n </div>\n\n {/* Footer */}\n {recentNotifications.length > 0 && (\n <div className=\"p-3 border-t border-default\">\n <button\n data-tour=\"notification-panel-view-all\"\n onClick={() => {\n togglePanel();\n if (onViewAll) onViewAll();\n }}\n className=\"w-full py-2 text-sm text-accent-primary hover:text-accent-primary/80 font-medium transition-colors duration-150\"\n >\n {tr('notifCommon.viewAllNotifications', 'View All Notifications')}\n </button>\n </div>\n )}\n </div>\n </>\n );\n}\n"],"mappings":";;;;;;;;AAeA,SAAgB,EAAkB,EAAE,gBAAqC;CACvE,IAAM,IAAK,GAAO,EACZ,EAAE,gBAAa,mBAAgB,GAAsB,EACrD,EACJ,kBACA,gBACA,eACA,kBACA,wBACA,oBACE,GAAkB;AAEtB,KAAI,CAAC,EAAa,QAAO;CAGzB,IAAM,IAAsB,EAAc,MAAM,GAAG,EAAE;AAErD,QACE,kBAAA,GAAA,EAAA,UAAA,CAEE,kBAAC,OAAD;EAAK,WAAU;EAAqB,SAAS;EAAa,eAAY;EAAS,CAAA,EAG/E,kBAAC,OAAD;EACE,aAAU;EACV,WAAU;YAFZ;GAKE,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,OAAD;KAAK,WAAU;eAAf;MACE,kBAAC,GAAD;OAAM,MAAM;OAAI,WAAU;OAAiB,CAAA;MAC3C,kBAAC,MAAD;OAAI,WAAU;iBACX,EAAG,6BAA6B,gBAAgB;OAC9C,CAAA;MACJ,IAAc,KACb,kBAAC,QAAD;OAAM,WAAU;iBACb;OACI,CAAA;MAEL;QAEN,kBAAC,OAAD;KAAK,WAAU;eAAf,CACG,IAAc,KACb,kBAAC,UAAD;MACE,aAAU;MACV,SAAS;MACT,WAAU;gBAET,EAAG,2BAA2B,gBAAgB;MACxC,CAAA,EAEX,kBAAC,UAAD;MACE,SAAS;MACT,WAAU;MACV,cAAY,EAAG,0BAA0B,cAAc;gBAEvD,kBAAC,GAAD;OAAG,MAAM;OAAI,WAAU;OAAkB,CAAA;MAClC,CAAA,CACL;OACF;;GAGN,kBAAC,OAAD;IAAK,WAAU;cACZ,EAAoB,SAAS,IAC5B,kBAAC,OAAD;KAAK,WAAU;eACZ,EAAoB,KAAK,MACxB,kBAAC,GAAD;MAEgB;MACd,cAAc;MACd,WAAW;MACX,UAAU;MACV,SAAA;MACA,iBAAgB;MAChB,EAPK,EAAa,GAOlB,CACF;KACE,CAAA,GAEN,kBAAC,OAAD;KAAK,WAAU;eAAf;MACE,kBAAC,GAAD;OAAM,MAAM;OAAI,WAAU;OAAuB,CAAA;MACjD,kBAAC,KAAD;OAAG,WAAU;iBACV,EAAG,+BAA+B,mBAAmB;OACpD,CAAA;MACJ,kBAAC,KAAD;OAAG,WAAU;iBACV,EAAG,2BAA2B,wBAAwB;OACrD,CAAA;MACA;;IAEJ,CAAA;GAGL,EAAoB,SAAS,KAC5B,kBAAC,OAAD;IAAK,WAAU;cACb,kBAAC,UAAD;KACE,aAAU;KACV,eAAe;AAEb,MADA,GAAa,EACT,KAAW,GAAW;;KAE5B,WAAU;eAET,EAAG,oCAAoC,yBAAyB;KAC1D,CAAA;IACL,CAAA;GAEJ;IACL,EAAA,CAAA"}
|
|
@@ -19,7 +19,7 @@ function p(e) {
|
|
|
19
19
|
});
|
|
20
20
|
default: return /* @__PURE__ */ d(l, {
|
|
21
21
|
size: 14,
|
|
22
|
-
className: "text-
|
|
22
|
+
className: "text-text-secondary"
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -125,18 +125,18 @@ function _({ recipients: o, onChange: s, channel: l, placeholder: _, disabled: v
|
|
|
125
125
|
className: `
|
|
126
126
|
relative flex flex-wrap items-center gap-2 p-2 min-h-[42px]
|
|
127
127
|
bg-surface border rounded-lg transition-colors
|
|
128
|
-
${E ? "border-primary-500 ring-1 ring-primary-500" : "border-border"}
|
|
129
|
-
${v ? "opacity-50 cursor-not-allowed bg-
|
|
128
|
+
${E ? "border-primary-500 ring-1 ring-primary-500" : "border-border-subtle"}
|
|
129
|
+
${v ? "opacity-50 cursor-not-allowed bg-bg-sunken" : ""}
|
|
130
130
|
${b || w ? "border-error-500" : ""}
|
|
131
131
|
`,
|
|
132
132
|
onClick: () => O.current?.focus(),
|
|
133
133
|
children: [
|
|
134
134
|
o.map((e) => /* @__PURE__ */ f("div", {
|
|
135
|
-
className: "flex items-center gap-1.5 px-2 py-1 bg-surface-elevated border border-border rounded-full text-sm",
|
|
135
|
+
className: "flex items-center gap-1.5 px-2 py-1 bg-surface-elevated border border-border-subtle rounded-full text-sm",
|
|
136
136
|
children: [
|
|
137
137
|
p(e.type),
|
|
138
138
|
/* @__PURE__ */ d("span", {
|
|
139
|
-
className: "text-
|
|
139
|
+
className: "text-text-primary max-w-[200px] truncate",
|
|
140
140
|
children: e.displayName
|
|
141
141
|
}),
|
|
142
142
|
!v && /* @__PURE__ */ d("button", {
|
|
@@ -148,7 +148,7 @@ function _({ recipients: o, onChange: s, channel: l, placeholder: _, disabled: v
|
|
|
148
148
|
"aria-label": x("notifCommon.removeRecipient", "Remove {{name}}").replace("{{name}}", e.displayName),
|
|
149
149
|
children: /* @__PURE__ */ d(u, {
|
|
150
150
|
size: 12,
|
|
151
|
-
className: "text-
|
|
151
|
+
className: "text-text-secondary"
|
|
152
152
|
})
|
|
153
153
|
})
|
|
154
154
|
]
|
|
@@ -172,7 +172,7 @@ function _({ recipients: o, onChange: s, channel: l, placeholder: _, disabled: v
|
|
|
172
172
|
D(!1), S.trim() && j(S);
|
|
173
173
|
},
|
|
174
174
|
placeholder: o.length === 0 ? A : x("notifCommon.addMore", "Add more..."),
|
|
175
|
-
className: "flex-1 min-w-[150px] bg-transparent border-none outline-none text-sm text-
|
|
175
|
+
className: "flex-1 min-w-[150px] bg-transparent border-none outline-none text-sm text-text-primary placeholder:text-text-secondary",
|
|
176
176
|
disabled: v
|
|
177
177
|
}),
|
|
178
178
|
!v && S.trim() && /* @__PURE__ */ d("button", {
|
|
@@ -189,7 +189,7 @@ function _({ recipients: o, onChange: s, channel: l, placeholder: _, disabled: v
|
|
|
189
189
|
children: [/* @__PURE__ */ d(a, { size: 14 }), /* @__PURE__ */ d("span", { children: b || w })]
|
|
190
190
|
}),
|
|
191
191
|
/* @__PURE__ */ f("div", {
|
|
192
|
-
className: "flex items-center justify-between text-xs text-
|
|
192
|
+
className: "flex items-center justify-between text-xs text-text-secondary",
|
|
193
193
|
children: [/* @__PURE__ */ f("span", { children: [
|
|
194
194
|
l === "EMAIL" && x("notifCommon.emailHelperText", "Enter email addresses. Press Enter or comma to add multiple."),
|
|
195
195
|
(l === "SMS" || l === "WHATSAPP") && x("notifCommon.phoneHelperText", "Enter phone numbers with country code (e.g., +1234567890)."),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecipientSelector.js","names":[],"sources":["../../src/components/RecipientSelector.tsx"],"sourcesContent":["import { useState, useCallback, useRef, useEffect } from 'react';\nimport { X, Plus, Mail, Phone, User, Users, AlertCircle } from 'lucide-react';\nimport type { RecipientInput, NotificationChannelType } from '../hooks/useSendNotification';\nimport { useTr } from '../shared/hooks/useTr';\n\n/**\n * Recipient with display info\n */\nexport interface Recipient extends RecipientInput {\n id: string;\n displayName: string;\n type: 'email' | 'phone' | 'user' | 'manual';\n}\n\ninterface RecipientSelectorProps {\n recipients: Recipient[];\n onChange: (recipients: Recipient[]) => void;\n channel: NotificationChannelType;\n placeholder?: string;\n disabled?: boolean;\n maxRecipients?: number;\n error?: string;\n}\n\n/**\n * Get icon for recipient type\n */\nfunction getRecipientIcon(type: Recipient['type']) {\n switch (type) {\n case 'email':\n return <Mail size={14} className=\"text-status-info-text\" />;\n case 'phone':\n return <Phone size={14} className=\"text-status-success-text\" />;\n case 'user':\n return <User size={14} className=\"text-accent-purple\" />;\n default:\n return <User size={14} className=\"text-muted-foreground\" />;\n }\n}\n\n/**\n * Validate email format\n */\nfunction isValidEmail(email: string): boolean {\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n return emailRegex.test(email);\n}\n\n/**\n * Validate phone format (basic validation)\n */\nfunction isValidPhone(phone: string): boolean {\n const phoneRegex = /^\\+?[1-9]\\d{6,14}$/;\n return phoneRegex.test(phone.replace(/[\\s\\-\\(\\)]/g, ''));\n}\n\n/**\n * Generate unique ID\n */\nfunction generateId(): string {\n return `recipient-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;\n}\n\n/**\n * RecipientSelector component\n *\n * Allows selecting multiple recipients for notifications.\n * Supports email, phone, and manual input based on channel type.\n */\nexport function RecipientSelector({\n recipients,\n onChange,\n channel,\n placeholder,\n disabled = false,\n maxRecipients = 100,\n error,\n}: RecipientSelectorProps) {\n const tr = useTr();\n const [inputValue, setInputValue] = useState('');\n const [inputError, setInputError] = useState<string | null>(null);\n const [isFocused, setIsFocused] = useState(false);\n const inputRef = useRef<HTMLInputElement>(null);\n\n // Determine input type based on channel\n const inputType =\n channel === 'EMAIL' ? 'email' : channel === 'SMS' || channel === 'WHATSAPP' ? 'phone' : 'text';\n const inputPlaceholder =\n placeholder ||\n (channel === 'EMAIL'\n ? tr('notifCommon.enterEmailPlaceholder', 'Enter email address...')\n : channel === 'SMS' || channel === 'WHATSAPP'\n ? tr('notifCommon.enterPhonePlaceholder', 'Enter phone number (e.g., +1234567890)...')\n : channel === 'PUSH'\n ? tr('notifCommon.enterDeviceTokenPlaceholder', 'Enter device token...')\n : channel === 'SLACK'\n ? tr('notifCommon.enterSlackIdPlaceholder', 'Enter Slack user ID...')\n : channel === 'TEAMS'\n ? tr('notifCommon.enterTeamsIdPlaceholder', 'Enter Teams user ID...')\n : tr('notifCommon.enterRecipientPlaceholder', 'Enter recipient...'));\n\n // Clear input error when input changes\n useEffect(() => {\n if (inputValue) {\n setInputError(null);\n }\n }, [inputValue]);\n\n /**\n * Add a recipient\n */\n const addRecipient = useCallback(\n (value: string) => {\n const trimmedValue = value.trim();\n if (!trimmedValue) return;\n\n // Check max recipients\n if (recipients.length >= maxRecipients) {\n setInputError(\n tr('notifCommon.maxRecipientsAllowed', `Maximum ${maxRecipients} recipients allowed`)\n );\n return;\n }\n\n // Check for duplicates\n const isDuplicate = recipients.some((r) => {\n if (channel === 'EMAIL') return r.email === trimmedValue;\n if (channel === 'SMS' || channel === 'WHATSAPP')\n return r.phoneNumber === trimmedValue || r.whatsappNumber === trimmedValue;\n return false;\n });\n\n if (isDuplicate) {\n setInputError(\n tr('notifCommon.duplicateRecipient', 'This recipient has already been added')\n );\n return;\n }\n\n // Validate based on channel\n let recipient: Recipient | null = null;\n\n if (channel === 'EMAIL') {\n if (!isValidEmail(trimmedValue)) {\n setInputError(tr('notifCommon.invalidEmail', 'Please enter a valid email address'));\n return;\n }\n recipient = {\n id: generateId(),\n email: trimmedValue,\n displayName: trimmedValue,\n type: 'email',\n };\n } else if (channel === 'SMS') {\n if (!isValidPhone(trimmedValue)) {\n setInputError(\n tr('notifCommon.invalidPhone', 'Please enter a valid phone number (e.g., +1234567890)')\n );\n return;\n }\n recipient = {\n id: generateId(),\n phoneNumber: trimmedValue,\n displayName: trimmedValue,\n type: 'phone',\n };\n } else if (channel === 'WHATSAPP') {\n if (!isValidPhone(trimmedValue)) {\n setInputError(\n tr(\n 'notifCommon.invalidWhatsApp',\n 'Please enter a valid WhatsApp number (e.g., +1234567890)'\n )\n );\n return;\n }\n recipient = {\n id: generateId(),\n whatsappNumber: trimmedValue,\n displayName: trimmedValue,\n type: 'phone',\n };\n } else if (channel === 'PUSH') {\n recipient = {\n id: generateId(),\n pushToken: trimmedValue,\n displayName: trimmedValue.substring(0, 20) + '...',\n type: 'manual',\n };\n } else if (channel === 'SLACK') {\n recipient = {\n id: generateId(),\n slackUserId: trimmedValue,\n displayName: trimmedValue,\n type: 'user',\n };\n } else if (channel === 'TEAMS') {\n recipient = {\n id: generateId(),\n teamsUserId: trimmedValue,\n displayName: trimmedValue,\n type: 'user',\n };\n } else if (channel === 'WEBHOOK') {\n recipient = {\n id: generateId(),\n webhookUrl: trimmedValue,\n displayName: trimmedValue,\n type: 'manual',\n };\n } else {\n // Other channels - use userId\n recipient = {\n id: generateId(),\n userId: trimmedValue,\n displayName: trimmedValue,\n type: 'user',\n };\n }\n\n if (recipient) {\n onChange([...recipients, recipient]);\n setInputValue('');\n setInputError(null);\n }\n },\n [recipients, onChange, channel, maxRecipients, tr]\n );\n\n /**\n * Remove a recipient\n */\n const removeRecipient = useCallback(\n (id: string) => {\n onChange(recipients.filter((r) => r.id !== id));\n },\n [recipients, onChange]\n );\n\n /**\n * Handle key down\n */\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter' || e.key === ',') {\n e.preventDefault();\n addRecipient(inputValue);\n } else if (e.key === 'Backspace' && !inputValue && recipients.length > 0) {\n // Remove last recipient on backspace when input is empty\n removeRecipient(recipients[recipients.length - 1].id);\n }\n };\n\n /**\n * Handle paste (for bulk adding)\n */\n const handlePaste = (e: React.ClipboardEvent<HTMLInputElement>) => {\n const pastedText = e.clipboardData.getData('text');\n\n // Check if pasted text contains multiple values (comma or newline separated)\n if (pastedText.includes(',') || pastedText.includes('\\n')) {\n e.preventDefault();\n const values = pastedText\n .split(/[,\\n]/)\n .map((v) => v.trim())\n .filter(Boolean);\n\n values.forEach((value) => {\n addRecipient(value);\n });\n }\n };\n\n return (\n <div className=\"space-y-2\">\n {/* Input container */}\n <div\n className={`\n relative flex flex-wrap items-center gap-2 p-2 min-h-[42px]\n bg-surface border rounded-lg transition-colors\n ${isFocused ? 'border-primary-500 ring-1 ring-primary-500' : 'border-border'}\n ${disabled ? 'opacity-50 cursor-not-allowed bg-muted' : ''}\n ${error || inputError ? 'border-error-500' : ''}\n `}\n onClick={() => inputRef.current?.focus()}\n >\n {/* Selected recipients */}\n {recipients.map((recipient) => (\n <div\n key={recipient.id}\n className=\"flex items-center gap-1.5 px-2 py-1 bg-surface-elevated border border-border rounded-full text-sm\"\n >\n {getRecipientIcon(recipient.type)}\n <span className=\"text-foreground max-w-[200px] truncate\">{recipient.displayName}</span>\n {!disabled && (\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation();\n removeRecipient(recipient.id);\n }}\n className=\"p-0.5 hover:bg-surface-hover rounded-full transition-colors\"\n aria-label={tr('notifCommon.removeRecipient', 'Remove {{name}}').replace(\n '{{name}}',\n recipient.displayName\n )}\n >\n <X size={12} className=\"text-muted-foreground\" />\n </button>\n )}\n </div>\n ))}\n\n {/* Input */}\n {!disabled && recipients.length < maxRecipients && (\n <input\n ref={inputRef}\n type={inputType}\n value={inputValue}\n onChange={(e) => setInputValue(e.target.value)}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n onFocus={() => setIsFocused(true)}\n onBlur={() => {\n setIsFocused(false);\n if (inputValue.trim()) {\n addRecipient(inputValue);\n }\n }}\n placeholder={\n recipients.length === 0 ? inputPlaceholder : tr('notifCommon.addMore', 'Add more...')\n }\n className=\"flex-1 min-w-[150px] bg-transparent border-none outline-none text-sm text-foreground placeholder:text-muted-foreground\"\n disabled={disabled}\n />\n )}\n\n {/* Add button for clarity */}\n {!disabled && inputValue.trim() && (\n <button\n type=\"button\"\n onClick={() => addRecipient(inputValue)}\n className=\"p-1 text-primary-500 hover:bg-primary-100 rounded transition-colors\"\n aria-label={tr('notifCommon.addRecipient', 'Add recipient')}\n >\n <Plus size={16} />\n </button>\n )}\n </div>\n\n {/* Error message */}\n {(error || inputError) && (\n <div className=\"flex items-center gap-1.5 text-error-500 text-sm\">\n <AlertCircle size={14} />\n <span>{error || inputError}</span>\n </div>\n )}\n\n {/* Helper text */}\n <div className=\"flex items-center justify-between text-xs text-muted-foreground\">\n <span>\n {channel === 'EMAIL' &&\n tr(\n 'notifCommon.emailHelperText',\n 'Enter email addresses. Press Enter or comma to add multiple.'\n )}\n {(channel === 'SMS' || channel === 'WHATSAPP') &&\n tr(\n 'notifCommon.phoneHelperText',\n 'Enter phone numbers with country code (e.g., +1234567890).'\n )}\n\n {channel === 'PUSH' &&\n tr('notifCommon.pushHelperText', 'Enter device tokens for push notifications.')}\n {channel === 'SLACK' && tr('notifCommon.slackHelperText', 'Enter Slack user IDs.')}\n {channel === 'TEAMS' &&\n tr('notifCommon.teamsHelperText', 'Enter Microsoft Teams user IDs.')}\n {channel === 'WEBHOOK' && tr('notifCommon.webhookHelperText', 'Enter webhook URLs.')}\n </span>\n <span>\n {recipients.length} / {maxRecipients}\n </span>\n </div>\n </div>\n );\n}\n\n/**\n * Compact recipient display for read-only views\n */\nexport function RecipientList({ recipients }: { recipients: Recipient[] }) {\n const tr = useTr();\n\n if (recipients.length === 0) {\n return (\n <span className=\"text-muted-foreground text-sm\">\n {tr('notifCommon.noRecipients', 'No recipients')}\n </span>\n );\n }\n\n return (\n <div className=\"flex flex-wrap items-center gap-1.5\">\n {recipients.slice(0, 5).map((recipient) => (\n <div\n key={recipient.id}\n className=\"flex items-center gap-1 px-2 py-0.5 bg-surface-elevated border border-border rounded-full text-xs\"\n >\n {getRecipientIcon(recipient.type)}\n <span className=\"text-foreground max-w-[150px] truncate\">{recipient.displayName}</span>\n </div>\n ))}\n {recipients.length > 5 && (\n <span className=\"flex items-center gap-1 px-2 py-0.5 bg-muted text-muted-foreground rounded-full text-xs\">\n <Users size={12} />+{recipients.length - 5} {tr('notifCommon.more', 'more')}\n </span>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;AA2BA,SAAS,EAAiB,GAAyB;AACjD,SAAQ,GAAR;EACE,KAAK,QACH,QAAO,kBAAC,GAAD;GAAM,MAAM;GAAI,WAAU;GAA0B,CAAA;EAC7D,KAAK,QACH,QAAO,kBAAC,GAAD;GAAO,MAAM;GAAI,WAAU;GAA6B,CAAA;EACjE,KAAK,OACH,QAAO,kBAAC,GAAD;GAAM,MA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,CAEX,SAAS,MAAU;AACxB,UAAa,EAAM;SACnB;;MAqDI,eAAe,EAAa,GAAK;MACjC,cAAc;AAEZ,OADA,EAAa,GAAM,EACf,EAAW,MAAM,IACnB,EAAa,EAAW;;MAG5B,aACE,EAAW,WAAW,IAAI,IAAmB,EAAG,uBAAuB,cAAc;MAEvF,WAAU;MACA;MACV,CAAA;KAIH,CAAC,KAAY,EAAW,MAAM,IAC7B,kBAAC,UAAD;MACE,MAAK;MACL,eAAe,EAAa,EAAW;MACvC,WAAU;MACV,cAAY,EAAG,4BAA4B,gBAAgB;gBAE3D,kBAAC,GAAD,EAAM,MAAM,IAAM,CAAA;MACX,CAAA;KAEP;;IAGJ,KAAS,MACT,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,GAAD,EAAa,MAAM,IAAM,CAAA,EACzB,kBAAC,QAAD,EAAA,UAAO,KAAS,GAAkB,CAAA,CAC9B;;GAIR,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,QAAD,EAAA,UAAA;KACG,MAAY,WACX,EACE,+BACA,+DACD;MACD,MAAY,SAAS,MAAY,eACjC,EACE,+BACA,6DACD;KAEF,MAAY,UACX,EAAG,8BAA8B,8CAA8C;KAChF,MAAY,WAAW,EAAG,+BAA+B,wBAAwB;KACjF,MAAY,WACX,EAAG,+BAA+B,kCAAkC;KACrE,MAAY,aAAa,EAAG,iCAAiC,sBAAsB;KAC/E,EAAA,CAAA,EACP,kBAAC,QAAD,EAAA,UAAA;KACG,EAAW;KAAO;KAAI;KAClB,EAAA,CAAA,CACH;;GACF"}
|
|
1
|
+
{"version":3,"file":"RecipientSelector.js","names":[],"sources":["../../src/components/RecipientSelector.tsx"],"sourcesContent":["import { useState, useCallback, useRef, useEffect } from 'react';\nimport { X, Plus, Mail, Phone, User, Users, AlertCircle } from 'lucide-react';\nimport type { RecipientInput, NotificationChannelType } from '../hooks/useSendNotification';\nimport { useTr } from '../shared/hooks/useTr';\n\n/**\n * Recipient with display info\n */\nexport interface Recipient extends RecipientInput {\n id: string;\n displayName: string;\n type: 'email' | 'phone' | 'user' | 'manual';\n}\n\ninterface RecipientSelectorProps {\n recipients: Recipient[];\n onChange: (recipients: Recipient[]) => void;\n channel: NotificationChannelType;\n placeholder?: string;\n disabled?: boolean;\n maxRecipients?: number;\n error?: string;\n}\n\n/**\n * Get icon for recipient type\n */\nfunction getRecipientIcon(type: Recipient['type']) {\n switch (type) {\n case 'email':\n return <Mail size={14} className=\"text-status-info-text\" />;\n case 'phone':\n return <Phone size={14} className=\"text-status-success-text\" />;\n case 'user':\n return <User size={14} className=\"text-accent-purple\" />;\n default:\n return <User size={14} className=\"text-text-secondary\" />;\n }\n}\n\n/**\n * Validate email format\n */\nfunction isValidEmail(email: string): boolean {\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n return emailRegex.test(email);\n}\n\n/**\n * Validate phone format (basic validation)\n */\nfunction isValidPhone(phone: string): boolean {\n const phoneRegex = /^\\+?[1-9]\\d{6,14}$/;\n return phoneRegex.test(phone.replace(/[\\s\\-\\(\\)]/g, ''));\n}\n\n/**\n * Generate unique ID\n */\nfunction generateId(): string {\n return `recipient-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;\n}\n\n/**\n * RecipientSelector component\n *\n * Allows selecting multiple recipients for notifications.\n * Supports email, phone, and manual input based on channel type.\n */\nexport function RecipientSelector({\n recipients,\n onChange,\n channel,\n placeholder,\n disabled = false,\n maxRecipients = 100,\n error,\n}: RecipientSelectorProps) {\n const tr = useTr();\n const [inputValue, setInputValue] = useState('');\n const [inputError, setInputError] = useState<string | null>(null);\n const [isFocused, setIsFocused] = useState(false);\n const inputRef = useRef<HTMLInputElement>(null);\n\n // Determine input type based on channel\n const inputType =\n channel === 'EMAIL' ? 'email' : channel === 'SMS' || channel === 'WHATSAPP' ? 'phone' : 'text';\n const inputPlaceholder =\n placeholder ||\n (channel === 'EMAIL'\n ? tr('notifCommon.enterEmailPlaceholder', 'Enter email address...')\n : channel === 'SMS' || channel === 'WHATSAPP'\n ? tr('notifCommon.enterPhonePlaceholder', 'Enter phone number (e.g., +1234567890)...')\n : channel === 'PUSH'\n ? tr('notifCommon.enterDeviceTokenPlaceholder', 'Enter device token...')\n : channel === 'SLACK'\n ? tr('notifCommon.enterSlackIdPlaceholder', 'Enter Slack user ID...')\n : channel === 'TEAMS'\n ? tr('notifCommon.enterTeamsIdPlaceholder', 'Enter Teams user ID...')\n : tr('notifCommon.enterRecipientPlaceholder', 'Enter recipient...'));\n\n // Clear input error when input changes\n useEffect(() => {\n if (inputValue) {\n setInputError(null);\n }\n }, [inputValue]);\n\n /**\n * Add a recipient\n */\n const addRecipient = useCallback(\n (value: string) => {\n const trimmedValue = value.trim();\n if (!trimmedValue) return;\n\n // Check max recipients\n if (recipients.length >= maxRecipients) {\n setInputError(\n tr('notifCommon.maxRecipientsAllowed', `Maximum ${maxRecipients} recipients allowed`)\n );\n return;\n }\n\n // Check for duplicates\n const isDuplicate = recipients.some((r) => {\n if (channel === 'EMAIL') return r.email === trimmedValue;\n if (channel === 'SMS' || channel === 'WHATSAPP')\n return r.phoneNumber === trimmedValue || r.whatsappNumber === trimmedValue;\n return false;\n });\n\n if (isDuplicate) {\n setInputError(\n tr('notifCommon.duplicateRecipient', 'This recipient has already been added')\n );\n return;\n }\n\n // Validate based on channel\n let recipient: Recipient | null = null;\n\n if (channel === 'EMAIL') {\n if (!isValidEmail(trimmedValue)) {\n setInputError(tr('notifCommon.invalidEmail', 'Please enter a valid email address'));\n return;\n }\n recipient = {\n id: generateId(),\n email: trimmedValue,\n displayName: trimmedValue,\n type: 'email',\n };\n } else if (channel === 'SMS') {\n if (!isValidPhone(trimmedValue)) {\n setInputError(\n tr('notifCommon.invalidPhone', 'Please enter a valid phone number (e.g., +1234567890)')\n );\n return;\n }\n recipient = {\n id: generateId(),\n phoneNumber: trimmedValue,\n displayName: trimmedValue,\n type: 'phone',\n };\n } else if (channel === 'WHATSAPP') {\n if (!isValidPhone(trimmedValue)) {\n setInputError(\n tr(\n 'notifCommon.invalidWhatsApp',\n 'Please enter a valid WhatsApp number (e.g., +1234567890)'\n )\n );\n return;\n }\n recipient = {\n id: generateId(),\n whatsappNumber: trimmedValue,\n displayName: trimmedValue,\n type: 'phone',\n };\n } else if (channel === 'PUSH') {\n recipient = {\n id: generateId(),\n pushToken: trimmedValue,\n displayName: trimmedValue.substring(0, 20) + '...',\n type: 'manual',\n };\n } else if (channel === 'SLACK') {\n recipient = {\n id: generateId(),\n slackUserId: trimmedValue,\n displayName: trimmedValue,\n type: 'user',\n };\n } else if (channel === 'TEAMS') {\n recipient = {\n id: generateId(),\n teamsUserId: trimmedValue,\n displayName: trimmedValue,\n type: 'user',\n };\n } else if (channel === 'WEBHOOK') {\n recipient = {\n id: generateId(),\n webhookUrl: trimmedValue,\n displayName: trimmedValue,\n type: 'manual',\n };\n } else {\n // Other channels - use userId\n recipient = {\n id: generateId(),\n userId: trimmedValue,\n displayName: trimmedValue,\n type: 'user',\n };\n }\n\n if (recipient) {\n onChange([...recipients, recipient]);\n setInputValue('');\n setInputError(null);\n }\n },\n [recipients, onChange, channel, maxRecipients, tr]\n );\n\n /**\n * Remove a recipient\n */\n const removeRecipient = useCallback(\n (id: string) => {\n onChange(recipients.filter((r) => r.id !== id));\n },\n [recipients, onChange]\n );\n\n /**\n * Handle key down\n */\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter' || e.key === ',') {\n e.preventDefault();\n addRecipient(inputValue);\n } else if (e.key === 'Backspace' && !inputValue && recipients.length > 0) {\n // Remove last recipient on backspace when input is empty\n removeRecipient(recipients[recipients.length - 1].id);\n }\n };\n\n /**\n * Handle paste (for bulk adding)\n */\n const handlePaste = (e: React.ClipboardEvent<HTMLInputElement>) => {\n const pastedText = e.clipboardData.getData('text');\n\n // Check if pasted text contains multiple values (comma or newline separated)\n if (pastedText.includes(',') || pastedText.includes('\\n')) {\n e.preventDefault();\n const values = pastedText\n .split(/[,\\n]/)\n .map((v) => v.trim())\n .filter(Boolean);\n\n values.forEach((value) => {\n addRecipient(value);\n });\n }\n };\n\n return (\n <div className=\"space-y-2\">\n {/* Input container */}\n <div\n className={`\n relative flex flex-wrap items-center gap-2 p-2 min-h-[42px]\n bg-surface border rounded-lg transition-colors\n ${isFocused ? 'border-primary-500 ring-1 ring-primary-500' : 'border-border-subtle'}\n ${disabled ? 'opacity-50 cursor-not-allowed bg-bg-sunken' : ''}\n ${error || inputError ? 'border-error-500' : ''}\n `}\n onClick={() => inputRef.current?.focus()}\n >\n {/* Selected recipients */}\n {recipients.map((recipient) => (\n <div\n key={recipient.id}\n className=\"flex items-center gap-1.5 px-2 py-1 bg-surface-elevated border border-border-subtle rounded-full text-sm\"\n >\n {getRecipientIcon(recipient.type)}\n <span className=\"text-text-primary max-w-[200px] truncate\">{recipient.displayName}</span>\n {!disabled && (\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation();\n removeRecipient(recipient.id);\n }}\n className=\"p-0.5 hover:bg-surface-hover rounded-full transition-colors\"\n aria-label={tr('notifCommon.removeRecipient', 'Remove {{name}}').replace(\n '{{name}}',\n recipient.displayName\n )}\n >\n <X size={12} className=\"text-text-secondary\" />\n </button>\n )}\n </div>\n ))}\n\n {/* Input */}\n {!disabled && recipients.length < maxRecipients && (\n <input\n ref={inputRef}\n type={inputType}\n value={inputValue}\n onChange={(e) => setInputValue(e.target.value)}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n onFocus={() => setIsFocused(true)}\n onBlur={() => {\n setIsFocused(false);\n if (inputValue.trim()) {\n addRecipient(inputValue);\n }\n }}\n placeholder={\n recipients.length === 0 ? inputPlaceholder : tr('notifCommon.addMore', 'Add more...')\n }\n className=\"flex-1 min-w-[150px] bg-transparent border-none outline-none text-sm text-text-primary placeholder:text-text-secondary\"\n disabled={disabled}\n />\n )}\n\n {/* Add button for clarity */}\n {!disabled && inputValue.trim() && (\n <button\n type=\"button\"\n onClick={() => addRecipient(inputValue)}\n className=\"p-1 text-primary-500 hover:bg-primary-100 rounded transition-colors\"\n aria-label={tr('notifCommon.addRecipient', 'Add recipient')}\n >\n <Plus size={16} />\n </button>\n )}\n </div>\n\n {/* Error message */}\n {(error || inputError) && (\n <div className=\"flex items-center gap-1.5 text-error-500 text-sm\">\n <AlertCircle size={14} />\n <span>{error || inputError}</span>\n </div>\n )}\n\n {/* Helper text */}\n <div className=\"flex items-center justify-between text-xs text-text-secondary\">\n <span>\n {channel === 'EMAIL' &&\n tr(\n 'notifCommon.emailHelperText',\n 'Enter email addresses. Press Enter or comma to add multiple.'\n )}\n {(channel === 'SMS' || channel === 'WHATSAPP') &&\n tr(\n 'notifCommon.phoneHelperText',\n 'Enter phone numbers with country code (e.g., +1234567890).'\n )}\n\n {channel === 'PUSH' &&\n tr('notifCommon.pushHelperText', 'Enter device tokens for push notifications.')}\n {channel === 'SLACK' && tr('notifCommon.slackHelperText', 'Enter Slack user IDs.')}\n {channel === 'TEAMS' &&\n tr('notifCommon.teamsHelperText', 'Enter Microsoft Teams user IDs.')}\n {channel === 'WEBHOOK' && tr('notifCommon.webhookHelperText', 'Enter webhook URLs.')}\n </span>\n <span>\n {recipients.length} / {maxRecipients}\n </span>\n </div>\n </div>\n );\n}\n\n/**\n * Compact recipient display for read-only views\n */\nexport function RecipientList({ recipients }: { recipients: Recipient[] }) {\n const tr = useTr();\n\n if (recipients.length === 0) {\n return (\n <span className=\"text-text-secondary text-sm\">\n {tr('notifCommon.noRecipients', 'No recipients')}\n </span>\n );\n }\n\n return (\n <div className=\"flex flex-wrap items-center gap-1.5\">\n {recipients.slice(0, 5).map((recipient) => (\n <div\n key={recipient.id}\n className=\"flex items-center gap-1 px-2 py-0.5 bg-surface-elevated border border-border-subtle rounded-full text-xs\"\n >\n {getRecipientIcon(recipient.type)}\n <span className=\"text-text-primary max-w-[150px] truncate\">{recipient.displayName}</span>\n </div>\n ))}\n {recipients.length > 5 && (\n <span className=\"flex items-center gap-1 px-2 py-0.5 bg-bg-sunken text-text-secondary rounded-full text-xs\">\n <Users size={12} />+{recipients.length - 5} {tr('notifCommon.more', 'more')}\n </span>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;AA2BA,SAAS,EAAiB,GAAyB;AACjD,SAAQ,GAAR;EACE,KAAK,QACH,QAAO,kBAAC,GAAD;GAAM,MAAM;GAAI,WAAU;GAA0B,CAAA;EAC7D,KAAK,QACH,QAAO,kBAAC,GAAD;GAAO,MAAM;GAAI,WAAU;GAA6B,CAAA;EACjE,KAAK,OACH,QAAO,kBAAC,GAAD;GAAM,MAAM;GAAI,WAAU;GAAuB,CAAA;EAC1D,QACE,QAAO,kBAAC,GAAD;GAAM,MAAM;GAAI,WAAU;GAAwB,CAAA;;;AAO/D,SAAS,EAAa,GAAwB;AAE5C,QADmB,6BACD,KAAK,EAAM;;AAM/B,SAAS,EAAa,GAAwB;AAE5C,QADmB,qBACD,KAAK,EAAM,QAAQ,eAAe,GAAG,CAAC;;AAM1D,SAAS,IAAqB;AAC5B,QAAO,aAAa,KAAK,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,OAAO,GAAG,EAAE;;AAS3E,SAAgB,EAAkB,EAChC,eACA,aACA,YACA,gBACA,cAAW,IACX,mBAAgB,KAChB,YACyB;CACzB,IAAM,IAAK,GAAO,EACZ,CAAC,GAAY,KAAiB,EAAS,GAAG,EAC1C,CAAC,GAAY,KAAiB,EAAwB,KAAK,EAC3D,CAAC,GAAW,KAAgB,EAAS,GAAM,EAC3C,IAAW,EAAyB,KAAK,EAGzC,IACJ,MAAY,UAAU,UAAU,MAAY,SAAS,MAAY,aAAa,UAAU,QACpF,IACJ,MACC,MAAY,UACT,EAAG,qCAAqC,yBAAyB,GACjE,MAAY,SAAS,MAAY,aAC/B,EAAG,qCAAqC,4CAA4C,GACpF,MAAY,SACV,EAAG,2CAA2C,wBAAwB,GACtE,MAAY,UACV,EAAG,uCAAuC,yBAAyB,GACnE,MAA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AAiC,sBAAsB;KAC/E,EAAA,CAAA,EACP,kBAAC,QAAD,EAAA,UAAA;KACG,EAAW;KAAO;KAAI;KAClB,EAAA,CAAA,CACH;;GACF"}
|
|
@@ -65,11 +65,11 @@ function m({ channel: t, subject: n, body: r, html: i, appName: s, onChannelChan
|
|
|
65
65
|
className: "flex items-center gap-1 p-2 border-b border-default bg-surface/50 shrink-0",
|
|
66
66
|
children: p.map((e) => /* @__PURE__ */ d("button", {
|
|
67
67
|
onClick: () => l(e.id),
|
|
68
|
-
className: `flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg transition-all duration-150 ${t === e.id ? "bg-accent-primary/10 text-accent-primary" : "text-tertiary hover:text-primary hover:bg-
|
|
68
|
+
className: `flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg transition-all duration-150 ${t === e.id ? "bg-accent-primary/10 text-accent-primary" : "text-tertiary hover:text-primary hover:bg-bg-sunken"}`,
|
|
69
69
|
children: [e.icon, m(`notifCommon.previewChannel.${e.id}`, e.label)]
|
|
70
70
|
}, e.id))
|
|
71
71
|
}), /* @__PURE__ */ d("div", {
|
|
72
|
-
className: "flex-1 p-4 overflow-auto bg-
|
|
72
|
+
className: "flex-1 p-4 overflow-auto bg-bg-sunken/30",
|
|
73
73
|
children: [
|
|
74
74
|
t === "email" && /* @__PURE__ */ u("div", {
|
|
75
75
|
className: "max-w-xl mx-auto",
|
|
@@ -77,7 +77,7 @@ function m({ channel: t, subject: n, body: r, html: i, appName: s, onChannelChan
|
|
|
77
77
|
className: "bg-surface rounded-xl shadow-lg overflow-hidden border border-default",
|
|
78
78
|
children: [
|
|
79
79
|
/* @__PURE__ */ d("div", {
|
|
80
|
-
className: "bg-
|
|
80
|
+
className: "bg-bg-sunken px-4 py-3 border-b border-default",
|
|
81
81
|
children: [/* @__PURE__ */ d("div", {
|
|
82
82
|
className: "flex items-center gap-1.5 mb-3",
|
|
83
83
|
children: [
|
|
@@ -309,7 +309,7 @@ function m({ channel: t, subject: n, body: r, html: i, appName: s, onChannelChan
|
|
|
309
309
|
children: /* @__PURE__ */ d("div", {
|
|
310
310
|
className: "bg-surface rounded-xl shadow-lg overflow-hidden border border-default",
|
|
311
311
|
children: [/* @__PURE__ */ d("div", {
|
|
312
|
-
className: "bg-
|
|
312
|
+
className: "bg-bg-sunken px-4 py-2.5 border-b border-default flex items-center justify-between",
|
|
313
313
|
children: [/* @__PURE__ */ d("div", {
|
|
314
314
|
className: "flex items-center gap-2",
|
|
315
315
|
children: [/* @__PURE__ */ u(a, {
|
|
@@ -364,7 +364,7 @@ function m({ channel: t, subject: n, body: r, html: i, appName: s, onChannelChan
|
|
|
364
364
|
/* @__PURE__ */ d("div", {
|
|
365
365
|
className: "p-3.5 flex items-start gap-2.5 opacity-40",
|
|
366
366
|
children: [/* @__PURE__ */ u("div", {
|
|
367
|
-
className: "w-8 h-8 bg-
|
|
367
|
+
className: "w-8 h-8 bg-bg-sunken rounded-full flex items-center justify-center flex-shrink-0",
|
|
368
368
|
children: /* @__PURE__ */ u(c, {
|
|
369
369
|
size: 14,
|
|
370
370
|
className: "text-tertiary"
|
|
@@ -389,7 +389,7 @@ function m({ channel: t, subject: n, body: r, html: i, appName: s, onChannelChan
|
|
|
389
389
|
/* @__PURE__ */ d("div", {
|
|
390
390
|
className: "p-3.5 flex items-start gap-2.5 opacity-40",
|
|
391
391
|
children: [/* @__PURE__ */ u("div", {
|
|
392
|
-
className: "w-8 h-8 bg-
|
|
392
|
+
className: "w-8 h-8 bg-bg-sunken rounded-full flex items-center justify-center flex-shrink-0",
|
|
393
393
|
children: /* @__PURE__ */ u(o, {
|
|
394
394
|
size: 14,
|
|
395
395
|
className: "text-tertiary"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplatePreview.js","names":[],"sources":["../../src/components/TemplatePreview.tsx"],"sourcesContent":["import { useState, useCallback, useEffect, useRef } from 'react';\nimport { Mail, MessageSquare, Bell, Smartphone, Monitor } from 'lucide-react';\nimport { useTr } from '../shared/hooks/useTr';\n\nexport type PreviewChannel = 'email' | 'sms' | 'push' | 'in_app';\n\nexport interface TemplatePreviewProps {\n channel: PreviewChannel;\n subject: string;\n body: string;\n html: string;\n appName: string;\n onChannelChange: (channel: PreviewChannel) => void;\n}\n\n/**\n * Hook to scale an iframe so the full-width email (600px) fits inside\n * the available container width while showing all content without scroll.\n */\nfunction useScaledIframe(html: string) {\n const containerRef = useRef<HTMLDivElement>(null);\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const [scale, setScale] = useState(1);\n const [iframeHeight, setIframeHeight] = useState(400);\n\n const EMAIL_WIDTH = 620; // email templates are typically 600px + a bit of padding\n\n const recalculate = useCallback(() => {\n const container = containerRef.current;\n const iframe = iframeRef.current;\n if (!container || !iframe) return;\n\n const containerWidth = container.clientWidth;\n const newScale = Math.min(1, containerWidth / EMAIL_WIDTH);\n setScale(newScale);\n\n // Give the iframe time to render, then measure its content height\n requestAnimationFrame(() => {\n try {\n const doc = iframe.contentDocument || iframe.contentWindow?.document;\n if (doc?.body) {\n const contentHeight = doc.body.scrollHeight;\n setIframeHeight(contentHeight);\n }\n } catch {\n // cross-origin guard — won't happen with srcDoc + allow-same-origin\n }\n });\n }, []);\n\n // Recalculate when html changes\n useEffect(() => {\n // Small delay to let iframe render new content\n const timer = setTimeout(recalculate, 100);\n return () => clearTimeout(timer);\n }, [html, recalculate]);\n\n // Recalculate on resize\n useEffect(() => {\n const observer = new ResizeObserver(recalculate);\n if (containerRef.current) observer.observe(containerRef.current);\n return () => observer.disconnect();\n }, [recalculate]);\n\n // Also recalculate when iframe loads\n const onIframeLoad = useCallback(() => {\n recalculate();\n }, [recalculate]);\n\n return { containerRef, iframeRef, scale, iframeHeight, onIframeLoad, EMAIL_WIDTH };\n}\n\nconst channelTabs: { id: PreviewChannel; label: string; icon: React.ReactNode }[] = [\n { id: 'email', label: 'Email', icon: <Mail size={14} /> },\n { id: 'sms', label: 'SMS', icon: <MessageSquare size={14} /> },\n { id: 'push', label: 'Push', icon: <Bell size={14} /> },\n { id: 'in_app', label: 'In-App', icon: <Smartphone size={14} /> },\n];\n\n/**\n * Template Preview Component\n *\n * Shows how a notification template will look across different channels.\n * Templates are channel-agnostic — this component lets you preview\n * the same content as it would render on Email, SMS, Push, or In-App.\n *\n * Uses semantic theme tokens (text-primary, bg-surface, etc.) for theme\n * compatibility, with hardcoded colors only inside device mockups where\n * the real device UI is always dark (iPhone SMS, Push lock screen).\n */\nexport function TemplatePreview({\n channel,\n subject,\n body,\n html,\n appName,\n onChannelChange,\n}: TemplatePreviewProps) {\n const tr = useTr();\n const { containerRef, iframeRef, scale, iframeHeight, onIframeLoad, EMAIL_WIDTH } =\n useScaledIframe(html);\n\n return (\n <div className=\"h-full flex flex-col overflow-hidden\">\n {/* ── Channel Tabs ─────────────────────────────────────────── */}\n <div className=\"flex items-center gap-1 p-2 border-b border-default bg-surface/50 shrink-0\">\n {channelTabs.map((tab) => (\n <button\n key={tab.id}\n onClick={() => onChannelChange(tab.id)}\n className={`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg transition-all duration-150 ${\n channel === tab.id\n ? 'bg-accent-primary/10 text-accent-primary'\n : 'text-tertiary hover:text-primary hover:bg-muted'\n }`}\n >\n {tab.icon}\n {tr(`notifCommon.previewChannel.${tab.id}`, tab.label)}\n </button>\n ))}\n </div>\n\n {/* ── Preview Area ─────────────────────────────────────────── */}\n <div className=\"flex-1 p-4 overflow-auto bg-muted/30\">\n {/* ═══════════════════════════════════════════════════════════\n EMAIL PREVIEW — Desktop email client mockup\n ═══════════════════════════════════════════════════════════ */}\n {channel === 'email' && (\n <div className=\"max-w-xl mx-auto\">\n <div className=\"bg-surface rounded-xl shadow-lg overflow-hidden border border-default\">\n {/* Window chrome */}\n <div className=\"bg-muted px-4 py-3 border-b border-default\">\n <div className=\"flex items-center gap-1.5 mb-3\">\n <div className=\"w-2.5 h-2.5 rounded-full bg-red-400\"></div>\n <div className=\"w-2.5 h-2.5 rounded-full bg-yellow-400\"></div>\n <div className=\"w-2.5 h-2.5 rounded-full bg-green-400\"></div>\n </div>\n <div className=\"space-y-1.5\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-[10px] font-medium text-tertiary w-12\">\n {tr('notifCommon.emailFromLabel', 'From:')}\n </span>\n <span className=\"text-xs text-secondary\">\n {appName || 'noreply@example.com'}\n </span>\n </div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-[10px] font-medium text-tertiary w-12\">\n {tr('notifCommon.emailToLabel', 'To:')}\n </span>\n <span className=\"text-xs text-secondary\">recipient@example.com</span>\n </div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-[10px] font-medium text-tertiary w-12\">\n {tr('notifCommon.emailSubjectLabel', 'Subject:')}\n </span>\n <span className=\"text-xs font-semibold text-primary\">\n {subject || (\n <span className=\"text-tertiary italic\">\n {tr('notifCommon.noSubject', 'No subject')}\n </span>\n )}\n </span>\n </div>\n </div>\n </div>\n\n {/* Email body — scaled iframe for pixel-perfect preview */}\n <div className=\"overflow-hidden\" ref={containerRef}>\n {html ? (\n <div\n style={{\n width: EMAIL_WIDTH,\n height: iframeHeight,\n transform: `scale(${scale})`,\n transformOrigin: 'top left',\n }}\n >\n <iframe\n ref={iframeRef}\n srcDoc={`<!DOCTYPE html><html><head><meta charset=\"utf-8\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/><style>body{font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,sans-serif;font-size:14px;line-height:1.6;color:#1a1a1a;margin:0;padding:0}img{max-width:100%}a{color:#2563eb}table{border-collapse:collapse}</style></head><body>${html}</body></html>`}\n sandbox=\"allow-same-origin\"\n style={{ width: EMAIL_WIDTH, height: iframeHeight, border: 'none' }}\n title=\"Email preview\"\n onLoad={onIframeLoad}\n />\n </div>\n ) : body ? (\n <div className=\"p-5 min-h-[180px]\">\n <pre className=\"text-sm text-primary whitespace-pre-wrap font-sans leading-relaxed\">\n {body}\n </pre>\n </div>\n ) : (\n <div className=\"flex items-center justify-center h-40 text-tertiary p-5\">\n <p className=\"text-sm italic\">\n {tr('notifCommon.startTypingEmail', 'Start typing to see email preview...')}\n </p>\n </div>\n )}\n </div>\n\n {/* Scaled container height — collapse outer div to match scaled size */}\n {html && (\n <div\n style={{\n marginTop: -(iframeHeight - iframeHeight * scale),\n }}\n />\n )}\n </div>\n </div>\n )}\n\n {/* ═══════════════════════════════════════════════════════════\n SMS PREVIEW — iPhone Messages mockup\n ═══════════════════════════════════════════════════════════ */}\n {channel === 'sms' && (\n <div className=\"flex justify-center\">\n <div className=\"w-72 bg-black rounded-[2.5rem] p-2.5 shadow-2xl\">\n <div className=\"bg-gray-900 rounded-[2rem] overflow-hidden\">\n {/* Notch */}\n <div className=\"flex justify-center pt-1.5 pb-3 bg-black\">\n <div className=\"w-20 h-5 bg-black rounded-full\"></div>\n </div>\n\n {/* Messages header */}\n <div className=\"bg-gray-800 px-3 py-2.5 flex items-center justify-between border-b border-gray-700\">\n <span className=\"text-blue-400 text-xs\">< Messages</span>\n <span className=\"text-white text-xs font-semibold\">{appName || 'Sender'}</span>\n <div className=\"w-6 h-6 bg-gray-600 rounded-full\"></div>\n </div>\n\n {/* Message area */}\n <div className=\"bg-black min-h-[280px] p-3 space-y-3\">\n <div className=\"text-center\">\n <span className=\"text-[10px] text-gray-500\">\n {tr('notifCommon.smsTimestamp', 'Today 10:30 AM')}\n </span>\n </div>\n\n {body ? (\n <div className=\"flex justify-start\">\n <div className=\"max-w-[80%] bg-gray-700 text-white text-xs px-3 py-2.5 rounded-2xl rounded-bl-md leading-relaxed\">\n {body}\n </div>\n </div>\n ) : (\n <div className=\"flex items-center justify-center h-24 text-gray-500\">\n <p className=\"text-xs italic\">\n {tr('notifCommon.noMessageContent', 'No message content')}\n </p>\n </div>\n )}\n </div>\n\n {/* Input bar */}\n <div className=\"bg-gray-900 px-3 py-2.5 flex items-center gap-2 border-t border-gray-800\">\n <div className=\"flex-1 bg-gray-700 rounded-full px-3 py-1.5\">\n <span className=\"text-gray-400 text-[10px]\">iMessage</span>\n </div>\n <div className=\"w-6 h-6 bg-blue-500 rounded-full flex items-center justify-center\">\n <span className=\"text-white text-[10px]\">↑</span>\n </div>\n </div>\n </div>\n </div>\n </div>\n )}\n\n {/* ═══════════════════════════════════════════════════════════\n PUSH PREVIEW — iPhone lock screen mockup\n ═══════════════════════════════════════════════════════════ */}\n {channel === 'push' && (\n <div className=\"flex justify-center\">\n <div className=\"w-72 bg-black rounded-[2.5rem] p-2.5 shadow-2xl\">\n <div className=\"bg-gradient-to-b from-purple-900 via-blue-900 to-black rounded-[2rem] overflow-hidden\">\n {/* Notch */}\n <div className=\"flex justify-center pt-1.5 pb-1.5 bg-black/30\">\n <div className=\"w-20 h-5 bg-black rounded-full\"></div>\n </div>\n\n {/* Time */}\n <div className=\"text-center pt-8 pb-6\">\n <div className=\"text-5xl font-light text-white\">9:41</div>\n <div className=\"text-sm text-white/80 mt-1\">\n {tr('notifCommon.pushDate', 'Monday, January 27')}\n </div>\n </div>\n\n {/* Push notification card */}\n <div className=\"px-3 pb-6\">\n <div className=\"bg-bg-surface/90 backdrop-blur-xl rounded-2xl p-3.5 shadow-lg\">\n <div className=\"flex items-start gap-2.5\">\n <div className=\"w-8 h-8 bg-blue-500 rounded-xl flex items-center justify-center flex-shrink-0\">\n <Bell size={16} className=\"text-white\" />\n </div>\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center justify-between\">\n <span className=\"text-[10px] font-semibold text-gray-900 uppercase tracking-wide\">\n {appName || tr('notifCommon.pushAppNameFallback', 'App Name')}\n </span>\n <span className=\"text-[10px] text-gray-500\">\n {tr('notifCommon.pushTimestampNow', 'now')}\n </span>\n </div>\n <div className=\"text-xs font-semibold text-gray-900 mt-0.5\">\n {subject || (\n <span className=\"text-gray-400 italic\">\n {tr('notifCommon.noTitle', 'No title')}\n </span>\n )}\n </div>\n <div className=\"text-xs text-gray-600 line-clamp-2 mt-0.5 leading-relaxed\">\n {body || (\n <span className=\"italic\">\n {tr('notifCommon.noMessage', 'No message')}\n </span>\n )}\n </div>\n </div>\n </div>\n </div>\n </div>\n\n {/* Home indicator */}\n <div className=\"flex justify-center pb-3\">\n <div className=\"w-28 h-1 bg-bg-surface/30 rounded-full\"></div>\n </div>\n </div>\n </div>\n </div>\n )}\n\n {/* ═══════════════════════════════════════════════════════════\n IN-APP PREVIEW — Desktop notification panel mockup\n ═══════════════════════════════════════════════════════════ */}\n {channel === 'in_app' && (\n <div className=\"max-w-sm mx-auto\">\n <div className=\"bg-surface rounded-xl shadow-lg overflow-hidden border border-default\">\n {/* Panel header */}\n <div className=\"bg-muted px-4 py-2.5 border-b border-default flex items-center justify-between\">\n <div className=\"flex items-center gap-2\">\n <Bell size={16} className=\"text-tertiary\" />\n <span className=\"text-sm font-semibold text-primary\">\n {tr('notifCommon.notifications', 'Notifications')}\n </span>\n </div>\n <span className=\"text-[10px] text-accent-primary font-medium\">\n {tr('notifCommon.markAllAsRead', 'Mark all as read')}\n </span>\n </div>\n\n {/* Notification items */}\n <div className=\"divide-y divide-default\">\n {/* Active notification (the template) */}\n <div className=\"p-3.5 bg-accent-primary/5 flex items-start gap-2.5\">\n <div className=\"w-8 h-8 bg-accent-primary/10 rounded-full flex items-center justify-center flex-shrink-0\">\n <Bell size={14} className=\"text-accent-primary\" />\n </div>\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center justify-between mb-0.5\">\n <span className=\"text-xs font-semibold text-primary\">\n {subject || appName || (\n <span className=\"text-tertiary italic\">\n {tr('notifCommon.notification', 'Notification')}\n </span>\n )}\n </span>\n <span className=\"text-[10px] text-tertiary\">\n {tr('notifCommon.inAppJustNow', 'Just now')}\n </span>\n </div>\n <p className=\"text-xs text-secondary leading-relaxed\">\n {body || (\n <span className=\"italic text-tertiary\">\n {tr('notifCommon.noMessageContent', 'No message content')}\n </span>\n )}\n </p>\n </div>\n <div className=\"w-1.5 h-1.5 bg-accent rounded-full flex-shrink-0 mt-1.5\"></div>\n </div>\n\n {/* Older notifications (dimmed placeholders) */}\n <div className=\"p-3.5 flex items-start gap-2.5 opacity-40\">\n <div className=\"w-8 h-8 bg-muted rounded-full flex items-center justify-center flex-shrink-0\">\n <Monitor size={14} className=\"text-tertiary\" />\n </div>\n <div className=\"flex-1\">\n <div className=\"flex items-center justify-between mb-0.5\">\n <span className=\"text-xs font-medium text-primary\">\n {tr('notifCommon.sampleSystemUpdate', 'System Update')}\n </span>\n <span className=\"text-[10px] text-tertiary\">\n {tr('notifCommon.sampleTwoHoursAgo', '2h ago')}\n </span>\n </div>\n <p className=\"text-xs text-secondary\">\n {tr(\n 'notifCommon.sampleSystemUpdateBody',\n 'Your system has been updated successfully.'\n )}\n </p>\n </div>\n </div>\n\n <div className=\"p-3.5 flex items-start gap-2.5 opacity-40\">\n <div className=\"w-8 h-8 bg-muted rounded-full flex items-center justify-center flex-shrink-0\">\n <Mail size={14} className=\"text-tertiary\" />\n </div>\n <div className=\"flex-1\">\n <div className=\"flex items-center justify-between mb-0.5\">\n <span className=\"text-xs font-medium text-primary\">\n {tr('notifCommon.sampleNewMessage', 'New Message')}\n </span>\n <span className=\"text-[10px] text-tertiary\">\n {tr('notifCommon.sampleOneDayAgo', '1d ago')}\n </span>\n </div>\n <p className=\"text-xs text-secondary\">\n {tr(\n 'notifCommon.sampleNewMessageBody',\n 'You have a new message from support.'\n )}\n </p>\n </div>\n </div>\n </div>\n </div>\n </div>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;AAmBA,SAAS,EAAgB,GAAc;CACrC,IAAM,IAAe,EAAuB,KAAK,EAC3C,IAAY,EAA0B,KAAK,EAC3C,CAAC,GAAO,KAAY,EAAS,EAAE,EAC/B,CAAC,GAAc,KAAmB,EAAS,IAAI,EAI/C,IAAc,QAAkB;EACpC,IAAM,IAAY,EAAa,SACzB,IAAS,EAAU;AACzB,MAAI,CAAC,KAAa,CAAC,EAAQ;EAE3B,IAAM,IAAiB,EAAU;AAKjC,EAHA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AK,WAAU,2DAAgE,CAAA;UAC3E;;QAGN,kBAAC,OAAD;SAAK,WAAU;mBAAf,CACE,kBAAC,OAAD;UAAK,WAAU;oBACb,kBAAC,GAAD;WAAS,MAAM;WAAI,WAAU;WAAkB,CAAA;UAC3C,CAAA,EACN,kBAAC,OAAD;UAAK,WAAU;oBAAf,CACE,kBAAC,OAAD;WAAK,WAAU;qBAAf,CACE,kBAAC,QAAD;YAAM,WAAU;sBACb,EAAG,kCAAkC,gBAAgB;YACjD,CAAA,EACP,kBAAC,QAAD;YAAM,WAAU;sBACb,EAAG,iCAAiC,SAAS;YACzC,CAAA,CACH;cACN,kBAAC,KAAD;WAAG,WAAU;qBACV,EACC,sCACA,6CACD;WACC,CAAA,CACA;YACF;;QAEN,kBAAC,OAAD;SAAK,WAAU;mBAAf,CACE,kBAAC,OAAD;UAAK,WAAU;oBACb,kBAAC,GAAD;WAAM,MAAM;WAAI,WAAU;WAAkB,CAAA;UACxC,CAAA,EACN,kBAAC,OAAD;UAAK,WAAU;oBAAf,CACE,kBAAC,OAAD;WAAK,WAAU;qBAAf,CACE,kBAAC,QAAD;YAAM,WAAU;sBACb,EAAG,gCAAgC,cAAc;YAC7C,CAAA,EACP,kBAAC,QAAD;YAAM,WAAU;sBACb,EAAG,+BAA+B,SAAS;YACvC,CAAA,CACH;cACN,kBAAC,KAAD;WAAG,WAAU;qBACV,EACC,oCACA,uCACD;WACC,CAAA,CACA;YACF;;QACF;SACF;;KACF,CAAA;IAEJ;KACF"}
|
|
1
|
+
{"version":3,"file":"TemplatePreview.js","names":[],"sources":["../../src/components/TemplatePreview.tsx"],"sourcesContent":["import { useState, useCallback, useEffect, useRef } from 'react';\nimport { Mail, MessageSquare, Bell, Smartphone, Monitor } from 'lucide-react';\nimport { useTr } from '../shared/hooks/useTr';\n\nexport type PreviewChannel = 'email' | 'sms' | 'push' | 'in_app';\n\nexport interface TemplatePreviewProps {\n channel: PreviewChannel;\n subject: string;\n body: string;\n html: string;\n appName: string;\n onChannelChange: (channel: PreviewChannel) => void;\n}\n\n/**\n * Hook to scale an iframe so the full-width email (600px) fits inside\n * the available container width while showing all content without scroll.\n */\nfunction useScaledIframe(html: string) {\n const containerRef = useRef<HTMLDivElement>(null);\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const [scale, setScale] = useState(1);\n const [iframeHeight, setIframeHeight] = useState(400);\n\n const EMAIL_WIDTH = 620; // email templates are typically 600px + a bit of padding\n\n const recalculate = useCallback(() => {\n const container = containerRef.current;\n const iframe = iframeRef.current;\n if (!container || !iframe) return;\n\n const containerWidth = container.clientWidth;\n const newScale = Math.min(1, containerWidth / EMAIL_WIDTH);\n setScale(newScale);\n\n // Give the iframe time to render, then measure its content height\n requestAnimationFrame(() => {\n try {\n const doc = iframe.contentDocument || iframe.contentWindow?.document;\n if (doc?.body) {\n const contentHeight = doc.body.scrollHeight;\n setIframeHeight(contentHeight);\n }\n } catch {\n // cross-origin guard — won't happen with srcDoc + allow-same-origin\n }\n });\n }, []);\n\n // Recalculate when html changes\n useEffect(() => {\n // Small delay to let iframe render new content\n const timer = setTimeout(recalculate, 100);\n return () => clearTimeout(timer);\n }, [html, recalculate]);\n\n // Recalculate on resize\n useEffect(() => {\n const observer = new ResizeObserver(recalculate);\n if (containerRef.current) observer.observe(containerRef.current);\n return () => observer.disconnect();\n }, [recalculate]);\n\n // Also recalculate when iframe loads\n const onIframeLoad = useCallback(() => {\n recalculate();\n }, [recalculate]);\n\n return { containerRef, iframeRef, scale, iframeHeight, onIframeLoad, EMAIL_WIDTH };\n}\n\nconst channelTabs: { id: PreviewChannel; label: string; icon: React.ReactNode }[] = [\n { id: 'email', label: 'Email', icon: <Mail size={14} /> },\n { id: 'sms', label: 'SMS', icon: <MessageSquare size={14} /> },\n { id: 'push', label: 'Push', icon: <Bell size={14} /> },\n { id: 'in_app', label: 'In-App', icon: <Smartphone size={14} /> },\n];\n\n/**\n * Template Preview Component\n *\n * Shows how a notification template will look across different channels.\n * Templates are channel-agnostic — this component lets you preview\n * the same content as it would render on Email, SMS, Push, or In-App.\n *\n * Uses semantic theme tokens (text-primary, bg-surface, etc.) for theme\n * compatibility, with hardcoded colors only inside device mockups where\n * the real device UI is always dark (iPhone SMS, Push lock screen).\n */\nexport function TemplatePreview({\n channel,\n subject,\n body,\n html,\n appName,\n onChannelChange,\n}: TemplatePreviewProps) {\n const tr = useTr();\n const { containerRef, iframeRef, scale, iframeHeight, onIframeLoad, EMAIL_WIDTH } =\n useScaledIframe(html);\n\n return (\n <div className=\"h-full flex flex-col overflow-hidden\">\n {/* ── Channel Tabs ─────────────────────────────────────────── */}\n <div className=\"flex items-center gap-1 p-2 border-b border-default bg-surface/50 shrink-0\">\n {channelTabs.map((tab) => (\n <button\n key={tab.id}\n onClick={() => onChannelChange(tab.id)}\n className={`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg transition-all duration-150 ${\n channel === tab.id\n ? 'bg-accent-primary/10 text-accent-primary'\n : 'text-tertiary hover:text-primary hover:bg-bg-sunken'\n }`}\n >\n {tab.icon}\n {tr(`notifCommon.previewChannel.${tab.id}`, tab.label)}\n </button>\n ))}\n </div>\n\n {/* ── Preview Area ─────────────────────────────────────────── */}\n <div className=\"flex-1 p-4 overflow-auto bg-bg-sunken/30\">\n {/* ═══════════════════════════════════════════════════════════\n EMAIL PREVIEW — Desktop email client mockup\n ═══════════════════════════════════════════════════════════ */}\n {channel === 'email' && (\n <div className=\"max-w-xl mx-auto\">\n <div className=\"bg-surface rounded-xl shadow-lg overflow-hidden border border-default\">\n {/* Window chrome */}\n <div className=\"bg-bg-sunken px-4 py-3 border-b border-default\">\n <div className=\"flex items-center gap-1.5 mb-3\">\n <div className=\"w-2.5 h-2.5 rounded-full bg-red-400\"></div>\n <div className=\"w-2.5 h-2.5 rounded-full bg-yellow-400\"></div>\n <div className=\"w-2.5 h-2.5 rounded-full bg-green-400\"></div>\n </div>\n <div className=\"space-y-1.5\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-[10px] font-medium text-tertiary w-12\">\n {tr('notifCommon.emailFromLabel', 'From:')}\n </span>\n <span className=\"text-xs text-secondary\">\n {appName || 'noreply@example.com'}\n </span>\n </div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-[10px] font-medium text-tertiary w-12\">\n {tr('notifCommon.emailToLabel', 'To:')}\n </span>\n <span className=\"text-xs text-secondary\">recipient@example.com</span>\n </div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-[10px] font-medium text-tertiary w-12\">\n {tr('notifCommon.emailSubjectLabel', 'Subject:')}\n </span>\n <span className=\"text-xs font-semibold text-primary\">\n {subject || (\n <span className=\"text-tertiary italic\">\n {tr('notifCommon.noSubject', 'No subject')}\n </span>\n )}\n </span>\n </div>\n </div>\n </div>\n\n {/* Email body — scaled iframe for pixel-perfect preview */}\n <div className=\"overflow-hidden\" ref={containerRef}>\n {html ? (\n <div\n style={{\n width: EMAIL_WIDTH,\n height: iframeHeight,\n transform: `scale(${scale})`,\n transformOrigin: 'top left',\n }}\n >\n <iframe\n ref={iframeRef}\n srcDoc={`<!DOCTYPE html><html><head><meta charset=\"utf-8\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/><style>body{font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,sans-serif;font-size:14px;line-height:1.6;color:#1a1a1a;margin:0;padding:0}img{max-width:100%}a{color:#2563eb}table{border-collapse:collapse}</style></head><body>${html}</body></html>`}\n sandbox=\"allow-same-origin\"\n style={{ width: EMAIL_WIDTH, height: iframeHeight, border: 'none' }}\n title=\"Email preview\"\n onLoad={onIframeLoad}\n />\n </div>\n ) : body ? (\n <div className=\"p-5 min-h-[180px]\">\n <pre className=\"text-sm text-primary whitespace-pre-wrap font-sans leading-relaxed\">\n {body}\n </pre>\n </div>\n ) : (\n <div className=\"flex items-center justify-center h-40 text-tertiary p-5\">\n <p className=\"text-sm italic\">\n {tr('notifCommon.startTypingEmail', 'Start typing to see email preview...')}\n </p>\n </div>\n )}\n </div>\n\n {/* Scaled container height — collapse outer div to match scaled size */}\n {html && (\n <div\n style={{\n marginTop: -(iframeHeight - iframeHeight * scale),\n }}\n />\n )}\n </div>\n </div>\n )}\n\n {/* ═══════════════════════════════════════════════════════════\n SMS PREVIEW — iPhone Messages mockup\n ═══════════════════════════════════════════════════════════ */}\n {channel === 'sms' && (\n <div className=\"flex justify-center\">\n <div className=\"w-72 bg-black rounded-[2.5rem] p-2.5 shadow-2xl\">\n <div className=\"bg-gray-900 rounded-[2rem] overflow-hidden\">\n {/* Notch */}\n <div className=\"flex justify-center pt-1.5 pb-3 bg-black\">\n <div className=\"w-20 h-5 bg-black rounded-full\"></div>\n </div>\n\n {/* Messages header */}\n <div className=\"bg-gray-800 px-3 py-2.5 flex items-center justify-between border-b border-gray-700\">\n <span className=\"text-blue-400 text-xs\">< Messages</span>\n <span className=\"text-white text-xs font-semibold\">{appName || 'Sender'}</span>\n <div className=\"w-6 h-6 bg-gray-600 rounded-full\"></div>\n </div>\n\n {/* Message area */}\n <div className=\"bg-black min-h-[280px] p-3 space-y-3\">\n <div className=\"text-center\">\n <span className=\"text-[10px] text-gray-500\">\n {tr('notifCommon.smsTimestamp', 'Today 10:30 AM')}\n </span>\n </div>\n\n {body ? (\n <div className=\"flex justify-start\">\n <div className=\"max-w-[80%] bg-gray-700 text-white text-xs px-3 py-2.5 rounded-2xl rounded-bl-md leading-relaxed\">\n {body}\n </div>\n </div>\n ) : (\n <div className=\"flex items-center justify-center h-24 text-gray-500\">\n <p className=\"text-xs italic\">\n {tr('notifCommon.noMessageContent', 'No message content')}\n </p>\n </div>\n )}\n </div>\n\n {/* Input bar */}\n <div className=\"bg-gray-900 px-3 py-2.5 flex items-center gap-2 border-t border-gray-800\">\n <div className=\"flex-1 bg-gray-700 rounded-full px-3 py-1.5\">\n <span className=\"text-gray-400 text-[10px]\">iMessage</span>\n </div>\n <div className=\"w-6 h-6 bg-blue-500 rounded-full flex items-center justify-center\">\n <span className=\"text-white text-[10px]\">↑</span>\n </div>\n </div>\n </div>\n </div>\n </div>\n )}\n\n {/* ═══════════════════════════════════════════════════════════\n PUSH PREVIEW — iPhone lock screen mockup\n ═══════════════════════════════════════════════════════════ */}\n {channel === 'push' && (\n <div className=\"flex justify-center\">\n <div className=\"w-72 bg-black rounded-[2.5rem] p-2.5 shadow-2xl\">\n <div className=\"bg-gradient-to-b from-purple-900 via-blue-900 to-black rounded-[2rem] overflow-hidden\">\n {/* Notch */}\n <div className=\"flex justify-center pt-1.5 pb-1.5 bg-black/30\">\n <div className=\"w-20 h-5 bg-black rounded-full\"></div>\n </div>\n\n {/* Time */}\n <div className=\"text-center pt-8 pb-6\">\n <div className=\"text-5xl font-light text-white\">9:41</div>\n <div className=\"text-sm text-white/80 mt-1\">\n {tr('notifCommon.pushDate', 'Monday, January 27')}\n </div>\n </div>\n\n {/* Push notification card */}\n <div className=\"px-3 pb-6\">\n <div className=\"bg-bg-surface/90 backdrop-blur-xl rounded-2xl p-3.5 shadow-lg\">\n <div className=\"flex items-start gap-2.5\">\n <div className=\"w-8 h-8 bg-blue-500 rounded-xl flex items-center justify-center flex-shrink-0\">\n <Bell size={16} className=\"text-white\" />\n </div>\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center justify-between\">\n <span className=\"text-[10px] font-semibold text-gray-900 uppercase tracking-wide\">\n {appName || tr('notifCommon.pushAppNameFallback', 'App Name')}\n </span>\n <span className=\"text-[10px] text-gray-500\">\n {tr('notifCommon.pushTimestampNow', 'now')}\n </span>\n </div>\n <div className=\"text-xs font-semibold text-gray-900 mt-0.5\">\n {subject || (\n <span className=\"text-gray-400 italic\">\n {tr('notifCommon.noTitle', 'No title')}\n </span>\n )}\n </div>\n <div className=\"text-xs text-gray-600 line-clamp-2 mt-0.5 leading-relaxed\">\n {body || (\n <span className=\"italic\">\n {tr('notifCommon.noMessage', 'No message')}\n </span>\n )}\n </div>\n </div>\n </div>\n </div>\n </div>\n\n {/* Home indicator */}\n <div className=\"flex justify-center pb-3\">\n <div className=\"w-28 h-1 bg-bg-surface/30 rounded-full\"></div>\n </div>\n </div>\n </div>\n </div>\n )}\n\n {/* ═══════════════════════════════════════════════════════════\n IN-APP PREVIEW — Desktop notification panel mockup\n ═══════════════════════════════════════════════════════════ */}\n {channel === 'in_app' && (\n <div className=\"max-w-sm mx-auto\">\n <div className=\"bg-surface rounded-xl shadow-lg overflow-hidden border border-default\">\n {/* Panel header */}\n <div className=\"bg-bg-sunken px-4 py-2.5 border-b border-default flex items-center justify-between\">\n <div className=\"flex items-center gap-2\">\n <Bell size={16} className=\"text-tertiary\" />\n <span className=\"text-sm font-semibold text-primary\">\n {tr('notifCommon.notifications', 'Notifications')}\n </span>\n </div>\n <span className=\"text-[10px] text-accent-primary font-medium\">\n {tr('notifCommon.markAllAsRead', 'Mark all as read')}\n </span>\n </div>\n\n {/* Notification items */}\n <div className=\"divide-y divide-default\">\n {/* Active notification (the template) */}\n <div className=\"p-3.5 bg-accent-primary/5 flex items-start gap-2.5\">\n <div className=\"w-8 h-8 bg-accent-primary/10 rounded-full flex items-center justify-center flex-shrink-0\">\n <Bell size={14} className=\"text-accent-primary\" />\n </div>\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center justify-between mb-0.5\">\n <span className=\"text-xs font-semibold text-primary\">\n {subject || appName || (\n <span className=\"text-tertiary italic\">\n {tr('notifCommon.notification', 'Notification')}\n </span>\n )}\n </span>\n <span className=\"text-[10px] text-tertiary\">\n {tr('notifCommon.inAppJustNow', 'Just now')}\n </span>\n </div>\n <p className=\"text-xs text-secondary leading-relaxed\">\n {body || (\n <span className=\"italic text-tertiary\">\n {tr('notifCommon.noMessageContent', 'No message content')}\n </span>\n )}\n </p>\n </div>\n <div className=\"w-1.5 h-1.5 bg-accent rounded-full flex-shrink-0 mt-1.5\"></div>\n </div>\n\n {/* Older notifications (dimmed placeholders) */}\n <div className=\"p-3.5 flex items-start gap-2.5 opacity-40\">\n <div className=\"w-8 h-8 bg-bg-sunken rounded-full flex items-center justify-center flex-shrink-0\">\n <Monitor size={14} className=\"text-tertiary\" />\n </div>\n <div className=\"flex-1\">\n <div className=\"flex items-center justify-between mb-0.5\">\n <span className=\"text-xs font-medium text-primary\">\n {tr('notifCommon.sampleSystemUpdate', 'System Update')}\n </span>\n <span className=\"text-[10px] text-tertiary\">\n {tr('notifCommon.sampleTwoHoursAgo', '2h ago')}\n </span>\n </div>\n <p className=\"text-xs text-secondary\">\n {tr(\n 'notifCommon.sampleSystemUpdateBody',\n 'Your system has been updated successfully.'\n )}\n </p>\n </div>\n </div>\n\n <div className=\"p-3.5 flex items-start gap-2.5 opacity-40\">\n <div className=\"w-8 h-8 bg-bg-sunken rounded-full flex items-center justify-center flex-shrink-0\">\n <Mail size={14} className=\"text-tertiary\" />\n </div>\n <div className=\"flex-1\">\n <div className=\"flex items-center justify-between mb-0.5\">\n <span className=\"text-xs font-medium text-primary\">\n {tr('notifCommon.sampleNewMessage', 'New Message')}\n </span>\n <span className=\"text-[10px] text-tertiary\">\n {tr('notifCommon.sampleOneDayAgo', '1d ago')}\n </span>\n </div>\n <p className=\"text-xs text-secondary\">\n {tr(\n 'notifCommon.sampleNewMessageBody',\n 'You have a new message from support.'\n )}\n </p>\n </div>\n </div>\n </div>\n </div>\n </div>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;AAmBA,SAAS,EAAgB,GAAc;CACrC,IAAM,IAAe,EAAuB,KAAK,EAC3C,IAAY,EAA0B,KAAK,EAC3C,CAAC,GAAO,KAAY,EAAS,EAAE,EAC/B,CAAC,GAAc,KAAmB,EAAS,IAAI,EAI/C,IAAc,QAAkB;EACpC,IAAM,IAAY,EAAa,SACzB,IAAS,EAAU;AACzB,MAAI,CAAC,KAAa,CAAC,EAAQ;EAE3B,IAAM,IAAiB,EAAU;AAKjC,EAHA,EADiB,KAAK,IAAI,GAAG,IAAiB,IAAY,CACxC,EAGlB,4BAA4B;AAC1B,OAAI;IACF,IAAM,IAAM,EAAO,mBAAmB,EAAO,eA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,GAAD;WAAS,MAAM;WAAI,WAAU;WAAkB,CAAA;UAC3C,CAAA,EACN,kBAAC,OAAD;UAAK,WAAU;oBAAf,CACE,kBAAC,OAAD;WAAK,WAAU;qBAAf,CACE,kBAAC,QAAD;YAAM,WAAU;sBACb,EAAG,kCAAkC,gBAAgB;YACjD,CAAA,EACP,kBAAC,QAAD;YAAM,WAAU;sBACb,EAAG,iCAAiC,SAAS;YACzC,CAAA,CACH;cACN,kBAAC,KAAD;WAAG,WAAU;qBACV,EACC,sCACA,6CACD;WACC,CAAA,CACA;YACF;;QAEN,kBAAC,OAAD;SAAK,WAAU;mBAAf,CACE,kBAAC,OAAD;UAAK,WAAU;oBACb,kBAAC,GAAD;WAAM,MAAM;WAAI,WAAU;WAAkB,CAAA;UACxC,CAAA,EACN,kBAAC,OAAD;UAAK,WAAU;oBAAf,CACE,kBAAC,OAAD;WAAK,WAAU;qBAAf,CACE,kBAAC,QAAD;YAAM,WAAU;sBACb,EAAG,gCAAgC,cAAc;YAC7C,CAAA,EACP,kBAAC,QAAD;YAAM,WAAU;sBACb,EAAG,+BAA+B,SAAS;YACvC,CAAA,CACH;cACN,kBAAC,KAAD;WAAG,WAAU;qBACV,EACC,oCACA,uCACD;WACC,CAAA,CACA;YACF;;QACF;SACF;;KACF,CAAA;IAEJ;KACF"}
|
|
@@ -1337,7 +1337,7 @@ function Oe() {
|
|
|
1337
1337
|
}), /* @__PURE__ */ d("div", {
|
|
1338
1338
|
className: "flex flex-wrap gap-2",
|
|
1339
1339
|
children: Q.map((e) => /* @__PURE__ */ d("span", {
|
|
1340
|
-
className: "rounded-full bg-
|
|
1340
|
+
className: "rounded-full bg-bg-sunken px-2 py-1 text-xs text-secondary",
|
|
1341
1341
|
children: e.label
|
|
1342
1342
|
}, e.id))
|
|
1343
1343
|
})]
|