"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _tooltip = _interopRequireDefault(require("antd/lib/tooltip"));
var _icon = _interopRequireDefault(require("@alifd/next/lib/icon"));
var _button = _interopRequireDefault(require("antd/lib/button"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
require("./index.less");
var _excluded = ["textValue", "tipColor", "defaultShow", "placement", "style", "mouseEnterDelay", "mouseLeaveDelay", "triggerMethod", "tipTextColor", "fontSize", "fontFamily", "tipsText", "type", "icons", "flag"];
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var antTooltip = function antTooltip(_ref) {
  var textValue = _ref.textValue,
    tipColor = _ref.tipColor,
    defaultShow = _ref.defaultShow,
    placement = _ref.placement,
    style = _ref.style,
    mouseEnterDelay = _ref.mouseEnterDelay,
    mouseLeaveDelay = _ref.mouseLeaveDelay,
    triggerMethod = _ref.triggerMethod,
    tipTextColor = _ref.tipTextColor,
    fontSize = _ref.fontSize,
    fontFamily = _ref.fontFamily,
    tipsText = _ref.tipsText,
    type = _ref.type,
    icons = _ref.icons,
    flag = _ref.flag,
    otherProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
  var _style = style || {};
  // _style['width'] = _style['width']
  // _style['fontSize'] = _style['fontSize'] ? _style['fontSize'] : '18px'

  var _otherProps = otherProps || {};
  var others = {};
  var _useState = (0, React.useState)(defaultShow),
    _defaultShow = _useState[0],
    setDefaultShow = _useState[1];
  _otherProps.style = _style;
  if (defaultShow) {
    others.visible = _defaultShow;
  } else {
    if (others.visible == true || others.visible == false) delete others.visible;
  }

  // 改变内容的颜色
  var tip = /*#__PURE__*/React.createElement("span", {
    style: {
      color: tipTextColor,
      fontSize: fontSize,
      fontFamily: fontFamily
    }
  }, tipsText);

  // console.log(_defaultShow)
  var $body = document.documentElement;
  $body.addEventListener('click', function (e) {
    setDefaultShow(false);
    console.log('点击到页面了');
  });
  return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
    id: "my-ant-tooptip"
  }, _otherProps, {
    className: flag ? 'tip-isflag' : 'tip-style'
  }), _defaultShow && /*#__PURE__*/React.createElement(_tooltip["default"], (0, _extends2["default"])({
    zIndex: _style['zIndex'],
    trigger: triggerMethod,
    mouseEnterDelay: mouseEnterDelay,
    mouseLeaveDelay: mouseLeaveDelay,
    title: tip,
    placement: placement,
    color: tipColor
  }, others, {
    getPopupContainer: function getPopupContainer(trigger) {
      return trigger.parentNode;
    }
  }), type == '文本' && /*#__PURE__*/React.createElement("span", {
    className: "my-tooptip"
  }, textValue), type == '按钮' && /*#__PURE__*/React.createElement(_button["default"], (0, _extends2["default"])({}, _otherProps, {
    className: "my_tip_btn"
  }), textValue), type == '图标' && /*#__PURE__*/React.createElement(_icon["default"], {
    type: icons
  })), _defaultShow || /*#__PURE__*/React.createElement(_tooltip["default"], {
    zIndex: _style['zIndex'],
    trigger: triggerMethod,
    mouseEnterDelay: mouseEnterDelay,
    mouseLeaveDelay: mouseLeaveDelay,
    title: tip,
    placement: placement,
    color: tipColor
  }, type == '文本' && /*#__PURE__*/React.createElement("span", {
    className: "my-tooptip"
  }, textValue), type == '按钮' && /*#__PURE__*/React.createElement(_button["default"], (0, _extends2["default"])({}, _otherProps, {
    className: "my_tip_btn"
  }), textValue), type == '图标' && /*#__PURE__*/React.createElement(_icon["default"], {
    type: icons
  })));
};
antTooltip.displayName = 'antTooltip';
var _default = antTooltip;
exports["default"] = _default;