@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
|
@@ -1,31 +1,52 @@
|
|
|
1
|
+
import { chatAtom, lastAssistantMessageAtom } from '@envive-ai/react-hooks/atoms/chat';
|
|
2
|
+
import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
1
3
|
import {
|
|
2
4
|
ChatPreviewComparisonWidgetV3Config,
|
|
3
5
|
WidgetTypeV3,
|
|
4
6
|
} from '@envive-ai/react-hooks/contexts/typesV3';
|
|
5
|
-
import { useAtomValue } from 'jotai';
|
|
6
|
-
import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
7
7
|
import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
|
|
8
|
-
import {
|
|
8
|
+
import { useAtomValue } from 'jotai';
|
|
9
9
|
|
|
10
|
-
import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
|
|
11
|
-
import { useCallback, useMemo } from 'react';
|
|
12
10
|
import {
|
|
13
11
|
ChatElementDisplayLocationV3,
|
|
14
12
|
Suggestion,
|
|
15
13
|
VariantTypeEnum,
|
|
16
14
|
} from '@envive-ai/react-hooks/application/models';
|
|
15
|
+
import { variantInfoAtom } from '@envive-ai/react-hooks/atoms/app';
|
|
16
|
+
import { EnviveMetricsEventName } from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
17
|
+
import { useWidgetInteraction } from '@envive-ai/react-hooks/hooks/WidgetInteraction';
|
|
18
|
+
import {
|
|
19
|
+
WidgetInteractionComponent,
|
|
20
|
+
WidgetInteractionType,
|
|
21
|
+
} from '@envive-ai/react-hooks/hooks/WidgetInteraction/types';
|
|
17
22
|
import { ChatPreviewComparison } from '@envive-ai/react-toolkit-v3/ChatPreviewComparison';
|
|
18
23
|
import { ChatPreviewComparisonProps } from '@envive-ai/react-toolkit-v3/ChatPreviewComparison/types/types';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
24
|
+
import { usePromptCarouselAnalytics } from '@envive-ai/react-toolkit-v3/PromptCarousel';
|
|
25
|
+
import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
|
|
26
|
+
import { useCallback, useMemo } from 'react';
|
|
21
27
|
import { BaseWidgetProps } from '../../hocs/withBaseWidget/types';
|
|
22
|
-
import {
|
|
28
|
+
import { withBaseWidget } from '../../hocs/withBaseWidget/withBaseWidget';
|
|
23
29
|
import { ChatPreviewLoadingWidgetWithBaseWidget } from '../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget';
|
|
30
|
+
import { getMessageText, getRecentProductImageUrls } from '../utils/functions';
|
|
24
31
|
|
|
25
32
|
const ChatPreviewComparisonWidgetHandler = (props: BaseWidgetProps) => {
|
|
26
33
|
const { onSuggestionClicked } = useSalesAgent();
|
|
27
34
|
const { openChat } = useChatToggle();
|
|
28
35
|
|
|
36
|
+
const { trackWidgetInteraction } = useWidgetInteraction();
|
|
37
|
+
const {
|
|
38
|
+
onClick: onPromptClicked,
|
|
39
|
+
onDrag,
|
|
40
|
+
onHover,
|
|
41
|
+
onMouseDown,
|
|
42
|
+
onMouseUp,
|
|
43
|
+
onTouchStart,
|
|
44
|
+
onTouchEnd,
|
|
45
|
+
} = usePromptCarouselAnalytics(
|
|
46
|
+
WidgetInteractionComponent.POST_INTERACTION_COMPARISON,
|
|
47
|
+
text => text,
|
|
48
|
+
);
|
|
49
|
+
|
|
29
50
|
const lastAssistantMessage = useAtomValue(lastAssistantMessageAtom);
|
|
30
51
|
|
|
31
52
|
const variantInfo = useAtomValue(variantInfoAtom);
|
|
@@ -75,14 +96,37 @@ const ChatPreviewComparisonWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
75
96
|
ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_PROMPT_BUTTON,
|
|
76
97
|
);
|
|
77
98
|
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_PROMPT_BUTTON);
|
|
99
|
+
onPromptClicked(suggestion.id);
|
|
78
100
|
},
|
|
79
101
|
[onSuggestionClicked, openChat],
|
|
80
102
|
);
|
|
81
103
|
|
|
82
104
|
const handleTextFieldClick = useCallback(() => {
|
|
83
105
|
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_TEXT_FIELD);
|
|
106
|
+
trackWidgetInteraction({
|
|
107
|
+
eventName: EnviveMetricsEventName.WidgetInteraction,
|
|
108
|
+
trigger: {
|
|
109
|
+
widget: WidgetInteractionComponent.POST_INTERACTION_COMPARISON,
|
|
110
|
+
widget_interaction: WidgetInteractionType.QUERY_INPUT_CLICKED,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
84
113
|
}, [openChat]);
|
|
85
114
|
|
|
115
|
+
const handleLinkClick = (url: string) => {
|
|
116
|
+
trackWidgetInteraction({
|
|
117
|
+
eventName: EnviveMetricsEventName.WidgetInteraction,
|
|
118
|
+
trigger: {
|
|
119
|
+
widget: WidgetInteractionComponent.POST_INTERACTION_COMPARISON,
|
|
120
|
+
widget_interaction: WidgetInteractionType.LINK_CLICKED,
|
|
121
|
+
widget_interaction_data: {
|
|
122
|
+
link_clicked: {
|
|
123
|
+
url,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
|
|
86
130
|
if (isLoading) {
|
|
87
131
|
return (
|
|
88
132
|
<ChatPreviewLoadingWidgetWithBaseWidget
|
|
@@ -116,6 +160,13 @@ const ChatPreviewComparisonWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
116
160
|
|
|
117
161
|
const widgetEventProps: ChatPreviewComparisonProps['widgetEventProps'] = {
|
|
118
162
|
handlePromptButtonClick,
|
|
163
|
+
handlePromptButtonDrag: onDrag,
|
|
164
|
+
handlePromptButtonHover: onHover,
|
|
165
|
+
handlePromptButtonMouseDown: onMouseDown,
|
|
166
|
+
handlePromptButtonMouseUp: onMouseUp,
|
|
167
|
+
handlePromptButtonTouchStart: onTouchStart,
|
|
168
|
+
handlePromptButtonTouchEnd: onTouchEnd,
|
|
169
|
+
handleLinkClick,
|
|
119
170
|
handleTextFieldClick,
|
|
120
171
|
};
|
|
121
172
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useAtomValue } from 'jotai';
|
|
1
|
+
import { chatAtom, lastAssistantMessageAtom } from '@envive-ai/react-hooks/atoms/chat';
|
|
3
2
|
import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
3
|
+
import { ChatPreviewWidgetV3Config, WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
4
4
|
import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
|
|
5
|
-
import {
|
|
5
|
+
import { useAtomValue } from 'jotai';
|
|
6
6
|
|
|
7
7
|
import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
|
|
8
8
|
|
|
@@ -10,17 +10,23 @@ import {
|
|
|
10
10
|
ChatElementDisplayLocationV3,
|
|
11
11
|
Suggestion,
|
|
12
12
|
} from '@envive-ai/react-hooks/application/models';
|
|
13
|
-
import { useCallback, useEffect, useMemo } from 'react';
|
|
14
13
|
import {
|
|
15
|
-
|
|
14
|
+
EnviveMetricsEventName,
|
|
16
15
|
useAmplitude,
|
|
17
16
|
} from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
18
|
-
import {
|
|
17
|
+
import { useWidgetInteraction } from '@envive-ai/react-hooks/hooks/WidgetInteraction';
|
|
18
|
+
import {
|
|
19
|
+
WidgetInteractionComponent,
|
|
20
|
+
WidgetInteractionType,
|
|
21
|
+
} from '@envive-ai/react-hooks/hooks/WidgetInteraction/types';
|
|
19
22
|
import { ChatPreview } from '@envive-ai/react-toolkit-v3/ChatPreview';
|
|
20
|
-
import {
|
|
23
|
+
import { ChatPreviewProps } from '@envive-ai/react-toolkit-v3/ChatPreview/types/types';
|
|
24
|
+
import { usePromptCarouselAnalytics } from '@envive-ai/react-toolkit-v3/PromptCarousel';
|
|
25
|
+
import { useCallback, useMemo } from 'react';
|
|
21
26
|
import { BaseWidgetProps } from '../../hocs/withBaseWidget/types';
|
|
22
|
-
import {
|
|
27
|
+
import { withBaseWidget } from '../../hocs/withBaseWidget/withBaseWidget';
|
|
23
28
|
import { ChatPreviewLoadingWidgetWithBaseWidget } from '../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget';
|
|
29
|
+
import { getMessageText } from '../utils/functions';
|
|
24
30
|
|
|
25
31
|
const ChatPreviewWidgetHandler = (props: BaseWidgetProps) => {
|
|
26
32
|
const { onSuggestionClicked } = useSalesAgent();
|
|
@@ -49,16 +55,16 @@ const ChatPreviewWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
49
55
|
>;
|
|
50
56
|
|
|
51
57
|
const { trackEvent } = useAmplitude();
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
58
|
+
const { trackWidgetInteraction } = useWidgetInteraction();
|
|
59
|
+
const {
|
|
60
|
+
onClick: onPromptClicked,
|
|
61
|
+
onDrag,
|
|
62
|
+
onHover,
|
|
63
|
+
onMouseDown,
|
|
64
|
+
onMouseUp,
|
|
65
|
+
onTouchStart,
|
|
66
|
+
onTouchEnd,
|
|
67
|
+
} = usePromptCarouselAnalytics(WidgetInteractionComponent.CHAT_PREVIEW, text => text);
|
|
62
68
|
|
|
63
69
|
const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc;
|
|
64
70
|
|
|
@@ -68,14 +74,37 @@ const ChatPreviewWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
68
74
|
(suggestion: Suggestion) => {
|
|
69
75
|
onSuggestionClicked(suggestion, ChatElementDisplayLocationV3.CHAT_PREVIEW_PROMPT_BUTTON);
|
|
70
76
|
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_PROMPT_BUTTON);
|
|
77
|
+
onPromptClicked(suggestion.id);
|
|
71
78
|
},
|
|
72
79
|
[onSuggestionClicked, openChat],
|
|
73
80
|
);
|
|
74
81
|
|
|
75
82
|
const handleTextFieldClick = useCallback(() => {
|
|
76
83
|
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_TEXT_FIELD);
|
|
84
|
+
trackWidgetInteraction({
|
|
85
|
+
eventName: EnviveMetricsEventName.WidgetInteraction,
|
|
86
|
+
trigger: {
|
|
87
|
+
widget: WidgetInteractionComponent.CHAT_PREVIEW,
|
|
88
|
+
widget_interaction: WidgetInteractionType.QUERY_INPUT_CLICKED,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
77
91
|
}, [openChat]);
|
|
78
92
|
|
|
93
|
+
const handleLinkClick = (url: string) => {
|
|
94
|
+
trackWidgetInteraction({
|
|
95
|
+
eventName: EnviveMetricsEventName.WidgetInteraction,
|
|
96
|
+
trigger: {
|
|
97
|
+
widget: WidgetInteractionComponent.CHAT_PREVIEW,
|
|
98
|
+
widget_interaction: WidgetInteractionType.LINK_CLICKED,
|
|
99
|
+
widget_interaction_data: {
|
|
100
|
+
link_clicked: {
|
|
101
|
+
url,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
|
|
79
108
|
if (isLoading) {
|
|
80
109
|
return (
|
|
81
110
|
<ChatPreviewLoadingWidgetWithBaseWidget
|
|
@@ -103,6 +132,13 @@ const ChatPreviewWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
103
132
|
|
|
104
133
|
const widgetEventProps: ChatPreviewProps['widgetEventProps'] = {
|
|
105
134
|
handlePromptButtonClick,
|
|
135
|
+
handlePromptButtonDrag: onDrag,
|
|
136
|
+
handlePromptButtonHover: onHover,
|
|
137
|
+
handlePromptButtonMouseDown: onMouseDown,
|
|
138
|
+
handlePromptButtonMouseUp: onMouseUp,
|
|
139
|
+
handlePromptButtonTouchStart: onTouchStart,
|
|
140
|
+
handlePromptButtonTouchEnd: onTouchEnd,
|
|
141
|
+
handleLinkClick,
|
|
106
142
|
handleTextFieldClick,
|
|
107
143
|
};
|
|
108
144
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { render, waitFor } from '@testing-library/react';
|
|
2
|
-
import { SpiffyMetricsEventName } from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
3
2
|
import { WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
4
3
|
import { UserEvent, UserEventCategory } from '@spiffy-ai/commerce-api-client';
|
|
5
4
|
import { ChatPreviewWidget } from '../ChatPreviewWidget';
|
|
6
5
|
|
|
7
6
|
const mockTrackEvent = vi.fn();
|
|
8
7
|
const mockGetHardcopy = vi.fn();
|
|
8
|
+
const mockUseTrackComponentVisibleEvent = vi.fn();
|
|
9
9
|
|
|
10
10
|
vi.mock('@envive-ai/react-toolkit-v3/ChatPreview', () => ({
|
|
11
11
|
ChatPreview: () => <div data-testid="chat-preview-mock">Chat Preview</div>,
|
|
@@ -22,6 +22,10 @@ vi.mock('@envive-ai/react-hooks/contexts/amplitudeContext', () => ({
|
|
|
22
22
|
},
|
|
23
23
|
}));
|
|
24
24
|
|
|
25
|
+
vi.mock('@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent', () => ({
|
|
26
|
+
useTrackComponentVisibleEvent: (...args: unknown[]) => mockUseTrackComponentVisibleEvent(...args),
|
|
27
|
+
}));
|
|
28
|
+
|
|
25
29
|
vi.mock('@envive-ai/react-hooks/contexts/hardcopyContext', () => ({
|
|
26
30
|
useHardcopy: () => ({
|
|
27
31
|
getHardcopy: mockGetHardcopy,
|
|
@@ -100,13 +104,15 @@ describe('ChatPreviewWidget analytics', () => {
|
|
|
100
104
|
|
|
101
105
|
await waitFor(
|
|
102
106
|
() => {
|
|
103
|
-
expect(
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
expect(mockUseTrackComponentVisibleEvent).toHaveBeenCalledWith(
|
|
108
|
+
expect.any(Object),
|
|
109
|
+
{
|
|
106
110
|
widget_config_id: 'test-config-1',
|
|
107
111
|
widget_type: WidgetTypeV3.ChatPreviewV3,
|
|
108
112
|
},
|
|
109
|
-
|
|
113
|
+
'0px',
|
|
114
|
+
true,
|
|
115
|
+
);
|
|
110
116
|
},
|
|
111
117
|
{ timeout: 3000 },
|
|
112
118
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { createPortal } from 'react-dom';
|
|
3
2
|
import { AnimatePresence, motion } from 'framer-motion';
|
|
4
3
|
import classNames from 'classnames';
|
|
4
|
+
import { useCheckIsMobile } from '@envive-ai/react-toolkit-v3/utils/useCheckIsMobile';
|
|
5
5
|
|
|
6
6
|
export interface FloatingChatOverlayProps {
|
|
7
7
|
children?: ReactNode;
|
|
@@ -10,8 +10,36 @@ export interface FloatingChatOverlayProps {
|
|
|
10
10
|
className?: string;
|
|
11
11
|
dataTestId?: string;
|
|
12
12
|
previewMode?: boolean;
|
|
13
|
+
isResultsModalOpen?: boolean;
|
|
13
14
|
}
|
|
14
15
|
|
|
16
|
+
const ANIMATION_DURATION = 0.3;
|
|
17
|
+
|
|
18
|
+
const useOverlayAnimations = ({
|
|
19
|
+
previewMode,
|
|
20
|
+
isMobile,
|
|
21
|
+
}: {
|
|
22
|
+
previewMode: boolean;
|
|
23
|
+
isMobile: boolean;
|
|
24
|
+
}) => {
|
|
25
|
+
if (previewMode) {
|
|
26
|
+
return {
|
|
27
|
+
overlayExitAnimation: { opacity: 0, x: 0 },
|
|
28
|
+
overlayAnimation: { opacity: 1, x: 0 },
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if (isMobile) {
|
|
32
|
+
return {
|
|
33
|
+
overlayExitAnimation: { opacity: 0 },
|
|
34
|
+
overlayAnimation: { opacity: 1 },
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
overlayExitAnimation: { opacity: 0, x: 512 },
|
|
39
|
+
overlayAnimation: { opacity: 1, x: 0 },
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
15
43
|
export const FloatingChatOverlay = ({
|
|
16
44
|
children,
|
|
17
45
|
isOpened,
|
|
@@ -19,7 +47,14 @@ export const FloatingChatOverlay = ({
|
|
|
19
47
|
className,
|
|
20
48
|
dataTestId,
|
|
21
49
|
previewMode = false,
|
|
50
|
+
isResultsModalOpen = false,
|
|
22
51
|
}: FloatingChatOverlayProps) => {
|
|
52
|
+
const { isMobile } = useCheckIsMobile();
|
|
53
|
+
const { overlayExitAnimation, overlayAnimation } = useOverlayAnimations({
|
|
54
|
+
previewMode,
|
|
55
|
+
isMobile,
|
|
56
|
+
});
|
|
57
|
+
|
|
23
58
|
const overlayClasses = classNames(
|
|
24
59
|
previewMode ? 'envive-tw-absolute' : 'envive-tw-fixed',
|
|
25
60
|
'envive-tw-top-0',
|
|
@@ -36,7 +71,7 @@ export const FloatingChatOverlay = ({
|
|
|
36
71
|
'envive-tw-left-0',
|
|
37
72
|
'envive-tw-h-full',
|
|
38
73
|
'envive-tw-w-full',
|
|
39
|
-
'envive-tw-bg-black',
|
|
74
|
+
isMobile ? 'envive-tw-bg-black' : '',
|
|
40
75
|
'envive-tw-opacity-50',
|
|
41
76
|
'envive-tw-pointer-events-none',
|
|
42
77
|
'envive-tw-z-0',
|
|
@@ -64,7 +99,7 @@ export const FloatingChatOverlay = ({
|
|
|
64
99
|
initial={{ opacity: 0 }}
|
|
65
100
|
animate={{ opacity: 1 }}
|
|
66
101
|
exit={{ opacity: 0 }}
|
|
67
|
-
transition={{ duration:
|
|
102
|
+
transition={{ duration: ANIMATION_DURATION }}
|
|
68
103
|
data-testid={dataTestId}
|
|
69
104
|
>
|
|
70
105
|
{!previewMode && (
|
|
@@ -73,7 +108,7 @@ export const FloatingChatOverlay = ({
|
|
|
73
108
|
initial={{ opacity: 0 }}
|
|
74
109
|
animate={{ opacity: 0.5 }}
|
|
75
110
|
exit={{ opacity: 0 }}
|
|
76
|
-
transition={{ duration:
|
|
111
|
+
transition={{ duration: ANIMATION_DURATION }}
|
|
77
112
|
aria-label="Close chat"
|
|
78
113
|
/>
|
|
79
114
|
)}
|
|
@@ -91,11 +126,15 @@ export const FloatingChatOverlay = ({
|
|
|
91
126
|
aria-label="Close floating chat"
|
|
92
127
|
>
|
|
93
128
|
<motion.div
|
|
94
|
-
initial={
|
|
95
|
-
animate={
|
|
96
|
-
exit={
|
|
97
|
-
transition={{ duration:
|
|
98
|
-
style={{
|
|
129
|
+
initial={overlayExitAnimation}
|
|
130
|
+
animate={overlayAnimation}
|
|
131
|
+
exit={overlayExitAnimation}
|
|
132
|
+
transition={{ duration: ANIMATION_DURATION }}
|
|
133
|
+
style={{
|
|
134
|
+
height: previewMode ? '100%' : '100dvh',
|
|
135
|
+
cursor: 'default',
|
|
136
|
+
margin: isResultsModalOpen ? '0 auto' : '0',
|
|
137
|
+
}}
|
|
99
138
|
className="envive-tw-shadow-md"
|
|
100
139
|
onClick={e => e.stopPropagation()}
|
|
101
140
|
>
|
|
@@ -107,16 +146,6 @@ export const FloatingChatOverlay = ({
|
|
|
107
146
|
</AnimatePresence>
|
|
108
147
|
);
|
|
109
148
|
|
|
110
|
-
// In preview mode, render inline. Otherwise use portal to body
|
|
111
|
-
if (previewMode) {
|
|
112
|
-
return chatWrapper;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Render using portal to body to ensure it's on top of everything
|
|
116
|
-
if (typeof document !== 'undefined') {
|
|
117
|
-
return createPortal(chatWrapper, document.body);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
149
|
return chatWrapper;
|
|
121
150
|
};
|
|
122
151
|
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ChatElementDisplayLocationV3 } from '@envive-ai/react-hooks/application/models';
|
|
2
|
+
import {
|
|
3
|
+
EnviveMetricsEventName,
|
|
4
|
+
useAmplitude,
|
|
5
|
+
} from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
6
|
+
import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
2
7
|
import {
|
|
3
8
|
FloatingChatConfig,
|
|
4
9
|
LookAndFeelConfig,
|
|
5
10
|
WidgetTypeV3,
|
|
6
11
|
} from '@envive-ai/react-hooks/contexts/typesV3';
|
|
12
|
+
import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
|
|
13
|
+
import { useTrackComponentVisibleEvent } from '@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent';
|
|
14
|
+
import { useWidgetInteraction } from '@envive-ai/react-hooks/hooks/WidgetInteraction';
|
|
7
15
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
|
|
16
|
+
Collapse,
|
|
17
|
+
WidgetInteractionComponent,
|
|
18
|
+
WidgetInteractionType,
|
|
19
|
+
} from '@envive-ai/react-hooks/hooks/WidgetInteraction/types';
|
|
13
20
|
import {
|
|
14
21
|
FloatingButton,
|
|
15
22
|
FloatingButtonBackgroundColor,
|
|
@@ -18,15 +25,15 @@ import {
|
|
|
18
25
|
FloatingButtonShow,
|
|
19
26
|
FloatingButtonVariant,
|
|
20
27
|
} from '@envive-ai/react-toolkit-v3/FloatingButton';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
28
|
+
import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
|
|
29
|
+
import { ReactNode, Suspense, lazy, useEffect, useMemo, useRef, useState } from 'react';
|
|
23
30
|
import { DebugBar } from 'src/debug/debugBar';
|
|
31
|
+
import { useUnifiedCXButton } from '../../CXIntegration/hooks/useUnifiedCXButton';
|
|
32
|
+
import { CustomerServiceType } from '../../CXIntegration/types';
|
|
24
33
|
import { BaseWidgetProps, withBaseWidget } from '../../hocs/withBaseWidget';
|
|
25
|
-
import { FloatingChatOverlay } from './FloatingChatOverlay';
|
|
26
34
|
import useGetWidgetStatus from '../hooks/useGetWidgetStatus';
|
|
27
|
-
import { useUnifiedCXButton } from '../../CXIntegration/hooks/useUnifiedCXButton';
|
|
28
35
|
import { FLOATING_BUTTON_ID } from './constants';
|
|
29
|
-
import {
|
|
36
|
+
import { FloatingChatOverlay } from './FloatingChatOverlay';
|
|
30
37
|
import { useFloatingButtonVisibility } from './hooks/useFloatingButtonVisibility';
|
|
31
38
|
import { useAutoPopup } from './hooks/useAutoPopup';
|
|
32
39
|
|
|
@@ -69,12 +76,13 @@ const CXButtonProvider = ({
|
|
|
69
76
|
interface FloatingChatWidgetHandlerProps extends BaseWidgetProps {
|
|
70
77
|
previewButtonOnly?: boolean;
|
|
71
78
|
previewChatAlwaysOpen?: boolean;
|
|
79
|
+
previewCXButtonsEnabled?: boolean;
|
|
72
80
|
}
|
|
73
81
|
|
|
74
82
|
const FloatingChatWidgetHandler = (props: FloatingChatWidgetHandlerProps) => {
|
|
75
|
-
const { previewButtonOnly, previewChatAlwaysOpen } = props;
|
|
83
|
+
const { previewButtonOnly, previewChatAlwaysOpen, previewCXButtonsEnabled } = props;
|
|
76
84
|
const salesAgentData = useSalesAgent();
|
|
77
|
-
|
|
85
|
+
const { trackWidgetInteraction } = useWidgetInteraction();
|
|
78
86
|
const { userHasInteractedValue } = useGetWidgetStatus();
|
|
79
87
|
|
|
80
88
|
// TODO: Get hardcopy
|
|
@@ -86,15 +94,29 @@ const FloatingChatWidgetHandler = (props: FloatingChatWidgetHandlerProps) => {
|
|
|
86
94
|
CustomerServiceType.unsupported;
|
|
87
95
|
|
|
88
96
|
// TODO: Get hardcopy content
|
|
89
|
-
const { isOpen, openChat, closeChat } = useChatToggle();
|
|
97
|
+
const { isOpen, openChat, closeChat, onHover } = useChatToggle();
|
|
90
98
|
|
|
91
99
|
const [isCXOpen, setIsCXOpen] = useState(false);
|
|
100
|
+
const [isResultsModalOpen, setIsResultsModalOpen] = useState(false);
|
|
92
101
|
|
|
93
102
|
// Reset CX open state when the envive widget is reopened
|
|
94
103
|
useEffect(() => {
|
|
95
104
|
if (isOpen) setIsCXOpen(false);
|
|
96
105
|
}, [isOpen]);
|
|
97
106
|
|
|
107
|
+
const handleClose = (type: Collapse) => {
|
|
108
|
+
trackWidgetInteraction({
|
|
109
|
+
eventName: EnviveMetricsEventName.WidgetInteraction,
|
|
110
|
+
trigger: {
|
|
111
|
+
widget: WidgetInteractionComponent.FLOATING_CHAT,
|
|
112
|
+
widget_interaction: WidgetInteractionType.WIDGET_COLLAPSED,
|
|
113
|
+
widget_interaction_data: {
|
|
114
|
+
widget_collapsed: type,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
|
|
98
120
|
const { shouldShowFloatingButton } = useFloatingButtonVisibility({
|
|
99
121
|
floatingButtonShowConfig: floatingButton?.showOption as FloatingButtonShow,
|
|
100
122
|
isChatOpen: isOpen,
|
|
@@ -118,21 +140,17 @@ const FloatingChatWidgetHandler = (props: FloatingChatWidgetHandlerProps) => {
|
|
|
118
140
|
|
|
119
141
|
useAutoPopup({ autoPopupConfig: floatingChat?.autoPopupConfig });
|
|
120
142
|
|
|
121
|
-
const {
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
});
|
|
133
|
-
hasTrackedEvent.current = true;
|
|
134
|
-
}
|
|
135
|
-
}, [trackEvent, buttonShouldRender]);
|
|
143
|
+
const { isReady } = useAmplitude();
|
|
144
|
+
const floatingButtonVisibilityRef = useRef<HTMLDivElement>(null);
|
|
145
|
+
useTrackComponentVisibleEvent(
|
|
146
|
+
floatingButtonVisibilityRef,
|
|
147
|
+
{
|
|
148
|
+
widget_config_id: 'floating-button',
|
|
149
|
+
widget_type: WidgetTypeV3.FloatingButtonV3,
|
|
150
|
+
},
|
|
151
|
+
'0px',
|
|
152
|
+
isReady && buttonShouldRender,
|
|
153
|
+
);
|
|
136
154
|
|
|
137
155
|
return (
|
|
138
156
|
<CXButtonProvider
|
|
@@ -146,31 +164,53 @@ const FloatingChatWidgetHandler = (props: FloatingChatWidgetHandlerProps) => {
|
|
|
146
164
|
{({ isSwitchEnabled, toggle }) => (
|
|
147
165
|
<>
|
|
148
166
|
{/* Render chat when always open preview OR when normally open */}
|
|
149
|
-
{
|
|
167
|
+
{!previewButtonOnly && (
|
|
150
168
|
<FloatingChatOverlay
|
|
151
169
|
isOpened={effectiveIsOpen}
|
|
170
|
+
isResultsModalOpen={isResultsModalOpen}
|
|
152
171
|
onClose={
|
|
153
172
|
previewChatAlwaysOpen
|
|
154
173
|
? () => {}
|
|
155
|
-
: () =>
|
|
174
|
+
: () => {
|
|
175
|
+
closeChat(ChatElementDisplayLocationV3.FLOATING_CHAT_OVERLAY);
|
|
176
|
+
handleClose({
|
|
177
|
+
collapse_source: 'body_click',
|
|
178
|
+
}); 1
|
|
179
|
+
}
|
|
156
180
|
}
|
|
157
181
|
previewMode={!!previewChatAlwaysOpen}
|
|
158
182
|
>
|
|
159
183
|
<Suspense>
|
|
160
184
|
<FloatingChat
|
|
185
|
+
setIsResultsModalOpen={setIsResultsModalOpen}
|
|
161
186
|
theme={theme}
|
|
162
187
|
salesAgentData={salesAgentData}
|
|
163
188
|
hardcopyContent={hardcopyContent}
|
|
164
189
|
floatingChatConfig={uiConfig?.floatingChat ?? ({} as FloatingChatConfig)}
|
|
165
190
|
lookAndFeelConfig={uiConfig?.lookAndFeel ?? ({} as LookAndFeelConfig)}
|
|
166
|
-
isCXButtonSwitchEnabled={!!isSwitchEnabled?.()}
|
|
191
|
+
isCXButtonSwitchEnabled={previewCXButtonsEnabled ? true : !!isSwitchEnabled?.()}
|
|
167
192
|
isFloatingChatOpen={effectiveIsOpen}
|
|
168
193
|
onToggleCXButton={toggle}
|
|
169
194
|
debugBar={<DebugBar />}
|
|
195
|
+
onSwipeClose={
|
|
196
|
+
previewChatAlwaysOpen
|
|
197
|
+
? () => {}
|
|
198
|
+
: () => {
|
|
199
|
+
closeChat(ChatElementDisplayLocationV3.FLOATING_CHAT_CLOSE_BUTTON);
|
|
200
|
+
handleClose({
|
|
201
|
+
collapse_source: 'swipe',
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
170
205
|
onClose={
|
|
171
206
|
previewChatAlwaysOpen
|
|
172
207
|
? () => {}
|
|
173
|
-
: () =>
|
|
208
|
+
: () => {
|
|
209
|
+
closeChat(ChatElementDisplayLocationV3.FLOATING_CHAT_CLOSE_BUTTON);
|
|
210
|
+
handleClose({
|
|
211
|
+
collapse_source: 'close_button',
|
|
212
|
+
});
|
|
213
|
+
}
|
|
174
214
|
}
|
|
175
215
|
/>
|
|
176
216
|
</Suspense>
|
|
@@ -179,23 +219,26 @@ const FloatingChatWidgetHandler = (props: FloatingChatWidgetHandlerProps) => {
|
|
|
179
219
|
|
|
180
220
|
{/* Render button when preview button only OR when chat is closed */}
|
|
181
221
|
{buttonShouldRender && (
|
|
182
|
-
<
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
222
|
+
<div ref={floatingButtonVisibilityRef}>
|
|
223
|
+
<FloatingButton
|
|
224
|
+
id={FLOATING_BUTTON_ID}
|
|
225
|
+
variant={floatingButton?.style as FloatingButtonVariant}
|
|
226
|
+
mode={floatingButton?.mode as FloatingButtonMode}
|
|
227
|
+
backgroundColor={floatingButton?.backgroundColor as FloatingButtonBackgroundColor}
|
|
228
|
+
onClick={
|
|
229
|
+
previewButtonOnly
|
|
230
|
+
? () => {}
|
|
231
|
+
: () => openChat(ChatElementDisplayLocationV3.FLOATING_BUTTON)
|
|
232
|
+
}
|
|
233
|
+
onMouseOver={onHover}
|
|
234
|
+
customIcon={floatingButton?.iconSVGSrc}
|
|
235
|
+
show={floatingButton?.showOption as FloatingButtonShow}
|
|
236
|
+
location={floatingButton?.position as FloatingButtonLocation}
|
|
237
|
+
hasInteractionHappened={userHasInteractedValue}
|
|
238
|
+
ariaLabel="Open chat"
|
|
239
|
+
previewMode={!!previewButtonOnly}
|
|
240
|
+
/>
|
|
241
|
+
</div>
|
|
199
242
|
)}
|
|
200
243
|
</>
|
|
201
244
|
)}
|
|
@@ -203,17 +246,21 @@ const FloatingChatWidgetHandler = (props: FloatingChatWidgetHandlerProps) => {
|
|
|
203
246
|
);
|
|
204
247
|
};
|
|
205
248
|
|
|
206
|
-
const FloatingChatWidgetWithBaseWidget =
|
|
207
|
-
|
|
249
|
+
const FloatingChatWidgetWithBaseWidget = withBaseWidget<FloatingChatWidgetHandlerProps>(
|
|
250
|
+
FloatingChatWidgetHandler,
|
|
251
|
+
{ deferLoading: false },
|
|
252
|
+
);
|
|
208
253
|
|
|
209
254
|
export interface FloatingChatWidgetProps {
|
|
210
255
|
previewButtonOnly?: boolean;
|
|
211
256
|
previewChatAlwaysOpen?: boolean;
|
|
257
|
+
previewCXButtonsEnabled?: boolean;
|
|
212
258
|
}
|
|
213
259
|
|
|
214
260
|
export const FloatingChatWidget = ({
|
|
215
261
|
previewButtonOnly,
|
|
216
262
|
previewChatAlwaysOpen,
|
|
263
|
+
previewCXButtonsEnabled,
|
|
217
264
|
}: FloatingChatWidgetProps = {}) => {
|
|
218
265
|
return (
|
|
219
266
|
<FloatingChatWidgetWithBaseWidget
|
|
@@ -221,6 +268,7 @@ export const FloatingChatWidget = ({
|
|
|
221
268
|
widgetConfigId="fake-widget-config-id"
|
|
222
269
|
previewButtonOnly={previewButtonOnly}
|
|
223
270
|
previewChatAlwaysOpen={previewChatAlwaysOpen}
|
|
271
|
+
previewCXButtonsEnabled={previewCXButtonsEnabled}
|
|
224
272
|
/>
|
|
225
273
|
);
|
|
226
274
|
};
|