import _extends from "@babel/runtime/helpers/extends";
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _createSuper from "@babel/runtime/helpers/createSuper";
import React, { Component } from 'react';
import Tooltip from '../tooltip';
import warning from '../_util/warning';
import ConfigContext from '../config-provider/ConfigContext';

var Popover = /*#__PURE__*/function (_Component) {
  _inherits(Popover, _Component);

  var _super = _createSuper(Popover);

  function Popover() {
    var _this;

    _classCallCheck(this, Popover);

    _this = _super.apply(this, arguments);

    _this.getOverlay = function () {
      var _this$props = _this.props,
          title = _this$props.title,
          content = _this$props.content;

      var prefixCls = _this.getPrefixCls();

      warning(!('overlay' in _this.props), 'Popover[overlay] is removed, please use Popover[content] instead');
      var header = typeof title === 'function' ? title() : title;
      return /*#__PURE__*/React.createElement("div", null, header && /*#__PURE__*/React.createElement("div", {
        className: "".concat(prefixCls, "-title")
      }, header), /*#__PURE__*/React.createElement("div", {
        className: "".concat(prefixCls, "-inner-content")
      }, typeof content === 'function' ? content() : content));
    };

    _this.saveTooltip = function (node) {
      _this.tooltip = node;
    };

    return _this;
  }

  _createClass(Popover, [{
    key: "getPopupDomNode",
    value: function getPopupDomNode() {
      return this.tooltip.getPopupDomNode();
    }
  }, {
    key: "getPrefixCls",
    value: function getPrefixCls() {
      var prefixCls = this.props.prefixCls;
      var getPrefixCls = this.context.getPrefixCls;
      return getPrefixCls('popover', prefixCls);
    }
  }, {
    key: "render",
    value: function render() {
      var props = _objectSpread({}, this.props);

      delete props.title;
      return /*#__PURE__*/React.createElement(Tooltip, _extends({}, props, {
        prefixCls: this.getPrefixCls(),
        ref: this.saveTooltip,
        overlay: this.getOverlay
      }));
    }
  }], [{
    key: "contextType",
    get: function get() {
      return ConfigContext;
    }
  }]);

  return Popover;
}(Component);

export { Popover as default };
Popover.displayName = 'Popover';
Popover.defaultProps = {
  placement: 'top',
  transitionName: 'zoom-big',
  trigger: 'hover',
  mouseEnterDelay: 0.1,
  mouseLeaveDelay: 0.1,
  overlayStyle: {}
};
//# sourceMappingURL=index.js.map
