"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
            t[p[i]] = s[p[i]];
    return t;
};
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/* @flow */
const React = __importStar(require("react"));
{
    TooltipProps;
}
from;
'./types';
const prop_types_1 = __importDefault(require("prop-types"));
const classnames_1 = __importDefault(require("classnames"));
const react_tippy_1 = require("react-tippy");
const types_1 = require("components/config/types");
const withStyles_1 = __importDefault(require("components/hoc/withStyles"));
const ErrorBoundary_1 = __importDefault(require("components/hoc/ErrorBoundary"));
const styles_1 = __importDefault(require("./styles"));
class Tooltip extends React.Component {
    constructor() {
        super(...arguments);
        this.state = {
            isVisible: false,
        };
    }
    render() {
        const _a = this.props, { classes, children, title, html, position, animation, arrow, onShow, onHide, trigger, theme } = _a, // eslint-disable-line
        rest = __rest(_a, ["classes", "children", "title", "html", "position", "animation", "arrow", "onShow", "onHide", "trigger", "theme"]);
        const { isVisible } = this.state;
        return (React.createElement(ErrorBoundary_1.default, null,
            React.createElement("div", { className: classnames_1.default(classes.component) },
                React.createElement(react_tippy_1.Tooltip, Object.assign({}, rest, { title: title, html: html, animation: animation, position: position, arrow: arrow, arrowType: "round", onShow: () => {
                        this.setState({ isVisible: true });
                        onShow();
                    }, onHide: () => {
                        this.setState({ isVisible: false });
                        onHide();
                    }, trigger: trigger, theme: "dark" }), children({ isVisible })))));
    }
}
Tooltip.propTypes = Object.assign({ 
    /* Plain string */
    title: prop_types_1.default.string, 
    /* Tooltip content. If you don't define html, the title will be used */
    html: prop_types_1.default.node, 
    /** Specifies the type of transition animation a tooltip has. */
    animation: prop_types_1.default.oneOf([
        'shift',
        'perspective',
        'fade',
        'scale',
        'none',
    ]), 
    /** Specifies which direction to position the tooltip on the element. */
    position: prop_types_1.default.oneOf(['top', 'bottom', 'left', 'right']), 
    /** Adds an arrow pointing to the tooltipped element. */
    arrow: prop_types_1.default.bool, 
    /** Specifies how big the tooltip's arrow is. */
    arrowSize: prop_types_1.default.oneOf(['small', 'regular', 'big']), 
    /** Callback when the tooltip has been triggered and has started to transition in */
    onShow: prop_types_1.default.func, 
    /** Callback when the tooltip has begun to transition out */
    onHide: prop_types_1.default.func, 
    /** Specifies which type of events will trigger a tooltip to show. Separate each by a space. mouseenter is for hovering and touch on mobile, and focus is for keyboard navigation. */
    trigger: prop_types_1.default.string, children: prop_types_1.default.func }, types_1.withStylesProps);
Tooltip.defaultProps = {
    title: '',
    onShow: () => { },
    onHide: () => { },
    position: 'top',
    arrowSize: 'regular',
    arrow: true,
    trigger: 'mouseenter focus',
    animation: 'fade',
    children: null,
};
exports.default = withStyles_1.default(styles_1.default)(Tooltip);
//# sourceMappingURL=index.js.map