@axa-fr/design-system-slash-react 2.0.1 → 2.0.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.
|
@@ -3,7 +3,7 @@ import { forwardRef } from "react";
|
|
|
3
3
|
import { Field } from "../core";
|
|
4
4
|
import { Date } from "./Date";
|
|
5
5
|
const DateInput = forwardRef(({ children, ...otherProps }, inputRef) => {
|
|
6
|
-
return (_jsx(Field, { ...otherProps, renderInput: ({ id, classModifier, ariaInvalid, errorId }) => (_jsxs(_Fragment, { children: [_jsx(Date, { id: id, classModifier: classModifier, ref: inputRef, "aria-describedby": errorId, "aria-invalid": ariaInvalid, ...
|
|
6
|
+
return (_jsx(Field, { ...otherProps, renderInput: ({ id, classModifier, ariaInvalid, errorId, ...props }) => (_jsxs(_Fragment, { children: [_jsx(Date, { id: id, classModifier: classModifier, ref: inputRef, "aria-describedby": errorId, "aria-invalid": ariaInvalid, ...props }), children] })) }));
|
|
7
7
|
});
|
|
8
8
|
DateInput.displayName = "DateInput";
|
|
9
9
|
export { DateInput };
|
|
@@ -26,6 +26,6 @@ const calculateStrength = (score) => {
|
|
|
26
26
|
const PassInput = ({ children, score, classModifier, disabled, ...props }) => {
|
|
27
27
|
const strength = calculateStrength(score);
|
|
28
28
|
const [type, setType] = useState("password");
|
|
29
|
-
return (_jsx(Field, { ...props, classModifier: classModifier, renderInput: ({ id, classModifier: modifier, ariaInvalid, errorId }) => (_jsxs(_Fragment, { children: [_jsx(Pass, { ...
|
|
29
|
+
return (_jsx(Field, { ...props, classModifier: classModifier, renderInput: ({ id, classModifier: modifier, ariaInvalid, errorId, ...inputProps }) => (_jsxs(_Fragment, { children: [_jsx(Pass, { ...inputProps, type: type, id: id, disabled: disabled, classModifier: `${modifier} ${strength}`, "aria-describedby": errorId, "aria-invalid": ariaInvalid, onToggleType: () => setType(type === "password" ? "text" : "password") }), children] })) }));
|
|
30
30
|
};
|
|
31
31
|
export { PassInput };
|
|
@@ -3,7 +3,7 @@ import { forwardRef } from "react";
|
|
|
3
3
|
import { Field } from "../core";
|
|
4
4
|
import { Text } from "./Text";
|
|
5
5
|
const TextInput = forwardRef(({ children, ...props }, inputRef) => {
|
|
6
|
-
return (_jsx(Field, { ...props, renderInput: ({ id, classModifier, ariaInvalid, errorId }) => (_jsxs(_Fragment, { children: [_jsx(Text, { id: id, classModifier: classModifier, ref: inputRef, "aria-describedby": errorId, "aria-invalid": ariaInvalid, ...
|
|
6
|
+
return (_jsx(Field, { ...props, renderInput: ({ id, classModifier, ariaInvalid, errorId, ...textProps }) => (_jsxs(_Fragment, { children: [JSON.stringify({ id }), _jsx(Text, { id: id, classModifier: classModifier, ref: inputRef, "aria-describedby": errorId, "aria-invalid": ariaInvalid, ...textProps }), children] })) }));
|
|
7
7
|
});
|
|
8
8
|
TextInput.displayName = "TextInput";
|
|
9
9
|
export { TextInput };
|
package/dist/Form/core/Field.js
CHANGED
|
@@ -4,9 +4,12 @@ import { useId } from "react";
|
|
|
4
4
|
import { FieldError, FormClassManager, HelpMessage, useInputClassModifier, } from ".";
|
|
5
5
|
import { getComponentClassName } from "../../utilities";
|
|
6
6
|
import { useAriaInvalid } from "./useAriaInvalid";
|
|
7
|
+
function isIdDefined(id) {
|
|
8
|
+
return typeof id === "string" && id.length > 0;
|
|
9
|
+
}
|
|
7
10
|
export const Field = ({ classNameContainerInput = "col-md-10", classNameContainerLabel = "col-md-2", className, label, forceDisplayMessage, message, messageType, required, classModifier = "", disabled = false, helpMessage, id, isVisible = true, roleContainer, ariaLabelContainer, isLabelContainerLinkedToInput = true, labelPosition = "center", classNameSuffix = "text", renderInput, appendChildren, ...otherProps }) => {
|
|
8
11
|
const inputUseId = useId();
|
|
9
|
-
const inputId = id
|
|
12
|
+
const inputId = isIdDefined(id) ? id : inputUseId;
|
|
10
13
|
const actualRequired = required || classModifier.includes("required");
|
|
11
14
|
const isInvalid = useAriaInvalid(message, forceDisplayMessage, messageType);
|
|
12
15
|
const errorId = forceDisplayMessage || helpMessage ? `${inputId}-description` : undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/design-system-slash-react",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://github.com/AxaFrance/design-system#readme",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@axa-fr/design-system-slash-css": "2.0.
|
|
50
|
+
"@axa-fr/design-system-slash-css": "2.0.2",
|
|
51
51
|
"@material-symbols/svg-400": ">= 0.19.0",
|
|
52
52
|
"@material-symbols/svg-700": ">= 0.19.0",
|
|
53
53
|
"react": ">= 18"
|