@envive-ai/react-widgets-v3 0.3.2 → 0.3.5

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 (111) hide show
  1. package/dist/hocs/withBaseWidget/types.d.ts +5 -5
  2. package/dist/hocs/withBaseWidget/withBaseWidget.d.cts +2 -2
  3. package/dist/hocs/withBaseWidget/withBaseWidget.d.ts +2 -2
  4. package/dist/node_modules/uuid/dist/native.js +6 -0
  5. package/dist/node_modules/uuid/dist/rng.js +13 -0
  6. package/dist/node_modules/uuid/dist/stringify.js +9 -0
  7. package/dist/node_modules/uuid/dist/v4.js +27 -0
  8. package/dist/node_modules/uuid/dist-node/native.cjs +8 -0
  9. package/dist/node_modules/uuid/dist-node/rng.cjs +16 -0
  10. package/dist/node_modules/uuid/dist-node/stringify.cjs +10 -0
  11. package/dist/node_modules/uuid/dist-node/v4.cjs +27 -0
  12. package/dist/{widgets → packages/widgets}/dist/SearchResults/SearchResults.d.ts +2 -2
  13. package/dist/{widgets → packages/widgets}/dist/SearchResults/SearchResultsWidget.d.ts +2 -2
  14. package/dist/{widgets → packages/widgets}/dist/SearchZeroState/SearchZeroStateWidget.d.ts +2 -2
  15. package/dist/{widgets → packages/widgets}/dist/SuggestionBar/SuggestionBar.d.ts +2 -2
  16. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs +28 -11
  17. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +3 -3
  18. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +3 -3
  19. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +28 -11
  20. package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
  21. package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
  22. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.cjs +27 -10
  23. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.cts +3 -3
  24. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +3 -3
  25. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.js +27 -10
  26. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +3 -3
  27. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +2 -2
  28. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +2 -2
  29. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +3 -3
  30. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +26 -8
  31. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +3 -3
  32. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +27 -9
  33. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +14 -6
  34. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +2 -2
  35. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +15 -7
  36. package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.cjs +1 -1
  37. package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.cts +2 -2
  38. package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.js +1 -1
  39. package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +36 -13
  40. package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
  41. package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
  42. package/dist/widgets/SocialProofWidget/SocialProofWidget.js +36 -13
  43. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +13 -5
  44. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
  45. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +2 -2
  46. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +14 -6
  47. package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.cjs +1 -1
  48. package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.cts +2 -2
  49. package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
  50. package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.js +1 -1
  51. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.cjs +14 -7
  52. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
  53. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
  54. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +14 -7
  55. package/dist/widgets/dist/SearchResults/SearchResults.d.cts +2 -2
  56. package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.cts +2 -2
  57. package/dist/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.cts +2 -2
  58. package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.cts +2 -2
  59. package/dist/widgets/hooks/useGetWidgetStatus.cjs +1 -1
  60. package/dist/widgets/hooks/useGetWidgetStatus.js +1 -1
  61. package/dist/widgets/utils/functions.cjs +1 -1
  62. package/dist/widgets/utils/functions.js +1 -1
  63. package/dist/widgets-v2/SearchResults/index.d.ts +3 -3
  64. package/dist/widgets-v2/SearchZeroState/index.d.ts +5 -5
  65. package/dist/widgets-v2/SuggestionBar/index.d.ts +3 -3
  66. package/dist/widgets-v2/SuggestionButtonContainer/index.d.ts +2 -2
  67. package/package.json +1 -1
  68. package/src/stories/SalesAgentTest/SalesAgentTest.tsx +2 -2
  69. package/src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.tsx +30 -8
  70. package/src/widgets/ChatPreviewWidget/ChatPreviewWidget.tsx +33 -9
  71. package/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx +33 -8
  72. package/src/widgets/PromptCarouselWidget/PromptCarouselWidget.tsx +19 -5
  73. package/src/widgets/SocialProofWidget/SocialProofWidget.tsx +41 -10
  74. package/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.tsx +19 -5
  75. package/src/widgets/TypingAnimationWidget/TypingAnimationWidget.tsx +18 -5
  76. /package/dist/{hooks → packages/hooks}/dist/application/models/api/orgConfigResults.d.ts +0 -0
  77. /package/dist/{hooks → packages/hooks}/dist/application/models/frontendConfig.d.ts +0 -0
  78. /package/dist/{hooks → packages/hooks}/dist/contexts/amplitudeContext/amplitudeContext.d.ts +0 -0
  79. /package/dist/{hooks → packages/hooks}/dist/contexts/amplitudeContext/index.d.ts +0 -0
  80. /package/dist/{hooks → packages/hooks}/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.d.ts +0 -0
  81. /package/dist/{hooks → packages/hooks}/dist/contexts/hardcopyContext/hardcopyContext.d.ts +0 -0
  82. /package/dist/{hooks → packages/hooks}/dist/contexts/hardcopyContext/index.d.ts +0 -0
  83. /package/dist/{hooks → packages/hooks}/dist/contexts/types.d.ts +0 -0
  84. /package/dist/{hooks → packages/hooks}/dist/contexts/typesV3.d.ts +0 -0
  85. /package/dist/{hooks → packages/hooks}/dist/services/amplitudeService/amplitudeService.d.ts +0 -0
  86. /package/dist/{hooks → packages/hooks}/dist/types/customerService.d.ts +0 -0
  87. /package/dist/{widgets → packages/widgets}/dist/SearchResults/index.d.ts +0 -0
  88. /package/dist/{widgets → packages/widgets}/dist/SearchResults/types.d.ts +0 -0
  89. /package/dist/{widgets → packages/widgets}/dist/SearchZeroState/SearchZeroState.d.ts +0 -0
  90. /package/dist/{widgets → packages/widgets}/dist/SearchZeroState/index.d.ts +0 -0
  91. /package/dist/{widgets → packages/widgets}/dist/SearchZeroState/types.d.ts +0 -0
  92. /package/dist/{widgets → packages/widgets}/dist/SuggestionBar/index.d.ts +0 -0
  93. /package/dist/{widgets → packages/widgets}/dist/SuggestionBar/types.d.ts +0 -0
  94. /package/dist/{widgets → packages/widgets}/dist/SuggestionButtonContainer/SuggestionButtonContainer.d.ts +0 -0
  95. /package/dist/{widgets → packages/widgets}/dist/SuggestionButtonContainer/types.d.ts +0 -0
  96. /package/dist/{widgets → packages/widgets}/dist/config/BaseWidgetConfig.d.ts +0 -0
  97. /package/dist/{widgets → packages/widgets}/dist/config/WidgetType.d.ts +0 -0
  98. /package/dist/{widgets → packages/widgets}/dist/packages/hooks/dist/application/models/api/response.d.ts +0 -0
  99. /package/dist/{widgets → packages/widgets}/dist/packages/hooks/dist/application/models/api/search.d.ts +0 -0
  100. /package/dist/{widgets → packages/widgets}/dist/packages/hooks/dist/application/models/utilityTypes/camelCase.d.ts +0 -0
  101. /package/dist/{widgets → packages/widgets}/dist/packages/hooks/dist/application/models/utilityTypes/camelCasedPropertiesDeep.d.ts +0 -0
  102. /package/dist/{widgets → packages/widgets}/dist/packages/hooks/dist/application/models/utilityTypes/internal.d.ts +0 -0
  103. /package/dist/{widgets → packages/widgets}/dist/packages/hooks/dist/application/models/utilityTypes/splitWords.d.ts +0 -0
  104. /package/dist/{widgets → packages/widgets}/dist/packages/hooks/dist/application/models/utilityTypes/trim.d.ts +0 -0
  105. /package/dist/{widgets → packages/widgets}/dist/packages/hooks/dist/application/models/utilityTypes/unknownArray.d.ts +0 -0
  106. /package/dist/{widgets → packages/widgets}/dist/packages/hooks/dist/atoms/search/searchAPI.d.ts +0 -0
  107. /package/dist/{widgets → packages/widgets}/dist/packages/hooks/dist/contexts/types.d.ts +0 -0
  108. /package/dist/{widgets → packages/widgets}/dist/packages/hooks/dist/hooks/Search/useSearch.d.ts +0 -0
  109. /package/dist/{widgets → packages/widgets}/dist/packages/hooks/dist/hooks/utils.d.ts +0 -0
  110. /package/dist/{widgets → packages/widgets}/dist/packages/hooks/dist/types/search-filter-types.d.ts +0 -0
  111. /package/dist/{widgets → packages/widgets}/dist/packages/hooks/dist/types/test-types.d.ts +0 -0
