@usechat/react-native 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clipboard-O4FPD4J6.mjs +2 -0
- package/dist/index.d.mts +664 -0
- package/dist/index.d.ts +664 -0
- package/dist/index.js +422 -5098
- package/dist/index.mjs +422 -5007
- package/package.json +1 -1
- package/dist/clipboard-LTWXJADM.mjs +0 -64
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
var s=async e=>{console.log("copyToClipboard called with text:",e);try{try{let{setStringAsync:o}=await import("expo-clipboard");console.log("expo-clipboard imported successfully"),console.log("setStringAsync function:",o),await o(e),console.log("Text copied to clipboard successfully")}catch(o){throw console.error("Failed to import expo-clipboard:",o),new Error("expo-clipboard not available")}try{let o=await import("react-native-toast-message"),t=o.default||o;console.log("react-native-toast-message imported successfully"),t.show({type:"success",text1:"Copied to clipboard",text2:"Message copied successfully",position:"bottom",visibilityTime:2e3}),console.log("Toast shown successfully")}catch(o){console.log("Toast not available, but message copied to clipboard"),console.error("Toast import error:",o)}return!0}catch(o){console.error("Failed to copy to clipboard:",o);try{let t=await import("react-native-toast-message");(t.default||t).show({type:"error",text1:"Copy failed",text2:"Failed to copy message to clipboard",position:"bottom",visibilityTime:2e3})}catch(t){console.error("Copy failed: expo-clipboard not available"),console.error("Toast import error:",t)}return!1}},a=async()=>{try{return await import("expo-clipboard"),!0}catch{return!1}};export{s as copyToClipboard,a as isClipboardAvailable};
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,664 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import React__default, { ReactNode, ComponentType } from 'react';
|
|
3
|
+
import { NativeSyntheticEvent, TextInputContentSizeChangeEventData, TextInput } from 'react-native';
|
|
4
|
+
|
|
5
|
+
interface Message$1 {
|
|
6
|
+
id: number;
|
|
7
|
+
text: string;
|
|
8
|
+
isMe: boolean;
|
|
9
|
+
timestamp: string;
|
|
10
|
+
status?: 'sent' | 'delivered' | 'read' | 'failed' | 'pending';
|
|
11
|
+
senderName?: string;
|
|
12
|
+
senderId?: string;
|
|
13
|
+
replyTo?: ReplyToMessage$1;
|
|
14
|
+
reactions?: MessageReaction$1[];
|
|
15
|
+
type?: 'text' | 'image';
|
|
16
|
+
attachments?: Attachment[];
|
|
17
|
+
deleted?: boolean;
|
|
18
|
+
imageData?: ImageAttachmentData$1;
|
|
19
|
+
}
|
|
20
|
+
interface ReplyToMessage$1 {
|
|
21
|
+
id: number;
|
|
22
|
+
text: string;
|
|
23
|
+
senderName?: string;
|
|
24
|
+
senderId?: string;
|
|
25
|
+
isMe: boolean;
|
|
26
|
+
timestamp?: string;
|
|
27
|
+
type?: 'text' | 'image';
|
|
28
|
+
imageData?: ImageAttachmentData$1;
|
|
29
|
+
}
|
|
30
|
+
interface MessageReaction$1 {
|
|
31
|
+
emoji: string;
|
|
32
|
+
count: number;
|
|
33
|
+
users: string[];
|
|
34
|
+
}
|
|
35
|
+
interface Attachment {
|
|
36
|
+
id: string;
|
|
37
|
+
type: 'image' | 'document' | 'location' | 'contact' | 'poll' | 'event';
|
|
38
|
+
data: any;
|
|
39
|
+
fileName?: string;
|
|
40
|
+
fileSize?: number;
|
|
41
|
+
mimeType?: string;
|
|
42
|
+
uploadStatus?: 'pending' | 'uploading' | 'completed' | 'failed';
|
|
43
|
+
uploadProgress?: number;
|
|
44
|
+
}
|
|
45
|
+
interface ImageAttachmentData$1 {
|
|
46
|
+
uri: string;
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
fileSize?: number;
|
|
50
|
+
fileName: string;
|
|
51
|
+
}
|
|
52
|
+
interface AttachmentResult {
|
|
53
|
+
id?: string;
|
|
54
|
+
type: 'image' | 'document' | 'location' | 'contact' | 'poll' | 'event';
|
|
55
|
+
data: any;
|
|
56
|
+
}
|
|
57
|
+
interface ChatScreenHeaderProps {
|
|
58
|
+
name?: string;
|
|
59
|
+
isOnline?: boolean;
|
|
60
|
+
onBack: () => void;
|
|
61
|
+
onVideoCall?: () => void;
|
|
62
|
+
onVoiceCall?: () => void;
|
|
63
|
+
onInfo?: () => void;
|
|
64
|
+
onSimulateTyping?: () => void;
|
|
65
|
+
}
|
|
66
|
+
interface MessageListProps {
|
|
67
|
+
messages: Message$1[];
|
|
68
|
+
onContentSizeChange?: () => void;
|
|
69
|
+
onMessageLongPress?: (message: Message$1, position?: {
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
width: number;
|
|
73
|
+
height: number;
|
|
74
|
+
}) => void;
|
|
75
|
+
onReactionPress?: (message: Message$1) => void;
|
|
76
|
+
isTyping?: boolean;
|
|
77
|
+
typingUserName?: string;
|
|
78
|
+
showScrollToBottom?: boolean;
|
|
79
|
+
isReplyActive?: boolean;
|
|
80
|
+
}
|
|
81
|
+
interface MessageInputProps {
|
|
82
|
+
value: string;
|
|
83
|
+
onChangeText: (text: string) => void;
|
|
84
|
+
onSend: () => void;
|
|
85
|
+
onFocus?: () => void;
|
|
86
|
+
height: number;
|
|
87
|
+
onContentSizeChange: (height: number) => void;
|
|
88
|
+
replyToMessage?: Message$1 | null;
|
|
89
|
+
onCancelReply?: () => void;
|
|
90
|
+
onAttachmentSend?: (attachmentResult: AttachmentResult, text?: string) => void;
|
|
91
|
+
}
|
|
92
|
+
interface MessageWithType$1 extends Message$1 {
|
|
93
|
+
listItemType: 'message';
|
|
94
|
+
}
|
|
95
|
+
interface DateSeparator$1 {
|
|
96
|
+
id: string;
|
|
97
|
+
listItemType: 'date-separator';
|
|
98
|
+
date: string;
|
|
99
|
+
displayDate: string;
|
|
100
|
+
}
|
|
101
|
+
type MessageListItem$1 = MessageWithType$1 | DateSeparator$1;
|
|
102
|
+
interface UseAttachmentsReturn {
|
|
103
|
+
attachments: Attachment[];
|
|
104
|
+
openPicker: (type: 'image' | 'document' | 'location' | 'contact') => Promise<void>;
|
|
105
|
+
addAttachment: (attachment: Attachment) => void;
|
|
106
|
+
removeAttachment: (attachmentId: string) => void;
|
|
107
|
+
clearAttachments: () => void;
|
|
108
|
+
uploadAttachments: () => Promise<Attachment[]>;
|
|
109
|
+
isUploading: boolean;
|
|
110
|
+
uploadProgress: number;
|
|
111
|
+
}
|
|
112
|
+
interface RenderMessageProps {
|
|
113
|
+
message: Message$1;
|
|
114
|
+
onLongPress?: (message: Message$1, position?: {
|
|
115
|
+
x: number;
|
|
116
|
+
y: number;
|
|
117
|
+
width: number;
|
|
118
|
+
height: number;
|
|
119
|
+
}) => void;
|
|
120
|
+
onReactionPress?: (message: Message$1) => void;
|
|
121
|
+
onReactionRemove?: (messageId: number, emoji: string) => void;
|
|
122
|
+
}
|
|
123
|
+
interface RenderInputProps {
|
|
124
|
+
value: string;
|
|
125
|
+
onChangeText: (text: string) => void;
|
|
126
|
+
onSend: () => void;
|
|
127
|
+
onFocus?: () => void;
|
|
128
|
+
height: number;
|
|
129
|
+
onContentSizeChange: (height: number) => void;
|
|
130
|
+
replyToMessage?: Message$1 | null;
|
|
131
|
+
onCancelReply?: () => void;
|
|
132
|
+
attachments: Attachment[];
|
|
133
|
+
onAttachmentAdd: (attachment: Attachment) => void;
|
|
134
|
+
onAttachmentRemove: (attachmentId: string) => void;
|
|
135
|
+
onAttachmentUpload: () => Promise<Attachment[]>;
|
|
136
|
+
}
|
|
137
|
+
interface RenderActionSheetProps {
|
|
138
|
+
visible: boolean;
|
|
139
|
+
onClose: () => void;
|
|
140
|
+
isMyMessage: boolean;
|
|
141
|
+
selectedMessage?: Message$1;
|
|
142
|
+
messagePosition?: {
|
|
143
|
+
x: number;
|
|
144
|
+
y: number;
|
|
145
|
+
width: number;
|
|
146
|
+
height: number;
|
|
147
|
+
};
|
|
148
|
+
onActionPress: (action: string) => void;
|
|
149
|
+
onEmojiReact: (emoji: string) => void;
|
|
150
|
+
}
|
|
151
|
+
interface RenderReactionDetailsProps {
|
|
152
|
+
visible: boolean;
|
|
153
|
+
onClose: () => void;
|
|
154
|
+
reactions: MessageReaction$1[];
|
|
155
|
+
messageText: string;
|
|
156
|
+
onAddReaction: (emoji: string) => void;
|
|
157
|
+
onRemoveReaction: (emoji: string) => void;
|
|
158
|
+
}
|
|
159
|
+
interface AttachmentUploader {
|
|
160
|
+
upload: (file: File | any) => Promise<{
|
|
161
|
+
url: string;
|
|
162
|
+
metadata?: any;
|
|
163
|
+
}>;
|
|
164
|
+
validate?: (file: File | any) => boolean | string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
interface MessageInputRef {
|
|
168
|
+
focus: () => void;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
interface ChatData {
|
|
172
|
+
id: string;
|
|
173
|
+
name: string;
|
|
174
|
+
message: string;
|
|
175
|
+
time: string;
|
|
176
|
+
avatar: string;
|
|
177
|
+
unreadCount?: number;
|
|
178
|
+
isOnline?: boolean;
|
|
179
|
+
hasAttachment?: boolean;
|
|
180
|
+
}
|
|
181
|
+
interface ChatItemProps {
|
|
182
|
+
item: ChatData;
|
|
183
|
+
onPress: (chat: ChatData) => void;
|
|
184
|
+
}
|
|
185
|
+
interface ChatListProps {
|
|
186
|
+
chats: ChatData[];
|
|
187
|
+
onChatPress: (chat: ChatData) => void;
|
|
188
|
+
onRefresh?: () => void;
|
|
189
|
+
refreshing?: boolean;
|
|
190
|
+
}
|
|
191
|
+
interface ChatAvatarProps {
|
|
192
|
+
avatar: string;
|
|
193
|
+
isOnline?: boolean;
|
|
194
|
+
size?: 'small' | 'medium' | 'large';
|
|
195
|
+
}
|
|
196
|
+
interface ReplyToMessage {
|
|
197
|
+
id: number;
|
|
198
|
+
text: string;
|
|
199
|
+
senderName?: string;
|
|
200
|
+
isMe: boolean;
|
|
201
|
+
type?: 'text' | 'image';
|
|
202
|
+
imageData?: ImageAttachmentData;
|
|
203
|
+
}
|
|
204
|
+
interface MessageReaction {
|
|
205
|
+
emoji: string;
|
|
206
|
+
count: number;
|
|
207
|
+
users: string[];
|
|
208
|
+
}
|
|
209
|
+
interface Message {
|
|
210
|
+
id: number;
|
|
211
|
+
text: string;
|
|
212
|
+
isMe: boolean;
|
|
213
|
+
timestamp: string;
|
|
214
|
+
status?: 'sent' | 'delivered' | 'read' | 'failed' | 'pending';
|
|
215
|
+
senderName?: string;
|
|
216
|
+
replyTo?: ReplyToMessage;
|
|
217
|
+
reactions?: MessageReaction[];
|
|
218
|
+
type?: 'text' | 'image';
|
|
219
|
+
imageData?: ImageAttachmentData;
|
|
220
|
+
deleted?: boolean;
|
|
221
|
+
}
|
|
222
|
+
interface DateSeparator {
|
|
223
|
+
id: string;
|
|
224
|
+
listItemType: 'date-separator';
|
|
225
|
+
date: string;
|
|
226
|
+
displayDate: string;
|
|
227
|
+
}
|
|
228
|
+
interface MessageWithType extends Message {
|
|
229
|
+
listItemType: 'message';
|
|
230
|
+
}
|
|
231
|
+
type MessageListItem = MessageWithType | DateSeparator;
|
|
232
|
+
interface AttachmentOption {
|
|
233
|
+
id: string;
|
|
234
|
+
label: string;
|
|
235
|
+
icon: any;
|
|
236
|
+
color: string;
|
|
237
|
+
}
|
|
238
|
+
interface AttachmentMenuProps {
|
|
239
|
+
onOptionSelect: (optionId: string) => void;
|
|
240
|
+
options: AttachmentOption[];
|
|
241
|
+
}
|
|
242
|
+
interface AttachmentMenuRef {
|
|
243
|
+
show: () => void;
|
|
244
|
+
hide: () => void;
|
|
245
|
+
}
|
|
246
|
+
interface ImageAttachmentData {
|
|
247
|
+
uri: string;
|
|
248
|
+
width: number;
|
|
249
|
+
height: number;
|
|
250
|
+
fileSize?: number;
|
|
251
|
+
fileName: string;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
interface MessageInputState<T = string> {
|
|
255
|
+
value: T;
|
|
256
|
+
height: number;
|
|
257
|
+
isFocused: boolean;
|
|
258
|
+
replyToMessage: Message$1 | null;
|
|
259
|
+
attachments: AttachmentResult[];
|
|
260
|
+
}
|
|
261
|
+
interface MessageInputActions<T = string> {
|
|
262
|
+
setValue: (value: T) => void;
|
|
263
|
+
setHeight: (height: number) => void;
|
|
264
|
+
setFocus: (focused: boolean) => void;
|
|
265
|
+
setReplyToMessage: (message: Message$1 | null) => void;
|
|
266
|
+
addAttachment: (attachment: AttachmentResult) => void;
|
|
267
|
+
removeAttachment: (attachmentId: string) => void;
|
|
268
|
+
clearAttachments: () => void;
|
|
269
|
+
sendMessage: () => void;
|
|
270
|
+
cancelReply: () => void;
|
|
271
|
+
focusInput: () => void;
|
|
272
|
+
handleAttachmentSelected: (result: AttachmentResult) => void;
|
|
273
|
+
handleContentSizeChange: (event: NativeSyntheticEvent<TextInputContentSizeChangeEventData>) => void;
|
|
274
|
+
handleFocus: () => void;
|
|
275
|
+
handleBlur: () => void;
|
|
276
|
+
}
|
|
277
|
+
interface MessageInputConfig<T = string> {
|
|
278
|
+
initialValue?: T;
|
|
279
|
+
initialHeight?: number;
|
|
280
|
+
onValueChange?: (value: T) => void;
|
|
281
|
+
onHeightChange?: (height: number) => void;
|
|
282
|
+
onSend?: (value: T, attachments: AttachmentResult[], replyTo?: Message$1 | null) => void;
|
|
283
|
+
onAttachmentSend?: (attachmentResult: AttachmentResult, text?: T) => void;
|
|
284
|
+
onReplyCancel?: () => void;
|
|
285
|
+
onFocus?: () => void;
|
|
286
|
+
onBlur?: () => void;
|
|
287
|
+
maxHeight?: number;
|
|
288
|
+
minHeight?: number;
|
|
289
|
+
maxLength?: number;
|
|
290
|
+
placeholder?: string;
|
|
291
|
+
}
|
|
292
|
+
interface UseMessageInputReturn<T = string> {
|
|
293
|
+
state: MessageInputState<T>;
|
|
294
|
+
actions: MessageInputActions<T>;
|
|
295
|
+
refs: {
|
|
296
|
+
textInputRef: React__default.RefObject<TextInput>;
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
interface UseChatMessagesReturn {
|
|
301
|
+
messages: Message[];
|
|
302
|
+
sendMessage: (text: string, replyTo?: ReplyToMessage) => void;
|
|
303
|
+
sendImageMessage: (imageData: any, text?: string, replyTo?: ReplyToMessage) => void;
|
|
304
|
+
updateMessageStatus: (messageId: number, status: 'sent' | 'delivered' | 'read') => void;
|
|
305
|
+
addReaction: (messageId: number, emoji: string) => void;
|
|
306
|
+
deleteMessage: (messageId: number) => void;
|
|
307
|
+
removeReaction: (messageId: number, emoji: string) => void;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
interface ChatSDKConfig {
|
|
311
|
+
initialMessages?: Message[];
|
|
312
|
+
enableOptimisticUpdates?: boolean;
|
|
313
|
+
}
|
|
314
|
+
interface ChatSDKReturn {
|
|
315
|
+
messages: Message[];
|
|
316
|
+
isTyping: boolean;
|
|
317
|
+
sendMessage: (text: string, replyTo?: Message) => void;
|
|
318
|
+
addReaction: (messageId: number, emoji: string) => void;
|
|
319
|
+
removeReaction: (messageId: number, emoji: string) => void;
|
|
320
|
+
setMessages: (messages: Message[]) => void;
|
|
321
|
+
addMessage: (message: Message) => void;
|
|
322
|
+
updateMessage: (messageId: number, updates: Partial<Message>) => void;
|
|
323
|
+
deleteMessage: (messageId: number) => void;
|
|
324
|
+
setTyping: (isTyping: boolean) => void;
|
|
325
|
+
resetChat: () => void;
|
|
326
|
+
getMessageById: (id: number) => Message | undefined;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
interface UseAttachmentsOptions {
|
|
330
|
+
uploader?: AttachmentUploader;
|
|
331
|
+
maxAttachments?: number;
|
|
332
|
+
maxFileSize?: number;
|
|
333
|
+
allowedTypes?: string[];
|
|
334
|
+
onAttachmentAdd?: (attachment: Attachment) => void;
|
|
335
|
+
onAttachmentRemove?: (attachmentId: string) => void;
|
|
336
|
+
onAttachmentUpload?: (attachments: Attachment[]) => void;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
interface MessageListConfig {
|
|
340
|
+
scrollThreshold?: number;
|
|
341
|
+
autoScrollToBottom?: boolean;
|
|
342
|
+
enableMessageActions?: boolean;
|
|
343
|
+
enableReactionDetails?: boolean;
|
|
344
|
+
initialNumToRender?: number;
|
|
345
|
+
maxToRenderPerBatch?: number;
|
|
346
|
+
windowSize?: number;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
interface ActionState {
|
|
350
|
+
actionSheetVisible: boolean;
|
|
351
|
+
selectedMessage: Message$1 | null;
|
|
352
|
+
messagePosition?: {
|
|
353
|
+
x: number;
|
|
354
|
+
y: number;
|
|
355
|
+
width: number;
|
|
356
|
+
height: number;
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
interface ReactionState {
|
|
361
|
+
isReactionDetailsVisible: boolean;
|
|
362
|
+
selectedReactions: any[];
|
|
363
|
+
selectedMessageText: string;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
interface ThemeColors {
|
|
367
|
+
primary: string;
|
|
368
|
+
secondary: string;
|
|
369
|
+
background: string;
|
|
370
|
+
surface: string;
|
|
371
|
+
surfaceSecondary: string;
|
|
372
|
+
text: string;
|
|
373
|
+
textSecondary: string;
|
|
374
|
+
textMuted: string;
|
|
375
|
+
border: string;
|
|
376
|
+
borderLight: string;
|
|
377
|
+
success: string;
|
|
378
|
+
error: string;
|
|
379
|
+
warning: string;
|
|
380
|
+
unread: string;
|
|
381
|
+
online: string;
|
|
382
|
+
messageBubble: {
|
|
383
|
+
sent: string;
|
|
384
|
+
received: string;
|
|
385
|
+
sentText: string;
|
|
386
|
+
receivedText: string;
|
|
387
|
+
};
|
|
388
|
+
gray: {
|
|
389
|
+
50: string;
|
|
390
|
+
100: string;
|
|
391
|
+
200: string;
|
|
392
|
+
300: string;
|
|
393
|
+
400: string;
|
|
394
|
+
500: string;
|
|
395
|
+
600: string;
|
|
396
|
+
700: string;
|
|
397
|
+
800: string;
|
|
398
|
+
900: string;
|
|
399
|
+
};
|
|
400
|
+
blue: {
|
|
401
|
+
50: string;
|
|
402
|
+
500: string;
|
|
403
|
+
600: string;
|
|
404
|
+
};
|
|
405
|
+
green: {
|
|
406
|
+
500: string;
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
interface ThemeSpacing {
|
|
410
|
+
xs: number;
|
|
411
|
+
sm: number;
|
|
412
|
+
md: number;
|
|
413
|
+
lg: number;
|
|
414
|
+
xl: number;
|
|
415
|
+
xxl: number;
|
|
416
|
+
}
|
|
417
|
+
interface ThemeBorderRadius {
|
|
418
|
+
sm: number;
|
|
419
|
+
md: number;
|
|
420
|
+
lg: number;
|
|
421
|
+
xl: number;
|
|
422
|
+
full: number;
|
|
423
|
+
}
|
|
424
|
+
interface ThemeTypography {
|
|
425
|
+
fontFamily: string;
|
|
426
|
+
fontSize: {
|
|
427
|
+
xs: number;
|
|
428
|
+
sm: number;
|
|
429
|
+
base: number;
|
|
430
|
+
lg: number;
|
|
431
|
+
xl: number;
|
|
432
|
+
xxl: number;
|
|
433
|
+
};
|
|
434
|
+
fontWeight: {
|
|
435
|
+
normal: '400' | 'normal';
|
|
436
|
+
medium: '500' | 'medium';
|
|
437
|
+
semibold: '600' | 'semibold';
|
|
438
|
+
bold: '700' | 'bold';
|
|
439
|
+
};
|
|
440
|
+
lineHeight: {
|
|
441
|
+
tight: number;
|
|
442
|
+
normal: number;
|
|
443
|
+
relaxed: number;
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
interface Theme {
|
|
447
|
+
colors: ThemeColors;
|
|
448
|
+
spacing: ThemeSpacing;
|
|
449
|
+
borderRadius: ThemeBorderRadius;
|
|
450
|
+
typography: ThemeTypography;
|
|
451
|
+
}
|
|
452
|
+
interface ThemeProviderProps {
|
|
453
|
+
children: React.ReactNode;
|
|
454
|
+
theme?: Partial<Theme>;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
interface ChatHeaderProps {
|
|
458
|
+
title: string;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
interface ChatListSearchBarProps {
|
|
462
|
+
value: string;
|
|
463
|
+
onChangeText: (text: string) => void;
|
|
464
|
+
onClear: () => void;
|
|
465
|
+
placeholder?: string;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
interface TypingIndicatorProps {
|
|
469
|
+
isVisible: boolean;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
interface ExtendedMessageListProps extends MessageListProps {
|
|
473
|
+
isTyping?: boolean;
|
|
474
|
+
typingUserName?: string;
|
|
475
|
+
onScroll?: (event: any) => void;
|
|
476
|
+
onContentSizeChange?: () => void;
|
|
477
|
+
showScrollToBottom?: boolean;
|
|
478
|
+
isReplyActive?: boolean;
|
|
479
|
+
scrollThreshold?: number;
|
|
480
|
+
autoScrollToBottom?: boolean;
|
|
481
|
+
onScrollToBottom?: () => void;
|
|
482
|
+
onScrollToTop?: () => void;
|
|
483
|
+
onScrollPositionChange?: (isNearBottom: boolean, isNearTop: boolean) => void;
|
|
484
|
+
onActionPress?: (action: string, message: Message$1) => void;
|
|
485
|
+
onReactionAdd?: (messageId: number, emoji: string) => void;
|
|
486
|
+
onReactionRemove?: (messageId: number, emoji: string) => void;
|
|
487
|
+
onMessageDelete?: (messageId: number) => void;
|
|
488
|
+
onReplyMessage?: (message: Message$1) => void;
|
|
489
|
+
onCancelReply?: () => void;
|
|
490
|
+
enableMessageActions?: boolean;
|
|
491
|
+
enableReactionDetails?: boolean;
|
|
492
|
+
}
|
|
493
|
+
interface MessageListRef {
|
|
494
|
+
scrollToEnd: (animated?: boolean) => void;
|
|
495
|
+
scrollToOffset: (offset: number, animated?: boolean) => void;
|
|
496
|
+
scrollToIndex: (index: number, animated?: boolean) => void;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
interface ChatConfig {
|
|
500
|
+
keyboardBehavior?: 'padding' | 'height' | 'position';
|
|
501
|
+
keyboardVerticalOffset?: number;
|
|
502
|
+
enableReactionDetails?: boolean;
|
|
503
|
+
enableMessageActions?: boolean;
|
|
504
|
+
enableScrollToBottom?: boolean;
|
|
505
|
+
enableTypingIndicator?: boolean;
|
|
506
|
+
onMessageSend?: (text: string, replyTo?: Message) => void;
|
|
507
|
+
onReactionAdd?: (messageId: number, emoji: string) => void;
|
|
508
|
+
onReactionRemove?: (messageId: number, emoji: string) => void;
|
|
509
|
+
}
|
|
510
|
+
interface ChatProviderProps {
|
|
511
|
+
children: ReactNode;
|
|
512
|
+
config?: ChatConfig;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
interface ChatInitConfig {
|
|
516
|
+
projectId: string;
|
|
517
|
+
apiUrl?: string;
|
|
518
|
+
debug?: boolean;
|
|
519
|
+
}
|
|
520
|
+
interface ChatInitResponse {
|
|
521
|
+
success: boolean;
|
|
522
|
+
message: string;
|
|
523
|
+
projectId: string;
|
|
524
|
+
activatedAt: string;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Initialize the chat SDK with project verification
|
|
528
|
+
*
|
|
529
|
+
* This function validates the project ID with the API and sets up the SDK for use.
|
|
530
|
+
* All UseChat components and hooks require this to be called first.
|
|
531
|
+
*
|
|
532
|
+
* @param config - Configuration object containing projectId and optional apiUrl
|
|
533
|
+
* @returns Promise that resolves to ChatInitResponse or rejects with ChatInitError
|
|
534
|
+
*/
|
|
535
|
+
declare const initChat: (config: ChatInitConfig) => Promise<ChatInitResponse>;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Simple Authentication System for UseChat SDK
|
|
539
|
+
*
|
|
540
|
+
* This system ensures initChat() is called before using any components or hooks.
|
|
541
|
+
* No loading states - just immediate error throwing for better developer experience.
|
|
542
|
+
*/
|
|
543
|
+
interface AuthState {
|
|
544
|
+
isInitialized: boolean;
|
|
545
|
+
projectId: string | null;
|
|
546
|
+
error: string | null;
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Get current authentication state (read-only)
|
|
550
|
+
*/
|
|
551
|
+
declare const getAuthState: () => Readonly<AuthState>;
|
|
552
|
+
/**
|
|
553
|
+
* Get the current project ID (throws if not initialized)
|
|
554
|
+
*/
|
|
555
|
+
declare const getProjectId: () => string;
|
|
556
|
+
/**
|
|
557
|
+
* Check if SDK is initialized (without throwing)
|
|
558
|
+
*/
|
|
559
|
+
declare const isInitialized: () => boolean;
|
|
560
|
+
|
|
561
|
+
interface ChatComponents {
|
|
562
|
+
MessageList?: ComponentType<MessageListProps>;
|
|
563
|
+
MessageInput?: ComponentType<MessageInputProps>;
|
|
564
|
+
MessageActionSheet?: ComponentType<any>;
|
|
565
|
+
ReactionDetailsSheet?: ComponentType<any>;
|
|
566
|
+
ScrollToBottomButton?: ComponentType<any>;
|
|
567
|
+
}
|
|
568
|
+
interface ChatRenderProps {
|
|
569
|
+
renderMessage?: (props: RenderMessageProps) => ReactNode;
|
|
570
|
+
renderInput?: (props: RenderInputProps) => ReactNode;
|
|
571
|
+
renderActionSheet?: (props: RenderActionSheetProps) => ReactNode;
|
|
572
|
+
renderReactionDetails?: (props: RenderReactionDetailsProps) => ReactNode;
|
|
573
|
+
}
|
|
574
|
+
interface ChatProps {
|
|
575
|
+
messages?: Message$1[];
|
|
576
|
+
components?: ChatComponents;
|
|
577
|
+
renderProps?: ChatRenderProps;
|
|
578
|
+
onMessageSend?: (message: Message$1) => void;
|
|
579
|
+
onReactionAdd?: (messageId: number, emoji: string) => void;
|
|
580
|
+
onReactionRemove?: (messageId: number, emoji: string) => void;
|
|
581
|
+
onMessageDelete?: (messageId: number) => void;
|
|
582
|
+
onActionPress?: (action: string, message: Message$1) => void;
|
|
583
|
+
attachmentUploader?: AttachmentUploader;
|
|
584
|
+
maxAttachments?: number;
|
|
585
|
+
maxFileSize?: number;
|
|
586
|
+
allowedFileTypes?: string[];
|
|
587
|
+
enableReactionDetails?: boolean;
|
|
588
|
+
enableMessageActions?: boolean;
|
|
589
|
+
enableScrollToBottom?: boolean;
|
|
590
|
+
enableTypingIndicator?: boolean;
|
|
591
|
+
isTyping?: boolean;
|
|
592
|
+
typingUserName?: string;
|
|
593
|
+
isLoading?: boolean;
|
|
594
|
+
loadingComponent?: ReactNode;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
declare const defaultTheme: Theme;
|
|
598
|
+
|
|
599
|
+
declare const Chat: React$1.ComponentType<ChatProps>;
|
|
600
|
+
declare const ChatProvider: React$1.ComponentType<ChatProviderProps>;
|
|
601
|
+
declare const useChatConfig: () => ChatConfig;
|
|
602
|
+
|
|
603
|
+
declare const MessageList: React$1.ComponentType<ExtendedMessageListProps & React$1.RefAttributes<MessageListRef>>;
|
|
604
|
+
declare const MessageInput: React$1.ComponentType<MessageInputProps & React$1.RefAttributes<MessageInputRef>>;
|
|
605
|
+
|
|
606
|
+
declare const ChatScreenHeader: React$1.ComponentType<ChatScreenHeaderProps>;
|
|
607
|
+
declare const TypingIndicator: React$1.ComponentType<TypingIndicatorProps>;
|
|
608
|
+
|
|
609
|
+
declare const ChatList: React$1.ComponentType<ChatListProps>;
|
|
610
|
+
declare const ChatItem: React$1.ComponentType<ChatItemProps>;
|
|
611
|
+
declare const ChatHeader: React$1.ComponentType<ChatHeaderProps>;
|
|
612
|
+
declare const ChatListSearchBar: React$1.ComponentType<ChatListSearchBarProps>;
|
|
613
|
+
|
|
614
|
+
declare const ChatAvatar: React$1.ComponentType<ChatAvatarProps>;
|
|
615
|
+
declare const AttachmentMenu: React$1.ComponentType<AttachmentMenuProps & React$1.RefAttributes<AttachmentMenuRef>>;
|
|
616
|
+
declare const ThemeProvider: React$1.ComponentType<ThemeProviderProps>;
|
|
617
|
+
|
|
618
|
+
declare const useTheme: () => Theme;
|
|
619
|
+
|
|
620
|
+
declare const useChatSDK: (config?: ChatSDKConfig | undefined) => ChatSDKReturn;
|
|
621
|
+
declare const useChatMessages: (senderName?: string | undefined) => UseChatMessagesReturn;
|
|
622
|
+
declare const useMessageList: (messages: Message$1[], config?: MessageListConfig | undefined) => {
|
|
623
|
+
messageItems: MessageListItem[];
|
|
624
|
+
keyExtractor: (item: MessageListItem$1) => string;
|
|
625
|
+
flatListProps: {
|
|
626
|
+
initialNumToRender: number;
|
|
627
|
+
maxToRenderPerBatch: number;
|
|
628
|
+
windowSize: number;
|
|
629
|
+
inverted: boolean;
|
|
630
|
+
showsVerticalScrollIndicator: boolean;
|
|
631
|
+
keyboardShouldPersistTaps: "handled";
|
|
632
|
+
removeClippedSubviews: boolean;
|
|
633
|
+
scrollEventThrottle: number;
|
|
634
|
+
};
|
|
635
|
+
};
|
|
636
|
+
declare const useMessageActions: (config?: MessageListConfig | undefined) => {
|
|
637
|
+
actionState: ActionState;
|
|
638
|
+
handleMessageLongPress: (message: Message$1, position?: {
|
|
639
|
+
x: number;
|
|
640
|
+
y: number;
|
|
641
|
+
width: number;
|
|
642
|
+
height: number;
|
|
643
|
+
}) => void;
|
|
644
|
+
handleActionSheetClose: () => void;
|
|
645
|
+
handleActionPress: (action: string, callbacks?: {
|
|
646
|
+
onReply?: (message: Message$1) => void;
|
|
647
|
+
onDelete?: (messageId: number) => void;
|
|
648
|
+
onCopy?: (message: Message$1) => void;
|
|
649
|
+
onCustomAction?: (action: string, message: Message$1) => void;
|
|
650
|
+
}) => void;
|
|
651
|
+
};
|
|
652
|
+
declare const useMessageReactions: (config?: MessageListConfig | undefined) => {
|
|
653
|
+
reactionState: ReactionState;
|
|
654
|
+
selectedMessage: Message$1 | null;
|
|
655
|
+
handleReactionPress: (message: Message$1) => void;
|
|
656
|
+
handleReactionDetailsClose: () => void;
|
|
657
|
+
handleAddReaction: (emoji: string, onAdd?: (messageId: number, emoji: string) => void) => void;
|
|
658
|
+
handleRemoveReaction: (emoji: string, onRemove?: (messageId: number, emoji: string) => void) => void;
|
|
659
|
+
handleEmojiReact: (emoji: string, onAdd?: (messageId: number, emoji: string) => void) => void;
|
|
660
|
+
};
|
|
661
|
+
declare const useAttachments: (options?: UseAttachmentsOptions | undefined) => UseAttachmentsReturn;
|
|
662
|
+
declare const useMessageInput: <T = string>(config?: MessageInputConfig<T> | undefined) => UseMessageInputReturn<T>;
|
|
663
|
+
|
|
664
|
+
export { AttachmentMenu, type AttachmentResult, Chat, ChatAvatar, type ChatConfig, ChatHeader, type ChatHeaderProps, type ChatInitConfig, type ChatInitResponse, ChatItem, ChatList, ChatListSearchBar, type ChatListSearchBarProps, type ChatProps, ChatProvider, ChatScreenHeader, type Message$1 as Message, MessageInput, type MessageInputRef, MessageList, type MessageListRef, type Theme, type ThemeBorderRadius, type ThemeColors, ThemeProvider, type ThemeProviderProps, type ThemeSpacing, type ThemeTypography, TypingIndicator, type TypingIndicatorProps, defaultTheme, getAuthState, getProjectId, initChat, isInitialized, useAttachments, useChatConfig, useChatMessages, useChatSDK, useMessageActions, useMessageInput, useMessageList, useMessageReactions, useTheme };
|