optimized-react-component-library-xyz123 1.1.26 → 1.1.27

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/index.d.mts CHANGED
@@ -800,7 +800,6 @@ interface NavigationHeaderProps {
800
800
  useNavigationMenu: boolean;
801
801
  useSearch?: boolean;
802
802
  useBreadCrumbs?: boolean;
803
- showNavigationCloseButton?: boolean;
804
803
  menuLinks: INavigationItem[];
805
804
  linkComponent?: ElementType;
806
805
  noLogoLink?: boolean;
@@ -810,7 +809,6 @@ declare const NavigationHeader: FC<NavigationHeaderProps>;
810
809
 
811
810
  interface NavigationProps {
812
811
  setIsMenyOpen?: (open: boolean) => void;
813
- showCloseButton?: boolean;
814
812
  activatedLanguage?: string;
815
813
  menuLinks?: INavigationLink[];
816
814
  isOpen: boolean;
@@ -879,6 +877,7 @@ interface CollapseProps {
879
877
  onToggle?: (open: boolean) => void;
880
878
  id?: string;
881
879
  activatedLanguage?: string;
880
+ customClass?: string;
882
881
  }
883
882
 
884
883
  declare const Collapse: FC<CollapseProps>;
package/dist/index.d.ts CHANGED
@@ -800,7 +800,6 @@ interface NavigationHeaderProps {
800
800
  useNavigationMenu: boolean;
801
801
  useSearch?: boolean;
802
802
  useBreadCrumbs?: boolean;
803
- showNavigationCloseButton?: boolean;
804
803
  menuLinks: INavigationItem[];
805
804
  linkComponent?: ElementType;
806
805
  noLogoLink?: boolean;
@@ -810,7 +809,6 @@ declare const NavigationHeader: FC<NavigationHeaderProps>;
810
809
 
811
810
  interface NavigationProps {
812
811
  setIsMenyOpen?: (open: boolean) => void;
813
- showCloseButton?: boolean;
814
812
  activatedLanguage?: string;
815
813
  menuLinks?: INavigationLink[];
816
814
  isOpen: boolean;
@@ -879,6 +877,7 @@ interface CollapseProps {
879
877
  onToggle?: (open: boolean) => void;
880
878
  id?: string;
881
879
  activatedLanguage?: string;
880
+ customClass?: string;
882
881
  }
883
882
 
884
883
  declare const Collapse: FC<CollapseProps>;
package/dist/index.js CHANGED
@@ -3298,11 +3298,11 @@ var Navigation = ({
3298
3298
  isOpen = false,
3299
3299
  activatedLanguage = "sv",
3300
3300
  menuLinks = [],
3301
- showCloseButton = true,
3302
3301
  openButtonRef = null,
3303
3302
  linkComponent: LinkComponent = "a"
3304
3303
  }) => {
3305
3304
  const closeMenuText = activatedLanguage === "sv" ? "St\xE4ng meny" : "Close menu";
3305
+ const navRef = (0, import_react13.useRef)(null);
3306
3306
  const [openSubMenu, setOpenSubMenu] = (0, import_react13.useState)(null);
3307
3307
  const handleSubMenu = (label) => {
3308
3308
  setOpenSubMenu(openSubMenu === label ? null : label);
@@ -3311,33 +3311,38 @@ var Navigation = ({
3311
3311
  setIsMenyOpen && setIsMenyOpen(false);
3312
3312
  };
3313
3313
  (0, import_react13.useEffect)(() => {
3314
- if (!isOpen) return;
3314
+ if (!isOpen || !navRef.current) return;
3315
+ const nav = navRef.current;
3316
+ const focusableSelectors = 'a, button, input, textarea, select, [tabindex]:not([tabindex="-1"])';
3317
+ const focusableElements = nav.querySelectorAll(focusableSelectors);
3318
+ const firstElement = focusableElements[0];
3319
+ const lastElement = focusableElements[focusableElements.length - 1];
3320
+ firstElement == null ? void 0 : firstElement.focus();
3315
3321
  const handleKeyDown = (event) => {
3316
3322
  var _a;
3317
3323
  if (event.key === "Escape") {
3318
3324
  setIsMenyOpen == null ? void 0 : setIsMenyOpen(false);
3319
- openButtonRef && ((_a = openButtonRef.current) == null ? void 0 : _a.focus());
3325
+ (_a = openButtonRef == null ? void 0 : openButtonRef.current) == null ? void 0 : _a.focus();
3326
+ return;
3327
+ }
3328
+ if (event.key !== "Tab") return;
3329
+ if (event.shiftKey) {
3330
+ if (document.activeElement === firstElement) {
3331
+ event.preventDefault();
3332
+ lastElement == null ? void 0 : lastElement.focus();
3333
+ }
3334
+ } else {
3335
+ if (document.activeElement === lastElement) {
3336
+ event.preventDefault();
3337
+ firstElement == null ? void 0 : firstElement.focus();
3338
+ }
3320
3339
  }
3321
3340
  };
3322
- document.addEventListener("keydown", handleKeyDown);
3323
- return () => document.removeEventListener("keydown", handleKeyDown);
3324
- }, [isOpen, setIsMenyOpen]);
3325
- (0, import_react13.useEffect)(() => {
3326
- const main = document.querySelector("main");
3327
- const footer = document.querySelector("footer");
3328
- if (!main) return;
3329
- if (isOpen) {
3330
- main.setAttribute("inert", "");
3331
- footer && footer.setAttribute("inert", "");
3332
- } else {
3333
- main.removeAttribute("inert");
3334
- footer && footer.removeAttribute("inert");
3335
- }
3341
+ nav.addEventListener("keydown", handleKeyDown);
3336
3342
  return () => {
3337
- main.removeAttribute("inert");
3338
- footer && footer.removeAttribute("inert");
3343
+ nav.removeEventListener("keydown", handleKeyDown);
3339
3344
  };
3340
- }, [isOpen]);
3345
+ }, [isOpen, setIsMenyOpen, openButtonRef]);
3341
3346
  const getSubMenuAriaLabel = (label) => {
3342
3347
  if (activatedLanguage === "en" && openSubMenu === label[activatedLanguage]) {
3343
3348
  return "Close submenu for " + label[activatedLanguage];
@@ -3356,11 +3361,12 @@ var Navigation = ({
3356
3361
  "nav",
3357
3362
  {
3358
3363
  id: "main-navigation",
3364
+ ref: navRef,
3359
3365
  "aria-label": activatedLanguage === "sv" ? "Huvudnavigation" : "Main navigation",
3360
- className: `${showCloseButton ? "pts-navigation-with-close-button" : ""} pts-navigation-menu-container`,
3366
+ className: " pts-navigation-menu-container",
3361
3367
  hidden: !isOpen,
3362
3368
  children: [
3363
- showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "pts-navigation-close-container", id: "menu-close", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3369
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "pts-navigation-close-container ", id: "menu-close", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3364
3370
  "button",
3365
3371
  {
3366
3372
  className: "pts-navigation-close-button",
@@ -3378,7 +3384,7 @@ var Navigation = ({
3378
3384
  className: `pts-navigation-link ${openSubMenu === label[activatedLanguage] ? "open" : ""}`,
3379
3385
  children: [
3380
3386
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "pts-navigation-button", children: [
3381
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: href.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: label[activatedLanguage] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(LinkComponent, { onClick: handleCloseButton, to: href, href, children: label[activatedLanguage] }) }),
3387
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: href.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: label[activatedLanguage] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(LinkComponent, { onClick: handleCloseButton, href, to: href, children: label[activatedLanguage] }) }),
3382
3388
  children && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3383
3389
  "button",
3384
3390
  {
@@ -3504,13 +3510,13 @@ var import_jsx_runtime26 = require("react/jsx-runtime");
3504
3510
  var NavigationHeader = ({
3505
3511
  headline = void 0,
3506
3512
  homelink = "",
3513
+ //??
3507
3514
  activatedLanguage = "sv",
3508
3515
  useLanguage = false,
3509
3516
  useNavigationMenu = true,
3510
3517
  useSearch = false,
3511
3518
  useBreadCrumbs = false,
3512
3519
  menuLinks = void 0,
3513
- showNavigationCloseButton = false,
3514
3520
  SetActivatedLanguage = () => {
3515
3521
  },
3516
3522
  linkComponent: LinkComponent = "a",
@@ -3602,8 +3608,6 @@ var NavigationHeader = ({
3602
3608
  onClick: handleMenuClick,
3603
3609
  "aria-expanded": isMenuOpen,
3604
3610
  "aria-controls": "main-navigation",
3605
- role: "dialog",
3606
- "aria-modal": "true",
3607
3611
  ref: menuButtonFocusRef,
3608
3612
  children: [
3609
3613
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { "aria-hidden": "true", className: isMenuOpen ? "pts-close-icon" : "pts-open-icon", children: getMenuIcon() }),
@@ -3619,21 +3623,11 @@ var NavigationHeader = ({
3619
3623
  activatedLanguage,
3620
3624
  setIsMenyOpen: setIsMenuOpen,
3621
3625
  menuLinks,
3622
- showCloseButton: showNavigationCloseButton != null ? showNavigationCloseButton : true,
3623
3626
  isOpen: isMenuOpen,
3624
3627
  openButtonRef: menuButtonFocusRef,
3625
3628
  linkComponent: LinkComponent
3626
3629
  }
3627
3630
  ),
3628
- isMenuOpen && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3629
- "div",
3630
- {
3631
- className: "pts-navigation-overlay",
3632
- onClick: () => setIsMenuOpen(false),
3633
- "aria-hidden": "true",
3634
- tabIndex: -1
3635
- }
3636
- ),
3637
3631
  !isMenuOpen && isSearchOpen && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(SearchBarStandard_default, { activatedLanguage }),
3638
3632
  !isMenuOpen && !isSearchOpen && useBreadCrumbs && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(BreadCrumbsStandard_default, { activatedLanguage })
3639
3633
  ] });
@@ -3769,7 +3763,8 @@ var Collapse = ({
3769
3763
  children,
3770
3764
  defaultOpen = false,
3771
3765
  id,
3772
- activatedLanguage = "sv"
3766
+ activatedLanguage = "sv",
3767
+ customClass = ""
3773
3768
  }) => {
3774
3769
  const [isOpen, setIsOpen] = (0, import_react19.useState)(defaultOpen);
3775
3770
  const uniqueId = id != null ? id : (0, import_react19.useId)();
@@ -3801,7 +3796,7 @@ var Collapse = ({
3801
3796
  "aria-labelledby": buttonId,
3802
3797
  "aria-hidden": !isOpen,
3803
3798
  role: "region",
3804
- children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "pts-collapse-content", children })
3799
+ children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: `pts-collapse-content ${customClass}`, children })
3805
3800
  }
3806
3801
  )
3807
3802
  ] }, uniqueId);