@inera/ids-react 8.0.0 → 8.2.0

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 (125) hide show
  1. package/components/accordion/accordion.d.ts +1 -0
  2. package/components/accordion/accordion.js +5 -43
  3. package/components/action-link/action-link.d.ts +6 -0
  4. package/components/action-link/action-link.js +9 -0
  5. package/components/badge/badge.d.ts +3 -5
  6. package/components/badge/badge.js +2 -2
  7. package/components/box-link/box-link.d.ts +3 -5
  8. package/components/box-link/box-link.js +3 -4
  9. package/components/breadcrumbs/breadcrumbs.d.ts +2 -3
  10. package/components/breadcrumbs/breadcrumbs.js +2 -3
  11. package/components/button/button.d.ts +1 -2
  12. package/components/button-group/button-group.d.ts +2 -3
  13. package/components/button-group/button-group.js +2 -2
  14. package/components/card/card.d.ts +3 -4
  15. package/components/card/card.js +12 -7
  16. package/components/date-label/date-label.d.ts +2 -2
  17. package/components/date-label/date-label.js +9 -31
  18. package/components/dialog/dialog.d.ts +1 -1
  19. package/components/dialog/dialog.js +5 -6
  20. package/components/dropdown/dropdown-content-link.d.ts +1 -1
  21. package/components/dropdown/dropdown-content-link.js +2 -2
  22. package/components/dropdown/dropdown.d.ts +1 -1
  23. package/components/dropdown/dropdown.js +2 -2
  24. package/components/footer-1177/footer-1177.d.ts +3 -4
  25. package/components/footer-1177/footer-1177.js +7 -44
  26. package/components/footer-1177-admin/footer-1177-admin.d.ts +1 -1
  27. package/components/footer-1177-admin/footer-1177-admin.js +4 -41
  28. package/components/footer-1177-pro/footer-1177-pro.d.ts +1 -1
  29. package/components/footer-1177-pro/footer-1177-pro.js +4 -41
  30. package/components/footer-inera/footer-inera.d.ts +1 -1
  31. package/components/footer-inera/footer-inera.js +4 -41
  32. package/components/footer-inera-admin/footer-inera-admin.d.ts +1 -1
  33. package/components/footer-inera-admin/footer-inera-admin.js +4 -41
  34. package/components/form/checkbox/checkbox.js +3 -2
  35. package/components/form/datepicker/datepicker.d.ts +29 -0
  36. package/components/form/datepicker/datepicker.js +179 -0
  37. package/components/form/input/input.js +1 -1
  38. package/components/form/radio/radio.js +2 -1
  39. package/components/global-alert/global-alert.js +2 -2
  40. package/components/grid/column.d.ts +3 -4
  41. package/components/grid/column.js +2 -3
  42. package/components/grid/container.d.ts +5 -3
  43. package/components/grid/container.js +11 -18
  44. package/components/grid/row.d.ts +4 -4
  45. package/components/grid/row.js +6 -11
  46. package/components/header-1177/header-1177-item.d.ts +2 -2
  47. package/components/header-1177/header-1177-item.js +19 -14
  48. package/components/header-1177/header-1177-nav-item-mobile.js +5 -10
  49. package/components/header-1177/header-1177-nav-item.d.ts +4 -4
  50. package/components/header-1177/header-1177-nav-item.js +23 -17
  51. package/components/header-1177/header-1177-nav.d.ts +2 -2
  52. package/components/header-1177/header-1177-nav.js +4 -5
  53. package/components/header-1177/header-1177.d.ts +1 -1
  54. package/components/header-1177/header-1177.js +3 -16
  55. package/components/header-1177-admin/header-1177-admin-item.d.ts +2 -2
  56. package/components/header-1177-admin/header-1177-admin-item.js +21 -17
  57. package/components/header-1177-admin/header-1177-admin-nav-item.d.ts +4 -4
  58. package/components/header-1177-admin/header-1177-admin-nav-item.js +20 -14
  59. package/components/header-1177-admin/header-1177-admin-nav.d.ts +2 -2
  60. package/components/header-1177-admin/header-1177-admin-nav.js +5 -6
  61. package/components/header-1177-admin/header-1177-admin.d.ts +2 -2
  62. package/components/header-1177-admin/header-1177-admin.js +3 -4
  63. package/components/header-1177-pro/header-1177-pro-item.d.ts +2 -2
  64. package/components/header-1177-pro/header-1177-pro-item.js +21 -14
  65. package/components/header-1177-pro/header-1177-pro-nav-item.d.ts +5 -5
  66. package/components/header-1177-pro/header-1177-pro-nav-item.js +15 -19
  67. package/components/header-1177-pro/header-1177-pro-nav.d.ts +2 -3
  68. package/components/header-1177-pro/header-1177-pro-nav.js +5 -7
  69. package/components/header-1177-pro/header-1177-pro.d.ts +2 -2
  70. package/components/header-1177-pro/header-1177-pro.js +4 -8
  71. package/components/header-inera/header-inera-item.d.ts +3 -4
  72. package/components/header-inera/header-inera-item.js +30 -14
  73. package/components/header-inera/header-inera-nav-item.js +7 -20
  74. package/components/header-inera/header-inera-nav.d.ts +1 -1
  75. package/components/header-inera/header-inera-nav.js +5 -6
  76. package/components/header-inera/header-inera.d.ts +2 -2
  77. package/components/header-inera/header-inera.js +4 -8
  78. package/components/header-inera-admin/header-inera-admin-item.d.ts +3 -4
  79. package/components/header-inera-admin/header-inera-admin-item.js +17 -13
  80. package/components/header-inera-admin/header-inera-admin-nav-item.d.ts +1 -3
  81. package/components/header-inera-admin/header-inera-admin-nav-item.js +14 -27
  82. package/components/header-inera-admin/header-inera-admin-nav.d.ts +2 -3
  83. package/components/header-inera-admin/header-inera-admin-nav.js +3 -4
  84. package/components/header-inera-admin/header-inera-admin.d.ts +1 -1
  85. package/components/header-inera-admin/header-inera-admin.js +3 -4
  86. package/components/link/link.d.ts +1 -1
  87. package/components/link/link.js +15 -13
  88. package/components/navigation/content/navigation-content.d.ts +2 -3
  89. package/components/navigation/content/navigation-content.js +5 -12
  90. package/components/navigation/local/navigation-local.d.ts +2 -3
  91. package/components/navigation/local/navigation-local.js +2 -2
  92. package/components/notification/badge/notification-badge.d.ts +2 -3
  93. package/components/notification/badge/notification-badge.js +3 -3
  94. package/components/pagination/data-pagination/data-pagination.d.ts +1 -2
  95. package/components/pagination/data-pagination/data-pagination.js +0 -1
  96. package/components/pagination/list-pagination/list-pagination.d.ts +1 -1
  97. package/components/pagination/list-pagination/list-pagination.js +2 -3
  98. package/components/popover/popover.js +1 -1
  99. package/components/progressbar/progressbar.d.ts +5 -3
  100. package/components/progressbar/progressbar.js +4 -4
  101. package/components/puff-list/puff-list-item/puff-list-item-date.d.ts +13 -0
  102. package/components/puff-list/puff-list-item/puff-list-item-date.js +23 -0
  103. package/components/puff-list/puff-list-item/puff-list-item-header.d.ts +10 -0
  104. package/components/puff-list/puff-list-item/puff-list-item-header.js +11 -0
  105. package/components/puff-list/puff-list-item/puff-list-item-info.d.ts +3 -5
  106. package/components/puff-list/puff-list-item/puff-list-item-info.js +4 -5
  107. package/components/puff-list/puff-list-item/puff-list-item.d.ts +9 -20
  108. package/components/puff-list/puff-list-item/puff-list-item.js +8 -78
  109. package/components/puff-list/puff-list.d.ts +1 -1
  110. package/components/puff-list/puff-list.js +4 -3
  111. package/components/region-icon/region-icon.d.ts +2 -2
  112. package/components/region-icon/region-icon.js +5 -4
  113. package/components/side-menu/side-menu.js +1 -1
  114. package/components/stepper/step.js +1 -1
  115. package/components/stepper/stepper.d.ts +1 -1
  116. package/components/stepper/stepper.js +2 -2
  117. package/components/tabs/tab.js +1 -1
  118. package/components/tag/tag.d.ts +11 -4
  119. package/components/tag/tag.js +7 -7
  120. package/components/tooltip/tooltip.d.ts +1 -0
  121. package/components/tooltip/tooltip.js +8 -7
  122. package/components/utils/hooks/useFocusTrap.js +3 -2
  123. package/index.d.ts +4 -0
  124. package/index.js +4 -0
  125. package/package.json +2 -2
