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 { Accept as AcceptIcon } from '@fluent-ui/icons';
import { CheckboxPropTypes } from './Checkbox.type';
import { styles } from './Checkbox.styled';
export const name = 'Checkbox';
const useStyles = createUseStyles(styles, {
  name
});
const Checkbox = 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 handleChange = React.useCallback(e => {
    onChange && onChange(e.target.checked);
  }, [onChange]);
  return React.createElement(Component, {
    className: className,
    style: style
  }, checked && React.createElement(AcceptIcon, null), React.createElement("input", _extends({
    ref: ref,
    type: "checkbox",
    checked: checked,
    value: value,
    onChange: handleChange,
    disabled: disabled
  }, rest)));
});
Checkbox.displayName = `F${name}`;
Checkbox.propTypes = CheckboxPropTypes;
export default Checkbox;