import React, { Component, PropTypes } from 'react' import CSSModules from 'react-css-modules' import styles from './index.styl' @CSSModules(styles, { allowMultiple: true, errorWhenNotFound: false }) export default class extends Component { static propTypes = { inputWidth: PropTypes.string, labelWidth: PropTypes.string, value: PropTypes.oneOfType([ PropTypes.string, PropTypes.number ]), onChange: PropTypes.func, onBlur: PropTypes.func, disabled: PropTypes.bool, required: PropTypes.bool, limited: PropTypes.number } static defaultProps = { inputWidth: '200px' } handleChange (e) { this.props.onChange(e) } handleBlur (e) { if (this.props.limited) { e.target.value = e.target.value.substr(0, this.props.limited) this.props.onChange(e) } if (typeof this.props.onBlur === 'function') { this.props.onBlur(e) } } render () { return (
) } }