stream-chat-react-native-core 5.2.0 → 5.3.0-beta.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.
Files changed (99) hide show
  1. package/lib/commonjs/components/Attachment/Card.js +29 -18
  2. package/lib/commonjs/components/Attachment/Card.js.map +1 -1
  3. package/lib/commonjs/components/Attachment/Gallery.js +16 -20
  4. package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
  5. package/lib/commonjs/components/Attachment/GalleryImage.js +34 -6
  6. package/lib/commonjs/components/Attachment/GalleryImage.js.map +1 -1
  7. package/lib/commonjs/components/Attachment/Giphy.js +37 -29
  8. package/lib/commonjs/components/Attachment/Giphy.js.map +1 -1
  9. package/lib/commonjs/components/Avatar/Avatar.js +10 -8
  10. package/lib/commonjs/components/Avatar/Avatar.js.map +1 -1
  11. package/lib/commonjs/components/Avatar/GroupAvatar.js +3 -1
  12. package/lib/commonjs/components/Avatar/GroupAvatar.js.map +1 -1
  13. package/lib/commonjs/components/ChannelPreview/ChannelAvatar.js +30 -6
  14. package/lib/commonjs/components/ChannelPreview/ChannelAvatar.js.map +1 -1
  15. package/lib/commonjs/components/Chat/Chat.js +8 -5
  16. package/lib/commonjs/components/Chat/Chat.js.map +1 -1
  17. package/lib/commonjs/components/Chat/hooks/useCreateChatContext.js +2 -0
  18. package/lib/commonjs/components/Chat/hooks/useCreateChatContext.js.map +1 -1
  19. package/lib/commonjs/components/ImageBackground.js +64 -0
  20. package/lib/commonjs/components/ImageBackground.js.map +1 -0
  21. package/lib/commonjs/components/Message/Message.js +15 -16
  22. package/lib/commonjs/components/Message/Message.js.map +1 -1
  23. package/lib/commonjs/components/Message/MessageSimple/MessageAvatar.js +12 -4
  24. package/lib/commonjs/components/Message/MessageSimple/MessageAvatar.js.map +1 -1
  25. package/lib/commonjs/components/Message/MessageSimple/MessageRepliesAvatars.js +26 -5
  26. package/lib/commonjs/components/Message/MessageSimple/MessageRepliesAvatars.js.map +1 -1
  27. package/lib/commonjs/components/MessageOverlay/MessageOverlay.js +58 -47
  28. package/lib/commonjs/components/MessageOverlay/MessageOverlay.js.map +1 -1
  29. package/lib/commonjs/contexts/chatContext/ChatContext.js +2 -2
  30. package/lib/commonjs/contexts/chatContext/ChatContext.js.map +1 -1
  31. package/lib/commonjs/contexts/messageOverlayContext/MessageOverlayContext.js +2 -2
  32. package/lib/commonjs/contexts/messageOverlayContext/MessageOverlayContext.js.map +1 -1
  33. package/lib/commonjs/version.json +1 -1
  34. package/lib/module/components/Attachment/Card.js +29 -18
  35. package/lib/module/components/Attachment/Card.js.map +1 -1
  36. package/lib/module/components/Attachment/Gallery.js +16 -20
  37. package/lib/module/components/Attachment/Gallery.js.map +1 -1
  38. package/lib/module/components/Attachment/GalleryImage.js +34 -6
  39. package/lib/module/components/Attachment/GalleryImage.js.map +1 -1
  40. package/lib/module/components/Attachment/Giphy.js +37 -29
  41. package/lib/module/components/Attachment/Giphy.js.map +1 -1
  42. package/lib/module/components/Avatar/Avatar.js +10 -8
  43. package/lib/module/components/Avatar/Avatar.js.map +1 -1
  44. package/lib/module/components/Avatar/GroupAvatar.js +3 -1
  45. package/lib/module/components/Avatar/GroupAvatar.js.map +1 -1
  46. package/lib/module/components/ChannelPreview/ChannelAvatar.js +30 -6
  47. package/lib/module/components/ChannelPreview/ChannelAvatar.js.map +1 -1
  48. package/lib/module/components/Chat/Chat.js +8 -5
  49. package/lib/module/components/Chat/Chat.js.map +1 -1
  50. package/lib/module/components/Chat/hooks/useCreateChatContext.js +2 -0
  51. package/lib/module/components/Chat/hooks/useCreateChatContext.js.map +1 -1
  52. package/lib/module/components/ImageBackground.js +64 -0
  53. package/lib/module/components/ImageBackground.js.map +1 -0
  54. package/lib/module/components/Message/Message.js +15 -16
  55. package/lib/module/components/Message/Message.js.map +1 -1
  56. package/lib/module/components/Message/MessageSimple/MessageAvatar.js +12 -4
  57. package/lib/module/components/Message/MessageSimple/MessageAvatar.js.map +1 -1
  58. package/lib/module/components/Message/MessageSimple/MessageRepliesAvatars.js +26 -5
  59. package/lib/module/components/Message/MessageSimple/MessageRepliesAvatars.js.map +1 -1
  60. package/lib/module/components/MessageOverlay/MessageOverlay.js +58 -47
  61. package/lib/module/components/MessageOverlay/MessageOverlay.js.map +1 -1
  62. package/lib/module/contexts/chatContext/ChatContext.js +2 -2
  63. package/lib/module/contexts/chatContext/ChatContext.js.map +1 -1
  64. package/lib/module/contexts/messageOverlayContext/MessageOverlayContext.js +2 -2
  65. package/lib/module/contexts/messageOverlayContext/MessageOverlayContext.js.map +1 -1
  66. package/lib/module/version.json +1 -1
  67. package/lib/typescript/components/Attachment/Card.d.ts +3 -2
  68. package/lib/typescript/components/Attachment/GalleryImage.d.ts +8 -2
  69. package/lib/typescript/components/Attachment/Giphy.d.ts +2 -1
  70. package/lib/typescript/components/Avatar/Avatar.d.ts +2 -1
  71. package/lib/typescript/components/Avatar/GroupAvatar.d.ts +2 -1
  72. package/lib/typescript/components/ChannelPreview/ChannelAvatar.d.ts +2 -0
  73. package/lib/typescript/components/Chat/Chat.d.ts +1 -1
  74. package/lib/typescript/components/Chat/hooks/useCreateChatContext.d.ts +1 -1
  75. package/lib/typescript/components/ImageBackground.d.ts +33 -0
  76. package/lib/typescript/components/Message/Message.d.ts +2 -1
  77. package/lib/typescript/components/Message/MessageSimple/MessageAvatar.d.ts +2 -1
  78. package/lib/typescript/components/Message/MessageSimple/MessageRepliesAvatars.d.ts +2 -0
  79. package/lib/typescript/contexts/chatContext/ChatContext.d.ts +3 -1
  80. package/lib/typescript/contexts/messageOverlayContext/MessageOverlayContext.d.ts +4 -0
  81. package/package.json +1 -1
  82. package/src/components/Attachment/Card.tsx +11 -2
  83. package/src/components/Attachment/Gallery.tsx +1 -7
  84. package/src/components/Attachment/GalleryImage.tsx +31 -9
  85. package/src/components/Attachment/Giphy.tsx +8 -2
  86. package/src/components/Avatar/Avatar.tsx +12 -2
  87. package/src/components/Avatar/GroupAvatar.tsx +4 -4
  88. package/src/components/ChannelList/hooks/listeners/__tests__/useChannelUpdated.test.tsx +2 -1
  89. package/src/components/ChannelPreview/ChannelAvatar.tsx +23 -4
  90. package/src/components/Chat/Chat.tsx +98 -95
  91. package/src/components/Chat/hooks/useCreateChatContext.ts +2 -0
  92. package/src/components/ImageBackground.tsx +77 -0
  93. package/src/components/Message/Message.tsx +8 -8
  94. package/src/components/Message/MessageSimple/MessageAvatar.tsx +6 -2
  95. package/src/components/Message/MessageSimple/MessageRepliesAvatars.tsx +15 -3
  96. package/src/components/MessageOverlay/MessageOverlay.tsx +210 -205
  97. package/src/contexts/chatContext/ChatContext.tsx +3 -1
  98. package/src/contexts/messageOverlayContext/MessageOverlayContext.tsx +8 -1
  99. package/src/version.json +1 -1
