@inera/ids-react 9.2.2 → 9.3.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.
- package/components/accordion/accordion.js +1 -1
- package/components/alert/alert-base.js +2 -2
- package/components/breadcrumbs/breadcrumbs.js +6 -1
- package/components/button/button.d.ts +1 -0
- package/components/button/button.js +2 -2
- package/components/button/control-button.d.ts +6 -0
- package/components/button/control-button.js +9 -0
- package/components/carousel/carousel.js +1 -1
- package/components/dialog/dialog-base.js +1 -1
- package/components/form/checkbox/checkbox-base.js +2 -3
- package/components/form/checkbox/checkbox-group-base.d.ts +2 -1
- package/components/form/checkbox/checkbox-group-base.js +3 -3
- package/components/form/checkbox/checkbox-group.d.ts +2 -1
- package/components/form/checkbox/checkbox-group.js +2 -2
- package/components/form/checkbox/checkbox.js +3 -4
- package/components/form/datepicker/datepicker.d.ts +3 -1
- package/components/form/datepicker/datepicker.js +142 -110
- package/components/form/form-hooks/useInputValidity.d.ts +1 -1
- package/components/form/form-hooks/useInputValidity.js +28 -12
- package/components/form/form-props/form-props.d.ts +1 -0
- package/components/form/input/input-base.d.ts +4 -2
- package/components/form/input/input-base.js +14 -9
- package/components/form/input/input.d.ts +3 -0
- package/components/form/input/input.js +1 -1
- package/components/form/radio/radio-base.js +1 -2
- package/components/form/radio/radio-group-base.d.ts +2 -1
- package/components/form/radio/radio-group-base.js +3 -3
- package/components/form/radio/radio-group.d.ts +2 -1
- package/components/form/radio/radio-group.js +2 -2
- package/components/form/range/range-base.d.ts +1 -1
- package/components/form/range/range-base.js +2 -2
- package/components/form/select/select-base.d.ts +3 -3
- package/components/form/select/select-base.js +3 -5
- package/components/form/select/select.d.ts +2 -2
- package/components/form/select/select.js +1 -1
- package/components/form/select-multiple/select-multiple-base.d.ts +1 -1
- package/components/form/select-multiple/select-multiple-base.js +2 -2
- package/components/form/textarea/textarea-base.d.ts +1 -1
- package/components/form/textarea/textarea-base.js +3 -5
- package/components/form/textarea/textarea.js +1 -1
- package/components/form/time/time-base.d.ts +1 -1
- package/components/form/time/time-base.js +2 -4
- package/components/form/time/time.js +4 -5
- package/components/header-1177/header-1177-region-picker-base.d.ts +3 -1
- package/components/header-1177/header-1177-region-picker-base.js +8 -3
- package/components/header-1177/header-1177-region-picker-mobile-base.d.ts +3 -1
- package/components/header-1177/header-1177-region-picker-mobile-base.js +8 -3
- package/components/header-1177/header-1177-region-picker-mobile.d.ts +2 -0
- package/components/header-1177/header-1177-region-picker.d.ts +2 -0
- package/components/header-1177-pro/header-1177-pro-region-picker-base.d.ts +3 -1
- package/components/header-1177-pro/header-1177-pro-region-picker-base.js +8 -3
- package/components/header-1177-pro/header-1177-pro-region-picker-mobile-base.d.ts +3 -1
- package/components/header-1177-pro/header-1177-pro-region-picker-mobile-base.js +8 -3
- package/components/header-1177-pro/header-1177-pro-region-picker-mobile.d.ts +3 -1
- package/components/header-1177-pro/header-1177-pro-region-picker-mobile.js +1 -1
- package/components/header-1177-pro/header-1177-pro-region-picker.d.ts +3 -1
- package/components/header-1177-pro/header-1177-pro-region-picker.js +1 -1
- package/components/popover/popover-content.js +1 -1
- package/components/popover/popover.d.ts +2 -1
- package/components/popover/popover.js +28 -14
- package/components/puff-list/puff-list-item-header.d.ts +1 -1
- package/components/puff-list/puff-list-item.d.ts +2 -1
- package/components/puff-list/puff-list-item.js +2 -2
- package/components/side-panel/side-panel-base.js +3 -1
- package/components/stepper/step-base.d.ts +1 -1
- package/components/stepper/step-base.js +1 -1
- package/components/stepper/step.d.ts +1 -1
- package/components/stepper/step.js +2 -11
- package/components/tag/tag.js +8 -2
- package/components/tooltip/tooltip-base.d.ts +1 -3
- package/components/tooltip/tooltip-base.js +14 -10
- package/components/tooltip/tooltip.js +1 -41
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +4 -3
|
@@ -1,30 +1,46 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
1
|
+
import { useState, useRef, useEffect } from 'react';
|
|
2
2
|
|
|
3
|
-
function useInputValidity(ref, validateOnBlur) {
|
|
3
|
+
function useInputValidity(ref, validateOnBlur, skipValidation) {
|
|
4
4
|
const [isValid, setIsValid] = useState(true);
|
|
5
|
+
const validationStartedRef = useRef(false);
|
|
5
6
|
useEffect(() => {
|
|
7
|
+
if (skipValidation) {
|
|
8
|
+
validationStartedRef.current = false;
|
|
9
|
+
setIsValid(true);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
6
12
|
const inputEl = ref.current;
|
|
7
13
|
if (!inputEl)
|
|
8
14
|
return;
|
|
9
15
|
const updateValidity = () => {
|
|
10
|
-
|
|
16
|
+
const isOptionalEmpty = !inputEl.required && inputEl.value === "";
|
|
17
|
+
setIsValid(isOptionalEmpty || inputEl.validity.valid);
|
|
18
|
+
};
|
|
19
|
+
const startValidation = () => {
|
|
20
|
+
validationStartedRef.current = true;
|
|
21
|
+
updateValidity();
|
|
22
|
+
};
|
|
23
|
+
const updateValidityAfterValidationStarted = () => {
|
|
24
|
+
if (validationStartedRef.current) {
|
|
25
|
+
updateValidity();
|
|
26
|
+
}
|
|
11
27
|
};
|
|
12
28
|
const form = inputEl.closest("form");
|
|
13
|
-
form?.addEventListener("submit",
|
|
29
|
+
form?.addEventListener("submit", startValidation);
|
|
30
|
+
inputEl.addEventListener("invalid", startValidation);
|
|
31
|
+
inputEl.addEventListener("change", updateValidityAfterValidationStarted);
|
|
14
32
|
if (validateOnBlur) {
|
|
15
|
-
inputEl.addEventListener("blur",
|
|
33
|
+
inputEl.addEventListener("blur", startValidation);
|
|
16
34
|
}
|
|
17
|
-
inputEl.addEventListener("change", updateValidity);
|
|
18
|
-
inputEl.addEventListener("invalid", updateValidity);
|
|
19
35
|
return () => {
|
|
20
|
-
form?.removeEventListener("submit",
|
|
36
|
+
form?.removeEventListener("submit", startValidation);
|
|
37
|
+
inputEl.removeEventListener("invalid", startValidation);
|
|
38
|
+
inputEl.removeEventListener("change", updateValidityAfterValidationStarted);
|
|
21
39
|
if (validateOnBlur) {
|
|
22
|
-
inputEl.removeEventListener("blur",
|
|
40
|
+
inputEl.removeEventListener("blur", startValidation);
|
|
23
41
|
}
|
|
24
|
-
inputEl.removeEventListener("change", updateValidity);
|
|
25
|
-
inputEl.removeEventListener("invalid", updateValidity);
|
|
26
42
|
};
|
|
27
|
-
}, [ref]);
|
|
43
|
+
}, [ref, validateOnBlur, skipValidation]);
|
|
28
44
|
return isValid;
|
|
29
45
|
}
|
|
30
46
|
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import React, { ReactNode, CSSProperties } from "react";
|
|
2
2
|
import { CommonFormPropsWithReadOnly } from "../form-props/form-props";
|
|
3
3
|
export interface IDSInputBaseProps extends React.InputHTMLAttributes<HTMLInputElement>, CommonFormPropsWithReadOnly {
|
|
4
|
-
icon?: string;
|
|
5
4
|
unit?: string;
|
|
5
|
+
subtitle?: string;
|
|
6
6
|
showSearchLabel?: boolean;
|
|
7
7
|
submitButton?: ReactNode;
|
|
8
8
|
hintId?: string;
|
|
9
9
|
errorMsgId?: string;
|
|
10
10
|
inputRef?: React.Ref<HTMLInputElement>;
|
|
11
11
|
style?: CSSProperties;
|
|
12
|
+
icon?: string;
|
|
13
|
+
clearButton?: ReactNode;
|
|
12
14
|
}
|
|
13
|
-
export declare function IDSInputBase({ label, type, icon, hint, unit, showSearchLabel, errorMsg, dataTestId, disabled, invalid, required, focusAnchor, light, readOnly, tooltip, submitButton, className, id, hintId, errorMsgId, inputRef, ...props }: IDSInputBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function IDSInputBase({ label, type, icon, clearButton, hint, unit, subtitle, showSearchLabel, errorMsg, dataTestId, disabled, invalid, required, focusAnchor, light, readOnly, tooltip, submitButton, className, id, hintId, errorMsgId, inputRef, ...props }: IDSInputBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
14
16
|
export declare namespace IDSInputBase {
|
|
15
17
|
var displayName: string;
|
|
16
18
|
}
|
|
@@ -3,7 +3,7 @@ import { useId } from 'react';
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { IDSErrorMessage } from '../error-message/error-message.js';
|
|
5
5
|
|
|
6
|
-
function IDSInputBase({ label, type = "text", icon, hint, unit, showSearchLabel = false, errorMsg, dataTestId, disabled = false, invalid = false, required = false, focusAnchor = false, light = false, readOnly = false, tooltip, submitButton, className, id, hintId, errorMsgId, inputRef, ...props }) {
|
|
6
|
+
function IDSInputBase({ label, type = "text", icon, clearButton, hint, unit, subtitle, showSearchLabel = false, errorMsg, dataTestId, disabled = false, invalid = false, required = false, focusAnchor = false, light = false, readOnly = false, tooltip, submitButton, className, id, hintId, errorMsgId, inputRef, ...props }) {
|
|
7
7
|
const reactId = useId();
|
|
8
8
|
const inputId = id ?? `input-base-${reactId}`;
|
|
9
9
|
const baseHintId = hintId ?? `input-base-hint-${reactId}`;
|
|
@@ -17,15 +17,20 @@ function IDSInputBase({ label, type = "text", icon, hint, unit, showSearchLabel
|
|
|
17
17
|
if (type === "search" && !showSearchLabel && label) {
|
|
18
18
|
ariaHandler["aria-label"] = label;
|
|
19
19
|
}
|
|
20
|
-
return (jsxs(Fragment, { children: [jsxs("div", { className: clsx("ids-input", {
|
|
21
|
-
|
|
20
|
+
return (jsxs(Fragment, { children: [jsxs("div", { className: clsx("ids-input", {
|
|
21
|
+
"ids-input--search": type === "search",
|
|
22
|
+
"ids-input--icon": !!icon && !clearButton,
|
|
23
|
+
"ids-input--clear-button": !!clearButton,
|
|
24
|
+
"ids-input--unit": !!unit
|
|
25
|
+
}, className), "data-testid": dataTestId, children: [jsxs("div", { className: "ids-input__wrapper", children: [label && (jsxs("div", { className: clsx("ids-label-wrapper", "ids-label-wrapper--margin-bottom", {
|
|
26
|
+
"ids-label-wrapper--sr-only": type === "search" && !showSearchLabel
|
|
22
27
|
}), children: [jsx("label", { className: clsx("ids-label", {
|
|
23
|
-
"ids-label--
|
|
24
|
-
}), htmlFor: inputId, children: label }), tooltip && jsx("span", { className: "ids-label__tooltip", children: tooltip })] })),
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
"ids-label--sr-only": type === "search" && !showSearchLabel
|
|
29
|
+
}), htmlFor: inputId, children: label }), tooltip && jsx("span", { className: "ids-label__tooltip", children: tooltip })] })), subtitle && jsx("div", { className: "ids-subtitle", children: subtitle }), jsxs("div", { className: "ids-input__input-wrapper", children: [type === "search" && jsx("span", { className: "ids-input__search-icon" }), jsx("input", { ref: inputRef, id: inputId, type: type, readOnly: readOnly, className: clsx("ids-input__input", {
|
|
30
|
+
"ids-input--light": light,
|
|
31
|
+
"ids-input--invalid": invalid,
|
|
32
|
+
"ids-focus-anchor": focusAnchor
|
|
33
|
+
}), "aria-invalid": invalid, required: required, disabled: disabled, ...ariaHandler, ...props }), icon && !clearButton && jsx("span", { className: `ids-input__icon ids-icon-${icon}` }), clearButton && jsx("span", { className: "ids-input__clear-button", children: clearButton }), unit && (jsx("div", { className: "ids-input__unit", "aria-hidden": "true", children: unit }))] }), hint && (jsx("div", { className: "ids-input__hint", id: baseHintId, children: hint }))] }), !!submitButton && submitButton] }), showErrorMsg && (jsx(IDSErrorMessage, { id: baseErrorMsgId, show: true, children: errorMsg }))] }));
|
|
29
34
|
}
|
|
30
35
|
IDSInputBase.displayName = "IDSInputBase";
|
|
31
36
|
|
|
@@ -2,7 +2,10 @@ import { ReactNode } from "react";
|
|
|
2
2
|
import { CommonFormPropsWithReadOnly } from "../form-props/form-props";
|
|
3
3
|
interface IDSInputProps extends React.InputHTMLAttributes<HTMLInputElement>, CommonFormPropsWithReadOnly {
|
|
4
4
|
icon?: string;
|
|
5
|
+
clearButton?: ReactNode;
|
|
5
6
|
unit?: string;
|
|
7
|
+
hint?: string | ReactNode;
|
|
8
|
+
subtitle?: string;
|
|
6
9
|
showSearchLabel?: boolean;
|
|
7
10
|
submitButton?: ReactNode;
|
|
8
11
|
}
|
|
@@ -6,7 +6,7 @@ import { IDSInputBase } from './input-base.js';
|
|
|
6
6
|
|
|
7
7
|
const IDSInput = forwardRef(({ invalid = false, noValidation = false, style, validationOnBlur = false, ...props }, ref) => {
|
|
8
8
|
const inputRef = useRef(null);
|
|
9
|
-
const hasValidValue = useInputValidity(inputRef, validationOnBlur);
|
|
9
|
+
const hasValidValue = useInputValidity(inputRef, validationOnBlur, noValidation);
|
|
10
10
|
const computedInvalid = (invalid || !hasValidValue) && !noValidation;
|
|
11
11
|
// Merge forwarded + local ref
|
|
12
12
|
const mergedRef = (node) => {
|
|
@@ -13,8 +13,7 @@ function IDSRadioBase({ id, name, light, disabled, focusAnchor, tooltip, dataTes
|
|
|
13
13
|
"ids-input--light": light,
|
|
14
14
|
"ids-focus-anchor": focusAnchor
|
|
15
15
|
}), name: name, disabled: disabled, "aria-invalid": invalid, ...ariaHandler, ...props }), !!children && (jsxs("div", { className: "ids-label-wrapper", children: [jsx("label", { htmlFor: inputId, className: clsx("ids-radio__label ids-label", {
|
|
16
|
-
"ids-label--clickable": !disabled
|
|
17
|
-
"ids-label--disabled": disabled
|
|
16
|
+
"ids-label--clickable": !disabled
|
|
18
17
|
}), children: children }), tooltip && jsx("span", { className: "ids-label__tooltip", children: tooltip })] }))] }));
|
|
19
18
|
}
|
|
20
19
|
IDSRadioBase.displayName = "IDSRadioBase";
|
|
@@ -7,10 +7,11 @@ interface IDSRadioGroupBaseProps extends FieldsetHTMLAttributes<HTMLFieldSetElem
|
|
|
7
7
|
required?: boolean;
|
|
8
8
|
tooltip?: ReactNode;
|
|
9
9
|
invalid?: boolean;
|
|
10
|
+
subtitle?: string | ReactNode;
|
|
10
11
|
errorMsgId?: string;
|
|
11
12
|
groupRef?: React.Ref<HTMLFieldSetElement>;
|
|
12
13
|
}
|
|
13
|
-
export declare function IDSRadioGroupBase({ legend, hideLegend, errorMsg, errorMsgId, compact, required, tooltip, className, children, invalid, groupRef, ...props }: IDSRadioGroupBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function IDSRadioGroupBase({ legend, hideLegend, errorMsg, errorMsgId, compact, required, tooltip, subtitle, className, children, invalid, groupRef, ...props }: IDSRadioGroupBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
14
15
|
export declare namespace IDSRadioGroupBase {
|
|
15
16
|
var displayName: string;
|
|
16
17
|
}
|
|
@@ -2,11 +2,11 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { IDSErrorMessage } from '../error-message/error-message.js';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
|
|
5
|
-
function IDSRadioGroupBase({ legend, hideLegend, errorMsg, errorMsgId, compact = false, required = false, tooltip, className, children, invalid, groupRef, ...props }) {
|
|
5
|
+
function IDSRadioGroupBase({ legend, hideLegend, errorMsg, errorMsgId, compact = false, required = false, tooltip, subtitle, 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 && (
|
|
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 && (jsxs("div", { className: clsx("ids-label-wrapper", {
|
|
8
8
|
"ids-label-wrapper--sr-only": hideLegend
|
|
9
|
-
}, className), 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 }))] }));
|
|
9
|
+
}, className), children: [jsxs("legend", { children: [legend, tooltip && jsx("span", { className: "ids-legend__tooltip", children: tooltip })] }), subtitle && jsx("div", { className: "ids-subtitle ids-subtitle--group", children: subtitle })] })), children, showErrorMsg && (jsx(IDSErrorMessage, { id: errorMsgId, show: true, style: { marginTop: compact ? "0.75rem" : "auto" }, children: errorMsg }))] }));
|
|
10
10
|
}
|
|
11
11
|
IDSRadioGroupBase.displayName = "IDSRadioGroupBase";
|
|
12
12
|
|
|
@@ -7,11 +7,12 @@ interface IDSRadioGroupProps extends FieldsetHTMLAttributes<HTMLFieldSetElement>
|
|
|
7
7
|
compact?: boolean;
|
|
8
8
|
invalid?: boolean;
|
|
9
9
|
required?: boolean;
|
|
10
|
+
subtitle?: string | ReactNode;
|
|
10
11
|
tooltip?: ReactNode;
|
|
11
12
|
noValidation?: boolean;
|
|
12
13
|
onRadioChange?: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
13
14
|
}
|
|
14
|
-
export declare function IDSRadioGroup({ name, required, noValidation, invalid, errorMsg, children, onRadioChange, ...props }: IDSRadioGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function IDSRadioGroup({ name, required, noValidation, invalid, errorMsg, subtitle, children, onRadioChange, ...props }: IDSRadioGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
15
16
|
export declare namespace IDSRadioGroup {
|
|
16
17
|
var displayName: string;
|
|
17
18
|
}
|
|
@@ -5,7 +5,7 @@ import { IDSRadioGroupBase } from './radio-group-base.js';
|
|
|
5
5
|
import { IDSRadio } from './radio.js';
|
|
6
6
|
import { useGroupValidity } from '../form-hooks/useGroupValidity.js';
|
|
7
7
|
|
|
8
|
-
function IDSRadioGroup({ name, required, noValidation, invalid, errorMsg, children, onRadioChange, ...props }) {
|
|
8
|
+
function IDSRadioGroup({ name, required, noValidation, invalid, errorMsg, subtitle, children, onRadioChange, ...props }) {
|
|
9
9
|
const groupRef = useRef(null);
|
|
10
10
|
const { isValid, hasInteracted } = useGroupValidity(groupRef, "radio");
|
|
11
11
|
const reactId = useId();
|
|
@@ -31,7 +31,7 @@ function IDSRadioGroup({ name, required, noValidation, invalid, errorMsg, childr
|
|
|
31
31
|
}
|
|
32
32
|
return child;
|
|
33
33
|
});
|
|
34
|
-
return (jsx(IDSRadioGroupBase, { ...props, groupRef: groupRef, required: required, invalid: groupInvalid || invalid, errorMsg: !noValidation && errorMsg, errorMsgId: errorMsgId, children: clonedChildren }));
|
|
34
|
+
return (jsx(IDSRadioGroupBase, { ...props, groupRef: groupRef, required: required, subtitle: subtitle, invalid: groupInvalid || invalid, errorMsg: !noValidation && errorMsg, errorMsgId: errorMsgId, children: clonedChildren }));
|
|
35
35
|
}
|
|
36
36
|
IDSRadioGroup.displayName = "IDSRadioGroup";
|
|
37
37
|
|
|
@@ -10,7 +10,7 @@ export interface IDSRangeBaseProps extends React.InputHTMLAttributes<HTMLInputEl
|
|
|
10
10
|
inputRef?: Ref<HTMLInputElement>;
|
|
11
11
|
style?: CSSProperties;
|
|
12
12
|
}
|
|
13
|
-
export declare function IDSRangeBase({ id, label, showTicks, ticks, disabled, focusAnchor, dataTestId, tooltip, valueNow, min, max, step, inputRef, style, className, ...props }: IDSRangeBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function IDSRangeBase({ id, label, showTicks, ticks, disabled, focusAnchor, dataTestId, tooltip, valueNow, min, max, step, inputRef, style, className, subtitle, ...props }: IDSRangeBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
14
14
|
export declare namespace IDSRangeBase {
|
|
15
15
|
var displayName: string;
|
|
16
16
|
}
|
|
@@ -2,9 +2,9 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { useId } from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
|
|
5
|
-
function IDSRangeBase({ id, label, showTicks, ticks = [], disabled, focusAnchor, dataTestId, tooltip, valueNow, min = 0, max = 10, step = 1, inputRef, style, className, ...props }) {
|
|
5
|
+
function IDSRangeBase({ id, label, showTicks, ticks = [], disabled, focusAnchor, dataTestId, tooltip, valueNow, min = 0, max = 10, step = 1, inputRef, style, className, subtitle, ...props }) {
|
|
6
6
|
const inputId = !!id ? id : `range-${useId()}`;
|
|
7
|
-
return (jsxs("div", { className: clsx("ids-range", className), "data-testid": dataTestId, style: style, children: [label && (jsxs("div", { className: "ids-label-wrapper ids-label-wrapper--margin-bottom", children: [jsx("label", { htmlFor: inputId, className:
|
|
7
|
+
return (jsxs("div", { className: clsx("ids-range", className), "data-testid": dataTestId, style: style, children: [label && (jsxs("div", { className: "ids-label-wrapper ids-label-wrapper--margin-bottom", children: [jsx("label", { htmlFor: inputId, className: "ids-label", children: label }), tooltip && jsx("span", { className: "ids-label__tooltip", children: tooltip })] })), subtitle && jsx("div", { className: "ids-subtitle", children: subtitle }), jsx("input", { id: inputId, ref: inputRef, type: "range", className: clsx("ids-range__input", {
|
|
8
8
|
"ids-focus-anchor": focusAnchor
|
|
9
9
|
}), min: min, "aria-valuemin": min, max: max, "aria-valuemax": max, "aria-valuenow": valueNow, "aria-disabled": disabled, disabled: disabled, step: step, style: {
|
|
10
10
|
backgroundSize: ((valueNow - (min ?? 0)) * 100) / ((max ?? 100) - (min ?? 0)) + "% 100%"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CSSProperties } from "react";
|
|
2
|
-
import {
|
|
3
|
-
export interface IDSSelectBaseProps extends React.SelectHTMLAttributes<HTMLSelectElement>,
|
|
2
|
+
import { CommonFormPropsWithReadOnly } from "../form-props/form-props";
|
|
3
|
+
export interface IDSSelectBaseProps extends React.SelectHTMLAttributes<HTMLSelectElement>, CommonFormPropsWithReadOnly {
|
|
4
4
|
selectRef?: React.Ref<HTMLSelectElement>;
|
|
5
5
|
errorMsgId?: string;
|
|
6
6
|
style?: CSSProperties;
|
|
7
7
|
}
|
|
8
|
-
export declare function IDSSelectBase({ id, label, errorMsgId, errorMsg, invalid, disabled, required, light, focusAnchor, tooltip, children, className, selectRef, dataTestId, style, ...props }: IDSSelectBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function IDSSelectBase({ id, label, errorMsgId, errorMsg, invalid, readOnly, disabled, required, light, focusAnchor, tooltip, children, className, selectRef, dataTestId, style, subtitle, ...props }: IDSSelectBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
export declare namespace IDSSelectBase {
|
|
10
10
|
var displayName: string;
|
|
11
11
|
}
|
|
@@ -3,7 +3,7 @@ import { useId } from 'react';
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { IDSErrorMessage } from '../error-message/error-message.js';
|
|
5
5
|
|
|
6
|
-
function IDSSelectBase({ id, label, errorMsgId, errorMsg, invalid, disabled, required, light, focusAnchor, tooltip, children, className, selectRef, dataTestId, style, ...props }) {
|
|
6
|
+
function IDSSelectBase({ id, label, errorMsgId, errorMsg, invalid, readOnly, disabled, required, light, focusAnchor, tooltip, children, className, selectRef, dataTestId, style, subtitle, ...props }) {
|
|
7
7
|
const reactId = useId();
|
|
8
8
|
const selectId = id ?? `select-base-${reactId}`;
|
|
9
9
|
const baseErrorMsgId = errorMsgId ?? `select-base-error-${reactId}`;
|
|
@@ -12,12 +12,10 @@ function IDSSelectBase({ id, label, errorMsgId, errorMsg, invalid, disabled, req
|
|
|
12
12
|
if (showErrorMsg) {
|
|
13
13
|
ariaHandler["aria-describedby"] = baseErrorMsgId;
|
|
14
14
|
}
|
|
15
|
-
return (jsxs("div", { className: clsx("ids-select", className), "data-testid": dataTestId, style: style, children: [label && (jsxs("div", { className: "ids-label-wrapper ids-label-wrapper--margin-bottom", children: [jsx("label", { htmlFor: selectId, className: clsx("ids-
|
|
16
|
-
"ids-label--disabled": disabled
|
|
17
|
-
}), children: label }), tooltip && jsx("span", { className: "ids-label__tooltip", children: tooltip })] })), jsx("div", { className: "ids-select__wrapper", children: jsx("select", { id: selectId, ref: selectRef, className: clsx("ids-select__select", {
|
|
15
|
+
return (jsxs("div", { className: clsx("ids-select", className), "data-testid": dataTestId, style: style, children: [label && (jsxs("div", { className: "ids-label-wrapper ids-label-wrapper--margin-bottom", children: [jsx("label", { htmlFor: selectId, className: "ids-label", children: label }), tooltip && jsx("span", { className: "ids-label__tooltip", children: tooltip })] })), subtitle && jsx("div", { className: "ids-subtitle", children: subtitle }), jsx("div", { className: "ids-select__wrapper", children: jsx("select", { id: selectId, ref: selectRef, className: clsx("ids-select__select", {
|
|
18
16
|
"ids-input--light": light,
|
|
19
17
|
"ids-focus-anchor": focusAnchor
|
|
20
|
-
}), "aria-invalid": invalid, "aria-disabled":
|
|
18
|
+
}), "aria-invalid": invalid, "aria-disabled": readOnly, disabled: disabled, required: required, ...ariaHandler, ...props, children: children }) }), showErrorMsg && (jsx(IDSErrorMessage, { id: baseErrorMsgId, show: true, children: errorMsg }))] }));
|
|
21
19
|
}
|
|
22
20
|
IDSSelectBase.displayName = "IDSSelectBase";
|
|
23
21
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface IDSSelectProps extends React.SelectHTMLAttributes<HTMLSelectElement>,
|
|
1
|
+
import { CommonFormPropsWithReadOnly } from "../form-props/form-props";
|
|
2
|
+
export interface IDSSelectProps extends React.SelectHTMLAttributes<HTMLSelectElement>, CommonFormPropsWithReadOnly {
|
|
3
3
|
}
|
|
4
4
|
export declare const IDSSelect: import("react").ForwardRefExoticComponent<IDSSelectProps & import("react").RefAttributes<HTMLSelectElement>>;
|
|
@@ -7,7 +7,7 @@ import { IDSSelectBase } from './select-base.js';
|
|
|
7
7
|
const IDSSelect = forwardRef(({ invalid = false, noValidation = false, validationOnBlur = false, children, ...props }, ref) => {
|
|
8
8
|
const errorMsgId = `select-error-${useId()}`;
|
|
9
9
|
const selectRef = useRef(null);
|
|
10
|
-
const hasValidValue = useInputValidity(selectRef, validationOnBlur);
|
|
10
|
+
const hasValidValue = useInputValidity(selectRef, validationOnBlur, noValidation);
|
|
11
11
|
const computedInvalid = (invalid || !hasValidValue) && !noValidation;
|
|
12
12
|
// Merge forwarded + local ref
|
|
13
13
|
const mergedRef = (node) => {
|
|
@@ -14,7 +14,7 @@ export interface IDSSelectMultipleBaseProps extends React.InputHTMLAttributes<HT
|
|
|
14
14
|
client?: boolean;
|
|
15
15
|
style?: CSSProperties;
|
|
16
16
|
}
|
|
17
|
-
export declare function IDSSelectMultipleBase({ id, label, placeholder, numbCheckedBoxes, selectedLabel, selectedLabelPlural, expanded, maxHeight, tooltip, componentRef, buttonRef, invalid, disabled, readOnly, ariaDisabled, light, focusAnchor, className, children, style, onClick, client }: IDSSelectMultipleBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function IDSSelectMultipleBase({ id, label, placeholder, numbCheckedBoxes, selectedLabel, selectedLabelPlural, expanded, maxHeight, tooltip, subtitle, componentRef, buttonRef, invalid, disabled, readOnly, ariaDisabled, light, focusAnchor, className, children, style, onClick, client }: IDSSelectMultipleBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
18
18
|
export declare namespace IDSSelectMultipleBase {
|
|
19
19
|
var displayName: string;
|
|
20
20
|
}
|
|
@@ -2,7 +2,7 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { useId } from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
|
|
5
|
-
function IDSSelectMultipleBase({ id, label, placeholder, numbCheckedBoxes, selectedLabel = "vald", selectedLabelPlural = "valda", expanded, maxHeight = "", tooltip, componentRef, buttonRef, invalid, disabled, readOnly, ariaDisabled, light, focusAnchor, className, children, style, onClick, client = false }) {
|
|
5
|
+
function IDSSelectMultipleBase({ id, label, placeholder, numbCheckedBoxes, selectedLabel = "vald", selectedLabelPlural = "valda", expanded, maxHeight = "", tooltip, subtitle, componentRef, buttonRef, invalid, disabled, readOnly, ariaDisabled, light, focusAnchor, className, children, style, onClick, client = false }) {
|
|
6
6
|
const reactId = useId();
|
|
7
7
|
const labelId = `select-multiple-base-label-${reactId}`;
|
|
8
8
|
const dropdownId = `select-multiple-base-dropdown-${reactId}`;
|
|
@@ -16,7 +16,7 @@ function IDSSelectMultipleBase({ id, label, placeholder, numbCheckedBoxes, selec
|
|
|
16
16
|
onClick
|
|
17
17
|
}
|
|
18
18
|
: {};
|
|
19
|
-
return (jsxs("div", { className: clsx("ids-select-multiple", className), ref: componentRef, style: style, children: [label && (jsxs("div", { className: "ids-label-wrapper ids-label-wrapper--margin-bottom", children: [jsx("label", { id: labelId, className:
|
|
19
|
+
return (jsxs("div", { className: clsx("ids-select-multiple", className), ref: componentRef, style: style, children: [label && (jsxs("div", { className: "ids-label-wrapper ids-label-wrapper--margin-bottom", children: [jsx("label", { id: labelId, className: "ids-label", children: label }), tooltip && jsx("span", { className: "ids-label__tooltip", children: tooltip })] })), subtitle && jsx("div", { className: "ids-subtitle", children: subtitle }), jsx("div", { className: "ids-select-multiple__select-wrapper", children: jsx("button", { ref: buttonRef, id: id, "aria-labelledby": labelId, type: "button", "aria-haspopup": "dialog", "aria-controls": dropdownId, className: clsx("ids-select-multiple__select", {
|
|
20
20
|
"ids-input--light": light,
|
|
21
21
|
"ids-focus-anchor": focusAnchor
|
|
22
22
|
}), disabled: disabled, "aria-disabled": ariaDisabled || readOnly || undefined, "aria-expanded": expanded, "aria-invalid": invalid, ...clickHandler, children: displayedValue }) }), jsx("div", { className: "ids-select-multiple__dropdown-wrapper", id: dropdownId, children: jsx("div", { className: clsx("ids-select-multiple__dropdown", {
|
|
@@ -9,7 +9,7 @@ interface IDSTextareaBaseProps extends Omit<React.TextareaHTMLAttributes<HTMLTex
|
|
|
9
9
|
errorMsgId?: string;
|
|
10
10
|
style?: CSSProperties;
|
|
11
11
|
}
|
|
12
|
-
export declare function IDSTextareaBase({ id, label, hint, hintId, errorMsg, errorMsgId, invalid, required, disabled, readOnly, light, block, autoSize, noResize, focusAnchor, tooltip, textareaRef, dataTestId, className, style, ...props }: IDSTextareaBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function IDSTextareaBase({ id, label, subtitle, hint, hintId, errorMsg, errorMsgId, invalid, required, disabled, readOnly, light, block, autoSize, noResize, focusAnchor, tooltip, textareaRef, dataTestId, className, style, ...props }: IDSTextareaBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
export declare namespace IDSTextareaBase {
|
|
14
14
|
var displayName: string;
|
|
15
15
|
}
|
|
@@ -3,7 +3,7 @@ import clsx from 'clsx';
|
|
|
3
3
|
import { IDSErrorMessage } from '../error-message/error-message.js';
|
|
4
4
|
import { useId } from 'react';
|
|
5
5
|
|
|
6
|
-
function IDSTextareaBase({ id, label, hint, hintId, errorMsg, errorMsgId, invalid, required, disabled, readOnly, light, block, autoSize, noResize, focusAnchor, tooltip, textareaRef, dataTestId, className, style, ...props }) {
|
|
6
|
+
function IDSTextareaBase({ id, label, subtitle, hint, hintId, errorMsg, errorMsgId, invalid, required, disabled, readOnly, light, block, autoSize, noResize, focusAnchor, tooltip, textareaRef, dataTestId, className, style, ...props }) {
|
|
7
7
|
const reactId = useId();
|
|
8
8
|
const inputId = !!id ? id : `textarea-base-${reactId}`;
|
|
9
9
|
const baseHintId = !!hintId ? hintId : `textarea-base-hint-${reactId}`;
|
|
@@ -18,13 +18,11 @@ function IDSTextareaBase({ id, label, hint, hintId, errorMsg, errorMsgId, invali
|
|
|
18
18
|
"ids-textarea--block": block,
|
|
19
19
|
"ids-textarea--autosize": autoSize,
|
|
20
20
|
"ids-textarea--no-resize": noResize
|
|
21
|
-
}, className), "data-testid": dataTestId, style: style, children: [label && (jsxs("div", { className: "ids-label-wrapper ids-label-wrapper--margin-bottom", children: [jsx("label", { htmlFor: inputId, className: clsx("ids-
|
|
22
|
-
"ids-label--disabled": disabled || readOnly
|
|
23
|
-
}), children: label }), tooltip && jsx("span", { className: "ids-label__tooltip", children: tooltip })] })), jsx("textarea", { ref: textareaRef, id: inputId, className: clsx("ids-textarea__textarea", {
|
|
21
|
+
}, className), "data-testid": dataTestId, style: style, children: [label && (jsxs("div", { className: "ids-label-wrapper ids-label-wrapper--margin-bottom", children: [jsx("label", { htmlFor: inputId, className: "ids-label", children: label }), tooltip && jsx("span", { className: "ids-label__tooltip", children: tooltip })] })), subtitle && jsx("div", { className: "ids-subtitle", children: subtitle }), jsx("textarea", { ref: textareaRef, id: inputId, className: clsx("ids-textarea__textarea", {
|
|
24
22
|
"ids-input--light": light,
|
|
25
23
|
"ids-input--invalid": invalid,
|
|
26
24
|
"ids-focus-anchor": focusAnchor
|
|
27
|
-
}), style: { minWidth:
|
|
25
|
+
}), style: { minWidth: !!hint || (!!errorMsg && showErrorMsg) ? "100%" : "inherit" }, required: required, disabled: disabled, "aria-required": required, "aria-disabled": disabled, "aria-invalid": invalid, readOnly: readOnly, ...ariaHandler, ...props }), hint && (jsx("div", { id: baseHintId, className: "ids-input__hint", children: hint })), showErrorMsg && (jsx(IDSErrorMessage, { id: baseErrorMsgId, show: true, children: errorMsg }))] }));
|
|
28
26
|
}
|
|
29
27
|
IDSTextareaBase.displayName = "IDSTextareaBase";
|
|
30
28
|
|
|
@@ -6,7 +6,7 @@ import { IDSTextareaBase } from './textarea-base.js';
|
|
|
6
6
|
|
|
7
7
|
const IDSTextarea = forwardRef(({ invalid = false, noValidation = false, validationOnBlur = false, ...props }, ref) => {
|
|
8
8
|
const textareaRef = useRef(null);
|
|
9
|
-
const hasValidValue = useInputValidity(textareaRef, validationOnBlur);
|
|
9
|
+
const hasValidValue = useInputValidity(textareaRef, validationOnBlur, noValidation);
|
|
10
10
|
const computedInvalid = (invalid || !hasValidValue) && !noValidation;
|
|
11
11
|
// Merge forwarded + local ref
|
|
12
12
|
const mergedRef = (node) => {
|
|
@@ -5,7 +5,7 @@ export interface IDSTimeBaseProps extends React.InputHTMLAttributes<HTMLInputEle
|
|
|
5
5
|
errorMsgId?: string;
|
|
6
6
|
style?: CSSProperties;
|
|
7
7
|
}
|
|
8
|
-
export declare function IDSTimeBase({ id, label, tooltip, errorMsg, errorMsgId, disabled, invalid, required, light, focusAnchor, dataTestId, className, inputRef, style, ...props }: IDSTimeBaseProps & React.InputHTMLAttributes<HTMLInputElement>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function IDSTimeBase({ id, label, tooltip, errorMsg, errorMsgId, disabled, invalid, required, light, focusAnchor, dataTestId, className, inputRef, style, subtitle, ...props }: IDSTimeBaseProps & React.InputHTMLAttributes<HTMLInputElement>): import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
export declare namespace IDSTimeBase {
|
|
10
10
|
var displayName: string;
|
|
11
11
|
}
|
|
@@ -3,7 +3,7 @@ import clsx from 'clsx';
|
|
|
3
3
|
import { IDSErrorMessage } from '../error-message/error-message.js';
|
|
4
4
|
import { useId } from 'react';
|
|
5
5
|
|
|
6
|
-
function IDSTimeBase({ id, label, tooltip, errorMsg, errorMsgId, disabled = false, invalid = false, required = false, light, focusAnchor, dataTestId, className, inputRef, style, ...props }) {
|
|
6
|
+
function IDSTimeBase({ id, label, tooltip, errorMsg, errorMsgId, disabled = false, invalid = false, required = false, light, focusAnchor, dataTestId, className, inputRef, style, subtitle, ...props }) {
|
|
7
7
|
const reactId = useId();
|
|
8
8
|
const inputId = id ?? `time-base-${reactId}`;
|
|
9
9
|
const baseErrorMsgId = errorMsgId ?? `time-base-error-${reactId}`;
|
|
@@ -12,9 +12,7 @@ function IDSTimeBase({ id, label, tooltip, errorMsg, errorMsgId, disabled = fals
|
|
|
12
12
|
if (showErrorMsg) {
|
|
13
13
|
ariaHandler["aria-describedby"] = baseErrorMsgId;
|
|
14
14
|
}
|
|
15
|
-
return (jsxs("div", { className: clsx("ids-time", className), "data-testid": dataTestId, style: style, children: [label && (jsxs("div", { className: "ids-label-wrapper ids-label-wrapper--margin-bottom", children: [jsx("label", { className: clsx("ids-
|
|
16
|
-
"ids-label--disabled": disabled
|
|
17
|
-
}), htmlFor: inputId, children: label }), tooltip && jsx("span", { className: "ids-label__tooltip", children: tooltip })] })), jsx("div", { className: "ids-time__input-wrapper", children: jsx("input", { ref: inputRef, id: inputId, type: "time", className: clsx("ids-time__input", {
|
|
15
|
+
return (jsxs("div", { className: clsx("ids-time", className), "data-testid": dataTestId, style: style, children: [label && (jsxs("div", { className: "ids-label-wrapper ids-label-wrapper--margin-bottom", children: [jsx("label", { className: "ids-label", htmlFor: inputId, children: label }), tooltip && jsx("span", { className: "ids-label__tooltip", children: tooltip })] })), subtitle && jsx("div", { className: "ids-subtitle", children: subtitle }), jsx("div", { className: "ids-time__input-wrapper", children: jsx("input", { ref: inputRef, id: inputId, type: "time", className: clsx("ids-time__input", {
|
|
18
16
|
"ids-input--light": light,
|
|
19
17
|
"ids-focus-anchor": focusAnchor
|
|
20
18
|
}), "aria-invalid": invalid, "aria-required": required, "aria-disabled": disabled, required: required, disabled: disabled, ...ariaHandler, ...props }) }), showErrorMsg && (jsx(IDSErrorMessage, { id: baseErrorMsgId, show: true, children: errorMsg }))] }));
|
|
@@ -4,11 +4,10 @@ import { forwardRef, useRef } from 'react';
|
|
|
4
4
|
import { useInputValidity } from '../form-hooks/useInputValidity.js';
|
|
5
5
|
import { IDSTimeBase } from './time-base.js';
|
|
6
6
|
|
|
7
|
-
const IDSTime = forwardRef(({ invalid = false, noValidation = false, validationOnBlur = false, ...props }, ref) => {
|
|
7
|
+
const IDSTime = forwardRef(({ invalid = false, noValidation = false, validationOnBlur = false, required = false, ...props }, ref) => {
|
|
8
8
|
const timeRef = useRef(null);
|
|
9
|
-
const hasValidValue = useInputValidity(timeRef, validationOnBlur);
|
|
10
|
-
const isInvalid = (invalid || !hasValidValue)
|
|
11
|
-
// Merge forwarded + local ref
|
|
9
|
+
const hasValidValue = useInputValidity(timeRef, validationOnBlur, noValidation);
|
|
10
|
+
const isInvalid = !noValidation && (invalid || !hasValidValue);
|
|
12
11
|
const mergedRef = (node) => {
|
|
13
12
|
timeRef.current = node;
|
|
14
13
|
if (typeof ref === "function")
|
|
@@ -16,7 +15,7 @@ const IDSTime = forwardRef(({ invalid = false, noValidation = false, validationO
|
|
|
16
15
|
else if (ref)
|
|
17
16
|
ref.current = node;
|
|
18
17
|
};
|
|
19
|
-
return jsx(IDSTimeBase, { invalid: isInvalid, inputRef: mergedRef, ...props });
|
|
18
|
+
return jsx(IDSTimeBase, { invalid: isInvalid, inputRef: mergedRef, required: noValidation ? false : required, ...props });
|
|
20
19
|
});
|
|
21
20
|
IDSTime.displayName = "IDSTime";
|
|
22
21
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { HTMLAttributes } from "react";
|
|
2
2
|
export interface IDSHeader1177RegionPickerBaseProps extends HTMLAttributes<HTMLElement> {
|
|
3
3
|
text?: string;
|
|
4
|
+
ariaLabel?: string;
|
|
5
|
+
ariaControls?: string;
|
|
4
6
|
expanded?: boolean;
|
|
5
7
|
hide?: boolean;
|
|
6
8
|
onToggle?: () => void;
|
|
7
9
|
client?: boolean;
|
|
8
10
|
}
|
|
9
|
-
export declare function IDSHeader1177RegionPickerBase({ text, expanded, hide, children, onToggle, client, ...props }: IDSHeader1177RegionPickerBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function IDSHeader1177RegionPickerBase({ text, ariaLabel, ariaControls, expanded, hide, children, onToggle, client, ...props }: IDSHeader1177RegionPickerBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
10
12
|
export declare namespace IDSHeader1177RegionPickerBase {
|
|
11
13
|
var displayName: string;
|
|
12
14
|
}
|
|
@@ -2,7 +2,7 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
|
|
5
|
-
function IDSHeader1177RegionPickerBase({ text = "Välj region", expanded = false, hide = false, children, onToggle, client = false, ...props }) {
|
|
5
|
+
function IDSHeader1177RegionPickerBase({ text = "Välj region", ariaLabel = "Välj region", ariaControls, expanded = false, hide = false, children, onToggle, client = false, ...props }) {
|
|
6
6
|
if (hide)
|
|
7
7
|
return null;
|
|
8
8
|
const hasChildren = React.Children.count(children) > 0;
|
|
@@ -11,11 +11,16 @@ function IDSHeader1177RegionPickerBase({ text = "Välj region", expanded = false
|
|
|
11
11
|
onClick: onToggle
|
|
12
12
|
}
|
|
13
13
|
: {};
|
|
14
|
+
const ariaHandler = ariaControls
|
|
15
|
+
? {
|
|
16
|
+
"aria-controls": ariaControls
|
|
17
|
+
}
|
|
18
|
+
: {};
|
|
14
19
|
return (jsxs("div", { className: clsx("ids-header-1177-region-picker", {
|
|
15
20
|
"ids-header-1177-region-picker--selected-region": hasChildren
|
|
16
|
-
}), ...props, children: [jsx("div", { className: "ids-header-1177-region-picker__region-icon", children: children }), jsx("div", { className: "ids-header-1177-region-picker__selector", children: jsx("button", { ...toggleHandler, className: clsx("ids-header-1177-region-picker__button", {
|
|
21
|
+
}), ...props, children: [jsx("div", { className: "ids-header-1177-region-picker__region-icon", children: children }), jsx("div", { className: "ids-header-1177-region-picker__selector", children: jsx("button", { ...toggleHandler, ...ariaHandler, className: clsx("ids-header-1177-region-picker__button", {
|
|
17
22
|
"ids-header-1177-region-picker__button--expanded": expanded
|
|
18
|
-
}), "aria-label":
|
|
23
|
+
}), "aria-expanded": expanded ? "true" : "false", "aria-label": ariaLabel, children: text }) })] }));
|
|
19
24
|
}
|
|
20
25
|
IDSHeader1177RegionPickerBase.displayName = "IDSHeader1177RegionPickerBase";
|
|
21
26
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { HTMLAttributes } from "react";
|
|
2
2
|
export interface IDSHeader1177RegionPickerMobileBaseProps extends HTMLAttributes<HTMLElement> {
|
|
3
3
|
text?: string;
|
|
4
|
+
ariaLabel?: string;
|
|
5
|
+
ariaControls?: string;
|
|
4
6
|
expanded?: boolean;
|
|
5
7
|
onToggle?: () => void;
|
|
6
8
|
hide?: boolean;
|
|
7
9
|
client?: boolean;
|
|
8
10
|
}
|
|
9
|
-
export declare function IDSHeader1177RegionPickerMobileBase({ text, expanded, children, onToggle, hide, client, ...props }: IDSHeader1177RegionPickerMobileBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function IDSHeader1177RegionPickerMobileBase({ text, ariaLabel, ariaControls, expanded, children, onToggle, hide, client, ...props }: IDSHeader1177RegionPickerMobileBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
10
12
|
export declare namespace IDSHeader1177RegionPickerMobileBase {
|
|
11
13
|
var displayName: string;
|
|
12
14
|
}
|
|
@@ -2,7 +2,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
|
|
5
|
-
function IDSHeader1177RegionPickerMobileBase({ text = "Välj region", expanded = false, children, onToggle, hide = false, client = false, ...props }) {
|
|
5
|
+
function IDSHeader1177RegionPickerMobileBase({ text = "Välj region", ariaLabel = "Välj region", ariaControls = "", expanded = false, children, onToggle, hide = false, client = false, ...props }) {
|
|
6
6
|
if (hide)
|
|
7
7
|
return null;
|
|
8
8
|
const hasChildren = React.Children.count(children) > 0;
|
|
@@ -11,11 +11,16 @@ function IDSHeader1177RegionPickerMobileBase({ text = "Välj region", expanded =
|
|
|
11
11
|
onClick: onToggle
|
|
12
12
|
}
|
|
13
13
|
: {};
|
|
14
|
+
const ariaHandler = ariaControls
|
|
15
|
+
? {
|
|
16
|
+
"aria-controls": ariaControls
|
|
17
|
+
}
|
|
18
|
+
: {};
|
|
14
19
|
return (jsx("div", { className: clsx("ids-header-1177-region-picker-mobile", {
|
|
15
20
|
"ids-header-1177-region-picker-mobile--selected-region": hasChildren
|
|
16
|
-
}), ...props, children: jsxs("button", { ...toggleHandler, className: clsx("ids-header-1177-region-picker-mobile__button", {
|
|
21
|
+
}), ...props, children: jsxs("button", { ...toggleHandler, ...ariaHandler, className: clsx("ids-header-1177-region-picker-mobile__button", {
|
|
17
22
|
"ids-header-1177-region-picker-mobile__button--expanded": expanded
|
|
18
|
-
}), "aria-label":
|
|
23
|
+
}), "aria-expanded": expanded ? "true" : "false", "aria-label": ariaLabel, children: [jsx("div", { className: "ids-header-1177-region-picker-mobile__region-icon", children: children }), jsx("span", { className: "ids-header-1177-region-picker-mobile__button-text", children: text })] }) }));
|
|
19
24
|
}
|
|
20
25
|
IDSHeader1177RegionPickerMobileBase.displayName = "IDSHeader1177RegionPickerMobileBase";
|
|
21
26
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { HTMLAttributes } from "react";
|
|
2
2
|
export interface IDSHeader1177RegionPickerMobileProps extends HTMLAttributes<HTMLElement> {
|
|
3
3
|
expanded?: boolean;
|
|
4
|
+
ariaLabel?: string;
|
|
5
|
+
ariaControls?: string;
|
|
4
6
|
onToggleRegion?: (isExpanded: boolean) => void;
|
|
5
7
|
}
|
|
6
8
|
export declare function IDSHeader1177RegionPickerMobile({ expanded, onToggleRegion, children, ...props }: IDSHeader1177RegionPickerMobileProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { HTMLAttributes } from "react";
|
|
2
2
|
export interface IDSHeader1177RegionPickerProps extends HTMLAttributes<HTMLElement> {
|
|
3
3
|
expanded?: boolean;
|
|
4
|
+
ariaLabel?: string;
|
|
5
|
+
ariaControls?: string;
|
|
4
6
|
onToggleRegion?: (isExpanded: boolean) => void;
|
|
5
7
|
}
|
|
6
8
|
export declare function IDSHeader1177RegionPicker({ expanded, onToggleRegion, children, ...props }: IDSHeader1177RegionPickerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { HTMLAttributes } from "react";
|
|
2
2
|
export interface IDSHeader1177ProRegionPickerBaseProps extends HTMLAttributes<HTMLElement> {
|
|
3
3
|
text?: string;
|
|
4
|
+
ariaControls?: string;
|
|
5
|
+
ariaLabel?: string;
|
|
4
6
|
expanded?: boolean;
|
|
5
7
|
hide?: boolean;
|
|
6
8
|
client?: boolean;
|
|
7
9
|
onToggleRegion?: () => void;
|
|
8
10
|
}
|
|
9
|
-
export declare function IDSHeader1177ProRegionPickerBase({ text, expanded, hide, children, client, onToggleRegion, ...props }: IDSHeader1177ProRegionPickerBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function IDSHeader1177ProRegionPickerBase({ text, ariaLabel, ariaControls, expanded, hide, children, client, onToggleRegion, ...props }: IDSHeader1177ProRegionPickerBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
10
12
|
export declare namespace IDSHeader1177ProRegionPickerBase {
|
|
11
13
|
var displayName: string;
|
|
12
14
|
}
|