'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.EuiRadio = undefined;

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

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);

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

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

var EuiRadio = function EuiRadio(_ref) {
  var className = _ref.className,
      id = _ref.id,
      name = _ref.name,
      checked = _ref.checked,
      label = _ref.label,
      value = _ref.value,
      onChange = _ref.onChange,
      disabled = _ref.disabled,
      compressed = _ref.compressed,
      autoFocus = _ref.autoFocus,
      rest = _objectWithoutProperties(_ref, ['className', 'id', 'name', 'checked', 'label', 'value', 'onChange', 'disabled', 'compressed', 'autoFocus']);

  var classes = (0, _classnames2.default)('euiRadio', {
    'euiRadio--noLabel': !label,
    'euiRadio--compressed': compressed
  }, className);

  var optionalLabel = void 0;

  if (label) {
    optionalLabel = _react2.default.createElement(
      'label',
      {
        className: 'euiRadio__label',
        htmlFor: id
      },
      label
    );
  }

  return _react2.default.createElement(
    'div',
    _extends({
      className: classes
    }, rest),
    _react2.default.createElement('input', {
      className: 'euiRadio__input',
      type: 'radio',
      id: id,
      name: name,
      value: value,
      checked: checked,
      onChange: onChange,
      disabled: disabled,
      autoFocus: autoFocus
    }),
    _react2.default.createElement('div', { className: 'euiRadio__circle' }),
    optionalLabel
  );
};

exports.EuiRadio = EuiRadio;
EuiRadio.propTypes = {
  className: _propTypes2.default.string,
  id: _propTypes2.default.string.isRequired,
  checked: _propTypes2.default.bool.isRequired,
  label: _propTypes2.default.node,
  value: _propTypes2.default.string,
  onChange: _propTypes2.default.func.isRequired,
  disabled: _propTypes2.default.bool,
  /**
   * when `true` creates a shorter height radio row
   */
  compressed: _propTypes2.default.bool,
  autoFocus: _propTypes2.default.bool
};

EuiRadio.defaultProps = {
  checked: false,
  disabled: false,
  compressed: false
};
EuiRadio.__docgenInfo = [{
  'description': '',
  'methods': [],
  'props': {
    'className': {
      'type': {
        'name': 'string'
      },
      'required': false,
      'description': ''
    },
    'id': {
      'type': {
        'name': 'string'
      },
      'required': true,
      'description': ''
    },
    'checked': {
      'type': {
        'name': 'bool'
      },
      'required': true,
      'description': '',
      'defaultValue': {
        'value': 'false',
        'computed': false
      }
    },
    'label': {
      'type': {
        'name': 'node'
      },
      'required': false,
      'description': ''
    },
    'value': {
      'type': {
        'name': 'string'
      },
      'required': false,
      'description': ''
    },
    'onChange': {
      'type': {
        'name': 'func'
      },
      'required': true,
      'description': ''
    },
    'disabled': {
      'type': {
        'name': 'bool'
      },
      'required': false,
      'description': '',
      'defaultValue': {
        'value': 'false',
        'computed': false
      }
    },
    'compressed': {
      'type': {
        'name': 'bool'
      },
      'required': false,
      'description': 'when `true` creates a shorter height radio row',
      'defaultValue': {
        'value': 'false',
        'computed': false
      }
    },
    'autoFocus': {
      'type': {
        'name': 'bool'
      },
      'required': false,
      'description': ''
    }
  }
}];