@botonic/webchat-react 2.23.1

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +269 -0
  2. package/README.md +236 -0
  3. package/index.d.ts +81 -0
  4. package/index.js +46 -0
  5. package/lib/components/message/audio-message/audio-message.d.ts +20 -0
  6. package/lib/components/message/audio-message/index.d.ts +1 -0
  7. package/lib/components/message/button-message/button-message.d.ts +24 -0
  8. package/lib/components/message/button-message/index.d.ts +1 -0
  9. package/lib/components/message/carousel-message/carousel-message.d.ts +18 -0
  10. package/lib/components/message/carousel-message/index.d.ts +1 -0
  11. package/lib/components/message/document-message/document-message.d.ts +22 -0
  12. package/lib/components/message/document-message/index.d.ts +1 -0
  13. package/lib/components/message/image-message/image-message.d.ts +14 -0
  14. package/lib/components/message/image-message/index.d.ts +1 -0
  15. package/lib/components/message/index.d.ts +33 -0
  16. package/lib/components/message/location-message/index.d.ts +1 -0
  17. package/lib/components/message/location-message/location-message.d.ts +16 -0
  18. package/lib/components/message/message/index.d.ts +5 -0
  19. package/lib/components/message/message/message-avatar/index.d.ts +1 -0
  20. package/lib/components/message/message/message-avatar/message-avatar.d.ts +24 -0
  21. package/lib/components/message/message/message-bubble/index.d.ts +1 -0
  22. package/lib/components/message/message/message-bubble/message-bubble.d.ts +17 -0
  23. package/lib/components/message/message/message-info/index.d.ts +1 -0
  24. package/lib/components/message/message/message-info/message-info.d.ts +25 -0
  25. package/lib/components/message/message/message.d.ts +23 -0
  26. package/lib/components/message/message/use-message.d.ts +43 -0
  27. package/lib/components/message/text-message/index.d.ts +1 -0
  28. package/lib/components/message/text-message/text-message.d.ts +10 -0
  29. package/lib/components/message/video-message/index.d.ts +1 -0
  30. package/lib/components/message/video-message/video-message.d.ts +20 -0
  31. package/lib/components/message-machine-renderer/index.d.ts +3 -0
  32. package/lib/components/message-machine-renderer/message-machine-renderer.d.ts +28 -0
  33. package/lib/components/message-machine-renderer/use-avatar.d.ts +34 -0
  34. package/lib/components/message-machine-renderer/use-message-machine-renderer.d.ts +31 -0
  35. package/lib/components/shared/button-component/button-component.d.ts +24 -0
  36. package/lib/components/shared/button-component/index.d.ts +2 -0
  37. package/lib/components/shared/index.d.ts +2 -0
  38. package/lib/components/typing-indicator/index.d.ts +1 -0
  39. package/lib/components/typing-indicator/typing-indicator.d.ts +11 -0
  40. package/lib/components/webchat-app/index.d.ts +1 -0
  41. package/lib/components/webchat-app/webchat-app.d.ts +41 -0
  42. package/lib/components/webchat-container/use-webchat-container.d.ts +26 -0
  43. package/lib/components/webchat-container/webchat-container.d.ts +2 -0
  44. package/lib/components/webchat-header/use-webchat-header.d.ts +19 -0
  45. package/lib/components/webchat-header/webchat-header.d.ts +2 -0
  46. package/lib/components/webchat-input/use-webchat-input.d.ts +31 -0
  47. package/lib/components/webchat-input/webchat-input.d.ts +2 -0
  48. package/lib/components/webchat-messages/use-webchat-messages.d.ts +54 -0
  49. package/lib/components/webchat-messages/webchat-messages.d.ts +2 -0
  50. package/lib/components/webchat-overlay/base/confirm-modal/confirm-modal.d.ts +8 -0
  51. package/lib/components/webchat-overlay/base/confirm-modal/index.d.ts +2 -0
  52. package/lib/components/webchat-overlay/base/content/content.d.ts +9 -0
  53. package/lib/components/webchat-overlay/base/content/index.d.ts +2 -0
  54. package/lib/components/webchat-overlay/base/header/header.d.ts +4 -0
  55. package/lib/components/webchat-overlay/base/header/index.d.ts +3 -0
  56. package/lib/components/webchat-overlay/base/header/use-header.d.ts +13 -0
  57. package/lib/components/webchat-overlay/base/index.d.ts +5 -0
  58. package/lib/components/webchat-overlay/base/overlay/index.d.ts +3 -0
  59. package/lib/components/webchat-overlay/base/overlay/overlay.d.ts +18 -0
  60. package/lib/components/webchat-overlay/base/overlay/use-overlay.d.ts +23 -0
  61. package/lib/components/webchat-overlay/base/overlay-context.d.ts +25 -0
  62. package/lib/components/webchat-overlay/cover/frame/cover-frame.d.ts +8 -0
  63. package/lib/components/webchat-overlay/cover/frame/index.d.ts +2 -0
  64. package/lib/components/webchat-overlay/cover/index.d.ts +1 -0
  65. package/lib/components/webchat-overlay/index.d.ts +3 -0
  66. package/lib/components/webchat-overlay/webview/frame/index.d.ts +2 -0
  67. package/lib/components/webchat-overlay/webview/frame/webview-frame.d.ts +8 -0
  68. package/lib/components/webchat-overlay/webview/index.d.ts +1 -0
  69. package/lib/components/webchat-provider/webchat-provider.d.ts +22 -0
  70. package/lib/components/webchat-trigger/use-webchat-trigger.d.ts +38 -0
  71. package/lib/components/webchat-trigger/webchat-trigger-error-boundary.d.ts +19 -0
  72. package/lib/components/webchat-trigger/webchat-trigger.d.ts +2 -0
  73. package/lib/hooks/use-webchat-state.d.ts +21 -0
  74. package/lib/types/primitives.d.ts +15 -0
  75. package/lib/types/webchat-props.d.ts +103 -0
  76. package/package.json +37 -0
  77. package/styles.css +466 -0
  78. package/trigger.d.ts +40 -0
  79. package/trigger.js +215 -0
  80. package/webchat-app-CtAHJapU.js +2285 -0
