/** * SearchHistory component for displaying and managing search history */ import { For, Show } from "solid-js" type SearchHistoryProps = { history: string[] focused: boolean selectedIndex: number onSelect?: (query: string) => void onRemove?: (query: string) => void onClear?: () => void onChange?: (index: number) => void } export function SearchHistory(props: SearchHistoryProps) { const handleSearchClick = (index: number, query: string) => { props.onChange?.(index) props.onSelect?.(query) } const handleRemoveClick = (query: string) => { props.onRemove?.(query) } return ( Recent Searches 0}> props.onClear?.()} padding={0}> [Clear All] 0} fallback={ No recent searches } > {(query, index) => { const isSelected = () => index() === props.selectedIndex && props.focused return ( handleSearchClick(index(), query)} > {">"} {query} handleRemoveClick(query)} padding={0}> [x] ) }} ) }