-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31356 from kubabutkiewicz/ts-migration/TextInput/…
…component [TS migration] Migrate 'TextInput' component to TypeScript
- Loading branch information
Showing
14 changed files
with
520 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
290 changes: 162 additions & 128 deletions
290
...s/TextInput/BaseTextInput/index.native.js → .../TextInput/BaseTextInput/index.native.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
298 changes: 165 additions & 133 deletions
298
...mponents/TextInput/BaseTextInput/index.js → ...ponents/TextInput/BaseTextInput/index.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import React from 'react'; | ||
import type {Component, ForwardedRef} from 'react'; | ||
import type {GestureResponderEvent, StyleProp, TextInputProps, TextStyle, ViewStyle} from 'react-native'; | ||
import type {AnimatedProps} from 'react-native-reanimated'; | ||
import type {SrcProps} from '@components/Icon'; | ||
import type {MaybePhraseKey} from '@libs/Localize'; | ||
|
||
type CustomBaseTextInputProps = { | ||
/** Input label */ | ||
label?: string; | ||
|
||
/** Name attribute for the input */ | ||
name?: string; | ||
|
||
/** Input value */ | ||
value?: string; | ||
|
||
/** Default value - used for non controlled inputs */ | ||
defaultValue?: string; | ||
|
||
/** Input value placeholder */ | ||
placeholder?: string; | ||
|
||
/** Error text to display */ | ||
errorText?: MaybePhraseKey; | ||
|
||
/** Icon to display in right side of text input */ | ||
icon: ((props: SrcProps) => React.ReactNode) | null; | ||
|
||
/** Customize the TextInput container */ | ||
textInputContainerStyles?: StyleProp<ViewStyle>; | ||
|
||
/** Customize the main container */ | ||
containerStyles?: StyleProp<ViewStyle>; | ||
|
||
/** input style */ | ||
inputStyle?: StyleProp<TextStyle>; | ||
|
||
/** If present, this prop forces the label to remain in a position where it will not collide with input text */ | ||
forceActiveLabel?: boolean; | ||
|
||
/** Should the input auto focus? */ | ||
autoFocus?: boolean; | ||
|
||
/** Disable the virtual keyboard */ | ||
disableKeyboard?: boolean; | ||
|
||
/** | ||
* Autogrow input container length based on the entered text. | ||
* Note: If you use this prop, the text input has to be controlled | ||
* by a value prop. | ||
*/ | ||
autoGrow?: boolean; | ||
|
||
/** | ||
* Autogrow input container height based on the entered text | ||
* Note: If you use this prop, the text input has to be controlled | ||
* by a value prop. | ||
*/ | ||
autoGrowHeight?: boolean; | ||
|
||
/** Hide the focus styles on TextInput */ | ||
hideFocusedState?: boolean; | ||
|
||
/** Hint text to display below the TextInput */ | ||
hint?: string; | ||
|
||
/** Prefix character */ | ||
prefixCharacter?: string; | ||
|
||
/** Whether autoCorrect functionality should enable */ | ||
autoCorrect?: boolean; | ||
|
||
/** Form props */ | ||
/** The ID used to uniquely identify the input in a Form */ | ||
inputID?: string; | ||
|
||
/** Saves a draft of the input value when used in a form */ | ||
shouldSaveDraft?: boolean; | ||
|
||
/** Callback to update the value on Form when input is used in the Form component. */ | ||
onInputChange?: (value: string) => void; | ||
|
||
/** Whether we should wait before focusing the TextInput, useful when using transitions */ | ||
shouldDelayFocus?: boolean; | ||
|
||
/** Indicate whether pressing Enter on multiline input is allowed to submit the form. */ | ||
submitOnEnter?: boolean; | ||
|
||
/** Indicate whether input is multiline */ | ||
multiline?: boolean; | ||
|
||
/** Set the default value to the input if there is a valid saved value */ | ||
shouldUseDefaultValue?: boolean; | ||
|
||
/** Indicate whether or not the input should prevent swipe actions in tabs */ | ||
shouldInterceptSwipe?: boolean; | ||
|
||
/** Should there be an error displayed */ | ||
hasError?: boolean; | ||
|
||
/** On Press handler */ | ||
onPress?: (event: GestureResponderEvent | KeyboardEvent) => void; | ||
|
||
/** Should loading state should be displayed */ | ||
isLoading?: boolean; | ||
|
||
/** Type of autocomplete */ | ||
autoCompleteType?: string; | ||
}; | ||
|
||
type BaseTextInputRef = ForwardedRef<HTMLFormElement | Component<AnimatedProps<TextInputProps>>>; | ||
|
||
type BaseTextInputProps = CustomBaseTextInputProps & TextInputProps; | ||
|
||
export type {CustomBaseTextInputProps, BaseTextInputRef, BaseTextInputProps}; |
25 changes: 0 additions & 25 deletions
25
src/components/TextInput/TextInputLabel/TextInputLabelPropTypes.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {Animated} from 'react-native'; | ||
|
||
type TextInputLabelProps = { | ||
/** Label */ | ||
label: string; | ||
|
||
/** Label vertical translate */ | ||
labelTranslateY: Animated.Value; | ||
|
||
/** Label scale */ | ||
labelScale: Animated.Value; | ||
|
||
/** Whether the label is currently active or not */ | ||
isLabelActive: boolean; | ||
|
||
/** For attribute for label */ | ||
for?: string; | ||
}; | ||
|
||
export default TextInputLabelProps; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.