@botonic/webchat-react 2.37.0 → 2.38.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 (110) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/embedded-config-CmlPSd0n.js +17 -0
  3. package/embedded.d.ts +2 -0
  4. package/embedded.js +28 -0
  5. package/index.d.ts +10 -1
  6. package/index.js +103 -64
  7. package/lib/components/debug-event/debug-event-wrapper.d.ts +40 -0
  8. package/lib/components/debug-event/index.d.ts +4 -0
  9. package/lib/components/{preview-events/preview-event-message → debug-event}/preview-event-message.d.ts +2 -2
  10. package/lib/components/debug-event/use-preview-event-message.d.ts +31 -0
  11. package/lib/components/dialog/dialog-types.d.ts +4 -1
  12. package/lib/components/image-previewer/image-previewer-portal.d.ts +8 -0
  13. package/lib/components/image-previewer/image-previewer.d.ts +6 -0
  14. package/lib/components/image-previewer/index.d.ts +3 -0
  15. package/lib/components/message/image-message/use-image-preview.d.ts +17 -0
  16. package/lib/components/message/index.d.ts +1 -0
  17. package/lib/components/message/message/message-info/message-info.d.ts +2 -0
  18. package/lib/components/message/message/message.d.ts +1 -0
  19. package/lib/components/message/message/use-message.d.ts +1 -0
  20. package/lib/components/message/whatsapp-request-contact-info/index.d.ts +1 -0
  21. package/lib/components/message/whatsapp-request-contact-info/whatsapp-request-contact-info-message.d.ts +10 -0
  22. package/lib/components/message-machine-renderer/use-message-machine-renderer.d.ts +1 -0
  23. package/lib/components/preview-events/events/index.d.ts +0 -14
  24. package/lib/components/preview-events/events/types.d.ts +9 -12
  25. package/lib/components/webchat-app/webchat-app.d.ts +3 -1
  26. package/lib/components/webchat-header/webchat-menu/dropdown-menu-item-download-transcript.d.ts +6 -2
  27. package/lib/components/webchat-header/webchat-menu/dropdown-menu-item-reset-conversation.d.ts +2 -1
  28. package/lib/components/webchat-header/webchat-menu/dropdown-menu-item-reset-session.d.ts +5 -2
  29. package/lib/components/webchat-header/webchat-menu/dropdown-menu-item-sounds.d.ts +3 -2
  30. package/lib/components/webchat-header/webchat-menu/use-dropdown-menu-item-download-transcript.d.ts +25 -0
  31. package/lib/components/webchat-header/webchat-menu/use-dropdown-menu-item-reset-conversation.d.ts +10 -0
  32. package/lib/components/webchat-header/webchat-menu/use-dropdown-menu-item-reset-session.d.ts +9 -2
  33. package/lib/components/webchat-header/webchat-menu/use-dropdown-menu-item-sounds.d.ts +6 -0
  34. package/lib/components/webchat-input/emoji-picker/index.d.ts +3 -0
  35. package/lib/components/webchat-input/emoji-picker/use-webchat-emoji-picker.d.ts +16 -0
  36. package/lib/components/webchat-input/emoji-picker/webchat-emoji-picker-panel.d.ts +6 -0
  37. package/lib/components/webchat-input/emoji-picker/webchat-emoji-picker-trigger-button.d.ts +8 -0
  38. package/lib/components/webchat-input/use-webchat-input.d.ts +8 -1
  39. package/lib/components/webchat-provider/webchat-context.d.ts +8 -1
  40. package/lib/components/webchat-trigger/read-css-duration-ms.d.ts +4 -0
  41. package/lib/components/webchat-trigger/use-trigger-hover-expand.d.ts +19 -0
  42. package/lib/components/webchat-trigger/use-trigger-preview-channels.d.ts +18 -0
  43. package/lib/components/webchat-trigger/use-trigger-proactive-popup.d.ts +13 -0
  44. package/lib/components/webchat-trigger/use-webchat-trigger.d.ts +15 -1
  45. package/lib/components/webchat-trigger/webchat-trigger-channels-panel.d.ts +10 -0
  46. package/lib/domain/supported-trigger-channels.d.ts +16 -0
  47. package/lib/embedded/embedded-config.d.ts +17 -0
  48. package/lib/embedded/embedded-container.d.ts +7 -0
  49. package/lib/embedded/mount-embedded-webchat.d.ts +5 -0
  50. package/lib/hooks/use-embed-trigger-state.d.ts +6 -0
  51. package/lib/hooks/use-webchat-download-transcript.d.ts +5 -0
  52. package/lib/hooks/use-webchat-reset-conversation.d.ts +6 -0
  53. package/lib/hooks/use-webchat-reset-session.d.ts +3 -0
  54. package/lib/hooks/use-webchat-tracking.d.ts +7 -0
  55. package/lib/types/webchat-props.d.ts +61 -3
  56. package/package.json +10 -4
  57. package/styles.css +123 -87
  58. package/supported-trigger-channels-JiTUD-jK.js +9 -0
  59. package/trigger.d.ts +4 -1
  60. package/trigger.js +592 -215
  61. package/webchat-app-md1b0_ze.js +5072 -0
  62. package/lib/components/preview-events/events/ai-agent/ai-agent.d.ts +0 -3
  63. package/lib/components/preview-events/events/ai-agent/executed-tools.d.ts +0 -7
  64. package/lib/components/preview-events/events/ai-agent/index.d.ts +0 -1
  65. package/lib/components/preview-events/events/ai-agent/parse-tools.d.ts +0 -9
  66. package/lib/components/preview-events/events/ai-agent-router/ai-agent-router.d.ts +0 -3
  67. package/lib/components/preview-events/events/ai-agent-router/index.d.ts +0 -1
  68. package/lib/components/preview-events/events/bot-action.d.ts +0 -3
  69. package/lib/components/preview-events/events/components/guardrail-item.d.ts +0 -14
  70. package/lib/components/preview-events/events/components/index.d.ts +0 -2
  71. package/lib/components/preview-events/events/components/sources-section.d.ts +0 -11
  72. package/lib/components/preview-events/events/conditional-channel.d.ts +0 -3
  73. package/lib/components/preview-events/events/conditional-country.d.ts +0 -3
  74. package/lib/components/preview-events/events/conditional-custom.d.ts +0 -3
  75. package/lib/components/preview-events/events/conditional-queue-status.d.ts +0 -3
  76. package/lib/components/preview-events/events/constants.d.ts +0 -35
  77. package/lib/components/preview-events/events/fallback.d.ts +0 -3
  78. package/lib/components/preview-events/events/handoff-success.d.ts +0 -3
  79. package/lib/components/preview-events/events/keyword.d.ts +0 -3
  80. package/lib/components/preview-events/events/knowledge-base.d.ts +0 -3
  81. package/lib/components/preview-events/events/redirect-flow.d.ts +0 -3
  82. package/lib/components/preview-events/events/smart-intent.d.ts +0 -3
  83. package/lib/components/preview-events/events/webview-action-triggered.d.ts +0 -3
  84. package/lib/components/preview-events/hooks/use-knowledge-base-info.d.ts +0 -19
  85. package/lib/components/preview-events/hooks/use-last-label-position.d.ts +0 -9
  86. package/lib/components/preview-events/icons/ai-router-icon.d.ts +0 -1
  87. package/lib/components/preview-events/icons/ai-specialist-icon.d.ts +0 -1
  88. package/lib/components/preview-events/icons/arrow-progress-icon.d.ts +0 -1
  89. package/lib/components/preview-events/icons/brain-icon.d.ts +0 -1
  90. package/lib/components/preview-events/icons/caret-down-icon.d.ts +0 -1
  91. package/lib/components/preview-events/icons/caret-up-icon.d.ts +0 -1
  92. package/lib/components/preview-events/icons/circle-check-icon.d.ts +0 -1
  93. package/lib/components/preview-events/icons/code-icon.d.ts +0 -1
  94. package/lib/components/preview-events/icons/file-pdf-icon.d.ts +0 -1
  95. package/lib/components/preview-events/icons/file-word-icon.d.ts +0 -1
  96. package/lib/components/preview-events/icons/hand-icon.d.ts +0 -1
  97. package/lib/components/preview-events/icons/head-set-icon.d.ts +0 -1
  98. package/lib/components/preview-events/icons/index.d.ts +0 -19
  99. package/lib/components/preview-events/icons/life-ring-icon.d.ts +0 -1
  100. package/lib/components/preview-events/icons/link-icon.d.ts +0 -1
  101. package/lib/components/preview-events/icons/quote-right-icon.d.ts +0 -1
  102. package/lib/components/preview-events/icons/screwdriver-wrench-icon.d.ts +0 -1
  103. package/lib/components/preview-events/icons/split-icon.d.ts +0 -1
  104. package/lib/components/preview-events/icons/wand-icon.d.ts +0 -1
  105. package/lib/components/preview-events/icons/window-restore-icon.d.ts +0 -1
  106. package/lib/components/preview-events/index.d.ts +0 -3
  107. package/lib/components/preview-events/preview-event-message/index.d.ts +0 -1
  108. package/lib/components/preview-events/preview-event-message/use-preview-event-message.d.ts +0 -17
  109. package/lib/components/preview-events/preview-events-types.d.ts +0 -12
  110. package/webchat-app-BrBET32o.js +0 -5447
