@envive-ai/react-toolkit-v3 0.3.6 → 0.3.7

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 (157) hide show
  1. package/dist/AnimatedText/AnimatedText.d.cts +3 -3
  2. package/dist/AnimatedText/AnimatedText.d.ts +3 -3
  3. package/dist/CSSVariablesEditor/CssVariablesEditorComponent.d.cts +2 -2
  4. package/dist/CSSVariablesEditor/CssVariablesEditorComponent.d.ts +2 -2
  5. package/dist/Carousel/Carousel.d.cts +2 -2
  6. package/dist/Carousel/Carousel.d.ts +2 -2
  7. package/dist/ChatFooter/ChatFooter.d.cts +2 -2
  8. package/dist/ChatFooter/ChatFooter.d.ts +2 -2
  9. package/dist/ChatFooter/components/index.d.cts +5 -5
  10. package/dist/ChatFooter/components/index.d.ts +5 -5
  11. package/dist/ChatFooter/hooks/useGetContainerProperties.cjs +2 -2
  12. package/dist/ChatFooter/hooks/useGetContainerProperties.js +2 -2
  13. package/dist/ChatHeader/ChatHeader.cjs +3 -2
  14. package/dist/ChatHeader/ChatHeader.d.cts +3 -2
  15. package/dist/ChatHeader/ChatHeader.d.ts +3 -2
  16. package/dist/ChatHeader/ChatHeader.js +3 -2
  17. package/dist/ChatHeader/components/Handle.cjs +27 -1
  18. package/dist/ChatHeader/components/Handle.js +27 -1
  19. package/dist/ChatHeader/types/index.d.cts +2 -0
  20. package/dist/ChatHeader/types/index.d.ts +2 -0
  21. package/dist/ChatPreview/ChatPreview.d.cts +2 -2
  22. package/dist/ChatPreview/ChatPreview.d.ts +2 -2
  23. package/dist/ChatPreviewComparison/ChatPreviewComparison.d.cts +2 -2
  24. package/dist/ChatPreviewComparison/ChatPreviewComparison.d.ts +2 -2
  25. package/dist/ChatPreviewLoading/ChatPreviewLoading.d.cts +2 -2
  26. package/dist/ChatPreviewLoading/ChatPreviewLoading.d.ts +2 -2
  27. package/dist/Container/Container.d.cts +176 -176
  28. package/dist/Container/Container.d.ts +176 -176
  29. package/dist/DesignTokens/DesignTokensComponent.d.cts +2 -2
  30. package/dist/DesignTokens/DesignTokensComponent.d.ts +2 -2
  31. package/dist/DocumentRetrievalCard/DocumentRetrievalCard.d.cts +2 -2
  32. package/dist/DocumentRetrievalCard/DocumentRetrievalCard.d.ts +2 -2
  33. package/dist/FloatingButton/FloatingButton.cjs +2 -1
  34. package/dist/FloatingButton/FloatingButton.d.cts +4 -3
  35. package/dist/FloatingButton/FloatingButton.d.ts +4 -3
  36. package/dist/FloatingButton/FloatingButton.js +2 -1
  37. package/dist/FloatingButton/components/Container.cjs +2 -2
  38. package/dist/FloatingButton/components/Container.js +2 -2
  39. package/dist/FloatingButton/hooks/useGetContainerProperties.cjs +2 -2
  40. package/dist/FloatingButton/hooks/useGetContainerProperties.js +2 -2
  41. package/dist/FloatingButton/types/types.cjs +4 -4
  42. package/dist/FloatingButton/types/types.d.cts +8 -4
  43. package/dist/FloatingButton/types/types.d.ts +8 -4
  44. package/dist/FloatingButton/types/types.js +4 -4
  45. package/dist/FloatingChat/FloatingChat.cjs +106 -39
  46. package/dist/FloatingChat/FloatingChat.d.cts +3 -2
  47. package/dist/FloatingChat/FloatingChat.d.ts +3 -2
  48. package/dist/FloatingChat/FloatingChat.js +108 -41
  49. package/dist/FloatingChat/components/AgentMessage.cjs +3 -2
  50. package/dist/FloatingChat/components/AgentMessage.js +3 -2
  51. package/dist/FloatingChat/components/ChatMessages.cjs +59 -41
  52. package/dist/FloatingChat/components/ChatMessages.js +58 -40
  53. package/dist/FloatingChat/components/Layout.cjs +2 -2
  54. package/dist/FloatingChat/components/Layout.js +2 -2
  55. package/dist/FloatingChat/components/ModalSheet.cjs +184 -0
  56. package/dist/FloatingChat/components/ModalSheet.js +182 -0
  57. package/dist/FloatingChat/components/SalesAgentProductCardsCarousel.cjs +3 -2
  58. package/dist/FloatingChat/components/SalesAgentProductCardsCarousel.js +3 -2
  59. package/dist/FloatingChat/components/index.cjs +1 -0
  60. package/dist/FloatingChat/components/index.js +1 -0
  61. package/dist/FloatingChat/hooks/useChatSuggestions.cjs +25 -0
  62. package/dist/FloatingChat/hooks/useChatSuggestions.js +24 -0
  63. package/dist/FloatingChat/hooks/useFilteredChatMessages.cjs +24 -0
  64. package/dist/FloatingChat/hooks/useFilteredChatMessages.js +23 -0
  65. package/dist/FloatingChat/hooks/usePreventScroll.cjs +117 -0
  66. package/dist/FloatingChat/hooks/usePreventScroll.js +116 -0
  67. package/dist/FloatingChat/hooks/useSnapCalculator.cjs +37 -0
  68. package/dist/FloatingChat/hooks/useSnapCalculator.js +35 -0
  69. package/dist/FloatingChat/hooks/useSnapControl.cjs +82 -0
  70. package/dist/FloatingChat/hooks/useSnapControl.js +81 -0
  71. package/dist/FloatingChat/hooks/useSnapSetup.cjs +59 -0
  72. package/dist/FloatingChat/hooks/useSnapSetup.js +58 -0
  73. package/dist/FloatingChat/types/types.d.cts +4 -0
  74. package/dist/FloatingChat/types/types.d.ts +4 -0
  75. package/dist/Image/Image.d.cts +2 -2
  76. package/dist/Image/Image.d.ts +2 -2
  77. package/dist/ImageGallery/ImageGallery.d.cts +2 -2
  78. package/dist/ImageGallery/ImageGallery.d.ts +2 -2
  79. package/dist/MarkdownProcessor/MarkdownProcessor.d.cts +2 -2
  80. package/dist/MarkdownProcessor/MarkdownProcessor.d.ts +2 -2
  81. package/dist/PromptButton/PromptButton.d.cts +2 -2
  82. package/dist/PromptButton/PromptButton.d.ts +2 -2
  83. package/dist/PromptButtonCarouselWithImage/PromptButtonCarouselWithImage.d.cts +2 -2
  84. package/dist/PromptButtonCarouselWithImage/PromptButtonCarouselWithImage.d.ts +2 -2
  85. package/dist/PromptCarousel/PromptCarousel.cjs +0 -1
  86. package/dist/PromptCarousel/PromptCarousel.d.cts +2 -2
  87. package/dist/PromptCarousel/PromptCarousel.d.ts +2 -2
  88. package/dist/PromptCarousel/PromptCarousel.js +0 -1
  89. package/dist/ReviewCard/ReviewCard.d.cts +2 -2
  90. package/dist/ReviewCard/ReviewCard.d.ts +2 -2
  91. package/dist/ReviewCard/components/index.d.cts +6 -6
  92. package/dist/ReviewCard/components/index.d.ts +6 -6
  93. package/dist/SalesAgentProductCard/SalesAgentProductCard.d.cts +2 -2
  94. package/dist/SalesAgentProductCard/SalesAgentProductCard.d.ts +2 -2
  95. package/dist/SalesAgentProductCard/components/index.d.cts +2 -2
  96. package/dist/SalesAgentProductCard/components/index.d.ts +8 -8
  97. package/dist/SocialProof/SocialProof.cjs +9 -2
  98. package/dist/SocialProof/SocialProof.d.cts +2 -2
  99. package/dist/SocialProof/SocialProof.d.ts +2 -2
  100. package/dist/SocialProof/SocialProof.js +9 -2
  101. package/dist/SocialProof/hooks/index.cjs +1 -0
  102. package/dist/SocialProof/hooks/index.js +3 -0
  103. package/dist/SocialProof/hooks/useSocialProofCount.cjs +48 -0
  104. package/dist/SocialProof/hooks/useSocialProofCount.d.cts +15 -0
  105. package/dist/SocialProof/hooks/useSocialProofCount.d.ts +15 -0
  106. package/dist/SocialProof/hooks/useSocialProofCount.js +46 -0
  107. package/dist/SocialProof/index.cjs +5 -1
  108. package/dist/SocialProof/index.d.cts +3 -2
  109. package/dist/SocialProof/index.d.ts +3 -2
  110. package/dist/SocialProof/index.js +4 -2
  111. package/dist/SocialProof/types/types.cjs +8 -1
  112. package/dist/SocialProof/types/types.d.cts +16 -6
  113. package/dist/SocialProof/types/types.d.ts +16 -6
  114. package/dist/SocialProof/types/types.js +7 -1
  115. package/dist/Stack/Stack.d.cts +2 -2
  116. package/dist/TitledPromptCarousel/TitledPromptCarousel.d.cts +2 -2
  117. package/dist/TitledPromptCarousel/TitledPromptCarousel.d.ts +2 -2
  118. package/dist/TypingAnimation/TypingAnimation.d.cts +2 -2
  119. package/dist/TypingAnimation/TypingAnimation.d.ts +2 -2
  120. package/dist/Typography/Typography.d.cts +4 -4
  121. package/dist/Typography/Typography.d.ts +4 -4
  122. package/dist/WidgetTextField/WidgetTextField.d.cts +2 -2
  123. package/dist/WidgetTextField/WidgetTextField.d.ts +2 -2
  124. package/dist/WidgetWrapper/WidgetWrapper.d.cts +2 -2
  125. package/dist/WidgetWrapperWithTitle/WidgetWrapperWithTitle.d.cts +2 -2
  126. package/dist/WidgetWrapperWithTitle/WidgetWrapperWithTitle.d.ts +2 -2
  127. package/dist/styles.css +1 -1
  128. package/package.json +1 -1
  129. package/src/components/ChatFooter/hooks/useGetContainerProperties.ts +2 -2
  130. package/src/components/ChatHeader/ChatHeader.tsx +2 -0
  131. package/src/components/ChatHeader/components/Handle.tsx +29 -1
  132. package/src/components/ChatHeader/types/index.ts +3 -0
  133. package/src/components/FloatingButton/FloatingButton.tsx +2 -0
  134. package/src/components/FloatingButton/components/Container.tsx +3 -0
  135. package/src/components/FloatingButton/hooks/useGetContainerProperties.ts +2 -1
  136. package/src/components/FloatingButton/types/types.ts +9 -4
  137. package/src/components/FloatingChat/FloatingChat.tsx +160 -59
  138. package/src/components/FloatingChat/components/AgentMessage.tsx +3 -0
  139. package/src/components/FloatingChat/components/ChatMessages.tsx +25 -0
  140. package/src/components/FloatingChat/components/Layout.tsx +2 -2
  141. package/src/components/FloatingChat/components/ModalSheet.tsx +288 -0
  142. package/src/components/FloatingChat/components/SalesAgentProductCardsCarousel.tsx +7 -2
  143. package/src/components/FloatingChat/components/index.ts +3 -0
  144. package/src/components/FloatingChat/hooks/useChatSuggestions.ts +49 -0
  145. package/src/components/FloatingChat/hooks/useFilteredChatMessages.ts +43 -0
  146. package/src/components/FloatingChat/hooks/usePreventScroll.ts +207 -0
  147. package/src/components/FloatingChat/hooks/useSnapCalculator.ts +41 -0
  148. package/src/components/FloatingChat/hooks/useSnapControl.ts +131 -0
  149. package/src/components/FloatingChat/hooks/useSnapSetup.ts +106 -0
  150. package/src/components/FloatingChat/types/types.ts +4 -0
  151. package/src/components/PromptCarousel/PromptCarousel.tsx +0 -1
  152. package/src/components/SocialProof/SocialProof.tsx +8 -2
  153. package/src/components/SocialProof/__tests__/SocialProof.test.tsx +66 -17
  154. package/src/components/SocialProof/hooks/index.ts +2 -0
  155. package/src/components/SocialProof/hooks/useSocialProofCount.ts +67 -0
  156. package/src/components/SocialProof/index.ts +2 -1
  157. package/src/components/SocialProof/types/types.ts +18 -6
