From cb58eace8967372697b7e0456598afd780b886ae Mon Sep 17 00:00:00 2001 From: Arno V Date: Mon, 1 Apr 2024 09:17:01 -0400 Subject: [PATCH] feat(ui-form): adding support for labelHidden prop (#457) ## Summary by CodeRabbit - **New Features** - Added a `labelHidden` property to TextInput and TextInputMask components to toggle label visibility while ensuring accessibility. - **Refactor** - Removed unused code related to button and icon components in TextInputMask. --- .../src/Form/TextInput.stories.tsx | 1 + .../src/Form/TextInputMask.stories.tsx | 1 + .../src/components/TextInput/TextInput.tsx | 3 ++- .../components/TextInput/TextInputMask.tsx | 14 ++------------ .../components/TextInput/TextInputTypes.d.ts | 4 ++++ .../TextInput/__tests__/TextInput.test.tsx | 14 ++++++++++++++ .../__tests__/TextInputMask.test.tsx | 19 +++++++++++++++++++ 7 files changed, 43 insertions(+), 13 deletions(-) diff --git a/packages/documentation/src/Form/TextInput.stories.tsx b/packages/documentation/src/Form/TextInput.stories.tsx index 4cad27ec..c112ddd1 100644 --- a/packages/documentation/src/Form/TextInput.stories.tsx +++ b/packages/documentation/src/Form/TextInput.stories.tsx @@ -20,6 +20,7 @@ export default { inputClassName: "", className: "", mode: "system", + labelHidden: false, }, argTypes: { mode: { diff --git a/packages/documentation/src/Form/TextInputMask.stories.tsx b/packages/documentation/src/Form/TextInputMask.stories.tsx index 83062b2c..52189183 100644 --- a/packages/documentation/src/Form/TextInputMask.stories.tsx +++ b/packages/documentation/src/Form/TextInputMask.stories.tsx @@ -21,6 +21,7 @@ export default { error: false, inputClassName: "", className: "", + labelHidden: false, }, argTypes: { focusMode: { diff --git a/packages/ui-form/src/components/TextInput/TextInput.tsx b/packages/ui-form/src/components/TextInput/TextInput.tsx index 8d054c1e..95b0dd99 100644 --- a/packages/ui-form/src/components/TextInput/TextInput.tsx +++ b/packages/ui-form/src/components/TextInput/TextInput.tsx @@ -23,6 +23,7 @@ export const TextInput = React.forwardRef( noBorder = false, labelId, + labelHidden = false, type = "text", helperText = "", @@ -79,7 +80,7 @@ export const TextInput = React.forwardRef( !raw && { style: { paddingRight: inputPaddingRight } })} {...extraProps} /> - {!raw && ( + {!raw && !labelHidden && (