/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module AccuDraw
 */
import * as React from "react";
import { DivWithOutsideClick, Icon, Size } from "@itwin/core-react";
import { PopupManager } from "../popup/PopupManager";
import { PositionPopup, PositionPopupContent } from "../popup/PositionPopup";
import { Calculator } from "./Calculator";
/** Popup component for Calculator
 * @alpha
 */
export class CalculatorPopup extends React.PureComponent {
    constructor() {
        super(...arguments);
        /** @internal */
        this.state = {
            size: new Size(-1, -1),
        };
        this._onSizeKnown = (newSize) => {
            // istanbul ignore else
            if (!this.state.size.equals(newSize))
                this.setState({ size: Size.create(newSize) });
        };
    }
    /** @internal */
    render() {
        const point = PopupManager.getPopupPosition(this.props.el, this.props.pt, this.props.offset, this.state.size);
        return (React.createElement(PositionPopup, { key: this.props.id, point: point, className: "uifw-calculator-host", onSizeKnown: this._onSizeKnown },
            React.createElement(DivWithOutsideClick, { onOutsideClick: this.props.onCancel },
                React.createElement(PositionPopupContent, null,
                    React.createElement(Calculator, { initialValue: this.props.initialValue, resultIcon: React.createElement(Icon, { iconSpec: this.props.resultIcon }), onOk: this.props.onOk, onCancel: this.props.onCancel })))));
    }
}
//# sourceMappingURL=CalculatorPopup.js.map