"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));

var _react = _interopRequireWildcard(require("react"));

var _tooltip = _interopRequireDefault(require("../tooltip"));

var _warning = _interopRequireDefault(require("../_util/warning"));

var _ConfigContext = _interopRequireDefault(require("../config-provider/ConfigContext"));

var Popover = /*#__PURE__*/function (_Component) {
  (0, _inherits2["default"])(Popover, _Component);

  var _super = (0, _createSuper2["default"])(Popover);

  function Popover() {
    var _this;

    (0, _classCallCheck2["default"])(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();

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

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

    return _this;
  }

  (0, _createClass2["default"])(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 = (0, _objectSpread2["default"])({}, this.props);
      delete props.title;
      return /*#__PURE__*/_react["default"].createElement(_tooltip["default"], (0, _extends2["default"])({}, props, {
        prefixCls: this.getPrefixCls(),
        ref: this.saveTooltip,
        overlay: this.getOverlay
      }));
    }
  }], [{
    key: "contextType",
    get: function get() {
      return _ConfigContext["default"];
    }
  }]);
  return Popover;
}(_react.Component);

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