import React, { Component } from 'react';
import classNames from 'classnames';
export class SoftTooltipPopover extends Component {
    constructor() {
        super(...arguments);
        this.updateDimensions = () => {
            requestAnimationFrame(() => {
                // Because of this delay, sometimes `positionToolTip` becomes unavailable.
                if (this.popover) {
                    this.props.positionToolTip(this.popover.getBoundingClientRect());
                }
            });
        };
        this.setPopoverRef = (ref) => {
            this.popover = ref;
            if (this.props.popoverRef) {
                this.props.popoverRef(ref);
            }
        };
    }
    componentDidMount() {
        document.body.classList.add('softBody-hasPortalContent');
        this.updateDimensions();
        window.addEventListener('resize', this.updateDimensions);
    }
    componentWillUnmount() {
        document.body.classList.remove('softBody-hasPortalContent');
        window.removeEventListener('resize', this.updateDimensions);
    }
    render() {
        const { children, title, className, positionToolTip, popoverRef, ...rest } = this.props;
        const classes = classNames('softToolTipPopover', className);
        let optionalTitle;
        if (title) {
            optionalTitle = React.createElement("div", { className: "softToolTip__title" }, title);
        }
        return (React.createElement("div", Object.assign({ className: classes, ref: this.setPopoverRef }, rest),
            optionalTitle,
            children));
    }
}
//# sourceMappingURL=SoftTooltipPopover.js.map