@envive-ai/react-widgets-v3 0.3.24 → 0.3.26

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.
Files changed (77) hide show
  1. package/dist/CXIntegration/hooks/useUnifiedCXButton.cjs +1 -1
  2. package/dist/CXIntegration/hooks/useUnifiedCXButton.js +1 -1
  3. package/dist/CXIntegration/implementations/useTidioUnifiedCXButton.cjs +24 -5
  4. package/dist/CXIntegration/implementations/useTidioUnifiedCXButton.js +24 -5
  5. package/dist/debug/MessageContent.cjs +1 -1
  6. package/dist/debug/MessageContent.js +1 -1
  7. package/dist/debug/chatEmbed.cjs +3 -3
  8. package/dist/debug/chatEmbed.js +2 -2
  9. package/dist/debug/reportIssue.cjs +2 -2
  10. package/dist/debug/reportIssue.js +2 -2
  11. package/dist/hocs/withBaseWidget/types.d.ts +1 -1
  12. package/dist/hocs/withBaseWidget/withBaseWidget.cjs +1 -1
  13. package/dist/hocs/withBaseWidget/withBaseWidget.d.ts +2 -2
  14. package/dist/hocs/withBaseWidget/withBaseWidget.js +1 -1
  15. package/dist/packages/widgets/dist/SearchResults/SearchResultsWidget.d.ts +2 -2
  16. package/dist/packages/widgets/dist/SuggestionBar/SuggestionBar.d.ts +2 -2
  17. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs +3 -3
  18. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +3 -3
  19. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +3 -3
  20. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +3 -3
  21. package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.cjs +1 -1
  22. package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
  23. package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
  24. package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.js +1 -1
  25. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.cjs +3 -3
  26. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.cts +3 -3
  27. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +3 -3
  28. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.js +3 -3
  29. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +4 -4
  30. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +2 -2
  31. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +2 -2
  32. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +4 -4
  33. package/dist/widgets/FloatingChatWidget/hooks/useAutoPopup.cjs +1 -1
  34. package/dist/widgets/FloatingChatWidget/hooks/useAutoPopup.js +1 -1
  35. package/dist/widgets/FloatingChatWidget/hooks/useFloatingButtonVisibility.cjs +1 -1
  36. package/dist/widgets/FloatingChatWidget/hooks/useFloatingButtonVisibility.js +1 -1
  37. package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.cjs +1 -1
  38. package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.cts +2 -2
  39. package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.ts +2 -2
  40. package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.js +1 -1
  41. package/dist/widgets/ProductCardWidget/ProductCardWidget.cjs +3 -3
  42. package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +2 -2
  43. package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +2 -2
  44. package/dist/widgets/ProductCardWidget/ProductCardWidget.js +3 -3
  45. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +3 -3
  46. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +3 -3
  47. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +3 -3
  48. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +3 -3
  49. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +3 -3
  50. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
  51. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +2 -2
  52. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +3 -3
  53. package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.cjs +1 -1
  54. package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
  55. package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.js +1 -1
  56. package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +3 -3
  57. package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
  58. package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
  59. package/dist/widgets/SocialProofWidget/SocialProofWidget.js +3 -3
  60. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +3 -3
  61. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
  62. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +2 -2
  63. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +3 -3
  64. package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.cjs +1 -1
  65. package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
  66. package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.js +1 -1
  67. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.cjs +9 -10
  68. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
  69. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
  70. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +9 -10
  71. package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.cts +2 -2
  72. package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.cts +2 -2
  73. package/dist/widgets/hooks/useGetWidgetStatus.cjs +1 -1
  74. package/dist/widgets/hooks/useGetWidgetStatus.js +1 -1
  75. package/package.json +1 -1
  76. package/src/CXIntegration/implementations/useTidioUnifiedCXButton.ts +29 -7
  77. package/src/widgets/TypingAnimationWidget/TypingAnimationWidget.tsx +6 -7
@@ -2,18 +2,17 @@ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
2
  const require_withBaseWidget = require('../../hocs/withBaseWidget/withBaseWidget.cjs');
3
3
  require('../../hocs/withBaseWidget/index.cjs');
4
4
  const require_functions = require('../utils/functions.cjs');
5
+ let react = require("react");
6
+ let __envive_ai_react_hooks_contexts_amplitudeContext = require("@envive-ai/react-hooks/contexts/amplitudeContext");
7
+ let react_jsx_runtime = require("react/jsx-runtime");
5
8
  let __envive_ai_react_hooks_contexts_salesAgentContext = require("@envive-ai/react-hooks/contexts/salesAgentContext");
