'use strict';

Object.defineProperty(exports, "__esModule", {
	value: true
});

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _reactBootstrap = require('react-bootstrap');

var _uuid = require('uuid');

var _uuid2 = _interopRequireDefault(_uuid);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _TooltipTrigger = require('./TooltipTrigger.scss');

var _TooltipTrigger2 = _interopRequireDefault(_TooltipTrigger);

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

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function getTooltipClass() {
	var _classNames;

	return (0, _classnames2.default)((_classNames = {}, _defineProperty(_classNames, _TooltipTrigger2.default['tooltip-container'], true), _defineProperty(_classNames, 'tooltip-container', true), _classNames));
}

/**
 * @param {object} props react props
 * @example
const props = {
	label: 'Help content here',
	tooltipPlacement: 'top',
};
<TooltipTrigger {...props} >
	<Icon name="my-icon" />
</TooltipTrigger>
 */
function TooltipTrigger(props) {
	var tooltip = _react2.default.createElement(
		_reactBootstrap.Tooltip,
		{ className: getTooltipClass(), id: _uuid2.default.v4() },
		props.label
	);
	return _react2.default.createElement(
		_reactBootstrap.OverlayTrigger,
		{
			placement: props.tooltipPlacement,
			overlay: tooltip,
			delayShow: 400
		},
		props.children
	);
}

TooltipTrigger.propTypes = {
	children: _react.PropTypes.element,
	label: _react.PropTypes.string,
	tooltipPlacement: _reactBootstrap.OverlayTrigger.propTypes.placement
};

exports.default = TooltipTrigger;