web: Added type to props and init default props

This commit is contained in:
Alexey Safronov 2019-05-22 16:26:25 +03:00
parent bbc002d5f8
commit 0f06c54151

View File

@ -5,7 +5,7 @@ import styled, { css } from 'styled-components';
const StyledInput = styled.input.attrs((props) => ({
id: props.id,
name: props.name,
type: "text",
type: props.type,
value: props.value,
placeholder: props.placeholder,
maxLength: props.maxLength,
@ -68,17 +68,12 @@ const StyledInput = styled.input.attrs((props) => ({
`;
const TextInput = props => {
return (
<StyledInput {...props} />
);
}
const TextInput = props => <StyledInput {...props} />
TextInput.propTypes = {
id: PropTypes.string,
name: PropTypes.string,
type: PropTypes.oneOf(['text', 'password']),
value: PropTypes.string.isRequired,
maxLength: PropTypes.number,
placeholder: PropTypes.string,
@ -98,4 +93,15 @@ TextInput.propTypes = {
autoComplete: PropTypes.string
}
TextInput.defaultProps = {
type: 'text',
value: '',
maxLength: 255,
size: 'middle',
tabIndex: -1,
hasError: false,
hasWarning: false,
autoComplete: 'off'
}
export default TextInput