UNPKG

stream-chat-react

Version:

React components to create chat conversations or livestream style chat

59 lines (58 loc) 2.49 kB
import type { PropsWithChildren } from 'react'; import React from 'react'; import type { Channel, ChannelConfigWithInfo, LocalMessage, Mute, ChannelState as StreamChannelState } from 'stream-chat'; import type { ChannelUnreadUiState, GiphyVersions, ImageAttachmentSizeHandler, UnknownType, VideoAttachmentSizeHandler } from '../types/types'; export type ChannelNotifications = Array<{ id: string; text: string; type: 'success' | 'error'; }>; export type ChannelState = { suppressAutoscroll: boolean; error?: Error | null; hasMore?: boolean; hasMoreNewer?: boolean; highlightedMessageId?: string; loading?: boolean; loadingMore?: boolean; loadingMoreNewer?: boolean; members?: StreamChannelState['members']; messages?: LocalMessage[]; pinnedMessages?: LocalMessage[]; read?: StreamChannelState['read']; thread?: LocalMessage | null; threadHasMore?: boolean; threadLoadingMore?: boolean; threadMessages?: LocalMessage[]; threadSuppressAutoscroll?: boolean; typing?: StreamChannelState['typing']; watcherCount?: number; watchers?: StreamChannelState['watchers']; }; export type ChannelStateContextValue = Omit<ChannelState, 'typing'> & { channel: Channel; channelCapabilities: Record<string, boolean>; channelConfig: ChannelConfigWithInfo | undefined; imageAttachmentSizeHandler: ImageAttachmentSizeHandler; notifications: ChannelNotifications; shouldGenerateVideoThumbnail: boolean; videoAttachmentSizeHandler: VideoAttachmentSizeHandler; channelUnreadUiState?: ChannelUnreadUiState; giphyVersion?: GiphyVersions; mutes?: Array<Mute>; watcher_count?: number; }; export declare const ChannelStateContext: React.Context<ChannelStateContextValue | undefined>; export declare const ChannelStateProvider: ({ children, value, }: PropsWithChildren<{ value: ChannelStateContextValue; }>) => React.JSX.Element; export declare const useChannelStateContext: (componentName?: string) => ChannelStateContextValue; /** * Typescript currently does not support partial inference, so if ChannelStateContext * typing is desired while using the HOC withChannelStateContext, the Props for the * wrapped component must be provided as the first generic. */ export declare const withChannelStateContext: <P extends UnknownType>(Component: React.ComponentType<P>) => { (props: Omit<P, keyof ChannelStateContextValue>): React.JSX.Element; displayName: string; };