@burdenoff/microfe-notification 2026.1029.2 → 2026.1113.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/AdminNotificationRoot.d.ts +33 -0
- package/dist/AdminNotificationRoot.js +9 -6
- package/dist/AdminNotificationRoot.js.map +1 -1
- package/dist/AdminNotificationRoutes.d.ts +1 -0
- package/dist/AdminNotificationRoutes.js +22 -23
- package/dist/AdminNotificationRoutes.js.map +1 -1
- package/dist/NotificationRoot.d.ts +29 -0
- package/dist/NotificationRoot.js +9 -6
- package/dist/NotificationRoot.js.map +1 -1
- package/dist/NotificationRoutes.d.ts +18 -0
- package/dist/NotificationRoutes.js +109 -38
- package/dist/NotificationRoutes.js.map +1 -1
- package/dist/UserNotificationRoot.d.ts +32 -0
- package/dist/UserNotificationRoot.js +9 -6
- package/dist/UserNotificationRoot.js.map +1 -1
- package/dist/UserNotificationRoutes.d.ts +16 -0
- package/dist/UserNotificationRoutes.js +9 -10
- package/dist/UserNotificationRoutes.js.map +1 -1
- package/dist/components/ConfirmDeleteDialog.d.ts +17 -0
- package/dist/components/ConfirmDeleteDialog.js +22 -0
- package/dist/components/ConfirmDeleteDialog.js.map +1 -0
- package/dist/components/FeatureDisabledPage.d.ts +6 -0
- package/dist/components/FeatureDisabledPage.js +1 -2
- package/dist/components/FeatureDisabledPage.js.map +1 -1
- package/dist/components/NotificationBell.d.ts +13 -0
- package/dist/components/NotificationBell.js +6 -7
- package/dist/components/NotificationBell.js.map +1 -1
- package/dist/components/NotificationCard.d.ts +27 -0
- package/dist/components/NotificationCard.js +106 -76
- package/dist/components/NotificationCard.js.map +1 -1
- package/dist/components/NotificationPanel.d.ts +10 -0
- package/dist/components/NotificationPanel.js +5 -6
- package/dist/components/NotificationPanel.js.map +1 -1
- package/dist/components/RecipientSelector.d.ts +32 -0
- package/dist/components/RecipientSelector.js +2 -3
- package/dist/components/RecipientSelector.js.map +1 -1
- package/dist/components/TemplatePreview.d.ts +21 -0
- package/dist/components/TemplatePreview.js +3 -4
- package/dist/components/TemplatePreview.js.map +1 -1
- package/dist/components/VariableInserter.d.ts +11 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +4 -3
- package/dist/constants/permissions.d.ts +23 -0
- package/dist/constants/permissions.js +1 -2
- package/dist/constants/permissions.js.map +1 -1
- package/dist/dev/main.d.ts +0 -0
- package/dist/generated/global-operations.d.ts +2119 -0
- package/dist/generated/global-operations.js +80 -69
- package/dist/generated/global-operations.js.map +1 -1
- package/dist/generated/global-types.d.ts +23507 -0
- package/dist/generated/wspace-operations.d.ts +4 -0
- package/dist/generated/wspace-types.d.ts +57831 -0
- package/dist/graphql/global-client.d.ts +32 -0
- package/dist/graphql/global-client.js +23 -30
- package/dist/graphql/global-client.js.map +1 -1
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.js +7 -6
- package/dist/hooks/useNotificationAdmin.d.ts +46 -0
- package/dist/hooks/useNotificationAdmin.js +18 -17
- package/dist/hooks/useNotificationAdmin.js.map +1 -1
- package/dist/hooks/useNotificationAnalytics.d.ts +65 -0
- package/dist/hooks/useNotificationAnalytics.js +1 -2
- package/dist/hooks/useNotificationAnalytics.js.map +1 -1
- package/dist/hooks/useNotificationPreferences.d.ts +10 -0
- package/dist/hooks/useNotificationPreferences.js +7 -7
- package/dist/hooks/useNotificationPreferences.js.map +1 -1
- package/dist/hooks/useNotificationTemplates.d.ts +131 -0
- package/dist/hooks/useNotificationTemplates.js +1 -2
- package/dist/hooks/useNotificationTemplates.js.map +1 -1
- package/dist/hooks/useNotificationTopics.d.ts +35 -0
- package/dist/hooks/useNotificationTopics.js +22 -22
- package/dist/hooks/useNotificationTopics.js.map +1 -1
- package/dist/hooks/useNotifications.d.ts +39 -0
- package/dist/hooks/useNotifications.js +6 -4
- package/dist/hooks/useNotifications.js.map +1 -1
- package/dist/hooks/usePreferenceToggles.d.ts +27 -0
- package/dist/hooks/usePreferenceToggles.js +84 -0
- package/dist/hooks/usePreferenceToggles.js.map +1 -0
- package/dist/hooks/useSendNotification.d.ts +158 -0
- package/dist/hooks/useSendNotification.js +12 -10
- package/dist/hooks/useSendNotification.js.map +1 -1
- package/dist/hooks/useUserSearch.d.ts +26 -0
- package/dist/hooks/useUserSearch.js +8 -10
- package/dist/hooks/useUserSearch.js.map +1 -1
- package/dist/index.d.ts +36 -0
- package/dist/index.js +8 -8
- package/dist/navigation-v2/AdminPageV2.d.ts +14 -0
- package/dist/navigation-v2/AdminPageV2.js +51 -0
- package/dist/navigation-v2/AdminPageV2.js.map +1 -0
- package/dist/navigation-v2/AdminToolsMenu.d.ts +6 -0
- package/dist/navigation-v2/AdminToolsMenu.js +32 -0
- package/dist/navigation-v2/AdminToolsMenu.js.map +1 -0
- package/dist/navigation-v2/BackToNotifications.d.ts +2 -0
- package/dist/navigation-v2/BackToNotifications.js +20 -0
- package/dist/navigation-v2/BackToNotifications.js.map +1 -0
- package/dist/navigation-v2/FilterControls.d.ts +25 -0
- package/dist/navigation-v2/FilterControls.js +64 -0
- package/dist/navigation-v2/FilterControls.js.map +1 -0
- package/dist/navigation-v2/NotificationArchivedV2.d.ts +9 -0
- package/dist/navigation-v2/NotificationArchivedV2.js +174 -0
- package/dist/navigation-v2/NotificationArchivedV2.js.map +1 -0
- package/dist/navigation-v2/NotificationInboxV2.d.ts +9 -0
- package/dist/navigation-v2/NotificationInboxV2.js +309 -0
- package/dist/navigation-v2/NotificationInboxV2.js.map +1 -0
- package/dist/navigation-v2/NotificationSettingsV2.d.ts +9 -0
- package/dist/navigation-v2/NotificationSettingsV2.js +203 -0
- package/dist/navigation-v2/NotificationSettingsV2.js.map +1 -0
- package/dist/navigation-v2/NotificationsV2Landing.d.ts +9 -0
- package/dist/navigation-v2/NotificationsV2Landing.js +37 -0
- package/dist/navigation-v2/NotificationsV2Landing.js.map +1 -0
- package/dist/navigation-v2/__tests__/uiMocks.d.ts +71 -0
- package/dist/navigation-v2/inboxFilters.d.ts +8 -0
- package/dist/navigation-v2/inboxFilters.js +10 -0
- package/dist/navigation-v2/inboxFilters.js.map +1 -0
- package/dist/navigation-v2/paths.d.ts +24 -0
- package/dist/navigation-v2/paths.js +31 -0
- package/dist/navigation-v2/paths.js.map +1 -0
- package/dist/navigation-v2/settingsOptions.d.ts +12 -0
- package/dist/navigation-v2/settingsOptions.js +58 -0
- package/dist/navigation-v2/settingsOptions.js.map +1 -0
- package/dist/navigation-v2/useAdminTools.d.ts +22 -0
- package/dist/navigation-v2/useAdminTools.js +76 -0
- package/dist/navigation-v2/useAdminTools.js.map +1 -0
- package/dist/node_modules/@apollo/client/errors/CombinedGraphQLErrors.js +1 -2
- package/dist/node_modules/@apollo/client/errors/CombinedGraphQLErrors.js.map +1 -1
- package/dist/node_modules/@apollo/client/errors/utils.js +1 -2
- package/dist/node_modules/@apollo/client/errors/utils.js.map +1 -1
- package/dist/node_modules/@apollo/client/link/core/ApolloLink.js +7 -8
- package/dist/node_modules/@apollo/client/link/core/ApolloLink.js.map +1 -1
- package/dist/node_modules/@apollo/client/link/subscriptions/index.js +9 -10
- package/dist/node_modules/@apollo/client/link/subscriptions/index.js.map +1 -1
- package/dist/node_modules/@apollo/client/link/utils/createOperation.js +5 -6
- package/dist/node_modules/@apollo/client/link/utils/createOperation.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/caching/sizes.js +0 -1
- package/dist/node_modules/@apollo/client/utilities/caching/sizes.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/graphql/print.js +4 -5
- package/dist/node_modules/@apollo/client/utilities/graphql/print.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/caches.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/caches.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/checkDocument.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/checkDocument.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/getMainDefinition.js +2 -3
- package/dist/node_modules/@apollo/client/utilities/internal/getMainDefinition.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/getMemoryInternals.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/getMemoryInternals.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/getOperationDefinition.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/getOperationDefinition.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/getOperationName.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/getOperationName.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/globals/global.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/globals/global.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/globals/maybe.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/globals/maybe.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/isNonNullObject.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/isNonNullObject.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/makeUniqueId.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/makeUniqueId.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/memoize.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/memoize.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/internal/stringifyForDisplay.js +1 -2
- package/dist/node_modules/@apollo/client/utilities/internal/stringifyForDisplay.js.map +1 -1
- package/dist/node_modules/@apollo/client/utilities/invariant/index.js +2 -3
- package/dist/node_modules/@apollo/client/utilities/invariant/index.js.map +1 -1
- package/dist/node_modules/@apollo/client/version.js +2 -3
- package/dist/node_modules/@apollo/client/version.js.map +1 -1
- package/dist/node_modules/@wry/caches/lib/weak.js +1 -2
- package/dist/node_modules/@wry/caches/lib/weak.js.map +1 -1
- package/dist/node_modules/@wry/trie/lib/index.js +2 -3
- package/dist/node_modules/@wry/trie/lib/index.js.map +1 -1
- package/dist/node_modules/graphql-ws/dist/client.js +76 -69
- package/dist/node_modules/graphql-ws/dist/client.js.map +1 -1
- package/dist/node_modules/graphql-ws/dist/common-CGW11Fyb.js +2 -3
- package/dist/node_modules/graphql-ws/dist/common-CGW11Fyb.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/NotificationFactories.js +2 -3
- package/dist/node_modules/rxjs/dist/esm5/internal/NotificationFactories.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/Observable.js +41 -42
- package/dist/node_modules/rxjs/dist/esm5/internal/Observable.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/Subscriber.js +14 -15
- package/dist/node_modules/rxjs/dist/esm5/internal/Subscriber.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/Subscription.js +21 -18
- package/dist/node_modules/rxjs/dist/esm5/internal/Subscription.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/config.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/config.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/observable/empty.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/observable/empty.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js +2 -3
- package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/symbol/observable.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/symbol/observable.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/arrRemove.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/util/arrRemove.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/errorContext.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/util/errorContext.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/identity.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/util/identity.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isFunction.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isFunction.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/noop.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/util/noop.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/pipe.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/util/pipe.js.map +1 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js +1 -2
- package/dist/node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js.map +1 -1
- package/dist/node_modules/{rxjs/node_modules/tslib → tslib}/tslib.es6.js +1 -2
- package/dist/node_modules/tslib/tslib.es6.js.map +1 -0
- package/dist/pages/CreateNotificationPage.d.ts +5 -0
- package/dist/pages/CreateNotificationPage.js +591 -573
- package/dist/pages/CreateNotificationPage.js.map +1 -1
- package/dist/pages/NotificationCenterPage.d.ts +8 -0
- package/dist/pages/NotificationCenterPage.js +87 -83
- package/dist/pages/NotificationCenterPage.js.map +1 -1
- package/dist/pages/NotificationHistoryAdminPage.d.ts +2 -0
- package/dist/pages/NotificationHistoryAdminPage.js +7 -8
- package/dist/pages/NotificationHistoryAdminPage.js.map +1 -1
- package/dist/pages/NotificationHistoryPage.d.ts +6 -0
- package/dist/pages/NotificationHistoryPage.js +59 -55
- package/dist/pages/NotificationHistoryPage.js.map +1 -1
- package/dist/pages/NotificationLandingPage.d.ts +10 -0
- package/dist/pages/NotificationLandingPage.js +5 -6
- package/dist/pages/NotificationLandingPage.js.map +1 -1
- package/dist/pages/NotificationPreferencesPage.d.ts +5 -0
- package/dist/pages/NotificationPreferencesPage.js +97 -159
- package/dist/pages/NotificationPreferencesPage.js.map +1 -1
- package/dist/pages/NotificationTemplatesPage.d.ts +7 -0
- package/dist/pages/NotificationTemplatesPage.js +192 -172
- package/dist/pages/NotificationTemplatesPage.js.map +1 -1
- package/dist/pages/NotificationTopicsPage.d.ts +1 -0
- package/dist/pages/NotificationTopicsPage.js +126 -112
- package/dist/pages/NotificationTopicsPage.js.map +1 -1
- package/dist/pages/TemplateEditorPage.d.ts +12 -0
- package/dist/pages/TemplateEditorPage.js +381 -341
- package/dist/pages/TemplateEditorPage.js.map +1 -1
- package/dist/providers/NotificationProvider.d.ts +11 -0
- package/dist/providers/NotificationProvider.js +7 -7
- package/dist/providers/NotificationProvider.js.map +1 -1
- package/dist/shared/hooks/useTr.d.ts +13 -0
- package/dist/shared/hooks/useTr.js +1 -2
- package/dist/shared/hooks/useTr.js.map +1 -1
- package/dist/store/notificationStore.d.ts +30 -0
- package/dist/store/notificationStore.js +1 -2
- package/dist/store/notificationStore.js.map +1 -1
- package/dist/test/happydom.d.ts +1 -0
- package/dist/translations/en.d.ts +468 -0
- package/dist/types/index.d.ts +257 -0
- package/dist/utils/inAppNavigation.d.ts +37 -0
- package/dist/utils/inAppNavigation.js +2 -3
- package/dist/utils/inAppNavigation.js.map +1 -1
- package/dist/utils/index.d.ts +68 -0
- package/dist/utils/index.js +1 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/nativeBridge.d.ts +2 -0
- package/dist/utils/nativeBridge.js +1 -2
- package/dist/utils/notificationHistoryExport.d.ts +12 -0
- package/dist/utils/notificationHistoryExport.js +1 -2
- package/dist/utils/notificationHistoryExport.js.map +1 -1
- package/package.json +67 -49
- package/dist/node_modules/rxjs/node_modules/tslib/tslib.es6.js.map +0 -1
|
@@ -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, USER_NOTIFICATION_CONTEXT } 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 context: USER_NOTIFICATION_CONTEXT,\n query: GetMyUnreadNotificationCountDocument,\n variables: { filter: { channel: 'IN_APP' } },\n fetchPolicy: 'network-only',\n });\n\n if (typeof result.data?.myUnreadNotificationCount === 'number') {\n setUnreadCount(result.data.myUnreadNotificationCount);\n }\n } catch {\n // Keep bell resilient; do not surface errors here.\n }\n }, [apiGatewayUrl, authToken, setUnreadCount]);\n\n useEffect(() => {\n refreshUnreadCount();\n }, [refreshUnreadCount]);\n\n useEffect(() => {\n if (!currentUser?.id) return undefined;\n\n const client = getGlobalNotificationClient(apiGatewayUrl ?? undefined, authToken ?? undefined);\n const subscription = client\n .subscribe<UnreadCountUpdatedSubscription>({\n query: UnreadCountUpdatedDocument,\n variables: { userId: currentUser.id },\n })\n .subscribe({\n next: (result) => {\n const nextCount = result.data?.unreadCountUpdated;\n if (typeof nextCount === 'number') {\n setUnreadCount(nextCount);\n }\n },\n error: () => {\n // Keep the header resilient; visibility refresh below handles recovery.\n },\n });\n\n return () => subscription.unsubscribe();\n }, [apiGatewayUrl, authToken, currentUser?.id, setUnreadCount]);\n\n useEffect(() => {\n const handleVisibilityChange = () => {\n if (document.visibilityState === 'visible') {\n refreshUnreadCount();\n }\n };\n\n document.addEventListener('visibilitychange', handleVisibilityChange);\n return () => document.removeEventListener('visibilitychange', handleVisibilityChange);\n }, [refreshUnreadCount]);\n\n const handleClick = () => {\n if (onClick) {\n onClick();\n } else {\n togglePanel();\n }\n };\n\n return (\n <button\n data-tour=\"notification-bell\"\n onClick={handleClick}\n className=\"relative inline-flex items-center justify-center p-2 rounded-md hover:bg-bg-sunken transition-all duration-150\"\n aria-label={`${tr('notifCommon.notifications', 'Notifications')}${unreadCount > 0 ? ` (${unreadCount} ${tr('notifCommon.unread', 'unread')})` : ''}`}\n >\n <Bell size={20} className=\"text-primary\" />\n {unreadCount > 0 && (\n <span className=\"absolute top-1 right-1 flex items-center justify-center min-w-[18px] h-[18px] px-1 text-xs font-semibold tabular-nums text-white bg-error rounded-full motion-safe:animate-vc-glow-pulse\">\n {unreadCount > 99 ? '99+' : unreadCount}\n </span>\n )}\n </button>\n );\n}\n"],"mappings":";;;;;;;;;AAyBA,
|
|
1
|
+
{"version":3,"file":"NotificationBell.js","names":["NotificationBell","tr","useTr","useNotification","useNotificationStore","refreshUnreadCount","useCallback","result","getGlobalNotificationClient","apiGatewayUrl","authToken","USER_NOTIFICATION_CONTEXT","GetMyUnreadNotificationCountDocument","setUnreadCount","useEffect","currentUser","subscription","UnreadCountUpdatedDocument","nextCount","handleVisibilityChange","onClick","togglePanel","unreadCount","Bell"],"sources":["../../src/components/NotificationBell.tsx"],"sourcesContent":["import { useCallback, useEffect } from 'react';\nimport { Bell } from 'lucide-react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient, USER_NOTIFICATION_CONTEXT } 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 context: USER_NOTIFICATION_CONTEXT,\n query: GetMyUnreadNotificationCountDocument,\n variables: { filter: { channel: 'IN_APP' } },\n fetchPolicy: 'network-only',\n });\n\n if (typeof result.data?.myUnreadNotificationCount === 'number') {\n setUnreadCount(result.data.myUnreadNotificationCount);\n }\n } catch {\n // Keep bell resilient; do not surface errors here.\n }\n }, [apiGatewayUrl, authToken, setUnreadCount]);\n\n useEffect(() => {\n refreshUnreadCount();\n }, [refreshUnreadCount]);\n\n useEffect(() => {\n if (!currentUser?.id) return undefined;\n\n const client = getGlobalNotificationClient(apiGatewayUrl ?? undefined, authToken ?? undefined);\n const subscription = client\n .subscribe<UnreadCountUpdatedSubscription>({\n query: UnreadCountUpdatedDocument,\n variables: { userId: currentUser.id },\n })\n .subscribe({\n next: (result) => {\n const nextCount = result.data?.unreadCountUpdated;\n if (typeof nextCount === 'number') {\n setUnreadCount(nextCount);\n }\n },\n error: () => {\n // Keep the header resilient; visibility refresh below handles recovery.\n },\n });\n\n return () => subscription.unsubscribe();\n }, [apiGatewayUrl, authToken, currentUser?.id, setUnreadCount]);\n\n useEffect(() => {\n const handleVisibilityChange = () => {\n if (document.visibilityState === 'visible') {\n refreshUnreadCount();\n }\n };\n\n document.addEventListener('visibilitychange', handleVisibilityChange);\n return () => document.removeEventListener('visibilitychange', handleVisibilityChange);\n }, [refreshUnreadCount]);\n\n const handleClick = () => {\n if (onClick) {\n onClick();\n } else {\n togglePanel();\n }\n };\n\n return (\n <button\n data-tour=\"notification-bell\"\n onClick={handleClick}\n className=\"relative inline-flex items-center justify-center p-2 rounded-md hover:bg-bg-sunken transition-all duration-150\"\n aria-label={`${tr('notifCommon.notifications', 'Notifications')}${unreadCount > 0 ? ` (${unreadCount} ${tr('notifCommon.unread', 'unread')})` : ''}`}\n >\n <Bell size={20} className=\"text-primary\" />\n {unreadCount > 0 && (\n <span className=\"absolute top-1 right-1 flex items-center justify-center min-w-[18px] h-[18px] px-1 text-xs font-semibold tabular-nums text-white bg-error rounded-full motion-safe:animate-vc-glow-pulse\">\n {unreadCount > 99 ? '99+' : unreadCount}\n </span>\n )}\n </button>\n );\n}\n"],"mappings":";;;;;;;;;AAyBA,SAAgBA,EAAiB,EAAE,cAAqC;CACtE,IAAMC,IAAKC,EAAM,GACX,EAAE,cAAW,kBAAe,mBAAgBC,EAAgB,GAC5D,EAAE,gBAAa,gBAAa,sBAAmBC,EAAqB,GAEpEC,IAAqBC,EAAY,YAAY;EACjD,IAAI;GAKF,IAAMC,IAAS,MAJAC,EACbC,KAAiB,KAAA,GACjBC,KAAa,KAAA,CAEM,CAAA,CAAO,MAAyC;IACnE,SAASC;IACT,OAAOC;IACP,WAAW,EAAE,QAAQ,EAAE,SAAS,SAAS,EAAE;IAC3C,aAAa;GACf,CAAC;GAED,AAAI,OAAOL,EAAO,MAAM,6BAA8B,YACpDM,EAAeN,EAAO,KAAK,yBAAyB;EAExD,QAAQ,CAER;CACF,GAAG;EAACE;EAAeC;EAAWG;CAAc,CAAC;CAiD7C,OA/CAC,QAAgB;EACd,EAAmB;CACrB,GAAG,CAACT,CAAkB,CAAC,GAEvBS,QAAgB;EACd,IAAI,CAACC,GAAa,IAAI;EAGtB,IAAMC,IADSR,EAA4BC,KAAiB,KAAA,GAAWC,KAAa,KAAA,CAC/D,CAAA,CAClB,UAA0C;GACzC,OAAOO;GACP,WAAW,EAAE,QAAQF,EAAY,GAAG;EACtC,CAAC,CAAC,CACD,UAAU;GACT,OAAO,MAAW;IAChB,IAAMG,IAAYX,EAAO,MAAM;IAC/B,AAAI,OAAOW,KAAc,YACvBL,EAAeK,CAAS;GAE5B;GACA,aAAa,CAEb;EACF,CAAC;EAEH,aAAaF,EAAa,YAAY;CACxC,GAAG;EAACP;EAAeC;EAAWK,GAAa;EAAIF;CAAc,CAAC,GAE9DC,QAAgB;EACd,IAAMK,UAA+B;GACnC,AAAI,SAAS,oBAAoB,aAC/Bd,EAAmB;EAEvB;EAGA,OADA,SAAS,iBAAiB,oBAAoBc,CAAsB,SACvD,SAAS,oBAAoB,oBAAoBA,CAAsB;CACtF,GAAG,CAACd,CAAkB,CAAC,GAWrB,kBAAC,UAAD;EACE,aAAU;EACV,eAXsB;GACxB,AAAIe,IACFA,EAAQ,IAERC,EAAY;EAEhB;EAMI,WAAU;EACV,cAAY,GAAGpB,EAAG,6BAA6B,eAAe,IAAIqB,IAAc,IAAI,KAAKA,EAAY,GAAGrB,EAAG,sBAAsB,QAAQ,EAAE,KAAK;EAJlJ,UAAA,CAME,kBAACsB,GAAD;GAAM,MAAM;GAAI,WAAU;EAAgB,CAAA,GACzCD,IAAc,KACb,kBAAC,QAAD;GAAM,WAAU;GACb,UAAAA,IAAc,KAAK,QAAQA;EACxB,CAAA,CAEF;;AAEZ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Notification } from '../types';
|
|
2
|
+
interface NotificationCardProps {
|
|
3
|
+
notification: Notification;
|
|
4
|
+
onMarkAsRead?: (id: string) => void;
|
|
5
|
+
onArchive?: (id: string) => void;
|
|
6
|
+
onAction?: (notificationId: string, actionId?: string) => void;
|
|
7
|
+
onClick?: (notification: Notification) => void;
|
|
8
|
+
showArchivedState?: boolean;
|
|
9
|
+
compact?: boolean;
|
|
10
|
+
analyticsSource?: 'center' | 'panel' | 'history' | 'admin_history';
|
|
11
|
+
/**
|
|
12
|
+
* FluidGrids' Navigation v2 card (BOFF-11872): an archive icon with an
|
|
13
|
+
* "Archive" tooltip instead of "X", the priority footer only for Urgent or
|
|
14
|
+
* High (sentence case), "Open" for the link, and the topic chip only when
|
|
15
|
+
* `showTopic` is on. Other apps leave it off and keep today's card.
|
|
16
|
+
*/
|
|
17
|
+
navigationV2?: boolean;
|
|
18
|
+
/** Navigation v2 only: show the topic chip (a level-2 detail). */
|
|
19
|
+
showTopic?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Notification card component
|
|
23
|
+
*
|
|
24
|
+
* Displays notification information with action buttons
|
|
25
|
+
*/
|
|
26
|
+
export declare function NotificationCard({ notification, onMarkAsRead, onArchive, onAction, onClick, showArchivedState, compact, analyticsSource, navigationV2, showTopic, }: NotificationCardProps): import('react').JSX.Element;
|
|
27
|
+
export {};
|
|
@@ -1,120 +1,150 @@
|
|
|
1
1
|
import { useNotificationAnalytics as e } from "../hooks/useNotificationAnalytics.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useTr as t } from "../shared/hooks/useTr.js";
|
|
3
|
+
import { formatRelativeTime as n, getNotificationTypeIcon as r, getPriorityColor as i, getPriorityIcon as a, truncateText as o } from "../utils/index.js";
|
|
4
4
|
import { nativeImpact as s, nativeOpenUrl as c } from "../utils/nativeBridge.js";
|
|
5
5
|
import { navigateInApp as l } from "../utils/inAppNavigation.js";
|
|
6
|
-
import {
|
|
7
|
-
import { Fragment as
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
6
|
+
import { Archive as u, ExternalLink as d, X as f } from "lucide-react";
|
|
7
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
8
|
+
import { Tooltip as g, TooltipContent as _, TooltipTrigger as v } from "@burdenoff/fe-libs/ui";
|
|
9
|
+
// src/components/NotificationCard.tsx
|
|
10
|
+
var y = {
|
|
11
|
+
URGENT: {
|
|
12
|
+
key: "notifications.priorityUrgent",
|
|
13
|
+
label: "Urgent"
|
|
14
|
+
},
|
|
15
|
+
HIGH: {
|
|
16
|
+
key: "notifications.priorityHigh",
|
|
17
|
+
label: "High"
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
function b({ notification: b, onMarkAsRead: x, onArchive: S, onAction: C, onClick: w, showArchivedState: T = !1, compact: E = !1, analyticsSource: D = "center", navigationV2: O = !1, showTopic: k = !1 }) {
|
|
21
|
+
let A = t(), { trackNotificationOpened: j } = e(), M = !b.readAt, N = !!b.archivedAt, P = y[b.priority], F = () => {
|
|
22
|
+
j(b, D, "card"), w && w(b), M && x && x(b.id);
|
|
23
|
+
}, I = (e) => {
|
|
24
|
+
e.stopPropagation(), S && S(b.id);
|
|
25
|
+
}, L = (e) => {
|
|
15
26
|
l(e) || (e.startsWith("https://") ? c(e) : window.open(e, "_blank", "noopener,noreferrer"));
|
|
16
|
-
},
|
|
17
|
-
e.stopPropagation(), s("light"),
|
|
18
|
-
},
|
|
19
|
-
e.stopPropagation(), s("light"),
|
|
27
|
+
}, R = (e) => {
|
|
28
|
+
e.stopPropagation(), s("light"), b.actionUrl && (j(b, D, "primary_action"), C?.(b.id), L(b.actionUrl));
|
|
29
|
+
}, z = (e, t, n) => {
|
|
30
|
+
e.stopPropagation(), s("light"), j(b, D, "custom_action"), C?.(b.id, t), L(n);
|
|
20
31
|
};
|
|
21
|
-
return /* @__PURE__ */
|
|
32
|
+
return /* @__PURE__ */ h("div", {
|
|
22
33
|
"data-tour": "notification-card",
|
|
23
34
|
className: `
|
|
24
35
|
relative flex flex-col gap-2 p-4 rounded-lg border cursor-pointer
|
|
25
36
|
transition-[box-shadow,border-color,opacity] duration-200 ease-in-out
|
|
26
37
|
bg-gloss-card
|
|
27
|
-
${
|
|
28
|
-
${
|
|
38
|
+
${M ? "border-accent-primary/30 shadow-sm ring-1 ring-accent-primary/10" : "border-border-seam opacity-75"}
|
|
39
|
+
${T && N ? "border-dashed opacity-60" : ""}
|
|
29
40
|
hover:shadow-[var(--shadow-pop)] hover:border-accent-primary/30 hover:opacity-100
|
|
30
41
|
`,
|
|
31
|
-
onClick:
|
|
42
|
+
onClick: F,
|
|
32
43
|
children: [
|
|
33
|
-
|
|
34
|
-
/* @__PURE__ */
|
|
44
|
+
M && /* @__PURE__ */ m("div", { className: "absolute top-4 left-1.5 w-2.5 h-2.5 bg-accent-primary rounded-full shadow-sm shadow-accent-primary/50 motion-safe:animate-vc-glow-pulse" }),
|
|
45
|
+
/* @__PURE__ */ h("div", {
|
|
35
46
|
className: "flex items-start justify-between gap-2 ml-3",
|
|
36
|
-
children: [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
children: [
|
|
48
|
+
/* @__PURE__ */ h("div", {
|
|
49
|
+
className: "flex items-center gap-2 flex-1 min-w-0",
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ m("span", {
|
|
52
|
+
className: "text-base",
|
|
53
|
+
"aria-hidden": "true",
|
|
54
|
+
children: r(b.type)
|
|
55
|
+
}),
|
|
56
|
+
/* @__PURE__ */ m("h3", {
|
|
57
|
+
className: `text-sm truncate ${M ? "font-bold text-primary" : "font-medium text-secondary"}`,
|
|
58
|
+
children: E ? o(b.title, 60) : b.title
|
|
59
|
+
}),
|
|
60
|
+
/* @__PURE__ */ m("span", {
|
|
61
|
+
className: "text-xs",
|
|
62
|
+
"aria-label": `Priority: ${b.priority}`,
|
|
63
|
+
children: a(b.priority)
|
|
64
|
+
})
|
|
65
|
+
]
|
|
66
|
+
}),
|
|
67
|
+
S && O && /* @__PURE__ */ h(g, { children: [/* @__PURE__ */ m(v, {
|
|
68
|
+
asChild: !0,
|
|
69
|
+
children: /* @__PURE__ */ m("button", {
|
|
70
|
+
type: "button",
|
|
71
|
+
"data-tour": "notification-archive-action",
|
|
72
|
+
onClick: I,
|
|
73
|
+
className: "flex-shrink-0 rounded p-1 transition-colors duration-150 hover:bg-bg-sunken focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]",
|
|
74
|
+
"aria-label": A("notifCommon.archiveNotification", "Archive notification"),
|
|
75
|
+
children: /* @__PURE__ */ m(u, {
|
|
76
|
+
size: 16,
|
|
77
|
+
className: "text-tertiary hover:text-secondary",
|
|
78
|
+
"aria-hidden": "true"
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
}), /* @__PURE__ */ m(_, { children: A("notifications.v2.archive", "Archive") })] }),
|
|
82
|
+
S && !O && /* @__PURE__ */ m("button", {
|
|
83
|
+
"data-tour": "notification-archive-action",
|
|
84
|
+
onClick: I,
|
|
85
|
+
className: "flex-shrink-0 p-1 hover:bg-bg-sunken rounded transition-colors duration-150",
|
|
86
|
+
"aria-label": A("notifCommon.archiveNotification", "Archive notification"),
|
|
87
|
+
children: /* @__PURE__ */ m(f, {
|
|
88
|
+
size: 16,
|
|
89
|
+
className: "text-tertiary hover:text-secondary"
|
|
52
90
|
})
|
|
53
|
-
]
|
|
54
|
-
}), _ && /* @__PURE__ */ p("button", {
|
|
55
|
-
"data-tour": "notification-archive-action",
|
|
56
|
-
onClick: O,
|
|
57
|
-
className: "flex-shrink-0 p-1 hover:bg-bg-sunken rounded transition-colors duration-150",
|
|
58
|
-
"aria-label": C("notifCommon.archiveNotification", "Archive notification"),
|
|
59
|
-
children: /* @__PURE__ */ p(d, {
|
|
60
|
-
size: 16,
|
|
61
|
-
className: "text-tertiary hover:text-secondary"
|
|
62
91
|
})
|
|
63
|
-
|
|
92
|
+
]
|
|
64
93
|
}),
|
|
65
|
-
/* @__PURE__ */
|
|
94
|
+
/* @__PURE__ */ h("div", {
|
|
66
95
|
className: "ml-3",
|
|
67
96
|
children: [
|
|
68
|
-
|
|
69
|
-
src:
|
|
70
|
-
alt:
|
|
97
|
+
b.media[0]?.url && /* @__PURE__ */ m("img", {
|
|
98
|
+
src: b.media[0].thumbnailUrl || b.media[0].url,
|
|
99
|
+
alt: b.media[0].label || b.title,
|
|
71
100
|
className: "mb-3 h-40 w-full rounded-md object-cover border border-default"
|
|
72
101
|
}),
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
className: `text-sm text-secondary ${
|
|
75
|
-
children:
|
|
102
|
+
/* @__PURE__ */ m("p", {
|
|
103
|
+
className: `text-sm text-secondary ${E ? "line-clamp-2" : ""}`,
|
|
104
|
+
children: E ? o(b.body, 120) : b.body
|
|
76
105
|
}),
|
|
77
|
-
|
|
106
|
+
b.topic && (!O || k) && /* @__PURE__ */ m("div", {
|
|
78
107
|
className: "mt-2 inline-flex items-center rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary",
|
|
79
|
-
children:
|
|
108
|
+
children: b.topic.name
|
|
80
109
|
})
|
|
81
110
|
]
|
|
82
111
|
}),
|
|
83
|
-
|
|
112
|
+
b.actions.length > 0 && !E && /* @__PURE__ */ m("div", {
|
|
84
113
|
className: "ml-3 flex flex-wrap gap-2",
|
|
85
|
-
children:
|
|
86
|
-
onClick: (t) =>
|
|
114
|
+
children: b.actions.map((e) => /* @__PURE__ */ m("button", {
|
|
115
|
+
onClick: (t) => z(t, e.id, e.url),
|
|
87
116
|
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
117
|
children: e.label
|
|
89
118
|
}, e.id))
|
|
90
119
|
}),
|
|
91
|
-
/* @__PURE__ */
|
|
120
|
+
/* @__PURE__ */ h("div", {
|
|
92
121
|
className: "flex items-center justify-between gap-2 ml-3",
|
|
93
|
-
children: [/* @__PURE__ */
|
|
122
|
+
children: [/* @__PURE__ */ h("div", {
|
|
94
123
|
className: "flex items-center gap-2 text-xs text-tertiary",
|
|
95
124
|
children: [
|
|
96
|
-
/* @__PURE__ */ p("span", {
|
|
97
|
-
className:
|
|
98
|
-
children:
|
|
99
|
-
}),
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
/* @__PURE__ */
|
|
103
|
-
|
|
104
|
-
|
|
125
|
+
O ? P && /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m("span", {
|
|
126
|
+
className: i(b.priority),
|
|
127
|
+
children: A(P.key, P.label)
|
|
128
|
+
}), /* @__PURE__ */ m("span", { children: "•" })] }) : /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m("span", {
|
|
129
|
+
className: i(b.priority),
|
|
130
|
+
children: b.priority
|
|
131
|
+
}), /* @__PURE__ */ m("span", { children: "•" })] }),
|
|
132
|
+
T && N && /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m("span", { children: A("notifCommon.archived", "Archived") }), /* @__PURE__ */ m("span", { children: "•" })] }),
|
|
133
|
+
/* @__PURE__ */ m("time", {
|
|
134
|
+
dateTime: b.createdAt,
|
|
135
|
+
children: n(b.createdAt, A)
|
|
105
136
|
})
|
|
106
137
|
]
|
|
107
|
-
}),
|
|
108
|
-
onClick:
|
|
138
|
+
}), b.actionUrl && /* @__PURE__ */ h("button", {
|
|
139
|
+
onClick: R,
|
|
109
140
|
className: "flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/80 transition-colors duration-150",
|
|
110
|
-
"aria-label":
|
|
111
|
-
children: [/* @__PURE__ */
|
|
141
|
+
"aria-label": A("notifCommon.openLink", "Open link"),
|
|
142
|
+
children: [/* @__PURE__ */ m("span", { children: O ? A("notifications.v2.open", "Open") : A("notifCommon.view", "View") }), /* @__PURE__ */ m(d, { size: 12 })]
|
|
112
143
|
})]
|
|
113
144
|
})
|
|
114
145
|
]
|
|
115
146
|
});
|
|
116
147
|
}
|
|
117
|
-
|
|
118
|
-
export { h as NotificationCard };
|
|
148
|
+
export { b as NotificationCard };
|
|
119
149
|
|
|
120
150
|
//# sourceMappingURL=NotificationCard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationCard.js","names":[],"sources":["../../src/components/NotificationCard.tsx"],"sourcesContent":["import { X, ExternalLink } from 'lucide-react';\nimport type { Notification } from '../types';\nimport { useNotificationAnalytics } from '../hooks/useNotificationAnalytics';\nimport { useTr } from '../shared/hooks/useTr';\nimport {\n formatRelativeTime,\n getPriorityColor,\n getPriorityIcon,\n getNotificationTypeIcon,\n truncateText,\n} from '../utils';\nimport { nativeImpact, nativeOpenUrl } from '../utils/nativeBridge';\nimport { navigateInApp } from '../utils/inAppNavigation';\n\ninterface NotificationCardProps {\n notification: Notification;\n onMarkAsRead?: (id: string) => void;\n onArchive?: (id: string) => void;\n onAction?: (notificationId: string, actionId?: string) => void;\n onClick?: (notification: Notification) => void;\n showArchivedState?: boolean;\n compact?: boolean;\n analyticsSource?: 'center' | 'panel' | 'history' | 'admin_history';\n}\n\n/**\n * Notification card component\n *\n * Displays notification information with action buttons\n */\nexport function NotificationCard({\n notification,\n onMarkAsRead,\n onArchive,\n onAction,\n onClick,\n showArchivedState = false,\n compact = false,\n analyticsSource = 'center',\n}: NotificationCardProps) {\n const tr = useTr();\n const { trackNotificationOpened } = useNotificationAnalytics();\n const isUnread = !notification.readAt;\n const isArchived = Boolean(notification.archivedAt);\n\n const handleClick = () => {\n trackNotificationOpened(notification, analyticsSource, 'card');\n if (onClick) {\n onClick(notification);\n }\n if (isUnread && onMarkAsRead) {\n onMarkAsRead(notification.id);\n }\n };\n\n const handleArchive = (e: React.MouseEvent) => {\n e.stopPropagation();\n if (onArchive) {\n onArchive(notification.id);\n }\n };\n\n // A link into this app (an agent, a run, a vibe) opens in place, like the\n // shell's notification bell; only a link that leaves the app opens a new tab\n // (or the system browser on native).\n const openNotificationLink = (url: string) => {\n if (navigateInApp(url)) return;\n if (url.startsWith('https://')) {\n void nativeOpenUrl(url);\n } else {\n window.open(url, '_blank', 'noopener,noreferrer');\n }\n };\n\n const handleActionUrl = (e: React.MouseEvent) => {\n e.stopPropagation();\n nativeImpact('light');\n if (notification.actionUrl) {\n trackNotificationOpened(notification, analyticsSource, 'primary_action');\n onAction?.(notification.id);\n openNotificationLink(notification.actionUrl);\n }\n };\n\n const handleActionClick = (e: React.MouseEvent, actionId: string, actionUrl: string) => {\n e.stopPropagation();\n nativeImpact('light');\n trackNotificationOpened(notification, analyticsSource, 'custom_action');\n onAction?.(notification.id, actionId);\n openNotificationLink(actionUrl);\n };\n\n return (\n <div\n data-tour=\"notification-card\"\n className={`\n relative flex flex-col gap-2 p-4 rounded-lg border cursor-pointer\n transition-[box-shadow,border-color,opacity] duration-200 ease-in-out\n bg-gloss-card\n ${isUnread ? 'border-accent-primary/30 shadow-sm ring-1 ring-accent-primary/10' : 'border-border-seam opacity-75'}\n ${showArchivedState && isArchived ? 'border-dashed opacity-60' : ''}\n hover:shadow-[var(--shadow-pop)] hover:border-accent-primary/30 hover:opacity-100\n `}\n onClick={handleClick}\n >\n {/* Unread indicator */}\n {isUnread && (\n <div className=\"absolute top-4 left-1.5 w-2.5 h-2.5 bg-accent-primary rounded-full shadow-sm shadow-accent-primary/50 motion-safe:animate-vc-glow-pulse\" />\n )}\n\n {/* Header */}\n <div className=\"flex items-start justify-between gap-2 ml-3\">\n <div className=\"flex items-center gap-2 flex-1 min-w-0\">\n <span className=\"text-base\" aria-hidden=\"true\">\n {getNotificationTypeIcon(notification.type)}\n </span>\n <h3\n className={`text-sm truncate ${isUnread ? 'font-bold text-primary' : 'font-medium text-secondary'}`}\n >\n {compact ? truncateText(notification.title, 60) : notification.title}\n </h3>\n <span className=\"text-xs\" aria-label={`Priority: ${notification.priority}`}>\n {getPriorityIcon(notification.priority)}\n </span>\n </div>\n\n {onArchive && (\n <button\n data-tour=\"notification-archive-action\"\n onClick={handleArchive}\n className=\"flex-shrink-0 p-1 hover:bg-bg-sunken rounded transition-colors duration-150\"\n aria-label={tr('notifCommon.archiveNotification', 'Archive notification')}\n >\n <X size={16} className=\"text-tertiary hover:text-secondary\" />\n </button>\n )}\n </div>\n\n {/* Body */}\n <div className=\"ml-3\">\n {notification.media[0]?.url && (\n <img\n src={notification.media[0].thumbnailUrl || notification.media[0].url}\n alt={notification.media[0].label || notification.title}\n className=\"mb-3 h-40 w-full rounded-md object-cover border border-default\"\n />\n )}\n <p className={`text-sm text-secondary ${compact ? 'line-clamp-2' : ''}`}>\n {compact ? truncateText(notification.body, 120) : notification.body}\n </p>\n {notification.topic && (\n <div className=\"mt-2 inline-flex items-center rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary\">\n {notification.topic.name}\n </div>\n )}\n </div>\n\n {notification.actions.length > 0 && !compact && (\n <div className=\"ml-3 flex flex-wrap gap-2\">\n {notification.actions.map((action) => (\n <button\n key={action.id}\n onClick={(e) => handleActionClick(e, action.id, action.url)}\n className={`rounded-md px-3 py-1.5 text-xs font-medium transition-colors ${\n action.style === 'secondary'\n ? 'bg-bg-sunken text-secondary hover:bg-bg-sunken/80'\n : action.style === 'danger'\n ? 'bg-status-error-bg-subtle text-status-error-text hover:opacity-80'\n : 'bg-accent-primary text-white hover:opacity-90'\n }`}\n >\n {action.label}\n </button>\n ))}\n </div>\n )}\n\n {/* Footer */}\n <div className=\"flex items-center justify-between gap-2 ml-3\">\n <div className=\"flex items-center gap-2 text-xs text-tertiary\">\n <span className={getPriorityColor(notification.priority)}>{notification.priority}</span>\n {showArchivedState && isArchived && (\n <>\n <span>•</span>\n <span>{tr('notifCommon.archived', 'Archived')}</span>\n </>\n )}\n <span>•</span>\n <time dateTime={notification.createdAt}>\n {formatRelativeTime(notification.createdAt, tr)}\n </time>\n </div>\n\n {notification.actionUrl && (\n <button\n onClick={handleActionUrl}\n className=\"flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/80 transition-colors duration-150\"\n aria-label={tr('notifCommon.openLink', 'Open link')}\n >\n <span>{tr('notifCommon.view', 'View')}</span>\n <ExternalLink size={12} />\n </button>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AA8BA,SAAgB,EAAiB,EAC/B,iBACA,iBACA,cACA,aACA,YACA,uBAAoB,IACpB,aAAU,IACV,qBAAkB,YACM;CACxB,IAAM,IAAK,GAAO,EACZ,EAAE,+BAA4B,GAA0B,EACxD,IAAW,CAAC,EAAa,QACzB,IAAa,EAAQ,EAAa,YAElC,UAAoB;AAKxB,EAJA,EAAwB,GAAc,GAAiB,OAAO,EAC1D,KACF,EAAQ,EAAa,EAEnB,KAAY,KACd,EAAa,EAAa,GAAG;IAI3B,KAAiB,MAAwB;AAE7C,EADA,EAAE,iBAAiB,EACf,KACF,EAAU,EAAa,GAAG;IAOxB,KAAwB,MAAgB;AACxC,IAAc,EAAI,KAClB,EAAI,WAAW,WAAW,GACvB,EAAc,EAAI,GAEvB,OAAO,KAAK,GAAK,UAAU,sBAAsB;IAI/C,KAAmB,MAAwB;AAG/C,EAFA,EAAE,iBAAiB,EACnB,EAAa,QAAQ,EACjB,EAAa,cACf,EAAwB,GAAc,GAAiB,iBAAiB,EACxE,IAAW,EAAa,GAAG,EAC3B,EAAqB,EAAa,UAAU;IAI1C,KAAqB,GAAqB,GAAkB,MAAsB;AAKtF,EAJA,EAAE,iBAAiB,EACnB,EAAa,QAAQ,EACrB,EAAwB,GAAc,GAAiB,gBAAgB,EACvE,IAAW,EAAa,IAAI,EAAS,EACrC,EAAqB,EAAU;;AAGjC,QACE,kBAAC,OAAD;EACE,aAAU;EACV,WAAW;;;;UAIP,IAAW,qEAAqE,gCAAgC;UAChH,KAAqB,IAAa,6BAA6B,GAAG;;;EAGtE,SAAS;YAVX;GAaG,KACC,kBAAC,OAAD,EAAK,WAAU,2IAA4I,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kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,OAAD;KAAK,WAAU;eAAf;MACE,kBAAC,QAAD;OAAM,WAAW,EAAiB,EAAa,SAAS;iBAAG,EAAa;OAAgB,CAAA;MACvF,KAAqB,KACpB,kBAAA,GAAA,EAAA,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,WAAW,EAAG;OAC1C,CAAA;MACH;QAEL,EAAa,aACZ,kBAAC,UAAD;KACE,SAAS;KACT,WAAU;KACV,cAAY,EAAG,wBAAwB,YAAY;eAHrD,CAKE,kBAAC,QAAD,EAAA,UAAO,EAAG,oBAAoB,OAAO,EAAQ,CAAA,EAC7C,kBAAC,GAAD,EAAc,MAAM,IAAM,CAAA,CACnB;OAEP;;GACF"}
|
|
1
|
+
{"version":3,"file":"NotificationCard.js","names":["_Fragment","V2_PRIORITY_LABELS","NotificationCard","tr","useTr","useNotificationAnalytics","isUnread","notification","isArchived","v2Priority","handleClick","trackNotificationOpened","analyticsSource","onClick","onMarkAsRead","handleArchive","onArchive","openNotificationLink","navigateInApp","url","nativeOpenUrl","handleActionUrl","nativeImpact","onAction","handleActionClick","actionId","actionUrl","showArchivedState","getNotificationTypeIcon","compact","truncateText","getPriorityIcon","navigationV2","Tooltip","TooltipTrigger","Archive","TooltipContent","X","showTopic","e","action","Fragment","getPriorityColor","formatRelativeTime","ExternalLink"],"sources":["../../src/components/NotificationCard.tsx"],"sourcesContent":["import { Archive, X, ExternalLink } from 'lucide-react';\nimport { Tooltip, TooltipContent, TooltipTrigger } from '@burdenoff/fe-libs/ui';\nimport type { Notification } from '../types';\nimport { useNotificationAnalytics } from '../hooks/useNotificationAnalytics';\nimport { useTr } from '../shared/hooks/useTr';\nimport {\n formatRelativeTime,\n getPriorityColor,\n getPriorityIcon,\n getNotificationTypeIcon,\n truncateText,\n} from '../utils';\nimport { nativeImpact, nativeOpenUrl } from '../utils/nativeBridge';\nimport { navigateInApp } from '../utils/inAppNavigation';\n\ninterface NotificationCardProps {\n notification: Notification;\n onMarkAsRead?: (id: string) => void;\n onArchive?: (id: string) => void;\n onAction?: (notificationId: string, actionId?: string) => void;\n onClick?: (notification: Notification) => void;\n showArchivedState?: boolean;\n compact?: boolean;\n analyticsSource?: 'center' | 'panel' | 'history' | 'admin_history';\n /**\n * FluidGrids' Navigation v2 card (BOFF-11872): an archive icon with an\n * \"Archive\" tooltip instead of \"X\", the priority footer only for Urgent or\n * High (sentence case), \"Open\" for the link, and the topic chip only when\n * `showTopic` is on. Other apps leave it off and keep today's card.\n */\n navigationV2?: boolean;\n /** Navigation v2 only: show the topic chip (a level-2 detail). */\n showTopic?: boolean;\n}\n\n/** Navigation v2's priority footer: only the two that need attention, in sentence case. */\nconst V2_PRIORITY_LABELS: Partial<\n Record<Notification['priority'], { key: string; label: string }>\n> = {\n URGENT: { key: 'notifications.priorityUrgent', label: 'Urgent' },\n HIGH: { key: 'notifications.priorityHigh', label: 'High' },\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 navigationV2 = false,\n showTopic = false,\n}: NotificationCardProps) {\n const tr = useTr();\n const { trackNotificationOpened } = useNotificationAnalytics();\n const isUnread = !notification.readAt;\n const isArchived = Boolean(notification.archivedAt);\n const v2Priority = V2_PRIORITY_LABELS[notification.priority];\n\n const handleClick = () => {\n trackNotificationOpened(notification, analyticsSource, 'card');\n if (onClick) {\n onClick(notification);\n }\n if (isUnread && onMarkAsRead) {\n onMarkAsRead(notification.id);\n }\n };\n\n const handleArchive = (e: React.MouseEvent) => {\n e.stopPropagation();\n if (onArchive) {\n onArchive(notification.id);\n }\n };\n\n // A link into this app (an agent, a run, a vibe) opens in place, like the\n // shell's notification bell; only a link that leaves the app opens a new tab\n // (or the system browser on native).\n const openNotificationLink = (url: string) => {\n if (navigateInApp(url)) return;\n if (url.startsWith('https://')) {\n void nativeOpenUrl(url);\n } else {\n window.open(url, '_blank', 'noopener,noreferrer');\n }\n };\n\n const handleActionUrl = (e: React.MouseEvent) => {\n e.stopPropagation();\n nativeImpact('light');\n if (notification.actionUrl) {\n trackNotificationOpened(notification, analyticsSource, 'primary_action');\n onAction?.(notification.id);\n openNotificationLink(notification.actionUrl);\n }\n };\n\n const handleActionClick = (e: React.MouseEvent, actionId: string, actionUrl: string) => {\n e.stopPropagation();\n nativeImpact('light');\n trackNotificationOpened(notification, analyticsSource, 'custom_action');\n onAction?.(notification.id, actionId);\n openNotificationLink(actionUrl);\n };\n\n return (\n <div\n data-tour=\"notification-card\"\n className={`\n relative flex flex-col gap-2 p-4 rounded-lg border cursor-pointer\n transition-[box-shadow,border-color,opacity] duration-200 ease-in-out\n bg-gloss-card\n ${isUnread ? 'border-accent-primary/30 shadow-sm ring-1 ring-accent-primary/10' : 'border-border-seam opacity-75'}\n ${showArchivedState && isArchived ? 'border-dashed opacity-60' : ''}\n hover:shadow-[var(--shadow-pop)] hover:border-accent-primary/30 hover:opacity-100\n `}\n onClick={handleClick}\n >\n {/* Unread indicator */}\n {isUnread && (\n <div className=\"absolute top-4 left-1.5 w-2.5 h-2.5 bg-accent-primary rounded-full shadow-sm shadow-accent-primary/50 motion-safe:animate-vc-glow-pulse\" />\n )}\n\n {/* Header */}\n <div className=\"flex items-start justify-between gap-2 ml-3\">\n <div className=\"flex items-center gap-2 flex-1 min-w-0\">\n <span className=\"text-base\" aria-hidden=\"true\">\n {getNotificationTypeIcon(notification.type)}\n </span>\n <h3\n className={`text-sm truncate ${isUnread ? 'font-bold text-primary' : 'font-medium text-secondary'}`}\n >\n {compact ? truncateText(notification.title, 60) : notification.title}\n </h3>\n <span className=\"text-xs\" aria-label={`Priority: ${notification.priority}`}>\n {getPriorityIcon(notification.priority)}\n </span>\n </div>\n\n {onArchive && navigationV2 && (\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n data-tour=\"notification-archive-action\"\n onClick={handleArchive}\n className=\"flex-shrink-0 rounded p-1 transition-colors duration-150 hover:bg-bg-sunken focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]\"\n aria-label={tr('notifCommon.archiveNotification', 'Archive notification')}\n >\n <Archive\n size={16}\n className=\"text-tertiary hover:text-secondary\"\n aria-hidden=\"true\"\n />\n </button>\n </TooltipTrigger>\n <TooltipContent>{tr('notifications.v2.archive', 'Archive')}</TooltipContent>\n </Tooltip>\n )}\n {onArchive && !navigationV2 && (\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 && (!navigationV2 || showTopic) && (\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 {navigationV2 ? (\n v2Priority && (\n <>\n <span className={getPriorityColor(notification.priority)}>\n {tr(v2Priority.key, v2Priority.label)}\n </span>\n <span>•</span>\n </>\n )\n ) : (\n <>\n <span className={getPriorityColor(notification.priority)}>\n {notification.priority}\n </span>\n <span>•</span>\n </>\n )}\n {showArchivedState && isArchived && (\n <>\n <span>{tr('notifCommon.archived', 'Archived')}</span>\n <span>•</span>\n </>\n )}\n <time dateTime={notification.createdAt}>\n {formatRelativeTime(notification.createdAt, tr)}\n </time>\n </div>\n\n {notification.actionUrl && (\n <button\n onClick={handleActionUrl}\n className=\"flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/80 transition-colors duration-150\"\n aria-label={tr('notifCommon.openLink', 'Open link')}\n >\n <span>\n {navigationV2 ? tr('notifications.v2.open', 'Open') : tr('notifCommon.view', 'View')}\n </span>\n <ExternalLink size={12} />\n </button>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAoCA,IAAMC,IAEF;CACF,QAAQ;EAAE,KAAK;EAAgC,OAAO;CAAS;CAC/D,MAAM;EAAE,KAAK;EAA8B,OAAO;CAAO;AAC3D;AAOA,SAAgBC,EAAiB,EAC/B,iBACA,iBACA,cACA,aACA,YACA,uBAAoB,IACpB,aAAU,IACV,qBAAkB,UAClB,kBAAe,IACf,eAAY,MACY;CACxB,IAAMC,IAAKC,EAAM,GACX,EAAE,+BAA4BC,EAAyB,GACvDC,IAAW,CAACC,EAAa,QACzBC,IAAa,EAAQD,EAAa,YAClCE,IAAaR,EAAmBM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,EAAc,MAAM,GAAK,CAAA,CACnB;IAEP,CAAA,CAAA;;EACF;;AAET"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface NotificationPanelProps {
|
|
2
|
+
onViewAll?: () => void;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Notification dropdown panel
|
|
6
|
+
*
|
|
7
|
+
* Quick view of recent notifications that appears when clicking the bell icon
|
|
8
|
+
*/
|
|
9
|
+
export declare function NotificationPanel({ onViewAll }: NotificationPanelProps): import('react').JSX.Element | null;
|
|
10
|
+
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useNotificationStore as e } from "../store/notificationStore.js";
|
|
2
2
|
import { useNotifications as t } from "../hooks/useNotifications.js";
|
|
3
3
|
import "../hooks/index.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { NotificationCard as n } from "./NotificationCard.js";
|
|
5
|
+
import { useTr as r } from "../shared/hooks/useTr.js";
|
|
6
6
|
import { Bell as i, X as a } from "lucide-react";
|
|
7
7
|
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
8
|
-
|
|
8
|
+
// src/components/NotificationPanel.tsx
|
|
9
9
|
function l({ onViewAll: l }) {
|
|
10
|
-
let u =
|
|
10
|
+
let u = r(), { isPanelOpen: d, togglePanel: f } = e(), { notifications: p, unreadCount: m, markAsRead: h, markAllAsRead: g, archiveNotification: _, recordAction: v } = t();
|
|
11
11
|
if (!d) return null;
|
|
12
12
|
let y = p.slice(0, 5);
|
|
13
13
|
return /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ s("div", {
|
|
@@ -58,7 +58,7 @@ function l({ onViewAll: l }) {
|
|
|
58
58
|
className: "flex-1 overflow-y-auto",
|
|
59
59
|
children: y.length > 0 ? /* @__PURE__ */ s("div", {
|
|
60
60
|
className: "flex flex-col gap-2 p-2",
|
|
61
|
-
children: y.map((e) => /* @__PURE__ */ s(
|
|
61
|
+
children: y.map((e) => /* @__PURE__ */ s(n, {
|
|
62
62
|
notification: e,
|
|
63
63
|
onMarkAsRead: h,
|
|
64
64
|
onArchive: _,
|
|
@@ -98,7 +98,6 @@ function l({ onViewAll: l }) {
|
|
|
98
98
|
]
|
|
99
99
|
})] });
|
|
100
100
|
}
|
|
101
|
-
//#endregion
|
|
102
101
|
export { l as NotificationPanel };
|
|
103
102
|
|
|
104
103
|
//# sourceMappingURL=NotificationPanel.js.map
|
|
@@ -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-gloss-card border border-border-seam rounded-lg shadow-[var(--shadow-pop)] 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-border-seam bg-accent-wash\">\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 tabular-nums 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-200\">\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,
|
|
1
|
+
{"version":3,"file":"NotificationPanel.js","names":["_Fragment","NotificationPanel","tr","useTr","useNotificationStore","useNotifications","isPanelOpen","recentNotifications","notifications","Fragment","togglePanel","Bell","unreadCount","markAllAsRead","X","NotificationCard","markAsRead","archiveNotification","recordAction","notification","onViewAll"],"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-gloss-card border border-border-seam rounded-lg shadow-[var(--shadow-pop)] 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-border-seam bg-accent-wash\">\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 tabular-nums 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-200\">\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,SAAgBC,EAAkB,EAAE,gBAAqC;CACvE,IAAMC,IAAKC,EAAM,GACX,EAAE,gBAAa,mBAAgBC,EAAqB,GACpD,EACJ,kBACA,gBACA,eACA,kBACA,wBACA,oBACEC,EAAiB;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AAG,WAAU;OACV,UAAAT,EAAG,+BAA+B,kBAAkB;MACpD,CAAA;MACH,kBAAC,KAAD;OAAG,WAAU;OACV,UAAAA,EAAG,2BAA2B,uBAAuB;MACrD,CAAA;KACA;;GAEJ,CAAA;GAGJK,EAAoB,SAAS,KAC5B,kBAAC,OAAD;IAAK,WAAU;IACb,UAAA,kBAAC,UAAD;KACE,aAAU;KACV,eAAe;MAEb,AADAG,EAAY,GACRU,KAAWA,EAAU;KAC3B;KACA,WAAU;KAET,UAAAlB,EAAG,oCAAoC,wBAAwB;IAC1D,CAAA;GACL,CAAA;EAEJ;CACL,CAAA,CAAA,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { RecipientInput, NotificationChannelType } from '../hooks/useSendNotification';
|
|
2
|
+
/**
|
|
3
|
+
* Recipient with display info
|
|
4
|
+
*/
|
|
5
|
+
export interface Recipient extends RecipientInput {
|
|
6
|
+
id: string;
|
|
7
|
+
displayName: string;
|
|
8
|
+
type: 'email' | 'phone' | 'user' | 'manual';
|
|
9
|
+
}
|
|
10
|
+
interface RecipientSelectorProps {
|
|
11
|
+
recipients: Recipient[];
|
|
12
|
+
onChange: (recipients: Recipient[]) => void;
|
|
13
|
+
channel: NotificationChannelType;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
maxRecipients?: number;
|
|
17
|
+
error?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* RecipientSelector component
|
|
21
|
+
*
|
|
22
|
+
* Allows selecting multiple recipients for notifications.
|
|
23
|
+
* Supports email, phone, and manual input based on channel type.
|
|
24
|
+
*/
|
|
25
|
+
export declare function RecipientSelector({ recipients, onChange, channel, placeholder, disabled, maxRecipients, error, }: RecipientSelectorProps): import('react').JSX.Element;
|
|
26
|
+
/**
|
|
27
|
+
* Compact recipient display for read-only views
|
|
28
|
+
*/
|
|
29
|
+
export declare function RecipientList({ recipients }: {
|
|
30
|
+
recipients: Recipient[];
|
|
31
|
+
}): import('react').JSX.Element;
|
|
32
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import { useTr as e } from "../shared/hooks/useTr.js";
|
|
|
2
2
|
import { useCallback as t, useEffect as n, useRef as r, useState as i } from "react";
|
|
3
3
|
import { AlertCircle as a, Mail as o, Phone as s, Plus as c, User as l, X as u } from "lucide-react";
|
|
4
4
|
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
5
|
-
|
|
5
|
+
// src/components/RecipientSelector.tsx
|
|
6
6
|
function p(e) {
|
|
7
7
|
switch (e) {
|
|
8
8
|
case "email": return /* @__PURE__ */ d(o, {
|
|
@@ -27,7 +27,7 @@ function m(e) {
|
|
|
27
27
|
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
|
|
28
28
|
}
|
|
29
29
|
function h(e) {
|
|
30
|
-
return /^\+?[1-9]\d{6,14}$/.test(e.replace(/[\s
|
|
30
|
+
return /^\+?[1-9]\d{6,14}$/.test(e.replace(/[\s\-()]/g, ""));
|
|
31
31
|
}
|
|
32
32
|
function g() {
|
|
33
33
|
return `recipient-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
@@ -206,7 +206,6 @@ function _({ recipients: o, onChange: s, channel: l, placeholder: _, disabled: v
|
|
|
206
206
|
]
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
|
-
//#endregion
|
|
210
209
|
export { _ as RecipientSelector };
|
|
211
210
|
|
|
212
211
|
//# sourceMappingURL=RecipientSelector.js.map
|
|
@@ -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-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\">\n {recipient.displayName}\n </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,MAAY,UACV,EAAG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C/E,EAAA,CAAA,EACP,kBAAC,QAAD,EAAA,UAAA;KACG,EAAW;KAAO;KAAI;KAClB,EAAA,CAAA,CACH;;GACF"}
|
|
1
|
+
{"version":3,"file":"RecipientSelector.js","names":["getRecipientIcon","type","Mail","Phone","User","isValidEmail","email","isValidPhone","phone","generateId","RecipientSelector","tr","useTr","inputValue","setInputValue","useState","inputError","setInputError","isFocused","setIsFocused","inputRef","useRef","inputType","channel","inputPlaceholder","placeholder","addRecipient","useCallback","trimmedValue","value","recipients","maxRecipients","r","recipient","onChange","removeRecipient","id","disabled","error","e","X","pastedText","v","Plus","AlertCircle"],"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\">\n {recipient.displayName}\n </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,SAASA,EAAiB,GAAyB;CACjD,QAAQC,GAAR;EACE,KAAK,SACH,OAAO,kBAACC,GAAD;GAAM,MAAM;GAAI,WAAU;EAAyB,CAAA;EAC5D,KAAK,SACH,OAAO,kBAACC,GAAD;GAAO,MAAM;GAAI,WAAU;EAA4B,CAAA;EAChE,KAAK,QACH,OAAO,kBAACC,GAAD;GAAM,MAAM;GAAI,WAAU;EAAsB,CAAA;EACzD,SACE,OAAO,kBAACA,GAAD;GAAM,MAAM;GAAI,WAAU;EAAuB,CAAA;CAC5D;AACF;AAKA,SAASC,EAAa,GAAwB;CAE5C,OAAO,6BAAW,KAAKC,CAAK;AAC9B;AAKA,SAASC,EAAa,GAAwB;CAE5C,OAAO,qBAAW,KAAKC,EAAM,QAAQ,aAAa,EAAE,CAAC;AACvD;AAKA,S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