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

import React from 'react';
import PropTypes from 'prop-types';
import { Popover } from "./..";
/**
 * @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.createElement("span", {
      style: contentStyle,
      className: "cui-tooltip__text"
    }, tooltip);
    return React.createElement(Popover, {
      content: content,
      popoverTrigger: tooltipTrigger,
      direction: direction,
      className: "cui-tooltip " + className,
      popupDelay: popupDelay,
      popupCloseDelay: popupCloseDelay,
      showArrow: true
    }, children);
  };

  return Tooltip;
}(React.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.string,

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

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

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

  /**
   * optional placement of tooltip
   */
  direction: PropTypes.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.string,

  /**
   * children of class
   */
  children: PropTypes.node,

  /**
   * width of tooltip content
   */
  width: PropTypes.number
};
export 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>
*   );
* }
*
**/