@axa-fr/design-system-slash-react 1.2.1-alpha.72 → 1.2.1-alpha.74
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/Form/Date/DateInput.d.ts +1 -1
- package/dist/Form/Date/DateInput.js +3 -3
- package/dist/Form/File/FileInput.d.ts +3 -3
- package/dist/Form/File/FileInput.js +2 -2
- package/dist/Form/Number/NumberInput.d.ts +2 -2
- package/dist/Form/Number/NumberInput.js +3 -3
- package/dist/Form/Pass/PassInput.d.ts +3 -3
- package/dist/Form/Pass/PassInput.js +3 -3
- package/dist/Form/Radio/RadioCardGroup.d.ts +1 -1
- package/dist/Form/Radio/RadioCardGroup.js +3 -3
- package/dist/Form/Radio/RadioInput.d.ts +1 -1
- package/dist/Form/Radio/RadioInput.js +3 -3
- package/dist/Form/Select/SelectInput.d.ts +58 -3
- package/dist/Form/Slider/SliderInput.d.ts +2 -2
- package/dist/Form/Slider/SliderInput.js +3 -3
- package/dist/Form/Text/TextInput.d.ts +1 -1
- package/dist/Form/Text/TextInput.js +3 -3
- package/dist/Form/Textarea/TextareaInput.d.ts +1 -1
- package/dist/Form/Textarea/TextareaInput.js +3 -3
- package/dist/Form/core/Field.d.ts +7 -3
- package/dist/Form/core/Field.js +2 -3
- package/package.json +2 -2
|
@@ -3,6 +3,6 @@ import { ConsumerFieldProps } from "../core";
|
|
|
3
3
|
import { Date } from "./Date";
|
|
4
4
|
type Props = Omit<ConsumerFieldProps & ComponentProps<typeof Date> & {
|
|
5
5
|
helpMessage?: ReactNode;
|
|
6
|
-
}, "renderInput">;
|
|
6
|
+
}, "renderInput" | "children">;
|
|
7
7
|
declare const DateInput: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
8
8
|
export { DateInput };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { Field } from "../core";
|
|
4
4
|
import { Date } from "./Date";
|
|
5
|
-
const DateInput = forwardRef(({
|
|
6
|
-
return (_jsx(Field, { ...otherProps, renderInput: ({ id, classModifier, ariaInvalid, errorId }) => (_jsx(Date, { id: id, classModifier: classModifier, ref: inputRef, "aria-describedby": errorId, "aria-invalid": ariaInvalid, ...otherProps })
|
|
5
|
+
const DateInput = forwardRef(({ rightElement, ...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, ...otherProps }), rightElement] })) }));
|
|
7
7
|
});
|
|
8
8
|
DateInput.displayName = "DateInput";
|
|
9
9
|
export { DateInput };
|
|
@@ -5,9 +5,9 @@ import { File } from "./File";
|
|
|
5
5
|
import { FileTable } from "./FileTable";
|
|
6
6
|
type FileProps = ComponentPropsWithoutRef<typeof File>;
|
|
7
7
|
type FileTableProps = ComponentPropsWithoutRef<typeof FileTable>;
|
|
8
|
-
type Props = ConsumerFieldProps & FileProps & Pick<FileTableProps, "values" | "errors"> & {
|
|
8
|
+
type Props = Omit<ConsumerFieldProps & FileProps & Pick<FileTableProps, "values" | "errors"> & {
|
|
9
9
|
fileLabel?: string;
|
|
10
10
|
helpMessage?: ReactNode;
|
|
11
|
-
}
|
|
12
|
-
declare const FileInput: ({ values, id, name, onChange,
|
|
11
|
+
}, "children">;
|
|
12
|
+
declare const FileInput: ({ values, id, name, onChange, rightElement, label, errors, fileLabel, classModifier, ...otherFileProps }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
export { FileInput };
|
|
@@ -4,7 +4,7 @@ import { useId } from "react";
|
|
|
4
4
|
import { Field } from "../core";
|
|
5
5
|
import { File } from "./File";
|
|
6
6
|
import { FileTable } from "./FileTable";
|
|
7
|
-
const FileInput = ({ values = [], id, name = "", onChange,
|
|
7
|
+
const FileInput = ({ values = [], id, name = "", onChange, rightElement, label, errors, fileLabel, classModifier, ...otherFileProps }) => {
|
|
8
8
|
const onDeleteClick = (selectedId, selectInputId) => {
|
|
9
9
|
const newValues = values.filter((element) => element.id !== selectedId);
|
|
10
10
|
onChange({
|
|
@@ -16,6 +16,6 @@ const FileInput = ({ values = [], id, name = "", onChange, children, label, erro
|
|
|
16
16
|
};
|
|
17
17
|
const generatedId = useId();
|
|
18
18
|
const actualId = id ?? generatedId;
|
|
19
|
-
return (_jsx(Field, { label: label, labelPosition: "top", id: actualId, classNameSuffix: "file", ...otherFileProps, renderInput: ({ classModifier: inputClassModifiers, id: inputId, ariaInvalid, errorId, ...inputProps }) => (_jsxs(_Fragment, { children: [_jsx(File, { id: inputId, name: name, onChange: onChange, classModifier: inputClassModifiers, label: fileLabel, "aria-describedby": errorId, "aria-invalid": ariaInvalid, ...inputProps }),
|
|
19
|
+
return (_jsx(Field, { label: label, labelPosition: "top", id: actualId, classNameSuffix: "file", ...otherFileProps, renderInput: ({ classModifier: inputClassModifiers, id: inputId, ariaInvalid, errorId, ...inputProps }) => (_jsxs(_Fragment, { children: [_jsx(File, { id: inputId, name: name, onChange: onChange, classModifier: inputClassModifiers, label: fileLabel, "aria-describedby": errorId, "aria-invalid": ariaInvalid, ...inputProps }), rightElement] })), appendChildren: _jsx(FileTable, { errors: errors, values: values, onClick: (selectedId) => onDeleteClick(selectedId, actualId), classModifier: classModifier }) }));
|
|
20
20
|
};
|
|
21
21
|
export { FileInput };
|
|
@@ -4,6 +4,6 @@ import "@axa-fr/design-system-slash-css/dist/Form/core/FormCore.scss";
|
|
|
4
4
|
import { ComponentPropsWithRef } from "react";
|
|
5
5
|
import { type ConsumerFieldProps } from "../core";
|
|
6
6
|
import { Number } from "./Number";
|
|
7
|
-
type Props = ConsumerFieldProps & ComponentPropsWithRef<typeof Number>;
|
|
8
|
-
export declare const NumberInput: ({
|
|
7
|
+
type Props = Omit<ConsumerFieldProps & ComponentPropsWithRef<typeof Number>, "children">;
|
|
8
|
+
export declare const NumberInput: ({ rightElement, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import "@axa-fr/design-system-slash-css/dist/common/grid.scss";
|
|
3
3
|
import "@axa-fr/design-system-slash-css/dist/common/reboot.scss";
|
|
4
4
|
import "@axa-fr/design-system-slash-css/dist/Form/core/FormCore.scss";
|
|
5
5
|
import { Field } from "../core";
|
|
6
6
|
import { Number } from "./Number";
|
|
7
|
-
export const NumberInput = ({
|
|
8
|
-
return (_jsx(Field, { ...props, renderInput: ({ id, classModifier, ariaInvalid, errorId, ...inputProps }) => (_jsx(Number, { id: id, classModifier: classModifier, "aria-describedby": errorId, "aria-invalid": ariaInvalid, ...inputProps })
|
|
7
|
+
export const NumberInput = ({ rightElement, ...props }) => {
|
|
8
|
+
return (_jsx(Field, { ...props, renderInput: ({ id, classModifier, ariaInvalid, errorId, ...inputProps }) => (_jsxs(_Fragment, { children: [_jsx(Number, { id: id, classModifier: classModifier, "aria-describedby": errorId, "aria-invalid": ariaInvalid, ...inputProps }), rightElement] })) }));
|
|
9
9
|
};
|
|
@@ -2,9 +2,9 @@ import { ComponentProps, ReactNode } from "react";
|
|
|
2
2
|
import { ConsumerFieldProps } from "../core";
|
|
3
3
|
import { Pass } from "./Pass";
|
|
4
4
|
type PassProps = ComponentProps<typeof Pass>;
|
|
5
|
-
type Props = ConsumerFieldProps &
|
|
5
|
+
type Props = Omit<ConsumerFieldProps & PassProps & {
|
|
6
6
|
helpMessage?: ReactNode;
|
|
7
7
|
score?: string;
|
|
8
|
-
}
|
|
9
|
-
declare const PassInput: ({
|
|
8
|
+
}, "onToggleType" | "type" | "children">;
|
|
9
|
+
declare const PassInput: ({ rightElement, score, classModifier, disabled, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export { PassInput };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { Field } from "../core";
|
|
4
4
|
import { Pass } from "./Pass";
|
|
@@ -23,9 +23,9 @@ const calculateStrength = (score) => {
|
|
|
23
23
|
}
|
|
24
24
|
return strengthList[strength];
|
|
25
25
|
};
|
|
26
|
-
const PassInput = ({
|
|
26
|
+
const PassInput = ({ rightElement, 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 }) => (_jsx(Pass, { ...props, type: type, id: id, disabled: disabled, classModifier: `${modifier} ${strength}`, "aria-describedby": errorId, "aria-invalid": ariaInvalid, onToggleType: () => setType(type === "password" ? "text" : "password") })
|
|
29
|
+
return (_jsx(Field, { ...props, classModifier: classModifier, renderInput: ({ id, classModifier: modifier, ariaInvalid, errorId }) => (_jsxs(_Fragment, { children: [_jsx(Pass, { ...props, type: type, id: id, disabled: disabled, classModifier: `${modifier} ${strength}`, "aria-describedby": errorId, "aria-invalid": ariaInvalid, onToggleType: () => setType(type === "password" ? "text" : "password") }), rightElement] })) }));
|
|
30
30
|
};
|
|
31
31
|
export { PassInput };
|
|
@@ -6,5 +6,5 @@ type Props = ComponentProps<"input"> & {
|
|
|
6
6
|
orientation?: "horizontal" | "vertical";
|
|
7
7
|
error?: boolean;
|
|
8
8
|
};
|
|
9
|
-
export declare const RadioCardGroup: ({ children, options, className, value, orientation, disabled, error, ...otherProps }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const RadioCardGroup: ({ children, options, className, value, name, orientation, disabled, error, ...otherProps }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export {};
|
|
@@ -5,7 +5,7 @@ import classNames from "classnames";
|
|
|
5
5
|
import { Svg } from "../../Svg";
|
|
6
6
|
const DEFAULT_CLASSNAME = "af-card";
|
|
7
7
|
const DEFAULT_CONTAINER_CLASSNAME = "af-form__radio-card-group";
|
|
8
|
-
export const RadioCardGroup = ({ children, options, className, value, orientation = "vertical", disabled = false, error = false, ...otherProps }) => {
|
|
8
|
+
export const RadioCardGroup = ({ children, options, className, value, name, orientation = "vertical", disabled = false, error = false, ...otherProps }) => {
|
|
9
9
|
const idGenerated = useId();
|
|
10
10
|
const radioGroupRef = useRef(null);
|
|
11
11
|
return (_jsxs("div", { ref: radioGroupRef, role: "radiogroup", className: classNames([
|
|
@@ -13,8 +13,8 @@ export const RadioCardGroup = ({ children, options, className, value, orientatio
|
|
|
13
13
|
className,
|
|
14
14
|
orientation === "horizontal" &&
|
|
15
15
|
`${DEFAULT_CONTAINER_CLASSNAME}--horizontal`,
|
|
16
|
-
]), children: [options.map(({ name, icon, label, disabled: optionDisabled, value: optionValue, ...otherOptionProps }) => {
|
|
17
|
-
const newName = name
|
|
16
|
+
]), children: [options.map(({ name: optionName, icon, label, disabled: optionDisabled, value: optionValue, ...otherOptionProps }) => {
|
|
17
|
+
const newName = name || optionName || idGenerated;
|
|
18
18
|
const allClassNames = classNames([
|
|
19
19
|
DEFAULT_CLASSNAME,
|
|
20
20
|
orientation === "horizontal" && `${DEFAULT_CLASSNAME}--horizontal`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef } from "react";
|
|
2
2
|
import { type ConsumerFieldProps } from "../core";
|
|
3
3
|
import { Radio } from "./Radio";
|
|
4
|
-
type RadioInputProps = ConsumerFieldProps & ComponentPropsWithoutRef<typeof Radio>;
|
|
4
|
+
type RadioInputProps = Omit<ConsumerFieldProps & ComponentPropsWithoutRef<typeof Radio>, "children">;
|
|
5
5
|
declare const RadioInput: import("react").ForwardRefExoticComponent<RadioInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
6
6
|
export { RadioInput };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { Field, useOptionsWithId } from "../core";
|
|
4
4
|
import { Radio, RadioModes } from "./Radio";
|
|
5
|
-
const RadioInput = forwardRef(({ label, mode = "default", options, ...props }, inputRef) => {
|
|
5
|
+
const RadioInput = forwardRef(({ label, mode = "default", options, rightElement, ...props }, inputRef) => {
|
|
6
6
|
const labelPosition = mode === RadioModes.classic ? "top" : "center";
|
|
7
7
|
const newOptions = useOptionsWithId(options);
|
|
8
|
-
return (_jsx(Field, { label: label, labelPosition: labelPosition, roleContainer: mode !== "card" ? "radiogroup" : undefined, ...props, renderInput: ({ classModifier, ariaInvalid, errorId, ...radioProps }) => (_jsx(Radio, { options: newOptions, mode: mode, classModifier: classModifier, ref: inputRef, "aria-describedby": errorId, "aria-invalid": ariaInvalid, ...radioProps })) }));
|
|
8
|
+
return (_jsx(Field, { label: label, labelPosition: labelPosition, roleContainer: mode !== "card" ? "radiogroup" : undefined, ...props, renderInput: ({ classModifier, ariaInvalid, errorId, ...radioProps }) => (_jsxs(_Fragment, { children: [_jsx(Radio, { options: newOptions, mode: mode, classModifier: classModifier, ref: inputRef, "aria-describedby": errorId, "aria-invalid": ariaInvalid, ...radioProps }), rightElement] })) }));
|
|
9
9
|
});
|
|
10
10
|
RadioInput.displayName = "EnhancedInputRadio";
|
|
11
11
|
export { RadioInput };
|
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
import { OptionHTMLAttributes } from "react";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
declare const SelectInput: import("react").ForwardRefExoticComponent<(Omit<Omit<{
|
|
3
|
+
label: import("react").ReactNode;
|
|
4
|
+
id?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
classModifier?: string;
|
|
7
|
+
classNameContainerLabel?: string;
|
|
8
|
+
classNameContainerInput?: string;
|
|
9
|
+
isVisible?: boolean;
|
|
10
|
+
roleContainer?: string;
|
|
11
|
+
ariaLabelContainer?: string;
|
|
12
|
+
isLabelContainerLinkedToInput?: boolean;
|
|
13
|
+
forceDisplayMessage?: boolean;
|
|
14
|
+
message?: string;
|
|
15
|
+
messageType?: import("../core").MessageTypes;
|
|
16
|
+
required?: boolean;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
helpMessage?: import("react").ReactNode;
|
|
19
|
+
labelPosition?: "top" | "center";
|
|
20
|
+
classNameSuffix?: string;
|
|
21
|
+
renderInput: (props: {
|
|
22
|
+
id: string;
|
|
23
|
+
classModifier: string;
|
|
24
|
+
errorId?: string;
|
|
25
|
+
ariaInvalid?: boolean;
|
|
26
|
+
} & Record<string, unknown>) => import("react").ReactNode;
|
|
27
|
+
appendChildren?: import("react").ReactNode;
|
|
28
|
+
}, "children" | "renderInput" | "classNameSuffix"> & {
|
|
29
|
+
rightElement?: import("react").ReactNode;
|
|
30
|
+
} & Omit<Omit<{
|
|
4
31
|
suppressHydrationWarning?: boolean | undefined | undefined;
|
|
5
32
|
className?: string | undefined | undefined;
|
|
6
33
|
color?: string | undefined | undefined;
|
|
@@ -301,7 +328,35 @@ declare const SelectInput: import("react").ForwardRefExoticComponent<(Omit<Consu
|
|
|
301
328
|
options: OptionHTMLAttributes<HTMLOptionElement>[];
|
|
302
329
|
} & {
|
|
303
330
|
children?: import("react").ReactNode | undefined;
|
|
304
|
-
}, "ref"> | Omit<
|
|
331
|
+
}, "ref"> | Omit<Omit<{
|
|
332
|
+
label: import("react").ReactNode;
|
|
333
|
+
id?: string;
|
|
334
|
+
className?: string;
|
|
335
|
+
classModifier?: string;
|
|
336
|
+
classNameContainerLabel?: string;
|
|
337
|
+
classNameContainerInput?: string;
|
|
338
|
+
isVisible?: boolean;
|
|
339
|
+
roleContainer?: string;
|
|
340
|
+
ariaLabelContainer?: string;
|
|
341
|
+
isLabelContainerLinkedToInput?: boolean;
|
|
342
|
+
forceDisplayMessage?: boolean;
|
|
343
|
+
message?: string;
|
|
344
|
+
messageType?: import("../core").MessageTypes;
|
|
345
|
+
required?: boolean;
|
|
346
|
+
disabled?: boolean;
|
|
347
|
+
helpMessage?: import("react").ReactNode;
|
|
348
|
+
labelPosition?: "top" | "center";
|
|
349
|
+
classNameSuffix?: string;
|
|
350
|
+
renderInput: (props: {
|
|
351
|
+
id: string;
|
|
352
|
+
classModifier: string;
|
|
353
|
+
errorId?: string;
|
|
354
|
+
ariaInvalid?: boolean;
|
|
355
|
+
} & Record<string, unknown>) => import("react").ReactNode;
|
|
356
|
+
appendChildren?: import("react").ReactNode;
|
|
357
|
+
}, "children" | "renderInput" | "classNameSuffix"> & {
|
|
358
|
+
rightElement?: import("react").ReactNode;
|
|
359
|
+
} & Omit<Omit<Omit<import("react").DetailedHTMLProps<import("react").SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>, "ref"> & {
|
|
305
360
|
options?: OptionHTMLAttributes<HTMLOptionElement>[];
|
|
306
361
|
classModifier?: string;
|
|
307
362
|
} & import("react").RefAttributes<HTMLSelectElement> & {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type ComponentProps } from "react";
|
|
2
2
|
import { ConsumerFieldProps } from "../core";
|
|
3
3
|
import { Slider } from "./Slider";
|
|
4
|
-
type Props = ConsumerFieldProps & ComponentProps<typeof Slider>;
|
|
4
|
+
type Props = Omit<ConsumerFieldProps & ComponentProps<typeof Slider>, "children">;
|
|
5
5
|
/**
|
|
6
6
|
* @deprecated This component is deprecated and will be removed in a future major release.
|
|
7
7
|
*/
|
|
8
|
-
declare const SliderInput: ({
|
|
8
|
+
declare const SliderInput: ({ rightElement, name, options, label, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
export { SliderInput };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Field } from "../core";
|
|
3
3
|
import { Slider } from "./Slider";
|
|
4
4
|
/**
|
|
5
5
|
* @deprecated This component is deprecated and will be removed in a future major release.
|
|
6
6
|
*/
|
|
7
|
-
const SliderInput = ({
|
|
8
|
-
return (_jsx(Field, { label: label, ...props, renderInput: ({ id, classModifier, ...sliderProps }) => (_jsx(Slider, { id: id, classModifier: classModifier, name: name, options: options, ...sliderProps })
|
|
7
|
+
const SliderInput = ({ rightElement, name, options, label, ...props }) => {
|
|
8
|
+
return (_jsx(Field, { label: label, ...props, renderInput: ({ id, classModifier, ...sliderProps }) => (_jsxs(_Fragment, { children: [_jsx(Slider, { id: id, classModifier: classModifier, name: name, options: options, ...sliderProps }), rightElement] })) }));
|
|
9
9
|
};
|
|
10
10
|
export { SliderInput };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
2
|
import { ConsumerFieldProps } from "../core";
|
|
3
3
|
import { Text } from "./Text";
|
|
4
|
-
export type TextInputProps = ConsumerFieldProps & ComponentProps<typeof Text>;
|
|
4
|
+
export type TextInputProps = Omit<ConsumerFieldProps & ComponentProps<typeof Text>, "children">;
|
|
5
5
|
declare const TextInput: import("react").ForwardRefExoticComponent<Omit<TextInputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
6
6
|
export { TextInput };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { Field } from "../core";
|
|
4
4
|
import { Text } from "./Text";
|
|
5
|
-
const TextInput = forwardRef(({
|
|
6
|
-
return (_jsx(Field, { ...props, renderInput: ({ id, classModifier, ariaInvalid, errorId }) => (_jsx(Text, { id: id, classModifier: classModifier, ref: inputRef, "aria-describedby": errorId, "aria-invalid": ariaInvalid, ...props })
|
|
5
|
+
const TextInput = forwardRef(({ rightElement, ...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, ...props }), rightElement] })) }));
|
|
7
7
|
});
|
|
8
8
|
TextInput.displayName = "TextInput";
|
|
9
9
|
export { TextInput };
|
|
@@ -4,6 +4,6 @@ import "@axa-fr/design-system-slash-css/dist/Form/core/FormCore.scss";
|
|
|
4
4
|
import { ComponentProps } from "react";
|
|
5
5
|
import { type ConsumerFieldProps } from "../core";
|
|
6
6
|
import { Textarea } from "./Textarea";
|
|
7
|
-
type Props = ConsumerFieldProps & ComponentProps<typeof Textarea>;
|
|
7
|
+
type Props = Omit<ConsumerFieldProps & ComponentProps<typeof Textarea>, "children">;
|
|
8
8
|
declare const TextareaInput: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
9
9
|
export { TextareaInput };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import "@axa-fr/design-system-slash-css/dist/common/grid.scss";
|
|
3
3
|
import "@axa-fr/design-system-slash-css/dist/common/reboot.scss";
|
|
4
4
|
import "@axa-fr/design-system-slash-css/dist/Form/core/FormCore.scss";
|
|
5
5
|
import { forwardRef } from "react";
|
|
6
6
|
import { Field } from "../core";
|
|
7
7
|
import { Textarea } from "./Textarea";
|
|
8
|
-
const TextareaInput = forwardRef(({ label,
|
|
9
|
-
return (_jsx(Field, { label: label, labelPosition: "top", classNameSuffix: "textarea", ...props, renderInput: ({ id, ariaInvalid, errorId, ...inputProps }) => (_jsx(Textarea, { id: id, ref: inputRef, "aria-describedby": errorId, "aria-invalid": ariaInvalid, ...inputProps })
|
|
8
|
+
const TextareaInput = forwardRef(({ label, rightElement, ...props }, inputRef) => {
|
|
9
|
+
return (_jsx(Field, { label: label, labelPosition: "top", classNameSuffix: "textarea", ...props, renderInput: ({ id, ariaInvalid, errorId, ...inputProps }) => (_jsxs(_Fragment, { children: [_jsx(Textarea, { id: id, ref: inputRef, "aria-describedby": errorId, "aria-invalid": ariaInvalid, ...inputProps }), rightElement] })) }));
|
|
10
10
|
});
|
|
11
11
|
TextareaInput.displayName = "TextareaInput";
|
|
12
12
|
export { TextareaInput };
|
|
@@ -5,7 +5,6 @@ type InputProps = {
|
|
|
5
5
|
* The label of the input element.
|
|
6
6
|
*/
|
|
7
7
|
label: ReactNode;
|
|
8
|
-
children?: ReactNode;
|
|
9
8
|
/**
|
|
10
9
|
* The id of the input element. If not provided, a unique id will be generated.
|
|
11
10
|
*/
|
|
@@ -71,6 +70,11 @@ type InputProps = {
|
|
|
71
70
|
*/
|
|
72
71
|
appendChildren?: ReactNode;
|
|
73
72
|
};
|
|
74
|
-
export type ConsumerFieldProps = Omit<InputProps, "renderInput" | "classNameSuffix"
|
|
75
|
-
|
|
73
|
+
export type ConsumerFieldProps = Omit<InputProps, "renderInput" | "classNameSuffix" | "children"> & {
|
|
74
|
+
/**
|
|
75
|
+
* Element appended right to the input
|
|
76
|
+
*/
|
|
77
|
+
rightElement?: ReactNode;
|
|
78
|
+
};
|
|
79
|
+
export declare const Field: ({ classNameContainerInput, classNameContainerLabel, className, label, forceDisplayMessage, message, messageType, required, classModifier, disabled, helpMessage, id, isVisible, roleContainer, ariaLabelContainer, isLabelContainerLinkedToInput, labelPosition, classNameSuffix, renderInput, appendChildren, ...otherProps }: InputProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
76
80
|
export {};
|
package/dist/Form/core/Field.js
CHANGED
|
@@ -4,13 +4,13 @@ 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
|
-
export const Field = ({ classNameContainerInput = "col-md-10", classNameContainerLabel = "col-md-2", className, label, forceDisplayMessage, message, messageType, required, classModifier = "",
|
|
7
|
+
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
8
|
const inputUseId = useId();
|
|
9
9
|
const inputId = id ?? inputUseId;
|
|
10
10
|
const actualRequired = required || classModifier.includes("required");
|
|
11
11
|
const isInvalid = useAriaInvalid(message, forceDisplayMessage, messageType);
|
|
12
12
|
const errorId = forceDisplayMessage || helpMessage ? `${inputId}-description` : undefined;
|
|
13
|
-
const { inputClassModifier, inputFieldClassModifier } = useInputClassModifier(classModifier, disabled,
|
|
13
|
+
const { inputClassModifier, inputFieldClassModifier } = useInputClassModifier(classModifier, disabled, false, actualRequired);
|
|
14
14
|
const labelId = useId();
|
|
15
15
|
if (!isVisible) {
|
|
16
16
|
return null;
|
|
@@ -33,7 +33,6 @@ export const Field = ({ classNameContainerInput = "col-md-10", classNameContaine
|
|
|
33
33
|
errorId,
|
|
34
34
|
disabled,
|
|
35
35
|
ariaInvalid: isInvalid,
|
|
36
|
-
children,
|
|
37
36
|
...otherProps,
|
|
38
37
|
}) }), forceDisplayMessage ? (_jsx(FieldError, { message: message, messageType: messageType, errorId: errorId })) : (_jsx(HelpMessage, { message: helpMessage, id: errorId })), appendChildren] })] }));
|
|
39
38
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/design-system-slash-react",
|
|
3
|
-
"version": "1.2.1-alpha.
|
|
3
|
+
"version": "1.2.1-alpha.74",
|
|
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": "1.2.1-alpha.
|
|
50
|
+
"@axa-fr/design-system-slash-css": "1.2.1-alpha.74",
|
|
51
51
|
"@material-symbols/svg-400": ">= 0.19.0",
|
|
52
52
|
"react": ">= 18"
|
|
53
53
|
},
|