@@ -30,10 +30,10 @@ declare enum FloatingButtonShow {
30
30
  * Determines the position of the button on the screen.
31
31
  */
32
32
  declare enum FloatingButtonLocation {
33
- MIDDLE_RIGHT = "middleRight",
34
- BOTTOM_RIGHT = "bottomRight",
35
- MIDDLE_LEFT = "middleLeft",
36
- BOTTOM_LEFT = "bottomLeft",
33
+ MIDDLE_RIGHT = "middle-right",
34
+ BOTTOM_RIGHT = "bottom-right",
35
+ MIDDLE_LEFT = "middle-left",
36
+ BOTTOM_LEFT = "bottom-left",
37
37
  }
38
38
  type FloatingButtonBackgroundColor = Extract<ColorNames, 'background-primary' | 'background-secondary' | 'background-tertiary' | 'background-dark' | 'background-light'>;
39
39
  /**
@@ -92,6 +92,10 @@ type FloatingButtonProps = {
92
92
  * Accessible label for the button, used by screen readers.
93
93
  */
94
94
  ariaLabel: string;
95
+ /**
96
+ * Preview mode: uses absolute positioning instead of fixed
97
+ */
98
+ previewMode?: boolean;
95
99
  };
96
100
  //#endregion
97
101
  export { FloatingButtonBackgroundColor, FloatingButtonLocation, FloatingButtonMode, FloatingButtonProps, FloatingButtonShow, FloatingButtonVariant };
