UNPKG

stream-chat-react

Version:

React components to create chat conversations or livestream style chat

56 lines (55 loc) 3.41 kB
import React from 'react'; import type { ReactNode } from 'react'; import type { Channel, LocalMessage } from 'stream-chat'; import type { MessageDeliveryStatus } from './hooks/useMessageDeliveryStatus'; import type { ChatContextValue } from '../../context/ChatContext'; import type { ChannelAvatarProps } from '../Avatar/ChannelAvatar'; import type { GroupChannelDisplayInfo } from './utils'; import type { TranslationContextValue } from '../../context/TranslationContext'; export type ChannelPreviewUIComponentProps = ChannelPreviewProps & { /** Image of Channel to display */ displayImage?: string; /** Title of Channel to display */ displayTitle?: string; /** Title of Channel to display */ groupChannelDisplayInfo?: GroupChannelDisplayInfo; /** The last message received in a channel */ lastMessage?: LocalMessage; /** @deprecated Use latestMessagePreview prop instead. */ latestMessage?: ReactNode; /** Latest message preview to display, will be a string or JSX element supporting markdown. */ latestMessagePreview?: ReactNode; /** Status describing whether own message has been delivered or read by another. If the last message is not an own message, then the status is undefined. */ messageDeliveryStatus?: MessageDeliveryStatus; /** Number of unread Messages */ unread?: number; }; export type ChannelPreviewProps = { /** Comes from either the `channelRenderFilterFn` or `usePaginatedChannels` call from [ChannelList](https://github.com/GetStream/stream-chat-react/blob/master/src/components/ChannelList/ChannelList.tsx) */ channel: Channel; /** If the component's channel is the active (selected) Channel */ active?: boolean; /** Current selected channel object */ activeChannel?: Channel; /** UI component to display an avatar, defaults to [Avatar](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Avatar/Avatar.tsx) component and accepts the same props as: [ChannelAvatar](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Avatar/ChannelAvatar.tsx) */ Avatar?: React.ComponentType<ChannelAvatarProps>; /** Forces the update of preview component on channel update */ channelUpdateCount?: number; /** Custom class for the channel preview root */ className?: string; /** Custom function that generates the message preview in ChannelPreview component */ getLatestMessagePreview?: (channel: Channel, t: TranslationContextValue['t'], userLanguage: TranslationContextValue['userLanguage'], isMessageAIGenerated: ChatContextValue['isMessageAIGenerated']) => ReactNode; key?: string; /** Custom ChannelPreview click handler function */ onSelect?: (event: React.MouseEvent) => void; /** Custom UI component to display the channel preview in the list, defaults to and accepts same props as: [ChannelPreviewMessenger](https://github.com/GetStream/stream-chat-react/blob/master/src/components/ChannelPreview/ChannelPreviewMessenger.tsx) */ Preview?: React.ComponentType<ChannelPreviewUIComponentProps>; /** Setter for selected Channel */ setActiveChannel?: ChatContextValue['setActiveChannel']; /** Object containing watcher parameters */ watchers?: { limit?: number; offset?: number; }; }; export declare const ChannelPreview: (props: ChannelPreviewProps) => React.JSX.Element | null;