@envive-ai/react-widgets-v3 0.3.8 → 0.3.9
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/CXIntegration/hooks/useUnifiedCXButton.cjs +3 -2
- package/dist/CXIntegration/hooks/useUnifiedCXButton.js +4 -3
- package/dist/hocs/withBaseWidget/withBaseWidget.d.cts +2 -2
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs +6 -13
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +6 -13
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.cjs +7 -13
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.js +7 -13
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.cjs +5 -3
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.js +5 -3
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +2 -2
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.cjs +12 -0
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.js +13 -1
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +14 -2
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +16 -4
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +2 -2
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.cjs +1 -1
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.cts +2 -2
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.js +1 -1
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +2 -2
- 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.d.cts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
- package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.cts +2 -2
- package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.ts +2 -2
- package/package.json +1 -1
- package/src/CXIntegration/hooks/useUnifiedCXButton.ts +4 -3
- package/src/stories/SalesAgentTest/SalesAgentTest.tsx +16 -7
- package/src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.tsx +10 -11
- package/src/widgets/ChatPreviewWidget/ChatPreviewWidget.tsx +11 -12
- package/src/widgets/FloatingChatWidget/FloatingChatOverlay.tsx +2 -3
- package/src/widgets/ProductCardWidget/ProductCardWidget.tsx +18 -1
- package/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx +32 -4
- package/src/widgets/PromptCarouselWidget/PromptCarouselWidget.tsx +1 -1
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ProductCardWidgetV3Config, WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
2
2
|
import { PromptButtonVariant } from '@envive-ai/react-toolkit-v3/PromptButton/types';
|
|
3
|
-
import { useCallback } from 'react';
|
|
3
|
+
import { useCallback, useEffect } from 'react';
|
|
4
|
+
import {
|
|
5
|
+
SpiffyMetricsEventName,
|
|
6
|
+
useAmplitude,
|
|
7
|
+
} from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
4
8
|
import { ChatElementDisplayLocationV3 } from '@envive-ai/react-hooks/application/models';
|
|
5
9
|
import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
6
10
|
import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
|
|
@@ -45,6 +49,19 @@ const ProductCardWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
45
49
|
const fallbackColor = productCardWidgetConfig?.fallbackColor;
|
|
46
50
|
const imageSrc = productCardWidgetConfig?.imageSrc || '';
|
|
47
51
|
|
|
52
|
+
const { trackEvent } = useAmplitude();
|
|
53
|
+
|
|
54
|
+
const { widgetConfigId } = props;
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
trackEvent({
|
|
57
|
+
eventName: SpiffyMetricsEventName.ChatComponentVisible,
|
|
58
|
+
eventProps: {
|
|
59
|
+
widget_config_id: widgetConfigId,
|
|
60
|
+
widget_type: WidgetTypeV3.ProductCardV3,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}, [trackEvent, widgetConfigId]);
|
|
64
|
+
|
|
48
65
|
const handleSelect = useCallback(
|
|
49
66
|
(prompt: string) => {
|
|
50
67
|
onTypedMessageSubmitted({ query: prompt, userTyped: false });
|
package/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx
CHANGED
|
@@ -6,18 +6,25 @@ import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext
|
|
|
6
6
|
import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
|
|
7
7
|
|
|
8
8
|
import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
|
|
9
|
-
import { useCallback, useEffect } from 'react';
|
|
9
|
+
import { useCallback, useEffect, useMemo } from 'react';
|
|
10
10
|
import {
|
|
11
11
|
SpiffyMetricsEventName,
|
|
12
12
|
useAmplitude,
|
|
13
13
|
} from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
ChatElementDisplayLocationV3,
|
|
16
|
+
VariantTypeEnum,
|
|
17
|
+
} from '@envive-ai/react-hooks/application/models';
|
|
15
18
|
import {
|
|
16
19
|
PromptButtonCarouselWithImage,
|
|
17
20
|
PromptButtonCarouselWithImageProps,
|
|
18
21
|
} from '@envive-ai/react-toolkit-v3/PromptButtonCarouselWithImage';
|
|
22
|
+
import { lastAssistantMessageAtom } from '@envive-ai/react-hooks/atoms/chat';
|
|
23
|
+
import { useAtomValue } from 'jotai';
|
|
24
|
+
import { variantInfoAtom } from '@envive-ai/react-hooks/atoms/app';
|
|
19
25
|
import { BaseWidgetProps } from '../../hocs/withBaseWidget/types';
|
|
20
26
|
import { withBaseWidget } from '../../hocs/withBaseWidget/withBaseWidget';
|
|
27
|
+
import { getRecentProductImageUrls } from '../utils/functions';
|
|
21
28
|
|
|
22
29
|
const PromptButtonCarouselWithImageWidgetHandler = (props: BaseWidgetProps) => {
|
|
23
30
|
const { onTypedMessageSubmitted } = useSalesAgent();
|
|
@@ -63,6 +70,27 @@ const PromptButtonCarouselWithImageWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
63
70
|
openChat(ChatElementDisplayLocationV3.PROMPT_BUTTON_CAROUSEL_WITH_IMAGE_TEXT_FIELD);
|
|
64
71
|
}, [openChat]);
|
|
65
72
|
|
|
73
|
+
const variantInfo = useAtomValue(variantInfoAtom);
|
|
74
|
+
const productId = variantInfo.variant === VariantTypeEnum.Pdp ? variantInfo.productId : undefined;
|
|
75
|
+
|
|
76
|
+
const lastAssistantMessage = useAtomValue(lastAssistantMessageAtom);
|
|
77
|
+
|
|
78
|
+
const productImageUrls = useMemo(
|
|
79
|
+
() => (lastAssistantMessage ? getRecentProductImageUrls(lastAssistantMessage, productId) : []),
|
|
80
|
+
[lastAssistantMessage, productId],
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const productImageUrl = productImageUrls[1] ?? productImageUrls[0] ?? '';
|
|
84
|
+
|
|
85
|
+
const isDynamic = promptButtonCarouselWithImageWidgetConfig?.isDynamic ?? false;
|
|
86
|
+
|
|
87
|
+
const finalImageSrc = isDynamic
|
|
88
|
+
? productImageUrl
|
|
89
|
+
: promptButtonCarouselWithImageWidgetConfig?.image?.src;
|
|
90
|
+
const finalImageAlt = isDynamic
|
|
91
|
+
? 'Product Image From Page'
|
|
92
|
+
: promptButtonCarouselWithImageWidgetConfig?.image?.alt;
|
|
93
|
+
|
|
66
94
|
return (
|
|
67
95
|
<PromptButtonCarouselWithImage
|
|
68
96
|
id={id}
|
|
@@ -71,8 +99,8 @@ const PromptButtonCarouselWithImageWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
71
99
|
title={hardCopyContent?.title}
|
|
72
100
|
promptButtonsTexts={hardCopyContent?.promptButtonsTexts}
|
|
73
101
|
promptButtonType={promptButtonCarouselWithImageWidgetConfig?.promptButtonType}
|
|
74
|
-
imageSrc={
|
|
75
|
-
alt={
|
|
102
|
+
imageSrc={finalImageSrc}
|
|
103
|
+
alt={finalImageAlt}
|
|
76
104
|
textFieldPlaceholder={hardCopyContent?.textFieldPlaceholder}
|
|
77
105
|
hideTextField={promptButtonCarouselWithImageWidgetConfig?.hideTextField}
|
|
78
106
|
handlePromptButtonClick={handlePromptButtonClick}
|
|
@@ -66,6 +66,7 @@ const PromptCarouselWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
66
66
|
|
|
67
67
|
return (
|
|
68
68
|
<PromptCarousel
|
|
69
|
+
{...props}
|
|
69
70
|
id={id}
|
|
70
71
|
theme={Theme.GLOBAL_CUSTOM}
|
|
71
72
|
isLoading={isLoading}
|
|
@@ -75,7 +76,6 @@ const PromptCarouselWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
75
76
|
animationSpeed={animationSpeed}
|
|
76
77
|
handleButtonClick={handleButtonClick}
|
|
77
78
|
promptButtonTexts={buttonTexts}
|
|
78
|
-
{...props}
|
|
79
79
|
/>
|
|
80
80
|
);
|
|
81
81
|
};
|