"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DropdownButton = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const ClickAwayListener_1 = __importDefault(require("@mui/material/ClickAwayListener"));
const Button_1 = require("../Button");
const Chevron_1 = require("../Chevron");
const Menu_1 = require("../Menu");
const useMenu_1 = require("../useMenu");
const DropdownButton = ({ children, name, popoverProps, ...props }) => {
    const { open, anchorRef, handleOpenMenu, handleCloseMenu } = (0, useMenu_1.useMenu)();
    return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ClickAwayListener_1.default, { onClickAway: handleCloseMenu, children: (0, jsx_runtime_1.jsx)(Button_1.Button, { ...props, ref: anchorRef, selected: open, onClick: handleOpenMenu, endIcon: (0, jsx_runtime_1.jsx)(Chevron_1.Chevron, { isActive: open }), children: name }) }), (0, jsx_runtime_1.jsx)(Menu_1.Menu, { open: open, anchorEl: anchorRef.current, ...popoverProps, children: children })] }));
};
exports.DropdownButton = DropdownButton;
