@axos-web-dev/shared-components 1.0.100-dev.43-executive.1 → 1.0.100-dev.43

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 (99) hide show
  1. package/dist/ATMLocator/ATMLocator.js +2 -3
  2. package/dist/Auth/ErrorAlert.js +1 -2
  3. package/dist/Auth/SignInPassword.js +2 -2
  4. package/dist/BulletItem/BulletItem.js +1 -0
  5. package/dist/Button/Button.js +1 -2
  6. package/dist/Calculators/AnnualFeeCalculator/index.js +1 -1
  7. package/dist/Calculators/BuyDownCalculator/index.js +1 -1
  8. package/dist/Calculators/Calculator.js +2 -3
  9. package/dist/Calculators/MarineLoanMonthlyPaymentCalculator/index.js +1 -1
  10. package/dist/Calculators/MaxLoanCalculator/index.js +1 -1
  11. package/dist/Calculators/MonthlyPaymentCalculator/index.js +1 -1
  12. package/dist/Carousel/index.js +1 -2
  13. package/dist/Chatbot/Bubble.css.js +0 -1
  14. package/dist/Chatbot/ChatWindow.css.d.ts +1 -0
  15. package/dist/Chatbot/ChatWindow.css.js +14 -11
  16. package/dist/Chatbot/ChatWindow.js +87 -66
  17. package/dist/Chatbot/Chatbot.d.ts +1 -1
  18. package/dist/Chatbot/Chatbot.js +46 -10
  19. package/dist/Chatbot/index.js +2 -1
  20. package/dist/Chevron/index.js +1 -2
  21. package/dist/Comparison/Comparison.js +1 -2
  22. package/dist/ExecutiveBio/ExecutiveBio.css.d.ts +0 -136
  23. package/dist/ExecutiveBio/ExecutiveBio.css.js +0 -46
  24. package/dist/ExecutiveBio/ExecutiveBio.d.ts +1 -1
  25. package/dist/ExecutiveBio/ExecutiveBio.interface.d.ts +4 -10
  26. package/dist/ExecutiveBio/ExecutiveBio.js +86 -331
  27. package/dist/ExecutiveBio/index.js +1 -24
  28. package/dist/FaqAccordion/index.js +1 -2
  29. package/dist/FooterSiteMap/AxosBank/FooterSiteMap.js +1 -2
  30. package/dist/Forms/ApplicationStart.js +4 -2
  31. package/dist/Forms/ApplyNow.js +2 -3
  32. package/dist/Forms/ClearingForm.js +4 -2
  33. package/dist/Forms/CommercialDeposits.js +4 -2
  34. package/dist/Forms/CommercialDepositsNoLendingOption.js +4 -2
  35. package/dist/Forms/CommercialLending.js +4 -2
  36. package/dist/Forms/CommercialPremiumFinance.js +4 -2
  37. package/dist/Forms/ContactCompany.js +4 -2
  38. package/dist/Forms/ContactCompanyTitle.js +4 -2
  39. package/dist/Forms/ContactUs.js +4 -2
  40. package/dist/Forms/ContactUsAAS.js +4 -2
  41. package/dist/Forms/ContactUsBusiness.js +5 -4
  42. package/dist/Forms/ContactUsBusinessNameEmail.js +5 -4
  43. package/dist/Forms/ContactUsLVF.js +4 -2
  44. package/dist/Forms/ContactUsNMLSId.js +5 -4
  45. package/dist/Forms/CpraRequest.d.ts +1 -1
  46. package/dist/Forms/CpraRequest.js +5 -2
  47. package/dist/Forms/CraPublicFile.js +5 -4
  48. package/dist/Forms/DealerServices.js +4 -2
  49. package/dist/Forms/EmailOnly.js +5 -4
  50. package/dist/Forms/EmailUs.js +7 -5
  51. package/dist/Forms/HoneyPot/index.js +2 -1
  52. package/dist/Forms/MortgageRate/MortgageRateForm.js +6 -5
  53. package/dist/Forms/MortgageRate/MortgageRateWatch.js +1 -2
  54. package/dist/Forms/MortgageWarehouseLending.js +5 -4
  55. package/dist/Forms/QuickPricer/QuickPricerForm.js +16 -12
  56. package/dist/Forms/ScheduleCall.js +4 -2
  57. package/dist/Forms/ScheduleCallPremier.js +4 -2
  58. package/dist/Forms/SuccesForm.js +2 -3
  59. package/dist/Forms/VendorQuestionnaire.js +6 -2
  60. package/dist/Forms/index.js +1 -0
  61. package/dist/Hyperlink/index.js +1 -2
  62. package/dist/ImageLink/ImageLink.js +2 -3
  63. package/dist/ImageLink/ImageLinkSet.js +1 -2
  64. package/dist/ImageLink/index.js +1 -2
  65. package/dist/Insight/Featured/CategorySelector.js +1 -2
  66. package/dist/Insight/Featured/Featured.js +1 -2
  67. package/dist/Insight/Featured/Header.js +1 -2
  68. package/dist/LoadingIndicator/index.js +1 -0
  69. package/dist/Modal/Modal.js +1 -2
  70. package/dist/Modal/contextApi/store.js +1 -1
  71. package/dist/NavigationMenu/AxosALTS/NavData.js +1 -2
  72. package/dist/NavigationMenu/AxosALTS/index.js +1 -2
  73. package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.js +1 -2
  74. package/dist/NavigationMenu/AxosBank/NavData.js +1 -2
  75. package/dist/NavigationMenu/AxosBank/SubNavBar.js +8 -7
  76. package/dist/NavigationMenu/AxosBank/index.js +1 -2
  77. package/dist/NavigationMenu/LaVictoire/NavData.js +1 -2
  78. package/dist/NavigationMenu/LaVictoire/index.js +1 -2
  79. package/dist/NavigationMenu/NavDataJson.js +1 -2
  80. package/dist/NavigationMenu/Navbar.js +1 -2
  81. package/dist/NavigationMenu/SignInNavButton.js +1 -2
  82. package/dist/SetContainer/SetContainer.js +2 -3
  83. package/dist/SocialMediaBar/iconsRepository.js +1 -2
  84. package/dist/Tab/Tab.js +1 -0
  85. package/dist/Table/Table.d.ts +1 -1
  86. package/dist/VideoTile/VideoTile.js +1 -2
  87. package/dist/VideoWrapper/index.js +1 -2
  88. package/dist/assets/Chatbot/ChatWindow.css +38 -26
  89. package/dist/assets/ExecutiveBio/ExecutiveBio.css +0 -268
  90. package/dist/main.js +11 -26
  91. package/dist/utils/emailValidation.d.ts +1 -0
  92. package/dist/utils/emailValidation.js +31 -0
  93. package/dist/utils/index.d.ts +4 -1
  94. package/dist/utils/index.js +9 -1
  95. package/dist/utils/nmlsValidation.d.ts +1 -0
  96. package/dist/utils/nmlsValidation.js +34 -0
  97. package/dist/utils/useCachedValidators.d.ts +2 -0
  98. package/dist/utils/useCachedValidators.js +22 -0
  99. package/package.json +1 -1
