@inera/ids-react 7.0.0 → 7.0.1

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.
@@ -94,5 +94,6 @@ const IDSButton = forwardRef(({ active = false, block = false, disabled = false,
94
94
  : oldIcon;
95
95
  return (jsxs("button", { ref: ref, className: classNames, "aria-disabled": disabled || loading, "aria-pressed": toggle, tabIndex: !disabled && !loading ? 0 : -1, disabled: disabled, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onFocus: handleFocus, onBlur: handleBlur, ...props, children: [icon && jsx("span", { className: `ids-icon-${icon}` }), oldIcon && renderOldIcon, children] }));
96
96
  });
97
+ IDSButton.displayName = "IDSButton";
97
98
 
98
99
  export { IDSButton };
@@ -60,12 +60,12 @@ const IDSDropdown = ({ expanded = false, persistent = false, position = "right",
60
60
  key: `dropdown-content-link-${i}`
61
61
  });
62
62
  });
63
- return (jsx("div", { id: contentId, ref: contentRef, "aria-labelledby": buttonId, className: clsx("ids-dropdown__content", {
63
+ return (jsx("div", { id: contentId, ref: contentRef, "aria-labelledby": buttonId, className: clsx(`ids-dropdown__content ids-dropdown__content--position-${position}`, {
64
64
  "ids-dropdown__content--mblock": mBlock,
65
65
  "ids-dropdown__content--sblock": sBlock
66
66
  }), ...props, children: enhancedChildren }));
67
67
  };
68
- return (jsxs("span", { className: clsx(`ids-dropdown ids-dropdown--position-${position}`, className, {
68
+ return (jsxs("span", { className: clsx(`ids-dropdown`, className, {
69
69
  "ids-dropdown--mblock": mBlock,
70
70
  "ids-dropdown--sblock": sBlock
71
71
  }), children: [renderTrigger(), isExpanded && renderDropdownContent()] }));
@@ -1,7 +1,7 @@
1
- import React, { ReactNode, InputHTMLAttributes } from "react";
1
+ import { ReactNode, InputHTMLAttributes } from "react";
2
2
  interface IDSCheckButtonProps extends InputHTMLAttributes<HTMLInputElement> {
3
3
  disabled?: boolean;
4
4
  children?: ReactNode;
5
5
  }
6
- export declare const IDSCheckButton: React.FC<IDSCheckButtonProps>;
6
+ export declare const IDSCheckButton: import("react").ForwardRefExoticComponent<IDSCheckButtonProps & import("react").RefAttributes<HTMLInputElement>>;
7
7
  export {};
@@ -1,11 +1,15 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { forwardRef, useRef, useImperativeHandle } from 'react';
3
4
  import { useElementId } from '../../utils/hooks/useElementId.js';
4
5
  import clsx from 'clsx';
5
6
 
6
- const IDSCheckButton = ({ disabled = false, id, children, className, ...props }) => {
7
+ const IDSCheckButton = forwardRef(({ disabled = false, id, children, className, ...props }, ref) => {
7
8
  const fieldId = useElementId(id);
8
- return (jsxs("div", { className: clsx("ids-check-button", { "ids-check-button--disabled": disabled }, className), children: [jsx("input", { id: fieldId, className: "ids-check-button__input", type: "checkbox", disabled: disabled, ...props }), jsx("label", { htmlFor: fieldId, className: "ids-check-button__label", children: children })] }));
9
- };
9
+ const checkButtonRef = useRef(null);
10
+ useImperativeHandle(ref, () => checkButtonRef.current);
11
+ return (jsxs("div", { className: clsx("ids-check-button", { "ids-check-button--disabled": disabled }, className), children: [jsx("input", { id: fieldId, ref: checkButtonRef, className: "ids-check-button__input", type: "checkbox", disabled: disabled, ...props }), jsx("label", { htmlFor: fieldId, className: "ids-check-button__label", children: children })] }));
12
+ });
13
+ IDSCheckButton.displayName = "IDSCheckButton";
10
14
 
11
15
  export { IDSCheckButton };
@@ -14,4 +14,4 @@ export interface IDSCheckboxProps extends InputHTMLAttributes<HTMLInputElement>
14
14
  tooltip?: ReactNode;
15
15
  children?: ReactNode;
16
16
  }
17
- export declare const IDSCheckbox: React.FC<IDSCheckboxProps>;
17
+ export declare const IDSCheckbox: React.ForwardRefExoticComponent<IDSCheckboxProps & React.RefAttributes<HTMLInputElement>>;
@@ -1,16 +1,17 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { useRef, useEffect } from 'react';
3
+ import { forwardRef, useRef, useEffect } from 'react';
4
4
  import { useElementId } from '../../utils/hooks/useElementId.js';
5
5
  import { IDSErrorMessage } from '../error-message/error-message.js';
6
6
  import { useAriaDescribedBy } from '../form-hooks/useAriaDescribedBy.js';
7
7
  import { useInputValidity } from '../form-hooks/useInputValidity.js';
8
8
  import clsx from 'clsx';
9
9
 
10
- const IDSCheckbox = ({ invalid = false, disabled = false, required = false, indeterminate = false, noValidation = false, noLabel = false, light = false, block = false, compact = false, errorMsg = "", groupErrorMsgId = "", tooltip, id, children, className, ...props }) => {
10
+ const IDSCheckbox = forwardRef(({ invalid = false, disabled = false, required = false, indeterminate = false, noValidation = false, noLabel = false, light = false, block = false, compact = false, errorMsg = "", groupErrorMsgId = "", tooltip, id, children, className, ...props }, ref) => {
11
+ const internalRef = useRef(null);
12
+ const checkboxRef = ref ?? internalRef;
11
13
  const fieldId = useElementId(id);
12
14
  const errorMsgId = useElementId();
13
- const checkboxRef = useRef(null);
14
15
  const hasValidValue = useInputValidity(checkboxRef);
15
16
  const isInvalid = (invalid || !hasValidValue) && !noValidation;
16
17
  if (groupErrorMsgId) {
@@ -20,13 +21,13 @@ const IDSCheckbox = ({ invalid = false, disabled = false, required = false, inde
20
21
  useAriaDescribedBy(checkboxRef, errorMsgId, isInvalid, !!errorMsg);
21
22
  }
22
23
  useEffect(() => {
23
- if (indeterminate) {
24
+ if (checkboxRef.current) {
24
25
  checkboxRef.current.indeterminate = indeterminate;
25
26
  }
26
27
  }, [checkboxRef, indeterminate]);
27
28
  useEffect(() => {
28
- if (checkboxRef.current) {
29
- const checkboxEl = checkboxRef.current;
29
+ const checkboxEl = checkboxRef.current;
30
+ if (checkboxEl) {
30
31
  const updateAriaChecked = () => {
31
32
  checkboxEl.setAttribute("aria-checked", checkboxEl.indeterminate ? "mixed" : `${checkboxEl.checked}`);
32
33
  };
@@ -48,6 +49,7 @@ const IDSCheckbox = ({ invalid = false, disabled = false, required = false, inde
48
49
  "ids-label--clickable": disabled,
49
50
  "ids-label--no-label": noLabel
50
51
  }), children: !noLabel && children }), tooltip] })] }), isInvalid && errorMsg && (jsx(IDSErrorMessage, { id: errorMsgId, show: true, compact: true, children: errorMsg }))] }));
51
- };
52
+ });
53
+ IDSCheckbox.displayName = "IDSCheckbox";
52
54
 
53
55
  export { IDSCheckbox };
@@ -18,5 +18,5 @@ interface IDSInputProps extends InputHTMLAttributes<HTMLInputElement> {
18
18
  submitButton?: ReactNode;
19
19
  oldIcon?: ReactNode;
20
20
  }
21
- export declare const IDSInput: React.FC<IDSInputProps>;
21
+ export declare const IDSInput: React.ForwardRefExoticComponent<IDSInputProps & React.RefAttributes<HTMLInputElement>>;
22
22
  export {};
@@ -1,18 +1,25 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
- import React__default, { useRef, useEffect } from 'react';
3
+ import React__default, { forwardRef, useRef, useEffect } from 'react';
4
4
  import { useElementId } from '../../utils/hooks/useElementId.js';
5
5
  import { IDSErrorMessage } from '../error-message/error-message.js';
6
6
  import { useInputValidity } from '../form-hooks/useInputValidity.js';
7
7
  import { useAriaDescribedBy } from '../form-hooks/useAriaDescribedBy.js';
8
8
  import clsx from 'clsx';
9
9
 
10
- const IDSInput = ({ label = "", type = "text", icon = "", hint = "", showSearchLabel = false, errorMsg = "", disabled = false, invalid = false, required = false, noValidation = false, autoSize = false, block = false, light = false, readOnly = false, id, tooltip, submitButton, oldIcon, className, ...props }) => {
10
+ const IDSInput = forwardRef(({ label = "", type = "text", icon = "", hint = "", showSearchLabel = false, errorMsg = "", disabled = false, invalid = false, required = false, noValidation = false, autoSize = false, block = false, light = false, readOnly = false, id, tooltip, submitButton, oldIcon, className, ...props }, ref) => {
11
11
  const fieldId = useElementId(id);
12
12
  const errorMsgId = useElementId();
13
13
  const hintId = useElementId();
14
14
  const oldIconRef = useRef(null);
15
15
  const inputRef = useRef(null);
16
+ const combinedRef = (node) => {
17
+ inputRef.current = node;
18
+ if (typeof ref === "function")
19
+ ref(node);
20
+ else if (ref)
21
+ ref.current = node;
22
+ };
16
23
  const hasValidValue = useInputValidity(inputRef);
17
24
  const isInvalid = (invalid || !hasValidValue) && !noValidation;
18
25
  useAriaDescribedBy(inputRef, errorMsgId, isInvalid, !!errorMsg && !noValidation, !!hint, hintId);
@@ -45,10 +52,11 @@ const IDSInput = ({ label = "", type = "text", icon = "", hint = "", showSearchL
45
52
  }), "aria-hidden": "false", htmlFor: fieldId, children: label }), tooltip] }), jsxs("div", { className: "ids-input__wrapper", children: [jsxs("div", { className: clsx("ids-input__inner-wrapper", {
46
53
  "ids-input--icon": icon,
47
54
  "ids-input__inner-wrapper--search": type === "search"
48
- }), children: [jsx("input", { ref: inputRef, id: fieldId, type: type, readOnly: readOnly, className: clsx("ids-input", {
55
+ }), children: [jsx("input", { ref: combinedRef, id: fieldId, type: type, readOnly: readOnly, className: clsx("ids-input", {
49
56
  "ids-input--light": light,
50
57
  "ids-input--invalid": invalid
51
58
  }), "aria-invalid": isInvalid, required: required, "aria-required": required, disabled: disabled, "aria-disabled": disabled, ...props }), type === "search" && jsx("span", { className: "ids-input__search-icon" }), icon && jsx("span", { className: `ids-input__icon ids-icon-${icon}` }), oldIcon && jsx("span", { className: "ids-input__icon", children: renderOldIcon })] }), submitButton] }), hint && (jsx("div", { id: hintId, className: "ids-input__hint", children: hint })), isInvalid && errorMsg && (jsx(IDSErrorMessage, { id: errorMsgId, show: true, children: errorMsg }))] }));
