/*---------------------------------------------------------------------------------------------
 * 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 } from "@itwin/components-react";
import { useResizeObserver } from "@itwin/core-react";
import { AccuDrawFieldContainer } from "./AccuDrawFieldContainer";
import { WidgetControl } from "../widgets/WidgetControl";
import { UiFramework } from "../UiFramework";
/** AccuDraw Widget Control
 * @public
 * @deprecated in 4.16.0. Use {@link AccuDrawWidget} component instead.
 */
// eslint-disable-next-line deprecation/deprecation
export class AccuDrawWidgetControl extends WidgetControl {
    static get label() {
        return UiFramework.translate("accuDraw.dialogTitle");
    }
    // eslint-disable-next-line deprecation/deprecation
    constructor(info, options) {
        super(info, options);
        this.reactNode = React.createElement(AccuDrawWidget, null);
    }
}
AccuDrawWidgetControl.id = "AccuDrawWidget";
/** AccuDraw Widget displays [[AccuDrawFieldContainer]] for AccuDraw Ui
 * @public
 */
export function AccuDrawWidget() {
    const [orientation, setOrientation] = React.useState(Orientation.Vertical);
    const breakpoint = 400;
    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