@cometchat/chat-uikit-react
Version:
Ready-to-use Chat UI Components for React(Javascript/Web)
163 lines (162 loc) • 5.4 kB
TypeScript
import { JSX } from "react";
import { SelectionMode, States } from "../../Enums/Enums";
import { CometChatOption } from "../../modals";
interface GroupsProps {
/**
* Hides the default search bar.
*
* @defaultValue `false`
*/
hideSearch?: boolean;
/**
* Hides the default and custom error view passed in `errorView` prop.
*
* @defaultValue `false`
*/
hideError?: boolean;
/**
* Hides the group type icon.
*
* @defaultValue `false`
*/
hideGroupType?: boolean;
/**
* The group to highlight in the list.
*/
activeGroup?: CometChat.Group;
/**
* A request builder for fetching groups.
*
* @defaultValue Default request builder having the limit set to `30`.
*/
groupsRequestBuilder?: CometChat.GroupsRequestBuilder;
/**
* A request builder configured with search parameters to fetch groups.
*
* @remarks If the search input is not empty, the search keyword of this request builder is set to the text in the search input.
*/
searchRequestBuilder?: CometChat.GroupsRequestBuilder;
/**
* A function that returns a list of actions available when hovering over a group item.
* @param group - An instance of `CometChat.Group` representing the group.
* @returns An array of `CometChatOption` objects.
*/
options?: (group: CometChat.Group) => CometChatOption[];
/**
* Selection mode to use for the default trailing view.
*
* @defaultValue `SelectionMode.none`
*/
selectionMode?: SelectionMode;
/**
* Callback function invoked when an error occurs in the component.
* @param error - An instance of `CometChat.CometChatException` representing the error that occurred.
* @returns void
*/
onError?: ((error: CometChat.CometChatException) => void) | null;
/**
* Callback function invoked when a group is selected.
*
* @remarks This prop works only if `selectionMode` is not set to `SelectionMode.none`.
* @param group - An instance of `CometChat.Group` representing the selected group.
* @param selected - A boolean indicating whether the group is selected.
* @returns void
*/
onSelect?: (group: CometChat.Group, selected: boolean) => void;
/**
* Callback function invoked when a group item is clicked.
*
* @param group - An instance of `CometChat.Group` representing the clicked group.
* @returns void
*/
onItemClick?: (group: CometChat.Group) => void;
/**
* A custom component to render in the top-right corner of the groups list.
*/
headerView?: JSX.Element;
/**
* A custom view to display during the loading state.
*/
loadingView?: JSX.Element;
/**
* Custom view for the empty state of the component.
*/
emptyView?: JSX.Element;
/**
* A custom view to display when an error occurs.
*/
errorView?: JSX.Element;
/**
* A custom view to render for each group in the fetched list.
*
* @param group - An instance of `CometChat.Group` representing the group.
* @returns A JSX element to be rendered as the group item.
*/
itemView?: (group: CometChat.Group) => JSX.Element;
/**
* A function that renders a JSX element to display the leading view.
*
* @param group - An instance of `CometChat.Group` representing the group.
* @returns A JSX element to be rendered as the leading view.
*/
leadingView?: (group: CometChat.Group) => JSX.Element;
/**
* A function that renders a JSX element to display the title view.
*
* @param group - An instance of `CometChat.Group` representing the group.
* @returns A JSX element to be rendered as the title view.
*/
titleView?: (group: CometChat.Group) => JSX.Element;
/**
* Custom subtitle view to be rendered for each group in the fetched list.
*
* @param group - An instance of `CometChat.Group` representing the group.
* @returns A JSX element to be rendered as the subtitle view.
*/
subtitleView?: (group: CometChat.Group) => JSX.Element;
/**
* A function that renders a JSX element to display the trailing view.
*
* @param group - An instance of `CometChat.Group` representing the group.
* @returns A JSX element to be rendered as the trailing view.
*/
trailingView?: (group: CometChat.Group) => JSX.Element;
}
export type Action = {
type: "appendGroups";
groups: CometChat.Group[];
removeOldGroups?: boolean;
} | {
type: "setGroupList";
groupList: CometChat.Group[];
} | {
type: "setFetchState";
fetchState: States;
} | {
type: "updateGroup";
group: CometChat.Group;
} | {
type: "updateGroupForSDKEvents";
group: CometChat.Group;
newScope?: CometChat.GroupMemberScope;
newCount?: number;
hasJoined?: boolean;
addGroup?: boolean;
} | {
type: "removeGroup";
guid: string;
} | {
type: "prependGroup";
group: CometChat.Group;
} | {
type: "setSearchText";
searchText: string;
} | {
type: "setIsFirstReload";
isFirstReload: boolean;
};
/**
* Renders a scrollable list of groups that has been created in a CometChat app
*/
export declare function CometChatGroups(props: GroupsProps): import("react/jsx-runtime").JSX.Element;
export {};