52
- };
59
+ });
60
+ IDSInput.displayName = "IDSInput"; // Needed when using forwardRef
53
61
 
54
62
  export { IDSInput };
@@ -14,4 +14,4 @@ export interface IDSRadioProps extends InputHTMLAttributes<HTMLInputElement> {
14
14
  children?: ReactNode;
15
15
  onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
16
16
  }
17
- export declare const IDSRadio: React.FC<IDSRadioProps>;
17
+ export declare const IDSRadio: React.ForwardRefExoticComponent<IDSRadioProps & React.RefAttributes<HTMLInputElement>>;
@@ -1,14 +1,15 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { useRef } from 'react';
3
+ import { forwardRef, useRef, useImperativeHandle } from 'react';
4
4
  import { useElementId } from '../../utils/hooks/useElementId.js';
5
5
  import { useInputValidity } from '../form-hooks/useInputValidity.js';
6
6
  import { useAriaDescribedBy } from '../form-hooks/useAriaDescribedBy.js';
7
7
  import clsx from 'clsx';
8
8
 
9
- const IDSRadio = ({ name = "", groupErrorMsgId = "", invalid = false, groupInvalid = false, disabled = false, noValidation = false, light = false, compact = false, tooltip, id, children, className, onChange, ...props }) => {
9
+ const IDSRadio = forwardRef(({ name = "", groupErrorMsgId = "", invalid = false, groupInvalid = false, disabled = false, noValidation = false, light = false, compact = false, tooltip, id, children, className, onChange, ...props }, ref) => {
10
10
  const fieldId = useElementId(id);
11
11
  const radioRef = useRef(null);
12
+ useImperativeHandle(ref, () => radioRef.current);
12
13
  const hasValidValue = useInputValidity(radioRef);
13
14
  const isInvalid = (invalid || groupInvalid || !hasValidValue) && !noValidation;
14
15
  useAriaDescribedBy(radioRef, groupErrorMsgId, isInvalid, !!groupErrorMsgId);
@@ -21,6 +22,7 @@ const IDSRadio = ({ name = "", groupErrorMsgId = "", invalid = false, groupInval
21
22
  }), children: [jsx("label", { htmlFor: fieldId, className: clsx("ids-radio__label ids-label", {
22
23
  "ids-input--clickable": !disabled
23
24
  }), children: children }), tooltip] })] }));
