@botpress/webchat 4.2.2 → 4.4.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/.storybook/main.ts +10 -27
- package/.storybook/preview.tsx +2 -2
- package/.turbo/turbo-build.log +8 -8
- package/ARCHITECTURE.md +737 -0
- package/dist/index.d.ts +333 -142
- package/dist/index.js +15376 -9451
- package/dist/index.umd.cjs +122 -113
- package/dist/style.css +1 -1
- package/package.json +14 -15
package/dist/index.d.ts
CHANGED
|
@@ -1,31 +1,39 @@
|
|
|
1
1
|
import { AddMessageFeedbackBody } from '@botpress/webchat-client';
|
|
2
|
-
import { ClassAttributes } from 'react';
|
|
2
|
+
import { ClassAttributes } from '../../../node_modules/@types/react';
|
|
3
3
|
import { Client } from '@botpress/webchat-client';
|
|
4
|
-
import { ComponentProps } from 'react';
|
|
5
|
-
import {
|
|
4
|
+
import { ComponentProps } from '../../../node_modules/@types/react';
|
|
5
|
+
import { ComponentProps as ComponentProps_2 } from '../../node_modules/@types/react';
|
|
6
|
+
import { ComponentPropsWithRef } from '../../node_modules/@types/react';
|
|
6
7
|
import { LatestWebchatConfig as Configuration } from '@bpinternal/shared';
|
|
7
|
-
import { Context } from 'react';
|
|
8
|
-
import {
|
|
8
|
+
import { Context } from '../../node_modules/@types/react';
|
|
9
|
+
import { createEventEmitter } from '@bpinternal/shared';
|
|
10
|
+
import { CSSProperties } from '../../node_modules/@types/react';
|
|
9
11
|
import * as Dialog from '@radix-ui/react-dialog';
|
|
10
|
-
import { Dispatch } from 'react';
|
|
12
|
+
import { Dispatch } from '../../node_modules/@types/react';
|
|
11
13
|
import { EventEmitter } from '@bpinternal/shared';
|
|
12
|
-
import
|
|
13
|
-
import { ForwardRefExoticComponent } from 'react';
|
|
14
|
-
import {
|
|
14
|
+
import { FC } from '../../node_modules/@types/react';
|
|
15
|
+
import { ForwardRefExoticComponent } from '../../node_modules/@types/react';
|
|
16
|
+
import { ForwardRefExoticComponent as ForwardRefExoticComponent_2 } from '../../../node_modules/@types/react';
|
|
17
|
+
import { ForwardRefExoticComponent as ForwardRefExoticComponent_3 } from 'react';
|
|
18
|
+
import { HTMLAttributes } from '../../../node_modules/@types/react';
|
|
15
19
|
import { IntegrationError } from '@botpress/webchat-client';
|
|
16
|
-
import { JSX } from 'react';
|
|
20
|
+
import { JSX } from '../../node_modules/@types/react';
|
|
17
21
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
18
22
|
import { LatestWebchatTheme } from '@bpinternal/shared';
|
|
19
|
-
import {
|
|
23
|
+
import { ListConversationsResponse } from '@botpress/webchat-client';
|
|
24
|
+
import { MemoExoticComponent } from '../../../node_modules/@types/react';
|
|
20
25
|
import { Message as Message_2 } from '@botpress/webchat-client';
|
|
21
|
-
import { NamedExoticComponent } from 'react';
|
|
26
|
+
import { NamedExoticComponent } from '../../../node_modules/@types/react';
|
|
22
27
|
import { PersistOptions } from 'zustand/middleware';
|
|
23
|
-
import { ReactNode } from 'react';
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
28
|
+
import { ReactNode } from '../../../node_modules/@types/react';
|
|
29
|
+
import { ReactNode as ReactNode_2 } from '../../node_modules/@types/react';
|
|
30
|
+
import { Ref } from '../../../node_modules/@types/react';
|
|
31
|
+
import { RefAttributes } from '../../node_modules/@types/react';
|
|
32
|
+
import { RefAttributes as RefAttributes_2 } from '../../../node_modules/@types/react';
|
|
33
|
+
import { RefAttributes as RefAttributes_3 } from 'react';
|
|
34
|
+
import { RefObject } from '../../node_modules/@types/react';
|
|
27
35
|
import { RotateCcw } from 'lucide-react';
|
|
28
|
-
import { SetStateAction } from 'react';
|
|
36
|
+
import { SetStateAction } from '../../node_modules/@types/react';
|
|
29
37
|
import { StoreApi } from 'zustand';
|
|
30
38
|
import { UseBoundStore } from 'zustand';
|
|
31
39
|
import { User } from '@botpress/webchat-client';
|
|
@@ -134,7 +142,7 @@ export declare type CarouselBlock = {
|
|
|
134
142
|
blocks: GenericBlock[];
|
|
135
143
|
};
|
|
136
144
|
|
|
137
|
-
export declare const Chat: ({ connected, configuration, isTyping, messages, user, isLoading, renderers, isReadOnly, disableComposer,
|
|
145
|
+
export declare const Chat: ({ connected, configuration, isTyping, messages, user, isLoading, renderers, isReadOnly, disableComposer, error, participants, closeWindow, sendMessage, uploadFile, addMessageFeedback, listConversations, restartConversation, clientId, storageKey, soundOn, toggleSound, disableSendButton, conversationId, ...props }: Props) => JSX_2.Element;
|
|
138
146
|
|
|
139
147
|
declare type ChatSoundStore = {
|
|
140
148
|
soundOn: boolean;
|
|
@@ -142,11 +150,9 @@ declare type ChatSoundStore = {
|
|
|
142
150
|
toggleSound: () => void;
|
|
143
151
|
};
|
|
144
152
|
|
|
145
|
-
declare
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
static getInstance(name?: string): BoundChatSoundStore;
|
|
149
|
-
}
|
|
153
|
+
export declare type ClientStates = 'connecting' | 'connected' | 'error' | 'disconnected';
|
|
154
|
+
|
|
155
|
+
declare type ClientStates_2 = 'connecting' | 'connected' | 'error' | 'disconnected';
|
|
150
156
|
|
|
151
157
|
export declare type ColumnBlock = {
|
|
152
158
|
type: 'column';
|
|
@@ -172,51 +178,88 @@ export declare type CommonBlockProps = Pick<RichBlockMessage, 'direction' | 'sen
|
|
|
172
178
|
addMessageFeedback?: (messageId: string, feedback: Feedback) => void;
|
|
173
179
|
};
|
|
174
180
|
|
|
181
|
+
declare type CommonWebchatProps = {
|
|
182
|
+
on: EventEmitter<Events>['on'];
|
|
183
|
+
messages: BlockMessage[];
|
|
184
|
+
newConversation: (conversationId?: string) => void;
|
|
185
|
+
participants: User[];
|
|
186
|
+
soundOn: boolean;
|
|
187
|
+
toggleSound: () => void;
|
|
188
|
+
disableSendButton: boolean;
|
|
189
|
+
error?: WebchatError;
|
|
190
|
+
};
|
|
191
|
+
|
|
175
192
|
export declare type ComposableIntegrationMessagePayload = Extract<IntegrationMessage['payload'], ToPayloadType<ComposableIntegrationMessageTypes>>;
|
|
176
193
|
|
|
177
194
|
declare type ComposableIntegrationMessageTypes = 'audio' | 'bloc' | 'file' | 'image' | 'location' | 'markdown' | 'text' | 'video';
|
|
178
195
|
|
|
179
|
-
export declare const Composer: NamedExoticComponent<Omit<Props_3, "ref"> &
|
|
196
|
+
export declare const Composer: NamedExoticComponent<Omit<Props_3, "ref"> & RefAttributes_2<HTMLDivElement>>;
|
|
180
197
|
|
|
181
198
|
export declare const CONFIG_ACCESS_DENIED = "Access denied to configuration file. Please check your credentials or your configuration URL and try again.";
|
|
182
199
|
|
|
183
200
|
export { Configuration }
|
|
184
201
|
|
|
185
202
|
export declare const Container: {
|
|
186
|
-
({ children, className, uploadFile, allowFileUpload, storageKey,
|
|
203
|
+
({ children, className, uploadFile, allowFileUpload, storageKey, conversationId, ...props }: Props_4): JSX_2.Element;
|
|
187
204
|
displayName: string;
|
|
188
205
|
};
|
|
189
206
|
|
|
207
|
+
export declare const ConversationHistory: {
|
|
208
|
+
({ className, onConversationClick, onNewConversation, onClose, currentConversationId, isLoading, conversations, botAvatar, botName, ...props }: ComponentProps<"div"> & ConversationHistoryProps): JSX_2.Element;
|
|
209
|
+
displayName: string;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
declare type ConversationHistoryProps = {
|
|
213
|
+
onConversationClick?: (conversationId: string) => void;
|
|
214
|
+
onNewConversation?: () => void;
|
|
215
|
+
onClose?: () => void;
|
|
216
|
+
currentConversationId?: string;
|
|
217
|
+
isLoading?: boolean;
|
|
218
|
+
conversations: Conversations;
|
|
219
|
+
botAvatar?: string;
|
|
220
|
+
botName?: string;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
declare type Conversations = ConversationWithLastMessage[];
|
|
224
|
+
|
|
225
|
+
declare type ConversationWithLastMessage = ListConversationsResponse['conversations'][number] & {
|
|
226
|
+
lastMessage: NonNullable<ListConversationsResponse['conversations'][number]['lastMessage']> & {
|
|
227
|
+
author: {
|
|
228
|
+
type: 'bot' | 'user';
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
|
|
190
233
|
declare const createChatSoundStore: (storeName: string) => UseBoundStore<Omit<Omit<StoreApi<ChatSoundStore>, "setState"> & {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
234
|
+
setState<A extends string | {
|
|
235
|
+
type: unknown;
|
|
236
|
+
}>(partial: ChatSoundStore | Partial<ChatSoundStore> | ((state: ChatSoundStore) => ChatSoundStore | Partial<ChatSoundStore>), replace?: boolean | undefined, action?: A | undefined): void;
|
|
194
237
|
}, "persist"> & {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
238
|
+
persist: {
|
|
239
|
+
setOptions: (options: Partial<PersistOptions<ChatSoundStore, ChatSoundStore>>) => void;
|
|
240
|
+
clearStorage: () => void;
|
|
241
|
+
rehydrate: () => Promise<void> | void;
|
|
242
|
+
hasHydrated: () => boolean;
|
|
243
|
+
onHydrate: (fn: (state: ChatSoundStore) => void) => () => void;
|
|
244
|
+
onFinishHydration: (fn: (state: ChatSoundStore) => void) => () => void;
|
|
245
|
+
getOptions: () => Partial<PersistOptions<ChatSoundStore, ChatSoundStore>>;
|
|
246
|
+
};
|
|
204
247
|
}>;
|
|
205
248
|
|
|
206
249
|
declare const createWebchatClientStore: (storeName: string, storageLocation?: StorageLocation) => UseBoundStore<Omit<Omit<StoreApi<WebchatClientStore>, "setState"> & {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
250
|
+
setState<A extends string | {
|
|
251
|
+
type: unknown;
|
|
252
|
+
}>(partial: WebchatClientStore | Partial<WebchatClientStore> | ((state: WebchatClientStore) => WebchatClientStore | Partial<WebchatClientStore>), replace?: boolean | undefined, action?: A | undefined): void;
|
|
210
253
|
}, "persist"> & {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
254
|
+
persist: {
|
|
255
|
+
setOptions: (options: Partial<PersistOptions<WebchatClientStore, unknown>>) => void;
|
|
256
|
+
clearStorage: () => void;
|
|
257
|
+
rehydrate: () => Promise<void> | void;
|
|
258
|
+
hasHydrated: () => boolean;
|
|
259
|
+
onHydrate: (fn: (state: WebchatClientStore) => void) => () => void;
|
|
260
|
+
onFinishHydration: (fn: (state: WebchatClientStore) => void) => () => void;
|
|
261
|
+
getOptions: () => Partial<PersistOptions<WebchatClientStore, unknown>>;
|
|
262
|
+
};
|
|
220
263
|
}>;
|
|
221
264
|
|
|
222
265
|
export declare type CustomBlock = {
|
|
@@ -262,9 +305,9 @@ declare type Events_2 = {
|
|
|
262
305
|
[key: string]: string;
|
|
263
306
|
};
|
|
264
307
|
|
|
265
|
-
export declare const Fab:
|
|
266
|
-
|
|
267
|
-
}, "ref"> &
|
|
308
|
+
export declare const Fab: ForwardRefExoticComponent_2<Omit<ClassAttributes<HTMLDivElement> & HTMLAttributes<HTMLDivElement> & {
|
|
309
|
+
imgUrl?: string;
|
|
310
|
+
}, "ref"> & RefAttributes_2<HTMLDivElement>>;
|
|
268
311
|
|
|
269
312
|
export declare type Feedback = AddMessageFeedbackBody;
|
|
270
313
|
|
|
@@ -284,16 +327,17 @@ export declare function generateThemeStylesheet(theme: LatestWebchatTheme): stri
|
|
|
284
327
|
|
|
285
328
|
export declare type GenericBlock = AudioBlock | BubbleBlock | ButtonBlock | CarouselBlock | ColumnBlock | DropdownBlock | FileBlock | ImageBlock | LocationBlock | RowBlock | TextBlock | VideoBlock | CustomBlock;
|
|
286
329
|
|
|
287
|
-
export declare const getUseChatSoundStore:
|
|
330
|
+
export declare const getUseChatSoundStore: (name?: string) => BoundChatSoundStore;
|
|
288
331
|
|
|
289
|
-
export declare const getUseWebchatClientStore:
|
|
332
|
+
export declare const getUseWebchatClientStore: (name?: string, storageLocation?: StorageLocation) => BoundWebchatClientStore;
|
|
290
333
|
|
|
291
|
-
export declare const Header: ({ defaultOpen, closeWindow, configuration, restartConversation, disabled, soundOn, toggleSound, clientId, ...props }: HeaderProps) => JSX_2.Element;
|
|
334
|
+
export declare const Header: ({ defaultOpen, closeWindow, configuration, restartConversation, showConversationHistory, disabled, soundOn, toggleSound, clientId, ...props }: HeaderProps) => JSX_2.Element;
|
|
292
335
|
|
|
293
336
|
declare type HeaderProps = {
|
|
294
337
|
defaultOpen?: boolean;
|
|
295
338
|
open?: boolean;
|
|
296
339
|
disabled?: boolean;
|
|
340
|
+
showConversationHistory?: () => void;
|
|
297
341
|
onOpenChange?(open: boolean): void;
|
|
298
342
|
restartConversation?: () => void;
|
|
299
343
|
closeWindow?: () => void;
|
|
@@ -320,7 +364,7 @@ export declare type InputModalProps<T> = {
|
|
|
320
364
|
Content?: ({ setValue }: {
|
|
321
365
|
value: T | undefined;
|
|
322
366
|
setValue: (value: T) => void;
|
|
323
|
-
}) =>
|
|
367
|
+
}) => ReactNode_2;
|
|
324
368
|
};
|
|
325
369
|
|
|
326
370
|
export declare type IntegrationMessage = Message_2;
|
|
@@ -364,21 +408,21 @@ export declare type LocationBlock = {
|
|
|
364
408
|
|
|
365
409
|
export declare const mapToWebchatError: (thrown: unknown) => WebchatError;
|
|
366
410
|
|
|
367
|
-
export declare const Message: NamedExoticComponent<{
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
411
|
+
export declare const Message: NamedExoticComponent< {
|
|
412
|
+
children?: ReactNode;
|
|
413
|
+
renderers?: Partial<Renderers>;
|
|
414
|
+
sendMessage?: (payload: IntegrationMessage["payload"]) => void;
|
|
415
|
+
addMessageFeedback?: (messageId: string, feedback: Feedback) => void;
|
|
416
|
+
isReadOnly?: boolean;
|
|
417
|
+
isLastDeliveredMessage?: boolean;
|
|
418
|
+
showAvatar?: boolean;
|
|
375
419
|
} & BlockMessage<GenericBlock> & {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
} &
|
|
420
|
+
direction: "incoming" | "outgoing" | "system";
|
|
421
|
+
sender: {
|
|
422
|
+
name: string;
|
|
423
|
+
avatar?: string;
|
|
424
|
+
};
|
|
425
|
+
} & RefAttributes_2<HTMLDivElement>>;
|
|
382
426
|
|
|
383
427
|
export declare const MessageContext: Context<MessageContextVaue | null>;
|
|
384
428
|
|
|
@@ -406,12 +450,12 @@ declare type MessageListProps = {
|
|
|
406
450
|
showOutgoingMessageAvatar?: boolean;
|
|
407
451
|
};
|
|
408
452
|
|
|
409
|
-
export declare const MessagePreview:
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}, "ref"> &
|
|
453
|
+
export declare const MessagePreview: ForwardRefExoticComponent_2<Omit<ClassAttributes<HTMLDivElement> & HTMLAttributes<HTMLDivElement> & {
|
|
454
|
+
avatarUrl?: string;
|
|
455
|
+
botName?: string;
|
|
456
|
+
description?: string;
|
|
457
|
+
onClose?: () => void;
|
|
458
|
+
}, "ref"> & RefAttributes_2<HTMLDivElement>>;
|
|
415
459
|
|
|
416
460
|
export declare const MISSING_API_URL = "The API url is required to initialize the webchat.";
|
|
417
461
|
|
|
@@ -428,8 +472,8 @@ export declare function Modal({ open, onOpenChange, children, }: {
|
|
|
428
472
|
}): JSX_2.Element;
|
|
429
473
|
|
|
430
474
|
export declare namespace Modal {
|
|
431
|
-
var Button:
|
|
432
|
-
var Close:
|
|
475
|
+
var Button: ForwardRefExoticComponent_3<Dialog.DialogTriggerProps & RefAttributes_3<HTMLButtonElement>>;
|
|
476
|
+
var Close: ForwardRefExoticComponent_3<Dialog.DialogCloseProps & RefAttributes_3<HTMLButtonElement>>;
|
|
433
477
|
var Content: typeof ModalContent;
|
|
434
478
|
}
|
|
435
479
|
|
|
@@ -450,7 +494,7 @@ declare type ModalContextValue = {
|
|
|
450
494
|
};
|
|
451
495
|
|
|
452
496
|
export declare const ModalProvider: ({ children }: {
|
|
453
|
-
children:
|
|
497
|
+
children: ReactNode_2;
|
|
454
498
|
}) => JSX_2.Element;
|
|
455
499
|
|
|
456
500
|
export declare const NETWORK_ERROR = "Please check your internet connection and refresh the page.";
|
|
@@ -472,27 +516,20 @@ export declare type Props = {
|
|
|
472
516
|
isReadOnly?: boolean;
|
|
473
517
|
isLoading?: boolean;
|
|
474
518
|
isTyping?: boolean;
|
|
475
|
-
lastTypingHeartbeat?: Date | null;
|
|
476
|
-
allowFileUpload?: boolean;
|
|
477
519
|
clientId?: string;
|
|
478
520
|
closeWindow?: () => void;
|
|
479
|
-
restartConversation?: () => void;
|
|
480
|
-
user?:
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
fileUrl: string;
|
|
486
|
-
name: string;
|
|
487
|
-
type: FileType;
|
|
488
|
-
}>;
|
|
489
|
-
addMessageFeedback?: (messageId: string, feedback: Feedback) => void;
|
|
490
|
-
triggerNetworkError?: (errorType?: 'network' | 'timeout' | 'server', delay?: number) => Promise<never>;
|
|
521
|
+
restartConversation?: (conversationid?: string) => void;
|
|
522
|
+
user?: UserCredentials;
|
|
523
|
+
sendMessage?: ScopedClient['sendMessage'];
|
|
524
|
+
uploadFile?: ScopedClient['uploadFile'];
|
|
525
|
+
addMessageFeedback?: ScopedClient['addMessageFeedback'];
|
|
526
|
+
listConversations?: ScopedClient['listConversations'];
|
|
491
527
|
error?: WebchatError;
|
|
492
528
|
soundOn?: boolean;
|
|
493
529
|
toggleSound?: () => void;
|
|
494
|
-
disableSendButton?: boolean;
|
|
495
530
|
storageKey?: string;
|
|
531
|
+
disableSendButton?: boolean;
|
|
532
|
+
conversationId?: string;
|
|
496
533
|
};
|
|
497
534
|
|
|
498
535
|
declare type Props_2 = {
|
|
@@ -505,6 +542,7 @@ declare type Props_2 = {
|
|
|
505
542
|
storageKey?: string;
|
|
506
543
|
storageLocation?: StorageLocation;
|
|
507
544
|
soundEnabled?: boolean;
|
|
545
|
+
clientHeaders?: Record<string, string>;
|
|
508
546
|
};
|
|
509
547
|
|
|
510
548
|
declare type Props_3 = ComponentProps<'div'> & {
|
|
@@ -514,29 +552,23 @@ declare type Props_3 = ComponentProps<'div'> & {
|
|
|
514
552
|
allowFileUpload?: boolean;
|
|
515
553
|
disableSendButton?: boolean;
|
|
516
554
|
connected?: boolean;
|
|
517
|
-
sendMessage?:
|
|
518
|
-
uploadFile?:
|
|
519
|
-
fileUrl: string;
|
|
520
|
-
name: string;
|
|
521
|
-
type: FileType;
|
|
522
|
-
}>;
|
|
555
|
+
sendMessage?: ScopedClient['sendMessage'];
|
|
556
|
+
uploadFile?: ScopedClient['uploadFile'];
|
|
523
557
|
storageKey?: string;
|
|
558
|
+
conversationId?: string;
|
|
524
559
|
} & Pick<Configuration, 'composerPlaceholder' | 'footer'>;
|
|
525
560
|
|
|
526
561
|
declare type Props_4 = ComponentProps<'div'> & {
|
|
527
562
|
connected?: boolean;
|
|
528
|
-
uploadFile?:
|
|
529
|
-
fileUrl: string;
|
|
530
|
-
name: string;
|
|
531
|
-
type: FileType;
|
|
532
|
-
}>;
|
|
563
|
+
uploadFile?: ScopedClient['uploadFile'];
|
|
533
564
|
allowFileUpload?: boolean;
|
|
534
565
|
storageKey?: string;
|
|
566
|
+
conversationId?: string;
|
|
535
567
|
};
|
|
536
568
|
|
|
537
569
|
declare type Props_5 = {
|
|
538
570
|
restartConversation: () => void;
|
|
539
|
-
} &
|
|
571
|
+
} & ComponentProps_2<typeof RotateCcw>;
|
|
540
572
|
|
|
541
573
|
declare type Props_6 = {
|
|
542
574
|
clientId: string;
|
|
@@ -547,7 +579,10 @@ declare type Props_6 = {
|
|
|
547
579
|
configuration?: Configuration;
|
|
548
580
|
soundOn?: boolean;
|
|
549
581
|
toggleSound?: () => void;
|
|
550
|
-
|
|
582
|
+
/** @deprecated This prop is no longer used, pass the allowFileUpload via the configuration object */
|
|
583
|
+
allowFileUpload?: boolean;
|
|
584
|
+
renderers?: Partial<Renderers>;
|
|
585
|
+
} & ComponentProps_2<'div'>;
|
|
551
586
|
|
|
552
587
|
declare type Props_7 = Partial<LatestWebchatTheme>;
|
|
553
588
|
|
|
@@ -582,7 +617,7 @@ export declare type RowOf<T extends GenericBlock> = Omit<RowBlock, 'blocks'> & {
|
|
|
582
617
|
blocks: T[];
|
|
583
618
|
};
|
|
584
619
|
|
|
585
|
-
declare type ScopedClient = {
|
|
620
|
+
export declare type ScopedClient = {
|
|
586
621
|
sendMessage: (payload: IntegrationMessage['payload']) => Promise<void>;
|
|
587
622
|
sendEvent: (event: Record<string, any>, options?: {
|
|
588
623
|
bindConversation?: boolean;
|
|
@@ -592,19 +627,25 @@ declare type ScopedClient = {
|
|
|
592
627
|
fileUrl: string;
|
|
593
628
|
name: string;
|
|
594
629
|
type: FileType;
|
|
630
|
+
fileId: string;
|
|
595
631
|
}>;
|
|
596
632
|
addMessageFeedback: (messageId: string, feedback: Feedback) => Promise<void>;
|
|
597
633
|
getUser: () => Promise<UserResponse>;
|
|
598
634
|
updateUser: (user: UserProfile) => Promise<User>;
|
|
635
|
+
listConversations: () => ReturnType<Client['listConversations']>;
|
|
599
636
|
};
|
|
600
637
|
|
|
638
|
+
export declare const _setDebugEnabled: (enabled: boolean) => void;
|
|
639
|
+
|
|
640
|
+
export declare const _setTrackFn: (fn: typeof _trackFn) => void;
|
|
641
|
+
|
|
601
642
|
export declare const SOUND_EFFECTS: {
|
|
602
643
|
readonly chatMessageNotification: string;
|
|
603
644
|
};
|
|
604
645
|
|
|
605
646
|
export declare const SSE_DISCONNECTED_ERROR = "You've been disconnected from the conversation.\nPlease refresh the page.";
|
|
606
647
|
|
|
607
|
-
declare type StorageLocation = 'sessionStorage' | 'localStorage';
|
|
648
|
+
export declare type StorageLocation = 'sessionStorage' | 'localStorage';
|
|
608
649
|
|
|
609
650
|
export declare type StyleOptions = {
|
|
610
651
|
className?: string;
|
|
@@ -628,8 +669,57 @@ declare type ToPayloadType<T extends IntegrationMessageTypes> = {
|
|
|
628
669
|
};
|
|
629
670
|
}[T];
|
|
630
671
|
|
|
672
|
+
declare let _trackFn: ((event: string, properties?: Record<string, unknown>) => void) | null;
|
|
673
|
+
|
|
631
674
|
export declare const TypingIndicator: MemoExoticComponent<({ ...props }: ComponentProps<"div">) => JSX_2.Element>;
|
|
632
675
|
|
|
676
|
+
export declare function useActiveConversation(): UseActiveConversationReturn;
|
|
677
|
+
|
|
678
|
+
declare type UseActiveConversationReturn = {
|
|
679
|
+
conversationId?: string;
|
|
680
|
+
messages: BlockMessage[];
|
|
681
|
+
participants: User[];
|
|
682
|
+
sendMessage: (payload: IntegrationMessage['payload']) => Promise<void>;
|
|
683
|
+
saveMessageFeedback: (messageId: string, feedback: Feedback) => Promise<void>;
|
|
684
|
+
sendEvent: (event: Record<string, unknown>, options?: {
|
|
685
|
+
bindConversation?: boolean;
|
|
686
|
+
bindUser?: boolean;
|
|
687
|
+
}) => Promise<void>;
|
|
688
|
+
uploadFile: (file: File) => Promise<{
|
|
689
|
+
fileUrl: string;
|
|
690
|
+
name: string;
|
|
691
|
+
type: FileType;
|
|
692
|
+
fileId: string;
|
|
693
|
+
}>;
|
|
694
|
+
status: ClientStates;
|
|
695
|
+
on: ReturnType<typeof createEventEmitter<Events>>['on'];
|
|
696
|
+
error?: WebchatError;
|
|
697
|
+
isTyping: boolean;
|
|
698
|
+
isAwaitingResponse: boolean;
|
|
699
|
+
};
|
|
700
|
+
|
|
701
|
+
export declare function useConversationList({ userCredentials, listConversations, clientId, }: UseConversationListParams): UseConversationListReturn;
|
|
702
|
+
|
|
703
|
+
declare type UseConversationListParams = {
|
|
704
|
+
userCredentials?: UserCredentials;
|
|
705
|
+
listConversations?: Client['listConversations'];
|
|
706
|
+
clientId?: string;
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
declare type UseConversationListReturn = {
|
|
710
|
+
conversations: Conversations;
|
|
711
|
+
isLoading: boolean;
|
|
712
|
+
error?: WebchatError;
|
|
713
|
+
refresh: () => Promise<Conversations | undefined>;
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
export declare function useConversations(): UseConversationsReturn;
|
|
717
|
+
|
|
718
|
+
declare type UseConversationsReturn = {
|
|
719
|
+
listConversations?: () => Promise<ListConversationsResponse>;
|
|
720
|
+
openConversation: (conversationId?: string) => void;
|
|
721
|
+
};
|
|
722
|
+
|
|
633
723
|
export declare type UseImageSizeResult = [Dimensions | null, {
|
|
634
724
|
loading: boolean;
|
|
635
725
|
error: string | null;
|
|
@@ -639,46 +729,61 @@ export declare function useMessageContext(): MessageContextVaue;
|
|
|
639
729
|
|
|
640
730
|
export declare function useModalContext(): ModalContextValue;
|
|
641
731
|
|
|
642
|
-
|
|
732
|
+
export { User }
|
|
733
|
+
|
|
734
|
+
export declare type UserProfile = Omit<User, 'id' | 'createdAt' | 'updatedAt'>;
|
|
735
|
+
|
|
736
|
+
export declare type UserResponse = Awaited<ReturnType<Client['getUser']>>['user'];
|
|
737
|
+
|
|
738
|
+
export declare const useUser: () => UseUserReturn;
|
|
739
|
+
|
|
740
|
+
declare type UseUserReturn = {
|
|
741
|
+
getUser?: () => Promise<UserResponse>;
|
|
742
|
+
updateUser?: (user: UserProfile) => Promise<User>;
|
|
743
|
+
userCredentials?: UserCredentials;
|
|
744
|
+
};
|
|
643
745
|
|
|
644
|
-
|
|
746
|
+
/**
|
|
747
|
+
* @deprecated This hook is deprecated. Use WebchatProvider with useActiveConversation, useConversations, and useUser instead.
|
|
748
|
+
*
|
|
749
|
+
* Migration guide:
|
|
750
|
+
* ```typescript
|
|
751
|
+
* // Old:
|
|
752
|
+
* const { messages, sendMessage, client } = useWebchat({ clientId, ... })
|
|
753
|
+
*
|
|
754
|
+
* // New:
|
|
755
|
+
* <WebchatProvider clientId={clientId} ...>
|
|
756
|
+
* const { messages, sendMessage } = useActiveConversation()
|
|
757
|
+
* const { listConversations, openConversation } = useConversations()
|
|
758
|
+
* const { getUser, updateUser } = useUser()
|
|
759
|
+
* </WebchatProvider>
|
|
760
|
+
* ```
|
|
761
|
+
*/
|
|
762
|
+
export declare function useWebchat({ apiUrl, clientId, storageKey, storageLocation, adminSecret, soundEnabled, clientHeaders, ...props }: Props_2): UseWebchatReturn;
|
|
645
763
|
|
|
646
|
-
export declare function
|
|
764
|
+
export declare function useWebchatContext(): WebchatContextValue;
|
|
647
765
|
|
|
648
|
-
|
|
766
|
+
/**
|
|
767
|
+
* @deprecated Use WebchatProvider with useActiveConversation, useConversations, and useUser instead
|
|
768
|
+
*/
|
|
769
|
+
declare type UseWebchatReturn = (CommonWebchatProps & {
|
|
649
770
|
clientState: 'connected';
|
|
650
|
-
on: EventEmitter<Events>['on'];
|
|
651
771
|
client: ScopedClient;
|
|
652
|
-
messages: BlockMessage[];
|
|
653
772
|
conversationId: string;
|
|
654
|
-
newConversation: () => Promise<void>;
|
|
655
773
|
user?: UserCredentials;
|
|
656
774
|
isTyping: boolean;
|
|
657
|
-
|
|
658
|
-
soundOn: boolean;
|
|
659
|
-
toggleSound: () => void;
|
|
660
|
-
disableSendButton: boolean;
|
|
661
|
-
error?: WebchatError;
|
|
662
|
-
} | {
|
|
775
|
+
}) | (CommonWebchatProps & {
|
|
663
776
|
clientState: 'connecting' | 'error' | 'disconnected';
|
|
664
|
-
on: EventEmitter<Events>['on'];
|
|
665
777
|
client: undefined;
|
|
666
|
-
messages: BlockMessage[];
|
|
667
778
|
conversationId: undefined;
|
|
668
|
-
newConversation: () => Promise<void>;
|
|
669
779
|
user: undefined;
|
|
670
780
|
isTyping: undefined;
|
|
671
|
-
|
|
672
|
-
soundOn: boolean;
|
|
673
|
-
toggleSound: () => void;
|
|
674
|
-
disableSendButton: boolean;
|
|
675
|
-
error?: WebchatError;
|
|
676
|
-
};
|
|
781
|
+
});
|
|
677
782
|
|
|
678
783
|
export declare const useWebchatStore: UseBoundStore<Omit<StoreApi<WebchatStore>, "setState"> & {
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
784
|
+
setState<A extends string | {
|
|
785
|
+
type: unknown;
|
|
786
|
+
}>(partial: WebchatStore | Partial<WebchatStore> | ((state: WebchatStore) => WebchatStore | Partial<WebchatStore>), replace?: boolean | undefined, action?: A | undefined): void;
|
|
682
787
|
}>;
|
|
683
788
|
|
|
684
789
|
declare type ValueOf<T> = T[keyof T];
|
|
@@ -688,7 +793,7 @@ export declare type VideoBlock = {
|
|
|
688
793
|
url: string;
|
|
689
794
|
};
|
|
690
795
|
|
|
691
|
-
export declare const Webchat: ({ clientId, storageKey, configuration,
|
|
796
|
+
export declare const Webchat: ({ clientId, storageKey, configuration, apiUrl, user: userCredentials, conversationId, ...props }: Props_6) => JSX_2.Element;
|
|
692
797
|
|
|
693
798
|
export declare const webchatClasses: {
|
|
694
799
|
readonly container: {
|
|
@@ -798,6 +903,9 @@ export declare const webchatClasses: {
|
|
|
798
903
|
readonly container: {
|
|
799
904
|
readonly className: "bpReset bpHeaderContentContainer";
|
|
800
905
|
};
|
|
906
|
+
readonly conversationHistory: {
|
|
907
|
+
readonly className: "bpHeaderConversationHistoryButton";
|
|
908
|
+
};
|
|
801
909
|
readonly title: {
|
|
802
910
|
readonly className: "bpHeaderContentTitle";
|
|
803
911
|
};
|
|
@@ -1214,12 +1322,69 @@ export declare const webchatClasses: {
|
|
|
1214
1322
|
readonly className: "bpProactiveBubbleArrow";
|
|
1215
1323
|
};
|
|
1216
1324
|
};
|
|
1325
|
+
readonly conversationHistory: {
|
|
1326
|
+
readonly container: {
|
|
1327
|
+
readonly className: "bpReset bpConversationHistoryContainer bpFont";
|
|
1328
|
+
};
|
|
1329
|
+
readonly header: {
|
|
1330
|
+
readonly className: "bpConversationHistoryHeader";
|
|
1331
|
+
};
|
|
1332
|
+
readonly closeButton: {
|
|
1333
|
+
readonly className: "bpConversationHistoryCloseButton";
|
|
1334
|
+
};
|
|
1335
|
+
readonly scrollContainer: {
|
|
1336
|
+
readonly className: "bpConversationHistoryScrollContainer";
|
|
1337
|
+
};
|
|
1338
|
+
readonly loaderContainer: {
|
|
1339
|
+
readonly className: "bpConversationHistoryLoaderContainer";
|
|
1340
|
+
};
|
|
1341
|
+
readonly conversation: {
|
|
1342
|
+
readonly container: {
|
|
1343
|
+
readonly className: "bpConversationHistoryConversationContainer";
|
|
1344
|
+
};
|
|
1345
|
+
readonly chevron: {
|
|
1346
|
+
readonly className: "bpConversationHistoryConversationChevron";
|
|
1347
|
+
};
|
|
1348
|
+
readonly userAvatar: {
|
|
1349
|
+
readonly className: {
|
|
1350
|
+
readonly className: "bpConversationHistoryConversationUserAvatarFallback";
|
|
1351
|
+
};
|
|
1352
|
+
};
|
|
1353
|
+
readonly avatar: {
|
|
1354
|
+
readonly container: {
|
|
1355
|
+
readonly className: "bpReset bpConversationHistoryConversationAvatarContainer";
|
|
1356
|
+
};
|
|
1357
|
+
readonly image: {
|
|
1358
|
+
readonly className: "bpConversationHistoryConversationAvatarImage";
|
|
1359
|
+
};
|
|
1360
|
+
readonly fallback: {
|
|
1361
|
+
readonly className: "bpConversationHistoryConversationAvatarFallback";
|
|
1362
|
+
};
|
|
1363
|
+
};
|
|
1364
|
+
readonly content: {
|
|
1365
|
+
readonly className: "bpConversationHistoryConversationContent";
|
|
1366
|
+
};
|
|
1367
|
+
readonly name: {
|
|
1368
|
+
readonly className: "bpConversationHistoryConversationName";
|
|
1369
|
+
};
|
|
1370
|
+
readonly timestamp: {
|
|
1371
|
+
readonly className: "bpConversationHistoryConversationTimestamp";
|
|
1372
|
+
};
|
|
1373
|
+
};
|
|
1374
|
+
readonly newConversation: {
|
|
1375
|
+
readonly button: {
|
|
1376
|
+
readonly className: "bpConversationHistoryNewConversationButton";
|
|
1377
|
+
};
|
|
1378
|
+
readonly icon: {
|
|
1379
|
+
readonly className: "bpConversationHistoryNewConversationButtonIcon";
|
|
1380
|
+
};
|
|
1381
|
+
};
|
|
1382
|
+
};
|
|
1217
1383
|
};
|
|
1218
1384
|
|
|
1219
1385
|
declare type WebchatClientActions = {
|
|
1220
1386
|
setUser: (userId?: UserCredentials) => void;
|
|
1221
|
-
setConversationId: (conversationId
|
|
1222
|
-
clearConversationId: () => void;
|
|
1387
|
+
setConversationId: (conversationId?: string) => void;
|
|
1223
1388
|
clearAll: () => void;
|
|
1224
1389
|
};
|
|
1225
1390
|
|
|
@@ -1230,11 +1395,23 @@ export declare type WebchatClientState = {
|
|
|
1230
1395
|
|
|
1231
1396
|
declare type WebchatClientStore = WebchatClientState & WebchatClientActions;
|
|
1232
1397
|
|
|
1233
|
-
declare
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1398
|
+
export declare type WebchatContextValue = {
|
|
1399
|
+
client: Client | undefined;
|
|
1400
|
+
userCredentials: UserCredentials | undefined;
|
|
1401
|
+
conversationId: string | undefined;
|
|
1402
|
+
openConversation: (params: {
|
|
1403
|
+
conversationId?: string;
|
|
1404
|
+
userToken?: string;
|
|
1405
|
+
}) => Promise<void>;
|
|
1406
|
+
clientState: ClientStates_2;
|
|
1407
|
+
setClientState: (state: ClientStates_2) => void;
|
|
1408
|
+
error: WebchatError | undefined;
|
|
1409
|
+
setError: (error?: WebchatError) => void;
|
|
1410
|
+
isTyping: boolean;
|
|
1411
|
+
isAwaitingResponse: boolean;
|
|
1412
|
+
setAwaitingResponse: (state: boolean, timeout?: number) => void;
|
|
1413
|
+
emitter: ReturnType<typeof createEventEmitter<Events>>;
|
|
1414
|
+
};
|
|
1238
1415
|
|
|
1239
1416
|
export declare type WebchatError = ({
|
|
1240
1417
|
type: 'configuration';
|
|
@@ -1268,6 +1445,20 @@ export declare type WebchatEvents = {
|
|
|
1268
1445
|
participantRemoved: string;
|
|
1269
1446
|
};
|
|
1270
1447
|
|
|
1448
|
+
export declare function WebchatProvider({ clientId, apiUrl, storageKey, storageLocation, adminSecret, clientHeaders, children, ...props }: WebchatProviderProps): JSX_2.Element;
|
|
1449
|
+
|
|
1450
|
+
declare type WebchatProviderProps = {
|
|
1451
|
+
clientId: string;
|
|
1452
|
+
apiUrl?: string;
|
|
1453
|
+
userCredentials?: UserCredentials;
|
|
1454
|
+
conversationId?: string;
|
|
1455
|
+
adminSecret?: string;
|
|
1456
|
+
storageKey?: string;
|
|
1457
|
+
storageLocation?: StorageLocation;
|
|
1458
|
+
clientHeaders?: Record<string, string>;
|
|
1459
|
+
children: ReactNode_2;
|
|
1460
|
+
};
|
|
1461
|
+
|
|
1271
1462
|
declare type WebchatStore = {
|
|
1272
1463
|
messageContainerRef: RefObject<HTMLDivElement | null>;
|
|
1273
1464
|
setMessageContainerRef: (ref: RefObject<HTMLDivElement | null>) => void;
|