import { Dropdown, DropdownMenu, DropdownToggle, } from '@/features/ui/components/bootstrap-5/dropdown-menu' import { FC, forwardRef, useCallback } from 'react' import classNames from 'classnames' import { useNestableDropdown } from '@/shared/hooks/use-nestable-dropdown' import { NestableDropdownContextProvider } from '@/shared/context/nestable-dropdown-context' import { AnchorProps } from 'react-bootstrap-5' import MaterialIcon from '../material-icon' import { DropdownMenuProps } from '@/features/ui/components/types/dropdown-menu-props' type MenuBarDropdownProps = { title: string id: string className?: string align?: 'start' | 'end' } export const MenuBarDropdown: FC = ({ title, children, id, className, align = 'start', }) => { const { menuId, selected, setSelected } = useNestableDropdown() const onToggle = useCallback( show => { setSelected(show ? id : null) }, [id, setSelected] ) const onHover = useCallback(() => { setSelected(prev => { if (prev === null) { return null } return id }) }, [id, setSelected]) return ( {title} {children} ) } const NestableDropdownMenu: FC = ({ children, id, ...props }) => { return ( {children} ) } const NestedDropdownToggle: FC = forwardRef( function NestedDropdownToggle( { children, className, onMouseEnter, id }, ref ) { return ( // eslint-disable-next-line jsx-a11y/anchor-is-valid {children} ) } ) export const NestedMenuBarDropdown: FC<{ id: string; title: string }> = ({ children, id, title, }) => { const { menuId, selected, setSelected } = useNestableDropdown() const select = useCallback(() => { setSelected(id) }, [id, setSelected]) const onToggle = useCallback( show => { setSelected(show ? id : null) }, [setSelected, id] ) const active = selected === id return ( {title} {children} ) }