function _extends() { _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; }; return _extends.apply(this, arguments); }

import * as React from 'react';
import classNames from 'classnames';
import { createUseStyles } from '@fluent-ui/styles';
import { RadioPropTypes } from './Radio.type';
import { styles } from './Radio.styled';
export const name = 'Radio';
const useStyles = createUseStyles(styles, {
  name
});
const Radio = React.forwardRef((props, ref) => {
  const {
    as: Component = 'div',
    className: classNameProp,
    style,
    checked,
    value,
    onChange,
    disabled,
    ...rest
  } = props;
  const classes = useStyles(props);
  const className = classNames(classes.root, {
    [classes.checked]: checked,
    [classes.disabled]: disabled
  }, classNameProp);
  const circleClassName = classNames(classes.circle, {
    [classes.circleChecked]: checked,
    [classes.circleDisabled]: disabled
  });

  function handleChange(e) {
    onChange && onChange(e.target.value);
  }

  return React.createElement(Component, {
    className: className,
    style: style
  }, React.createElement("div", {
    className: circleClassName
  }), React.createElement("input", _extends({
    ref: ref,
    type: "radio",
    checked: checked,
    value: value,
    onChange: handleChange,
    disabled: disabled
  }, rest)));
});
Radio.displayName = `F${name}`;
Radio.propTypes = RadioPropTypes;
export default Radio;