import _pt from "prop-types";

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); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

import * as React from 'react'; // Can't use ES6 imports :(
// The types for it are also wrong, we should probably ditch this dependency.
// tslint:disable-next-line

var FocusTrap = require('focus-trap-react');

import styles from "../../@patternfly/patternfly/layouts/Bullseye/bullseye.css.js";
import { css } from '@patternfly/react-styles';
import Backdrop from '../Backdrop/Backdrop';
import { ModalBoxBody } from './ModalBoxBody';
import { ModalBoxHeader } from './ModalBoxHeader';
import { ModalBoxCloseButton } from './ModalBoxCloseButton';
import { ModalBox } from './ModalBox';
import { ModalBoxFooter } from './ModalBoxFooter';
export var ModalContent = function ModalContent(_ref) {
  var children = _ref.children,
      _ref$className = _ref.className,
      className = _ref$className === void 0 ? '' : _ref$className,
      _ref$isOpen = _ref.isOpen,
      isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
      title = _ref.title,
      _ref$hideTitle = _ref.hideTitle,
      hideTitle = _ref$hideTitle === void 0 ? false : _ref$hideTitle,
      _ref$actions = _ref.actions,
      actions = _ref$actions === void 0 ? [] : _ref$actions,
      _ref$onClose = _ref.onClose,
      onClose = _ref$onClose === void 0 ? function () {
    return undefined;
  } : _ref$onClose,
      _ref$isLarge = _ref.isLarge,
      isLarge = _ref$isLarge === void 0 ? false : _ref$isLarge,
      _ref$isSmall = _ref.isSmall,
      isSmall = _ref$isSmall === void 0 ? false : _ref$isSmall,
      _ref$width = _ref.width,
      width = _ref$width === void 0 ? -1 : _ref$width,
      _ref$ariaDescribedByI = _ref.ariaDescribedById,
      ariaDescribedById = _ref$ariaDescribedByI === void 0 ? '' : _ref$ariaDescribedByI,
      _ref$id = _ref.id,
      id = _ref$id === void 0 ? '' : _ref$id,
      props = _objectWithoutProperties(_ref, ["children", "className", "isOpen", "title", "hideTitle", "actions", "onClose", "isLarge", "isSmall", "width", "ariaDescribedById", "id"]);

  var modalBoxHeader = React.createElement(ModalBoxHeader, {
    hideTitle: hideTitle
  }, " ", title, " ");
  var modalBoxFooter = actions.length > 0 && React.createElement(ModalBoxFooter, null, " ", actions, " ");

  if (!isOpen) {
    return null;
  }

  var boxStyle = width === -1 ? {} : {
    width: width
  };
  return React.createElement(Backdrop, null, React.createElement(FocusTrap, {
    focusTrapOptions: {
      clickOutsideDeactivates: true
    },
    className: css(styles.bullseye)
  }, React.createElement(ModalBox, {
    style: boxStyle,
    className: className,
    isLarge: isLarge,
    isSmall: isSmall,
    title: title,
    id: ariaDescribedById || id
  }, React.createElement(ModalBoxCloseButton, {
    onClose: onClose
  }), modalBoxHeader, React.createElement(ModalBoxBody, _extends({}, props, {
    id: id
  }), children), modalBoxFooter)));
};
ModalContent.propTypes = {
  children: _pt.node.isRequired,
  className: _pt.string,
  isLarge: _pt.bool,
  isSmall: _pt.bool,
  isOpen: _pt.bool,
  title: _pt.string.isRequired,
  hideTitle: _pt.bool,
  width: _pt.oneOfType([_pt.number, _pt.string]),
  actions: _pt.any,
  onClose: _pt.func,
  ariaDescribedById: _pt.string,
  id: _pt.string.isRequired
};