@envive-ai/react-widgets-v3 0.3.11 → 0.3.12
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 -1
- package/dist/CXIntegration/hooks/useUnifiedCXButton.js +2 -1
- package/dist/CXIntegration/implementations/useGladlyUnifiedCXButton.cjs +6 -0
- package/dist/CXIntegration/implementations/useGladlyUnifiedCXButton.js +6 -0
- package/dist/CXIntegration/implementations/useGorgiasUnifiedCXButton.cjs +7 -6
- package/dist/CXIntegration/implementations/useGorgiasUnifiedCXButton.js +7 -6
- package/dist/CXIntegration/implementations/useGrooveUnifiedCXButton.cjs +10 -11
- package/dist/CXIntegration/implementations/useGrooveUnifiedCXButton.js +10 -11
- package/dist/CXIntegration/implementations/useKustomerUnifiedCXButton.cjs +10 -7
- package/dist/CXIntegration/implementations/useKustomerUnifiedCXButton.js +10 -7
- package/dist/CXIntegration/implementations/useReDoUnifiedCXButton.cjs +2 -2
- package/dist/CXIntegration/implementations/useReDoUnifiedCXButton.js +2 -2
- package/dist/CXIntegration/implementations/useRichpanelUnifiedCXButton.cjs +9 -7
- package/dist/CXIntegration/implementations/useRichpanelUnifiedCXButton.js +9 -7
- package/dist/CXIntegration/implementations/useShopifyChatUnifiedCXButton.cjs +13 -16
- package/dist/CXIntegration/implementations/useShopifyChatUnifiedCXButton.js +13 -16
- package/dist/CXIntegration/implementations/useTidioUnifiedCXButton.cjs +6 -0
- package/dist/CXIntegration/implementations/useTidioUnifiedCXButton.js +6 -0
- package/dist/CXIntegration/implementations/useZendeskUnifiedCXButton.cjs +7 -5
- package/dist/CXIntegration/implementations/useZendeskUnifiedCXButton.js +7 -5
- package/dist/CXIntegration/implementations/useZowieUnifiedCXButton.cjs +6 -0
- package/dist/CXIntegration/implementations/useZowieUnifiedCXButton.js +6 -0
- package/dist/debug/debugBar.cjs +0 -1
- package/dist/debug/debugBar.js +0 -1
- package/dist/hocs/withBaseWidget/withBaseWidget.d.cts +2 -2
- package/dist/hocs/withBaseWidget/withBaseWidget.d.ts +2 -2
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/UrlResolvingRequest.cjs +4 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/WidgetTextRequest.cjs +2 -0
- package/dist/packages/widgets/dist/SearchResults/SearchResultsWidget.d.ts +2 -2
- package/dist/packages/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.ts +2 -2
- package/dist/packages/widgets/dist/SuggestionBar/SuggestionBar.d.ts +2 -2
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.cts +3 -3
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +64 -36
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +2 -2
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +2 -2
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +65 -37
- package/dist/widgets/FloatingChatWidget/hooks/useAutoPopup.cjs +50 -0
- package/dist/widgets/FloatingChatWidget/hooks/useAutoPopup.js +49 -0
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.cts +2 -2
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +2 -2
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +3 -3
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +1 -1
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +1 -1
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.cts +2 -2
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +1 -1
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +1 -1
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.cts +2 -2
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
- package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.cts +2 -2
- package/dist/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.cts +2 -2
- package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.cts +2 -2
- package/package.json +1 -1
- package/src/CXIntegration/hooks/useUnifiedCXButton.ts +4 -1
- package/src/CXIntegration/implementations/useGladlyUnifiedCXButton.ts +5 -0
- package/src/CXIntegration/implementations/useGorgiasUnifiedCXButton.ts +11 -8
- package/src/CXIntegration/implementations/useGrooveUnifiedCXButton.ts +12 -15
- package/src/CXIntegration/implementations/useKustomerUnifiedCXButton.ts +11 -11
- package/src/CXIntegration/implementations/useReDoUnifiedCXButton.ts +2 -4
- package/src/CXIntegration/implementations/useRichpanelUnifiedCXButton.ts +9 -10
- package/src/CXIntegration/implementations/useShopifyChatUnifiedCXButton.ts +18 -28
- package/src/CXIntegration/implementations/useTidioUnifiedCXButton.ts +5 -0
- package/src/CXIntegration/implementations/useZendeskUnifiedCXButton.ts +11 -6
- package/src/CXIntegration/implementations/useZowieUnifiedCXButton.ts +5 -0
- package/src/CXIntegration/types.ts +1 -0
- package/src/debug/debugBar.tsx +0 -1
- package/src/widgets/FloatingChatWidget/FloatingChatWidget.tsx +109 -66
- package/src/widgets/FloatingChatWidget/hooks/useAutoPopup.ts +65 -0
- package/src/widgets/PromptCarouselWidget/PromptCarouselWidget.tsx +1 -1
- package/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.tsx +1 -1
|
@@ -6,11 +6,12 @@ let jotai = require("jotai");
|
|
|
6
6
|
let __envive_ai_react_hooks_atoms_app = require("@envive-ai/react-hooks/atoms/app");
|
|
7
7
|
|
|
8
8
|
//#region src/CXIntegration/hooks/useUnifiedCXButton.ts
|
|
9
|
-
const useUnifiedCXButton = ({ enabled = false, provider = require_types.CustomerServiceType.unsupported, suppressMerchantButton = false, onSwitchToAgent }) => {
|
|
9
|
+
const useUnifiedCXButton = ({ enabled = false, provider = require_types.CustomerServiceType.unsupported, suppressMerchantButton = false, onSwitchToAgent, onCXClose }) => {
|
|
10
10
|
const { isSupported } = (0, __envive_ai_react_hooks_contexts_pageContext.usePage)();
|
|
11
11
|
const hasParsedVariantInfo = (0, jotai.useAtomValue)(__envive_ai_react_hooks_atoms_app.hasParsedVariantInfoAtom);
|
|
12
12
|
const selectedCustomerService = require_functions.findCustomerServiceImpl(provider)({
|
|
13
13
|
onSwitchToAgent,
|
|
14
|
+
onCXClose,
|
|
14
15
|
suppressMerchantButton
|
|
15
16
|
});
|
|
16
17
|
if (!enabled) return void 0;
|
|
@@ -5,11 +5,12 @@ import { useAtomValue } from "jotai";
|
|
|
5
5
|
import { hasParsedVariantInfoAtom } from "@envive-ai/react-hooks/atoms/app";
|
|
6
6
|
|
|
7
7
|
//#region src/CXIntegration/hooks/useUnifiedCXButton.ts
|
|
8
|
-
const useUnifiedCXButton = ({ enabled = false, provider = CustomerServiceType.unsupported, suppressMerchantButton = false, onSwitchToAgent }) => {
|
|
8
|
+
const useUnifiedCXButton = ({ enabled = false, provider = CustomerServiceType.unsupported, suppressMerchantButton = false, onSwitchToAgent, onCXClose }) => {
|
|
9
9
|
const { isSupported } = usePage();
|
|
10
10
|
const hasParsedVariantInfo = useAtomValue(hasParsedVariantInfoAtom);
|
|
11
11
|
const selectedCustomerService = findCustomerServiceImpl(provider)({
|
|
12
12
|
onSwitchToAgent,
|
|
13
|
+
onCXClose,
|
|
13
14
|
suppressMerchantButton
|
|
14
15
|
});
|
|
15
16
|
if (!enabled) return void 0;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_constants = require('../../widgets/FloatingChatWidget/constants.cjs');
|
|
3
|
+
let __envive_ai_react_hooks_application_utils = require("@envive-ai/react-hooks/application/utils");
|
|
4
|
+
let __envive_ai_react_hooks_hooks_ElementObserver = require("@envive-ai/react-hooks/hooks/ElementObserver");
|
|
1
5
|
|
|
2
6
|
//#region src/CXIntegration/implementations/useGladlyUnifiedCXButton.ts
|
|
3
7
|
const useGladlyUnifiedCXButton = ({ onSwitchToAgent }) => {
|
|
4
8
|
const gladlyButton = document.querySelector("[data-aid*=\"gladlyChatChatButton\"]");
|
|
9
|
+
const enviveFloatingButton = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.id(require_constants.FLOATING_BUTTON_ID));
|
|
5
10
|
const toggle = () => {
|
|
6
11
|
onSwitchToAgent();
|
|
12
|
+
enviveFloatingButton.hide();
|
|
7
13
|
if (gladlyButton && gladlyButton instanceof HTMLElement) gladlyButton.click();
|
|
8
14
|
};
|
|
9
15
|
const isGladlyButtonEnabled = () => {
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import { FLOATING_BUTTON_ID } from "../../widgets/FloatingChatWidget/constants.js";
|
|
2
|
+
import { SelectorFactory } from "@envive-ai/react-hooks/application/utils";
|
|
3
|
+
import { useElementObserver } from "@envive-ai/react-hooks/hooks/ElementObserver";
|
|
4
|
+
|
|
1
5
|
//#region src/CXIntegration/implementations/useGladlyUnifiedCXButton.ts
|
|
2
6
|
const useGladlyUnifiedCXButton = ({ onSwitchToAgent }) => {
|
|
3
7
|
const gladlyButton = document.querySelector("[data-aid*=\"gladlyChatChatButton\"]");
|
|
8
|
+
const enviveFloatingButton = useElementObserver(SelectorFactory.id(FLOATING_BUTTON_ID));
|
|
4
9
|
const toggle = () => {
|
|
5
10
|
onSwitchToAgent();
|
|
11
|
+
enviveFloatingButton.hide();
|
|
6
12
|
if (gladlyButton && gladlyButton instanceof HTMLElement) gladlyButton.click();
|
|
7
13
|
};
|
|
8
14
|
const isGladlyButtonEnabled = () => {
|
|
@@ -7,7 +7,7 @@ let __envive_ai_react_hooks_hooks_ElementObserver = require("@envive-ai/react-ho
|
|
|
7
7
|
const CHAT_WINDOW_ID = "chat-window";
|
|
8
8
|
const CHAT_BUTTON_ID = "chat-button";
|
|
9
9
|
const GORGIAS_BUTTON_SELECTOR = "id|chat-button @ id|gorgias-chat-messenger-button";
|
|
10
|
-
const useGorgiasUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }) => {
|
|
10
|
+
const useGorgiasUnifiedCXButton = ({ onSwitchToAgent, onCXClose, suppressMerchantButton }) => {
|
|
11
11
|
const chatWindow = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.id(CHAT_WINDOW_ID));
|
|
12
12
|
const chatButton = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.id(CHAT_BUTTON_ID));
|
|
13
13
|
const trigger = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.chain(GORGIAS_BUTTON_SELECTOR));
|
|
@@ -16,7 +16,7 @@ const useGorgiasUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton })
|
|
|
16
16
|
onSwitchToAgent();
|
|
17
17
|
chatButton.show();
|
|
18
18
|
trigger.fire("click");
|
|
19
|
-
|
|
19
|
+
enviveFloatingButton.hide();
|
|
20
20
|
};
|
|
21
21
|
const isSwitchEnabled = () => !!__envive_ai_react_hooks_application_utils.SelectorFactory.chain(GORGIAS_BUTTON_SELECTOR).parse();
|
|
22
22
|
chatButton.onAdd(() => {
|
|
@@ -26,19 +26,20 @@ const useGorgiasUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton })
|
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
chatWindow.onAdd((el) => {
|
|
29
|
-
if (el
|
|
29
|
+
if (el) {
|
|
30
30
|
const chatWindowDisplay = window.getComputedStyle(el).getPropertyValue("display");
|
|
31
31
|
const chatButtonDisplay = chatButton.targetNode?.style.display;
|
|
32
32
|
if (chatWindowDisplay === "block" && chatButtonDisplay === "none") {
|
|
33
|
-
chatButton.show();
|
|
33
|
+
if (suppressMerchantButton) chatButton.show();
|
|
34
34
|
enviveFloatingButton.hide();
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
chatWindow.onChange((el) => {
|
|
39
|
-
if (el
|
|
39
|
+
if (el) {
|
|
40
40
|
if (window.getComputedStyle(el).getPropertyValue("display") === "none") {
|
|
41
|
-
|
|
41
|
+
onCXClose?.();
|
|
42
|
+
if (suppressMerchantButton) chatButton.hide();
|
|
42
43
|
enviveFloatingButton.show();
|
|
43
44
|
}
|
|
44
45
|
}
|
|
@@ -6,7 +6,7 @@ import { useElementObserver } from "@envive-ai/react-hooks/hooks/ElementObserver
|
|
|
6
6
|
const CHAT_WINDOW_ID = "chat-window";
|
|
7
7
|
const CHAT_BUTTON_ID = "chat-button";
|
|
8
8
|
const GORGIAS_BUTTON_SELECTOR = "id|chat-button @ id|gorgias-chat-messenger-button";
|
|
9
|
-
const useGorgiasUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }) => {
|
|
9
|
+
const useGorgiasUnifiedCXButton = ({ onSwitchToAgent, onCXClose, suppressMerchantButton }) => {
|
|
10
10
|
const chatWindow = useElementObserver(SelectorFactory.id(CHAT_WINDOW_ID));
|
|
11
11
|
const chatButton = useElementObserver(SelectorFactory.id(CHAT_BUTTON_ID));
|
|
12
12
|
const trigger = useElementObserver(SelectorFactory.chain(GORGIAS_BUTTON_SELECTOR));
|
|
@@ -15,7 +15,7 @@ const useGorgiasUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton })
|
|
|
15
15
|
onSwitchToAgent();
|
|
16
16
|
chatButton.show();
|
|
17
17
|
trigger.fire("click");
|
|
18
|
-
|
|
18
|
+
enviveFloatingButton.hide();
|
|
19
19
|
};
|
|
20
20
|
const isSwitchEnabled = () => !!SelectorFactory.chain(GORGIAS_BUTTON_SELECTOR).parse();
|
|
21
21
|
chatButton.onAdd(() => {
|
|
@@ -25,19 +25,20 @@ const useGorgiasUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton })
|
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
chatWindow.onAdd((el) => {
|
|
28
|
-
if (el
|
|
28
|
+
if (el) {
|
|
29
29
|
const chatWindowDisplay = window.getComputedStyle(el).getPropertyValue("display");
|
|
30
30
|
const chatButtonDisplay = chatButton.targetNode?.style.display;
|
|
31
31
|
if (chatWindowDisplay === "block" && chatButtonDisplay === "none") {
|
|
32
|
-
chatButton.show();
|
|
32
|
+
if (suppressMerchantButton) chatButton.show();
|
|
33
33
|
enviveFloatingButton.hide();
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
chatWindow.onChange((el) => {
|
|
38
|
-
if (el
|
|
38
|
+
if (el) {
|
|
39
39
|
if (window.getComputedStyle(el).getPropertyValue("display") === "none") {
|
|
40
|
-
|
|
40
|
+
onCXClose?.();
|
|
41
|
+
if (suppressMerchantButton) chatButton.hide();
|
|
41
42
|
enviveFloatingButton.show();
|
|
42
43
|
}
|
|
43
44
|
}
|
|
@@ -5,13 +5,13 @@ let __envive_ai_react_hooks_application_utils = require("@envive-ai/react-hooks/
|
|
|
5
5
|
let __envive_ai_react_hooks_hooks_ElementObserver = require("@envive-ai/react-hooks/hooks/ElementObserver");
|
|
6
6
|
|
|
7
7
|
//#region src/CXIntegration/implementations/useGrooveUnifiedCXButton.ts
|
|
8
|
-
const useGrooveUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }) => {
|
|
8
|
+
const useGrooveUnifiedCXButton = ({ onSwitchToAgent, onCXClose, suppressMerchantButton }) => {
|
|
9
9
|
const grooveChatContainer = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.query("div[id*=\"groove-container\"]"));
|
|
10
10
|
const windowGrooveWidget = window.groove?.widget;
|
|
11
11
|
const enviveFloatingButton = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.id(require_constants.FLOATING_BUTTON_ID));
|
|
12
12
|
const previousIsOpenRef = (0, react.useRef)(void 0);
|
|
13
13
|
const toggle = () => {
|
|
14
|
-
|
|
14
|
+
enviveFloatingButton.hide();
|
|
15
15
|
onSwitchToAgent();
|
|
16
16
|
if (windowGrooveWidget) windowGrooveWidget.open();
|
|
17
17
|
};
|
|
@@ -19,20 +19,19 @@ const useGrooveUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }) =
|
|
|
19
19
|
const isSwitchEnabled = () => isGrooveWidgetEnabled();
|
|
20
20
|
const hideEnviveFloatingButton = () => {
|
|
21
21
|
enviveFloatingButton.hide();
|
|
22
|
-
if (windowGrooveWidget) windowGrooveWidget.open();
|
|
22
|
+
if (suppressMerchantButton && windowGrooveWidget) windowGrooveWidget.open();
|
|
23
23
|
};
|
|
24
24
|
const showEnviveFloatingButton = () => {
|
|
25
|
+
onCXClose?.();
|
|
25
26
|
enviveFloatingButton.show();
|
|
26
|
-
if (windowGrooveWidget) windowGrooveWidget.close();
|
|
27
|
+
if (suppressMerchantButton && windowGrooveWidget) windowGrooveWidget.close();
|
|
27
28
|
};
|
|
28
29
|
grooveChatContainer.onChange(() => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
else showEnviveFloatingButton();
|
|
35
|
-
}
|
|
30
|
+
const isOpen = windowGrooveWidget?.shim.isOpen;
|
|
31
|
+
if (isOpen !== previousIsOpenRef.current) {
|
|
32
|
+
previousIsOpenRef.current = isOpen;
|
|
33
|
+
if (isOpen) hideEnviveFloatingButton();
|
|
34
|
+
else showEnviveFloatingButton();
|
|
36
35
|
}
|
|
37
36
|
});
|
|
38
37
|
return {
|
|
@@ -4,13 +4,13 @@ import { SelectorFactory } from "@envive-ai/react-hooks/application/utils";
|
|
|
4
4
|
import { useElementObserver } from "@envive-ai/react-hooks/hooks/ElementObserver";
|
|
5
5
|
|
|
6
6
|
//#region src/CXIntegration/implementations/useGrooveUnifiedCXButton.ts
|
|
7
|
-
const useGrooveUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }) => {
|
|
7
|
+
const useGrooveUnifiedCXButton = ({ onSwitchToAgent, onCXClose, suppressMerchantButton }) => {
|
|
8
8
|
const grooveChatContainer = useElementObserver(SelectorFactory.query("div[id*=\"groove-container\"]"));
|
|
9
9
|
const windowGrooveWidget = window.groove?.widget;
|
|
10
10
|
const enviveFloatingButton = useElementObserver(SelectorFactory.id(FLOATING_BUTTON_ID));
|
|
11
11
|
const previousIsOpenRef = useRef(void 0);
|
|
12
12
|
const toggle = () => {
|
|
13
|
-
|
|
13
|
+
enviveFloatingButton.hide();
|
|
14
14
|
onSwitchToAgent();
|
|
15
15
|
if (windowGrooveWidget) windowGrooveWidget.open();
|
|
16
16
|
};
|
|
@@ -18,20 +18,19 @@ const useGrooveUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }) =
|
|
|
18
18
|
const isSwitchEnabled = () => isGrooveWidgetEnabled();
|
|
19
19
|
const hideEnviveFloatingButton = () => {
|
|
20
20
|
enviveFloatingButton.hide();
|
|
21
|
-
if (windowGrooveWidget) windowGrooveWidget.open();
|
|
21
|
+
if (suppressMerchantButton && windowGrooveWidget) windowGrooveWidget.open();
|
|
22
22
|
};
|
|
23
23
|
const showEnviveFloatingButton = () => {
|
|
24
|
+
onCXClose?.();
|
|
24
25
|
enviveFloatingButton.show();
|
|
25
|
-
if (windowGrooveWidget) windowGrooveWidget.close();
|
|
26
|
+
if (suppressMerchantButton && windowGrooveWidget) windowGrooveWidget.close();
|
|
26
27
|
};
|
|
27
28
|
grooveChatContainer.onChange(() => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
else showEnviveFloatingButton();
|
|
34
|
-
}
|
|
29
|
+
const isOpen = windowGrooveWidget?.shim.isOpen;
|
|
30
|
+
if (isOpen !== previousIsOpenRef.current) {
|
|
31
|
+
previousIsOpenRef.current = isOpen;
|
|
32
|
+
if (isOpen) hideEnviveFloatingButton();
|
|
33
|
+
else showEnviveFloatingButton();
|
|
35
34
|
}
|
|
36
35
|
});
|
|
37
36
|
return {
|
|
@@ -4,14 +4,14 @@ let __envive_ai_react_hooks_application_utils = require("@envive-ai/react-hooks/
|
|
|
4
4
|
let __envive_ai_react_hooks_hooks_ElementObserver = require("@envive-ai/react-hooks/hooks/ElementObserver");
|
|
5
5
|
|
|
6
6
|
//#region src/CXIntegration/implementations/useKustomerUnifiedCXButton.ts
|
|
7
|
-
const useKustomerUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }) => {
|
|
7
|
+
const useKustomerUnifiedCXButton = ({ onSwitchToAgent, onCXClose, suppressMerchantButton }) => {
|
|
8
8
|
const kustomerButton = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.chain("id|kustomer-ui-sdk-iframe @ query|div[role=\"button\"]"));
|
|
9
9
|
const kustomerNotification = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.chain("id|kustomer-ui-sdk-iframe @ query|div[class^=\"unread__unread\"]"));
|
|
10
10
|
const kustomerWidgetRoot = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.chain("id|kustomer-ui-sdk-iframe @ id|root"));
|
|
11
11
|
const enviveFloatingButton = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.id(require_constants.FLOATING_BUTTON_ID));
|
|
12
12
|
const toggle = () => {
|
|
13
13
|
onSwitchToAgent();
|
|
14
|
-
|
|
14
|
+
enviveFloatingButton.hide();
|
|
15
15
|
kustomerButton.show();
|
|
16
16
|
kustomerButton.fire("click");
|
|
17
17
|
};
|
|
@@ -26,13 +26,16 @@ const useKustomerUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton })
|
|
|
26
26
|
if (suppressMerchantButton) kustomerNotification.hide();
|
|
27
27
|
});
|
|
28
28
|
kustomerWidgetRoot.onChange(async (el) => {
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
for (const child of el?.children || []) if ([...child.classList].some((cls) => cls.includes("widget__widgetWrapper"))) {
|
|
30
|
+
enviveFloatingButton.hide();
|
|
31
|
+
if (suppressMerchantButton) {
|
|
32
32
|
kustomerButton.show();
|
|
33
33
|
kustomerNotification.show();
|
|
34
|
-
}
|
|
35
|
-
|
|
34
|
+
}
|
|
35
|
+
} else if ([...child.classList].some((cls) => cls.includes("chatRootIcon__chatIconWrapper"))) {
|
|
36
|
+
onCXClose?.();
|
|
37
|
+
enviveFloatingButton.show();
|
|
38
|
+
if (suppressMerchantButton) {
|
|
36
39
|
kustomerButton.hide();
|
|
37
40
|
kustomerNotification.hide();
|
|
38
41
|
}
|
|
@@ -3,14 +3,14 @@ import { SelectorFactory } from "@envive-ai/react-hooks/application/utils";
|
|
|
3
3
|
import { useElementObserver } from "@envive-ai/react-hooks/hooks/ElementObserver";
|
|
4
4
|
|
|
5
5
|
//#region src/CXIntegration/implementations/useKustomerUnifiedCXButton.ts
|
|
6
|
-
const useKustomerUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }) => {
|
|
6
|
+
const useKustomerUnifiedCXButton = ({ onSwitchToAgent, onCXClose, suppressMerchantButton }) => {
|
|
7
7
|
const kustomerButton = useElementObserver(SelectorFactory.chain("id|kustomer-ui-sdk-iframe @ query|div[role=\"button\"]"));
|
|
8
8
|
const kustomerNotification = useElementObserver(SelectorFactory.chain("id|kustomer-ui-sdk-iframe @ query|div[class^=\"unread__unread\"]"));
|
|
9
9
|
const kustomerWidgetRoot = useElementObserver(SelectorFactory.chain("id|kustomer-ui-sdk-iframe @ id|root"));
|
|
10
10
|
const enviveFloatingButton = useElementObserver(SelectorFactory.id(FLOATING_BUTTON_ID));
|
|
11
11
|
const toggle = () => {
|
|
12
12
|
onSwitchToAgent();
|
|
13
|
-
|
|
13
|
+
enviveFloatingButton.hide();
|
|
14
14
|
kustomerButton.show();
|
|
15
15
|
kustomerButton.fire("click");
|
|
16
16
|
};
|
|
@@ -25,13 +25,16 @@ const useKustomerUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton })
|
|
|
25
25
|
if (suppressMerchantButton) kustomerNotification.hide();
|
|
26
26
|
});
|
|
27
27
|
kustomerWidgetRoot.onChange(async (el) => {
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
for (const child of el?.children || []) if ([...child.classList].some((cls) => cls.includes("widget__widgetWrapper"))) {
|
|
29
|
+
enviveFloatingButton.hide();
|
|
30
|
+
if (suppressMerchantButton) {
|
|
31
31
|
kustomerButton.show();
|
|
32
32
|
kustomerNotification.show();
|
|
33
|
-
}
|
|
34
|
-
|
|
33
|
+
}
|
|
34
|
+
} else if ([...child.classList].some((cls) => cls.includes("chatRootIcon__chatIconWrapper"))) {
|
|
35
|
+
onCXClose?.();
|
|
36
|
+
enviveFloatingButton.show();
|
|
37
|
+
if (suppressMerchantButton) {
|
|
35
38
|
kustomerButton.hide();
|
|
36
39
|
kustomerNotification.hide();
|
|
37
40
|
}
|
|
@@ -9,7 +9,7 @@ const TIMEOUT = 700;
|
|
|
9
9
|
const REDO_CHAT_CONTAINER_SELECTOR = "redo-chat-widget";
|
|
10
10
|
const REDO_CHAT_MODAL_SELECTOR = "id|redo-chat-widget @ query|div > div";
|
|
11
11
|
const REDO_BUTTON_SELECTOR = "id|redo-chat-widget @ query|div[data-target=supp-chat-bubble]";
|
|
12
|
-
const useReDoUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }) => {
|
|
12
|
+
const useReDoUnifiedCXButton = ({ onSwitchToAgent, onCXClose, suppressMerchantButton }) => {
|
|
13
13
|
const chatContainer = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.id(REDO_CHAT_CONTAINER_SELECTOR));
|
|
14
14
|
const chatModal = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.chain(REDO_CHAT_MODAL_SELECTOR));
|
|
15
15
|
const chatButton = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.chain(REDO_BUTTON_SELECTOR));
|
|
@@ -19,7 +19,7 @@ const useReDoUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }) =>
|
|
|
19
19
|
onSwitchToAgent();
|
|
20
20
|
chatButton.show();
|
|
21
21
|
chatButton.fire("click");
|
|
22
|
-
|
|
22
|
+
enviveFloatingButton.hide();
|
|
23
23
|
};
|
|
24
24
|
const isReDoButtonEnabled = () => !!__envive_ai_react_hooks_application_utils.SelectorFactory.chain(REDO_BUTTON_SELECTOR).parse();
|
|
25
25
|
const isSwitchEnabled = () => isReDoButtonEnabled();
|
|
@@ -8,7 +8,7 @@ const TIMEOUT = 700;
|
|
|
8
8
|
const REDO_CHAT_CONTAINER_SELECTOR = "redo-chat-widget";
|
|
9
9
|
const REDO_CHAT_MODAL_SELECTOR = "id|redo-chat-widget @ query|div > div";
|
|
10
10
|
const REDO_BUTTON_SELECTOR = "id|redo-chat-widget @ query|div[data-target=supp-chat-bubble]";
|
|
11
|
-
const useReDoUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }) => {
|
|
11
|
+
const useReDoUnifiedCXButton = ({ onSwitchToAgent, onCXClose, suppressMerchantButton }) => {
|
|
12
12
|
const chatContainer = useElementObserver(SelectorFactory.id(REDO_CHAT_CONTAINER_SELECTOR));
|
|
13
13
|
const chatModal = useElementObserver(SelectorFactory.chain(REDO_CHAT_MODAL_SELECTOR));
|
|
14
14
|
const chatButton = useElementObserver(SelectorFactory.chain(REDO_BUTTON_SELECTOR));
|
|
@@ -18,7 +18,7 @@ const useReDoUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }) =>
|
|
|
18
18
|
onSwitchToAgent();
|
|
19
19
|
chatButton.show();
|
|
20
20
|
chatButton.fire("click");
|
|
21
|
-
|
|
21
|
+
enviveFloatingButton.hide();
|
|
22
22
|
};
|
|
23
23
|
const isReDoButtonEnabled = () => !!SelectorFactory.chain(REDO_BUTTON_SELECTOR).parse();
|
|
24
24
|
const isSwitchEnabled = () => isReDoButtonEnabled();
|
|
@@ -4,7 +4,7 @@ let __envive_ai_react_hooks_application_utils = require("@envive-ai/react-hooks/
|
|
|
4
4
|
let __envive_ai_react_hooks_hooks_ElementObserver = require("@envive-ai/react-hooks/hooks/ElementObserver");
|
|
5
5
|
|
|
6
6
|
//#region src/CXIntegration/implementations/useRichpanelUnifiedCXButton.ts
|
|
7
|
-
const useRichpanelUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }) => {
|
|
7
|
+
const useRichpanelUnifiedCXButton = ({ onSwitchToAgent, onCXClose, suppressMerchantButton }) => {
|
|
8
8
|
const chatWindow = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.chain("id|richpanel_messenger_iframe @ query|.rp-messenger-container"));
|
|
9
9
|
const chatButton = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.query(".rp-messenger-trigger"));
|
|
10
10
|
const chatAlternativeButton = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.query(".rp-micro-app-dummy-icon"));
|
|
@@ -12,15 +12,14 @@ const useRichpanelUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }
|
|
|
12
12
|
const toggle = () => {
|
|
13
13
|
chatWindow.show();
|
|
14
14
|
onSwitchToAgent();
|
|
15
|
+
enviveFloatingButton.hide();
|
|
15
16
|
if (chatButton) {
|
|
16
17
|
chatButton.show();
|
|
17
18
|
chatButton.fire("click");
|
|
18
|
-
if (suppressMerchantButton) enviveFloatingButton.hide();
|
|
19
19
|
}
|
|
20
20
|
if (chatAlternativeButton) {
|
|
21
21
|
chatAlternativeButton.show();
|
|
22
22
|
chatAlternativeButton.fire("click");
|
|
23
|
-
if (suppressMerchantButton) enviveFloatingButton.hide();
|
|
24
23
|
}
|
|
25
24
|
};
|
|
26
25
|
const isRichpanelButtonEnabled = () => {
|
|
@@ -42,16 +41,19 @@ const useRichpanelUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }
|
|
|
42
41
|
enviveFloatingButton.show();
|
|
43
42
|
});
|
|
44
43
|
chatWindow.onChange((el) => {
|
|
45
|
-
if (el
|
|
44
|
+
if (el) {
|
|
46
45
|
const { classList } = el;
|
|
47
46
|
if (classList.contains("opened")) {
|
|
48
47
|
enviveFloatingButton.hide();
|
|
49
48
|
chatWindow.show();
|
|
50
49
|
} else if (classList.length === 1 && classList.contains("rp-messenger-container")) {
|
|
50
|
+
onCXClose?.();
|
|
51
51
|
enviveFloatingButton.show();
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
if (suppressMerchantButton) {
|
|
53
|
+
chatButton.hide();
|
|
54
|
+
chatAlternativeButton.hide();
|
|
55
|
+
chatWindow.hide();
|
|
56
|
+
}
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
});
|
|
@@ -3,7 +3,7 @@ import { SelectorFactory } from "@envive-ai/react-hooks/application/utils";
|
|
|
3
3
|
import { useElementObserver } from "@envive-ai/react-hooks/hooks/ElementObserver";
|
|
4
4
|
|
|
5
5
|
//#region src/CXIntegration/implementations/useRichpanelUnifiedCXButton.ts
|
|
6
|
-
const useRichpanelUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }) => {
|
|
6
|
+
const useRichpanelUnifiedCXButton = ({ onSwitchToAgent, onCXClose, suppressMerchantButton }) => {
|
|
7
7
|
const chatWindow = useElementObserver(SelectorFactory.chain("id|richpanel_messenger_iframe @ query|.rp-messenger-container"));
|
|
8
8
|
const chatButton = useElementObserver(SelectorFactory.query(".rp-messenger-trigger"));
|
|
9
9
|
const chatAlternativeButton = useElementObserver(SelectorFactory.query(".rp-micro-app-dummy-icon"));
|
|
@@ -11,15 +11,14 @@ const useRichpanelUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }
|
|
|
11
11
|
const toggle = () => {
|
|
12
12
|
chatWindow.show();
|
|
13
13
|
onSwitchToAgent();
|
|
14
|
+
enviveFloatingButton.hide();
|
|
14
15
|
if (chatButton) {
|
|
15
16
|
chatButton.show();
|
|
16
17
|
chatButton.fire("click");
|
|
17
|
-
if (suppressMerchantButton) enviveFloatingButton.hide();
|
|
18
18
|
}
|
|
19
19
|
if (chatAlternativeButton) {
|
|
20
20
|
chatAlternativeButton.show();
|
|
21
21
|
chatAlternativeButton.fire("click");
|
|
22
|
-
if (suppressMerchantButton) enviveFloatingButton.hide();
|
|
23
22
|
}
|
|
24
23
|
};
|
|
25
24
|
const isRichpanelButtonEnabled = () => {
|
|
@@ -41,16 +40,19 @@ const useRichpanelUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }
|
|
|
41
40
|
enviveFloatingButton.show();
|
|
42
41
|
});
|
|
43
42
|
chatWindow.onChange((el) => {
|
|
44
|
-
if (el
|
|
43
|
+
if (el) {
|
|
45
44
|
const { classList } = el;
|
|
46
45
|
if (classList.contains("opened")) {
|
|
47
46
|
enviveFloatingButton.hide();
|
|
48
47
|
chatWindow.show();
|
|
49
48
|
} else if (classList.length === 1 && classList.contains("rp-messenger-container")) {
|
|
49
|
+
onCXClose?.();
|
|
50
50
|
enviveFloatingButton.show();
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
if (suppressMerchantButton) {
|
|
52
|
+
chatButton.hide();
|
|
53
|
+
chatAlternativeButton.hide();
|
|
54
|
+
chatWindow.hide();
|
|
55
|
+
}
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
});
|
|
@@ -4,12 +4,12 @@ let __envive_ai_react_hooks_application_utils = require("@envive-ai/react-hooks/
|
|
|
4
4
|
let __envive_ai_react_hooks_hooks_ElementObserver = require("@envive-ai/react-hooks/hooks/ElementObserver");
|
|
5
5
|
|
|
6
6
|
//#region src/CXIntegration/implementations/useShopifyChatUnifiedCXButton.ts
|
|
7
|
-
const useShopifyChatUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }) => {
|
|
7
|
+
const useShopifyChatUnifiedCXButton = ({ onSwitchToAgent, onCXClose, suppressMerchantButton }) => {
|
|
8
8
|
const shopifyChatContainer = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.id("ShopifyChat"));
|
|
9
9
|
const shopifyButton = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.chain("id|ShopifyChat @ query|.chat-app > button"));
|
|
10
10
|
const enviveFloatingButton = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.id(require_constants.FLOATING_BUTTON_ID));
|
|
11
11
|
const toggle = () => {
|
|
12
|
-
|
|
12
|
+
enviveFloatingButton.hide();
|
|
13
13
|
shopifyButton.show();
|
|
14
14
|
onSwitchToAgent();
|
|
15
15
|
shopifyButton.fire("click");
|
|
@@ -18,30 +18,27 @@ const useShopifyChatUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton
|
|
|
18
18
|
return !!shopifyButton;
|
|
19
19
|
};
|
|
20
20
|
const isSwitchEnabled = () => isShopifyButtonEnabled();
|
|
21
|
-
const hideEnviveFloatingButton = () => {
|
|
22
|
-
enviveFloatingButton.hide();
|
|
23
|
-
shopifyButton.show();
|
|
24
|
-
};
|
|
25
|
-
const showEnviveFloatingButton = () => {
|
|
26
|
-
enviveFloatingButton.show();
|
|
27
|
-
shopifyButton.hide();
|
|
28
|
-
shopifyChatContainer.hide();
|
|
29
|
-
};
|
|
30
21
|
const handleChatStateChange = async (isOpen) => {
|
|
31
22
|
if (isOpen) {
|
|
32
|
-
|
|
23
|
+
enviveFloatingButton.hide();
|
|
24
|
+
if (suppressMerchantButton) shopifyButton.show();
|
|
33
25
|
return;
|
|
34
26
|
}
|
|
35
|
-
|
|
27
|
+
onCXClose?.();
|
|
28
|
+
enviveFloatingButton.show();
|
|
29
|
+
if (suppressMerchantButton) {
|
|
30
|
+
shopifyButton.hide();
|
|
31
|
+
shopifyChatContainer.hide();
|
|
32
|
+
}
|
|
36
33
|
};
|
|
37
34
|
shopifyButton.onAdd(() => {
|
|
38
|
-
|
|
35
|
+
handleChatStateChange(shopifyChatContainer.targetNode?.getAttribute("is-open") === "true");
|
|
39
36
|
});
|
|
40
37
|
shopifyChatContainer.onAdd((el) => {
|
|
41
|
-
|
|
38
|
+
handleChatStateChange(el?.getAttribute("is-open") === "true");
|
|
42
39
|
});
|
|
43
40
|
shopifyChatContainer.onChange((el) => {
|
|
44
|
-
|
|
41
|
+
handleChatStateChange(el?.getAttribute("is-open") === "true");
|
|
45
42
|
});
|
|
46
43
|
return {
|
|
47
44
|
toggle,
|
|
@@ -3,12 +3,12 @@ import { SelectorFactory } from "@envive-ai/react-hooks/application/utils";
|
|
|
3
3
|
import { useElementObserver } from "@envive-ai/react-hooks/hooks/ElementObserver";
|
|
4
4
|
|
|
5
5
|
//#region src/CXIntegration/implementations/useShopifyChatUnifiedCXButton.ts
|
|
6
|
-
const useShopifyChatUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton }) => {
|
|
6
|
+
const useShopifyChatUnifiedCXButton = ({ onSwitchToAgent, onCXClose, suppressMerchantButton }) => {
|
|
7
7
|
const shopifyChatContainer = useElementObserver(SelectorFactory.id("ShopifyChat"));
|
|
8
8
|
const shopifyButton = useElementObserver(SelectorFactory.chain("id|ShopifyChat @ query|.chat-app > button"));
|
|
9
9
|
const enviveFloatingButton = useElementObserver(SelectorFactory.id(FLOATING_BUTTON_ID));
|
|
10
10
|
const toggle = () => {
|
|
11
|
-
|
|
11
|
+
enviveFloatingButton.hide();
|
|
12
12
|
shopifyButton.show();
|
|
13
13
|
onSwitchToAgent();
|
|
14
14
|
shopifyButton.fire("click");
|
|
@@ -17,30 +17,27 @@ const useShopifyChatUnifiedCXButton = ({ onSwitchToAgent, suppressMerchantButton
|
|
|
17
17
|
return !!shopifyButton;
|
|
18
18
|
};
|
|
19
19
|
const isSwitchEnabled = () => isShopifyButtonEnabled();
|
|
20
|
-
const hideEnviveFloatingButton = () => {
|
|
21
|
-
enviveFloatingButton.hide();
|
|
22
|
-
shopifyButton.show();
|
|
23
|
-
};
|
|
24
|
-
const showEnviveFloatingButton = () => {
|
|
25
|
-
enviveFloatingButton.show();
|
|
26
|
-
shopifyButton.hide();
|
|
27
|
-
shopifyChatContainer.hide();
|
|
28
|
-
};
|
|
29
20
|
const handleChatStateChange = async (isOpen) => {
|
|
30
21
|
if (isOpen) {
|
|
31
|
-
|
|
22
|
+
enviveFloatingButton.hide();
|
|
23
|
+
if (suppressMerchantButton) shopifyButton.show();
|
|
32
24
|
return;
|
|
33
25
|
}
|
|
34
|
-
|
|
26
|
+
onCXClose?.();
|
|
27
|
+
enviveFloatingButton.show();
|
|
28
|
+
if (suppressMerchantButton) {
|
|
29
|
+
shopifyButton.hide();
|
|
30
|
+
shopifyChatContainer.hide();
|
|
31
|
+
}
|
|
35
32
|
};
|
|
36
33
|
shopifyButton.onAdd(() => {
|
|
37
|
-
|
|
34
|
+
handleChatStateChange(shopifyChatContainer.targetNode?.getAttribute("is-open") === "true");
|
|
38
35
|
});
|
|
39
36
|
shopifyChatContainer.onAdd((el) => {
|
|
40
|
-
|
|
37
|
+
handleChatStateChange(el?.getAttribute("is-open") === "true");
|
|
41
38
|
});
|
|
42
39
|
shopifyChatContainer.onChange((el) => {
|
|
43
|
-
|
|
40
|
+
handleChatStateChange(el?.getAttribute("is-open") === "true");
|
|
44
41
|
});
|
|
45
42
|
return {
|
|
46
43
|
toggle,
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_constants = require('../../widgets/FloatingChatWidget/constants.cjs');
|
|
3
|
+
let __envive_ai_react_hooks_application_utils = require("@envive-ai/react-hooks/application/utils");
|
|
4
|
+
let __envive_ai_react_hooks_hooks_ElementObserver = require("@envive-ai/react-hooks/hooks/ElementObserver");
|
|
1
5
|
|
|
2
6
|
//#region src/CXIntegration/implementations/useTidioUnifiedCXButton.ts
|
|
3
7
|
const useTidioUnifiedCXButton = ({ onSwitchToAgent }) => {
|
|
4
8
|
const tidioButton = window.tidioChatApi;
|
|
9
|
+
const enviveFloatingButton = (0, __envive_ai_react_hooks_hooks_ElementObserver.useElementObserver)(__envive_ai_react_hooks_application_utils.SelectorFactory.id(require_constants.FLOATING_BUTTON_ID));
|
|
5
10
|
const toggle = () => {
|
|
6
11
|
onSwitchToAgent();
|
|
12
|
+
enviveFloatingButton.hide();
|
|
7
13
|
if (tidioButton) tidioButton.open();
|
|
8
14
|
};
|
|
9
15
|
const isTidioButtonEnabled = () => !!document.getElementById("tidio-chat-iframe");
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import { FLOATING_BUTTON_ID } from "../../widgets/FloatingChatWidget/constants.js";
|
|
2
|
+
import { SelectorFactory } from "@envive-ai/react-hooks/application/utils";
|
|
3
|
+
import { useElementObserver } from "@envive-ai/react-hooks/hooks/ElementObserver";
|
|
4
|
+
|
|
1
5
|
//#region src/CXIntegration/implementations/useTidioUnifiedCXButton.ts
|
|
2
6
|
const useTidioUnifiedCXButton = ({ onSwitchToAgent }) => {
|
|
3
7
|
const tidioButton = window.tidioChatApi;
|
|
8
|
+
const enviveFloatingButton = useElementObserver(SelectorFactory.id(FLOATING_BUTTON_ID));
|
|
4
9
|
const toggle = () => {
|
|
5
10
|
onSwitchToAgent();
|
|
11
|
+
enviveFloatingButton.hide();
|
|
6
12
|
if (tidioButton) tidioButton.open();
|
|
7
13
|
};
|
|
8
14
|
const isTidioButtonEnabled = () => !!document.getElementById("tidio-chat-iframe");
|