@@ -1,13 +1,12 @@
1
- "use client";
2
1
  import { jsx } from 'react/jsx-runtime';
3
2
  import { useRef } from 'react';
4
3
  import '@inera/ids-design/components/grid/column/column.css';
5
4
  import clsx from 'clsx';
6
5
 
7
- const IDSColumn = ({ cols, s, m, offset, sOffset, mOffset, alignSelf, className, children, style, ...props }) => {
6
+ function IDSColumn({ cols, s, m, offset, sOffset, mOffset, alignSelf, className, children, style, ...props }) {
8
7
  const colRef = useRef(null);
9
8
  const classNames = clsx("ids-col", cols && `ids-col--${cols}`, s && `ids-col--s-${s}`, m && `ids-col--m-${m}`, offset && `ids-col--offset-${offset}`, sOffset && `ids-col--s-offset-${sOffset}`, mOffset && `ids-col--m-offset-${mOffset}`, alignSelf && `ids-col--align-${alignSelf}`, className);
10
9
  return (jsx("div", { ref: colRef, className: classNames, style: { ...style }, ...props, children: children }));
11
- };
10
+ }
12
11
 
13
12
  export { IDSColumn };
@@ -1,8 +1,10 @@
1
- import React, { ReactNode } from "react";
1
+ import { ReactNode, HTMLAttributes } from "react";
2
2
  import "@inera/ids-design/components/grid/container/container.css";
3
- export interface IDSContainerProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ export interface IDSContainerProps extends HTMLAttributes<HTMLDivElement> {
4
4
  width?: string;
5
+ maxWidth?: string;
5
6
  gutterless?: boolean;
7
+ rowGap?: string;
6
8
  children?: ReactNode;
7
9
  }
8
- export declare const IDSContainer: React.FC<IDSContainerProps>;
10
+ export declare const IDSContainer: import("react").ForwardRefExoticComponent<IDSContainerProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,24 +1,17 @@
1
- "use client";
2
1
  import { jsx } from 'react/jsx-runtime';
3
- import { useRef, useEffect } from 'react';
2
+ import { forwardRef } from 'react';
4
3
  import '@inera/ids-design/components/grid/container/container.css';
5
4
  import clsx from 'clsx';
6
5
 
7
- const IDSContainer = ({ width = "", gutterless = false, children, className, style, ...props }) => {
8
- const containerRef = useRef(null);
9
- const classNames = clsx("ids-container", gutterless && `ids-container--gutterless-${gutterless}`, className);
10
- useEffect(() => {
11
- const el = containerRef.current;
12
- if (el) {
13
- if (width) {
14
- el.style.maxWidth = `${width}px`;
15
- }
16
- else {
17
- el.style.maxWidth = "";
18
- }
19
- }
20
- }, [width]);
21
- return (jsx("div", { ref: containerRef, className: classNames, style: { ...style }, ...props, children: children }));
22
- };
6
+ const IDSContainer = forwardRef(({ gutterless = false, width, maxWidth, rowGap, children, className, style, ...props }, ref) => {
7
+ const mergedStyle = {
8
+ ...style,
9
+ width: width ?? style?.width,
10
+ maxWidth: maxWidth ?? style?.maxWidth,
11
+ rowGap: rowGap ?? style?.rowGap
12
+ };
13
+ return (jsx("div", { ref: ref, className: clsx("ids-container", { "ids-container--gutterless": gutterless }, className), style: mergedStyle, ...props, children: children }));
14
+ });
15
+ IDSContainer.displayName = "IDSContainer";
23
16
 
24
17
  export { IDSContainer };
