'use client' import { useEffect, useState } from 'react' import { formatShortcutKeys, SHORTCUT_EVENTS, type ShortcutDefinition, SHORTCUTS } from '@/lib/keyboard-shortcuts' import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from './ui/dialog' const shortcutList: ShortcutDefinition[] = Object.values(SHORTCUTS).filter( s => s.id !== 'showShortcuts' ) function ShortcutKey({ children }: { children: string }) { return ( {children} ) } export function KeyboardShortcutDialog() { const [open, setOpen] = useState(false) useEffect(() => { const handler = () => setOpen(prev => !prev) window.addEventListener(SHORTCUT_EVENTS.showShortcuts, handler) return () => window.removeEventListener(SHORTCUT_EVENTS.showShortcuts, handler) }, []) return ( Keyboard Shortcuts List of available keyboard shortcuts
{shortcutList.map(shortcut => (
{shortcut.description}
{formatShortcutKeys(shortcut).map((key, i) => ( {key} ))}
))}
{SHORTCUTS.showShortcuts.description}
{formatShortcutKeys(SHORTCUTS.showShortcuts).map((key, i) => ( {key} ))}
) }