mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-06-02 02:25:22 +00:00
add(TextInput): initial implementation
This commit is contained in:
@@ -3,6 +3,7 @@ import WebStyleComponent from './modules/WebStyleComponent';
|
||||
import StylePropTypes from './modules/StylePropTypes';
|
||||
import Image from './modules/Image';
|
||||
import Text from './modules/Text';
|
||||
import TextInput from './modules/TextInput';
|
||||
import View from './modules/View';
|
||||
|
||||
export default {
|
||||
@@ -13,5 +14,6 @@ export default {
|
||||
WebStyleComponent,
|
||||
Image,
|
||||
Text,
|
||||
TextInput,
|
||||
View
|
||||
};
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { PropTypes } from 'react';
|
||||
import { TypographicPropTypes } from '../StylePropTypes';
|
||||
import ViewStylePropTypes from '../View/ViewStylePropTypes';
|
||||
|
||||
export default {
|
||||
...ViewStylePropTypes,
|
||||
...TypographicPropTypes
|
||||
};
|
||||
|
||||
export const TextInputDefaultStyles = {
|
||||
background: 'transparent',
|
||||
color: 'inherit',
|
||||
font: 'inherit'
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
import { pickProps } from '../filterObjectProps';
|
||||
import React, { PropTypes } from 'react';
|
||||
import TextInputStylePropTypes, { TextInputDefaultStyles } from './TextInputStylePropTypes';
|
||||
import WebStyleComponent from '../WebStyleComponent';
|
||||
|
||||
class TextInput extends React.Component {
|
||||
static propTypes = {
|
||||
className: PropTypes.string,
|
||||
editable: PropTypes.bool,
|
||||
multiline: PropTypes.bool,
|
||||
placeholder: PropTypes.string,
|
||||
style: PropTypes.shape(TextInputStylePropTypes)
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
editable: true,
|
||||
multiline: false
|
||||
}
|
||||
|
||||
render() {
|
||||
const { className, editable, multiline, placeholder, style, ...other } = this.props;
|
||||
const filteredStyle = pickProps(style, Object.keys(TextInputStylePropTypes));
|
||||
const mergedStyle = { ...TextInputDefaultStyles, ...filteredStyle };
|
||||
|
||||
return (
|
||||
<WebStyleComponent
|
||||
{...other}
|
||||
className={`sdk-TextInput ${className}`}
|
||||
disabled={!editable}
|
||||
element={multiline ? 'textarea' : 'input'}
|
||||
placeholder={placeholder}
|
||||
style={mergedStyle}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default TextInput;
|
||||
Reference in New Issue
Block a user