@@ -1,11 +1,13 @@
1
1
  import { withBaseWidget } from "../../hocs/withBaseWidget/withBaseWidget.js";
2
2
  import "../../hocs/withBaseWidget/index.js";
3
+ import v4_default from "../../node_modules/uuid/dist/v4.js";
3
4
  import { useCallback } from "react";
4
5
  import { jsx } from "react/jsx-runtime";
5
6
  import { WidgetTypeV3 } from "@envive-ai/react-hooks/contexts/typesV3";
6
- import { useSalesAgent } from "@envive-ai/react-hooks/contexts/salesAgentContext";
7
+ import { useSetAtom } from "jotai";
8
+ import { handleReplyAtom } from "@envive-ai/react-hooks/atoms/chat/replies";
7
9
  import { useChatToggle } from "@envive-ai/react-hooks/hooks/ChatToggle";
8
- import { ChatElementDisplayLocationV3 } from "@envive-ai/react-hooks/application/models";
10
+ import { ChatElementDisplayLocationV3, MessageRole, MessageType } from "@envive-ai/react-hooks/application/models";
9
11
  import { AnimationSpeed } from "@envive-ai/react-toolkit-v3/PromptCarousel";
10
12
  import { TitledPromptCarousel } from "@envive-ai/react-toolkit-v3/TitledPromptCarousel";
11
13
 
@@ -19,7 +21,7 @@ const mockButtonTexts = [
19
21
  ];
20
22
  const mockTitleLabel = "Loading...";
21
23
  const TitledPromptCarouselWidgetHandler = (props) => {
22
- const { onTypedMessageSubmitted } = useSalesAgent();
24
+ const handleReply = useSetAtom(handleReplyAtom);
23
25
  const { openChat } = useChatToggle();
24
26
  const { hardcopyContent, widgetConfig, isLoading } = props;
25
27
  const hardCopyTitleLabel = hardcopyContent?.values?.titleLabel;
@@ -43,12 +45,18 @@ const TitledPromptCarouselWidgetHandler = (props) => {
43
45
  promptCarouselRows,
44
46
  animationSpeed: isLoading ? AnimationSpeed.FAST : titledPromptCarouselWidgetConfig?.animationSpeed,
45
47
  handleButtonClick: useCallback((text) => {
46
- onTypedMessageSubmitted({
47
- query: text,
48
+ handleReply({
49
+ message: {
50
+ id: v4_default(),
51
+ role: MessageRole.User,
52
+ type: MessageType.QueryTyped,
53
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
54
+ metadata: { content: text }
55
+ },
48
56
  userTyped: false
49
57
  });
50
58
  openChat(ChatElementDisplayLocationV3.TITLED_PROMPT_CAROUSEL);
51
- }, [onTypedMessageSubmitted, openChat]),
59
+ }, [handleReply, openChat]),
52
60
  promptButtonTexts: buttonTexts,
53
61
  promptCarouselAriaLabel
54
62
  });
