/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Popup
 */
import * as React from "react";
import { DivWithOutsideClick, MessageRenderer } from "@itwin/core-react";
import { Point } from "@itwin/core-react/internal";
import { CursorPopup } from "../cursor/cursorpopup/CursorPopup.js";
import { PopupManager } from "./PopupManager.js";
import { PositionPopup } from "./PositionPopup.js";
/** Popup component for HTMLElement
 * @alpha
 * @deprecated in 4.11.0. Though this is alpha, the main interface to using it is not. Please use {@link @itwin/appui-react#UiFramework.showComponent}.
 */
export class HTMLElementPopup extends React.PureComponent {
    state = {
        size: { width: -1, height: -1 },
    };
    _onSizeKnown = (newSize) => {
        if (newSize.height === this.state.size.height &&
            newSize.width === this.state.size.width)
            return;
        this.setState({ size: newSize });
    };
    render() {
        let point = PopupManager.getPopupPosition(this.props.el, this.props.pt, new Point(), this.state.size);
        const popupRect = CursorPopup.getPopupRect(point, this.props.offset, this.state.size, this.props.relativePosition);
        point = new Point(popupRect.left, popupRect.top);
        return (React.createElement(PositionPopup, { key: this.props.id, className: "uifw-no-border", point: point, onSizeKnown: this._onSizeKnown },
            React.createElement(DivWithOutsideClick, { onOutsideClick: this.props.onCancel },
                React.createElement(MessageRenderer, { message: this.props.element }))));
    }
}
//# sourceMappingURL=HTMLElementPopup.js.map