@@ -4,24 +4,23 @@ import { DeepPartial, Omit } from 'ts-essentials';
44
55import { ThemeContext } from '../../theme' ;
66import { mergeStyles , ReplaceReturnType } from '../../utils/mergeStyles' ;
7+ import {
8+ getIconTextInputStyles ,
9+ IconTextInputStyles ,
10+ } from './IconTextInput.styles' ;
711import TextInput , { TextInputProps } from './TextInput' ;
812import { GetTextInputStyles , TextInputStyles } from './TextInput.styles' ;
9- import {
10- getTextInputWithIconStyles ,
11- TextInputWithIconStyles ,
12- } from './TextInputWithIcon.styles' ;
1313
14- export interface TextInputWithIconProps
15- extends Omit < TextInputProps , 'getStyles' > {
14+ export interface IconTextInputProps extends Omit < TextInputProps , 'getStyles' > {
1615 leftIcon ?: React . ReactNode ;
1716 rightIcon ?: React . ReactNode ;
1817 getStyles ?: ReplaceReturnType <
1918 GetTextInputStyles ,
20- DeepPartial < TextInputStyles & TextInputWithIconStyles >
19+ DeepPartial < TextInputStyles & IconTextInputStyles >
2120 > ;
2221}
2322
24- const TextInputWithIconBase = ( props : TextInputWithIconProps ) => {
23+ const IconTextInputBase = ( props : IconTextInputProps ) => {
2524 const {
2625 leftIcon = null ,
2726 rightIcon = null ,
@@ -34,19 +33,29 @@ const TextInputWithIconBase = (props: TextInputWithIconProps) => {
3433 containerStyle,
3534 leftContainerStyle,
3635 rightContainerStyle,
37- } = mergeStyles ( getTextInputWithIconStyles , getStyles ) ( theme ) ;
36+ inputStyle,
37+ } = mergeStyles ( getIconTextInputStyles , getStyles ) (
38+ { hasLeftIcon : ! ! leftIcon , hasRightIcon : ! ! rightIcon } ,
39+ theme ,
40+ ) ;
3841
3942 return (
4043 < View style = { containerStyle } >
4144 < View style = { leftContainerStyle } > { leftIcon } </ View >
42- < TextInput ref = { innerRef } { ...textInputProps } />
45+ < TextInput
46+ ref = { innerRef }
47+ getStyles = { ( ) => ( {
48+ inputStyle,
49+ } ) }
50+ { ...textInputProps }
51+ />
4352 < View style = { rightContainerStyle } > { rightIcon } </ View >
4453 </ View >
4554 ) ;
4655} ;
4756
48- export const TextInputWithIcon = React . forwardRef < RNTextInput , TextInputProps > (
49- ( props , ref ) => < TextInputWithIconBase { ...props } innerRef = { ref } /> ,
57+ export const IconTextInput = React . forwardRef < RNTextInput , TextInputProps > (
58+ ( props , ref ) => < IconTextInputBase { ...props } innerRef = { ref } /> ,
5059) ;
5160
52- export default TextInputWithIcon ;
61+ export default IconTextInput ;
0 commit comments