"use strict";

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

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["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 _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

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

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

var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));

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

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

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

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

var _trigger = _interopRequireDefault(require("../trigger"));

var _placements = require("./placements");

var _Content = _interopRequireDefault(require("./Content"));

var _excluded = ["overlayClassName", "trigger", "mouseEnterDelay", "mouseLeaveDelay", "overlayStyle", "prefixCls", "children", "onVisibleChange", "onVisibleBeforeChange", "afterVisibleChange", "transitionName", "animation", "placement", "align", "destroyTooltipOnHide", "defaultVisible", "getTooltipContainer"];

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

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

  function Tooltip() {
    var _this;

    (0, _classCallCheck2["default"])(this, Tooltip);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _super.call.apply(_super, [this].concat(args));
    (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getPopupElement", function () {
      var _this$props = _this.props,
          arrowContent = _this$props.arrowContent,
          overlay = _this$props.overlay,
          prefixCls = _this$props.prefixCls,
          id = _this$props.id,
          theme = _this$props.theme;
      return [/*#__PURE__*/_react["default"].createElement("div", {
        className: "".concat(prefixCls, "-arrow ").concat(prefixCls, "-arrow-").concat(theme),
        key: "arrow"
      }, arrowContent), /*#__PURE__*/_react["default"].createElement(_Content["default"], {
        key: "content",
        trigger: _this.trigger,
        prefixCls: prefixCls,
        id: id,
        overlay: overlay,
        theme: theme
      })];
    });
    (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "saveTrigger", function (node) {
      _this.trigger = node;
    });
    return _this;
  }

  (0, _createClass2["default"])(Tooltip, [{
    key: "getPopupDomNode",
    value: function getPopupDomNode() {
      return this.trigger.getPopupDomNode();
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props2 = this.props,
          overlayClassName = _this$props2.overlayClassName,
          trigger = _this$props2.trigger,
          mouseEnterDelay = _this$props2.mouseEnterDelay,
          mouseLeaveDelay = _this$props2.mouseLeaveDelay,
          overlayStyle = _this$props2.overlayStyle,
          prefixCls = _this$props2.prefixCls,
          children = _this$props2.children,
          onVisibleChange = _this$props2.onVisibleChange,
          onVisibleBeforeChange = _this$props2.onVisibleBeforeChange,
          afterVisibleChange = _this$props2.afterVisibleChange,
          transitionName = _this$props2.transitionName,
          animation = _this$props2.animation,
          placement = _this$props2.placement,
          align = _this$props2.align,
          destroyTooltipOnHide = _this$props2.destroyTooltipOnHide,
          defaultVisible = _this$props2.defaultVisible,
          getTooltipContainer = _this$props2.getTooltipContainer,
          restProps = (0, _objectWithoutProperties2["default"])(_this$props2, _excluded);
      var extraProps = (0, _objectSpread2["default"])({}, restProps);

      if ('visible' in this.props) {
        extraProps.popupVisible = this.props.visible;
      }

      return /*#__PURE__*/_react["default"].createElement(_trigger["default"], (0, _extends2["default"])({
        popupClassName: overlayClassName,
        ref: this.saveTrigger,
        prefixCls: prefixCls,
        popup: this.getPopupElement,
        action: trigger,
        builtinPlacements: _placements.placements,
        popupPlacement: placement,
        popupAlign: align,
        getPopupContainer: getTooltipContainer,
        beforePopupVisibleChange: onVisibleBeforeChange,
        onPopupVisibleChange: onVisibleChange,
        afterPopupVisibleChange: afterVisibleChange,
        popupTransitionName: transitionName,
        popupAnimation: animation,
        defaultPopupVisible: defaultVisible,
        destroyPopupOnHide: destroyTooltipOnHide,
        mouseLeaveDelay: mouseLeaveDelay,
        popupStyle: overlayStyle,
        mouseEnterDelay: mouseEnterDelay
      }, extraProps), children);
    }
  }]);
  return Tooltip;
}(_react.Component);

(0, _defineProperty2["default"])(Tooltip, "defaultProps", {
  prefixCls: 'rc-tooltip',
  mouseEnterDelay: 0,
  destroyTooltipOnHide: false,
  mouseLeaveDelay: 0.1,
  align: {},
  placement: 'right',
  trigger: ['hover'],
  arrowContent: null
});
var _default = Tooltip;
exports["default"] = _default;
//# sourceMappingURL=Tooltip.js.map
