@botonic/webchat-react 2.26.0 → 2.27.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/CHANGELOG.md +32 -0
- package/CLAUDE.md +170 -0
- package/index.d.ts +12 -5
- package/index.js +59 -28
- package/lib/components/dialog/backdrop/backdrop.d.ts +5 -0
- package/lib/components/dialog/dialog/dialog.d.ts +7 -0
- package/lib/components/dialog/dialog-context.d.ts +3 -0
- package/lib/components/dialog/dialog-provider.d.ts +17 -0
- package/lib/components/dialog/dialog-types.d.ts +24 -0
- package/lib/components/dialog/icons/check-icon.d.ts +1 -0
- package/lib/components/dialog/icons/xmark-icon.d.ts +1 -0
- package/lib/components/dialog/index.d.ts +5 -0
- package/lib/components/dialog/webchat-dialog-provider.d.ts +6 -0
- package/lib/components/message/audio-message/audio-message.d.ts +2 -0
- package/lib/components/message/audio-message/use-audio-message.d.ts +294 -0
- package/lib/components/message/button-message/button-message.d.ts +6 -1
- package/lib/components/message/carousel-message/carousel-message.d.ts +2 -2
- package/lib/components/message/carousel-message/icons/chevron-left-icon.d.ts +1 -0
- package/lib/components/message/carousel-message/icons/chevron-right-icon.d.ts +1 -0
- package/lib/components/message/carousel-message/index.d.ts +1 -1
- package/lib/components/message/carousel-message/use-carousel-message.d.ts +47 -0
- package/lib/components/message/document-message/document-message.d.ts +2 -8
- package/lib/components/message/document-message/use-document-message.d.ts +11 -0
- package/lib/components/message/image-message/use-image-message.d.ts +10 -0
- package/lib/components/message/index.d.ts +2 -1
- package/lib/components/message/message/message-avatar/message-avatar.d.ts +2 -0
- package/lib/components/message/message/message-bubble/message-bubble.d.ts +0 -3
- package/lib/components/message/message/message-info/message-info.d.ts +2 -0
- package/lib/components/message/message/message.d.ts +2 -0
- package/lib/components/message/message/use-message.d.ts +3 -3
- package/lib/components/{typing-indicator → message/typing-message}/index.d.ts +1 -1
- package/lib/components/{typing-indicator/typing-indicator.d.ts → message/typing-message/typing-message.d.ts} +0 -5
- package/lib/components/message/video-message/use-video-message.d.ts +21 -0
- package/lib/components/message/video-message/video-message.d.ts +3 -1
- package/lib/components/message-machine-renderer/message-machine-renderer.d.ts +1 -0
- package/lib/components/message-machine-renderer/use-message-machine-renderer.d.ts +1 -0
- package/lib/components/shared/button-component/external-link-icon.d.ts +1 -0
- package/lib/components/webchat-app/webchat-app.d.ts +10 -3
- package/lib/components/webchat-container/use-webchat-container.d.ts +1 -0
- package/lib/components/webchat-header/icons/close-icon.d.ts +1 -0
- package/lib/components/webchat-header/icons/download-icon.d.ts +1 -0
- package/lib/components/webchat-header/icons/leave-icon.d.ts +1 -0
- package/lib/components/webchat-header/icons/menu-icon.d.ts +1 -0
- package/lib/components/webchat-header/icons/sounds-icon.d.ts +1 -0
- package/lib/components/webchat-header/icons/start-over-icon.d.ts +1 -0
- package/lib/components/webchat-header/use-webchat-header.d.ts +11 -2
- package/lib/components/webchat-header/webchat-header.d.ts +4 -1
- package/lib/components/webchat-header/webchat-menu/dropdown-menu-item-download-transcript.d.ts +5 -0
- package/lib/components/webchat-header/webchat-menu/dropdown-menu-item-reset-conversation.d.ts +5 -0
- package/lib/components/webchat-header/webchat-menu/dropdown-menu-item-reset-session.d.ts +5 -0
- package/lib/components/webchat-header/webchat-menu/dropdown-menu-item-sounds.d.ts +5 -0
- package/lib/components/webchat-header/webchat-menu/use-dropdown-menu-item-reset-session.d.ts +9 -0
- package/lib/components/webchat-input/attachment-preview/attachment-preview.d.ts +2 -0
- package/lib/components/webchat-input/attachment-preview/index.d.ts +3 -0
- package/lib/components/webchat-input/attachment-preview/use-attachment-preview.d.ts +23 -0
- package/lib/components/webchat-input/audio-input/audio-input.d.ts +2 -0
- package/lib/components/webchat-input/audio-input/index.d.ts +3 -0
- package/lib/components/webchat-input/audio-input/use-audio-input.d.ts +34 -0
- package/lib/components/webchat-input/audio-waveform/audio-waveform.d.ts +5 -0
- package/lib/components/webchat-input/audio-waveform/index.d.ts +1 -0
- package/lib/components/webchat-input/audio-waveform/static-waveform.d.ts +9 -0
- package/lib/components/webchat-input/constants.d.ts +3 -0
- package/lib/components/webchat-input/icons/cancel-icon.d.ts +1 -0
- package/lib/components/webchat-input/icons/close-icon.d.ts +1 -0
- package/lib/components/webchat-input/icons/confirm-icon.d.ts +1 -0
- package/lib/components/webchat-input/icons/file-icon.d.ts +2 -0
- package/lib/components/webchat-input/icons/file-pdf-icon.d.ts +2 -0
- package/lib/components/webchat-input/icons/pause-icon.d.ts +1 -0
- package/lib/components/webchat-input/icons/play-icon.d.ts +1 -0
- package/lib/components/webchat-input/use-webchat-input.d.ts +21 -10
- package/lib/components/webchat-input/webchat-input.d.ts +6 -1
- package/lib/components/webchat-messages/use-webchat-messages-list-scroll.d.ts +15 -0
- package/lib/components/webchat-messages/use-webchat-messages.d.ts +18 -0
- package/lib/components/webchat-provider/webchat-context.d.ts +8 -0
- package/lib/components/webchat-provider/webchat-provider.d.ts +1 -10
- package/lib/components/webchat-trigger/icons/chat-icon.d.ts +1 -0
- package/lib/components/webchat-trigger/icons/chevron-down-icon.d.ts +1 -0
- package/lib/components/webchat-trigger/use-webchat-trigger.d.ts +10 -0
- package/lib/contexts/media-playback-context.d.ts +11 -0
- package/lib/hero-header-layout/index.d.ts +3 -0
- package/lib/hero-header-layout/use-webchat-hero-header-layout.d.ts +40 -0
- package/lib/hero-header-layout/webchat-hero-header-layout-config.d.ts +26 -0
- package/lib/hero-header-layout/webchat-hero-header-layout-utils.d.ts +2 -0
- package/lib/hooks/use-audio-recorder.d.ts +20 -0
- package/lib/hooks/use-webchat-state.d.ts +7 -0
- package/lib/hooks/webchat-client-settings-behaviors.d.ts +13 -0
- package/lib/types/webchat-props.d.ts +43 -2
- package/lib/utils/audio-utils.d.ts +1 -0
- package/lib/utils/uuid-utils.d.ts +1 -0
- package/package.json +4 -3
- package/styles.css +154 -14
- package/trigger.js +231 -135
- package/webchat-app-DSDMjE-m.js +4051 -0
- package/lib/components/webchat-messages/use-custom-scrollbar.d.ts +0 -11
- package/webchat-app-CLGvs-LL.js +0 -2518
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { WebchatController } from '@botonic/webchat-core';
|
|
2
|
+
import { ComponentType } from 'react';
|
|
3
|
+
import { WebchatHeroHeaderLayoutConfig } from '../../hero-header-layout';
|
|
2
4
|
import { WebchatStateProps } from '../../hooks/use-webchat-state';
|
|
3
5
|
import { WebchatInputIcons } from '../../types/webchat-props';
|
|
4
6
|
import { CoverComponentRegistry } from '../webchat-overlay';
|
|
5
7
|
export interface WebchatAppProps extends Omit<WebchatStateProps, 'customMessages'> {
|
|
6
8
|
/** Whether the webchat is open */
|
|
7
9
|
isOpen: boolean;
|
|
8
|
-
/** Callback when webchat is closed */
|
|
10
|
+
/** Callback when the webchat is closed */
|
|
9
11
|
onClose?: () => void;
|
|
10
12
|
/** Callback when controller is ready - passes the controller instance */
|
|
11
13
|
onControllerReady?: (controller: WebchatController) => void;
|
|
@@ -21,11 +23,16 @@ export interface WebchatAppProps extends Omit<WebchatStateProps, 'customMessages
|
|
|
21
23
|
*/
|
|
22
24
|
showBranding?: boolean;
|
|
23
25
|
/** Custom messages registry */
|
|
24
|
-
customMessages?: Record<string,
|
|
26
|
+
customMessages?: Record<string, ComponentType<any>>;
|
|
25
27
|
/** Cover components registry */
|
|
26
28
|
coverRegistry?: CoverComponentRegistry;
|
|
27
29
|
/** Override default icons for the input action bar. */
|
|
28
30
|
icons?: WebchatInputIcons;
|
|
31
|
+
/**
|
|
32
|
+
* Optional overrides for hero ↔ compact header behavior (merged with defaults).
|
|
33
|
+
* Same object can be passed inside `WebchatTrigger` → `webchatConfig.heroHeaderLayout`.
|
|
34
|
+
*/
|
|
35
|
+
heroHeaderLayout?: Partial<WebchatHeroHeaderLayoutConfig>;
|
|
29
36
|
}
|
|
30
37
|
/**
|
|
31
38
|
* WebchatApp - Complete webchat component for lazy loading
|
|
@@ -46,4 +53,4 @@ export interface WebchatAppProps extends Omit<WebchatStateProps, 'customMessages
|
|
|
46
53
|
* />
|
|
47
54
|
* ```
|
|
48
55
|
*/
|
|
49
|
-
export declare function WebchatApp({ appId, isOpen, onClose, onControllerReady, title, placeholder, showBranding, customMessages, avatarConfig, coverRegistry, icons, ...restConfig }: WebchatAppProps): import("react/jsx-runtime").JSX.Element;
|
|
56
|
+
export declare function WebchatApp({ appId, isOpen, onClose, onControllerReady, title, placeholder, showBranding, customMessages, avatarConfig, coverRegistry, icons, heroHeaderLayout, ...restConfig }: WebchatAppProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,6 +4,7 @@ import { WebchatContainerProps } from '../../types/webchat-props';
|
|
|
4
4
|
export declare function useWebchatContainer(props: Omit<WebchatContainerProps, 'children'>, state: WebchatState, ref: RefObject<HTMLDivElement>): {
|
|
5
5
|
shouldRender: boolean;
|
|
6
6
|
containerProps: {
|
|
7
|
+
style?: import('react').CSSProperties | undefined;
|
|
7
8
|
ref: RefObject<HTMLDivElement>;
|
|
8
9
|
role: string;
|
|
9
10
|
'aria-label': string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function CloseIcon(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function DownloadIcon(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function LeaveIcon(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function MenuIcon(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function SoundsIcon(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function StartOverIcon(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,19 +1,28 @@
|
|
|
1
|
-
import { RefObject } from 'react';
|
|
1
|
+
import { CSSProperties, RefObject } from 'react';
|
|
2
2
|
import { WebchatState } from '../../hooks/use-webchat-state';
|
|
3
3
|
import { WebchatHeaderProps } from '../../types/webchat-props';
|
|
4
|
+
type HeaderStyle = CSSProperties & Record<`--${string}`, string>;
|
|
4
5
|
export declare function useWebchatHeader(props: WebchatHeaderProps, state: WebchatState, ref: RefObject<HTMLElement>): {
|
|
5
6
|
headerProps: {
|
|
6
7
|
ref: RefObject<HTMLElement>;
|
|
7
8
|
'aria-label': string;
|
|
9
|
+
style: HeaderStyle;
|
|
10
|
+
'data-webchat-responsive-hero': string;
|
|
11
|
+
children?: import('react').ReactNode;
|
|
8
12
|
};
|
|
9
13
|
title: string;
|
|
14
|
+
avatarSrc: string | undefined;
|
|
15
|
+
avatarSvg: string | undefined;
|
|
16
|
+
avatarAlt: string | undefined;
|
|
10
17
|
showStatus: boolean;
|
|
11
18
|
statusText: string | undefined;
|
|
12
19
|
showClose: boolean;
|
|
13
20
|
onClose: () => void;
|
|
14
21
|
connectionStatus: any;
|
|
15
22
|
variants: {
|
|
16
|
-
variant: "default";
|
|
23
|
+
variant: "expanded" | "collapsed" | "default";
|
|
24
|
+
hasShadow: boolean;
|
|
17
25
|
className: string | undefined;
|
|
18
26
|
};
|
|
19
27
|
};
|
|
28
|
+
export {};
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { AriaButtonProps } from 'react-aria';
|
|
1
2
|
import { WebchatHeaderProps } from '../../types/webchat-props';
|
|
2
|
-
export declare
|
|
3
|
+
export declare const MenuTriggerButton: import('react').ForwardRefExoticComponent<AriaButtonProps<"button"> & import('react').RefAttributes<HTMLButtonElement>>;
|
|
4
|
+
export declare function CloseButton(props: AriaButtonProps<'button'>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function WebchatHeader({ children, ...propsWithoutSlots }: WebchatHeaderProps): import("react/jsx-runtime").JSX.Element;
|
package/lib/components/webchat-header/webchat-menu/dropdown-menu-item-download-transcript.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export interface DropdownMenuItemDownloadTranscriptProps {
|
|
2
|
+
onClose?: () => void;
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
export declare function DropdownMenuItemDownloadTranscript({ onClose, children, }: DropdownMenuItemDownloadTranscriptProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export interface DropdownMenuItemResetConversationProps {
|
|
2
|
+
onClose?: () => void;
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
export declare function DropdownMenuItemResetConversation({ onClose, children, }: DropdownMenuItemResetConversationProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ChangeEvent } from 'react';
|
|
2
|
+
export interface PendingAttachment {
|
|
3
|
+
id: string;
|
|
4
|
+
file: File;
|
|
5
|
+
previewUrl: string;
|
|
6
|
+
fileType: 'image' | 'video' | 'document';
|
|
7
|
+
}
|
|
8
|
+
export interface AttachmentListProps {
|
|
9
|
+
attachments: PendingAttachment[];
|
|
10
|
+
onRemove: (id: string) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function useAttachmentPreview(): {
|
|
13
|
+
attachments: PendingAttachment[];
|
|
14
|
+
hasAttachments: boolean;
|
|
15
|
+
attachmentError: string | undefined;
|
|
16
|
+
fileInputRef: import('react').RefObject<HTMLInputElement>;
|
|
17
|
+
handleFileInputChange: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
18
|
+
handleRemoveAttachment: (id: string) => void;
|
|
19
|
+
clearAttachments: () => void;
|
|
20
|
+
handleOpenFilePicker: () => void;
|
|
21
|
+
sendAttachments: () => void;
|
|
22
|
+
attachmentListProps: AttachmentListProps;
|
|
23
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { AudioInputOverlayProps } from './use-audio-input';
|
|
2
|
+
export declare function AudioInput({ showControls, recordingControlsClassName, frozenIsRecording, frozenIsPreview, analyserNode, audioBlob, audioProgress, isPlaying, isPreview, handlePlayPause, handleSeekPreview, handleCancelRecording, timerDisplay, objectUrl, audioRef, handleAudioPlay, handleAudioPause, handleAudioEnded, handleAudioLoadedMetadata, handleAudioTimeUpdate, }: AudioInputOverlayProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { WebchatState } from '../../../hooks/use-webchat-state';
|
|
3
|
+
export interface AudioInputOverlayProps {
|
|
4
|
+
showControls: boolean;
|
|
5
|
+
recordingControlsClassName: string;
|
|
6
|
+
frozenIsRecording: boolean;
|
|
7
|
+
frozenIsPreview: boolean;
|
|
8
|
+
analyserNode: AnalyserNode | undefined;
|
|
9
|
+
audioBlob: Blob | undefined;
|
|
10
|
+
audioProgress: number;
|
|
11
|
+
isPlaying: boolean;
|
|
12
|
+
isPreview: boolean;
|
|
13
|
+
handlePlayPause: () => void;
|
|
14
|
+
handleSeekPreview: (progress: number) => void;
|
|
15
|
+
handleCancelRecording: () => void;
|
|
16
|
+
timerDisplay: string;
|
|
17
|
+
objectUrl: string;
|
|
18
|
+
audioRef: RefObject<HTMLAudioElement>;
|
|
19
|
+
handleAudioPlay: () => void;
|
|
20
|
+
handleAudioPause: () => void;
|
|
21
|
+
handleAudioEnded: () => void;
|
|
22
|
+
handleAudioLoadedMetadata: (e: React.SyntheticEvent<HTMLAudioElement>) => void;
|
|
23
|
+
handleAudioTimeUpdate: (e: React.SyntheticEvent<HTMLAudioElement>) => void;
|
|
24
|
+
}
|
|
25
|
+
export declare function useAudioInput(state: WebchatState, disabled?: boolean): {
|
|
26
|
+
audioRecordingAvailable: boolean;
|
|
27
|
+
hideBaseContent: boolean;
|
|
28
|
+
isPreview: boolean;
|
|
29
|
+
isRecording: boolean;
|
|
30
|
+
handleMicrophoneClick: () => void;
|
|
31
|
+
handleConfirmRecording: () => void;
|
|
32
|
+
handleSendRecording: () => void;
|
|
33
|
+
overlayProps: AudioInputOverlayProps;
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AudioWaveform } from './audio-waveform';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface StaticWaveformProps {
|
|
2
|
+
audioBlob: Blob;
|
|
3
|
+
/** Playback progress 0–1; bars before this point render at full opacity */
|
|
4
|
+
progress: number;
|
|
5
|
+
/** Called with a 0–1 seek position when the user clicks or drags the waveform */
|
|
6
|
+
onSeek?: (progress: number) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function StaticWaveform({ audioBlob, progress, onSeek, }: StaticWaveformProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function CancelIcon(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function CloseIcon(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ConfirmIcon(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function PauseIcon(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function PlayIcon(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,32 +7,43 @@ export declare function useWebchatInput(props: WebchatInputProps, state: Webchat
|
|
|
7
7
|
'aria-label': string;
|
|
8
8
|
'data-webchat-input': string;
|
|
9
9
|
icons?: import('../../..').WebchatInputIcons;
|
|
10
|
+
style?: import('react').CSSProperties;
|
|
10
11
|
};
|
|
11
12
|
inputValue: string;
|
|
12
13
|
hasText: boolean;
|
|
13
14
|
handleSubmit: (e: React.FormEvent) => void;
|
|
14
|
-
handleInputChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
15
|
-
handleKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
16
15
|
onEmojiClick: (() => void) | undefined;
|
|
17
|
-
onAttachmentClick: (
|
|
18
|
-
|
|
16
|
+
onAttachmentClick: () => void;
|
|
17
|
+
hasAttachments: boolean;
|
|
18
|
+
attachmentError: string | undefined;
|
|
19
|
+
fileInputRef: RefObject<HTMLInputElement>;
|
|
20
|
+
handleFileInputChange: (e: import('react').ChangeEvent<HTMLInputElement>) => void;
|
|
21
|
+
attachmentListProps: import('./attachment-preview').AttachmentListProps;
|
|
19
22
|
fieldProps: {
|
|
20
23
|
value: string;
|
|
21
24
|
onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
22
25
|
onKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
23
26
|
placeholder: string;
|
|
24
|
-
disabled: boolean | undefined;
|
|
25
|
-
rows: number;
|
|
26
|
-
};
|
|
27
|
-
primaryActionProps: {
|
|
28
|
-
type: "submit" | "button";
|
|
29
27
|
disabled: boolean;
|
|
30
|
-
|
|
28
|
+
rows: 1;
|
|
31
29
|
};
|
|
32
30
|
variants: {
|
|
33
31
|
variant: "default";
|
|
34
32
|
className: string | undefined;
|
|
35
33
|
};
|
|
34
|
+
isInputEnabled: boolean;
|
|
36
35
|
isInputDisabled: boolean | undefined;
|
|
36
|
+
inputBehavior: import('../../hooks/webchat-client-settings-behaviors').WebchatInputBehavior;
|
|
37
37
|
showBranding: boolean;
|
|
38
|
+
overlayProps: import('./audio-input').AudioInputOverlayProps;
|
|
39
|
+
hideBaseContent: boolean;
|
|
40
|
+
audioRecordingAvailable: boolean;
|
|
41
|
+
primaryBgClass: string;
|
|
42
|
+
primaryType: "button" | "submit";
|
|
43
|
+
isPrimaryDisabled: boolean;
|
|
44
|
+
primaryHandler: (() => void) | undefined;
|
|
45
|
+
primaryLabel: string;
|
|
46
|
+
showMic: boolean;
|
|
47
|
+
showConfirm: boolean;
|
|
48
|
+
showSend: boolean;
|
|
38
49
|
};
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import { WebchatInputProps } from '../../types/webchat-props';
|
|
2
|
-
|
|
2
|
+
declare module 'react' {
|
|
3
|
+
interface HTMLAttributes<T> {
|
|
4
|
+
inert?: '' | undefined;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export declare function WebchatInput(props: WebchatInputProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
export interface UseWebchatMessagesListScrollParams {
|
|
3
|
+
scrollRef: RefObject<HTMLDivElement | null>;
|
|
4
|
+
hasUserInteracted: boolean;
|
|
5
|
+
messageActorsLength: number;
|
|
6
|
+
isTyping: boolean;
|
|
7
|
+
onScrollDepthChange?: (hasDepth: boolean) => void;
|
|
8
|
+
onMessagesScrollAtTopChange?: (isAtTop: boolean) => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Scroll depth (header shadow), hero “at top” sync, and auto-scroll-to-bottom when the thread grows.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useWebchatMessagesListScroll({ scrollRef, hasUserInteracted, messageActorsLength, isTyping, onScrollDepthChange, onMessagesScrollAtTopChange, }: UseWebchatMessagesListScrollParams): {
|
|
14
|
+
handleScrollState: () => void;
|
|
15
|
+
};
|
|
@@ -8,15 +8,23 @@ export declare function useWebchatMessages(props: WebchatMessagesProps, state: W
|
|
|
8
8
|
'aria-live': "polite";
|
|
9
9
|
'data-webchat-messages': string;
|
|
10
10
|
enableScrollToBottom?: boolean;
|
|
11
|
+
style?: import('react').CSSProperties;
|
|
11
12
|
};
|
|
12
13
|
messageListProps: {
|
|
13
14
|
messageActors: import('xstate').ActorRef<import('xstate').MachineSnapshot<{
|
|
14
15
|
message: import('@botonic/shared').WebchatMessage;
|
|
15
16
|
user: import('@botonic/shared').HubtypeUser;
|
|
16
17
|
status: import('@botonic/webchat-core').WebchatMessageStatus;
|
|
18
|
+
file?: File;
|
|
17
19
|
postMessageActor?: any;
|
|
18
20
|
}, {
|
|
19
21
|
type: "RETRY";
|
|
22
|
+
} | {
|
|
23
|
+
type: "UPDATE_MESSAGE_INFO";
|
|
24
|
+
message: {
|
|
25
|
+
id: string;
|
|
26
|
+
data: Record<string, string>;
|
|
27
|
+
};
|
|
20
28
|
} | {
|
|
21
29
|
type: "BUTTON_CLICKED";
|
|
22
30
|
button: import('@botonic/shared').BotonicButtonContent;
|
|
@@ -32,6 +40,12 @@ export declare function useWebchatMessages(props: WebchatMessagesProps, state: W
|
|
|
32
40
|
};
|
|
33
41
|
}>, {
|
|
34
42
|
type: "RETRY";
|
|
43
|
+
} | {
|
|
44
|
+
type: "UPDATE_MESSAGE_INFO";
|
|
45
|
+
message: {
|
|
46
|
+
id: string;
|
|
47
|
+
data: Record<string, string>;
|
|
48
|
+
};
|
|
35
49
|
} | {
|
|
36
50
|
type: "BUTTON_CLICKED";
|
|
37
51
|
button: import('@botonic/shared').BotonicButtonContent;
|
|
@@ -43,9 +57,13 @@ export declare function useWebchatMessages(props: WebchatMessagesProps, state: W
|
|
|
43
57
|
title: string;
|
|
44
58
|
}>[];
|
|
45
59
|
isTyping: any;
|
|
60
|
+
hasUserInteracted: boolean;
|
|
46
61
|
customMessageRenderer: undefined;
|
|
47
62
|
botAvatarConfig: import('../message-machine-renderer').AvatarConfigResult | null;
|
|
48
63
|
agentAvatarConfig: import('../message-machine-renderer').AvatarConfigResult | null;
|
|
64
|
+
onScrollDepthChange: ((hasDepth: boolean) => void) | undefined;
|
|
65
|
+
onMessagesScrollAtTopChange: ((isAtTop: boolean) => void) | undefined;
|
|
66
|
+
onUserInteraction: (() => void) | undefined;
|
|
49
67
|
};
|
|
50
68
|
variants: {
|
|
51
69
|
variant: "default";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WebchatController } from '@botonic/webchat-core';
|
|
2
|
+
import { WebchatState } from '../../hooks/use-webchat-state';
|
|
3
|
+
export interface WebchatContextValue {
|
|
4
|
+
state: WebchatState;
|
|
5
|
+
controller: WebchatController;
|
|
6
|
+
}
|
|
7
|
+
export declare const WebchatContext: import('react').Context<WebchatContextValue | null>;
|
|
8
|
+
export declare function useWebchatContext(): WebchatContextValue;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { WebchatController } from '@botonic/webchat-core';
|
|
2
2
|
import { default as React } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
interface WebchatContextValue {
|
|
5
|
-
state: WebchatState;
|
|
6
|
-
controller: WebchatController;
|
|
7
|
-
}
|
|
3
|
+
import { WebchatStateProps } from '../../hooks/use-webchat-state';
|
|
8
4
|
export interface WebchatProviderProps extends WebchatStateProps {
|
|
9
5
|
children: React.ReactNode;
|
|
10
6
|
}
|
|
@@ -15,8 +11,3 @@ export interface WebchatProviderProps extends WebchatStateProps {
|
|
|
15
11
|
* It provides better state management, persistence, and error handling.
|
|
16
12
|
*/
|
|
17
13
|
export declare const WebchatProvider: React.ForwardRefExoticComponent<WebchatProviderProps & React.RefAttributes<WebchatController>>;
|
|
18
|
-
/**
|
|
19
|
-
* Hook to access webchat context
|
|
20
|
-
*/
|
|
21
|
-
export declare function useWebchatContext(): WebchatContextValue;
|
|
22
|
-
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ChatIcon(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ChevronDownIcon(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -34,5 +34,15 @@ export interface WebchatTriggerHookReturn {
|
|
|
34
34
|
handleLoadError: (error: Error) => void;
|
|
35
35
|
/** Increments on retry; use as key for Error Boundary so it resets */
|
|
36
36
|
retryKey: number;
|
|
37
|
+
/** True when new bot messages arrived while the chat was closed */
|
|
38
|
+
hasNewMessages: boolean;
|
|
39
|
+
/** True when the proactive pop-up should be visible */
|
|
40
|
+
isPopupVisible: boolean;
|
|
41
|
+
/** True while the pop-up is fading out */
|
|
42
|
+
isPopupDismissing: boolean;
|
|
43
|
+
/** The proactive message text (forwarded from props for render layer) */
|
|
44
|
+
proactiveMessage: string | undefined;
|
|
45
|
+
/** Call on animationend of the popup element to complete dismissal */
|
|
46
|
+
onPopupAnimationEnd: () => void;
|
|
37
47
|
}
|
|
38
48
|
export declare function useWebchatTrigger(props: WebchatTriggerProps, ref: RefObject<HTMLButtonElement>): WebchatTriggerHookReturn;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface MediaPlaybackContextValue {
|
|
2
|
+
activeId: string | undefined;
|
|
3
|
+
setActive: (id: string) => void;
|
|
4
|
+
clearActive: (id: string) => void;
|
|
5
|
+
pauseAll: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function MediaPlaybackProvider({ children, }: {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function useMediaPlayback(): MediaPlaybackContextValue;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { useWebchatHeroHeaderLayout, type UseWebchatHeroHeaderLayoutParams, type WebchatHeroHeaderLayoutResult, } from './use-webchat-hero-header-layout';
|
|
2
|
+
export { DEFAULT_WEBCHAT_HERO_HEADER_LAYOUT_CONFIG, mergeWebchatHeroHeaderLayoutConfig, type WebchatHeroHeaderLayoutConfig, } from './webchat-hero-header-layout-config';
|
|
3
|
+
export { getMessageActorCount } from './webchat-hero-header-layout-utils';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { WebchatController } from '@botonic/webchat-core';
|
|
2
|
+
import { WebchatHeroHeaderLayoutConfig } from './webchat-hero-header-layout-config';
|
|
3
|
+
export interface UseWebchatHeroHeaderLayoutParams {
|
|
4
|
+
controller: WebchatController;
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
/** Partial overrides; merged with {@link DEFAULT_WEBCHAT_HERO_HEADER_LAYOUT_CONFIG}. */
|
|
7
|
+
layout?: Partial<WebchatHeroHeaderLayoutConfig>;
|
|
8
|
+
/**
|
|
9
|
+
* Mirrors `WebchatConfig.enableResponsiveHeroHeader`. When false, the responsive hero
|
|
10
|
+
* and related scroll/engagement syncing are skipped (fixed compact header).
|
|
11
|
+
*/
|
|
12
|
+
enableResponsiveHeroHeader?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface WebchatHeroHeaderLayoutResult {
|
|
15
|
+
/** Pass to {@link WebchatHeader}: `variant`, `collapseProgress`, `hasShadow`. */
|
|
16
|
+
header: {
|
|
17
|
+
variant: 'expanded' | 'collapsed';
|
|
18
|
+
collapseProgress: 0 | 1;
|
|
19
|
+
hasShadow: boolean;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Spread onto {@link WebchatMessages}: scroll / interaction wiring for header sync.
|
|
23
|
+
*/
|
|
24
|
+
messages: {
|
|
25
|
+
hasUserInteracted: boolean;
|
|
26
|
+
onScrollDepthChange: (hasDepth: boolean) => void;
|
|
27
|
+
onMessagesScrollAtTopChange: (isAtTop: boolean) => void;
|
|
28
|
+
onUserInteraction: () => void;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Single callback for “user engaged” surfaces (composer send, quick replies, etc.).
|
|
32
|
+
* Wire to {@link WebchatInput} `onUserMessageSent` and any other engagement hooks you add.
|
|
33
|
+
*/
|
|
34
|
+
onUserEngagement: () => void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Encapsulates hero ↔ compact header state for the default app: conversation length, panel open,
|
|
38
|
+
* scroll-at-top, and user engagement. Tune via {@link WebchatHeroHeaderLayoutConfig} or CSS tokens.
|
|
39
|
+
*/
|
|
40
|
+
export declare function useWebchatHeroHeaderLayout({ controller, isOpen, layout: layoutPartial, enableResponsiveHeroHeader, }: UseWebchatHeroHeaderLayoutParams): WebchatHeroHeaderLayoutResult;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Controls hero vs compact header behavior for the default bundled webchat layout (`WebchatApp`).
|
|
3
|
+
* Pass via the `heroHeaderLayout` prop or `WebchatTrigger` → `webchatConfig.heroHeaderLayout`.
|
|
4
|
+
*
|
|
5
|
+
* Turn off the responsive hero header via `WebchatConfig.enableResponsiveHeroHeader` / `webchatConfig.enableResponsiveHeroHeader`.
|
|
6
|
+
*
|
|
7
|
+
* Transition speed / easing use CSS tokens (e.g. `--webchat-header-collapse-duration` in `webchat-tokens.css`).
|
|
8
|
+
*/
|
|
9
|
+
export interface WebchatHeroHeaderLayoutConfig {
|
|
10
|
+
/**
|
|
11
|
+
* When true (default), a thread that already has messages uses the compact header on load
|
|
12
|
+
* (persisted history, reopen after lazy load, first batch after restore).
|
|
13
|
+
*/
|
|
14
|
+
collapsedByDefaultWhenConversationHasMessages: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* When true (default), collapse the hero after the user engages (composer send, message actions, etc.).
|
|
17
|
+
*/
|
|
18
|
+
collapseOnUserEngagement: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* When true (default), scrolling back to the top of the message list restores the expanded hero,
|
|
21
|
+
* after the list has left the top at least once (avoids collapse→expand flicker on first tap).
|
|
22
|
+
*/
|
|
23
|
+
expandHeroWhenReturningToScrollTop: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare const DEFAULT_WEBCHAT_HERO_HEADER_LAYOUT_CONFIG: WebchatHeroHeaderLayoutConfig;
|
|
26
|
+
export declare function mergeWebchatHeroHeaderLayoutConfig(partial?: Partial<WebchatHeroHeaderLayoutConfig>): WebchatHeroHeaderLayoutConfig;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type AudioRecorderState = 'idle' | 'recording' | 'preview';
|
|
2
|
+
export interface UseAudioRecorderResult {
|
|
3
|
+
/** Current state in the recording flow */
|
|
4
|
+
recorderState: AudioRecorderState;
|
|
5
|
+
/** The recorded audio blob — available in preview state */
|
|
6
|
+
audioBlob: Blob | undefined;
|
|
7
|
+
/** AnalyserNode for waveform visualisation — available while recording */
|
|
8
|
+
analyserNode: AnalyserNode | undefined;
|
|
9
|
+
/** Whether the browser supports getUserMedia + MediaRecorder */
|
|
10
|
+
isSupported: boolean;
|
|
11
|
+
/** Set when getUserMedia throws NotAllowedError */
|
|
12
|
+
permissionError: boolean;
|
|
13
|
+
/** Start recording — transitions idle → recording */
|
|
14
|
+
startRecording: () => Promise<void>;
|
|
15
|
+
/** Stop and keep the recording — transitions recording → preview */
|
|
16
|
+
confirmRecording: () => void;
|
|
17
|
+
/** Discard current recording — transitions recording|preview → idle */
|
|
18
|
+
cancelRecording: () => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function useAudioRecorder(): UseAudioRecorderResult;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { WebchatClientSettings } from '@botonic/shared';
|
|
1
2
|
import { OverlayState, WebchatConfig, WebchatController, WebchatMessageMachine } from '@botonic/webchat-core';
|
|
2
3
|
import { ActorRefFrom } from 'xstate';
|
|
3
4
|
import { AvatarConfig } from '../components/message-machine-renderer/use-avatar';
|
|
5
|
+
import { WebchatClientSettingsBehaviors } from './webchat-client-settings-behaviors';
|
|
4
6
|
export type WebchatStateProps = WebchatConfig & {
|
|
5
7
|
avatarConfig?: AvatarConfig;
|
|
6
8
|
customMessages: any;
|
|
@@ -14,8 +16,13 @@ export interface WebchatState {
|
|
|
14
16
|
initializationError: boolean;
|
|
15
17
|
messageActors: ActorRefFrom<typeof WebchatMessageMachine>[];
|
|
16
18
|
connectionStatus: string;
|
|
19
|
+
webchatClientSettings: WebchatClientSettings;
|
|
20
|
+
webchatClientSettingsBehaviors: WebchatClientSettingsBehaviors;
|
|
17
21
|
overlayState: OverlayState | null;
|
|
22
|
+
soundsEnabled: boolean;
|
|
18
23
|
avatarConfig?: AvatarConfig;
|
|
24
|
+
/** Mirrors `WebchatConfig.enableResponsiveHeroHeader`; default true. */
|
|
25
|
+
enableResponsiveHeroHeader: boolean;
|
|
19
26
|
customMessages: any;
|
|
20
27
|
}
|
|
21
28
|
export declare function useWebchatState(stateProps: WebchatStateProps): WebchatState;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { WebchatClientSettings } from '@botonic/shared';
|
|
2
|
+
export interface WebchatInputBehavior {
|
|
3
|
+
isComposerVisible: boolean;
|
|
4
|
+
isTextInputEnabled: boolean;
|
|
5
|
+
areAttachmentsVisible: boolean;
|
|
6
|
+
isEmojiPickerVisible: boolean;
|
|
7
|
+
isAudioRecordingVisible: boolean;
|
|
8
|
+
blockInputs: WebchatClientSettings['block_inputs'];
|
|
9
|
+
}
|
|
10
|
+
export interface WebchatClientSettingsBehaviors {
|
|
11
|
+
input: WebchatInputBehavior;
|
|
12
|
+
}
|
|
13
|
+
export declare function createWebchatClientSettingsBehaviors(settings: WebchatClientSettings): WebchatClientSettingsBehaviors;
|