From 4b1e34304b109c52a454fe25ee2d0f6ca51b8e5d Mon Sep 17 00:00:00 2001 From: "pinar.kizilarslan" Date: Tue, 10 Dec 2024 17:36:11 +0300 Subject: [PATCH] fix(input) removed optional text from default --- ios/Podfile.lock | 2 +- src/components/Input/Input.stories.tsx | 19 +++++++- src/components/Input/Input.tsx | 3 ++ src/components/Input/InputLabel.test.tsx | 8 +++- src/components/Input/InputLabel.tsx | 8 ++-- .../Input/__snapshots__/Input.test.tsx.snap | 43 ++++++------------- .../__snapshots__/InputLabel.test.tsx.snap | 21 +-------- 7 files changed, 47 insertions(+), 57 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 1a98887..e7c0c15 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -558,4 +558,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 2c095cf05d0978e12f6ac4350329c2d085601c15 -COCOAPODS: 1.14.3 +COCOAPODS: 1.15.2 diff --git a/src/components/Input/Input.stories.tsx b/src/components/Input/Input.stories.tsx index e5d9479..7b853dc 100644 --- a/src/components/Input/Input.stories.tsx +++ b/src/components/Input/Input.stories.tsx @@ -26,7 +26,8 @@ const InputMeta: ComponentMeta = { label: 'Label', placeholder: 'Placeholder Text', labelFixed: false, - required: true, + required: false, + requiredText: false, secureTextEntry: false, helpText: 'Help Text', error: false, @@ -83,6 +84,22 @@ export const Cases: InputStory = args => { label={null} /> + + + & errorText?: string | null; successText?: string | null; required?: boolean; + requiredText?: boolean; icon?: IconNameType | null; success?: boolean; error?: boolean; @@ -89,6 +90,7 @@ const Input = forwardRef( error = false, secureTextEntry = false, required = false, + requiredText = false, disabled = false, editable = true, easing = Easing.inOut(Easing.ease), @@ -232,6 +234,7 @@ const Input = forwardRef( label={label} labelFixed={labelFixed} required={required} + requiredText={requiredText} errorState={errorState} successState={successState} animatedViewProps={animatedViewProps} diff --git a/src/components/Input/InputLabel.test.tsx b/src/components/Input/InputLabel.test.tsx index 8a20993..fa2e5e8 100644 --- a/src/components/Input/InputLabel.test.tsx +++ b/src/components/Input/InputLabel.test.tsx @@ -7,6 +7,7 @@ describe('Input Label', () => { let label: string | null; let labelFixed: boolean; let required: boolean; + let requiredText: boolean; let errorState: boolean; let successState: boolean; let animatedViewProps: AnimatedViewPropsType; @@ -16,7 +17,8 @@ describe('Input Label', () => { beforeEach(() => { label = 'Label'; labelFixed = false; - required = true; + required = false; + requiredText = false; errorState = false; successState = false; animatedViewProps = {}; @@ -53,6 +55,7 @@ describe('Input Label', () => { label={label} labelFixed={labelFixed} required={required} + requiredText={requiredText} errorState={errorState} successState={successState} animatedViewProps={animatedViewProps} @@ -75,6 +78,7 @@ describe('Input Label', () => { label={label} labelFixed={labelFixed} required={required} + requiredText={requiredText} errorState={errorState} successState={successState} animatedViewProps={animatedViewProps} @@ -97,6 +101,7 @@ describe('Input Label', () => { label={label} labelFixed={labelFixed} required={required} + requiredText={requiredText} errorState={errorState} successState={successState} animatedViewProps={animatedViewProps} @@ -120,6 +125,7 @@ describe('Input Label', () => { label={label} labelFixed={labelFixed} required={required} + requiredText={requiredText} errorState={errorState} successState={successState} animatedViewProps={animatedViewProps} diff --git a/src/components/Input/InputLabel.tsx b/src/components/Input/InputLabel.tsx index 12a2120..91b230d 100644 --- a/src/components/Input/InputLabel.tsx +++ b/src/components/Input/InputLabel.tsx @@ -10,6 +10,7 @@ export const InputLabel = React.memo( label, labelFixed, required, + requiredText, errorState, successState, animatedViewProps, @@ -18,7 +19,8 @@ export const InputLabel = React.memo( }: { label?: string | null; labelFixed?: boolean; - required: boolean; + required?: boolean; + requiredText?: boolean; errorState: boolean; successState: boolean; animatedViewProps: AnimatedViewPropsType; @@ -40,7 +42,7 @@ export const InputLabel = React.memo( testID="fixed-label"> {label} - {!required ? ( + {!required && requiredText ? ( {label} - {!required ? ' (Optional)' : ''} + {!required && requiredText ? ' (Optional)' : ''} diff --git a/src/components/Input/__snapshots__/Input.test.tsx.snap b/src/components/Input/__snapshots__/Input.test.tsx.snap index 75ebd23..86ab1ae 100644 --- a/src/components/Input/__snapshots__/Input.test.tsx.snap +++ b/src/components/Input/__snapshots__/Input.test.tsx.snap @@ -54,7 +54,7 @@ exports[`Input should render disabled input correctly 1`] = ` } > label - (Optional) + @@ -157,7 +157,7 @@ exports[`Input should render input correctly 1`] = ` } > label - (Optional) + @@ -260,7 +260,7 @@ exports[`Input should render input with error state and error text correctly 1`] } > label - (Optional) + @@ -453,7 +453,7 @@ exports[`Input should render input with error state correctly 1`] = ` } > label - (Optional) + @@ -618,7 +618,7 @@ exports[`Input should render input with help text correctly 1`] = ` } > label - (Optional) + @@ -749,7 +749,7 @@ exports[`Input should render input with icon correctly 1`] = ` } > label - (Optional) + @@ -942,7 +942,7 @@ exports[`Input should render input with leadingText correctly 1`] = ` } > label - (Optional) + @@ -1074,7 +1074,7 @@ exports[`Input should render input with medium size correctly 1`] = ` } > label - (Optional) + @@ -1177,7 +1177,7 @@ exports[`Input should render input with small size correctly 1`] = ` } > label - (Optional) + @@ -1280,7 +1280,7 @@ exports[`Input should render input with success state and success text correctly } > label - (Optional) + @@ -1473,7 +1473,7 @@ exports[`Input should render input with success state correctly 1`] = ` } > label - (Optional) + @@ -1638,7 +1638,7 @@ exports[`Input should render input with trailingText correctly 1`] = ` } > label - (Optional) + @@ -1759,25 +1759,6 @@ exports[`Input should render label fixed input correctly 1`] = ` > label - - (Optional) - Label - - (Optional) - `; @@ -145,7 +126,7 @@ exports[`Input Label should render outlined label with optional correctly 1`] = style={Object {}} > Label - (Optional) +