6
9
  let __envive_ai_react_hooks_contexts_typesV3 = require("@envive-ai/react-hooks/contexts/typesV3");
7
- let jotai = require("jotai");
10
+ let __envive_ai_react_hooks_hooks_ChatToggle = require("@envive-ai/react-hooks/hooks/ChatToggle");
8
11
  let __envive_ai_react_hooks_contexts_featureFlagServiceContext = require("@envive-ai/react-hooks/contexts/featureFlagServiceContext");
9
12
  let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
10
- let __envive_ai_react_hooks_contexts_amplitudeContext = require("@envive-ai/react-hooks/contexts/amplitudeContext");
11
13
  let __envive_ai_react_hooks_hooks_WidgetInteraction = require("@envive-ai/react-hooks/hooks/WidgetInteraction");
12
14
  let __envive_ai_react_hooks_hooks_WidgetInteraction_types = require("@envive-ai/react-hooks/hooks/WidgetInteraction/types");
13
15
  let __envive_ai_react_toolkit_v3_PromptCarousel = require("@envive-ai/react-toolkit-v3/PromptCarousel");
14
- let react = require("react");
15
- let react_jsx_runtime = require("react/jsx-runtime");
16
- let __envive_ai_react_hooks_atoms_chat_chatState = require("@envive-ai/react-hooks/atoms/chat/chatState");
17
16
  let __envive_ai_react_toolkit_v3_PromptButton_types = require("@envive-ai/react-toolkit-v3/PromptButton/types");
18
17
  let __envive_ai_react_toolkit_v3_TypingAnimation = require("@envive-ai/react-toolkit-v3/TypingAnimation");
19
18
  let __envive_ai_react_toolkit_v3_WidgetWrapper = require("@envive-ai/react-toolkit-v3/WidgetWrapper");
@@ -31,7 +30,7 @@ const mockAnimatedTextSequence = ["..."];
31
30
  const mockHintText = "Ask me anything";
32
31
  const TypingAnimationWidgetHandler = (props) => {
33
32
  const { onTypedMessageSubmitted } = (0, __envive_ai_react_hooks_contexts_salesAgentContext.useSalesAgent)();
34
- const onToggle = (0, jotai.useSetAtom)(__envive_ai_react_hooks_atoms_chat_chatState.chatOnToggleAtom);
33
+ const { openChat } = (0, __envive_ai_react_hooks_hooks_ChatToggle.useChatToggle)();
35
34
  const { hardcopyContent, widgetConfig, uiConfig, isLoading } = props;
36
35
  const titleLabel = hardcopyContent?.values?.titleLabel || "";
37
36
  const headlineText = hardcopyContent?.values?.headlineText || "";
@@ -74,16 +73,16 @@ const TypingAnimationWidgetHandler = (props) => {
74
73
  userTyped: false,
75
74
  displayLocation: __envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.TYPING_ANIMATION
76
75
  });
77
- onToggle(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.TYPING_ANIMATION);
76
+ openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.TYPING_ANIMATION);
78
77
  onPromptClicked(text);
79
78
  }, [
80
79
  hardcopyContent,
81
80
  trackEvent,
82
81
  onTypedMessageSubmitted,
83
- onToggle
82
+ openChat
84
83
  ]);
85
84
  const handleTextFieldClick = (0, react.useCallback)(() => {
86
- onToggle(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.TYPING_ANIMATION);
85
+ openChat(__envive_ai_react_hooks_application_models.ChatElementDisplayLocationV3.TYPING_ANIMATION);
87
86
  trackWidgetInteraction({
88
87
  eventName: __envive_ai_react_hooks_contexts_amplitudeContext.EnviveMetricsEventName.WidgetInteraction,
89
88
  trigger: {
@@ -91,7 +90,7 @@ const TypingAnimationWidgetHandler = (props) => {
91
90
  widget_interaction: __envive_ai_react_hooks_hooks_WidgetInteraction_types.WidgetInteractionType.QUERY_INPUT_CLICKED
92
91
  }
93
92
  });
94
- }, [onToggle]);
93
+ }, [openChat]);
95
94
  const handleTranscriptionStarted = (0, react.useCallback)(() => {
96
95
  trackWidgetInteraction({
97
96
  eventName: __envive_ai_react_hooks_contexts_amplitudeContext.EnviveMetricsEventName.WidgetInteraction,
@@ -1,9 +1,9 @@
1
1
  import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.cjs";
2
- import * as react_jsx_runtime12 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime1 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts
5
5
  declare const TypingAnimationWithBaseWidget: {
6
- (props: BaseWidgetProps): react_jsx_runtime12.JSX.Element;
6
+ (props: BaseWidgetProps): react_jsx_runtime1.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): react_jsx_runtime12.JSX.Element;
15
+ }: TypingAnimationWidgetProps): react_jsx_runtime1.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 react_jsx_runtime12 from "react/jsx-runtime";
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): react_jsx_runtime12.JSX.Element;
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): react_jsx_runtime12.JSX.Element;
15
+ }: TypingAnimationWidgetProps): react_jsx_runtime18.JSX.Element;
16
16
  displayName: string;
