@axos-web-dev/shared-components 0.0.145 → 0.0.147

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.
@@ -8,7 +8,7 @@ import "../../icons/CheckIcon/CheckIcon.css.js";
8
8
  /* empty css */
9
9
  /* empty css */
10
10
  /* empty css */
11
- import { useState, useEffect } from "react";
11
+ import { useState, useRef, useEffect } from "react";
12
12
  import "../../Chevron/Chevron.css.js";
13
13
  import "../../AlertBanner/AlertBanner.css.js";
14
14
  import "../../Article/Article.css.js";
@@ -96,16 +96,17 @@ import "../../StepItemSet/StepItemSet.css.js";
96
96
  import "next/script.js";
97
97
  /* empty css */
98
98
  /* empty css */
99
+ import { usePathname } from "next/navigation.js";
99
100
  import Image from "next/image.js";
100
101
  import Link from "next/link.js";
101
- import { usePathname } from "next/navigation.js";
102
102
  import { sub_nav, dd_media } from "./SubNavbar.css.js";
103
103
  function SubNavBar() {
104
104
  const pathname = usePathname();
105
105
  const [hoveredLink, setHoveredLink] = useState(void 0);
106
106
  const handleMouseEnter = (link) => setHoveredLink(link);
107
107
  const handleMouseLeave = () => setHoveredLink(void 0);
108
- const hideOnClick = () => setHoveredLink(void 0);
108
+ const containerRef = useRef(null);
109
+ const [isClient, setIsClient] = useState(false);
109
110
  const [showNavbar, setShowNavbar] = useState(false);
110
111
  const support = subNavItems.support;
111
112
  const about = subNavItems.about;
@@ -127,6 +128,31 @@ function SubNavBar() {
127
128
  ].some((el) => pathname?.includes(el) || isHomepage)
128
129
  );
129
130
  }, [pathname]);
