@sendbird/uikit-react
Version:
Sendbird UIKit for React: A feature-rich and customizable chat UI kit with messaging, channel management, and user authentication.
84 lines (83 loc) • 4.28 kB
TypeScript
import type { EmojiCategory, SendbirdError, User } from '@sendbird/chat';
import { type FileMessage, FileMessageCreateParams, type MultipleFilesMessage, MultipleFilesMessageCreateParams, UserMessageCreateParams, UserMessageUpdateParams } from '@sendbird/chat/message';
import type { GroupChannel, MessageCollectionParams, MessageFilterParams } from '@sendbird/chat/groupChannel';
import type { PubSubTypes } from '../../../lib/pubSub';
import type { ScrollTopics, ScrollTopicUnion } from './hooks/useMessageListScroll';
import type { SendableMessageType } from '../../../utils';
import type { UserProfileProviderProps } from '../../../lib/UserProfileContext';
import { ReplyType } from '../../../types';
import { useMessageActions } from './hooks/useMessageActions';
import { useGroupChannelMessages } from '@sendbird/uikit-tools';
import { ThreadReplySelectType } from './const';
import { PropsWithChildren } from 'react';
type MessageDataSource = ReturnType<typeof useGroupChannelMessages>;
export type MessageActions = ReturnType<typeof useMessageActions>;
export type MessageListQueryParamsType = Omit<MessageCollectionParams, 'filter'> & MessageFilterParams;
export type OnBeforeHandler<T> = (params: T) => T | Promise<T> | void | Promise<void>;
export type OnBeforeDownloadFileMessageType = (params: {
message: FileMessage | MultipleFilesMessage;
index?: number;
}) => Promise<boolean>;
export interface GroupChannelState extends GroupChannelProviderProps, Omit<InternalGroupChannelState, keyof GroupChannelProviderProps> {
}
interface InternalGroupChannelState extends MessageDataSource {
currentChannel: GroupChannel | null;
channelUrl: string;
fetchChannelError: SendbirdError | null;
nicknamesMap: Map<string, string>;
quoteMessage: SendableMessageType | null;
animatedMessageId: number | null;
isScrollBottomReached: boolean;
readState: string | null;
scrollRef: React.RefObject<HTMLDivElement>;
scrollDistanceFromBottomRef: React.MutableRefObject<number>;
scrollPositionRef: React.MutableRefObject<number>;
messageInputRef: React.RefObject<HTMLDivElement>;
isReactionEnabled: boolean;
isMessageGroupingEnabled: boolean;
isMultipleFilesMessageEnabled: boolean;
showSearchIcon: boolean;
replyType: ReplyType;
threadReplySelectType: ThreadReplySelectType;
disableMarkAsRead: boolean;
scrollBehavior: 'smooth' | 'auto';
markAsUnread?: (message: SendableMessageType) => void;
markAsUnreadSourceRef: React.MutableRefObject<'manual' | 'internal' | null>;
scrollPubSub: PubSubTypes<ScrollTopics, ScrollTopicUnion>;
}
export interface GroupChannelProviderProps extends PropsWithChildren<Pick<UserProfileProviderProps, 'renderUserProfile' | 'disableUserProfile' | 'onUserProfileMessage' | 'onStartDirectMessage'>> {
channelUrl: string;
isReactionEnabled?: boolean;
isMessageGroupingEnabled?: boolean;
isMultipleFilesMessageEnabled?: boolean;
showSearchIcon?: boolean;
replyType?: ReplyType;
threadReplySelectType?: ThreadReplySelectType;
disableMarkAsRead?: boolean;
scrollBehavior?: 'smooth' | 'auto';
forceLeftToRightMessageLayout?: boolean;
startingPoint?: number;
animatedMessageId?: number | null;
onMessageAnimated?: () => void;
messageListQueryParams?: MessageListQueryParamsType;
filterEmojiCategoryIds?: (message: SendableMessageType) => EmojiCategory['id'][];
onBeforeSendUserMessage?: OnBeforeHandler<UserMessageCreateParams>;
onBeforeSendFileMessage?: OnBeforeHandler<FileMessageCreateParams>;
onBeforeSendVoiceMessage?: OnBeforeHandler<FileMessageCreateParams>;
onBeforeSendMultipleFilesMessage?: OnBeforeHandler<MultipleFilesMessageCreateParams>;
onBeforeUpdateUserMessage?: OnBeforeHandler<UserMessageUpdateParams>;
onBeforeDownloadFileMessage?: OnBeforeDownloadFileMessageType;
onBackClick?(): void;
onChatHeaderActionClick?(event: React.MouseEvent<HTMLElement>): void;
onReplyInThreadClick?: (props: {
message: SendableMessageType;
}) => void;
onSearchClick?(): void;
onQuoteMessageClick?: (props: {
message: SendableMessageType;
}) => void;
renderUserMentionItem?: (props: {
user: User;
}) => JSX.Element;
}
export {};