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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

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 React from "react";
import classNames from "classnames";
import PropTypes from "prop-types";
var DEFAULT_PADDING_PROP = "default";
var HARD_PADDING_PROP = "hard";
var SOFT_DOUBLE_PROP = "soft-double";
var SOFT_HALF_PADDING_PROP = "soft-half";
/**
 * Simple component often used to display supplemental information to contents
 * on a page.
 *
 * See `OverlayWrapper` component to position a popover on a page.
 * @param {Object} props - Properties passed to component
 * @returns {ReactElement}
 */

var Popover = function Popover(_ref) {
  var children = _ref.children,
      className = _ref.className,
      padding = _ref.padding,
      testSection = _ref.testSection,
      title = _ref.title,
      props = _objectWithoutProperties(_ref, ["children", "className", "padding", "testSection", "title"]);

  var popOverClasses = classNames({
    "oui-pop--over": true
  }, className);
  var popOverContentClasses = classNames({
    "oui-pop--over__content": true
  });
  var shouldAddPaddingClass = padding !== DEFAULT_PADDING_PROP && [HARD_PADDING_PROP, SOFT_DOUBLE_PROP, SOFT_HALF_PADDING_PROP].includes(padding);

  if (shouldAddPaddingClass) {
    popOverContentClasses = classNames(_defineProperty({
      "oui-pop--over__content": true
    }, padding, true));
  }

  return React.createElement("div", _extends({
    "data-oui-component": true,
    className: popOverClasses,
    style: {
      display: "block",
      opacity: 1,
      position: "initial"
    },
    "data-test-section": testSection
  }, props), React.createElement("div", {
    className: popOverContentClasses
  }, title && React.createElement("div", {
    className: "oui-pop--over__title"
  }, title), children));
};

Popover.propTypes = {
  /** Content that appears within the popover body */
  children: PropTypes.node.isRequired,

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

  /** Padding class or 'default' padding for the popover container */
  padding: PropTypes.oneOf([DEFAULT_PADDING_PROP, HARD_PADDING_PROP, SOFT_DOUBLE_PROP, SOFT_HALF_PADDING_PROP]),

  /** Hook for automated JavaScript tests */
  testSection: PropTypes.string,

  /** Text describing the popover contents */
  title: PropTypes.string
};
Popover.defaultProps = {
  padding: "default"
};
export default Popover;