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

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
@@ -803,6 +803,7 @@ interface NavigationHeaderProps {
803
803
  showNavigationCloseButton?: boolean;
804
804
  menuLinks: INavigationItem[];
805
805
  linkComponent?: ElementType;
806
+ noLogoLink?: boolean;
806
807
  }
807
808
 
808
809
  declare const NavigationHeader: FC<NavigationHeaderProps>;
@@ -815,7 +816,6 @@ interface NavigationProps {
815
816
  isOpen: boolean;
816
817
  openButtonRef: RefObject<HTMLButtonElement | null>;
817
818
  linkComponent?: ElementType;
818
- mainId?: string;
819
819
  }
820
820
  type Locale = 'sv' | 'en';
821
821
  type Label = Record<Locale, string>;
@@ -878,6 +878,7 @@ interface CollapseProps {
878
878
  defaultOpen?: boolean;
879
879
  onToggle?: (open: boolean) => void;
880
880
  id?: string;
881
+ activatedLanguage?: string;
881
882
  }
882
883
 
883
884
  declare const Collapse: FC<CollapseProps>;
package/dist/index.d.ts CHANGED
@@ -803,6 +803,7 @@ interface NavigationHeaderProps {
803
803
  showNavigationCloseButton?: boolean;
804
804
  menuLinks: INavigationItem[];
805
805
  linkComponent?: ElementType;
806
+ noLogoLink?: boolean;
806
807
  }
807
808
 
808
809
  declare const NavigationHeader: FC<NavigationHeaderProps>;
@@ -815,7 +816,6 @@ interface NavigationProps {
815
816
  isOpen: boolean;
816
817
  openButtonRef: RefObject<HTMLButtonElement | null>;
817
818
  linkComponent?: ElementType;
818
- mainId?: string;
819
819
  }
820
820
  type Locale = 'sv' | 'en';
821
821
  type Label = Record<Locale, string>;
@@ -878,6 +878,7 @@ interface CollapseProps {
878
878
  defaultOpen?: boolean;
879
879
  onToggle?: (open: boolean) => void;
880
880
  id?: string;
881
+ activatedLanguage?: string;
881
882
  }
882
883
 
883
884
  declare const Collapse: FC<CollapseProps>;
