@axos-web-dev/shared-components 2.2.5 → 2.2.6

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 (64) hide show
  1. package/dist/ATMLocator/ATMLocator.js +1 -0
  2. package/dist/Auth/ErrorAlert.js +1 -0
  3. package/dist/Button/Button.js +1 -0
  4. package/dist/Calculators/Calculator.js +2 -1
  5. package/dist/Calculators/MarginTradingCalculator/index.js +1 -0
  6. package/dist/Carousel/index.js +1 -0
  7. package/dist/Chatbot/AudioManager.d.ts +19 -0
  8. package/dist/Chatbot/AudioManager.js +61 -0
  9. package/dist/Chatbot/ChatWindow.css.d.ts +2 -0
  10. package/dist/Chatbot/ChatWindow.css.js +34 -30
  11. package/dist/Chatbot/ChatWindow.js +382 -363
  12. package/dist/Chatbot/Chatbot.d.ts +3 -0
  13. package/dist/Chatbot/Chatbot.js +24 -1
  14. package/dist/Chatbot/ExpandChatToggle.d.ts +8 -0
  15. package/dist/Chatbot/ExpandChatToggle.js +74 -0
  16. package/dist/Chatbot/index.js +5 -2
  17. package/dist/Chatbot/store/chat.d.ts +8 -0
  18. package/dist/Chatbot/store/chat.js +14 -2
  19. package/dist/Chevron/index.js +1 -0
  20. package/dist/Comparison/Comparison.js +1 -0
  21. package/dist/ExecutiveBio/ExecutiveBio.js +1 -0
  22. package/dist/FaqAccordion/index.js +1 -0
  23. package/dist/FooterSiteMap/AxosBank/FooterSiteMap.js +1 -0
  24. package/dist/Forms/ApplyNow.js +1 -0
  25. package/dist/Forms/ContactUsBusiness.js +1 -0
  26. package/dist/Forms/ContactUsBusinessNameEmail.js +1 -0
  27. package/dist/Forms/ContactUsNMLSId.js +1 -0
  28. package/dist/Forms/CpraRequest.js +1 -0
  29. package/dist/Forms/CraPublicFile.js +1 -0
  30. package/dist/Forms/EmailOnly.js +1 -0
  31. package/dist/Forms/MortgageRate/MortgageRateForm.js +1 -0
  32. package/dist/Forms/MortgageRate/MortgageRateWatch.js +1 -0
  33. package/dist/Forms/MortgageWarehouseLending.js +1 -0
  34. package/dist/Forms/SuccesForm.js +2 -1
  35. package/dist/Hyperlink/index.js +1 -0
  36. package/dist/ImageLink/ImageLink.js +1 -0
  37. package/dist/ImageLink/ImageLinkSet.js +1 -0
  38. package/dist/ImageLink/index.js +1 -0
  39. package/dist/Insight/Featured/CategorySelector.js +1 -0
  40. package/dist/Insight/Featured/Featured.js +1 -0
  41. package/dist/Insight/Featured/Header.js +1 -0
  42. package/dist/Modal/Modal.js +1 -0
  43. package/dist/NavigationMenu/AxosALTS/index.js +1 -0
  44. package/dist/NavigationMenu/AxosBank/MobileMenu/MobileMenu.js +1 -0
  45. package/dist/NavigationMenu/AxosBank/SubNavBar.js +1 -0
  46. package/dist/NavigationMenu/AxosBank/index.js +1 -0
  47. package/dist/NavigationMenu/LaVictoire/index.js +1 -0
  48. package/dist/NavigationMenu/Navbar.js +1 -0
  49. package/dist/NavigationMenu/SignInNavButton.js +1 -0
  50. package/dist/SetContainer/SetContainer.js +1 -0
  51. package/dist/SocialMediaBar/iconsRepository.js +1 -0
  52. package/dist/VideoTile/VideoTile.js +1 -0
  53. package/dist/VideoWrapper/index.js +1 -0
  54. package/dist/assets/Chatbot/ChatWindow.css +69 -57
  55. package/dist/assets/notification.mp3.js +4 -0
  56. package/dist/main.js +5 -2
  57. package/dist/utils/useVisibility.d.ts +1 -0
  58. package/dist/utils/useVisibility.js +18 -0
  59. package/dist/vite-env.d.js +1 -0
  60. package/package.json +1 -1
  61. package/dist/Chatbot/Chat.d.ts +0 -1
  62. package/dist/Chatbot/Chat.js +0 -158
  63. package/dist/Chatbot/useHeadlessChat.d.ts +0 -27
  64. package/dist/Chatbot/useHeadlessChat.js +0 -240
