"use client" import { useEffect, useRef, useState } from "react" import { usePathname, useRouter } from "next/navigation" import { navigationGroups } from "@/lib/navigation" import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@/components/ui/command" import { Dialog, DialogContent, DialogDescription, DialogTitle } from "@/components/ui/dialog" /** Keyboard search from the App Shell 12 composition, using installed Base UI primitives. */ export function CommandPalette() { const [open, setOpen] = useState(false) const [query, setQuery] = useState("") const inputRef = useRef(null) const returnFocusRef = useRef(null) const pathname = usePathname() const router = useRouter() useEffect(() => { function onKey(event: KeyboardEvent) { if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k" && !event.isComposing) { event.preventDefault() if (!open) { returnFocusRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null setQuery("") } setOpen(!open) } } window.addEventListener("keydown", onKey) return () => window.removeEventListener("keydown", onKey) }, [open]) useEffect(() => { queueMicrotask(() => setOpen(false)) }, [pathname]) return ( Поиск страниц Найдите раздел по названию или ключевым словам. Стрелки выбирают страницу, Enter открывает её, Escape закрывает поиск.

Ничего не найдено. Попробуйте другое название.

{navigationGroups.map(group => ( {group.items.map(item => { const Icon = item.icon return ( { setOpen(false) router.push(item.url) }}> ) })} ))}

↑↓ выбрать · Enter открыть · Esc закрыть

) }