import _extends from "@babel/runtime/helpers/extends";
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/inherits";
import _createSuper from "@babel/runtime/helpers/createSuper";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
var _excluded = ["overlayClassName", "trigger", "mouseEnterDelay", "mouseLeaveDelay", "overlayStyle", "prefixCls", "children", "onVisibleChange", "onVisibleBeforeChange", "afterVisibleChange", "transitionName", "animation", "placement", "align", "destroyTooltipOnHide", "defaultVisible", "getTooltipContainer"];
import React, { Component } from 'react';
import Trigger from '../trigger';
import { placements } from './placements';
import Content from './Content';

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

  var _super = _createSuper(Tooltip);

  function Tooltip() {
    var _this;

    _classCallCheck(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));

    _defineProperty(_assertThisInitialized(_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.createElement("div", {
        className: "".concat(prefixCls, "-arrow ").concat(prefixCls, "-arrow-").concat(theme),
        key: "arrow"
      }, arrowContent), /*#__PURE__*/React.createElement(Content, {
        key: "content",
        trigger: _this.trigger,
        prefixCls: prefixCls,
        id: id,
        overlay: overlay,
        theme: theme
      })];
    });

    _defineProperty(_assertThisInitialized(_this), "saveTrigger", function (node) {
      _this.trigger = node;
    });

    return _this;
  }

  _createClass(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 = _objectWithoutProperties(_this$props2, _excluded);

      var extraProps = _objectSpread({}, restProps);

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

      return /*#__PURE__*/React.createElement(Trigger, _extends({
        popupClassName: overlayClassName,
        ref: this.saveTrigger,
        prefixCls: prefixCls,
        popup: this.getPopupElement,
        action: trigger,
        builtinPlacements: 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;
}(Component);

_defineProperty(Tooltip, "defaultProps", {
  prefixCls: 'rc-tooltip',
  mouseEnterDelay: 0,
  destroyTooltipOnHide: false,
  mouseLeaveDelay: 0.1,
  align: {},
  placement: 'right',
  trigger: ['hover'],
  arrowContent: null
});

export default Tooltip;
//# sourceMappingURL=Tooltip.js.map