@@ -1,5 +1,11 @@
1
1
  import React from 'react';
2
2
  import { ImageProps } from 'react-native';
3
- export declare const GalleryImage: React.FC<Omit<ImageProps, 'height' | 'source'> & {
3
+ import { ChatContextValue } from '../../contexts/chatContext/ChatContext';
4
+ import type { DefaultStreamChatGenerics } from '../../types/types';
5
+ export declare type GalleryImageWithContextProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = GalleryImageProps & Pick<ChatContextValue<StreamChatGenerics>, 'ImageComponent'>;
6
+ export declare const GalleryImageWithContext: React.FC<GalleryImageWithContextProps>;
7
+ export declare const MemoizedGalleryImage: React.NamedExoticComponent<GalleryImageWithContextProps<DefaultStreamChatGenerics>>;
8
+ export declare type GalleryImageProps = Omit<ImageProps, 'height' | 'source'> & {
4
9
  uri: string;
5
- }>;
10
+ };
11
+ export declare const GalleryImage: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(props: GalleryImageProps) => JSX.Element;
@@ -1,10 +1,11 @@
1
1
  import type { Attachment } from 'stream-chat';
2
+ import { ChatContextValue } from '../../contexts/chatContext/ChatContext';
2
3
  import { ImageGalleryContextValue } from '../../contexts/imageGalleryContext/ImageGalleryContext';
3
4
  import { MessageContextValue } from '../../contexts/messageContext/MessageContext';
4
5
  import { MessagesContextValue } from '../../contexts/messagesContext/MessagesContext';
5
6
  import { OverlayContextValue } from '../../contexts/overlayContext/OverlayContext';
6
7
  import type { DefaultStreamChatGenerics } from '../../types/types';