@@ -1,9 +1,9 @@
1
- import React, { ReactNode } from "react";
1
+ import { ReactNode, HTMLAttributes } from "react";
2
2
  import "@inera/ids-design/components/grid/row/row.css";
3
- export interface IDSRowProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ export interface IDSRowProps extends HTMLAttributes<HTMLDivElement> {
4
+ gap?: string;
4
5
  align?: "start" | "center" | "end" | "baseline" | "stretch";
5
6
  justify?: "start" | "center" | "end" | "space-between" | "space-around";
6
- gap?: string;
7
7
  children?: ReactNode;
8
8
  }
9
- export declare const IDSRow: React.FC<IDSRowProps>;
9
+ export declare const IDSRow: import("react").ForwardRefExoticComponent<IDSRowProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,18 +1,13 @@
1
- "use client";
2
1
  import { jsx } from 'react/jsx-runtime';
3
- import { useRef, useEffect } from 'react';
2
+ import { forwardRef } from 'react';
4
3
  import '@inera/ids-design/components/grid/row/row.css';
5
4
  import clsx from 'clsx';
6
5
 
7
- const IDSRow = ({ align, justify, gap, className, children, style, ...props }) => {
8
- const rowRef = useRef(null);
6
+ const IDSRow = forwardRef(({ gap, align, justify, children, className, style, ...props }, ref) => {
9
7
  const classNames = clsx("ids-row", align && `ids-row--align-${align}`, justify && `ids-row--justify-${justify}`, className);
10
- useEffect(() => {
11
- if (rowRef.current) {
12
- rowRef.current.style.gap = gap ?? "";
13
- }
14
- }, [gap]);
15
- return (jsx("div", { ref: rowRef, className: classNames, style: { ...style }, ...props, children: children }));
16
- };
8
+ const mergedStyle = { ...style, gap: gap ?? style?.gap };
9
+ return (jsx("div", { ref: ref, className: classNames, style: mergedStyle, ...props, children: children }));
10
+ });
11
+ IDSRow.displayName = "IDSRow";
17
12
 
18
13
  export { IDSRow };
@@ -1,4 +1,4 @@
1
- import React, { ReactNode, PropsWithChildren, HTMLAttributes } from "react";
1
+ import { ReactNode, HTMLAttributes, PropsWithChildren } from "react";
2
2
  import "@inera/ids-design/components/header-1177/header-1177-item.css";
