{"size": 1059, "ext": "js", "max_stars_repo_path": "src/fields/Input.js", "max_stars_repo_name": "ShakingMap/rf-materialize", "max_stars_repo_stars_event_min_datetime": "2016-05-16T08:13:56.000Z", "max_stars_repo_stars_event_max_datetime": "2016-05-16T08:13:56.000Z", "max_issues_repo_path": "src/fields/Input.js", "max_issues_repo_name": "ShakingMap/rf-materialize", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/fields/Input.js", "max_forks_repo_name": "ShakingMap/rf-materialize", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.2142857143, "max_line_length": 99, "alphanum_fraction": 0.6430594901}
import React from 'react';
import utils from '../utils';
import {cleanValue} from 'rf-fields-utils';

const propTypes = {
    id: React.PropTypes.string,
    validationState: React.PropTypes.any,
    value: React.PropTypes.string,
    onChange: React.PropTypes.func,
    readOnly: React.PropTypes.bool,
    disabled: React.PropTypes.bool

    // other props will be passed down to inner input directly
};

const defaultProps = {
    onChange(){}
};

class Input extends React.Component {
    render() {
        let {id, validationState, value, onChange, readOnly, disabled, ...otherProps} = this.props;

        const style = utils.getInputValidationStyle(validationState);

        return <input
            style={style}
            id={id}
            value={value}
            onChange={e=>onChange(e.target.value, e)}
            readOnly={readOnly}
            disabled={disabled}
            {...otherProps}
        />
    }
}

Input.propTypes = propTypes;
Input.defaultProps = defaultProps;
Input.cleanValue = cleanValue.string;

export default Input;