@@ -50,45 +50,16 @@ export interface AutocompleteProps {
5050 items : AutocompleteItem [ ]
5151 highlightedItem : AutocompleteItem
5252 onSelect : ( hit : AutocompleteItem ) => void
53- onClearRecents ?: ( ) => void
5453}
5554
56- export default function Autocomplete ( { items, highlightedItem, onSelect, onClearRecents } : AutocompleteProps ) {
57- let recentHeaderShown = false
55+ export default function Autocomplete ( { items, highlightedItem, onSelect } : AutocompleteProps ) {
5856 return (
5957 < ul >
60- { items . map ( ( item , i ) => {
61- let header = null
62- if ( item instanceof RecentLocationItem && ! recentHeaderShown ) {
63- recentHeaderShown = true
64- header = (
65- < div className = { styles . recentHeader } >
66- < span className = { styles . recentHeaderText } > Recent</ span >
67- { onClearRecents && (
68- < button
69- className = { styles . clearRecentsButton }
70- onMouseDown = { e => e . preventDefault ( ) }
71- onClick = { onClearRecents }
72- title = "Clear recent locations"
73- >
74- < svg xmlns = "http://www.w3.org/2000/svg" width = "12" height = "12" viewBox = "0 -960 960 960" >
75- < path
76- fill = "currentColor"
77- d = "m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"
78- />
79- </ svg >
80- </ button >
81- ) }
82- </ div >
83- )
84- }
85- return (
86- < li key = { i } className = { styles . autocompleteItem } >
87- { header }
88- { mapToComponent ( item , highlightedItem === item , onSelect ) }
89- </ li >
90- )
91- } ) }
58+ { items . map ( ( item , i ) => (
59+ < li key = { i } className = { styles . autocompleteItem } >
60+ { mapToComponent ( item , highlightedItem === item , onSelect ) }
61+ </ li >
62+ ) ) }
9263 </ ul >
9364 )
9465}
@@ -153,9 +124,17 @@ function RecentLocationEntry({
153124} ) {
154125 return (
155126 < AutocompleteEntry isHighlighted = { isHighlighted } onSelect = { ( ) => onSelect ( item ) } >
156- < div className = { styles . recentLocationEntry } title = { item . toText ( ) } >
157- < span className = { styles . mainText } > { item . mainText } </ span >
158- < span className = { styles . secondaryText } > { item . secondText } </ span >
127+ < div className = { styles . recentEntry } title = { item . toText ( ) } >
128+ < svg className = { styles . recentIcon } xmlns = "http://www.w3.org/2000/svg" width = "20" height = "20" viewBox = "0 -960 960 960" >
129+ < path
130+ fill = "currentColor"
131+ d = "M480-120q-150 0-255-105T120-480q0-150 105-255t255-105q150 0 255 105t105 255q0 150-105 255T480-120Zm0-80q117 0 198.5-81.5T760-480q0-117-81.5-198.5T480-760q-117 0-198.5 81.5T200-480q0 117 81.5 198.5T480-200Zm-40-264v-216h80v184l128 128-56 56-152-152Z"
132+ />
133+ </ svg >
134+ < div className = { styles . recentEntryText } >
135+ < span className = { styles . mainText } > { item . mainText } </ span >
136+ < span className = { styles . secondaryText } > { item . secondText } </ span >
137+ </ div >
159138 </ div >
160139 </ AutocompleteEntry >
161140 )
0 commit comments