7
- export declare type GiphyPropsWithContext<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<ImageGalleryContextValue<StreamChatGenerics>, 'setSelectedMessage' | 'setMessages'> & Pick<MessageContextValue<StreamChatGenerics>, 'handleAction' | 'isMyMessage' | 'message' | 'onLongPress' | 'onPress' | 'onPressIn' | 'preventPress'> & Pick<MessagesContextValue<StreamChatGenerics>, 'giphyVersion' | 'additionalTouchableProps' | 'ImageLoadingIndicator' | 'ImageLoadingFailedIndicator'> & {
8
+ export declare type GiphyPropsWithContext<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<ImageGalleryContextValue<StreamChatGenerics>, 'setSelectedMessage' | 'setMessages'> & Pick<MessageContextValue<StreamChatGenerics>, 'handleAction' | 'isMyMessage' | 'message' | 'onLongPress' | 'onPress' | 'onPressIn' | 'preventPress'> & Pick<ChatContextValue<StreamChatGenerics>, 'ImageComponent'> & Pick<MessagesContextValue<StreamChatGenerics>, 'giphyVersion' | 'additionalTouchableProps' | 'ImageLoadingIndicator' | 'ImageLoadingFailedIndicator'> & {
8
9
  attachment: Attachment<StreamChatGenerics>;
9
10
  } & Pick<OverlayContextValue, 'setOverlay'>;
10
11
  export declare type GiphyProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Partial<GiphyPropsWithContext<StreamChatGenerics>> & {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ImageStyle, StyleProp, ViewStyle } from 'react-native';
2
+ import { ImageProps, ImageStyle, StyleProp, ViewStyle } from 'react-native';
3
3
  import { CircleProps } from 'react-native-svg';
4
4
  export declare type AvatarProps = {
5
5
  /** size in pixels */
@@ -7,6 +7,7 @@ export declare type AvatarProps = {
7
7
  containerStyle?: StyleProp<ViewStyle>;
8
8
  /** image url */
9
9
  image?: string;
10
+ ImageComponent?: React.ComponentType<ImageProps>;
10
11
  /** name of the picture, used for fallback */
11
12
  imageStyle?: StyleProp<ImageStyle>;
12
13
  name?: string;
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
- import { StyleProp, ViewStyle } from 'react-native';
2
+ import { ImageProps, StyleProp, ViewStyle } from 'react-native';
3
3
  export declare type GroupAvatarProps = {
4
4
  /** total size in pixels */
5
5
  size: number;
6
6
  containerStyle?: StyleProp<ViewStyle>;
7
+ ImageComponent?: React.ComponentType<ImageProps>;
7
8
  /** image urls */
8
9
  images?: string[];
9
10
  /** name of the users, used for fallback */
@@ -1,7 +1,9 @@
1
1
  import type { ChannelPreviewProps } from './ChannelPreview';
2
+ import { ChatContextValue } from '../../contexts/chatContext/ChatContext';
2
3
  import type { DefaultStreamChatGenerics } from '../../types/types';
3
4
  export declare type ChannelAvatarProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<ChannelPreviewProps<StreamChatGenerics>, 'channel'>;
4
5
  /**
5
6
  * This UI component displays an avatar for a particular channel.
6
7
  */
8
+ export declare const ChannelAvatarWithContext: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(props: ChannelAvatarProps<StreamChatGenerics> & Pick<ChatContextValue<DefaultStreamChatGenerics>, "ImageComponent">) => JSX.Element;
7
9
  export declare const ChannelAvatar: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(props: ChannelAvatarProps<StreamChatGenerics>) => JSX.Element;
@@ -4,7 +4,7 @@ import { DeepPartial } from '../../contexts/themeContext/ThemeContext';
4
4
  import type { Theme } from '../../contexts/themeContext/utils/theme';
5
5
  import type { DefaultStreamChatGenerics } from '../../types/types';
6
6
  import type { Streami18n } from '../../utils/Streami18n';
7
- export declare type ChatProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<ChatContextValue<StreamChatGenerics>, 'client'> & {
7
+ export declare type ChatProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<ChatContextValue<StreamChatGenerics>, 'client'> & Partial<Pick<ChatContextValue<StreamChatGenerics>, 'ImageComponent'>> & {
8
8
  /**
9
9
  * When false, ws connection won't be disconnection upon backgrounding the app.
10
10
  * To receive push notifications, its necessary that user doesn't have active
@@ -1,3 +1,3 @@
1
1
  import type { ChatContextValue } from '../../../contexts/chatContext/ChatContext';
2
2
  import type { DefaultStreamChatGenerics } from '../../../types/types';
3
- export declare const useCreateChatContext: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ appSettings, channel, client, connectionRecovering, enableOfflineSupport, isOnline, mutedUsers, setActiveChannel, subscribeConnectionRecoveredCallback, }: ChatContextValue<StreamChatGenerics>) => ChatContextValue<StreamChatGenerics>;
3
+ export declare const useCreateChatContext: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ appSettings, channel, client, connectionRecovering, enableOfflineSupport, ImageComponent, isOnline, mutedUsers, setActiveChannel, subscribeConnectionRecoveredCallback, }: ChatContextValue<StreamChatGenerics>) => ChatContextValue<StreamChatGenerics>;
@@ -0,0 +1,33 @@
1
+ import * as React from 'react';
2
+ import { ImageBackgroundProps, ImageProps } from 'react-native';
3
+ /**
4
+ * DISCLAIMER: This component has been pretty-much copied from react-native's source code
5
+ * https://github.com/facebook/react-native/blob/main/Libraries/Image/ImageBackground.js
6
+ * Few modifications have been done such as converting to functional component, removing ref related logic (since its not required).
7
+ * Also support for prop `ImageComponent` has been introduced to allow rendering custom
8
+ * component instead of `Image`.
9
+ *
10
+ *
11
+ * Very simple drop-in replacement for <Image> which supports nesting views.
12
+ *
13
+ * ```ReactNativeWebPlayer
14
+ * import React, { Component } from 'react';
15
+ * import { AppRegistry, View, ImageBackground, Text } from 'react-native';
16
+ *
17
+ * class DisplayAnImageBackground extends Component {
18
+ * render() {
19
+ * return (
20
+ * <ImageBackground
21
+ * style={{width: 50, height: 50}}
22
+ * source={{uri: 'https://reactnative.dev/img/opengraph.png'}}
23
+ * >
24
+ * <Text>React</Text>
25
+ * </ImageBackground>
26
+ * );
27
+ * }
28
+ * }
29
+ *
30
+ */
31
+ export declare const ImageBackground: React.ComponentType<ImageBackgroundProps & {
32
+ ImageComponent?: React.ComponentType<ImageProps>;
33
+ }>;
@@ -52,7 +52,8 @@ export declare type MessageActionHandlers = {
52
52
  toggleMuteUser: () => Promise<void>;
53
53
  toggleReaction: (reactionType: string) => Promise<void>;
54
54
  };
55
- export declare type MessagePropsWithContext<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<ChannelContextValue<StreamChatGenerics>, 'channel' | 'disabled' | 'enforceUniqueReaction' | 'members'> & Pick<ChatContextValue<StreamChatGenerics>, 'client' | 'mutedUsers'> & Pick<KeyboardContextValue, 'dismissKeyboard'> & Partial<Omit<MessageContextValue<StreamChatGenerics>, 'groupStyles' | 'message'>> & Pick<MessageContextValue<StreamChatGenerics>, 'groupStyles' | 'message'> & Pick<MessagesContextValue<StreamChatGenerics>, 'dismissKeyboardOnMessageTouch' | 'forceAlignMessages' | 'handleBlock' | 'handleCopy' | 'handleDelete' | 'handleEdit' | 'handleFlag' | 'handleMute' | 'handlePinMessage' | 'handleQuotedReply' | 'handleReaction' | 'handleRetry' | 'handleThreadReply' | 'isAttachmentEqual' | 'messageActions' | 'messageContentOrder' | 'MessageSimple' | 'onLongPressMessage' | 'onPressInMessage' | 'onPressMessage' | 'OverlayReactionList' | 'removeMessage' | 'retrySendMessage' | 'selectReaction' | 'setEditingState' | 'setQuotedMessageState' | 'supportedReactions' | 'updateMessage'> & Pick<MessageOverlayContextValue<StreamChatGenerics>, 'setData'> & Pick<OverlayContextValue, 'setOverlay'> & Pick<ThreadContextValue<StreamChatGenerics>, 'openThread'> & Pick<TranslationContextValue, 't'> & {
55
+ export declare type MessagePropsWithContext<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<ChannelContextValue<StreamChatGenerics>, 'channel' | 'disabled' | 'enforceUniqueReaction' | 'members'> & Pick<KeyboardContextValue, 'dismissKeyboard'> & Partial<Omit<MessageContextValue<StreamChatGenerics>, 'groupStyles' | 'message'>> & Pick<MessageContextValue<StreamChatGenerics>, 'groupStyles' | 'message'> & Pick<MessagesContextValue<StreamChatGenerics>, 'dismissKeyboardOnMessageTouch' | 'forceAlignMessages' | 'handleBlock' | 'handleCopy' | 'handleDelete' | 'handleEdit' | 'handleFlag' | 'handleMute' | 'handlePinMessage' | 'handleQuotedReply' | 'handleReaction' | 'handleRetry' | 'handleThreadReply' | 'isAttachmentEqual' | 'messageActions' | 'messageContentOrder' | 'MessageSimple' | 'onLongPressMessage' | 'onPressInMessage' | 'onPressMessage' | 'OverlayReactionList' | 'removeMessage' | 'retrySendMessage' | 'selectReaction' | 'setEditingState' | 'setQuotedMessageState' | 'supportedReactions' | 'updateMessage'> & Pick<MessageOverlayContextValue<StreamChatGenerics>, 'setData'> & Pick<OverlayContextValue, 'setOverlay'> & Pick<ThreadContextValue<StreamChatGenerics>, 'openThread'> & Pick<TranslationContextValue, 't'> & {
56
+ chatContext: ChatContextValue<StreamChatGenerics>;
56
57
  messagesContext: MessagesContextValue<StreamChatGenerics>;
57
58
  /**
58
59
  * Whether or not users are able to long press messages.
@@ -1,7 +1,8 @@
1
+ import { ChatContextValue } from '../../../contexts/chatContext/ChatContext';
1
2
  import { MessageContextValue } from '../../../contexts/messageContext/MessageContext';
2
3
  import type { DefaultStreamChatGenerics } from '../../../types/types';
3
4
  import { AvatarProps } from '../../Avatar/Avatar';
4
- export declare type MessageAvatarPropsWithContext<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<MessageContextValue<StreamChatGenerics>, 'alignment' | 'lastGroupMessage' | 'message' | 'showAvatar'> & Partial<Pick<AvatarProps, 'size'>>;
5
+ export declare type MessageAvatarPropsWithContext<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<MessageContextValue<StreamChatGenerics>, 'alignment' | 'lastGroupMessage' | 'message' | 'showAvatar'> & Pick<ChatContextValue<StreamChatGenerics>, 'ImageComponent'> & Partial<Pick<AvatarProps, 'size'>>;
5
6
  export declare type MessageAvatarProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Partial<MessageAvatarPropsWithContext<StreamChatGenerics>>;
6
7
  export declare const MessageAvatar: {
7
8
  <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(props: Partial<MessageAvatarPropsWithContext<StreamChatGenerics>>): JSX.Element;
@@ -1,4 +1,6 @@
1
+ import { ChatContextValue } from '../../../contexts/chatContext/ChatContext';
1
2
  import type { MessageContextValue } from '../../../contexts/messageContext/MessageContext';
2
3
  import type { DefaultStreamChatGenerics } from '../../../types/types';
3
4
  export declare type MessageRepliesAvatarsProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<MessageContextValue<StreamChatGenerics>, 'alignment' | 'message'>;
5
+ export declare const MessageRepliesAvatarsWithContext: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(props: MessageRepliesAvatarsProps<StreamChatGenerics> & Pick<ChatContextValue<DefaultStreamChatGenerics>, "ImageComponent">) => JSX.Element;
4
6
  export declare const MessageRepliesAvatars: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(props: MessageRepliesAvatarsProps<StreamChatGenerics>) => JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import React, { PropsWithChildren } from 'react';
2
+ import type { ImageProps } from 'react-native';
2
3
  import type { AppSettingsAPIResponse, Channel, EventHandler, Mute, StreamChat } from 'stream-chat';
3
4
  import type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';
4
5
  export declare type ChatContextValue<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
@@ -25,6 +26,7 @@ export declare type ChatContextValue<StreamChatGenerics extends DefaultStreamCha
25
26
  client: StreamChat<StreamChatGenerics>;
26
27
  connectionRecovering: boolean;
27
28
  enableOfflineSupport: boolean;
29
+ ImageComponent: React.ComponentType<ImageProps>;
28
30
  isOnline: boolean;
29
31
  mutedUsers: Mute<StreamChatGenerics>[];
30
32
  /**
@@ -55,7 +57,7 @@ export declare type ChatContextValue<StreamChatGenerics extends DefaultStreamCha
55
57
  };
56
58
  export declare const ChatContext: React.Context<ChatContextValue<DefaultStreamChatGenerics>>;
57
59
  export declare const ChatProvider: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ children, value, }: React.PropsWithChildren<{
58
- value: ChatContextValue<StreamChatGenerics>;
60
+ value?: ChatContextValue<StreamChatGenerics> | undefined;
59
61
  }>) => JSX.Element;
60
62
  export declare const useChatContext: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>() => ChatContextValue<StreamChatGenerics>;
61
63
  /**
@@ -1,4 +1,5 @@
1
1
  import React, { PropsWithChildren } from 'react';
2
+ import type { ImageProps } from 'react-native';
2
3
  import type { Attachment, TranslationLanguages } from 'stream-chat';
3
4
  import type { GroupType, MessageType } from '../../components/MessageList/hooks/useMessageList';
4
5
  import type { MessageActionListProps } from '../../components/MessageOverlay/MessageActionList';
@@ -8,15 +9,18 @@ import type { OverlayReactionsProps } from '../../components/MessageOverlay/Over
8
9
  import type { OverlayReactionsAvatarProps } from '../../components/MessageOverlay/OverlayReactionsAvatar';
9
10
  import type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';
10
11
  import type { ReactionData } from '../../utils/utils';
12
+ import type { ChatContextValue } from '../chatContext/ChatContext';
11
13
  import type { Alignment, MessageContextValue } from '../messageContext/MessageContext';
12
14
  import type { MessagesContextValue } from '../messagesContext/MessagesContext';
13
15
  import type { OwnCapabilitiesContextValue } from '../ownCapabilitiesContext/OwnCapabilitiesContext';
14
16
  export declare type MessageOverlayData<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
15
17
  alignment?: Alignment;
18
+ chatContext?: ChatContextValue<StreamChatGenerics>;
16
19
  clientId?: string;
17
20
  files?: Attachment<StreamChatGenerics>[];
18
21
  groupStyles?: GroupType[];
19
22
  handleReaction?: (reactionType: string) => Promise<void>;
23
+ ImageComponent?: React.ComponentType<ImageProps>;
20
24
  images?: Attachment<StreamChatGenerics>[];
21
25
  message?: MessageType<StreamChatGenerics>;
22
26
  messageActions?: MessageActionType[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stream-chat-react-native-core",
3
3
  "description": "The official React Native and Expo components for Stream Chat, a service for building chat applications",
4
- "version": "5.2.0",
4
+ "version": "5.3.0-beta.1",
5
5
  "author": {
6
6
  "company": "Stream.io Inc",
7
7
  "name": "Stream.io Inc"
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import {
3
- ImageBackground,
3
+ Image,
4
4
  ImageStyle,
5
5
  StyleProp,
6
6
  StyleSheet,
@@ -15,6 +15,8 @@ import type { Attachment } from 'stream-chat';
15
15
 
16
16
  import { openUrlSafely } from './utils/openUrlSafely';
17
17
 
18
+ import { ChatContextValue, useChatContext } from '../../contexts/chatContext/ChatContext';
19
+
18
20
  import {
19
21
  MessageContextValue,
20
22
  useMessageContext,
@@ -27,6 +29,7 @@ import { useTheme } from '../../contexts/themeContext/ThemeContext';
27
29
  import { Play } from '../../icons/Play';
28
30
  import type { DefaultStreamChatGenerics } from '../../types/types';
29
31
  import { makeImageCompatibleUrl } from '../../utils/utils';
32
+ import { ImageBackground } from '../ImageBackground';
30
33
 
31
34
  const styles = StyleSheet.create({
32
35
  authorName: { fontSize: 14.5, fontWeight: '600' },
@@ -82,6 +85,7 @@ const styles = StyleSheet.create({
82
85
  export type CardPropsWithContext<
83
86
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
84
87
  > = Attachment<StreamChatGenerics> &
88
+ Pick<ChatContextValue, 'ImageComponent'> &
85
89
  Pick<
86
90
  MessageContextValue<StreamChatGenerics>,
87
91
  'onLongPress' | 'onPress' | 'onPressIn' | 'preventPress'
@@ -117,6 +121,7 @@ const CardWithContext = <
117
121
  CardCover,
118
122
  CardFooter,
119
123
  CardHeader,
124
+ ImageComponent = Image,
120
125
  image_url,
121
126
  og_scrape_url,
122
127
  onLongPress,
@@ -198,6 +203,7 @@ const CardWithContext = <
198
203
  {uri && !CardCover && (
199
204
  <View>
200
205
  <ImageBackground
206
+ ImageComponent={ImageComponent}
201
207
  imageStyle={styles.cardCover}
202
208
  resizeMode='cover'
203
209
  source={{ uri: makeImageCompatibleUrl(uri) }}
@@ -287,7 +293,8 @@ export type CardProps<
287
293
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
288
294
  > = Attachment<StreamChatGenerics> &
289
295
  Partial<
290
- Pick<MessageContextValue<StreamChatGenerics>, 'onLongPress' | 'onPress' | 'onPressIn'> &
296
+ Pick<ChatContextValue<StreamChatGenerics>, 'ImageComponent'> &
297
+ Pick<MessageContextValue<StreamChatGenerics>, 'onLongPress' | 'onPress' | 'onPressIn'> &
291
298
  Pick<
292
299
  MessagesContextValue<StreamChatGenerics>,
293
300
  'additionalTouchableProps' | 'CardCover' | 'CardFooter' | 'CardHeader'
@@ -302,6 +309,7 @@ export const Card = <
302
309
  >(
303
310
  props: CardProps<StreamChatGenerics>,
304
311
  ) => {
312
+ const { ImageComponent } = useChatContext<StreamChatGenerics>();
305
313
  const { message, onLongPress, onPress, onPressIn, preventPress } =
306
314
  useMessageContext<StreamChatGenerics>();
307
315
  const { additionalTouchableProps, CardCover, CardFooter, CardHeader } =
@@ -316,6 +324,7 @@ export const Card = <
316
324
  CardFooter,
317
325
  CardHeader,
318
326
  channelId: message.cid,
327
+ ImageComponent,
319
328
  messageId: message.id,
320
329
  onLongPress,
321
330
  onPress,
@@ -34,12 +34,6 @@ import { isVideoPackageAvailable } from '../../native';
34
34
  import type { DefaultStreamChatGenerics } from '../../types/types';
35
35
  import { getUrlWithoutParams } from '../../utils/utils';
36
36
 
37
- const MemoizedGalleryImage = React.memo(
38
- GalleryImage,
39
- (prevProps, nextProps) =>
40
- getUrlWithoutParams(prevProps.uri) === getUrlWithoutParams(nextProps.uri),
41
- ) as typeof GalleryImage;
42
-
43
37
  const styles = StyleSheet.create({
44
38
  errorTextSize: { fontSize: 10 },
45
39
  galleryContainer: {
@@ -476,7 +470,7 @@ const GalleryImageThumbnail = <
476
470
  <ImageLoadingFailedIndicator style={[styles.imageLoadingErrorIndicatorStyle]} />
477
471
  ) : (
478
472
  <>
479
- <MemoizedGalleryImage
473
+ <GalleryImage
480
474
  onError={(error) => {
481
475
  console.warn(error);
482
476
  setLoadingImage(false);
@@ -1,17 +1,20 @@
1
1
  import React from 'react';
2
- import { ImageBackground, ImageProps } from 'react-native';
2
+ import { Image, ImageProps } from 'react-native';
3
3
 
4
- import { makeImageCompatibleUrl } from '../../utils/utils';
4
+ import { ChatContextValue, useChatContext } from '../../contexts/chatContext/ChatContext';
5
5
 
6
- export const GalleryImage: React.FC<
7
- Omit<ImageProps, 'height' | 'source'> & {
8
- uri: string;
9
- }
10
- > = (props) => {
11
- const { uri, ...rest } = props;
6
+ import type { DefaultStreamChatGenerics } from '../../types/types';
7
+ import { getUrlWithoutParams, makeImageCompatibleUrl } from '../../utils/utils';
8
+
9
+ export type GalleryImageWithContextProps<
10
+ StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
11
+ > = GalleryImageProps & Pick<ChatContextValue<StreamChatGenerics>, 'ImageComponent'>;
12
+
13
+ export const GalleryImageWithContext: React.FC<GalleryImageWithContextProps> = (props) => {
14
+ const { ImageComponent = Image, uri, ...rest } = props;
12
15
 
13
16
  return (
14
- <ImageBackground
17
+ <ImageComponent
15
18
  {...rest}
16
19
  accessibilityLabel='Gallery Image'
17
20
  source={{
@@ -20,3 +23,22 @@ export const GalleryImage: React.FC<
20
23
  />
21
24
  );
22
25
  };
26
+
27
+ export const MemoizedGalleryImage = React.memo(
28
+ GalleryImageWithContext,
29
+ (prevProps, nextProps) =>
30
+ getUrlWithoutParams(prevProps.uri) === getUrlWithoutParams(nextProps.uri),
31
+ );
32
+ export type GalleryImageProps = Omit<ImageProps, 'height' | 'source'> & {
33
+ uri: string;
34
+ };
35
+
36
+ export const GalleryImage = <
37
+ StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
38
+ >(
39
+ props: GalleryImageProps,
40
+ ) => {
41
+ const { ImageComponent } = useChatContext<StreamChatGenerics>();
42
+
43
+ return <MemoizedGalleryImage ImageComponent={ImageComponent} {...props} />;
44
+ };
@@ -3,6 +3,8 @@ import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
3
3
 
4
4
  import type { Attachment } from 'stream-chat';
5
5
 
6
+ import { ChatContextValue, useChatContext } from '../../contexts/chatContext/ChatContext';
7
+
6
8
  import {
7
9
  ImageGalleryContextValue,
8
10
  useImageGalleryContext,
@@ -145,6 +147,7 @@ export type GiphyPropsWithContext<
145
147
  | 'onPressIn'
146
148
  | 'preventPress'
147
149
  > &
150
+ Pick<ChatContextValue<StreamChatGenerics>, 'ImageComponent'> &
148
151
  Pick<
149
152
  MessagesContextValue<StreamChatGenerics>,
150
153
  | 'giphyVersion'
@@ -165,6 +168,7 @@ const GiphyWithContext = <
165
168
  attachment,
166
169
  giphyVersion,
167
170
  handleAction,
171
+ ImageComponent = Image,
168
172
  ImageLoadingFailedIndicator,
169
173
  ImageLoadingIndicator,
170
174
  isMyMessage,
@@ -241,7 +245,7 @@ const GiphyWithContext = <
241
245
  >{`/giphy ${title}`}</Text>
242
246
  </View>
243
247
  <View style={styles.selectionImageContainer}>
244
- <Image
248
+ <ImageComponent
245
249
  onError={(error) => {
246
250
  console.warn(error);
247
251
  setLoadingImage(false);
@@ -339,7 +343,7 @@ const GiphyWithContext = <
339
343
  container,
340
344
  ]}
341
345
  >
342
- <Image
346
+ <ImageComponent
343
347
  accessibilityLabel='Giphy Attachment Image'
344
348
  onError={(error) => {
345
349
  console.warn(error);
@@ -446,6 +450,7 @@ export const Giphy = <
446
450
  ) => {
447
451
  const { handleAction, isMyMessage, message, onLongPress, onPress, onPressIn, preventPress } =
448
452
  useMessageContext<StreamChatGenerics>();
453
+ const { ImageComponent } = useChatContext<StreamChatGenerics>();
449
454
  const { additionalTouchableProps, giphyVersion } = useMessagesContext<StreamChatGenerics>();
450
455
  const { setMessages, setSelectedMessage } = useImageGalleryContext<StreamChatGenerics>();
451
456
  const { setOverlay } = useOverlayContext();
@@ -464,6 +469,7 @@ export const Giphy = <
464
469
  additionalTouchableProps,
465
470
  giphyVersion,
466
471
  handleAction,
472
+ ImageComponent,
467
473
  ImageLoadingFailedIndicator,
468
474
  ImageLoadingIndicator,
469
475
  isMyMessage,
@@ -1,5 +1,13 @@
1
1
  import React from 'react';
2
- import { Image, ImageStyle, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
2
+ import {
3
+ Image,
4
+ ImageProps,
5
+ ImageStyle,
6
+ StyleProp,
7
+ StyleSheet,
8
+ View,
9
+ ViewStyle,
10
+ } from 'react-native';
3
11
  import Svg, { Circle, CircleProps } from 'react-native-svg';
4
12
 
5
13
  import { useTheme } from '../../contexts/themeContext/ThemeContext';
@@ -38,6 +46,7 @@ export type AvatarProps = {
38
46
  containerStyle?: StyleProp<ViewStyle>;
39
47
  /** image url */
40
48
  image?: string;
49
+ ImageComponent?: React.ComponentType<ImageProps>;
41
50
  /** name of the picture, used for fallback */
42
51
  imageStyle?: StyleProp<ImageStyle>;
43
52
  name?: string;
@@ -53,6 +62,7 @@ export type AvatarProps = {
53
62
  export const Avatar: React.FC<AvatarProps> = (props) => {
54
63
  const {
55
64
  containerStyle,
65
+ ImageComponent = Image,
56
66
  image: imageProp,
57
67
  imageStyle,
58
68
  name,
@@ -95,7 +105,7 @@ export const Avatar: React.FC<AvatarProps> = (props) => {
95
105
  }}
96
106
  />
97
107
  ) : (
98
- <Image
108
+ <ImageComponent
99
109
  accessibilityLabel={testID || 'Avatar Image'}
100
110
  onError={() => setLoadingImageError(true)}
101
111
  source={{
@@ -1,10 +1,9 @@
1
1
  import React from 'react';
2
- import { Image, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
2
+ import { Image, ImageProps, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
3
3
 
4
4
  import { useTheme } from '../../contexts/themeContext/ThemeContext';
5
5
  import { useLoadingImage } from '../../hooks/useLoadingImage';
6
6
  import { getResizedImageUrl } from '../../utils/getResizedImageUrl';
7
-
8
7
  const randomImageBaseUrl = 'https://getstream.io/random_png/';
9
8
  const randomSvgBaseUrl = 'https://getstream.io/random_svg/';
10
9
  const streamCDN = 'stream-io-cdn.com';
@@ -27,6 +26,7 @@ export type GroupAvatarProps = {
27
26
  /** total size in pixels */
28
27
  size: number;
29
28
  containerStyle?: StyleProp<ViewStyle>;
29
+ ImageComponent?: React.ComponentType<ImageProps>;
30
30
  /** image urls */
31
31
  images?: string[];
32
32
  /** name of the users, used for fallback */
@@ -38,7 +38,7 @@ export type GroupAvatarProps = {
38
38
  * GroupAvatar - A round group of avatar images with fallbacks to users' initials
39
39
  */
40
40
  export const GroupAvatar: React.FC<GroupAvatarProps> = (props) => {
41
- const { containerStyle, images, names, size, testID } = props;
41
+ const { containerStyle, ImageComponent = Image, images, names, size, testID } = props;
42
42
  const {
43
43
  theme: {
44
44
  groupAvatar: { container, image },
@@ -136,7 +136,7 @@ export const GroupAvatar: React.FC<GroupAvatarProps> = (props) => {
136
136
  ]}
137
137
  >
138
138
  {column.map(({ height, name, url, width }, rowIndex) => (
139
- <Image
139
+ <ImageComponent
140
140
  accessibilityLabel={testID || 'Avatar Image'}
141
141
  key={`avatar-${url}-${rowIndex}`}
142
142
  onError={() => setLoadingImageError(true)}
@@ -1,5 +1,5 @@
1
1
  import React, { useState } from 'react';
2
- import { Text } from 'react-native';
2
+ import { Image, Text } from 'react-native';
3
3
 
4
4
  import { act } from 'react-test-renderer';
5
5
 
@@ -59,6 +59,7 @@ describe('useChannelUpdated', () => {
59
59
  client: mockClient,
60
60
  connectionRecovering: false,
61
61
  enableOfflineSupport: false,
62
+ ImageComponent: Image,
62
63
  isOnline: true,
63
64
  mutedUsers: [],
64
65
  setActiveChannel: () => null,
@@ -4,6 +4,7 @@ import type { ChannelPreviewProps } from './ChannelPreview';
4
4
  import { useChannelPreviewDisplayAvatar } from './hooks/useChannelPreviewDisplayAvatar';
5
5
  import { useChannelPreviewDisplayPresence } from './hooks/useChannelPreviewDisplayPresence';
6
6
 
7
+ import { ChatContextValue, useChatContext } from '../../contexts/chatContext/ChatContext';
7
8
  import type { DefaultStreamChatGenerics } from '../../types/types';
8
9
  import { Avatar } from '../Avatar/Avatar';
9
10
  import { GroupAvatar } from '../Avatar/GroupAvatar';
@@ -15,26 +16,44 @@ export type ChannelAvatarProps<
15
16
  /**
16
17
  * This UI component displays an avatar for a particular channel.
17
18
  */
18
- export const ChannelAvatar = <
19
+ export const ChannelAvatarWithContext = <
19
20
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
20
21
  >(
21
- props: ChannelAvatarProps<StreamChatGenerics>,
22
+ props: ChannelAvatarProps<StreamChatGenerics> & Pick<ChatContextValue, 'ImageComponent'>,
22
23
  ) => {
23
- const { channel } = props;
24
+ const { channel, ImageComponent } = props;
24
25
 
25
26
  const displayAvatar = useChannelPreviewDisplayAvatar(channel);
26
27
  const displayPresence = useChannelPreviewDisplayPresence(channel);
27
28
 
28
29
  if (displayAvatar.images) {
29
- return <GroupAvatar images={displayAvatar.images} names={displayAvatar.names} size={40} />;
30
+ return (
31
+ <GroupAvatar
32
+ ImageComponent={ImageComponent}
33
+ images={displayAvatar.images}
34
+ names={displayAvatar.names}
35
+ size={40}
36
+ />
37
+ );
30
38
  }
31
39
 
32
40
  return (
33
41
  <Avatar
34
42
  image={displayAvatar.image}
43
+ ImageComponent={ImageComponent}
35
44
  name={displayAvatar.name}
36
45
  online={displayPresence}
37
46
  size={40}
38
47
  />
39
48
  );
40
49
  };
50
+
51
+ export const ChannelAvatar = <
52
+ StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
53
+ >(
54
+ props: ChannelAvatarProps<StreamChatGenerics>,
55
+ ) => {
56
+ const { ImageComponent } = useChatContext<StreamChatGenerics>();
57
+
58
+ return <ChannelAvatarWithContext {...props} ImageComponent={ImageComponent} />;
59
+ };