UNPKG

stream-chat-react

Version:

React components to create chat conversations or livestream style chat

58 lines (57 loc) 2.66 kB
import React from 'react'; import type { PropsWithChildren } from 'react'; import type { AppSettingsAPIResponse, Channel, Mute, SearchController } from 'stream-chat'; import type { ChatProps } from '../components/Chat/Chat'; import type { 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 ChannelConfId = string; export type ChatContextValue = { /** * Indicates, whether a channels query has been triggered within ChannelList by its channels pagination controller. */ channelsQueryState: ChannelsQueryState; closeMobileNav: () => void; getAppSettings: () => Promise<AppSettingsAPIResponse> | null; latestMessageDatesByChannels: Record<ChannelConfId, Date>; mutes: Array<Mute>; openMobileNav: () => void; /** Instance of SearchController class that allows to control all the search operations. */ searchController: SearchController; /** * Sets active channel to be rendered within Channel component. * @param newChannel * @param watchers * @param event */ setActiveChannel: (newChannel?: Channel, watchers?: { limit?: number; offset?: number; }, event?: React.BaseSyntheticEvent) => void; useImageFlagEmojisOnWindows: boolean; /** * Active channel used to render the contents of the Channel component. */ channel?: Channel; /** * Object through which custom classes can be set for main container components of the SDK. */ customClasses?: CustomClasses; navOpen?: boolean; } & Partial<Pick<ChatProps, 'isMessageAIGenerated'>> & Required<Pick<ChatProps, 'theme' | 'client'>>; export declare const ChatContext: React.Context<ChatContextValue | undefined>; export declare const ChatProvider: ({ children, value, }: PropsWithChildren<{ value: ChatContextValue; }>) => React.JSX.Element; export declare const useChatContext: (componentName?: string) => ChatContextValue; /** * 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>(Component: React.ComponentType<P>) => { (props: Omit<P, keyof ChatContextValue>): React.JSX.Element; displayName: string; }; export {};