package/dist/index.js CHANGED
@@ -3300,8 +3300,7 @@ var Navigation = ({
3300
3300
  menuLinks = [],
3301
3301
  showCloseButton = true,
3302
3302
  openButtonRef = null,
3303
- linkComponent: LinkComponent = "a",
3304
- mainId = "main-content"
3303
+ linkComponent: LinkComponent = "a"
3305
3304
  }) => {
3306
3305
  const closeMenuText = activatedLanguage === "sv" ? "St\xE4ng meny" : "Close menu";
3307
3306
  const [openSubMenu, setOpenSubMenu] = (0, import_react13.useState)(null);
@@ -3324,16 +3323,19 @@ var Navigation = ({
3324
3323
  return () => document.removeEventListener("keydown", handleKeyDown);
3325
3324
  }, [isOpen, setIsMenyOpen]);
3326
3325
  (0, import_react13.useEffect)(() => {
3327
- const main = document.getElementById(mainId);
3328
- console.log(main);
3326
+ const main = document.querySelector("main");
3327
+ const footer = document.querySelector("footer");
3329
3328
  if (!main) return;
3330
3329
  if (isOpen) {
3331
3330
  main.setAttribute("inert", "");
3331
+ footer && footer.setAttribute("inert", "");
3332
3332
  } else {
3333
3333
  main.removeAttribute("inert");
3334
+ footer && footer.removeAttribute("inert");
3334
3335
  }
3335
3336
  return () => {
3336
3337
  main.removeAttribute("inert");
3338
+ footer && footer.removeAttribute("inert");
3337
3339
  };
3338
3340
  }, [isOpen]);
3339
3341
  const getSubMenuAriaLabel = (label) => {
@@ -3348,53 +3350,68 @@ var Navigation = ({
3348
3350
  }
3349
3351
  return "\xD6ppna undermeny f\xF6r " + label["sv"];
3350
3352
  };
3351
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3352
- "nav",
3353
- {
3354
- id: "main-navigation",
3355
- "aria-label": activatedLanguage === "sv" ? "Huvudnavigation" : "Main navigation",
3356
- className: `${showCloseButton ? "pts-navigation-with-close-button" : ""} pts-navigation-menu-container`,
3357
- hidden: !isOpen,
3358
- children: [
3359
- showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "pts-navigation-close-container", id: "menu-close", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("button", { className: "pts-navigation-close-button", onClick: handleCloseButton, children: [
3360
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CloseIcon, {}) }),
3361
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "pts-navigation-close-text", children: closeMenuText })
3362
- ] }) }),
3363
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("ul", { className: "pts-navigation-link-list", children: menuLinks && menuLinks.map(({ label, href, children }, index) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3364
- "li",
3365
- {
3366
- className: `pts-navigation-link ${openSubMenu === label[activatedLanguage] ? "open" : ""}`,
3367
- children: [
3368
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "pts-navigation-button", children: [
3369
- /* @__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] }) }),
3353
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
3354
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { "aria-live": "polite", className: "sr-only", children: isOpen && (activatedLanguage === "sv" ? "Navigationsmenyn \xF6ppnades" : "Navigation menu opened") }),
3355
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3356
+ "nav",
3357
+ {
3358
+ id: "main-navigation",
3359
+ "aria-label": activatedLanguage === "sv" ? "Huvudnavigation" : "Main navigation",
3360
+ className: `${showCloseButton ? "pts-navigation-with-close-button" : ""} pts-navigation-menu-container`,
3361
+ hidden: !isOpen,
3362
+ 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)(
3364
+ "button",
3365
+ {
3366
+ className: "pts-navigation-close-button",
3367
+ onClick: handleCloseButton,
3368
+ type: "button",
3369
+ children: [
3370
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CloseIcon, {}) }),
3371
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "pts-navigation-close-text", children: closeMenuText })
3372
+ ]
3373
+ }
3374
+ ) }),
3375
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("ul", { className: "pts-navigation-link-list", children: menuLinks && menuLinks.map(({ label, href, children }, index) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3376
+ "li",
3377
+ {
3378
+ className: `pts-navigation-link ${openSubMenu === label[activatedLanguage] ? "open" : ""}`,
3379
+ children: [
3380
+ /* @__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] }) }),
3382
+ children && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3383
+ "button",
3384
+ {
3385
+ className: `pts-navigation-link-expand-button`,
3386
+ onClick: () => handleSubMenu(label[activatedLanguage]),
3387
+ "aria-label": getSubMenuAriaLabel(label),
3388
+ "aria-expanded": openSubMenu === label[activatedLanguage],
3389
+ "aria-controls": "sub-menu-" + index,
3390
+ type: "button",
3391
+ id: "menu-button-" + index,
3392
+ children: openSubMenu === label[activatedLanguage] ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { "aria-hidden": true, className: "pts-contract-icon", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(MinusIcon, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { "aria-hidden": true, className: "pts-expand-icon", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AddIcon, {}) })
3393
+ }
3394
+ )
3395
+ ] }) }),
3370
3396
  children && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3371
- "button",
3397
+ "div",
3372
3398
  {
3373
- className: `pts-navigation-link-expand-button`,
3374
- onClick: () => handleSubMenu(label[activatedLanguage]),
3375
- "aria-label": getSubMenuAriaLabel(label),
3376
- "aria-expanded": openSubMenu === label[activatedLanguage],
3377
- "aria-controls": "sub-menu-" + index,
3378
- children: openSubMenu === label[activatedLanguage] ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { "aria-hidden": true, className: "pts-contract-icon", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(MinusIcon, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { "aria-hidden": true, className: "pts-expand-icon", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AddIcon, {}) })
3399
+ hidden: openSubMenu !== label[activatedLanguage],
3400
+ className: "pts-sub-navigation-container",
3401
+ id: "sub-menu-" + index,
3402
+ role: "region",
3403
+ "aria-labelledby": "menu-button-" + index,
3404
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("ul", { className: "pts-sub-navigation-list", children: children.map(({ label: label2, href: href2 }, index2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("li", { className: "pts-sub-navigation-item", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(LinkComponent, { onClick: handleCloseButton, href: href2, to: href2, children: label2[activatedLanguage] }) }, "nav-child-" + index2)) })
3379
3405
  }
3380
3406
  )
3381
- ] }) }),
3382
- children && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3383
- "div",
3384
- {
3385
- hidden: openSubMenu !== label[activatedLanguage],
3386
- className: "pts-sub-navigation-container",
3387
- id: "sub-menu-" + index,
3388
- children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("ul", { className: "pts-sub-navigation-list", children: children.map(({ label: label2, href: href2 }, index2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("li", { className: "pts-sub-navigation-item", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(LinkComponent, { onClick: handleCloseButton, href: href2, to: href2, children: label2[activatedLanguage] }) }, "nav-child-" + index2)) })
3389
- }
3390
- )
3391
- ]
3392
- },
3393
- "nav-" + index
3394
- )) })
3395
- ]
3396
- }
3397
- );
3407
+ ]
3408
+ },
3409
+ "nav-" + index
3410
+ )) })
3411
+ ]
3412
+ }
3413
+ )
3414
+ ] });
3398
3415
  };
3399
3416
  var NavigationStandard_default = Navigation;
3400
3417
 
@@ -3496,7 +3513,8 @@ var NavigationHeader = ({
3496
3513
  showNavigationCloseButton = false,
3497
3514
  SetActivatedLanguage = () => {
3498
3515
  },
3499
- linkComponent: LinkComponent = "a"
3516
+ linkComponent: LinkComponent = "a",
3517
+ noLogoLink = false
3500
3518
  }) => {
3501
3519
  const logoLink = activatedLanguage === "en" ? "https://pts.se/en" : "https://pts.se/";
3502
3520
  const hasHeadline = headline && headline.length > 0;
@@ -3512,7 +3530,6 @@ var NavigationHeader = ({
3512
3530
  if (activatedLanguage === "sv") return "English";
3513
3531
  else return "Svenska";
3514
3532
  };
3515
- const resolvedHomelink = homelink && homelink.trim() !== "" ? homelink : activatedLanguage === "en" ? "https://pts.se/en" : "https://pts.se/";
3516
3533
  const [isMenuOpen, setIsMenuOpen] = (0, import_react17.useState)(false);
3517
3534
  const handleMenuClick = () => {
3518
3535
  setIsMenuOpen((prev) => !prev);
@@ -3547,7 +3564,7 @@ var NavigationHeader = ({
3547
3564
  };
3548
3565
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { children: [
3549
3566
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("header", { className: "pts-navigation-header-container", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "pts-navigation-header-content", children: [
3550
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "pts-navigation-header-logo-container", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3567
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "pts-navigation-header-logo-container", children: noLogoLink ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { "aria-hidden": "true", children: activatedLanguage === "en" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Logo_en2, {}) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Logo_sv2, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3551
3568
  LinkComponent,
3552
3569
  {
3553
3570
  className: "pts-navigation-header-logo",
@@ -3556,34 +3573,37 @@ var NavigationHeader = ({
3556
3573
  target: "_blank",
3557
3574
  rel: "noopener",
3558
3575
  "aria-label": activatedLanguage === "en" ? "PTS logotype (to the homepage on pts.se, opens in new tab)" : "PTS logotyp (till startsidan p\xE5 pts.se, \xF6ppnas i ny flik)",
3559
- children: activatedLanguage === "en" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Logo_en2, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Logo_sv2, {}) })
3576
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { "aria-hidden": "true", children: activatedLanguage === "en" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Logo_en2, {}) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Logo_sv2, {}) })
3560
3577
  }
3561
3578
  ) }),
3562
3579
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: `${hasHeadline ? "pts-navigation-header-headline-container" : ""}`, children: hasHeadline && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "pts-site-headline", children: headline }) }),
3563
3580
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "pts-navigation-header-nav-container", children: (useLanguage || useNavigationMenu || useSearch) && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
3564
- useSearch && !isMenuOpen && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("button", { onClick: handleSearchClick, children: [
3581
+ useSearch && !isMenuOpen && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("button", { type: "button", onClick: handleSearchClick, children: [
3565
3582
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { "aria-hidden": "true", className: "pts-navigation-header-icons", children: getSearchIcon() }),
3566
3583
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "pts-navigation-header-button-label", children: getSearchLabel() })
3567
3584
  ] }) }),
3568
3585
  useLanguage && !isMenuOpen && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
3569
3586
  "button",
3570
3587
  {
3588
+ type: "button",
3571
3589
  lang: activatedLanguage === "en" ? "en" : "sv",
3572
3590
  onClick: handleLanguageClick,
3591
+ "aria-label": activatedLanguage === "sv" ? "Change language to English" : "\xC4ndra spr\xE5k till svenska",
3573
3592
  children: [
3574
3593
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { "aria-hidden": "true", className: "pts-navigation-header-icons", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(LanguageIcon2, {}) }),
3575
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { "aria-hidden": "true", className: "pts-navigation-header-button-label", children: getLanguageLabel() }),
3576
- activatedLanguage === "en" && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "sr-only", children: "\xC4ndra spr\xE5k till svenska" }),
3577
- activatedLanguage === "sv" && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "sr-only", children: "Change language to English" })
3594
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { "aria-hidden": "true", className: "pts-navigation-header-button-label", children: getLanguageLabel() })
3578
3595
  ]
3579
3596
  }
3580
3597
  ),
3581
3598
  useNavigationMenu && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
3582
3599
  "button",
3583
3600
  {
3601
+ type: "button",
3584
3602
  onClick: handleMenuClick,
3585
3603
  "aria-expanded": isMenuOpen,
3586
3604
  "aria-controls": "main-navigation",
3605
+ role: "dialog",
3606
+ "aria-modal": "true",
3587
3607
  ref: menuButtonFocusRef,
3588
3608
  children: [
3589
3609
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { "aria-hidden": "true", className: isMenuOpen ? "pts-close-icon" : "pts-open-icon", children: getMenuIcon() }),
@@ -3591,15 +3611,7 @@ var NavigationHeader = ({
3591
3611
  ]
3592
3612
  }
3593
3613
  )
3594
- ] }) }),
3595
- isMenuOpen && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3596
- "div",
3597
- {
3598
- className: "pts-navigation-overlay",
3599
- onClick: () => setIsMenuOpen(false),
3600
- "aria-hidden": "true"
3601
- }
3602
- )
3614
+ ] }) })
3603
3615
  ] }) }),
3604
3616
  useNavigationMenu && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3605
3617
  NavigationStandard_default,
@@ -3613,6 +3625,15 @@ var NavigationHeader = ({
3613
3625
  linkComponent: LinkComponent
3614
3626
  }
3615
3627
  ),
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
+ ),
3616
3637
  !isMenuOpen && isSearchOpen && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(SearchBarStandard_default, { activatedLanguage }),
3617
3638
  !isMenuOpen && !isSearchOpen && useBreadCrumbs && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(BreadCrumbsStandard_default, { activatedLanguage })
3618
3639
  ] });
@@ -3747,12 +3768,15 @@ var Collapse = ({
3747
3768
  title,
3748
3769
  children,
3749
3770
  defaultOpen = false,
3750
- id
3771
+ id,
3772
+ activatedLanguage = "sv"
3751
3773
  }) => {
3752
3774
  const [isOpen, setIsOpen] = (0, import_react19.useState)(defaultOpen);
3753
3775
  const uniqueId = id != null ? id : (0, import_react19.useId)();
3754
3776
  const contentId = `${uniqueId}-content`;
3755
3777
  const buttonId = `${uniqueId}-button`;
3778
+ const openLabel = activatedLanguage === "sv" ? "Visa" : "Show";
3779
+ const closeLabel = activatedLanguage === "sv" ? "D\xF6lj" : "Hide";
3756
3780
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "pts-collapse", children: [
3757
3781
  /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
3758
3782
  "button",
@@ -3764,7 +3788,7 @@ var Collapse = ({
3764
3788
  "aria-expanded": isOpen,
3765
3789
  "aria-controls": contentId,
3766
3790
  children: [
3767
- title,
3791
+ `${isOpen ? closeLabel : openLabel} ${title}`,
3768
3792
  /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "pts-open-close-icon", children: isOpen ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(CollapseIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ExpandIcon, {}) })
3769
3793
  ]
3770
3794
  }