@axos-web-dev/shared-components 1.0.100-dev.9-patch.1 → 1.0.100-envVars-0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ATMLocator/ATMLocator.js +5 -10
- package/dist/Article/Article.css.d.ts +9 -36
- package/dist/Article/Article.css.js +10 -8
- package/dist/Article/index.js +3 -2
- package/dist/ArticlesSet/ArticlesSet.css.d.ts +10 -70
- package/dist/ArticlesSet/ArticlesSet.js +1 -1
- package/dist/Auth/ErrorAlert.js +5 -10
- package/dist/Auth/SignInPassword.js +2 -3
- package/dist/Avatar/Avatar.module.js +7 -7
- package/dist/AwardsBanner/AwardsBanner.css.js +4 -1
- package/dist/AwardsItem/AwardsItem.css.js +1 -2
- package/dist/Blockquote/Blockquote.module.js +3 -3
- package/dist/BulletItem/BulletItem.js +1 -1
- package/dist/Button/Button.css.d.ts +3 -3
- package/dist/Button/Button.js +6 -10
- package/dist/Calculators/AnnualFeeCalculator/index.js +1 -2
- package/dist/Calculators/ApyCalculator/ApyCalculator.css.d.ts +2 -30
- package/dist/Calculators/ApyCalculator/index.js +11 -5
- package/dist/Calculators/AxosOneCalculator/BalanceAPYCalculator.css.d.ts +1 -0
- package/dist/Calculators/AxosOneCalculator/BalanceAPYCalculator.css.js +3 -1
- package/dist/Calculators/AxosOneCalculator/index.d.ts +3 -0
- package/dist/Calculators/AxosOneCalculator/index.js +48 -21
- package/dist/Calculators/BalanceAPYCalculator/BalanceAPYCalculator.css.d.ts +2 -30
- package/dist/Calculators/BalanceAPYCalculator/index.js +0 -1
- package/dist/Calculators/BuyDownCalculator/BuyDownCalculator.css.d.ts +0 -1
- package/dist/Calculators/BuyDownCalculator/BuyDownCalculator.css.js +2 -4
- package/dist/Calculators/BuyDownCalculator/index.d.ts +4 -1
- package/dist/Calculators/BuyDownCalculator/index.js +108 -69
- package/dist/Calculators/Calculator.d.ts +3 -0
- package/dist/Calculators/Calculator.js +10 -11
- package/dist/Calculators/MarginTradingCalculator/index.js +118 -1
- package/dist/Calculators/MarineLoanMonthlyPaymentCalculator/index.js +1 -2
- package/dist/Calculators/MaxLoanCalculator/index.js +1 -2
- package/dist/Calculators/MonthlyPaymentCalculator/index.js +1 -2
- package/dist/Calculators/MonthlyPaymentLVFCalculator/index.js +0 -1
- package/dist/Calculators/SummitApyCalculator/index.js +15 -7
- package/dist/Calculators/calculator.css.d.ts +2 -8
- package/dist/CallToActionBar/CallToActionBar.css.d.ts +3 -1
- package/dist/CallToActionBar/CallToActionBar.css.js +22 -16
- package/dist/CallToActionBar/index.js +4 -3
- package/dist/Carousel/Carousel.css.d.ts +8 -19
- package/dist/Carousel/index.js +4 -9
- package/dist/Chatbot/Bubble.d.ts +3 -1
- package/dist/Chatbot/Bubble.js +6 -3
- package/dist/Chatbot/ChatWindow.css.d.ts +1 -0
- package/dist/Chatbot/ChatWindow.css.js +14 -11
- package/dist/Chatbot/ChatWindow.d.ts +3 -6
- package/dist/Chatbot/ChatWindow.js +139 -68
- package/dist/Chatbot/Chatbot.css.js +0 -1
- package/dist/Chatbot/Chatbot.d.ts +6 -1
- package/dist/Chatbot/Chatbot.js +236 -21
- package/dist/Chatbot/EllipsisAnimation.d.ts +2 -0
- package/dist/Chatbot/EllipsisAnimation.js +85 -0
- package/dist/Chatbot/index.d.ts +0 -1
- package/dist/Chatbot/index.js +2 -3
- package/dist/Chatbot/store/chat.d.ts +1 -0
- package/dist/Chatbot/store/chat.js +11 -4
- package/dist/Chatbot/useHeadlessChat.d.ts +2 -1
- package/dist/Chatbot/useHeadlessChat.js +59 -14
- package/dist/Chevron/Chevron.css.d.ts +2 -2
- package/dist/Chevron/index.js +5 -9
- package/dist/CollectInformationAlert/index.js +1 -1
- package/dist/Comparison/Comparison.js +4 -9
- package/dist/ContentBanner/ContentBanner.css.js +2 -1
- package/dist/ExecutiveBio/ExecutiveBio.css.d.ts +153 -0
- package/dist/ExecutiveBio/ExecutiveBio.css.js +50 -0
- package/dist/ExecutiveBio/ExecutiveBio.d.ts +1 -1
- package/dist/ExecutiveBio/ExecutiveBio.interface.d.ts +11 -4
- package/dist/ExecutiveBio/ExecutiveBio.js +260 -12
- package/dist/ExecutiveBio/Overlay.d.ts +8 -0
- package/dist/ExecutiveBio/Overlay.js +589 -0
- package/dist/ExecutiveBio/index.js +26 -1
- package/dist/FaqAccordion/index.js +4 -9
- package/dist/FooterSiteMap/AxosBank/FooterSiteMap.js +142 -96
- package/dist/Forms/ApplicationStart.js +4 -3
- package/dist/Forms/ApplyNow.js +4 -9
- package/dist/Forms/ClearingForm.js +4 -3
- package/dist/Forms/CommercialDeposits.js +4 -3
- package/dist/Forms/CommercialDepositsNoLendingOption.d.ts +16 -0
- package/dist/Forms/CommercialDepositsNoLendingOption.js +331 -0
- package/dist/Forms/CommercialLending.js +4 -3
- package/dist/Forms/CommercialPremiumFinance.js +4 -3
- package/dist/Forms/ContactCompany.js +4 -3
- package/dist/Forms/ContactCompanyTitle.js +4 -3
- package/dist/Forms/ContactUs.js +4 -3
- package/dist/Forms/ContactUsAAS.js +4 -3
- package/dist/Forms/ContactUsBusiness.d.ts +1 -1
- package/dist/Forms/ContactUsBusiness.js +12 -15
- package/dist/Forms/ContactUsBusinessNameEmail.js +8 -11
- package/dist/Forms/ContactUsLVF.js +4 -3
- package/dist/Forms/ContactUsNMLSId.js +8 -11
- package/dist/Forms/CpraRequest.d.ts +1 -1
- package/dist/Forms/CpraRequest.js +104 -4
- package/dist/Forms/CraPublicFile.js +8 -11
- package/dist/Forms/DealerServices.js +4 -3
- package/dist/Forms/EmailOnly.js +90 -73
- package/dist/Forms/EmailUs.js +7 -6
- package/dist/Forms/Forms.css.d.ts +8 -31
- package/dist/Forms/Forms.css.js +50 -44
- package/dist/Forms/HoneyPot/index.js +2 -2
- package/dist/Forms/MortgageRate/MortgageRateForm.js +41 -23
- package/dist/Forms/MortgageRate/MortgageRateQuoteFilters.js +11 -5
- package/dist/Forms/MortgageRate/MortgageRateWatch.js +4 -9
- package/dist/Forms/MortgageWarehouseLending.js +8 -11
- package/dist/Forms/QuickPricer/QuickPricerForm.js +16 -13
- package/dist/Forms/ScheduleCall.js +4 -3
- package/dist/Forms/ScheduleCallPremier.js +4 -3
- package/dist/Forms/SuccesForm.js +7 -12
- package/dist/Forms/VendorQuestionnaire.js +6 -3
- package/dist/Forms/index.d.ts +1 -0
- package/dist/Forms/index.js +7 -2
- package/dist/HeroBanner/HeroBanner.css.d.ts +5 -17
- package/dist/HeroBanner/HeroBanner.css.js +2 -1
- package/dist/HeroBanner/HeroBanner.js +14 -16
- package/dist/HeroBanner/SelectionBanner.css.d.ts +1 -19
- package/dist/HeroBanner/SelectionBanner.css.js +6 -6
- package/dist/Hyperlink/Hyperlink.css.d.ts +4 -4
- package/dist/Hyperlink/Hyperlink.css.js +4 -1
- package/dist/Hyperlink/index.js +6 -10
- package/dist/IconBillboard/IconBillboard.css.d.ts +6 -40
- package/dist/ImageBillboard/ImageBillboard.css.d.ts +5 -61
- package/dist/ImageBillboard/ImageBillboard.css.js +2 -1
- package/dist/ImageLink/ImageLink.js +5 -10
- package/dist/ImageLink/ImageLinkSet.js +4 -9
- package/dist/ImageLink/index.js +3 -8
- package/dist/Input/Input.css.d.ts +1 -0
- package/dist/Input/Input.css.js +10 -8
- package/dist/Input/index.js +2 -1
- package/dist/Insight/Featured/CategorySelector.js +3 -8
- package/dist/Insight/Featured/Featured.js +4 -9
- package/dist/Insight/Featured/Header.js +4 -9
- package/dist/Insight/Insight.css.d.ts +18 -0
- package/dist/Insight/Insight.css.js +44 -8
- package/dist/Insight/index.js +19 -1
- package/dist/LandingPageHeader/LandingPageHeader.css.d.ts +2 -0
- package/dist/LandingPageHeader/LandingPageHeader.css.js +6 -2
- package/dist/LandingPageHeader/LandingPageHeader.js +18 -9
- package/dist/LandingPageHeader/index.js +3 -1
- package/dist/LoadingIndicator/LoadingIndicator.css.d.ts +4 -4
- package/dist/LoadingIndicator/index.js +1 -1
- package/dist/Modal/Modal.css.d.ts +1 -0
- package/dist/Modal/Modal.css.js +5 -3
- package/dist/Modal/Modal.js +6 -11
- package/dist/Modal/contextApi/store.d.ts +9 -2
- package/dist/Modal/contextApi/store.js +16 -5
- package/dist/NavigationMenu/AxosALTS/NavData.d.ts +5 -1
- package/dist/NavigationMenu/AxosALTS/NavData.js +12 -12
- package/dist/NavigationMenu/AxosALTS/index.js +16 -13
- package/dist/NavigationMenu/AxosAdvisor/NavBar.css.d.ts +2 -0
- package/dist/NavigationMenu/AxosAdvisor/NavBar.css.js +7 -2
- package/dist/NavigationMenu/AxosAdvisor/NavBar.module.js +52 -52
- package/dist/NavigationMenu/AxosAdvisor/SubNavBar.js +0 -1
- package/dist/NavigationMenu/AxosAdvisor/index.js +40 -23
- package/dist/NavigationMenu/AxosAdvisorServices/NavBar.css.d.ts +2 -0
- package/dist/NavigationMenu/AxosAdvisorServices/NavBar.css.js +7 -2
- package/dist/NavigationMenu/AxosAdvisorServices/NavBar.module.js +53 -53
- package/dist/NavigationMenu/AxosAdvisorServices/SubNavBar.js +0 -1
- package/dist/NavigationMenu/AxosAdvisorServices/SubNavbar.css.d.ts +1 -1
- package/dist/NavigationMenu/AxosAdvisorServices/SubNavbar.css.js +2 -2
- package/dist/NavigationMenu/AxosAdvisorServices/index.js +14 -9
- package/dist/NavigationMenu/AxosBank/MobileMenu/MobileMenu.js +127 -5
- package/dist/NavigationMenu/AxosBank/MobileMenu/MobileMenu.module.js +16 -16
- package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.d.ts +7 -13
- package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.js +305 -202
- package/dist/NavigationMenu/AxosBank/NavBar.css.js +2 -1
- package/dist/NavigationMenu/AxosBank/NavBar.module.js +41 -41
- package/dist/NavigationMenu/AxosBank/NavData.d.ts +37 -2
- package/dist/NavigationMenu/AxosBank/NavData.js +46 -41
- package/dist/NavigationMenu/AxosBank/SubNavBar.js +591 -482
- package/dist/NavigationMenu/AxosBank/SubNavbar.css.d.ts +2 -0
- package/dist/NavigationMenu/AxosBank/SubNavbar.css.js +4 -0
- package/dist/NavigationMenu/AxosBank/index.js +23 -17
- package/dist/NavigationMenu/AxosClearing/NavBar.module.js +37 -37
- package/dist/NavigationMenu/AxosClearing/index.js +0 -1
- package/dist/NavigationMenu/AxosFiduciary/NavBar.module.js +41 -41
- package/dist/NavigationMenu/LaVictoire/NavData.d.ts +11 -2
- package/dist/NavigationMenu/LaVictoire/NavData.js +16 -21
- package/dist/NavigationMenu/LaVictoire/SubNavBar.js +4 -1
- package/dist/NavigationMenu/LaVictoire/index.js +18 -18
- package/dist/NavigationMenu/Navbar.js +6 -7
- package/dist/NavigationMenu/SignInNavButton.js +19 -18
- package/dist/PageNavItem/PageNavItem.css.d.ts +4 -22
- package/dist/Pagination/Pagination.js +6 -6
- package/dist/SetContainer/SetContainer.js +5 -10
- package/dist/SocialMediaBar/iconsRepository.d.ts +42 -14
- package/dist/SocialMediaBar/iconsRepository.js +35 -34
- package/dist/SocialMediaBar/index.js +3 -1
- package/dist/StepItem/StepItem.css.d.ts +8 -36
- package/dist/StepItemSet/StepItemSet.css.d.ts +5 -32
- package/dist/StepItemSet/StepItemSet.css.js +5 -3
- package/dist/StepItemSet/StepItemSet.d.ts +2 -0
- package/dist/StepItemSet/StepItemSet.js +18 -13
- package/dist/StepItemSet/index.js +3 -2
- package/dist/Tab/Tab.js +1 -1
- package/dist/Table/Table.css.d.ts +7 -7
- package/dist/Table/Table.css.js +5 -5
- package/dist/Table/Table.d.ts +1 -1
- package/dist/Table/Table.js +1 -2
- package/dist/VideoTile/VideoTile.js +2 -7
- package/dist/VideoWrapper/index.js +2 -7
- package/dist/WalnutIframe/wrapper.module.js +3 -3
- package/dist/assets/Accordion/Accordion.css +4 -4
- package/dist/assets/Article/Article.css +87 -86
- package/dist/assets/ArticlesSet/ArticlesSet.css +26 -56
- package/dist/assets/Auth/SignIn.css +12 -12
- package/dist/assets/Avatar/Avatar.css.css +10 -10
- package/dist/assets/AwardsBanner/AwardsBanner.css +1 -1
- package/dist/assets/AwardsItem/AwardsItem.css +3 -4
- package/dist/assets/Blockquote/Blockquote.css.css +21 -17
- package/dist/assets/Button/Button.css +28 -28
- package/dist/assets/Calculators/AnnualFeeCalculator/AnnualFeeCalculator.css +8 -8
- package/dist/assets/Calculators/ApyCalculator/ApyCalculator.css +12 -21
- package/dist/assets/Calculators/AxosOneCalculator/BalanceAPYCalculator.css +32 -12
- package/dist/assets/Calculators/BalanceAPYCalculator/BalanceAPYCalculator.css +22 -34
- package/dist/assets/Calculators/BuyDownCalculator/BuyDownCalculator.css +15 -21
- package/dist/assets/Calculators/MonthlyPaymentCalculator/MonthlyPaymentCalculator.css +9 -9
- package/dist/assets/Calculators/MonthlyPaymentLVFCalculator/MonthlyPaymentCalculator.css +10 -10
- package/dist/assets/Calculators/SummitApyCalculator/BalanceAPYCalculator.css +18 -10
- package/dist/assets/Calculators/calculator.css +9 -15
- package/dist/assets/CallToActionBar/CallToActionBar.css +95 -69
- package/dist/assets/Carousel/Carousel.css +27 -41
- package/dist/assets/Chatbot/ChatWindow.css +38 -26
- package/dist/assets/Chevron/Chevron.css +11 -10
- package/dist/assets/CollectInformationAlert/CollectInformationAlert.css +4 -3
- package/dist/assets/Comparison/Comparison.css +5 -4
- package/dist/assets/ContentBanner/ContentBanner.css +14 -8
- package/dist/assets/DownloadTile/DownloadTile.css +6 -6
- package/dist/assets/ExecutiveBio/ExecutiveBio.css +342 -27
- package/dist/assets/FaqAccordion/FaqAccordion.css +5 -5
- package/dist/assets/FooterDisclosure/FooterDisclosure.css +1 -1
- package/dist/assets/FooterSiteMap/AxosBank/FooterSiteMap.css +3 -8
- package/dist/assets/Forms/Forms.css +176 -165
- package/dist/assets/Forms/QuickPricer/UserInformation.css +1 -1
- package/dist/assets/HeroBanner/HeroBanner.css +85 -76
- package/dist/assets/HeroBanner/LargeBanner.css +15 -15
- package/dist/assets/HeroBanner/SelectionBanner.css +15 -29
- package/dist/assets/Hyperlink/Hyperlink.css +4 -4
- package/dist/assets/IconBillboard/IconBillboard.css +32 -48
- package/dist/assets/ImageBillboard/ImageBillboard.css +59 -64
- package/dist/assets/Input/Input.css +54 -47
- package/dist/assets/Inputs/Input.css +4 -4
- package/dist/assets/Insight/Featured/CategorySelector.css +1 -1
- package/dist/assets/Insight/Insight.css +212 -43
- package/dist/assets/Interstitial/Interstitial-variants.css +3 -3
- package/dist/assets/LandingPageHeader/LandingPageHeader.css +37 -4
- package/dist/assets/LoadingIndicator/LoadingIndicator.css +5 -5
- package/dist/assets/Modal/Modal.css +17 -28
- package/dist/assets/NavigationMenu/AxosALTS/NavBar.css +1 -1
- package/dist/assets/NavigationMenu/AxosAdvisor/NavBar.css +25 -2
- package/dist/assets/NavigationMenu/AxosAdvisor/NavBar.css.css +138 -126
- package/dist/assets/NavigationMenu/AxosAdvisor/SubNavbar.css +5 -4
- package/dist/assets/NavigationMenu/AxosAdvisorServices/NavBar.css +25 -2
- package/dist/assets/NavigationMenu/AxosAdvisorServices/NavBar.css.css +142 -130
- package/dist/assets/NavigationMenu/AxosAdvisorServices/SubNavbar.css +22 -4
- package/dist/assets/NavigationMenu/AxosBank/MobileMenu/MobileMenu.css.css +32 -31
- package/dist/assets/NavigationMenu/AxosBank/NavBar.css +21 -9
- package/dist/assets/NavigationMenu/AxosBank/NavBar.css.css +120 -148
- package/dist/assets/NavigationMenu/AxosBank/SubNavbar.css +35 -1
- package/dist/assets/NavigationMenu/AxosClearing/NavBar.css.css +133 -107
- package/dist/assets/NavigationMenu/AxosFiduciary/NavBar.css.css +84 -83
- package/dist/assets/PageNavItem/PageNavItem.css +16 -33
- package/dist/assets/Pagination/Pagination.css +1 -1
- package/dist/assets/SetContainer/SetContainer.css +5 -5
- package/dist/assets/StepItem/StepItem.css +26 -42
- package/dist/assets/StepItemSet/StepItemSet.css +27 -35
- package/dist/assets/Tab/Tab.css +12 -12
- package/dist/assets/Table/Table.css +90 -97
- package/dist/assets/TextBlock/TextBlock.css +1 -1
- package/dist/assets/TopicalNavItem/TopicalNavItem.css +3 -3
- package/dist/assets/TopicalNavSet/TopicalNavSet.css +1 -1
- package/dist/assets/VideoTile/VideoTile.css +1 -1
- package/dist/assets/WalnutIframe/wrapper.css.css +48 -49
- package/dist/assets/globals.css +11 -8
- package/dist/assets/icons/ArrowIcon/ArrowIcon.css +3 -3
- package/dist/assets/icons/DownloadIcon/DownloadIcon.css +1 -1
- package/dist/assets/icons/FollowIcon/FollowIcon.css +1 -1
- package/dist/assets/themes/axos.css +32 -32
- package/dist/assets/themes/premier.css +31 -31
- package/dist/assets/themes/victorie.css +23 -23
- package/dist/icons/CheckCircle.js +1 -1
- package/dist/icons/CheckCircleLight.js +1 -1
- package/dist/icons/CheckIcon/index.js +1 -1
- package/dist/icons/Clock/index.js +6 -6
- package/dist/icons/Logos/SPB.d.ts +4 -0
- package/dist/icons/Logos/SPB.js +132 -0
- package/dist/icons/QuoteIconGrey.js +2 -2
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.js +2 -0
- package/dist/main.js +88 -26
- package/dist/themes/axos.css.d.ts +12 -12
- package/dist/themes/axos.css.js +1 -1
- package/dist/utils/allowedAxosDomains.d.ts +3 -2
- package/dist/utils/allowedAxosDomains.js +49 -45
- package/dist/utils/emailValidation.d.ts +1 -0
- package/dist/utils/emailValidation.js +31 -0
- package/dist/utils/index.d.ts +4 -1
- package/dist/utils/index.js +11 -2
- package/dist/utils/nmlsValidation.d.ts +1 -0
- package/dist/utils/nmlsValidation.js +34 -0
- package/dist/utils/useCachedValidators.d.ts +2 -0
- package/dist/utils/useCachedValidators.js +22 -0
- package/dist/utils/validateExternalLinks.d.ts +1 -1
- package/dist/utils/validateExternalLinks.js +2 -2
- package/package.json +1 -1
- package/dist/NavigationMenu/NavDataJson.d.ts +0 -2
- package/dist/NavigationMenu/NavDataJson.js +0 -315
package/dist/Chatbot/Bubble.js
CHANGED
|
@@ -3,10 +3,13 @@ import { jsxs, jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { AnimatePresence, motion } from "framer-motion";
|
|
4
4
|
import { bubbleWrapper, svgFill } from "./Bubble.css.js";
|
|
5
5
|
import { useOpenChat } from "./store/chat.js";
|
|
6
|
-
const Bubble = ({
|
|
6
|
+
const Bubble = ({
|
|
7
|
+
children,
|
|
8
|
+
onClick = () => {
|
|
9
|
+
}
|
|
10
|
+
}) => {
|
|
7
11
|
const isOpen = useOpenChat((state) => state.isOpen);
|
|
8
|
-
|
|
9
|
-
return /* @__PURE__ */ jsxs("div", { className: bubbleWrapper, onClick: toggle, children: [
|
|
12
|
+
return /* @__PURE__ */ jsxs("div", { className: bubbleWrapper, onClick, children: [
|
|
10
13
|
/* @__PURE__ */ jsx("div", { className: "bubble-circle flex", children: /* @__PURE__ */ jsx(AnimatePresence, { children: !isOpen ? /* @__PURE__ */ jsxs(
|
|
11
14
|
motion.svg,
|
|
12
15
|
{
|
|
@@ -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
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
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,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MessageResponse as BaseMessageResponse, HumanAgent } from '@ujet/websdk-headless';
|
|
1
|
+
import { MessageResponse as BaseMessageResponse, HumanAgent, VirtualAgent } from '@ujet/websdk-headless';
|
|
2
2
|
import { default as React } from 'react';
|
|
3
3
|
|
|
4
4
|
interface MessageResponse extends BaseMessageResponse {
|
|
@@ -19,11 +19,8 @@ interface ChatWindowProps {
|
|
|
19
19
|
onClose?: () => void;
|
|
20
20
|
endChat?: () => void;
|
|
21
21
|
showReconnect?: boolean;
|
|
22
|
-
virtualAgent?:
|
|
23
|
-
|
|
24
|
-
name: string;
|
|
25
|
-
id: string;
|
|
26
|
-
};
|
|
22
|
+
virtualAgent?: VirtualAgent | null;
|
|
23
|
+
showAvatar?: boolean;
|
|
27
24
|
}
|
|
28
25
|
export declare const ChatWindow: React.FC<ChatWindowProps>;
|
|
29
26
|
export {};
|
|
@@ -5,7 +5,8 @@ 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
|
+
import EllipsisLoader from "./EllipsisAnimation.js";
|
|
9
10
|
import { EllipsisIcon } from "./EllipsisIcon.js";
|
|
10
11
|
import { useOpenChat } from "./store/chat.js";
|
|
11
12
|
const ChatWindow = ({
|
|
@@ -18,7 +19,8 @@ const ChatWindow = ({
|
|
|
18
19
|
console.log("End chat");
|
|
19
20
|
},
|
|
20
21
|
showReconnect = false,
|
|
21
|
-
virtualAgent
|
|
22
|
+
virtualAgent,
|
|
23
|
+
showAvatar = false
|
|
22
24
|
}) => {
|
|
23
25
|
const [mounted, setMounted] = React.useState(false);
|
|
24
26
|
const [menuOpen, setMenuOpen] = React.useState(false);
|
|
@@ -26,14 +28,16 @@ const ChatWindow = ({
|
|
|
26
28
|
const state = useNetworkState();
|
|
27
29
|
const [input, setInput] = React.useState("");
|
|
28
30
|
const messagesEndRef = useRef(null);
|
|
31
|
+
const inputRef = useRef(null);
|
|
29
32
|
const isOpen = useOpenChat((state2) => state2.isOpen);
|
|
30
33
|
useEffect(() => {
|
|
31
34
|
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
32
35
|
}, [messages]);
|
|
33
36
|
const handleSend = (e) => {
|
|
34
37
|
e.preventDefault();
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
const cleaned = cleanInput(input);
|
|
39
|
+
if (cleaned) {
|
|
40
|
+
onSend(cleaned);
|
|
37
41
|
setInput("");
|
|
38
42
|
}
|
|
39
43
|
};
|
|
@@ -44,6 +48,21 @@ const ChatWindow = ({
|
|
|
44
48
|
const isAxos = project === "axos";
|
|
45
49
|
const endUserBg = isAxos ? "#14263d" : "#323339";
|
|
46
50
|
const chatbotBg = isAxos ? "#E9F8FF" : "#EAE8E8";
|
|
51
|
+
const escalationDeflected = messages?.filter(
|
|
52
|
+
(item) => item.type == "noti" && item.event == "escalationDeflected"
|
|
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]);
|
|
47
66
|
return /* @__PURE__ */ jsxs("div", { className: clsx(windowStyle, isOpen && windowOpenStyle), children: [
|
|
48
67
|
/* @__PURE__ */ jsxs("div", { className: windowBarStyle, children: [
|
|
49
68
|
/* @__PURE__ */ jsxs("div", { className: "flex middle", style: { paddingBlock: "6px" }, children: [
|
|
@@ -209,6 +228,34 @@ const ChatWindow = ({
|
|
|
209
228
|
}
|
|
210
229
|
) }) : null,
|
|
211
230
|
/* @__PURE__ */ jsxs("div", { className: clsx(messagesContainerStyle), children: [
|
|
231
|
+
(status === "idle" || messages.length == 0) && /* @__PURE__ */ jsx(
|
|
232
|
+
"div",
|
|
233
|
+
{
|
|
234
|
+
className: clsx(),
|
|
235
|
+
style: {
|
|
236
|
+
textAlign: "left",
|
|
237
|
+
alignSelf: "flex-start",
|
|
238
|
+
background: "#eee",
|
|
239
|
+
color: "#1e3860",
|
|
240
|
+
borderRadius: 16,
|
|
241
|
+
padding: "8px 8px",
|
|
242
|
+
maxWidth: "80%",
|
|
243
|
+
marginBottom: 2
|
|
244
|
+
},
|
|
245
|
+
children: /* @__PURE__ */ jsx(
|
|
246
|
+
"div",
|
|
247
|
+
{
|
|
248
|
+
style: {
|
|
249
|
+
fontSize: 13,
|
|
250
|
+
display: "flex",
|
|
251
|
+
flexDirection: "column",
|
|
252
|
+
gap: 4
|
|
253
|
+
},
|
|
254
|
+
children: /* @__PURE__ */ jsx(EllipsisLoader, {})
|
|
255
|
+
}
|
|
256
|
+
)
|
|
257
|
+
}
|
|
258
|
+
),
|
|
212
259
|
messages?.map((msg) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
213
260
|
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),
|
|
214
261
|
msg.type == "noti" && msg.$userType == "system" && msg.event == "memberLeft" && /* @__PURE__ */ jsxs("div", { className: notificationStyle, children: [
|
|
@@ -220,7 +267,23 @@ const ChatWindow = ({
|
|
|
220
267
|
" ",
|
|
221
268
|
msg.to_agent ? /* @__PURE__ */ jsx("strong", { children: msg?.to_agent?.name }) : "an agent"
|
|
222
269
|
] }, msg.$index),
|
|
223
|
-
|
|
270
|
+
msg.type == "noti" && msg.$userType == "virtual_agent" && msg.event == "escalationDeflected" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
271
|
+
/* @__PURE__ */ jsxs(
|
|
272
|
+
"div",
|
|
273
|
+
{
|
|
274
|
+
className: notificationStyle,
|
|
275
|
+
style: { fontSize: 12 },
|
|
276
|
+
children: [
|
|
277
|
+
"Our chat team is available weekdays, 8am-5pm, except federal bank holidays. For immediate assistance you can reach out to us at ",
|
|
278
|
+
/* @__PURE__ */ jsx("a", { href: "tel:1-888-502-2967", children: "1-888-502-2967" }),
|
|
279
|
+
"."
|
|
280
|
+
]
|
|
281
|
+
},
|
|
282
|
+
msg.$index
|
|
283
|
+
),
|
|
284
|
+
/* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginBottom: 12 }, children: /* @__PURE__ */ jsx("button", { className: endChatButtonStyle, onClick: endChat, children: "End Chat" }) })
|
|
285
|
+
] }),
|
|
286
|
+
["text", "markdown_template", "markdown"].includes(msg.type) && /* @__PURE__ */ jsx(
|
|
224
287
|
"div",
|
|
225
288
|
{
|
|
226
289
|
className: messageStyle,
|
|
@@ -231,62 +294,58 @@ const ChatWindow = ({
|
|
|
231
294
|
color: msg.$userType == "end_user" ? "#fff" : "#1F1F1F",
|
|
232
295
|
boxShadow: msg.$userType == "end_user" ? "0 1px 4px #b3e0ff55" : void 0
|
|
233
296
|
},
|
|
234
|
-
children:
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
{
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
{
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
{
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
"
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
),
|
|
288
|
-
/* @__PURE__ */ jsx("div", { style: { fontSize: 10, color: "#888", marginTop: 2 } })
|
|
289
|
-
]
|
|
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
|
+
)
|
|
290
349
|
},
|
|
291
350
|
msg.$index
|
|
292
351
|
),
|
|
@@ -349,20 +408,31 @@ const ChatWindow = ({
|
|
|
349
408
|
onSubmit: handleSend,
|
|
350
409
|
style: {
|
|
351
410
|
borderTop: "1px solid #eee",
|
|
352
|
-
display: "flex"
|
|
353
|
-
gap: 8
|
|
411
|
+
display: "flex"
|
|
412
|
+
// gap: 8,
|
|
354
413
|
},
|
|
355
414
|
children: [
|
|
356
415
|
/* @__PURE__ */ jsx(
|
|
357
|
-
"
|
|
416
|
+
"textarea",
|
|
358
417
|
{
|
|
359
|
-
|
|
418
|
+
ref: inputRef,
|
|
360
419
|
value: input,
|
|
361
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
|
+
},
|
|
362
431
|
placeholder: "Ask something...",
|
|
363
|
-
className: inputStyle,
|
|
432
|
+
className: clsx(inputStyle, autoResize),
|
|
364
433
|
autoFocus: true,
|
|
365
|
-
disabled: inputDisabled || status !== "connected"
|
|
434
|
+
disabled: inputDisabled || status !== "connected" || messages.length == 0 || escalationDeflected,
|
|
435
|
+
rows: 1
|
|
366
436
|
}
|
|
367
437
|
),
|
|
368
438
|
/* @__PURE__ */ jsx(
|
|
@@ -370,7 +440,8 @@ const ChatWindow = ({
|
|
|
370
440
|
{
|
|
371
441
|
className: clsx(sendButtonStyle, input.trim().length > 0 && "active"),
|
|
372
442
|
type: "submit",
|
|
373
|
-
|
|
443
|
+
title: "Send message",
|
|
444
|
+
disabled: inputDisabled || status !== "connected" || !input.trim() || messages.length == 0 || escalationDeflected,
|
|
374
445
|
children: /* @__PURE__ */ jsxs(
|
|
375
446
|
"svg",
|
|
376
447
|
{
|
|
@@ -2,4 +2,9 @@ export type ChatbotProps = {
|
|
|
2
2
|
project?: "axos" | "ufb";
|
|
3
3
|
debug?: boolean;
|
|
4
4
|
};
|
|
5
|
-
export declare const Chatbot: (
|
|
5
|
+
export declare const Chatbot: ({ project, projectEnv, menuOption, debug, }: {
|
|
6
|
+
project?: "axos" | "ufb";
|
|
7
|
+
projectEnv?: "dev" | "qa" | "uat" | "stg" | "prod";
|
|
8
|
+
menuOption?: "Support Virtual Agent" | string;
|
|
9
|
+
debug?: boolean;
|
|
10
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
package/dist/Chatbot/Chatbot.js
CHANGED
|
@@ -6,33 +6,248 @@ 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 {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
import { useRef, useState, useEffect } from "react";
|
|
10
|
+
import { useMount, useUnmount } from "react-use";
|
|
11
|
+
const Chatbot = ({
|
|
12
|
+
project = "axos",
|
|
13
|
+
projectEnv = "dev",
|
|
14
|
+
menuOption = "Support Virtual Agent",
|
|
15
|
+
debug = false
|
|
16
|
+
}) => {
|
|
17
|
+
const { hasOpenedOnce, toggle, reset } = useOpenChat();
|
|
18
|
+
const { addMessage, addMessages, clearMessages, messages } = useMessages();
|
|
19
|
+
const clientRef = useRef(null);
|
|
20
|
+
const menuRef = useRef(null);
|
|
21
|
+
const isMountedRef = useRef(false);
|
|
22
|
+
const hasLoadedBefore = useRef(true);
|
|
23
|
+
const chatRef = useRef(null);
|
|
24
|
+
const agent_virtual = useRef(null);
|
|
25
|
+
const [status, setStatus] = useState("idle");
|
|
26
|
+
const [hasStarted, setHasStarted] = useState(false);
|
|
27
|
+
const [menusLoaded, setMenusLoaded] = useState(false);
|
|
28
|
+
const [pendingStart, setPendingStart] = useState(false);
|
|
29
|
+
const brandMap = /* @__PURE__ */ new Map([
|
|
30
|
+
["axos", 1],
|
|
31
|
+
["ufb", 3]
|
|
32
|
+
]);
|
|
33
|
+
const custom_data = {
|
|
34
|
+
unsigned: {
|
|
35
|
+
facingBrandId: {
|
|
36
|
+
label: "facingBrandId",
|
|
37
|
+
value: `${brandMap.get(project) || 1}`
|
|
38
|
+
},
|
|
39
|
+
channel: {
|
|
40
|
+
label: "channel",
|
|
41
|
+
value: "in_web"
|
|
42
|
+
},
|
|
43
|
+
user_auth: {
|
|
44
|
+
label: "user_auth",
|
|
45
|
+
value: "false"
|
|
46
|
+
},
|
|
47
|
+
env: {
|
|
48
|
+
label: "env",
|
|
49
|
+
value: projectEnv === "dev" ? "uat" : projectEnv
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const onReadyHandler = async () => {
|
|
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
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const onAuthenticatedHandler = async () => {
|
|
62
|
+
console.log("Chat client is authenticated");
|
|
63
|
+
};
|
|
64
|
+
const onChatOngoingHandler = async (chat) => {
|
|
65
|
+
console.log("Ongoing chat:", chat);
|
|
66
|
+
};
|
|
67
|
+
const onChatMessageHandler = async (message) => {
|
|
68
|
+
console.log("Received message:", message);
|
|
69
|
+
addMessage(message);
|
|
70
|
+
};
|
|
71
|
+
const onChatTypingStartedHandler = async (identity) => {
|
|
72
|
+
console.log("Typing started by:", identity);
|
|
73
|
+
};
|
|
74
|
+
const onChatDisconnectedHandler = async () => {
|
|
75
|
+
console.log("Chat disconnected");
|
|
76
|
+
setStatus("idle");
|
|
77
|
+
};
|
|
78
|
+
const onDismissedHandler = async () => {
|
|
79
|
+
console.log("Chat dismissed");
|
|
80
|
+
};
|
|
81
|
+
const onTimeoutHandler = async () => {
|
|
82
|
+
console.log("Chat timeout");
|
|
83
|
+
};
|
|
84
|
+
const onEndedHandler = async () => {
|
|
85
|
+
console.log("Chat ended");
|
|
86
|
+
setStatus("finished");
|
|
87
|
+
};
|
|
88
|
+
const onDestroyedHandler = async () => {
|
|
89
|
+
console.log("Chat destroyed");
|
|
90
|
+
};
|
|
91
|
+
const onChatMemberLeftHandler = async (identity) => {
|
|
92
|
+
console.log("Chat member left:", identity);
|
|
93
|
+
};
|
|
94
|
+
const onChatConnectedHandler = async () => {
|
|
95
|
+
setStatus("connected");
|
|
96
|
+
console.log("connected");
|
|
97
|
+
const messages2 = await clientRef.current?.fetchMessages();
|
|
98
|
+
if (messages2) {
|
|
99
|
+
addMessages(messages2);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const registerEventHandlers = () => {
|
|
103
|
+
clientRef.current?.on("chat.ongoing", onChatOngoingHandler);
|
|
104
|
+
clientRef.current?.on("chat.message", onChatMessageHandler);
|
|
105
|
+
clientRef.current?.on("chat.typingStarted", onChatTypingStartedHandler);
|
|
106
|
+
clientRef.current?.on("chat.disconnected", onChatDisconnectedHandler);
|
|
107
|
+
clientRef.current?.on("chat.dismissed", onDismissedHandler);
|
|
108
|
+
clientRef.current?.on("chat.timeout", onTimeoutHandler);
|
|
109
|
+
clientRef.current?.on("chat.ended", onEndedHandler);
|
|
110
|
+
clientRef.current?.on("chat.destroyed", onDestroyedHandler);
|
|
111
|
+
clientRef.current?.on("chat.memberLeft", onChatMemberLeftHandler);
|
|
112
|
+
clientRef?.current?.on("chat.connected", onChatConnectedHandler);
|
|
113
|
+
};
|
|
114
|
+
const deregisterEventHandlers = () => {
|
|
115
|
+
clientRef.current?.off("ready", onReadyHandler);
|
|
116
|
+
clientRef.current?.off("authenticated", onAuthenticatedHandler);
|
|
117
|
+
clientRef.current?.off("chat.ongoing", onDismissedHandler);
|
|
118
|
+
clientRef.current?.off("chat.message", onChatMessageHandler);
|
|
119
|
+
clientRef.current?.off("chat.typingStarted", onChatTypingStartedHandler);
|
|
120
|
+
clientRef.current?.off("chat.disconnected", onChatDisconnectedHandler);
|
|
121
|
+
clientRef.current?.off("chat.dismissed", onDismissedHandler);
|
|
122
|
+
clientRef.current?.off("chat.timeout", onTimeoutHandler);
|
|
123
|
+
clientRef.current?.off("chat.ended", onEndedHandler);
|
|
124
|
+
clientRef.current?.off("chat.destroyed", onDestroyedHandler);
|
|
125
|
+
clientRef.current?.off("chat.memberLeft", onChatMemberLeftHandler);
|
|
126
|
+
clientRef.current?.off("chat.connected", onChatConnectedHandler);
|
|
127
|
+
};
|
|
128
|
+
const createClient = async () => {
|
|
129
|
+
const { Client, Logger, consoleLoggerHandler } = await import("@ujet/websdk-headless");
|
|
130
|
+
if (projectEnv !== "prod" || debug) {
|
|
131
|
+
Logger.addHandler(consoleLoggerHandler);
|
|
132
|
+
}
|
|
133
|
+
if (clientRef.current) return;
|
|
134
|
+
const client = new Client({
|
|
135
|
+
companyId: process.env.CCAI_COMPANY_ID || "",
|
|
136
|
+
tenant: process.env.CCAI_TENANT_NAME || "",
|
|
137
|
+
host: process.env.CCAI_HOST || "",
|
|
138
|
+
// or your region
|
|
139
|
+
authenticate
|
|
140
|
+
});
|
|
141
|
+
client?.on("ready", onReadyHandler);
|
|
142
|
+
client?.on("authenticated", onAuthenticatedHandler);
|
|
143
|
+
isMountedRef.current = true;
|
|
144
|
+
clientRef.current = client;
|
|
145
|
+
registerEventHandlers();
|
|
146
|
+
return;
|
|
147
|
+
};
|
|
148
|
+
const startChat = async () => {
|
|
149
|
+
console.log("Starting chat");
|
|
150
|
+
const client = clientRef.current;
|
|
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
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
const ongoingChat = await client.loadOngoingChat();
|
|
165
|
+
if (ongoingChat) {
|
|
166
|
+
console.log("Ongoing chat found:", ongoingChat);
|
|
167
|
+
console.log("Resuming chat:", ongoingChat.id);
|
|
168
|
+
chatRef.current = await client.resumeChat(ongoingChat.id);
|
|
169
|
+
agent_virtual.current = ongoingChat.agent;
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const foundMenu = menuRef.current.menus.find(
|
|
173
|
+
(menu) => menu.name === menuOption
|
|
174
|
+
);
|
|
175
|
+
const menuId = foundMenu && foundMenu.id;
|
|
176
|
+
console.log("Creating new chat with menu ID:", menuId);
|
|
177
|
+
const newChat = await client.createChat(menuId, { custom_data });
|
|
178
|
+
if (newChat !== null) {
|
|
179
|
+
chatRef.current = newChat;
|
|
180
|
+
agent_virtual.current = newChat.agent;
|
|
181
|
+
console.log("Chat created id:", newChat.id);
|
|
182
|
+
}
|
|
183
|
+
} catch (err) {
|
|
184
|
+
console.error("Error creating chat:", err);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
const handleClick = async () => {
|
|
188
|
+
toggle();
|
|
189
|
+
if (hasStarted) return;
|
|
190
|
+
if (!menusLoaded) {
|
|
191
|
+
setPendingStart(true);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (!hasOpenedOnce) {
|
|
195
|
+
await startChat();
|
|
196
|
+
setHasStarted(true);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
const onSendMessage = (msg) => {
|
|
200
|
+
console.log("Sending message:", msg);
|
|
201
|
+
clientRef.current?.sendTextMessage(msg);
|
|
202
|
+
};
|
|
203
|
+
const onEndChat = async () => {
|
|
204
|
+
console.log("Ending chat");
|
|
205
|
+
if (chatRef.current) {
|
|
206
|
+
await clientRef.current?.finishChat();
|
|
207
|
+
await chatRef.current.destroy();
|
|
208
|
+
clearMessages();
|
|
209
|
+
chatRef.current = null;
|
|
210
|
+
console.log("Chat ended");
|
|
211
|
+
setHasStarted(false);
|
|
212
|
+
reset();
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
useMount(async () => {
|
|
216
|
+
console.log("Chatbot mounted");
|
|
217
|
+
if (isMountedRef.current) return;
|
|
218
|
+
isMountedRef.current = true;
|
|
219
|
+
await createClient();
|
|
220
|
+
});
|
|
221
|
+
useEffect(() => {
|
|
222
|
+
if (menusLoaded && pendingStart && !hasStarted) {
|
|
223
|
+
startChat();
|
|
224
|
+
setHasStarted(true);
|
|
225
|
+
setPendingStart(false);
|
|
226
|
+
}
|
|
227
|
+
}, [menusLoaded, pendingStart, hasStarted]);
|
|
228
|
+
useUnmount(() => {
|
|
229
|
+
console.log("Chatbot unmounted");
|
|
230
|
+
deregisterEventHandlers();
|
|
231
|
+
isMountedRef.current = false;
|
|
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;
|
|
21
240
|
});
|
|
22
|
-
return /* @__PURE__ */ jsxs("div", { className:
|
|
23
|
-
/* @__PURE__ */ jsx(Bubble, {}),
|
|
241
|
+
return /* @__PURE__ */ jsxs("div", { className: project === "ufb" ? chatbotUFB : chatbotAXB, children: [
|
|
242
|
+
/* @__PURE__ */ jsx(Bubble, { onClick: handleClick }),
|
|
24
243
|
/* @__PURE__ */ jsx(
|
|
25
244
|
ChatWindow,
|
|
26
245
|
{
|
|
27
246
|
status,
|
|
28
|
-
|
|
247
|
+
virtualAgent: agent_virtual.current,
|
|
29
248
|
messages,
|
|
30
|
-
onSend:
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
endChat,
|
|
34
|
-
virtualAgent,
|
|
35
|
-
showReconnect
|
|
249
|
+
onSend: onSendMessage,
|
|
250
|
+
endChat: onEndChat
|
|
36
251
|
}
|
|
37
252
|
)
|
|
38
253
|
] });
|