import { useRef, useState } from "react"; import { SearchIcon } from "@chopin/icons"; import { NavigationDialog } from "./navigation-dialog"; import { currentShortcutPlatform, shortcutKeys, SHORTCUTS } from "./shortcuts"; import type { NavigationDialogMotion } from "./navigation-dialog"; export function KeyboardShortcutsDialog( { motion, onDismiss }: { motion: NavigationDialogMotion; onDismiss: () => void }, ) { let platform = currentShortcutPlatform(); let input = useRef(null); let [query, setQuery] = useState(""); let needle = query.trim().toLocaleLowerCase(); let shown = SHORTCUTS.filter(entry => entry.label.toLocaleLowerCase().includes(needle)); return (
{shown.length === 0 && (

No matching shortcuts

)} {(["General", "Editing"] as const).map(group => { let entries = shown.filter(entry => entry.group === group); if (entries.length === 0) return null; return (

{group}

{entries.map(entry => (
{entry.label}
{shortcutKeys(entry.id, platform).map(key => {key})}
))}
); })}
); }