3
3
  interface IDSHeader1177ItemProps extends HTMLAttributes<HTMLElement> {
4
4
  mobile?: boolean;
@@ -9,5 +9,5 @@ interface IDSHeader1177ItemProps extends HTMLAttributes<HTMLElement> {
9
9
  link?: ReactNode;
10
10
  onClick?: () => void;
11
11
  }
12
- export declare const IDSHeader1177Item: React.FC<PropsWithChildren<IDSHeader1177ItemProps>>;
12
+ export declare function IDSHeader1177Item({ mobile, keepTextOnMobile, text, href, icon, link, onClick, ...props }: PropsWithChildren<IDSHeader1177ItemProps>): import("react/jsx-runtime").JSX.Element;
13
13
  export {};
@@ -1,29 +1,34 @@
1
- "use client";
2
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
- import { isValidElement, cloneElement } from 'react';
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import React, { isValidElement, cloneElement } from 'react';
4
3
  import clsx from 'clsx';
5
- import '@inera/ids-design/components/header-1177/header-1177-item.css';
6
4
  import { useHeaderContext } from '../utils/contexts/HeaderContext.js';
5
+ import '@inera/ids-design/components/header-1177/header-1177-item.css';
7
6
 
8
- const IDSHeader1177Item = ({ mobile = false, keepTextOnMobile = false, text = "", href = "", icon, link, onClick, ...props }) => {
9
- const headerContext = useHeaderContext();
7
+ function IDSHeader1177Item({ mobile = false, keepTextOnMobile = false, text = "", href = "", icon, link, onClick, ...props }) {
8
+ const headerContext = useHeaderContext() || { unresponsive: false };
10
9
  const classNames = clsx("ids-header-1177-item", {
11
- "ids-header-1177-item--unresponsive": headerContext?.unresponsive,
10
+ "ids-header-1177-item--unresponsive": headerContext.unresponsive,
12
11
  "ids-header-1177-item--mobile": mobile,
13
12
  "ids-header-1177-item--keep-text": keepTextOnMobile
14
13
  });
15
- const renderContent = () => (jsxs(Fragment, { children: [icon && (jsx("div", { className: "ids-header-1177-item-icon", "aria-hidden": "true", children: jsx("span", { className: `ids-icon-${icon}` }) })), jsx("div", { className: "ids-header-1177-item-text", children: text })] }));
14
+ const renderContent = () => (jsx("div", { className: "ids-header-1177-item-icon", "aria-hidden": "true", children: jsx("span", { className: `ids-icon-${icon}` }) }));
16
15
  if (link && isValidElement(link)) {
17
- return cloneElement(link, {
16
+ const linkProps = link.props;
17
+ const hasChildren = !!linkProps.children &&
18
+ (typeof linkProps.children === "string"
19
+ ? linkProps.children.trim().length > 0
20
+ : React.Children.count(linkProps.children) > 0);
21
+ const newLink = cloneElement(link, {
18
22
  ...props,
19
- className: clsx(link.props.className, classNames),
20
- children: renderContent()
23
+ className: clsx(linkProps.className),
24
+ children: hasChildren ? linkProps.children : text
21
25
  });
26
+ return (jsxs("div", { className: classNames, children: [renderContent(), " ", newLink] }));
22
27
  }
23
28
  if (onClick) {
24
- return (jsx("button", { className: classNames, onClick: onClick, style: { cursor: "pointer" }, ...props, children: renderContent() }));
29
+ return (jsxs("div", { className: classNames, children: [renderContent(), jsx("button", { onClick: onClick, ...props, children: text })] }));
25
30
  }
26
- return (jsx("a", { className: classNames, href: href, ...props, children: renderContent() }));
27
- };
31
+ return (jsxs("div", { className: classNames, children: [renderContent(), jsx("a", { href: href, ...props, children: text })] }));
32
+ }
28
33
 
29
34
  export { IDSHeader1177Item };
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
- import { isValidElement, cloneElement } from 'react';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { isValidElement } from 'react';
4
4
  import '@inera/ids-design/components/header-1177/header-1177-nav-item-mobile.css';
5
5
  import { useHeaderContext } from '../utils/contexts/HeaderContext.js';
6
6
  import clsx from 'clsx';
@@ -11,17 +11,12 @@ const IDSHeader1177NavItemMobile = ({ text = "", href = "", icon = "", link, chi
11
11
  "ids-header-1177-nav-item-mobile--unresponsive": headerContext?.unresponsive
12
12
  });
13
13
  const renderContent = () => {
14
- return (jsxs(Fragment, { children: [icon && (jsx("span", { className: "ids-header-1177-nav-item-mobile__icon", children: jsx("span", { className: `ids-icon-${icon}` }) })), text] }));
14
+ return (jsx("span", { className: "ids-header-1177-nav-item-mobile__icon", children: jsx("span", { className: `ids-icon-${icon}` }) }));
15
15
  };
16
16
  if (link && isValidElement(link)) {
17
- return cloneElement(link, {
18
- ...props,
19
- style: { textDecoration: "none" },
20
- className: clsx(link.props.className, classNames),
21
- children: renderContent()
22
- });
17
+ return (jsxs("div", { className: classNames, children: [renderContent(), link] }));
23
18
  }
24
- return (jsx("a", { className: classNames, href: href, style: { textDecoration: "none" }, ...props, children: renderContent() }));
19
+ return (jsxs("div", { className: classNames, children: [renderContent(), jsx("a", { href: href, ...props, children: text })] }));
25
20
  };
26
21
 
27
22
  export { IDSHeader1177NavItemMobile };
@@ -1,15 +1,15 @@
1
1
  import React, { ReactNode, ReactElement } from "react";
2
2
  import "@inera/ids-design/components/header-1177/header-1177-nav-item.css";
3
3
  import { IDSLinkProps } from "../link/link";
4
- interface IDSHeader1177NavItemProps {
4
+ export interface IDSHeader1177NavItemProps {
5
+ label?: string;
5
6
  active?: boolean;
6
7
  expanded?: boolean;
7
- label?: string;
8
+ notification?: ReactNode;
9
+ children?: ReactNode;
8
10
  col1?: ReactElement<IDSLinkProps>[];
9
11
  col2?: ReactElement<IDSLinkProps>[];
10
12
  col3?: ReactElement<IDSLinkProps>[];
11
13
  col4?: ReactNode;
12
- children?: ReactNode;
13
14
  }
14
15
  export declare const IDSHeader1177NavItem: React.FC<IDSHeader1177NavItemProps>;
15
- export {};
@@ -1,14 +1,17 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
- import React, { useState, useRef, useEffect } from 'react';
3
+ import { useState, useRef, useEffect } from 'react';
4
4
  import '@inera/ids-design/components/header-1177/header-1177-nav-item.css';
5
5
  import clsx from 'clsx';
6
6
  import { useHeaderContext } from '../utils/contexts/HeaderContext.js';
7
+ import { useElementId } from '../utils/hooks/useElementId.js';
7
8
 
8
- const IDSHeader1177NavItem = ({ active = false, expanded = false, label = "", col1, col2, col3, col4, children, ...props }) => {
9
- const [isExpanded, setIsExpanded] = useState(expanded);
9
+ const IDSHeader1177NavItem = ({ label = "", active = false, expanded = false, notification, children, col1, col2, col3, col4, ...props }) => {
10
10
  const headerContext = useHeaderContext();
11
+ const [isExpanded, setIsExpanded] = useState(expanded);
11
12
  const containerRef = useRef(null);
13
+ const contentId = useElementId();
14
+ //FIXME click on link should also close menu
12
15
  const handleClickOutside = (event) => {
13
16
  if (containerRef.current && !containerRef.current.contains(event.target)) {
14
17
  setIsExpanded(false);
@@ -21,21 +24,24 @@ const IDSHeader1177NavItem = ({ active = false, expanded = false, label = "", co
21
24
  document.removeEventListener("click", handleClickOutside);
22
25
  };
23
26
  }, [expanded]);
24
- const renderLink = (link) => {
25
- return React.isValidElement(link)
26
- ? React.cloneElement(link, {
27
- activeIcon: true,
28
- block: true,
29
- colorPreset: 2,
30
- onClick: () => setIsExpanded(false)
31
- })
32
- : link;
27
+ const renderNavItem = () => {
28
+ if (label) {
29
+ return (jsxs("button", { "aria-controls": contentId, "aria-expanded": isExpanded, className: "ids-header-1177-nav-item__button", onClick: () => setIsExpanded(prev => !prev), children: [label, " ", notification] }));
30
+ }
31
+ else {
32
+ return (jsxs("span", { className: "ids-header-1177-nav-item__link", children: [children, " ", notification] }));
33
+ }
34
+ };
35
+ const renderContent = () => {
36
+ if (!isExpanded)
37
+ return null;
38
+ return (jsx("div", { id: contentId, className: "ids-header-1177-nav-item__menu ids-header-1177-nav-item__menu--expanded", children: jsxs("div", { className: "ids-header-1177-nav-item__menu-content", children: [jsx("div", { className: "ids-header-1177-nav-item__menu-col-1", children: col1?.map((link, idx) => (jsx("div", { className: "ids-header-1177-nav__menu-item-wrapper", children: link }, idx))) }), jsx("div", { className: "ids-header-1177-nav-item__menu-col-2", children: col2?.map((link, idx) => (jsx("div", { className: "ids-header-1177-nav__menu-item-wrapper", children: link }, idx))) }), jsx("div", { className: "ids-header-1177-nav-item__menu-col-3", children: col3?.map((link, idx) => (jsx("div", { className: "ids-header-1177-nav__menu-item-wrapper", children: link }, idx))) }), jsx("div", { className: "ids-header-1177-nav-item__menu-col-4", children: col4 })] }) }));
33
39
  };
34
- const renderDropdown = () => isExpanded && (jsx("div", { id: "ids-header-1177-nav-dropdown", className: "ids-header-1177-nav-item__menu ids-header-1177-nav-item__menu--expanded", children: jsxs("div", { className: "ids-header-1177-nav-item__menu__content", children: [jsx("div", { className: "ids-header-1177-nav-item__menu__content-col-1", children: col1?.map((link, idx) => (jsx("div", { className: "ids-header-1177-nav__menu-item-wrapper", children: renderLink(link) }, idx))) }), jsx("div", { className: "ids-header-1177-nav-item__menu__content-col-2", children: col2?.map((link, idx) => (jsx("div", { className: "ids-header-1177-nav__menu-item-wrapper", children: renderLink(link) }, idx))) }), jsx("div", { className: "ids-header-1177-nav-item__menu__content-col-3", children: col3?.map((link, idx) => (jsx("div", { className: "ids-header-1177-nav__menu-item-wrapper", children: renderLink(link) }, idx))) }), jsx("div", { className: "ids-header-1177-nav-item__menu__content-col-4", children: col4 })] }) }));
35
- return (jsxs("div", { ref: containerRef, className: clsx("ids-header-1177__nav-item", {
36
- "ids-header-1177__nav-item--unresponsive": headerContext?.unresponsive,
37
- "ids-header-1177__nav-item--active": active || isExpanded
38
- }), ...props, children: [label ? (jsx("button", { onClick: () => setIsExpanded(prev => !prev), "aria-expanded": isExpanded, "aria-controls": "ids-header-1177-nav-dropdown", children: label })) : (children), renderDropdown()] }));
40
+ return (jsxs("div", { ref: containerRef, className: clsx("ids-header-1177-nav-item", {
41
+ "ids-header-1177-nav-item--unresponsive": headerContext?.unresponsive,
42
+ "ids-header-1177-nav-item--expanded": isExpanded,
43
+ "ids-header-1177-nav-item--active": active
44
+ }), ...props, children: [renderNavItem(), renderContent()] }));
39
45
  };
40
46
 
41
47
  export { IDSHeader1177NavItem };
@@ -1,4 +1,4 @@
1
- import React, { ReactNode } from "react";
1
+ import { ReactNode } from "react";
2
2
  import "@inera/ids-design/components/header-1177/header-1177-nav.css";
3
3
  interface IDSHeader1177NavProps {
4
4
  hideOnTablet?: boolean;
@@ -6,5 +6,5 @@ interface IDSHeader1177NavProps {
6
6
  mobileRight?: ReactNode;
7
7
  children?: ReactNode;
8
8
  }
9
- export declare const IDSHeader1177Nav: React.FC<IDSHeader1177NavProps>;
9
+ export declare function IDSHeader1177Nav({ hideOnTablet, mobileLeft, mobileRight, children, ...props }: IDSHeader1177NavProps): import("react/jsx-runtime").JSX.Element;
10
10
  export {};
@@ -1,16 +1,15 @@
1
- "use client";
2
1
  import { jsxs, jsx } from 'react/jsx-runtime';
3
2
  import '@inera/ids-design/components/header-1177/header-1177-nav.css';
4
3
  import clsx from 'clsx';
5
4
  import { useHeaderContext } from '../utils/contexts/HeaderContext.js';
6
5
 
7
- const IDSHeader1177Nav = ({ hideOnTablet = false, mobileLeft, mobileRight, children, ...props }) => {
8
- const headerContext = useHeaderContext();
6
+ function IDSHeader1177Nav({ hideOnTablet = false, mobileLeft, mobileRight, children, ...props }) {
7
+ const headerContext = useHeaderContext() || { unresponsive: false };
9
8
  const navClass = clsx("ids-header-1177__nav", {
10
- "ids-header-1177__nav--unresponsive": headerContext?.unresponsive,
9
+ "ids-header-1177__nav--unresponsive": headerContext.unresponsive,
11
10
  "ids-header-1177__nav--hide-on-tablet": hideOnTablet
12
11
  });
13
12
  return (jsxs("nav", { className: navClass, ...props, children: [jsx("div", { className: "ids-header-1177__nav-inner", children: jsx("div", { className: "ids-header-1177__nav-content", children: children }) }), jsxs("div", { className: "ids-header-1177__nav-inner-mobile", children: [jsx("div", { className: "ids-header-1177__nav-inner-mobile-left", children: mobileLeft }), jsx("div", { className: "ids-header-1177__nav-inner-mobile-right", children: mobileRight })] })] }));
14
- };
13
+ }
15
14
 
16
15
  export { IDSHeader1177Nav };
@@ -14,5 +14,5 @@ interface IDSHeader1177Props extends React.HTMLAttributes<HTMLDivElement> {
14
14
  avatar?: ReactNode;
15
15
  children?: ReactNode;
16
16
  }
17
- export declare const IDSHeader1177: React.FC<IDSHeader1177Props>;
17
+ export declare function IDSHeader1177({ srLogoText, hideRegionPicker, unresponsive, logoHref, logoProps, logo, regionPicker, skipToContentLink, items, avatar, className, children, ...props }: IDSHeader1177Props): import("react/jsx-runtime").JSX.Element;
18
18
  export {};
@@ -1,28 +1,15 @@
1
- "use client";
2
1
  import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { useState, useRef, useEffect } from 'react';
4
2
  import clsx from 'clsx';
5
- import '@inera/ids-design/components/header-1177/header-1177.css';
6
3
  import { HeaderProvider } from '../utils/contexts/HeaderContext.js';
4
+ import '@inera/ids-design/components/header-1177/header-1177.css';
7
5
 
8
- const IDSHeader1177 = ({ srLogoText = "Logotyp", hideRegionPicker: initialRegionPicker = false, unresponsive = false, logoHref = "", logoProps = {}, logo, regionPicker, skipToContentLink, items, avatar, className, children, ...props }) => {
9
- const [hideRegionPicker, setHideRegionPicker] = useState(initialRegionPicker);
10
- useRef(null);
11
- useEffect(() => {
12
- if (avatar) {
13
- // No region picker when avatar
14
- setHideRegionPicker(true);
15
- }
16
- else {
17
- setHideRegionPicker(initialRegionPicker);
18
- }
19
- }, [avatar]);
6
+ function IDSHeader1177({ srLogoText = "Logotyp", hideRegionPicker = false, unresponsive = false, logoHref = "", logoProps = {}, logo, regionPicker, skipToContentLink, items, avatar, className, children, ...props }) {
20
7
  const renderLogo = () => {
21
8
  return (jsx("div", { className: "ids-header-1177__logo-wrapper", children: jsx("div", { className: "ids-header-1177__logo", children: logo ? (jsx("span", { className: "ids-header-1177__link", children: logo })) : (jsx("a", { className: "ids-header-1177__logo-link", href: logoHref, "aria-label": srLogoText, ...logoProps })) }) }));
22
9
  };
23
10
  return (jsx(HeaderProvider, { value: { unresponsive, hideRegionPicker }, children: jsxs("header", { className: clsx("ids-header-1177", {
24
11
  "ids-header-1177--unresponsive": unresponsive
25
12
  }, className), ...props, children: [skipToContentLink && jsx("div", { className: "ids-header-1177__skip-to-content", children: skipToContentLink }), jsxs("div", { className: "ids-header-1177__container", children: [jsx("div", { className: "ids-header-1177__left" }), jsxs("div", { className: "ids-header-1177__inner", children: [jsxs("div", { className: "ids-header-1177__inner-left", children: [renderLogo(), !hideRegionPicker && regionPicker && jsx("div", { className: "ids-header-1177__region-picker", children: regionPicker })] }), jsxs("div", { className: "ids-header-1177__inner-right", children: [items, " ", avatar] })] }), jsx("div", { className: "ids-header-1177__right" })] }), children] }) }));
26
- };
13
+ }
27
14
 
28
15
  export { IDSHeader1177 };
@@ -1,4 +1,4 @@
1
- import React, { ReactNode } from "react";
1
+ import { ReactNode } from "react";
2
2
  import "@inera/ids-design/components/header-1177-admin/header-1177-admin-item.css";
3
3
  interface IDSHeader1177AdminItemProps {
4
4
  mobile?: boolean;
@@ -8,5 +8,5 @@ interface IDSHeader1177AdminItemProps {
8
8
  link?: ReactNode;
9
9
  onClick?: () => void;
10
10
  }
11
- export declare const IDSHeader1177AdminItem: React.FC<IDSHeader1177AdminItemProps>;
11
+ export declare function IDSHeader1177AdminItem({ mobile, href, text, icon, link, onClick, ...props }: IDSHeader1177AdminItemProps): import("react/jsx-runtime").JSX.Element;
12
12
  export {};
@@ -1,29 +1,33 @@
1
- "use client";
2
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
- import { isValidElement, cloneElement } from 'react';
4
- import '@inera/ids-design/components/header-1177-admin/header-1177-admin-item.css';
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import React, { isValidElement, cloneElement } from 'react';
5
3
  import clsx from 'clsx';
6
4
  import { useHeaderContext } from '../utils/contexts/HeaderContext.js';
5
+ import '@inera/ids-design/components/header-1177-admin/header-1177-admin-item.css';
7
6
 
8
- const IDSHeader1177AdminItem = ({ mobile = false, href = "", text = "", icon, link, onClick, ...props }) => {
9
- const headerContext = useHeaderContext();
7
+ function IDSHeader1177AdminItem({ mobile = false, href = "", text = "", icon, link, onClick, ...props }) {
8
+ const headerContext = useHeaderContext() || { unresponsive: false };
10
9
  const classNames = clsx("ids-header-1177-admin-item", {
11
- "ids-header-1177-admin-item--unresponsive": headerContext?.unresponsive,
10
+ "ids-header-1177-admin-item--unresponsive": headerContext.unresponsive,
12
11
  "ids-header-1177-admin-item--mobile": mobile
13
12
  });
14
- const renderContent = () => {
15
- return (jsxs(Fragment, { children: [jsx("div", { className: "ids-header-1177-admin-item-icon", "aria-hidden": "true", children: jsx("span", { className: `ids-icon-${icon}` }) }), jsx("div", { className: "ids-header-1177-admin-item-text", children: text })] }));
16
- };
13
+ const renderContent = () => (jsx("div", { className: "ids-header-1177-admin-item-icon", "aria-hidden": "true", children: jsx("span", { className: `ids-icon-${icon}` }) }));
17
14
  if (link && isValidElement(link)) {
18
- return cloneElement(link, {
15
+ const linkProps = link.props;
16
+ const hasChildren = !!linkProps.children &&
17
+ (typeof linkProps.children === "string"
18
+ ? linkProps.children.trim().length > 0
19
+ : React.Children.count(linkProps.children) > 0);
20
+ const newLink = cloneElement(link, {
19
21
  ...props,
20
- className: clsx(link.props.className, classNames),
21
- children: renderContent()
22
+ className: clsx(linkProps.className),
23
+ children: hasChildren ? linkProps.children : text
22
24
  });
25
+ return (jsxs("div", { className: classNames, children: [renderContent(), " ", newLink] }));
26
+ }
27
+ if (onClick) {
28
+ return (jsxs("div", { className: classNames, children: [renderContent(), jsx("button", { onClick: onClick, ...props, children: text })] }));
23
29
  }
24
- return onClick ? (jsx("button", { className: classNames, onClick: onClick, style: {
25
- cursor: "pointer"
26
- }, ...props, children: renderContent() })) : (jsx("a", { className: classNames, href: href, ...props, children: renderContent() }));
27
- };
30
+ return (jsxs("div", { className: classNames, children: [renderContent(), jsx("a", { href: href, ...props, children: text })] }));
31
+ }
28
32
 
29
33
  export { IDSHeader1177AdminItem };
@@ -1,15 +1,15 @@
1
1
  import React, { ReactNode, ReactElement } from "react";
2
2
  import "@inera/ids-design/components/header-1177-admin/header-1177-admin-nav-item.css";
3
3
  import { IDSLinkProps } from "../link/link";
4
- interface IDSHeader1177AdminNavItemProps {
4
+ export interface IDSHeader1177AdminNavItemProps {
5
+ label?: string;
5
6
  active?: boolean;
6
7
  expanded?: boolean;
7
- label?: string;
8
+ notification?: ReactNode;
9
+ children?: ReactNode;
8
10
  col1?: ReactElement<IDSLinkProps>[];
9
11
  col2?: ReactElement<IDSLinkProps>[];
10
12
  col3?: ReactElement<IDSLinkProps>[];
11
13
  col4?: ReactElement<IDSLinkProps>[];
12
- children?: ReactNode;
13
14
  }
14
15
  export declare const IDSHeader1177AdminNavItem: React.FC<IDSHeader1177AdminNavItemProps>;
15
- export {};
@@ -1,14 +1,17 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
- import React, { useState, useRef, useEffect } from 'react';
3
+ import { useState, useRef, useEffect } from 'react';
4
4
  import '@inera/ids-design/components/header-1177-admin/header-1177-admin-nav-item.css';
5
5
  import clsx from 'clsx';
6
6
  import { useHeaderContext } from '../utils/contexts/HeaderContext.js';
7
+ import { useElementId } from '../utils/hooks/useElementId.js';
7
8
 
8
- const IDSHeader1177AdminNavItem = ({ active = false, expanded = false, label = "", col1, col2, col3, col4, children, ...props }) => {
9
+ const IDSHeader1177AdminNavItem = ({ label = "", active = false, expanded = false, notification, children, col1, col2, col3, col4, ...props }) => {
9
10
  const headerContext = useHeaderContext();
10
11
  const [isExpanded, setIsExpanded] = useState(expanded);
11
12
  const containerRef = useRef(null);
13
+ const contentId = useElementId();
14
+ //FIXME click on link should also close menu
12
15
  const handleClickOutside = (event) => {
13
16
  if (containerRef.current && !containerRef.current.contains(event.target)) {
14
17
  setIsExpanded(false);
@@ -21,21 +24,24 @@ const IDSHeader1177AdminNavItem = ({ active = false, expanded = false, label = "
21
24
  document.removeEventListener("click", handleClickOutside);
22
25
  };
23
26
  }, [expanded]);
24
- const renderLink = (link) => {
25
- return React.isValidElement(link)
26
- ? React.cloneElement(link, {
27
- activeIcon: true,
28
- block: true,
29
- menu: true,
30
- onClick: () => setIsExpanded(false)
31
- })
32
- : link;
27
+ const renderNavItem = () => {
28
+ if (label) {
29
+ return (jsxs("button", { "aria-controls": contentId, "aria-expanded": isExpanded, className: "ids-header-1177-admin-nav-item__button", onClick: () => setIsExpanded(prev => !prev), children: [label, " ", notification] }));
30
+ }
31
+ else {
32
+ return (jsxs("span", { className: "ids-header-1177-admin-nav-item__link", children: [children, " ", notification] }));
33
+ }
34
+ };
35
+ const renderContent = () => {
36
+ if (!isExpanded)
37
+ return null;
38
+ return (jsx("div", { id: contentId, className: "ids-header-1177-admin-nav-item__menu ids-header-1177-admin-nav-item__menu--expanded", children: jsxs("div", { className: "ids-header-1177-admin-nav-item__menu-content", children: [jsx("div", { className: "ids-header-1177-admin-nav-item__menu-col-1", children: col1?.map((link, idx) => (jsx("div", { className: "ids-header-1177-admin-nav__menu-item-wrapper", children: link }, idx))) }), jsx("div", { className: "ids-header-1177-admin-nav-item__menu-col-2", children: col2?.map((link, idx) => (jsx("div", { className: "ids-header-1177-admin-nav__menu-item-wrapper", children: link }, idx))) }), jsx("div", { className: "ids-header-1177-admin-nav-item__menu-col-3", children: col3?.map((link, idx) => (jsx("div", { className: "ids-header-1177-admin-nav__menu-item-wrapper", children: link }, idx))) }), jsx("div", { className: "ids-header-1177-admin-nav-item__menu-col-4", children: col4?.map((link, idx) => (jsx("div", { className: "ids-header-1177-admin-nav__menu-item-wrapper", children: link }, idx))) })] }) }));
33
39
  };
34
- const renderDropdown = () => isExpanded && (jsx("div", { id: "ids-header-1177-admin-nav-dropdown", className: "ids-header-1177-admin-nav-item__menu ids-header-1177-admin-nav-item__menu--expanded", children: jsxs("div", { className: "ids-header-1177-admin-nav-item__menu__content", children: [jsx("div", { className: "ids-header-1177-admin-nav-item__menu__content-col-1", children: col1?.map((link, idx) => (jsx("div", { className: "ids-header-1177-admin-nav__menu-item-wrapper", children: renderLink(link) }, idx))) }), jsx("div", { className: "ids-header-1177-admin-nav-item__menu__content-col-2", children: col2?.map((link, idx) => (jsx("div", { className: "ids-header-1177-admin-nav__menu-item-wrapper", children: renderLink(link) }, idx))) }), jsx("div", { className: "ids-header-1177-admin-nav-item__menu__content-col-3", children: col3?.map((link, idx) => (jsx("div", { className: "ids-header-1177-admin-nav__menu-item-wrapper", children: renderLink(link) }, idx))) }), jsx("div", { className: "ids-header-1177-admin-nav-item__menu__content-col-4", children: col4?.map((link, idx) => (jsx("div", { className: "ids-header-1177-admin-nav__menu-item-wrapper", children: renderLink(link) }, idx))) })] }) }));
35
40
  return (jsxs("div", { ref: containerRef, className: clsx("ids-header-1177-admin-nav-item", {
36
41
  "ids-header-1177-admin-nav-item--unresponsive": headerContext?.unresponsive,
37
- "ids-header-1177-admin-nav-item--active": active || isExpanded
38
- }), ...props, children: [label ? (jsx("button", { onClick: () => setIsExpanded(prev => !prev), "aria-expanded": isExpanded, "aria-controls": "ids-header-1177-admin-nav-dropdown", children: label })) : (children), renderDropdown()] }));
42
+ "ids-header-1177-admin-nav-item--expanded": isExpanded,
43
+ "ids-header-1177-admin-nav-item--active": active
44
+ }), ...props, children: [renderNavItem(), renderContent()] }));
39
45
  };
40
46
 
41
47
  export { IDSHeader1177AdminNavItem };
@@ -1,7 +1,7 @@
1
- import React, { ReactNode } from "react";
1
+ import { ReactNode } from "react";
2
2
  import "@inera/ids-design/components/header-1177-admin/header-1177-admin-nav.css";
3
3
  interface IDSHeader1177AdminNavProps {
4
4
  children?: ReactNode;
5
5
  }
6
- export declare const IDSHeader1177AdminNav: React.FC<IDSHeader1177AdminNavProps>;
6
+ export declare function IDSHeader1177AdminNav({ children, ...props }: IDSHeader1177AdminNavProps): import("react/jsx-runtime").JSX.Element;
7
7
  export {};
@@ -1,14 +1,13 @@
1
- "use client";
2
1
  import { jsx } from 'react/jsx-runtime';
3
- import '@inera/ids-design/components/header-1177-admin/header-1177-admin-nav.css';
4
2
  import clsx from 'clsx';
5
3
  import { useHeaderContext } from '../utils/contexts/HeaderContext.js';
4
+ import '@inera/ids-design/components/header-1177-admin/header-1177-admin-nav.css';
6
5
 
7
- const IDSHeader1177AdminNav = ({ children, ...props }) => {
8
- const headerContext = useHeaderContext();
6
+ function IDSHeader1177AdminNav({ children, ...props }) {
7
+ const headerContext = useHeaderContext() || { unresponsive: false };
9
8
  return (jsx("nav", { className: clsx("ids-header-1177-admin-nav", {
10
- "ids-header-1177-admin-nav--unresponsive": headerContext?.unresponsive
9
+ "ids-header-1177-admin-nav--unresponsive": headerContext.unresponsive
11
10
  }), ...props, children: jsx("div", { className: "ids-header-1177-admin-nav__inner", children: jsx("div", { className: "ids-header-1177-admin-nav__items", children: children }) }) }));
12
- };
11
+ }
13
12
 
14
13
  export { IDSHeader1177AdminNav };
@@ -1,4 +1,4 @@
1
- import React, { AnchorHTMLAttributes, ReactNode } from "react";
1
+ import React, { ReactNode, AnchorHTMLAttributes } from "react";
2
2
  import "@inera/ids-design/components/header-1177-admin/header-1177-admin.css";
3
3
  interface IDSHeader1177AdminProps extends React.HTMLAttributes<HTMLDivElement> {
4
4
  unresponsive?: boolean;
@@ -15,5 +15,5 @@ interface IDSHeader1177AdminProps extends React.HTMLAttributes<HTMLDivElement> {
15
15
  skipToContentLink?: ReactNode;
16
16
  children?: ReactNode;
17
17
  }
18
- export declare const IDSHeader1177Admin: React.FC<IDSHeader1177AdminProps>;
18
+ export declare function IDSHeader1177Admin({ unresponsive, srLogoText, brandTextTop, brandText, brandTextBottom, logoHref, logoProps, logo, avatar, mobileMenu, items, skipToContentLink, className, children, ...props }: IDSHeader1177AdminProps): import("react/jsx-runtime").JSX.Element;
19
19
  export {};
@@ -1,16 +1,15 @@
1
- "use client";
2
1
  import { jsx, jsxs } from 'react/jsx-runtime';
3
- import '@inera/ids-design/components/header-1177-admin/header-1177-admin.css';
4
2
  import clsx from 'clsx';
5
3
  import { HeaderProvider } from '../utils/contexts/HeaderContext.js';
4
+ import '@inera/ids-design/components/header-1177-admin/header-1177-admin.css';
6
5
 
7
- const IDSHeader1177Admin = ({ unresponsive = false, srLogoText = "Logotyp", brandTextTop = "", brandText = "", brandTextBottom = "", logoHref = "", logoProps = {}, logo, avatar, mobileMenu, items, skipToContentLink, className, children, ...props }) => {
6
+ function IDSHeader1177Admin({ unresponsive = false, srLogoText = "Logotyp", brandTextTop = "", brandText = "", brandTextBottom = "", logoHref = "", logoProps = {}, logo, avatar, mobileMenu, items, skipToContentLink, className, children, ...props }) {
8
7
  const renderLogo = () => {
9
8
  return logo ? (logo) : (jsx("a", { className: "ids-header-1177-admin__logo-link", href: logoHref, "aria-label": srLogoText, ...logoProps }));
10
9
  };
11
10
  return (jsx(HeaderProvider, { value: { unresponsive }, children: jsxs("header", { className: clsx("ids-header-1177-admin", {
12
11
  "ids-header-1177-admin--unresponsive": unresponsive
13
12
  }, className), style: { position: "relative", zIndex: 3 }, ...props, children: [skipToContentLink && jsx("div", { className: "ids-header-1177-admin__skip-to-content", children: skipToContentLink }), jsxs("div", { className: "ids-header-1177-admin__main", children: [jsxs("div", { className: "ids-header-1177-admin__main-left", children: [jsx("div", { className: "ids-header-1177-admin__logo", children: renderLogo() }), jsxs("div", { className: "ids-header-1177-admin__brand", children: [brandTextTop && jsx("div", { className: "ids-header-1177-admin__brand-text---supplement", children: brandTextTop }), brandText && jsx("div", { className: "ids-header-1177-admin__brand-text", children: brandText }), brandTextBottom && jsx("div", { className: "ids-header-1177-admin__brand-text---supplement", children: brandTextBottom })] })] }), jsxs("div", { className: "ids-header-1177-admin__main-right", children: [items, avatar, mobileMenu] })] }), children] }) }));
14
- };
13
+ }
15
14
 
16
15
  export { IDSHeader1177Admin };
@@ -1,4 +1,4 @@
1
- import React, { ReactNode } from "react";
1
+ import { ReactNode } from "react";
2
2
  import "@inera/ids-design/components/header-1177-pro/header-1177-pro-item.css";
3
3
  interface IDSHeader1177ProItemProps {
4
4
  mobile?: boolean;
@@ -8,5 +8,5 @@ interface IDSHeader1177ProItemProps {
8
8
  link?: ReactNode;
9
9
  onClick?: () => void;
10
10
  }
11
- export declare const IDSHeader1177ProItem: React.FC<IDSHeader1177ProItemProps>;
11
+ export declare function IDSHeader1177ProItem({ mobile, icon, text, href, link, onClick, ...props }: IDSHeader1177ProItemProps): import("react/jsx-runtime").JSX.Element;
12
12
  export {};