17
17
  };
18
18
  //#endregion
@@ -1,18 +1,17 @@
1
1
  import { withBaseWidget } from "../../hocs/withBaseWidget/withBaseWidget.js";
2
2
  import "../../hocs/withBaseWidget/index.js";
3
3
  import { getStringIdForText } from "../utils/functions.js";
4
+ import { useCallback } from "react";
5
+ import { EnviveMetricsEventName, useAmplitude } from "@envive-ai/react-hooks/contexts/amplitudeContext";
6
+ import { jsx } from "react/jsx-runtime";
4
7
  import { useSalesAgent } from "@envive-ai/react-hooks/contexts/salesAgentContext";
5
8
  import { WidgetTypeV3 } from "@envive-ai/react-hooks/contexts/typesV3";
6
- import { useSetAtom } from "jotai";
9
+ import { useChatToggle } from "@envive-ai/react-hooks/hooks/ChatToggle";
7
10
  import { useFeatureFlagService } from "@envive-ai/react-hooks/contexts/featureFlagServiceContext";
8
11
  import { ChatElementDisplayLocationV3, FeatureGates } from "@envive-ai/react-hooks/application/models";
9
- import { EnviveMetricsEventName, useAmplitude } from "@envive-ai/react-hooks/contexts/amplitudeContext";
10
12
  import { useWidgetInteraction } from "@envive-ai/react-hooks/hooks/WidgetInteraction";
11
13
  import { WidgetInteractionComponent, WidgetInteractionType } from "@envive-ai/react-hooks/hooks/WidgetInteraction/types";
12
14
  import { PromptCarouselRows, usePromptCarouselAnalytics } from "@envive-ai/react-toolkit-v3/PromptCarousel";
13
- import { useCallback } from "react";
14
- import { jsx } from "react/jsx-runtime";
15
- import { chatOnToggleAtom } from "@envive-ai/react-hooks/atoms/chat/chatState";
16
15
  import { PromptButtonVariant } from "@envive-ai/react-toolkit-v3/PromptButton/types";
17
16
  import { TypingAnimation } from "@envive-ai/react-toolkit-v3/TypingAnimation";
18
17
  import { WidgetWrapperVariant } from "@envive-ai/react-toolkit-v3/WidgetWrapper";
@@ -30,7 +29,7 @@ const mockAnimatedTextSequence = ["..."];
30
29
  const mockHintText = "Ask me anything";
31
30
  const TypingAnimationWidgetHandler = (props) => {
32
31
  const { onTypedMessageSubmitted } = useSalesAgent();
33
- const onToggle = useSetAtom(chatOnToggleAtom);
32
+ const { openChat } = useChatToggle();
34
33
  const { hardcopyContent, widgetConfig, uiConfig, isLoading } = props;
35
34
  const titleLabel = hardcopyContent?.values?.titleLabel || "";
36
35
  const headlineText = hardcopyContent?.values?.headlineText || "";
@@ -73,16 +72,16 @@ const TypingAnimationWidgetHandler = (props) => {
73
72
  userTyped: false,
74
73
  displayLocation: ChatElementDisplayLocationV3.TYPING_ANIMATION
75
74
  });
76
- onToggle(ChatElementDisplayLocationV3.TYPING_ANIMATION);
75
+ openChat(ChatElementDisplayLocationV3.TYPING_ANIMATION);
77
76
  onPromptClicked(text);
78
77
  }, [
79
78
  hardcopyContent,
80
79
  trackEvent,
81
80
  onTypedMessageSubmitted,
82
- onToggle
81
+ openChat
83
82
  ]);
