@inera/ids-react 9.2.0 → 9.2.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.
@@ -9,12 +9,13 @@ interface IDSAccordionBaseProps extends HTMLAttributes<HTMLDivElement> {
9
9
  headlineSize?: "m" | "s" | "xs";
10
10
  lean?: boolean;
11
11
  noBorder?: boolean;
12
+ hasChildren?: boolean;
12
13
  children?: ReactNode;
13
14
  onToggleAccordion?: () => void;
14
15
  client?: boolean;
15
16
  accordionRef?: React.Ref<HTMLDivElement>;
16
17
  }
17
- export declare function IDSAccordionBase({ headline, subtitle, expanded, level, headlineSize, lean, noBorder, onToggleAccordion, client, children, className, accordionRef, ...props }: IDSAccordionBaseProps): import("react/jsx-runtime").JSX.Element;
18
+ export declare function IDSAccordionBase({ headline, subtitle, expanded, level, headlineSize, lean, noBorder, onToggleAccordion, client, hasChildren, children, className, accordionRef, ...props }: IDSAccordionBaseProps): import("react/jsx-runtime").JSX.Element;
18
19
  export declare namespace IDSAccordionBase {
19
20
  var displayName: string;
20
21
  }
@@ -1,13 +1,12 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import clsx from 'clsx';
3
- import React, { useId } from 'react';
3
+ import { useId } from 'react';
4
4
  import '@inera/ids-design/components/accordion/accordion.css';
5
5
 
6
- function IDSAccordionBase({ headline, subtitle, expanded = false, level = 1, headlineSize = "m", lean = false, noBorder, onToggleAccordion, client = false, children, className, accordionRef, ...props }) {
6
+ function IDSAccordionBase({ headline, subtitle, expanded = false, level = 1, headlineSize = "m", lean = false, noBorder, onToggleAccordion, client = false, hasChildren = false, children, className, accordionRef, ...props }) {
7
7
  const reactId = useId();
8
8
  const headerId = `accordion-header-${reactId}`;
9
9
  const contentId = `accordion-content-${reactId}`;
10
- const hasChildren = !!React.Children.toArray(children).length;
11
10
  const handleKeyDown = (e) => {
12
11
  if (!onToggleAccordion)
13
12
  return;
@@ -52,7 +51,7 @@ function IDSAccordionBase({ headline, subtitle, expanded = false, level = 1, hea
52
51
  "ids-accordion--lean": lean,
53
52
  "ids-accordion--has-children": !!hasChildren,
54
53
  "ids-accordion--is-child": level === 2
55
- }, className), children: [jsx("div", { className: clsx("ids-accordion__button", `ids-accordion__button--${headlineSize}`), role: "button", tabIndex: 0, "data-accordion-header": true, "aria-expanded": expanded, "aria-controls": contentId, ...toggleHandlers, children: jsxs("div", { id: headerId, className: clsx("ids-accordion__headline", `ids-accordion__headline-${level}`, `ids-accordion__headline--${headlineSize}`, expanded && "ids-accordion__headline--expanded"), children: [headline, !!subtitle && jsx("div", { className: "ids-accordion__subtitle", children: subtitle })] }) }), jsx("div", { "aria-hidden": !expanded, id: contentId, "aria-labelledby": headerId, role: "region", className: "ids-accordion__content", children: jsx("div", { "data-accordion-root": true, children: children }) })] }));
54
+ }, className), children: [jsx("button", { className: clsx("ids-accordion__button", `ids-accordion__button--${headlineSize}`), type: "button", "data-accordion-header": true, "aria-expanded": expanded, "aria-controls": contentId, ...toggleHandlers, children: jsxs("div", { id: headerId, className: clsx("ids-accordion__headline", `ids-accordion__headline-${level}`, `ids-accordion__headline--${headlineSize}`, expanded && "ids-accordion__headline--expanded"), children: [headline, !!subtitle && jsx("div", { className: "ids-accordion__subtitle", children: subtitle })] }) }), jsx("div", { "aria-hidden": !expanded, id: contentId, "aria-labelledby": headerId, role: "region", className: "ids-accordion__content", children: jsx("div", { "data-accordion-root": true, children: children }) })] }));
56
55
  }
57
56
  IDSAccordionBase.displayName = "IDSAccordionBase";
58
57
 
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx } from 'react/jsx-runtime';
3
- import { useState, useRef, useEffect } from 'react';
3
+ import React, { useState, useRef, useEffect } from 'react';
4
4
  import { IDSAccordionBase } from './accordion-base.js';
5
5
 
