@envive-ai/react-widgets-v3 0.3.6 → 0.3.7
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 +2 -0
- package/dist/CXIntegration/hooks/useUnifiedCXButton.js +2 -0
- package/dist/hocs/withBaseWidget/withBaseWidget.d.cts +2 -2
- package/dist/hocs/withBaseWidget/withBaseWidget.d.ts +2 -2
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs +7 -24
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +9 -26
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.cjs +18 -24
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.js +21 -27
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.cjs +7 -6
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.js +7 -6
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +40 -11
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +9 -3
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +8 -2
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +41 -12
- package/dist/widgets/FloatingChatWidget/hooks/useFloatingButtonVisibility.cjs +19 -0
- package/dist/widgets/FloatingChatWidget/hooks/useFloatingButtonVisibility.js +18 -0
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +19 -26
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +21 -28
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +17 -14
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +19 -16
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.cts +2 -2
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
- package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +42 -36
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.js +45 -39
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +19 -15
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +21 -17
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.cts +2 -2
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.cjs +17 -13
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +19 -15
- package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.cts +2 -2
- package/dist/{packages/widgets → widgets}/dist/SearchResults/SearchResultsWidget.d.ts +2 -2
- package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.cts +2 -2
- package/dist/{packages/widgets → widgets}/dist/SuggestionBar/SuggestionBar.d.ts +2 -2
- package/dist/widgets-v2/SearchResults/index.d.ts +3 -3
- package/dist/widgets-v2/SearchZeroState/index.d.ts +4 -4
- package/dist/widgets-v2/SuggestionBar/index.d.ts +3 -3
- package/dist/widgets-v2/SuggestionButtonContainer/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/CXIntegration/hooks/useUnifiedCXButton.ts +8 -0
- package/src/stories/SalesAgentTest/SalesAgentTest.tsx +2 -2
- package/src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.tsx +8 -30
- package/src/widgets/ChatPreviewWidget/ChatPreviewWidget.tsx +26 -33
- package/src/widgets/FloatingChatWidget/FloatingChatOverlay.tsx +22 -13
- package/src/widgets/FloatingChatWidget/FloatingChatWidget.tsx +89 -22
- package/src/widgets/FloatingChatWidget/hooks/useFloatingButtonVisibility.ts +43 -0
- package/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx +25 -34
- package/src/widgets/PromptCarouselWidget/PromptCarouselWidget.tsx +23 -20
- package/src/widgets/SocialProofWidget/SocialProofWidget.tsx +55 -45
- package/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.tsx +23 -20
- package/src/widgets/TypingAnimationWidget/TypingAnimationWidget.tsx +22 -19
- package/dist/node_modules/uuid/dist/native.js +0 -6
- package/dist/node_modules/uuid/dist/rng.js +0 -13
- package/dist/node_modules/uuid/dist/stringify.js +0 -9
- package/dist/node_modules/uuid/dist/v4.js +0 -27
- package/dist/node_modules/uuid/dist-node/native.cjs +0 -8
- package/dist/node_modules/uuid/dist-node/rng.cjs +0 -16
- package/dist/node_modules/uuid/dist-node/stringify.cjs +0 -10
- package/dist/node_modules/uuid/dist-node/v4.cjs +0 -27
- /package/dist/{packages/widgets → widgets}/dist/SearchResults/SearchResults.d.ts +0 -0
- /package/dist/{packages/widgets → widgets}/dist/SearchResults/index.d.ts +0 -0
- /package/dist/{packages/widgets → widgets}/dist/SearchResults/types.d.ts +0 -0
- /package/dist/{packages/widgets → widgets}/dist/SearchZeroState/SearchZeroState.d.ts +0 -0
- /package/dist/{packages/widgets → widgets}/dist/SearchZeroState/SearchZeroStateWidget.d.ts +0 -0
- /package/dist/{packages/widgets → widgets}/dist/SearchZeroState/index.d.ts +0 -0
- /package/dist/{packages/widgets → widgets}/dist/SearchZeroState/types.d.ts +0 -0
- /package/dist/{packages/widgets → widgets}/dist/SuggestionBar/index.d.ts +0 -0
- /package/dist/{packages/widgets → widgets}/dist/SuggestionBar/types.d.ts +0 -0
- /package/dist/{packages/widgets → widgets}/dist/SuggestionButtonContainer/SuggestionButtonContainer.d.ts +0 -0
- /package/dist/{packages/widgets → widgets}/dist/SuggestionButtonContainer/types.d.ts +0 -0
- /package/dist/{packages/widgets → widgets}/dist/config/BaseWidgetConfig.d.ts +0 -0
- /package/dist/{packages/widgets → widgets}/dist/config/WidgetType.d.ts +0 -0
|
@@ -16,6 +16,8 @@ const useUnifiedCXButton = ({ enabled = false, provider = require_types.Customer
|
|
|
16
16
|
if (suppressMerchantButton) {
|
|
17
17
|
if (!(hasParsedVariantInfo && supportedEvent?.supported)) return void 0;
|
|
18
18
|
}
|
|
19
|
+
if (!selectedCustomerService.isSwitchEnabled() && !window?._spiffy?.selectedCustomizeOption) return;
|
|
20
|
+
if (window?._spiffy?.selectedCustomizeOption && provider === require_types.CustomerServiceType.unsupported) return;
|
|
19
21
|
return selectedCustomerService;
|
|
20
22
|
};
|
|
21
23
|
|
|
@@ -15,6 +15,8 @@ const useUnifiedCXButton = ({ enabled = false, provider = CustomerServiceType.un
|
|
|
15
15
|
if (suppressMerchantButton) {
|
|
16
16
|
if (!(hasParsedVariantInfo && supportedEvent?.supported)) return void 0;
|
|
17
17
|
}
|
|
18
|
+
if (!selectedCustomerService.isSwitchEnabled() && !window?._spiffy?.selectedCustomizeOption) return;
|
|
19
|
+
if (window?._spiffy?.selectedCustomizeOption && provider === CustomerServiceType.unsupported) return;
|
|
18
20
|
return selectedCustomerService;
|
|
19
21
|
};
|
|
20
22
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps, WithBaseWidgetOptions } from "./types.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime9 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_runtime9.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_runtime15 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_runtime15.JSX.Element;
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
//#endregion
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_withBaseWidget = require('../../hocs/withBaseWidget/withBaseWidget.cjs');
|
|
3
|
-
const require_v4 = require('../../node_modules/uuid/dist-node/v4.cjs');
|
|
4
3
|
const require_functions = require('../utils/functions.cjs');
|
|
5
4
|
const require_ChatPreviewLoadingWidget = require('../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.cjs');
|
|
6
5
|
let react = require("react");
|
|
7
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
7
|
let __envive_ai_react_hooks_contexts_typesV3 = require("@envive-ai/react-hooks/contexts/typesV3");
|
|
9
8
|
let jotai = require("jotai");
|
|
10
|
-
let
|
|
9
|
+
let __envive_ai_react_hooks_contexts_salesAgentContext = require("@envive-ai/react-hooks/contexts/salesAgentContext");
|
|
11
10
|
let __envive_ai_react_hooks_hooks_ChatToggle = require("@envive-ai/react-hooks/hooks/ChatToggle");
|
|
12
11
|
let __envive_ai_react_hooks_atoms_chat = require("@envive-ai/react-hooks/atoms/chat");
|
|
13
12
|
let __envive_ai_react_toolkit_v3_Tokens = require("@envive-ai/react-toolkit-v3/Tokens");
|
|
@@ -17,7 +16,7 @@ let __envive_ai_react_hooks_atoms_app = require("@envive-ai/react-hooks/atoms/ap
|
|
|
17
16
|
|
|
18
17
|
//#region src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.tsx
|
|
19
18
|
const ChatPreviewComparisonWidgetHandler = (props) => {
|
|
20
|
-
const
|
|
19
|
+
const { onTypedMessageSubmitted } = (0, __envive_ai_react_hooks_contexts_salesAgentContext.useSalesAgent)();
|
|
21
20
|
const { openChat } = (0, __envive_ai_react_hooks_hooks_ChatToggle.useChatToggle)();
|
|
22
21
|
const lastAssistantMessage = (0, jotai.useAtomValue)(__envive_ai_react_hooks_atoms_chat.lastAssistantMessageAtom);
|
|
23
22
|
const variantInfo = (0, jotai.useAtomValue)(__envive_ai_react_hooks_atoms_app.variantInfoAtom);
|
|
@@ -45,31 +44,15 @@ const ChatPreviewComparisonWidgetHandler = (props) => {
|
|
|
45
44
|
const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc;
|
|
46
45
|
const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
|
|
47
46
|
const handlePromptButtonClick = (0, react.useCallback)((text) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
id: require_v4.default(),
|
|
51
|
-
role: __envive_ai_react_hooks_application_models.MessageRole.User,
|
|
52
|
-
type: __envive_ai_react_hooks_application_models.MessageType.QueryTyped,
|
|
53
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
54
|
-
metadata: { content: text }
|
|
55
|
-
},
|
|
47
|
+
onTypedMessageSubmitted({
|
|
48
|
+
query: text,
|
|
56
49
|
userTyped: false
|
|
57
50
|
});
|
|
58
51
|
openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_PROMPT_BUTTON);
|
|
59
|
-
}, [
|
|
60
|
-
const handleTextFieldClick = (0, react.useCallback)((
|
|
61
|
-
handleReply({
|
|
62
|
-
message: {
|
|
63
|
-
id: require_v4.default(),
|
|
64
|
-
role: __envive_ai_react_hooks_application_models.MessageRole.User,
|
|
65
|
-
type: __envive_ai_react_hooks_application_models.MessageType.QueryTyped,
|
|
66
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
67
|
-
metadata: { content: text }
|
|
68
|
-
},
|
|
69
|
-
userTyped: false
|
|
70
|
-
});
|
|
52
|
+
}, [onTypedMessageSubmitted, openChat]);
|
|
53
|
+
const handleTextFieldClick = (0, react.useCallback)(() => {
|
|
71
54
|
openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_TEXT_FIELD);
|
|
72
|
-
}, [
|
|
55
|
+
}, [openChat]);
|
|
73
56
|
if (isLoading) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ChatPreviewLoadingWidget.ChatPreviewLoadingWidgetWithBaseWidget, {
|
|
74
57
|
widgetConfigId,
|
|
75
58
|
widgetType: __envive_ai_react_hooks_contexts_typesV3.WidgetTypeV3.ChatPreviewLoadingV3
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime5 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_runtime5.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_runtime5.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_runtime11 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_runtime11.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_runtime11.JSX.Element;
|
|
16
16
|
displayName: string;
|
|
17
17
|
};
|
|
18
18
|
//#endregion
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { withBaseWidget } from "../../hocs/withBaseWidget/withBaseWidget.js";
|
|
2
|
-
import v4_default from "../../node_modules/uuid/dist/v4.js";
|
|
3
2
|
import { getMessageText, getRecentProductImageUrls } from "../utils/functions.js";
|
|
4
3
|
import { ChatPreviewLoadingWidgetWithBaseWidget } from "../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.js";
|
|
5
4
|
import { useCallback, useMemo } from "react";
|
|
6
5
|
import { jsx } from "react/jsx-runtime";
|
|
7
6
|
import { WidgetTypeV3 } from "@envive-ai/react-hooks/contexts/typesV3";
|
|
8
|
-
import { useAtomValue
|
|
9
|
-
import {
|
|
7
|
+
import { useAtomValue } from "jotai";
|
|
8
|
+
import { useSalesAgent } from "@envive-ai/react-hooks/contexts/salesAgentContext";
|
|
10
9
|
import { useChatToggle } from "@envive-ai/react-hooks/hooks/ChatToggle";
|
|
11
10
|
import { chatAtom, lastAssistantMessageAtom } from "@envive-ai/react-hooks/atoms/chat";
|
|
12
11
|
import { Theme } from "@envive-ai/react-toolkit-v3/Tokens";
|
|
13
|
-
import { ChatElementDisplayLocationV3,
|
|
12
|
+
import { ChatElementDisplayLocationV3, VariantTypeEnum } from "@envive-ai/react-hooks/application/models";
|
|
14
13
|
import { ChatPreviewComparison } from "@envive-ai/react-toolkit-v3/ChatPreviewComparison";
|
|
15
14
|
import { variantInfoAtom } from "@envive-ai/react-hooks/atoms/app";
|
|
16
15
|
|
|
17
16
|
//#region src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.tsx
|
|
18
17
|
const ChatPreviewComparisonWidgetHandler = (props) => {
|
|
19
|
-
const
|
|
18
|
+
const { onTypedMessageSubmitted } = useSalesAgent();
|
|
20
19
|
const { openChat } = useChatToggle();
|
|
21
20
|
const lastAssistantMessage = useAtomValue(lastAssistantMessageAtom);
|
|
22
21
|
const variantInfo = useAtomValue(variantInfoAtom);
|
|
@@ -44,31 +43,15 @@ const ChatPreviewComparisonWidgetHandler = (props) => {
|
|
|
44
43
|
const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc;
|
|
45
44
|
const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
|
|
46
45
|
const handlePromptButtonClick = useCallback((text) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
id: v4_default(),
|
|
50
|
-
role: MessageRole.User,
|
|
51
|
-
type: MessageType.QueryTyped,
|
|
52
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
53
|
-
metadata: { content: text }
|
|
54
|
-
},
|
|
46
|
+
onTypedMessageSubmitted({
|
|
47
|
+
query: text,
|
|
55
48
|
userTyped: false
|
|
56
49
|
});
|
|
57
50
|
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_PROMPT_BUTTON);
|
|
58
|
-
}, [
|
|
59
|
-
const handleTextFieldClick = useCallback((
|
|
60
|
-
handleReply({
|
|
61
|
-
message: {
|
|
62
|
-
id: v4_default(),
|
|
63
|
-
role: MessageRole.User,
|
|
64
|
-
type: MessageType.QueryTyped,
|
|
65
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
66
|
-
metadata: { content: text }
|
|
67
|
-
},
|
|
68
|
-
userTyped: false
|
|
69
|
-
});
|
|
51
|
+
}, [onTypedMessageSubmitted, openChat]);
|
|
52
|
+
const handleTextFieldClick = useCallback(() => {
|
|
70
53
|
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_TEXT_FIELD);
|
|
71
|
-
}, [
|
|
54
|
+
}, [openChat]);
|
|
72
55
|
if (isLoading) return /* @__PURE__ */ jsx(ChatPreviewLoadingWidgetWithBaseWidget, {
|
|
73
56
|
widgetConfigId,
|
|
74
57
|
widgetType: WidgetTypeV3.ChatPreviewLoadingV3
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts
|
|
5
5
|
declare const ChatPreviewLoadingWidgetWithBaseWidget: {
|
|
6
|
-
(props: BaseWidgetProps):
|
|
6
|
+
(props: BaseWidgetProps): react_jsx_runtime0.JSX.Element;
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
interface ChatPreviewLoadingWidgetProps {
|
|
@@ -11,6 +11,6 @@ interface ChatPreviewLoadingWidgetProps {
|
|
|
11
11
|
}
|
|
12
12
|
declare const ChatPreviewLoadingWidget: ({
|
|
13
13
|
widgetConfigId
|
|
14
|
-
}: ChatPreviewLoadingWidgetProps) =>
|
|
14
|
+
}: ChatPreviewLoadingWidgetProps) => react_jsx_runtime0.JSX.Element;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { ChatPreviewLoadingWidget, ChatPreviewLoadingWidgetProps, ChatPreviewLoadingWidgetWithBaseWidget };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime5 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_runtime5.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_runtime5.JSX.Element;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { ChatPreviewLoadingWidget, ChatPreviewLoadingWidgetProps, ChatPreviewLoadingWidgetWithBaseWidget };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_withBaseWidget = require('../../hocs/withBaseWidget/withBaseWidget.cjs');
|
|
3
|
-
const require_v4 = require('../../node_modules/uuid/dist-node/v4.cjs');
|
|
4
3
|
const require_functions = require('../utils/functions.cjs');
|
|
5
4
|
const require_ChatPreviewLoadingWidget = require('../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.cjs');
|
|
6
5
|
let react = require("react");
|
|
6
|
+
let __envive_ai_react_hooks_contexts_amplitudeContext = require("@envive-ai/react-hooks/contexts/amplitudeContext");
|
|
7
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
8
|
let __envive_ai_react_hooks_contexts_typesV3 = require("@envive-ai/react-hooks/contexts/typesV3");
|
|
9
9
|
let jotai = require("jotai");
|
|
10
|
-
let
|
|
10
|
+
let __envive_ai_react_hooks_contexts_salesAgentContext = require("@envive-ai/react-hooks/contexts/salesAgentContext");
|
|
11
11
|
let __envive_ai_react_hooks_hooks_ChatToggle = require("@envive-ai/react-hooks/hooks/ChatToggle");
|
|
12
12
|
let __envive_ai_react_hooks_atoms_chat = require("@envive-ai/react-hooks/atoms/chat");
|
|
13
13
|
let __envive_ai_react_toolkit_v3_Tokens = require("@envive-ai/react-toolkit-v3/Tokens");
|
|
@@ -16,7 +16,7 @@ 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 { onTypedMessageSubmitted } = (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);
|
|
@@ -33,34 +33,28 @@ const ChatPreviewWidgetHandler = (props) => {
|
|
|
33
33
|
messageText,
|
|
34
34
|
promptButtonTexts
|
|
35
35
|
};
|
|
36
|
+
const { trackEvent } = (0, __envive_ai_react_hooks_contexts_amplitudeContext.useAmplitude)();
|
|
37
|
+
(0, react.useEffect)(() => {
|
|
38
|
+
trackEvent({
|
|
39
|
+
eventName: __envive_ai_react_hooks_contexts_amplitudeContext.SpiffyMetricsEventName.ChatComponentVisible,
|
|
40
|
+
eventProps: {
|
|
41
|
+
widget_config_id: widgetConfigId,
|
|
42
|
+
widget_type: __envive_ai_react_hooks_contexts_typesV3.WidgetTypeV3.ChatPreviewV3
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}, [trackEvent, widgetConfigId]);
|
|
36
46
|
const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc;
|
|
37
47
|
const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
|
|
38
48
|
const handlePromptButtonClick = (0, react.useCallback)((text) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
id: require_v4.default(),
|
|
42
|
-
role: __envive_ai_react_hooks_application_models.MessageRole.User,
|
|
43
|
-
type: __envive_ai_react_hooks_application_models.MessageType.QueryTyped,
|
|
44
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
45
|
-
metadata: { content: text }
|
|
46
|
-
},
|
|
49
|
+
onTypedMessageSubmitted({
|
|
50
|
+
query: text,
|
|
47
51
|
userTyped: false
|
|
48
52
|
});
|
|
49
53
|
openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.CHAT_PREVIEW_PROMPT_BUTTON);
|
|
50
|
-
}, [
|
|
51
|
-
const handleTextFieldClick = (0, react.useCallback)((
|
|
52
|
-
handleReply({
|
|
53
|
-
message: {
|
|
54
|
-
id: require_v4.default(),
|
|
55
|
-
role: __envive_ai_react_hooks_application_models.MessageRole.User,
|
|
56
|
-
type: __envive_ai_react_hooks_application_models.MessageType.QueryTyped,
|
|
57
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
58
|
-
metadata: { content: text }
|
|
59
|
-
},
|
|
60
|
-
userTyped: false
|
|
61
|
-
});
|
|
54
|
+
}, [onTypedMessageSubmitted, openChat]);
|
|
55
|
+
const handleTextFieldClick = (0, react.useCallback)(() => {
|
|
62
56
|
openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.CHAT_PREVIEW_TEXT_FIELD);
|
|
63
|
-
}, [
|
|
57
|
+
}, [openChat]);
|
|
64
58
|
if (isLoading) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ChatPreviewLoadingWidget.ChatPreviewLoadingWidgetWithBaseWidget, {
|
|
65
59
|
widgetConfigId,
|
|
66
60
|
widgetType: __envive_ai_react_hooks_contexts_typesV3.WidgetTypeV3.ChatPreviewLoadingV3
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime13 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_runtime13.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_runtime13.JSX.Element;
|
|
16
16
|
displayName: string;
|
|
17
17
|
};
|
|
18
18
|
//#endregion
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { withBaseWidget } from "../../hocs/withBaseWidget/withBaseWidget.js";
|
|
2
|
-
import v4_default from "../../node_modules/uuid/dist/v4.js";
|
|
3
2
|
import { getMessageText } from "../utils/functions.js";
|
|
4
3
|
import { ChatPreviewLoadingWidgetWithBaseWidget } from "../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.js";
|
|
5
|
-
import { useCallback, useMemo } from "react";
|
|
4
|
+
import { useCallback, useEffect, useMemo } from "react";
|
|
5
|
+
import { SpiffyMetricsEventName, useAmplitude } from "@envive-ai/react-hooks/contexts/amplitudeContext";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
import { WidgetTypeV3 } from "@envive-ai/react-hooks/contexts/typesV3";
|
|
8
|
-
import { useAtomValue
|
|
9
|
-
import {
|
|
8
|
+
import { useAtomValue } from "jotai";
|
|
9
|
+
import { useSalesAgent } from "@envive-ai/react-hooks/contexts/salesAgentContext";
|
|
10
10
|
import { useChatToggle } from "@envive-ai/react-hooks/hooks/ChatToggle";
|
|
11
11
|
import { chatAtom, lastAssistantMessageAtom } from "@envive-ai/react-hooks/atoms/chat";
|
|
12
12
|
import { Theme } from "@envive-ai/react-toolkit-v3/Tokens";
|
|
13
|
-
import { ChatElementDisplayLocationV3
|
|
13
|
+
import { ChatElementDisplayLocationV3 } from "@envive-ai/react-hooks/application/models";
|
|
14
14
|
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 { onTypedMessageSubmitted } = useSalesAgent();
|
|
19
19
|
const { openChat } = useChatToggle();
|
|
20
20
|
const lastAssistantMessage = useAtomValue(lastAssistantMessageAtom);
|
|
21
21
|
const { suggestions } = useAtomValue(chatAtom);
|
|
@@ -32,34 +32,28 @@ const ChatPreviewWidgetHandler = (props) => {
|
|
|
32
32
|
messageText,
|
|
33
33
|
promptButtonTexts
|
|
34
34
|
};
|
|
35
|
+
const { trackEvent } = useAmplitude();
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
trackEvent({
|
|
38
|
+
eventName: SpiffyMetricsEventName.ChatComponentVisible,
|
|
39
|
+
eventProps: {
|
|
40
|
+
widget_config_id: widgetConfigId,
|
|
41
|
+
widget_type: WidgetTypeV3.ChatPreviewV3
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}, [trackEvent, widgetConfigId]);
|
|
35
45
|
const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc;
|
|
36
46
|
const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
|
|
37
47
|
const handlePromptButtonClick = useCallback((text) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
id: v4_default(),
|
|
41
|
-
role: MessageRole.User,
|
|
42
|
-
type: MessageType.QueryTyped,
|
|
43
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
44
|
-
metadata: { content: text }
|
|
45
|
-
},
|
|
48
|
+
onTypedMessageSubmitted({
|
|
49
|
+
query: text,
|
|
46
50
|
userTyped: false
|
|
47
51
|
});
|
|
48
52
|
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_PROMPT_BUTTON);
|
|
49
|
-
}, [
|
|
50
|
-
const handleTextFieldClick = useCallback((
|
|
51
|
-
handleReply({
|
|
52
|
-
message: {
|
|
53
|
-
id: v4_default(),
|
|
54
|
-
role: MessageRole.User,
|
|
55
|
-
type: MessageType.QueryTyped,
|
|
56
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
57
|
-
metadata: { content: text }
|
|
58
|
-
},
|
|
59
|
-
userTyped: false
|
|
60
|
-
});
|
|
53
|
+
}, [onTypedMessageSubmitted, openChat]);
|
|
54
|
+
const handleTextFieldClick = useCallback(() => {
|
|
61
55
|
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_TEXT_FIELD);
|
|
62
|
-
}, [
|
|
56
|
+
}, [openChat]);
|
|
63
57
|
if (isLoading) return /* @__PURE__ */ jsx(ChatPreviewLoadingWidgetWithBaseWidget, {
|
|
64
58
|
widgetConfigId,
|
|
65
59
|
widgetType: WidgetTypeV3.ChatPreviewLoadingV3
|
|
@@ -6,8 +6,8 @@ let classnames = require("classnames");
|
|
|
6
6
|
classnames = require_rolldown_runtime.__toESM(classnames);
|
|
7
7
|
|
|
8
8
|
//#region src/widgets/FloatingChatWidget/FloatingChatOverlay.tsx
|
|
9
|
-
const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestId }) => {
|
|
10
|
-
const overlayClasses = (0, classnames.default)("envive-floating-chat-overlay", "envive-tw-fixed", "envive-tw-top-0", "envive-tw-left-0", "envive-tw-h-screen", "envive-tw-w-full", "envive-tw-z-[2147483647]", className);
|
|
9
|
+
const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestId, previewMode = false }) => {
|
|
10
|
+
const overlayClasses = (0, classnames.default)("envive-floating-chat-overlay", 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
11
|
const backdropClasses = (0, classnames.default)("envive-floating-chat-backdrop", "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
12
|
const overlayContentClasses = (0, classnames.default)("envive-floating-chat-overlay-content", "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, {
|
|
@@ -17,7 +17,7 @@ const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestI
|
|
|
17
17
|
exit: { opacity: 0 },
|
|
18
18
|
transition: { duration: .3 },
|
|
19
19
|
"data-testid": dataTestId,
|
|
20
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(framer_motion.motion.div, {
|
|
20
|
+
children: [!previewMode && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(framer_motion.motion.div, {
|
|
21
21
|
className: backdropClasses,
|
|
22
22
|
initial: { opacity: 0 },
|
|
23
23
|
animate: { opacity: .5 },
|
|
@@ -36,7 +36,7 @@ const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestI
|
|
|
36
36
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(framer_motion.motion.div, {
|
|
37
37
|
initial: {
|
|
38
38
|
opacity: 0,
|
|
39
|
-
x: 512
|
|
39
|
+
x: previewMode ? 0 : 512
|
|
40
40
|
},
|
|
41
41
|
animate: {
|
|
42
42
|
opacity: 1,
|
|
@@ -44,11 +44,11 @@ const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestI
|
|
|
44
44
|
},
|
|
45
45
|
exit: {
|
|
46
46
|
opacity: 0,
|
|
47
|
-
x: 512
|
|
47
|
+
x: previewMode ? 0 : 512
|
|
48
48
|
},
|
|
49
49
|
transition: { duration: .3 },
|
|
50
50
|
style: {
|
|
51
|
-
height: "100dvh",
|
|
51
|
+
height: previewMode ? "100%" : "100dvh",
|
|
52
52
|
cursor: "default"
|
|
53
53
|
},
|
|
54
54
|
className: "envive-tw-shadow-md",
|
|
@@ -57,6 +57,7 @@ const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestI
|
|
|
57
57
|
})
|
|
58
58
|
})]
|
|
59
59
|
}, "floating-chat-overlay") });
|
|
60
|
+
if (previewMode) return chatWrapper;
|
|
60
61
|
if (typeof document !== "undefined") return (0, react_dom.createPortal)(chatWrapper, document.body);
|
|
61
62
|
return chatWrapper;
|
|
62
63
|
};
|
|
@@ -4,8 +4,8 @@ import { AnimatePresence, motion } from "framer-motion";
|
|
|
4
4
|
import classNames from "classnames";
|
|
5
5
|
|
|
6
6
|
//#region src/widgets/FloatingChatWidget/FloatingChatOverlay.tsx
|
|
7
|
-
const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestId }) => {
|
|
8
|
-
const overlayClasses = classNames("envive-floating-chat-overlay", "envive-tw-fixed", "envive-tw-top-0", "envive-tw-left-0", "envive-tw-h-screen", "envive-tw-w-full", "envive-tw-z-[2147483647]", className);
|
|
7
|
+
const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestId, previewMode = false }) => {
|
|
8
|
+
const overlayClasses = classNames("envive-floating-chat-overlay", 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
9
|
const backdropClasses = classNames("envive-floating-chat-backdrop", "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
10
|
const overlayContentClasses = classNames("envive-floating-chat-overlay-content", "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, {
|
|
@@ -15,7 +15,7 @@ const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestI
|
|
|
15
15
|
exit: { opacity: 0 },
|
|
16
16
|
transition: { duration: .3 },
|
|
17
17
|
"data-testid": dataTestId,
|
|
18
|
-
children: [/* @__PURE__ */ jsx(motion.div, {
|
|
18
|
+
children: [!previewMode && /* @__PURE__ */ jsx(motion.div, {
|
|
19
19
|
className: backdropClasses,
|
|
20
20
|
initial: { opacity: 0 },
|
|
21
21
|
animate: { opacity: .5 },
|
|
@@ -34,7 +34,7 @@ const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestI
|
|
|
34
34
|
children: /* @__PURE__ */ jsx(motion.div, {
|
|
35
35
|
initial: {
|
|
36
36
|
opacity: 0,
|
|
37
|
-
x: 512
|
|
37
|
+
x: previewMode ? 0 : 512
|
|
38
38
|
},
|
|
39
39
|
animate: {
|
|
40
40
|
opacity: 1,
|
|
@@ -42,11 +42,11 @@ const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestI
|
|
|
42
42
|
},
|
|
43
43
|
exit: {
|
|
44
44
|
opacity: 0,
|
|
45
|
-
x: 512
|
|
45
|
+
x: previewMode ? 0 : 512
|
|
46
46
|
},
|
|
47
47
|
transition: { duration: .3 },
|
|
48
48
|
style: {
|
|
49
|
-
height: "100dvh",
|
|
49
|
+
height: previewMode ? "100%" : "100dvh",
|
|
50
50
|
cursor: "default"
|
|
51
51
|
},
|
|
52
52
|
className: "envive-tw-shadow-md",
|
|
@@ -55,6 +55,7 @@ const FloatingChatOverlay = ({ children, isOpened, onClose, className, dataTestI
|
|
|
55
55
|
})
|
|
56
56
|
})]
|
|
57
57
|
}, "floating-chat-overlay") });
|
|
58
|
+
if (previewMode) return chatWrapper;
|
|
58
59
|
if (typeof document !== "undefined") return createPortal(chatWrapper, document.body);
|
|
59
60
|
return chatWrapper;
|
|
60
61
|
};
|
|
@@ -6,18 +6,21 @@ const require_useGetWidgetStatus = require('../hooks/useGetWidgetStatus.cjs');
|
|
|
6
6
|
const require_types = require('../../CXIntegration/types.cjs');
|
|
7
7
|
const require_constants = require('./constants.cjs');
|
|
8
8
|
const require_useUnifiedCXButton = require('../../CXIntegration/hooks/useUnifiedCXButton.cjs');
|
|
9
|
+
const require_useFloatingButtonVisibility = require('./hooks/useFloatingButtonVisibility.cjs');
|
|
9
10
|
let react = require("react");
|
|
11
|
+
let __envive_ai_react_hooks_contexts_amplitudeContext = require("@envive-ai/react-hooks/contexts/amplitudeContext");
|
|
10
12
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
13
|
let __envive_ai_react_hooks_contexts_typesV3 = require("@envive-ai/react-hooks/contexts/typesV3");
|
|
14
|
+
let __envive_ai_react_hooks_contexts_salesAgentContext = require("@envive-ai/react-hooks/contexts/salesAgentContext");
|
|
12
15
|
let __envive_ai_react_hooks_hooks_ChatToggle = require("@envive-ai/react-hooks/hooks/ChatToggle");
|
|
13
16
|
let __envive_ai_react_toolkit_v3_Tokens = require("@envive-ai/react-toolkit-v3/Tokens");
|
|
14
17
|
let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
|
|
15
18
|
let __envive_ai_react_toolkit_v3_FloatingChat = require("@envive-ai/react-toolkit-v3/FloatingChat");
|
|
16
|
-
let __envive_ai_react_hooks_contexts_salesAgentContext = require("@envive-ai/react-hooks/contexts/salesAgentContext");
|
|
17
19
|
let __envive_ai_react_toolkit_v3_FloatingButton = require("@envive-ai/react-toolkit-v3/FloatingButton");
|
|
18
20
|
|
|
19
21
|
//#region src/widgets/FloatingChatWidget/FloatingChatWidget.tsx
|
|
20
22
|
const FloatingChatWidgetHandler = (props) => {
|
|
23
|
+
const { previewButtonOnly, previewChatAlwaysOpen } = props;
|
|
21
24
|
const salesAgentData = (0, __envive_ai_react_hooks_contexts_salesAgentContext.useSalesAgent)();
|
|
22
25
|
const { userHasInteractedValue } = require_useGetWidgetStatus.default();
|
|
23
26
|
const { uiConfig, isUiConfigLoading } = props;
|
|
@@ -26,42 +29,68 @@ const FloatingChatWidgetHandler = (props) => {
|
|
|
26
29
|
enabled: false,
|
|
27
30
|
suppressMerchantButton: false
|
|
28
31
|
}) ?? {};
|
|
32
|
+
const { floatingButton } = uiConfig ?? {};
|
|
29
33
|
const { isOpen, openChat, closeChat } = (0, __envive_ai_react_hooks_hooks_ChatToggle.useChatToggle)();
|
|
34
|
+
const { shouldShowFloatingButton } = require_useFloatingButtonVisibility.useFloatingButtonVisibility({
|
|
35
|
+
floatingButtonShowConfig: floatingButton?.showOption,
|
|
36
|
+
isChatOpen: isOpen,
|
|
37
|
+
userHasInteracted: userHasInteractedValue
|
|
38
|
+
});
|
|
39
|
+
const effectiveIsOpen = previewChatAlwaysOpen ? true : isOpen;
|
|
40
|
+
const buttonShouldRender = previewButtonOnly ? true : !isOpen && shouldShowFloatingButton;
|
|
30
41
|
const theme = (0, react.useMemo)(() => {
|
|
31
42
|
if (isUiConfigLoading || !uiConfig) return __envive_ai_react_toolkit_v3_Tokens.Theme.STANDARD;
|
|
32
43
|
return uiConfig?.lookAndFeel?.theme ?? __envive_ai_react_toolkit_v3_Tokens.Theme.GLOBAL_CUSTOM;
|
|
33
44
|
}, [isUiConfigLoading, uiConfig]);
|
|
34
|
-
const {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
45
|
+
const { trackEvent } = (0, __envive_ai_react_hooks_contexts_amplitudeContext.useAmplitude)();
|
|
46
|
+
const hasTrackedEvent = (0, react.useRef)(false);
|
|
47
|
+
(0, react.useEffect)(() => {
|
|
48
|
+
if (buttonShouldRender && !hasTrackedEvent.current) {
|
|
49
|
+
trackEvent({
|
|
50
|
+
eventName: __envive_ai_react_hooks_contexts_amplitudeContext.SpiffyMetricsEventName.ChatComponentVisible,
|
|
51
|
+
eventProps: {
|
|
52
|
+
widget_config_id: "floating-button",
|
|
53
|
+
widget_type: __envive_ai_react_hooks_contexts_typesV3.WidgetTypeV3.FloatingButtonV3
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
hasTrackedEvent.current = true;
|
|
57
|
+
}
|
|
58
|
+
}, [trackEvent, buttonShouldRender]);
|
|
59
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(previewChatAlwaysOpen || effectiveIsOpen) && !previewButtonOnly && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FloatingChatOverlay.FloatingChatOverlay, {
|
|
60
|
+
isOpened: effectiveIsOpen,
|
|
61
|
+
onClose: previewChatAlwaysOpen ? () => {} : () => closeChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.FLOATING_CHAT_OVERLAY),
|
|
62
|
+
previewMode: !!previewChatAlwaysOpen,
|
|
38
63
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__envive_ai_react_toolkit_v3_FloatingChat.FloatingChat, {
|
|
39
64
|
theme,
|
|
40
65
|
salesAgentData,
|
|
41
66
|
floatingChatConfig: uiConfig?.floatingChat ?? {},
|
|
42
67
|
lookAndFeelConfig: uiConfig?.lookAndFeel ?? {},
|
|
43
68
|
isCXButtonSwitchEnabled: !!isSwitchEnabled?.(),
|
|
69
|
+
isFloatingChatOpen: effectiveIsOpen,
|
|
44
70
|
onToggleCXButton: toggle,
|
|
45
|
-
onClose: () => closeChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.FLOATING_CHAT_CLOSE_BUTTON)
|
|
71
|
+
onClose: previewChatAlwaysOpen ? () => {} : () => closeChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.FLOATING_CHAT_CLOSE_BUTTON)
|
|
46
72
|
})
|
|
47
|
-
}),
|
|
73
|
+
}), buttonShouldRender && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__envive_ai_react_toolkit_v3_FloatingButton.FloatingButton, {
|
|
48
74
|
id: require_constants.FLOATING_BUTTON_ID,
|
|
49
75
|
variant: floatingButton?.style,
|
|
50
76
|
mode: floatingButton?.mode,
|
|
51
77
|
backgroundColor: floatingButton?.backgroundColor,
|
|
52
|
-
onClick: () => openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.FLOATING_BUTTON),
|
|
78
|
+
onClick: previewButtonOnly ? () => {} : () => openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.FLOATING_BUTTON),
|
|
53
79
|
customIcon: floatingButton?.iconSVGSrc,
|
|
54
80
|
show: floatingButton?.showOption,
|
|
55
81
|
location: floatingButton?.position,
|
|
56
82
|
hasInteractionHappened: userHasInteractedValue,
|
|
57
|
-
ariaLabel: "Open chat"
|
|
83
|
+
ariaLabel: "Open chat",
|
|
84
|
+
previewMode: !!previewButtonOnly
|
|
58
85
|
})] });
|
|
59
86
|
};
|
|
60
87
|
const FloatingChatWidgetWithBaseWidget = require_withBaseWidget.withBaseWidget(FloatingChatWidgetHandler);
|
|
61
|
-
const FloatingChatWidget = () => {
|
|
88
|
+
const FloatingChatWidget = ({ previewButtonOnly, previewChatAlwaysOpen } = {}) => {
|
|
62
89
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FloatingChatWidgetWithBaseWidget, {
|
|
63
90
|
widgetType: __envive_ai_react_hooks_contexts_typesV3.WidgetTypeV3.FloatingChatV3,
|
|
64
|
-
widgetConfigId: "fake-widget-config-id"
|
|
91
|
+
widgetConfigId: "fake-widget-config-id",
|
|
92
|
+
previewButtonOnly,
|
|
93
|
+
previewChatAlwaysOpen
|
|
65
94
|
});
|
|
66
95
|
};
|
|
67
96
|
FloatingChatWidget.displayName = "FloatingChatWidget";
|