@@ -30,10 +30,10 @@ let FloatingButtonShow = /* @__PURE__ */ function(FloatingButtonShow$1) {
30
30
  * Determines the position of the button on the screen.
31
31
  */
32
32
  let FloatingButtonLocation = /* @__PURE__ */ function(FloatingButtonLocation$1) {
33
- FloatingButtonLocation$1["MIDDLE_RIGHT"] = "middleRight";
34
- FloatingButtonLocation$1["BOTTOM_RIGHT"] = "bottomRight";
35
- FloatingButtonLocation$1["MIDDLE_LEFT"] = "middleLeft";
36
- FloatingButtonLocation$1["BOTTOM_LEFT"] = "bottomLeft";
33
+ FloatingButtonLocation$1["MIDDLE_RIGHT"] = "middle-right";
34
+ FloatingButtonLocation$1["BOTTOM_RIGHT"] = "bottom-right";
35
+ FloatingButtonLocation$1["MIDDLE_LEFT"] = "middle-left";
36
+ FloatingButtonLocation$1["BOTTOM_LEFT"] = "bottom-left";
37
37
  return FloatingButtonLocation$1;
38
38
  }({});
39
39
 
@@ -1,7 +1,5 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_theme = require('../tokens/theme/theme.cjs');
3
- const require_Stack = require('../Stack/Stack.cjs');
4
- require('../Stack/index.cjs');
5
3
  const require_resolveTheme = require('../utils/resolveTheme.cjs');
6
4
  const require_PromptButton_types_index = require('../PromptButton/types/index.cjs');
7
5
  require('../PromptButton/index.cjs');
@@ -13,29 +11,31 @@ require('../ChatFooter/index.cjs');
13
11
  const require_index = require('../ChatHeader/types/index.cjs');
14
12
  const require_ChatHeader = require('../ChatHeader/ChatHeader.cjs');
15
13
  require('../ChatHeader/index.cjs');
14
+ const require_useSnapCalculator = require('./hooks/useSnapCalculator.cjs');
15
+ const require_ModalSheet = require('./components/ModalSheet.cjs');
16
16
  const require_index$1 = require('./components/index.cjs');
17
17
  const require_useScrollToBottom = require('./hooks/useScrollToBottom.cjs');
18
+ const require_useSnapSetup = require('./hooks/useSnapSetup.cjs');
19
+ const require_useChatSuggestions = require('./hooks/useChatSuggestions.cjs');
18
20
  const require_WelcomeMessage = require('../WelcomeMessage/WelcomeMessage.cjs');
21
+ const require_useFilteredChatMessages = require('./hooks/useFilteredChatMessages.cjs');
19
22
  let react = require("react");
20
23
  let react_jsx_runtime = require("react/jsx-runtime");
24
+ let framer_motion = require("framer-motion");
21
25
 
22
26
  //#region src/components/FloatingChat/FloatingChat.tsx
23
- const FloatingChat = ({ id, className, style, testId, theme = require_theme.Theme.GLOBAL_CUSTOM, salesAgentData, floatingChatConfig, lookAndFeelConfig, isCXButtonSwitchEnabled, onClose, onToggleCXButton }) => {
27
+ const FloatingChat = ({ id, className, style, testId, theme = require_theme.Theme.GLOBAL_CUSTOM, salesAgentData, floatingChatConfig, lookAndFeelConfig, isCXButtonSwitchEnabled, isFloatingChatOpen, onClose, onToggleCXButton }) => {
24
28
  const finalTheme = require_resolveTheme.resolveTheme(theme);
25
29
  const [query, setQuery] = (0, react.useState)("");
26
30
  const chatMessagesRef = (0, react.useRef)(null);
27
- const { headerBackgroundColor, headerMode, welcomeMessageIconColor, showVerifiedBuyer, userQueryInputEnabled, showEnviveLogo, ignoreFirstModelResponse, neverShowSingleProductCards, welcomeMessageTitle, welcomeMessageText, chatFooterTextFieldPlaceholderText } = floatingChatConfig;
31
+ const { headerBackgroundColor, headerMode, welcomeMessageIconColor, showVerifiedBuyer, userQueryInputEnabled = true, showEnviveLogo, ignoreFirstModelResponse, neverShowSingleProductCards, welcomeMessageTitle, welcomeMessageText, chatFooterTextFieldPlaceholderText } = floatingChatConfig;
28
32
  const { agentName, chatHeaderLogoDarkSrc, chatHeaderLogoLightSrc } = lookAndFeelConfig;
29
33
  const { messages, isResponseStreaming, isPendingResponse, suggestions, onSuggestionClicked, onTypedMessageSubmitted } = salesAgentData;
30
- const [answerSuggestions, setAnswerSuggestions] = (0, react.useState)([]);
31
- const [generalSuggestions, setGeneralSuggestions] = (0, react.useState)([]);
32
- const showAnswerSuggestions = answerSuggestions.length > 0 && !isPendingResponse && !isResponseStreaming;
33
- (0, react.useEffect)(() => {
34
- if (suggestions.length > 0) {
35
- setAnswerSuggestions(suggestions.filter((suggestion) => suggestion.isAnswer).map((suggestion) => suggestion.content));
36
- setGeneralSuggestions(suggestions.filter((suggestion) => !suggestion.isAnswer).map((suggestion) => suggestion.content));
37
- }
38
- }, [suggestions]);
34
+ const { answerSuggestions, generalSuggestions, showAnswerSuggestions, setAnswerSuggestions, setGeneralSuggestions } = require_useChatSuggestions.useChatSuggestions({
35
+ suggestions,
36
+ isPendingResponse,
37
+ isResponseStreaming
38
+ });
39
39
  const handleToggleCXButton = (item) => {
40
40
  if (item === require_index.ChatHeaderOptions.LIVE_SUPPORT) {
41
41
  onToggleCXButton?.();
@@ -53,6 +53,13 @@ const FloatingChat = ({ id, className, style, testId, theme = require_theme.Them
53
53
  ],
54
54
  scrollThreshold: 30
55
55
  });
56
+ const { modalSheetControl, maxSwipeableViewHeight, isOpen, isMobile, snaps, initialSnap, shouldAutoExpand, currentSnapPercentage, handleSnapChange, animationKey, mobileHeaderHeight, shouldShowHeader, shouldShowScrolled, isFullView, isPartialView } = require_useSnapSetup.useSnapSetup({ isFloatingChatOpen });
57
+ const { filteredMessages, hasFilteredMessages, handlePreviousDiscussions } = require_useFilteredChatMessages.useFilteredChatMessages({
58
+ messages,
59
+ isMobile,
60
+ currentSnapPercentage,
61
+ modalSheetControl
62
+ });
56
63
  const header = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ChatHeader.ChatHeader, {
57
64
  logoDark: chatHeaderLogoDarkSrc,
58
65
  logoLight: chatHeaderLogoLightSrc,
@@ -67,32 +74,62 @@ const FloatingChat = ({ id, className, style, testId, theme = require_theme.Them
67
74
  variant: headerMode,
68
75
  headerBgColor: headerBackgroundColor
69
76
  });
70
- const footer = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Stack.Stack, {
71
- direction: "column",
72
- gap: 4,
73
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ChatFooter.ChatFooter, {
77
+ const mobileHeader = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(framer_motion.motion.div, {
78
+ style: {
79
+ maxHeight: mobileHeaderHeight,
80
+ overflow: "hidden"
81
+ },
82
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ChatHeader.ChatHeader, {
83
+ logoDark: chatHeaderLogoDarkSrc,
84
+ logoLight: chatHeaderLogoLightSrc,
74
85
  theme: finalTheme,
75
- isScrolled: false,
76
- onChange: setQuery,
77
- onSubmit: () => {
78
- onTypedMessageSubmitted({ query });
79
- setAnswerSuggestions([]);
80
- setGeneralSuggestions([]);
81
- },
82
- textFieldPlaceholderText: chatFooterTextFieldPlaceholderText,
83
- promptSuggestions: isPendingResponse || isResponseStreaming || generalSuggestions.length === 0 ? ["Loading suggestions 1...", "Loading suggestions 2..."] : generalSuggestions,
84
- handleButtonClick: (buttonText) => {
85
- const suggestion = suggestions.find((s) => s.content === buttonText && !s.isAnswer);
86
- if (suggestion) onSuggestionClicked(suggestion);
87
- setAnswerSuggestions([]);
88
- setGeneralSuggestions([]);
89
- },
90
- disabled: isPendingResponse || isResponseStreaming,
91
- disabledInput: !userQueryInputEnabled,
92
- isLoadingPromptSuggestions: isPendingResponse || isResponseStreaming || generalSuggestions.length === 0,
93
- hideEnviveWatermark: !showEnviveLogo
86
+ variant: headerMode,
87
+ headerBgColor: headerBackgroundColor,
88
+ showLogo: true,
89
+ showCXToggle: isCXButtonSwitchEnabled,
90
+ centralizeCXToggle: true,
91
+ selectedOption: require_index.ChatHeaderOptions.ASSISTANT,
92
+ onToggle: handleToggleCXButton,
93
+ onClose
94
94
  })
95
95
  });
96
+ const handler = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ChatHeader.ChatHeader, {
97
+ theme: finalTheme,
98
+ variant: headerMode,
99
+ headerBgColor: headerBackgroundColor,
100
+ showHandle: true,
101
+ handleState: isFullView ? require_index.HandleState.OPEN : require_index.HandleState.CLOSED,
102
+ handleAnimationKey: animationKey,
103
+ showMainContent: false,
104
+ selectedOption: require_index.ChatHeaderOptions.ASSISTANT,
105
+ onToggle: handleToggleCXButton,
106
+ onClose
107
+ });
108
+ const footer = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ChatFooter.ChatFooter, {
109
+ theme: finalTheme,
110
+ isScrolled: isMobile ? shouldShowScrolled : false,
111
+ onChange: setQuery,
112
+ onSubmit: () => {
113
+ onTypedMessageSubmitted({
114
+ query,
115
+ userTyped: true
116
+ });
117
+ setAnswerSuggestions([]);
118
+ setGeneralSuggestions([]);
119
+ },
120
+ textFieldPlaceholderText: chatFooterTextFieldPlaceholderText,
121
+ promptSuggestions: isPendingResponse || isResponseStreaming || generalSuggestions.length === 0 ? ["Loading suggestions 1...", "Loading suggestions 2..."] : generalSuggestions,
122
+ handleButtonClick: (buttonText) => {
123
+ const suggestion = suggestions.find((s) => s.content === buttonText && !s.isAnswer);
124
+ if (suggestion) onSuggestionClicked(suggestion);
125
+ setAnswerSuggestions([]);
126
+ setGeneralSuggestions([]);
127
+ },
128
+ disabled: isPendingResponse || isResponseStreaming,
129
+ disabledInput: !userQueryInputEnabled,
130
+ isLoadingPromptSuggestions: isPendingResponse || isResponseStreaming || generalSuggestions.length === 0,
131
+ hideEnviveWatermark: !showEnviveLogo
132
+ });
96
133
  const welcomeMessage = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_WelcomeMessage.WelcomeMessage, {
97
134
  sparkleIconColor: welcomeMessageIconColor,
98
135
  title: welcomeMessageTitle,
@@ -104,11 +141,14 @@ const FloatingChat = ({ id, className, style, testId, theme = require_theme.Them
104
141
  ref: chatMessagesRef,
105
142
  isLoading: isPendingResponse && !isResponseStreaming,
106
143
  agentName,
107
- messages,
144
+ messages: filteredMessages,
145
+ hasFilteredMessages,
146
+ handlePreviousDiscussions,
108
147
  isResponseStreaming,
109
148
  ignoreFirstModelResponse,
110
149
  neverShowSingleProductCards,
111
- showVerifiedBuyer
150
+ showVerifiedBuyer,
151
+ isPartialView
112
152
  });
113
153
  const answerSuggestionsComponent = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PromptCarousel.PromptCarousel, {
114
154
  className: "envive-tw-flex envive-tw-justify-end envive-tw-p-4 [&>div>div]:envive-tw-items-end",
@@ -123,7 +163,7 @@ const FloatingChat = ({ id, className, style, testId, theme = require_theme.Them
123
163
  setGeneralSuggestions([]);
124
164
  }
125
165
  });
126
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index$1.FloatingChatComponents.Layout, {
166
+ const desktopLayout = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index$1.FloatingChatComponents.Layout, {
127
167
  id,
128
168
  className,
129
169
  style,
@@ -136,6 +176,33 @@ const FloatingChat = ({ id, className, style, testId, theme = require_theme.Them
136
176
  answerSuggestions: showAnswerSuggestions ? answerSuggestionsComponent : void 0,
137
177
  scrollToBottomButton: showScrollButton ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index$1.FloatingChatComponents.ScrollToBottomButton, { onClick: scrollToBottom }) : void 0
138
178
  });
179
+ const mobileLayout = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index$1.FloatingChatComponents.Layout, {
180
+ id,
181
+ className,
182
+ style,
183
+ testId,
184
+ theme: finalTheme,
185
+ header: shouldShowHeader ? mobileHeader : void 0,
186
+ footer,
187
+ welcomeMessage,
188
+ chatMessages,
189
+ answerSuggestions: showAnswerSuggestions ? answerSuggestionsComponent : void 0,
190
+ scrollToBottomButton: showScrollButton ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index$1.FloatingChatComponents.ScrollToBottomButton, { onClick: scrollToBottom }) : void 0
191
+ });
192
+ return isMobile ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ModalSheet.ModalSheet, {
193
+ animationKey,
194
+ open: isOpen,
195
+ height: maxSwipeableViewHeight,
196
+ handler,
197
+ unit: require_useSnapCalculator.Unit.PERCENT,
198
+ snaps,
199
+ initSnap: initialSnap,
200
+ onSnap: handleSnapChange,
201
+ onClose,
202
+ controlRef: modalSheetControl,
203
+ disableDrag: shouldAutoExpand,
204
+ children: mobileLayout
205
+ }) : desktopLayout;
139
206
  };
140
207
 
141
208
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { FloatingChatProps } from "./types/types.cjs";
2
- import * as react_jsx_runtime10 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime28 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/components/FloatingChat/FloatingChat.d.ts
5
5
  declare const FloatingChat: ({
@@ -12,8 +12,9 @@ declare const FloatingChat: ({
12
12
  floatingChatConfig,
13
13
  lookAndFeelConfig,
14
14
  isCXButtonSwitchEnabled,
15
+ isFloatingChatOpen,
15
16
  onClose,
16
17
  onToggleCXButton
17
- }: FloatingChatProps) => react_jsx_runtime10.JSX.Element;
18
+ }: FloatingChatProps) => react_jsx_runtime28.JSX.Element;
18
19
  //#endregion
19
20
  export { FloatingChat };
@@ -1,5 +1,5 @@
1
1
  import { FloatingChatProps } from "./types/types.js";
2
- import * as react_jsx_runtime28 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime23 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/components/FloatingChat/FloatingChat.d.ts
5
5
  declare const FloatingChat: ({
@@ -12,8 +12,9 @@ declare const FloatingChat: ({
12
12
  floatingChatConfig,
13
13
  lookAndFeelConfig,
14
14
  isCXButtonSwitchEnabled,
15
+ isFloatingChatOpen,
15
16
  onClose,
16
17
  onToggleCXButton
17
- }: FloatingChatProps) => react_jsx_runtime28.JSX.Element;
18
+ }: FloatingChatProps) => react_jsx_runtime23.JSX.Element;
18
19
  //#endregion
19
20
  export { FloatingChat };
@@ -1,6 +1,4 @@
1
1
  import { Theme } from "../tokens/theme/theme.js";
2
- import { Stack } from "../Stack/Stack.js";
3
- import "../Stack/index.js";
4
2
  import { resolveTheme } from "../utils/resolveTheme.js";
5
3
  import { PromptButtonVariant } from "../PromptButton/types/index.js";
6
4
  import "../PromptButton/index.js";
@@ -9,32 +7,34 @@ import { PromptCarousel } from "../PromptCarousel/PromptCarousel.js";
9
7
  import "../PromptCarousel/index.js";
10
8
  import { ChatFooter } from "../ChatFooter/ChatFooter.js";
11
9
  import "../ChatFooter/index.js";
12
- import { ChatHeaderOptions } from "../ChatHeader/types/index.js";
10
+ import { ChatHeaderOptions, HandleState } from "../ChatHeader/types/index.js";
13
11
  import { ChatHeader } from "../ChatHeader/ChatHeader.js";
14
12
  import "../ChatHeader/index.js";
13
+ import { Unit } from "./hooks/useSnapCalculator.js";
14
+ import { ModalSheet } from "./components/ModalSheet.js";
15
15
  import { FloatingChatComponents } from "./components/index.js";
16
16
  import { useScrollToBottom } from "./hooks/useScrollToBottom.js";
17
+ import { useSnapSetup } from "./hooks/useSnapSetup.js";
18
+ import { useChatSuggestions } from "./hooks/useChatSuggestions.js";
17
19
  import { WelcomeMessage } from "../WelcomeMessage/WelcomeMessage.js";
18
- import { useEffect, useRef, useState } from "react";
20
+ import { useFilteredChatMessages } from "./hooks/useFilteredChatMessages.js";
21
+ import { useRef, useState } from "react";
19
22
  import { jsx } from "react/jsx-runtime";
23
+ import { motion } from "framer-motion";
20
24
 
21
25
  //#region src/components/FloatingChat/FloatingChat.tsx
22
- const FloatingChat = ({ id, className, style, testId, theme = Theme.GLOBAL_CUSTOM, salesAgentData, floatingChatConfig, lookAndFeelConfig, isCXButtonSwitchEnabled, onClose, onToggleCXButton }) => {
26
+ const FloatingChat = ({ id, className, style, testId, theme = Theme.GLOBAL_CUSTOM, salesAgentData, floatingChatConfig, lookAndFeelConfig, isCXButtonSwitchEnabled, isFloatingChatOpen, onClose, onToggleCXButton }) => {
23
27
  const finalTheme = resolveTheme(theme);
24
28
  const [query, setQuery] = useState("");
25
29
  const chatMessagesRef = useRef(null);
26
- const { headerBackgroundColor, headerMode, welcomeMessageIconColor, showVerifiedBuyer, userQueryInputEnabled, showEnviveLogo, ignoreFirstModelResponse, neverShowSingleProductCards, welcomeMessageTitle, welcomeMessageText, chatFooterTextFieldPlaceholderText } = floatingChatConfig;
30
+ const { headerBackgroundColor, headerMode, welcomeMessageIconColor, showVerifiedBuyer, userQueryInputEnabled = true, showEnviveLogo, ignoreFirstModelResponse, neverShowSingleProductCards, welcomeMessageTitle, welcomeMessageText, chatFooterTextFieldPlaceholderText } = floatingChatConfig;
27
31
  const { agentName, chatHeaderLogoDarkSrc, chatHeaderLogoLightSrc } = lookAndFeelConfig;
28
32
  const { messages, isResponseStreaming, isPendingResponse, suggestions, onSuggestionClicked, onTypedMessageSubmitted } = salesAgentData;
29
- const [answerSuggestions, setAnswerSuggestions] = useState([]);
30
- const [generalSuggestions, setGeneralSuggestions] = useState([]);
31
- const showAnswerSuggestions = answerSuggestions.length > 0 && !isPendingResponse && !isResponseStreaming;
32
- useEffect(() => {
33
- if (suggestions.length > 0) {
34
- setAnswerSuggestions(suggestions.filter((suggestion) => suggestion.isAnswer).map((suggestion) => suggestion.content));
35
- setGeneralSuggestions(suggestions.filter((suggestion) => !suggestion.isAnswer).map((suggestion) => suggestion.content));
36
- }
37
- }, [suggestions]);
33
+ const { answerSuggestions, generalSuggestions, showAnswerSuggestions, setAnswerSuggestions, setGeneralSuggestions } = useChatSuggestions({
34
+ suggestions,
35
+ isPendingResponse,
36
+ isResponseStreaming
37
+ });
38
38
  const handleToggleCXButton = (item) => {
39
39
  if (item === ChatHeaderOptions.LIVE_SUPPORT) {
40
40
  onToggleCXButton?.();
@@ -52,6 +52,13 @@ const FloatingChat = ({ id, className, style, testId, theme = Theme.GLOBAL_CUSTO
52
52
  ],
53
53
  scrollThreshold: 30
54
54
  });
55
+ const { modalSheetControl, maxSwipeableViewHeight, isOpen, isMobile, snaps, initialSnap, shouldAutoExpand, currentSnapPercentage, handleSnapChange, animationKey, mobileHeaderHeight, shouldShowHeader, shouldShowScrolled, isFullView, isPartialView } = useSnapSetup({ isFloatingChatOpen });
56
+ const { filteredMessages, hasFilteredMessages, handlePreviousDiscussions } = useFilteredChatMessages({
57
+ messages,
58
+ isMobile,
59
+ currentSnapPercentage,
60
+ modalSheetControl
61
+ });
55
62
  const header = /* @__PURE__ */ jsx(ChatHeader, {
56
63
  logoDark: chatHeaderLogoDarkSrc,
57
64
  logoLight: chatHeaderLogoLightSrc,
@@ -66,32 +73,62 @@ const FloatingChat = ({ id, className, style, testId, theme = Theme.GLOBAL_CUSTO
66
73
  variant: headerMode,
67
74
  headerBgColor: headerBackgroundColor
68
75
  });
69
- const footer = /* @__PURE__ */ jsx(Stack, {
70
- direction: "column",
71
- gap: 4,
72
- children: /* @__PURE__ */ jsx(ChatFooter, {
76
+ const mobileHeader = /* @__PURE__ */ jsx(motion.div, {
77
+ style: {
78
+ maxHeight: mobileHeaderHeight,
79
+ overflow: "hidden"
80
+ },
81
+ children: /* @__PURE__ */ jsx(ChatHeader, {
82
+ logoDark: chatHeaderLogoDarkSrc,
83
+ logoLight: chatHeaderLogoLightSrc,
73
84
  theme: finalTheme,
74
- isScrolled: false,
75
- onChange: setQuery,
76
- onSubmit: () => {
77
- onTypedMessageSubmitted({ query });
78
- setAnswerSuggestions([]);
79
- setGeneralSuggestions([]);
80
- },
81
- textFieldPlaceholderText: chatFooterTextFieldPlaceholderText,
82
- promptSuggestions: isPendingResponse || isResponseStreaming || generalSuggestions.length === 0 ? ["Loading suggestions 1...", "Loading suggestions 2..."] : generalSuggestions,
83
- handleButtonClick: (buttonText) => {
84
- const suggestion = suggestions.find((s) => s.content === buttonText && !s.isAnswer);
85
- if (suggestion) onSuggestionClicked(suggestion);
86
- setAnswerSuggestions([]);
87
- setGeneralSuggestions([]);
88
- },
89
- disabled: isPendingResponse || isResponseStreaming,
90
- disabledInput: !userQueryInputEnabled,
91
- isLoadingPromptSuggestions: isPendingResponse || isResponseStreaming || generalSuggestions.length === 0,
92
- hideEnviveWatermark: !showEnviveLogo
85
+ variant: headerMode,
86
+ headerBgColor: headerBackgroundColor,
87
+ showLogo: true,
88
+ showCXToggle: isCXButtonSwitchEnabled,
89
+ centralizeCXToggle: true,
90
+ selectedOption: ChatHeaderOptions.ASSISTANT,
91
+ onToggle: handleToggleCXButton,
92
+ onClose
93
93
  })
94
94
  });
95
+ const handler = /* @__PURE__ */ jsx(ChatHeader, {
96
+ theme: finalTheme,
97
+ variant: headerMode,
98
+ headerBgColor: headerBackgroundColor,
99
+ showHandle: true,
100
+ handleState: isFullView ? HandleState.OPEN : HandleState.CLOSED,
101
+ handleAnimationKey: animationKey,
102
+ showMainContent: false,
103
+ selectedOption: ChatHeaderOptions.ASSISTANT,
104
+ onToggle: handleToggleCXButton,
105
+ onClose
106
+ });
107
+ const footer = /* @__PURE__ */ jsx(ChatFooter, {
108
+ theme: finalTheme,
109
+ isScrolled: isMobile ? shouldShowScrolled : false,
110
+ onChange: setQuery,
111
+ onSubmit: () => {
112
+ onTypedMessageSubmitted({
113
+ query,
114
+ userTyped: true
115
+ });
116
+ setAnswerSuggestions([]);
117
+ setGeneralSuggestions([]);
118
+ },
119
+ textFieldPlaceholderText: chatFooterTextFieldPlaceholderText,
120
+ promptSuggestions: isPendingResponse || isResponseStreaming || generalSuggestions.length === 0 ? ["Loading suggestions 1...", "Loading suggestions 2..."] : generalSuggestions,
121
+ handleButtonClick: (buttonText) => {
122
+ const suggestion = suggestions.find((s) => s.content === buttonText && !s.isAnswer);
123
+ if (suggestion) onSuggestionClicked(suggestion);
124
+ setAnswerSuggestions([]);
125
+ setGeneralSuggestions([]);
126
+ },
127
+ disabled: isPendingResponse || isResponseStreaming,
128
+ disabledInput: !userQueryInputEnabled,
129
+ isLoadingPromptSuggestions: isPendingResponse || isResponseStreaming || generalSuggestions.length === 0,
130
+ hideEnviveWatermark: !showEnviveLogo
131
+ });
95
132
  const welcomeMessage = /* @__PURE__ */ jsx(WelcomeMessage, {
96
133
  sparkleIconColor: welcomeMessageIconColor,
97
134
  title: welcomeMessageTitle,
@@ -103,11 +140,14 @@ const FloatingChat = ({ id, className, style, testId, theme = Theme.GLOBAL_CUSTO
103
140
  ref: chatMessagesRef,
104
141
  isLoading: isPendingResponse && !isResponseStreaming,
105
142
  agentName,
106
- messages,
143
+ messages: filteredMessages,
144
+ hasFilteredMessages,
145
+ handlePreviousDiscussions,
107
146
  isResponseStreaming,
108
147
  ignoreFirstModelResponse,
109
148
  neverShowSingleProductCards,
110
- showVerifiedBuyer
149
+ showVerifiedBuyer,
150
+ isPartialView
111
151
  });
112
152
  const answerSuggestionsComponent = /* @__PURE__ */ jsx(PromptCarousel, {
113
153
  className: "envive-tw-flex envive-tw-justify-end envive-tw-p-4 [&>div>div]:envive-tw-items-end",
@@ -122,7 +162,7 @@ const FloatingChat = ({ id, className, style, testId, theme = Theme.GLOBAL_CUSTO
122
162
  setGeneralSuggestions([]);
123
163
  }
124
164
  });
125
- return /* @__PURE__ */ jsx(FloatingChatComponents.Layout, {
165
+ const desktopLayout = /* @__PURE__ */ jsx(FloatingChatComponents.Layout, {
126
166
  id,
127
167
  className,
128
168
  style,
@@ -135,6 +175,33 @@ const FloatingChat = ({ id, className, style, testId, theme = Theme.GLOBAL_CUSTO
135
175
  answerSuggestions: showAnswerSuggestions ? answerSuggestionsComponent : void 0,
136
176
  scrollToBottomButton: showScrollButton ? /* @__PURE__ */ jsx(FloatingChatComponents.ScrollToBottomButton, { onClick: scrollToBottom }) : void 0
137
177
  });
178
+ const mobileLayout = /* @__PURE__ */ jsx(FloatingChatComponents.Layout, {
179
+ id,
180
+ className,
181
+ style,
182
+ testId,
183
+ theme: finalTheme,
184
+ header: shouldShowHeader ? mobileHeader : void 0,
185
+ footer,
186
+ welcomeMessage,
187
+ chatMessages,
188
+ answerSuggestions: showAnswerSuggestions ? answerSuggestionsComponent : void 0,
189
+ scrollToBottomButton: showScrollButton ? /* @__PURE__ */ jsx(FloatingChatComponents.ScrollToBottomButton, { onClick: scrollToBottom }) : void 0
190
+ });
191
+ return isMobile ? /* @__PURE__ */ jsx(ModalSheet, {
192
+ animationKey,
193
+ open: isOpen,
194
+ height: maxSwipeableViewHeight,
195
+ handler,
196
+ unit: Unit.PERCENT,
197
+ snaps,
198
+ initSnap: initialSnap,
199
+ onSnap: handleSnapChange,
200
+ onClose,
201
+ controlRef: modalSheetControl,
202
+ disableDrag: shouldAutoExpand,
203
+ children: mobileLayout
204
+ }) : desktopLayout;
138
205
  };
139
206
 
140
207
  //#endregion
@@ -15,7 +15,7 @@ let react_jsx_runtime = require("react/jsx-runtime");
15
15
  let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
16
16
 
17
17
  //#region src/components/FloatingChat/components/AgentMessage.tsx
18
- const AgentMessage = ({ theme = require_theme.Theme.GLOBAL_CUSTOM, agentName, type, messages, hideAgentName = false, isResponseStreaming = false, neverShowSingleProductCards = false, showVerifiedBuyer = false }) => {
18
+ const AgentMessage = ({ theme = require_theme.Theme.GLOBAL_CUSTOM, agentName, type, messages, hideAgentName = false, isResponseStreaming = false, neverShowSingleProductCards = false, showVerifiedBuyer = false, isPartialView }) => {
19
19
  const finalTheme = require_resolveTheme.resolveTheme(theme);
20
20
  if (new Set([
21
21
  __envive_ai_react_hooks_application_models.MessageType.Text,
@@ -42,7 +42,8 @@ const AgentMessage = ({ theme = require_theme.Theme.GLOBAL_CUSTOM, agentName, ty
42
42
  hideNavigation: products.length === 1,
43
43
  products,
44
44
  numberOfProducts: products.length,
45
- theme: finalTheme
45
+ theme: finalTheme,
46
+ isPartialView
46
47
  });
47
48
  }
48
49
  if (type === __envive_ai_react_hooks_application_models.MessageType.Page) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_DocumentRetrievalCardsCarousel.DocumentRetrievalCardsCarousel, {
@@ -14,7 +14,7 @@ import { jsx } from "react/jsx-runtime";
14
14
  import { MessageType } from "@envive-ai/react-hooks/application/models";
15
15
 
16
16
  //#region src/components/FloatingChat/components/AgentMessage.tsx
17
- const AgentMessage = ({ theme = Theme.GLOBAL_CUSTOM, agentName, type, messages, hideAgentName = false, isResponseStreaming = false, neverShowSingleProductCards = false, showVerifiedBuyer = false }) => {
17
+ const AgentMessage = ({ theme = Theme.GLOBAL_CUSTOM, agentName, type, messages, hideAgentName = false, isResponseStreaming = false, neverShowSingleProductCards = false, showVerifiedBuyer = false, isPartialView }) => {
18
18
  const finalTheme = resolveTheme(theme);
19
19
  if (new Set([
20
20
  MessageType.Text,
@@ -41,7 +41,8 @@ const AgentMessage = ({ theme = Theme.GLOBAL_CUSTOM, agentName, type, messages,
41
41
  hideNavigation: products.length === 1,
42
42
  products,
43
43
  numberOfProducts: products.length,
44
- theme: finalTheme
44
+ theme: finalTheme,
45
+ isPartialView
45
46
  });
46
47
  }
47
48
  if (type === MessageType.Page) return /* @__PURE__ */ jsx(DocumentRetrievalCardsCarousel, {