import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import ClickAwayListener from '@mui/material/ClickAwayListener';
import { Button } from '../Button';
import { Chevron } from '../Chevron';
import { Menu } from '../Menu';
import { useMenu } from '../useMenu';
export const DropdownButton = ({ children, name, popoverProps, ...props }) => {
    const { open, anchorRef, handleOpenMenu, handleCloseMenu } = useMenu();
    return (_jsxs(_Fragment, { children: [_jsx(ClickAwayListener, { onClickAway: handleCloseMenu, children: _jsx(Button, { ...props, ref: anchorRef, selected: open, onClick: handleOpenMenu, endIcon: _jsx(Chevron, { isActive: open }), children: name }) }), _jsx(Menu, { open: open, anchorEl: anchorRef.current, ...popoverProps, children: children })] }));
};
