"use strict";

exports.__esModule = true;
exports.default = void 0;

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

var _propTypes = _interopRequireDefault(require("prop-types"));

var _ = require("./..");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }

/**
 * @category communication
 * @component tooltip
 * @variations collab-ui-react
 */
var Tooltip =
/*#__PURE__*/
function (_React$Component) {
  _inheritsLoose(Tooltip, _React$Component);

  function Tooltip() {
    return _React$Component.apply(this, arguments) || this;
  }

  var _proto = Tooltip.prototype;

  _proto.render = function render() {
    var _this$props = this.props,
        tooltip = _this$props.tooltip,
        direction = _this$props.direction,
        tooltipTrigger = _this$props.tooltipTrigger,
        popupDelay = _this$props.popupDelay,
        popupCloseDelay = _this$props.popupCloseDelay,
        className = _this$props.className,
        children = _this$props.children,
        width = _this$props.width;
    var contentStyle = width ? {
      width: width
    } : {};

    var content = _react.default.createElement("span", {
      style: contentStyle,
      className: "cui-tooltip__text"
    }, tooltip);

    return _react.default.createElement(_.Popover, {
      content: content,
      popoverTrigger: tooltipTrigger,
      direction: direction,
      className: "cui-tooltip " + className,
      popupDelay: popupDelay,
      popupCloseDelay: popupCloseDelay,
      showArrow: true
    }, children);
  };

  return Tooltip;
}(_react.default.Component);

Tooltip.displayName = 'Tooltip';
Tooltip.defaultProps = {
  children: null,
  className: '',
  popupDelay: null,
  popupCloseDelay: null,
  direction: 'top-center',
  tooltipTrigger: 'MouseEnter',
  tooltip: '',
  width: null
};
Tooltip.propTypes = {
  /**
   * Tooltip Message
   */
  tooltip: _propTypes.default.string,

  /**
   * optional popup Delay tooltip for tooltip to showup after mouseEnter.
   */
  popupDelay: _propTypes.default.number,

  /**
   * optional popup Delay Close tooltip for tooltip to close after mouseLeave.
   */
  popupCloseDelay: _propTypes.default.number,

  /**
   * Event that will trigger tooltip appearance
   */
  tooltipTrigger: _propTypes.default.oneOf(['MouseEnter', 'Click', 'Focus']),

  /**
   * optional placement of tooltip
   */
  direction: _propTypes.default.oneOf(['top-center', 'top-left', 'top-right', 'left-center', 'left-top', 'left-bottom', 'bottom-center', 'bottom-left', 'bottom-right', 'right-center', 'right-top', 'right-bottom']),

  /**
   * css class names
   */
  className: _propTypes.default.string,

  /**
   * children of class
   */
  children: _propTypes.default.node,

  /**
   * width of tooltip content
   */
  width: _propTypes.default.number
};
var _default = Tooltip;
/**
* @name Tooltip Default
*
* @category communication
* @component tooltip
* @section default
*
* @js
*
* import {
*   Button
* } from '@collab-ui/react';
*
* export default function TooltipDefault() {
*   return (
*     <div className='row'>
*       <div>
*         <Tooltip
            tooltip='Hey There good buddy'
            direction='top-center'
            className="widthOverride"
            >
*           <Button
*             children='Hover Top'
*             ariaLabel='Hover Top'
*             color='primary'
*             onClick={() => { }}
*           />
*         </Tooltip>
*       </div>
*       <br />
*     </div>
*   );
* }
*
**/

/**
* @name Tooltip Bottom
*
* @category communication
* @component tooltip
* @section positional
*
* @js
*
* import {
*   Button
* } from '@collab-ui/react';
*
* export default function TooltipDefault() {
*   return (
*     <div className='row'>
*       <div>
*         <Tooltip
*           tooltip='Hey There good buddy'
*           direction='bottom-center'
*           tooltipTrigger='Focus'
*           popupDelay={500}
*           popupCloseDelay={100}
*         >
*           <Button
*             children='Focus Bottom'
*             ariaLabel='Focus Bottom'
*             color='primary'
*             onClick={() => { }}
*           />
*         </Tooltip>
*       </div>
*       <br />
*     </div>
*   );
* }
*
**/

/**
* @name Tooltip Click
*
* @category communication
* @component tooltip
* @section trigger
*
* @js
*
* import {
*   Button
* } from '@collab-ui/react';
*
* export default function TooltipDefault() {
*   return (
*     <div className='row'>
*       <div>
*         <Tooltip
*           tooltip='Hey There good buddy'
*           direction='right-center'
*           tooltipTrigger='Click'
*         >
*           <Button
*             children='Click to Trigger'
*             ariaLabel='Click to Trigger'
*             color='primary'
*             onClick={() => { }}
*           />
*         </Tooltip>
*       </div>
*       <br />
*     </div>
*   );
* }
*
**/

exports.default = _default;