/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Widget
 */
import * as React from "react";
import { useProximityToMouse, WidgetElementSet, WidgetOpacityContext, } from "@itwin/core-react";
import { ToolsArea } from "@itwin/appui-layout-react";
import { UiFramework } from "../UiFramework";
/**
 * ToolWidget component that supports use of ToolbarComposer-based Toolbars. The ToolWidget is shown in the top left of the content area
 * and typically holds tools to manipulate or interrogate content. The horizontal toolbar often includes context specific tools based on
 * selected items. The vertical toolbar typically contains a more fixed list of tools.
 * @public
 */
export function ToolWidgetComposer(props) {
    const { cornerItem, horizontalToolbar, verticalToolbar, ...otherProps } = props;
    const [elementSet] = React.useState(new WidgetElementSet());
    const handleChildRef = React.useCallback((elementRef) => {
        elementSet.add(elementRef);
    }, [elementSet]);
    const proximityScale = useProximityToMouse(elementSet, UiFramework.visibility.snapWidgetOpacity);
    return (React.createElement(WidgetOpacityContext.Provider, { value: {
            onElementRef: handleChildRef,
            proximityScale,
        } },
        React.createElement(ToolsArea, { button: cornerItem, horizontalToolbar: horizontalToolbar, verticalToolbar: verticalToolbar, ...otherProps, onMouseEnter: UiFramework.visibility.handleWidgetMouseEnter })));
}
//# sourceMappingURL=ToolWidgetComposer.js.map