|
|
|
|
@@ -12,6 +12,7 @@ interface CommandPaletteProps {
|
|
|
|
|
onSelect: (result: SearchResult) => void
|
|
|
|
|
data: SearchResult[]
|
|
|
|
|
onOpen?: () => void
|
|
|
|
|
onQueryChange?: (query: string) => void
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const CATEGORY_LABELS: Record<SearchCategory | 'all', string> = {
|
|
|
|
|
@@ -60,7 +61,7 @@ function highlightText(text: string, query: string, matchRanges?: [number, numbe
|
|
|
|
|
return <>{parts}</>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function CommandPalette({ open, onClose, onSelect, data, onOpen }: CommandPaletteProps) {
|
|
|
|
|
export function CommandPalette({ open, onClose, onSelect, data, onOpen, onQueryChange }: CommandPaletteProps) {
|
|
|
|
|
const [query, setQuery] = useState('')
|
|
|
|
|
const [activeCategory, setActiveCategory] = useState<SearchCategory | 'all'>('all')
|
|
|
|
|
const [scopeFilters, setScopeFilters] = useState<ScopeFilter[]>([])
|
|
|
|
|
@@ -102,7 +103,7 @@ export function CommandPalette({ open, onClose, onSelect, data, onOpen }: Comman
|
|
|
|
|
if (query.trim()) {
|
|
|
|
|
const q = query.toLowerCase()
|
|
|
|
|
results = results.filter(
|
|
|
|
|
(r) => r.title.toLowerCase().includes(q) || r.meta.toLowerCase().includes(q),
|
|
|
|
|
(r) => r.serverFiltered || r.title.toLowerCase().includes(q) || r.meta.toLowerCase().includes(q),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -208,6 +209,7 @@ export function CommandPalette({ open, onClose, onSelect, data, onOpen }: Comman
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
setQuery(e.target.value)
|
|
|
|
|
setFocusedIdx(0)
|
|
|
|
|
onQueryChange?.(e.target.value)
|
|
|
|
|
}}
|
|
|
|
|
aria-label="Search"
|
|
|
|
|
/>
|
|
|
|
|
|