({
autocomplete,
query,
collection,
}: {
autocomplete: Autocomplete
query: string
collection: AutocompleteCollection<Result>
})
| 230 | } |
| 231 | |
| 232 | function SearchResults({ |
| 233 | autocomplete, |
| 234 | query, |
| 235 | collection, |
| 236 | }: { |
| 237 | autocomplete: Autocomplete |
| 238 | query: string |
| 239 | collection: AutocompleteCollection<Result> |
| 240 | }) { |
| 241 | if (collection.items.length === 0) { |
| 242 | return ( |
| 243 | <div className="p-6 text-center"> |
| 244 | <NoResultsIcon className="mx-auto h-5 w-5 stroke-zinc-900 dark:stroke-zinc-600" /> |
| 245 | <p className="mt-2 text-xs text-zinc-700 dark:text-zinc-400"> |
| 246 | Nothing found for{' '} |
| 247 | <strong className="break-words font-semibold text-zinc-900 dark:text-white"> |
| 248 | ‘{query}’ |
| 249 | </strong> |
| 250 | . Please try again. |
| 251 | </p> |
| 252 | </div> |
| 253 | ) |
| 254 | } |
| 255 | |
| 256 | return ( |
| 257 | <ul {...autocomplete.getListProps()}> |
| 258 | {collection.items.map((result, resultIndex) => ( |
| 259 | <SearchResult |
| 260 | key={result.url} |
| 261 | result={result} |
| 262 | resultIndex={resultIndex} |
| 263 | autocomplete={autocomplete} |
| 264 | collection={collection} |
| 265 | query={query} |
| 266 | /> |
| 267 | ))} |
| 268 | </ul> |
| 269 | ) |
| 270 | } |
| 271 | |
| 272 | const SearchInput = forwardRef< |
| 273 | React.ElementRef<'input'>, |
nothing calls this directly
no outgoing calls
no test coverage detected