/*---------------------------------------------------------------------------------------------
 * 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 { Orientation, useResizeObserver } from "@itwin/core-react";
import { AccuDrawFieldContainer } from "./AccuDrawFieldContainer";
import { WidgetControl } from "../widgets/WidgetControl";
import { UiFramework } from "../UiFramework";
/** AccuDraw Widget Control
 * @beta
 */
class AccuDrawWidgetControl extends WidgetControl {
    static get label() {
        return UiFramework.translate("accuDraw.dialogTitle");
    }
    constructor(info, options) {
        super(info, options);
        this.reactNode = React.createElement(AccuDrawWidget, null);
    }
}
AccuDrawWidgetControl.id = "AccuDrawWidget";
export { AccuDrawWidgetControl };
/** AccuDraw Widget displays [[AccuDrawFieldContainer]] for AccuDraw Ui
 * @beta
 */
export function AccuDrawWidget() {
    const [orientation, setOrientation] = React.useState(Orientation.Vertical);
    const breakpoint = 400;
    // istanbul ignore next - currently unable to replicate resizing in unit test
    const handleResize = React.useCallback((w, _h) => {
        setOrientation(w <= breakpoint ? Orientation.Vertical : Orientation.Horizontal);
    }, []);
    const ref = useResizeObserver(handleResize);
    return (React.createElement("div", { ref: ref },
        React.createElement(AccuDrawFieldContainer, { orientation: orientation })));
}
//# sourceMappingURL=AccuDrawWidget.js.map