@@ -61,12 +61,15 @@ function BaseTextInput(
61
61
multiline = false ,
62
62
autoCorrect = true ,
63
63
prefixCharacter = '' ,
64
+ suffixCharacter = '' ,
64
65
inputID,
65
66
isMarkdownEnabled = false ,
66
67
excludedMarkdownStyles = [ ] ,
67
68
shouldShowClearButton = false ,
68
69
prefixContainerStyle = [ ] ,
69
70
prefixStyle = [ ] ,
71
+ suffixContainerStyle = [ ] ,
72
+ suffixStyle = [ ] ,
70
73
contentWidth,
71
74
loadingSpinnerStyle,
72
75
...props
@@ -87,7 +90,7 @@ function BaseTextInput(
87
90
// Disabling this line for safeness as nullish coalescing works only if the value is undefined or null
88
91
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
89
92
const initialValue = value || defaultValue || '' ;
90
- const initialActiveLabel = ! ! forceActiveLabel || initialValue . length > 0 || ! ! prefixCharacter ;
93
+ const initialActiveLabel = ! ! forceActiveLabel || initialValue . length > 0 || ! ! prefixCharacter || ! ! suffixCharacter ;
91
94
const isMultiline = multiline || autoGrowHeight ;
92
95
93
96
const [ isFocused , setIsFocused ] = useState ( false ) ;
@@ -141,13 +144,13 @@ function BaseTextInput(
141
144
const deactivateLabel = useCallback ( ( ) => {
142
145
const inputValue = value ?? '' ;
143
146
144
- if ( ! ! forceActiveLabel || inputValue . length !== 0 || prefixCharacter ) {
147
+ if ( ! ! forceActiveLabel || inputValue . length !== 0 || prefixCharacter || suffixCharacter ) {
145
148
return ;
146
149
}
147
150
148
151
animateLabel ( styleConst . INACTIVE_LABEL_TRANSLATE_Y , styleConst . INACTIVE_LABEL_SCALE ) ;
149
152
isLabelActive . current = false ;
150
- } , [ animateLabel , forceActiveLabel , prefixCharacter , value ] ) ;
153
+ } , [ animateLabel , forceActiveLabel , prefixCharacter , suffixCharacter , value ] ) ;
151
154
152
155
const onFocus = ( event : NativeSyntheticEvent < TextInputFocusEventData > ) => {
153
156
inputProps . onFocus ?.( event ) ;
@@ -250,7 +253,7 @@ function BaseTextInput(
250
253
// Disabling this line for safeness as nullish coalescing works only if the value is undefined or null, and errorText can be an empty string
251
254
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
252
255
const inputHelpText = errorText || hint ;
253
- const placeholderValue = ! ! prefixCharacter || isFocused || ! hasLabel || ( hasLabel && forceActiveLabel ) ? placeholder : undefined ;
256
+ const placeholderValue = ! ! prefixCharacter || ! ! suffixCharacter || isFocused || ! hasLabel || ( hasLabel && forceActiveLabel ) ? placeholder : undefined ;
254
257
const newTextInputContainerStyles : StyleProp < ViewStyle > = StyleSheet . flatten ( [
255
258
styles . textInputContainer ,
256
259
textInputContainerStyles ,
@@ -263,7 +266,7 @@ function BaseTextInput(
263
266
] ) ;
264
267
265
268
const inputPaddingLeft = ! ! prefixCharacter && StyleUtils . getPaddingLeft ( StyleUtils . getCharacterPadding ( prefixCharacter ) + styles . pl1 . paddingLeft ) ;
266
-
269
+ const inputPaddingRight = ! ! suffixCharacter && StyleUtils . getPaddingRight ( StyleUtils . getCharacterPadding ( suffixCharacter ) + styles . pr1 . paddingRight ) ;
267
270
return (
268
271
< >
269
272
< View style = { [ containerStyles ] } >
@@ -351,6 +354,7 @@ function BaseTextInput(
351
354
inputStyle ,
352
355
( ! hasLabel || isMultiline ) && styles . pv0 ,
353
356
inputPaddingLeft ,
357
+ inputPaddingRight ,
354
358
inputProps . secureTextEntry && styles . secureInput ,
355
359
356
360
! isMultiline && { height, lineHeight : undefined } ,
@@ -380,6 +384,17 @@ function BaseTextInput(
380
384
defaultValue = { defaultValue }
381
385
markdownStyle = { markdownStyle }
382
386
/>
387
+ { ! ! suffixCharacter && (
388
+ < View style = { [ styles . textInputSuffixWrapper , suffixContainerStyle ] } >
389
+ < Text
390
+ tabIndex = { - 1 }
391
+ style = { [ styles . textInputSuffix , ! hasLabel && styles . pv0 , styles . pointerEventsNone , suffixStyle ] }
392
+ dataSet = { { [ CONST . SELECTION_SCRAPER_HIDDEN_ELEMENT ] : true } }
393
+ >
394
+ { suffixCharacter }
395
+ </ Text >
396
+ </ View >
397
+ ) }
383
398
{ isFocused && ! isReadOnly && shouldShowClearButton && ! ! value && < TextInputClearButton onPressButton = { ( ) => setValue ( '' ) } /> }
384
399
{ ! ! inputProps . isLoading && (
385
400
< ActivityIndicator
0 commit comments