@axa-fr/design-system-slash-react 1.1.1-alpha.99 → 1.2.0-RC.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.
- package/dist/Action/Action.js +1 -1
- package/dist/Alert/Alert.d.ts +2 -1
- package/dist/Alert/Alert.js +2 -2
- package/dist/Form/Checkbox/CheckboxInput.js +8 -3
- package/dist/Form/Choice/Choice.d.ts +2 -1
- package/dist/Form/Choice/Choice.js +11 -9
- package/dist/Form/Choice/ChoiceInput.js +12 -6
- package/dist/Form/Date/DateInput.d.ts +40 -6
- package/dist/Form/Date/DateInput.js +8 -4
- package/dist/Form/File/FileInput.js +4 -1
- package/dist/Form/MultiSelect/MultiSelectInput.js +4 -1
- package/dist/Form/Number/NumberInput.js +4 -1
- package/dist/Form/Pass/PassInput.js +6 -2
- package/dist/Form/Radio/RadioInput.d.ts +1 -0
- package/dist/Form/Radio/RadioInput.js +5 -2
- package/dist/Form/Select/Select.d.ts +310 -5
- package/dist/Form/Select/Select.js +7 -4
- package/dist/Form/Select/SelectBase.d.ts +1 -1
- package/dist/Form/Select/SelectBase.js +3 -2
- package/dist/Form/Select/SelectDefault.d.ts +3 -2
- package/dist/Form/Select/SelectDefault.js +6 -8
- package/dist/Form/Select/SelectDefaultWithOptions.d.ts +9 -0
- package/dist/Form/Select/SelectDefaultWithOptions.js +18 -0
- package/dist/Form/Select/SelectInput.d.ts +386 -6
- package/dist/Form/Select/SelectInput.js +4 -1
- package/dist/Form/Text/TextInput.js +7 -2
- package/dist/Form/Textarea/TextareaInput.js +4 -1
- package/dist/Form/core/Field.d.ts +2 -1
- package/dist/Form/core/Field.js +5 -2
- package/dist/Form/core/FieldError.d.ts +2 -1
- package/dist/Form/core/FieldError.js +2 -2
- package/dist/Form/core/LegacyField.d.ts +3 -2
- package/dist/Form/core/LegacyField.js +2 -2
- package/dist/Form/core/useAriaInvalid.d.ts +2 -0
- package/dist/Form/core/useAriaInvalid.js +2 -0
- package/dist/Link/CustomLink.d.ts +8 -0
- package/dist/Link/CustomLink.js +6 -0
- package/dist/Link/Link.d.ts +4 -9
- package/dist/Link/Link.js +9 -5
- package/dist/Link/LinkAnchor.d.ts +10 -0
- package/dist/Link/LinkAnchor.js +10 -0
- package/dist/Link/linkClassName.d.ts +1 -0
- package/dist/Link/linkClassName.js +1 -0
- package/dist/ModalAgent/Modal.js +1 -1
- package/dist/Restitution/HeaderRestitution.js +1 -1
- package/dist/Restitution/SectionRestitutionTitle.js +1 -1
- package/dist/Table/Pagination/Items.d.ts +2 -1
- package/dist/Table/Pagination/Items.js +9 -5
- package/dist/Table/Pagination/Paging.d.ts +1 -1
- package/dist/Table/Pagination/Paging.js +2 -2
- package/dist/Title/Title.d.ts +3 -1
- package/dist/Title/Title.js +6 -5
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/package.json +4 -4
package/dist/Action/Action.js
CHANGED
|
@@ -4,6 +4,6 @@ import { forwardRef } from "react";
|
|
|
4
4
|
import { getComponentClassName } from "../utilities";
|
|
5
5
|
export const Action = forwardRef(({ icon, className, classModifier, ...otherProps }, ref) => {
|
|
6
6
|
const componentClassName = getComponentClassName(className, classModifier, "btn af-btn--circle");
|
|
7
|
-
return (_jsx("a", { ...otherProps, className: componentClassName, ref: ref, children: _jsx("i", { className: `glyphicon glyphicon-${icon}` }) }));
|
|
7
|
+
return (_jsx("a", { ...otherProps, className: componentClassName, ref: ref, children: _jsx("i", { role: "img", className: `glyphicon glyphicon-${icon}` }) }));
|
|
8
8
|
});
|
|
9
9
|
Action.displayName = "Action";
|
package/dist/Alert/Alert.d.ts
CHANGED
|
@@ -12,5 +12,6 @@ export type AlertCoreComponentProps = {
|
|
|
12
12
|
onClose?: MouseEventHandler<HTMLButtonElement>;
|
|
13
13
|
className?: string;
|
|
14
14
|
classModifier?: "error" | "danger" | "info" | "success";
|
|
15
|
+
ariaLabel?: string;
|
|
15
16
|
};
|
|
16
|
-
export declare const Alert: ({ className, onClose, icon, title, children, classModifier, }: PropsWithChildren<AlertCoreComponentProps>) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare const Alert: ({ className, onClose, icon, title, children, classModifier, ariaLabel, }: PropsWithChildren<AlertCoreComponentProps>) => import("react/jsx-runtime").JSX.Element;
|
package/dist/Alert/Alert.js
CHANGED
|
@@ -8,7 +8,7 @@ export var TypeIcons;
|
|
|
8
8
|
TypeIcons["info"] = "glyphicon glyphicon-info-sign";
|
|
9
9
|
TypeIcons["success"] = "glyphicon glyphicon-ok";
|
|
10
10
|
})(TypeIcons || (TypeIcons = {}));
|
|
11
|
-
export const Alert = ({ className, onClose, icon, title, children, classModifier = "error", }) => {
|
|
11
|
+
export const Alert = ({ className, onClose, icon, title, children, classModifier = "error", ariaLabel = "close", }) => {
|
|
12
12
|
const componentClassName = getComponentClassName(className, classModifier, "af-alert");
|
|
13
|
-
return (_jsxs("div", { className: componentClassName, role: "alert", children: [_jsxs("div", { className: "af-alert__title", children: [_jsx("div", { className: "af-alert__title-icon", children: _jsx("i", { className: icon || TypeIcons[classModifier] }) }), _jsx("div", { className: "af-alert__title-text", children: title }), onClose && (_jsx("button", { type: "button", className: "af-alert__title-icon-close", onClick: onClose, "aria-label":
|
|
13
|
+
return (_jsxs("div", { className: componentClassName, role: "alert", children: [_jsxs("div", { className: "af-alert__title", children: [_jsx("div", { className: "af-alert__title-icon", children: _jsx("i", { role: "presentation", className: icon || TypeIcons[classModifier] }) }), _jsx("div", { className: "af-alert__title-text", children: title }), onClose && (_jsx("button", { type: "button", className: "af-alert__title-icon-close", onClick: onClose, "aria-label": ariaLabel, children: _jsx("i", { className: "glyphicon glyphicon-close" }) }))] }), children && (_jsxs("div", { className: "af-alert__content", children: [_jsx("div", { className: "af-alert__content-left" }), _jsx("div", { className: "af-alert__content-right", children: children })] }))] }));
|
|
14
14
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
|
-
import { LegacyField, useOptionsWithId } from "../core";
|
|
2
|
+
import { forwardRef, useId } from "react";
|
|
3
|
+
import { LegacyField, MessageTypes, useOptionsWithId } from "../core";
|
|
4
4
|
import { Checkbox } from "./Checkbox";
|
|
5
5
|
import { CheckboxModes } from "./CheckboxModes";
|
|
6
|
+
import { useAriaInvalid } from "../core/useAriaInvalid";
|
|
6
7
|
const CheckboxInput = forwardRef(({ mode, messageType, message, classModifier, options, classNameContainerLabel, classNameContainerInput, label, isVisible, className, forceDisplayMessage, required, ...checkboxProps }, inputRef) => {
|
|
7
8
|
let rowModifier = classModifier;
|
|
8
9
|
if (mode === CheckboxModes.classic) {
|
|
@@ -11,8 +12,12 @@ const CheckboxInput = forwardRef(({ mode, messageType, message, classModifier, o
|
|
|
11
12
|
if (required) {
|
|
12
13
|
rowModifier += " required";
|
|
13
14
|
}
|
|
15
|
+
const errorUseId = useId();
|
|
14
16
|
const newOptions = useOptionsWithId(options);
|
|
15
|
-
|
|
17
|
+
const isInvalid = useAriaInvalid(message, forceDisplayMessage, messageType);
|
|
18
|
+
return (_jsx(LegacyField, { label: label, id: newOptions[0].id, message: message, messageType: messageType, isVisible: isVisible, forceDisplayMessage: forceDisplayMessage, className: className, classModifier: rowModifier, classNameContainerLabel: classNameContainerLabel, classNameContainerInput: classNameContainerInput, errorId: errorUseId, children: _jsx(Checkbox, { mode: mode, options: newOptions, classModifier: message && messageType === MessageTypes.error && forceDisplayMessage
|
|
19
|
+
? `${classModifier} error`
|
|
20
|
+
: classModifier, ref: inputRef, "aria-describedby": errorUseId, "aria-invalid": isInvalid, ...checkboxProps }) }));
|
|
16
21
|
});
|
|
17
22
|
CheckboxInput.displayName = "CheckboxInput";
|
|
18
23
|
export { CheckboxInput };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import "@axa-fr/design-system-slash-css/dist/Form/Choice/Choice.scss";
|
|
2
2
|
import { type ComponentProps } from "react";
|
|
3
3
|
import { Radio } from "../Radio";
|
|
4
|
-
import type
|
|
4
|
+
import { type Option } from "../core";
|
|
5
5
|
type Props = Omit<ComponentProps<typeof Radio>, "options"> & {
|
|
6
6
|
id: string;
|
|
7
|
+
name?: string;
|
|
7
8
|
options?: Array<Omit<Option, "value"> & {
|
|
8
9
|
value: boolean;
|
|
9
10
|
}>;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import "@axa-fr/design-system-slash-css/dist/Form/Choice/Choice.scss";
|
|
3
|
-
import { forwardRef } from "react";
|
|
3
|
+
import { forwardRef, useId } from "react";
|
|
4
4
|
import { Radio } from "../Radio";
|
|
5
|
+
import { useOptionsWithId } from "../core";
|
|
5
6
|
const defaultOptions = [
|
|
6
|
-
{ label: "Oui", value: true
|
|
7
|
-
{ label: "Non", value: false
|
|
7
|
+
{ label: "Oui", value: true },
|
|
8
|
+
{ label: "Non", value: false },
|
|
8
9
|
];
|
|
9
|
-
const Choice = forwardRef(({ children, value, options = defaultOptions, ...otherProps }, inputRef) => {
|
|
10
|
-
const choiceOptions = options.map((
|
|
11
|
-
...
|
|
12
|
-
value: `${
|
|
13
|
-
}));
|
|
14
|
-
|
|
10
|
+
const Choice = forwardRef(({ children, value, options = defaultOptions, name, ...otherProps }, inputRef) => {
|
|
11
|
+
const choiceOptions = useOptionsWithId(options.map((o) => ({
|
|
12
|
+
...o,
|
|
13
|
+
value: `${o.value}`,
|
|
14
|
+
})));
|
|
15
|
+
const generatedId = useId();
|
|
16
|
+
return (_jsx(Radio, { ...otherProps, ref: inputRef, name: name ?? `choice_${generatedId}`, value: value?.toString(), options: choiceOptions, children: children }));
|
|
15
17
|
});
|
|
16
18
|
Choice.displayName = "Choice";
|
|
17
19
|
export { Choice };
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
2
|
+
import { forwardRef, useId } from "react";
|
|
3
3
|
import { LegacyField, useInputClassModifier, useOptionsWithId } from "../core";
|
|
4
4
|
import { Choice } from "./Choice";
|
|
5
|
+
import { useAriaInvalid } from "../core/useAriaInvalid";
|
|
5
6
|
const defaultOptions = [
|
|
6
|
-
{ label: "Oui", value: true
|
|
7
|
-
{ label: "Non", value: false
|
|
7
|
+
{ label: "Oui", value: true },
|
|
8
|
+
{ label: "Non", value: false },
|
|
8
9
|
];
|
|
9
|
-
const ChoiceInput = forwardRef(({ id, messageType, message, className, classModifier, isVisible, classNameContainerLabel, classNameContainerInput, label, forceDisplayMessage, options = defaultOptions, disabled, required, ...otherProps }, inputRef) => {
|
|
10
|
-
const
|
|
10
|
+
const ChoiceInput = forwardRef(({ id, name, messageType, message, className, classModifier, isVisible, classNameContainerLabel, classNameContainerInput, label, forceDisplayMessage, options = defaultOptions, disabled, required, ...otherProps }, inputRef) => {
|
|
11
|
+
const errorUseId = useId();
|
|
12
|
+
const newOptions = useOptionsWithId(options.map((o) => ({
|
|
13
|
+
...o,
|
|
14
|
+
value: `${o.value}`,
|
|
15
|
+
})));
|
|
11
16
|
const { inputClassModifier, inputFieldClassModifier } = useInputClassModifier(classModifier ?? "", disabled ?? false, false, required);
|
|
12
17
|
const firstId = newOptions?.[0]?.id ?? "";
|
|
13
18
|
const choiceOptions = newOptions.map((o) => ({
|
|
14
19
|
...o,
|
|
15
20
|
value: o.value === "true",
|
|
16
21
|
}));
|
|
17
|
-
|
|
22
|
+
const isInvalid = useAriaInvalid(message, forceDisplayMessage, messageType);
|
|
23
|
+
return (_jsx(LegacyField, { label: label, id: firstId, message: message, messageType: messageType, isVisible: isVisible, forceDisplayMessage: forceDisplayMessage, className: className, classModifier: inputFieldClassModifier, classNameContainerLabel: classNameContainerLabel, classNameContainerInput: classNameContainerInput, errorId: errorUseId, children: _jsx(Choice, { ...otherProps, id: id, name: name, ref: inputRef, classModifier: inputClassModifier, options: options ? choiceOptions : undefined, required: required, disabled: disabled, "aria-describedby": errorUseId, "aria-invalid": isInvalid }) }));
|
|
18
24
|
});
|
|
19
25
|
ChoiceInput.displayName = "ChoiceInput";
|
|
20
26
|
export { ChoiceInput };
|
|
@@ -1,10 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
declare const DateInput: import("react").ForwardRefExoticComponent<Omit<Omit<Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "value"> & {
|
|
3
|
+
classModifier?: string;
|
|
4
|
+
defaultValue?: Date | string;
|
|
5
|
+
value?: Date | string;
|
|
6
|
+
}, "ref"> & import("react").RefAttributes<HTMLInputElement>, "ref">, "placeholderText"> & Omit<{
|
|
7
|
+
message?: string;
|
|
8
|
+
messageType?: import("../core").MessageTypes;
|
|
9
|
+
} & {
|
|
10
|
+
className?: string;
|
|
11
|
+
classModifier?: string;
|
|
12
|
+
forceDisplayMessage?: boolean;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
setStateMemoryFn?: typeof import("../core/FieldForm").setStateMemory;
|
|
15
|
+
onChangeByStateFn?: typeof import("../core/FieldForm").onChangeByState;
|
|
16
|
+
setStateOnBlurFn?: typeof import("../core/FieldForm").setStateOnBlur;
|
|
17
|
+
setStateOnFocusFn?: typeof import("../core/FieldForm").setStateOnFocus;
|
|
18
|
+
initialState?: {
|
|
19
|
+
hasLostFocusOnce: boolean;
|
|
20
|
+
hasFocus: boolean;
|
|
21
|
+
hasChange: boolean;
|
|
22
|
+
memory: {
|
|
23
|
+
message?: string;
|
|
24
|
+
messageType?: import("../core").MessageTypes;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}, "children"> & {
|
|
28
|
+
label: ReactNode;
|
|
29
|
+
children?: ReactNode;
|
|
30
|
+
id?: string;
|
|
31
|
+
classModifier?: string;
|
|
32
|
+
classNameContainerLabel?: string;
|
|
33
|
+
classNameContainerInput?: string;
|
|
34
|
+
isVisible?: boolean;
|
|
35
|
+
roleContainer?: string;
|
|
36
|
+
ariaLabelContainer?: string;
|
|
37
|
+
isLabelContainerLinkedToInput?: boolean;
|
|
38
|
+
errorId?: string;
|
|
39
|
+
} & {
|
|
5
40
|
placeholder?: string;
|
|
6
41
|
helpMessage?: ReactNode;
|
|
7
42
|
children?: ReactNode;
|
|
8
|
-
}
|
|
9
|
-
declare const DateInput: ({ classModifier, message, children, helpMessage, id, classNameContainerLabel, classNameContainerInput, label, messageType, isVisible, forceDisplayMessage, className, disabled, required, ...otherProps }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
10
44
|
export { DateInput };
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useId } from "react";
|
|
2
|
+
import { forwardRef, useId } from "react";
|
|
3
3
|
import { FieldInput, HelpMessage, LegacyField, useInputClassModifier, } from "../core";
|
|
4
4
|
import { Date } from "./Date";
|
|
5
|
-
|
|
5
|
+
import { useAriaInvalid } from "../core/useAriaInvalid";
|
|
6
|
+
const DateInput = forwardRef(({ classModifier = "", message, children, helpMessage, id, classNameContainerLabel, classNameContainerInput, label, messageType, isVisible, forceDisplayMessage, className, disabled = false, required, ...otherProps }, ref) => {
|
|
6
7
|
const inputUseId = useId();
|
|
8
|
+
const errorUseId = useId();
|
|
7
9
|
const inputId = id ?? inputUseId;
|
|
8
10
|
const { inputClassModifier, inputFieldClassModifier } = useInputClassModifier(classModifier, disabled, Boolean(children), required);
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
+
const isInvalid = useAriaInvalid(message, forceDisplayMessage, messageType);
|
|
12
|
+
return (_jsxs(LegacyField, { label: label, id: inputId, message: message, messageType: messageType, isVisible: isVisible, forceDisplayMessage: forceDisplayMessage, className: className, classModifier: inputFieldClassModifier, classNameContainerLabel: classNameContainerLabel, classNameContainerInput: classNameContainerInput, errorId: errorUseId, children: [_jsxs(FieldInput, { className: "af-form__date", classModifier: inputFieldClassModifier, children: [_jsx(Date, { id: inputId, classModifier: inputClassModifier, disabled: disabled, required: required, ref: ref, "aria-describedby": errorUseId, "aria-invalid": isInvalid, ...otherProps }), children] }), _jsx(HelpMessage, { message: helpMessage, isVisible: !message })] }));
|
|
13
|
+
});
|
|
14
|
+
DateInput.displayName = "DateInput";
|
|
11
15
|
export { DateInput };
|
|
@@ -4,6 +4,7 @@ import { useId } from "react";
|
|
|
4
4
|
import { FieldInput, HelpMessage, LegacyField, useInputClassModifier, } from "../core";
|
|
5
5
|
import { File } from "./File";
|
|
6
6
|
import { FileTable } from "./FileTable";
|
|
7
|
+
import { useAriaInvalid } from "../core/useAriaInvalid";
|
|
7
8
|
const FileInput = ({ values = [], name = "", onChange, classModifier = "", message, children, helpMessage, id = "", forceDisplayMessage, messageType, classNameContainerLabel, classNameContainerInput, label, isVisible, className, errors, fileLabel, disabled = false, required, ...otherFileProps }) => {
|
|
8
9
|
const onDeleteClick = (selectedId, selectInputId) => {
|
|
9
10
|
const newValues = values.filter((element) => element.id !== selectedId);
|
|
@@ -15,9 +16,11 @@ const FileInput = ({ values = [], name = "", onChange, classModifier = "", messa
|
|
|
15
16
|
});
|
|
16
17
|
};
|
|
17
18
|
const inputUseId = useId();
|
|
19
|
+
const errorUseId = useId();
|
|
18
20
|
const inputId = id ?? inputUseId;
|
|
19
21
|
const { inputClassModifier, inputFieldClassModifier } = useInputClassModifier(classModifier, disabled, Boolean(children), required);
|
|
20
22
|
const rowModifier = `${inputFieldClassModifier} label-top`;
|
|
21
|
-
|
|
23
|
+
const isInvalid = useAriaInvalid(message, forceDisplayMessage, messageType);
|
|
24
|
+
return (_jsxs(LegacyField, { label: label, id: inputId, message: message, messageType: messageType, isVisible: isVisible, forceDisplayMessage: forceDisplayMessage, className: className, classModifier: rowModifier, classNameContainerLabel: classNameContainerLabel, classNameContainerInput: classNameContainerInput, errorId: errorUseId, children: [_jsxs(FieldInput, { className: "af-form__file", classModifier: inputFieldClassModifier, children: [_jsx(File, { id: inputId, name: name, onChange: onChange, disabled: disabled, classModifier: inputClassModifier, label: fileLabel, required: required || classModifier?.includes("required"), "aria-describedby": errorUseId, "aria-invalid": isInvalid, ...otherFileProps }), children] }), _jsx(HelpMessage, { message: helpMessage, isVisible: !message }), _jsx(FileTable, { errors: errors, values: values, onClick: (selectedId) => onDeleteClick(selectedId, inputId), classModifier: classModifier })] }));
|
|
22
25
|
};
|
|
23
26
|
export { FileInput };
|
|
@@ -3,10 +3,13 @@ import "@axa-fr/design-system-slash-css/dist/Form/MultiSelect/MultiSelect.scss";
|
|
|
3
3
|
import { useId } from "react";
|
|
4
4
|
import { FieldInput, HelpMessage, LegacyField, useInputClassModifier, } from "../core";
|
|
5
5
|
import { MultiSelect } from "./MultiSelect";
|
|
6
|
+
import { useAriaInvalid } from "../core/useAriaInvalid";
|
|
6
7
|
const MultiSelectInput = ({ classModifier, message, children, helpMessage, id, disabled, classNameContainerLabel, classNameContainerInput, label, messageType, isVisible, forceDisplayMessage, className, required, ...multiSelectProps }) => {
|
|
7
8
|
const { inputFieldClassModifier } = useInputClassModifier(classModifier ?? "", disabled ?? false, Boolean(children), required);
|
|
8
9
|
const generatedId = useId();
|
|
10
|
+
const errorUseId = useId();
|
|
9
11
|
const inputId = id || generatedId;
|
|
10
|
-
|
|
12
|
+
const isInvalid = useAriaInvalid(message, forceDisplayMessage, messageType);
|
|
13
|
+
return (_jsxs(LegacyField, { label: label, id: inputId, message: message, messageType: messageType, isVisible: isVisible, forceDisplayMessage: forceDisplayMessage, className: className, classModifier: inputFieldClassModifier, classNameContainerLabel: classNameContainerLabel, classNameContainerInput: classNameContainerInput, errorId: errorUseId, children: [_jsxs(FieldInput, { className: "af-form__select", classModifier: inputFieldClassModifier, children: [_jsx(MultiSelect, { inputId: inputId, disabled: disabled, required: required, "aria-invalid": isInvalid, "aria-errormessage": errorUseId, ...multiSelectProps }), children] }), _jsx(HelpMessage, { message: helpMessage, isVisible: !message })] }));
|
|
11
14
|
};
|
|
12
15
|
export { MultiSelectInput };
|
|
@@ -5,9 +5,12 @@ import "@axa-fr/design-system-slash-css/dist/Form/core/FormCore.scss";
|
|
|
5
5
|
import { useId, } from "react";
|
|
6
6
|
import { FieldInput, HelpMessage, LegacyField, useInputClassModifier, } from "../core";
|
|
7
7
|
import { Number } from "./Number";
|
|
8
|
+
import { useAriaInvalid } from "../core/useAriaInvalid";
|
|
8
9
|
export const NumberInput = ({ message, children, helpMessage, id, label, classNameContainerLabel, classNameContainerInput, forceDisplayMessage, messageType, isVisible, className, disabled = false, classModifier = "", required, ...otherProps }) => {
|
|
9
10
|
const inputUseId = useId();
|
|
11
|
+
const errorUseId = useId();
|
|
10
12
|
const inputId = id ?? inputUseId;
|
|
11
13
|
const { inputClassModifier, inputFieldClassModifier } = useInputClassModifier(classModifier, disabled, Boolean(children), required);
|
|
12
|
-
|
|
14
|
+
const isInvalid = useAriaInvalid(message, forceDisplayMessage, messageType);
|
|
15
|
+
return (_jsxs(LegacyField, { label: label, id: inputId, message: message, messageType: messageType, isVisible: isVisible, forceDisplayMessage: forceDisplayMessage, className: className, classModifier: inputFieldClassModifier, classNameContainerLabel: classNameContainerLabel, classNameContainerInput: classNameContainerInput, errorId: errorUseId, children: [_jsxs(FieldInput, { className: "af-form__text", classModifier: inputFieldClassModifier, children: [_jsx(Number, { id: inputId, classModifier: inputClassModifier, disabled: disabled, "aria-describedby": errorUseId, "aria-invalid": isInvalid, ...otherProps }), children] }), _jsx(HelpMessage, { message: helpMessage, isVisible: !message })] }));
|
|
13
16
|
};
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useId, useState } from "react";
|
|
3
3
|
import { FieldInput, HelpMessage, LegacyField, useInputClassModifier, } from "../core";
|
|
4
4
|
import { Pass } from "./Pass";
|
|
5
|
+
import { useAriaInvalid } from "../core/useAriaInvalid";
|
|
5
6
|
const strengthList = {
|
|
6
7
|
0: "bad",
|
|
7
8
|
1: "okay",
|
|
@@ -13,7 +14,8 @@ const calculateStrength = (score) => {
|
|
|
13
14
|
if (score === null || score === undefined) {
|
|
14
15
|
return null;
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
const scoreToNumber = Number(score);
|
|
18
|
+
let strength = Number.isNaN(scoreToNumber) ? 0 : scoreToNumber;
|
|
17
19
|
if (strength > 4) {
|
|
18
20
|
strength = 4;
|
|
19
21
|
}
|
|
@@ -27,8 +29,10 @@ const PassInput = ({ message, children, helpMessage, id, disabled = false, label
|
|
|
27
29
|
const classModifierStrength = [classModifier ?? "", strength ?? ""].join(" ");
|
|
28
30
|
const [type, setType] = useState("password");
|
|
29
31
|
const inputId = useId();
|
|
32
|
+
const errorUseId = useId();
|
|
30
33
|
const finalId = id ?? inputId;
|
|
31
34
|
const { inputClassModifier, inputFieldClassModifier } = useInputClassModifier(classModifierStrength, disabled, Boolean(children), required);
|
|
32
|
-
|
|
35
|
+
const isInvalid = useAriaInvalid(message, forceDisplayMessage, messageType);
|
|
36
|
+
return (_jsx(LegacyField, { label: label, message: message, messageType: messageType, isVisible: isVisible, forceDisplayMessage: forceDisplayMessage, className: className, id: finalId, classModifier: `${classModifierStrength} ${inputFieldClassModifier}`, classNameContainerLabel: classNameContainerLabel, classNameContainerInput: classNameContainerInput, errorId: errorUseId, children: _jsxs(FieldInput, { className: "af-form__pass-container", classModifier: inputFieldClassModifier, children: [_jsx(Pass, { ...passProps, type: type, id: inputId, disabled: disabled, classModifier: inputClassModifier, "aria-describedby": errorUseId, "aria-invalid": isInvalid, onToggleType: () => setType(type === "password" ? "text" : "password") }), children, _jsx(HelpMessage, { message: helpMessage, isVisible: !message })] }) }));
|
|
33
37
|
};
|
|
34
38
|
export { PassInput };
|
|
@@ -31,6 +31,7 @@ declare const RadioInput: import("react").ForwardRefExoticComponent<Omit<{
|
|
|
31
31
|
roleContainer?: string;
|
|
32
32
|
ariaLabelContainer?: string;
|
|
33
33
|
isLabelContainerLinkedToInput?: boolean;
|
|
34
|
+
errorId?: string;
|
|
34
35
|
} & Omit<Omit<Omit<Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "type" | "checked"> & {
|
|
35
36
|
classModifier?: string;
|
|
36
37
|
optionClassName?: string;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
2
|
+
import { forwardRef, useId } from "react";
|
|
3
3
|
import { LegacyField, getFirstId, useInputClassModifier, useOptionsWithId, } from "../core";
|
|
4
4
|
import { Radio, RadioModes } from "./Radio";
|
|
5
|
+
import { useAriaInvalid } from "../core/useAriaInvalid";
|
|
5
6
|
const RadioInput = forwardRef(({ mode, messageType, message, className, classModifier = "", isVisible, options, classNameContainerLabel, classNameContainerInput, label, forceDisplayMessage, children, required, disabled = false, ariaLabelContainer, ...radioProps }, inputRef) => {
|
|
6
7
|
const rowModifier = `${classModifier ?? ""}${mode === RadioModes.classic ? " label-top " : ""}`;
|
|
7
8
|
const newOptions = useOptionsWithId(options);
|
|
8
9
|
const firstId = getFirstId(newOptions);
|
|
10
|
+
const errorUseId = useId();
|
|
9
11
|
const { inputClassModifier, inputFieldClassModifier } = useInputClassModifier(classModifier, disabled, Boolean(children), required);
|
|
10
|
-
|
|
12
|
+
const isInvalid = useAriaInvalid(message, forceDisplayMessage, messageType);
|
|
13
|
+
return (_jsxs(LegacyField, { label: label, id: firstId, message: message, messageType: messageType, isVisible: isVisible, forceDisplayMessage: forceDisplayMessage, className: className, classModifier: rowModifier + inputFieldClassModifier, classNameContainerLabel: classNameContainerLabel, classNameContainerInput: classNameContainerInput, roleContainer: "radiogroup", ariaLabelContainer: ariaLabelContainer ?? label?.toString(), isLabelContainerLinkedToInput: false, errorId: errorUseId, children: [_jsx(Radio, { options: newOptions, mode: mode, classModifier: inputClassModifier, ref: inputRef, disabled: disabled, required: required || classModifier?.includes("required"), "aria-describedby": errorUseId, "aria-invalid": isInvalid, ...radioProps }), children] }));
|
|
11
14
|
});
|
|
12
15
|
RadioInput.displayName = "EnhancedInputRadio";
|
|
13
16
|
export { RadioInput };
|