131
+ useEffect(() => {
132
+ setIsClient(true);
133
+ }, []);
134
+ useEffect(() => {
135
+ if (hoveredLink && containerRef.current && isClient) {
136
+ containerRef.current.focus();
137
+ }
138
+ }, [hoveredLink, isClient]);
139
+ const handleKeyDownContainer = (e, linkId) => {
140
+ if (e.key === "Tab") {
141
+ const focusableElements = containerRef.current?.querySelectorAll(
142
+ 'button, [href], a, [tabindex]:not([tabindex="-1"])'
143
+ );
144
+ if (focusableElements && isClient) {
145
+ const lastElement = focusableElements[focusableElements.length - 1];
146
+ const isShiftPressed = e.shiftKey;
147
+ if (!isShiftPressed && document.activeElement === lastElement) {
148
+ e.preventDefault();
149
+ const triggeredLink = document.getElementById(linkId);
150
+ setHoveredLink(void 0);
151
+ triggeredLink?.focus();
152
+ }
153
+ }
154
+ }
155
+ };
130
156
  return showNavbar ? /* @__PURE__ */ jsx("div", { className: `${styles.sub_nav} ${sub_nav} ${styles.desktop_only}`, children: /* @__PURE__ */ jsx("div", { className: styles.wrapper, children: /* @__PURE__ */ jsx("div", { className: styles.header_sub_row, children: /* @__PURE__ */ jsxs("nav", { children: [
131
157
  /* @__PURE__ */ jsxs("ul", { className: "list_unstyled flex_row middle", children: [
132
158
  (isHomepage || pathname?.includes("/personal") || pathname?.includes("/invest/insights")) && /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -137,7 +163,11 @@ function SubNavBar() {
137
163
  id: "personalNav1",
138
164
  role: "menuitem",
139
165
  onMouseEnter: () => handleMouseEnter("bank"),
140
- onClick: hideOnClick,
166
+ onKeyDown: (event) => {
167
+ if (event.key === "Enter") {
168
+ handleMouseEnter("bank");
169
+ }
170
+ },
141
171
  children: [
142
172
  "Bank",
143
173
  /* @__PURE__ */ jsx(
@@ -168,7 +198,11 @@ function SubNavBar() {
168
198
  id: "personalNav2",
169
199
  role: "menuitem",
170
200
  onMouseEnter: () => handleMouseEnter("borrow"),
171
- onClick: hideOnClick,
201
+ onKeyDown: (event) => {
202
+ if (event.key === "Enter") {
203
+ handleMouseEnter("borrow");
204
+ }
205
+ },
172
206
  children: [
173
207
  "Borrow",
174
208
  /* @__PURE__ */ jsx(
@@ -199,7 +233,11 @@ function SubNavBar() {
199
233
  id: "personalNav3",
200
234
  role: "menuitem",
201
235
  onMouseEnter: () => handleMouseEnter("invest"),
202
- onClick: hideOnClick,
236
+ onKeyDown: (event) => {
237
+ if (event.key === "Enter") {
238
+ handleMouseEnter("invest");
239
+ }
240
+ },
203
241
  children: [
204
242
  "Invest",
205
243
  /* @__PURE__ */ jsx(
@@ -230,7 +268,11 @@ function SubNavBar() {
230
268
  id: "personalNav4",
231
269
  role: "menuitem",
232
270
  onMouseEnter: () => handleMouseEnter("plan"),
233
- onClick: hideOnClick,
271
+ onKeyDown: (event) => {
272
+ if (event.key === "Enter") {
273
+ handleMouseEnter("plan");
274
+ }
275
+ },
234
276
  children: [
235
277
  "Plan",
236
278
  /* @__PURE__ */ jsx(
@@ -263,7 +305,11 @@ function SubNavBar() {
263
305
  id: "busNav1",
264
306
  role: "menuitem",
265
307
  onMouseEnter: () => handleMouseEnter("sbb"),
266
- onClick: hideOnClick,
308
+ onKeyDown: (event) => {
309
+ if (event.key === "Enter") {
310
+ handleMouseEnter("sbb");
311
+ }
312
+ },
267
313
  children: [
268
314
  "Small Business Banking",
269
315
  /* @__PURE__ */ jsx(
@@ -294,7 +340,11 @@ function SubNavBar() {
294
340
  id: "busNav2",
295
341
  role: "menuitem",
296
342
  onMouseEnter: () => handleMouseEnter("combank"),
297
- onClick: hideOnClick,
343
+ onKeyDown: (event) => {
344
+ if (event.key === "Enter") {
345
+ handleMouseEnter("combank");
346
+ }
347
+ },
298
348
  children: [
299
349
  "Commercial Banking",
300
350
  /* @__PURE__ */ jsx(
@@ -325,7 +375,11 @@ function SubNavBar() {
325
375
  id: "busNav3",
326
376
  role: "menuitem",
327
377
  onMouseEnter: () => handleMouseEnter("comlending"),
328
- onClick: hideOnClick,
378
+ onKeyDown: (event) => {
379
+ if (event.key === "Enter") {
380
+ handleMouseEnter("comlending");
381
+ }
382
+ },
329
383
  children: [
330
384
  "Commercial Lending",
331
385
  /* @__PURE__ */ jsx(
@@ -368,7 +422,11 @@ function SubNavBar() {
368
422
  id: "partNav2",
369
423
  role: "menuitem",
370
424
  onMouseEnter: () => handleMouseEnter("wholelending"),
371
- onClick: hideOnClick,
425
+ onKeyDown: (event) => {
426
+ if (event.key === "Enter") {
427
+ handleMouseEnter("wholelending");
428
+ }
429
+ },
372
430
  children: [
373
431
  "Wholesale Lending",
374
432
  /* @__PURE__ */ jsx(
@@ -399,7 +457,11 @@ function SubNavBar() {
399
457
  id: "partNav3",
400
458
  role: "menuitem",
401
459
  onMouseEnter: () => handleMouseEnter("sbc"),
402
- onClick: hideOnClick,
460
+ onKeyDown: (event) => {
461
+ if (event.key === "Enter") {
462
+ handleMouseEnter("sbc");
463
+ }
464
+ },
403
465
  children: [
404
466
  "Small Balance Commercial",
405
467
  /* @__PURE__ */ jsx(
@@ -440,7 +502,11 @@ function SubNavBar() {
440
502
  id: "partNav5",
441
503
  role: "menuitem",
442
504
  onMouseEnter: () => handleMouseEnter("dealerservices"),
443
- onClick: hideOnClick,
505
+ onKeyDown: (event) => {
506
+ if (event.key === "Enter") {
507
+ handleMouseEnter("dealerservices");
508
+ }
509
+ },
444
510
  children: [
445
511
  "Dealer Services",
446
512
  /* @__PURE__ */ jsx(
@@ -488,6 +554,9 @@ function SubNavBar() {
488
554
  className: `${styles.dd_wrapper} ${styles.desktop_only} `,
489
555
  role: "menu",
490
556
  onMouseLeave: handleMouseLeave,
557
+ ref: containerRef,
558
+ tabIndex: 0,
559
+ onKeyDown: (event) => handleKeyDownContainer(event, "personalNav2"),
491
560
  children: /* @__PURE__ */ jsx("div", { className: styles.wrapper, children: /* @__PURE__ */ jsxs("div", { className: `${styles.shadow} rounded flex_row`, children: [
492
561
  /* @__PURE__ */ jsxs(
493
562
  "div",
@@ -495,8 +564,8 @@ function SubNavBar() {
495
564
  className: `${styles.dd_media} ${styles.opacity} ${dd_media} w_auto text_center`,
496
565
  children: [
497
566
  /* @__PURE__ */ jsxs("div", { className: styles.dd_media_header, children: [
498
- /* @__PURE__ */ jsx("p", { role: "heading", children: "Checking" }),
499
- /* @__PURE__ */ jsx("p", { className: styles.mt_8, children: "Explore the benefits of our newest account bundle with up to 4.53% APY on Savings, 0.51% on Checking, plus early paydays and no monthly fees." })
567
+ /* @__PURE__ */ jsx("p", { role: "heading", children: "Introducing Axos ONE" }),
568
+ /* @__PURE__ */ jsx("p", { className: styles.mt_8, children: "Explore the benefits of our newest account bundle with up to 4.86% APY on Savings, 0.51% on Checking, plus early paydays and no monthly fees." })
500
569
  ] }),
501
570
  /* @__PURE__ */ jsx(
502
571
  "div",
@@ -505,10 +574,10 @@ function SubNavBar() {
505
574
  children: /* @__PURE__ */ jsx(
506
575
  Image,
507
576
  {
508
- src: `https://images.axos.com/o9ov1v03uwqk/eEwgc8g9ws7oWWUTh2G8X/de2e3ede3ca7c3762e052d9cba375de7/nav-submenu-bank.svg`,
577
+ src: `https://images.axos.com/o9ov1v03uwqk/4dO1rYpd0H4ONDtLWCw5ze/2a843450436d41d18d91d6b97a7501bb/axos-one-nav.png`,
509
578
  alt: "",
510
579
  width: 233,
511
- height: 222
580
+ height: 233
512
581
  }
513
582
  )
514
583
  }
@@ -837,6 +906,9 @@ function SubNavBar() {
837
906
  className: `${styles.dd_wrapper} ${styles.desktop_only} `,
838
907
  role: "menu",
839
908
  onMouseLeave: handleMouseLeave,
909
+ ref: containerRef,
910
+ tabIndex: 0,
911
+ onKeyDown: (event) => handleKeyDownContainer(event, "personalNav3"),
840
912
  children: /* @__PURE__ */ jsx("div", { className: styles.wrapper, children: /* @__PURE__ */ jsxs("div", { className: `${styles.shadow} rounded flex_row`, children: [
841
913
  /* @__PURE__ */ jsxs(
842
914
  "div",
@@ -1204,6 +1276,9 @@ function SubNavBar() {
1204
1276
  className: `${styles.dd_wrapper} ${styles.desktop_only} `,
1205
1277
  role: "menu",
1206
1278
  onMouseLeave: handleMouseLeave,
1279
+ ref: containerRef,
1280
+ tabIndex: 0,
1281
+ onKeyDown: (event) => handleKeyDownContainer(event, "personalNav4"),
1207
1282
  children: /* @__PURE__ */ jsx("div", { className: styles.wrapper, children: /* @__PURE__ */ jsxs("div", { className: `${styles.shadow} rounded flex_row`, children: [
1208
1283
  /* @__PURE__ */ jsxs(
1209
1284
  "div",
@@ -1474,6 +1549,9 @@ function SubNavBar() {
1474
1549
  className: `${styles.dd_wrapper} ${styles.desktop_only} `,
1475
1550
  role: "menu",
1476
1551
  onMouseLeave: handleMouseLeave,
1552
+ ref: containerRef,
1553
+ tabIndex: 0,
1554
+ onKeyDown: (event) => handleKeyDownContainer(event, "personalNav4"),
1477
1555
  children: /* @__PURE__ */ jsx("div", { className: styles.wrapper, children: /* @__PURE__ */ jsxs("div", { className: `${styles.shadow} rounded flex_row`, children: [
1478
1556
  /* @__PURE__ */ jsxs(
1479
1557
  "div",
@@ -1702,7 +1780,7 @@ function SubNavBar() {
1702
1780
  href: findMoreAxosDomains(
1703
1781
  "{AXOS}/invest/insights/investing-evolved"
1704
1782
  ),
1705
- children: "Investing Podcase"
1783
+ children: "Investing Podcast"
1706
1784
  }
1707
1785
  ) })
1708
1786
  ] })
@@ -1720,6 +1798,9 @@ function SubNavBar() {
1720
1798
  className: `${styles.dd_wrapper} ${styles.desktop_only} `,
1721
1799
  role: "menu",
1722
1800
  onMouseLeave: handleMouseLeave,
1801
+ ref: containerRef,
1802
+ tabIndex: 0,
1803
+ onKeyDown: (event) => handleKeyDownContainer(event, "busNav2"),
1723
1804
  children: /* @__PURE__ */ jsx("div", { className: styles.wrapper, children: /* @__PURE__ */ jsxs("div", { className: `${styles.shadow} rounded flex_row`, children: [
1724
1805
  /* @__PURE__ */ jsxs(
1725
1806
  "div",
@@ -1989,6 +2070,9 @@ function SubNavBar() {
1989
2070
  className: `${styles.dd_wrapper} ${styles.desktop_only} `,
1990
2071
  role: "menu",
1991
2072
  onMouseLeave: handleMouseLeave,
2073
+ ref: containerRef,
2074
+ tabIndex: 0,
2075
+ onKeyDown: (event) => handleKeyDownContainer(event, "busNav3"),
1992
2076
  children: /* @__PURE__ */ jsx("div", { className: styles.wrapper, children: /* @__PURE__ */ jsxs("div", { className: `${styles.shadow} rounded flex_row`, children: [
1993
2077
  /* @__PURE__ */ jsxs(
1994
2078
  "div",
@@ -2217,6 +2301,9 @@ function SubNavBar() {
2217
2301
  className: `${styles.dd_wrapper} ${styles.desktop_only} `,
2218
2302
  role: "menu",
2219
2303
  onMouseLeave: handleMouseLeave,
2304
+ ref: containerRef,
2305
+ tabIndex: 0,
2306
+ onKeyDown: (event) => handleKeyDownContainer(event, "busNav3"),
2220
2307
  children: /* @__PURE__ */ jsx("div", { className: styles.wrapper, children: /* @__PURE__ */ jsxs("div", { className: `${styles.shadow} rounded flex_row`, children: [
2221
2308
  /* @__PURE__ */ jsxs(
2222
2309
  "div",
@@ -2427,6 +2514,9 @@ function SubNavBar() {
2427
2514
  className: `${styles.dd_wrapper} ${styles.desktop_only} `,
2428
2515
  role: "menu",
2429
2516
  onMouseLeave: handleMouseLeave,
2517
+ ref: containerRef,
2518
+ tabIndex: 0,
2519
+ onKeyDown: (event) => handleKeyDownContainer(event, "partNav3"),
2430
2520
  children: /* @__PURE__ */ jsx("div", { className: styles.wrapper, children: /* @__PURE__ */ jsxs("div", { className: `${styles.shadow} rounded flex_row`, children: [
2431
2521
  /* @__PURE__ */ jsxs(
2432
2522
  "div",
@@ -2557,6 +2647,9 @@ function SubNavBar() {
2557
2647
  className: `${styles.dd_wrapper} ${styles.desktop_only} `,
2558
2648
  role: "menu",
2559
2649
  onMouseLeave: handleMouseLeave,
2650
+ ref: containerRef,
2651
+ tabIndex: 0,
2652
+ onKeyDown: (event) => handleKeyDownContainer(event, "partNav4"),
2560
2653
  children: /* @__PURE__ */ jsx("div", { className: styles.wrapper, children: /* @__PURE__ */ jsxs("div", { className: `${styles.shadow} rounded flex_row`, children: [
2561
2654
  /* @__PURE__ */ jsxs(
2562
2655
  "div",
@@ -2700,6 +2793,9 @@ function SubNavBar() {
2700
2793
  className: `${styles.dd_wrapper} ${styles.desktop_only} `,
2701
2794
  role: "menu",
2702
2795
  onMouseLeave: handleMouseLeave,
2796
+ ref: containerRef,
2797
+ tabIndex: 0,
2798
+ onKeyDown: (event) => handleKeyDownContainer(event, "partNav6"),
2703
2799
  children: /* @__PURE__ */ jsx("div", { className: styles.wrapper, children: /* @__PURE__ */ jsxs("div", { className: `${styles.shadow} rounded flex_row`, children: [
2704
2800
  /* @__PURE__ */ jsxs(
2705
2801
  "div",