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