import _extends from "@babel/runtime/helpers/esm/extends";
import { __rest } from "tslib";
import * as React from 'react';
import Radio from './radio';
import { ConfigContext } from '../config-provider';
import RadioGroupContext from './context';

var RadioButton = function RadioButton(props, ref) {
  var radioGroupContext = React.useContext(RadioGroupContext);

  var _React$useContext = React.useContext(ConfigContext),
      getPrefixCls = _React$useContext.getPrefixCls;

  var customizePrefixCls = props.prefixCls,
      radioProps = __rest(props, ["prefixCls"]);

  var prefixCls = getPrefixCls('radio-button', customizePrefixCls);

  if (radioGroupContext) {
    radioProps.checked = props.value === radioGroupContext.value;
    radioProps.disabled = props.disabled || radioGroupContext.disabled;
  }

  return /*#__PURE__*/React.createElement(Radio, _extends({
    prefixCls: prefixCls
  }, radioProps, {
    type: "radio",
    ref: ref
  }));
};

export default /*#__PURE__*/React.forwardRef(RadioButton);