@envive-ai/react-widgets-v3 0.3.5 → 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/types.d.cts +3 -3
- package/dist/hocs/withBaseWidget/types.d.ts +3 -5
- 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.cts +3 -3
- 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 +9 -3
- 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.d.cts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +3 -3
- 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.d.ts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +19 -16
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.cjs +1 -1
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.js +1 -1
- package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +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.cjs +1 -1
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.cts +2 -2
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.js +1 -1
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.cjs +17 -13
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +19 -15
- package/dist/widgets/dist/SearchResults/SearchResults.d.cts +2 -3
- package/dist/{packages/widgets → widgets}/dist/SearchResults/SearchResults.d.ts +2 -3
- 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/SearchZeroState/index.d.ts +3 -0
- package/dist/widgets/dist/SearchZeroState/types.d.cts +2 -2
- package/dist/{packages/widgets → widgets}/dist/SearchZeroState/types.d.ts +2 -2
- package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.cts +1 -1
- package/dist/{packages/widgets → widgets}/dist/SuggestionBar/SuggestionBar.d.ts +1 -1
- package/dist/widgets/dist/SuggestionButtonContainer/types.d.cts +2 -3
- package/dist/{packages/widgets → widgets}/dist/SuggestionButtonContainer/types.d.ts +2 -3
- package/dist/widgets-v2/SearchResults/index.d.ts +3 -3
- package/dist/widgets-v2/SearchZeroState/index.d.cts +1 -2
- package/dist/widgets-v2/SearchZeroState/index.d.ts +4 -5
- 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/hooks/dist/contexts/hardcopyContext/hardcopyContext.d.cts +0 -8
- package/dist/hooks/dist/contexts/types.d.cts +0 -44
- package/dist/hooks/dist/contexts/typesV3.d.cts +0 -201
- package/dist/hooks/dist/services/amplitudeService/amplitudeService.d.cts +0 -36
- package/dist/hooks/dist/types/customerService.d.cts +0 -18
- 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/hooks/dist/application/models/api/orgConfigResults.d.ts +0 -1
- package/dist/packages/hooks/dist/application/models/frontendConfig.d.ts +0 -1
- package/dist/packages/hooks/dist/contexts/amplitudeContext/amplitudeContext.d.ts +0 -2
- package/dist/packages/hooks/dist/contexts/amplitudeContext/index.d.ts +0 -2
- package/dist/packages/hooks/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.d.ts +0 -2
- package/dist/packages/hooks/dist/contexts/hardcopyContext/hardcopyContext.d.ts +0 -11
- package/dist/packages/hooks/dist/contexts/hardcopyContext/index.d.ts +0 -1
- package/dist/packages/hooks/dist/contexts/types.d.ts +0 -47
- package/dist/packages/hooks/dist/contexts/typesV3.d.ts +0 -201
- package/dist/packages/hooks/dist/services/amplitudeService/amplitudeService.d.ts +0 -37
- package/dist/packages/hooks/dist/types/customerService.d.ts +0 -18
- package/dist/packages/widgets/dist/SearchZeroState/index.d.ts +0 -4
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/api/response.d.ts +0 -14
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/api/search.d.ts +0 -15
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/camelCase.d.ts +0 -73
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/camelCasedPropertiesDeep.d.ts +0 -61
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/internal.d.ts +0 -25
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/splitWords.d.ts +0 -35
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/trim.d.ts +0 -32
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/unknownArray.d.ts +0 -32
- package/dist/packages/widgets/dist/packages/hooks/dist/atoms/search/searchAPI.d.ts +0 -15
- package/dist/packages/widgets/dist/packages/hooks/dist/contexts/types.d.ts +0 -61
- package/dist/packages/widgets/dist/packages/hooks/dist/hooks/Search/useSearch.d.ts +0 -60
- package/dist/packages/widgets/dist/packages/hooks/dist/hooks/utils.d.ts +0 -11
- package/dist/packages/widgets/dist/packages/hooks/dist/types/search-filter-types.d.ts +0 -28
- package/dist/packages/widgets/dist/packages/hooks/dist/types/test-types.d.ts +0 -10
- package/dist/widgets/dist/packages/hooks/dist/application/models/api/response.d.cts +0 -14
- package/dist/widgets/dist/packages/hooks/dist/application/models/api/search.d.cts +0 -15
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/camelCase.d.cts +0 -73
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/camelCasedPropertiesDeep.d.cts +0 -61
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/internal.d.cts +0 -25
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/splitWords.d.cts +0 -35
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/trim.d.cts +0 -32
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/unknownArray.d.cts +0 -32
- package/dist/widgets/dist/packages/hooks/dist/atoms/search/searchAPI.d.cts +0 -14
- package/dist/widgets/dist/packages/hooks/dist/contexts/types.d.cts +0 -61
- package/dist/widgets/dist/packages/hooks/dist/hooks/Search/useSearch.d.cts +0 -60
- package/dist/widgets/dist/packages/hooks/dist/hooks/utils.d.cts +0 -11
- package/dist/widgets/dist/packages/hooks/dist/types/search-filter-types.d.cts +0 -28
- package/dist/widgets/dist/packages/hooks/dist/types/test-types.d.cts +0 -10
- /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/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/config/BaseWidgetConfig.d.ts +0 -0
- /package/dist/{packages/widgets → widgets}/dist/config/WidgetType.d.ts +0 -0
|
@@ -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";
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime13 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/widgets/FloatingChatWidget/FloatingChatWidget.d.ts
|
|
4
|
-
interface FloatingChatWidgetProps {
|
|
4
|
+
interface FloatingChatWidgetProps {
|
|
5
|
+
previewButtonOnly?: boolean;
|
|
6
|
+
previewChatAlwaysOpen?: boolean;
|
|
7
|
+
}
|
|
5
8
|
declare const FloatingChatWidget: {
|
|
6
|
-
(
|
|
9
|
+
({
|
|
10
|
+
previewButtonOnly,
|
|
11
|
+
previewChatAlwaysOpen
|
|
12
|
+
}?: FloatingChatWidgetProps): react_jsx_runtime13.JSX.Element;
|
|
7
13
|
displayName: string;
|
|
8
14
|
};
|
|
9
15
|
//#endregion
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime7 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/widgets/FloatingChatWidget/FloatingChatWidget.d.ts
|
|
4
|
-
interface FloatingChatWidgetProps {
|
|
4
|
+
interface FloatingChatWidgetProps {
|
|
5
|
+
previewButtonOnly?: boolean;
|
|
6
|
+
previewChatAlwaysOpen?: boolean;
|
|
7
|
+
}
|
|
5
8
|
declare const FloatingChatWidget: {
|
|
6
|
-
(
|
|
9
|
+
({
|
|
10
|
+
previewButtonOnly,
|
|
11
|
+
previewChatAlwaysOpen
|
|
12
|
+
}?: FloatingChatWidgetProps): react_jsx_runtime7.JSX.Element;
|
|
7
13
|
displayName: string;
|
|
8
14
|
};
|
|
9
15
|
//#endregion
|
|
@@ -5,18 +5,21 @@ import useGetWidgetStatus_default from "../hooks/useGetWidgetStatus.js";
|
|
|
5
5
|
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
|
-
import {
|
|
8
|
+
import { useFloatingButtonVisibility } from "./hooks/useFloatingButtonVisibility.js";
|
|
9
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
10
|
+
import { SpiffyMetricsEventName, useAmplitude } from "@envive-ai/react-hooks/contexts/amplitudeContext";
|
|
9
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
12
|
import { WidgetTypeV3 } from "@envive-ai/react-hooks/contexts/typesV3";
|
|
13
|
+
import { useSalesAgent } from "@envive-ai/react-hooks/contexts/salesAgentContext";
|
|
11
14
|
import { useChatToggle } from "@envive-ai/react-hooks/hooks/ChatToggle";
|
|
12
15
|
import { Theme } from "@envive-ai/react-toolkit-v3/Tokens";
|
|
13
16
|
import { ChatElementDisplayLocationV3 } from "@envive-ai/react-hooks/application/models";
|
|
14
17
|
import { FloatingChat } from "@envive-ai/react-toolkit-v3/FloatingChat";
|
|
15
|
-
import { useSalesAgent } from "@envive-ai/react-hooks/contexts/salesAgentContext";
|
|
16
18
|
import { FloatingButton } from "@envive-ai/react-toolkit-v3/FloatingButton";
|
|
17
19
|
|
|
18
20
|
//#region src/widgets/FloatingChatWidget/FloatingChatWidget.tsx
|
|
19
21
|
const FloatingChatWidgetHandler = (props) => {
|
|
22
|
+
const { previewButtonOnly, previewChatAlwaysOpen } = props;
|
|
20
23
|
const salesAgentData = useSalesAgent();
|
|
21
24
|
const { userHasInteractedValue } = useGetWidgetStatus_default();
|
|
22
25
|
const { uiConfig, isUiConfigLoading } = props;
|
|
@@ -25,42 +28,68 @@ const FloatingChatWidgetHandler = (props) => {
|
|
|
25
28
|
enabled: false,
|
|
26
29
|
suppressMerchantButton: false
|
|
27
30
|
}) ?? {};
|
|
31
|
+
const { floatingButton } = uiConfig ?? {};
|
|
28
32
|
const { isOpen, openChat, closeChat } = useChatToggle();
|
|
33
|
+
const { shouldShowFloatingButton } = useFloatingButtonVisibility({
|
|
34
|
+
floatingButtonShowConfig: floatingButton?.showOption,
|
|
35
|
+
isChatOpen: isOpen,
|
|
36
|
+
userHasInteracted: userHasInteractedValue
|
|
37
|
+
});
|
|
38
|
+
const effectiveIsOpen = previewChatAlwaysOpen ? true : isOpen;
|
|
39
|
+
const buttonShouldRender = previewButtonOnly ? true : !isOpen && shouldShowFloatingButton;
|
|
29
40
|
const theme = useMemo(() => {
|
|
30
41
|
if (isUiConfigLoading || !uiConfig) return Theme.STANDARD;
|
|
31
42
|
return uiConfig?.lookAndFeel?.theme ?? Theme.GLOBAL_CUSTOM;
|
|
32
43
|
}, [isUiConfigLoading, uiConfig]);
|
|
33
|
-
const {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
44
|
+
const { trackEvent } = useAmplitude();
|
|
45
|
+
const hasTrackedEvent = useRef(false);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (buttonShouldRender && !hasTrackedEvent.current) {
|
|
48
|
+
trackEvent({
|
|
49
|
+
eventName: SpiffyMetricsEventName.ChatComponentVisible,
|
|
50
|
+
eventProps: {
|
|
51
|
+
widget_config_id: "floating-button",
|
|
52
|
+
widget_type: WidgetTypeV3.FloatingButtonV3
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
hasTrackedEvent.current = true;
|
|
56
|
+
}
|
|
57
|
+
}, [trackEvent, buttonShouldRender]);
|
|
58
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [(previewChatAlwaysOpen || effectiveIsOpen) && !previewButtonOnly && /* @__PURE__ */ jsx(FloatingChatOverlay, {
|
|
59
|
+
isOpened: effectiveIsOpen,
|
|
60
|
+
onClose: previewChatAlwaysOpen ? () => {} : () => closeChat(ChatElementDisplayLocationV3.FLOATING_CHAT_OVERLAY),
|
|
61
|
+
previewMode: !!previewChatAlwaysOpen,
|
|
37
62
|
children: /* @__PURE__ */ jsx(FloatingChat, {
|
|
38
63
|
theme,
|
|
39
64
|
salesAgentData,
|
|
40
65
|
floatingChatConfig: uiConfig?.floatingChat ?? {},
|
|
41
66
|
lookAndFeelConfig: uiConfig?.lookAndFeel ?? {},
|
|
42
67
|
isCXButtonSwitchEnabled: !!isSwitchEnabled?.(),
|
|
68
|
+
isFloatingChatOpen: effectiveIsOpen,
|
|
43
69
|
onToggleCXButton: toggle,
|
|
44
|
-
onClose: () => closeChat(ChatElementDisplayLocationV3.FLOATING_CHAT_CLOSE_BUTTON)
|
|
70
|
+
onClose: previewChatAlwaysOpen ? () => {} : () => closeChat(ChatElementDisplayLocationV3.FLOATING_CHAT_CLOSE_BUTTON)
|
|
45
71
|
})
|
|
46
|
-
}),
|
|
72
|
+
}), buttonShouldRender && /* @__PURE__ */ jsx(FloatingButton, {
|
|
47
73
|
id: FLOATING_BUTTON_ID,
|
|
48
74
|
variant: floatingButton?.style,
|
|
49
75
|
mode: floatingButton?.mode,
|
|
50
76
|
backgroundColor: floatingButton?.backgroundColor,
|
|
51
|
-
onClick: () => openChat(ChatElementDisplayLocationV3.FLOATING_BUTTON),
|
|
77
|
+
onClick: previewButtonOnly ? () => {} : () => openChat(ChatElementDisplayLocationV3.FLOATING_BUTTON),
|
|
52
78
|
customIcon: floatingButton?.iconSVGSrc,
|
|
53
79
|
show: floatingButton?.showOption,
|
|
54
80
|
location: floatingButton?.position,
|
|
55
81
|
hasInteractionHappened: userHasInteractedValue,
|
|
56
|
-
ariaLabel: "Open chat"
|
|
82
|
+
ariaLabel: "Open chat",
|
|
83
|
+
previewMode: !!previewButtonOnly
|
|
57
84
|
})] });
|
|
58
85
|
};
|
|
59
86
|
const FloatingChatWidgetWithBaseWidget = withBaseWidget(FloatingChatWidgetHandler);
|
|
60
|
-
const FloatingChatWidget = () => {
|
|
87
|
+
const FloatingChatWidget = ({ previewButtonOnly, previewChatAlwaysOpen } = {}) => {
|
|
61
88
|
return /* @__PURE__ */ jsx(FloatingChatWidgetWithBaseWidget, {
|
|
62
89
|
widgetType: WidgetTypeV3.FloatingChatV3,
|
|
63
|
-
widgetConfigId: "fake-widget-config-id"
|
|
90
|
+
widgetConfigId: "fake-widget-config-id",
|
|
91
|
+
previewButtonOnly,
|
|
92
|
+
previewChatAlwaysOpen
|
|
64
93
|
});
|
|
65
94
|
};
|
|
66
95
|
FloatingChatWidget.displayName = "FloatingChatWidget";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let react = require("react");
|
|
3
|
+
let jotai = require("jotai");
|
|
4
|
+
let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
|
|
5
|
+
let __envive_ai_react_toolkit_v3_FloatingButton = require("@envive-ai/react-toolkit-v3/FloatingButton");
|
|
6
|
+
let __envive_ai_react_hooks_atoms_org = require("@envive-ai/react-hooks/atoms/org");
|
|
7
|
+
|
|
8
|
+
//#region src/widgets/FloatingChatWidget/hooks/useFloatingButtonVisibility.ts
|
|
9
|
+
const useFloatingButtonVisibility = ({ floatingButtonShowConfig = __envive_ai_react_toolkit_v3_FloatingButton.FloatingButtonShow.ALWAYS, isChatOpen, userHasInteracted }) => {
|
|
10
|
+
const featureFlagService = (0, jotai.useAtomValue)(__envive_ai_react_hooks_atoms_org.featureFlagServiceAtom);
|
|
11
|
+
const isSalesAgentEnabled = (0, react.useMemo)(() => featureFlagService?.featureFlagService?.isFeatureGateEnabled(__envive_ai_react_hooks_application_models.FeatureGates.IsSalesAgentEnabled), [featureFlagService]);
|
|
12
|
+
return {
|
|
13
|
+
shouldShowFloatingButton: (isSalesAgentEnabled || isSalesAgentEnabled === void 0) && !isChatOpen && (floatingButtonShowConfig === __envive_ai_react_toolkit_v3_FloatingButton.FloatingButtonShow.ALWAYS || floatingButtonShowConfig === __envive_ai_react_toolkit_v3_FloatingButton.FloatingButtonShow.POST_INTERACTION && userHasInteracted),
|
|
14
|
+
isSalesAgentEnabled
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.useFloatingButtonVisibility = useFloatingButtonVisibility;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useAtomValue } from "jotai";
|
|
3
|
+
import { FeatureGates } from "@envive-ai/react-hooks/application/models";
|
|
4
|
+
import { FloatingButtonShow } from "@envive-ai/react-toolkit-v3/FloatingButton";
|
|
5
|
+
import { featureFlagServiceAtom } from "@envive-ai/react-hooks/atoms/org";
|
|
6
|
+
|
|
7
|
+
//#region src/widgets/FloatingChatWidget/hooks/useFloatingButtonVisibility.ts
|
|
8
|
+
const useFloatingButtonVisibility = ({ floatingButtonShowConfig = FloatingButtonShow.ALWAYS, isChatOpen, userHasInteracted }) => {
|
|
9
|
+
const featureFlagService = useAtomValue(featureFlagServiceAtom);
|
|
10
|
+
const isSalesAgentEnabled = useMemo(() => featureFlagService?.featureFlagService?.isFeatureGateEnabled(FeatureGates.IsSalesAgentEnabled), [featureFlagService]);
|
|
11
|
+
return {
|
|
12
|
+
shouldShowFloatingButton: (isSalesAgentEnabled || isSalesAgentEnabled === void 0) && !isChatOpen && (floatingButtonShowConfig === FloatingButtonShow.ALWAYS || floatingButtonShowConfig === FloatingButtonShow.POST_INTERACTION && userHasInteracted),
|
|
13
|
+
isSalesAgentEnabled
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { useFloatingButtonVisibility };
|
package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
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
|
let react = require("react");
|
|
4
|
+
let __envive_ai_react_hooks_contexts_amplitudeContext = require("@envive-ai/react-hooks/contexts/amplitudeContext");
|
|
5
5
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
6
|
let __envive_ai_react_hooks_contexts_typesV3 = require("@envive-ai/react-hooks/contexts/typesV3");
|
|
7
|
-
let
|
|
8
|
-
let __envive_ai_react_hooks_atoms_chat_replies = require("@envive-ai/react-hooks/atoms/chat/replies");
|
|
7
|
+
let __envive_ai_react_hooks_contexts_salesAgentContext = require("@envive-ai/react-hooks/contexts/salesAgentContext");
|
|
9
8
|
let __envive_ai_react_hooks_hooks_ChatToggle = require("@envive-ai/react-hooks/hooks/ChatToggle");
|
|
10
9
|
let __envive_ai_react_toolkit_v3_Tokens = require("@envive-ai/react-toolkit-v3/Tokens");
|
|
11
10
|
let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
|
|
@@ -13,9 +12,9 @@ let __envive_ai_react_toolkit_v3_PromptButtonCarouselWithImage = require("@enviv
|
|
|
13
12
|
|
|
14
13
|
//#region src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx
|
|
15
14
|
const PromptButtonCarouselWithImageWidgetHandler = (props) => {
|
|
16
|
-
const
|
|
15
|
+
const { onTypedMessageSubmitted } = (0, __envive_ai_react_hooks_contexts_salesAgentContext.useSalesAgent)();
|
|
17
16
|
const { openChat } = (0, __envive_ai_react_hooks_hooks_ChatToggle.useChatToggle)();
|
|
18
|
-
const { hardcopyContent, widgetConfig, isLoading } = props;
|
|
17
|
+
const { hardcopyContent, widgetConfig, isLoading, widgetConfigId } = props;
|
|
19
18
|
const promptButtonCarouselWithImageWidgetConfig = widgetConfig;
|
|
20
19
|
const id = widgetConfig?.contentId;
|
|
21
20
|
const hardCopyContent = {
|
|
@@ -23,32 +22,26 @@ const PromptButtonCarouselWithImageWidgetHandler = (props) => {
|
|
|
23
22
|
promptButtonsTexts: hardcopyContent?.values?.promptButtonsTexts,
|
|
24
23
|
textFieldPlaceholder: hardcopyContent?.values?.textFieldPlaceholderText
|
|
25
24
|
};
|
|
25
|
+
const { trackEvent } = (0, __envive_ai_react_hooks_contexts_amplitudeContext.useAmplitude)();
|
|
26
|
+
(0, react.useEffect)(() => {
|
|
27
|
+
trackEvent({
|
|
28
|
+
eventName: __envive_ai_react_hooks_contexts_amplitudeContext.SpiffyMetricsEventName.ChatComponentVisible,
|
|
29
|
+
eventProps: {
|
|
30
|
+
widget_config_id: widgetConfigId,
|
|
31
|
+
widget_type: __envive_ai_react_hooks_contexts_typesV3.WidgetTypeV3.PromptButtonCarouselWithImageV3
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}, [trackEvent, widgetConfigId]);
|
|
26
35
|
const handlePromptButtonClick = (0, react.useCallback)((text) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
id: require_v4.default(),
|
|
30
|
-
role: __envive_ai_react_hooks_application_models.MessageRole.User,
|
|
31
|
-
type: __envive_ai_react_hooks_application_models.MessageType.QueryTyped,
|
|
32
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
33
|
-
metadata: { content: text }
|
|
34
|
-
},
|
|
36
|
+
onTypedMessageSubmitted({
|
|
37
|
+
query: text,
|
|
35
38
|
userTyped: false
|
|
36
39
|
});
|
|
37
40
|
openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.PROMPT_BUTTON_CAROUSEL_WITH_IMAGE_PROMPT_BUTTON);
|
|
38
|
-
}, [
|
|
39
|
-
const handleTextFieldClick = (0, react.useCallback)((
|
|
40
|
-
handleReply({
|
|
41
|
-
message: {
|
|
42
|
-
id: require_v4.default(),
|
|
43
|
-
role: __envive_ai_react_hooks_application_models.MessageRole.User,
|
|
44
|
-
type: __envive_ai_react_hooks_application_models.MessageType.QueryTyped,
|
|
45
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
46
|
-
metadata: { content: text }
|
|
47
|
-
},
|
|
48
|
-
userTyped: false
|
|
49
|
-
});
|
|
41
|
+
}, [onTypedMessageSubmitted, openChat]);
|
|
42
|
+
const handleTextFieldClick = (0, react.useCallback)(() => {
|
|
50
43
|
openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.PROMPT_BUTTON_CAROUSEL_WITH_IMAGE_TEXT_FIELD);
|
|
51
|
-
}, [
|
|
44
|
+
}, [openChat]);
|
|
52
45
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__envive_ai_react_toolkit_v3_PromptButtonCarouselWithImage.PromptButtonCarouselWithImage, {
|
|
53
46
|
id,
|
|
54
47
|
theme: __envive_ai_react_toolkit_v3_Tokens.Theme.GLOBAL_CUSTOM,
|
package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime7 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts
|
|
5
5
|
declare const PromptButtonCarouselWithImageWidgetWithBaseWidget: {
|
|
6
|
-
(props: BaseWidgetProps):
|
|
6
|
+
(props: BaseWidgetProps): react_jsx_runtime7.JSX.Element;
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
interface PromptButtonCarouselWithImageWidgetProps {
|
|
@@ -12,7 +12,7 @@ interface PromptButtonCarouselWithImageWidgetProps {
|
|
|
12
12
|
declare const PromptButtonCarouselWithImageWidget: {
|
|
13
13
|
({
|
|
14
14
|
widgetConfigId
|
|
15
|
-
}: PromptButtonCarouselWithImageWidgetProps):
|
|
15
|
+
}: PromptButtonCarouselWithImageWidgetProps): react_jsx_runtime7.JSX.Element;
|
|
16
16
|
displayName: string;
|
|
17
17
|
};
|
|
18
18
|
//#endregion
|
package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts
CHANGED
|
@@ -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/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts
|
|
5
5
|
declare const PromptButtonCarouselWithImageWidgetWithBaseWidget: {
|
|
6
|
-
(props: BaseWidgetProps):
|
|
6
|
+
(props: BaseWidgetProps): react_jsx_runtime9.JSX.Element;
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
interface PromptButtonCarouselWithImageWidgetProps {
|
|
@@ -12,7 +12,7 @@ interface PromptButtonCarouselWithImageWidgetProps {
|
|
|
12
12
|
declare const PromptButtonCarouselWithImageWidget: {
|
|
13
13
|
({
|
|
14
14
|
widgetConfigId
|
|
15
|
-
}: PromptButtonCarouselWithImageWidgetProps):
|
|
15
|
+
}: PromptButtonCarouselWithImageWidgetProps): react_jsx_runtime9.JSX.Element;
|
|
16
16
|
displayName: string;
|
|
17
17
|
};
|
|
18
18
|
//#endregion
|
package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { withBaseWidget } from "../../hocs/withBaseWidget/withBaseWidget.js";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import { useCallback, useEffect } from "react";
|
|
3
|
+
import { SpiffyMetricsEventName, useAmplitude } from "@envive-ai/react-hooks/contexts/amplitudeContext";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { WidgetTypeV3 } from "@envive-ai/react-hooks/contexts/typesV3";
|
|
6
|
-
import {
|
|
7
|
-
import { handleReplyAtom } from "@envive-ai/react-hooks/atoms/chat/replies";
|
|
6
|
+
import { useSalesAgent } from "@envive-ai/react-hooks/contexts/salesAgentContext";
|
|
8
7
|
import { useChatToggle } from "@envive-ai/react-hooks/hooks/ChatToggle";
|
|
9
8
|
import { Theme } from "@envive-ai/react-toolkit-v3/Tokens";
|
|
10
|
-
import { ChatElementDisplayLocationV3
|
|
9
|
+
import { ChatElementDisplayLocationV3 } from "@envive-ai/react-hooks/application/models";
|
|
11
10
|
import { PromptButtonCarouselWithImage } from "@envive-ai/react-toolkit-v3/PromptButtonCarouselWithImage";
|
|
12
11
|
|
|
13
12
|
//#region src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx
|
|
14
13
|
const PromptButtonCarouselWithImageWidgetHandler = (props) => {
|
|
15
|
-
const
|
|
14
|
+
const { onTypedMessageSubmitted } = useSalesAgent();
|
|
16
15
|
const { openChat } = useChatToggle();
|
|
17
|
-
const { hardcopyContent, widgetConfig, isLoading } = props;
|
|
16
|
+
const { hardcopyContent, widgetConfig, isLoading, widgetConfigId } = props;
|
|
18
17
|
const promptButtonCarouselWithImageWidgetConfig = widgetConfig;
|
|
19
18
|
const id = widgetConfig?.contentId;
|
|
20
19
|
const hardCopyContent = {
|
|
@@ -22,32 +21,26 @@ const PromptButtonCarouselWithImageWidgetHandler = (props) => {
|
|
|
22
21
|
promptButtonsTexts: hardcopyContent?.values?.promptButtonsTexts,
|
|
23
22
|
textFieldPlaceholder: hardcopyContent?.values?.textFieldPlaceholderText
|
|
24
23
|
};
|
|
24
|
+
const { trackEvent } = useAmplitude();
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
trackEvent({
|
|
27
|
+
eventName: SpiffyMetricsEventName.ChatComponentVisible,
|
|
28
|
+
eventProps: {
|
|
29
|
+
widget_config_id: widgetConfigId,
|
|
30
|
+
widget_type: WidgetTypeV3.PromptButtonCarouselWithImageV3
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}, [trackEvent, widgetConfigId]);
|
|
25
34
|
const handlePromptButtonClick = useCallback((text) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
id: v4_default(),
|
|
29
|
-
role: MessageRole.User,
|
|
30
|
-
type: MessageType.QueryTyped,
|
|
31
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
32
|
-
metadata: { content: text }
|
|
33
|
-
},
|
|
35
|
+
onTypedMessageSubmitted({
|
|
36
|
+
query: text,
|
|
34
37
|
userTyped: false
|
|
35
38
|
});
|
|
36
39
|
openChat(ChatElementDisplayLocationV3.PROMPT_BUTTON_CAROUSEL_WITH_IMAGE_PROMPT_BUTTON);
|
|
37
|
-
}, [
|
|
38
|
-
const handleTextFieldClick = useCallback((
|
|
39
|
-
handleReply({
|
|
40
|
-
message: {
|
|
41
|
-
id: v4_default(),
|
|
42
|
-
role: MessageRole.User,
|
|
43
|
-
type: MessageType.QueryTyped,
|
|
44
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
45
|
-
metadata: { content: text }
|
|
46
|
-
},
|
|
47
|
-
userTyped: false
|
|
48
|
-
});
|
|
40
|
+
}, [onTypedMessageSubmitted, openChat]);
|
|
41
|
+
const handleTextFieldClick = useCallback(() => {
|
|
49
42
|
openChat(ChatElementDisplayLocationV3.PROMPT_BUTTON_CAROUSEL_WITH_IMAGE_TEXT_FIELD);
|
|
50
|
-
}, [
|
|
43
|
+
}, [openChat]);
|
|
51
44
|
return /* @__PURE__ */ jsx(PromptButtonCarouselWithImage, {
|
|
52
45
|
id,
|
|
53
46
|
theme: Theme.GLOBAL_CUSTOM,
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_withBaseWidget = require('../../hocs/withBaseWidget/withBaseWidget.cjs');
|
|
3
3
|
require('../../hocs/withBaseWidget/index.cjs');
|
|
4
|
-
const require_v4 = require('../../node_modules/uuid/dist-node/v4.cjs');
|
|
5
4
|
let react = require("react");
|
|
5
|
+
let __envive_ai_react_hooks_contexts_amplitudeContext = require("@envive-ai/react-hooks/contexts/amplitudeContext");
|
|
6
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
7
|
let __envive_ai_react_hooks_contexts_typesV3 = require("@envive-ai/react-hooks/contexts/typesV3");
|
|
8
|
-
let
|
|
9
|
-
let __envive_ai_react_hooks_atoms_chat_replies = require("@envive-ai/react-hooks/atoms/chat/replies");
|
|
8
|
+
let __envive_ai_react_hooks_contexts_salesAgentContext = require("@envive-ai/react-hooks/contexts/salesAgentContext");
|
|
10
9
|
let __envive_ai_react_hooks_hooks_ChatToggle = require("@envive-ai/react-hooks/hooks/ChatToggle");
|
|
11
10
|
let __envive_ai_react_toolkit_v3_Tokens = require("@envive-ai/react-toolkit-v3/Tokens");
|
|
12
11
|
let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
|
|
@@ -22,9 +21,9 @@ const mockButtonTexts = [
|
|
|
22
21
|
"Loading button 5"
|
|
23
22
|
];
|
|
24
23
|
const PromptCarouselWidgetHandler = (props) => {
|
|
25
|
-
const
|
|
24
|
+
const { onTypedMessageSubmitted } = (0, __envive_ai_react_hooks_contexts_salesAgentContext.useSalesAgent)();
|
|
26
25
|
const { openChat } = (0, __envive_ai_react_hooks_hooks_ChatToggle.useChatToggle)();
|
|
27
|
-
const { hardcopyContent, widgetConfig, isLoading } = props;
|
|
26
|
+
const { hardcopyContent, widgetConfig, isLoading, widgetConfigId } = props;
|
|
28
27
|
const promptButtonTexts = hardcopyContent?.values?.promptButtonTexts || [];
|
|
29
28
|
const buttonTexts = isLoading ? mockButtonTexts : promptButtonTexts;
|
|
30
29
|
const promptCarouselWidgetConfig = widgetConfig;
|
|
@@ -33,19 +32,23 @@ const PromptCarouselWidgetHandler = (props) => {
|
|
|
33
32
|
const promptButtonType = promptCarouselWidgetConfig?.promptButtonType;
|
|
34
33
|
const promptCarouselRows = promptCarouselWidgetConfig?.promptCarouselRows;
|
|
35
34
|
const animationSpeed = isLoading ? __envive_ai_react_toolkit_v3_PromptCarousel_types_types.AnimationSpeed.FAST : promptCarouselWidgetConfig?.animationSpeed;
|
|
35
|
+
const { trackEvent } = (0, __envive_ai_react_hooks_contexts_amplitudeContext.useAmplitude)();
|
|
36
|
+
(0, react.useEffect)(() => {
|
|
37
|
+
trackEvent({
|
|
38
|
+
eventName: __envive_ai_react_hooks_contexts_amplitudeContext.SpiffyMetricsEventName.ChatComponentVisible,
|
|
39
|
+
eventProps: {
|
|
40
|
+
widget_config_id: widgetConfigId,
|
|
41
|
+
widget_type: __envive_ai_react_hooks_contexts_typesV3.WidgetTypeV3.PromptCarouselV3
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}, [trackEvent, widgetConfigId]);
|
|
36
45
|
const handleButtonClick = (0, react.useCallback)((text) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
id: require_v4.default(),
|
|
40
|
-
role: __envive_ai_react_hooks_application_models.MessageRole.User,
|
|
41
|
-
type: __envive_ai_react_hooks_application_models.MessageType.QueryTyped,
|
|
42
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
43
|
-
metadata: { content: text }
|
|
44
|
-
},
|
|
46
|
+
onTypedMessageSubmitted({
|
|
47
|
+
query: text,
|
|
45
48
|
userTyped: false
|
|
46
49
|
});
|
|
47
50
|
openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.PROMPT_CAROUSEL);
|
|
48
|
-
}, [
|
|
51
|
+
}, [onTypedMessageSubmitted, openChat]);
|
|
49
52
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__envive_ai_react_toolkit_v3_PromptCarousel.PromptCarousel, {
|
|
50
53
|
id,
|
|
51
54
|
theme: __envive_ai_react_toolkit_v3_Tokens.Theme.GLOBAL_CUSTOM,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts
|
|
4
4
|
interface PromptCarouselWidgetProps {
|
|
@@ -7,7 +7,7 @@ interface PromptCarouselWidgetProps {
|
|
|
7
7
|
declare const PromptCarouselWidget: {
|
|
8
8
|
({
|
|
9
9
|
widgetConfigId
|
|
10
|
-
}: PromptCarouselWidgetProps):
|
|
10
|
+
}: PromptCarouselWidgetProps): react_jsx_runtime0.JSX.Element;
|
|
11
11
|
displayName: string;
|
|
12
12
|
};
|
|
13
13
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime8 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts
|
|
4
4
|
interface PromptCarouselWidgetProps {
|
|
@@ -7,7 +7,7 @@ interface PromptCarouselWidgetProps {
|
|
|
7
7
|
declare const PromptCarouselWidget: {
|
|
8
8
|
({
|
|
9
9
|
widgetConfigId
|
|
10
|
-
}: PromptCarouselWidgetProps):
|
|
10
|
+
}: PromptCarouselWidgetProps): react_jsx_runtime8.JSX.Element;
|
|
11
11
|
displayName: string;
|
|
12
12
|
};
|
|
13
13
|
//#endregion
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { withBaseWidget } from "../../hocs/withBaseWidget/withBaseWidget.js";
|
|
2
2
|
import "../../hocs/withBaseWidget/index.js";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
3
|
+
import { useCallback, useEffect } from "react";
|
|
4
|
+
import { SpiffyMetricsEventName, useAmplitude } from "@envive-ai/react-hooks/contexts/amplitudeContext";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { WidgetTypeV3 } from "@envive-ai/react-hooks/contexts/typesV3";
|
|
7
|
-
import {
|
|
8
|
-
import { handleReplyAtom } from "@envive-ai/react-hooks/atoms/chat/replies";
|
|
7
|
+
import { useSalesAgent } from "@envive-ai/react-hooks/contexts/salesAgentContext";
|
|
9
8
|
import { useChatToggle } from "@envive-ai/react-hooks/hooks/ChatToggle";
|
|
10
9
|
import { Theme } from "@envive-ai/react-toolkit-v3/Tokens";
|
|
11
|
-
import { ChatElementDisplayLocationV3
|
|
10
|
+
import { ChatElementDisplayLocationV3 } from "@envive-ai/react-hooks/application/models";
|
|
12
11
|
import { AnimationSpeed } from "@envive-ai/react-toolkit-v3/PromptCarousel/types/types";
|
|
13
12
|
import { PromptCarousel } from "@envive-ai/react-toolkit-v3/PromptCarousel";
|
|
14
13
|
|
|
@@ -21,9 +20,9 @@ const mockButtonTexts = [
|
|
|
21
20
|
"Loading button 5"
|
|
22
21
|
];
|
|
23
22
|
const PromptCarouselWidgetHandler = (props) => {
|
|
24
|
-
const
|
|
23
|
+
const { onTypedMessageSubmitted } = useSalesAgent();
|
|
25
24
|
const { openChat } = useChatToggle();
|
|
26
|
-
const { hardcopyContent, widgetConfig, isLoading } = props;
|
|
25
|
+
const { hardcopyContent, widgetConfig, isLoading, widgetConfigId } = props;
|
|
27
26
|
const promptButtonTexts = hardcopyContent?.values?.promptButtonTexts || [];
|
|
28
27
|
const buttonTexts = isLoading ? mockButtonTexts : promptButtonTexts;
|
|
29
28
|
const promptCarouselWidgetConfig = widgetConfig;
|
|
@@ -32,19 +31,23 @@ const PromptCarouselWidgetHandler = (props) => {
|
|
|
32
31
|
const promptButtonType = promptCarouselWidgetConfig?.promptButtonType;
|
|
33
32
|
const promptCarouselRows = promptCarouselWidgetConfig?.promptCarouselRows;
|
|
34
33
|
const animationSpeed = isLoading ? AnimationSpeed.FAST : promptCarouselWidgetConfig?.animationSpeed;
|
|
34
|
+
const { trackEvent } = useAmplitude();
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
trackEvent({
|
|
37
|
+
eventName: SpiffyMetricsEventName.ChatComponentVisible,
|
|
38
|
+
eventProps: {
|
|
39
|
+
widget_config_id: widgetConfigId,
|
|
40
|
+
widget_type: WidgetTypeV3.PromptCarouselV3
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}, [trackEvent, widgetConfigId]);
|
|
35
44
|
const handleButtonClick = useCallback((text) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
id: v4_default(),
|
|
39
|
-
role: MessageRole.User,
|
|
40
|
-
type: MessageType.QueryTyped,
|
|
41
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
42
|
-
metadata: { content: text }
|
|
43
|
-
},
|
|
45
|
+
onTypedMessageSubmitted({
|
|
46
|
+
query: text,
|
|
44
47
|
userTyped: false
|
|
45
48
|
});
|
|
46
49
|
openChat(ChatElementDisplayLocationV3.PROMPT_CAROUSEL);
|
|
47
|
-
}, [
|
|
50
|
+
}, [onTypedMessageSubmitted, openChat]);
|
|
48
51
|
return /* @__PURE__ */ jsx(PromptCarousel, {
|
|
49
52
|
id,
|
|
50
53
|
theme: Theme.GLOBAL_CUSTOM,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_ChatPreviewLoadingWidget = require('../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.cjs');
|
|
3
|
-
const require_ChatPreviewWidget = require('../ChatPreviewWidget/ChatPreviewWidget.cjs');
|
|
4
3
|
const require_ChatPreviewComparisonWidget = require('../ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs');
|
|
4
|
+
const require_ChatPreviewWidget = require('../ChatPreviewWidget/ChatPreviewWidget.cjs');
|
|
5
5
|
const require_useGetWidgetStatus = require('../hooks/useGetWidgetStatus.cjs');
|
|
6
6
|
const require_SocialProofWidget = require('../SocialProofWidget/SocialProofWidget.cjs');
|
|
7
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|