"use strict";
/*---------------------------------------------------------------------------------------------
* 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
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.PositionPopupContent = exports.PositionPopup = void 0;
require("./PositionPopup.scss");
const classnames_1 = require("classnames");
const React = require("react");
const core_react_1 = require("@itwin/core-react");
/** Popup component at screen position
 * @beta */
class PositionPopup extends React.PureComponent {
    constructor(props) {
        super(props);
    }
    render() {
        const { point, className, style, onSizeKnown, ...props } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars
        const divStyle = {
            ...style,
            top: point.y,
            left: point.x,
        };
        return (React.createElement("div", { ...props, className: (0, classnames_1.default)("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 core_react_1.Size(rect.width, rect.height);
            // istanbul ignore else
            if (this.props.onSizeKnown)
                this.props.onSizeKnown(size);
        }
    }
}
exports.PositionPopup = PositionPopup;
/** PositionPopup content with padding
 * @beta
 */
function PositionPopupContent(props) {
    return React.createElement(core_react_1.Div, { ...props, mainClassName: "uifw-position-popup-content" });
}
exports.PositionPopupContent = PositionPopupContent;
//# sourceMappingURL=PositionPopup.js.map