"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.default = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));

var _react = _interopRequireDefault(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _ramdaExtension = require("ramda-extension");

var _getEventHandlersFromProps = _interopRequireDefault(require("../utils/getEventHandlersFromProps"));

var _RadioGroup = _interopRequireDefault(require("../RadioGroup"));

var _FormGroup = _interopRequireDefault(require("../FormGroup"));

var RadioGroupField = function RadioGroupField(_ref) {
  var children = _ref.children,
      onChange = _ref.onChange,
      value = _ref.value,
      disabled = _ref.disabled,
      readOnly = _ref.readOnly,
      hasError = _ref.hasError,
      hint = _ref.hint,
      legend = _ref.legend,
      name = _ref.name,
      rest = (0, _objectWithoutPropertiesLoose2.default)(_ref, ["children", "onChange", "value", "disabled", "readOnly", "hasError", "hint", "legend", "name"]);
  return (
    /*#__PURE__*/
    _react.default.createElement(_FormGroup.default, (0, _extends2.default)({
      legend: legend,
      hint: hint,
      disabled: disabled,
      readOnly: readOnly,
      hasError: hasError
    }, rest),
    /*#__PURE__*/
    _react.default.createElement(_RadioGroup.default, (0, _extends2.default)({
      "aria-label": (0, _ramdaExtension.isString)(legend) ? legend : null,
      onChange: onChange,
      value: value,
      disabled: disabled,
      readOnly: readOnly,
      hasError: hasError,
      name: name
    }, (0, _getEventHandlersFromProps.default)(rest)), children))
  );
};

process.env.NODE_ENV !== "production" ? RadioGroupField.propTypes = {
  /** Children to be rendered in the main container. */
  children: _propTypes.default.node,

  /** Disabled state */
  disabled: _propTypes.default.bool,

  /** Error state */
  hasError: _propTypes.default.bool,
  hint: _propTypes.default.node,
  legend: _propTypes.default.node,
  name: _propTypes.default.string,

  /** Called when `onChange` event is triggered on any of children which has `value` prop set. */
  onChange: _propTypes.default.func,

  /** Read-only state */
  readOnly: _propTypes.default.bool,

  /** Current value of the radio group. */
  value: _propTypes.default.any
} : void 0;
var _default = RadioGroupField;
exports.default = _default;