'use strict';

exports.__esModule = true;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

require('./style.css');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var InputRadio = function InputRadio(props) {
  var radioClasses = (0, _classnames2.default)({
    'ma__input-radio': !props.outline,
    'ma__input-radio--outline': props.outline
  });
  var inputClasses = (0, _classnames2.default)({
    'ma__input-radio__control': !props.outline,
    'ma__input-radio--outline__control': props.outline,
    'ma__input-radio--outline__control--error': props.error
  });
  var labelClasses = (0, _classnames2.default)({
    'ma__input-radio__label': !props.outline,
    'ma__input-radio__label--error': props.error && !props.outline,
    'ma__input-radio--outline__label': props.outline,
    'ma__input-radio--outline__label--error': props.error && props.outline
  });
  return _react2.default.createElement(
    'div',
    { className: radioClasses },
    _react2.default.createElement('input', {
      checked: props.checked,
      name: props.name,
      type: 'radio',
      value: props.value,
      id: props.id || props.value,
      required: props.required,
      onChange: props.onChange,
      disabled: props.disabled,
      className: inputClasses
    }),
    _react2.default.createElement(
      'label',
      { htmlFor: props.id || props.value, className: labelClasses },
      _react2.default.createElement(
        'span',
        null,
        props.label
      )
    )
  );
};

InputRadio.propTypes = process.env.NODE_ENV !== "production" ? {
  /** The name of the input radio. */
  name: _propTypes2.default.string.isRequired,
  /** The id of the input radio. Defaults to the value if not provided. */
  id: _propTypes2.default.string,
  /** The value of the input radio */
  value: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]).isRequired,
  /** The input radio label */
  label: _propTypes2.default.string.isRequired,
  /** Whether the input radio is checked or not  */
  checked: _propTypes2.default.bool,
  /** Whether radio input is required or not */
  required: _propTypes2.default.bool,
  /** Whether you want the radio input outlined */
  outline: _propTypes2.default.bool,
  /** OnChange function */
  onChange: _propTypes2.default.func,
  /** Whether the radio button is disabled or not */
  disabled: _propTypes2.default.bool,
  /** Whether the input is in an error state */
  error: _propTypes2.default.bool
} : {};

InputRadio.defaultProps = {
  outline: false,
  required: false,
  onChange: function onChange() {},
  disabled: false,
  error: false
};

exports.default = InputRadio;
module.exports = exports['default'];