/*---------------------------------------------------------------------------------------------
 * 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 "./PositionPopup.scss";
import classnames from "classnames";
import * as React from "react";
import { Div, Size } from "@itwin/core-react";
/** Popup component at screen position
 * @beta */
export class PositionPopup extends React.PureComponent {
    constructor(props) {
        super(props);
    }
    render() {
        const { point, className, style, onSizeKnown, ...props } = this.props;
        const divStyle = {
            ...style,
            top: point.y,
            left: point.x,
        };
        return (React.createElement("div", { ...props, className: classnames("uifw-position-popup", className), style: divStyle, ref: (e) => this.setDivRef(e) }, this.props.children));
    }
    setDivRef(div) {
        // istanbul ignore else
        if (div) {
            const rect = div.getBoundingClientRect();
            const size = new Size(rect.width, rect.height);
            // istanbul ignore else
            if (this.props.onSizeKnown)
                this.props.onSizeKnown(size);
        }
    }
}
/** PositionPopup content with padding
 * @beta
 */
export function PositionPopupContent(props) {
    return React.createElement(Div, { ...props, mainClassName: "uifw-position-popup-content" });
}
//# sourceMappingURL=PositionPopup.js.map