@inera/ids-react 9.0.2 → 9.0.3
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/components/accordion/accordion.js +3 -0
- package/components/form/checkbox/checkbox-base.d.ts +2 -1
- package/components/form/checkbox/checkbox-base.js +4 -3
- package/components/form/checkbox/checkbox-group-base.js +1 -1
- package/components/form/checkbox/checkbox-group.js +1 -1
- package/components/form/checkbox/checkbox.js +1 -1
- package/components/form/form-hooks/useInputValidity.js +2 -2
- package/components/form/radio/radio-group-base.js +1 -1
- package/components/form/select-multiple/select-multiple.js +3 -0
- package/components/side-menu/side-menu.js +4 -1
- package/package.json +1 -1
|
@@ -12,6 +12,9 @@ function IDSAccordion({ headline, accordions, level = 1, headlineSize = level ==
|
|
|
12
12
|
setIsLean(true);
|
|
13
13
|
}
|
|
14
14
|
}, [level]);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
setIsExpanded(expanded);
|
|
17
|
+
}, [expanded]);
|
|
15
18
|
const toggleExpanded = () => {
|
|
16
19
|
setIsExpanded(prev => !prev);
|
|
17
20
|
if (isExpanded)
|
|
@@ -3,6 +3,7 @@ export interface IDSCheckboxBaseProps extends InputHTMLAttributes<HTMLInputEleme
|
|
|
3
3
|
invalid?: boolean;
|
|
4
4
|
disabled?: boolean;
|
|
5
5
|
required?: boolean;
|
|
6
|
+
indeterminate?: boolean;
|
|
6
7
|
light?: boolean;
|
|
7
8
|
block?: boolean;
|
|
8
9
|
compact?: boolean;
|
|
@@ -15,4 +16,4 @@ export interface IDSCheckboxBaseProps extends InputHTMLAttributes<HTMLInputEleme
|
|
|
15
16
|
errorMsgId?: string;
|
|
16
17
|
inputRef?: React.Ref<HTMLInputElement>;
|
|
17
18
|
}
|
|
18
|
-
export declare function IDSCheckboxBase({ invalid, disabled, required, light, block, compact, focusAnchor, errorMsg, tooltip, children, dataTestId, id, groupErrorMsgId, errorMsgId, inputRef, className, ...props }: IDSCheckboxBaseProps): ReactElement;
|
|
19
|
+
export declare function IDSCheckboxBase({ invalid, disabled, required, indeterminate, light, block, compact, focusAnchor, errorMsg, tooltip, children, dataTestId, id, groupErrorMsgId, errorMsgId, inputRef, className, ...props }: IDSCheckboxBaseProps): ReactElement;
|
|
@@ -3,22 +3,23 @@ import { useId } from 'react';
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { IDSErrorMessage } from '../error-message/error-message.js';
|
|
5
5
|
|
|
6
|
-
function IDSCheckboxBase({ invalid, disabled, required, light, block, compact, focusAnchor, errorMsg, tooltip, children, dataTestId, id, groupErrorMsgId, errorMsgId, inputRef, className, ...props }) {
|
|
6
|
+
function IDSCheckboxBase({ invalid, disabled, required, indeterminate, light, block, compact, focusAnchor, errorMsg, tooltip, children, dataTestId, id, groupErrorMsgId, errorMsgId, inputRef, className, ...props }) {
|
|
7
7
|
const reactId = useId();
|
|
8
8
|
const inputId = !!id ? id : `checkbox-base-${reactId}`;
|
|
9
9
|
const baseErrorMsgId = !!errorMsgId ? errorMsgId : `checkbox-base-error-${reactId}`;
|
|
10
10
|
const showErrorMsg = invalid && !!errorMsg;
|
|
11
|
-
const
|
|
11
|
+
const ariaErrorHandler = showErrorMsg || !!groupErrorMsgId
|
|
12
12
|
? {
|
|
13
13
|
"aria-describedby": groupErrorMsgId || baseErrorMsgId
|
|
14
14
|
}
|
|
15
15
|
: {};
|
|
16
|
+
const ariaCheckedHandler = indeterminate ? { "aria-checked": "mixed" } : {};
|
|
16
17
|
return (jsxs("div", { className: clsx("ids-checkbox-component", className), style: { display: "inline-flex", flexDirection: "column", gap: showErrorMsg ? "0.5rem" : "" }, "data-testid": dataTestId, children: [jsxs("div", { className: clsx("ids-checkbox", {
|
|
17
18
|
"ids-checkbox--light": light,
|
|
18
19
|
"ids-checkbox--block": block
|
|
19
20
|
}), "data-testid": dataTestId, children: [jsx("input", { id: inputId, ref: inputRef, type: "checkbox", className: clsx("ids-checkbox__input", {
|
|
20
21
|
"ids-focus-anchor": focusAnchor
|
|
21
|
-
}), "aria-invalid": invalid, disabled: disabled, "aria-disabled": disabled, required: required, "aria-required": required, ...
|
|
22
|
+
}), "aria-invalid": invalid, disabled: disabled, "aria-disabled": disabled, required: required, "aria-required": required, ...ariaErrorHandler, ...ariaCheckedHandler, ...props }), !!children && (jsxs("div", { className: clsx("ids-label-wrapper", {
|
|
22
23
|
"ids-label-wrapper--block": block
|
|
23
24
|
}), children: [jsx("label", { htmlFor: inputId, className: clsx("ids-checkbox__label ids-label", {
|
|
24
25
|
"ids-label--clickable": !disabled,
|
|
@@ -7,7 +7,7 @@ function IDSCheckboxGroupBase({ legend = "", errorMsg = "", compact = false, too
|
|
|
7
7
|
const baseErrorMsgId = !!errorMsgId ? errorMsgId : `checkbox-group-base-error-${useId()}`;
|
|
8
8
|
return (jsxs("fieldset", { ref: groupRef, className: clsx("ids-form-group__fieldset", {
|
|
9
9
|
"ids-form-group__fieldset--compact": compact
|
|
10
|
-
}, className), ...props, children: [legend && (jsx("div", { className: "ids-label-wrapper", children: jsxs("legend", { children: [legend, tooltip && jsx("span", { className: "ids-legend__tooltip", children: tooltip })] }) })), children, invalid && !!errorMsg && (jsx(IDSErrorMessage, { id: baseErrorMsgId, show: true, compact: true, children: errorMsg }))] }));
|
|
10
|
+
}, className), ...props, children: [legend && (jsx("div", { className: "ids-label-wrapper", children: jsxs("legend", { children: [legend, tooltip && jsx("span", { className: "ids-legend__tooltip", children: tooltip })] }) })), children, invalid && !!errorMsg && (jsx(IDSErrorMessage, { id: baseErrorMsgId, show: true, compact: true, style: { marginTop: compact ? "0.75rem" : "auto" }, children: errorMsg }))] }));
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export { IDSCheckboxGroupBase };
|
|
@@ -33,7 +33,7 @@ function IDSCheckboxGroup({ errorMsg = "", block, invalid, noValidation = false,
|
|
|
33
33
|
}
|
|
34
34
|
return child;
|
|
35
35
|
});
|
|
36
|
-
return (jsx(IDSCheckboxGroupBase, { ...props, groupRef: groupRef, invalid: !isValid || invalid, errorMsgId: errorMsgId, errorMsg: !noValidation && errorMsg, children: clonedChildren }));
|
|
36
|
+
return (jsx(IDSCheckboxGroupBase, { ...props, groupRef: groupRef, invalid: !isValid && hasInteracted || invalid, errorMsgId: errorMsgId, errorMsg: !noValidation && errorMsg, children: clonedChildren }));
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export { IDSCheckboxGroup };
|
|
@@ -15,7 +15,7 @@ const IDSCheckbox = forwardRef(({ invalid = false, noValidation = false, indeter
|
|
|
15
15
|
checkboxRef.current.indeterminate = indeterminate;
|
|
16
16
|
}
|
|
17
17
|
}, [indeterminate]);
|
|
18
|
-
return (jsx(IDSCheckboxBase, { ...props, inputRef: checkboxRef, invalid: isInvalid, children: children }));
|
|
18
|
+
return (jsx(IDSCheckboxBase, { ...props, inputRef: checkboxRef, invalid: isInvalid, indeterminate: indeterminate, children: children }));
|
|
19
19
|
});
|
|
20
20
|
IDSCheckbox.displayName = "IDSCheckbox";
|
|
21
21
|
|
|
@@ -14,14 +14,14 @@ function useInputValidity(ref, validateOnBlur) {
|
|
|
14
14
|
if (validateOnBlur) {
|
|
15
15
|
inputEl.addEventListener("blur", updateValidity);
|
|
16
16
|
}
|
|
17
|
-
inputEl.addEventListener("
|
|
17
|
+
inputEl.addEventListener("change", updateValidity);
|
|
18
18
|
inputEl.addEventListener("invalid", updateValidity);
|
|
19
19
|
return () => {
|
|
20
20
|
form?.removeEventListener("submit", updateValidity);
|
|
21
21
|
if (validateOnBlur) {
|
|
22
22
|
inputEl.removeEventListener("blur", updateValidity);
|
|
23
23
|
}
|
|
24
|
-
inputEl.removeEventListener("
|
|
24
|
+
inputEl.removeEventListener("change", updateValidity);
|
|
25
25
|
inputEl.removeEventListener("invalid", updateValidity);
|
|
26
26
|
};
|
|
27
27
|
}, [ref]);
|
|
@@ -4,7 +4,7 @@ import clsx from 'clsx';
|
|
|
4
4
|
|
|
5
5
|
function IDSRadioGroupBase({ legend, errorMsg, errorMsgId, compact = false, required = false, tooltip, className, children, invalid, groupRef, ...props }) {
|
|
6
6
|
const showErrorMsg = invalid && !!errorMsg && !!errorMsgId;
|
|
7
|
-
return (jsxs("fieldset", { ref: groupRef, "aria-required": required, className: clsx("ids-form-group__fieldset", { "ids-form-group__fieldset--compact": compact }, className), ...props, children: [legend && (jsx("div", { className: "ids-label-wrapper", children: jsxs("legend", { children: [legend, tooltip && jsx("span", { className: "ids-legend__tooltip", children: tooltip })] }) })), children, showErrorMsg && (jsx(IDSErrorMessage, { id: errorMsgId, show: true, children: errorMsg }))] }));
|
|
7
|
+
return (jsxs("fieldset", { ref: groupRef, "aria-required": required, className: clsx("ids-form-group__fieldset", { "ids-form-group__fieldset--compact": compact }, className), ...props, children: [legend && (jsx("div", { className: "ids-label-wrapper", children: jsxs("legend", { children: [legend, tooltip && jsx("span", { className: "ids-legend__tooltip", children: tooltip })] }) })), children, showErrorMsg && (jsx(IDSErrorMessage, { id: errorMsgId, show: true, style: { marginTop: compact ? "0.75rem" : "auto" }, children: errorMsg }))] }));
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export { IDSRadioGroupBase };
|
|
@@ -13,6 +13,9 @@ function IDSSelectMultiple({ invalid = false, noValidation = false, expanded = f
|
|
|
13
13
|
if (checkboxListInvalid && !noValidation)
|
|
14
14
|
setIsExpanded(true);
|
|
15
15
|
}, [checkboxListInvalid, noValidation]);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
setIsExpanded(expanded);
|
|
18
|
+
}, [expanded]);
|
|
16
19
|
useEffect(() => {
|
|
17
20
|
const handleClickOutside = (event) => {
|
|
18
21
|
if (componentRef.current && !componentRef.current.contains(event.target)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { useState } from 'react';
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
4
|
import { IDSSideMenuBase } from './side-menu-base.js';
|
|
5
5
|
|
|
6
6
|
function IDSSideMenu({ expanded = false, onToggleMenu, srToggleText = "Sektion", className, ...props }) {
|
|
@@ -11,6 +11,9 @@ function IDSSideMenu({ expanded = false, onToggleMenu, srToggleText = "Sektion",
|
|
|
11
11
|
setIsExpanded(newExpanded);
|
|
12
12
|
onToggleMenu?.(newExpanded);
|
|
13
13
|
};
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
setIsExpanded(expanded);
|
|
16
|
+
}, [expanded]);
|
|
14
17
|
const handleKeyDown = (e) => {
|
|
15
18
|
if (e.code !== "Escape")
|
|
16
19
|
e.stopPropagation();
|