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