"use client"; import { CommandDialog, CommandEmpty, CommandInput, CommandList, } from "@mdxui/primitives/command"; import { useCallback } from "react"; import { SearchEmpty } from "./components/search-empty"; import { SearchResultItem } from "./components/search-result-item"; import { SearchFooter } from "./search-footer"; import { useSearchContext } from "./search-provider"; import type { SearchResult } from "./searchbox-types"; interface SearchPaletteProps { placeholder?: string; } export function SearchPalette({ placeholder = "Search documentation...", }: SearchPaletteProps) { const { isOpen, setIsOpen, query, setQuery, results, selectResult, isLoading, } = useSearchContext(); const handleSelect = useCallback( (result: SearchResult) => { selectResult(result); }, [selectResult], ); const showEmpty = query && results.length === 0 && !isLoading; return ( {/* Empty state */} {showEmpty && ( )} {/* Search results */} {results.length > 0 && (
{results.map((result) => ( ))}
)}
); }