84
83
  const handleTextFieldClick = useCallback(() => {
85
- onToggle(ChatElementDisplayLocationV3.TYPING_ANIMATION);
84
+ openChat(ChatElementDisplayLocationV3.TYPING_ANIMATION);
86
85
  trackWidgetInteraction({
87
86
  eventName: EnviveMetricsEventName.WidgetInteraction,
88
87
  trigger: {
@@ -90,7 +89,7 @@ const TypingAnimationWidgetHandler = (props) => {
90
89
  widget_interaction: WidgetInteractionType.QUERY_INPUT_CLICKED
91
90
  }
92
91
  });
93
- }, [onToggle]);
92
+ }, [openChat]);
94
93
  const handleTranscriptionStarted = useCallback(() => {
95
94
  trackWidgetInteraction({
96
95
  eventName: EnviveMetricsEventName.WidgetInteraction,
@@ -1,8 +1,8 @@
1
- import * as react_jsx_runtime2 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime1 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: () => react_jsx_runtime2.JSX.Element;
5
+ declare const SearchResultsWidget: () => react_jsx_runtime1.JSX.Element;
6
6
  //#endregion
7
7
 
8
8
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { SuggestionBarLocationForMetrics } from "./types.cjs";
2
- import * as react_jsx_runtime0 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime2 from "react/jsx-runtime";
3
3
  import { SuggestionButtonVariant } from "@envive-ai/react-hooks/contexts/types";
4
4
  import { Message } from "postcss";
5
5
 
@@ -30,7 +30,7 @@ declare function SuggestionBar({
30
30
  buttonBorderRadius,
31
31
  handleReply,
32
32
  dataTestId
33
- }: Readonly<SuggestionBarProps>): react_jsx_runtime0.JSX.Element;
33
+ }: Readonly<SuggestionBarProps>): react_jsx_runtime2.JSX.Element;
34
34
  //#endregion
35
35
  //#endregion
36
36
  export { SuggestionBar };
@@ -1,8 +1,8 @@
1
1
  const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
2
  const require_functions = require('../utils/functions.cjs');
3
+ let react = require("react");
3
4
  let __envive_ai_react_hooks_atoms_chat = require("@envive-ai/react-hooks/atoms/chat");
4
5
  let jotai = require("jotai");
5
- let react = require("react");
6
6
  let __envive_ai_react_hooks_atoms_chat_chatState = require("@envive-ai/react-hooks/atoms/chat/chatState");
7
7
 
8
8
  //#region src/widgets/hooks/useGetWidgetStatus.tsx
@@ -1,7 +1,7 @@
1
1
  import { isLoading, isProductComparison, userHasInteracted, userHasNotInteracted } from "../utils/functions.js";
2
+ import { useMemo } from "react";
2
3
  import { chatAtom, lastAssistantMessageAtom } from "@envive-ai/react-hooks/atoms/chat";
3
4
  import { useAtomValue } from "jotai";
4
- import { useMemo } from "react";
5
5
  import { responseStreamingAtom } from "@envive-ai/react-hooks/atoms/chat/chatState";
6
6
 
7
7
  //#region src/widgets/hooks/useGetWidgetStatus.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envive-ai/react-widgets-v3",
3
- "version": "0.3.24",
3
+ "version": "0.3.26",
4
4
  "description": "React widget library v3 for Envive services.",
5
5
  "keywords": [
6
6
  "react",
@@ -3,6 +3,9 @@ import { useElementObserver } from '@envive-ai/react-hooks/hooks/ElementObserver
3
3
  import { FLOATING_BUTTON_ID } from '../../widgets/FloatingChatWidget/constants';
4
4
  import { CustomerServiceImplProps, UnifiedCXButton } from '../types';
5
5
 
6
+ const CHAT_BUTTON_ID = 'tidio-chat';
7
+ const CHAT_BUTTON_SELECTOR = 'id|tidio-chat @ id|button';
8
+
6
9
  declare global {
7
10
  interface Window {
8
11
  tidioChatApi?: {
@@ -16,21 +19,40 @@ interface UseTidioUnifiedCXButtonProps extends CustomerServiceImplProps {}
16
19
 
17
20
  export const useTidioUnifiedCXButton = ({
18
21
  onSwitchToAgent,
22
+ onCXClose,
23
+ suppressMerchantButton,
19
24
  }: UseTidioUnifiedCXButtonProps): UnifiedCXButton => {
20
- const tidioButton = window.tidioChatApi;
25
+ const tidioApi = window.tidioChatApi;
21
26
  const enviveFloatingButton = useElementObserver(SelectorFactory.id(FLOATING_BUTTON_ID));
27
+ const tidioChatButton = useElementObserver(SelectorFactory.chain(CHAT_BUTTON_SELECTOR));
28
+ const tidioFrame = useElementObserver(SelectorFactory.id(CHAT_BUTTON_ID));
29
+
30
+ const chatButtonControl = (el: HTMLElement | null) => {
31
+ if (el) {
32
+ if (el.className.includes('chat-closed')) {
33
+ onCXClose?.();
34
+ if (suppressMerchantButton) {
35
+ tidioFrame.hide();
36
+ }
37
+ enviveFloatingButton.show();
38
+ }
39
+ if (el.className.includes('chat-open')) {
40
+ tidioFrame.show();
41
+ enviveFloatingButton.show();
42
+ }
43
+ }
44
+ };
45
+ tidioChatButton.onAdd(chatButtonControl);
46
+ tidioChatButton.onChange(chatButtonControl);
22
47
 
23
48
  const toggle = () => {
24
49
  onSwitchToAgent();
25
50
  enviveFloatingButton.hide();
26
- if (tidioButton) {
27
- tidioButton.open();
28
- }
51
+ tidioFrame.show();
52
+ tidioApi?.open();
29
53
  };
30
54
 
31
- const isTidioButtonEnabled = () => !!document.getElementById('tidio-chat-iframe');
32
-
33
- const isSwitchEnabled = () => isTidioButtonEnabled();
55
+ const isSwitchEnabled = () => !!SelectorFactory.chain(CHAT_BUTTON_SELECTOR).parse();
34
56
 
35
57
  return {
36
58
  toggle,
@@ -2,7 +2,6 @@ import {
2
2
  ChatElementDisplayLocationV3,
3
3
  FeatureGates,
4
4
  } from '@envive-ai/react-hooks/application/models';
5
- import { chatOnToggleAtom } from '@envive-ai/react-hooks/atoms/chat/chatState';
6
5
  import {
7
6
  EnviveMetricsEventName,
8
7
  useAmplitude,
@@ -25,7 +24,7 @@ import {
25
24
  } from '@envive-ai/react-toolkit-v3/PromptCarousel';
26
25
  import { TypingAnimation } from '@envive-ai/react-toolkit-v3/TypingAnimation';
27
26
  import { WidgetWrapperVariant } from '@envive-ai/react-toolkit-v3/WidgetWrapper';
28
- import { useSetAtom } from 'jotai';
27
+ import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
29
28
  import { useCallback } from 'react';
30
29
  import { BaseWidgetProps, withBaseWidget } from '../../hocs/withBaseWidget';
31
30
  import { RawValues, getStringIdForText } from '../utils/functions';
@@ -44,7 +43,7 @@ const mockHintText = 'Ask me anything';
44
43
 
45
44
  const TypingAnimationWidgetHandler = (props: BaseWidgetProps) => {
46
45
  const { onTypedMessageSubmitted } = useSalesAgent();
47
- const onToggle = useSetAtom(chatOnToggleAtom);
46
+ const { openChat } = useChatToggle();
48
47
 
49
48
  const { hardcopyContent, widgetConfig, uiConfig, isLoading } = props;
50
49
 
@@ -110,14 +109,14 @@ const TypingAnimationWidgetHandler = (props: BaseWidgetProps) => {
110
109
  userTyped: false,
111
110
  displayLocation: ChatElementDisplayLocationV3.TYPING_ANIMATION,
112
111
  });
113
- onToggle(ChatElementDisplayLocationV3.TYPING_ANIMATION);
112
+ openChat(ChatElementDisplayLocationV3.TYPING_ANIMATION);
114
113
  onPromptClicked(text);
115
114
  },
116
- [hardcopyContent, trackEvent, onTypedMessageSubmitted, onToggle],
115
+ [hardcopyContent, trackEvent, onTypedMessageSubmitted, openChat],
117
116
  );
118
117
 
119
118
  const handleTextFieldClick = useCallback(() => {
120
- onToggle(ChatElementDisplayLocationV3.TYPING_ANIMATION);
119
+ openChat(ChatElementDisplayLocationV3.TYPING_ANIMATION);
121
120
  trackWidgetInteraction({
122
121
  eventName: EnviveMetricsEventName.WidgetInteraction,
123
122
  trigger: {
@@ -125,7 +124,7 @@ const TypingAnimationWidgetHandler = (props: BaseWidgetProps) => {
125
124
  widget_interaction: WidgetInteractionType.QUERY_INPUT_CLICKED,
126
125
  },
127
126
  });
128
- }, [onToggle]);
127
+ }, [openChat]);
129
128
 
130
129
  const handleTranscriptionStarted = useCallback(() => {
131
130
  trackWidgetInteraction({