"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 Toolbar
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.OverflowButton = exports.ToolGroupOverflowContext = void 0;
const React = require("react");
const itwinui_react_1 = require("@itwin/itwinui-react");
const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
const Item_1 = require("./Item");
const GroupItem_1 = require("./GroupItem");
const Toolbar_1 = require("./Toolbar");
/** @internal */
exports.ToolGroupOverflowContext = React.createContext(undefined);
/** @internal */
exports.OverflowButton = React.forwardRef(function OverflowButton(props, ref) {
    const placement = (0, GroupItem_1.usePopoverPlacement)();
    const labelProps = (0, Item_1.useLabelProps)();
    const context = React.useContext(Toolbar_1.ToolbarContext);
    return (React.createElement(itwinui_react_1.DropdownMenu, { menuItems: (close) => {
            return [
                React.createElement(OverflowMenu, { key: 0, onClose: close }, props.children),
            ];
        }, placement: placement, onVisibleChange: (newVisible) => {
            context?.setPopoverOpen(newVisible);
        } },
        React.createElement(itwinui_react_1.IconButton, { ref: ref, label: "More", labelProps: labelProps, styleType: "borderless" },
            React.createElement(itwinui_icons_react_1.SvgMore, null))));
});
function OverflowMenu({ children, onClose }) {
    return (React.createElement(exports.ToolGroupOverflowContext.Provider, { value: { onClose } }, children));
}
//# sourceMappingURL=OverflowButton.js.map