UNPKG

softchatjs-react-native

Version:

React native UI SDK for softchatjs-core. Create a free account at: https://www.softchatjs.com

248 lines (245 loc) 6.6 kB
import { Dispatch, SetStateAction } from 'react'; import { TextInput } from 'react-native'; import { Message } from 'softchatjs-core'; declare enum ClientActions { INCOMING_MESSAGE = "incomingMessage", MESSAGES_READ = "messagesRead", USER_IS_TYPING = "userIsTyping", MESSAGE_ERROR = "sendMessageError", NEW_MESSAGE_REACTION = "newMessageReaction", ACK_HEALTH_CHECK = "acknowledgeHealthCheck", EDITED_MESSAGE = "editedMessage" } declare enum ServerActions { INITIALIZE = "initialize", SEND_MESSAGE = "sendMessage", SEND_MESSAGE_REPLY = "sendMessageReply", USER_TYPING = "userTyping", HEALTH_CHECK = "healthCheck", SEND_LOCATION = "sendLocation", READ_MESSAGES = "readMessages", DELETE_MESSAGE = "deleteMessage", EDIT_MESSAGE = "editMessage", SEND_MESSAGE_REACTION = "sendMessageReaction", CONNECTION_CLOSED = "clearUserSession" } type Timetamps = { createdAt: string | Date; updatedAt: string | Date; deletedAt?: string | Date; }; type Prettify<T> = { [K in keyof T]: T[K]; } & {}; declare enum AttachmentTypes { NONE = "none", MAP = "map", MEDIA = "media", STICKER = "sticker" } interface Participant extends User { meta: UserMeta; } type User = { uid: string; connectionId?: string; projectId?: string; meta: UserMeta; } & Timetamps; type UserMeta = { username: string; uid: string; firstname?: string; lastname?: string; profileUrl?: string; color?: string; custom?: Record<string, string>; }; declare enum MediaType { VIDEO = "video", AUDIO = "audio", IMAGE = "image", DOCUMENT = "document", STICKER = "sticker" } type Media = { type: MediaType; ext: string; mediaId: string; mediaUrl: string; mimeType?: string; meta?: { aspectRatio?: number; height?: number; width?: number; size?: number; audioDurationSec?: number; }; }; type Point = { lng: number; lat: number; }; type ParticipantListInfo = { id: string; uid: string; projectId: string | null; connectionId: string; participantId: string; participantDetails: UserMeta; } & Timetamps; type ConversationType = 'private-chat' | 'group-chat' | "admin-chat"; type GroupChatMeta = { groupName: string; groupIcon?: string; groupWallpaper?: string; groupBanner?: string; }; type PrivateChatMeta = { chatWallpaper?: string; }; type Conversation = { participants: string[]; admins: string[]; conversationId: string; messages: Message[]; conversationType: ConversationType; participantList: ParticipantListInfo[]; meta: PrivateChatMeta | null; groupMeta: GroupChatMeta | null; } & Timetamps; type UploadContent = { base64: string; conversationId: string; key: string; }; type IncomingMessage = { action: ClientActions.INCOMING_MESSAGE; message: Message; }; type WsPayLoad<Action, Data> = { action: Action; message: Data; }; type ReceivedAction = ServerActions; type ReadMessages = { uid: string; messageIds: string[]; }; type UserTyping = { uid: string; }; type SetState<T> = Dispatch<SetStateAction<T>>; type InitiateConnection = { from: string; to: string; newConversation: boolean; userDetails: UserMeta; recipientMeta: UserMeta; }; type StringOrNumber = string | number; type Config = { projectId: string; apiKey: string; }; type StartConversation = { from: string; recipientMeta: UserMeta; message: string; }; type Reaction = { emoji: string; uid: string; }; declare enum MessageStates { NONE = 0, FAILED = 1, LOADING = 2, SENT = 3, DELIVERED = 4, READ = 5 } type Children = React.ReactNode; type ChatBubbleRenderProps = { message: Omit<Message, 'conversationId' | 'token' | 'shouldEdit'>; }; type ChatInputRenderProps = { sendMessage: (externalInputRef: React.RefObject<TextInput>) => void; value: string; onValueChange: (value: string) => void; openMediaOptions: (externalInputRef: React.RefObject<TextInput>) => void; openEmojis: () => void; onStopEditing: () => void; isEditing: boolean; onStartRecording: () => void; onDeleteRecording: () => void; sendVoiceMessage: () => void; meteringProgress: { [key: number]: { metering: number; height: number; }; }; isRecording: boolean; audioDuration: number; isLoading: boolean; }; type ConversationHeaderRenderProps = { isConnected: boolean; isConnecting: boolean; }; type ChatHeaderRenderProps = { conversationTitle: string | null | undefined; conversationType: string; activeUser: UserMeta | undefined; groupMeta: GroupChatMeta | null; }; type ConversationListRenderProps = { title: string | undefined; recipient: UserMeta | undefined; lastMessage: Message | undefined | null; imageUrl: string | null; }; type DefaultColors = { primary: string; secondary: string; }; type ChatTheme = { background: DefaultColors & { disabled: string; }; text: DefaultColors & { disabled: string; }; action: DefaultColors; icon: string; divider: string; chatBubble: { left: { bgColor: string; messageColor: string; messageTimeColor: string; replyBorderColor: string; }; right: { bgColor: string; messageColor: string; messageTimeColor: string; replyBorderColor: string; }; }; }; type Emoji = { emoji: string; description: string; category: string; aliases: string[]; tags: string[]; unicode_version: string; ios_version: string; }; type BottomSheetRef = { open: () => void; close: () => void; }; export { AttachmentTypes, type BottomSheetRef, type ChatBubbleRenderProps, type ChatHeaderRenderProps, type ChatInputRenderProps, type ChatTheme, type Children, ClientActions, type Config, type Conversation, type ConversationHeaderRenderProps, type ConversationListRenderProps, type ConversationType, type Emoji, type GroupChatMeta, type IncomingMessage, type InitiateConnection, type Media, MediaType, MessageStates, type Participant, type ParticipantListInfo, type Point, type Prettify, type PrivateChatMeta, type Reaction, type ReadMessages, type ReceivedAction, ServerActions, type SetState, type StartConversation, type StringOrNumber, type UploadContent, type UserMeta, type UserTyping, type WsPayLoad };