@@ -96,20 +96,24 @@ const captalize = (text: string) =>
96
96
text . charAt ( 0 ) . toUpperCase ( ) + text . slice ( 1 ) ;
97
97
98
98
export interface TextInputAdornmentProps {
99
+ forceFocus : ( ) => void ;
99
100
adornmentConfig : AdornmentConfig [ ] ;
100
- affixTopPosition : {
101
- [ AdornmentSide . Left ] : number | null ;
102
- [ AdornmentSide . Right ] : number | null ;
101
+ topPosition : {
102
+ [ AdornmentType . Affix ] : {
103
+ [ AdornmentSide . Left ] : number | null ;
104
+ [ AdornmentSide . Right ] : number | null ;
105
+ } ;
106
+ [ AdornmentType . Icon ] : number ;
103
107
} ;
104
108
onAffixChange : {
105
109
[ AdornmentSide . Left ] : ( event : LayoutChangeEvent ) => void ;
106
110
[ AdornmentSide . Right ] : ( event : LayoutChangeEvent ) => void ;
107
111
} ;
108
- iconTopPosition : number ;
109
112
left ?: React . ReactNode ;
110
113
right ?: React . ReactNode ;
111
114
textStyle ?: StyleProp < TextStyle > ;
112
115
visible ?: Animated . Value ;
116
+ isTextInputFocused : boolean ;
113
117
}
114
118
115
119
const TextInputAdornment : React . FunctionComponent < TextInputAdornmentProps > = ( {
@@ -118,40 +122,44 @@ const TextInputAdornment: React.FunctionComponent<TextInputAdornmentProps> = ({
118
122
right,
119
123
onAffixChange,
120
124
textStyle,
121
- affixTopPosition,
122
125
visible,
123
- iconTopPosition,
126
+ topPosition,
127
+ isTextInputFocused,
128
+ forceFocus,
124
129
} ) => {
125
130
if ( adornmentConfig . length ) {
126
131
return (
127
132
< >
128
133
{ adornmentConfig . map ( ( { type, side } : AdornmentConfig ) => {
129
- let adornmentInputComponent ;
134
+ let inputAdornmentComponent ;
130
135
if ( side === AdornmentSide . Left ) {
131
- adornmentInputComponent = left ;
136
+ inputAdornmentComponent = left ;
132
137
} else if ( side === AdornmentSide . Right ) {
133
- adornmentInputComponent = right ;
138
+ inputAdornmentComponent = right ;
134
139
}
135
140
141
+ const commonProps = {
142
+ key : side ,
143
+ side : side ,
144
+ testID : `${ side } -${ type } -adornment` ,
145
+ isTextInputFocused,
146
+ } ;
136
147
if ( type === AdornmentType . Icon ) {
137
148
return (
138
149
< IconAdornment
139
- testID = { `${ side } -icon-adornment` }
140
- key = { side }
141
- icon = { adornmentInputComponent }
142
- side = { side }
143
- iconTopPosition = { iconTopPosition }
150
+ { ...commonProps }
151
+ icon = { inputAdornmentComponent }
152
+ topPosition = { topPosition [ AdornmentType . Icon ] }
153
+ forceFocus = { forceFocus }
144
154
/>
145
155
) ;
146
156
} else if ( type === AdornmentType . Affix ) {
147
157
return (
148
158
< AffixAdornment
149
- testID = { `${ side } -affix-adornment` }
150
- key = { side }
151
- affix = { adornmentInputComponent }
152
- side = { side }
159
+ { ...commonProps }
160
+ topPosition = { topPosition [ AdornmentType . Affix ] [ side ] }
161
+ affix = { inputAdornmentComponent }
153
162
textStyle = { textStyle }
154
- affixTopPosition = { affixTopPosition [ side ] }
155
163
onLayout = { onAffixChange [ side ] }
156
164
visible = { visible }
157
165
/>
0 commit comments