@@ -0,0 +1,25 @@
1
+ export interface DropdownMenuItemDownloadTranscriptDialogLabels {
2
+ downloadingTitle: string;
3
+ successTitle: string;
4
+ successLeaveLabel: string;
5
+ successContinueLabel: string;
6
+ errorTitle: string;
7
+ errorSubtitle: string;
8
+ errorContinueLabel: string;
9
+ errorLeaveLabel: string;
10
+ }
11
+ interface UseDropdownMenuItemDownloadTranscriptProps {
12
+ onClose?: () => void;
13
+ dialogLabels?: DropdownMenuItemDownloadTranscriptDialogLabels;
14
+ /**
15
+ * Override leave-after-download. Default matches V1 download modal: close webchat
16
+ * and clear in-memory messages (not `resetSession()` — see header Leave chat menu).
17
+ */
18
+ onLeaveChat?: () => void;
19
+ }
20
+ export declare function useDropdownMenuItemDownloadTranscript({ onClose, dialogLabels, onLeaveChat, }?: UseDropdownMenuItemDownloadTranscriptProps): {
21
+ menuItemProps: {
22
+ onPress: (closeMenu?: () => void) => void;
23
+ };
24
+ };
25
+ export {};
@@ -0,0 +1,10 @@
1
+ interface UseDropdownMenuItemResetConversationProps {
2
+ onClose?: () => void;
3
+ onAfterReset?: () => void | Promise<void>;
4
+ }
5
+ export declare function useDropdownMenuItemResetConversation({ onClose, onAfterReset, }?: UseDropdownMenuItemResetConversationProps): {
6
+ menuItemProps: {
7
+ onPress: (closeMenu?: () => void) => void;
8
+ };
9
+ };
10
+ export {};
@@ -1,9 +1,16 @@
1
+ export interface DropdownMenuItemResetSessionDialogLabels {
2
+ title: string;
3
+ subtitle: string;
4
+ cancelLabel: string;
5
+ confirmLabel: string;
6
+ }
1
7
  interface UseDropdownMenuItemResetSessionProps {
2
8
  onClose?: () => void;
9
+ dialogLabels?: DropdownMenuItemResetSessionDialogLabels;
3
10
  }
