@realtimexsco/live-chat 1.1.0 → 1.3.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/LICENSE +1 -1
- package/README.md +1248 -761
- package/dist/index.cjs +14642 -5035
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +753 -108
- package/dist/index.d.ts +753 -108
- package/dist/index.mjs +14513 -4915
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +578 -11
- package/package.json +6 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { ReactNode } from 'react';
|
|
2
3
|
import * as zustand_middleware from 'zustand/middleware';
|
|
3
4
|
import * as zustand from 'zustand';
|
|
4
5
|
import { ManagerOptions, SocketOptions, Socket } from 'socket.io-client';
|
|
@@ -22,12 +23,14 @@ interface IChannel {
|
|
|
22
23
|
starredCount?: number;
|
|
23
24
|
isLeft?: boolean;
|
|
24
25
|
isBlocked?: boolean;
|
|
26
|
+
email?: string;
|
|
25
27
|
}
|
|
26
28
|
interface IMessage {
|
|
27
29
|
id: string;
|
|
28
30
|
_id?: string;
|
|
29
31
|
content: string;
|
|
30
32
|
sender: string;
|
|
33
|
+
senderId?: string;
|
|
31
34
|
receiver?: string;
|
|
32
35
|
timestamp: string;
|
|
33
36
|
isOwnMessage: boolean;
|
|
@@ -49,52 +52,45 @@ interface IMessageAttachment {
|
|
|
49
52
|
url: string;
|
|
50
53
|
type: "image" | "video" | "audio" | "file";
|
|
51
54
|
name: string;
|
|
55
|
+
fileType?: string;
|
|
56
|
+
size?: number;
|
|
57
|
+
width?: number;
|
|
58
|
+
height?: number;
|
|
59
|
+
duration?: number;
|
|
60
|
+
caption?: string;
|
|
61
|
+
starredBy?: string[];
|
|
62
|
+
reactions?: any[];
|
|
63
|
+
isStarredByMe?: boolean;
|
|
64
|
+
isPinned?: boolean;
|
|
65
|
+
isDeletedForEveryone?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/** Payload shape for dm_send / group_message_send socket events */
|
|
68
|
+
interface ISocketMessageAttachment {
|
|
69
|
+
url: string;
|
|
70
|
+
filename: string;
|
|
71
|
+
fileType: string;
|
|
72
|
+
size?: number;
|
|
73
|
+
width?: number;
|
|
74
|
+
height?: number;
|
|
75
|
+
duration?: number;
|
|
76
|
+
uploadedAt?: string;
|
|
77
|
+
caption?: string;
|
|
52
78
|
}
|
|
53
79
|
interface IAttachment {
|
|
54
80
|
id: string;
|
|
55
81
|
file: File;
|
|
56
82
|
previewUrl: string;
|
|
57
83
|
type: "image" | "video" | "audio" | "file";
|
|
84
|
+
uploadStatus: "uploading" | "uploaded" | "error";
|
|
85
|
+
uploadError?: string;
|
|
86
|
+
caption?: string;
|
|
87
|
+
uploaded?: ISocketMessageAttachment;
|
|
58
88
|
}
|
|
59
89
|
|
|
60
|
-
interface
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
showChannelDetails?: boolean;
|
|
64
|
-
messageDateFormat?: (date: string) => string;
|
|
65
|
-
}
|
|
66
|
-
interface ChatContextValue {
|
|
67
|
-
activeChannel: IChannel | null;
|
|
68
|
-
setActiveChannel: (channel: IChannel | null) => void;
|
|
69
|
-
onSendMessage?: (content: string, attachments: any[]) => void;
|
|
70
|
-
client?: any;
|
|
71
|
-
theme?: string;
|
|
72
|
-
uiConfig: UIConfig;
|
|
73
|
-
themeColor: string;
|
|
74
|
-
channelsData?: IChannel[];
|
|
75
|
-
messagesData?: Record<string, IMessage[]>;
|
|
76
|
-
}
|
|
77
|
-
declare const useChatContext: () => ChatContextValue;
|
|
78
|
-
interface ChatProps {
|
|
79
|
-
children: React.ReactNode;
|
|
80
|
-
onSendMessage?: (content: string, attachments: any[]) => void;
|
|
81
|
-
client?: {
|
|
82
|
-
id: string;
|
|
83
|
-
};
|
|
84
|
-
theme?: string;
|
|
85
|
-
uiConfig?: UIConfig;
|
|
86
|
-
themeColor?: string;
|
|
87
|
-
accessToken?: string;
|
|
88
|
-
loggedUserDetails?: any;
|
|
89
|
-
apiUrl?: string;
|
|
90
|
-
socketUrl?: string;
|
|
91
|
-
channelsData?: IChannel[];
|
|
92
|
-
messagesData?: Record<string, IMessage[]>;
|
|
93
|
-
onMessageReceived?: (message: any) => void;
|
|
94
|
-
onSocketConnected?: (socketId: string) => void;
|
|
95
|
-
onSocketError?: (error: string) => void;
|
|
90
|
+
interface ChatForwardItem {
|
|
91
|
+
message: IMessage;
|
|
92
|
+
attachmentId?: string;
|
|
96
93
|
}
|
|
97
|
-
declare const Chat: ({ children, onSendMessage, client, theme, uiConfig, themeColor, accessToken, loggedUserDetails, apiUrl, socketUrl, channelsData, messagesData, onMessageReceived, onSocketConnected, onSocketError }: ChatProps) => React.JSX.Element;
|
|
98
94
|
|
|
99
95
|
interface ChatLayoutConfig {
|
|
100
96
|
/** Sidebar with profile + conversation list */
|
|
@@ -115,28 +111,15 @@ interface ChatLayoutConfig {
|
|
|
115
111
|
declare const defaultChatLayoutConfig: Required<ChatLayoutConfig>;
|
|
116
112
|
declare const mergeChatLayoutConfig: (config?: ChatLayoutConfig) => Required<ChatLayoutConfig>;
|
|
117
113
|
|
|
118
|
-
interface ChatMainProps {
|
|
119
|
-
clientId: string;
|
|
120
|
-
loggedUserDetails: any;
|
|
121
|
-
accessToken: string;
|
|
122
|
-
apiUrl?: string;
|
|
123
|
-
socketUrl?: string;
|
|
124
|
-
themeColor?: string;
|
|
125
|
-
theme?: string;
|
|
126
|
-
uiConfig?: UIConfig;
|
|
127
|
-
/** Control which sections render. Omit for full UI. */
|
|
128
|
-
layout?: ChatLayoutConfig;
|
|
129
|
-
}
|
|
130
|
-
declare const ChatMain: (props: ChatMainProps) => React.JSX.Element;
|
|
131
|
-
|
|
132
114
|
interface IUser {
|
|
133
115
|
_id: string;
|
|
116
|
+
id?: string;
|
|
134
117
|
name: string;
|
|
135
118
|
email: string;
|
|
136
119
|
role: string;
|
|
137
120
|
isActive: boolean;
|
|
138
|
-
createdAt:
|
|
139
|
-
updatedAt:
|
|
121
|
+
createdAt: Date;
|
|
122
|
+
updatedAt: Date;
|
|
140
123
|
image?: string;
|
|
141
124
|
refreshToken?: string;
|
|
142
125
|
isOnline?: boolean;
|
|
@@ -149,7 +132,6 @@ interface AuthState {
|
|
|
149
132
|
accessToken: string | null;
|
|
150
133
|
tenantId: string | null;
|
|
151
134
|
isTenant: boolean;
|
|
152
|
-
/** True only after client-user login + session setup completes */
|
|
153
135
|
isSessionReady: boolean;
|
|
154
136
|
setSession: (payload: {
|
|
155
137
|
accessToken: string;
|
|
@@ -157,8 +139,8 @@ interface AuthState {
|
|
|
157
139
|
tenantId?: string;
|
|
158
140
|
isTenant?: boolean;
|
|
159
141
|
}) => void;
|
|
160
|
-
setSessionReady: (ready: boolean) => void;
|
|
161
142
|
clearSession: () => void;
|
|
143
|
+
setSessionReady: (ready: boolean) => void;
|
|
162
144
|
}
|
|
163
145
|
interface GroupPermissions {
|
|
164
146
|
onlyAdminCanSendMessage: boolean;
|
|
@@ -176,6 +158,7 @@ interface IConversationInfo {
|
|
|
176
158
|
groupName?: string;
|
|
177
159
|
groupDescription?: string;
|
|
178
160
|
image?: string;
|
|
161
|
+
groupImage?: string;
|
|
179
162
|
groupAdmins: any[];
|
|
180
163
|
createdAt: string;
|
|
181
164
|
updatedAt: string;
|
|
@@ -201,12 +184,8 @@ interface SocketState {
|
|
|
201
184
|
isFetchingAllUsers: boolean;
|
|
202
185
|
isFetchingConversations: boolean;
|
|
203
186
|
isFetchingMessages: boolean;
|
|
204
|
-
isFetchingMessagesByConv: Record<string, number>;
|
|
205
|
-
isFetchingInfo: Record<string, boolean>;
|
|
206
187
|
conversationsPage: number;
|
|
207
188
|
conversationsHasMore: boolean;
|
|
208
|
-
lastConversationsFetchKey: string | null;
|
|
209
|
-
sidebarConversationsSearchKey: string | null;
|
|
210
189
|
lastDM: any | null;
|
|
211
190
|
lastEditDM: any | null;
|
|
212
191
|
lastDeleteDM: any | null;
|
|
@@ -219,6 +198,8 @@ interface SocketState {
|
|
|
219
198
|
typingUsers: Record<string, any[]>;
|
|
220
199
|
pinnedMessagesByConversation: Record<string, any[]>;
|
|
221
200
|
starredMessagesByConversation: Record<string, any[]>;
|
|
201
|
+
isFetchingPinnedMessages: Record<string, boolean>;
|
|
202
|
+
isFetchingStarredMessages: Record<string, boolean>;
|
|
222
203
|
messagePendingActions: Record<string, string[]>;
|
|
223
204
|
messagesMetadata: Record<string, MessagesMetadata>;
|
|
224
205
|
liveConversationCounts: Record<string, {
|
|
@@ -228,13 +209,14 @@ interface SocketState {
|
|
|
228
209
|
isClearingChat: Record<string, boolean>;
|
|
229
210
|
isDeletingConversation: Record<string, boolean>;
|
|
230
211
|
conversationInfos: Record<string, IConversationInfo>;
|
|
212
|
+
isFetchingInfo: Record<string, boolean>;
|
|
231
213
|
isSearchActive: boolean;
|
|
232
214
|
searchedMessageId: string | null;
|
|
233
215
|
activeConversationId: string | null;
|
|
234
|
-
|
|
235
|
-
|
|
216
|
+
globalAppError: AppErrorState | null;
|
|
217
|
+
conversationErrors: Record<string, AppErrorState>;
|
|
218
|
+
composerDisabledByConversation: Record<string, string>;
|
|
236
219
|
rateLimitResetAt: number;
|
|
237
|
-
activeChannel: IChannel | null;
|
|
238
220
|
connectRequested: (config?: any) => void;
|
|
239
221
|
disconnectRequested: () => void;
|
|
240
222
|
setConnecting: () => void;
|
|
@@ -270,9 +252,8 @@ interface SocketState {
|
|
|
270
252
|
receivedGroupMessage: (payload: any) => void;
|
|
271
253
|
fetchMessages: (conversationId: string, limit?: number, cursor?: string | null) => Promise<void>;
|
|
272
254
|
setActiveConversationId: (conversationId: string | null) => void;
|
|
273
|
-
setActiveChannel: (channel: IChannel | null) => void;
|
|
274
255
|
handleAppError: (message: string) => void;
|
|
275
|
-
clearAppError: () => void;
|
|
256
|
+
clearAppError: (conversationId?: string | null) => void;
|
|
276
257
|
setRateLimitResetAt: (resetAt: number) => void;
|
|
277
258
|
receivedDM: (dm: any) => void;
|
|
278
259
|
emitDmSend: (payload: any) => void;
|
|
@@ -395,6 +376,7 @@ interface SocketState {
|
|
|
395
376
|
sender: string;
|
|
396
377
|
targetConversationIds: string[];
|
|
397
378
|
sourceConversationId?: string;
|
|
379
|
+
attachmentId?: string;
|
|
398
380
|
}) => void;
|
|
399
381
|
clearForwardPending: (messageId?: string) => void;
|
|
400
382
|
emitConversationUpdate: (payload: {
|
|
@@ -405,14 +387,539 @@ interface SocketState {
|
|
|
405
387
|
sender: string;
|
|
406
388
|
}) => void;
|
|
407
389
|
receivedGroupLeave: (payload: any) => void;
|
|
408
|
-
fetchSearchMessageContext: (messageId: string
|
|
390
|
+
fetchSearchMessageContext: (messageId: string, options?: {
|
|
391
|
+
searchMode?: boolean;
|
|
392
|
+
}) => Promise<void>;
|
|
409
393
|
setSearchActive: (active: boolean) => void;
|
|
410
394
|
setSearchedMessageId: (messageId: string | null) => void;
|
|
411
|
-
toggleBlock: (userId: string, isBlocked: boolean) => void;
|
|
395
|
+
toggleBlock: (userId: string, isBlocked: boolean, conversationId?: string | null) => void;
|
|
412
396
|
}
|
|
413
397
|
interface AppStoreState extends SocketState, AuthState {
|
|
414
398
|
}
|
|
415
399
|
|
|
400
|
+
/** Context passed to phone / video call handlers */
|
|
401
|
+
interface ChatCallContext {
|
|
402
|
+
activeChannel: IChannel;
|
|
403
|
+
conversationId: string | null;
|
|
404
|
+
}
|
|
405
|
+
/** Feature flags & callbacks — phone/video call, etc. */
|
|
406
|
+
interface ChatFeatures {
|
|
407
|
+
/** Show voice call button in header (default: `true` for DMs) */
|
|
408
|
+
showPhoneCall?: boolean;
|
|
409
|
+
/** Show video call button in header (default: `true`) */
|
|
410
|
+
showVideoCall?: boolean;
|
|
411
|
+
/**
|
|
412
|
+
* When `true`, hide phone/video buttons in group chats.
|
|
413
|
+
* Default: `false` (buttons show in all chats).
|
|
414
|
+
*/
|
|
415
|
+
hideCallActionsInGroupChats?: boolean;
|
|
416
|
+
/** Called when user taps voice call */
|
|
417
|
+
onPhoneCall?: (ctx: ChatCallContext) => void;
|
|
418
|
+
/** Called when user taps video call */
|
|
419
|
+
onVideoCall?: (ctx: ChatCallContext) => void;
|
|
420
|
+
}
|
|
421
|
+
declare const defaultChatFeatures: Required<Pick<ChatFeatures, 'showPhoneCall' | 'showVideoCall' | 'hideCallActionsInGroupChats'>>;
|
|
422
|
+
interface AvatarSlotProps {
|
|
423
|
+
src?: string | null;
|
|
424
|
+
alt?: string;
|
|
425
|
+
name?: string;
|
|
426
|
+
fallback?: string;
|
|
427
|
+
id?: string;
|
|
428
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
429
|
+
showOnline?: boolean;
|
|
430
|
+
isOnline?: boolean;
|
|
431
|
+
className?: string;
|
|
432
|
+
fallbackClassName?: string;
|
|
433
|
+
}
|
|
434
|
+
interface MessageItemSlotProps {
|
|
435
|
+
isSender: boolean;
|
|
436
|
+
message: string;
|
|
437
|
+
createdAt: string;
|
|
438
|
+
attachments?: IMessageAttachment[];
|
|
439
|
+
messageId?: string;
|
|
440
|
+
receiver?: string;
|
|
441
|
+
isEdited?: boolean;
|
|
442
|
+
isDeletedForEveryone?: boolean;
|
|
443
|
+
reactions?: any[];
|
|
444
|
+
conversationId?: string;
|
|
445
|
+
onReply?: () => void;
|
|
446
|
+
onForward?: () => void;
|
|
447
|
+
replyTo?: any;
|
|
448
|
+
isPinned?: boolean;
|
|
449
|
+
isStarred?: boolean;
|
|
450
|
+
isForwarded?: boolean;
|
|
451
|
+
status?: 'sent' | 'delivered' | 'read';
|
|
452
|
+
isGroup?: boolean;
|
|
453
|
+
isSystemMessage?: boolean;
|
|
454
|
+
conversationInfo?: any;
|
|
455
|
+
isHighlighted?: boolean;
|
|
456
|
+
senderName?: string;
|
|
457
|
+
senderImage?: string;
|
|
458
|
+
showSenderName?: boolean;
|
|
459
|
+
showSenderLabel?: boolean;
|
|
460
|
+
senderAvatarImage?: string;
|
|
461
|
+
isGroupedWithPrev?: boolean;
|
|
462
|
+
isGroupedWithNext?: boolean;
|
|
463
|
+
}
|
|
464
|
+
interface ChannelHeaderSlotProps {
|
|
465
|
+
activeChannel: IChannel | null;
|
|
466
|
+
conversationId: string | null;
|
|
467
|
+
onBack?: () => void;
|
|
468
|
+
}
|
|
469
|
+
interface ChannelListSlotProps {
|
|
470
|
+
activeChannel: IChannel | null;
|
|
471
|
+
onChannelSelect: (channel: IChannel) => void;
|
|
472
|
+
onNewChatClick?: () => void;
|
|
473
|
+
debouncedSearch?: string;
|
|
474
|
+
}
|
|
475
|
+
interface ChannelListItemSlotProps {
|
|
476
|
+
channel: IChannel & {
|
|
477
|
+
isTyping?: boolean;
|
|
478
|
+
draftPreview?: string | null;
|
|
479
|
+
isOwnLastMessage?: boolean;
|
|
480
|
+
lastMessage?: IChannel['lastMessage'] & {
|
|
481
|
+
status?: 'sent' | 'delivered' | 'read';
|
|
482
|
+
};
|
|
483
|
+
};
|
|
484
|
+
isActive: boolean;
|
|
485
|
+
onSelect: (channel: IChannel) => void;
|
|
486
|
+
}
|
|
487
|
+
interface LoggedUserDetailsSlotProps {
|
|
488
|
+
loggedUserDetails: any;
|
|
489
|
+
onUserSelect?: (channel: IChannel) => void;
|
|
490
|
+
isCreateModalOpen?: boolean;
|
|
491
|
+
setIsCreateModalOpen?: (open: boolean) => void;
|
|
492
|
+
searchQuery?: string;
|
|
493
|
+
setSearchQuery?: (val: string) => void;
|
|
494
|
+
}
|
|
495
|
+
interface ActiveChannelMessagesSlotProps {
|
|
496
|
+
activeChannel: IChannel | null;
|
|
497
|
+
loggedUserId?: string;
|
|
498
|
+
conversationMessages?: any[];
|
|
499
|
+
localMessages?: IMessage[];
|
|
500
|
+
isLoading?: boolean;
|
|
501
|
+
conversationId?: string | null;
|
|
502
|
+
onReply?: (message: IMessage) => void;
|
|
503
|
+
onForward?: (message: IMessage) => void;
|
|
504
|
+
conversationInfo: IConversationInfo | null;
|
|
505
|
+
}
|
|
506
|
+
interface ChannelMessageBoxSlotProps {
|
|
507
|
+
activeChannel: IChannel | null;
|
|
508
|
+
conversationId: string | null;
|
|
509
|
+
onSendMessage?: (content: string, attachments: IAttachment[], replyTo?: IMessage | null) => void;
|
|
510
|
+
replyTo?: IMessage | null;
|
|
511
|
+
onCancelReply?: () => void;
|
|
512
|
+
}
|
|
513
|
+
interface ForwardModalSlotProps {
|
|
514
|
+
isOpen: boolean;
|
|
515
|
+
onClose: () => void;
|
|
516
|
+
items: ChatForwardItem[];
|
|
517
|
+
onForwardComplete?: (channel: IChannel) => void;
|
|
518
|
+
}
|
|
519
|
+
interface ChatPanelAlertsSlotProps {
|
|
520
|
+
className?: string;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Replace the entire chat shell. Custom layouts should call `useChatController()`
|
|
524
|
+
* for state, handlers, and message data.
|
|
525
|
+
*/
|
|
526
|
+
interface ChatLayoutSlotProps {
|
|
527
|
+
layout?: ChatLayoutConfig;
|
|
528
|
+
loggedUserDetails?: any;
|
|
529
|
+
themeColor?: string;
|
|
530
|
+
className?: string;
|
|
531
|
+
shellClassName?: string;
|
|
532
|
+
}
|
|
533
|
+
interface HeaderLeftSideSlotProps {
|
|
534
|
+
onBack?: () => void;
|
|
535
|
+
activeChannel: IChannel;
|
|
536
|
+
pinnedCount: number;
|
|
537
|
+
starredCount: number;
|
|
538
|
+
onOpenDetails: () => void;
|
|
539
|
+
onOpenPins: () => void;
|
|
540
|
+
onOpenStars: () => void;
|
|
541
|
+
}
|
|
542
|
+
interface HeaderRightSideSlotProps {
|
|
543
|
+
activeChannel: IChannel;
|
|
544
|
+
conversationId: string | null;
|
|
545
|
+
isAdmin: boolean;
|
|
546
|
+
canViewMembers: boolean;
|
|
547
|
+
onOpenSearch: () => void;
|
|
548
|
+
onOpenDetails: () => void;
|
|
549
|
+
onOpenPermissions: () => void;
|
|
550
|
+
onOpenMembers: () => void;
|
|
551
|
+
onOpenAdmins: () => void;
|
|
552
|
+
onOpenAttachments: () => void;
|
|
553
|
+
onOpenPins: () => void;
|
|
554
|
+
onOpenStars: () => void;
|
|
555
|
+
onOpenClearChat: () => void;
|
|
556
|
+
onOpenDeleteChannel: () => void;
|
|
557
|
+
onOpenLeaveGroup?: () => void;
|
|
558
|
+
onToggleBlock?: () => void;
|
|
559
|
+
isBlocked?: boolean;
|
|
560
|
+
}
|
|
561
|
+
interface HeaderCallActionsSlotProps {
|
|
562
|
+
activeChannel: IChannel;
|
|
563
|
+
conversationId: string | null;
|
|
564
|
+
showPhoneCall?: boolean;
|
|
565
|
+
showVideoCall?: boolean;
|
|
566
|
+
onPhoneCall?: () => void;
|
|
567
|
+
onVideoCall?: () => void;
|
|
568
|
+
className?: string;
|
|
569
|
+
}
|
|
570
|
+
interface PhoneCallButtonSlotProps {
|
|
571
|
+
activeChannel: IChannel;
|
|
572
|
+
conversationId: string | null;
|
|
573
|
+
onPhoneCall?: () => void;
|
|
574
|
+
className?: string;
|
|
575
|
+
}
|
|
576
|
+
interface VideoCallButtonSlotProps {
|
|
577
|
+
activeChannel: IChannel;
|
|
578
|
+
conversationId: string | null;
|
|
579
|
+
onVideoCall?: () => void;
|
|
580
|
+
className?: string;
|
|
581
|
+
}
|
|
582
|
+
interface HeaderSearchOverlaySlotProps {
|
|
583
|
+
searchQuery: string;
|
|
584
|
+
isSearching: boolean;
|
|
585
|
+
searchResults: any[];
|
|
586
|
+
onSelectResult: (result: any) => void;
|
|
587
|
+
hasMore: boolean;
|
|
588
|
+
isLoadingMore: boolean;
|
|
589
|
+
onLoadMore: () => void;
|
|
590
|
+
}
|
|
591
|
+
interface ChatActionModalSlotProps {
|
|
592
|
+
isOpen: boolean;
|
|
593
|
+
onOpenChange: (open: boolean) => void;
|
|
594
|
+
title: string;
|
|
595
|
+
description: string;
|
|
596
|
+
warningTitle: string;
|
|
597
|
+
warningDescription: string;
|
|
598
|
+
actionButtonText: string;
|
|
599
|
+
loadingText: string;
|
|
600
|
+
isLoading: boolean;
|
|
601
|
+
onAction: () => void;
|
|
602
|
+
type: 'clear' | 'delete' | 'block';
|
|
603
|
+
}
|
|
604
|
+
interface ChannelDetailsDrawerSlotProps {
|
|
605
|
+
isOpen: boolean;
|
|
606
|
+
onOpenChange: (open: boolean) => void;
|
|
607
|
+
activeChannel: IChannel;
|
|
608
|
+
conversationInfo: IConversationInfo | null;
|
|
609
|
+
}
|
|
610
|
+
interface MembersDrawerSlotProps {
|
|
611
|
+
isOpen: boolean;
|
|
612
|
+
onOpenChange: (open: boolean) => void;
|
|
613
|
+
conversationId: string | null;
|
|
614
|
+
conversationInfo: IConversationInfo | null;
|
|
615
|
+
}
|
|
616
|
+
interface AdminsDrawerSlotProps {
|
|
617
|
+
isOpen: boolean;
|
|
618
|
+
onOpenChange: (open: boolean) => void;
|
|
619
|
+
conversationId: string | null;
|
|
620
|
+
conversationInfo: IConversationInfo | null;
|
|
621
|
+
}
|
|
622
|
+
interface PermissionDrawerSlotProps {
|
|
623
|
+
isOpen: boolean;
|
|
624
|
+
onOpenChange: (open: boolean) => void;
|
|
625
|
+
conversationId: string | null;
|
|
626
|
+
conversationInfo: IConversationInfo | null;
|
|
627
|
+
}
|
|
628
|
+
interface AttachmentsDrawerSlotProps {
|
|
629
|
+
isOpen: boolean;
|
|
630
|
+
onOpenChange: (open: boolean) => void;
|
|
631
|
+
}
|
|
632
|
+
interface PinnedMessagesDrawerSlotProps {
|
|
633
|
+
isOpen: boolean;
|
|
634
|
+
onOpenChange: (open: boolean) => void;
|
|
635
|
+
pinnedMessages: any[];
|
|
636
|
+
loggedUserDetails: any;
|
|
637
|
+
conversationId: string | null;
|
|
638
|
+
activeChannel: IChannel;
|
|
639
|
+
loadingIds: Set<string>;
|
|
640
|
+
formatRelativeTime: (date: string) => string;
|
|
641
|
+
onUnpin: (messageId: string) => void;
|
|
642
|
+
}
|
|
643
|
+
interface StarredMessagesDrawerSlotProps {
|
|
644
|
+
isOpen: boolean;
|
|
645
|
+
onOpenChange: (open: boolean) => void;
|
|
646
|
+
starredMessages: any[];
|
|
647
|
+
loggedUserDetails: any;
|
|
648
|
+
conversationId: string | null;
|
|
649
|
+
activeChannel: IChannel;
|
|
650
|
+
loadingIds: Set<string>;
|
|
651
|
+
formatRelativeTime: (date: string) => string;
|
|
652
|
+
onUnstar: (messageId: string) => void;
|
|
653
|
+
}
|
|
654
|
+
interface MessageToolbarSlotProps {
|
|
655
|
+
isSender: boolean;
|
|
656
|
+
isRecent: boolean;
|
|
657
|
+
messageId: string;
|
|
658
|
+
isPinned?: boolean;
|
|
659
|
+
isStarred?: boolean;
|
|
660
|
+
isPinPending?: boolean;
|
|
661
|
+
isStarPending?: boolean;
|
|
662
|
+
isReactionOpen: boolean;
|
|
663
|
+
isDeleteOpen: boolean;
|
|
664
|
+
setIsReactionOpen: (val: boolean) => void;
|
|
665
|
+
setIsDeleteOpen: (val: boolean) => void;
|
|
666
|
+
onReply?: () => void;
|
|
667
|
+
onForward?: () => void;
|
|
668
|
+
onEdit: () => void;
|
|
669
|
+
onDelete: (deleteType: 'me' | 'everyone') => void;
|
|
670
|
+
onReactionClick: (emoji: any) => void;
|
|
671
|
+
onPinClick: () => void;
|
|
672
|
+
onStarClick: () => void;
|
|
673
|
+
canUnpin: boolean;
|
|
674
|
+
canEdit: boolean;
|
|
675
|
+
}
|
|
676
|
+
interface MessageStatusSlotProps {
|
|
677
|
+
status?: 'sent' | 'delivered' | 'read';
|
|
678
|
+
isPending?: boolean;
|
|
679
|
+
isGroup?: boolean;
|
|
680
|
+
className?: string;
|
|
681
|
+
}
|
|
682
|
+
interface MessageAttachmentsSlotProps {
|
|
683
|
+
attachments: IMessageAttachment[];
|
|
684
|
+
isDeletedForEveryone?: boolean;
|
|
685
|
+
}
|
|
686
|
+
interface MessageReactionsSlotProps {
|
|
687
|
+
groupedReactions: Record<string, number>;
|
|
688
|
+
reactions?: any[];
|
|
689
|
+
loggedUserId?: string;
|
|
690
|
+
isSender: boolean;
|
|
691
|
+
isDeletedForEveryone?: boolean;
|
|
692
|
+
onReactionClick: (emoji: string) => void;
|
|
693
|
+
}
|
|
694
|
+
interface MessageReplySnippetSlotProps {
|
|
695
|
+
replyTo: any;
|
|
696
|
+
isSender: boolean;
|
|
697
|
+
loggedUserDetails?: any;
|
|
698
|
+
allUsers?: any[];
|
|
699
|
+
}
|
|
700
|
+
interface ChatClassNames {
|
|
701
|
+
shell?: string;
|
|
702
|
+
mainPanel?: string;
|
|
703
|
+
sidebar?: string;
|
|
704
|
+
loggedUserDetails?: string;
|
|
705
|
+
channelList?: string;
|
|
706
|
+
channelListItem?: string;
|
|
707
|
+
channelListItemActive?: string;
|
|
708
|
+
channelHeader?: string;
|
|
709
|
+
headerLeft?: string;
|
|
710
|
+
headerRight?: string;
|
|
711
|
+
headerCallActions?: string;
|
|
712
|
+
phoneCallButton?: string;
|
|
713
|
+
videoCallButton?: string;
|
|
714
|
+
messageList?: string;
|
|
715
|
+
messageItem?: string;
|
|
716
|
+
messageBubble?: string;
|
|
717
|
+
messageBubbleSender?: string;
|
|
718
|
+
messageBubbleReceiver?: string;
|
|
719
|
+
messageInput?: string;
|
|
720
|
+
messageInputTextarea?: string;
|
|
721
|
+
avatar?: string;
|
|
722
|
+
avatarFallback?: string;
|
|
723
|
+
dateDivider?: string;
|
|
724
|
+
emptyState?: string;
|
|
725
|
+
forwardModal?: string;
|
|
726
|
+
chatPanelAlerts?: string;
|
|
727
|
+
drawer?: string;
|
|
728
|
+
drawerContent?: string;
|
|
729
|
+
searchOverlay?: string;
|
|
730
|
+
}
|
|
731
|
+
interface ChatComponents {
|
|
732
|
+
/** Case 1: replace the entire chat UI shell */
|
|
733
|
+
ChatLayout?: React__default.ComponentType<ChatLayoutSlotProps>;
|
|
734
|
+
LoggedUserDetails?: React__default.ComponentType<LoggedUserDetailsSlotProps>;
|
|
735
|
+
ChannelList?: React__default.ComponentType<ChannelListSlotProps>;
|
|
736
|
+
ChannelListItem?: React__default.ComponentType<ChannelListItemSlotProps>;
|
|
737
|
+
ChannelHeader?: React__default.ComponentType<ChannelHeaderSlotProps>;
|
|
738
|
+
HeaderLeftSide?: React__default.ComponentType<HeaderLeftSideSlotProps>;
|
|
739
|
+
HeaderRightSide?: React__default.ComponentType<HeaderRightSideSlotProps>;
|
|
740
|
+
HeaderCallActions?: React__default.ComponentType<HeaderCallActionsSlotProps>;
|
|
741
|
+
PhoneCallButton?: React__default.ComponentType<PhoneCallButtonSlotProps>;
|
|
742
|
+
VideoCallButton?: React__default.ComponentType<VideoCallButtonSlotProps>;
|
|
743
|
+
HeaderSearchOverlay?: React__default.ComponentType<HeaderSearchOverlaySlotProps>;
|
|
744
|
+
MessageList?: React__default.ComponentType<ActiveChannelMessagesSlotProps>;
|
|
745
|
+
MessageItem?: React__default.ComponentType<MessageItemSlotProps>;
|
|
746
|
+
MessageInput?: React__default.ComponentType<ChannelMessageBoxSlotProps>;
|
|
747
|
+
ForwardModal?: React__default.ComponentType<ForwardModalSlotProps>;
|
|
748
|
+
ChatPanelAlerts?: React__default.ComponentType<ChatPanelAlertsSlotProps>;
|
|
749
|
+
ChatActionModal?: React__default.ComponentType<ChatActionModalSlotProps>;
|
|
750
|
+
ChannelDetailsDrawer?: React__default.ComponentType<ChannelDetailsDrawerSlotProps>;
|
|
751
|
+
MembersDrawer?: React__default.ComponentType<MembersDrawerSlotProps>;
|
|
752
|
+
AdminsDrawer?: React__default.ComponentType<AdminsDrawerSlotProps>;
|
|
753
|
+
PermissionDrawer?: React__default.ComponentType<PermissionDrawerSlotProps>;
|
|
754
|
+
AttachmentsDrawer?: React__default.ComponentType<AttachmentsDrawerSlotProps>;
|
|
755
|
+
PinnedMessagesDrawer?: React__default.ComponentType<PinnedMessagesDrawerSlotProps>;
|
|
756
|
+
StarredMessagesDrawer?: React__default.ComponentType<StarredMessagesDrawerSlotProps>;
|
|
757
|
+
Avatar?: React__default.ComponentType<AvatarSlotProps>;
|
|
758
|
+
MessageToolbar?: React__default.ComponentType<MessageToolbarSlotProps>;
|
|
759
|
+
MessageStatus?: React__default.ComponentType<MessageStatusSlotProps>;
|
|
760
|
+
MessageAttachments?: React__default.ComponentType<MessageAttachmentsSlotProps>;
|
|
761
|
+
MessageReactions?: React__default.ComponentType<MessageReactionsSlotProps>;
|
|
762
|
+
MessageReplySnippet?: React__default.ComponentType<MessageReplySnippetSlotProps>;
|
|
763
|
+
ChatThemeToggle?: React__default.ComponentType<{
|
|
764
|
+
className?: string;
|
|
765
|
+
}>;
|
|
766
|
+
ChatDateTimeSettings?: React__default.ComponentType<Record<string, never>>;
|
|
767
|
+
ChatSocketStatus?: React__default.ComponentType<{
|
|
768
|
+
className?: string;
|
|
769
|
+
}>;
|
|
770
|
+
}
|
|
771
|
+
interface ChatCustomizationConfig {
|
|
772
|
+
components?: ChatComponents;
|
|
773
|
+
classNames?: ChatClassNames;
|
|
774
|
+
features?: ChatFeatures;
|
|
775
|
+
}
|
|
776
|
+
declare const defaultChatClassNames: ChatClassNames;
|
|
777
|
+
declare const defaultChatComponents: ChatComponents;
|
|
778
|
+
declare const mergeChatCustomization: (config?: ChatCustomizationConfig) => {
|
|
779
|
+
components: ChatComponents;
|
|
780
|
+
classNames: ChatClassNames;
|
|
781
|
+
features: ChatFeatures;
|
|
782
|
+
};
|
|
783
|
+
|
|
784
|
+
interface UIConfig extends ChatCustomizationConfig {
|
|
785
|
+
showSidebarAvatar?: boolean;
|
|
786
|
+
sidebarAvatarColor?: string;
|
|
787
|
+
showChannelDetails?: boolean;
|
|
788
|
+
messageDateFormat?: (date: string) => string;
|
|
789
|
+
}
|
|
790
|
+
interface ChatContextValue {
|
|
791
|
+
onSendMessage?: (content: string, attachments: any[]) => void;
|
|
792
|
+
client?: any;
|
|
793
|
+
theme?: string;
|
|
794
|
+
uiConfig: UIConfig;
|
|
795
|
+
themeColor: string;
|
|
796
|
+
channelsData?: IChannel[];
|
|
797
|
+
messagesData?: Record<string, IMessage[]>;
|
|
798
|
+
}
|
|
799
|
+
declare const useChatContext: () => ChatContextValue;
|
|
800
|
+
interface ChatProps {
|
|
801
|
+
children: React__default.ReactNode;
|
|
802
|
+
onSendMessage?: (content: string, attachments: any[]) => void;
|
|
803
|
+
client?: {
|
|
804
|
+
id: string;
|
|
805
|
+
};
|
|
806
|
+
theme?: string;
|
|
807
|
+
uiConfig?: UIConfig;
|
|
808
|
+
themeColor?: string;
|
|
809
|
+
accessToken?: string;
|
|
810
|
+
loggedUserDetails?: any;
|
|
811
|
+
apiUrl: string;
|
|
812
|
+
socketUrl?: string;
|
|
813
|
+
channelsData?: IChannel[];
|
|
814
|
+
messagesData?: Record<string, IMessage[]>;
|
|
815
|
+
onMessageReceived?: (message: any) => void;
|
|
816
|
+
onSocketConnected?: (socketId: string) => void;
|
|
817
|
+
onSocketError?: (error: string) => void;
|
|
818
|
+
}
|
|
819
|
+
declare const Chat: ({ children, onSendMessage, client, theme, uiConfig, themeColor, accessToken, loggedUserDetails, apiUrl, socketUrl, channelsData, messagesData, onMessageReceived, onSocketConnected, onSocketError }: ChatProps) => React__default.JSX.Element;
|
|
820
|
+
|
|
821
|
+
type ChatColorMode = 'light' | 'dark';
|
|
822
|
+
|
|
823
|
+
interface ChatThemeContextValue {
|
|
824
|
+
colorMode: ChatColorMode;
|
|
825
|
+
isDark: boolean;
|
|
826
|
+
isThemeTransitionReady: boolean;
|
|
827
|
+
themeColor: string;
|
|
828
|
+
themeStyles: React__default.CSSProperties;
|
|
829
|
+
scopeClassName: string;
|
|
830
|
+
setColorMode: (mode: ChatColorMode) => void;
|
|
831
|
+
toggleColorMode: () => void;
|
|
832
|
+
showColorModeToggle: boolean;
|
|
833
|
+
}
|
|
834
|
+
interface ChatThemeProviderProps {
|
|
835
|
+
children: React__default.ReactNode;
|
|
836
|
+
/** Brand color — pass from host project, same as npm package usage */
|
|
837
|
+
themeColor: string;
|
|
838
|
+
/** Optional controlled light/dark — omit to use built-in toggle (default: light) */
|
|
839
|
+
colorMode?: ChatColorMode;
|
|
840
|
+
/** Default light/dark when uncontrolled. Defaults to `light`. */
|
|
841
|
+
defaultColorMode?: ChatColorMode;
|
|
842
|
+
onColorModeChange?: (mode: ChatColorMode) => void;
|
|
843
|
+
showColorModeToggle?: boolean;
|
|
844
|
+
}
|
|
845
|
+
declare const ChatThemeProvider: ({ children, themeColor, colorMode, defaultColorMode, onColorModeChange, showColorModeToggle, }: ChatThemeProviderProps) => React__default.JSX.Element;
|
|
846
|
+
declare const useChatTheme: () => ChatThemeContextValue;
|
|
847
|
+
|
|
848
|
+
interface ChatDateTimePreferences {
|
|
849
|
+
/** BCP 47 locale, e.g. "en-US", "en-GB". Defaults to browser locale. */
|
|
850
|
+
locale?: string;
|
|
851
|
+
/** IANA timezone, e.g. "America/New_York". Defaults to browser timezone. */
|
|
852
|
+
timeZone?: string;
|
|
853
|
+
/** `true` = 12-hour, `false` = 24-hour. Defaults to locale preference. */
|
|
854
|
+
hour12?: boolean;
|
|
855
|
+
}
|
|
856
|
+
declare function createChatDateTimeFormatters(prefs: ChatDateTimePreferences): {
|
|
857
|
+
prefs: ChatDateTimePreferences;
|
|
858
|
+
formatMessageTime: (input: Date | string | number) => string;
|
|
859
|
+
formatSidebarTime: (input: Date | string | number) => string;
|
|
860
|
+
formatDateDivider: (input: Date | string | number) => string;
|
|
861
|
+
formatShortDate: (input: Date | string | number) => string;
|
|
862
|
+
formatLongDate: (input: Date | string | number) => string;
|
|
863
|
+
formatSavedMessageDate: (dateStr?: string) => string;
|
|
864
|
+
};
|
|
865
|
+
type ChatDateTimeFormatters = ReturnType<typeof createChatDateTimeFormatters>;
|
|
866
|
+
|
|
867
|
+
type ChatViewportHeight = "full" | "screen" | "auto" | (string & {});
|
|
868
|
+
type ChatViewportProps = {
|
|
869
|
+
children: React__default.ReactNode;
|
|
870
|
+
className?: string;
|
|
871
|
+
/**
|
|
872
|
+
* Height strategy for the chat root.
|
|
873
|
+
* - `full` (default): fill parent (`h-full`) — parent must have a bounded height
|
|
874
|
+
* - `screen`: full viewport (`h-dvh`)
|
|
875
|
+
* - `auto`: no height class — use with `className` / `style.height`
|
|
876
|
+
* - any CSS length: e.g. `calc(100dvh - 4rem)` for admin shells with fixed header
|
|
877
|
+
*/
|
|
878
|
+
height?: ChatViewportHeight;
|
|
879
|
+
style?: React__default.CSSProperties;
|
|
880
|
+
};
|
|
881
|
+
/** Bounded root wrapper — required for scroll + input to stay inside the chat panel */
|
|
882
|
+
declare function ChatViewport({ children, className, height, style, }: ChatViewportProps): React__default.JSX.Element;
|
|
883
|
+
|
|
884
|
+
interface ChatMainProps {
|
|
885
|
+
clientId: string;
|
|
886
|
+
loggedUserDetails: any;
|
|
887
|
+
accessToken: string;
|
|
888
|
+
apiUrl: string;
|
|
889
|
+
socketUrl?: string;
|
|
890
|
+
themeColor?: string;
|
|
891
|
+
theme?: string;
|
|
892
|
+
uiConfig?: UIConfig;
|
|
893
|
+
/** Replace any built-in component with your own */
|
|
894
|
+
components?: ChatComponents;
|
|
895
|
+
/** Override classNames per UI region */
|
|
896
|
+
classNames?: ChatClassNames;
|
|
897
|
+
/** Phone/video call and other feature callbacks */
|
|
898
|
+
features?: ChatFeatures;
|
|
899
|
+
layout?: ChatLayoutConfig;
|
|
900
|
+
colorMode?: ChatColorMode;
|
|
901
|
+
defaultColorMode?: ChatColorMode;
|
|
902
|
+
onColorModeChange?: (mode: ChatColorMode) => void;
|
|
903
|
+
showColorModeToggle?: boolean;
|
|
904
|
+
locale?: string;
|
|
905
|
+
timeZone?: string;
|
|
906
|
+
hour12?: boolean;
|
|
907
|
+
defaultLocale?: string;
|
|
908
|
+
defaultTimeZone?: string;
|
|
909
|
+
defaultHour12?: boolean;
|
|
910
|
+
onDateTimePreferencesChange?: (prefs: ChatDateTimePreferences) => void;
|
|
911
|
+
showDateTimeSettings?: boolean;
|
|
912
|
+
error?: string | null;
|
|
913
|
+
info?: string | null;
|
|
914
|
+
onErrorDismiss?: () => void;
|
|
915
|
+
onInfoDismiss?: () => void;
|
|
916
|
+
/** Outer viewport height — default `full` (parent must set height). Use `screen` or `calc(100dvh - 4rem)` in admin apps */
|
|
917
|
+
viewportHeight?: ChatViewportHeight;
|
|
918
|
+
/** Extra classes on the viewport wrapper */
|
|
919
|
+
viewportClassName?: string;
|
|
920
|
+
}
|
|
921
|
+
declare const ChatMain: ({ clientId, loggedUserDetails, accessToken, apiUrl, socketUrl, themeColor, theme, uiConfig, components, classNames, features, layout, colorMode, defaultColorMode, onColorModeChange, showColorModeToggle, locale, timeZone, hour12, defaultLocale, defaultTimeZone, defaultHour12, onDateTimePreferencesChange, showDateTimeSettings, error, info, onErrorDismiss, onInfoDismiss, viewportHeight, viewportClassName, }: ChatMainProps) => React__default.JSX.Element;
|
|
922
|
+
|
|
416
923
|
declare const useStore: zustand.UseBoundStore<Omit<zustand.StoreApi<AppStoreState>, "setState" | "persist"> & {
|
|
417
924
|
setState(partial: AppStoreState | Partial<AppStoreState> | ((state: AppStoreState) => AppStoreState | Partial<AppStoreState>), replace?: false | undefined): unknown;
|
|
418
925
|
setState(state: AppStoreState | ((state: AppStoreState) => AppStoreState), replace: true): unknown;
|
|
@@ -443,7 +950,10 @@ interface ISocketConfig {
|
|
|
443
950
|
url: string;
|
|
444
951
|
options: Partial<ManagerOptions & SocketOptions>;
|
|
445
952
|
}
|
|
446
|
-
declare const getSocketConfig: (accessToken: string, tenantId: string,
|
|
953
|
+
declare const getSocketConfig: (accessToken: string, tenantId: string, options?: {
|
|
954
|
+
apiUrl?: string;
|
|
955
|
+
socketUrl?: string;
|
|
956
|
+
}) => ISocketConfig;
|
|
447
957
|
|
|
448
958
|
declare class SocketService {
|
|
449
959
|
private socket;
|
|
@@ -459,12 +969,14 @@ declare class SocketService {
|
|
|
459
969
|
messageId: string;
|
|
460
970
|
sender: string;
|
|
461
971
|
receiver: string;
|
|
972
|
+
attachmentId?: string;
|
|
462
973
|
}): void;
|
|
463
974
|
emitDmDelete(payload: {
|
|
464
975
|
messageId: string;
|
|
465
976
|
sender: string;
|
|
466
977
|
receiver: string;
|
|
467
|
-
deleteType:
|
|
978
|
+
deleteType: 'me' | 'everyone';
|
|
979
|
+
attachmentId?: string;
|
|
468
980
|
}): void;
|
|
469
981
|
emitDmClearChat(payload: {
|
|
470
982
|
conversationId: string;
|
|
@@ -526,6 +1038,9 @@ declare class SocketService {
|
|
|
526
1038
|
messageId: string;
|
|
527
1039
|
sender: string;
|
|
528
1040
|
targetConversationIds: string[];
|
|
1041
|
+
receiver?: string;
|
|
1042
|
+
conversationId?: string;
|
|
1043
|
+
attachmentId?: string;
|
|
529
1044
|
}): void;
|
|
530
1045
|
emitGroupJoin(payload: {
|
|
531
1046
|
conversationId: string;
|
|
@@ -550,7 +1065,8 @@ declare class SocketService {
|
|
|
550
1065
|
emitGroupDelete(payload: {
|
|
551
1066
|
messageId: string;
|
|
552
1067
|
sender: string;
|
|
553
|
-
deleteType:
|
|
1068
|
+
deleteType: 'me' | 'everyone';
|
|
1069
|
+
attachmentId?: string;
|
|
554
1070
|
}): void;
|
|
555
1071
|
emitGroupPin(payload: {
|
|
556
1072
|
conversationId: string;
|
|
@@ -578,6 +1094,9 @@ declare class SocketService {
|
|
|
578
1094
|
messageId: string;
|
|
579
1095
|
sender: string;
|
|
580
1096
|
targetConversationIds: string[];
|
|
1097
|
+
conversationId?: string;
|
|
1098
|
+
sourceConversationId?: string;
|
|
1099
|
+
attachmentId?: string;
|
|
581
1100
|
}): void;
|
|
582
1101
|
emitConversationUpdate(payload: {
|
|
583
1102
|
conversationId: string;
|
|
@@ -591,8 +1110,8 @@ declare class SocketService {
|
|
|
591
1110
|
declare const socketService: SocketService;
|
|
592
1111
|
|
|
593
1112
|
declare const Channel: ({ children }: {
|
|
594
|
-
children:
|
|
595
|
-
}) =>
|
|
1113
|
+
children: React__default.ReactNode;
|
|
1114
|
+
}) => React__default.JSX.Element;
|
|
596
1115
|
|
|
597
1116
|
interface ChannelListProps {
|
|
598
1117
|
activeChannel: IChannel | null;
|
|
@@ -600,14 +1119,17 @@ interface ChannelListProps {
|
|
|
600
1119
|
onNewChatClick?: () => void;
|
|
601
1120
|
debouncedSearch?: string;
|
|
602
1121
|
}
|
|
603
|
-
|
|
1122
|
+
|
|
1123
|
+
declare const ChannelListView: ({ activeChannel, onChannelSelect, onNewChatClick, debouncedSearch }: ChannelListProps) => React.JSX.Element;
|
|
604
1124
|
|
|
605
1125
|
interface ChannelHeaderProps {
|
|
606
1126
|
activeChannel: IChannel | null;
|
|
607
1127
|
conversationId: string | null;
|
|
608
1128
|
onBack?: () => void;
|
|
1129
|
+
onActiveChannelPatch?: (patch: Partial<IChannel>) => void;
|
|
609
1130
|
}
|
|
610
|
-
|
|
1131
|
+
|
|
1132
|
+
declare const ChannelHeaderView: (props: ChannelHeaderProps) => React.JSX.Element | null;
|
|
611
1133
|
|
|
612
1134
|
interface ActiveChannelMessagesProps {
|
|
613
1135
|
activeChannel: IChannel | null;
|
|
@@ -618,72 +1140,69 @@ interface ActiveChannelMessagesProps {
|
|
|
618
1140
|
conversationId?: string | null;
|
|
619
1141
|
onReply?: (message: IMessage) => void;
|
|
620
1142
|
onForward?: (message: IMessage) => void;
|
|
1143
|
+
onForwardItems?: (items: ChatForwardItem[]) => void;
|
|
1144
|
+
onSelectionModeChange?: (active: boolean) => void;
|
|
621
1145
|
conversationInfo: IConversationInfo | null;
|
|
622
1146
|
}
|
|
623
|
-
|
|
1147
|
+
|
|
1148
|
+
declare const ActiveChannelMessagesView: (props: ActiveChannelMessagesProps) => React.JSX.Element;
|
|
624
1149
|
|
|
625
1150
|
interface ChannelMessageBoxProps {
|
|
626
1151
|
activeChannel: IChannel | null;
|
|
627
1152
|
conversationId: string | null;
|
|
628
|
-
onSendMessage?: (content: string, attachments:
|
|
1153
|
+
onSendMessage?: (content: string, attachments: ISocketMessageAttachment[], replyTo?: IMessage | null) => void;
|
|
629
1154
|
replyTo?: IMessage | null;
|
|
630
1155
|
onCancelReply?: () => void;
|
|
1156
|
+
onActiveChannelPatch?: (patch: Partial<IChannel>) => void;
|
|
631
1157
|
}
|
|
632
|
-
|
|
1158
|
+
|
|
1159
|
+
declare const ChannelMessageBoxView: (props: ChannelMessageBoxProps) => React__default.JSX.Element | null;
|
|
633
1160
|
|
|
634
1161
|
interface LoggedUserDetailsProps {
|
|
635
|
-
loggedUserDetails
|
|
1162
|
+
loggedUserDetails: any;
|
|
636
1163
|
onUserSelect?: (channel: IChannel) => void;
|
|
637
1164
|
isCreateModalOpen?: boolean;
|
|
638
1165
|
setIsCreateModalOpen?: (open: boolean) => void;
|
|
639
1166
|
searchQuery?: string;
|
|
640
1167
|
setSearchQuery?: (val: string) => void;
|
|
641
|
-
themeColor?: string;
|
|
642
1168
|
}
|
|
643
|
-
declare const LoggedUserDetails: ({ loggedUserDetails
|
|
1169
|
+
declare const LoggedUserDetails: ({ loggedUserDetails, onUserSelect, isCreateModalOpen, setIsCreateModalOpen, searchQuery, setSearchQuery, }: LoggedUserDetailsProps) => React.JSX.Element;
|
|
644
1170
|
|
|
645
1171
|
interface ForwardModalProps {
|
|
646
1172
|
isOpen: boolean;
|
|
647
1173
|
onClose: () => void;
|
|
648
|
-
|
|
1174
|
+
items: ChatForwardItem[];
|
|
649
1175
|
onForwardComplete: (channel: IChannel) => void;
|
|
650
1176
|
}
|
|
651
|
-
declare const ForwardModal: ({ isOpen, onClose, message, onForwardComplete }: ForwardModalProps) => React.JSX.Element | null;
|
|
652
1177
|
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
/** Passed to LoggedUserDetails */
|
|
657
|
-
loggedUserDetails?: any;
|
|
658
|
-
themeColor?: string;
|
|
659
|
-
className?: string;
|
|
660
|
-
shellClassName?: string;
|
|
661
|
-
}
|
|
1178
|
+
declare function ForwardModalView(props: ForwardModalProps): React.JSX.Element | null;
|
|
1179
|
+
|
|
1180
|
+
type ChatLayoutProps = ChatLayoutSlotProps;
|
|
662
1181
|
/**
|
|
663
|
-
*
|
|
664
|
-
*
|
|
665
|
-
*
|
|
666
|
-
* `<ChatLayout />`
|
|
667
|
-
*
|
|
668
|
-
* @example Messages only (no sidebar, header, or input)
|
|
669
|
-
* `<ChatLayout layout={{ sidebar: false, header: false, input: false }} />`
|
|
670
|
-
*
|
|
671
|
-
* @example Custom — import pieces individually instead:
|
|
672
|
-
* `import { Channel, MessageList } from '@realtimexsco/live-chat'`
|
|
1182
|
+
* Chat layout entry — renders `components.ChatLayout` when provided,
|
|
1183
|
+
* otherwise the package default. Custom full-UI layouts should use
|
|
1184
|
+
* `useChatController()` inside their component.
|
|
673
1185
|
*/
|
|
674
|
-
declare const ChatLayout: (
|
|
1186
|
+
declare const ChatLayout: (props: ChatLayoutProps) => React__default.JSX.Element;
|
|
1187
|
+
|
|
1188
|
+
type DefaultChatLayoutProps = ChatLayoutSlotProps;
|
|
1189
|
+
declare const DefaultChatLayout: ({ layout, loggedUserDetails: loggedUserDetailsProp, className, shellClassName, }: DefaultChatLayoutProps) => React__default.JSX.Element;
|
|
1190
|
+
|
|
1191
|
+
declare function buildReplyTarget(message: IMessage, attachmentId?: string): IMessage;
|
|
1192
|
+
declare function buildForwardItem(message: IMessage, attachmentId?: string): ChatForwardItem;
|
|
675
1193
|
|
|
676
1194
|
interface ChatControllerState {
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
1195
|
+
activeChannel: IChannel | null;
|
|
1196
|
+
activeConversationId: string | null;
|
|
1197
|
+
replyToMessage: IMessage | null;
|
|
1198
|
+
forwardItems: ChatForwardItem[];
|
|
1199
|
+
isMessageSelectionMode: boolean;
|
|
680
1200
|
searchQuery: string;
|
|
681
1201
|
debouncedSearch: string;
|
|
682
1202
|
isCreateModalOpen: boolean;
|
|
683
1203
|
}
|
|
684
1204
|
declare const useChatController: () => {
|
|
685
1205
|
activeChannel: IChannel | null;
|
|
686
|
-
setActiveChannel: (channel: IChannel | null) => void;
|
|
687
1206
|
conversationId: string | null;
|
|
688
1207
|
rateLimitResetAt: number;
|
|
689
1208
|
isFetchingMessages: boolean;
|
|
@@ -694,12 +1213,28 @@ declare const useChatController: () => {
|
|
|
694
1213
|
state: ChatControllerState;
|
|
695
1214
|
updateState: (updates: Partial<ChatControllerState>) => void;
|
|
696
1215
|
handleChannelSelect: (channel: IChannel) => void;
|
|
697
|
-
handleSendMessage: (content: string, attachments:
|
|
1216
|
+
handleSendMessage: (content: string, attachments: ISocketMessageAttachment[], replyTo?: IMessage | null) => void;
|
|
1217
|
+
handleSelectionModeChange: (active: boolean) => void;
|
|
1218
|
+
handleActiveChannelPatch: (patch: Partial<IChannel>) => void;
|
|
1219
|
+
buildReplyTarget: typeof buildReplyTarget;
|
|
1220
|
+
buildForwardItem: typeof buildForwardItem;
|
|
1221
|
+
setActiveChannel: (channel: IChannel | null) => void;
|
|
698
1222
|
};
|
|
699
1223
|
|
|
700
1224
|
declare const setChatClientId: (id: string) => void;
|
|
701
1225
|
declare const setChatAccessToken: (token: string) => void;
|
|
702
1226
|
declare const setChatBaseURL: (url: string) => void;
|
|
1227
|
+
declare const getChatBaseUrl: () => string;
|
|
1228
|
+
declare const setChatSocketUrl: (url: string) => void;
|
|
1229
|
+
declare const getChatSocketUrl: () => string;
|
|
1230
|
+
|
|
1231
|
+
/** Normalize API base URL passed by the host app (must end with /api/v1). */
|
|
1232
|
+
declare function resolveApiUrl(apiUrl?: string): string;
|
|
1233
|
+
/**
|
|
1234
|
+
* Socket.io connects to the host origin with path `/connection`.
|
|
1235
|
+
* Prefer explicit `socketUrl`; otherwise derive from `apiUrl` by stripping `/api/v1`.
|
|
1236
|
+
*/
|
|
1237
|
+
declare function resolveSocketUrl(socketUrl?: string, apiUrl?: string): string;
|
|
703
1238
|
|
|
704
1239
|
type IDMMessage = {
|
|
705
1240
|
sender: string;
|
|
@@ -767,4 +1302,114 @@ declare function uniqueList<T extends Record<string, any>>(list: T[], key: keyof
|
|
|
767
1302
|
declare const capitalizeFirst: (str: string) => string;
|
|
768
1303
|
declare const getFirstAndLastNameOneCharacter: (name: string) => string;
|
|
769
1304
|
|
|
770
|
-
|
|
1305
|
+
interface ChatCustomizationContextValue {
|
|
1306
|
+
components: ChatComponents;
|
|
1307
|
+
classNames: ChatClassNames;
|
|
1308
|
+
features: ChatFeatures;
|
|
1309
|
+
slotClassName: (key: keyof ChatClassNames, defaultClassName?: string) => string | undefined;
|
|
1310
|
+
resolveComponent: <P extends object>(slot: keyof ChatComponents, DefaultComponent: React__default.ComponentType<P>) => React__default.ComponentType<P>;
|
|
1311
|
+
}
|
|
1312
|
+
interface ChatCustomizationProviderProps {
|
|
1313
|
+
children: React__default.ReactNode;
|
|
1314
|
+
customization?: ChatCustomizationConfig;
|
|
1315
|
+
}
|
|
1316
|
+
declare const ChatCustomizationProvider: ({ children, customization, }: ChatCustomizationProviderProps) => React__default.JSX.Element;
|
|
1317
|
+
declare const useChatCustomization: () => ChatCustomizationContextValue;
|
|
1318
|
+
declare const useChatCustomizationOptional: () => ChatCustomizationContextValue;
|
|
1319
|
+
declare const useChatFeatures: () => ChatFeatures;
|
|
1320
|
+
declare const useChatFeaturesOptional: () => ChatFeatures;
|
|
1321
|
+
|
|
1322
|
+
declare const DefaultChatAvatar: ({ src, alt, name, fallback, size, showOnline, isOnline, className, fallbackClassName, }: AvatarSlotProps) => React__default.JSX.Element;
|
|
1323
|
+
declare const ChatAvatar: (props: AvatarSlotProps) => React__default.JSX.Element;
|
|
1324
|
+
|
|
1325
|
+
declare const DefaultChannelListItem: ({ channel, isActive, onSelect, }: ChannelListItemSlotProps) => React__default.JSX.Element;
|
|
1326
|
+
declare const ChannelListItem: (props: ChannelListItemSlotProps) => React__default.JSX.Element;
|
|
1327
|
+
|
|
1328
|
+
declare const HeaderCallActions: (props: HeaderCallActionsSlotProps) => React__default.JSX.Element | null;
|
|
1329
|
+
|
|
1330
|
+
/**
|
|
1331
|
+
* Built-in components for every `ChatComponents` slot.
|
|
1332
|
+
* Use as fallback when building custom wrappers: `withMyTheme(packageDefaultComponents.MessageItem)`.
|
|
1333
|
+
*/
|
|
1334
|
+
declare const packageDefaultComponents: ChatComponents;
|
|
1335
|
+
|
|
1336
|
+
interface MessageItemProps {
|
|
1337
|
+
isSender: boolean;
|
|
1338
|
+
message: string;
|
|
1339
|
+
createdAt: string;
|
|
1340
|
+
attachments?: IMessageAttachment[];
|
|
1341
|
+
messageId?: string;
|
|
1342
|
+
receiver?: string;
|
|
1343
|
+
isEdited?: boolean;
|
|
1344
|
+
isDeletedForEveryone?: boolean;
|
|
1345
|
+
reactions?: any[];
|
|
1346
|
+
conversationId?: string;
|
|
1347
|
+
onReply?: () => void;
|
|
1348
|
+
onForward?: () => void;
|
|
1349
|
+
onReplyClick?: (messageId: string) => void;
|
|
1350
|
+
replyTo?: any;
|
|
1351
|
+
isPinned?: boolean;
|
|
1352
|
+
isStarred?: boolean;
|
|
1353
|
+
isForwarded?: boolean;
|
|
1354
|
+
status?: "sent" | "delivered" | "read";
|
|
1355
|
+
isGroup?: boolean;
|
|
1356
|
+
isSystemMessage?: boolean;
|
|
1357
|
+
conversationInfo?: any;
|
|
1358
|
+
isHighlighted?: boolean;
|
|
1359
|
+
senderName?: string;
|
|
1360
|
+
senderImage?: string;
|
|
1361
|
+
showSenderName?: boolean;
|
|
1362
|
+
showSenderLabel?: boolean;
|
|
1363
|
+
senderAvatarImage?: string;
|
|
1364
|
+
isGroupedWithPrev?: boolean;
|
|
1365
|
+
isGroupedWithNext?: boolean;
|
|
1366
|
+
selectionMode?: boolean;
|
|
1367
|
+
selectedKeys?: Set<string>;
|
|
1368
|
+
onToggleSelect?: () => void;
|
|
1369
|
+
onToggleAttachmentSelect?: (attachmentId: string) => void;
|
|
1370
|
+
onEnterSelectionMode?: (attachmentId?: string) => void;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
declare function MessageItemView(props: MessageItemProps): React.JSX.Element;
|
|
1374
|
+
|
|
1375
|
+
interface ChatDateTimePreferencesChange {
|
|
1376
|
+
locale?: string;
|
|
1377
|
+
timeZone?: string;
|
|
1378
|
+
hour12?: boolean;
|
|
1379
|
+
}
|
|
1380
|
+
interface ChatLocaleContextValue extends ChatDateTimeFormatters {
|
|
1381
|
+
locale?: string;
|
|
1382
|
+
timeZone?: string;
|
|
1383
|
+
hour12: boolean;
|
|
1384
|
+
setLocale: (locale?: string) => void;
|
|
1385
|
+
setTimeZone: (timeZone?: string) => void;
|
|
1386
|
+
setHour12: (hour12: boolean) => void;
|
|
1387
|
+
showDateTimeSettings: boolean;
|
|
1388
|
+
}
|
|
1389
|
+
interface ChatLocaleProviderProps {
|
|
1390
|
+
children: React__default.ReactNode;
|
|
1391
|
+
locale?: string;
|
|
1392
|
+
timeZone?: string;
|
|
1393
|
+
hour12?: boolean;
|
|
1394
|
+
defaultLocale?: string;
|
|
1395
|
+
defaultTimeZone?: string;
|
|
1396
|
+
defaultHour12?: boolean;
|
|
1397
|
+
onDateTimePreferencesChange?: (prefs: ChatDateTimePreferencesChange) => void;
|
|
1398
|
+
showDateTimeSettings?: boolean;
|
|
1399
|
+
}
|
|
1400
|
+
declare const ChatLocaleProvider: ({ children, locale: controlledLocale, timeZone: controlledTimeZone, hour12: controlledHour12, defaultLocale, defaultTimeZone, defaultHour12, onDateTimePreferencesChange, showDateTimeSettings, }: ChatLocaleProviderProps) => React__default.JSX.Element;
|
|
1401
|
+
declare const useChatLocale: () => ChatLocaleContextValue;
|
|
1402
|
+
|
|
1403
|
+
interface ChatAlertsContextValue {
|
|
1404
|
+
error?: string | null;
|
|
1405
|
+
info?: string | null;
|
|
1406
|
+
onDismissError?: () => void;
|
|
1407
|
+
onDismissInfo?: () => void;
|
|
1408
|
+
}
|
|
1409
|
+
declare function ChatAlertsProvider({ children, value, }: {
|
|
1410
|
+
children: ReactNode;
|
|
1411
|
+
value: ChatAlertsContextValue;
|
|
1412
|
+
}): React.JSX.Element;
|
|
1413
|
+
declare function useChatAlerts(): ChatAlertsContextValue;
|
|
1414
|
+
|
|
1415
|
+
export { type ActiveChannelMessagesSlotProps, type AdminsDrawerSlotProps, type AttachmentsDrawerSlotProps, type AvatarSlotProps, Channel, type ChannelDetailsDrawerSlotProps, ChannelHeaderView as ChannelHeader, type ChannelHeaderSlotProps, ChannelListView as ChannelList, ChannelListItem, type ChannelListItemSlotProps, type ChannelListSlotProps, type ChannelMessageBoxSlotProps, Chat, type ChatActionModalSlotProps, ChatAlertsProvider, ChatAvatar, type ChatCallContext, type ChatClassNames, type ChatColorMode, type ChatComponents, type ChatCustomizationConfig, ChatCustomizationProvider, type ChatDateTimePreferences, type ChatFeatures, ChatLayout, type ChatLayoutConfig, type ChatLayoutSlotProps, ChatLocaleProvider, ChatMain, type ChatPanelAlertsSlotProps, ChatThemeProvider, ChatViewport, type ChatViewportHeight, DefaultChannelListItem, DefaultChatAvatar, DefaultChatLayout, ForwardModalView as ForwardModal, type ForwardModalSlotProps, HeaderCallActions, type HeaderCallActionsSlotProps, type HeaderLeftSideSlotProps, type HeaderRightSideSlotProps, type HeaderSearchOverlaySlotProps, type IAttachment, type IChannel, type IDMDelete, type IDMEditMessage, type IDMForward, type IDMMessage, type IDMPin, type IDMReaction, type IDMRead, type IDMStar, type IDMTyping, type IDMUnstar, type IMessage, type ISocketConfig, LoggedUserDetails, type LoggedUserDetailsSlotProps, type MembersDrawerSlotProps, type MessageAttachmentsSlotProps, ChannelMessageBoxView as MessageInput, MessageItemView as MessageItem, type MessageItemSlotProps, ActiveChannelMessagesView as MessageList, type MessageReactionsSlotProps, type MessageReplySnippetSlotProps, type MessageStatusSlotProps, type MessageToolbarSlotProps, type PermissionDrawerSlotProps, type PhoneCallButtonSlotProps, type PinnedMessagesDrawerSlotProps, type StarredMessagesDrawerSlotProps, type UIConfig, type VideoCallButtonSlotProps, capitalizeFirst, ChatMain as default, defaultChatClassNames, defaultChatComponents, defaultChatFeatures, defaultChatLayoutConfig, downloadFile, getChatBaseUrl, getChatSocketUrl, getFirstAndLastNameOneCharacter, getResponsiveWidth, getSocketConfig, isEmpty, mergeChatCustomization, mergeChatLayoutConfig, packageDefaultComponents, resolveApiUrl, resolveSocketUrl, setChatAccessToken, setChatBaseURL, setChatClientId, setChatSocketUrl, showNotification, socketService, uniqueList, useChatAlerts, useChatContext, useChatController, useChatCustomization, useChatCustomizationOptional, useChatFeatures, useChatFeaturesOptional, useChatLocale, useStore as useChatStore, useChatTheme };
|