6
6
  function IDSAccordion({ headline, subtitle, accordions, level = 1, headlineSize = level === 2 ? "s" : "m", expanded, defaultExpanded = false, lean = false, noBorder = false, onCollapsed, onExpanded, onExpandedChange, children, ...props }) {
@@ -9,6 +9,9 @@ function IDSAccordion({ headline, subtitle, accordions, level = 1, headlineSize
9
9
  const [isLean, setIsLean] = useState(lean);
10
10
  const accordionRef = useRef(null);
11
11
  const isExpanded = isControlled ? expanded : internalExpanded;
12
+ const hasChildren = React.Children.toArray(children).some(child => {
13
+ return React.isValidElement(child) && child.type === IDSAccordion;
14
+ });
12
15
  useEffect(() => {
13
16
  if (level === 1 && accordionRef.current?.closest(".ids-card") && !accordions) {
14
17
  setIsLean(true);
@@ -25,7 +28,7 @@ function IDSAccordion({ headline, subtitle, accordions, level = 1, headlineSize
25
28
  else
26
29
  onCollapsed?.();
27
30
  };
28
- return (jsx(IDSAccordionBase, { ...props, client: true, accordionRef: accordionRef, headline: headline, subtitle: subtitle, level: level, headlineSize: headlineSize, expanded: isExpanded, lean: isLean, noBorder: noBorder, onToggleAccordion: toggleExpanded, children: children }));
31
+ return (jsx(IDSAccordionBase, { ...props, client: true, accordionRef: accordionRef, headline: headline, subtitle: subtitle, level: level, headlineSize: headlineSize, hasChildren: hasChildren, expanded: isExpanded, lean: isLean, noBorder: noBorder, onToggleAccordion: toggleExpanded, children: children }));
29
32
  }
30
33
  IDSAccordion.displayName = "IDSAccordion";
31
34
 
@@ -27,7 +27,7 @@ function IDSRadioGroup({ name, required, noValidation, invalid, errorMsg, childr
27
27
  groupInvalid: groupInvalid,
28
28
  onChange: onRadioChange
29
29
  };
30
- return React.cloneElement(child, cloneProps, undefined);
30
+ return React.cloneElement(child, cloneProps);
31
31
  }
32
32
  return child;
33
33
  });
@@ -1,5 +1,5 @@
1
- import { CommonFormPropsWithReadOnly } from "../form-props/form-props";
2
- export interface IDSRadioProps extends React.InputHTMLAttributes<HTMLInputElement>, CommonFormPropsWithReadOnly {
1
+ import { CommonFormProps } from "../form-props/form-props";
2
+ export interface IDSRadioProps extends React.InputHTMLAttributes<HTMLInputElement>, CommonFormProps {
3
3
  groupInvalid?: boolean;
4
4
  groupErrorMsgId?: string;
5
5
  }
@@ -18,6 +18,7 @@ export interface IDSSidePanelBaseProps extends React.HTMLAttributes<HTMLDivEleme
18
18
  client?: boolean;
19
19
  srClose?: string;
20
20
  srOpen?: string;
21
+ noCloseButton?: boolean;
21
22
  noScrollAreaFocus?: boolean;
22
23
  hamburgerRef?: React.Ref<HTMLButtonElement>;
23
24
  componentRef?: React.Ref<HTMLDivElement>;
@@ -3,7 +3,7 @@ import React, { forwardRef } from 'react';
3
3
  import clsx from 'clsx';
4
4
  import '@inera/ids-design/components/side-panel/side-panel.css';
5
5
 
6
- const IDSSidePanelBase = forwardRef(({ visible = false, left = false, elevated = false, menu = false, footer = false, noScrollAreaFocus = false, footerDarkmodeToggle, size = "m", srLabel = "Sidopanel", onTogglePanel, onClosePanel, srClose, srOpen, client, headline, footerLinks, footerText, hamburgerRef, componentRef, className, children, ...props }, ref) => {
6
+ const IDSSidePanelBase = forwardRef(({ visible = false, left = false, elevated = false, menu = false, footer = false, noCloseButton = false, noScrollAreaFocus = false, footerDarkmodeToggle, size = "m", srLabel = "Sidopanel", onTogglePanel, onClosePanel, srClose, srOpen, client, headline, footerLinks, footerText, hamburgerRef, componentRef, className, children, ...props }, ref) => {
7
7
  const [ready, setReady] = React.useState(false);
8
8
  React.useEffect(() => {
9
9
  setReady(true);
@@ -30,7 +30,7 @@ const IDSSidePanelBase = forwardRef(({ visible = false, left = false, elevated =
30
30
  return null;
31
31
  };
32
32
  const renderContent = () => (jsxs("div", { className: "ids-side-panel__content", tabIndex: noScrollAreaFocus ? -1 : 0, children: [jsxs("div", { className: "ids-side-panel__inner", children: [headline, children] }), renderFooter()] }));
33
- return (jsx("div", { className: classNames, ref: ref, ...props, children: jsxs("div", { className: "ids-side-panel__panel", children: [jsx("div", { className: "ids-side-panel__actions", children: menu ? (jsx("button", { "aria-label": visible ? srClose : srOpen, className: "ids-side-panel__hamburger", "aria-expanded": visible, ...toggleHandler, ref: hamburgerRef, children: jsx("div", { className: "ids-hamburger", children: jsx("div", { className: "ids-hamburger__lines" }) }) })) : (jsx("button", { "aria-label": srClose, "aria-expanded": visible, className: "ids-side-panel__close-button", ...closeHandler })) }), renderContent()] }) }));
33
+ return (jsx("div", { className: classNames, ref: ref, ...props, children: jsxs("div", { className: "ids-side-panel__panel", children: [!noCloseButton && (jsx("div", { className: "ids-side-panel__actions", children: menu ? (jsx("button", { "aria-label": visible ? srClose : srOpen, className: "ids-side-panel__hamburger", "aria-expanded": visible, ...toggleHandler, ref: hamburgerRef, children: jsx("div", { className: "ids-hamburger", children: jsx("div", { className: "ids-hamburger__lines" }) }) })) : (jsx("button", { "aria-label": srClose, "aria-expanded": visible, className: "ids-side-panel__close-button", ...closeHandler })) })), renderContent()] }) }));
34
34
  });
35
35
  IDSSidePanelBase.displayName = "IDSSidePanelBase";
36
36
 
@@ -18,8 +18,9 @@ export interface IDSSidePanelProps extends React.HTMLAttributes<HTMLDivElement>
18
18
  footerLinks?: ReactNode;
19
19
  footerText?: ReactNode;
20
20
  noScrollAreaFocus?: boolean;
21
+ noCloseButton?: boolean;
21
22
  }
22
- export declare function IDSSidePanel({ show, menu, noScrollAreaFocus, srLabel, onVisibilityChange, srClose, srOpen, onOpen, onClose, className, children, ...props }: IDSSidePanelProps): import("react/jsx-runtime").JSX.Element;
23
+ export declare function IDSSidePanel({ show, menu, noScrollAreaFocus, noCloseButton, srLabel, onVisibilityChange, srClose, srOpen, onOpen, onClose, className, children, ...props }: IDSSidePanelProps): import("react/jsx-runtime").JSX.Element;
23
24
  export declare namespace IDSSidePanel {
24
25
  var displayName: string;
25
26
  }
@@ -4,7 +4,7 @@ import { useRef, useState, useEffect } from 'react';
4
4
  import { IDSSidePanelBase } from './side-panel-base.js';
5
5
  import { useEsc } from '../utils/hooks/useEsc.js';
6
6
 
7
- function IDSSidePanel({ show, menu = false, noScrollAreaFocus = false, srLabel = "Sidopanel", onVisibilityChange, srClose = "Stäng", srOpen = "Öppna", onOpen, onClose, className, children, ...props }) {
7
+ function IDSSidePanel({ show, menu = false, noScrollAreaFocus = false, noCloseButton = false, srLabel = "Sidopanel", onVisibilityChange, srClose = "Stäng", srOpen = "Öppna", onOpen, onClose, className, children, ...props }) {
8
8
  const componentRef = useRef(null);
9
9
  const hamburgerRef = useRef(null);
10
10
  const isControlled = show !== undefined;
@@ -96,7 +96,7 @@ function IDSSidePanel({ show, menu = false, noScrollAreaFocus = false, srLabel =
96
96
  document.body.style.overflow = ""; // cleanup on unmount
97
97
  };
98
98
  }, [visible]);
99
- return (jsx(IDSSidePanelBase, { ...props, ref: componentRef, client: true, menu: menu, className: className, srClose: srClose, srOpen: srOpen, noScrollAreaFocus: noScrollAreaFocus, visible: visible, onClosePanel: closePanel, onTogglePanel: togglePanel, hamburgerRef: hamburgerRef, children: children }));
99
+ return (jsx(IDSSidePanelBase, { ...props, ref: componentRef, client: true, menu: menu, className: className, srClose: srClose, srOpen: srOpen, noCloseButton: noCloseButton, noScrollAreaFocus: noScrollAreaFocus, visible: visible, onClosePanel: closePanel, onTogglePanel: togglePanel, hamburgerRef: hamburgerRef, children: children }));
100
100
  }
101
101
  IDSSidePanel.displayName = "IDSSidePanel";
102
102
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inera/ids-react",
3
- "version": "9.2.0",
3
+ "version": "9.2.2",
4
4
  "type": "module",
5
5
  "peerDependencies": {
6
6
  "react": "*",