@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
package/package.json
CHANGED
|
@@ -9,7 +9,8 @@ interface UseUnifiedCXButtonProps {
|
|
|
9
9
|
enabled: boolean;
|
|
10
10
|
provider: CustomerServiceType;
|
|
11
11
|
suppressMerchantButton?: boolean;
|
|
12
|
-
onSwitchToAgent
|
|
12
|
+
onSwitchToAgent: () => void;
|
|
13
|
+
onCXClose?: () => void;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export const useUnifiedCXButton = ({
|
|
@@ -17,6 +18,7 @@ export const useUnifiedCXButton = ({
|
|
|
17
18
|
provider = CustomerServiceType.unsupported,
|
|
18
19
|
suppressMerchantButton = false,
|
|
19
20
|
onSwitchToAgent,
|
|
21
|
+
onCXClose,
|
|
20
22
|
}: UseUnifiedCXButtonProps): UnifiedCXButton | undefined => {
|
|
21
23
|
const { isSupported } = usePage();
|
|
22
24
|
const hasParsedVariantInfo = useAtomValue(hasParsedVariantInfoAtom);
|
|
@@ -25,6 +27,7 @@ export const useUnifiedCXButton = ({
|
|
|
25
27
|
|
|
26
28
|
const selectedCustomerService = customerService({
|
|
27
29
|
onSwitchToAgent,
|
|
30
|
+
onCXClose,
|
|
28
31
|
suppressMerchantButton,
|
|
29
32
|
});
|
|
30
33
|
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { SelectorFactory } from '@envive-ai/react-hooks/application/utils';
|
|
2
|
+
import { useElementObserver } from '@envive-ai/react-hooks/hooks/ElementObserver';
|
|
3
|
+
import { FLOATING_BUTTON_ID } from '../../widgets/FloatingChatWidget/constants';
|
|
1
4
|
import { CustomerServiceImplProps, UnifiedCXButton } from '../types';
|
|
2
5
|
|
|
3
6
|
interface UseGladlyUnifiedCXButtonProps extends CustomerServiceImplProps {}
|
|
@@ -6,9 +9,11 @@ export const useGladlyUnifiedCXButton = ({
|
|
|
6
9
|
onSwitchToAgent,
|
|
7
10
|
}: UseGladlyUnifiedCXButtonProps): UnifiedCXButton => {
|
|
8
11
|
const gladlyButton = document.querySelector('[data-aid*="gladlyChatChatButton"]');
|
|
12
|
+
const enviveFloatingButton = useElementObserver(SelectorFactory.id(FLOATING_BUTTON_ID));
|
|
9
13
|
|
|
10
14
|
const toggle = () => {
|
|
11
15
|
onSwitchToAgent();
|
|
16
|
+
enviveFloatingButton.hide();
|
|
12
17
|
if (gladlyButton && gladlyButton instanceof HTMLElement) {
|
|
13
18
|
gladlyButton.click();
|
|
14
19
|
}
|
|
@@ -11,6 +11,7 @@ interface UseGorgiasUnifiedCXButtonProps extends CustomerServiceImplProps {}
|
|
|
11
11
|
|
|
12
12
|
export const useGorgiasUnifiedCXButton = ({
|
|
13
13
|
onSwitchToAgent,
|
|
14
|
+
onCXClose,
|
|
14
15
|
suppressMerchantButton,
|
|
15
16
|
}: UseGorgiasUnifiedCXButtonProps): UnifiedCXButton => {
|
|
16
17
|
const chatWindow = useElementObserver(SelectorFactory.id(CHAT_WINDOW_ID));
|
|
@@ -22,10 +23,7 @@ export const useGorgiasUnifiedCXButton = ({
|
|
|
22
23
|
onSwitchToAgent();
|
|
23
24
|
chatButton.show();
|
|
24
25
|
trigger.fire('click');
|
|
25
|
-
|
|
26
|
-
if (suppressMerchantButton) {
|
|
27
|
-
enviveFloatingButton.hide();
|
|
28
|
-
}
|
|
26
|
+
enviveFloatingButton.hide();
|
|
29
27
|
};
|
|
30
28
|
|
|
31
29
|
const isSwitchEnabled = () => !!SelectorFactory.chain(GORGIAS_BUTTON_SELECTOR).parse();
|
|
@@ -38,23 +36,28 @@ export const useGorgiasUnifiedCXButton = ({
|
|
|
38
36
|
});
|
|
39
37
|
|
|
40
38
|
chatWindow.onAdd(el => {
|
|
41
|
-
if (el
|
|
39
|
+
if (el) {
|
|
42
40
|
const styles = window.getComputedStyle(el);
|
|
43
41
|
const chatWindowDisplay = styles.getPropertyValue('display');
|
|
44
42
|
const chatButtonDisplay = chatButton.targetNode?.style.display;
|
|
45
43
|
|
|
46
44
|
if (chatWindowDisplay === 'block' && chatButtonDisplay === 'none') {
|
|
47
|
-
|
|
45
|
+
if (suppressMerchantButton) {
|
|
46
|
+
chatButton.show();
|
|
47
|
+
}
|
|
48
48
|
enviveFloatingButton.hide();
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
chatWindow.onChange(el => {
|
|
54
|
-
if (el
|
|
54
|
+
if (el) {
|
|
55
55
|
const styles = window.getComputedStyle(el);
|
|
56
56
|
if (styles.getPropertyValue('display') === 'none') {
|
|
57
|
-
|
|
57
|
+
onCXClose?.();
|
|
58
|
+
if (suppressMerchantButton) {
|
|
59
|
+
chatButton.hide();
|
|
60
|
+
}
|
|
58
61
|
enviveFloatingButton.show();
|
|
59
62
|
}
|
|
60
63
|
}
|
|
@@ -22,6 +22,7 @@ interface UseGrooveUnifiedCXButtonProps extends CustomerServiceImplProps {}
|
|
|
22
22
|
|
|
23
23
|
export const useGrooveUnifiedCXButton = ({
|
|
24
24
|
onSwitchToAgent,
|
|
25
|
+
onCXClose,
|
|
25
26
|
suppressMerchantButton,
|
|
26
27
|
}: UseGrooveUnifiedCXButtonProps): UnifiedCXButton => {
|
|
27
28
|
const grooveChatContainer = useElementObserver(
|
|
@@ -32,10 +33,7 @@ export const useGrooveUnifiedCXButton = ({
|
|
|
32
33
|
const previousIsOpenRef = useRef<boolean | undefined>(undefined);
|
|
33
34
|
|
|
34
35
|
const toggle = () => {
|
|
35
|
-
|
|
36
|
-
enviveFloatingButton.hide();
|
|
37
|
-
}
|
|
38
|
-
|
|
36
|
+
enviveFloatingButton.hide();
|
|
39
37
|
onSwitchToAgent();
|
|
40
38
|
if (windowGrooveWidget) {
|
|
41
39
|
windowGrooveWidget.open();
|
|
@@ -48,30 +46,29 @@ export const useGrooveUnifiedCXButton = ({
|
|
|
48
46
|
|
|
49
47
|
const hideEnviveFloatingButton = () => {
|
|
50
48
|
enviveFloatingButton.hide();
|
|
51
|
-
if (windowGrooveWidget) {
|
|
49
|
+
if (suppressMerchantButton && windowGrooveWidget) {
|
|
52
50
|
windowGrooveWidget.open();
|
|
53
51
|
}
|
|
54
52
|
};
|
|
55
53
|
|
|
56
54
|
const showEnviveFloatingButton = () => {
|
|
55
|
+
onCXClose?.();
|
|
57
56
|
enviveFloatingButton.show();
|
|
58
|
-
if (windowGrooveWidget) {
|
|
57
|
+
if (suppressMerchantButton && windowGrooveWidget) {
|
|
59
58
|
windowGrooveWidget.close();
|
|
60
59
|
}
|
|
61
60
|
};
|
|
62
61
|
|
|
63
62
|
grooveChatContainer.onChange(() => {
|
|
64
|
-
|
|
65
|
-
const isOpen = windowGrooveWidget?.shim.isOpen;
|
|
63
|
+
const isOpen = windowGrooveWidget?.shim.isOpen;
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
if (isOpen !== previousIsOpenRef.current) {
|
|
66
|
+
previousIsOpenRef.current = isOpen;
|
|
69
67
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
68
|
+
if (isOpen) {
|
|
69
|
+
hideEnviveFloatingButton();
|
|
70
|
+
} else {
|
|
71
|
+
showEnviveFloatingButton();
|
|
75
72
|
}
|
|
76
73
|
}
|
|
77
74
|
});
|
|
@@ -7,6 +7,7 @@ interface UseKustomerUnifiedCXButtonProps extends CustomerServiceImplProps {}
|
|
|
7
7
|
|
|
8
8
|
export const useKustomerUnifiedCXButton = ({
|
|
9
9
|
onSwitchToAgent,
|
|
10
|
+
onCXClose,
|
|
10
11
|
suppressMerchantButton,
|
|
11
12
|
}: UseKustomerUnifiedCXButtonProps): UnifiedCXButton => {
|
|
12
13
|
const kustomerButton = useElementObserver(
|
|
@@ -24,9 +25,7 @@ export const useKustomerUnifiedCXButton = ({
|
|
|
24
25
|
|
|
25
26
|
const toggle = () => {
|
|
26
27
|
onSwitchToAgent();
|
|
27
|
-
|
|
28
|
-
enviveFloatingButton.hide();
|
|
29
|
-
}
|
|
28
|
+
enviveFloatingButton.hide();
|
|
30
29
|
kustomerButton.show();
|
|
31
30
|
kustomerButton.fire('click');
|
|
32
31
|
};
|
|
@@ -53,16 +52,17 @@ export const useKustomerUnifiedCXButton = ({
|
|
|
53
52
|
});
|
|
54
53
|
|
|
55
54
|
kustomerWidgetRoot.onChange(async el => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
for (const child of el?.children || []) {
|
|
56
|
+
if ([...child.classList].some(cls => cls.includes('widget__widgetWrapper'))) {
|
|
57
|
+
enviveFloatingButton.hide();
|
|
58
|
+
if (suppressMerchantButton) {
|
|
60
59
|
kustomerButton.show();
|
|
61
60
|
kustomerNotification.show();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
)
|
|
65
|
-
|
|
61
|
+
}
|
|
62
|
+
} else if ([...child.classList].some(cls => cls.includes('chatRootIcon__chatIconWrapper'))) {
|
|
63
|
+
onCXClose?.();
|
|
64
|
+
enviveFloatingButton.show();
|
|
65
|
+
if (suppressMerchantButton) {
|
|
66
66
|
kustomerButton.hide();
|
|
67
67
|
kustomerNotification.hide();
|
|
68
68
|
}
|
|
@@ -13,6 +13,7 @@ interface UseReDoUnifiedCXButtonProps extends CustomerServiceImplProps {}
|
|
|
13
13
|
|
|
14
14
|
export const useReDoUnifiedCXButton = ({
|
|
15
15
|
onSwitchToAgent,
|
|
16
|
+
onCXClose,
|
|
16
17
|
suppressMerchantButton,
|
|
17
18
|
}: UseReDoUnifiedCXButtonProps): UnifiedCXButton => {
|
|
18
19
|
const chatContainer = useElementObserver(SelectorFactory.id(REDO_CHAT_CONTAINER_SELECTOR));
|
|
@@ -25,10 +26,7 @@ export const useReDoUnifiedCXButton = ({
|
|
|
25
26
|
onSwitchToAgent();
|
|
26
27
|
chatButton.show();
|
|
27
28
|
chatButton.fire('click');
|
|
28
|
-
|
|
29
|
-
if (suppressMerchantButton) {
|
|
30
|
-
enviveFloatingButton.hide();
|
|
31
|
-
}
|
|
29
|
+
enviveFloatingButton.hide();
|
|
32
30
|
};
|
|
33
31
|
|
|
34
32
|
const isReDoButtonEnabled = () => !!SelectorFactory.chain(REDO_BUTTON_SELECTOR).parse();
|
|
@@ -7,6 +7,7 @@ interface UseRichpanelUnifiedCXButtonProps extends CustomerServiceImplProps {}
|
|
|
7
7
|
|
|
8
8
|
export const useRichpanelUnifiedCXButton = ({
|
|
9
9
|
onSwitchToAgent,
|
|
10
|
+
onCXClose,
|
|
10
11
|
suppressMerchantButton,
|
|
11
12
|
}: UseRichpanelUnifiedCXButtonProps): UnifiedCXButton => {
|
|
12
13
|
const chatWindow = useElementObserver(
|
|
@@ -21,21 +22,16 @@ export const useRichpanelUnifiedCXButton = ({
|
|
|
21
22
|
const toggle = () => {
|
|
22
23
|
chatWindow.show();
|
|
23
24
|
onSwitchToAgent();
|
|
25
|
+
enviveFloatingButton.hide();
|
|
24
26
|
|
|
25
27
|
if (chatButton) {
|
|
26
28
|
chatButton.show();
|
|
27
29
|
chatButton.fire('click');
|
|
28
|
-
if (suppressMerchantButton) {
|
|
29
|
-
enviveFloatingButton.hide();
|
|
30
|
-
}
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
if (chatAlternativeButton) {
|
|
34
33
|
chatAlternativeButton.show();
|
|
35
34
|
chatAlternativeButton.fire('click');
|
|
36
|
-
if (suppressMerchantButton) {
|
|
37
|
-
enviveFloatingButton.hide();
|
|
38
|
-
}
|
|
39
35
|
}
|
|
40
36
|
};
|
|
41
37
|
|
|
@@ -62,16 +58,19 @@ export const useRichpanelUnifiedCXButton = ({
|
|
|
62
58
|
});
|
|
63
59
|
|
|
64
60
|
chatWindow.onChange(el => {
|
|
65
|
-
if (el
|
|
61
|
+
if (el) {
|
|
66
62
|
const { classList } = el;
|
|
67
63
|
if (classList.contains('opened')) {
|
|
68
64
|
enviveFloatingButton.hide();
|
|
69
65
|
chatWindow.show();
|
|
70
66
|
} else if (classList.length === 1 && classList.contains('rp-messenger-container')) {
|
|
67
|
+
onCXClose?.();
|
|
71
68
|
enviveFloatingButton.show();
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
if (suppressMerchantButton) {
|
|
70
|
+
chatButton.hide();
|
|
71
|
+
chatAlternativeButton.hide();
|
|
72
|
+
chatWindow.hide();
|
|
73
|
+
}
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
});
|
|
@@ -7,6 +7,7 @@ interface UseShopifyChatUnifiedCXButtonProps extends CustomerServiceImplProps {}
|
|
|
7
7
|
|
|
8
8
|
export const useShopifyChatUnifiedCXButton = ({
|
|
9
9
|
onSwitchToAgent,
|
|
10
|
+
onCXClose,
|
|
10
11
|
suppressMerchantButton,
|
|
11
12
|
}: UseShopifyChatUnifiedCXButtonProps): UnifiedCXButton => {
|
|
12
13
|
const shopifyChatContainer = useElementObserver(SelectorFactory.id('ShopifyChat'));
|
|
@@ -16,9 +17,7 @@ export const useShopifyChatUnifiedCXButton = ({
|
|
|
16
17
|
const enviveFloatingButton = useElementObserver(SelectorFactory.id(FLOATING_BUTTON_ID));
|
|
17
18
|
|
|
18
19
|
const toggle = () => {
|
|
19
|
-
|
|
20
|
-
enviveFloatingButton.hide();
|
|
21
|
-
}
|
|
20
|
+
enviveFloatingButton.hide();
|
|
22
21
|
shopifyButton.show();
|
|
23
22
|
onSwitchToAgent();
|
|
24
23
|
shopifyButton.fire('click');
|
|
@@ -30,45 +29,36 @@ export const useShopifyChatUnifiedCXButton = ({
|
|
|
30
29
|
|
|
31
30
|
const isSwitchEnabled = () => isShopifyButtonEnabled();
|
|
32
31
|
|
|
33
|
-
const hideEnviveFloatingButton = () => {
|
|
34
|
-
enviveFloatingButton.hide();
|
|
35
|
-
shopifyButton.show();
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const showEnviveFloatingButton = () => {
|
|
39
|
-
enviveFloatingButton.show();
|
|
40
|
-
shopifyButton.hide();
|
|
41
|
-
shopifyChatContainer.hide();
|
|
42
|
-
};
|
|
43
|
-
|
|
44
32
|
const handleChatStateChange = async (isOpen: boolean) => {
|
|
45
33
|
if (isOpen) {
|
|
46
|
-
|
|
34
|
+
enviveFloatingButton.hide();
|
|
35
|
+
if (suppressMerchantButton) {
|
|
36
|
+
shopifyButton.show();
|
|
37
|
+
}
|
|
47
38
|
return;
|
|
48
39
|
}
|
|
49
40
|
|
|
50
|
-
|
|
41
|
+
onCXClose?.();
|
|
42
|
+
enviveFloatingButton.show();
|
|
43
|
+
if (suppressMerchantButton) {
|
|
44
|
+
shopifyButton.hide();
|
|
45
|
+
shopifyChatContainer.hide();
|
|
46
|
+
}
|
|
51
47
|
};
|
|
52
48
|
|
|
53
49
|
shopifyButton.onAdd(() => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
handleChatStateChange(isOpen);
|
|
57
|
-
}
|
|
50
|
+
const isOpen = shopifyChatContainer.targetNode?.getAttribute('is-open') === 'true';
|
|
51
|
+
handleChatStateChange(isOpen);
|
|
58
52
|
});
|
|
59
53
|
|
|
60
54
|
shopifyChatContainer.onAdd(el => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
handleChatStateChange(isOpen);
|
|
64
|
-
}
|
|
55
|
+
const isOpen = el?.getAttribute('is-open') === 'true';
|
|
56
|
+
handleChatStateChange(isOpen);
|
|
65
57
|
});
|
|
66
58
|
|
|
67
59
|
shopifyChatContainer.onChange(el => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
handleChatStateChange(isOpen);
|
|
71
|
-
}
|
|
60
|
+
const isOpen = el?.getAttribute('is-open') === 'true';
|
|
61
|
+
handleChatStateChange(isOpen);
|
|
72
62
|
});
|
|
73
63
|
|
|
74
64
|
return {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { SelectorFactory } from '@envive-ai/react-hooks/application/utils';
|
|
2
|
+
import { useElementObserver } from '@envive-ai/react-hooks/hooks/ElementObserver';
|
|
3
|
+
import { FLOATING_BUTTON_ID } from '../../widgets/FloatingChatWidget/constants';
|
|
1
4
|
import { CustomerServiceImplProps, UnifiedCXButton } from '../types';
|
|
2
5
|
|
|
3
6
|
declare global {
|
|
@@ -15,9 +18,11 @@ export const useTidioUnifiedCXButton = ({
|
|
|
15
18
|
onSwitchToAgent,
|
|
16
19
|
}: UseTidioUnifiedCXButtonProps): UnifiedCXButton => {
|
|
17
20
|
const tidioButton = window.tidioChatApi;
|
|
21
|
+
const enviveFloatingButton = useElementObserver(SelectorFactory.id(FLOATING_BUTTON_ID));
|
|
18
22
|
|
|
19
23
|
const toggle = () => {
|
|
20
24
|
onSwitchToAgent();
|
|
25
|
+
enviveFloatingButton.hide();
|
|
21
26
|
if (tidioButton) {
|
|
22
27
|
tidioButton.open();
|
|
23
28
|
}
|
|
@@ -7,6 +7,7 @@ interface UseZendeskUnifiedCXButtonProps extends CustomerServiceImplProps {}
|
|
|
7
7
|
|
|
8
8
|
export const useZendeskUnifiedCXButton = ({
|
|
9
9
|
onSwitchToAgent,
|
|
10
|
+
onCXClose,
|
|
10
11
|
suppressMerchantButton,
|
|
11
12
|
}: UseZendeskUnifiedCXButtonProps): UnifiedCXButton => {
|
|
12
13
|
const zendeskButton = useElementObserver(SelectorFactory.chain('id|launcher @ query|button'));
|
|
@@ -18,9 +19,7 @@ export const useZendeskUnifiedCXButton = ({
|
|
|
18
19
|
zendeskIframe.hide();
|
|
19
20
|
onSwitchToAgent();
|
|
20
21
|
zendeskButton.fire('click');
|
|
21
|
-
|
|
22
|
-
enviveFloatingButton.hide();
|
|
23
|
-
}
|
|
22
|
+
enviveFloatingButton.hide();
|
|
24
23
|
};
|
|
25
24
|
|
|
26
25
|
const isZendeskButtonEnabled = () => {
|
|
@@ -40,22 +39,28 @@ export const useZendeskUnifiedCXButton = ({
|
|
|
40
39
|
});
|
|
41
40
|
|
|
42
41
|
zendeskButton.onChange(el => {
|
|
43
|
-
if (el
|
|
42
|
+
if (el) {
|
|
44
43
|
const ariaLabel = el.getAttribute('aria-label');
|
|
45
44
|
|
|
46
45
|
if (ariaLabel === 'Open messaging window') {
|
|
46
|
+
onCXClose?.();
|
|
47
47
|
enviveFloatingButton.show();
|
|
48
|
-
|
|
48
|
+
if (suppressMerchantButton) {
|
|
49
|
+
zendeskIframe.hide();
|
|
50
|
+
}
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
if (ariaLabel === 'Close messaging window') {
|
|
52
54
|
enviveFloatingButton.hide();
|
|
53
|
-
|
|
55
|
+
if (suppressMerchantButton) {
|
|
56
|
+
zendeskIframe.show();
|
|
57
|
+
}
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
60
|
});
|
|
57
61
|
|
|
58
62
|
zendeskAlternativeIframe.onRemove(() => {
|
|
63
|
+
onCXClose?.();
|
|
59
64
|
if (suppressMerchantButton) {
|
|
60
65
|
enviveFloatingButton.show();
|
|
61
66
|
zendeskIframe.hide();
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { SelectorFactory } from '@envive-ai/react-hooks/application/utils';
|
|
2
|
+
import { useElementObserver } from '@envive-ai/react-hooks/hooks/ElementObserver';
|
|
3
|
+
import { FLOATING_BUTTON_ID } from '../../widgets/FloatingChatWidget/constants';
|
|
1
4
|
import { CustomerServiceImplProps, UnifiedCXButton } from '../types';
|
|
2
5
|
|
|
3
6
|
declare global {
|
|
@@ -15,9 +18,11 @@ export const useZowieUnifiedCXButton = ({
|
|
|
15
18
|
onSwitchToAgent,
|
|
16
19
|
}: UseZowieUnifiedCXButtonProps): UnifiedCXButton => {
|
|
17
20
|
const zowieButton = window?.Zowie;
|
|
21
|
+
const enviveFloatingButton = useElementObserver(SelectorFactory.id(FLOATING_BUTTON_ID));
|
|
18
22
|
|
|
19
23
|
const toggle = () => {
|
|
20
24
|
onSwitchToAgent();
|
|
25
|
+
enviveFloatingButton.hide();
|
|
21
26
|
if (zowieButton) {
|
|
22
27
|
zowieButton?.open();
|
|
23
28
|
}
|
package/src/debug/debugBar.tsx
CHANGED
|
@@ -3,7 +3,6 @@ import { ReportIssue } from './reportIssue';
|
|
|
3
3
|
|
|
4
4
|
export const DebugBar = () => {
|
|
5
5
|
const { showDebugBar } = useSystemSettingsContext();
|
|
6
|
-
console.log('=== showDebugBar ===', showDebugBar);
|
|
7
6
|
if (!showDebugBar) return null;
|
|
8
7
|
return (
|
|
9
8
|
<div className="envive-tw-flex envive-tw-items-center envive-tw-p-[4px]">
|