"use strict";

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

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

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

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

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _bem = require("@zarm-design/bem");

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

var _configProvider = require("../config-provider");

var _popper = _interopRequireDefault(require("../popper"));

var Tooltip = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
  var children = props.children,
      content = props.content,
      className = props.className,
      others = (0, _objectWithoutProperties2.default)(props, ["children", "content", "className"]);

  var _React$useContext = _react.default.useContext(_configProvider.ConfigContext),
      prefixCls = _React$useContext.prefixCls;

  var bem = (0, _bem.createBEM)('tooltip', {
    prefixCls: prefixCls
  });
  var cls = bem([className]);
  var poperRef = (0, _react.useRef)(null);
  (0, _react.useImperativeHandle)(ref, function () {
    return {
      update: function update() {
        var _poperRef$current;

        return (_poperRef$current = poperRef.current) === null || _poperRef$current === void 0 ? void 0 : _poperRef$current.update();
      }
    };
  });
  return /*#__PURE__*/_react.default.createElement(_popper.default, (0, _extends2.default)({
    content: content,
    className: cls
  }, others, {
    ref: poperRef
  }), children);
});
Tooltip.defaultProps = {
  direction: 'top',
  hasArrow: true,
  onVisibleChange: function onVisibleChange() {}
};
var _default = Tooltip;
exports.default = _default;