@axos-web-dev/shared-components 1.0.100-dev.3 → 1.0.100-feature-buydown.1

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 (83) hide show
  1. package/dist/ATMLocator/ATMLocator.js +1 -7
  2. package/dist/ArticlesSet/ArticlesSet.js +2 -2
  3. package/dist/Auth/ErrorAlert.js +1 -7
  4. package/dist/Button/Button.js +1 -7
  5. package/dist/Calculators/BuyDownCalculator/index.d.ts +1 -0
  6. package/dist/Calculators/BuyDownCalculator/index.js +161 -71
  7. package/dist/Calculators/Calculator.js +1 -7
  8. package/dist/Carousel/index.js +1 -7
  9. package/dist/Chevron/index.js +1 -7
  10. package/dist/Comparison/Comparison.js +1 -7
  11. package/dist/ExecutiveBio/ExecutiveBio.js +1 -7
  12. package/dist/FaqAccordion/index.js +1 -7
  13. package/dist/FooterSiteMap/AxosBank/FooterSiteMap.js +1 -7
  14. package/dist/Forms/ApplyNow.js +1 -7
  15. package/dist/Forms/ContactUsBusiness.js +1 -7
  16. package/dist/Forms/ContactUsBusinessNameEmail.js +1 -7
  17. package/dist/Forms/ContactUsNMLSId.js +1 -7
  18. package/dist/Forms/CraPublicFile.js +1 -7
  19. package/dist/Forms/EmailOnly.js +1 -7
  20. package/dist/Forms/MortgageRate/MortgageRateForm.js +1 -7
  21. package/dist/Forms/MortgageRate/MortgageRateWatch.js +1 -7
  22. package/dist/Forms/MortgageWarehouseLending.js +1 -7
  23. package/dist/Forms/QuickPricer/QuickPricerForm.js +1 -1
  24. package/dist/Forms/SalesforceFieldsForm.d.ts +5 -0
  25. package/dist/Forms/SalesforceFieldsForm.js +11 -1
  26. package/dist/Forms/SuccesForm.js +1 -7
  27. package/dist/Hyperlink/index.js +1 -7
  28. package/dist/ImageLink/ImageLink.js +1 -7
  29. package/dist/ImageLink/ImageLinkSet.js +1 -7
  30. package/dist/ImageLink/index.js +1 -7
  31. package/dist/Input/Dropdown.js +1 -0
  32. package/dist/Insight/Featured/CategorySelector.js +1 -7
  33. package/dist/Insight/Featured/Featured.js +1 -7
  34. package/dist/Insight/Featured/Header.js +1 -7
  35. package/dist/Modal/Modal.js +1 -7
  36. package/dist/NavigationMenu/AxosALTS/NavData.js +1 -7
  37. package/dist/NavigationMenu/AxosALTS/index.js +1 -7
  38. package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.js +1 -7
  39. package/dist/NavigationMenu/AxosBank/NavData.js +1 -7
  40. package/dist/NavigationMenu/AxosBank/SubNavBar.js +1 -7
  41. package/dist/NavigationMenu/AxosBank/index.js +1 -7
  42. package/dist/NavigationMenu/LaVictoire/NavData.js +1 -7
  43. package/dist/NavigationMenu/LaVictoire/index.js +1 -7
  44. package/dist/NavigationMenu/NavDataJson.js +1 -7
  45. package/dist/NavigationMenu/Navbar.js +1 -7
  46. package/dist/NavigationMenu/SignInNavButton.js +1 -7
  47. package/dist/SetContainer/SetContainer.js +1 -7
  48. package/dist/SocialMediaBar/iconsRepository.js +1 -7
  49. package/dist/Table/Table.d.ts +1 -1
  50. package/dist/VideoTile/VideoTile.js +1 -7
  51. package/dist/VideoWrapper/index.js +1 -7
  52. package/dist/WalnutIframe/wrapper.module.js +3 -3
  53. package/dist/assets/WalnutIframe/wrapper.css.css +49 -49
  54. package/dist/main.d.ts +0 -1
  55. package/dist/main.js +0 -33
  56. package/package.json +133 -136
  57. package/dist/Chatbot/Bubble.css.d.ts +0 -2
  58. package/dist/Chatbot/Bubble.css.js +0 -7
  59. package/dist/Chatbot/Bubble.d.ts +0 -3
  60. package/dist/Chatbot/Bubble.js +0 -100
  61. package/dist/Chatbot/Chat.d.ts +0 -1
  62. package/dist/Chatbot/Chat.js +0 -165
  63. package/dist/Chatbot/ChatWindow.css.d.ts +0 -14
  64. package/dist/Chatbot/ChatWindow.css.js +0 -31
  65. package/dist/Chatbot/ChatWindow.d.ts +0 -23
  66. package/dist/Chatbot/ChatWindow.js +0 -208
  67. package/dist/Chatbot/Chatbot.css.d.ts +0 -2
  68. package/dist/Chatbot/Chatbot.css.js +0 -7
  69. package/dist/Chatbot/Chatbot.css.ts.vanilla.css.js +0 -1
  70. package/dist/Chatbot/Chatbot.d.ts +0 -5
  71. package/dist/Chatbot/Chatbot.js +0 -39
  72. package/dist/Chatbot/authenticate.d.ts +0 -3
  73. package/dist/Chatbot/authenticate.js +0 -16
  74. package/dist/Chatbot/index.d.ts +0 -9
  75. package/dist/Chatbot/index.js +0 -36
  76. package/dist/Chatbot/store/chat.d.ts +0 -9
  77. package/dist/Chatbot/store/chat.js +0 -11
  78. package/dist/Chatbot/store/messages.d.ts +0 -14
  79. package/dist/Chatbot/store/messages.js +0 -12
  80. package/dist/Chatbot/useHeadlessChat.d.ts +0 -22
  81. package/dist/Chatbot/useHeadlessChat.js +0 -157
  82. package/dist/assets/Chatbot/Bubble.css +0 -51
  83. package/dist/assets/Chatbot/ChatWindow.css +0 -157
