@cometchat/chat-uikit-react-native
Version:
Ready-to-use Chat UI Components for React Native
170 lines (169 loc) • 6.06 kB
TypeScript
import { CometChat } from "@cometchat/chat-sdk-react-native";
import { JSX } from "react";
import { StyleProp, TextStyle } from "react-native";
import { MentionsTargetElement, MentionsType, MentionsVisibility } from "../../constants/UIKitConstants";
import { SuggestionItem } from "../../views/CometChatSuggestionList";
import { CometChatTextFormatter } from "../CometChatTextFormatter";
import { CometChatTheme } from "../../../theme/type";
/**
* Represents the CometChatMentionsFormatter class.
* This class extends the CometChatTextFormatter class and provides methods for handling mentions in text.
* @extends CometChatTextFormatter
*/
export declare class CometChatMentionsFormatter extends CometChatTextFormatter {
/**
* List of users for mentions.
*/
protected SuggestionItems: Array<SuggestionItem>;
/**
* List of searched data.
*/
protected searchData: Array<SuggestionItem>;
/**
* Stores the formatting style for mentions.
*/
protected mentionsStyle: CometChatTheme["mentionsStyle"];
/**
* Default search request object to fetch users or group members.
*/
private searchRequest?;
/**
* Custom request object to fetch users or group members.
*/
private customRequest?;
/**
* Limit of unique users to be added in the composer.
*/
protected limit: number;
/**
* visibleIn property to determine where the mentions should be visible.
* @type {MentionsVisibility}
* @default MentionsVisibility.both
*/
protected visibleIn: MentionsVisibility;
/**
* type property to determine the type of mention list.
* @type {MentionsType}
* @default MentionsType.usersAndGroupMembers
*/
protected type: MentionsType;
/**
* type property to determine the type of mention list.
* @type {MentionsType}
* @default MentionsType.usersAndGroupMembers
*/
protected target: MentionsTargetElement;
protected textStyle: any;
/**
* Initializes a new CometChatMentionsFormatter.
* @param {CometChat.User} loggedInUser - The user who is currently logged in.
*/
constructor(loggedInUser?: CometChat.User);
/**
* Sets the message object.
*
* @param {CometChat.BaseMessage} messageObject - The message object to be set.
*/
setMessage(messageObject: CometChat.BaseMessage): void;
setTargetElement(target: MentionsTargetElement): void;
setTextStyle(textStyle: any): void;
handlePreMessageSend(message: CometChat.TextMessage): CometChat.TextMessage;
handleComposerPreview(message: CometChat.TextMessage): void;
private convertCCUsersToSuggestionsItem;
/**
* Sets the search request builder.
* @param requestBuilder - The request builder to set.
*/
setSearchRequestBuilder(requestBuilder: CometChat.UsersRequestBuilder | CometChat.GroupMembersRequestBuilder): void;
private shouldLoadLocalData;
search(searchKey: string): void;
fetchNext(freshCall?: boolean): void | null;
setSearchData(data: Array<SuggestionItem>): void;
/**
* Sets the limit of unique users to be added in the composer.
*/
setLimit(limit: number): void;
/**
* Retrieves the limit of unique users to be added in the composer.
*/
getLimit(): number;
/**
* Retrieves the unique users list.
*/
getUniqueUsersList(): Set<number | string>;
/**
* Retrieves the message object.
*
* @returns {CometChat.BaseMessage} - The current message object.
*/
getMessage(): CometChat.BaseMessage;
/**
* Sets the regex pattern for matching text.
*
* @param {<RegExp>} regexPattern - Regex patterns.
*/
setRegexPattern: (regexPattern: RegExp) => void;
/**
* Gets the regex pattern for matching text.
*/
getRegexPattern: () => RegExp;
/**
* Retrieves the SuggestionItems.
*
* @returns {Array<SuggestionItem>} - The current SuggestionItems.
*/
getSuggestionItems(): Array<SuggestionItem>;
/**
* Sets the SuggestionItems.
*
* @param {Array<SuggestionItem>} SuggestionItems - The SuggestionItems to be set.
*/
setSuggestionItems(SuggestionItems: Array<SuggestionItem>): void;
/**
* Retrieves the mentions style.
*
* @returns {CometChatTheme["mentionsStyle"]} - The current mentions style.
*/
getMentionsStyle(): CometChatTheme["mentionsStyle"];
/**
* Sets the mentions style.
*
* @param {CometChatTheme["mentionsStyle"]} mentionsStyle - The mentions style to be set.
*/
setMentionsStyle(mentionsStyle?: CometChatTheme["mentionsStyle"]): void;
getFormattedText(inputText: string | null | JSX.Element, textStyle?: StyleProp<TextStyle>): string | JSX.Element;
temp: Function;
setOnMentionClick(callBack: (message: CometChat.BaseMessage, uid: string) => void): void;
/**
* Emits the event for mention click.
* @param {any} event - The event object.
* @param {string} uid - The user id.
*/
private onMentionClick;
/**
* This function adds the mention view to the input text.
*
* @param {string} inputText - The input text where the view needs to be added.
* @returns {string} - The modified input text.
*/
protected addMentionsView(inputText: string | JSX.Element, textStyle?: StyleProp<TextStyle>): any;
/**
* Sets the type of mention list.
* @param type - The type of mention list.
*/
setType(type: MentionsType): void;
/**
* Sets the visibleIn property to determine where the mentions should be visible.
* @param visibleIn - The visibleIn property to set.
*/
setVisibleIn(visibleIn: MentionsVisibility): void;
/**
* Retrieves the visibleIn property to determine where the mentions should be visible.
*/
getVisibleIn(): MentionsVisibility;
/**
* Retrieves the type of mention list.
*/
getType(): MentionsType;
getErrorString(): string;
}