@@ -1,8 +1,8 @@
1
1
  const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
- const require_useGetWidgetStatus = require('../hooks/useGetWidgetStatus.cjs');
3
2
  const require_ChatPreviewLoadingWidget = require('../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.cjs');
4
3
  const require_ChatPreviewWidget = require('../ChatPreviewWidget/ChatPreviewWidget.cjs');
5
4
  const require_ChatPreviewComparisonWidget = require('../ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs');
5
+ const require_useGetWidgetStatus = require('../hooks/useGetWidgetStatus.cjs');
6
6
  const require_TypingAnimationWidget = require('../TypingAnimationWidget/TypingAnimationWidget.cjs');
7
7
  let react_jsx_runtime = require("react/jsx-runtime");
8
8
  let __envive_ai_react_hooks_contexts_typesV3 = require("@envive-ai/react-hooks/contexts/typesV3");
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime16 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
2
2
 
3
3
  //#region src/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts
4
4
  interface TypingAnimationFlowWidgetProps {
@@ -7,7 +7,7 @@ interface TypingAnimationFlowWidgetProps {
7
7
  declare const TypingAnimationFlowWidget: {
8
8
  ({
9
9
  widgetConfigId
10
- }: TypingAnimationFlowWidgetProps): react_jsx_runtime16.JSX.Element;
10
+ }: TypingAnimationFlowWidgetProps): react_jsx_runtime0.JSX.Element;
11
11
  displayName: string;
12
12
  };
13
13
  //#endregion
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime16 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime2 from "react/jsx-runtime";
2
2
 
3
3
  //#region src/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts
4
4
  interface TypingAnimationFlowWidgetProps {
@@ -7,7 +7,7 @@ interface TypingAnimationFlowWidgetProps {
7
7
  declare const TypingAnimationFlowWidget: {
8
8
  ({
9
9
  widgetConfigId
10
- }: TypingAnimationFlowWidgetProps): react_jsx_runtime16.JSX.Element;
10
+ }: TypingAnimationFlowWidgetProps): react_jsx_runtime2.JSX.Element;
11
11
  displayName: string;
12
12
  };
13
13
  //#endregion
@@ -1,7 +1,7 @@
1
- import useGetWidgetStatus_default from "../hooks/useGetWidgetStatus.js";
2
1
  import { ChatPreviewLoadingWidgetWithBaseWidget } from "../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.js";
3
2
  import { ChatPreviewWidgetWithBaseWidget } from "../ChatPreviewWidget/ChatPreviewWidget.js";
4
3
  import { ChatPreviewComparisonWidgetWithBaseWidget } from "../ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js";
4
+ import useGetWidgetStatus_default from "../hooks/useGetWidgetStatus.js";
5
5
  import { TypingAnimationWithBaseWidget } from "../TypingAnimationWidget/TypingAnimationWidget.js";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  import { WidgetTypeV3 } from "@envive-ai/react-hooks/contexts/typesV3";
@@ -1,14 +1,15 @@
1
1
  const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
2
  const require_withBaseWidget = require('../../hocs/withBaseWidget/withBaseWidget.cjs');
3
3
  require('../../hocs/withBaseWidget/index.cjs');
4
+ const require_v4 = require('../../node_modules/uuid/dist-node/v4.cjs');
4
5
  let react = require("react");
5
6
  let react_jsx_runtime = require("react/jsx-runtime");
6
7
  let __envive_ai_react_hooks_contexts_typesV3 = require("@envive-ai/react-hooks/contexts/typesV3");
7
- let __envive_ai_react_hooks_contexts_salesAgentContext = require("@envive-ai/react-hooks/contexts/salesAgentContext");
8
- let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
9
8
  let jotai = require("jotai");
10
- let __envive_ai_react_hooks_atoms_chat_chatState = require("@envive-ai/react-hooks/atoms/chat/chatState");
9
+ let __envive_ai_react_hooks_atoms_chat_replies = require("@envive-ai/react-hooks/atoms/chat/replies");
10
+ let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
11
11
  let __envive_ai_react_toolkit_v3_PromptCarousel = require("@envive-ai/react-toolkit-v3/PromptCarousel");
12
+ let __envive_ai_react_hooks_atoms_chat_chatState = require("@envive-ai/react-hooks/atoms/chat/chatState");
12
13
  let __envive_ai_react_toolkit_v3_PromptButton_types = require("@envive-ai/react-toolkit-v3/PromptButton/types");
13
14
  let __envive_ai_react_toolkit_v3_WidgetWrapper = require("@envive-ai/react-toolkit-v3/WidgetWrapper");
14
15
  let __envive_ai_react_toolkit_v3_TypingAnimation = require("@envive-ai/react-toolkit-v3/TypingAnimation");
@@ -25,7 +26,7 @@ const mockHeadlineText = "Loading";
25
26
  const mockAnimatedTextSequence = ["..."];
26
27
  const mockHintText = "Ask me anything";
