Sha256: 482a3fb2e671923245820bd13bad650a84e8787906d9a359b8516ce41c4d95fe

Contents?: true

Size: 1.71 KB

Versions: 37

Compression:

Stored size: 1.71 KB

Contents

class InputText extends BaseInput {

  render() {
    const { errors, inputType, name, value, defaultValue, disabled, helpMessage, label, labelHidden, onChange, onKeyDown, onKeyUp, placeholder } = this.props;

    const wrapperClassName = classNames({
      'next-input-wrapper': true,
      'next-input-wrapper--is-error': this.hasError() 
    });

    const labelClassName = classNames({
      'next-label': true,
      'helper--visually-hidden': labelHidden
    });

    const handleChange = (e) => {
      onChange && onChange(e.target.value);
    };

    const handleKeyDown = (e) => {
      onKeyDown && onKeyDown(e);
    };

    const handleKeyUp = (e) => {
      onKeyUp && onKeyUp(e);
    };

    let helpElement = null;
    if(helpMessage) {
      helpElement = <p className="next-input__help-text">{helpMessage}</p>;
    }

    return (
      <div className={wrapperClassName}>
        <label className={labelClassName} htmlFor={name}>{label}</label>
        <input
          id={name}
          className="next-input"
          disabled={disabled}
          value={value}
          defaultValue={defaultValue}
          name={name}
          onChange={handleChange}
          onKeyDown={handleKeyDown}
          onKeyUp={handleKeyUp}
          placeholder={placeholder}
          type={inputType || 'text'}
        />
        {helpElement}
      </div>
    );
  }
}

InputText.propTypes = {
  errors: React.PropTypes.object,
  label: React.PropTypes.string.isRequired,
  name: React.PropTypes.string,
  onChange: React.PropTypes.func,
  placeholder: React.PropTypes.string,
  helpMessage: React.PropTypes.string,
  error: React.PropTypes.bool,
  disabled: React.PropTypes.bool
};

InputText.defaultProps = {
  errors: {},
  disabled: false
};

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
disco_app-0.16.1.pre.sidekiq.pre.6.pre.release app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx
disco_app-0.10.4 app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx
disco_app-0.10.5 app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx
disco_app-0.11.0 app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx
disco_app-0.11.1 app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx
disco_app-0.12.0 app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx
disco_app-0.12.1 app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx
disco_app-0.12.5 app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx
disco_app-0.12.6 app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx
disco_app-0.12.7 app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx
disco_app-0.13.0 app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx
disco_app-0.13.1 app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx
disco_app-0.13.2 app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx
disco_app-0.13.3 app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx
disco_app-0.13.4 app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx
disco_app-0.13.5 app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx
disco_app-0.13.6 app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx
disco_app-0.13.7 app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx
disco_app-0.13.8 app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx
disco_app-0.14.1 app/assets/javascripts/disco_app/components/ui-kit/forms/input-text.es6.jsx