import { Button, ButtonProps } from '@/components/ui/button' import { useKeyboardNavigable } from '@/hooks/useKeyboardNavigable' import { cn } from '@/lib/utils' import { forwardRef, useCallback, useRef } from 'react' import { useTranslation } from 'react-i18next' const SidebarItem = forwardRef< HTMLButtonElement, ButtonProps & { title: string collapse: boolean description?: string active?: boolean navIndex?: number } >(({ children, title, description, className, active, collapse, navIndex, onClick, ...props }, _ref) => { const { t } = useTranslation() const buttonRef = useRef(null) const handleActivate = useCallback(() => { buttonRef.current?.click() }, []) const { ref: navRef, isSelected } = useKeyboardNavigable(0, navIndex ?? 0, { meta: { type: 'sidebar', onActivate: handleActivate } }) return (
) }) SidebarItem.displayName = 'SidebarItem' export default SidebarItem