@cometchat/chat-uikit-react
Version:
Ready-to-use Chat UI Components for React(Javascript/Web)
222 lines (221 loc) • 7.82 kB
TypeScript
import { JSX } from "react";
import { CometChatTextFormatter } from "../../formatters/CometChatFormatters/CometChatTextFormatter";
import { SelectionMode, States } from "../../Enums/Enums";
import { CometChatOption } from "../../modals";
import { CalendarObject } from "../../utils/CalendarObject";
interface ConversationsProps {
/**
* Disables the display of message read receipts.
*
* @remarks If set to `true`, the receipt status of the sent message won't be displayed.
* @defaultValue `false`
*/
hideReceipts?: boolean;
/**
* Hides the default and the custom error view passed in the `errorView` prop.
*
* @defaultValue `false`
*/
hideError?: boolean;
/**
* Hides the delete conversation option in the default context menu.
*
* @defaultValue `false`
*/
hideDeleteConversation?: boolean;
/**
* Hides the user's online/offline status indicator.
*
* @defaultValue `false`
*/
hideUserStatus?: boolean;
/**
* Hides the group type icon.
*
* @defaultValue `false`
*/
hideGroupType?: boolean;
/**
* A request builder to fetch conversations.
*
* @defaultValue Default request builder with the limit set to 30.
*/
conversationsRequestBuilder?: CometChat.ConversationsRequestBuilder;
/**
* Specifies the conversation to highlight in the list.
*/
activeConversation?: CometChat.Conversation;
/**
* Allows the user to pass custom formatters for text.
*
* These formatters should be an array of `CometChatTextFormatter` instances, enabling customized text rendering and processing.
*/
textFormatters?: CometChatTextFormatter[];
/**
* Determines the selection mode for the component.
*
* @defaultValue `SelectionMode.none`
*/
selectionMode?: SelectionMode;
/**
* A function that returns a list of actions available when hovering over a conversation item.
* @param conversation - An instance of `CometChat.Conversation` representing the conversation.
* @returns An array of `CometChatOption` objects.
*/
options?: ((conversation: CometChat.Conversation) => CometChatOption[]) | null;
/**
* Format for displaying the timestamp of the last message in the conversations list.
*/
lastMessageDateTimeFormat?: CalendarObject;
/**
* Disables sound for incoming messages.
*
* @defaultValue `false`
*/
disableSoundForMessages?: boolean;
/**
* Custom audio sound for incoming messages.
*/
customSoundForMessages?: string;
/**
* Callback function triggered when the component encounters an error.
*
* @param error - An instance of `CometChat.CometChatException` representing the error.
* @returns void
*/
onError?: ((error: CometChat.CometChatException) => void) | null;
/**
* Callback function invoked when a conversation item is clicked.
*
* @param conversation - An instance of `CometChat.Conversation` representing the clicked conversation.
* @returns void
*/
onItemClick?: (conversation: CometChat.Conversation) => void;
/**
* Callback function invoked when a conversation item is selected.
*
* @param conversation - An instance of `CometChat.Conversation` representing the selected conversation.
* @param selected - A boolean indicating whether the item is selected.
* @returns void
* @remarks This prop works only if `selectionMode` is not set to `SelectionMode.none`.
*/
onSelect?: (conversation: CometChat.Conversation, selected: boolean) => void;
/**
* A custom component to render in the top-right corner of the Conversations UI.
*/
headerView?: JSX.Element;
/**
* A custom component to display during the loading state.
*/
loadingView?: JSX.Element;
/**
* A custom component to display when there are no conversations available.
*/
emptyView?: JSX.Element;
/**
* A custom component to display when an error occurs.
*/
errorView?: JSX.Element;
/**
* A custom view to render each conversation in the list.
*
* @param conversation - An instance of `CometChat.Conversation` representing the conversation.
* @returns A JSX element to be rendered as the conversation item.
*/
itemView?: (conversation: CometChat.Conversation) => JSX.Element;
/**
* A function that renders a JSX element to display the leading view.
*
* @param conversation - An instance of `CometChat.Conversation` representing the conversation.
* @returns A JSX element to be rendered as the leading view.
*/
leadingView?: (conversation: CometChat.Conversation) => JSX.Element;
/**
* A function that renders a JSX element to display the title view.
*
* @param conversation - An instance of `CometChat.Conversation` representing the conversation.
* @returns A JSX element to be rendered as the title view.
*/
titleView?: (conversation: CometChat.Conversation) => JSX.Element;
/**
* A custom view to render the subtitle for each conversation.
*
* @param conversation - An instance of `CometChat.Conversation` representing the conversation.
* @returns A JSX element to be rendered as the subtitle view.
*/
subtitleView?: (conversation: CometChat.Conversation) => JSX.Element;
/**
* A custom view to render at the end of each conversation item.
*
* @param conversation - An instance of `CometChat.Conversation` representing the conversation.
* @returns A JSX element to be rendered as the trailing view.
*/
trailingView?: (conversation: CometChat.Conversation) => JSX.Element;
}
export type Action = {
type: "appendConversations";
conversations: CometChat.Conversation[];
removeOldConversation?: boolean;
} | {
type: "setConversationList";
conversationList: CometChat.Conversation[];
} | {
type: "setFetchState";
fetchState: States;
} | {
type: "setConversationToBeDeleted";
conversation: CometChat.Conversation | null;
} | {
type: "removeConversation";
conversation: CometChat.Conversation;
} | {
type: "updateConversationWithUser";
user: CometChat.User;
} | {
type: "fromUpdateConversationListFn";
conversation: CometChat.Conversation;
} | {
type: "addTypingIndicator";
typingIndicator: CometChat.TypingIndicator;
} | {
type: "removeTypingIndicator";
typingIndicator: CometChat.TypingIndicator;
} | {
type: "updateConversationLastMessage";
message: CometChat.BaseMessage;
} | {
type: "updateConversationLastMessageAndPlaceAtTheTop";
message: CometChat.BaseMessage;
} | {
type: "updateConversationLastMessageAndGroupAndPlaceAtTheTop";
group: CometChat.Group;
message: CometChat.Action;
} | {
type: "removeConversationOfTheGroup";
group: CometChat.Group;
} | {
type: "removeConversationOfTheUser";
user: CometChat.User;
} | {
type: "updateConversationLastMessageResetUnreadCountAndPlaceAtTheTop";
message: CometChat.BaseMessage;
conversation: CometChat.Conversation;
} | {
type: "resetUnreadCountAndSetReadAtIfLastMessage";
message: CometChat.BaseMessage;
} | {
type: "setLastMessageReadOrDeliveredAt";
updateReadAt: boolean;
messageReceipt: CometChat.MessageReceipt;
} | {
type: "setLoggedInUser";
loggedInUser: CometChat.User | null;
} | {
type: "setIsFirstReload";
isFirstReload: boolean;
};
/**
* Renders a scrollable list of conversations that has been created in a CometChat app
*/
export declare function CometChatConversations(props: ConversationsProps): import("react/jsx-runtime").JSX.Element;
export {};