@envive-ai/react-widgets-v3 0.3.14 → 0.3.15-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/debug/chatEmbed.cjs +1 -1
- package/dist/debug/chatEmbed.js +1 -1
- package/dist/debug/reportIssue.cjs +1 -1
- package/dist/debug/reportIssue.js +1 -1
- package/dist/hocs/withBaseWidget/types.d.cts +7 -8
- package/dist/hocs/withBaseWidget/types.d.ts +8 -8
- package/dist/hocs/withBaseWidget/withBaseWidget.cjs +37 -43
- package/dist/hocs/withBaseWidget/withBaseWidget.d.cts +2 -2
- package/dist/hocs/withBaseWidget/withBaseWidget.d.ts +2 -2
- package/dist/hocs/withBaseWidget/withBaseWidget.js +39 -45
- package/dist/hooks/dist/application/models/api/widgetText.d.cts +8 -0
- package/dist/hooks/dist/contexts/hardcopyContext/hardcopyContext.d.cts +12 -0
- package/dist/hooks/dist/contexts/types.d.cts +38 -0
- package/dist/hooks/dist/contexts/typesV3.d.cts +230 -0
- package/dist/hooks/dist/types/customerService.d.cts +21 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/WidgetType.cjs +1 -0
- package/dist/packages/hooks/dist/application/models/api/orgConfigResults.d.ts +2 -0
- package/dist/packages/hooks/dist/application/models/api/userEvent.d.ts +1 -0
- package/dist/packages/hooks/dist/application/models/api/widgetText.d.ts +8 -0
- package/dist/packages/hooks/dist/application/models/frontendConfig.d.ts +1 -0
- package/dist/packages/hooks/dist/contexts/hardcopyContext/hardcopyContext.d.ts +15 -0
- package/dist/packages/hooks/dist/contexts/hardcopyContext/index.d.ts +1 -0
- package/dist/packages/hooks/dist/contexts/types.d.ts +44 -0
- package/dist/packages/hooks/dist/contexts/typesV3.d.ts +230 -0
- package/dist/packages/hooks/dist/types/customerService.d.ts +21 -0
- package/dist/packages/hooks/dist/types/custservice-types.d.ts +1 -0
- package/dist/packages/icons/dist/IconCloseVariant.cjs +5 -6
- package/dist/packages/icons/dist/IconCloseVariant.js +4 -6
- package/dist/packages/widgets/dist/SearchResults/SearchResults.d.ts +4 -3
- package/dist/packages/widgets/dist/SearchResults/SearchResultsWidget.d.ts +2 -2
- package/dist/packages/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.ts +2 -2
- package/dist/packages/widgets/dist/SearchZeroState/index.d.ts +2 -1
- package/dist/packages/widgets/dist/SearchZeroState/types.d.ts +2 -2
- package/dist/packages/widgets/dist/SuggestionBar/SuggestionBar.d.ts +3 -3
- package/dist/packages/widgets/dist/SuggestionButtonContainer/index.d.ts +2 -0
- package/dist/packages/widgets/dist/SuggestionButtonContainer/types.d.ts +3 -2
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/api/response.d.ts +14 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/api/search.d.ts +15 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/camelCase.d.ts +73 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/camelCasedPropertiesDeep.d.ts +61 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/internal.d.ts +25 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/splitWords.d.ts +35 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/trim.d.ts +32 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/unknownArray.d.ts +32 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/variantInfo/pageVisitInfo.d.ts +1 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/variantInfo/variantInfo.d.ts +2 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/atoms/search/searchAPI.d.ts +15 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/contexts/hardcopyContext/hardcopyContext.d.ts +1 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/contexts/types.d.ts +64 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/hooks/Search/useSearch.d.ts +60 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/hooks/utils.d.ts +13 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/types/OrgInfo.d.ts +1 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/types/index.d.ts +1 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/types/search-filter-types.d.ts +28 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/types/test-types.d.ts +10 -0
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs +35 -4
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +35 -4
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.cjs +33 -12
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.js +35 -14
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.cjs +44 -23
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.js +44 -23
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +62 -38
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +5 -3
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +5 -3
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +63 -39
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.cts +2 -2
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.cjs +24 -12
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.js +26 -14
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +22 -12
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +24 -14
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +14 -11
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +18 -15
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.cjs +1 -1
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.js +1 -1
- package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +53 -15
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.js +56 -18
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +10 -10
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +13 -13
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.cjs +1 -1
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.cts +2 -2
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.js +1 -1
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.cjs +23 -11
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +26 -14
- package/dist/widgets/dist/SearchResults/SearchResults.d.cts +4 -3
- package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.cts +2 -2
- package/dist/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.cts +2 -2
- package/dist/widgets/dist/SearchZeroState/types.d.cts +2 -2
- package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.cts +3 -3
- package/dist/widgets/dist/SuggestionButtonContainer/types.d.cts +3 -2
- package/dist/widgets/dist/packages/hooks/dist/application/models/api/response.d.cts +14 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/api/search.d.cts +15 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/camelCase.d.cts +73 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/camelCasedPropertiesDeep.d.cts +61 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/internal.d.cts +25 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/splitWords.d.cts +35 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/trim.d.cts +32 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/unknownArray.d.cts +32 -0
- package/dist/widgets/dist/packages/hooks/dist/atoms/search/searchAPI.d.cts +14 -0
- package/dist/widgets/dist/packages/hooks/dist/contexts/types.d.cts +61 -0
- package/dist/widgets/dist/packages/hooks/dist/hooks/Search/useSearch.d.cts +60 -0
- package/dist/widgets/dist/packages/hooks/dist/hooks/utils.d.cts +12 -0
- package/dist/widgets/dist/packages/hooks/dist/types/search-filter-types.d.cts +28 -0
- package/dist/widgets/dist/packages/hooks/dist/types/test-types.d.cts +10 -0
- package/dist/widgets/hooks/useGetWidgetStatus.cjs +1 -1
- package/dist/widgets/hooks/useGetWidgetStatus.js +1 -1
- package/dist/widgets/utils/functions.cjs +0 -14
- package/dist/widgets/utils/functions.js +1 -14
- package/dist/widgets-v2/SearchZeroState/index.d.cts +2 -1
- package/dist/widgets-v2/SearchZeroState/index.d.ts +2 -1
- package/dist/widgets-v2/SuggestionButtonContainer/index.d.ts +1 -0
- package/package.json +4 -4
- package/src/hocs/withBaseWidget/__tests__/withBaseWidget.test.tsx +68 -302
- package/src/hocs/withBaseWidget/types.ts +6 -6
- package/src/hocs/withBaseWidget/withBaseWidget.tsx +46 -61
- package/src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.tsx +59 -8
- package/src/widgets/ChatPreviewWidget/ChatPreviewWidget.tsx +54 -18
- package/src/widgets/ChatPreviewWidget/__tests__/ChatPreviewWidget.test.tsx +11 -5
- package/src/widgets/FloatingChatWidget/FloatingChatOverlay.tsx +48 -19
- package/src/widgets/FloatingChatWidget/FloatingChatWidget.tsx +100 -52
- package/src/widgets/FloatingChatWidget/__tests__/FloatingChatWidget.test.tsx +11 -5
- package/src/widgets/ProductCardWidget/ProductCardWidget.tsx +37 -16
- package/src/widgets/ProductCardWidget/__tests__/ProductCardWidget.test.tsx +12 -8
- package/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx +38 -19
- package/src/widgets/PromptButtonCarouselWithImageWidget/__tests__/PromptButtonCarouselWithImageWidget.test.tsx +19 -8
- package/src/widgets/PromptCarouselWidget/PromptCarouselWidget.tsx +32 -19
- package/src/widgets/PromptCarouselWidget/__tests__/PromptCarouselWidget.test.tsx +21 -8
- package/src/widgets/SocialProofWidget/SocialProofWidget.tsx +77 -18
- package/src/widgets/SocialProofWidget/__tests__/SocialProofWidget.test.tsx +19 -8
- package/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.tsx +23 -19
- package/src/widgets/TitledPromptCarouselWidget/__tests__/TitledPromptCarouselWidget.test.tsx +19 -8
- package/src/widgets/TypingAnimationWidget/TypingAnimationWidget.tsx +45 -21
- package/src/widgets/TypingAnimationWidget/__tests__/TypingAnimationWidget.test.tsx +19 -8
- package/src/widgets/__tests__/trackEventCanary.test.ts +1 -1
- package/dist/packages/icons/dist/_virtual/rolldown_runtime.cjs +0 -27
- package/dist/packages/icons/dist/_virtual/rolldown_runtime.js +0 -25
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.development.cjs +0 -696
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.development.js +0 -696
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.production.min.cjs +0 -43
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.production.min.js +0 -43
- package/dist/packages/icons/dist/node_modules/react/cjs/react.development.cjs +0 -1528
- package/dist/packages/icons/dist/node_modules/react/cjs/react.development.js +0 -1528
- package/dist/packages/icons/dist/node_modules/react/cjs/react.production.min.cjs +0 -329
- package/dist/packages/icons/dist/node_modules/react/cjs/react.production.min.js +0 -329
- package/dist/packages/icons/dist/node_modules/react/index.cjs +0 -13
- package/dist/packages/icons/dist/node_modules/react/index.js +0 -13
- package/dist/packages/icons/dist/node_modules/react/jsx-runtime.cjs +0 -13
- package/dist/packages/icons/dist/node_modules/react/jsx-runtime.js +0 -13
|
@@ -3,21 +3,27 @@ const require_withBaseWidget = require('../../hocs/withBaseWidget/withBaseWidget
|
|
|
3
3
|
const require_functions = require('../utils/functions.cjs');
|
|
4
4
|
const require_ChatPreviewLoadingWidget = require('../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.cjs');
|
|
5
5
|
let react = require("react");
|
|
6
|
+
let __envive_ai_react_hooks_contexts_amplitudeContext = require("@envive-ai/react-hooks/contexts/amplitudeContext");
|
|
6
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
-
let
|
|
8
|
-
let jotai = require("jotai");
|
|
8
|
+
let __envive_ai_react_hooks_atoms_chat = require("@envive-ai/react-hooks/atoms/chat");
|
|
9
9
|
let __envive_ai_react_hooks_contexts_salesAgentContext = require("@envive-ai/react-hooks/contexts/salesAgentContext");
|
|
10
|
+
let __envive_ai_react_hooks_contexts_typesV3 = require("@envive-ai/react-hooks/contexts/typesV3");
|
|
10
11
|
let __envive_ai_react_hooks_hooks_ChatToggle = require("@envive-ai/react-hooks/hooks/ChatToggle");
|
|
11
|
-
let
|
|
12
|
+
let jotai = require("jotai");
|
|
12
13
|
let __envive_ai_react_toolkit_v3_Tokens = require("@envive-ai/react-toolkit-v3/Tokens");
|
|
13
14
|
let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
|
|
14
|
-
let
|
|
15
|
+
let __envive_ai_react_hooks_hooks_WidgetInteraction = require("@envive-ai/react-hooks/hooks/WidgetInteraction");
|
|
16
|
+
let __envive_ai_react_hooks_hooks_WidgetInteraction_types = require("@envive-ai/react-hooks/hooks/WidgetInteraction/types");
|
|
17
|
+
let __envive_ai_react_toolkit_v3_PromptCarousel = require("@envive-ai/react-toolkit-v3/PromptCarousel");
|
|
15
18
|
let __envive_ai_react_hooks_atoms_app = require("@envive-ai/react-hooks/atoms/app");
|
|
19
|
+
let __envive_ai_react_toolkit_v3_ChatPreviewComparison = require("@envive-ai/react-toolkit-v3/ChatPreviewComparison");
|
|
16
20
|
|
|
17
21
|
//#region src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.tsx
|
|
18
22
|
const ChatPreviewComparisonWidgetHandler = (props) => {
|
|
19
23
|
const { onSuggestionClicked } = (0, __envive_ai_react_hooks_contexts_salesAgentContext.useSalesAgent)();
|
|
20
24
|
const { openChat } = (0, __envive_ai_react_hooks_hooks_ChatToggle.useChatToggle)();
|
|
25
|
+
const { trackWidgetInteraction } = (0, __envive_ai_react_hooks_hooks_WidgetInteraction.useWidgetInteraction)();
|
|
26
|
+
const { onClick: onPromptClicked, onDrag, onHover, onMouseDown, onMouseUp, onTouchStart, onTouchEnd } = (0, __envive_ai_react_toolkit_v3_PromptCarousel.usePromptCarouselAnalytics)(__envive_ai_react_hooks_hooks_WidgetInteraction_types.WidgetInteractionComponent.POST_INTERACTION_COMPARISON, (text) => text);
|
|
21
27
|
const lastAssistantMessage = (0, jotai.useAtomValue)(__envive_ai_react_hooks_atoms_chat.lastAssistantMessageAtom);
|
|
22
28
|
const variantInfo = (0, jotai.useAtomValue)(__envive_ai_react_hooks_atoms_app.variantInfoAtom);
|
|
23
29
|
const productId = variantInfo.variant === __envive_ai_react_hooks_application_models.VariantTypeEnum.Pdp ? variantInfo.productId : void 0;
|
|
@@ -42,10 +48,28 @@ const ChatPreviewComparisonWidgetHandler = (props) => {
|
|
|
42
48
|
const handlePromptButtonClick = (0, react.useCallback)((suggestion) => {
|
|
43
49
|
onSuggestionClicked(suggestion, __envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_PROMPT_BUTTON);
|
|
44
50
|
openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_PROMPT_BUTTON);
|
|
51
|
+
onPromptClicked(suggestion.id);
|
|
45
52
|
}, [onSuggestionClicked, openChat]);
|
|
46
53
|
const handleTextFieldClick = (0, react.useCallback)(() => {
|
|
47
54
|
openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_TEXT_FIELD);
|
|
55
|
+
trackWidgetInteraction({
|
|
56
|
+
eventName: __envive_ai_react_hooks_contexts_amplitudeContext.EnviveMetricsEventName.WidgetInteraction,
|
|
57
|
+
trigger: {
|
|
58
|
+
widget: __envive_ai_react_hooks_hooks_WidgetInteraction_types.WidgetInteractionComponent.POST_INTERACTION_COMPARISON,
|
|
59
|
+
widget_interaction: __envive_ai_react_hooks_hooks_WidgetInteraction_types.WidgetInteractionType.QUERY_INPUT_CLICKED
|
|
60
|
+
}
|
|
61
|
+
});
|
|
48
62
|
}, [openChat]);
|
|
63
|
+
const handleLinkClick = (url) => {
|
|
64
|
+
trackWidgetInteraction({
|
|
65
|
+
eventName: __envive_ai_react_hooks_contexts_amplitudeContext.EnviveMetricsEventName.WidgetInteraction,
|
|
66
|
+
trigger: {
|
|
67
|
+
widget: __envive_ai_react_hooks_hooks_WidgetInteraction_types.WidgetInteractionComponent.POST_INTERACTION_COMPARISON,
|
|
68
|
+
widget_interaction: __envive_ai_react_hooks_hooks_WidgetInteraction_types.WidgetInteractionType.LINK_CLICKED,
|
|
69
|
+
widget_interaction_data: { link_clicked: { url } }
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
};
|
|
49
73
|
if (isLoading) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ChatPreviewLoadingWidget.ChatPreviewLoadingWidgetWithBaseWidget, {
|
|
50
74
|
widgetConfigId,
|
|
51
75
|
widgetType: __envive_ai_react_hooks_contexts_typesV3.WidgetTypeV3.ChatPreviewLoadingV3
|
|
@@ -73,6 +97,13 @@ const ChatPreviewComparisonWidgetHandler = (props) => {
|
|
|
73
97
|
widgetContentProps,
|
|
74
98
|
widgetEventProps: {
|
|
75
99
|
handlePromptButtonClick,
|
|
100
|
+
handlePromptButtonDrag: onDrag,
|
|
101
|
+
handlePromptButtonHover: onHover,
|
|
102
|
+
handlePromptButtonMouseDown: onMouseDown,
|
|
103
|
+
handlePromptButtonMouseUp: onMouseUp,
|
|
104
|
+
handlePromptButtonTouchStart: onTouchStart,
|
|
105
|
+
handlePromptButtonTouchEnd: onTouchEnd,
|
|
106
|
+
handleLinkClick,
|
|
76
107
|
handleTextFieldClick
|
|
77
108
|
}
|
|
78
109
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts
|
|
5
5
|
declare const ChatPreviewComparisonWidgetWithBaseWidget: {
|
|
6
|
-
(props: BaseWidgetProps):
|
|
6
|
+
(props: BaseWidgetProps): react_jsx_runtime1.JSX.Element;
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
interface ChatPreviewComparisonWidgetProps {
|
|
@@ -12,7 +12,7 @@ interface ChatPreviewComparisonWidgetProps {
|
|
|
12
12
|
declare const ChatPreviewComparisonWidget: {
|
|
13
13
|
({
|
|
14
14
|
widgetConfigId
|
|
15
|
-
}: ChatPreviewComparisonWidgetProps):
|
|
15
|
+
}: ChatPreviewComparisonWidgetProps): react_jsx_runtime1.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
|
|
2
|
+
import * as react_jsx_runtime16 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts
|
|
5
5
|
declare const ChatPreviewComparisonWidgetWithBaseWidget: {
|
|
6
|
-
(props: BaseWidgetProps):
|
|
6
|
+
(props: BaseWidgetProps): react_jsx_runtime16.JSX.Element;
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
interface ChatPreviewComparisonWidgetProps {
|
|
@@ -12,7 +12,7 @@ interface ChatPreviewComparisonWidgetProps {
|
|
|
12
12
|
declare const ChatPreviewComparisonWidget: {
|
|
13
13
|
({
|
|
14
14
|
widgetConfigId
|
|
15
|
-
}: ChatPreviewComparisonWidgetProps):
|
|
15
|
+
}: ChatPreviewComparisonWidgetProps): react_jsx_runtime16.JSX.Element;
|
|
16
16
|
displayName: string;
|
|
17
17
|
};
|
|
18
18
|
//#endregion
|
|
@@ -2,21 +2,27 @@ import { withBaseWidget } from "../../hocs/withBaseWidget/withBaseWidget.js";
|
|
|
2
2
|
import { getMessageText, getRecentProductImageUrls } from "../utils/functions.js";
|
|
3
3
|
import { ChatPreviewLoadingWidgetWithBaseWidget } from "../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.js";
|
|
4
4
|
import { useCallback, useMemo } from "react";
|
|
5
|
+
import { EnviveMetricsEventName } from "@envive-ai/react-hooks/contexts/amplitudeContext";
|
|
5
6
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
import {
|
|
7
|
-
import { useAtomValue } from "jotai";
|
|
7
|
+
import { chatAtom, lastAssistantMessageAtom } from "@envive-ai/react-hooks/atoms/chat";
|
|
8
8
|
import { useSalesAgent } from "@envive-ai/react-hooks/contexts/salesAgentContext";
|
|
9
|
+
import { WidgetTypeV3 } from "@envive-ai/react-hooks/contexts/typesV3";
|
|
9
10
|
import { useChatToggle } from "@envive-ai/react-hooks/hooks/ChatToggle";
|
|
10
|
-
import {
|
|
11
|
+
import { useAtomValue } from "jotai";
|
|
11
12
|
import { Theme } from "@envive-ai/react-toolkit-v3/Tokens";
|
|
12
13
|
import { ChatElementDisplayLocationV3, VariantTypeEnum } from "@envive-ai/react-hooks/application/models";
|
|
13
|
-
import {
|
|
14
|
+
import { useWidgetInteraction } from "@envive-ai/react-hooks/hooks/WidgetInteraction";
|
|
15
|
+
import { WidgetInteractionComponent, WidgetInteractionType } from "@envive-ai/react-hooks/hooks/WidgetInteraction/types";
|
|
16
|
+
import { usePromptCarouselAnalytics } from "@envive-ai/react-toolkit-v3/PromptCarousel";
|
|
14
17
|
import { variantInfoAtom } from "@envive-ai/react-hooks/atoms/app";
|
|
18
|
+
import { ChatPreviewComparison } from "@envive-ai/react-toolkit-v3/ChatPreviewComparison";
|
|
15
19
|
|
|
16
20
|
//#region src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.tsx
|
|
17
21
|
const ChatPreviewComparisonWidgetHandler = (props) => {
|
|
18
22
|
const { onSuggestionClicked } = useSalesAgent();
|
|
19
23
|
const { openChat } = useChatToggle();
|
|
24
|
+
const { trackWidgetInteraction } = useWidgetInteraction();
|
|
25
|
+
const { onClick: onPromptClicked, onDrag, onHover, onMouseDown, onMouseUp, onTouchStart, onTouchEnd } = usePromptCarouselAnalytics(WidgetInteractionComponent.POST_INTERACTION_COMPARISON, (text) => text);
|
|
20
26
|
const lastAssistantMessage = useAtomValue(lastAssistantMessageAtom);
|
|
21
27
|
const variantInfo = useAtomValue(variantInfoAtom);
|
|
22
28
|
const productId = variantInfo.variant === VariantTypeEnum.Pdp ? variantInfo.productId : void 0;
|
|
@@ -41,10 +47,28 @@ const ChatPreviewComparisonWidgetHandler = (props) => {
|
|
|
41
47
|
const handlePromptButtonClick = useCallback((suggestion) => {
|
|
42
48
|
onSuggestionClicked(suggestion, ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_PROMPT_BUTTON);
|
|
43
49
|
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_PROMPT_BUTTON);
|
|
50
|
+
onPromptClicked(suggestion.id);
|
|
44
51
|
}, [onSuggestionClicked, openChat]);
|
|
45
52
|
const handleTextFieldClick = useCallback(() => {
|
|
46
53
|
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_TEXT_FIELD);
|
|
54
|
+
trackWidgetInteraction({
|
|
55
|
+
eventName: EnviveMetricsEventName.WidgetInteraction,
|
|
56
|
+
trigger: {
|
|
57
|
+
widget: WidgetInteractionComponent.POST_INTERACTION_COMPARISON,
|
|
58
|
+
widget_interaction: WidgetInteractionType.QUERY_INPUT_CLICKED
|
|
59
|
+
}
|
|
60
|
+
});
|
|
47
61
|
}, [openChat]);
|
|
62
|
+
const handleLinkClick = (url) => {
|
|
63
|
+
trackWidgetInteraction({
|
|
64
|
+
eventName: EnviveMetricsEventName.WidgetInteraction,
|
|
65
|
+
trigger: {
|
|
66
|
+
widget: WidgetInteractionComponent.POST_INTERACTION_COMPARISON,
|
|
67
|
+
widget_interaction: WidgetInteractionType.LINK_CLICKED,
|
|
68
|
+
widget_interaction_data: { link_clicked: { url } }
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
};
|
|
48
72
|
if (isLoading) return /* @__PURE__ */ jsx(ChatPreviewLoadingWidgetWithBaseWidget, {
|
|
49
73
|
widgetConfigId,
|
|
50
74
|
widgetType: WidgetTypeV3.ChatPreviewLoadingV3
|
|
@@ -72,6 +96,13 @@ const ChatPreviewComparisonWidgetHandler = (props) => {
|
|
|
72
96
|
widgetContentProps,
|
|
73
97
|
widgetEventProps: {
|
|
74
98
|
handlePromptButtonClick,
|
|
99
|
+
handlePromptButtonDrag: onDrag,
|
|
100
|
+
handlePromptButtonHover: onHover,
|
|
101
|
+
handlePromptButtonMouseDown: onMouseDown,
|
|
102
|
+
handlePromptButtonMouseUp: onMouseUp,
|
|
103
|
+
handlePromptButtonTouchStart: onTouchStart,
|
|
104
|
+
handlePromptButtonTouchEnd: onTouchEnd,
|
|
105
|
+
handleLinkClick,
|
|
75
106
|
handleTextFieldClick
|
|
76
107
|
}
|
|
77
108
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime12 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts
|
|
5
5
|
declare const ChatPreviewLoadingWidgetWithBaseWidget: {
|
|
6
|
-
(props: BaseWidgetProps):
|
|
6
|
+
(props: BaseWidgetProps): react_jsx_runtime12.JSX.Element;
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
interface ChatPreviewLoadingWidgetProps {
|
|
@@ -11,6 +11,6 @@ interface ChatPreviewLoadingWidgetProps {
|
|
|
11
11
|
}
|
|
12
12
|
declare const ChatPreviewLoadingWidget: ({
|
|
13
13
|
widgetConfigId
|
|
14
|
-
}: ChatPreviewLoadingWidgetProps) =>
|
|
14
|
+
}: ChatPreviewLoadingWidgetProps) => react_jsx_runtime12.JSX.Element;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { ChatPreviewLoadingWidget, ChatPreviewLoadingWidgetProps, ChatPreviewLoadingWidgetWithBaseWidget };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts
|
|
5
5
|
declare const ChatPreviewLoadingWidgetWithBaseWidget: {
|
|
6
|
-
(props: BaseWidgetProps):
|
|
6
|
+
(props: BaseWidgetProps): react_jsx_runtime0.JSX.Element;
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
interface ChatPreviewLoadingWidgetProps {
|
|
@@ -11,6 +11,6 @@ interface ChatPreviewLoadingWidgetProps {
|
|
|
11
11
|
}
|
|
12
12
|
declare const ChatPreviewLoadingWidget: ({
|
|
13
13
|
widgetConfigId
|
|
14
|
-
}: ChatPreviewLoadingWidgetProps) =>
|
|
14
|
+
}: ChatPreviewLoadingWidgetProps) => react_jsx_runtime0.JSX.Element;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { ChatPreviewLoadingWidget, ChatPreviewLoadingWidgetProps, ChatPreviewLoadingWidgetWithBaseWidget };
|
|
@@ -5,14 +5,17 @@ const require_ChatPreviewLoadingWidget = require('../ChatPreviewLoadingWidget/Ch
|
|
|
5
5
|
let react = require("react");
|
|
6
6
|
let __envive_ai_react_hooks_contexts_amplitudeContext = require("@envive-ai/react-hooks/contexts/amplitudeContext");
|
|
7
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
-
let
|
|
9
|
-
let jotai = require("jotai");
|
|
8
|
+
let __envive_ai_react_hooks_atoms_chat = require("@envive-ai/react-hooks/atoms/chat");
|
|
10
9
|
let __envive_ai_react_hooks_contexts_salesAgentContext = require("@envive-ai/react-hooks/contexts/salesAgentContext");
|
|
10
|
+
let __envive_ai_react_hooks_contexts_typesV3 = require("@envive-ai/react-hooks/contexts/typesV3");
|
|
11
11
|
let __envive_ai_react_hooks_hooks_ChatToggle = require("@envive-ai/react-hooks/hooks/ChatToggle");
|
|
12
|
-
let
|
|
12
|
+
let jotai = require("jotai");
|
|
13
13
|
let __envive_ai_react_toolkit_v3_Tokens = require("@envive-ai/react-toolkit-v3/Tokens");
|
|
14
14
|
let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
|
|
15
|
+
let __envive_ai_react_hooks_hooks_WidgetInteraction = require("@envive-ai/react-hooks/hooks/WidgetInteraction");
|
|
16
|
+
let __envive_ai_react_hooks_hooks_WidgetInteraction_types = require("@envive-ai/react-hooks/hooks/WidgetInteraction/types");
|
|
15
17
|
let __envive_ai_react_toolkit_v3_ChatPreview = require("@envive-ai/react-toolkit-v3/ChatPreview");
|
|
18
|
+
let __envive_ai_react_toolkit_v3_PromptCarousel = require("@envive-ai/react-toolkit-v3/PromptCarousel");
|
|
16
19
|
|
|
17
20
|
//#region src/widgets/ChatPreviewWidget/ChatPreviewWidget.tsx
|
|
18
21
|
const ChatPreviewWidgetHandler = (props) => {
|
|
@@ -31,24 +34,35 @@ const ChatPreviewWidgetHandler = (props) => {
|
|
|
31
34
|
messageText
|
|
32
35
|
};
|
|
33
36
|
const { trackEvent } = (0, __envive_ai_react_hooks_contexts_amplitudeContext.useAmplitude)();
|
|
34
|
-
(0,
|
|
35
|
-
|
|
36
|
-
eventName: __envive_ai_react_hooks_contexts_amplitudeContext.SpiffyMetricsEventName.ChatComponentVisible,
|
|
37
|
-
eventProps: {
|
|
38
|
-
widget_config_id: widgetConfigId,
|
|
39
|
-
widget_type: __envive_ai_react_hooks_contexts_typesV3.WidgetTypeV3.ChatPreviewV3
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}, [trackEvent, widgetConfigId]);
|
|
37
|
+
const { trackWidgetInteraction } = (0, __envive_ai_react_hooks_hooks_WidgetInteraction.useWidgetInteraction)();
|
|
38
|
+
const { onClick: onPromptClicked, onDrag, onHover, onMouseDown, onMouseUp, onTouchStart, onTouchEnd } = (0, __envive_ai_react_toolkit_v3_PromptCarousel.usePromptCarouselAnalytics)(__envive_ai_react_hooks_hooks_WidgetInteraction_types.WidgetInteractionComponent.CHAT_PREVIEW, (text) => text);
|
|
43
39
|
const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc;
|
|
44
40
|
const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
|
|
45
41
|
const handlePromptButtonClick = (0, react.useCallback)((suggestion) => {
|
|
46
42
|
onSuggestionClicked(suggestion, __envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.CHAT_PREVIEW_PROMPT_BUTTON);
|
|
47
43
|
openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.CHAT_PREVIEW_PROMPT_BUTTON);
|
|
44
|
+
onPromptClicked(suggestion.id);
|
|
48
45
|
}, [onSuggestionClicked, openChat]);
|
|
49
46
|
const handleTextFieldClick = (0, react.useCallback)(() => {
|
|
50
47
|
openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.CHAT_PREVIEW_TEXT_FIELD);
|
|
48
|
+
trackWidgetInteraction({
|
|
49
|
+
eventName: __envive_ai_react_hooks_contexts_amplitudeContext.EnviveMetricsEventName.WidgetInteraction,
|
|
50
|
+
trigger: {
|
|
51
|
+
widget: __envive_ai_react_hooks_hooks_WidgetInteraction_types.WidgetInteractionComponent.CHAT_PREVIEW,
|
|
52
|
+
widget_interaction: __envive_ai_react_hooks_hooks_WidgetInteraction_types.WidgetInteractionType.QUERY_INPUT_CLICKED
|
|
53
|
+
}
|
|
54
|
+
});
|
|
51
55
|
}, [openChat]);
|
|
56
|
+
const handleLinkClick = (url) => {
|
|
57
|
+
trackWidgetInteraction({
|
|
58
|
+
eventName: __envive_ai_react_hooks_contexts_amplitudeContext.EnviveMetricsEventName.WidgetInteraction,
|
|
59
|
+
trigger: {
|
|
60
|
+
widget: __envive_ai_react_hooks_hooks_WidgetInteraction_types.WidgetInteractionComponent.CHAT_PREVIEW,
|
|
61
|
+
widget_interaction: __envive_ai_react_hooks_hooks_WidgetInteraction_types.WidgetInteractionType.LINK_CLICKED,
|
|
62
|
+
widget_interaction_data: { link_clicked: { url } }
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
};
|
|
52
66
|
if (isLoading) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ChatPreviewLoadingWidget.ChatPreviewLoadingWidgetWithBaseWidget, {
|
|
53
67
|
widgetConfigId,
|
|
54
68
|
widgetType: __envive_ai_react_hooks_contexts_typesV3.WidgetTypeV3.ChatPreviewLoadingV3
|
|
@@ -73,6 +87,13 @@ const ChatPreviewWidgetHandler = (props) => {
|
|
|
73
87
|
widgetContentProps,
|
|
74
88
|
widgetEventProps: {
|
|
75
89
|
handlePromptButtonClick,
|
|
90
|
+
handlePromptButtonDrag: onDrag,
|
|
91
|
+
handlePromptButtonHover: onHover,
|
|
92
|
+
handlePromptButtonMouseDown: onMouseDown,
|
|
93
|
+
handlePromptButtonMouseUp: onMouseUp,
|
|
94
|
+
handlePromptButtonTouchStart: onTouchStart,
|
|
95
|
+
handlePromptButtonTouchEnd: onTouchEnd,
|
|
96
|
+
handleLinkClick,
|
|
76
97
|
handleTextFieldClick
|
|
77
98
|
}
|
|
78
99
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime7 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts
|
|
5
5
|
declare const ChatPreviewWidgetWithBaseWidget: {
|
|
6
|
-
(props: BaseWidgetProps):
|
|
6
|
+
(props: BaseWidgetProps): react_jsx_runtime7.JSX.Element;
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
interface ChatPreviewWidgetProps {
|
|
@@ -12,7 +12,7 @@ interface ChatPreviewWidgetProps {
|
|
|
12
12
|
declare const ChatPreviewWidget: {
|
|
13
13
|
({
|
|
14
14
|
widgetConfigId
|
|
15
|
-
}: ChatPreviewWidgetProps):
|
|
15
|
+
}: ChatPreviewWidgetProps): react_jsx_runtime7.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
|
|
2
|
+
import * as react_jsx_runtime9 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts
|
|
5
5
|
declare const ChatPreviewWidgetWithBaseWidget: {
|
|
6
|
-
(props: BaseWidgetProps):
|
|
6
|
+
(props: BaseWidgetProps): react_jsx_runtime9.JSX.Element;
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
interface ChatPreviewWidgetProps {
|
|
@@ -12,7 +12,7 @@ interface ChatPreviewWidgetProps {
|
|
|
12
12
|
declare const ChatPreviewWidget: {
|
|
13
13
|
({
|
|
14
14
|
widgetConfigId
|
|
15
|
-
}: ChatPreviewWidgetProps):
|
|
15
|
+
}: ChatPreviewWidgetProps): react_jsx_runtime9.JSX.Element;
|
|
16
16
|
displayName: string;
|
|
17
17
|
};
|
|
18
18
|
//#endregion
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { withBaseWidget } from "../../hocs/withBaseWidget/withBaseWidget.js";
|
|
2
2
|
import { getMessageText } from "../utils/functions.js";
|
|
3
3
|
import { ChatPreviewLoadingWidgetWithBaseWidget } from "../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.js";
|
|
4
|
-
import { useCallback,
|
|
5
|
-
import {
|
|
4
|
+
import { useCallback, useMemo } from "react";
|
|
5
|
+
import { EnviveMetricsEventName, useAmplitude } from "@envive-ai/react-hooks/contexts/amplitudeContext";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
import {
|
|
8
|
-
import { useAtomValue } from "jotai";
|
|
7
|
+
import { chatAtom, lastAssistantMessageAtom } from "@envive-ai/react-hooks/atoms/chat";
|
|
9
8
|
import { useSalesAgent } from "@envive-ai/react-hooks/contexts/salesAgentContext";
|
|
9
|
+
import { WidgetTypeV3 } from "@envive-ai/react-hooks/contexts/typesV3";
|
|
10
10
|
import { useChatToggle } from "@envive-ai/react-hooks/hooks/ChatToggle";
|
|
11
|
-
import {
|
|
11
|
+
import { useAtomValue } from "jotai";
|
|
12
12
|
import { Theme } from "@envive-ai/react-toolkit-v3/Tokens";
|
|
13
13
|
import { ChatElementDisplayLocationV3 } from "@envive-ai/react-hooks/application/models";
|
|
14
|
+
import { useWidgetInteraction } from "@envive-ai/react-hooks/hooks/WidgetInteraction";
|
|
15
|
+
import { WidgetInteractionComponent, WidgetInteractionType } from "@envive-ai/react-hooks/hooks/WidgetInteraction/types";
|
|
14
16
|
import { ChatPreview } from "@envive-ai/react-toolkit-v3/ChatPreview";
|
|
17
|
+
import { usePromptCarouselAnalytics } from "@envive-ai/react-toolkit-v3/PromptCarousel";
|
|
15
18
|
|
|
16
19
|
//#region src/widgets/ChatPreviewWidget/ChatPreviewWidget.tsx
|
|
17
20
|
const ChatPreviewWidgetHandler = (props) => {
|
|
@@ -30,24 +33,35 @@ const ChatPreviewWidgetHandler = (props) => {
|
|
|
30
33
|
messageText
|
|
31
34
|
};
|
|
32
35
|
const { trackEvent } = useAmplitude();
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
eventName: SpiffyMetricsEventName.ChatComponentVisible,
|
|
36
|
-
eventProps: {
|
|
37
|
-
widget_config_id: widgetConfigId,
|
|
38
|
-
widget_type: WidgetTypeV3.ChatPreviewV3
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}, [trackEvent, widgetConfigId]);
|
|
36
|
+
const { trackWidgetInteraction } = useWidgetInteraction();
|
|
37
|
+
const { onClick: onPromptClicked, onDrag, onHover, onMouseDown, onMouseUp, onTouchStart, onTouchEnd } = usePromptCarouselAnalytics(WidgetInteractionComponent.CHAT_PREVIEW, (text) => text);
|
|
42
38
|
const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc;
|
|
43
39
|
const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
|
|
44
40
|
const handlePromptButtonClick = useCallback((suggestion) => {
|
|
45
41
|
onSuggestionClicked(suggestion, ChatElementDisplayLocationV3.CHAT_PREVIEW_PROMPT_BUTTON);
|
|
46
42
|
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_PROMPT_BUTTON);
|
|
43
|
+
onPromptClicked(suggestion.id);
|
|
47
44
|
}, [onSuggestionClicked, openChat]);
|
|
48
45
|
const handleTextFieldClick = useCallback(() => {
|
|
49
46
|
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_TEXT_FIELD);
|
|
47
|
+
trackWidgetInteraction({
|
|
48
|
+
eventName: EnviveMetricsEventName.WidgetInteraction,
|
|
49
|
+
trigger: {
|
|
50
|
+
widget: WidgetInteractionComponent.CHAT_PREVIEW,
|
|
51
|
+
widget_interaction: WidgetInteractionType.QUERY_INPUT_CLICKED
|
|
52
|
+
}
|
|
53
|
+
});
|
|
50
54
|
}, [openChat]);
|
|
55
|
+
const handleLinkClick = (url) => {
|
|
56
|
+
trackWidgetInteraction({
|
|
57
|
+
eventName: EnviveMetricsEventName.WidgetInteraction,
|
|
58
|
+
trigger: {
|
|
59
|
+
widget: WidgetInteractionComponent.CHAT_PREVIEW,
|
|
60
|
+
widget_interaction: WidgetInteractionType.LINK_CLICKED,
|
|
61
|
+
widget_interaction_data: { link_clicked: { url } }
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
};
|
|
51
65
|
if (isLoading) return /* @__PURE__ */ jsx(ChatPreviewLoadingWidgetWithBaseWidget, {
|
|
52
66
|
widgetConfigId,
|
|
53
67
|
widgetType: WidgetTypeV3.ChatPreviewLoadingV3
|
|
@@ -72,6 +86,13 @@ const ChatPreviewWidgetHandler = (props) => {
|
|
|
72
86
|
widgetContentProps,
|
|
73
87
|
widgetEventProps: {
|
|
74
88
|
handlePromptButtonClick,
|
|
89
|
+
handlePromptButtonDrag: onDrag,
|
|
90
|
+
handlePromptButtonHover: onHover,
|
|
91
|
+
handlePromptButtonMouseDown: onMouseDown,
|
|
92
|
+
handlePromptButtonMouseUp: onMouseUp,
|
|
93
|
+
handlePromptButtonTouchStart: onTouchStart,
|
|
94
|
+
handlePromptButtonTouchEnd: onTouchEnd,
|
|
95
|
+
handleLinkClick,
|
|
75
96
|
handleTextFieldClick
|
|
76
97
|
}
|
|
77
98
|
});
|
|
@@ -2,28 +2,60 @@ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
|
2
2
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
3
3
|
let classnames = require("classnames");
|
|
4
4
|
classnames = require_rolldown_runtime.__toESM(classnames);
|
|
5
|
-
let react_dom = require("react-dom");
|
|
6
5
|
let framer_motion = require("framer-motion");
|
|
6
|
+
let __envive_ai_react_toolkit_v3_utils_useCheckIsMobile = require("@envive-ai/react-toolkit-v3/utils/useCheckIsMobile");
|
|
7
7
|
|
|
8
8
|
//#region src/widgets/FloatingChatWidget/FloatingChatOverlay.tsx
|
|
9
|
-
const
|
|
9
|
+
const ANIMATION_DURATION = .3;
|
|
10
|
+
const useOverlayAnimations = ({ previewMode, isMobile }) => {
|
|
11
|
+
if (previewMode) return {
|
|
12
|
+
overlayExitAnimation: {
|
|
13
|
+
opacity: 0,
|
|
14
|
+
x: 0
|
|
15
|
+
},
|
|
16
|
+
overlayAnimation: {
|
|
17
|
+
opacity: 1,
|
|
18
|
+
x: 0
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
if (isMobile) return {
|
|
22
|
+
overlayExitAnimation: { opacity: 0 },
|
|
23
|
+
overlayAnimation: { opacity: 1 }
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
overlayExitAnimation: {
|
|
27
|
+
opacity: 0,
|
|
28
|
+
x: 512
|
|
29
|
+
},
|
|
30
|
+
overlayAnimation: {
|
|
31
|
+
opacity: 1,
|
|
32
|
+
x: 0
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestId, previewMode = false, isResultsModalOpen = false }) => {
|
|
37
|
+
const { isMobile } = (0, __envive_ai_react_toolkit_v3_utils_useCheckIsMobile.useCheckIsMobile)();
|
|
38
|
+
const { overlayExitAnimation, overlayAnimation } = useOverlayAnimations({
|
|
39
|
+
previewMode,
|
|
40
|
+
isMobile
|
|
41
|
+
});
|
|
10
42
|
const overlayClasses = (0, classnames.default)(previewMode ? "envive-tw-absolute" : "envive-tw-fixed", "envive-tw-top-0", "envive-tw-left-0", previewMode ? "envive-tw-h-full" : "envive-tw-h-screen", "envive-tw-w-full", "envive-tw-z-[2147483647]", className);
|
|
11
|
-
const backdropClasses = (0, classnames.default)("envive-tw-absolute", "envive-tw-top-0", "envive-tw-left-0", "envive-tw-h-full", "envive-tw-w-full", "envive-tw-bg-black", "envive-tw-opacity-50", "envive-tw-pointer-events-none", "envive-tw-z-0");
|
|
43
|
+
const backdropClasses = (0, classnames.default)("envive-tw-absolute", "envive-tw-top-0", "envive-tw-left-0", "envive-tw-h-full", "envive-tw-w-full", isMobile ? "envive-tw-bg-black" : "", "envive-tw-opacity-50", "envive-tw-pointer-events-none", "envive-tw-z-0");
|
|
12
44
|
const overlayContentClasses = (0, classnames.default)("envive-tw-relative", "envive-tw-flex", "envive-tw-justify-end", "envive-tw-items-stretch", "envive-tw-h-full", "envive-tw-w-full", "envive-tw-pointer-events-auto", "envive-tw-cursor-pointer", "envive-tw-z-10");
|
|
13
|
-
|
|
45
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(framer_motion.AnimatePresence, { children: isOpened && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(framer_motion.motion.div, {
|
|
14
46
|
className: overlayClasses,
|
|
15
47
|
style: { top: "0px" },
|
|
16
48
|
initial: { opacity: 0 },
|
|
17
49
|
animate: { opacity: 1 },
|
|
18
50
|
exit: { opacity: 0 },
|
|
19
|
-
transition: { duration:
|
|
51
|
+
transition: { duration: ANIMATION_DURATION },
|
|
20
52
|
"data-testid": dataTestId,
|
|
21
53
|
children: [!previewMode && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(framer_motion.motion.div, {
|
|
22
54
|
className: backdropClasses,
|
|
23
55
|
initial: { opacity: 0 },
|
|
24
56
|
animate: { opacity: .5 },
|
|
25
57
|
exit: { opacity: 0 },
|
|
26
|
-
transition: { duration:
|
|
58
|
+
transition: { duration: ANIMATION_DURATION },
|
|
27
59
|
"aria-label": "Close chat"
|
|
28
60
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
29
61
|
className: overlayContentClasses,
|
|
@@ -36,22 +68,14 @@ const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestI
|
|
|
36
68
|
tabIndex: 0,
|
|
37
69
|
"aria-label": "Close floating chat",
|
|
38
70
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(framer_motion.motion.div, {
|
|
39
|
-
initial:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
animate: {
|
|
44
|
-
opacity: 1,
|
|
45
|
-
x: 0
|
|
46
|
-
},
|
|
47
|
-
exit: {
|
|
48
|
-
opacity: 0,
|
|
49
|
-
x: previewMode ? 0 : 512
|
|
50
|
-
},
|
|
51
|
-
transition: { duration: .3 },
|
|
71
|
+
initial: overlayExitAnimation,
|
|
72
|
+
animate: overlayAnimation,
|
|
73
|
+
exit: overlayExitAnimation,
|
|
74
|
+
transition: { duration: ANIMATION_DURATION },
|
|
52
75
|
style: {
|
|
53
76
|
height: previewMode ? "100%" : "100dvh",
|
|
54
|
-
cursor: "default"
|
|
77
|
+
cursor: "default",
|
|
78
|
+
margin: isResultsModalOpen ? "0 auto" : "0"
|
|
55
79
|
},
|
|
56
80
|
className: "envive-tw-shadow-md",
|
|
57
81
|
onClick: (e) => e.stopPropagation(),
|
|
@@ -59,9 +83,6 @@ const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestI
|
|
|
59
83
|
})
|
|
60
84
|
})]
|
|
61
85
|
}, "floating-chat-overlay") });
|
|
62
|
-
if (previewMode) return chatWrapper;
|
|
63
|
-
if (typeof document !== "undefined") return (0, react_dom.createPortal)(chatWrapper, document.body);
|
|
64
|
-
return chatWrapper;
|
|
65
86
|
};
|
|
66
87
|
FloatingChatOverlay.displayName = "FloatingChatOverlay";
|
|
67
88
|
|
|
@@ -1,27 +1,59 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import classNames from "classnames";
|
|
3
|
-
import { createPortal } from "react-dom";
|
|
4
3
|
import { AnimatePresence, motion } from "framer-motion";
|
|
4
|
+
import { useCheckIsMobile } from "@envive-ai/react-toolkit-v3/utils/useCheckIsMobile";
|
|
5
5
|
|
|
6
6
|
//#region src/widgets/FloatingChatWidget/FloatingChatOverlay.tsx
|
|
7
|
-
const
|
|
7
|
+
const ANIMATION_DURATION = .3;
|
|
8
|
+
const useOverlayAnimations = ({ previewMode, isMobile }) => {
|
|
9
|
+
if (previewMode) return {
|
|
10
|
+
overlayExitAnimation: {
|
|
11
|
+
opacity: 0,
|
|
12
|
+
x: 0
|
|
13
|
+
},
|
|
14
|
+
overlayAnimation: {
|
|
15
|
+
opacity: 1,
|
|
16
|
+
x: 0
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
if (isMobile) return {
|
|
20
|
+
overlayExitAnimation: { opacity: 0 },
|
|
21
|
+
overlayAnimation: { opacity: 1 }
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
overlayExitAnimation: {
|
|
25
|
+
opacity: 0,
|
|
26
|
+
x: 512
|
|
27
|
+
},
|
|
28
|
+
overlayAnimation: {
|
|
29
|
+
opacity: 1,
|
|
30
|
+
x: 0
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestId, previewMode = false, isResultsModalOpen = false }) => {
|
|
35
|
+
const { isMobile } = useCheckIsMobile();
|
|
36
|
+
const { overlayExitAnimation, overlayAnimation } = useOverlayAnimations({
|
|
37
|
+
previewMode,
|
|
38
|
+
isMobile
|
|
39
|
+
});
|
|
8
40
|
const overlayClasses = classNames(previewMode ? "envive-tw-absolute" : "envive-tw-fixed", "envive-tw-top-0", "envive-tw-left-0", previewMode ? "envive-tw-h-full" : "envive-tw-h-screen", "envive-tw-w-full", "envive-tw-z-[2147483647]", className);
|
|
9
|
-
const backdropClasses = classNames("envive-tw-absolute", "envive-tw-top-0", "envive-tw-left-0", "envive-tw-h-full", "envive-tw-w-full", "envive-tw-bg-black", "envive-tw-opacity-50", "envive-tw-pointer-events-none", "envive-tw-z-0");
|
|
41
|
+
const backdropClasses = classNames("envive-tw-absolute", "envive-tw-top-0", "envive-tw-left-0", "envive-tw-h-full", "envive-tw-w-full", isMobile ? "envive-tw-bg-black" : "", "envive-tw-opacity-50", "envive-tw-pointer-events-none", "envive-tw-z-0");
|
|
10
42
|
const overlayContentClasses = classNames("envive-tw-relative", "envive-tw-flex", "envive-tw-justify-end", "envive-tw-items-stretch", "envive-tw-h-full", "envive-tw-w-full", "envive-tw-pointer-events-auto", "envive-tw-cursor-pointer", "envive-tw-z-10");
|
|
11
|
-
|
|
43
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { children: isOpened && /* @__PURE__ */ jsxs(motion.div, {
|
|
12
44
|
className: overlayClasses,
|
|
13
45
|
style: { top: "0px" },
|
|
14
46
|
initial: { opacity: 0 },
|
|
15
47
|
animate: { opacity: 1 },
|
|
16
48
|
exit: { opacity: 0 },
|
|
17
|
-
transition: { duration:
|
|
49
|
+
transition: { duration: ANIMATION_DURATION },
|
|
18
50
|
"data-testid": dataTestId,
|
|
19
51
|
children: [!previewMode && /* @__PURE__ */ jsx(motion.div, {
|
|
20
52
|
className: backdropClasses,
|
|
21
53
|
initial: { opacity: 0 },
|
|
22
54
|
animate: { opacity: .5 },
|
|
23
55
|
exit: { opacity: 0 },
|
|
24
|
-
transition: { duration:
|
|
56
|
+
transition: { duration: ANIMATION_DURATION },
|
|
25
57
|
"aria-label": "Close chat"
|
|
26
58
|
}), /* @__PURE__ */ jsx("div", {
|
|
27
59
|
className: overlayContentClasses,
|
|
@@ -34,22 +66,14 @@ const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestI
|
|
|
34
66
|
tabIndex: 0,
|
|
35
67
|
"aria-label": "Close floating chat",
|
|
36
68
|
children: /* @__PURE__ */ jsx(motion.div, {
|
|
37
|
-
initial:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
animate: {
|
|
42
|
-
opacity: 1,
|
|
43
|
-
x: 0
|
|
44
|
-
},
|
|
45
|
-
exit: {
|
|
46
|
-
opacity: 0,
|
|
47
|
-
x: previewMode ? 0 : 512
|
|
48
|
-
},
|
|
49
|
-
transition: { duration: .3 },
|
|
69
|
+
initial: overlayExitAnimation,
|
|
70
|
+
animate: overlayAnimation,
|
|
71
|
+
exit: overlayExitAnimation,
|
|
72
|
+
transition: { duration: ANIMATION_DURATION },
|
|
50
73
|
style: {
|
|
51
74
|
height: previewMode ? "100%" : "100dvh",
|
|
52
|
-
cursor: "default"
|
|
75
|
+
cursor: "default",
|
|
76
|
+
margin: isResultsModalOpen ? "0 auto" : "0"
|
|
53
77
|
},
|
|
54
78
|
className: "envive-tw-shadow-md",
|
|
55
79
|
onClick: (e) => e.stopPropagation(),
|
|
@@ -57,9 +81,6 @@ const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestI
|
|
|
57
81
|
})
|
|
58
82
|
})]
|
|
59
83
|
}, "floating-chat-overlay") });
|
|
60
|
-
if (previewMode) return chatWrapper;
|
|
61
|
-
if (typeof document !== "undefined") return createPortal(chatWrapper, document.body);
|
|
62
|
-
return chatWrapper;
|
|
63
84
|
};
|
|
64
85
|
FloatingChatOverlay.displayName = "FloatingChatOverlay";
|
|
65
86
|
|