@@ -11,11 +11,11 @@ import '../assets/VideoWrapper/VideoWrapper.css';import '../assets/TopicalNavSet
11
11
  /* empty css */
12
12
  import "../utils/allowedAxosDomains.js";
13
13
  import { getVariant } from "../utils/getVariant.js";
14
+ import "react";
14
15
  import clsx from "clsx";
15
16
  /* empty css */
16
17
  /* empty css */
17
18
  import "../Button/Button.css.js";
18
- import "react";
19
19
  import "react-use";
20
20
  import "../Accordion/Accordion.js";
21
21
  import "../Accordion/Accordion.css.js";
@@ -67,13 +67,12 @@ import "../Calculators/MonthlyPaymentCalculator/MonthlyPaymentCalculator.css.js"
67
67
  /* empty css */
68
68
  /* empty css */
69
69
  import "../Carousel/index.js";
70
- import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
71
70
  /* empty css */
72
71
  import "../Chatbot/store/chat.js";
73
72
  import "../Chatbot/authenticate.js";
73
+ import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
74
74
  /* empty css */
75
75
  import "../Chatbot/store/messages.js";
76
- import "@ujet/websdk-headless";
77
76
  /* empty css */
78
77
  import "../Comparison/Comparison.css.js";
79
78
  import "next/image.js";
@@ -59,13 +59,12 @@ import "./SignInPassword.js";
59
59
  /* empty css */
60
60
  /* empty css */
61
61
  import "../Carousel/index.js";
62
- import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
63
62
  /* empty css */
64
63
  import "../Chatbot/store/chat.js";
65
64
  import "../Chatbot/authenticate.js";
65
+ import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
66
66
  /* empty css */
67
67
  import "../Chatbot/store/messages.js";
68
- import "@ujet/websdk-headless";
69
68
  import { Hyperlink } from "../Hyperlink/index.js";
70
69
  /* empty css */
71
70
  import "../Comparison/Comparison.css.js";
@@ -3,12 +3,12 @@ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { zodResolver } from "@hookform/resolvers/zod";
4
4
  import { Input } from "../Input/Input.js";
5
5
  import "../utils/allowedAxosDomains.js";
6
+ import { z } from "zod";
6
7
  import { getVariant } from "../utils/getVariant.js";
8
+ import { useState } from "react";
7
9
  import clsx from "clsx";