@@ -1,158 +0,0 @@
1
- "use client";
2
- import { jsxs, jsx } from "react/jsx-runtime";
3
- import { useRef, useEffect } from "react";
4
- import { authenticate } from "./authenticate.js";
5
- import { useMessages } from "./store/messages.js";
6
- const companyId = process.env.CCAI_COMPANY_ID || "";
7
- const tenant = process.env.CCAI_TENANT_NAME || "";
8
- const host = process.env.CCAI_HOST || "";
9
- const COBROWSE_CONSENT_TEMPLATE = `
10
- <script class="cobrowse-template" type="text/template">
11
- <div class="cobrowse">
12
- <div class="cobrowse-title">$title</div>
13
- <div class="cobrowse-content">$content</div>
14
- <div class="cobrowse-footer">
15
- <button class="cobrowse-deny js-cobrowse-deny">$deny</button>
16
- <button class="cobrowse-allow js-cobrowse-allow">$allow</button>
17
- </div>
18
- </div>
19
- <\/script>
20
- `;
21
- function Chat() {
22
- const clientRef = useRef(null);
23
- const hasLoadedBefore = useRef(true);
24
- const addMessages = useMessages((state) => state.addMessages);
25
- const addMessage = useMessages((state) => state.addMessage);
26
- const chatRef = useRef(null);
27
- const isMounted = useRef(true);
28
- useEffect(() => {
29
- let messageHandler;
30
- let identityHandler;
31
- let chatUpdatedHandler;
32
- let memberJoinedHandler;
33
- let chatConnectedHandler;
34
- async function initChat() {
35
- const { Client, consoleLoggerHandler, Logger } = await import("@ujet/websdk-headless");
36
- Logger.addHandler(consoleLoggerHandler);
37
- clientRef.current = new Client({
38
- companyId,
39
- tenant,
40
- cobrowse: {
41
- enabled: true,
42
- template: COBROWSE_CONSENT_TEMPLATE,
43
- messages: {
44
- confirmSessionTitle: "...",
45
- confirmSessionContent: "...",
46
- endSessionText: "...",
47
- confirmRemoteControlTitle: "...",
48
- confirmRemoteControlContent: "...",
49
- confirmFullDeviceTitle: "...",
50
- confirmFullDeviceContent: "...",
51
- allowText: "...",
52
- denyText: "..."
53
- }
54
- },
55
- host,
56
- authenticate
57
- });
58
- const menus = await clientRef.current?.getMenus();
59
- try {
60
- chatRef.current = await clientRef.current?.loadOngoingChat();
61
- console.log("chat:", chatRef.current);
62
- if (!chatRef.current) {
63
- chatRef.current = await clientRef.current?.createChat(
64
- menus?.menus[5].id
65
- );
66
- }
67
- } catch (error) {
68
- console.error("Error creating chat:", error);
69
- chatRef.current = await clientRef.current?.createChat(
70
- menus?.menus[5].id
71
- );
72
- }
73
- identityHandler = (identity) => {
74
- if (!isMounted.current) return;
75
- console.log("identity:", identity);
76
- };
77
- messageHandler = (msg) => {
78
- addMessage(msg);
79
- };
80
- chatUpdatedHandler = (chat) => {
81
- console.log("chat updated:", chat);
82
- };
83
- chatConnectedHandler = async () => {
84
- console.log("connected");
85
- const messagesFetched = await clientRef.current?.fetchMessages();
86
- addMessages(messagesFetched || []);
87
- };
88
- memberJoinedHandler = (identity) => {
89
- console.log("member joined:", identity);
90
- };
91
- clientRef.current?.on("authenticated", () => {
92
- console.log("authenticated");
93
- });
94
- clientRef.current?.on("chat.ongoing", (chat) => {
95
- if (!isMounted.current) return;
96
- console.log("chat:", chat);
97
- });
98
- clientRef.current?.on("chat.connected", chatConnectedHandler);
99
- clientRef.current?.on("chat.updated", chatUpdatedHandler);
100
- clientRef.current?.on("chat.identity", identityHandler);
101
- clientRef.current?.on("chat.message", messageHandler);
102
- clientRef.current?.on("cobrowse.request", ({ from }) => {
103
- console.log("request by", from);
104
- });
105
- clientRef.current?.on("chat.memberJoined", memberJoinedHandler);
106
- }
107
- if (hasLoadedBefore.current) {
108
- console.log("Initial setup");
109
- initChat();
110
- hasLoadedBefore.current = false;
111
- }
112
- return () => {
113
- isMounted.current = false;
114
- console.log("Component unmounted. Cancelling pending async operations.");
115
- if (clientRef.current) {
116
- if (messageHandler)
117
- clientRef.current.off("chat.message", messageHandler);
118
- if (identityHandler)
119
- clientRef.current.off("chat.identity", identityHandler);
120
- clientRef.current.off("chat.connected", chatConnectedHandler);
121
- clientRef.current.off("chat.updated", chatUpdatedHandler);
122
- clientRef.current.off("chat.memberJoined", memberJoinedHandler);
123
- if (typeof clientRef.current.destroyChat === "function") {
124
- console.log("Destroying chat:", chatRef.current);
125
- clientRef.current.destroyChat();
126
- }
127
- }
128
- };
129
- }, [addMessage, addMessages]);
130
- return /* @__PURE__ */ jsxs("div", { children: [
131
- /* @__PURE__ */ jsx("h2", { children: "Chat" }),
132
- /* @__PURE__ */ jsxs(
133
- "form",
134
- {
135
- style: { marginTop: "1rem", display: "flex", gap: "0.5rem" },
136
- onSubmit: async (e) => {
137
- e.preventDefault();
138
- const form = e.target;
139
- const input = form.elements[0];
140
- const message = input.value;
141
- try {
142
- await clientRef.current?.sendTextMessage(message);
143
- input.value = "";
144
- } catch (error) {
145
- console.error("Error sending message:", error);
146
- }
147
- },
148
- children: [
149
- /* @__PURE__ */ jsx("input", { type: "text", name: "message", placeholder: "Type a message..." }),
150
- /* @__PURE__ */ jsx("button", { type: "submit", children: "Send" })
151
- ]
152
- }
153
- )
154
- ] });
155
- }
156
- export {
157
- Chat as default
158
- };
@@ -1,27 +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
- menuOption?: string;
12
- }
13
- export interface ChatMessage {
14
- id: string;
15
- body: string;
16
- sender?: string;
17
- timestamp?: string;
18
- }
19
- export declare function useHeadlessChat({ companyId, tenant, host, getToken, projectId, debug, menuOption, }: UseHeadlessChatOptions): {
20
- status: "error" | "idle" | "connected" | "connecting" | "finished";
21
- sendMessage: (body: string) => Promise<void>;
22
- showReconnect: boolean;
23
- setShowReconnect: import('react').Dispatch<import('react').SetStateAction<boolean>>;
24
- endChat: () => Promise<void>;
25
- virtualAgent: any;
26
- };
27
- export {};
@@ -1,240 +0,0 @@
1
- "use client";
2
- import { useState, useRef, useCallback, useEffect } from "react";
3
- import { useLocation } from "react-use";
4
- import { useMessages } from "./store/messages.js";
5
- const brandMap = /* @__PURE__ */ new Map([
6
- ["axos", 1],
7
- ["", 2],
8
- ["ufb", 3]
9
- ]);
10
- function useHeadlessChat({
11
- companyId,
12
- tenant,
13
- host,
14
- getToken,
15
- projectId = "axos",
16
- debug = false,
17
- menuOption = "Support Virtual Agent"
18
- }) {
19
- const { hostname } = useLocation();
20
- const addMessage = useMessages((state) => state.addMessage);
21
- const addMessages = useMessages((state) => state.addMessages);
22
- const clearMessages = useMessages((state) => state.clearMessages);
23
- const [showReconnect, setShowReconnect] = useState(false);
24
- const [status, setStatus] = useState("idle");
25
- const chatRef = useRef(null);
26
- const clientRef = useRef(null);
27
- const isMountedRef = useRef(true);
28
- const hasLoadedBefore = useRef(true);
29
- const menuRef = useRef({ menus: [] });
30
- const sendMessage = useCallback(async (body) => {
31
- if (chatRef.current) {
32
- await clientRef.current?.sendTextMessage(body);
33
- }
34
- }, []);
35
- const endChat = useCallback(async () => {
36
- if (chatRef.current) {
37
- await clientRef.current?.finishChat();
38
- clearMessages();
39
- clientRef.current?.createChat(
40
- menuRef.current.menus.find((menu) => menu.name === menuOption)?.id,
41
- {
42
- custom_data: {
43
- unsigned: {
44
- facingBrandId: {
45
- label: "facingBrandId",
46
- value: `${brandMap.get(projectId) || 1}`
47
- },
48
- channel: {
49
- label: "channel",
50
- value: "in_web"
51
- },
52
- user_auth: {
53
- label: "user_auth",
54
- value: "false"
55
- },
56
- env: {
57
- label: "env",
58
- value: hostname?.includes("www") ? "prod" : hostname?.split(".")[1] ? hostname?.split(".")[1] : ""
59
- }
60
- }
61
- }
62
- }
63
- );
64
- }
65
- }, [clearMessages, hostname, menuOption, projectId]);
66
- useEffect(() => {
67
- let messageHandler;
68
- let chatReadyHandler;
69
- let chatEndedHandler;
70
- let chatConnectedHandler;
71
- let chatDisconnectedHandler;
72
- let memberLeftHandler;
73
- let memberJoinedHandler;
74
- let startTypingHandler;
75
- let stopTypingHandler;
76
- let chatTimeoutHandler;
77
- async function init() {
78
- setStatus("connecting");
79
- const { Client, Logger, consoleLoggerHandler } = await import("@ujet/websdk-headless");
80
- if (debug) Logger.addHandler(consoleLoggerHandler);
81
- try {
82
- clientRef.current = new Client({
83
- companyId,
84
- tenant,
85
- host,
86
- authenticate: getToken
87
- });
88
- if (debug) console.log("clientRef:", clientRef.current);
89
- } catch (e) {
90
- console.error("Error creating client:", e);
91
- if (isMountedRef.current) setStatus("error");
92
- return;
93
- }
94
- menuRef.current = await clientRef.current?.getMenus();
95
- if (debug) console.log("channelId:", menuRef.current);
96
- if (debug)
97
- console.log(
98
- "channelId:",
99
- menuRef.current?.menus.find((menu) => menu.name === menuOption)?.id
100
- );
101
- const custom_data = {
102
- unsigned: {
103
- facingBrandId: {
104
- label: "facingBrandId",
105
- value: `${brandMap.get(projectId) || 1}`
106
- },
107
- channel: {
108
- label: "channel",
109
- value: "in_web"
110
- },
111
- user_auth: {
112
- label: "user_auth",
113
- value: "false"
114
- },
115
- env: {
116
- label: "env",
117
- value: hostname?.includes("www") ? "prod" : hostname?.split(".")[1] ? hostname?.split(".")[1] : ""
118
- }
119
- }
120
- };
121
- try {
122
- chatRef.current = await clientRef.current?.loadOngoingChat();
123
- if (chatRef.current != null) {
124
- chatRef.current = await clientRef.current?.resumeChat(
125
- chatRef.current?.state?.id
126
- );
127
- if (debug) console.log("Resumed chatRef:", chatRef.current);
128
- } else {
129
- chatRef.current = await clientRef.current?.createChat(
130
- menuRef.current.menus.find((menu) => menu.name === menuOption)?.id,
131
- {
132
- custom_data
133
- }
134
- );
135
- if (debug) console.log("chatRef:", chatRef.current);
136
- }
137
- } catch (error) {
138
- console.error("Error creating chat:", error);
139
- }
140
- messageHandler = (msg) => {
141
- if (debug) console.log("Received message:", msg);
142
- addMessage(msg);
143
- };
144
- chatReadyHandler = () => {
145
- console.log("Chat is ready");
146
- };
147
- chatEndedHandler = () => {
148
- console.log("Chat has ended");
149
- setStatus("finished");
150
- };
151
- chatConnectedHandler = async () => {
152
- console.log("Chat connected");
153
- setStatus("connected");
154
- try {
155
- const messagesFetched = await chatRef.current?.fetchMessages();
156
- if (debug) console.log("[messages]:", messagesFetched);
157
- addMessages(messagesFetched || []);
158
- } catch (error) {
159
- console.error("Error fetching messages:", error);
160
- }
161
- };
162
- startTypingHandler = (identity) => {
163
- console.log("start typing: ", identity);
164
- };
165
- stopTypingHandler = (identity) => {
166
- console.log("stop typing: ", identity);
167
- };
168
- memberLeftHandler = (identity) => {
169
- console.log("Member has left the chat: ", identity);
170
- };
171
- memberJoinedHandler = (identity) => {
172
- console.log("Member has joined the chat: ", identity);
173
- };
174
- chatDisconnectedHandler = () => {
175
- console.log("Chat disconnected");
176
- setStatus("idle");
177
- };
178
- chatTimeoutHandler = () => {
179
- console.log("Chat timeout");
180
- };
181
- clientRef.current?.on("ready", chatReadyHandler);
182
- clientRef.current?.on("chat.connected", chatConnectedHandler);
183
- clientRef.current?.on("chat.message", messageHandler);
184
- clientRef.current?.on("chat.memberLeft", memberLeftHandler);
185
- clientRef.current?.on("chat.memberJoined", memberJoinedHandler);
186
- clientRef.current?.on("chat.typingStarted", startTypingHandler);
187
- clientRef.current?.on("chat.typingEnded", stopTypingHandler);
188
- clientRef.current?.on("chat.disconnected", chatDisconnectedHandler);
189
- clientRef.current?.on("chat.ended", chatEndedHandler);
190
- clientRef.current?.on("chat.timeout", chatTimeoutHandler);
191
- }
192
- if (hasLoadedBefore.current) {
193
- if (debug) console.log("Initializing chat...");
194
- init();
195
- hasLoadedBefore.current = false;
196
- }
197
- return () => {
198
- isMountedRef.current = false;
199
- if (debug)
200
- console.log(
201
- "Component unmounted. Cancelling pending async operations."
202
- );
203
- chatRef.current = null;
204
- clientRef.current?.off("ready", chatReadyHandler);
205
- clientRef.current?.off("chat.message", messageHandler);
206
- clientRef.current?.off("chat.connected", chatConnectedHandler);
207
- clientRef.current?.off("chat.ended", chatEndedHandler);
208
- clientRef.current?.off("chat.memberLeft", memberLeftHandler);
209
- clientRef.current?.off("chat.memberJoined", memberJoinedHandler);
210
- clientRef.current?.off("chat.typingStarted", startTypingHandler);
211
- clientRef.current?.off("chat.typingEnded", stopTypingHandler);
212
- clientRef.current?.off("chat.disconnected", chatDisconnectedHandler);
213
- clientRef.current?.off("chat.timeout", chatTimeoutHandler);
214
- clientRef.current?.destroyChat();
215
- clientRef.current = null;
216
- };
217
- }, [
218
- companyId,
219
- tenant,
220
- host,
221
- getToken,
222
- addMessage,
223
- addMessages,
224
- debug,
225
- projectId,
226
- menuOption,
227
- hostname
228
- ]);
229
- return {
230
- status,
231
- sendMessage,
232
- showReconnect,
233
- setShowReconnect,
234
- endChat,
235
- virtualAgent: chatRef.current?.state.virtual_agent
236
- };
237
- }
238
- export {
239
- useHeadlessChat
240
- };