Skip to content

Commit 8f6c061

Browse files
lfernandezsmaurobender
authored andcommitted
Added Text Input Component
1 parent 1b0e82a commit 8f6c061

File tree

6 files changed

+40
-2
lines changed

6 files changed

+40
-2
lines changed

src/components/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export { default as IconButton } from './main/IconButton';
88
export { default as Checkbox } from './main/Checkbox';
99
export { default as Radio } from './main/Radio';
1010
export { default as FormControl } from './main/FormControl';
11+
export { default as TextInput } from './main/TextInput';
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
import { TextInput as TextInputRN } from 'react-native';
3+
import { useComponentPropsResolver, useStyleFromPropsResolver } from '../../../hooks';
4+
import type { ITextInputProps } from './types';
5+
6+
const TextInput = ( props: ITextInputProps ) => {
7+
const resolvedProps = useComponentPropsResolver( 'TextInput', props );
8+
const [ style, restProps ] = useStyleFromPropsResolver( 'TextInput', resolvedProps );
9+
return <TextInputRN style={style} {...restProps}/>;
10+
};
11+
12+
export default TextInput;
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import type { TextInputProps } from 'react-native';
2+
import type { ComponentStyledProps } from '../../../core/components/types';
3+
4+
export interface ITextInputProps extends Omit<TextInputProps, 'textAlign'>, ComponentStyledProps<'TextInput'> {}

src/core/components/types/common.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { StyledProps } from '../../theme/types';
22

33
export type ComponentName = 'Text' | 'Box' | 'Stack' | 'Button' | 'Pressable' | 'Icon' | 'Checkbox'
4-
| 'IconButton' | 'Radio' | 'FormControl';
4+
| 'IconButton' | 'Radio' | 'FormControl' | 'TextInput';
55

66
export type VariantName = string;
77

src/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export {
1515
Text,
1616
Checkbox,
1717
Radio,
18-
FormControl
18+
FormControl,
19+
TextInput
1920
} from './components';
2021
export { UIKitIcon };
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { render } from '@testing-library/react-native';
2+
import React from 'react';
3+
import TextInput from '../../../src/components/main/TextInput';
4+
import WithThemeProvider from '../../support/withThemeProvider';
5+
6+
const { itBehavesLike } = require( '../../support/sharedExamples' );
7+
8+
describe( 'TextInput', () => {
9+
const renderTextInput = props => render(
10+
<TextInput testID='test-text-input' {...props} />,
11+
{ wrapper: WithThemeProvider }
12+
);
13+
14+
itBehavesLike( 'aStyledSystemComponent',
15+
{
16+
renderComponent: props => renderTextInput( props ),
17+
testId: 'test-text-input',
18+
omitProps: [ 'gap', 'tintColor' ]
19+
} );
20+
} );

0 commit comments

Comments
 (0)