4
- export declare function useDropdownMenuItemResetSession({ onClose, }: UseDropdownMenuItemResetSessionProps): {
11
+ export declare function useDropdownMenuItemResetSession({ onClose, dialogLabels, }?: UseDropdownMenuItemResetSessionProps): {
5
12
  menuItemProps: {
6
- onPress: () => void;
13
+ onPress: (closeMenu?: () => void) => void;
7
14
  };
8
15
  };
9
16
  export {};
@@ -0,0 +1,6 @@
1
+ export declare function useDropdownMenuItemSounds(): {
2
+ checkboxItemProps: {
3
+ isSelected: boolean;
4
+ onChange: (enabled: boolean) => void;
5
+ };
6
+ };
@@ -0,0 +1,3 @@
1
+ export { useWebchatEmojiPicker, type UseWebchatEmojiPickerParams, WEBCHAT_EMOJI_PICKER_WIDTH, } from './use-webchat-emoji-picker';
2
+ export { WebchatEmojiPickerPanel, type WebchatEmojiPickerPanelProps, } from './webchat-emoji-picker-panel';
3
+ export { WebchatEmojiPickerTriggerButton, type WebchatEmojiPickerTriggerButtonProps, } from './webchat-emoji-picker-trigger-button';
@@ -0,0 +1,16 @@
1
+ import { BaseEmoji } from '@lilara/ui-web-react';
2
+ import { MutableRefObject, RefObject } from 'react';
3
+ export declare const WEBCHAT_EMOJI_PICKER_WIDTH = "275px";
4
+ export interface UseWebchatEmojiPickerParams {
5
+ inputValue: string;
6
+ setInputValue: (value: string) => void;
7
+ inputValueRef: MutableRefObject<string>;
8
+ onEmojiClick?: () => void;
9
+ isDisabled?: boolean;
10
+ }
11
+ export declare function useWebchatEmojiPicker({ inputValue, setInputValue, inputValueRef, onEmojiClick, isDisabled, }: UseWebchatEmojiPickerParams): {
12
+ textareaRef: RefObject<HTMLTextAreaElement>;
13
+ isEmojiPickerOpen: boolean;
14
+ handleEmojiPickerOpenChange: (isOpen: boolean) => void;
15
+ handleEmojiSelect: (emoji: BaseEmoji) => void;
16
+ };
@@ -0,0 +1,6 @@
1
+ import { BaseEmoji } from '@lilara/ui-web-react';
2
+ export interface WebchatEmojiPickerPanelProps {
3
+ inputValue: string;
4
+ onEmojiSelect: (emoji: BaseEmoji) => void;
5
+ }
6
+ export declare function WebchatEmojiPickerPanel({ inputValue, onEmojiSelect, }: WebchatEmojiPickerPanelProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from 'react';
2
+ export interface WebchatEmojiPickerTriggerButtonProps {
3
+ triggerIcon: ReactNode;
4
+ isDisabled?: boolean;
5
+ onPress?: () => void;
6
+ 'aria-expanded'?: boolean;
7
+ }
8
+ export declare const WebchatEmojiPickerTriggerButton: import('react').ForwardRefExoticComponent<WebchatEmojiPickerTriggerButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
@@ -1,3 +1,4 @@
1
+ import { MessageSentBy } from '@botonic/shared';
1
2
  import { RefObject } from 'react';
2
3
  import { WebchatState } from '../../hooks/use-webchat-state';
3
4
  import { WebchatInputProps } from '../../types/webchat-props';
@@ -12,14 +13,20 @@ export declare function useWebchatInput(props: WebchatInputProps, state: Webchat
12
13
  inputValue: string;
13
14
  hasText: boolean;
14
15
  handleSubmit: (e: React.FormEvent) => void;
15
- onEmojiClick: (() => void) | undefined;
16
16
  onAttachmentClick: () => void;
17
+ emojiPickerProps: {
18
+ isOpen: boolean;
19
+ onOpenChange: (isOpen: boolean) => void;
20
+ inputValue: string;
21
+ onEmojiSelect: (emoji: MessageSentBy) => void;
22
+ };
17
23
  hasAttachments: boolean;
18
24
  attachmentError: string | undefined;
19
25
  fileInputRef: RefObject<HTMLInputElement>;
20
26
  handleFileInputChange: (e: import('react').ChangeEvent<HTMLInputElement>) => void;
21
27
  attachmentListProps: import('./attachment-preview').AttachmentListProps;
22
28
  fieldProps: {
29
+ ref: RefObject<HTMLTextAreaElement>;
23
30
  value: string;
24
31
  onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
25
32
  onKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
@@ -1,10 +1,17 @@
1
1
  import { PreviewUtils } from '@botonic/shared';
2
- import { WebchatController } from '@botonic/webchat-core';
2
+ import { WebchatController, WebchatTrackEventHandler } from '@botonic/webchat-core';
3
3
  import { WebchatState } from '../../hooks/use-webchat-state';
4
4
  export interface WebchatContextValue {
5
5
  state: WebchatState;
6
6
  controller: WebchatController;
7
7
  previewUtils?: PreviewUtils;
8
+ formatMessageTimestamp?: (date: Date) => string;
9
+ imagePreviewer?: (props: {
10
+ src: string;
11
+ isPreviewerOpened: boolean;
12
+ closePreviewer: () => void;
13
+ }) => unknown;
14
+ trackEvent?: WebchatTrackEventHandler;
8
15
  }
9
16
  export declare const WebchatContext: import('react').Context<WebchatContextValue | null>;
10
17
  export declare function useWebchatContext(): WebchatContextValue;
@@ -0,0 +1,4 @@
1
+ /** Parses a CSS time value (e.g. `6000ms`, `6s`) to milliseconds. */
2
+ export declare function readCssDurationMs(raw: string, fallbackMs: number): number;
3
+ export declare const WEBCHAT_TRIGGER_FIRST_VISIT_EXPAND_DELAY_VAR = "--webchat-trigger-first-visit-expand-delay";
4
+ export declare const WEBCHAT_TRIGGER_FIRST_VISIT_EXPAND_DURATION_VAR = "--webchat-trigger-first-visit-expand-duration";
@@ -0,0 +1,19 @@
1
+ import { RefObject } from 'react';
2
+ export interface UseTriggerHoverExpandParams {
3
+ hoverExpandLabel?: string;
4
+ firstVisitHoverExpand?: boolean;
5
+ forceHoverExpanded?: boolean;
6
+ triggerRef: RefObject<HTMLButtonElement>;
7
+ isChannelsPanelVisible: boolean;
8
+ isOpen: boolean;
9
+ isEmbedTriggerHydrated: boolean;
10
+ firstHoverExpandShown: boolean;
11
+ markFirstHoverExpandShown: () => void;
12
+ }
13
+ export declare function useTriggerHoverExpand({ hoverExpandLabel, firstVisitHoverExpand, forceHoverExpanded, triggerRef, isChannelsPanelVisible, isOpen, isEmbedTriggerHydrated, firstHoverExpandShown, markFirstHoverExpandShown, }: UseTriggerHoverExpandParams): {
14
+ hasHoverExpand: boolean;
15
+ isHoverExpandVisible: boolean;
16
+ handleTriggerMouseEnter: () => void;
17
+ handleTriggerMouseLeave: () => void;
18
+ collapseHoverExpand: () => void;
19
+ };
@@ -0,0 +1,18 @@
1
+ import { WebchatTriggerChannel } from '../../types/webchat-props';
2
+ export interface UseTriggerPreviewChannelsParams {
3
+ onTriggerPreviewChannels?: () => readonly WebchatTriggerChannel[];
4
+ requestOpen: () => void;
5
+ controller: {
6
+ close: () => void;
7
+ } | null;
8
+ isOpen: boolean;
9
+ setIsChannelsPanelVisible: (value: boolean | ((visible: boolean) => boolean)) => void;
10
+ }
11
+ export declare function useTriggerPreviewChannels({ onTriggerPreviewChannels, requestOpen, controller, isOpen, setIsChannelsPanelVisible, }: UseTriggerPreviewChannelsParams): {
12
+ previewChannels: readonly WebchatTriggerChannel[];
13
+ useChannelsMenu: boolean;
14
+ channels: readonly WebchatTriggerChannel[] | undefined;
15
+ onSelectChannel: (channel: WebchatTriggerChannel) => void;
16
+ onDismissChannelsPanel: () => void;
17
+ handleTriggerClickWithChannels: (defaultClick: () => void) => void;
18
+ };
@@ -0,0 +1,13 @@
1
+ import { RefObject } from 'react';
2
+ export interface UseTriggerProactivePopupParams {
3
+ proactiveMessage?: string;
4
+ proactiveDelay?: number;
5
+ triggerRef: RefObject<HTMLButtonElement>;
6
+ isOpen: boolean;
7
+ }
8
+ export declare function useTriggerProactivePopup({ proactiveMessage, proactiveDelay, triggerRef, isOpen, }: UseTriggerProactivePopupParams): {
9
+ isPopupVisible: boolean;
10
+ isPopupDismissing: boolean;
11
+ proactiveMessage: string | undefined;
12
+ onPopupAnimationEnd: () => void;
13
+ };
@@ -1,10 +1,12 @@
1
1
  import { AnimationEvent, ComponentType, LazyExoticComponent, RefObject } from 'react';
2
- import { WebchatCompositionProps, WebchatTriggerProps } from '../../types/webchat-props';
2
+ import { WebchatCompositionProps, WebchatTriggerChannel, WebchatTriggerProps } from '../../types/webchat-props';
3
3
  export interface WebchatTriggerHookReturn {
4
4
  triggerProps: {
5
5
  ref: RefObject<HTMLButtonElement>;
6
6
  type: 'button';
7
7
  onClick: () => void;
8
+ onMouseEnter?: () => void;
9
+ onMouseLeave?: () => void;
8
10
  onAnimationEnd?: (e: AnimationEvent<HTMLButtonElement>) => void;
9
11
  'aria-label': string;
10
12
  'aria-expanded': boolean;
@@ -15,12 +17,15 @@ export interface WebchatTriggerHookReturn {
15
17
  variants: {
16
18
  position: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
17
19
  isPulsing?: boolean;
20
+ hasHoverExpand?: boolean;
21
+ isHoverExpandVisible?: boolean;
18
22
  isAppearing?: boolean;
19
23
  isOpening?: boolean;
20
24
  isClosing?: boolean;
21
25
  isLoading: boolean;
22
26
  isOpen: boolean;
23
27
  };
28
+ hoverExpandLabel: string | undefined;
24
29
  webchatProps: WebchatCompositionProps;
25
30
  /** When true, render the lazy webchat inside Suspense (loads on first open) */
26
31
  shouldRenderWebchat: boolean;
@@ -44,5 +49,14 @@ export interface WebchatTriggerHookReturn {
44
49
  proactiveMessage: string | undefined;
45
50
  /** Call on animationend of the popup element to complete dismissal */
46
51
  onPopupAnimationEnd: () => void;
52
+ isChannelsPanelVisible: boolean;
53
+ channels?: readonly WebchatTriggerChannel[];
54
+ onSelectChannel: (channel: WebchatTriggerChannel) => void;
55
+ onDismissChannelsPanel: () => void;
56
+ /** In-memory embed trigger state (first-visit hover expand; not in client storage). */
57
+ embedTrigger: {
58
+ isHydrated: boolean;
59
+ firstHoverExpandShown: boolean;
60
+ };
47
61
  }
48
62
  export declare function useWebchatTrigger(props: WebchatTriggerProps, ref: RefObject<HTMLButtonElement>): WebchatTriggerHookReturn;
@@ -0,0 +1,10 @@
1
+ import { RefObject } from 'react';
2
+ import { WebchatTriggerChannel } from '../../types/webchat-props';
3
+ export interface WebchatTriggerChannelsPanelProps {
4
+ channels: readonly WebchatTriggerChannel[];
5
+ position: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
6
+ triggerRef: RefObject<HTMLButtonElement>;
7
+ onSelectChannel: (channel: WebchatTriggerChannel) => void;
8
+ onDismiss: () => void;
9
+ }
10
+ export declare function WebchatTriggerChannelsPanel({ channels, position, triggerRef, onSelectChannel, onDismiss, }: WebchatTriggerChannelsPanelProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Messaging channels commonly offered from the webchat trigger contact menu.
3
+ * Values align with {@link MessagingChannel} from `@botonic/shared`.
4
+ */
5
+ export declare const SupportedTriggerChannels: {
6
+ readonly Webchat: any;
7
+ readonly Whatsapp: any;
8
+ };
9
+ export type SupportedTriggerChannel = (typeof SupportedTriggerChannels)[keyof typeof SupportedTriggerChannels];
10
+ /** @alias SupportedTriggerChannels */
11
+ export declare const SupportedChannels: {
12
+ readonly Webchat: any;
13
+ readonly Whatsapp: any;
14
+ };
15
+ /** @alias SupportedTriggerChannel */
16
+ export type SupportedChannel = SupportedTriggerChannel;
@@ -0,0 +1,17 @@
1
+ import { WebchatConfig, WebchatController, WebchatMessage } from '@botonic/webchat-core';
2
+ export interface EmbeddedWebchatUserConfig {
3
+ country?: string;
4
+ locale?: string;
5
+ }
6
+ export interface EmbeddedWebchatLifecycleHooks {
7
+ onInit?: (controller: WebchatController) => void | Promise<void>;
8
+ onOpen?: (controller: WebchatController) => void | Promise<void>;
9
+ onClose?: (controller: WebchatController) => void | Promise<void>;
10
+ onMessage?: (controller: WebchatController, message: WebchatMessage) => void | Promise<void>;
11
+ }
12
+ export type EmbeddedWebchatConfig = WebchatConfig & {
13
+ user?: EmbeddedWebchatUserConfig;
14
+ lifecycleHooks?: EmbeddedWebchatLifecycleHooks;
15
+ };
16
+ export declare function toCoreWebchatConfig(config: EmbeddedWebchatConfig): WebchatConfig;
17
+ export declare function applyEmbeddedUser(controller: WebchatController, user: EmbeddedWebchatUserConfig | undefined): Promise<void>;
@@ -0,0 +1,7 @@
1
+ import { Root } from 'react-dom/client';
2
+ export declare function claimEmbeddedWebchatContainer(container: HTMLElement, createRoot: () => Root): {
3
+ root: Root;
4
+ owner: symbol;
5
+ };
6
+ export declare function isEmbeddedWebchatRenderOwner(container: HTMLElement, owner: symbol): boolean;
7
+ export declare function unmountEmbeddedWebchatIfOwner(container: HTMLElement, owner: symbol): void;
@@ -0,0 +1,5 @@
1
+ import { Root } from 'react-dom/client';
2
+ export interface EmbeddedWebchatHandle {
3
+ unmount: () => void;
4
+ }
5
+ export declare function mountEmbeddedWebchat(container: HTMLElement, render: (root: Root) => void): EmbeddedWebchatHandle | undefined;
@@ -0,0 +1,6 @@
1
+ /** In-memory embed trigger UX state (see `useWebchatTrigger` `embedTrigger`). */
2
+ export declare function useEmbedTriggerState(): {
3
+ isHydrated: any;
4
+ firstHoverExpandShown: any;
5
+ markFirstHoverExpandShown: () => void;
6
+ };
@@ -0,0 +1,5 @@
1
+ export type DownloadChatTranscriptResult = 'success' | 'error' | 'ignored';
2
+ export declare function useWebchatDownloadTranscript(): {
3
+ downloadChatTranscript: () => Promise<DownloadChatTranscriptResult>;
4
+ isDownloadInFlight: () => boolean;
5
+ };
@@ -0,0 +1,6 @@
1
+ export interface UseWebchatResetConversationOptions {
2
+ onAfterReset?: () => void | Promise<void>;
3
+ }
4
+ export declare function useWebchatResetConversation({ onAfterReset, }?: UseWebchatResetConversationOptions): {
5
+ resetConversation: () => Promise<boolean>;
6
+ };
@@ -0,0 +1,3 @@
1
+ export declare function useWebchatResetSession(): {
2
+ resetSession: () => boolean;
3
+ };
@@ -0,0 +1,7 @@
1
+ import { EventCustom, EventFeedback } from '@botonic/shared';
2
+ interface UseWebchatTracking {
3
+ trackCustomEvent: (event: EventCustom) => Promise<void>;
4
+ trackFeedbackEvent: (event: EventFeedback) => Promise<void>;
5
+ }
6
+ export declare function useWebchatTracking(): UseWebchatTracking;
7
+ export {};
@@ -1,6 +1,8 @@
1
- import { WebchatController } from '@botonic/webchat-core';
1
+ import { WebchatController, WebchatMessage } from '@botonic/webchat-core';
2
2
  import { ComponentType, CSSProperties, ReactNode } from 'react';
3
3
  import { CoverComponentRegistry } from '../components/webchat-overlay';
4
+ import { SupportedTriggerChannels } from '../domain/supported-trigger-channels';
5
+ import { EmbeddedWebchatUserConfig } from '../embedded/embedded-config';
4
6
  import { WebchatHeroHeaderLayoutConfig } from '../hero-header-layout';
5
7
  import { WebchatStateProps } from '../hooks/use-webchat-state';
6
8
  export interface WebchatInputIcons {
@@ -58,7 +60,7 @@ export interface WebchatCompositionProps {
58
60
  * their types stay in lockstep with the provider (no `as any` at the call site);
59
61
  * the remaining fields are composition/layout options consumed by the layout itself.
60
62
  */
61
- export type WebchatCompositionExtras = Pick<WebchatStateProps, 'avatarConfig' | 'customMessages' | 'storage' | 'webchatClientSettings' | 'enableResponsiveHeroHeader' | 'previewUtils'> & {
63
+ export type WebchatCompositionExtras = Pick<WebchatStateProps, 'avatarConfig' | 'customMessages' | 'storage' | 'webchatClientSettings' | 'enableResponsiveHeroHeader' | 'previewUtils' | 'formatMessageTimestamp' | 'imagePreviewer' | 'onTrackEvent'> & {
62
64
  title?: string;
63
65
  placeholder?: string;
64
66
  showBranding?: boolean;
@@ -98,7 +100,7 @@ export interface WebchatInputProps extends BaseWebchatProps {
98
100
  disabled?: boolean;
99
101
  /** When true, shows the "Powered by Hubtype" line below the input. Default: true. */
100
102
  showBranding?: boolean;
101
- /** Called when the emoji control is activated (UI-only until wired by consumer). */
103
+ /** Called when the emoji picker opens. */
102
104
  onEmojiClick?: () => void;
103
105
  /** Called when the attachment control is activated (UI-only until wired by consumer). */
104
106
  onAttachmentClick?: () => void;
@@ -136,6 +138,19 @@ export interface WebchatHeaderProps extends BaseWebchatProps {
136
138
  */
137
139
  children?: ReactNode;
138
140
  }
141
+ export type WebchatTriggerChannel = {
142
+ channel: typeof SupportedTriggerChannels.Webchat;
143
+ label: string;
144
+ icon?: ReactNode;
145
+ } | {
146
+ channel: typeof SupportedTriggerChannels.Whatsapp;
147
+ label: string;
148
+ icon?: ReactNode;
149
+ href: string;
150
+ target?: '_blank' | '_self';
151
+ };
152
+ export type { SupportedChannel, SupportedTriggerChannel, } from '../domain/supported-trigger-channels';
153
+ export { SupportedChannels, SupportedTriggerChannels, } from '../domain/supported-trigger-channels';
139
154
  export interface WebchatTriggerProps extends BaseWebchatProps {
140
155
  /** Hubtype App ID - required for webchat connection */
141
156
  appId: string;
@@ -145,6 +160,21 @@ export interface WebchatTriggerProps extends BaseWebchatProps {
145
160
  icon?: ReactNode;
146
161
  /** Pulsing animation */
147
162
  isPulsing?: boolean;
163
+ /**
164
+ * Label that expands the trigger on hover (V1-style pill unfold).
165
+ * When set, the trigger grows horizontally to reveal this text.
166
+ */
167
+ hoverExpandLabel?: string;
168
+ /** Temporarily keeps the hover-expand label visible (e.g. first-visit teaser). */
169
+ forceHoverExpanded?: boolean;
170
+ /**
171
+ * First session visit: expand hover label after a delay once (in-memory only;
172
+ * read `useWebchatTrigger` `embedTrigger.firstHoverExpandShown`).
173
+ * Delay and duration use CSS tokens
174
+ * `--webchat-trigger-first-visit-expand-delay` and
175
+ * `--webchat-trigger-first-visit-expand-duration`.
176
+ */
177
+ firstVisitHoverExpand?: boolean;
148
178
  /** Additional webchat configuration passed to composition component */
149
179
  webchatConfig?: Record<string, unknown>;
150
180
  /**
@@ -153,6 +183,29 @@ export interface WebchatTriggerProps extends BaseWebchatProps {
153
183
  * The webchat loads automatically on mount; onReady decides whether to open or not.
154
184
  */
155
185
  onReady?: (controller: WebchatController) => void;
186
+ /**
187
+ * Embedded integration user context applied on the controller before `onInit`.
188
+ */
189
+ embeddedUser?: EmbeddedWebchatUserConfig;
190
+ /**
191
+ * Called once after the lazy-loaded webchat connects its controller, before
192
+ * `onReady` and `window.botonic.ready`. Embed integrations use this for
193
+ * host `lifecycleHooks.onInit` after generic user initialization.
194
+ */
195
+ onInit?: (controller: WebchatController) => void | Promise<void>;
196
+ /**
197
+ * Called each time the webchat panel opens (including when already open once
198
+ * the controller is connected). Uses `registerOnOpen` from `@botonic/webchat-core`.
199
+ */
200
+ onOpen?: (controller: WebchatController) => void | Promise<void>;
201
+ /**
202
+ * Called when the webchat panel closes (`WEBCHAT_CLOSED` on the controller).
203
+ */
204
+ onClose?: (controller: WebchatController) => void | Promise<void>;
205
+ /**
206
+ * Called for sent and received messages (`MESSAGE_SENT` / `MESSAGE_RECEIVED`).
207
+ */
208
+ onMessage?: (controller: WebchatController, message: WebchatMessage) => void | Promise<void>;
156
209
  /**
157
210
  * Custom webchat composition loader for full composition control.
158
211
  * If not provided, uses default WebchatApp.
@@ -176,4 +229,9 @@ export interface WebchatTriggerProps extends BaseWebchatProps {
176
229
  * @default 5
177
230
  */
178
231
  proactiveDelay?: number;
232
+ /**
233
+ * Resolves contact channels for the trigger preview menu (V1-style integrations panel).
234
+ * When more than one channel is returned, the first trigger click opens the panel.
235
+ */
236
+ onTriggerPreviewChannels?: () => readonly WebchatTriggerChannel[];
179
237
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botonic/webchat-react",
3
- "version": "2.37.0",
3
+ "version": "2.38.1",
4
4
  "type": "module",
5
5
  "types": "./index.d.ts",
6
6
  "module": "./index.js",
@@ -16,6 +16,10 @@
16
16
  "types": "./trigger.d.ts",
17
17
  "import": "./trigger.js"
18
18
  },
19
+ "./embedded": {
20
+ "types": "./embedded.d.ts",
21
+ "import": "./embedded.js"
22
+ },
19
23
  "./styles.css": "./styles.css"
20
24
  },
21
25
  "dependencies": {
@@ -30,9 +34,11 @@
30
34
  "peerDependencies": {
31
35
  "react": "^18.0.0",
32
36
  "react-dom": "^18.0.0",
33
- "@botonic/webchat-core": "2.37.0",
34
- "@botonic/shared": "2.37.0",
35
- "@lilara/ui-web-react": ">=0.11.2"
37
+ "@botonic/webchat-core": "2.38.1",
38
+ "@botonic/shared": "2.38.1",
39
+ "@botonic/webchat-lit": "2.38.1",
40
+ "@lilara/ui-web-react": ">=0.11.8",
41
+ "@lit/react": "^1.0.8"
36
42
  },
37
43
  "publishConfig": {
38
44
  "access": "public"