8
10
  import { useAction } from "next-safe-action/hooks";
9
- import { useState } from "react";
10
11
  import { useForm } from "react-hook-form";
11
- import { z } from "zod";
12
12
  import { ErrorAlert } from "./ErrorAlert.js";
13
13
  import { body_sign_in, form_input_wrapper, sign_in_button, sign_in_form } from "./SignIn.css.js";
14
14
  const schema = z.object({
@@ -10,6 +10,7 @@ import '../assets/icons/FollowIcon/FollowIcon.css';import '../assets/icons/Downl
10
10
  /* empty css */
11
11
  import "../utils/allowedAxosDomains.js";
12
12
  import { getVariant } from "../utils/getVariant.js";
13
+ import "react";
13
14
  import clsx from "clsx";
14
15
  import { bulletIcon } from "./BulletItem.css.js";
15
16
  const BulletItem = (props) => {
@@ -70,13 +70,12 @@ import "../Auth/SignInPassword.js";
70
70
  /* empty css */
71
71
  /* empty css */
72
72
  import "../Carousel/index.js";
73
- import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
74
73
  /* empty css */
75
74
  import "../Chatbot/store/chat.js";
76
75
  import "../Chatbot/authenticate.js";
76
+ import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
77
77
  /* empty css */
78
78
  import "../Chatbot/store/messages.js";
79
- import "@ujet/websdk-headless";
80
79
  /* empty css */
81
80
  import "../Comparison/Comparison.css.js";
82
81
  import "next/image.js";
@@ -5,8 +5,8 @@ import { Chevron } from "../../Chevron/index.js";
5
5
  import { title } from "../../IconBillboard/IconBillboard.css.js";
6
6
  import "../../utils/allowedAxosDomains.js";
7
7
  import { getVariant } from "../../utils/getVariant.js";
8
- import clsx from "clsx";
9
8
  import { useRef, useState, useEffect } from "react";
9
+ import clsx from "clsx";
10
10
  import { calculator } from "../calculator.css.js";
11
11
  import { container, calc_container, calc_block, pb0_1023, slider_block_wrapper, w100, stat_row, balance_wrapper, fb50, stat, slider_wrapper, slider, pt0_1023, text_block } from "./AnnualFeeCalculator.css.js";
12
12
  const AnnualFeeCalculator = ({
@@ -19,10 +19,10 @@ import "../../Input/DownPaymentInput.js";
19
19
  import "../../Input/RadioButton.js";
20
20
  import { PercentageInput } from "../../Input/PercentageInput.js";
21
21
  import "../../utils/allowedAxosDomains.js";
22
+ import { z } from "zod";
22
23
  import { getVariant } from "../../utils/getVariant.js";
23
24
  import clsx from "clsx";
24
25
  import { useForm, FormProvider } from "react-hook-form";
25
- import { z } from "zod";
26
26
  import { calc_container, calculator_section, section_header, theme_header, mt_8, buydown_calculator_form, row_form, calculate_row, form_wrapper, form_disclosure } from "./BuyDownCalculator.css.js";
27
27
  const BuyDownCalculator = ({
28
28
  header,
@@ -14,13 +14,13 @@ import '../assets/Forms/QuickPricer/UserInformation.css';import '../assets/Forms
14
14
  /* empty css */
15
15
  import "../utils/allowedAxosDomains.js";
16
16
  import { getVariant } from "../utils/getVariant.js";
17
+ import { useRef, useEffect } from "react";
17
18
  import clsx from "clsx";
18
19
  /* empty css */
19
20
  /* empty css */
20
21
  import "../Accordion/Accordion.js";
21
22
  import "../Accordion/Accordion.css.js";
22
23
  import "../AlertBanner/AlertBanner.css.js";
23
- import { useRef, useEffect } from "react";
24
24
  import "../Article/Article.css.js";
25
25
  import "../ArticlesSet/ArticlesSet.css.js";
26
26
  import "../Chevron/Chevron.css.js";
@@ -49,14 +49,13 @@ import { SummitApyCalculator } from "./SummitApyCalculator/index.js";
49
49
  /* empty css */
50
50
  /* empty css */
51
51
  import "../Carousel/index.js";
52
- import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
53
52
  /* empty css */
54
53
  import "../Chatbot/store/chat.js";
55
54
  import "../Chatbot/authenticate.js";
56
55
  import "react-use";
56
+ import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
57
57
  /* empty css */
58
58
  import "../Chatbot/store/messages.js";
59
- import "@ujet/websdk-headless";
60
59
  /* empty css */
61
60
  import "../Comparison/Comparison.css.js";
62
61
  import "next/image.js";
@@ -4,8 +4,8 @@ import { button } from "../../Button/Button.css.js";
4
4
  import { title } from "../../IconBillboard/IconBillboard.css.js";
5
5
  import "../../utils/allowedAxosDomains.js";
6
6
  import { getVariant } from "../../utils/getVariant.js";
7
- import clsx from "clsx";
8
7
  import { useState } from "react";
8
+ import clsx from "clsx";
9
9
  import { calc_text, description_text, calc_disclosure } from "../BalanceAPYCalculator/BalanceAPYCalculator.css.js";
10
10
  import { calculator } from "../calculator.css.js";
11
11
  import { calc_container, container, h2i, inputs_container, input_container, input_box, error_message, hide_select_arrow, calculation_header, payment_results } from "../MonthlyPaymentCalculator/MonthlyPaymentCalculator.css.js";
@@ -5,8 +5,8 @@ import { calc_container, container, h2i, inputs_container, input_container, inpu
5
5
  import { title } from "../../IconBillboard/IconBillboard.css.js";
6
6
  import "../../utils/allowedAxosDomains.js";
7
7
  import { getVariant } from "../../utils/getVariant.js";
8
- import clsx from "clsx";
9
8
  import { useState } from "react";
9
+ import clsx from "clsx";
10
10
  import { calculator } from "../calculator.css.js";
11
11
  const MaxLoanCalculator = ({
12
12
  variant,
@@ -4,8 +4,8 @@ import { button } from "../../Button/Button.css.js";
4
4
  import { title } from "../../IconBillboard/IconBillboard.css.js";
5
5
  import "../../utils/allowedAxosDomains.js";
6
6
  import { getVariant } from "../../utils/getVariant.js";
7
- import clsx from "clsx";
8
7
  import { useState } from "react";
8
+ import clsx from "clsx";
9
9
  import { calc_text, description_text, calc_disclosure } from "../BalanceAPYCalculator/BalanceAPYCalculator.css.js";
10
10
  import { calculator } from "../calculator.css.js";
11
11
  import { calc_container, container, h2i, inputs_container, input_container, input_box, error_message, calculation_header, payment_results } from "./MonthlyPaymentCalculator.css.js";
@@ -72,13 +72,12 @@ import "../Auth/SignInPassword.js";
72
72
  /* empty css */
73
73
  /* empty css */
74
74
  /* empty css */
75
- import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
76
75
  /* empty css */
77
76
  import "../Chatbot/store/chat.js";
78
77
  import "../Chatbot/authenticate.js";
78
+ import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
79
79
  /* empty css */
80
80
  import "../Chatbot/store/messages.js";
81
- import "@ujet/websdk-headless";
82
81
  /* empty css */
83
82
  import "../Comparison/Comparison.css.js";
84
83
  import "next/image.js";
@@ -1,4 +1,3 @@
1
- import "./Chatbot.css.ts.vanilla.css.js";
2
1
  import '../assets/Chatbot/Bubble.css';/* empty css */
3
2
  var bubbleWrapper = "_7u9pv30";
4
3
  var svgFill = "_7u9pv31";
@@ -5,6 +5,7 @@ export declare const chat_title: string;
5
5
  export declare const button_reset: string;
6
6
  export declare const arrowFill: string;
7
7
  export declare const inputStyle: string;
8
+ export declare const autoResize: string;
8
9
  export declare const sendButtonStyle: string;
9
10
  export declare const messagesContainerStyle: string;
10
11
  export declare const notificationStyle: string;
@@ -1,3 +1,4 @@
1
+ import "./Chatbot.css.ts.vanilla.css.js";
1
2
  import '../assets/Chatbot/ChatWindow.css';/* empty css */
2
3
  var windowStyle = "_13n1jqk0";
3
4
  var windowOpenStyle = "_13n1jqk1";
@@ -6,19 +7,21 @@ var chat_title = "_13n1jqk3";
6
7
  var button_reset = "_13n1jqk4";
7
8
  var arrowFill = "_13n1jqk5";
8
9
  var inputStyle = "_13n1jqk6";
9
- var sendButtonStyle = "_13n1jqk7";
10
- var messagesContainerStyle = "_13n1jqk8";
11
- var notificationStyle = "_13n1jqk9";
12
- var messageStyle = "_13n1jqka";
13
- var inline_button_wrapper = "_13n1jqkb";
14
- var inline_button = "_13n1jqkc";
15
- var endChatButtonStyle = "_13n1jqkd";
16
- var chatbotMenu = "_13n1jqke";
17
- var chatbotMenuItem = "_13n1jqkf";
18
- var chatNetworkStatus = "_13n1jqkg";
19
- var chatFinishDialog = "_13n1jqkh";
10
+ var autoResize = "_13n1jqk7";
11
+ var sendButtonStyle = "_13n1jqk8";
12
+ var messagesContainerStyle = "_13n1jqk9";
13
+ var notificationStyle = "_13n1jqka";
14
+ var messageStyle = "_13n1jqkb";
15
+ var inline_button_wrapper = "_13n1jqkc";
16
+ var inline_button = "_13n1jqkd";
17
+ var endChatButtonStyle = "_13n1jqke";
18
+ var chatbotMenu = "_13n1jqkf";
19
+ var chatbotMenuItem = "_13n1jqkg";
20
+ var chatNetworkStatus = "_13n1jqkh";
21
+ var chatFinishDialog = "_13n1jqki";
20
22
  export {
21
23
  arrowFill,
24
+ autoResize,
22
25
  button_reset,
23
26
  chatFinishDialog,
24
27
  chatNetworkStatus,
@@ -5,7 +5,7 @@ import React, { useRef, useEffect, Fragment as Fragment$1 } from "react";
5
5
  import ReactMarkdown from "react-markdown";
6
6
  import { useNetworkState, useMount } from "react-use";
7
7
  import remarkGfm from "remark-gfm";
8
- import { windowBarStyle, chat_title, chatbotMenuItem, chatbotMenu, chatFinishDialog, endChatButtonStyle, button_reset, arrowFill, chatNetworkStatus, notificationStyle, messageStyle, inline_button_wrapper, inline_button, messagesContainerStyle, inputStyle, sendButtonStyle, windowStyle, windowOpenStyle } from "./ChatWindow.css.js";
8
+ import { windowBarStyle, chat_title, chatbotMenuItem, chatbotMenu, chatFinishDialog, endChatButtonStyle, button_reset, arrowFill, chatNetworkStatus, notificationStyle, messageStyle, inline_button_wrapper, inline_button, messagesContainerStyle, inputStyle, autoResize, sendButtonStyle, windowStyle, windowOpenStyle } from "./ChatWindow.css.js";
9
9
  import EllipsisLoader from "./EllipsisAnimation.js";
10
10
  import { EllipsisIcon } from "./EllipsisIcon.js";
11
11
  import { useOpenChat } from "./store/chat.js";
@@ -28,14 +28,16 @@ const ChatWindow = ({
28
28
  const state = useNetworkState();
29
29
  const [input, setInput] = React.useState("");
30
30
  const messagesEndRef = useRef(null);
31
+ const inputRef = useRef(null);
31
32
  const isOpen = useOpenChat((state2) => state2.isOpen);
32
33
  useEffect(() => {
33
34
  messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
34
35
  }, [messages]);
35
36
  const handleSend = (e) => {
36
37
  e.preventDefault();
37
- if (input.trim()) {
38
- onSend(input);
38
+ const cleaned = cleanInput(input);
39
+ if (cleaned) {
40
+ onSend(cleaned);
39
41
  setInput("");
40
42
  }
41
43
  };
@@ -49,6 +51,18 @@ const ChatWindow = ({
49
51
  const escalationDeflected = messages?.filter(
50
52
  (item) => item.type == "noti" && item.event == "escalationDeflected"
51
53
  ).length > 0;
54
+ const cleanInput = (text) => text.replace(/[\r\n]+/g, " ").trim();
55
+ const autoResizeTextarea = () => {
56
+ if (inputRef.current) {
57
+ inputRef.current.style.height = "auto";
58
+ inputRef.current.style.maxHeight = "80px";
59
+ inputRef.current.style.height = inputRef.current.scrollHeight + "px";
60
+ inputRef.current.style.overflowY = inputRef.current.scrollHeight > 80 ? "auto" : "hidden";
61
+ }
62
+ };
63
+ useEffect(() => {
64
+ autoResizeTextarea();
65
+ }, [input]);
52
66
  return /* @__PURE__ */ jsxs("div", { className: clsx(windowStyle, isOpen && windowOpenStyle), children: [
53
67
  /* @__PURE__ */ jsxs("div", { className: windowBarStyle, children: [
54
68
  /* @__PURE__ */ jsxs("div", { className: "flex middle", style: { paddingBlock: "6px" }, children: [
@@ -269,7 +283,7 @@ const ChatWindow = ({
269
283
  ),
270
284
  /* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginBottom: 12 }, children: /* @__PURE__ */ jsx("button", { className: endChatButtonStyle, onClick: endChat, children: "End Chat" }) })
271
285
  ] }),
272
- ["text", "markdown_template", "markdown"].includes(msg.type) && /* @__PURE__ */ jsxs(
286
+ ["text", "markdown_template", "markdown"].includes(msg.type) && /* @__PURE__ */ jsx(
273
287
  "div",
274
288
  {
275
289
  className: messageStyle,
@@ -280,62 +294,58 @@ const ChatWindow = ({
280
294
  color: msg.$userType == "end_user" ? "#fff" : "#1F1F1F",
281
295
  boxShadow: msg.$userType == "end_user" ? "0 1px 4px #b3e0ff55" : void 0
282
296
  },
283
- children: [
284
- /* @__PURE__ */ jsxs(
285
- "div",
286
- {
287
- style: {
288
- fontSize: 13,
289
- display: "flex",
290
- flexDirection: "column",
291
- gap: 4
292
- },
293
- children: [
294
- msg.$userType == "virtual_agent" && /* @__PURE__ */ jsxs(
295
- "div",
296
- {
297
- style: {
298
- display: "flex",
299
- // justifyContent: "center",
300
- alignItems: "center",
301
- gap: "8px"
302
- },
303
- children: [
304
- showAvatar && /* @__PURE__ */ jsx(
305
- "img",
306
- {
307
- width: 24,
308
- height: 24,
309
- src: virtualAgent?.avatar_url,
310
- alt: "agent avatar"
311
- }
312
- ),
313
- /* @__PURE__ */ jsx("strong", { children: virtualAgent?.name })
314
- ]
315
- }
316
- ),
317
- /* @__PURE__ */ jsx(
318
- ReactMarkdown,
319
- {
320
- remarkPlugins: [[remarkGfm, { singleTilde: false }]],
321
- components: {
322
- p: ({ ...props }) => /* @__PURE__ */ jsx(
323
- "p",
324
- {
325
- style: { margin: 0, fontSize: "inherit" },
326
- title: new Date(msg.$timestamp).toLocaleString(),
327
- ...props
328
- }
329
- )
330
- },
331
- children: msg.content
332
- }
333
- )
334
- ]
335
- }
336
- ),
337
- /* @__PURE__ */ jsx("div", { style: { fontSize: 10, color: "#888", marginTop: 2 } })
338
- ]
297
+ children: /* @__PURE__ */ jsxs(
298
+ "div",
299
+ {
300
+ style: {
301
+ fontSize: 13,
302
+ display: "flex",
303
+ flexDirection: "column",
304
+ gap: 4
305
+ },
306
+ children: [
307
+ msg.$userType == "virtual_agent" && /* @__PURE__ */ jsxs(
308
+ "div",
309
+ {
310
+ style: {
311
+ display: "flex",
312
+ alignItems: "center",
313
+ gap: "8px"
314
+ },
315
+ children: [
316
+ showAvatar && /* @__PURE__ */ jsx(
317
+ "img",
318
+ {
319
+ width: 24,
320
+ height: 24,
321
+ src: virtualAgent?.avatar_url,
322
+ alt: "agent avatar"
323
+ }
324
+ ),
325
+ /* @__PURE__ */ jsx("strong", { children: virtualAgent?.name })
326
+ ]
327
+ }
328
+ ),
329
+ msg.$userType != "end_user" ? /* @__PURE__ */ jsx(
330
+ ReactMarkdown,
331
+ {
332
+ remarkPlugins: [[remarkGfm, { singleTilde: false }]],
333
+ components: {
334
+ p: ({ ...props }) => /* @__PURE__ */ jsx(
335
+ "p",
336
+ {
337
+ style: { margin: 0, fontSize: "inherit" },
338
+ title: new Date(msg.$timestamp).toLocaleString(),
339
+ ...props
340
+ }
341
+ )
342
+ },
343
+ children: msg.content
344
+ }
345
+ ) : /* @__PURE__ */ jsx("div", { title: new Date(msg.$timestamp).toLocaleString(), children: msg.content })
346
+ ]
347
+ }
348
+ )
339
349
  },
340
350
  msg.$index
341
351
  ),
@@ -398,20 +408,31 @@ const ChatWindow = ({
398
408
  onSubmit: handleSend,
399
409
  style: {
400
410
  borderTop: "1px solid #eee",
401
- display: "flex",
402
- gap: 8
411
+ display: "flex"
412
+ // gap: 8,
403
413
  },
404
414
  children: [
405
415
  /* @__PURE__ */ jsx(
406
- "input",
416
+ "textarea",
407
417
  {
408
- type: "text",
418
+ ref: inputRef,
409
419
  value: input,
410
420
  onChange: (e) => setInput(e.target.value),
421
+ onKeyDown: (e) => {
422
+ if (e.key === "Enter" && !e.shiftKey) {
423
+ e.preventDefault();
424
+ const cleaned = cleanInput(input);
425
+ if (cleaned) {
426
+ onSend(cleaned);
427
+ setInput("");
428
+ }
429
+ }
430
+ },
411
431
  placeholder: "Ask something...",
412
- className: inputStyle,
432
+ className: clsx(inputStyle, autoResize),
413
433
  autoFocus: true,
414
- disabled: inputDisabled || status !== "connected" || messages.length == 0 || escalationDeflected
434
+ disabled: inputDisabled || status !== "connected" || messages.length == 0 || escalationDeflected,
435
+ rows: 1
415
436
  }
416
437
  ),
417
438
  /* @__PURE__ */ jsx(
@@ -2,7 +2,7 @@ export type ChatbotProps = {
2
2
  project?: "axos" | "ufb";
3
3
  debug?: boolean;
4
4
  };
5
- export declare const Chatbot: ({ project, projectEnv, menuOption, }: {
5
+ export declare const Chatbot: ({ project, projectEnv, menuOption, debug, }: {
6
6
  project?: "axos" | "ufb";
7
7
  projectEnv?: "dev" | "qa" | "uat" | "stg" | "prod";
8
8
  menuOption?: "Support Virtual Agent" | string;
@@ -6,13 +6,13 @@ import { chatbotUFB, chatbotAXB } from "./Chatbot.css.js";
6
6
  import { ChatWindow } from "./ChatWindow.js";
7
7
  import { useOpenChat } from "./store/chat.js";
8
8
  import { useMessages } from "./store/messages.js";
9
- import { Logger, consoleLoggerHandler, Client } from "@ujet/websdk-headless";
10
- import { useRef, useState } from "react";
9
+ import { useRef, useState, useEffect } from "react";
11
10
  import { useMount, useUnmount } from "react-use";
12
11
  const Chatbot = ({
13
12
  project = "axos",
14
13
  projectEnv = "dev",
15
- menuOption = "Support Virtual Agent"
14
+ menuOption = "Support Virtual Agent",
15
+ debug = false
16
16
  }) => {
17
17
  const { hasOpenedOnce, toggle, reset } = useOpenChat();
18
18
  const { addMessage, addMessages, clearMessages, messages } = useMessages();
@@ -24,6 +24,8 @@ const Chatbot = ({
24
24
  const agent_virtual = useRef(null);
25
25
  const [status, setStatus] = useState("idle");
26
26
  const [hasStarted, setHasStarted] = useState(false);
27
+ const [menusLoaded, setMenusLoaded] = useState(false);
28
+ const [pendingStart, setPendingStart] = useState(false);
27
29
  const brandMap = /* @__PURE__ */ new Map([
28
30
  ["axos", 1],
29
31
  ["ufb", 3]
@@ -48,11 +50,13 @@ const Chatbot = ({
48
50
  }
49
51
  }
50
52
  };
51
- if (projectEnv !== "prod") {
52
- Logger.addHandler(consoleLoggerHandler);
53
- }
54
53
  const onReadyHandler = async () => {
55
54
  console.log("Chat client is ready");
55
+ if (clientRef.current) {
56
+ menuRef.current = await clientRef.current.getMenus();
57
+ setMenusLoaded(true);
58
+ console.log("menus:", menuRef.current);
59
+ }
56
60
  };
57
61
  const onAuthenticatedHandler = async () => {
58
62
  console.log("Chat client is authenticated");
@@ -96,8 +100,6 @@ const Chatbot = ({
96
100
  }
97
101
  };
98
102
  const registerEventHandlers = () => {
99
- clientRef.current?.on("ready", onReadyHandler);
100
- clientRef.current?.on("authenticated", onAuthenticatedHandler);
101
103
  clientRef.current?.on("chat.ongoing", onChatOngoingHandler);
102
104
  clientRef.current?.on("chat.message", onChatMessageHandler);
103
105
  clientRef.current?.on("chat.typingStarted", onChatTypingStartedHandler);
@@ -124,6 +126,10 @@ const Chatbot = ({
124
126
  clientRef.current?.off("chat.connected", onChatConnectedHandler);
125
127
  };
126
128
  const createClient = async () => {
129
+ const { Client, Logger, consoleLoggerHandler } = await import("@ujet/websdk-headless");
130
+ if (projectEnv !== "prod" || debug) {
131
+ Logger.addHandler(consoleLoggerHandler);
132
+ }
127
133
  if (clientRef.current) return;
128
134
  const client = new Client({
129
135
  companyId: process.env.CCAI_COMPANY_ID || "",
@@ -132,10 +138,10 @@ const Chatbot = ({
132
138
  // or your region
133
139
  authenticate
134
140
  });
141
+ client?.on("ready", onReadyHandler);
142
+ client?.on("authenticated", onAuthenticatedHandler);
135
143
  isMountedRef.current = true;
136
144
  clientRef.current = client;
137
- menuRef.current = await client.getMenus();
138
- console.log("menus:", menuRef.current);
139
145
  registerEventHandlers();
140
146
  return;
141
147
  };
@@ -143,6 +149,17 @@ const Chatbot = ({
143
149
  console.log("Starting chat");
144
150
  const client = clientRef.current;
145
151
  if (!client) return;
152
+ if (!menuRef.current || !menuRef.current.menus) {
153
+ let waited = 0;
154
+ while ((!menuRef.current || !menuRef.current.menus) && waited < 5e3) {
155
+ await new Promise((res) => setTimeout(res, 100));
156
+ waited += 100;
157
+ }
158
+ if (!menuRef.current || !menuRef.current.menus) {
159
+ console.error("Menu not loaded, cannot start chat");
160
+ return;
161
+ }
162
+ }
146
163
  try {
147
164
  const ongoingChat = await client.loadOngoingChat();
148
165
  if (ongoingChat) {
@@ -160,6 +177,7 @@ const Chatbot = ({
160
177
  const newChat = await client.createChat(menuId, { custom_data });
161
178
  if (newChat !== null) {
162
179
  chatRef.current = newChat;
180
+ agent_virtual.current = newChat.agent;
163
181
  console.log("Chat created id:", newChat.id);
164
182
  }
165
183
  } catch (err) {
@@ -169,6 +187,10 @@ const Chatbot = ({
169
187
  const handleClick = async () => {
170
188
  toggle();
171
189
  if (hasStarted) return;
190
+ if (!menusLoaded) {
191
+ setPendingStart(true);
192
+ return;
193
+ }
172
194
  if (!hasOpenedOnce) {
173
195
  await startChat();
174
196
  setHasStarted(true);
@@ -196,11 +218,25 @@ const Chatbot = ({
196
218
  isMountedRef.current = true;
197
219
  await createClient();
198
220
  });
221
+ useEffect(() => {
222
+ if (menusLoaded && pendingStart && !hasStarted) {
223
+ startChat();
224
+ setHasStarted(true);
225
+ setPendingStart(false);
226
+ }
227
+ }, [menusLoaded, pendingStart, hasStarted]);
199
228
  useUnmount(() => {
200
229
  console.log("Chatbot unmounted");
201
230
  deregisterEventHandlers();
202
231
  isMountedRef.current = false;
203
232
  hasLoadedBefore.current = true;
233
+ reset();
234
+ setHasStarted(false);
235
+ setStatus("idle");
236
+ clearMessages();
237
+ clientRef.current?.destroy();
238
+ clientRef.current?.destroyChat();
239
+ clientRef.current = null;
204
240
  });
205
241
  return /* @__PURE__ */ jsxs("div", { className: project === "ufb" ? chatbotUFB : chatbotAXB, children: [
206
242
  /* @__PURE__ */ jsx(Bubble, { onClick: handleClick }),
@@ -4,7 +4,7 @@ import { bubbleWrapper, svgFill } from "./Bubble.css.js";
4
4
  import { Chatbot } from "./Chatbot.js";
5
5
  import { chatbotAXB, chatbotUFB } from "./Chatbot.css.js";
6
6
  import { ChatWindow } from "./ChatWindow.js";
7
- import { arrowFill, button_reset, chatFinishDialog, chatNetworkStatus, chat_title, chatbotMenu, chatbotMenuItem, endChatButtonStyle, inline_button, inline_button_wrapper, inputStyle, messageStyle, messagesContainerStyle, notificationStyle, sendButtonStyle, windowBarStyle, windowOpenStyle, windowStyle } from "./ChatWindow.css.js";
7
+ import { arrowFill, autoResize, button_reset, chatFinishDialog, chatNetworkStatus, chat_title, chatbotMenu, chatbotMenuItem, endChatButtonStyle, inline_button, inline_button_wrapper, inputStyle, messageStyle, messagesContainerStyle, notificationStyle, sendButtonStyle, windowBarStyle, windowOpenStyle, windowStyle } from "./ChatWindow.css.js";
8
8
  import { useOpenChat } from "./store/chat.js";
9
9
  import { useMessages } from "./store/messages.js";
10
10
  export {
@@ -12,6 +12,7 @@ export {
12
12
  ChatWindow,
13
13
  Chatbot,
14
14
  arrowFill,
15
+ autoResize,
15
16
  bubbleWrapper,
16
17
  button_reset,
17
18
  chatFinishDialog,
@@ -72,13 +72,12 @@ import "../Auth/SignInPassword.js";
72
72
  /* empty css */
73
73
  /* empty css */
74
74
  import "../Carousel/index.js";
75
- import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
76
75
  /* empty css */
77
76
  import "../Chatbot/store/chat.js";
78
77
  import "../Chatbot/authenticate.js";
78
+ import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
79
79
  /* empty css */
80
80
  import "../Chatbot/store/messages.js";
81
- import "@ujet/websdk-headless";
82
81
  /* empty css */
83
82
  import "../Comparison/Comparison.css.js";
84
83
  import "next/image.js";