@@ -1,208 +0,0 @@
1
- "use client";
2
- import { jsxs, jsx } from "react/jsx-runtime";
3
- import clsx from "clsx";
4
- import React, { useRef, useEffect, Fragment } from "react";
5
- import ReactMarkdown from "react-markdown";
6
- import remarkGfm from "remark-gfm";
7
- import { useOpenChat } from "./store/chat.js";
8
- import { windowBarStyle, chat_title, button_reset, arrowFill, notificationStyle, messageStyle, inline_button_wrapper, inline_button, endChatButtonStyle, messagesContainerStyle, inputStyle, sendButtonStyle, windowStyle, windowOpenStyle } from "./ChatWindow.css.js";
9
- const ChatWindow = ({
10
- messages,
11
- status = "connected",
12
- onSend,
13
- inputDisabled = false,
14
- onClose,
15
- endChat = () => {
16
- console.log("End chat");
17
- }
18
- }) => {
19
- const [input, setInput] = React.useState("");
20
- const messagesEndRef = useRef(null);
21
- const isOpen = useOpenChat((state) => state.isOpen);
22
- useEffect(() => {
23
- messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
24
- }, [messages]);
25
- const handleSend = (e) => {
26
- e.preventDefault();
27
- if (input.trim()) {
28
- onSend(input);
29
- setInput("");
30
- }
31
- };
32
- const project = process.env.CCAI_PROJECT_ID;
33
- const isAxos = project === "axos";
34
- const endUserBg = isAxos ? "#14263d" : "#323339";
35
- const chatbotBg = isAxos ? "#E9F8FF" : "#EAE8E8";
36
- return /* @__PURE__ */ jsxs("div", { className: clsx(windowStyle, isOpen && windowOpenStyle), children: [
37
- /* @__PURE__ */ jsxs("div", { className: windowBarStyle, children: [
38
- /* @__PURE__ */ jsxs("div", { className: "flex middle", style: { paddingBlock: "6px" }, children: [
39
- /* @__PURE__ */ jsx(
40
- "img",
41
- {
42
- src: "https://www.axos.com/images/2xmVfQm5l0HWOKjgxQO1Iw/axb-assistant.svg",
43
- style: { marginRight: 12 },
44
- height: 18,
45
- width: 18
46
- }
47
- ),
48
- /* @__PURE__ */ jsx("h2", { className: chat_title, children: "Evo Virtual Assistant" })
49
- ] }),
50
- onClose && /* @__PURE__ */ jsx(
51
- "button",
52
- {
53
- onClick: onClose,
54
- className: button_reset,
55
- "aria-label": "Close chat",
56
- title: "Close",
57
- children: /* @__PURE__ */ jsx(
58
- "svg",
59
- {
60
- xmlns: "http://www.w3.org/2000/svg",
61
- width: "24",
62
- height: "24",
63
- viewBox: "0 0 24 24",
64
- fill: "none",
65
- children: /* @__PURE__ */ jsx(
66
- "path",
67
- {
68
- className: arrowFill,
69
- d: "M2.46875 7.76574L11.9991 17.2961L21.5294 7.76574L20.4687 6.70508L11.9991 15.1749L3.52941 6.70508L2.46875 7.76574Z",
70
- fill: "#98DDFF"
71
- }
72
- )
73
- }
74
- )
75
- }
76
- )
77
- ] }),
78
- /* @__PURE__ */ jsxs("div", { className: clsx(messagesContainerStyle), children: [
79
- messages?.map((msg) => /* @__PURE__ */ jsxs(Fragment, { children: [
80
- msg.type == "noti" && msg.$userType == "system" && msg.event == "escalationStarted" && /* @__PURE__ */ jsx("div", { className: notificationStyle, children: "We are connecting you with a human agent..." }, msg.$index),
81
- msg.type == "noti" && msg.$userType == "system" && msg.event == "memberLeft" && /* @__PURE__ */ jsxs("div", { className: notificationStyle, children: [
82
- /* @__PURE__ */ jsx("strong", { children: "Virtual Agent" }),
83
- " just left the conversation."
84
- ] }, msg.$index),
85
- msg.type == "noti" && msg.$userType == "system" && msg.event == "escalationAccepted" && /* @__PURE__ */ jsxs("div", { className: notificationStyle, children: [
86
- "You are now connected with a",
87
- " ",
88
- msg.to_agent ? /* @__PURE__ */ jsx("strong", { children: msg?.to_agent?.name }) : "an agent"
89
- ] }, msg.$index),
90
- ["text", "markdown_template", "markdown"].includes(msg.type) && /* @__PURE__ */ jsxs(
91
- "div",
92
- {
93
- className: messageStyle,
94
- style: {
95
- textAlign: msg.$userType == "end_user" ? "right" : "left",
96
- alignSelf: msg.$userType == "end_user" ? "flex-end" : "flex-start",
97
- background: msg.$userType == "end_user" ? endUserBg : chatbotBg,
98
- color: msg.$userType == "end_user" ? "#fff" : "#1F1F1F",
99
- boxShadow: msg.$userType == "end_user" ? "0 1px 4px #b3e0ff55" : void 0
100
- },
101
- children: [
102
- /* @__PURE__ */ jsx(
103
- "div",
104
- {
105
- style: {
106
- fontSize: 13,
107
- display: "flex",
108
- flexDirection: "column",
109
- gap: 4
110
- },
111
- children: /* @__PURE__ */ jsx(
112
- ReactMarkdown,
113
- {
114
- remarkPlugins: [[remarkGfm, { singleTilde: false }]],
115
- components: {
116
- p: ({ ...props }) => /* @__PURE__ */ jsx(
117
- "p",
118
- {
119
- style: { margin: 0, fontSize: "inherit" },
120
- ...props
121
- }
122
- )
123
- },
124
- children: msg.content
125
- }
126
- )
127
- }
128
- ),
129
- /* @__PURE__ */ jsx("div", { style: { fontSize: 10, color: "#888", marginTop: 2 } })
130
- ]
131
- },
132
- msg.$index
133
- ),
134
- msg.type == "inline_button" && Array.isArray(msg.buttons) && msg.buttons.length > 0 && /* @__PURE__ */ jsx("div", { className: inline_button_wrapper, children: msg.buttons.length !== 0 && Array.isArray(msg.buttons) && msg.buttons.map((button, index) => {
135
- const lastItem = msg.buttons && msg.buttons?.length - 1;
136
- return /* @__PURE__ */ jsx(
137
- "button",
138
- {
139
- className: inline_button,
140
- style: {
141
- borderRadius: "0px",
142
- borderTopLeftRadius: [0].includes(index) ? 8 : 0,
143
- borderTopRightRadius: [0].includes(index) ? 8 : 0,
144
- borderBottomLeftRadius: [lastItem].includes(index) ? 8 : 0,
145
- borderBottomRightRadius: [lastItem].includes(index) ? 8 : 0
146
- },
147
- onClick: () => {
148
- onSend(button?.title);
149
- },
150
- children: button.title
151
- },
152
- index
153
- );
154
- }) }),
155
- msg.event == "chatEnded" && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("button", { className: endChatButtonStyle, onClick: endChat, children: "End Chat" }) })
156
- ] }, msg.$index)),
157
- /* @__PURE__ */ jsx("div", { ref: messagesEndRef })
158
- ] }),
159
- /* @__PURE__ */ jsxs(
160
- "form",
161
- {
162
- onSubmit: handleSend,
163
- style: {
164
- borderTop: "1px solid #eee",
165
- display: "flex",
166
- gap: 8
167
- },
168
- children: [
169
- /* @__PURE__ */ jsx(
170
- "input",
171
- {
172
- type: "text",
173
- value: input,
174
- onChange: (e) => setInput(e.target.value),
175
- placeholder: "Ask something...",
176
- className: inputStyle,
177
- disabled: inputDisabled || status !== "connected"
178
- }
179
- ),
180
- /* @__PURE__ */ jsx(
181
- "button",
182
- {
183
- className: clsx(sendButtonStyle, input.trim().length > 0 && "active"),
184
- type: "submit",
185
- disabled: inputDisabled || status !== "connected" || !input.trim(),
186
- children: /* @__PURE__ */ jsxs(
187
- "svg",
188
- {
189
- xmlns: "http://www.w3.org/2000/svg",
190
- id: "send-icon",
191
- width: 24,
192
- height: 24,
193
- children: [
194
- /* @__PURE__ */ jsx("path", { d: "M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" }),
195
- /* @__PURE__ */ jsx("path", { d: "M0 0h24v24H0z", fill: "none" })
196
- ]
197
- }
198
- )
199
- }
200
- )
201
- ]
202
- }
203
- )
204
- ] });
205
- };
206
- export {
207
- ChatWindow
208
- };
@@ -1,2 +0,0 @@
1
- export declare const chatbotAXB: string;
2
- export declare const chatbotUFB: string;
@@ -1,7 +0,0 @@
1
- import "./Chatbot.css.ts.vanilla.css.js";
2
- var chatbotAXB = "_1hpv6vm0";
3
- var chatbotUFB = "_1hpv6vm1";
4
- export {
5
- chatbotAXB,
6
- chatbotUFB
7
- };
@@ -1,5 +0,0 @@
1
- export type ChatbotProps = {
2
- project?: "axos" | "ufb";
3
- debug?: boolean;
4
- };
5
- export declare const Chatbot: (props: ChatbotProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,39 +0,0 @@
1
- "use client";
2
- import { jsxs, jsx } from "react/jsx-runtime";
3
- import { authenticate } from "./authenticate.js";
4
- import { Bubble } from "./Bubble.js";
5
- import { ChatWindow } from "./ChatWindow.js";
6
- import { useOpenChat } from "./store/chat.js";
7
- import { useMessages } from "./store/messages.js";
8
- import { useHeadlessChat } from "./useHeadlessChat.js";
9
- import { chatbotUFB, chatbotAXB } from "./Chatbot.css.js";
10
- const Chatbot = (props) => {
11
- const messages = useMessages((state) => state.messages);
12
- const close = useOpenChat((state) => state.close);
13
- const { status, sendMessage } = useHeadlessChat({
14
- companyId: process.env.CCAI_COMPANY_ID || "",
15
- tenant: process.env.CCAI_TENANT_NAME || "",
16
- host: process.env.CCAI_HOST || "",
17
- // or your region
18
- projectId: process.env.CCAI_PROJECT_ID || props.project || "axos",
19
- getToken: authenticate,
20
- debug: props.debug || process.env.NODE_ENV === "development"
21
- });
22
- return /* @__PURE__ */ jsxs("div", { className: props.project === "ufb" ? chatbotUFB : chatbotAXB, children: [
23
- /* @__PURE__ */ jsx(Bubble, {}),
24
- /* @__PURE__ */ jsx(
25
- ChatWindow,
26
- {
27
- status,
28
- onClose: close,
29
- messages,
30
- onSend: function(msg) {
31
- sendMessage(msg);
32
- }
33
- }
34
- )
35
- ] });
36
- };
37
- export {
38
- Chatbot
39
- };
@@ -1,3 +0,0 @@
1
- export declare const authenticate: () => Promise<{
2
- token: any;
3
- }>;
@@ -1,16 +0,0 @@
1
- const AUTH_URL = process.env.AUTH_CHAT_URL || "http://localhost:3000/api/auth/token";
2
- const authenticate = async () => {
3
- const res = await fetch(AUTH_URL, {
4
- method: "GET",
5
- headers: {
6
- "Content-Type": "application/json"
7
- }
8
- });
9
- const data = await res.json();
10
- return {
11
- token: data.token
12
- };
13
- };
14
- export {
15
- authenticate
16
- };
@@ -1,9 +0,0 @@
1
- export * from './Bubble';
2
- export * from './Bubble.css';
3
- export * from './Chatbot';
4
- export * from './Chatbot.css';
5
- export * from './ChatWindow';
6
- export * from './ChatWindow.css';
7
- export * from './store/chat';
8
- export * from './store/messages';
9
- export * from './useHeadlessChat';
@@ -1,36 +0,0 @@
1
- "use client";
2
- import { Bubble } from "./Bubble.js";
3
- import { bubbleWrapper, svgFill } from "./Bubble.css.js";
4
- import { Chatbot } from "./Chatbot.js";
5
- import { chatbotAXB, chatbotUFB } from "./Chatbot.css.js";
6
- import { ChatWindow } from "./ChatWindow.js";
7
- import { arrowFill, button_reset, chat_title, endChatButtonStyle, inline_button, inline_button_wrapper, inputStyle, messageStyle, messagesContainerStyle, notificationStyle, sendButtonStyle, windowBarStyle, windowOpenStyle, windowStyle } from "./ChatWindow.css.js";
8
- import { useOpenChat } from "./store/chat.js";
9
- import { useMessages } from "./store/messages.js";
10
- import { useHeadlessChat } from "./useHeadlessChat.js";
11
- export {
12
- Bubble,
13
- ChatWindow,
14
- Chatbot,
15
- arrowFill,
16
- bubbleWrapper,
17
- button_reset,
18
- chat_title,
19
- chatbotAXB,
20
- chatbotUFB,
21
- endChatButtonStyle,
22
- inline_button,
23
- inline_button_wrapper,
24
- inputStyle,
25
- messageStyle,
26
- messagesContainerStyle,
27
- notificationStyle,
28
- sendButtonStyle,
29
- svgFill,
30
- useHeadlessChat,
31
- useMessages,
32
- useOpenChat,
33
- windowBarStyle,
34
- windowOpenStyle,
35
- windowStyle
36
- };
@@ -1,9 +0,0 @@
1
- interface OpenChatState {
2
- isOpen: boolean;
3
- toggle: () => void;
4
- open: () => void;
5
- close: () => void;
6
- reset: () => void;
7
- }
8
- export declare const useOpenChat: import('zustand').UseBoundStore<import('zustand').StoreApi<OpenChatState>>;
9
- export {};
@@ -1,11 +0,0 @@
1
- import { create } from "zustand";
2
- const useOpenChat = create((set) => ({
3
- isOpen: false,
4
- toggle: () => set((state) => ({ isOpen: !state.isOpen })),
5
- open: () => set({ isOpen: true }),
6
- close: () => set({ isOpen: false }),
7
- reset: () => set({ isOpen: false })
8
- }));
9
- export {
10
- useOpenChat
11
- };
@@ -1,14 +0,0 @@
1
- import { MessageResponse } from '@ujet/websdk-headless';
2
-
3
- interface MessageStore {
4
- messages: MessageResponse[];
5
- addMessage: (message: MessageResponse) => void;
6
- removeMessage: (id: string) => void;
7
- addMessages: (newMessages: MessageResponse[]) => void;
8
- }
9
- export interface Message {
10
- id: string;
11
- text: string;
12
- }
13
- export declare const useMessages: import('zustand').UseBoundStore<import('zustand').StoreApi<MessageStore>>;
14
- export {};
@@ -1,12 +0,0 @@
1
- import { create } from "zustand";
2
- const useMessages = create((set) => ({
3
- messages: [],
4
- addMessage: (message) => set((state) => ({ messages: [...state.messages, message] })),
5
- removeMessage: (id) => set((state) => ({
6
- messages: state.messages.filter((msg) => msg.id !== id)
7
- })),
8
- addMessages: (newMessages) => set((state) => ({ messages: [...state.messages, ...newMessages] }))
9
- }));
10
- export {
11
- useMessages
12
- };
@@ -1,22 +0,0 @@
1
- import { TokenResponse } from '@ujet/websdk-headless';
2
-
3
- interface UseHeadlessChatOptions {
4
- companyId: string;
5
- tenant: string;
6
- host: string;
7
- getToken: () => Promise<TokenResponse>;
8
- channelId?: string;
9
- projectId?: "axos" | "" | "ufb" | string;
10
- debug?: boolean;
11
- }
12
- export interface ChatMessage {
13
- id: string;
14
- body: string;
15
- sender?: string;
16
- timestamp?: string;
17
- }
18
- export declare function useHeadlessChat({ companyId, tenant, host, getToken, projectId, debug, }: UseHeadlessChatOptions): {
19
- status: "error" | "idle" | "connected" | "connecting" | "finished";
20
- sendMessage: (body: string) => Promise<void>;
21
- };
22
- export {};
@@ -1,157 +0,0 @@
1
- "use client";
2
- import { useState, useRef, useCallback, useEffect } from "react";
3
- import { useMessages } from "./store/messages.js";
4
- function useHeadlessChat({
5
- companyId,
6
- tenant,
7
- host,
8
- getToken,
9
- projectId = "axos",
10
- debug = false
11
- }) {
12
- const addMessage = useMessages((state) => state.addMessage);
13
- const addMessages = useMessages((state) => state.addMessages);
14
- const [status, setStatus] = useState("idle");
15
- const chatRef = useRef(null);
16
- const clientRef = useRef(null);
17
- const isMountedRef = useRef(true);
18
- const hasLoadedBefore = useRef(true);
19
- const sendMessage = useCallback(async (body) => {
20
- if (chatRef.current) {
21
- await clientRef.current?.sendTextMessage(body);
22
- }
23
- }, []);
24
- useEffect(() => {
25
- let messageHandler;
26
- let chatReadyHandler;
27
- let chatEndedHandler;
28
- let chatConnectedHandler;
29
- let chatDisconnectedHandler;
30
- let memberLeftHandler;
31
- let memberJoinedHandler;
32
- let startTypingHandler;
33
- let stopTypingHandler;
34
- let chatTimeoutHandler;
35
- async function init() {
36
- setStatus("connecting");
37
- const { Client, Logger, consoleLoggerHandler } = await import("@ujet/websdk-headless");
38
- if (debug) Logger.addHandler(consoleLoggerHandler);
39
- try {
40
- clientRef.current = new Client({
41
- companyId,
42
- tenant,
43
- host,
44
- authenticate: getToken
45
- });
46
- if (debug) console.log("clientRef:", clientRef.current);
47
- } catch (e) {
48
- console.error("Error creating client:", e);
49
- if (isMountedRef.current) setStatus("error");
50
- return;
51
- }
52
- const menus = await clientRef.current?.getMenus();
53
- if (debug) console.log("channelId:", menus);
54
- if (debug) console.log("channelId:", menus?.menus[5].id);
55
- try {
56
- chatRef.current = await clientRef.current?.createChat(
57
- menus.menus[5].id
58
- // {
59
- // custom_data: {
60
- // unsigned: {
61
- // facingBrandId: brandMap.get(projectId) || 1,
62
- // },
63
- // },
64
- // }
65
- );
66
- if (debug) console.log("chatRef:", chatRef.current);
67
- } catch (error) {
68
- console.error("Error creating chat:", error);
69
- }
70
- messageHandler = (msg) => {
71
- if (debug) console.log("Received message:", msg);
72
- addMessage(msg);
73
- };
74
- chatReadyHandler = () => {
75
- console.log("Chat is ready");
76
- };
77
- chatEndedHandler = () => {
78
- console.log("Chat has ended");
79
- setStatus("finished");
80
- };
81
- chatConnectedHandler = async () => {
82
- console.log("Chat connected");
83
- setStatus("connected");
84
- const messagesFetched = await chatRef.current?.fetchMessages();
85
- if (debug) console.log("[messages]:", messagesFetched);
86
- addMessages(messagesFetched || []);
87
- };
88
- startTypingHandler = (identity) => {
89
- console.log("start typing: ", identity);
90
- };
91
- stopTypingHandler = (identity) => {
92
- console.log("stop typing: ", identity);
93
- };
94
- memberLeftHandler = (identity) => {
95
- console.log("Member has left the chat: ", identity);
96
- };
97
- memberJoinedHandler = (identity) => {
98
- console.log("Member has joined the chat: ", identity);
99
- };
100
- chatDisconnectedHandler = () => {
101
- console.log("Chat disconnected");
102
- setStatus("idle");
103
- };
104
- chatTimeoutHandler = () => {
105
- console.log("Chat timeout");
106
- };
107
- clientRef.current?.on("ready", chatReadyHandler);
108
- clientRef.current?.on("chat.connected", chatConnectedHandler);
109
- clientRef.current?.on("chat.message", messageHandler);
110
- clientRef.current?.on("chat.memberLeft", memberLeftHandler);
111
- clientRef.current?.on("chat.memberJoined", memberJoinedHandler);
112
- clientRef.current?.on("chat.typingStarted", startTypingHandler);
113
- clientRef.current?.on("chat.typingEnded", stopTypingHandler);
114
- clientRef.current?.on("chat.disconnected", chatDisconnectedHandler);
115
- clientRef.current?.on("chat.ended", chatEndedHandler);
116
- clientRef.current?.on("chat.timeout", chatTimeoutHandler);
117
- }
118
- if (hasLoadedBefore.current) {
119
- if (debug) console.log("Initializing chat...");
120
- init();
121
- hasLoadedBefore.current = false;
122
- }
123
- return () => {
124
- isMountedRef.current = false;
125
- if (debug)
126
- console.log(
127
- "Component unmounted. Cancelling pending async operations."
128
- );
129
- chatRef.current = null;
130
- clientRef.current?.off("ready", chatReadyHandler);
131
- clientRef.current?.off("chat.message", messageHandler);
132
- clientRef.current?.off("chat.connected", chatConnectedHandler);
133
- clientRef.current?.off("chat.ended", chatEndedHandler);
134
- clientRef.current?.off("chat.memberLeft", memberLeftHandler);
135
- clientRef.current?.off("chat.memberJoined", memberJoinedHandler);
136
- clientRef.current?.off("chat.typingStarted", startTypingHandler);
137
- clientRef.current?.off("chat.typingEnded", stopTypingHandler);
138
- clientRef.current?.off("chat.disconnected", chatDisconnectedHandler);
139
- clientRef.current?.off("chat.timeout", chatTimeoutHandler);
140
- clientRef.current?.destroyChat();
141
- clientRef.current = null;
142
- };
143
- }, [
144
- companyId,
145
- tenant,
146
- host,
147
- getToken,
148
- addMessage,
149
- addMessages,
150
- debug,
151
- projectId
152
- ]);
153
- return { status, sendMessage };
154
- }
155
- export {
156
- useHeadlessChat
157
- };
@@ -1,51 +0,0 @@
1
- @keyframes fade-in-bounce {
2
- 0% {
3
- transform: translate3d(100px,100px,0) scale(0.3);
4
- opacity: 0;
5
- }
6
- 50% {
7
- transform: translate3d(-10px,-10px,0) scale(1.1);
8
- opacity: 1;
9
- }
10
- 100% {
11
- transform: translate3d(0,0,0) scale(1);
12
- opacity: 1;
13
- }
14
- }
15
- @keyframes pulse {
16
- 0%,100% {
17
- box-shadow: 0 0 0 0 rgba(0,123,255,0.4);
18
- }
19
- 50% {
20
- box-shadow: 0 0 0 10px rgba(0,123,255,0);
21
- }
22
- }
23
- ._7u9pv30 {
24
- align-items: center;
25
- animation: fade-in-bounce 2s cubic-bezier(0.65, 0.25, 0.14, 0.93) forwards, pulse 4.5s 0.5s;
26
- background-color: #14263d;
27
- border-radius: 50%;
28
- bottom: 16px;
29
- cursor: pointer;
30
- display: grid;
31
- font-family: var(--main-font-family);
32
- height: 68px;
33
- line-height: 1;
34
- outline: 2px solid #98DDFF;
35
- place-items: center;
36
- position: fixed;
37
- right: 16px;
38
- width: 68px;
39
- z-index: 9999;
40
- }
41
- ._1hpv6vm1 ._7u9pv30 {
42
- animation: fade-in-bounce 2s cubic-bezier(0.65, 0.25, 0.14, 0.93) forwards;
43
- background-color: #60707A;
44
- outline: none;
45
- }
46
- ._7u9pv31 {
47
- fill: #98DDFF;
48
- }
49
- ._1hpv6vm1 ._7u9pv31 {
50
- fill: #FFFFFF;
51
- }