@cometchat/chat-uikit-react-native
Version:
Ready-to-use Chat UI Components for React Native
183 lines (182 loc) • 5.75 kB
TypeScript
import { CometChat } from "@cometchat/chat-sdk-react-native";
import React, { JSX } from "react";
import { ColorValue } from "react-native";
import { CometChatListActionsInterface, CometChatListProps } from "../shared";
import { DeepPartial } from "../shared/helper/types";
import { UserStyle } from "./style";
/**
* Interface for the menu items (tooltip actions).
*/
export interface MenuItemInterface {
text: string;
onPress: () => void;
textColor?: ColorValue;
iconColor?: ColorValue;
disabled?: boolean;
}
/**
* Interface for the props accepted by the CometChatUsers component.
* @interface CometChatUsersInterface
*/
export interface CometChatUsersInterface extends Omit<CometChatListProps, "title" | "requestBuilder" | "listStyle" | "TitleView" | "SubtitleView" | "statusIndicatorStyle" | "avatarStyle" | "hideBackButton" | "onListFetched" | "listItemStyle" | "ListItemView" | "TailView" | "disableUsersPresence" | "ItemView" | "onItemPress" | "onItemLongPress" | "listItemKey" | "onSelection" | "statusIndicatorType" | "emptyStateText" | "errorStateText" | "hideStickyHeader"> {
/**
* Callback function when a list item (user) is pressed.
*
* @param {CometChat.User} user - The user object that was pressed.
*/
onItemPress?: (user: CometChat.User) => void;
/**
* Callback function when a list item (user) is long pressed.
*
* @param {CometChat.User} user - The user object that was long pressed.
*/
onItemLongPress?: (user: CometChat.User) => void;
/**
* Callback function providing the selected users list.
*
* @param {CometChat.User[]} list - The array of selected user objects.
*/
onSelection?: (list: CometChat.User[]) => void;
/**
* Callback when submit selection button is pressed.
*/
onSubmit?: (list: Array<CometChat.User>) => void;
/**
* Users request builder instance to customize the user request.
*
* @type {CometChat.UsersRequestBuilder}
*/
usersRequestBuilder?: CometChat.UsersRequestBuilder;
/**
* Custom styling for the users list.
*
* @type {DeepPartial<UserStyle>}
*/
style?: DeepPartial<UserStyle>;
/**
* Custom title view component.
*
* @param {CometChat.User} conversation - The user conversation object.
* @returns {JSX.Element}
*/
TitleView?: (conversation: CometChat.User) => JSX.Element;
/**
* Function that returns a custom subtitle view for a user.
*
* @param {CometChat.User} item - The user object.
* @returns {JSX.Element}
*/
SubtitleView?: (item: CometChat.User) => JSX.Element;
/**
* Function that returns a custom trailing view for a user.
*
* @param {CometChat.User} item - The user object.
* @returns {JSX.Element}
*/
TrailingView?: (item: CometChat.User) => JSX.Element;
/**
* Function that returns a custom list item view.
*
* @param {CometChat.User} item - The user object.
* @returns {JSX.Element}
*/
ItemView?: (item: CometChat.User) => JSX.Element;
/**
* Custom component to display for the empty state.
*
* @returns {JSX.Element}
*/
EmptyView?: () => JSX.Element;
/**
* Custom component to display for the error state.
*
* @returns {JSX.Element}
*/
ErrorView?: () => JSX.Element;
/**
* Custom component to display for the loading state.
*
* @returns {JSX.Element}
*/
LoadingView?: () => JSX.Element;
/**
* Custom leading view component.
*
* @param {CometChat.User} item - The user object.
* @returns {JSX.Element}
*/
LeadingView?: (item: CometChat.User) => JSX.Element;
/**
* Hide the header view.
*
* @type {boolean}
*/
hideHeader?: boolean;
/**
* Placeholder text for the search input.
*
* @type {string}
*/
searchPlaceholderText?: string;
/**
* Hide the users Status.
*/
usersStatusVisibility?: boolean;
/**
* Search Keyword.
*/
searchKeyword?: string;
/**
* Callback when an error occurs.
*/
onError?: (e: CometChat.CometChatException) => void;
/**
* Callback triggered when the fetched list is empty.
*/
onEmpty?: () => void;
/**
* Callback triggered once the users have loaded and are not empty.
*/
onLoad?: (list: CometChat.User[]) => void;
/**
* Hide the loading skeleton.
*/
hideLoadingState?: boolean;
/**
* Title for the header.
*/
title?: string;
/**
* A function to **append** more menu items on top of the default menu items for a users.
*/
addOptions?: (user: CometChat.User) => MenuItemInterface[];
/**
* A function to **replace** the default menu items entirely for a users.
*/
options?: (user: CometChat.User) => MenuItemInterface[];
/**
* Toggle error view visibility.
*/
hideError?: boolean;
/**
* Toggle back button visibility.
*/
showBackButton?: boolean;
/**
* Toggle Sticky Header visibility.
*/
stickyHeaderVisibility?: boolean;
}
/**
* Interface for actions exposed by the CometChatUsers component.
*
* @interface CometChatUsersActionsInterface
* @extends {CometChatListActionsInterface}
*/
export interface CometChatUsersActionsInterface extends CometChatListActionsInterface {
}
/**
* CometChatUsers component renders a list of users with support for search,
* selection, and custom empty/error/loading states.
*/
export declare const CometChatUsers: React.ForwardRefExoticComponent<CometChatUsersInterface & React.RefAttributes<CometChatUsersActionsInterface>>;