@banbox/chat 1.0.0
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/README.md +215 -0
- package/dist/index.cjs +3408 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +556 -0
- package/dist/index.d.ts +556 -0
- package/dist/index.js +3385 -0
- package/dist/index.js.map +1 -0
- package/package.json +83 -0
- package/src/adapter/types.ts +146 -0
- package/src/chat/ChatImagePreviewModal.tsx +194 -0
- package/src/chat/ChatRoot.tsx +67 -0
- package/src/chat/InboxPopup.tsx +312 -0
- package/src/chat/SinglePopup.tsx +240 -0
- package/src/contexts/ChatUIContext.tsx +30 -0
- package/src/contexts/ChatUIProvider.tsx +38 -0
- package/src/contexts/GalleryContext.tsx +40 -0
- package/src/contexts/GalleryProvider.tsx +89 -0
- package/src/hooks/useDisableBodyScroll.ts +16 -0
- package/src/icons/index.tsx +248 -0
- package/src/index.ts +56 -0
- package/src/lottie/typingdotanimation2.json +1 -0
- package/src/modals/chat/ChatConfirmModal.tsx +104 -0
- package/src/modals/chat/ChatTranslateSettingsModal.tsx +180 -0
- package/src/types/index.ts +163 -0
- package/src/ui/Button.tsx +83 -0
- package/src/ui/Portal.tsx +40 -0
- package/src/ui/Select.tsx +74 -0
- package/src/ui/chat/AttachmentPreviewStrip.tsx +166 -0
- package/src/ui/chat/ChatComposerBar.tsx +231 -0
- package/src/ui/chat/ChatFooter.tsx +442 -0
- package/src/ui/chat/ChatHeader.tsx +24 -0
- package/src/ui/chat/ChatIdentity.tsx +145 -0
- package/src/ui/chat/ChatInquiryBar.tsx +57 -0
- package/src/ui/chat/ChatListHeader.tsx +179 -0
- package/src/ui/chat/ChatMessageItem.tsx +214 -0
- package/src/ui/chat/ChatScroll.tsx +64 -0
- package/src/ui/chat/ChatSpinner.tsx +49 -0
- package/src/ui/chat/ChatThreadItem.tsx +140 -0
- package/src/ui/chat/MessageHoverActions.tsx +120 -0
- package/src/ui/chat/ReplyCard.tsx +217 -0
- package/src/ui/chat/TypingIndicator.tsx +93 -0
- package/src/ui/chat/drop-up/BusinessCardDropup.tsx +253 -0
- package/src/ui/chat/drop-up/EmojiDropup.tsx +132 -0
- package/src/ui/chat/message-items/ChatAddressCard.tsx +130 -0
- package/src/ui/chat/message-items/ChatBubbleAudio.tsx +209 -0
- package/src/ui/chat/message-items/ChatBubbleFiles.tsx +80 -0
- package/src/ui/chat/message-items/ChatBubbleImages.tsx +120 -0
- package/src/ui/chat/message-items/ChatBubbleText.tsx +16 -0
- package/src/ui/chat/message-items/ChatBusinessCard.tsx +95 -0
- package/src/ui/chat/scrollToMessage.ts +61 -0
- package/src/ui/chat/types.ts +37 -0
- package/src/utils/cn.ts +6 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { ClassValue } from 'clsx';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Thread status — controls the status badge/icon in the thread list.
|
|
7
|
+
* "seen" — blue double tick
|
|
8
|
+
* "delivered" — grey double tick
|
|
9
|
+
* "new" — unread count badge
|
|
10
|
+
*/
|
|
11
|
+
type ThreadStatus = {
|
|
12
|
+
kind: "seen";
|
|
13
|
+
} | {
|
|
14
|
+
kind: "delivered";
|
|
15
|
+
} | {
|
|
16
|
+
kind: "new";
|
|
17
|
+
count: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A contextual reference attached to a chat session.
|
|
21
|
+
* Allows the host app to link a chat to an order, inquiry, or quotation.
|
|
22
|
+
*/
|
|
23
|
+
type Reference = {
|
|
24
|
+
kind: "quotation" | "order" | "inquiry" | "productInquiry";
|
|
25
|
+
id?: string;
|
|
26
|
+
/** Human-readable label shown in the chat header (e.g. "Quotation Request", "Order #123") */
|
|
27
|
+
title?: string;
|
|
28
|
+
/** Arbitrary metadata the host app wants to attach (e.g. product name, amount) */
|
|
29
|
+
meta?: Record<string, string | number | boolean>;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A conversation thread shown in the thread list.
|
|
33
|
+
*/
|
|
34
|
+
type Thread = {
|
|
35
|
+
id: string;
|
|
36
|
+
title: string;
|
|
37
|
+
subTitle?: string;
|
|
38
|
+
avatarText?: string;
|
|
39
|
+
avatarSrc?: string;
|
|
40
|
+
online?: boolean;
|
|
41
|
+
/** True if the contact has a "verified seller" badge */
|
|
42
|
+
badge?: boolean;
|
|
43
|
+
pinned?: boolean;
|
|
44
|
+
/** Unread message count */
|
|
45
|
+
unread?: number;
|
|
46
|
+
/** Preview of the last message */
|
|
47
|
+
last?: string;
|
|
48
|
+
/** Timestamp of the last message */
|
|
49
|
+
time?: string;
|
|
50
|
+
/** For linking to an order */
|
|
51
|
+
orderId?: string;
|
|
52
|
+
/** For linking to an inquiry */
|
|
53
|
+
inquiryId?: string;
|
|
54
|
+
status?: ThreadStatus;
|
|
55
|
+
/** Contextual references attached when opening from a specific order/inquiry */
|
|
56
|
+
references?: Reference[];
|
|
57
|
+
};
|
|
58
|
+
/** A file attachment in a message */
|
|
59
|
+
type MessageFile = {
|
|
60
|
+
name: string;
|
|
61
|
+
sizeMB: number;
|
|
62
|
+
ext: string;
|
|
63
|
+
href?: string;
|
|
64
|
+
downloadName?: string;
|
|
65
|
+
};
|
|
66
|
+
/** An audio clip attachment in a message */
|
|
67
|
+
type MessageAudio = {
|
|
68
|
+
src?: string;
|
|
69
|
+
duration?: string;
|
|
70
|
+
};
|
|
71
|
+
/** A reference to a message being replied to */
|
|
72
|
+
type MessageRef$1 = {
|
|
73
|
+
id: string;
|
|
74
|
+
author: string | {
|
|
75
|
+
name: string;
|
|
76
|
+
};
|
|
77
|
+
time?: string;
|
|
78
|
+
text?: string;
|
|
79
|
+
images?: string[];
|
|
80
|
+
files?: MessageFile[];
|
|
81
|
+
audio?: MessageAudio;
|
|
82
|
+
};
|
|
83
|
+
/** Business card shared in a message */
|
|
84
|
+
type BusinessCard$1 = {
|
|
85
|
+
avatarSrc?: string;
|
|
86
|
+
name: string;
|
|
87
|
+
country?: string;
|
|
88
|
+
flag?: string;
|
|
89
|
+
company?: string;
|
|
90
|
+
email?: string;
|
|
91
|
+
phone?: string;
|
|
92
|
+
[key: string]: string | undefined;
|
|
93
|
+
};
|
|
94
|
+
/** Address card shared in a message */
|
|
95
|
+
type AddressCard$1 = {
|
|
96
|
+
name?: string;
|
|
97
|
+
label?: string;
|
|
98
|
+
businessName?: string;
|
|
99
|
+
mobileNumber?: string;
|
|
100
|
+
country?: string;
|
|
101
|
+
district?: string | null;
|
|
102
|
+
policeStation?: string | null;
|
|
103
|
+
state?: string | null;
|
|
104
|
+
city?: string | null;
|
|
105
|
+
postalCode?: string;
|
|
106
|
+
addressLine?: string;
|
|
107
|
+
landMark?: string | null;
|
|
108
|
+
[key: string]: string | null | undefined;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* A single chat message.
|
|
112
|
+
*/
|
|
113
|
+
type Message = {
|
|
114
|
+
id: string;
|
|
115
|
+
author: string | {
|
|
116
|
+
name: string;
|
|
117
|
+
};
|
|
118
|
+
time?: string;
|
|
119
|
+
/** Primary text content */
|
|
120
|
+
text?: string;
|
|
121
|
+
/** Alias for text (legacy compat) */
|
|
122
|
+
content?: string;
|
|
123
|
+
images?: string[];
|
|
124
|
+
files?: MessageFile[];
|
|
125
|
+
audio?: MessageAudio;
|
|
126
|
+
businessCard?: BusinessCard$1 | Record<string, string>;
|
|
127
|
+
addressCard?: AddressCard$1 | Record<string, string>;
|
|
128
|
+
replyTo?: MessageRef$1;
|
|
129
|
+
avatarSrc?: string;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* The unified send payload — all message types in one discriminated union.
|
|
133
|
+
* ChatFooter produces one of these; the adapter's messages.send() consumes it.
|
|
134
|
+
*
|
|
135
|
+
* To add a new message type:
|
|
136
|
+
* 1. Add a new variant here
|
|
137
|
+
* 2. Handle it in the adapter's send() implementation
|
|
138
|
+
*/
|
|
139
|
+
type SendPayload = {
|
|
140
|
+
type: "text";
|
|
141
|
+
text: string;
|
|
142
|
+
replyTo?: MessageRef$1;
|
|
143
|
+
} | {
|
|
144
|
+
type: "voice";
|
|
145
|
+
src?: string;
|
|
146
|
+
durationSec: number;
|
|
147
|
+
durationText: string;
|
|
148
|
+
replyTo?: MessageRef$1;
|
|
149
|
+
} | {
|
|
150
|
+
type: "attachments";
|
|
151
|
+
images: string[];
|
|
152
|
+
files: MessageFile[];
|
|
153
|
+
replyTo?: MessageRef$1;
|
|
154
|
+
} | {
|
|
155
|
+
type: "businessCard";
|
|
156
|
+
card: BusinessCard$1;
|
|
157
|
+
replyTo?: MessageRef$1;
|
|
158
|
+
} | {
|
|
159
|
+
type: "addressCard";
|
|
160
|
+
card: AddressCard$1;
|
|
161
|
+
replyTo?: MessageRef$1;
|
|
162
|
+
} | {
|
|
163
|
+
type: "combined";
|
|
164
|
+
text: string;
|
|
165
|
+
images: string[];
|
|
166
|
+
files: MessageFile[];
|
|
167
|
+
replyTo?: MessageRef$1;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/** Options for the kebab menu (⋮) rendered by the host app */
|
|
171
|
+
type KebabMenuOpts = {
|
|
172
|
+
pinned: boolean;
|
|
173
|
+
onPinToggle: () => void;
|
|
174
|
+
onDelete: () => void;
|
|
175
|
+
};
|
|
176
|
+
/** Options for a toast notification triggered by the package */
|
|
177
|
+
type ToastOpts = {
|
|
178
|
+
type?: "success" | "error" | "info" | "warning";
|
|
179
|
+
title: string;
|
|
180
|
+
message?: string;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* The unified data adapter.
|
|
184
|
+
*
|
|
185
|
+
* Implement this interface in your host app and pass it to <ChatRoot adapter={...} />.
|
|
186
|
+
*
|
|
187
|
+
* ### Demo implementation (local state):
|
|
188
|
+
* ```ts
|
|
189
|
+
* const adapter: ChatAdapter = {
|
|
190
|
+
* threads: { list: getThreads, subscribe: subscribeThreads, pin, delete: deleteThread },
|
|
191
|
+
* messages: { list: getMessages, send: handleSend },
|
|
192
|
+
* };
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* ### Real API implementation:
|
|
196
|
+
* ```ts
|
|
197
|
+
* const adapter: ChatAdapter = {
|
|
198
|
+
* threads: {
|
|
199
|
+
* list: (ref) => cachedThreads, // from polling/socket
|
|
200
|
+
* subscribe: (cb) => socket.on("threads", cb),
|
|
201
|
+
* pin: (id, p) => api.patch(`/threads/${id}`, { pinned: p }),
|
|
202
|
+
* delete: (id) => api.delete(`/threads/${id}`),
|
|
203
|
+
* },
|
|
204
|
+
* messages: {
|
|
205
|
+
* list: (tid) => cachedMessages[tid] ?? [],
|
|
206
|
+
* subscribe: (tid, cb) => socket.on(`messages:${tid}`, cb),
|
|
207
|
+
* send: (tid, payload) => api.post(`/threads/${tid}/messages`, payload),
|
|
208
|
+
* },
|
|
209
|
+
* };
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
interface ChatAdapter {
|
|
213
|
+
threads: {
|
|
214
|
+
/**
|
|
215
|
+
* Returns the current list of threads.
|
|
216
|
+
* Called synchronously; keep a local cache if using async data.
|
|
217
|
+
*/
|
|
218
|
+
list: (reference?: Reference) => Thread[];
|
|
219
|
+
/**
|
|
220
|
+
* Subscribe to thread list changes.
|
|
221
|
+
* Call the callback whenever threads change (new msg, pin, delete, etc.)
|
|
222
|
+
* Returns an unsubscribe function.
|
|
223
|
+
*
|
|
224
|
+
* For WebSocket: `(cb) => socket.on("threads:update", cb)`
|
|
225
|
+
*/
|
|
226
|
+
subscribe: (cb: () => void) => () => void;
|
|
227
|
+
/**
|
|
228
|
+
* Pin or unpin a thread.
|
|
229
|
+
* @param id Thread ID
|
|
230
|
+
* @param pinned True to pin, false to unpin
|
|
231
|
+
*/
|
|
232
|
+
pin: (id: string, pinned: boolean) => Promise<void> | void;
|
|
233
|
+
/**
|
|
234
|
+
* Delete a thread permanently.
|
|
235
|
+
*/
|
|
236
|
+
delete: (id: string) => Promise<void> | void;
|
|
237
|
+
/**
|
|
238
|
+
* Mark a thread as read (optional).
|
|
239
|
+
* Called when the user opens a thread.
|
|
240
|
+
*/
|
|
241
|
+
markRead?: (id: string) => Promise<void> | void;
|
|
242
|
+
};
|
|
243
|
+
messages: {
|
|
244
|
+
/**
|
|
245
|
+
* Returns the current messages for a thread.
|
|
246
|
+
* Called synchronously; keep a local cache if using async data.
|
|
247
|
+
*/
|
|
248
|
+
list: (threadId: string) => Message[];
|
|
249
|
+
/**
|
|
250
|
+
* Subscribe to message changes for a specific thread.
|
|
251
|
+
* Returns an unsubscribe function.
|
|
252
|
+
*
|
|
253
|
+
* For WebSocket: `(tid, cb) => socket.on(`messages:${tid}`, cb)`
|
|
254
|
+
* For demo: optional (UI re-renders via onAfterSend)
|
|
255
|
+
*/
|
|
256
|
+
subscribe?: (threadId: string, cb: () => void) => () => void;
|
|
257
|
+
/**
|
|
258
|
+
* Send a message.
|
|
259
|
+
* The payload is a discriminated union covering all message types.
|
|
260
|
+
* Mutate your local cache + emit to server here.
|
|
261
|
+
*/
|
|
262
|
+
send: (threadId: string, payload: SendPayload) => Promise<void> | void;
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* UI-level callbacks — side-effects that the host app controls.
|
|
267
|
+
*
|
|
268
|
+
* These are NOT data operations; they are UI actions that the package
|
|
269
|
+
* delegates back to the host app (so the package stays decoupled from
|
|
270
|
+
* the host app's routing, notification, and menu systems).
|
|
271
|
+
*/
|
|
272
|
+
interface ChatUICallbacks {
|
|
273
|
+
/**
|
|
274
|
+
* Show a toast notification.
|
|
275
|
+
* Use your app's existing toast system (react-toastify, sonner, etc.)
|
|
276
|
+
*/
|
|
277
|
+
showToast?: (opts: ToastOpts) => void;
|
|
278
|
+
/**
|
|
279
|
+
* Navigate to an order or inquiry page.
|
|
280
|
+
* Called when the user clicks "View Order" / "View Inquiry" in the chat.
|
|
281
|
+
*/
|
|
282
|
+
onNavigate?: (route: {
|
|
283
|
+
type: "order" | "inquiry";
|
|
284
|
+
id: string;
|
|
285
|
+
}) => void;
|
|
286
|
+
/**
|
|
287
|
+
* Render the kebab (⋮) menu in the chat header.
|
|
288
|
+
* Return your app's custom dropdown component here.
|
|
289
|
+
*/
|
|
290
|
+
renderKebabMenu?: (opts: KebabMenuOpts) => React__default.ReactNode;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
type ChatRootProps = {
|
|
294
|
+
/**
|
|
295
|
+
* The unified data adapter — provides all threads, messages, and send logic.
|
|
296
|
+
*
|
|
297
|
+
* Implement this in your host app:
|
|
298
|
+
* ```ts
|
|
299
|
+
* const adapter = createDemoChatAdapter(); // or createApiChatAdapter(...)
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
adapter: ChatAdapter;
|
|
303
|
+
/**
|
|
304
|
+
* Optional UI callbacks — controls toast notifications, navigation,
|
|
305
|
+
* and the kebab (⋮) menu renderer.
|
|
306
|
+
*
|
|
307
|
+
* These delegate UI side-effects back to the host app so the package
|
|
308
|
+
* stays decoupled from the host's routing and notification systems.
|
|
309
|
+
*/
|
|
310
|
+
uiCallbacks?: ChatUICallbacks;
|
|
311
|
+
};
|
|
312
|
+
declare function ChatRoot({ adapter, uiCallbacks }: ChatRootProps): React$1.ReactPortal | null;
|
|
313
|
+
|
|
314
|
+
declare function ChatUIProvider({ children }: {
|
|
315
|
+
children: React__default.ReactNode;
|
|
316
|
+
}): React__default.JSX.Element;
|
|
317
|
+
|
|
318
|
+
type ChatVariant = "inbox" | "single";
|
|
319
|
+
type ChatUIState = {
|
|
320
|
+
isOpen: boolean;
|
|
321
|
+
variant: ChatVariant;
|
|
322
|
+
reference?: Reference;
|
|
323
|
+
selectedThreadId?: string | null;
|
|
324
|
+
openInbox: (opts?: {
|
|
325
|
+
reference?: Reference;
|
|
326
|
+
threadId?: string;
|
|
327
|
+
}) => void;
|
|
328
|
+
openSingle: (opts?: {
|
|
329
|
+
reference?: Reference;
|
|
330
|
+
}) => void;
|
|
331
|
+
close: () => void;
|
|
332
|
+
selectThread: (id: string | null) => void;
|
|
333
|
+
};
|
|
334
|
+
declare const ChatUIContext: React$1.Context<ChatUIState | null>;
|
|
335
|
+
declare function useChatUI(): ChatUIState;
|
|
336
|
+
|
|
337
|
+
type FooterAction = {
|
|
338
|
+
key: "attachment" | "emoji" | "businessCard" | "addressCard" | "translate" | string;
|
|
339
|
+
title: string;
|
|
340
|
+
icon: React__default.ReactNode;
|
|
341
|
+
onClick?: () => void;
|
|
342
|
+
};
|
|
343
|
+
type Props$8 = {
|
|
344
|
+
variant?: "single" | "group";
|
|
345
|
+
/**
|
|
346
|
+
* Called when the user sends any type of message.
|
|
347
|
+
* The adapter (host app) handles storage and server communication.
|
|
348
|
+
*/
|
|
349
|
+
onSend: (payload: SendPayload) => void;
|
|
350
|
+
/** Called after send completes — triggers parent re-render / scroll */
|
|
351
|
+
onAfterSend?: () => void;
|
|
352
|
+
actions?: FooterAction[];
|
|
353
|
+
className?: string;
|
|
354
|
+
maxRows?: number;
|
|
355
|
+
/** The message being replied to */
|
|
356
|
+
replyTo?: MessageRef$1;
|
|
357
|
+
clearReply?: () => void;
|
|
358
|
+
};
|
|
359
|
+
declare const ChatFooter: React__default.FC<Props$8>;
|
|
360
|
+
|
|
361
|
+
type Props$7 = {
|
|
362
|
+
left: React__default.ReactNode;
|
|
363
|
+
right?: React__default.ReactNode;
|
|
364
|
+
below?: React__default.ReactNode;
|
|
365
|
+
className?: string;
|
|
366
|
+
};
|
|
367
|
+
declare function ChatHeader({ left, right, below, className }: Props$7): React__default.JSX.Element;
|
|
368
|
+
|
|
369
|
+
type SubtitleVariant = "live" | "muted";
|
|
370
|
+
type BaseProps = {
|
|
371
|
+
title: string;
|
|
372
|
+
subtitle?: string;
|
|
373
|
+
subtitleVariant?: SubtitleVariant;
|
|
374
|
+
online?: boolean;
|
|
375
|
+
verified?: boolean;
|
|
376
|
+
/** Circle size in px (default 46) */
|
|
377
|
+
size?: number;
|
|
378
|
+
className?: string;
|
|
379
|
+
};
|
|
380
|
+
type AvatarVariant = BaseProps & {
|
|
381
|
+
variant: "avatar";
|
|
382
|
+
src: string;
|
|
383
|
+
};
|
|
384
|
+
type InitialVariant = BaseProps & {
|
|
385
|
+
variant: "initial";
|
|
386
|
+
initial: string;
|
|
387
|
+
initialSrc?: string;
|
|
388
|
+
bg?: string;
|
|
389
|
+
textClassName?: string;
|
|
390
|
+
};
|
|
391
|
+
type LogoVariant = BaseProps & {
|
|
392
|
+
variant: "logo";
|
|
393
|
+
src: string;
|
|
394
|
+
ringColor?: string;
|
|
395
|
+
};
|
|
396
|
+
type ChatIdentityProps = AvatarVariant | InitialVariant | LogoVariant;
|
|
397
|
+
declare const ChatIdentity: (props: ChatIdentityProps) => React$1.JSX.Element;
|
|
398
|
+
|
|
399
|
+
type MessageRef = {
|
|
400
|
+
id: string;
|
|
401
|
+
author: string | {
|
|
402
|
+
name: string;
|
|
403
|
+
};
|
|
404
|
+
time?: string;
|
|
405
|
+
text?: string;
|
|
406
|
+
images?: string[];
|
|
407
|
+
files?: ChatFile[];
|
|
408
|
+
audio?: ChatAudio;
|
|
409
|
+
};
|
|
410
|
+
type BusinessCard = {
|
|
411
|
+
avatarSrc: string;
|
|
412
|
+
name: string;
|
|
413
|
+
country: string;
|
|
414
|
+
flag?: string;
|
|
415
|
+
company: string;
|
|
416
|
+
email: string;
|
|
417
|
+
phone: string;
|
|
418
|
+
};
|
|
419
|
+
type AddressCard = {
|
|
420
|
+
name: string;
|
|
421
|
+
label?: "Home" | "Office";
|
|
422
|
+
businessName?: string;
|
|
423
|
+
mobileNumber: string;
|
|
424
|
+
country: string;
|
|
425
|
+
district?: string | null;
|
|
426
|
+
policeStation?: string | null;
|
|
427
|
+
state?: string | null;
|
|
428
|
+
city?: string | null;
|
|
429
|
+
postalCode?: string;
|
|
430
|
+
addressLine: string;
|
|
431
|
+
landMark?: string | null;
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
type ChatAudio = {
|
|
435
|
+
src?: string;
|
|
436
|
+
duration?: string;
|
|
437
|
+
};
|
|
438
|
+
type ChatFile = {
|
|
439
|
+
name: string;
|
|
440
|
+
sizeMB: number;
|
|
441
|
+
ext: string;
|
|
442
|
+
href?: string;
|
|
443
|
+
downloadName?: string;
|
|
444
|
+
};
|
|
445
|
+
type ChatMessageItemProps = {
|
|
446
|
+
id: string;
|
|
447
|
+
mine?: boolean;
|
|
448
|
+
time: string;
|
|
449
|
+
authorInitial?: string;
|
|
450
|
+
avatarBg?: string;
|
|
451
|
+
text?: string;
|
|
452
|
+
businessCard?: BusinessCard;
|
|
453
|
+
addressCard?: AddressCard;
|
|
454
|
+
images?: string[];
|
|
455
|
+
files?: ChatFile[];
|
|
456
|
+
audio?: ChatAudio;
|
|
457
|
+
replyTo?: MessageRef;
|
|
458
|
+
showStatus?: boolean;
|
|
459
|
+
status?: string;
|
|
460
|
+
className?: string;
|
|
461
|
+
onReply?: () => void;
|
|
462
|
+
onTranslate?: () => void;
|
|
463
|
+
initialSrc?: string;
|
|
464
|
+
};
|
|
465
|
+
declare const ChatMessageItem: ({ id, mine, time, authorInitial, avatarBg, text, businessCard, addressCard, images, files, audio, replyTo, showStatus, status, className, onReply, onTranslate, initialSrc, }: ChatMessageItemProps) => React$1.JSX.Element;
|
|
466
|
+
|
|
467
|
+
type Props$6 = {
|
|
468
|
+
top?: React__default.ReactNode;
|
|
469
|
+
children: React__default.ReactNode;
|
|
470
|
+
className?: string;
|
|
471
|
+
/** set true if you want short threads anchored at the bottom */
|
|
472
|
+
bottomAlignWhenShort?: boolean;
|
|
473
|
+
/** when this value changes, we auto-scroll to the bottom */
|
|
474
|
+
scrollKey?: string | number;
|
|
475
|
+
};
|
|
476
|
+
declare const ChatScroll: React__default.FC<Props$6>;
|
|
477
|
+
|
|
478
|
+
type ChatThreadStatus = {
|
|
479
|
+
kind: "seen";
|
|
480
|
+
} | {
|
|
481
|
+
kind: "delivered";
|
|
482
|
+
} | {
|
|
483
|
+
kind: "new";
|
|
484
|
+
count: number;
|
|
485
|
+
};
|
|
486
|
+
type Props$5 = {
|
|
487
|
+
active?: boolean;
|
|
488
|
+
pinned?: boolean;
|
|
489
|
+
online?: boolean;
|
|
490
|
+
verified?: boolean;
|
|
491
|
+
title: string;
|
|
492
|
+
preview: string;
|
|
493
|
+
time: string;
|
|
494
|
+
status: ChatThreadStatus;
|
|
495
|
+
avatarText: string;
|
|
496
|
+
avatarSrc?: string;
|
|
497
|
+
size?: number;
|
|
498
|
+
avatarBg?: string;
|
|
499
|
+
className?: string;
|
|
500
|
+
onClick?: () => void;
|
|
501
|
+
};
|
|
502
|
+
declare const ChatThreadItem: ({ active, pinned, online, verified, title, preview, time, status, avatarText, avatarSrc, avatarBg, className, onClick, }: Props$5) => React$1.JSX.Element;
|
|
503
|
+
|
|
504
|
+
type Props$4 = {
|
|
505
|
+
className?: string;
|
|
506
|
+
onClose?: () => void;
|
|
507
|
+
onSearchChange?: (value: string) => void;
|
|
508
|
+
};
|
|
509
|
+
declare const ChatListHeader: ({ className, onClose, onSearchChange }: Props$4) => React$1.JSX.Element;
|
|
510
|
+
|
|
511
|
+
type Props$3 = {
|
|
512
|
+
id?: string;
|
|
513
|
+
onView?: () => void;
|
|
514
|
+
className?: string;
|
|
515
|
+
label?: string;
|
|
516
|
+
buttonLabel?: string;
|
|
517
|
+
};
|
|
518
|
+
declare const ChatInquiryBar: React__default.FC<Props$3>;
|
|
519
|
+
|
|
520
|
+
type Props$2 = {
|
|
521
|
+
/** Pixel box for the animation area */
|
|
522
|
+
size?: number;
|
|
523
|
+
loop?: boolean;
|
|
524
|
+
autoplay?: boolean;
|
|
525
|
+
className?: string;
|
|
526
|
+
ariaLabel?: string;
|
|
527
|
+
/** Avatar size in px */
|
|
528
|
+
avatarSize?: number;
|
|
529
|
+
};
|
|
530
|
+
declare const TypingIndicator: React__default.FC<Props$2>;
|
|
531
|
+
|
|
532
|
+
type Props$1 = {
|
|
533
|
+
refMsg: MessageRef;
|
|
534
|
+
onClose?: () => void;
|
|
535
|
+
compact?: boolean;
|
|
536
|
+
className?: string;
|
|
537
|
+
jumpOnClick?: boolean;
|
|
538
|
+
};
|
|
539
|
+
declare const ReplyCard: React__default.FC<Props$1>;
|
|
540
|
+
|
|
541
|
+
type Props = {
|
|
542
|
+
className?: string;
|
|
543
|
+
/** Size in px (default 32) */
|
|
544
|
+
size?: number;
|
|
545
|
+
};
|
|
546
|
+
declare const ChatSpinner: React__default.FC<Props>;
|
|
547
|
+
|
|
548
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
549
|
+
|
|
550
|
+
interface PortalProps {
|
|
551
|
+
children: React.ReactNode;
|
|
552
|
+
containerId?: string;
|
|
553
|
+
}
|
|
554
|
+
declare function Portal({ children, containerId }: PortalProps): React$1.ReactPortal | null;
|
|
555
|
+
|
|
556
|
+
export { type AddressCard$1 as AddressCard, type BusinessCard$1 as BusinessCard, type ChatAdapter, ChatFooter, ChatHeader, ChatIdentity, ChatInquiryBar, ChatListHeader, ChatMessageItem, ChatRoot, type ChatRootProps, ChatScroll, ChatSpinner, ChatThreadItem, type ChatThreadStatus, type ChatUICallbacks, ChatUIContext, ChatUIProvider, type ChatUIState, type ChatVariant, type KebabMenuOpts, type Message, type MessageAudio, type MessageFile, type MessageRef$1 as MessageRef, Portal, type Reference, ReplyCard, type SendPayload, type Thread, type ThreadStatus, type ToastOpts, TypingIndicator, cn, useChatUI };
|