27
28
  const TypingAnimationWidgetHandler = (props) => {
28
- const { onTypedMessageSubmitted } = (0, __envive_ai_react_hooks_contexts_salesAgentContext.useSalesAgent)();
29
+ const handleReply = (0, jotai.useSetAtom)(__envive_ai_react_hooks_atoms_chat_replies.handleReplyAtom);
29
30
  const onToggle = (0, jotai.useSetAtom)(__envive_ai_react_hooks_atoms_chat_chatState.chatOnToggleAtom);
30
31
  const { hardcopyContent, widgetConfig, isLoading } = props;
31
32
  const titleLabel = hardcopyContent?.values?.titleLabel || "";
@@ -43,12 +44,18 @@ const TypingAnimationWidgetHandler = (props) => {
43
44
  const promptCarouselRows = typingAnimationWidgetConfig?.promptCarouselRows || __envive_ai_react_toolkit_v3_PromptCarousel.PromptCarouselRows.ALWAYS_ONE;
44
45
  const showTextField = typingAnimationWidgetConfig?.showTextField !== false;
45
46
  const handleButtonClick = (0, react.useCallback)((text) => {
46
- onTypedMessageSubmitted({
47
- query: text,
47
+ handleReply({
48
+ message: {
49
+ id: require_v4.default(),
50
+ role: __envive_ai_react_hooks_application_models.MessageRole.User,
51
+ type: __envive_ai_react_hooks_application_models.MessageType.QueryTyped,
52
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
53
+ metadata: { content: text }
54
+ },
48
55
  userTyped: false
49
56
  });
50
57
  onToggle(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.TYPING_ANIMATION);
51
- }, [onTypedMessageSubmitted, onToggle]);
58
+ }, [handleReply, onToggle]);
52
59
  const handleTextFieldClick = (0, react.useCallback)(() => {
53
60
  onToggle(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.TYPING_ANIMATION);
54
61
  }, [onToggle]);
@@ -1,9 +1,9 @@
1
1
  import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.cjs";
2
- import * as react_jsx_runtime0 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime3 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts
5
5
  declare const TypingAnimationWithBaseWidget: {
6
- (props: BaseWidgetProps): react_jsx_runtime0.JSX.Element;
6
+ (props: BaseWidgetProps): react_jsx_runtime3.JSX.Element;
7
7
  displayName: string;
8
8
  };
9
9
  interface TypingAnimationWidgetProps {
@@ -12,7 +12,7 @@ interface TypingAnimationWidgetProps {
12
12
  declare const TypingAnimationWidget: {
13
13
  ({
14
14
  widgetConfigId
15
- }: TypingAnimationWidgetProps): react_jsx_runtime0.JSX.Element;
15
+ }: TypingAnimationWidgetProps): react_jsx_runtime3.JSX.Element;
16
16
  displayName: string;
17
17
  };
18
18
  //#endregion
@@ -1,9 +1,9 @@
1
1
  import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.js";
2
- import * as react_jsx_runtime0 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime9 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts
5
5
  declare const TypingAnimationWithBaseWidget: {
6
- (props: BaseWidgetProps): react_jsx_runtime0.JSX.Element;
6
+ (props: BaseWidgetProps): react_jsx_runtime9.JSX.Element;
7
7
  displayName: string;
8
8
  };
9
9
  interface TypingAnimationWidgetProps {
@@ -12,7 +12,7 @@ interface TypingAnimationWidgetProps {
12
12
  declare const TypingAnimationWidget: {
13
13
  ({
14
14
  widgetConfigId
15
- }: TypingAnimationWidgetProps): react_jsx_runtime0.JSX.Element;
15
+ }: TypingAnimationWidgetProps): react_jsx_runtime9.JSX.Element;
16
16
  displayName: string;
17
17
  };
18
18
  //#endregion
@@ -1,13 +1,14 @@
1
1
  import { withBaseWidget } from "../../hocs/withBaseWidget/withBaseWidget.js";
2
2
  import "../../hocs/withBaseWidget/index.js";
3
+ import v4_default from "../../node_modules/uuid/dist/v4.js";
3
4
  import { useCallback } from "react";
4
5
  import { jsx } from "react/jsx-runtime";
5
6
  import { WidgetTypeV3 } from "@envive-ai/react-hooks/contexts/typesV3";
6
- import { useSalesAgent } from "@envive-ai/react-hooks/contexts/salesAgentContext";
7
- import { ChatElementDisplayLocationV3 } from "@envive-ai/react-hooks/application/models";
8
7
  import { useSetAtom } from "jotai";
9
- import { chatOnToggleAtom } from "@envive-ai/react-hooks/atoms/chat/chatState";
8
+ import { handleReplyAtom } from "@envive-ai/react-hooks/atoms/chat/replies";
9
+ import { ChatElementDisplayLocationV3, MessageRole, MessageType } from "@envive-ai/react-hooks/application/models";
10
10
  import { PromptCarouselRows } from "@envive-ai/react-toolkit-v3/PromptCarousel";
11
+ import { chatOnToggleAtom } from "@envive-ai/react-hooks/atoms/chat/chatState";
11
12
  import { PromptButtonVariant } from "@envive-ai/react-toolkit-v3/PromptButton/types";
12
13
  import { WidgetWrapperVariant } from "@envive-ai/react-toolkit-v3/WidgetWrapper";
13
14
  import { TypingAnimation } from "@envive-ai/react-toolkit-v3/TypingAnimation";
@@ -24,7 +25,7 @@ const mockHeadlineText = "Loading";
24
25
  const mockAnimatedTextSequence = ["..."];
25
26
  const mockHintText = "Ask me anything";
26
27
  const TypingAnimationWidgetHandler = (props) => {
27
- const { onTypedMessageSubmitted } = useSalesAgent();
28
+ const handleReply = useSetAtom(handleReplyAtom);
28
29
  const onToggle = useSetAtom(chatOnToggleAtom);
29
30
  const { hardcopyContent, widgetConfig, isLoading } = props;
30
31
  const titleLabel = hardcopyContent?.values?.titleLabel || "";
@@ -42,12 +43,18 @@ const TypingAnimationWidgetHandler = (props) => {
42
43
  const promptCarouselRows = typingAnimationWidgetConfig?.promptCarouselRows || PromptCarouselRows.ALWAYS_ONE;
43
44
  const showTextField = typingAnimationWidgetConfig?.showTextField !== false;
44
45
  const handleButtonClick = useCallback((text) => {
45
- onTypedMessageSubmitted({
46
- query: text,
46
+ handleReply({
47
+ message: {
48
+ id: v4_default(),
49
+ role: MessageRole.User,
50
+ type: MessageType.QueryTyped,
51
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
52
+ metadata: { content: text }
53
+ },
47
54
  userTyped: false
48
55
  });
49
56
  onToggle(ChatElementDisplayLocationV3.TYPING_ANIMATION);
50
- }, [onTypedMessageSubmitted, onToggle]);
57
+ }, [handleReply, onToggle]);
51
58
  const handleTextFieldClick = useCallback(() => {
52
59
  onToggle(ChatElementDisplayLocationV3.TYPING_ANIMATION);
53
60
  }, [onToggle]);
@@ -1,6 +1,6 @@
1
1
  import { SearchResultsHocProps } from "../packages/hooks/dist/hooks/Search/useSearch.cjs";
2
2
  import { SearchResultsEntryPointWidgetConfig } from "./types.cjs";
3
- import * as react_jsx_runtime1 from "react/jsx-runtime";
3
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
4
4
 
5
5
  //#region ../widgets/dist/SearchResults/SearchResults.d.ts
6
6
 
@@ -8,7 +8,7 @@ import * as react_jsx_runtime1 from "react/jsx-runtime";
8
8
  interface SearchResultsProps extends SearchResultsHocProps {
9
9
  widgetConfig: SearchResultsEntryPointWidgetConfig;
10
10
  }
11
- declare const SearchResults: (props: Omit<SearchResultsProps, keyof SearchResultsHocProps>) => react_jsx_runtime1.JSX.Element;
11
+ declare const SearchResults: (props: Omit<SearchResultsProps, keyof SearchResultsHocProps>) => react_jsx_runtime0.JSX.Element;
12
12
  //#endregion
13
13
 
14
14
  //#endregion
@@ -1,8 +1,8 @@
1
- import * as react_jsx_runtime3 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
2
2
 
3
3
  //#region ../widgets/dist/SearchResults/SearchResultsWidget.d.ts
4
4
  //#region src/SearchResults/SearchResultsWidget.d.ts
5
- declare const SearchResultsWidget: () => react_jsx_runtime3.JSX.Element;
5
+ declare const SearchResultsWidget: () => react_jsx_runtime0.JSX.Element;
6
6
  //#endregion
7
7
 
8
8
  //#endregion
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime0 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime3 from "react/jsx-runtime";
2
2
 
3
3
  //#region ../widgets/dist/SearchZeroState/SearchZeroStateWidget.d.ts
4
4
  //#region src/SearchZeroState/SearchZeroStateWidget.d.ts
@@ -11,7 +11,7 @@ declare const SearchZeroStateWidget: ({
11
11
  initialIsOpen,
12
12
  widgetConfigId,
13
13
  entryPointRef
14
- }: SearchZeroStateWidgetProps) => react_jsx_runtime0.JSX.Element;
14
+ }: SearchZeroStateWidgetProps) => react_jsx_runtime3.JSX.Element;
15
15
  //#endregion
16
16
 
17
17
  //#endregion
@@ -1,6 +1,6 @@
1
1
  import { SuggestionButtonVariant } from "../packages/hooks/dist/contexts/types.cjs";
2
2
  import { SuggestionBarLocationForMetrics } from "./types.cjs";
3
- import * as react_jsx_runtime0 from "react/jsx-runtime";
3
+ import * as react_jsx_runtime2 from "react/jsx-runtime";
4
4
  import { Message } from "postcss";
5
5
 
6
6
  //#region ../widgets/dist/SuggestionBar/SuggestionBar.d.ts
@@ -30,7 +30,7 @@ declare function SuggestionBar({
30
30
  buttonBorderRadius,
31
31
  handleReply,
32
32
  dataTestId
33
- }: Readonly<SuggestionBarProps>): react_jsx_runtime0.JSX.Element;
33
+ }: Readonly<SuggestionBarProps>): react_jsx_runtime2.JSX.Element;
34
34
  //#endregion
