stream-chat-react-native-core 9.2.0-beta.2 → 9.2.0-beta.3
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/README.md +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerContent.js +2 -2
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerContent.js.map +1 -1
- package/lib/commonjs/components/Channel/Channel.js +10 -1
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useMessageListPagination.js +26 -3
- package/lib/commonjs/components/Channel/hooks/useMessageListPagination.js.map +1 -1
- package/lib/commonjs/components/ChannelList/ChannelList.js +29 -4
- package/lib/commonjs/components/ChannelList/ChannelList.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/useChannelActions.js +314 -11
- package/lib/commonjs/components/ChannelList/hooks/useChannelActions.js.map +1 -1
- package/lib/commonjs/components/Message/hooks/useMessageActionHandlers.js +202 -15
- package/lib/commonjs/components/Message/hooks/useMessageActionHandlers.js.map +1 -1
- package/lib/commonjs/components/MessageInput/MessageComposer.js +1 -1
- package/lib/commonjs/components/MessageInput/MessageComposerLeadingView.js +1 -1
- package/lib/commonjs/components/MessageInput/MessageComposerLeadingView.js.map +1 -1
- package/lib/commonjs/components/MessageInput/MessageInputHeaderView.js +1 -1
- package/lib/commonjs/components/MessageInput/MessageInputHeaderView.js.map +1 -1
- package/lib/commonjs/components/MessageInput/MessageInputTrailingView.js +1 -1
- package/lib/commonjs/components/MessageInput/MessageInputTrailingView.js.map +1 -1
- package/lib/commonjs/components/MessageInput/components/AttachmentPreview/AttachmentUploadPreviewList.js +7 -13
- package/lib/commonjs/components/MessageInput/components/AttachmentPreview/AttachmentUploadPreviewList.js.map +1 -1
- package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecorder.js +27 -6
- package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecorder.js.map +1 -1
- package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js +29 -9
- package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js.map +1 -1
- package/lib/commonjs/components/MessageInput/components/OutputButtons/index.js +1 -1
- package/lib/commonjs/components/MessageList/MessageFlashList.js +5 -2
- package/lib/commonjs/components/MessageList/MessageFlashList.js.map +1 -1
- package/lib/commonjs/components/MessageList/MessageList.js +5 -2
- package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
- package/lib/commonjs/components/MessageMenu/hooks/useFetchReactions.js +23 -2
- package/lib/commonjs/components/MessageMenu/hooks/useFetchReactions.js.map +1 -1
- package/lib/commonjs/components/Notifications/Notification.js +232 -0
- package/lib/commonjs/components/Notifications/Notification.js.map +1 -0
- package/lib/commonjs/components/Notifications/NotificationList.js +120 -0
- package/lib/commonjs/components/Notifications/NotificationList.js.map +1 -0
- package/lib/commonjs/components/Notifications/NotificationTargetContext.js +45 -0
- package/lib/commonjs/components/Notifications/NotificationTargetContext.js.map +1 -0
- package/lib/commonjs/components/Notifications/hooks/index.js +59 -0
- package/lib/commonjs/components/Notifications/hooks/index.js.map +1 -0
- package/lib/commonjs/components/Notifications/hooks/useNotificationApi.js +133 -0
- package/lib/commonjs/components/Notifications/hooks/useNotificationApi.js.map +1 -0
- package/lib/commonjs/components/Notifications/hooks/useNotificationListController.js +133 -0
- package/lib/commonjs/components/Notifications/hooks/useNotificationListController.js.map +1 -0
- package/lib/commonjs/components/Notifications/hooks/useNotificationTarget.js +26 -0
- package/lib/commonjs/components/Notifications/hooks/useNotificationTarget.js.map +1 -0
- package/lib/commonjs/components/Notifications/hooks/useNotifications.js +26 -0
- package/lib/commonjs/components/Notifications/hooks/useNotifications.js.map +1 -0
- package/lib/commonjs/components/Notifications/hooks/useSystemNotifications.js +22 -0
- package/lib/commonjs/components/Notifications/hooks/useSystemNotifications.js.map +1 -0
- package/lib/commonjs/components/Notifications/index.js +59 -0
- package/lib/commonjs/components/Notifications/index.js.map +1 -0
- package/lib/commonjs/components/Notifications/notificationTarget.js +220 -0
- package/lib/commonjs/components/Notifications/notificationTarget.js.map +1 -0
- package/lib/commonjs/components/Notifications/notificationTranslations.js +137 -0
- package/lib/commonjs/components/Notifications/notificationTranslations.js.map +1 -0
- package/lib/commonjs/components/Poll/components/PollOption.js +14 -9
- package/lib/commonjs/components/Poll/components/PollOption.js.map +1 -1
- package/lib/commonjs/components/Poll/hooks/usePollState.js +35 -3
- package/lib/commonjs/components/Poll/hooks/usePollState.js.map +1 -1
- package/lib/commonjs/components/Thread/Thread.js +19 -11
- package/lib/commonjs/components/Thread/Thread.js.map +1 -1
- package/lib/commonjs/components/ThreadList/ThreadList.js +30 -9
- package/lib/commonjs/components/ThreadList/ThreadList.js.map +1 -1
- package/lib/commonjs/components/index.js +11 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/contexts/componentsContext/defaultComponents.js +4 -0
- package/lib/commonjs/contexts/componentsContext/defaultComponents.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +37 -0
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/themeContext/utils/theme.js +13 -0
- package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/commonjs/hooks/index.js +11 -0
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useAudioPlayer.js +34 -1
- package/lib/commonjs/hooks/useAudioPlayer.js.map +1 -1
- package/lib/commonjs/hooks/useInAppNotificationsState.js.map +1 -1
- package/lib/commonjs/hooks/useLazyRef.js +13 -0
- package/lib/commonjs/hooks/useLazyRef.js.map +1 -0
- package/lib/commonjs/i18n/en.json +60 -1
- package/lib/commonjs/i18n/es.json +62 -3
- package/lib/commonjs/i18n/fr.json +60 -1
- package/lib/commonjs/i18n/he.json +60 -1
- package/lib/commonjs/i18n/hi.json +60 -1
- package/lib/commonjs/i18n/it.json +60 -1
- package/lib/commonjs/i18n/ja.json +60 -1
- package/lib/commonjs/i18n/ko.json +60 -1
- package/lib/commonjs/i18n/nl.json +60 -1
- package/lib/commonjs/i18n/pt-br.json +60 -1
- package/lib/commonjs/i18n/ru.json +60 -1
- package/lib/commonjs/i18n/tr.json +60 -1
- package/lib/commonjs/state-store/audio-player-pool.js +1 -0
- package/lib/commonjs/state-store/audio-player-pool.js.map +1 -1
- package/lib/commonjs/state-store/audio-player.js +92 -13
- package/lib/commonjs/state-store/audio-player.js.map +1 -1
- package/lib/commonjs/theme/generated/dark/StreamTokens.android.js +16 -16
- package/lib/commonjs/theme/generated/dark/StreamTokens.android.js.map +1 -1
- package/lib/commonjs/theme/generated/dark/StreamTokens.ios.js +8 -8
- package/lib/commonjs/theme/generated/dark/StreamTokens.ios.js.map +1 -1
- package/lib/commonjs/theme/generated/dark/StreamTokens.web.js +8 -8
- package/lib/commonjs/theme/generated/dark/StreamTokens.web.js.map +1 -1
- package/lib/commonjs/theme/generated/light/StreamTokens.android.js +16 -16
- package/lib/commonjs/theme/generated/light/StreamTokens.android.js.map +1 -1
- package/lib/commonjs/theme/generated/light/StreamTokens.ios.js +8 -8
- package/lib/commonjs/theme/generated/light/StreamTokens.ios.js.map +1 -1
- package/lib/commonjs/theme/generated/light/StreamTokens.web.js +8 -8
- package/lib/commonjs/theme/generated/light/StreamTokens.web.js.map +1 -1
- package/lib/commonjs/utils/animations/createBoundedZoomTransition.js +151 -0
- package/lib/commonjs/utils/animations/createBoundedZoomTransition.js.map +1 -0
- package/lib/commonjs/utils/{transitions.js → animations/transitions.js} +6 -0
- package/lib/commonjs/utils/animations/transitions.js.map +1 -0
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerContent.js +2 -2
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerContent.js.map +1 -1
- package/lib/module/components/Channel/Channel.js +10 -1
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/Channel/hooks/useMessageListPagination.js +26 -3
- package/lib/module/components/Channel/hooks/useMessageListPagination.js.map +1 -1
- package/lib/module/components/ChannelList/ChannelList.js +29 -4
- package/lib/module/components/ChannelList/ChannelList.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/useChannelActions.js +314 -11
- package/lib/module/components/ChannelList/hooks/useChannelActions.js.map +1 -1
- package/lib/module/components/Message/hooks/useMessageActionHandlers.js +202 -15
- package/lib/module/components/Message/hooks/useMessageActionHandlers.js.map +1 -1
- package/lib/module/components/MessageInput/MessageComposer.js +1 -1
- package/lib/module/components/MessageInput/MessageComposerLeadingView.js +1 -1
- package/lib/module/components/MessageInput/MessageComposerLeadingView.js.map +1 -1
- package/lib/module/components/MessageInput/MessageInputHeaderView.js +1 -1
- package/lib/module/components/MessageInput/MessageInputHeaderView.js.map +1 -1
- package/lib/module/components/MessageInput/MessageInputTrailingView.js +1 -1
- package/lib/module/components/MessageInput/MessageInputTrailingView.js.map +1 -1
- package/lib/module/components/MessageInput/components/AttachmentPreview/AttachmentUploadPreviewList.js +7 -13
- package/lib/module/components/MessageInput/components/AttachmentPreview/AttachmentUploadPreviewList.js.map +1 -1
- package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecorder.js +27 -6
- package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecorder.js.map +1 -1
- package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js +29 -9
- package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js.map +1 -1
- package/lib/module/components/MessageInput/components/OutputButtons/index.js +1 -1
- package/lib/module/components/MessageList/MessageFlashList.js +5 -2
- package/lib/module/components/MessageList/MessageFlashList.js.map +1 -1
- package/lib/module/components/MessageList/MessageList.js +5 -2
- package/lib/module/components/MessageList/MessageList.js.map +1 -1
- package/lib/module/components/MessageMenu/hooks/useFetchReactions.js +23 -2
- package/lib/module/components/MessageMenu/hooks/useFetchReactions.js.map +1 -1
- package/lib/module/components/Notifications/Notification.js +232 -0
- package/lib/module/components/Notifications/Notification.js.map +1 -0
- package/lib/module/components/Notifications/NotificationList.js +120 -0
- package/lib/module/components/Notifications/NotificationList.js.map +1 -0
- package/lib/module/components/Notifications/NotificationTargetContext.js +45 -0
- package/lib/module/components/Notifications/NotificationTargetContext.js.map +1 -0
- package/lib/module/components/Notifications/hooks/index.js +59 -0
- package/lib/module/components/Notifications/hooks/index.js.map +1 -0
- package/lib/module/components/Notifications/hooks/useNotificationApi.js +133 -0
- package/lib/module/components/Notifications/hooks/useNotificationApi.js.map +1 -0
- package/lib/module/components/Notifications/hooks/useNotificationListController.js +133 -0
- package/lib/module/components/Notifications/hooks/useNotificationListController.js.map +1 -0
- package/lib/module/components/Notifications/hooks/useNotificationTarget.js +26 -0
- package/lib/module/components/Notifications/hooks/useNotificationTarget.js.map +1 -0
- package/lib/module/components/Notifications/hooks/useNotifications.js +26 -0
- package/lib/module/components/Notifications/hooks/useNotifications.js.map +1 -0
- package/lib/module/components/Notifications/hooks/useSystemNotifications.js +22 -0
- package/lib/module/components/Notifications/hooks/useSystemNotifications.js.map +1 -0
- package/lib/module/components/Notifications/index.js +59 -0
- package/lib/module/components/Notifications/index.js.map +1 -0
- package/lib/module/components/Notifications/notificationTarget.js +220 -0
- package/lib/module/components/Notifications/notificationTarget.js.map +1 -0
- package/lib/module/components/Notifications/notificationTranslations.js +137 -0
- package/lib/module/components/Notifications/notificationTranslations.js.map +1 -0
- package/lib/module/components/Poll/components/PollOption.js +14 -9
- package/lib/module/components/Poll/components/PollOption.js.map +1 -1
- package/lib/module/components/Poll/hooks/usePollState.js +35 -3
- package/lib/module/components/Poll/hooks/usePollState.js.map +1 -1
- package/lib/module/components/Thread/Thread.js +19 -11
- package/lib/module/components/Thread/Thread.js.map +1 -1
- package/lib/module/components/ThreadList/ThreadList.js +30 -9
- package/lib/module/components/ThreadList/ThreadList.js.map +1 -1
- package/lib/module/components/index.js +11 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/contexts/componentsContext/defaultComponents.js +4 -0
- package/lib/module/contexts/componentsContext/defaultComponents.js.map +1 -1
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +37 -0
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/contexts/themeContext/utils/theme.js +13 -0
- package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/module/hooks/index.js +11 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useAudioPlayer.js +34 -1
- package/lib/module/hooks/useAudioPlayer.js.map +1 -1
- package/lib/module/hooks/useInAppNotificationsState.js.map +1 -1
- package/lib/module/hooks/useLazyRef.js +13 -0
- package/lib/module/hooks/useLazyRef.js.map +1 -0
- package/lib/module/i18n/en.json +60 -1
- package/lib/module/i18n/es.json +62 -3
- package/lib/module/i18n/fr.json +60 -1
- package/lib/module/i18n/he.json +60 -1
- package/lib/module/i18n/hi.json +60 -1
- package/lib/module/i18n/it.json +60 -1
- package/lib/module/i18n/ja.json +60 -1
- package/lib/module/i18n/ko.json +60 -1
- package/lib/module/i18n/nl.json +60 -1
- package/lib/module/i18n/pt-br.json +60 -1
- package/lib/module/i18n/ru.json +60 -1
- package/lib/module/i18n/tr.json +60 -1
- package/lib/module/state-store/audio-player-pool.js +1 -0
- package/lib/module/state-store/audio-player-pool.js.map +1 -1
- package/lib/module/state-store/audio-player.js +92 -13
- package/lib/module/state-store/audio-player.js.map +1 -1
- package/lib/module/theme/generated/dark/StreamTokens.android.js +16 -16
- package/lib/module/theme/generated/dark/StreamTokens.android.js.map +1 -1
- package/lib/module/theme/generated/dark/StreamTokens.ios.js +8 -8
- package/lib/module/theme/generated/dark/StreamTokens.ios.js.map +1 -1
- package/lib/module/theme/generated/dark/StreamTokens.web.js +8 -8
- package/lib/module/theme/generated/dark/StreamTokens.web.js.map +1 -1
- package/lib/module/theme/generated/light/StreamTokens.android.js +16 -16
- package/lib/module/theme/generated/light/StreamTokens.android.js.map +1 -1
- package/lib/module/theme/generated/light/StreamTokens.ios.js +8 -8
- package/lib/module/theme/generated/light/StreamTokens.ios.js.map +1 -1
- package/lib/module/theme/generated/light/StreamTokens.web.js +8 -8
- package/lib/module/theme/generated/light/StreamTokens.web.js.map +1 -1
- package/lib/module/utils/animations/createBoundedZoomTransition.js +151 -0
- package/lib/module/utils/animations/createBoundedZoomTransition.js.map +1 -0
- package/lib/module/utils/{transitions.js → animations/transitions.js} +6 -0
- package/lib/module/utils/animations/transitions.js.map +1 -0
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/AttachmentPicker/components/AttachmentPickerContent.d.ts.map +1 -1
- package/lib/typescript/components/Channel/Channel.d.ts +1 -0
- package/lib/typescript/components/Channel/Channel.d.ts.map +1 -1
- package/lib/typescript/components/Channel/hooks/useMessageListPagination.d.ts.map +1 -1
- package/lib/typescript/components/ChannelList/ChannelList.d.ts +1 -0
- package/lib/typescript/components/ChannelList/ChannelList.d.ts.map +1 -1
- package/lib/typescript/components/ChannelList/hooks/useChannelActions.d.ts.map +1 -1
- package/lib/typescript/components/Message/hooks/useMessageActionHandlers.d.ts.map +1 -1
- package/lib/typescript/components/MessageInput/components/AttachmentPreview/AttachmentUploadPreviewList.d.ts.map +1 -1
- package/lib/typescript/components/MessageInput/components/AudioRecorder/AudioRecorder.d.ts.map +1 -1
- package/lib/typescript/components/MessageInput/components/AudioRecorder/AudioRecordingButton.d.ts.map +1 -1
- package/lib/typescript/components/MessageList/MessageFlashList.d.ts.map +1 -1
- package/lib/typescript/components/MessageList/MessageList.d.ts.map +1 -1
- package/lib/typescript/components/MessageMenu/hooks/useFetchReactions.d.ts.map +1 -1
- package/lib/typescript/components/Notifications/Notification.d.ts +31 -0
- package/lib/typescript/components/Notifications/Notification.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/NotificationList.d.ts +28 -0
- package/lib/typescript/components/Notifications/NotificationList.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/NotificationTargetContext.d.ts +14 -0
- package/lib/typescript/components/Notifications/NotificationTargetContext.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/hooks/index.d.ts +6 -0
- package/lib/typescript/components/Notifications/hooks/index.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/hooks/useNotificationApi.d.ts +48 -0
- package/lib/typescript/components/Notifications/hooks/useNotificationApi.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/hooks/useNotificationListController.d.ts +14 -0
- package/lib/typescript/components/Notifications/hooks/useNotificationListController.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/hooks/useNotificationTarget.d.ts +3 -0
- package/lib/typescript/components/Notifications/hooks/useNotificationTarget.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/hooks/useNotifications.d.ts +14 -0
- package/lib/typescript/components/Notifications/hooks/useNotifications.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/hooks/useSystemNotifications.d.ts +9 -0
- package/lib/typescript/components/Notifications/hooks/useSystemNotifications.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/index.d.ts +6 -0
- package/lib/typescript/components/Notifications/index.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/notificationTarget.d.ts +55 -0
- package/lib/typescript/components/Notifications/notificationTarget.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/notificationTranslations.d.ts +7 -0
- package/lib/typescript/components/Notifications/notificationTranslations.d.ts.map +1 -0
- package/lib/typescript/components/Poll/components/PollOption.d.ts.map +1 -1
- package/lib/typescript/components/Poll/hooks/usePollState.d.ts.map +1 -1
- package/lib/typescript/components/Thread/Thread.d.ts +1 -0
- package/lib/typescript/components/Thread/Thread.d.ts.map +1 -1
- package/lib/typescript/components/ThreadList/ThreadList.d.ts +3 -1
- package/lib/typescript/components/ThreadList/ThreadList.d.ts.map +1 -1
- package/lib/typescript/components/index.d.ts +1 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/contexts/componentsContext/defaultComponents.d.ts +3 -0
- package/lib/typescript/contexts/componentsContext/defaultComponents.d.ts.map +1 -1
- package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts.map +1 -1
- package/lib/typescript/contexts/themeContext/ThemeContext.d.ts +13 -0
- package/lib/typescript/contexts/themeContext/ThemeContext.d.ts.map +1 -1
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts +13 -0
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts.map +1 -1
- package/lib/typescript/hooks/index.d.ts +1 -0
- package/lib/typescript/hooks/index.d.ts.map +1 -1
- package/lib/typescript/hooks/useAudioPlayer.d.ts.map +1 -1
- package/lib/typescript/hooks/useInAppNotificationsState.d.ts +6 -0
- package/lib/typescript/hooks/useInAppNotificationsState.d.ts.map +1 -1
- package/lib/typescript/hooks/useLazyRef.d.ts +7 -0
- package/lib/typescript/hooks/useLazyRef.d.ts.map +1 -0
- package/lib/typescript/i18n/en.json +60 -1
- package/lib/typescript/i18n/es.json +62 -3
- package/lib/typescript/i18n/fr.json +60 -1
- package/lib/typescript/i18n/he.json +60 -1
- package/lib/typescript/i18n/hi.json +60 -1
- package/lib/typescript/i18n/it.json +60 -1
- package/lib/typescript/i18n/ja.json +60 -1
- package/lib/typescript/i18n/ko.json +60 -1
- package/lib/typescript/i18n/nl.json +60 -1
- package/lib/typescript/i18n/pt-br.json +60 -1
- package/lib/typescript/i18n/ru.json +60 -1
- package/lib/typescript/i18n/tr.json +60 -1
- package/lib/typescript/state-store/audio-player-pool.d.ts.map +1 -1
- package/lib/typescript/state-store/audio-player.d.ts +13 -0
- package/lib/typescript/state-store/audio-player.d.ts.map +1 -1
- package/lib/typescript/utils/animations/createBoundedZoomTransition.d.ts +21 -0
- package/lib/typescript/utils/animations/createBoundedZoomTransition.d.ts.map +1 -0
- package/lib/typescript/utils/animations/transitions.d.ts +21 -0
- package/lib/typescript/utils/animations/transitions.d.ts.map +1 -0
- package/lib/typescript/utils/i18n/Streami18n.d.ts +59 -0
- package/lib/typescript/utils/i18n/Streami18n.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/AttachmentPicker/components/AttachmentPickerContent.tsx +3 -3
- package/src/components/AttachmentPicker/components/__tests__/AttachmentPickerContent.test.tsx +19 -18
- package/src/components/Channel/Channel.tsx +15 -1
- package/src/components/Channel/__tests__/useMessageListPagination.test.tsx +34 -2
- package/src/components/Channel/hooks/useMessageListPagination.tsx +19 -3
- package/src/components/ChannelList/ChannelList.tsx +27 -5
- package/src/components/ChannelList/hooks/__tests__/useChannelActions.test.tsx +123 -0
- package/src/components/ChannelList/hooks/useChannelActions.ts +181 -12
- package/src/components/Message/hooks/__tests__/useMessageActionHandlers.test.tsx +131 -0
- package/src/components/Message/hooks/useMessageActionHandlers.ts +133 -23
- package/src/components/MessageInput/MessageComposer.tsx +1 -1
- package/src/components/MessageInput/MessageComposerLeadingView.tsx +1 -1
- package/src/components/MessageInput/MessageInputHeaderView.tsx +1 -1
- package/src/components/MessageInput/MessageInputTrailingView.tsx +1 -1
- package/src/components/MessageInput/components/AttachmentPreview/AttachmentUploadPreviewList.tsx +1 -10
- package/src/components/MessageInput/components/AudioRecorder/AudioRecorder.tsx +10 -2
- package/src/components/MessageInput/components/AudioRecorder/AudioRecordingButton.tsx +27 -13
- package/src/components/MessageInput/components/OutputButtons/index.tsx +1 -1
- package/src/components/MessageList/MessageFlashList.tsx +3 -1
- package/src/components/MessageList/MessageList.tsx +3 -1
- package/src/components/MessageList/__tests__/MessageList.test.tsx +35 -0
- package/src/components/MessageList/__tests__/__snapshots__/ScrollToBottomButton.test.tsx.snap +1 -1
- package/src/components/MessageMenu/hooks/useFetchReactions.ts +17 -2
- package/src/components/Notifications/Notification.tsx +254 -0
- package/src/components/Notifications/NotificationList.tsx +160 -0
- package/src/components/Notifications/NotificationTargetContext.tsx +45 -0
- package/src/components/Notifications/__tests__/NotificationList.test.tsx +480 -0
- package/src/components/Notifications/__tests__/notificationTarget.test.ts +157 -0
- package/src/components/Notifications/hooks/__tests__/useNotificationApi.test.tsx +172 -0
- package/src/components/Notifications/hooks/__tests__/useNotificationTarget.test.tsx +85 -0
- package/src/components/Notifications/hooks/index.ts +5 -0
- package/src/components/Notifications/hooks/useNotificationApi.ts +248 -0
- package/src/components/Notifications/hooks/useNotificationListController.ts +160 -0
- package/src/components/Notifications/hooks/useNotificationTarget.ts +37 -0
- package/src/components/Notifications/hooks/useNotifications.ts +43 -0
- package/src/components/Notifications/hooks/useSystemNotifications.ts +33 -0
- package/src/components/Notifications/index.ts +5 -0
- package/src/components/Notifications/notificationTarget.ts +305 -0
- package/src/components/Notifications/notificationTranslations.ts +142 -0
- package/src/components/Poll/components/PollOption.tsx +10 -6
- package/src/components/Poll/hooks/usePollState.ts +26 -2
- package/src/components/Thread/Thread.tsx +24 -16
- package/src/components/ThreadList/ThreadList.tsx +33 -9
- package/src/components/index.ts +2 -0
- package/src/contexts/componentsContext/defaultComponents.ts +4 -0
- package/src/contexts/messageInputContext/MessageInputContext.tsx +36 -0
- package/src/contexts/themeContext/utils/theme.ts +26 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useAudioPlayer.ts +44 -3
- package/src/hooks/useInAppNotificationsState.ts +6 -0
- package/src/hooks/useLazyRef.ts +15 -0
- package/src/i18n/en.json +60 -1
- package/src/i18n/es.json +62 -3
- package/src/i18n/fr.json +60 -1
- package/src/i18n/he.json +60 -1
- package/src/i18n/hi.json +60 -1
- package/src/i18n/it.json +60 -1
- package/src/i18n/ja.json +60 -1
- package/src/i18n/ko.json +60 -1
- package/src/i18n/nl.json +60 -1
- package/src/i18n/pt-br.json +60 -1
- package/src/i18n/ru.json +60 -1
- package/src/i18n/tr.json +60 -1
- package/src/state-store/__tests__/audio-player.test.ts +45 -0
- package/src/state-store/audio-player-pool.ts +1 -0
- package/src/state-store/audio-player.ts +108 -16
- package/src/theme/generated/dark/StreamTokens.android.ts +16 -16
- package/src/theme/generated/dark/StreamTokens.ios.ts +8 -8
- package/src/theme/generated/dark/StreamTokens.web.ts +8 -8
- package/src/theme/generated/light/StreamTokens.android.ts +16 -16
- package/src/theme/generated/light/StreamTokens.ios.ts +8 -8
- package/src/theme/generated/light/StreamTokens.web.ts +8 -8
- package/src/utils/animations/createBoundedZoomTransition.ts +117 -0
- package/src/utils/{transitions.ts → animations/transitions.ts} +6 -0
- package/src/version.json +1 -1
- package/lib/commonjs/utils/transitions.js.map +0 -1
- package/lib/module/utils/transitions.js.map +0 -1
- package/lib/typescript/utils/transitions.d.ts +0 -9
- package/lib/typescript/utils/transitions.d.ts.map +0 -1
package/src/components/MessageInput/components/AttachmentPreview/AttachmentUploadPreviewList.tsx
CHANGED
|
@@ -29,6 +29,7 @@ import { useComponentsContext } from '../../../../contexts/componentsContext/Com
|
|
|
29
29
|
import { useAttachmentManagerState } from '../../../../contexts/messageInputContext/hooks/useAttachmentManagerState';
|
|
30
30
|
import { useMessageInputContext } from '../../../../contexts/messageInputContext/MessageInputContext';
|
|
31
31
|
import { useTheme } from '../../../../contexts/themeContext/ThemeContext';
|
|
32
|
+
import { useLazyRef } from '../../../../hooks/useLazyRef';
|
|
32
33
|
import { isSoundPackageAvailable } from '../../../../native';
|
|
33
34
|
import { primitives } from '../../../../theme';
|
|
34
35
|
|
|
@@ -73,16 +74,6 @@ const ItemSeparatorComponent = () => {
|
|
|
73
74
|
return <View style={[styles.itemSeparator, itemSeparator]} />;
|
|
74
75
|
};
|
|
75
76
|
|
|
76
|
-
const useLazyRef = <T,>(getInitialValue: () => T) => {
|
|
77
|
-
const ref = useRef<T | null>(null);
|
|
78
|
-
|
|
79
|
-
if (ref.current === null) {
|
|
80
|
-
ref.current = getInitialValue();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return ref as React.RefObject<T>;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
77
|
const getIsAudioAttachmentPreview =
|
|
87
78
|
(soundPackageAvailable: boolean) =>
|
|
88
79
|
(
|
|
@@ -23,6 +23,7 @@ import { Mic } from '../../../../icons/voice';
|
|
|
23
23
|
import { NativeHandlers } from '../../../../native';
|
|
24
24
|
import { AudioRecorderManagerState } from '../../../../state-store/audio-recorder-manager';
|
|
25
25
|
import { primitives } from '../../../../theme';
|
|
26
|
+
import { useNotificationApi } from '../../../Notifications';
|
|
26
27
|
|
|
27
28
|
type AudioRecorderPropsWithContext = Pick<
|
|
28
29
|
MessageInputContextValue,
|
|
@@ -100,9 +101,16 @@ const DeleteRecording = ({
|
|
|
100
101
|
}: {
|
|
101
102
|
deleteVoiceRecordingHandler: () => Promise<void>;
|
|
102
103
|
}) => {
|
|
103
|
-
const
|
|
104
|
+
const { addNotification } = useNotificationApi();
|
|
105
|
+
const { t } = useTranslationContext();
|
|
106
|
+
const onDeleteVoiceRecording = async () => {
|
|
104
107
|
NativeHandlers.triggerHaptic('impactMedium');
|
|
105
|
-
deleteVoiceRecordingHandler();
|
|
108
|
+
await deleteVoiceRecordingHandler();
|
|
109
|
+
addNotification({
|
|
110
|
+
message: t('Voice message deleted'),
|
|
111
|
+
options: { severity: 'info', type: 'audioRecording:cancel:success' },
|
|
112
|
+
origin: { emitter: 'AudioRecorder' },
|
|
113
|
+
});
|
|
106
114
|
};
|
|
107
115
|
return (
|
|
108
116
|
<Button
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Linking, StyleSheet } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { Gesture, GestureDetector, State } from 'react-native-gesture-handler';
|
|
5
5
|
import Animated, {
|
|
@@ -24,6 +24,7 @@ import { Mic } from '../../../../icons/voice';
|
|
|
24
24
|
import { NativeHandlers } from '../../../../native';
|
|
25
25
|
import { AudioRecorderManagerState } from '../../../../state-store/audio-recorder-manager';
|
|
26
26
|
import { primitives } from '../../../../theme';
|
|
27
|
+
import { useNotificationApi } from '../../../Notifications';
|
|
27
28
|
import { ButtonStylesConfig, useButtonStyles } from '../../../ui/Button/hooks/useButtonStyles';
|
|
28
29
|
import { useMicPositionContext } from '../../contexts/MicPositionContext';
|
|
29
30
|
|
|
@@ -92,6 +93,7 @@ export const AudioRecordingButtonWithContext = (props: AudioRecordingButtonProps
|
|
|
92
93
|
},
|
|
93
94
|
} = useTheme();
|
|
94
95
|
const buttonStyles = useButtonStyles(buttonStylesConfig);
|
|
96
|
+
const { addNotification } = useNotificationApi();
|
|
95
97
|
|
|
96
98
|
const onPressHandler = useStableCallback(() => {
|
|
97
99
|
if (handlePress) {
|
|
@@ -99,7 +101,14 @@ export const AudioRecordingButtonWithContext = (props: AudioRecordingButtonProps
|
|
|
99
101
|
}
|
|
100
102
|
if (!recording) {
|
|
101
103
|
NativeHandlers.triggerHaptic('notificationError');
|
|
102
|
-
|
|
104
|
+
addNotification({
|
|
105
|
+
message: 'Hold to record. Release to save.',
|
|
106
|
+
options: {
|
|
107
|
+
severity: 'info',
|
|
108
|
+
type: 'validation:audio:recording:hold-required',
|
|
109
|
+
},
|
|
110
|
+
origin: { emitter: 'AudioRecordingButton' },
|
|
111
|
+
});
|
|
103
112
|
}
|
|
104
113
|
});
|
|
105
114
|
|
|
@@ -115,18 +124,23 @@ export const AudioRecordingButtonWithContext = (props: AudioRecordingButtonProps
|
|
|
115
124
|
}
|
|
116
125
|
const permissionsGranted = await startVoiceRecording();
|
|
117
126
|
if (!permissionsGranted) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
127
|
+
addNotification({
|
|
128
|
+
message: 'Please allow Audio permissions in settings.',
|
|
129
|
+
options: {
|
|
130
|
+
actions: [
|
|
131
|
+
{
|
|
132
|
+
handler: () => {
|
|
133
|
+
Linking.openSettings();
|
|
134
|
+
},
|
|
135
|
+
label: t('Open Settings'),
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
duration: 0,
|
|
139
|
+
severity: 'warning',
|
|
140
|
+
type: 'permission:audio:recording:blocked',
|
|
124
141
|
},
|
|
125
|
-
{
|
|
126
|
-
|
|
127
|
-
style: 'cancel',
|
|
128
|
-
},
|
|
129
|
-
]);
|
|
142
|
+
origin: { emitter: 'AudioRecordingButton' },
|
|
143
|
+
});
|
|
130
144
|
return;
|
|
131
145
|
}
|
|
132
146
|
NativeHandlers.triggerHaptic('impactHeavy');
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
useMessageInputContext,
|
|
23
23
|
} from '../../../../contexts/messageInputContext/MessageInputContext';
|
|
24
24
|
import { useStateStore } from '../../../../hooks/useStateStore';
|
|
25
|
-
import { transitions } from '../../../../utils/transitions';
|
|
25
|
+
import { transitions } from '../../../../utils/animations/transitions';
|
|
26
26
|
import { AIStates, useAIState } from '../../../AITypingIndicatorView';
|
|
27
27
|
import { useIsCooldownActive } from '../../hooks/useIsCooldownActive';
|
|
28
28
|
|
|
@@ -58,7 +58,7 @@ import { useStableCallback, useStateStore } from '../../hooks';
|
|
|
58
58
|
import { bumpOverlayLayoutRevision } from '../../state-store';
|
|
59
59
|
import { MessageInputHeightState } from '../../state-store/message-input-height-store';
|
|
60
60
|
import { primitives } from '../../theme';
|
|
61
|
-
import { transitions } from '../../utils/transitions';
|
|
61
|
+
import { transitions } from '../../utils/animations/transitions';
|
|
62
62
|
import { MessageWrapper } from '../Message/MessageItemView/MessageWrapper';
|
|
63
63
|
|
|
64
64
|
type FlashListContextApi = { getRef?: () => FlashListRef<LocalMessage> | null } | undefined;
|
|
@@ -298,6 +298,7 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
|
|
|
298
298
|
EmptyStateIndicator,
|
|
299
299
|
MessageListLoadingIndicator: LoadingIndicator,
|
|
300
300
|
NetworkDownIndicator,
|
|
301
|
+
NotificationList,
|
|
301
302
|
ScrollToBottomButton,
|
|
302
303
|
StickyHeader,
|
|
303
304
|
TypingIndicator,
|
|
@@ -1127,6 +1128,7 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
|
|
|
1127
1128
|
/>
|
|
1128
1129
|
</View>
|
|
1129
1130
|
) : null}
|
|
1131
|
+
<NotificationList bottomOffset={messageInputFloating ? messageInputHeight + 16 : undefined} />
|
|
1130
1132
|
</View>
|
|
1131
1133
|
);
|
|
1132
1134
|
};
|
|
@@ -71,7 +71,7 @@ import { useStateStore } from '../../hooks/useStateStore';
|
|
|
71
71
|
import { bumpOverlayLayoutRevision } from '../../state-store';
|
|
72
72
|
import { MessageInputHeightState } from '../../state-store/message-input-height-store';
|
|
73
73
|
import { primitives } from '../../theme';
|
|
74
|
-
import { transitions } from '../../utils/transitions';
|
|
74
|
+
import { transitions } from '../../utils/animations/transitions';
|
|
75
75
|
import { useIncomingMessageAnnouncements } from '../Accessibility/hooks/useIncomingMessageAnnouncements';
|
|
76
76
|
import { MessageWrapper } from '../Message/MessageItemView/MessageWrapper';
|
|
77
77
|
|
|
@@ -354,6 +354,7 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
|
|
|
354
354
|
EmptyStateIndicator,
|
|
355
355
|
MessageListLoadingIndicator: LoadingIndicator,
|
|
356
356
|
NetworkDownIndicator,
|
|
357
|
+
NotificationList,
|
|
357
358
|
ScrollToBottomButton,
|
|
358
359
|
StickyHeader,
|
|
359
360
|
TypingIndicator,
|
|
@@ -1356,6 +1357,7 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
|
|
|
1356
1357
|
/>
|
|
1357
1358
|
</View>
|
|
1358
1359
|
) : null}
|
|
1360
|
+
<NotificationList bottomOffset={messageInputFloating ? messageInputHeight + 16 : undefined} />
|
|
1359
1361
|
</View>
|
|
1360
1362
|
);
|
|
1361
1363
|
};
|
|
@@ -184,6 +184,41 @@ describe('MessageList', () => {
|
|
|
184
184
|
});
|
|
185
185
|
});
|
|
186
186
|
|
|
187
|
+
it('should render client notifications in the message list notification host', async () => {
|
|
188
|
+
const user1 = generateUser();
|
|
189
|
+
const mockedChannel = generateChannelResponse({
|
|
190
|
+
members: [generateMember({ user: user1 })],
|
|
191
|
+
messages: [generateMessage({ user: user1 })],
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const chatClient = await getTestClientWithUser({ id: 'testID' });
|
|
195
|
+
useMockedApis(chatClient, [getOrCreateChannelApi(mockedChannel)]);
|
|
196
|
+
const channel = chatClient.channel('messaging', mockedChannel.channel.id);
|
|
197
|
+
await channel.watch();
|
|
198
|
+
|
|
199
|
+
const { getByText } = render(
|
|
200
|
+
<OverlayProvider>
|
|
201
|
+
<Chat client={chatClient}>
|
|
202
|
+
<Channel channel={channel}>
|
|
203
|
+
<MessageList />
|
|
204
|
+
</Channel>
|
|
205
|
+
</Chat>
|
|
206
|
+
</OverlayProvider>,
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
act(() => {
|
|
210
|
+
chatClient.notifications.add({
|
|
211
|
+
message: 'Message list notification',
|
|
212
|
+
options: { severity: 'warning' },
|
|
213
|
+
origin: { emitter: 'MessageListTest' },
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
await waitFor(() => {
|
|
218
|
+
expect(getByText('Message list notification')).toBeTruthy();
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
|
|
187
222
|
it('should render the is offline error', async () => {
|
|
188
223
|
const user1 = generateUser();
|
|
189
224
|
const mockedChannel = generateChannelResponse({
|
|
@@ -3,6 +3,8 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
|
3
3
|
import { LocalMessage, ReactionResponse, ReactionSort } from 'stream-chat';
|
|
4
4
|
|
|
5
5
|
import { useChatContext } from '../../../contexts/chatContext/ChatContext';
|
|
6
|
+
import { useTranslationContext } from '../../../contexts/translationContext/TranslationContext';
|
|
7
|
+
import { useNotificationApi } from '../../Notifications';
|
|
6
8
|
|
|
7
9
|
export type UseFetchReactionParams = {
|
|
8
10
|
limit?: number;
|
|
@@ -98,6 +100,8 @@ export const useFetchReactions = ({
|
|
|
98
100
|
const messageId = message?.id;
|
|
99
101
|
|
|
100
102
|
const { client } = useChatContext();
|
|
103
|
+
const { t } = useTranslationContext();
|
|
104
|
+
const { addNotification } = useNotificationApi();
|
|
101
105
|
|
|
102
106
|
const sortString = useMemo(() => JSON.stringify(sort), [sort]);
|
|
103
107
|
|
|
@@ -122,10 +126,21 @@ export const useFetchReactions = ({
|
|
|
122
126
|
setLoading(false);
|
|
123
127
|
}
|
|
124
128
|
} catch (error) {
|
|
125
|
-
|
|
129
|
+
addNotification({
|
|
130
|
+
message: t('Error fetching reactions'),
|
|
131
|
+
options: {
|
|
132
|
+
...(error instanceof Error ? { originalError: error } : {}),
|
|
133
|
+
severity: 'error',
|
|
134
|
+
type: 'api:message:reactions:fetch:failed',
|
|
135
|
+
},
|
|
136
|
+
origin: {
|
|
137
|
+
...(message ? { context: { message } } : {}),
|
|
138
|
+
emitter: 'Reactions',
|
|
139
|
+
},
|
|
140
|
+
});
|
|
126
141
|
}
|
|
127
142
|
},
|
|
128
|
-
[
|
|
143
|
+
[addNotification, client, limit, message, messageId, reactionType, sort, t],
|
|
129
144
|
);
|
|
130
145
|
|
|
131
146
|
const loadNextPage = useCallback(async () => {
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import React, { type ComponentType, useMemo } from 'react';
|
|
2
|
+
import { StyleSheet, Text, useColorScheme, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { Pressable } from 'react-native-gesture-handler';
|
|
5
|
+
|
|
6
|
+
import type { Notification as NotificationType, NotificationSeverity } from 'stream-chat';
|
|
7
|
+
|
|
8
|
+
import { useNotificationApi } from './hooks/useNotificationApi';
|
|
9
|
+
import { getNotificationDisplayMessage } from './notificationTranslations';
|
|
10
|
+
|
|
11
|
+
import { useComponentsContext } from '../../contexts/componentsContext/ComponentsContext';
|
|
12
|
+
import { useTheme } from '../../contexts/themeContext/ThemeContext';
|
|
13
|
+
import { useTranslationContext } from '../../contexts/translationContext/TranslationContext';
|
|
14
|
+
import { Check } from '../../icons/checkmark';
|
|
15
|
+
import { Warning } from '../../icons/exclamation-triangle-fill';
|
|
16
|
+
import { Reload } from '../../icons/refresh';
|
|
17
|
+
import { IconProps } from '../../icons/utils/base';
|
|
18
|
+
import { NewClose } from '../../icons/xmark';
|
|
19
|
+
import { primitives } from '../../theme';
|
|
20
|
+
import { Button } from '../ui/Button';
|
|
21
|
+
|
|
22
|
+
/** Direction from which a snackbar enters and exits the screen. */
|
|
23
|
+
export type NotificationEntryDirection = 'bottom' | 'left' | 'right' | 'top';
|
|
24
|
+
export type NotificationTransitionState = 'enter' | 'exit';
|
|
25
|
+
|
|
26
|
+
export type NotificationIconProps = {
|
|
27
|
+
/** Notification rendered by the icon slot. */
|
|
28
|
+
notification: NotificationType;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/** Visual variant resolved from notification severity. Notifications without severity use `default`. */
|
|
32
|
+
export type NotificationVariant = 'default' | NotificationSeverity;
|
|
33
|
+
|
|
34
|
+
/** Resolves the visual variant used by the default notification renderer. */
|
|
35
|
+
export const getNotificationVariant = (notification: NotificationType): NotificationVariant =>
|
|
36
|
+
notification.severity ?? 'default';
|
|
37
|
+
|
|
38
|
+
const IconsByVariant: Partial<Record<NotificationVariant, ComponentType<IconProps> | null>> = {
|
|
39
|
+
error: Warning,
|
|
40
|
+
info: null,
|
|
41
|
+
loading: Reload,
|
|
42
|
+
success: Check,
|
|
43
|
+
warning: Warning,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const getNotificationIconComponent = (notification: NotificationType) => {
|
|
47
|
+
const variant = getNotificationVariant(notification);
|
|
48
|
+
if (variant === 'default') return undefined;
|
|
49
|
+
|
|
50
|
+
return IconsByVariant[variant] ?? undefined;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const NotificationIcon = ({ notification }: NotificationIconProps) => {
|
|
54
|
+
const Icon = getNotificationIconComponent(notification);
|
|
55
|
+
const { iconColor, styles } = useNotificationIconStyles();
|
|
56
|
+
if (!Icon) return null;
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<View style={styles.iconContainer} testID='notification-icon'>
|
|
60
|
+
<Icon height={20} pathFill={iconColor} stroke={iconColor} width={20} />
|
|
61
|
+
</View>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export type NotificationProps = {
|
|
66
|
+
/** Notification object produced by the Stream Chat notification manager. */
|
|
67
|
+
notification: NotificationType;
|
|
68
|
+
/** Direction used by the surrounding list animation. */
|
|
69
|
+
entryDirection?: NotificationEntryDirection;
|
|
70
|
+
/** Optional icon override for this notification instance. */
|
|
71
|
+
Icon?: React.ComponentType<NotificationIconProps>;
|
|
72
|
+
/** Called instead of the default notification removal behavior. */
|
|
73
|
+
onDismiss?: () => void;
|
|
74
|
+
/** Forces a dismiss button for transient notifications. Persistent notifications always show one. */
|
|
75
|
+
showClose?: boolean;
|
|
76
|
+
/** Reserved for custom animated notification implementations. */
|
|
77
|
+
transitionState?: NotificationTransitionState;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/** Default snackbar notification renderer used by `NotificationList`. */
|
|
81
|
+
export const Notification = ({
|
|
82
|
+
Icon,
|
|
83
|
+
notification,
|
|
84
|
+
onDismiss,
|
|
85
|
+
showClose = false,
|
|
86
|
+
}: NotificationProps) => {
|
|
87
|
+
const { NotificationIcon: NotificationIconComponent = NotificationIcon } = useComponentsContext();
|
|
88
|
+
const { removeNotification } = useNotificationApi();
|
|
89
|
+
const { t } = useTranslationContext();
|
|
90
|
+
const displayMessage = getNotificationDisplayMessage({ notification, t });
|
|
91
|
+
const ResolvedIcon = Icon ?? NotificationIconComponent;
|
|
92
|
+
const hasResolvedIcon =
|
|
93
|
+
ResolvedIcon === NotificationIcon
|
|
94
|
+
? !!getNotificationIconComponent(notification)
|
|
95
|
+
: !!ResolvedIcon;
|
|
96
|
+
const { closeIconColor, styles } = useNotificationStyles({ hasResolvedIcon });
|
|
97
|
+
const isPersistent = !notification.duration;
|
|
98
|
+
const closeVisible = showClose || isPersistent;
|
|
99
|
+
|
|
100
|
+
const handleDismiss = () => {
|
|
101
|
+
if (onDismiss) {
|
|
102
|
+
onDismiss();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
removeNotification(notification.id);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<View
|
|
111
|
+
accessibilityLiveRegion={notification.severity === 'error' ? 'assertive' : 'polite'}
|
|
112
|
+
accessibilityRole={notification.severity === 'error' ? 'alert' : 'summary'}
|
|
113
|
+
style={styles.container}
|
|
114
|
+
testID='notification'
|
|
115
|
+
>
|
|
116
|
+
<View style={styles.contentContainer}>
|
|
117
|
+
{hasResolvedIcon ? <ResolvedIcon notification={notification} /> : null}
|
|
118
|
+
<Text style={styles.message}>{displayMessage}</Text>
|
|
119
|
+
</View>
|
|
120
|
+
{notification.actions && notification.actions.length > 0 ? (
|
|
121
|
+
<View style={styles.actionsContainer}>
|
|
122
|
+
{notification.actions.map((action, index) => (
|
|
123
|
+
<Button
|
|
124
|
+
accessibilityLabel={action.label}
|
|
125
|
+
key={`${action.label}-${index}`}
|
|
126
|
+
label={action.label}
|
|
127
|
+
onPress={action.handler}
|
|
128
|
+
size='sm'
|
|
129
|
+
style={styles.actionButton}
|
|
130
|
+
type='outline'
|
|
131
|
+
variant='primary'
|
|
132
|
+
/>
|
|
133
|
+
))}
|
|
134
|
+
</View>
|
|
135
|
+
) : null}
|
|
136
|
+
{closeVisible ? (
|
|
137
|
+
<Pressable
|
|
138
|
+
accessibilityLabel={t('a11y/Dismiss notification')}
|
|
139
|
+
accessibilityRole='button'
|
|
140
|
+
hitSlop={8}
|
|
141
|
+
onPress={handleDismiss}
|
|
142
|
+
style={({ pressed }) => (pressed ? styles.closeButtonPressed : styles.closeButton)}
|
|
143
|
+
testID='notification-close-button'
|
|
144
|
+
>
|
|
145
|
+
<NewClose height={20} stroke={closeIconColor} width={20} />
|
|
146
|
+
</Pressable>
|
|
147
|
+
) : null}
|
|
148
|
+
</View>
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const useNotificationIconStyles = () => {
|
|
153
|
+
const {
|
|
154
|
+
theme: { notification: notificationTheme, semantics },
|
|
155
|
+
} = useTheme();
|
|
156
|
+
|
|
157
|
+
return useMemo(() => {
|
|
158
|
+
const baseStyles = StyleSheet.create({
|
|
159
|
+
iconContainer: {
|
|
160
|
+
alignItems: 'center',
|
|
161
|
+
height: 20,
|
|
162
|
+
justifyContent: 'center',
|
|
163
|
+
width: 20,
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
iconColor: semantics.textOnInverse,
|
|
169
|
+
styles: {
|
|
170
|
+
iconContainer: [baseStyles.iconContainer, notificationTheme.iconContainer],
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
}, [notificationTheme.iconContainer, semantics]);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const useNotificationStyles = ({ hasResolvedIcon }: { hasResolvedIcon: boolean }) => {
|
|
177
|
+
const {
|
|
178
|
+
theme: { notification: notificationTheme, semantics },
|
|
179
|
+
} = useTheme();
|
|
180
|
+
const scheme = useColorScheme();
|
|
181
|
+
const notificationShadow =
|
|
182
|
+
scheme === 'dark' ? primitives.darkElevation3 : primitives.lightElevation3;
|
|
183
|
+
|
|
184
|
+
return useMemo(() => {
|
|
185
|
+
const baseStyles = StyleSheet.create({
|
|
186
|
+
actionButton: {
|
|
187
|
+
width: 'auto',
|
|
188
|
+
},
|
|
189
|
+
actionsContainer: {
|
|
190
|
+
flexDirection: 'row',
|
|
191
|
+
flexWrap: 'wrap',
|
|
192
|
+
gap: primitives.spacingXs,
|
|
193
|
+
marginTop: primitives.spacingXs,
|
|
194
|
+
},
|
|
195
|
+
closeButton: {
|
|
196
|
+
alignItems: 'center',
|
|
197
|
+
borderRadius: primitives.radiusMax,
|
|
198
|
+
height: 24,
|
|
199
|
+
justifyContent: 'center',
|
|
200
|
+
marginLeft: primitives.spacingXs,
|
|
201
|
+
width: 24,
|
|
202
|
+
},
|
|
203
|
+
closeButtonPressed: {
|
|
204
|
+
backgroundColor: semantics.backgroundUtilityPressed,
|
|
205
|
+
},
|
|
206
|
+
container: {
|
|
207
|
+
alignItems: 'flex-start',
|
|
208
|
+
alignSelf: 'center',
|
|
209
|
+
backgroundColor: semantics.backgroundCoreInverse,
|
|
210
|
+
borderRadius: primitives.radius3xl,
|
|
211
|
+
flexDirection: 'row',
|
|
212
|
+
maxWidth: '100%',
|
|
213
|
+
paddingHorizontal: primitives.spacingSm,
|
|
214
|
+
...notificationShadow,
|
|
215
|
+
shadowOpacity: 0,
|
|
216
|
+
},
|
|
217
|
+
contentContainer: {
|
|
218
|
+
alignItems: 'center',
|
|
219
|
+
flexDirection: 'row',
|
|
220
|
+
flexShrink: 1,
|
|
221
|
+
gap: primitives.spacingXs,
|
|
222
|
+
minHeight: 48,
|
|
223
|
+
paddingLeft: hasResolvedIcon ? primitives.spacingXxs : primitives.spacingXs,
|
|
224
|
+
paddingRight: primitives.spacingXs,
|
|
225
|
+
paddingVertical: primitives.spacingXxxs,
|
|
226
|
+
},
|
|
227
|
+
message: {
|
|
228
|
+
color: semantics.textOnInverse,
|
|
229
|
+
flexShrink: 1,
|
|
230
|
+
fontSize: primitives.typographyFontSizeSm,
|
|
231
|
+
fontWeight: primitives.typographyFontWeightRegular,
|
|
232
|
+
lineHeight: primitives.typographyLineHeightNormal,
|
|
233
|
+
paddingVertical: primitives.spacingSm,
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
return {
|
|
238
|
+
closeIconColor: semantics.textOnInverse,
|
|
239
|
+
styles: {
|
|
240
|
+
actionButton: [baseStyles.actionButton, notificationTheme.actionButton],
|
|
241
|
+
actionsContainer: [baseStyles.actionsContainer, notificationTheme.actionsContainer],
|
|
242
|
+
closeButton: [baseStyles.closeButton, notificationTheme.closeButton],
|
|
243
|
+
closeButtonPressed: [
|
|
244
|
+
baseStyles.closeButton,
|
|
245
|
+
baseStyles.closeButtonPressed,
|
|
246
|
+
notificationTheme.closeButton,
|
|
247
|
+
],
|
|
248
|
+
container: [baseStyles.container, notificationTheme.container],
|
|
249
|
+
contentContainer: [baseStyles.contentContainer, notificationTheme.contentContainer],
|
|
250
|
+
message: [baseStyles.message, notificationTheme.message],
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
}, [hasResolvedIcon, notificationShadow, notificationTheme, semantics]);
|
|
254
|
+
};
|