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 * as PropTypes from 'prop-types';
import { createUseStyles } from '@fluent-ui/styles';
import { styles } from '../Dialog.styled';
import { DialogContext } from '../Dialog';
import Typography from '../../Typography';
import IconButton from '../../IconButton';
import { Cancel as CancelIcon } from '@fluent-ui/icons';
export const name = 'DialogTitle';
const useStyles = createUseStyles(styles, {
  name
});

const Title = props => {
  const {
    children,
    ...rest
  } = props;
  const classes = useStyles(props);
  const {
    onChange
  } = React.useContext(DialogContext);

  function handleClose() {
    onChange && onChange(false);
  }

  return React.createElement("div", _extends({
    className: classes.title
  }, rest), React.createElement(Typography, {
    variant: "h6"
  }, children), React.createElement(IconButton, {
    size: "small",
    style: {
      marginRight: '-10px',
      height: '100%'
    },
    onClick: handleClose
  }, React.createElement(CancelIcon, null)));
};

Title.displayName = `F${name}`;
Title.propTypes = {
  children: PropTypes.any.isRequired
};
export default Title;