24
- };
25
+ });
26
+ IDSRadio.displayName = "IDSRadio";
25
27
 
26
28
  export { IDSRadio };
@@ -4,6 +4,6 @@ export interface IDSRadioButtonProps extends InputHTMLAttributes<HTMLInputElemen
4
4
  id?: string;
5
5
  icon: string;
6
6
  children?: ReactNode;
7
- onChange?: (e: React.ChangeEvent<HTMLInputElement>) => {};
7
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
8
8
  }
9
- export declare const IDSRadioButton: React.FC<IDSRadioButtonProps>;
9
+ export declare const IDSRadioButton: React.ForwardRefExoticComponent<IDSRadioButtonProps & React.RefAttributes<HTMLInputElement>>;
@@ -1,13 +1,15 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { useRef } from 'react';
3
+ import { forwardRef, useRef, useImperativeHandle } from 'react';
4
4
  import { useElementId } from '../../utils/hooks/useElementId.js';
5
5
  import clsx from 'clsx';
6
6
 
7
- const IDSRadioButton = ({ name = "", icon = "user", id, children, onChange, className, ...props }) => {
7
+ const IDSRadioButton = forwardRef(({ name = "", icon = "user", id, children, onChange, className, ...props }, ref) => {
8
8
  const fieldId = useElementId(id);
9
- const radioRef = useRef(null);
10
- return (jsxs("div", { className: clsx("ids-radio-button", className), children: [jsx("input", { id: fieldId, ref: radioRef, type: "radio", className: "ids-radio-button__input", name: name, onChange: onChange, ...props }), jsx("label", { htmlFor: fieldId, className: `ids-radio-button__label ids-icon-${icon}`, children: children })] }));
11
- };
9
+ const radioButtonRef = useRef(null);
10
+ useImperativeHandle(ref, () => radioButtonRef.current);
11
+ return (jsxs("div", { className: clsx("ids-radio-button", className), children: [jsx("input", { id: fieldId, ref: radioButtonRef, type: "radio", className: "ids-radio-button__input", name: name, onChange: onChange, ...props }), jsx("label", { htmlFor: fieldId, className: `ids-radio-button__label ids-icon-${icon}`, children: children })] }));
12
+ });
13
+ IDSRadioButton.displayName = "IDSRadioButton";
12
14
 
