From 2c3440edb589c7c00bf2ec5f01baf9a120f26b6b Mon Sep 17 00:00:00 2001 From: Lilian Saget-Lethias Date: Mon, 30 Dec 2024 14:37:57 +0100 Subject: [PATCH 1/3] feat(input): add action and enable wrap class access --- src/Input.tsx | 25 +++++++++++++++++-------- stories/Input.stories.tsx | 5 +++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/Input.tsx b/src/Input.tsx index b47376e35..05dbfba4f 100644 --- a/src/Input.tsx +++ b/src/Input.tsx @@ -28,7 +28,10 @@ export namespace InputProps { disabled?: boolean; iconId?: FrIconClassName | RiIconClassName; classes?: Partial< - Record<"root" | "label" | "description" | "nativeInputOrTextArea" | "message", string> + Record< + "root" | "label" | "description" | "nativeInputOrTextArea" | "message" | "wrap", + string + > >; style?: CSSProperties; /** Default: "default" */ @@ -36,6 +39,7 @@ export namespace InputProps { /** The message won't be displayed if state is "default" */ stateRelatedMessage?: ReactNode; addon?: ReactNode; + action?: ReactNode; }; export type RegularInput = Common & { @@ -84,6 +88,7 @@ export const Input = memo( nativeTextAreaProps, nativeInputProps, addon, + action, ...rest } = props; @@ -154,7 +159,6 @@ export const Input = memo( case "default": return undefined; } - assert>(); })() ), classes.nativeInputOrTextArea @@ -168,16 +172,22 @@ export const Input = memo( const hasIcon = iconId !== undefined; const hasAddon = addon !== undefined; - return hasIcon || hasAddon ? ( + const hasAction = action !== undefined; + return hasIcon || hasAddon || hasAction ? (
{nativeInputOrTextArea} {hasAddon && addon} + {hasAction && action}
) : ( nativeInputOrTextArea @@ -198,7 +208,6 @@ export const Input = memo( case "info": return "fr-info-text"; } - assert>(); })() ), classes.message diff --git a/stories/Input.stories.tsx b/stories/Input.stories.tsx index a0f697093..548c0ddf7 100644 --- a/stories/Input.stories.tsx +++ b/stories/Input.stories.tsx @@ -144,3 +144,8 @@ export const WithButtonAddon = getStory({ "label": "Label champs de saisie", "addon": }); + +export const WithButtonAction = getStory({ + "label": "Label champs de saisie", + "addon":