35
35
  //#endregion
36
36
  export { SuggestionBar };
@@ -2,8 +2,8 @@ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
2
  const require_functions = require('../utils/functions.cjs');
3
3
  let react = require("react");
4
4
  let jotai = require("jotai");
5
- let __envive_ai_react_hooks_atoms_chat_chatState = require("@envive-ai/react-hooks/atoms/chat/chatState");
6
5
  let __envive_ai_react_hooks_atoms_chat = require("@envive-ai/react-hooks/atoms/chat");
6
+ let __envive_ai_react_hooks_atoms_chat_chatState = require("@envive-ai/react-hooks/atoms/chat/chatState");
7
7
 
8
8
  //#region src/widgets/hooks/useGetWidgetStatus.tsx
9
9
  const useGetWidgetStatus = () => {
@@ -1,8 +1,8 @@
1
1
  import { isLoading, isProductComparison, userHasInteracted, userHasNotInteracted } from "../utils/functions.js";
2
2
  import { useMemo } from "react";
3
3
  import { useAtomValue } from "jotai";
4
- import { responseStreamingAtom } from "@envive-ai/react-hooks/atoms/chat/chatState";
5
4
  import { chatAtom, lastAssistantMessageAtom } from "@envive-ai/react-hooks/atoms/chat";
5
+ import { responseStreamingAtom } from "@envive-ai/react-hooks/atoms/chat/chatState";
6
6
 
7
7
  //#region src/widgets/hooks/useGetWidgetStatus.tsx
8
8
  const useGetWidgetStatus = () => {
@@ -1,6 +1,6 @@
1
1
  const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
- let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
3
2
  let __envive_ai_react_hooks_atoms_chat = require("@envive-ai/react-hooks/atoms/chat");
3
+ let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
4
4
  let __envive_ai_react_hooks_atoms_atomStore = require("@envive-ai/react-hooks/atoms/atomStore");
5
5
 
6
6
  //#region src/widgets/utils/functions.ts
@@ -1,5 +1,5 @@
1
- import { MessageRole, MessageType } from "@envive-ai/react-hooks/application/models";
2
1
  import { chatAtom, lastAssistantMessageAtom } from "@envive-ai/react-hooks/atoms/chat";
2
+ import { MessageRole, MessageType } from "@envive-ai/react-hooks/application/models";
3
3
  import { getAtomStore } from "@envive-ai/react-hooks/atoms/atomStore";
4
4
 
5
5
  //#region src/widgets/utils/functions.ts
@@ -1,4 +1,4 @@
1
- import { SearchResultsWidget } from "../../widgets/dist/SearchResults/SearchResultsWidget.js";
2
- import { SearchResults } from "../../widgets/dist/SearchResults/SearchResults.js";
3
- import "../../widgets/dist/SearchResults/index.js";
1
+ import { SearchResultsWidget } from "../../packages/widgets/dist/SearchResults/SearchResultsWidget.js";
2
+ import { SearchResults } from "../../packages/widgets/dist/SearchResults/SearchResults.js";
3
+ import "../../packages/widgets/dist/SearchResults/index.js";
4
4
  export { SearchResults, SearchResultsWidget };
@@ -1,6 +1,6 @@
1
- import { SearchEntryPointWidgetConfig, SearchInputVariant } from "../../widgets/dist/packages/hooks/dist/contexts/types.js";
2
- import { SearchZeroStateProps } from "../../widgets/dist/SearchZeroState/types.js";
3
- import { SearchZeroState } from "../../widgets/dist/SearchZeroState/SearchZeroState.js";
4
- import { SearchZeroStateWidget } from "../../widgets/dist/SearchZeroState/SearchZeroStateWidget.js";
5
- import "../../widgets/dist/SearchZeroState/index.js";
1
+ import { SearchEntryPointWidgetConfig, SearchInputVariant } from "../../packages/widgets/dist/packages/hooks/dist/contexts/types.js";
2
+ import { SearchZeroStateProps } from "../../packages/widgets/dist/SearchZeroState/types.js";
3
+ import { SearchZeroState } from "../../packages/widgets/dist/SearchZeroState/SearchZeroState.js";
4
+ import { SearchZeroStateWidget } from "../../packages/widgets/dist/SearchZeroState/SearchZeroStateWidget.js";
5
+ import "../../packages/widgets/dist/SearchZeroState/index.js";
6
6
  export { SearchEntryPointWidgetConfig, SearchInputVariant, SearchZeroState, SearchZeroStateProps, SearchZeroStateWidget };
@@ -1,4 +1,4 @@
1
- import { SuggestionBarLocationForMetrics } from "../../widgets/dist/SuggestionBar/types.js";
2
- import { SuggestionBar } from "../../widgets/dist/SuggestionBar/SuggestionBar.js";
3
- import "../../widgets/dist/SuggestionBar/index.js";
1
+ import { SuggestionBarLocationForMetrics } from "../../packages/widgets/dist/SuggestionBar/types.js";
2
+ import { SuggestionBar } from "../../packages/widgets/dist/SuggestionBar/SuggestionBar.js";
3
+ import "../../packages/widgets/dist/SuggestionBar/index.js";
4
4
  export { SuggestionBar, SuggestionBarLocationForMetrics };
@@ -1,3 +1,3 @@
1
- import { SuggestionButtonContainerProps } from "../../widgets/dist/SuggestionButtonContainer/types.js";
2
- import { SuggestionButtonContainer } from "../../widgets/dist/SuggestionButtonContainer/SuggestionButtonContainer.js";
1
+ import { SuggestionButtonContainerProps } from "../../packages/widgets/dist/SuggestionButtonContainer/types.js";
2
+ import { SuggestionButtonContainer } from "../../packages/widgets/dist/SuggestionButtonContainer/SuggestionButtonContainer.js";
3
3
  export { SuggestionButtonContainer, SuggestionButtonContainerProps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envive-ai/react-widgets-v3",
3
- "version": "0.3.2",
3
+ "version": "0.3.5",
4
4
  "description": "React widget library v3 for Envive services.",
5
5
  "keywords": [
6
6
  "react",
@@ -56,7 +56,7 @@ export const SalesAgentTest = () => {
56
56
  onChange={e => setQuery(e.target.value)}
57
57
  onKeyDown={e => {
58
58
  if (e.key === 'Enter') {
59
- onTypedMessageSubmitted({ query, userTyped: true });
59
+ onTypedMessageSubmitted({ query });
60
60
  setQuery('');
61
61
  }
62
62
  }}
@@ -65,7 +65,7 @@ export const SalesAgentTest = () => {
65
65
  <button
66
66
  type="button"
67
67
  onClick={() => {
68
- onTypedMessageSubmitted({ query, userTyped: true });
68
+ onTypedMessageSubmitted({ query });
69
69
  setQuery('');
70
70
  }}
71
71
  >
@@ -2,8 +2,8 @@ import {
2
2
  ChatPreviewComparisonWidgetV3Config,
3
3
  WidgetTypeV3,
4
4
  } from '@envive-ai/react-hooks/contexts/typesV3';
5
- import { useAtomValue } from 'jotai';
6
- import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
5
+ import { useAtomValue, useSetAtom } from 'jotai';
6
+ import { handleReplyAtom } from '@envive-ai/react-hooks/atoms/chat/replies';
7
7
  import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
8
8
  import { chatAtom, lastAssistantMessageAtom } from '@envive-ai/react-hooks/atoms/chat';
9
9
 
@@ -11,8 +11,12 @@ import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
11
11
  import { useCallback, useMemo } from 'react';
12
12
  import {
13
13
  ChatElementDisplayLocationV3,
14
+ Message,
15
+ MessageRole,
16
+ MessageType,
14
17
  VariantTypeEnum,
15
18
  } from '@envive-ai/react-hooks/application/models';
19
+ import { v4 as uuid } from 'uuid';
16
20
  import { ChatPreviewComparison } from '@envive-ai/react-toolkit-v3/ChatPreviewComparison';
17
21
  import { ChatPreviewComparisonProps } from '@envive-ai/react-toolkit-v3/ChatPreviewComparison/types/types';
18
22
  import { variantInfoAtom } from '@envive-ai/react-hooks/atoms/app';
@@ -22,7 +26,7 @@ import { getMessageText, getRecentProductImageUrls } from '../utils/functions';
22
26
  import { ChatPreviewLoadingWidgetWithBaseWidget } from '../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget';
23
27
 
24
28
  const ChatPreviewComparisonWidgetHandler = (props: BaseWidgetProps) => {
25
- const { onTypedMessageSubmitted } = useSalesAgent();
29
+ const handleReply = useSetAtom(handleReplyAtom);
26
30
  const { openChat } = useChatToggle();
27
31
 
28
32
  const lastAssistantMessage = useAtomValue(lastAssistantMessageAtom);
@@ -74,15 +78,33 @@ const ChatPreviewComparisonWidgetHandler = (props: BaseWidgetProps) => {
74
78
 
75
79
  const handlePromptButtonClick = useCallback(
76
80
  (text: string) => {
77
- onTypedMessageSubmitted({ query: text, userTyped: false });
81
+ const newMessage: Message = {
82
+ id: uuid(),
83
+ role: MessageRole.User,
84
+ type: MessageType.QueryTyped,
85
+ createdAt: new Date().toISOString(),
86
+ metadata: { content: text },
87
+ };
88
+ handleReply({ message: newMessage, userTyped: false });
78
89
  openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_PROMPT_BUTTON);
79
90
  },
80
- [onTypedMessageSubmitted, openChat],
91
+ [handleReply, openChat],
81
92
  );
82
93
 
83
- const handleTextFieldClick = useCallback(() => {
84
- openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_TEXT_FIELD);
85
- }, [openChat]);
94
+ const handleTextFieldClick = useCallback(
95
+ (text: string) => {
96
+ const newMessage: Message = {
97
+ id: uuid(),
98
+ role: MessageRole.User,
99
+ type: MessageType.QueryTyped,
100
+ createdAt: new Date().toISOString(),
101
+ metadata: { content: text },
102
+ };
103
+ handleReply({ message: newMessage, userTyped: false });
104
+ openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_TEXT_FIELD);
105
+ },
106
+ [handleReply, openChat],
107
+ );
86
108
 
87
109
  if (isLoading) {
88
110
  return (
@@ -1,12 +1,18 @@
1
1
  import { ChatPreviewWidgetV3Config, WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
2
- import { useAtomValue } from 'jotai';
3
- import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
2
+ import { useAtomValue, useSetAtom } from 'jotai';
3
+ import { handleReplyAtom } from '@envive-ai/react-hooks/atoms/chat/replies';
4
4
  import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
5
5
  import { chatAtom, lastAssistantMessageAtom } from '@envive-ai/react-hooks/atoms/chat';
6
6
 
7
7
  import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
8
8
  import { useCallback, useMemo } from 'react';
9
- import { ChatElementDisplayLocationV3 } from '@envive-ai/react-hooks/application/models';
9
+ import {
10
+ ChatElementDisplayLocationV3,
11
+ Message,
12
+ MessageRole,
13
+ MessageType,
14
+ } from '@envive-ai/react-hooks/application/models';
15
+ import { v4 as uuid } from 'uuid';
10
16
  import { ChatPreviewProps } from '@envive-ai/react-toolkit-v3/ChatPreview/types/types';
11
17
  import { ChatPreview } from '@envive-ai/react-toolkit-v3/ChatPreview';
12
18
  import { withBaseWidget } from '../../hocs/withBaseWidget/withBaseWidget';
@@ -15,7 +21,7 @@ import { getMessageText } from '../utils/functions';
15
21
  import { ChatPreviewLoadingWidgetWithBaseWidget } from '../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget';
16
22
 
17
23
  const ChatPreviewWidgetHandler = (props: BaseWidgetProps) => {
18
- const { onTypedMessageSubmitted } = useSalesAgent();
24
+ const handleReply = useSetAtom(handleReplyAtom);
19
25
  const { openChat } = useChatToggle();
20
26
 
21
27
  const lastAssistantMessage = useAtomValue(lastAssistantMessageAtom);
@@ -50,15 +56,33 @@ const ChatPreviewWidgetHandler = (props: BaseWidgetProps) => {
50
56
 
51
57
  const handlePromptButtonClick = useCallback(
52
58
  (text: string) => {
53
- onTypedMessageSubmitted({ query: text, userTyped: false });
59
+ const newMessage: Message = {
60
+ id: uuid(),
61
+ role: MessageRole.User,
62
+ type: MessageType.QueryTyped,
63
+ createdAt: new Date().toISOString(),
64
+ metadata: { content: text },
65
+ };
66
+ handleReply({ message: newMessage, userTyped: false });
54
67
  openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_PROMPT_BUTTON);
55
68
  },
56
- [onTypedMessageSubmitted, openChat],
69
+ [handleReply, openChat],
57
70
  );
58
71
 
59
- const handleTextFieldClick = useCallback(() => {
60
- openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_TEXT_FIELD);
61
- }, [openChat]);
72
+ const handleTextFieldClick = useCallback(
73
+ (text: string) => {
74
+ const newMessage: Message = {
75
+ id: uuid(),
76
+ role: MessageRole.User,
77
+ type: MessageType.QueryTyped,
78
+ createdAt: new Date().toISOString(),
79
+ metadata: { content: text },
80
+ };
81
+ handleReply({ message: newMessage, userTyped: false });
82
+ openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_TEXT_FIELD);
83
+ },
84
+ [handleReply, openChat],
85
+ );
62
86
 
63
87
  if (isLoading) {
64
88
  return (
@@ -2,12 +2,19 @@ import {
2
2
  PromptButtonCarouselWithImageWidgetV3Config,
3
3
  WidgetTypeV3,
4
4
  } from '@envive-ai/react-hooks/contexts/typesV3';
5
- import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
5
+ import { useSetAtom } from 'jotai';
6
+ import { handleReplyAtom } from '@envive-ai/react-hooks/atoms/chat/replies';
6
7
  import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
7
8
 
8
9
  import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
9
10
  import { useCallback } from 'react';
10
- import { ChatElementDisplayLocationV3 } from '@envive-ai/react-hooks/application/models';
11
+ import {
12
+ ChatElementDisplayLocationV3,
13
+ Message,
14
+ MessageRole,
15
+ MessageType,
16
+ } from '@envive-ai/react-hooks/application/models';
17
+ import { v4 as uuid } from 'uuid';
11
18
  import {
12
19
  PromptButtonCarouselWithImage,
13
20
  PromptButtonCarouselWithImageProps,
@@ -16,7 +23,7 @@ import { BaseWidgetProps } from '../../hocs/withBaseWidget/types';
16
23
  import { withBaseWidget } from '../../hocs/withBaseWidget/withBaseWidget';
17
24
 
18
25
  const PromptButtonCarouselWithImageWidgetHandler = (props: BaseWidgetProps) => {
19
- const { onTypedMessageSubmitted } = useSalesAgent();
26
+ const handleReply = useSetAtom(handleReplyAtom);
20
27
  const { openChat } = useChatToggle();
21
28
 
22
29
  const { hardcopyContent, widgetConfig, isLoading } = props;
@@ -37,15 +44,33 @@ const PromptButtonCarouselWithImageWidgetHandler = (props: BaseWidgetProps) => {
37
44
 
38
45
  const handlePromptButtonClick = useCallback(
39
46
  (text: string) => {
40
- onTypedMessageSubmitted({ query: text, userTyped: false });
47
+ const newMessage: Message = {
48
+ id: uuid(),
49
+ role: MessageRole.User,
50
+ type: MessageType.QueryTyped,
51
+ createdAt: new Date().toISOString(),
52
+ metadata: { content: text },
53
+ };
54
+ handleReply({ message: newMessage, userTyped: false });
41
55
  openChat(ChatElementDisplayLocationV3.PROMPT_BUTTON_CAROUSEL_WITH_IMAGE_PROMPT_BUTTON);
42
56
  },
43
- [onTypedMessageSubmitted, openChat],
57
+ [handleReply, openChat],
44
58
  );
45
59
 
46
- const handleTextFieldClick = useCallback(() => {
47
- openChat(ChatElementDisplayLocationV3.PROMPT_BUTTON_CAROUSEL_WITH_IMAGE_TEXT_FIELD);
48
- }, [openChat]);
60
+ const handleTextFieldClick = useCallback(
61
+ (text: string) => {
62
+ const newMessage: Message = {
63
+ id: uuid(),
64
+ role: MessageRole.User,
65
+ type: MessageType.QueryTyped,
66
+ createdAt: new Date().toISOString(),
67
+ metadata: { content: text },
68
+ };
69
+ handleReply({ message: newMessage, userTyped: false });
70
+ openChat(ChatElementDisplayLocationV3.PROMPT_BUTTON_CAROUSEL_WITH_IMAGE_TEXT_FIELD);
71
+ },
72
+ [handleReply, openChat],
73
+ );
49
74
 
50
75
  return (
51
76
  <PromptButtonCarouselWithImage