import React, { useContext, useRef, RefObject } from 'react'; import styles from '../style.css'; import MenuItem from './menu-item'; import { ThemeContext } from '../theme'; import { useRect, useMenuScroll, useLayoutBounds, useScrollFocus } from '../effects'; import { currentSelected, menuItemClick, calcMaximums } from '../utils'; import { MenuListProps, FullMenuListProps } from '../typings'; const MenuList = ({ menu, parentRef, currentWindow, depth, selectedPath, dispatch, subLabel }: FullMenuListProps) => { const theme = useContext(ThemeContext); const menuRef = useRef(null); const scrollRef = useRef(null); const parentBounds = useRect(parentRef); const bounds = useRect(menuRef); const [maxHeight, maxWidth] = calcMaximums(bounds, theme); const hasSubLabel = !!(subLabel && subLabel !== "" && theme.menu.header!.show!); const layout = useLayoutBounds(parentBounds, depth, hasSubLabel); const handleScroll = useMenuScroll(scrollRef); useScrollFocus( currentSelected(selectedPath, depth), theme.menu.item!.height!, parentBounds, scrollRef ); return (