UNPKG

stream-chat-react

Version:

React components to create chat conversations or livestream style chat

57 lines (56 loc) 3.21 kB
import React, { PropsWithChildren } from 'react'; import type { AppSettingsAPIResponse, Channel, Mute, SearchController } from 'stream-chat'; import type { ChatProps } from '../components/Chat/Chat'; import type { DefaultStreamChatGenerics, UnknownType } from '../types/types'; import type { ChannelsQueryState } from '../components/Chat/hooks/useChannelsQueryState'; type CSSClasses = 'chat' | 'chatContainer' | 'channel' | 'channelList' | 'message' | 'messageList' | 'thread' | 'threadList' | 'virtualMessage' | 'virtualizedMessageList'; export type CustomClasses = Partial<Record<CSSClasses, string>>; type ChannelCID = string; export type ChatContextValue<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = { /** * Indicates, whether a channels query has been triggered within ChannelList by its channels pagination controller. */ channelsQueryState: ChannelsQueryState; closeMobileNav: () => void; getAppSettings: () => Promise<AppSettingsAPIResponse<StreamChatGenerics>> | null; latestMessageDatesByChannels: Record<ChannelCID, Date>; mutes: Array<Mute<StreamChatGenerics>>; openMobileNav: () => void; /** Instance of SearchController class that allows to control all the search operations. */ searchController: SearchController<StreamChatGenerics>; /** * Sets active channel to be rendered within Channel component. * @param newChannel * @param watchers * @param event */ setActiveChannel: (newChannel?: Channel<StreamChatGenerics>, watchers?: { limit?: number; offset?: number; }, event?: React.BaseSyntheticEvent) => void; useImageFlagEmojisOnWindows: boolean; /** * Active channel used to render the contents of the Channel component. */ channel?: Channel<StreamChatGenerics>; /** * Object through which custom classes can be set for main container components of the SDK. */ customClasses?: CustomClasses; navOpen?: boolean; } & Partial<Pick<ChatProps<StreamChatGenerics>, 'isMessageAIGenerated'>> & Required<Pick<ChatProps<StreamChatGenerics>, 'theme' | 'client'>>; export declare const ChatContext: React.Context<ChatContextValue<DefaultStreamChatGenerics> | undefined>; export declare const ChatProvider: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ children, value, }: PropsWithChildren<{ value: ChatContextValue<StreamChatGenerics>; }>) => React.JSX.Element; export declare const useChatContext: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(componentName?: string) => ChatContextValue<StreamChatGenerics>; /** * Typescript currently does not support partial inference so if ChatContext * typing is desired while using the HOC withChatContext the Props for the * wrapped component must be provided as the first generic. */ export declare const withChatContext: <P extends UnknownType, StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(Component: React.ComponentType<P>) => { (props: Omit<P, keyof ChatContextValue<StreamChatGenerics>>): React.JSX.Element; displayName: string; }; export {};