11import React , { PropsWithChildren , useMemo } from 'react' ;
2+ import type { StreamChat } from 'stream-chat' ;
23import {
34 ChannelSearchSource ,
45 MessageSearchSource ,
@@ -12,73 +13,47 @@ import { useChannelsQueryState } from './hooks/useChannelsQueryState';
1213
1314import { ChatProvider , CustomClasses } from '../../context/ChatContext' ;
1415import { TranslationProvider } from '../../context/TranslationContext' ;
15- import { WithComponents } from '../../context' ;
1616
17- import type { StreamChat } from 'stream-chat' ;
18- import type { ChannelPropsForwardedToComponentContext } from '../Channel' ;
19- import type { ComponentContextValue } from '../../context' ;
17+ import type { MessageContextValue } from '../../context' ;
2018import type { SupportedTranslations } from '../../i18n/types' ;
2119import type { Streami18n } from '../../i18n/Streami18n' ;
22- import type { CustomTrigger , DefaultStreamChatGenerics } from '../../types/types' ;
23- import type { MessageContextValue } from '../../context' ;
24-
25- export type ChatPropsForwardedToComponentContext <
26- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics ,
27- V extends CustomTrigger = CustomTrigger
28- > = Pick <
29- ComponentContextValue < StreamChatGenerics , V > ,
30- | 'ChannelAvatar'
31- | 'Search'
32- | 'SearchBar'
33- | 'SearchResults'
34- | 'SearchResultsHeader'
35- | 'SearchResultsPresearch'
36- | 'SearchSourceResultList'
37- | 'SearchSourceResultListFooter'
38- | 'SearchSourceResults'
39- | 'SearchSourceResultsEmpty'
40- | 'SearchSourceResultsHeader'
41- | 'SearchSourceResultsLoadingIndicator'
42- > ;
20+ import type { DefaultStreamChatGenerics } from '../../types/types' ;
4321
4422export type ChatProps <
45- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics ,
46- V extends CustomTrigger = CustomTrigger
47- > = ChatPropsForwardedToComponentContext < StreamChatGenerics , V > &
48- ChannelPropsForwardedToComponentContext < StreamChatGenerics > & {
49- /** The StreamChat client object */
50- client : StreamChat < StreamChatGenerics > ;
51- /** Object containing custom CSS classnames to override the library's default container CSS */
52- customClasses ?: CustomClasses ;
53- /** Sets the default fallback language for UI component translation, defaults to 'en' for English */
54- defaultLanguage ?: SupportedTranslations ;
55- /** Instance of Stream i18n */
56- i18nInstance ?: Streami18n ;
57- /** Initial status of mobile navigation */
58- initialNavOpen ?: boolean ;
59- /** Instance of SearchController class that allows to control all the search operations. */
60- searchController ?: SearchController < StreamChatGenerics > ;
61- /** Used for injecting className/s to the Channel and ChannelList components */
62- theme ?: string ;
63- /**
64- * Windows 10 does not support country flag emojis out of the box. It chooses to render these emojis as characters instead. Stream
65- * Chat can override this behavior by loading a custom web font that will render images instead (PNGs or SVGs depending on the platform).
66- * Set this prop to true if you want to use these custom emojis for Windows users.
67- *
68- * Note: requires importing `stream-chat-react/css/v2/emoji-replacement.css` style sheet
69- */
70- useImageFlagEmojisOnWindows ?: boolean ;
71- } & Partial < Pick < MessageContextValue < StreamChatGenerics > , 'isMessageAIGenerated' > > ;
23+ StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
24+ > = {
25+ /** The StreamChat client object */
26+ client : StreamChat < StreamChatGenerics > ;
27+ /** Object containing custom CSS classnames to override the library's default container CSS */
28+ customClasses ?: CustomClasses ;
29+ /** Sets the default fallback language for UI component translation, defaults to 'en' for English */
30+ defaultLanguage ?: SupportedTranslations ;
31+ /** Instance of Stream i18n */
32+ i18nInstance ?: Streami18n ;
33+ /** Initial status of mobile navigation */
34+ initialNavOpen ?: boolean ;
35+ /** Instance of SearchController class that allows to control all the search operations. */
36+ searchController ?: SearchController < StreamChatGenerics > ;
37+ /** Used for injecting className/s to the Channel and ChannelList components */
38+ theme ?: string ;
39+ /**
40+ * Windows 10 does not support country flag emojis out of the box. It chooses to render these emojis as characters instead. Stream
41+ * Chat can override this behavior by loading a custom web font that will render images instead (PNGs or SVGs depending on the platform).
42+ * Set this prop to true if you want to use these custom emojis for Windows users.
43+ *
44+ * Note: requires importing `stream-chat-react/css/v2/emoji-replacement.css` style sheet
45+ */
46+ useImageFlagEmojisOnWindows ?: boolean ;
47+ } & Partial < Pick < MessageContextValue < StreamChatGenerics > , 'isMessageAIGenerated' > > ;
7248
7349/**
7450 * Wrapper component for a StreamChat application. Chat needs to be placed around any other chat components
7551 * as it provides the ChatContext.
7652 */
7753export const Chat = <
78- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics ,
79- V extends CustomTrigger = CustomTrigger
54+ StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
8055> (
81- props : PropsWithChildren < ChatProps < StreamChatGenerics , V > > ,
56+ props : PropsWithChildren < ChatProps < StreamChatGenerics > > ,
8257) => {
8358 const {
8459 children,
@@ -138,159 +113,11 @@ export const Chat = <
138113 useImageFlagEmojisOnWindows,
139114 } ) ;
140115
141- // @ts -expect-error
142- const componentContextValue : Partial < ComponentContextValue > = useMemo (
143- ( ) => ( {
144- Attachment : props . Attachment ,
145- AttachmentPreviewList : props . AttachmentPreviewList ,
146- AttachmentSelector : props . AttachmentSelector ,
147- AttachmentSelectorInitiationButtonContents : props . AttachmentSelectorInitiationButtonContents ,
148- AudioRecorder : props . AudioRecorder ,
149- AutocompleteSuggestionItem : props . AutocompleteSuggestionItem ,
150- AutocompleteSuggestionList : props . AutocompleteSuggestionList ,
151- Avatar : props . Avatar ,
152- BaseImage : props . BaseImage ,
153- ChannelAvatar : props . ChannelAvatar ,
154- CooldownTimer : props . CooldownTimer ,
155- CustomMessageActionsList : props . CustomMessageActionsList ,
156- DateSeparator : props . DateSeparator ,
157- EditMessageInput : props . EditMessageInput ,
158- EmojiPicker : props . EmojiPicker ,
159- emojiSearchIndex : props . emojiSearchIndex ,
160- EmptyStateIndicator : props . EmptyStateIndicator ,
161- FileUploadIcon : props . FileUploadIcon ,
162- GiphyPreviewMessage : props . GiphyPreviewMessage ,
163- HeaderComponent : props . HeaderComponent ,
164- Input : props . Input ,
165- LinkPreviewList : props . LinkPreviewList ,
166- LoadingIndicator : props . LoadingIndicator ,
167- Message : props . Message ,
168- MessageActions : props . MessageActions ,
169- MessageBouncePrompt : props . MessageBouncePrompt ,
170- MessageDeleted : props . MessageDeleted ,
171- MessageListNotifications : props . MessageListNotifications ,
172- MessageNotification : props . MessageNotification ,
173- MessageOptions : props . MessageOptions ,
174- MessageRepliesCountButton : props . MessageRepliesCountButton ,
175- MessageStatus : props . MessageStatus ,
176- MessageSystem : props . MessageSystem ,
177- MessageTimestamp : props . MessageTimestamp ,
178- ModalGallery : props . ModalGallery ,
179- PinIndicator : props . PinIndicator ,
180- PollActions : props . PollActions ,
181- PollContent : props . PollContent ,
182- PollCreationDialog : props . PollCreationDialog ,
183- PollHeader : props . PollHeader ,
184- PollOptionSelector : props . PollOptionSelector ,
185- QuotedMessage : props . QuotedMessage ,
186- QuotedMessagePreview : props . QuotedMessagePreview ,
187- QuotedPoll : props . QuotedPoll ,
188- reactionOptions : props . reactionOptions ,
189- ReactionSelector : props . ReactionSelector ,
190- ReactionsList : props . ReactionsList ,
191- Search : props . Search ,
192- SearchBar : props . SearchBar ,
193- SearchResults : props . SearchResults ,
194- SearchResultsHeader : props . SearchResultsHeader ,
195- SearchResultsPresearch : props . SearchResultsPresearch ,
196- SearchSourceResultList : props . SearchSourceResultList ,
197- SearchSourceResultListFooter : props . SearchSourceResultListFooter ,
198- SearchSourceResults : props . SearchSourceResults ,
199- SearchSourceResultsEmpty : props . SearchSourceResultsEmpty ,
200- SearchSourceResultsHeader : props . SearchSourceResultsHeader ,
201- SearchSourceResultsLoadingIndicator : props . SearchSourceResultsLoadingIndicator ,
202- SendButton : props . SendButton ,
203- StartRecordingAudioButton : props . StartRecordingAudioButton ,
204- ThreadHead : props . ThreadHead ,
205- ThreadHeader : props . ThreadHeader ,
206- ThreadStart : props . ThreadStart ,
207- Timestamp : props . Timestamp ,
208- TriggerProvider : props . TriggerProvider ,
209- TypingIndicator : props . TypingIndicator ,
210- UnreadMessagesNotification : props . UnreadMessagesNotification ,
211- UnreadMessagesSeparator : props . UnreadMessagesSeparator ,
212- VirtualMessage : props . VirtualMessage ,
213- } ) ,
214- [
215- props . Attachment ,
216- props . AttachmentPreviewList ,
217- props . AttachmentSelector ,
218- props . AttachmentSelectorInitiationButtonContents ,
219- props . AudioRecorder ,
220- props . AutocompleteSuggestionItem ,
221- props . AutocompleteSuggestionList ,
222- props . Avatar ,
223- props . BaseImage ,
224- props . ChannelAvatar ,
225- props . CooldownTimer ,
226- props . CustomMessageActionsList ,
227- props . DateSeparator ,
228- props . EditMessageInput ,
229- props . EmojiPicker ,
230- props . EmptyStateIndicator ,
231- props . FileUploadIcon ,
232- props . GiphyPreviewMessage ,
233- props . HeaderComponent ,
234- props . Input ,
235- props . LinkPreviewList ,
236- props . LoadingIndicator ,
237- props . Message ,
238- props . MessageActions ,
239- props . MessageBouncePrompt ,
240- props . MessageDeleted ,
241- props . MessageListNotifications ,
242- props . MessageNotification ,
243- props . MessageOptions ,
244- props . MessageRepliesCountButton ,
245- props . MessageStatus ,
246- props . MessageSystem ,
247- props . MessageTimestamp ,
248- props . ModalGallery ,
249- props . PinIndicator ,
250- props . PollActions ,
251- props . PollContent ,
252- props . PollCreationDialog ,
253- props . PollHeader ,
254- props . PollOptionSelector ,
255- props . QuotedMessage ,
256- props . QuotedMessagePreview ,
257- props . QuotedPoll ,
258- props . ReactionSelector ,
259- props . ReactionsList ,
260- props . Search ,
261- props . SearchBar ,
262- props . SearchResults ,
263- props . SearchResultsHeader ,
264- props . SearchResultsPresearch ,
265- props . SearchSourceResultList ,
266- props . SearchSourceResultListFooter ,
267- props . SearchSourceResults ,
268- props . SearchSourceResultsEmpty ,
269- props . SearchSourceResultsHeader ,
270- props . SearchSourceResultsLoadingIndicator ,
271- props . SendButton ,
272- props . StartRecordingAudioButton ,
273- props . ThreadHead ,
274- props . ThreadHeader ,
275- props . ThreadStart ,
276- props . Timestamp ,
277- props . TriggerProvider ,
278- props . TypingIndicator ,
279- props . UnreadMessagesNotification ,
280- props . UnreadMessagesSeparator ,
281- props . VirtualMessage ,
282- props . emojiSearchIndex ,
283- props . reactionOptions ,
284- ] ,
285- ) ;
286-
287116 if ( ! translators . t ) return null ;
288117
289118 return (
290119 < ChatProvider value = { chatContextValue } >
291- < TranslationProvider value = { translators } >
292- < WithComponents overrides = { componentContextValue } > { children } </ WithComponents >
293- </ TranslationProvider >
120+ < TranslationProvider value = { translators } > { children } </ TranslationProvider >
294121 </ ChatProvider >
295122 ) ;
296123} ;
0 commit comments