import { useState, useRef } from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import Menu from 'components/common/Menu'; import useDocumentClick from 'hooks/useDocumentClick'; import styles from './MenuButton.module.css'; import { Button } from 'react-basics'; function MenuButton({ children, value, options, buttonClassName, buttonVariant, menuClassName, menuPosition = 'bottom', menuAlign = 'right', onSelect, renderValue, hideLabel, }) { const [showMenu, setShowMenu] = useState(false); const ref = useRef(); const selectedOption = options.find(e => e.value === value); function handleSelect(value) { onSelect(value); setShowMenu(false); } function toggleMenu() { setShowMenu(state => !state); } useDocumentClick(e => { if (!ref.current?.contains(e.target)) { setShowMenu(false); } }); return (