-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.d.ts
More file actions
383 lines (380 loc) · 12.4 KB
/
index.d.ts
File metadata and controls
383 lines (380 loc) · 12.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
import { CloseNotification, ShowNotification, ShowNotificationOptions } from '@toolpad/core';
import React$1 from 'react';
import { CSSProperties, ComponentType, ElementType, ReactElement, ReactNode, Ref } from 'react';
import { Primitive } from 'utility-types';
declare function Message$1({ message: messageRaw, reply, reaction, showTimeStamp, isReplyContext, isReplyMessage }: Props$3): import("react/jsx-runtime").JSX.Element;
declare function Message$2({ showTimeStamp, reply, reaction, className, children }: Props$5): import("react/jsx-runtime").JSX.Element;
declare function Root({ widgetProps, primaryColor, messageClientColor, messageClientTextColor, messageResponseColor, messageResponseTextColor, anchorBottom, anchorRight, anchorMobileBottom, anchorMobileRight, headerPaddingTop, headerPaddingBottom }: CProps$7): import("react/jsx-runtime").JSX.Element;
declare function Snippet({ message: messageRaw, reply, reaction, showTimeStamp, isReplyContext, isReplyMessage }: Props$4): import("react/jsx-runtime").JSX.Element;
export declare const Component: {
Message: typeof Message$1;
Snippet: typeof Snippet;
Custom: typeof Message$2;
};
export declare const MESSAGES_TYPES: {
TEXT: string;
FILES: string;
SNIPPET: {
LINK: string;
};
CUSTOM_COMPONENT: string;
};
export declare const MESSAGE_BOX_SCROLL_DURATION = 400;
export declare const MESSAGE_SENDER: {
CLIENT: string;
RESPONSE: string;
SYSTEM: string;
};
export declare const MessageContext: React$1.Context<MessageAPI>;
export declare const ref: <T extends object>(v: T) => StateRef<T>;
export declare const useSelector: <T>(selector: (state: Snapshot<GlobalState>) => T) => T;
export declare function addLinkSnippet(link: LinkParams, id?: string, props?: any): void;
export declare function addResponseMessage(text: string, { id, status, props }?: MessageOptions, overrides?: Partial<MessageTypes>): void;
export declare function addSystemMessage(text: string, { id, status, props }?: MessageOptions, overrides?: Partial<MessageTypes>): void;
export declare function addToggleChatListener(f: (s: boolean) => void): () => void;
export declare function addUserMessage(text: string, { id, status, props }?: MessageOptions, overrides?: Partial<MessageTypes>): void;
export declare function closeFullscreenPreview(): void;
export declare function closeNotification(key: string): void;
export declare function createComponentMessage(component: React$1.ComponentType, props: any, showAvatar: boolean, id?: string): CustomCompMessage;
export declare function createLinkSnippet(link: LinkParams, id?: string, props?: any): Link;
export declare function createNewMessage(text: string, sender: string, id?: string, status?: string, props?: any, overrides?: Partial<MessageTypes>): MessageTypes;
export declare function createQuickButton(button: {
label: string;
value: string | number;
}): QuickButtonTypes;
export declare function deleteMessages(count: number, id?: string): void;
export declare function dropMessages(): void;
export declare function hideAvatar(index: number): void;
export declare function hidePopup(): void;
export declare function hideSuggestions(): void;
export declare function isWidgetOpened(): boolean;
export declare function markAllMessagesRead(): void;
export declare function openFullscreenPreview(payload: ImageState): void;
export declare function renderCustomComponent(component: React$1.ComponentType, props: any, showAvatar: boolean, id?: string): void;
export declare function scrollToBottom(messagesDiv: HTMLDivElement | null): void;
export declare function setBadgeCount(count: number): void;
export declare function setContextMenu(id: string | null, pos?: Position | HTMLElement, data?: any): void;
export declare function setMessageReaction(id: string, reaction: string | null): boolean;
export declare function setMessageStatus(id: string, status: string, props?: any): boolean;
export declare function setMessages(messages: Message[]): void;
export declare function setNotification({ show, close }: NotificationState): void;
export declare function setPopupMessage(message: string | string[] | null): void;
export declare function setQuickButtons(buttons: Array<{
label: string;
value: string | number;
}>): void;
export declare function setReplyMessage(message: Message | null): void;
export declare function setResponseUser(user: ResponseUser): void;
export declare function setStatusLocale(locale: string): void;
export declare function setVoiceLocale(locale: string): void;
export declare function showNotification(message: React$1.ReactNode, options?: ShowNotificationOptions): string | null;
export declare function showPopup(component: React$1.FC, styles?: React$1.CSSProperties): void;
export declare function showSuggestions(right: Record<string, () => void>, bottom: Record<string, () => void>): void;
export declare function toggleChat(): void;
export declare function toggleInputDisabled(): void;
export declare function toggleMsgLoader(): void;
export interface BehaviorState {
showChat: boolean;
disabledInput: boolean;
messageLoader: boolean;
}
export interface ContextMenuState {
id: string;
position: StateRef<Position | HTMLElement>;
data?: any;
}
export interface CustomCompMessage extends BaseMessage {
props: any;
}
export interface FullscreenPreviewState extends ImageState {
visible?: boolean;
}
export interface GlobalState {
messages: MessagesState;
behavior: BehaviorState;
quickButtons: QuickButtonsState;
preview: FullscreenPreviewState;
popup: PopupState;
suggestions: SuggestionsState;
notification: NotificationState;
}
export interface ISenderRef {
onSelectEmoji: (event: any) => void;
}
export interface ImageState {
src: string;
alt?: string;
width: number;
height: number;
}
export interface Link extends BaseMessage {
title: string;
link: string;
target: string;
showPreview?: boolean;
}
export interface LinkParams {
link: string;
title: string;
target?: string;
}
export interface MessageButton {
icon: string;
label: string;
onClick?: () => void;
}
export interface MessageTypes extends BaseMessage {
text: string;
}
export interface MessagesState {
responseUser: ResponseUser | null;
messages: Message[];
badgeCount: number;
popupMessage: string | string[] | null;
statusLocale?: string;
voiceLocale?: string;
replyMessage: Message | null;
contextMenu: ContextMenuState | null;
}
export interface NotificationState {
show: ShowNotification | null;
close: CloseNotification | null;
}
export interface PopupState {
showPopup: boolean;
styles: React$1.CSSProperties;
component: StateRef<React$1.ElementType> | null;
}
export interface QuickButtonsState {
quickButtons: QuickButtonTypes[];
}
export interface ResizableProps {
heightOffset?: number;
widthOffset?: number;
}
export interface SuggestionsState {
showSuggestion: boolean;
right: Record<string, () => void>;
bottom: Record<string, () => void>;
}
export type AnyFunction = (...args: any[]) => any;
export type BaseMessage = {
type: string;
component: StateRef<React$1.ElementType>;
sender: string;
showAvatar: boolean;
profileAvatar?: string;
timestamp: Date;
status?: string;
unread: boolean;
customId?: string;
props?: any;
};
export type CProps = {
title?: string | React$1.ReactElement;
subtitle?: string;
showMenuButton?: boolean;
showCloseButton?: boolean;
titleAvatar?: string;
menus?: Array<{
icon: string;
title: string | React$1.ReactElement;
onClick?: () => void;
selects?: Array<{
icon?: string;
title: string | React$1.ReactElement;
onClick: () => void;
}>;
}>;
};
export type ContextMenuItem = "divider" | {
icon: string;
label: string;
onClick?: (data: any) => void;
};
export type CustomComponentProps = Props$5;
export type FileAddProps = {
onSelect?: (items: FileList) => void;
addFileRef?: React$1.MutableRefObject<() => void>;
showButton?: boolean;
multiple?: boolean;
allowImage?: boolean;
allowVideo?: boolean;
allowAny?: boolean;
};
export type Message = MessageTypes | Link | CustomCompMessage;
export type MessageAPI = Message & {
isShow: boolean;
hide(): void;
};
export type MessageOptions = {
id?: string;
status?: string;
props?: any;
};
export type Nullable<T> = T | null;
export type Position = {
x: number;
y: number;
};
export type Props = {
onQuickButtonClicked?: AnyFunction;
};
export type QuickButtonTypes = {
label: string;
value: string | number;
component: StateRef<React$1.ElementType>;
};
export type ResponseUser = {
avatar: string | string[];
name?: string;
message?: string;
online?: boolean;
};
export type Snapshot<T> = T extends StateRef<infer S> ? S : T extends SnapshotIgnore ? T : T extends Promise<unknown> ? Awaited<T> : T extends object ? {
readonly [K in keyof T]: Snapshot<T[K]>;
} : T;
export type SnapshotIgnore = Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | Error | RegExp | AnyFunction | Primitive;
export type StateRef<T> = T & {
$$valtioSnapshot: T;
};
type CProps$1 = {
onClick?: (text: string, next: () => void) => void;
};
type CProps$2 = {
showTimeStamp?: boolean;
reply?: boolean;
reaction?: boolean;
onReaction?: (mId: string, emoji: string | null) => boolean;
profileAvatar?: string;
profileClientAvatar?: string;
suggestionsProps?: CProps$1;
allowDropToUpload?: boolean;
onSelectFile?: (event: any) => void;
};
type CProps$3 = {
senderRef?: React$1.Ref<ISenderRef>;
placeholder?: string;
disabledInput?: boolean;
allowSend: boolean;
autofocus?: boolean;
sendMessage: (event: string) => void;
buttonAlt?: string;
onPressEmoji: (() => void) | null;
onPressFile: (() => void) | null;
onTextInputChange?: (event: any) => void;
onVoiceInputChange?: (text: string, isFinal: boolean) => void;
};
type CProps$4 = {
headerProps?: CProps;
messagesProps?: Omit<CProps$2, "reply" | "reaction">;
senderProps?: Omit<CProps$3, "sendMessage" | "onPressEmoji" | "onPressFile" | "disabledInput" | "allowSend">;
quickButtonsProps?: Props;
filePickerProps?: Omit<FileAddProps, "items" | "onSelectFile" | "addFileRef">;
className?: string;
sendMessage?: (data: {
text?: string;
files?: File[];
replyMessage?: Message | null;
}) => void;
resizable?: boolean;
resizableProps?: ResizableProps;
defaultSize?: {
width: number;
height: number;
};
onResize?: (w: number, h: number) => void;
emojis?: boolean;
files?: boolean;
reply?: boolean;
reaction?: boolean;
disabledInput?: boolean;
copyright?: string;
copyrightPosition?: string;
isShowCloseConfirmPopup?: boolean;
onCloseConfirmPopup?: () => void;
CloseConfirmElement?: React$1.FC<void>;
};
type CProps$5 = {
toggle: () => void;
chatId?: string;
openLabel?: string;
closeLabel?: string;
closeImg?: string;
openImg?: string;
showBadge?: boolean;
showPopup?: boolean;
isLoading?: boolean;
popupProps?: Omit<Props$1, "text">;
};
type CProps$6 = {
rootRef?: React$1.Ref<HTMLDivElement>;
conversationProps?: CProps$4;
launcherProps?: Omit<CProps$5, "toggle" | "isLoading">;
onToggleConversation: () => Promise<void>;
fullScreenMode?: boolean;
customLauncher?: AnyFunction;
imagePreview?: boolean;
zoomStep?: number;
};
type CProps$7 = {
widgetProps: Props$2;
primaryColor?: string;
messageClientColor?: string;
messageClientTextColor?: string;
messageResponseColor?: string;
messageResponseTextColor?: string;
anchorBottom?: number | string;
anchorRight?: number | string;
anchorMobileBottom?: number | string;
anchorMobileRight?: number | string;
headerPaddingTop?: string;
headerPaddingBottom?: string;
};
type Props$1 = {
text: string | readonly string[];
onResize?: (w: number, h: number) => void;
};
type Props$2 = {
layoutProps?: Omit<CProps$6, "onToggleConversation" | "onSendMessage" | "onQuickButtonClicked" | "onTextInputChange">;
handleNewUserMessage?: (data: {
text?: string;
files?: File[];
replyMessage?: Message | null;
}) => void | Promise<void>;
handleQuickButtonClicked?: AnyFunction;
handleTextInputChange?: (event: any) => void;
disableRichTextInput?: boolean;
handleToggle?: (state: boolean) => boolean | Promise<boolean>;
handleSubmit?: (data: {
text?: string;
files?: File[];
}) => void | Error | Promise<void | Error>;
onResize?: (w: number, h: number) => void;
};
type Props$3 = {
message: MessageTypes;
showTimeStamp?: boolean;
reply?: boolean;
reaction?: boolean;
isReplyContext?: boolean;
isReplyMessage?: boolean;
};
type Props$4 = {
message: Link;
showTimeStamp?: boolean;
reply?: boolean;
reaction?: boolean;
isReplyContext?: boolean;
isReplyMessage?: boolean;
};
type Props$5 = {
showTimeStamp?: boolean;
reply?: boolean;
reaction?: boolean;
className: string;
children?: React$1.ReactNode;
};
export {
Root as default,
};