@@ -0,0 +1,18 @@
1
+ import { BotonicButtonContent, BotonicCarouselElement } from '@botonic/shared';
2
+ import { MessageProps } from '../message';
3
+ export interface CarouselElement extends BotonicCarouselElement {
4
+ id: string;
5
+ }
6
+ export interface CarouselMessageProps extends Omit<MessageProps, 'children'> {
7
+ /** The carousel elements to display. */
8
+ elements: CarouselElement[];
9
+ /** Callback when a button is clicked. */
10
+ onButtonClick?: (button: BotonicButtonContent) => void;
11
+ /** Callback when an element image loads. */
12
+ onElementImageLoad?: (elementIndex: number) => void;
13
+ /** Additional CSS class names. */
14
+ className?: string;
15
+ }
16
+ /** Carousel message component displaying a list of elements with images and buttons. */
17
+ export declare const CarouselMessage: import('react').ForwardRefExoticComponent<CarouselMessageProps & import('react').RefAttributes<HTMLDivElement>>;
18
+ export default CarouselMessage;
@@ -0,0 +1 @@
1
+ export { type CarouselElement, type CarouselMessageProps, } from './carousel-message';
@@ -0,0 +1,22 @@
1
+ import { MessageProps } from '../message';
2
+ export interface DocumentMessageProps extends Omit<MessageProps, 'children'> {
3
+ /** The document URL. */
4
+ src: string;
5
+ /** The filename of the document. */
6
+ filename?: string;
7
+ /** The MIME type of the document. */
8
+ mimeType?: string;
9
+ /** The file size in bytes. */
10
+ size?: number;
11
+ /** Alt text for the document (for accessibility). */
12
+ alt?: string;
13
+ /** Callback when document loads (useful for scroll adjustment). */
14
+ onDocumentLoad?: () => void;
15
+ /** Callback when document is downloaded. */
16
+ onDownload?: () => void;
17
+ /** Additional CSS class names to apply to the message. */
18
+ className?: string;
19
+ }
20
+ /** Document message component for displaying document messages. */
21
+ export declare const DocumentMessage: import('react').ForwardRefExoticComponent<DocumentMessageProps & import('react').RefAttributes<HTMLDivElement>>;
22
+ export default DocumentMessage;
@@ -0,0 +1 @@
1
+ export { default, DocumentMessage, type DocumentMessageProps, } from './document-message';
@@ -0,0 +1,14 @@
1
+ import { MessageProps } from '../message';
2
+ export interface ImageMessageProps extends Omit<MessageProps, 'children'> {
3
+ /** The image URL. */
4
+ src: string;
5
+ /** Alt text for the image. */
6
+ alt?: string;
7
+ /** Callback when image loads (useful for scroll adjustment). */
8
+ onImageLoad?: () => void;
9
+ /** Additional CSS class names to apply to the message. */
10
+ className?: string;
11
+ }
12
+ /** Image message component for displaying image messages. */
13
+ export declare const ImageMessage: import('react').ForwardRefExoticComponent<ImageMessageProps & import('react').RefAttributes<HTMLDivElement>>;
14
+ export default ImageMessage;
@@ -0,0 +1 @@
1
+ export { default, ImageMessage, type ImageMessageProps } from './image-message';
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Message Components
3
+ *
4
+ * All message components now support custom CSS classes via the `className` prop.
5
+ * Each message type has its own CSS module with a base class that can be extended:
6
+ *
7
+ * - TextMessage: `.textMessageBase` class for text-specific styling
8
+ * - ImageMessage: `.imageMessageBase` class for image-specific styling
9
+ * - AudioMessage: `.audioMessageBase` class for audio-specific styling
10
+ * - VideoMessage: `.videoMessageBase` class for video-specific styling
11
+ * - DocumentMessage: `.documentMessageBase` class for document-specific styling
12
+ * - LocationMessage: `.locationMessageBase` class for location-specific styling
13
+ * - CarouselMessage: `.carouselMessageBase` class for carousel-specific styling
14
+ * - ButtonMessage: `.buttonMessageBase` class for button-specific styling
15
+ *
16
+ * Usage example:
17
+ * ```tsx
18
+ * <TextMessage
19
+ * text="Hello world"
20
+ * className="my-custom-text-style"
21
+ * variant="bot"
22
+ * />
23
+ * ```
24
+ */
25
+ export { Message, type MessageProps } from './message';
26
+ export { AudioMessage, type AudioMessageProps } from './audio-message';
27
+ export { ButtonMessage, type ButtonMessageProps, type MessageButton, } from './button-message';
28
+ export { type CarouselElement, type CarouselMessageProps, } from './carousel-message';
29
+ export { DocumentMessage, type DocumentMessageProps } from './document-message';
30
+ export { ImageMessage, type ImageMessageProps } from './image-message';
31
+ export { LocationMessage, type LocationMessageProps } from './location-message';
32
+ export { TextMessage, type TextMessageProps } from './text-message';
33
+ export { VideoMessage, type VideoMessageProps } from './video-message';
@@ -0,0 +1 @@
1
+ export { default, LocationMessage, type LocationMessageProps, } from './location-message';
@@ -0,0 +1,16 @@
1
+ import { MessageProps } from '../message';
2
+ export interface LocationMessageProps extends Omit<MessageProps, 'children'> {
3
+ /** The latitude coordinate. */
4
+ latitude: number;
5
+ /** The longitude coordinate. */
6
+ longitude: number;
7
+ /** Alt text for accessibility. */
8
+ alt?: string;
9
+ /** Callback when location loads. */
10
+ onLocationLoad?: () => void;
11
+ /** Additional CSS class names. */
12
+ className?: string;
13
+ }
14
+ /** Location message component for displaying location coordinates. */
15
+ export declare const LocationMessage: import('react').ForwardRefExoticComponent<LocationMessageProps & import('react').RefAttributes<HTMLDivElement>>;
16
+ export default LocationMessage;
@@ -0,0 +1,5 @@
1
+ export { Message, type MessageProps } from './message';
2
+ export { MessageAvatar, type MessageAvatarProps } from './message-avatar';
3
+ export { MessageBubble, type MessageBubbleProps } from './message-bubble';
4
+ export { MessageInfo, type MessageInfoProps } from './message-info';
5
+ export { useMessage, type UseMessageProps, type UseMessageReturn, } from './use-message';
@@ -0,0 +1 @@
1
+ export { MessageAvatar, type MessageAvatarProps } from './message-avatar';
@@ -0,0 +1,24 @@
1
+ import { default as React } from 'react';
2
+ export interface MessageAvatarProps {
3
+ /** The variant of the message indicating who sent it. */
4
+ variant?: 'user' | 'bot' | 'system' | 'agent';
5
+ /** The size of the avatar. */
6
+ size?: 'small' | 'medium' | 'large';
7
+ /** The source URL for the avatar image. */
8
+ src?: string;
9
+ /** Alt text for the avatar image. */
10
+ alt?: string;
11
+ /** SVG content as a string (alternative to src). */
12
+ svg?: string;
13
+ /** Whether to show sender name. */
14
+ showName?: boolean;
15
+ /** The sender name to display. */
16
+ name?: string;
17
+ /** Fallback content when no image is provided. */
18
+ fallback?: React.ReactNode;
19
+ /** A class name to apply to the avatar. */
20
+ className?: string;
21
+ }
22
+ /** Message avatar component that displays the sender's avatar. */
23
+ export declare const MessageAvatar: React.ForwardRefExoticComponent<MessageAvatarProps & React.RefAttributes<HTMLDivElement>>;
24
+ export default MessageAvatar;
@@ -0,0 +1 @@
1
+ export { MessageBubble, type MessageBubbleProps } from './message-bubble';
@@ -0,0 +1,17 @@
1
+ import { default as React } from 'react';
2
+ import { MessageAvatarProps } from '../message-avatar';
3
+ export interface MessageBubbleProps {
4
+ /** The variant of the message indicating who sent it. */
5
+ variant?: 'user' | 'bot' | 'system' | 'agent';
6
+ /** The status of the message. */
7
+ status?: 'sending' | 'sent' | 'error';
8
+ /** Avatar props when avatar should be rendered inside the bubble. */
9
+ avatarProps?: MessageAvatarProps;
10
+ /** A class name to apply to the bubble. */
11
+ className?: string;
12
+ /** The content to render inside the bubble. */
13
+ children: React.ReactNode;
14
+ }
15
+ /** Message bubble component that contains the actual message content. */
16
+ export declare const MessageBubble: React.ForwardRefExoticComponent<MessageBubbleProps & React.RefAttributes<HTMLDivElement>>;
17
+ export default MessageBubble;
@@ -0,0 +1 @@
1
+ export { MessageInfo, type MessageInfoProps } from './message-info';
@@ -0,0 +1,25 @@
1
+ import { default as React } from 'react';
2
+ import { MessageAvatarProps } from '../message-avatar';
3
+ export interface MessageInfoProps {
4
+ /** The variant of the message indicating who sent it. */
5
+ variant?: 'user' | 'bot' | 'system' | 'agent';
6
+ /** Position of the info relative to the bubble. */
7
+ position?: 'top' | 'bottom';
8
+ /** Whether to show timestamp. */
9
+ showTimestamp?: boolean;
10
+ /** The timestamp to display. */
11
+ timestamp?: string | Date;
12
+ /** Whether to show message status. */
13
+ showStatus?: boolean;
14
+ /** The status of the message. */
15
+ status?: 'sending' | 'sent' | 'error';
16
+ /** Avatar props when avatar should be rendered in the info area. */
17
+ avatarProps?: MessageAvatarProps;
18
+ /** A class name to apply to the info container. */
19
+ className?: string;
20
+ /** Additional content to render in the info area. */
21
+ children?: React.ReactNode;
22
+ }
23
+ /** Message info component that displays timestamp, status, and other metadata. */
24
+ export declare const MessageInfo: React.ForwardRefExoticComponent<MessageInfoProps & React.RefAttributes<HTMLDivElement>>;
25
+ export default MessageInfo;
@@ -0,0 +1,23 @@
1
+ import { default as React } from 'react';
2
+ import { AvatarConfigResult } from '../../message-machine-renderer/use-avatar';
3
+ export interface MessageProps {
4
+ /** The variant of the message indicating who sent it. */
5
+ variant?: 'user' | 'bot' | 'system' | 'agent';
6
+ /** The status of the message. */
7
+ status?: 'sending' | 'sent' | 'error';
8
+ /** Whether to show timestamp. */
9
+ showTimestamp?: boolean;
10
+ /** The timestamp to display. */
11
+ timestamp?: string | Date;
12
+ /** Whether to show message status. */
13
+ showStatus?: boolean;
14
+ /** Pre-computed avatar configuration from useAvatar hook. */
15
+ avatarConfig?: AvatarConfigResult;
16
+ /** A class name to apply to the message. */
17
+ className?: string;
18
+ /** The content to render inside the message bubble. */
19
+ children: React.ReactNode;
20
+ }
21
+ /** Message component with common functionality for all message types. */
22
+ export declare const Message: React.ForwardRefExoticComponent<MessageProps & React.RefAttributes<HTMLDivElement>>;
23
+ export default Message;
@@ -0,0 +1,43 @@
1
+ import { AvatarConfigResult } from '../../message-machine-renderer/use-avatar';
2
+ import { MessageAvatarProps } from './message-avatar';
3
+ import { MessageBubbleProps } from './message-bubble';
4
+ import { MessageInfoProps } from './message-info';
5
+ export interface UseMessageProps {
6
+ /** The variant of the message indicating who sent it. */
7
+ variant?: 'user' | 'bot' | 'system' | 'agent';
8
+ /** The status of the message. */
9
+ status?: 'sending' | 'sent' | 'error';
10
+ /** Whether to show timestamp. */
11
+ showTimestamp?: boolean;
12
+ /** The timestamp to display. */
13
+ timestamp?: string | Date;
14
+ /** Whether to show message status. */
15
+ showStatus?: boolean;
16
+ /** Pre-computed avatar configuration from useAvatar hook. */
17
+ avatarConfig?: AvatarConfigResult;
18
+ /** A class name to apply to the message. */
19
+ className?: string;
20
+ /** The content to render inside the bubble. */
21
+ children: React.ReactNode;
22
+ /** Additional props to pass through. */
23
+ [key: string]: any;
24
+ }
25
+ export interface UseMessageReturn {
26
+ /** CSS classes for the message container */
27
+ messageClasses: string;
28
+ /** Props to spread into MessageBubble component */
29
+ bubbleProps: MessageBubbleProps & {
30
+ avatarProps?: MessageAvatarProps;
31
+ };
32
+ /** Props to spread into MessageInfo component */
33
+ infoProps: MessageInfoProps & {
34
+ avatarProps?: MessageAvatarProps;
35
+ };
36
+ /** Props for standalone MessageAvatar component (null if integrated) */
37
+ standaloneAvatarProps: MessageAvatarProps | null;
38
+ }
39
+ /**
40
+ * Hook for Message component that handles avatar placement and prop distribution
41
+ * This hook receives pre-computed avatar configs for performance optimization
42
+ */
43
+ export declare function useMessage(props: UseMessageProps): UseMessageReturn;
@@ -0,0 +1 @@
1
+ export { default, TextMessage, type TextMessageProps } from './text-message';
@@ -0,0 +1,10 @@
1
+ import { MessageProps } from '../message';
2
+ export interface TextMessageProps extends Omit<MessageProps, 'children'> {
3
+ /** The text content of the message. */
4
+ text: string;
5
+ /** Additional CSS class names to apply to the message. */
6
+ className?: string;
7
+ }
8
+ /** Text message component for displaying plain text messages. */
9
+ export declare const TextMessage: import('react').ForwardRefExoticComponent<TextMessageProps & import('react').RefAttributes<HTMLDivElement>>;
10
+ export default TextMessage;
@@ -0,0 +1 @@
1
+ export { default, VideoMessage, type VideoMessageProps } from './video-message';
@@ -0,0 +1,20 @@
1
+ import { MessageProps } from '../message';
2
+ export interface VideoMessageProps extends Omit<MessageProps, 'children'> {
3
+ /** The video URL. */
4
+ src: string;
5
+ /** Alt text for the video (for accessibility). */
6
+ alt?: string;
7
+ /** Callback when video loads (useful for scroll adjustment). */
8
+ onVideoLoad?: () => void;
9
+ /** Callback when video starts playing. */
10
+ onPlay?: () => void;
11
+ /** Callback when video pauses. */
12
+ onPause?: () => void;
13
+ /** Callback when video ends. */
14
+ onEnded?: () => void;
15
+ /** Additional CSS class names to apply to the message. */
16
+ className?: string;
17
+ }
18
+ /** Video message component for displaying video messages. */
19
+ export declare const VideoMessage: import('react').ForwardRefExoticComponent<VideoMessageProps & import('react').RefAttributes<HTMLDivElement>>;
20
+ export default VideoMessage;
@@ -0,0 +1,3 @@
1
+ export { MessageMachineRenderer, type MessageMachineRendererProps, } from './message-machine-renderer';
2
+ export { type AvatarConfig, type AvatarConfigResult, useAvatar, type UseAvatarReturn, } from './use-avatar';
3
+ export { type MessageMachineData, useMessageMachineRenderer, type UseMessageMachineRendererOptions, } from './use-message-machine-renderer';
@@ -0,0 +1,28 @@
1
+ import { BotonicButtonContent } from '@botonic/shared';
2
+ import { WebchatMessageMachine } from '@botonic/webchat-core';
3
+ import { default as React } from 'react';
4
+ import { ActorRefFrom } from 'xstate';
5
+ import { MessageProps } from '../message/message';
6
+ import { AvatarConfig } from './use-avatar';
7
+ export interface MessageMachineRendererProps {
8
+ /** The XState message machine actor */
9
+ messageActor: ActorRefFrom<typeof WebchatMessageMachine>;
10
+ /** Custom renderer for custom message types */
11
+ customMessageRenderer?: (message: unknown, messageData: unknown, onButtonClick: (button: BotonicButtonContent) => void) => React.ReactNode;
12
+ /** Additional props to pass to all message components */
13
+ baseProps?: Partial<MessageProps> & {
14
+ avatarConfig?: AvatarConfig;
15
+ customMessages?: any;
16
+ };
17
+ /** Callback when content (like images) finishes loading */
18
+ onContentLoad?: () => void;
19
+ /** Callback when image starts loading */
20
+ onImageLoadStart?: (imageId: string) => void;
21
+ /** Callback when image finishes loading */
22
+ onImageLoadComplete?: (imageId: string) => void;
23
+ }
24
+ /**
25
+ * Pure UI component that renders a message machine state to UI components
26
+ * Uses the useMessageMachineRenderer hook from @botonic/webchat for all XState logic
27
+ */
28
+ export declare const MessageMachineRenderer: React.FC<MessageMachineRendererProps>;
@@ -0,0 +1,34 @@
1
+ import { MessageAvatarProps } from '../message/message/message-avatar';
2
+ export interface AvatarConfig {
3
+ bot?: {
4
+ placement: 'standalone' | 'bubble' | 'info';
5
+ src?: string;
6
+ alt?: string;
7
+ showName?: boolean;
8
+ name?: string;
9
+ /** SVG content as a string (alternative to src) */
10
+ svg?: string;
11
+ };
12
+ agent?: {
13
+ placement: 'standalone' | 'bubble' | 'info';
14
+ src?: string;
15
+ alt?: string;
16
+ showName?: boolean;
17
+ name?: string;
18
+ /** SVG content as a string (alternative to src) */
19
+ svg?: string;
20
+ };
21
+ }
22
+ export interface AvatarConfigResult {
23
+ placement: 'standalone' | 'bubble' | 'info';
24
+ avatarProps: MessageAvatarProps;
25
+ }
26
+ export interface UseAvatarReturn {
27
+ bot: AvatarConfigResult | null;
28
+ agent: AvatarConfigResult | null;
29
+ }
30
+ /**
31
+ * Hook that computes avatar configurations once for all messages
32
+ * This is a performance optimization to avoid recomputing avatar props for each message
33
+ */
34
+ export declare function useAvatar(avatarConfig?: AvatarConfig): UseAvatarReturn;
@@ -0,0 +1,31 @@
1
+ import { BotonicButtonContent, WebchatMessage } from '@botonic/shared';
2
+ import { WebchatMessageMachine } from '@botonic/webchat-core';
3
+ import { ActorRefFrom } from 'xstate';
4
+ import { AvatarConfigResult } from './use-avatar';
5
+ export interface MessageMachineData {
6
+ message: WebchatMessage;
7
+ status: 'unsent' | 'sent' | 'failed';
8
+ canRetry: boolean;
9
+ messageProps: {
10
+ variant: 'user' | 'bot' | 'agent';
11
+ status: 'sending' | 'sent' | 'error';
12
+ timestamp?: Date;
13
+ showTimestamp: boolean;
14
+ isClickable: boolean;
15
+ onPress?: () => void;
16
+ avatarConfig?: AvatarConfigResult;
17
+ };
18
+ handleButtonClick: (button: BotonicButtonContent) => void;
19
+ }
20
+ export interface UseMessageMachineRendererOptions {
21
+ messageActor: ActorRefFrom<typeof WebchatMessageMachine>;
22
+ baseProps?: Record<string, any> & {
23
+ botAvatarConfig?: AvatarConfigResult | null;
24
+ agentAvatarConfig?: AvatarConfigResult | null;
25
+ };
26
+ }
27
+ /**
28
+ * Hook that abstracts all XState machine logic for message rendering
29
+ * This handles machine state subscription, prop transformation, and interactions
30
+ */
31
+ export declare function useMessageMachineRenderer({ messageActor, baseProps, }: UseMessageMachineRendererOptions): MessageMachineData;
@@ -0,0 +1,24 @@
1
+ import { BotonicButtonContent } from '@botonic/shared';
2
+ export interface ButtonComponentProps {
3
+ /** The button text. */
4
+ text: string;
5
+ /** Whether the button is disabled. */
6
+ disabled?: boolean;
7
+ /** Handler for button click. */
8
+ onClick?: (button: BotonicButtonContent | {
9
+ text: string;
10
+ value: string;
11
+ }) => void;
12
+ /** The button data (either BotonicButtonContent or simple button data). */
13
+ button: BotonicButtonContent | {
14
+ text: string;
15
+ value: string;
16
+ };
17
+ /** Additional CSS class names to apply to the button. */
18
+ className?: string;
19
+ /** Button variant - 'primary' for carousel-style, 'secondary' for button-message-style. */
20
+ variant?: 'primary' | 'secondary';
21
+ }
22
+ /** Shared button component for use in button messages and carousel messages. */
23
+ export declare const ButtonComponent: import('react').ForwardRefExoticComponent<ButtonComponentProps & import('react').RefAttributes<HTMLButtonElement>>;
24
+ export default ButtonComponent;
@@ -0,0 +1,2 @@
1
+ export type { ButtonComponentProps } from './button-component';
2
+ export { ButtonComponent } from './button-component';
@@ -0,0 +1,2 @@
1
+ export type { ButtonComponentProps } from './button-component';
2
+ export { ButtonComponent } from './button-component';
@@ -0,0 +1 @@
1
+ export { TypingIndicator, type TypingIndicatorProps } from './typing-indicator';
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+ export interface TypingIndicatorProps {
3
+ /** Whether the typing indicator should be visible */
4
+ isVisible?: boolean;
5
+ /** Custom class name for styling */
6
+ className?: string;
7
+ }
8
+ /**
9
+ * Typing indicator component that shows animated dots when the bot is typing
10
+ */
11
+ export declare const TypingIndicator: React.FC<TypingIndicatorProps>;
@@ -0,0 +1 @@
1
+ export { WebchatApp, type WebchatAppProps } from './webchat-app';
@@ -0,0 +1,41 @@
1
+ import { WebchatController } from '@botonic/webchat-core';
2
+ import { WebchatStateProps } from '../../hooks/use-webchat-state';
3
+ import { CoverComponentRegistry } from '../webchat-overlay';
4
+ export interface WebchatAppProps extends Omit<WebchatStateProps, 'customMessages'> {
5
+ /** Whether the webchat is open */
6
+ isOpen: boolean;
7
+ /** Callback when webchat is closed */
8
+ onClose?: () => void;
9
+ /** Callback when controller is ready - passes the controller instance */
10
+ onControllerReady?: (controller: WebchatController) => void;
11
+ /** Whether to show the trigger button (false when used with external trigger) */
12
+ showTrigger?: boolean;
13
+ /** Title for the header */
14
+ title?: string;
15
+ /** Placeholder text for input */
16
+ placeholder?: string;
17
+ /** Custom messages registry */
18
+ customMessages?: Record<string, React.ComponentType<any>>;
19
+ /** Cover components registry */
20
+ coverRegistry?: CoverComponentRegistry;
21
+ }
22
+ /**
23
+ * WebchatApp - Complete webchat component for lazy loading
24
+ *
25
+ * This component wraps WebchatProvider and all UI components,
26
+ * designed to be lazy-loaded by WebchatTrigger.
27
+ *
28
+ * @example
29
+ * ```tsx
30
+ * // Used internally by WebchatTrigger via lazy loading
31
+ * // Used internally by WebchatTrigger via relative lazy import
32
+ *
33
+ * <WebchatApp
34
+ * appId="your-app-id"
35
+ * isOpen={isOpen}
36
+ * onClose={() => setIsOpen(false)}
37
+ * onControllerReady={(ctrl) => console.log('Ready!', ctrl)}
38
+ * />
39
+ * ```
40
+ */
41
+ export declare function WebchatApp({ appId, isOpen, onClose, onControllerReady, title, placeholder, customMessages, avatarConfig, coverRegistry, ...restConfig }: WebchatAppProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,26 @@
1
+ import { AnimationEvent, RefObject } from 'react';
2
+ import { WebchatState } from '../../hooks/use-webchat-state';
3
+ import { WebchatContainerProps } from '../../types/webchat-props';
4
+ export declare function useWebchatContainer(props: Omit<WebchatContainerProps, 'children'>, state: WebchatState, ref: RefObject<HTMLDivElement>): {
5
+ shouldRender: boolean;
6
+ containerProps: {
7
+ ref: RefObject<HTMLDivElement>;
8
+ role: string;
9
+ 'aria-label': string;
10
+ 'aria-live': "polite";
11
+ 'data-testid': string;
12
+ 'data-layout': "default";
13
+ 'data-size': "large" | "compact" | "normal";
14
+ tabIndex: number;
15
+ onAnimationEnd: (e: AnimationEvent<HTMLDivElement>) => void;
16
+ };
17
+ variants: {
18
+ layout: "default";
19
+ size: "large" | "compact" | "normal";
20
+ position: "bottom-right" | "bottom-left" | "top-right" | "top-left";
21
+ isOpen: any;
22
+ isOpening: boolean;
23
+ isClosing: boolean;
24
+ className: string | undefined;
25
+ };
26
+ };
@@ -0,0 +1,2 @@
1
+ import { WebchatContainerProps } from '../../types/webchat-props';
2
+ export declare function WebchatContainer(props: WebchatContainerProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,19 @@
1
+ import { RefObject } from 'react';
2
+ import { WebchatState } from '../../hooks/use-webchat-state';
3
+ import { WebchatHeaderProps } from '../../types/webchat-props';
4
+ export declare function useWebchatHeader(props: WebchatHeaderProps, state: WebchatState, ref: RefObject<HTMLElement>): {
5
+ headerProps: {
6
+ ref: RefObject<HTMLElement>;
7
+ 'aria-label': string;
8
+ };
9
+ title: string;
10
+ showStatus: boolean;
11
+ statusText: string | undefined;
12
+ showClose: boolean;
13
+ onClose: () => void;
14
+ connectionStatus: any;
15
+ variants: {
16
+ variant: "default";
17
+ className: string | undefined;
18
+ };
19
+ };
@@ -0,0 +1,2 @@
1
+ import { WebchatHeaderProps } from '../../types/webchat-props';
2
+ export declare function WebchatHeader(props: WebchatHeaderProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { RefObject } from 'react';
2
+ import { WebchatState } from '../../hooks/use-webchat-state';
3
+ import { WebchatInputProps } from '../../types/webchat-props';
4
+ export declare function useWebchatInput(props: WebchatInputProps, state: WebchatState, ref: RefObject<HTMLDivElement>): {
5
+ inputProps: {
6
+ ref: RefObject<HTMLDivElement>;
7
+ 'aria-label': string;
8
+ 'data-webchat-input': string;
9
+ };
10
+ inputValue: string;
11
+ handleSubmit: (e: React.FormEvent) => void;
12
+ handleInputChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
13
+ handleKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
14
+ fieldProps: {
15
+ value: string;
16
+ onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
17
+ onKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
18
+ placeholder: string;
19
+ disabled: boolean | undefined;
20
+ rows: number;
21
+ };
22
+ submitProps: {
23
+ type: "submit";
24
+ disabled: boolean | undefined;
25
+ 'aria-label': string;
26
+ };
27
+ variants: {
28
+ variant: "default";
29
+ className: string | undefined;
30
+ };
31
+ };
@@ -0,0 +1,2 @@
1
+ import { WebchatInputProps } from '../../types/webchat-props';
2
+ export declare function WebchatInput(props: WebchatInputProps): import("react/jsx-runtime").JSX.Element;