import * as React from 'react'; import InputStyle from './Input.styled'; import { Icons } from '../index'; export interface IProps { feedback?: string|Object; placeholder: string; type: string; isInvalid?: boolean|string; isWarning?: boolean|string; comment?: string; label?: string; css?: string|Object; passwordType?: boolean; onChange?: ({ target }: any) => void|any; onBlur?: ({ target }: any) => void|any; onFocus?: ({ target }: any) => void|any; value?: string|number; minLength?: number; maxLength?: number; name?: string; min?: string; max?: string; disabled?: boolean; } interface IState { valid?: boolean; passwordType?: boolean; } export default class Input extends React.PureComponent { state = { passwordType: false, }; togglePassword = (passwordType: any) => this.setState(({ passwordType })); renderIcon = (type: string) => { switch (type) { case 'password': { return ( this.togglePassword(passwordType)} /> ); } case 'search': { return ( ); } default: return null; } } render () { const { feedback, comment, label, type, placeholder, isInvalid, isWarning } = this.props; const { passwordType } = this.state; const password = passwordType && { type: 'text' }; const moreInformationInInput = feedback || comment || isInvalid || isWarning; return ( {(moreInformationInInput) && {moreInformationInInput}} {this.renderIcon(type)} ); } }