@envive-ai/react-widgets-v3 0.3.7 → 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/hocs/withBaseWidget/withBaseWidget.d.ts +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.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.cjs +6 -5
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +2 -2
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +2 -2
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +7 -6
- package/dist/widgets/ProductCardWidget/ProductCardWidget.cjs +90 -0
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +14 -0
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +14 -0
- package/dist/widgets/ProductCardWidget/ProductCardWidget.js +89 -0
- package/dist/widgets/ProductCardWidget/index.cjs +3 -0
- package/dist/widgets/ProductCardWidget/index.d.cts +2 -0
- package/dist/widgets/ProductCardWidget/index.d.ts +2 -0
- package/dist/widgets/ProductCardWidget/index.js +3 -0
- 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.cjs +2 -1
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.js +4 -3
- 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/dist/SearchResults/SearchResultsWidget.d.cts +2 -2
- package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.ts +2 -2
- package/dist/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.cts +2 -2
- package/dist/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.ts +2 -2
- package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.cts +2 -2
- package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.ts +2 -2
- package/package.json +5 -1
- package/src/CXIntegration/hooks/useUnifiedCXButton.ts +4 -3
- package/src/stories/ProductCardWidget.stories.tsx +58 -0
- package/src/stories/SalesAgentTest/SalesAgentTest.tsx +24 -8
- 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/FloatingChatWidget/FloatingChatWidget.tsx +24 -18
- package/src/widgets/ProductCardWidget/ProductCardWidget.tsx +112 -0
- package/src/widgets/ProductCardWidget/index.ts +2 -0
- package/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx +32 -4
- package/src/widgets/PromptCarouselWidget/PromptCarouselWidget.tsx +1 -1
- package/src/widgets/SocialProofWidget/SocialProofWidget.tsx +4 -6
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
|
};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SocialProofWidgetKind,
|
|
3
|
-
SocialProofWidgetV3Config,
|
|
4
|
-
WidgetTypeV3,
|
|
5
|
-
} from '@envive-ai/react-hooks/contexts/typesV3';
|
|
1
|
+
import { SocialProofWidgetV3Config, WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
6
2
|
import { useAtomValue, useSetAtom } from 'jotai';
|
|
7
3
|
import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
8
4
|
import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
|
|
@@ -12,6 +8,7 @@ import {
|
|
|
12
8
|
PageVariant,
|
|
13
9
|
SocialProof,
|
|
14
10
|
SocialProofProps,
|
|
11
|
+
WidgetKind,
|
|
15
12
|
} from '@envive-ai/react-toolkit-v3/SocialProof';
|
|
16
13
|
|
|
17
14
|
import {
|
|
@@ -87,7 +84,7 @@ const SocialProofWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
87
84
|
const dynamicImageUrl = getProductImageUrl(lastAssistantMessage);
|
|
88
85
|
|
|
89
86
|
const images =
|
|
90
|
-
socialProofWidgetConfig?.kind !==
|
|
87
|
+
socialProofWidgetConfig?.kind !== WidgetKind.DYNAMIC
|
|
91
88
|
? socialProofWidgetConfig?.images
|
|
92
89
|
: [{ src: dynamicImageUrl, alt: 'Product Image' }];
|
|
93
90
|
|
|
@@ -143,6 +140,7 @@ const SocialProofWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
143
140
|
const widgetStyleProps: SocialProofProps['widgetStyleProps'] = {
|
|
144
141
|
theme: Theme.GLOBAL_CUSTOM,
|
|
145
142
|
variant: socialProofWidgetConfig?.variant,
|
|
143
|
+
kind: socialProofWidgetConfig?.kind as WidgetKind,
|
|
146
144
|
primaryButtonVariant: socialProofWidgetConfig?.primaryButtonVariant,
|
|
147
145
|
secondaryButtonVariant: socialProofWidgetConfig?.secondaryButtonVariant,
|
|
148
146
|
promptCarouselRows: socialProofWidgetConfig?.promptCarouselRows,
|