@envive-ai/react-widgets-v3 0.3.11 → 0.3.13
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/useEightByEightUnifiedCXButton.cjs +54 -0
- package/dist/CXIntegration/implementations/useEightByEightUnifiedCXButton.js +53 -0
- 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 +9 -7
- package/dist/CXIntegration/implementations/useZendeskUnifiedCXButton.js +9 -7
- package/dist/CXIntegration/implementations/useZowieUnifiedCXButton.cjs +6 -0
- package/dist/CXIntegration/implementations/useZowieUnifiedCXButton.js +6 -0
- package/dist/CXIntegration/types.cjs +1 -0
- package/dist/CXIntegration/types.js +1 -0
- package/dist/CXIntegration/utils/functions.cjs +2 -0
- package/dist/CXIntegration/utils/functions.js +2 -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/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/ProductCardWidget/ProductCardWidget.d.cts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +2 -2
- 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.cjs +8 -8
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.cts +2 -2
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.js +8 -8
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +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.cjs +8 -8
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.cts +2 -2
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.js +8 -8
- 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/package.json +1 -1
- package/src/CXIntegration/hooks/useUnifiedCXButton.ts +4 -1
- package/src/CXIntegration/implementations/useEightByEightUnifiedCXButton.ts +91 -0
- 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 +15 -8
- package/src/CXIntegration/implementations/useZowieUnifiedCXButton.ts +5 -0
- package/src/CXIntegration/types.ts +2 -0
- package/src/CXIntegration/utils/functions.ts +4 -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/SocialProofFlowWidget/SocialProofFlowWidget.tsx +12 -12
- package/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.tsx +1 -1
- package/src/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.tsx +12 -12
|
@@ -10,21 +10,21 @@ import { ChatPreviewLoading } from "@envive-ai/react-toolkit-v3/ChatPreviewLoadi
|
|
|
10
10
|
//#region src/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.tsx
|
|
11
11
|
const TypingAnimationFlowWidget = ({ widgetConfigId }) => {
|
|
12
12
|
const { userHasInteractedValue, userHasNotInteractedValue, isLoadingValue, isProductComparisonValue } = useGetWidgetStatus_default();
|
|
13
|
-
if (userHasInteractedValue) return /* @__PURE__ */ jsx(
|
|
13
|
+
if (userHasInteractedValue && isLoadingValue) return /* @__PURE__ */ jsx(ChatPreviewLoadingWidgetWithBaseWidget, {
|
|
14
14
|
widgetConfigId,
|
|
15
|
-
widgetType: WidgetTypeV3.
|
|
15
|
+
widgetType: WidgetTypeV3.ChatPreviewLoadingV3
|
|
16
16
|
});
|
|
17
|
-
if (
|
|
17
|
+
if (userHasInteractedValue && isProductComparisonValue) return /* @__PURE__ */ jsx(ChatPreviewComparisonWidgetWithBaseWidget, {
|
|
18
18
|
widgetConfigId,
|
|
19
|
-
widgetType: WidgetTypeV3.
|
|
19
|
+
widgetType: WidgetTypeV3.ChatPreviewComparisonV3
|
|
20
20
|
});
|
|
21
|
-
if (
|
|
21
|
+
if (userHasInteractedValue) return /* @__PURE__ */ jsx(ChatPreviewWidgetWithBaseWidget, {
|
|
22
22
|
widgetConfigId,
|
|
23
|
-
widgetType: WidgetTypeV3.
|
|
23
|
+
widgetType: WidgetTypeV3.ChatPreviewV3
|
|
24
24
|
});
|
|
25
|
-
if (
|
|
25
|
+
if (userHasNotInteractedValue) return /* @__PURE__ */ jsx(TypingAnimationWithBaseWidget, {
|
|
26
26
|
widgetConfigId,
|
|
27
|
-
widgetType: WidgetTypeV3.
|
|
27
|
+
widgetType: WidgetTypeV3.TypingAnimationV3
|
|
28
28
|
});
|
|
29
29
|
return /* @__PURE__ */ jsx(ChatPreviewLoading, { fullIsLoading: true });
|
|
30
30
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime18 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts
|
|
5
5
|
declare const TypingAnimationWithBaseWidget: {
|
|
6
|
-
(props: BaseWidgetProps):
|
|
6
|
+
(props: BaseWidgetProps): react_jsx_runtime18.JSX.Element;
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
interface TypingAnimationWidgetProps {
|
|
@@ -12,7 +12,7 @@ interface TypingAnimationWidgetProps {
|
|
|
12
12
|
declare const TypingAnimationWidget: {
|
|
13
13
|
({
|
|
14
14
|
widgetConfigId
|
|
15
|
-
}: TypingAnimationWidgetProps):
|
|
15
|
+
}: TypingAnimationWidgetProps): react_jsx_runtime18.JSX.Element;
|
|
16
16
|
displayName: string;
|
|
17
17
|
};
|
|
18
18
|
//#endregion
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime7 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts
|
|
5
5
|
declare const TypingAnimationWithBaseWidget: {
|
|
6
|
-
(props: BaseWidgetProps):
|
|
6
|
+
(props: BaseWidgetProps): react_jsx_runtime7.JSX.Element;
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
interface TypingAnimationWidgetProps {
|
|
@@ -12,7 +12,7 @@ interface TypingAnimationWidgetProps {
|
|
|
12
12
|
declare const TypingAnimationWidget: {
|
|
13
13
|
({
|
|
14
14
|
widgetConfigId
|
|
15
|
-
}: TypingAnimationWidgetProps):
|
|
15
|
+
}: TypingAnimationWidgetProps): react_jsx_runtime7.JSX.Element;
|
|
16
16
|
displayName: string;
|
|
17
17
|
};
|
|
18
18
|
//#endregion
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region ../widgets/dist/SearchResults/SearchResultsWidget.d.ts
|
|
4
4
|
//#region src/SearchResults/SearchResultsWidget.d.ts
|
|
5
|
-
declare const SearchResultsWidget: () =>
|
|
5
|
+
declare const SearchResultsWidget: () => react_jsx_runtime0.JSX.Element;
|
|
6
6
|
//#endregion
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region ../widgets/dist/SearchZeroState/SearchZeroStateWidget.d.ts
|
|
4
4
|
//#region src/SearchZeroState/SearchZeroStateWidget.d.ts
|
|
@@ -11,7 +11,7 @@ declare const SearchZeroStateWidget: ({
|
|
|
11
11
|
initialIsOpen,
|
|
12
12
|
widgetConfigId,
|
|
13
13
|
entryPointRef
|
|
14
|
-
}: SearchZeroStateWidgetProps) =>
|
|
14
|
+
}: SearchZeroStateWidgetProps) => react_jsx_runtime2.JSX.Element;
|
|
15
15
|
//#endregion
|
|
16
16
|
|
|
17
17
|
//#endregion
|
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
|
|
|
@@ -0,0 +1,91 @@
|
|
|
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';
|
|
4
|
+
import { CustomerServiceImplProps, UnifiedCXButton } from '../types';
|
|
5
|
+
|
|
6
|
+
interface UseEightByEightUnifiedCXButtonProps extends CustomerServiceImplProps {}
|
|
7
|
+
|
|
8
|
+
const EIGHT_BY_EIGHT_BUBBLE_SELECTOR = 'div[id^="__8x8-chat-button-container-script"]';
|
|
9
|
+
|
|
10
|
+
const EIGHT_BY_EIGHT_BUTTON_SELECTOR = `${EIGHT_BY_EIGHT_BUBBLE_SELECTOR} a[data-type="online"], ${EIGHT_BY_EIGHT_BUBBLE_SELECTOR} a[data-type="offline"]`;
|
|
11
|
+
|
|
12
|
+
const EIGHT_BY_EIGHT_CHAT_WINDOW_SELECTOR = 'div.__8x8Chat-Container';
|
|
13
|
+
|
|
14
|
+
export const useEightByEightUnifiedCXButton = ({
|
|
15
|
+
onSwitchToAgent,
|
|
16
|
+
onCXClose,
|
|
17
|
+
suppressMerchantButton,
|
|
18
|
+
}: UseEightByEightUnifiedCXButtonProps): UnifiedCXButton => {
|
|
19
|
+
const eightByEightBubble = useElementObserver(
|
|
20
|
+
SelectorFactory.query(EIGHT_BY_EIGHT_BUBBLE_SELECTOR),
|
|
21
|
+
);
|
|
22
|
+
const eightByEightChatWindow = useElementObserver(
|
|
23
|
+
SelectorFactory.query(EIGHT_BY_EIGHT_CHAT_WINDOW_SELECTOR),
|
|
24
|
+
);
|
|
25
|
+
const enviveFloatingButton = useElementObserver(SelectorFactory.id(FLOATING_BUTTON_ID));
|
|
26
|
+
|
|
27
|
+
const isEightByEightEnabled = () => !!document.querySelector(EIGHT_BY_EIGHT_BUTTON_SELECTOR);
|
|
28
|
+
|
|
29
|
+
const toggle = () => {
|
|
30
|
+
const button = document.querySelector(EIGHT_BY_EIGHT_BUTTON_SELECTOR) as HTMLElement | null;
|
|
31
|
+
|
|
32
|
+
if (!button) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
onSwitchToAgent();
|
|
37
|
+
enviveFloatingButton.hide();
|
|
38
|
+
|
|
39
|
+
button.click();
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const isSwitchEnabled = () => isEightByEightEnabled();
|
|
43
|
+
|
|
44
|
+
eightByEightBubble.onAdd(el => {
|
|
45
|
+
if (suppressMerchantButton && el) {
|
|
46
|
+
eightByEightBubble.hide();
|
|
47
|
+
}
|
|
48
|
+
enviveFloatingButton.show();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
eightByEightBubble.onChange(el => {
|
|
52
|
+
if (!el || !suppressMerchantButton) return;
|
|
53
|
+
|
|
54
|
+
const styles = window.getComputedStyle(el);
|
|
55
|
+
const display = styles.getPropertyValue('display');
|
|
56
|
+
if (display !== 'none') {
|
|
57
|
+
eightByEightBubble.hide();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
eightByEightChatWindow.onChange(el => {
|
|
62
|
+
if (!el) return;
|
|
63
|
+
|
|
64
|
+
const rect = el.getBoundingClientRect();
|
|
65
|
+
const isOpen = rect.width > 50 && rect.height > 50;
|
|
66
|
+
|
|
67
|
+
if (isOpen) {
|
|
68
|
+
enviveFloatingButton.hide();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
onCXClose?.();
|
|
73
|
+
if (suppressMerchantButton) {
|
|
74
|
+
eightByEightBubble.hide();
|
|
75
|
+
}
|
|
76
|
+
enviveFloatingButton.show();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
eightByEightChatWindow.onRemove(() => {
|
|
80
|
+
onCXClose?.();
|
|
81
|
+
if (suppressMerchantButton) {
|
|
82
|
+
eightByEightBubble.hide();
|
|
83
|
+
}
|
|
84
|
+
enviveFloatingButton.show();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
toggle,
|
|
89
|
+
isSwitchEnabled,
|
|
90
|
+
};
|
|
91
|
+
};
|
|
@@ -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,20 +7,21 @@ interface UseZendeskUnifiedCXButtonProps extends CustomerServiceImplProps {}
|
|
|
7
7
|
|
|
8
8
|
export const useZendeskUnifiedCXButton = ({
|
|
9
9
|
onSwitchToAgent,
|
|
10
|
+
onCXClose,
|
|
10
11
|
suppressMerchantButton,
|
|
11
12
|
}: UseZendeskUnifiedCXButtonProps): UnifiedCXButton => {
|
|
12
|
-
const zendeskButton = useElementObserver(
|
|
13
|
+
const zendeskButton = useElementObserver(
|
|
14
|
+
SelectorFactory.chain('query|iframe#launcher @ query|button'),
|
|
15
|
+
);
|
|
13
16
|
const zendeskAlternativeIframe = useElementObserver(SelectorFactory.chain('id|webWidget'));
|
|
14
17
|
const enviveFloatingButton = useElementObserver(SelectorFactory.id(FLOATING_BUTTON_ID));
|
|
15
|
-
const zendeskIframe = useElementObserver(SelectorFactory.
|
|
18
|
+
const zendeskIframe = useElementObserver(SelectorFactory.query('iframe#launcher'));
|
|
16
19
|
|
|
17
20
|
const toggle = () => {
|
|
18
21
|
zendeskIframe.hide();
|
|
19
22
|
onSwitchToAgent();
|
|
20
23
|
zendeskButton.fire('click');
|
|
21
|
-
|
|
22
|
-
enviveFloatingButton.hide();
|
|
23
|
-
}
|
|
24
|
+
enviveFloatingButton.hide();
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
const isZendeskButtonEnabled = () => {
|
|
@@ -40,22 +41,28 @@ export const useZendeskUnifiedCXButton = ({
|
|
|
40
41
|
});
|
|
41
42
|
|
|
42
43
|
zendeskButton.onChange(el => {
|
|
43
|
-
if (el
|
|
44
|
+
if (el) {
|
|
44
45
|
const ariaLabel = el.getAttribute('aria-label');
|
|
45
46
|
|
|
46
47
|
if (ariaLabel === 'Open messaging window') {
|
|
48
|
+
onCXClose?.();
|
|
47
49
|
enviveFloatingButton.show();
|
|
48
|
-
|
|
50
|
+
if (suppressMerchantButton) {
|
|
51
|
+
zendeskIframe.hide();
|
|
52
|
+
}
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
if (ariaLabel === 'Close messaging window') {
|
|
52
56
|
enviveFloatingButton.hide();
|
|
53
|
-
|
|
57
|
+
if (suppressMerchantButton) {
|
|
58
|
+
zendeskIframe.show();
|
|
59
|
+
}
|
|
54
60
|
}
|
|
55
61
|
}
|
|
56
62
|
});
|
|
57
63
|
|
|
58
64
|
zendeskAlternativeIframe.onRemove(() => {
|
|
65
|
+
onCXClose?.();
|
|
59
66
|
if (suppressMerchantButton) {
|
|
60
67
|
enviveFloatingButton.show();
|
|
61
68
|
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
|
}
|