import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import React, { forwardRef } from 'react';
import PropTypes from 'prop-types';
import { isString } from 'ramda-extension';
import getEventHandlersFromProps from '../utils/getEventHandlersFromProps';
import RadioGroup from '../RadioGroup';
import FormGroup from '../FormGroup';
var RadioGroupField = /*#__PURE__*/forwardRef(function (_ref, 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 = _objectWithoutProperties(_ref, ["children", "onChange", "value", "disabled", "readOnly", "hasError", "hint", "legend", "name"]);

  return /*#__PURE__*/React.createElement(FormGroup, _extends({
    ref: ref,
    legend: legend,
    hint: hint,
    disabled: disabled,
    readOnly: readOnly,
    hasError: hasError
  }, rest), /*#__PURE__*/React.createElement(RadioGroup, _extends({
    "aria-label": isString(legend) ? legend : null,
    onChange: onChange,
    value: value,
    disabled: disabled,
    readOnly: readOnly,
    hasError: hasError,
    name: name
  }, getEventHandlersFromProps(rest)), children));
});
RadioGroupField.displayName = 'RadioGroupField';
RadioGroupField.propTypes = {
  /** Children to be rendered in the main container. */
  children: PropTypes.node,

  /** Disabled state */
  disabled: PropTypes.bool,

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

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

  /** Read-only state */
  readOnly: PropTypes.bool,

  /** Current value of the radio group. */
  value: PropTypes.any
};
export default RadioGroupField;