13
15
  export { IDSRadioButton };
@@ -12,5 +12,5 @@ interface IDSRangeProps extends InputHTMLAttributes<HTMLInputElement> {
12
12
  tooltip?: ReactNode;
13
13
  onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
14
14
  }
15
- export declare const IDSRange: React.FC<IDSRangeProps>;
15
+ export declare const IDSRange: React.ForwardRefExoticComponent<IDSRangeProps & React.RefAttributes<HTMLInputElement>>;
16
16
  export {};
@@ -1,15 +1,16 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { useState, useRef, useEffect } from 'react';
3
+ import { forwardRef, useState, useRef, useImperativeHandle, useEffect } from 'react';
4
4
  import { useElementId } from '../../utils/hooks/useElementId.js';
5
5
  import '@inera/ids-design/components/form/range/range.css';
6
6
  import clsx from 'clsx';
7
7
 
8
- const IDSRange = ({ label = "", value = 0, showTicks = false, interval = 0, min = 0, max = 0, step = 0, disabled = false, tooltip, id, onChange, className, ...props }) => {
8
+ const IDSRange = forwardRef(({ label = "", value = 0, showTicks = false, interval = 0, min = 0, max = 0, step = 0, disabled = false, tooltip, id, onChange, className, ...props }, ref) => {
9
9
  const [internalValue, setInternalValue] = useState(value);
10
10
  const [ticks, setTicks] = useState([]);
11
11
  const fieldId = useElementId(id);
12
12
  const rangeRef = useRef(null);
13
+ useImperativeHandle(ref, () => rangeRef.current);
13
14
  useEffect(() => {
14
15
  if (step > 0) {
15
16
  const steps = [];
@@ -26,7 +27,8 @@ const IDSRange = ({ label = "", value = 0, showTicks = false, interval = 0, min
26
27
  onChange(ev);
27
28
  }
28
29
  };
29
- return (jsxs("div", { className: clsx("ids-range", className), children: [jsxs("div", { className: "ids-label-tooltip-wrapper", children: [jsx("label", { htmlFor: fieldId, className: `ids-label ${disabled ? "ids-label--disabled" : ""}`, children: label }), tooltip] }), jsx("input", { id: fieldId, ref: rangeRef, type: "range", className: "ids-range__input", min: min, "aria-valuemin": min, max: max, "aria-valuemax": max, step: step, value: internalValue, "aria-valuenow": internalValue, disabled: disabled, style: { backgroundSize: ((internalValue - min) * 100) / (max - min) + "% 100%" }, onChange: handleOnChange, ...props }), showTicks && (jsx("div", { className: `ids-range-ticks ${disabled ? "ids-range-ticks--disabled" : ""}`, children: ticks.map(tick => (jsx("div", { className: "ids-range-tick", children: tick }, tick))) }))] }));
30
- };
30
+ return (jsxs("div", { className: clsx("ids-range", className), children: [jsxs("div", { className: "ids-label-tooltip-wrapper", children: [jsx("label", { htmlFor: fieldId, className: clsx("ids-label", { "ids-label--disabled": disabled }), children: label }), tooltip] }), jsx("input", { id: fieldId, ref: rangeRef, type: "range", className: "ids-range__input", min: min, "aria-valuemin": min, max: max, "aria-valuemax": max, step: step, value: internalValue, "aria-valuenow": internalValue, disabled: disabled, style: { backgroundSize: ((internalValue - min) * 100) / (max - min) + "% 100%" }, onChange: handleOnChange, ...props }), showTicks && (jsx("div", { className: clsx("ids-range-ticks", { "ids-range-ticks--disabled": disabled }), children: ticks.map(tick => (jsx("div", { className: "ids-range-tick", children: tick }, tick))) }))] }));
31
+ });
32
+ IDSRange.displayName = "IDSRange";
31
33
 
32
34
  export { IDSRange };
@@ -11,5 +11,5 @@ interface IDSSelectProps extends React.SelectHTMLAttributes<HTMLSelectElement> {
11
11
  tooltip?: ReactNode;
12
12
  children?: ReactNode;
13
13
  }
14
- export declare const IDSSelect: React.FC<IDSSelectProps>;
14
+ export declare const IDSSelect: React.ForwardRefExoticComponent<IDSSelectProps & React.RefAttributes<HTMLSelectElement>>;
15
15
  export {};
@@ -1,22 +1,24 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { useRef } from 'react';
3
+ import { forwardRef, useRef, useImperativeHandle } from 'react';
4
4
  import { useElementId } from '../../utils/hooks/useElementId.js';
5
5
  import { IDSErrorMessage } from '../error-message/error-message.js';
6
6
  import { useInputValidity } from '../form-hooks/useInputValidity.js';
7
7
  import { useAriaDescribedBy } from '../form-hooks/useAriaDescribedBy.js';
8
8
  import clsx from 'clsx';
9
9
 
10
- const IDSSelect = ({ label = "", srOf = "av", errorMsg = "", disabled = false, required = false, invalid = false, light = false, noValidation = false, tooltip, id, children, className, ...props }) => {
10
+ const IDSSelect = forwardRef(({ label = "", srOf = "av", errorMsg = "", disabled = false, required = false, invalid = false, light = false, noValidation = false, tooltip, id, children, className, ...props }, ref) => {
11
11
  const fieldId = useElementId(id);
12
12
  const errorMsgId = useElementId();
13
13
  const selectRef = useRef(null);
14
+ useImperativeHandle(ref, () => selectRef.current);
14
15
  const hasValidValue = useInputValidity(selectRef);
15
16
  const isInvalid = (invalid || !hasValidValue) && !noValidation;
16
17
  useAriaDescribedBy(selectRef, errorMsgId, isInvalid, !!errorMsg);
17
18
  return (jsxs("div", { className: clsx("ids-select-component", className), children: [jsxs("div", { className: "ids-label-tooltip-wrapper", children: [jsx("label", { htmlFor: fieldId, className: "ids-label", children: label }), tooltip] }), jsx("div", { className: "ids-select-wrapper", children: jsx("select", { id: fieldId, ref: selectRef, className: clsx("ids-select", {
18
19
  "ids-input--light": light
19
20
  }), "aria-invalid": isInvalid, required: required, disabled: disabled, ...props, children: children }) }), isInvalid && errorMsg && (jsx(IDSErrorMessage, { id: errorMsgId, show: true, children: errorMsg }))] }));
20
- };
21
+ });
22
+ IDSSelect.displayName = "IDSSelect";
21
23
 
22
24
  export { IDSSelect };
@@ -1,4 +1,4 @@
1
- import React, { ReactNode, TextareaHTMLAttributes } from "react";
1
+ import { ReactNode, TextareaHTMLAttributes } from "react";
2
2
  interface IDSTextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
3
3
  label?: string;
4
4
  hint?: string | ReactNode;
@@ -14,5 +14,5 @@ interface IDSTextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
14
14
  readOnly?: boolean;
15
15
  tooltip?: ReactNode;
16
16
  }
17
- export declare const IDSTextarea: React.FC<IDSTextareaProps>;
17
+ export declare const IDSTextarea: import("react").ForwardRefExoticComponent<IDSTextareaProps & import("react").RefAttributes<HTMLTextAreaElement>>;
18
18
  export {};
@@ -1,17 +1,18 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { useRef } from 'react';
3
+ import { forwardRef, useRef, useImperativeHandle } from 'react';
4
4
  import { useElementId } from '../../utils/hooks/useElementId.js';
5
5
  import { IDSErrorMessage } from '../error-message/error-message.js';
6
6
  import { useInputValidity } from '../form-hooks/useInputValidity.js';
7
7
  import { useAriaDescribedBy } from '../form-hooks/useAriaDescribedBy.js';
8
8
  import clsx from 'clsx';
9
9
 
10
- const IDSTextarea = ({ label = "", hint, errorMsg = "", disabled = false, invalid = false, required = false, noValidation = false, autoSize = false, noResize = false, block = false, light = false, readOnly = false, id, tooltip, className, ...props }) => {
10
+ const IDSTextarea = forwardRef(({ label = "", hint, errorMsg = "", disabled = false, invalid = false, required = false, noValidation = false, autoSize = false, noResize = false, block = false, light = false, readOnly = false, id, tooltip, className, ...props }, ref) => {
11
11
  const fieldId = useElementId(id);
12
12
  const errorMsgId = useElementId();
13
13
  const hintId = useElementId();
14
14
  const textareaRef = useRef(null);
15
+ useImperativeHandle(ref, () => textareaRef.current);
15
16
  const hasValidValue = useInputValidity(textareaRef);
16
17
  const isInvalid = (invalid || !hasValidValue) && !noValidation;
17
18
  useAriaDescribedBy(textareaRef, errorMsgId, isInvalid, !!errorMsg, !!hint, hintId);
@@ -24,6 +25,7 @@ const IDSTextarea = ({ label = "", hint, errorMsg = "", disabled = false, invali
24
25
  }), htmlFor: fieldId, children: label }), tooltip && tooltip] }), jsx("textarea", { ref: textareaRef, id: fieldId, className: clsx("ids-textarea__textarea", {
25
26
  "ids-input--light": light
26
27
  }), "aria-invalid": isInvalid, required: required, "aria-required": required, disabled: disabled, "aria-disabled": disabled, readOnly: readOnly, ...props }), hint && (jsx("div", { id: hintId, className: "ids-input__hint", children: hint })), isInvalid && errorMsg && (jsx(IDSErrorMessage, { id: errorMsgId, show: true, children: errorMsg }))] }));
