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 PropTypes from "prop-types";
import React from "react";
import classNames from "classnames";
import ButtonRow from "../ButtonRow";
import CloseButton from "../CloseButton";
import Fieldset from "../Fieldset";
import Footer from "./Deprecated/Footer";
import Title from "./Deprecated/Title";
import Wrapper from "./Deprecated/Wrapper";
/**
 *
 * @param {Object} props - Properties passed to component
 * @returns {ReactElement}
 */

export var DialogNew = function DialogNew(_ref) {
  var children = _ref.children,
      className = _ref.className,
      footerButtonList = _ref.footerButtonList,
      hasCloseButton = _ref.hasCloseButton,
      hasOverlay = _ref.hasOverlay,
      onClose = _ref.onClose,
      subtitle = _ref.subtitle,
      testSection = _ref.testSection,
      title = _ref.title,
      props = _objectWithoutProperties(_ref, ["children", "className", "footerButtonList", "hasCloseButton", "hasOverlay", "onClose", "subtitle", "testSection", "title"]);

  var subtitleContent;

  if (subtitle && typeof subtitle === "string") {
    subtitleContent = React.createElement("p", {
      className: "push--top flush--bottom"
    }, subtitle);
  } else {
    subtitleContent = React.createElement("div", {
      className: "push--top flush--bottom"
    }, subtitle);
  }

  return React.createElement("div", _extends({
    className: classNames("oui-dialog__wrapper", className)
  }, props), hasOverlay && React.createElement("div", {
    className: "oui-dialog__overlay"
  }), React.createElement("div", {
    "data-oui-component": true,
    className: "oui-dialog",
    "data-test-section": testSection
  }, hasCloseButton && React.createElement(CloseButton, {
    onClick: onClose,
    size: "medium"
  }), React.createElement("header", {
    className: "oui-dialog__header"
  }, React.createElement("h2", {
    className: "flush--bottom"
  }, title), subtitleContent), React.createElement("div", {
    className: "oui-dialog__body overflow-y--auto"
  }, children), React.createElement("footer", {
    className: "oui-dialog__footer-container"
  }, React.createElement(ButtonRow, {
    rightGroup: footerButtonList
  }))));
};
DialogNew.propTypes = {
  /**
   * The body of the dialog to request minimal information from the user.
   */
  children: PropTypes.node.isRequired,

  /** CSS class names. */
  className: PropTypes.string,

  /**
   * Array of buttons used in the footer of the dialog.
   */
  footerButtonList: PropTypes.array.isRequired,

  /**
   *  Used to determine if the dialog should have a close button.
   */
  hasCloseButton: PropTypes.bool,

  /**
   * Used to determine if dialog should have a semi
   * transparent overlay behind it.
   */
  hasOverlay: PropTypes.bool,

  /**
   *  Function to perform when the dialog is closed.
   */
  onClose: PropTypes.func,

  /**
   * A subtitle for the dialog.
   */
  subtitle: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),

  /**
   * Identifier used to create data-test-section attributes for testing.
   */
  testSection: PropTypes.string,

  /**
   * Main title of the dialog.
   */
  title: PropTypes.string.isRequired
};
DialogNew.defaultProps = {
  hasCloseButton: true,
  hasOverlay: true,
  onClose: function onClose() {
    return null;
  },
  subtitle: "",
  testSection: ""
};
var Dialog = {
  Fieldset: Fieldset,
  Footer: Footer,
  Title: Title,
  Wrapper: Wrapper
};
export default Dialog;