@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
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_types = require('../types.cjs');
|
|
3
3
|
const require_functions = require('../utils/functions.cjs');
|
|
4
|
+
let __envive_ai_react_hooks_contexts_pageContext = require("@envive-ai/react-hooks/contexts/pageContext");
|
|
4
5
|
let jotai = require("jotai");
|
|
5
6
|
let __envive_ai_react_hooks_atoms_app = require("@envive-ai/react-hooks/atoms/app");
|
|
6
7
|
|
|
7
8
|
//#region src/CXIntegration/hooks/useUnifiedCXButton.ts
|
|
8
9
|
const useUnifiedCXButton = ({ enabled = false, provider = require_types.CustomerServiceType.unsupported, suppressMerchantButton = false, onSwitchToAgent }) => {
|
|
9
|
-
const
|
|
10
|
+
const { isSupported } = (0, __envive_ai_react_hooks_contexts_pageContext.usePage)();
|
|
10
11
|
const hasParsedVariantInfo = (0, jotai.useAtomValue)(__envive_ai_react_hooks_atoms_app.hasParsedVariantInfoAtom);
|
|
11
12
|
const selectedCustomerService = require_functions.findCustomerServiceImpl(provider)({
|
|
12
13
|
onSwitchToAgent,
|
|
@@ -14,7 +15,7 @@ const useUnifiedCXButton = ({ enabled = false, provider = require_types.Customer
|
|
|
14
15
|
});
|
|
15
16
|
if (!enabled) return void 0;
|
|
16
17
|
if (suppressMerchantButton) {
|
|
17
|
-
if (!(hasParsedVariantInfo &&
|
|
18
|
+
if (!(hasParsedVariantInfo && isSupported)) return void 0;
|
|
18
19
|
}
|
|
19
20
|
if (!selectedCustomerService.isSwitchEnabled() && !window?._spiffy?.selectedCustomizeOption) return;
|
|
20
21
|
if (window?._spiffy?.selectedCustomizeOption && provider === require_types.CustomerServiceType.unsupported) return;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { CustomerServiceType } from "../types.js";
|
|
2
2
|
import { findCustomerServiceImpl } from "../utils/functions.js";
|
|
3
|
+
import { usePage } from "@envive-ai/react-hooks/contexts/pageContext";
|
|
3
4
|
import { useAtomValue } from "jotai";
|
|
4
|
-
import { hasParsedVariantInfoAtom
|
|
5
|
+
import { hasParsedVariantInfoAtom } from "@envive-ai/react-hooks/atoms/app";
|
|
5
6
|
|
|
6
7
|
//#region src/CXIntegration/hooks/useUnifiedCXButton.ts
|
|
7
8
|
const useUnifiedCXButton = ({ enabled = false, provider = CustomerServiceType.unsupported, suppressMerchantButton = false, onSwitchToAgent }) => {
|
|
8
|
-
const
|
|
9
|
+
const { isSupported } = usePage();
|
|
9
10
|
const hasParsedVariantInfo = useAtomValue(hasParsedVariantInfoAtom);
|
|
10
11
|
const selectedCustomerService = findCustomerServiceImpl(provider)({
|
|
11
12
|
onSwitchToAgent,
|
|
@@ -13,7 +14,7 @@ const useUnifiedCXButton = ({ enabled = false, provider = CustomerServiceType.un
|
|
|
13
14
|
});
|
|
14
15
|
if (!enabled) return void 0;
|
|
15
16
|
if (suppressMerchantButton) {
|
|
16
|
-
if (!(hasParsedVariantInfo &&
|
|
17
|
+
if (!(hasParsedVariantInfo && isSupported)) return void 0;
|
|
17
18
|
}
|
|
18
19
|
if (!selectedCustomerService.isSwitchEnabled() && !window?._spiffy?.selectedCustomizeOption) return;
|
|
19
20
|
if (window?._spiffy?.selectedCustomizeOption && provider === CustomerServiceType.unsupported) return;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps, WithBaseWidgetOptions } from "./types.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime13 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/hocs/withBaseWidget/withBaseWidget.d.ts
|
|
5
5
|
declare function withBaseWidget<P extends BaseWidgetProps>(Widget: React.ComponentType<P>, options?: WithBaseWidgetOptions): {
|
|
6
|
-
(props: P):
|
|
6
|
+
(props: P): react_jsx_runtime13.JSX.Element;
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
//#endregion
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps, WithBaseWidgetOptions } from "./types.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime17 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/hocs/withBaseWidget/withBaseWidget.d.ts
|
|
5
5
|
declare function withBaseWidget<P extends BaseWidgetProps>(Widget: React.ComponentType<P>, options?: WithBaseWidgetOptions): {
|
|
6
|
-
(props: P):
|
|
6
|
+
(props: P): react_jsx_runtime17.JSX.Element;
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
//#endregion
|
|
@@ -16,15 +16,12 @@ let __envive_ai_react_hooks_atoms_app = require("@envive-ai/react-hooks/atoms/ap
|
|
|
16
16
|
|
|
17
17
|
//#region src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.tsx
|
|
18
18
|
const ChatPreviewComparisonWidgetHandler = (props) => {
|
|
19
|
-
const {
|
|
19
|
+
const { onSuggestionClicked } = (0, __envive_ai_react_hooks_contexts_salesAgentContext.useSalesAgent)();
|
|
20
20
|
const { openChat } = (0, __envive_ai_react_hooks_hooks_ChatToggle.useChatToggle)();
|
|
21
21
|
const lastAssistantMessage = (0, jotai.useAtomValue)(__envive_ai_react_hooks_atoms_chat.lastAssistantMessageAtom);
|
|
22
22
|
const variantInfo = (0, jotai.useAtomValue)(__envive_ai_react_hooks_atoms_app.variantInfoAtom);
|
|
23
23
|
const productId = variantInfo.variant === __envive_ai_react_hooks_application_models.VariantTypeEnum.Pdp ? variantInfo.productId : void 0;
|
|
24
24
|
const { suggestions } = (0, jotai.useAtomValue)(__envive_ai_react_hooks_atoms_chat.chatAtom);
|
|
25
|
-
const promptButtonTexts = (0, react.useMemo)(() => {
|
|
26
|
-
return suggestions.map((suggestion) => suggestion.content);
|
|
27
|
-
}, [suggestions]);
|
|
28
25
|
const messageText = (0, react.useMemo)(() => require_functions.getMessageText(lastAssistantMessage), [lastAssistantMessage]);
|
|
29
26
|
const productImageUrls = (0, react.useMemo)(() => lastAssistantMessage ? require_functions.getRecentProductImageUrls(lastAssistantMessage, productId) : [], [lastAssistantMessage, productId]);
|
|
30
27
|
const images = (0, react.useMemo)(() => productImageUrls ? productImageUrls.map((url, index) => ({
|
|
@@ -38,18 +35,14 @@ const ChatPreviewComparisonWidgetHandler = (props) => {
|
|
|
38
35
|
titleLabel: hardcopyContent?.values?.titleLabel,
|
|
39
36
|
headlineText: hardcopyContent?.values?.headlineText,
|
|
40
37
|
textFieldPlaceholderText: hardcopyContent?.values?.textFieldPlaceholderText,
|
|
41
|
-
messageText
|
|
42
|
-
promptButtonTexts
|
|
38
|
+
messageText
|
|
43
39
|
};
|
|
44
40
|
const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc;
|
|
45
41
|
const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
|
|
46
|
-
const handlePromptButtonClick = (0, react.useCallback)((
|
|
47
|
-
|
|
48
|
-
query: text,
|
|
49
|
-
userTyped: false
|
|
50
|
-
});
|
|
42
|
+
const handlePromptButtonClick = (0, react.useCallback)((suggestion) => {
|
|
43
|
+
onSuggestionClicked(suggestion, __envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_PROMPT_BUTTON);
|
|
51
44
|
openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_PROMPT_BUTTON);
|
|
52
|
-
}, [
|
|
45
|
+
}, [onSuggestionClicked, openChat]);
|
|
53
46
|
const handleTextFieldClick = (0, react.useCallback)(() => {
|
|
54
47
|
openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_TEXT_FIELD);
|
|
55
48
|
}, [openChat]);
|
|
@@ -69,7 +62,7 @@ const ChatPreviewComparisonWidgetHandler = (props) => {
|
|
|
69
62
|
titleLabel: hardCopyContent?.titleLabel,
|
|
70
63
|
headlineText: hardCopyContent?.headlineText,
|
|
71
64
|
messageText: hardCopyContent?.messageText,
|
|
72
|
-
|
|
65
|
+
promptButtons: suggestions,
|
|
73
66
|
textFieldPlaceholderText: hardCopyContent?.textFieldPlaceholderText,
|
|
74
67
|
images: images ?? [],
|
|
75
68
|
logoSrc: logoSrc ?? void 0
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.cjs";
|
|
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
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime15 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_runtime15.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_runtime15.JSX.Element;
|
|
16
16
|
displayName: string;
|
|
17
17
|
};
|
|
18
18
|
//#endregion
|
|
@@ -15,15 +15,12 @@ import { variantInfoAtom } from "@envive-ai/react-hooks/atoms/app";
|
|
|
15
15
|
|
|
16
16
|
//#region src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.tsx
|
|
17
17
|
const ChatPreviewComparisonWidgetHandler = (props) => {
|
|
18
|
-
const {
|
|
18
|
+
const { onSuggestionClicked } = useSalesAgent();
|
|
19
19
|
const { openChat } = useChatToggle();
|
|
20
20
|
const lastAssistantMessage = useAtomValue(lastAssistantMessageAtom);
|
|
21
21
|
const variantInfo = useAtomValue(variantInfoAtom);
|
|
22
22
|
const productId = variantInfo.variant === VariantTypeEnum.Pdp ? variantInfo.productId : void 0;
|
|
23
23
|
const { suggestions } = useAtomValue(chatAtom);
|
|
24
|
-
const promptButtonTexts = useMemo(() => {
|
|
25
|
-
return suggestions.map((suggestion) => suggestion.content);
|
|
26
|
-
}, [suggestions]);
|
|
27
24
|
const messageText = useMemo(() => getMessageText(lastAssistantMessage), [lastAssistantMessage]);
|
|
28
25
|
const productImageUrls = useMemo(() => lastAssistantMessage ? getRecentProductImageUrls(lastAssistantMessage, productId) : [], [lastAssistantMessage, productId]);
|
|
29
26
|
const images = useMemo(() => productImageUrls ? productImageUrls.map((url, index) => ({
|
|
@@ -37,18 +34,14 @@ const ChatPreviewComparisonWidgetHandler = (props) => {
|
|
|
37
34
|
titleLabel: hardcopyContent?.values?.titleLabel,
|
|
38
35
|
headlineText: hardcopyContent?.values?.headlineText,
|
|
39
36
|
textFieldPlaceholderText: hardcopyContent?.values?.textFieldPlaceholderText,
|
|
40
|
-
messageText
|
|
41
|
-
promptButtonTexts
|
|
37
|
+
messageText
|
|
42
38
|
};
|
|
43
39
|
const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc;
|
|
44
40
|
const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
|
|
45
|
-
const handlePromptButtonClick = useCallback((
|
|
46
|
-
|
|
47
|
-
query: text,
|
|
48
|
-
userTyped: false
|
|
49
|
-
});
|
|
41
|
+
const handlePromptButtonClick = useCallback((suggestion) => {
|
|
42
|
+
onSuggestionClicked(suggestion, ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_PROMPT_BUTTON);
|
|
50
43
|
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_PROMPT_BUTTON);
|
|
51
|
-
}, [
|
|
44
|
+
}, [onSuggestionClicked, openChat]);
|
|
52
45
|
const handleTextFieldClick = useCallback(() => {
|
|
53
46
|
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_TEXT_FIELD);
|
|
54
47
|
}, [openChat]);
|
|
@@ -68,7 +61,7 @@ const ChatPreviewComparisonWidgetHandler = (props) => {
|
|
|
68
61
|
titleLabel: hardCopyContent?.titleLabel,
|
|
69
62
|
headlineText: hardCopyContent?.headlineText,
|
|
70
63
|
messageText: hardCopyContent?.messageText,
|
|
71
|
-
|
|
64
|
+
promptButtons: suggestions,
|
|
72
65
|
textFieldPlaceholderText: hardCopyContent?.textFieldPlaceholderText,
|
|
73
66
|
images: images ?? [],
|
|
74
67
|
logoSrc: logoSrc ?? void 0
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.js";
|
|
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 };
|
|
@@ -16,13 +16,10 @@ let __envive_ai_react_toolkit_v3_ChatPreview = require("@envive-ai/react-toolkit
|
|
|
16
16
|
|
|
17
17
|
//#region src/widgets/ChatPreviewWidget/ChatPreviewWidget.tsx
|
|
18
18
|
const ChatPreviewWidgetHandler = (props) => {
|
|
19
|
-
const {
|
|
19
|
+
const { onSuggestionClicked } = (0, __envive_ai_react_hooks_contexts_salesAgentContext.useSalesAgent)();
|
|
20
20
|
const { openChat } = (0, __envive_ai_react_hooks_hooks_ChatToggle.useChatToggle)();
|
|
21
21
|
const lastAssistantMessage = (0, jotai.useAtomValue)(__envive_ai_react_hooks_atoms_chat.lastAssistantMessageAtom);
|
|
22
22
|
const { suggestions } = (0, jotai.useAtomValue)(__envive_ai_react_hooks_atoms_chat.chatAtom);
|
|
23
|
-
const promptButtonTexts = (0, react.useMemo)(() => {
|
|
24
|
-
return suggestions.map((suggestion) => suggestion.content);
|
|
25
|
-
}, [suggestions]);
|
|
26
23
|
const messageText = (0, react.useMemo)(() => require_functions.getMessageText(lastAssistantMessage), [lastAssistantMessage]);
|
|
27
24
|
const { hardcopyContent, widgetConfig, uiConfig, isLoading, widgetConfigId } = props;
|
|
28
25
|
const chatPreviewWidgetConfig = widgetConfig;
|
|
@@ -30,8 +27,8 @@ const ChatPreviewWidgetHandler = (props) => {
|
|
|
30
27
|
const hardCopyContent = {
|
|
31
28
|
titleLabel: hardcopyContent?.values?.titleLabel,
|
|
32
29
|
textFieldPlaceholderText: hardcopyContent?.values?.textFieldPlaceholderText,
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
promptButtons: suggestions,
|
|
31
|
+
messageText
|
|
35
32
|
};
|
|
36
33
|
const { trackEvent } = (0, __envive_ai_react_hooks_contexts_amplitudeContext.useAmplitude)();
|
|
37
34
|
(0, react.useEffect)(() => {
|
|
@@ -45,13 +42,10 @@ const ChatPreviewWidgetHandler = (props) => {
|
|
|
45
42
|
}, [trackEvent, widgetConfigId]);
|
|
46
43
|
const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc;
|
|
47
44
|
const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
|
|
48
|
-
const handlePromptButtonClick = (0, react.useCallback)((
|
|
49
|
-
|
|
50
|
-
query: text,
|
|
51
|
-
userTyped: false
|
|
52
|
-
});
|
|
45
|
+
const handlePromptButtonClick = (0, react.useCallback)((suggestion) => {
|
|
46
|
+
onSuggestionClicked(suggestion, __envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.CHAT_PREVIEW_PROMPT_BUTTON);
|
|
53
47
|
openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.CHAT_PREVIEW_PROMPT_BUTTON);
|
|
54
|
-
}, [
|
|
48
|
+
}, [onSuggestionClicked, openChat]);
|
|
55
49
|
const handleTextFieldClick = (0, react.useCallback)(() => {
|
|
56
50
|
openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.CHAT_PREVIEW_TEXT_FIELD);
|
|
57
51
|
}, [openChat]);
|
|
@@ -69,7 +63,7 @@ const ChatPreviewWidgetHandler = (props) => {
|
|
|
69
63
|
const widgetContentProps = {
|
|
70
64
|
titleLabel: hardCopyContent?.titleLabel,
|
|
71
65
|
messageText: hardCopyContent?.messageText,
|
|
72
|
-
|
|
66
|
+
promptButtons: hardCopyContent?.promptButtons,
|
|
73
67
|
textFieldPlaceholderText: hardCopyContent?.textFieldPlaceholderText,
|
|
74
68
|
logoSrc: logoSrc ?? void 0
|
|
75
69
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime14 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_runtime14.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_runtime14.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
|
|
@@ -15,13 +15,10 @@ import { ChatPreview } from "@envive-ai/react-toolkit-v3/ChatPreview";
|
|
|
15
15
|
|
|
16
16
|
//#region src/widgets/ChatPreviewWidget/ChatPreviewWidget.tsx
|
|
17
17
|
const ChatPreviewWidgetHandler = (props) => {
|
|
18
|
-
const {
|
|
18
|
+
const { onSuggestionClicked } = useSalesAgent();
|
|
19
19
|
const { openChat } = useChatToggle();
|
|
20
20
|
const lastAssistantMessage = useAtomValue(lastAssistantMessageAtom);
|
|
21
21
|
const { suggestions } = useAtomValue(chatAtom);
|
|
22
|
-
const promptButtonTexts = useMemo(() => {
|
|
23
|
-
return suggestions.map((suggestion) => suggestion.content);
|
|
24
|
-
}, [suggestions]);
|
|
25
22
|
const messageText = useMemo(() => getMessageText(lastAssistantMessage), [lastAssistantMessage]);
|
|
26
23
|
const { hardcopyContent, widgetConfig, uiConfig, isLoading, widgetConfigId } = props;
|
|
27
24
|
const chatPreviewWidgetConfig = widgetConfig;
|
|
@@ -29,8 +26,8 @@ const ChatPreviewWidgetHandler = (props) => {
|
|
|
29
26
|
const hardCopyContent = {
|
|
30
27
|
titleLabel: hardcopyContent?.values?.titleLabel,
|
|
31
28
|
textFieldPlaceholderText: hardcopyContent?.values?.textFieldPlaceholderText,
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
promptButtons: suggestions,
|
|
30
|
+
messageText
|
|
34
31
|
};
|
|
35
32
|
const { trackEvent } = useAmplitude();
|
|
36
33
|
useEffect(() => {
|
|
@@ -44,13 +41,10 @@ const ChatPreviewWidgetHandler = (props) => {
|
|
|
44
41
|
}, [trackEvent, widgetConfigId]);
|
|
45
42
|
const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc;
|
|
46
43
|
const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
|
|
47
|
-
const handlePromptButtonClick = useCallback((
|
|
48
|
-
|
|
49
|
-
query: text,
|
|
50
|
-
userTyped: false
|
|
51
|
-
});
|
|
44
|
+
const handlePromptButtonClick = useCallback((suggestion) => {
|
|
45
|
+
onSuggestionClicked(suggestion, ChatElementDisplayLocationV3.CHAT_PREVIEW_PROMPT_BUTTON);
|
|
52
46
|
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_PROMPT_BUTTON);
|
|
53
|
-
}, [
|
|
47
|
+
}, [onSuggestionClicked, openChat]);
|
|
54
48
|
const handleTextFieldClick = useCallback(() => {
|
|
55
49
|
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_TEXT_FIELD);
|
|
56
50
|
}, [openChat]);
|
|
@@ -68,7 +62,7 @@ const ChatPreviewWidgetHandler = (props) => {
|
|
|
68
62
|
const widgetContentProps = {
|
|
69
63
|
titleLabel: hardCopyContent?.titleLabel,
|
|
70
64
|
messageText: hardCopyContent?.messageText,
|
|
71
|
-
|
|
65
|
+
promptButtons: hardCopyContent?.promptButtons,
|
|
72
66
|
textFieldPlaceholderText: hardCopyContent?.textFieldPlaceholderText,
|
|
73
67
|
logoSrc: logoSrc ?? void 0
|
|
74
68
|
};
|
|
@@ -7,11 +7,12 @@ classnames = require_rolldown_runtime.__toESM(classnames);
|
|
|
7
7
|
|
|
8
8
|
//#region src/widgets/FloatingChatWidget/FloatingChatOverlay.tsx
|
|
9
9
|
const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestId, previewMode = false }) => {
|
|
10
|
-
const overlayClasses = (0, classnames.default)(
|
|
11
|
-
const backdropClasses = (0, classnames.default)("envive-
|
|
12
|
-
const overlayContentClasses = (0, classnames.default)("envive-
|
|
10
|
+
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");
|
|
12
|
+
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
13
|
const chatWrapper = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(framer_motion.AnimatePresence, { children: isOpened && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(framer_motion.motion.div, {
|
|
14
14
|
className: overlayClasses,
|
|
15
|
+
style: { top: "0px" },
|
|
15
16
|
initial: { opacity: 0 },
|
|
16
17
|
animate: { opacity: 1 },
|
|
17
18
|
exit: { opacity: 0 },
|
|
@@ -26,6 +27,7 @@ const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestI
|
|
|
26
27
|
"aria-label": "Close chat"
|
|
27
28
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
28
29
|
className: overlayContentClasses,
|
|
30
|
+
style: { top: "0px" },
|
|
29
31
|
onClick: onClose,
|
|
30
32
|
onKeyDown: (e) => {
|
|
31
33
|
if (e.key === "Escape") onClose();
|
|
@@ -5,11 +5,12 @@ import classNames from "classnames";
|
|
|
5
5
|
|
|
6
6
|
//#region src/widgets/FloatingChatWidget/FloatingChatOverlay.tsx
|
|
7
7
|
const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestId, previewMode = false }) => {
|
|
8
|
-
const overlayClasses = classNames(
|
|
9
|
-
const backdropClasses = classNames("envive-
|
|
10
|
-
const overlayContentClasses = classNames("envive-
|
|
8
|
+
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");
|
|
10
|
+
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
11
|
const chatWrapper = /* @__PURE__ */ jsx(AnimatePresence, { children: isOpened && /* @__PURE__ */ jsxs(motion.div, {
|
|
12
12
|
className: overlayClasses,
|
|
13
|
+
style: { top: "0px" },
|
|
13
14
|
initial: { opacity: 0 },
|
|
14
15
|
animate: { opacity: 1 },
|
|
15
16
|
exit: { opacity: 0 },
|
|
@@ -24,6 +25,7 @@ const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestI
|
|
|
24
25
|
"aria-label": "Close chat"
|
|
25
26
|
}), /* @__PURE__ */ jsx("div", {
|
|
26
27
|
className: overlayContentClasses,
|
|
28
|
+
style: { top: "0px" },
|
|
27
29
|
onClick: onClose,
|
|
28
30
|
onKeyDown: (e) => {
|
|
29
31
|
if (e.key === "Escape") onClose();
|
|
@@ -15,15 +15,15 @@ let __envive_ai_react_hooks_contexts_salesAgentContext = require("@envive-ai/rea
|
|
|
15
15
|
let __envive_ai_react_hooks_hooks_ChatToggle = require("@envive-ai/react-hooks/hooks/ChatToggle");
|
|
16
16
|
let __envive_ai_react_toolkit_v3_Tokens = require("@envive-ai/react-toolkit-v3/Tokens");
|
|
17
17
|
let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
|
|
18
|
-
let __envive_ai_react_toolkit_v3_FloatingChat = require("@envive-ai/react-toolkit-v3/FloatingChat");
|
|
19
18
|
let __envive_ai_react_toolkit_v3_FloatingButton = require("@envive-ai/react-toolkit-v3/FloatingButton");
|
|
20
19
|
|
|
21
20
|
//#region src/widgets/FloatingChatWidget/FloatingChatWidget.tsx
|
|
21
|
+
const FloatingChat = (0, react.lazy)(async () => ({ default: (await import("@envive-ai/react-toolkit-v3/FloatingChat")).FloatingChat }));
|
|
22
22
|
const FloatingChatWidgetHandler = (props) => {
|
|
23
23
|
const { previewButtonOnly, previewChatAlwaysOpen } = props;
|
|
24
24
|
const salesAgentData = (0, __envive_ai_react_hooks_contexts_salesAgentContext.useSalesAgent)();
|
|
25
25
|
const { userHasInteractedValue } = require_useGetWidgetStatus.default();
|
|
26
|
-
const { uiConfig, isUiConfigLoading } = props;
|
|
26
|
+
const { uiConfig, isUiConfigLoading, hardcopyContent } = props;
|
|
27
27
|
const { isSwitchEnabled, toggle } = require_useUnifiedCXButton.useUnifiedCXButton({
|
|
28
28
|
provider: require_types.CustomerServiceType.unsupported,
|
|
29
29
|
enabled: false,
|
|
@@ -37,7 +37,7 @@ const FloatingChatWidgetHandler = (props) => {
|
|
|
37
37
|
userHasInteracted: userHasInteractedValue
|
|
38
38
|
});
|
|
39
39
|
const effectiveIsOpen = previewChatAlwaysOpen ? true : isOpen;
|
|
40
|
-
const buttonShouldRender = previewButtonOnly ? true : !
|
|
40
|
+
const buttonShouldRender = previewButtonOnly ? true : !effectiveIsOpen && shouldShowFloatingButton;
|
|
41
41
|
const theme = (0, react.useMemo)(() => {
|
|
42
42
|
if (isUiConfigLoading || !uiConfig) return __envive_ai_react_toolkit_v3_Tokens.Theme.STANDARD;
|
|
43
43
|
return uiConfig?.lookAndFeel?.theme ?? __envive_ai_react_toolkit_v3_Tokens.Theme.GLOBAL_CUSTOM;
|
|
@@ -60,16 +60,17 @@ const FloatingChatWidgetHandler = (props) => {
|
|
|
60
60
|
isOpened: effectiveIsOpen,
|
|
61
61
|
onClose: previewChatAlwaysOpen ? () => {} : () => closeChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.FLOATING_CHAT_OVERLAY),
|
|
62
62
|
previewMode: !!previewChatAlwaysOpen,
|
|
63
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
63
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Suspense, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FloatingChat, {
|
|
64
64
|
theme,
|
|
65
65
|
salesAgentData,
|
|
66
|
+
hardcopyContent,
|
|
66
67
|
floatingChatConfig: uiConfig?.floatingChat ?? {},
|
|
67
68
|
lookAndFeelConfig: uiConfig?.lookAndFeel ?? {},
|
|
68
69
|
isCXButtonSwitchEnabled: !!isSwitchEnabled?.(),
|
|
69
70
|
isFloatingChatOpen: effectiveIsOpen,
|
|
70
71
|
onToggleCXButton: toggle,
|
|
71
72
|
onClose: previewChatAlwaysOpen ? () => {} : () => closeChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.FLOATING_CHAT_CLOSE_BUTTON)
|
|
72
|
-
})
|
|
73
|
+
}) })
|
|
73
74
|
}), buttonShouldRender && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__envive_ai_react_toolkit_v3_FloatingButton.FloatingButton, {
|
|
74
75
|
id: require_constants.FLOATING_BUTTON_ID,
|
|
75
76
|
variant: floatingButton?.style,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime12 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/widgets/FloatingChatWidget/FloatingChatWidget.d.ts
|
|
4
4
|
interface FloatingChatWidgetProps {
|
|
@@ -9,7 +9,7 @@ declare const FloatingChatWidget: {
|
|
|
9
9
|
({
|
|
10
10
|
previewButtonOnly,
|
|
11
11
|
previewChatAlwaysOpen
|
|
12
|
-
}?: FloatingChatWidgetProps):
|
|
12
|
+
}?: FloatingChatWidgetProps): react_jsx_runtime12.JSX.Element;
|
|
13
13
|
displayName: string;
|
|
14
14
|
};
|
|
15
15
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/widgets/FloatingChatWidget/FloatingChatWidget.d.ts
|
|
4
4
|
interface FloatingChatWidgetProps {
|
|
@@ -9,7 +9,7 @@ declare const FloatingChatWidget: {
|
|
|
9
9
|
({
|
|
10
10
|
previewButtonOnly,
|
|
11
11
|
previewChatAlwaysOpen
|
|
12
|
-
}?: FloatingChatWidgetProps):
|
|
12
|
+
}?: FloatingChatWidgetProps): react_jsx_runtime0.JSX.Element;
|
|
13
13
|
displayName: string;
|
|
14
14
|
};
|
|
15
15
|
//#endregion
|
|
@@ -6,7 +6,7 @@ import { CustomerServiceType } from "../../CXIntegration/types.js";
|
|
|
6
6
|
import { FLOATING_BUTTON_ID } from "./constants.js";
|
|
7
7
|
import { useUnifiedCXButton } from "../../CXIntegration/hooks/useUnifiedCXButton.js";
|
|
8
8
|
import { useFloatingButtonVisibility } from "./hooks/useFloatingButtonVisibility.js";
|
|
9
|
-
import { useEffect, useMemo, useRef } from "react";
|
|
9
|
+
import { Suspense, lazy, useEffect, useMemo, useRef } from "react";
|
|
10
10
|
import { SpiffyMetricsEventName, useAmplitude } from "@envive-ai/react-hooks/contexts/amplitudeContext";
|
|
11
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
import { WidgetTypeV3 } from "@envive-ai/react-hooks/contexts/typesV3";
|
|
@@ -14,15 +14,15 @@ import { useSalesAgent } from "@envive-ai/react-hooks/contexts/salesAgentContext
|
|
|
14
14
|
import { useChatToggle } from "@envive-ai/react-hooks/hooks/ChatToggle";
|
|
15
15
|
import { Theme } from "@envive-ai/react-toolkit-v3/Tokens";
|
|
16
16
|
import { ChatElementDisplayLocationV3 } from "@envive-ai/react-hooks/application/models";
|
|
17
|
-
import { FloatingChat } from "@envive-ai/react-toolkit-v3/FloatingChat";
|
|
18
17
|
import { FloatingButton } from "@envive-ai/react-toolkit-v3/FloatingButton";
|
|
19
18
|
|
|
20
19
|
//#region src/widgets/FloatingChatWidget/FloatingChatWidget.tsx
|
|
20
|
+
const FloatingChat = lazy(async () => ({ default: (await import("@envive-ai/react-toolkit-v3/FloatingChat")).FloatingChat }));
|
|
21
21
|
const FloatingChatWidgetHandler = (props) => {
|
|
22
22
|
const { previewButtonOnly, previewChatAlwaysOpen } = props;
|
|
23
23
|
const salesAgentData = useSalesAgent();
|
|
24
24
|
const { userHasInteractedValue } = useGetWidgetStatus_default();
|
|
25
|
-
const { uiConfig, isUiConfigLoading } = props;
|
|
25
|
+
const { uiConfig, isUiConfigLoading, hardcopyContent } = props;
|
|
26
26
|
const { isSwitchEnabled, toggle } = useUnifiedCXButton({
|
|
27
27
|
provider: CustomerServiceType.unsupported,
|
|
28
28
|
enabled: false,
|
|
@@ -36,7 +36,7 @@ const FloatingChatWidgetHandler = (props) => {
|
|
|
36
36
|
userHasInteracted: userHasInteractedValue
|
|
37
37
|
});
|
|
38
38
|
const effectiveIsOpen = previewChatAlwaysOpen ? true : isOpen;
|
|
39
|
-
const buttonShouldRender = previewButtonOnly ? true : !
|
|
39
|
+
const buttonShouldRender = previewButtonOnly ? true : !effectiveIsOpen && shouldShowFloatingButton;
|
|
40
40
|
const theme = useMemo(() => {
|
|
41
41
|
if (isUiConfigLoading || !uiConfig) return Theme.STANDARD;
|
|
42
42
|
return uiConfig?.lookAndFeel?.theme ?? Theme.GLOBAL_CUSTOM;
|
|
@@ -59,16 +59,17 @@ const FloatingChatWidgetHandler = (props) => {
|
|
|
59
59
|
isOpened: effectiveIsOpen,
|
|
60
60
|
onClose: previewChatAlwaysOpen ? () => {} : () => closeChat(ChatElementDisplayLocationV3.FLOATING_CHAT_OVERLAY),
|
|
61
61
|
previewMode: !!previewChatAlwaysOpen,
|
|
62
|
-
children: /* @__PURE__ */ jsx(FloatingChat, {
|
|
62
|
+
children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(FloatingChat, {
|
|
63
63
|
theme,
|
|
64
64
|
salesAgentData,
|
|
65
|
+
hardcopyContent,
|
|
65
66
|
floatingChatConfig: uiConfig?.floatingChat ?? {},
|
|
66
67
|
lookAndFeelConfig: uiConfig?.lookAndFeel ?? {},
|
|
67
68
|
isCXButtonSwitchEnabled: !!isSwitchEnabled?.(),
|
|
68
69
|
isFloatingChatOpen: effectiveIsOpen,
|
|
69
70
|
onToggleCXButton: toggle,
|
|
70
71
|
onClose: previewChatAlwaysOpen ? () => {} : () => closeChat(ChatElementDisplayLocationV3.FLOATING_CHAT_CLOSE_BUTTON)
|
|
71
|
-
})
|
|
72
|
+
}) })
|
|
72
73
|
}), buttonShouldRender && /* @__PURE__ */ jsx(FloatingButton, {
|
|
73
74
|
id: FLOATING_BUTTON_ID,
|
|
74
75
|
variant: floatingButton?.style,
|