27
- };
28
+ });
29
+ IDSTextarea.displayName = "IDSTextarea";
28
30
 
29
31
  export { IDSTextarea };
@@ -1,4 +1,4 @@
1
- import React, { ReactNode, InputHTMLAttributes } from "react";
1
+ import { ReactNode, InputHTMLAttributes } from "react";
2
2
  interface IDSTimeProps extends InputHTMLAttributes<HTMLInputElement> {
3
3
  label?: string;
4
4
  errorMsg?: string;
@@ -9,5 +9,5 @@ interface IDSTimeProps extends InputHTMLAttributes<HTMLInputElement> {
9
9
  light?: boolean;
10
10
  tooltip?: ReactNode;
11
11
  }
12
- export declare const IDSTime: React.FC<IDSTimeProps>;
12
+ export declare const IDSTime: import("react").ForwardRefExoticComponent<IDSTimeProps & import("react").RefAttributes<HTMLInputElement>>;
13
13
  export {};
@@ -1,24 +1,26 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { useRef } from 'react';
3
+ import { forwardRef, useRef, useImperativeHandle } from 'react';
4
4
  import { useElementId } from '../../utils/hooks/useElementId.js';
5
5
  import { IDSErrorMessage } from '../error-message/error-message.js';
6
6
  import { useInputValidity } from '../form-hooks/useInputValidity.js';
7
7
  import { useAriaDescribedBy } from '../form-hooks/useAriaDescribedBy.js';
8
8
  import clsx from 'clsx';
9
9
 
10
- const IDSTime = ({ label = "", errorMsg = "", disabled = false, invalid = false, required = false, noValidation = false, light = false, id, tooltip, className, ...props }) => {
10
+ const IDSTime = forwardRef(({ label = "", errorMsg = "", disabled = false, invalid = false, required = false, noValidation = false, light = false, id, tooltip, className, ...props }, ref) => {
11
11
  const fieldId = useElementId(id);
12
12
  const errorMsgId = useElementId();
13
- const timeRef = useRef(null);
14
- const hasValidValue = useInputValidity(timeRef); // can this happen? i cannot enter an invalid value when i try
13
+ const inputRef = useRef(null);
14
+ useImperativeHandle(ref, () => inputRef.current);
15
+ const hasValidValue = useInputValidity(inputRef);
15
16
  const isInvalid = (invalid || !hasValidValue) && !noValidation;
16
- useAriaDescribedBy(timeRef, errorMsgId, isInvalid, !!errorMsg);
17
+ useAriaDescribedBy(inputRef, errorMsgId, isInvalid, !!errorMsg);
17
18
  return (jsxs("div", { className: clsx("ids-time-component", className), children: [jsxs("div", { className: "ids-label-tooltip-wrapper", children: [jsx("label", { className: clsx("ids-label", {
18
19
  "ids-label--disabled": disabled
19
- }), htmlFor: fieldId, children: label }), tooltip] }), jsx("div", { className: "ids-time", children: jsx("div", { className: "ids-time__input-wrapper", children: jsx("input", { ref: timeRef, id: fieldId, type: "time", className: clsx("ids-time__input", {
20
+ }), htmlFor: fieldId, children: label }), tooltip] }), jsx("div", { className: "ids-time", children: jsx("div", { className: "ids-time__input-wrapper", children: jsx("input", { ref: inputRef, id: fieldId, type: "time", className: clsx("ids-time__input", {
20
21
  "ids-input--light": light
21
22
  }), "aria-invalid": isInvalid, required: required, "aria-required": required, disabled: disabled, "aria-disabled": disabled, ...props }) }) }), isInvalid && errorMsg && (jsx(IDSErrorMessage, { id: errorMsgId, show: true, children: errorMsg }))] }));
22
- };
23
+ });
24
+ IDSTime.displayName = "IDSTime";
23
25
 
24
26
  export { IDSTime };
@@ -1,8 +1,8 @@
1
- import React, { ReactNode, InputHTMLAttributes } from "react";
1
+ import { ReactNode, InputHTMLAttributes } from "react";
2
2
  interface IDSToggleProps extends InputHTMLAttributes<HTMLInputElement> {
3
3
  disabled?: boolean;
4
4
  tooltip?: ReactNode;
5
5
  children?: ReactNode;
6
6
  }
7
- export declare const IDSToggle: React.FC<IDSToggleProps>;
7
+ export declare const IDSToggle: import("react").ForwardRefExoticComponent<IDSToggleProps & import("react").RefAttributes<HTMLInputElement>>;
8
8
  export {};
@@ -1,13 +1,15 @@
1
1
  "use client";
2
2
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
3
- import { useRef } from 'react';
3
+ import { forwardRef, useRef, useImperativeHandle } from 'react';
4
4
  import { useElementId } from '../../utils/hooks/useElementId.js';
5
5
  import clsx from 'clsx';
6
6
 
7
- const IDSToggle = ({ disabled = false, tooltip, id, children, className, ...props }) => {
7
+ const IDSToggle = forwardRef(({ disabled = false, tooltip, id, children, className, ...props }, ref) => {
8
8
  const fieldId = useElementId(id);
9
9
  const toggleRef = useRef(null);
10
+ useImperativeHandle(ref, () => toggleRef.current);
10
11
  return (jsx(Fragment, { children: jsxs("div", { className: clsx("ids-toggle", className), children: [jsx("input", { id: fieldId, ref: toggleRef, className: "ids-toggle__input", type: "checkbox", disabled: disabled, ...props }), jsxs("div", { className: "ids-label-tooltip-wrapper ids-label-tooltip-wrapper--inline", children: [jsx("label", { htmlFor: fieldId, className: "ids-toggle__label ids-label ids-label--clickable", children: children }), tooltip] })] }) }));
11
- };
12
+ });
13
+ IDSToggle.displayName = "IDSToggle";
12
14
 
13
15
  export { IDSToggle };
@@ -11,6 +11,7 @@ interface IDSPuffListItemProps extends React.HTMLAttributes<HTMLDivElement> {
11
11
  day?: number;
12
12
  time?: string;
13
13
  noContent?: boolean;
14
+ noMargin?: boolean;
14
15
  dateLabel?: ReactNode;
15
16
  children?: ReactNode;
16
17
  }
@@ -5,7 +5,7 @@ import '@inera/ids-design/components/puff-list/puff-list.css';
5
5
  import { getMonthAsSweText, getDayAsText } from '../../utils/utils.js';
6
6
  import clsx from 'clsx';
7
7
 
8
- const IDSPuffListItem = ({ headline = "", headlineLink, itemLink, date = null, year = "", month = -1, monthLabel = "", day = -1, time = "", noContent = false, dateLabel, className, children }) => {
8
+ const IDSPuffListItem = ({ headline = "", headlineLink, itemLink, date = null, year = "", month = -1, monthLabel = "", day = -1, time = "", noContent = false, noMargin = false, dateLabel, className, children }) => {
9
9
  const [presentedDate, setPresentedDate] = useState(date);
10
10
  useEffect(() => {
11
11
  if (date) {
@@ -27,23 +27,21 @@ const IDSPuffListItem = ({ headline = "", headlineLink, itemLink, date = null, y
27
27
  }
28
28
  return "";
29
29
  };
30
- const getHeaderClass = (noContent) => clsx("ids-puff-list-item__header", {
31
- "ids-puff-list-item--no-margin": noContent
30
+ const getHeaderClass = (noMargin) => clsx("ids-puff-list-item__header", {
31
+ "ids-puff-list-item--no-margin": noMargin
32
32
  });
33
33
  const renderHeadline = () => {
34
34
  const headlineContent = jsx(Fragment, { children: headline });
35
35
  if (headlineLink && isValidElement(headlineLink)) {
36
- return (jsx("h2", { className: getHeaderClass(noContent), children: cloneElement(headlineLink, {
36
+ return (jsx("h2", { className: getHeaderClass(noMargin), children: cloneElement(headlineLink, {
37
37
  ...headlineLink.props,
38
38
  children: headlineContent
39
39
  }) }));
40
40
  }
41
- return jsx("h2", { className: getHeaderClass(noContent), children: headline });
41
+ return jsx("h2", { className: getHeaderClass(noMargin), children: headline });
42
42
  };
43
43
  const renderBody = () => {
44
- if (noContent)
45
- return null;
46
- const content = (jsxs(Fragment, { children: [renderHeadline(), jsx("div", { className: "ids-puff-list-item__body", children: children })] }));
44
+ const content = (jsxs(Fragment, { children: [renderHeadline(), !noContent && jsx("div", { className: "ids-puff-list-item__body", children: children })] }));
47
45
  if (itemLink && isValidElement(itemLink)) {
48
46
  return cloneElement(itemLink, {
49
47
  ...itemLink.props,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inera/ids-react",
3
- "version": "7.0.0",
3
+ "version": "7.0.1",
4
4
  "type": "module",
5
5
  "peerDependencies": {
6
6
  "react": "*"