@@ -46,88 +46,84 @@ export function createLocalStorageRecentlyViewedItems<
4646> (
4747 params : CreateLocalStorageRecentlyViewedItemsParams < TItem >
4848) : AutocompletePlugin < TItem , RecentlyViewedItemsPluginData < TItem > > {
49- const {
50- onReset,
51- onSubmit,
52- subscribe,
53- ...plugin
54- } = createLocalStorageRecentSearchesPlugin < TItem > ( {
55- ...params ,
56- search ( params ) {
57- if ( params . query ) {
58- return [ ] ;
59- }
49+ const { onReset, onSubmit, subscribe, ...plugin } =
50+ createLocalStorageRecentSearchesPlugin < TItem > ( {
51+ ...params ,
52+ search ( params ) {
53+ if ( params . query ) {
54+ return [ ] ;
55+ }
6056
61- return search ( params ) ;
62- } ,
63- transformSource ( { source, onRemove, state } ) {
64- const transformedSource = params . transformSource
65- ? params . transformSource ( { source, onRemove, state } )
66- : source ;
57+ return search ( params ) ;
58+ } ,
59+ transformSource ( { source, onRemove, state } ) {
60+ const transformedSource = params . transformSource
61+ ? params . transformSource ( { source, onRemove, state } )
62+ : source ;
6763
68- return {
69- ...transformedSource ,
70- getItemUrl ( { item } ) {
71- return item . url ;
72- } ,
73- templates : {
74- ...transformedSource . templates ,
75- header ( ) {
76- return (
77- < Fragment >
78- < span className = "aa-SourceHeaderTitle" > Recently viewed</ span >
79- < div className = "aa-SourceHeaderLine" />
80- </ Fragment >
81- ) ;
64+ return {
65+ ...transformedSource ,
66+ getItemUrl ( { item } ) {
67+ return item . url ;
8268 } ,
83- item ( { item, components } ) {
84- return (
85- < a className = "aa-ItemLink" href = { item . url } >
86- < div className = "aa-ItemContent" >
87- { item . image ? (
88- < div className = "aa-ItemIcon" >
89- < img src = { item . image } alt = { item . label } />
90- </ div >
91- ) : (
92- < div className = "aa-ItemIcon aa-ItemIcon--noBorder" >
93- < svg viewBox = "0 0 24 24" fill = "currentColor" >
94- < path d = "M12.516 6.984v5.25l4.5 2.672-0.75 1.266-5.25-3.188v-6h1.5zM12 20.016q3.281 0 5.648-2.367t2.367-5.648-2.367-5.648-5.648-2.367-5.648 2.367-2.367 5.648 2.367 5.648 5.648 2.367zM12 2.016q4.125 0 7.055 2.93t2.93 7.055-2.93 7.055-7.055 2.93-7.055-2.93-2.93-7.055 2.93-7.055 7.055-2.93z" />
95- </ svg >
96- </ div >
97- ) }
98- < div className = "aa-ItemContentBody" >
99- < div className = "aa-ItemContentTitle" >
100- < components . Highlight hit = { item } attribute = "label" />
69+ templates : {
70+ ...transformedSource . templates ,
71+ header ( ) {
72+ return (
73+ < Fragment >
74+ < span className = "aa-SourceHeaderTitle" > Recently viewed</ span >
75+ < div className = "aa-SourceHeaderLine" />
76+ </ Fragment >
77+ ) ;
78+ } ,
79+ item ( { item, components } ) {
80+ return (
81+ < a className = "aa-ItemLink" href = { item . url } >
82+ < div className = "aa-ItemContent" >
83+ { item . image ? (
84+ < div className = "aa-ItemIcon" >
85+ < img src = { item . image } alt = { item . label } />
86+ </ div >
87+ ) : (
88+ < div className = "aa-ItemIcon aa-ItemIcon--noBorder" >
89+ < svg viewBox = "0 0 24 24" fill = "currentColor" >
90+ < path d = "M12.516 6.984v5.25l4.5 2.672-0.75 1.266-5.25-3.188v-6h1.5zM12 20.016q3.281 0 5.648-2.367t2.367-5.648-2.367-5.648-5.648-2.367-5.648 2.367-2.367 5.648 2.367 5.648 5.648 2.367zM12 2.016q4.125 0 7.055 2.93t2.93 7.055-2.93 7.055-7.055 2.93-7.055-2.93-2.93-7.055 2.93-7.055 7.055-2.93z" />
91+ </ svg >
92+ </ div >
93+ ) }
94+ < div className = "aa-ItemContentBody" >
95+ < div className = "aa-ItemContentTitle" >
96+ < components . Highlight hit = { item } attribute = "label" />
97+ </ div >
10198 </ div >
10299 </ div >
103- </ div >
104- < div className = "aa-ItemActions" >
105- < button
106- className = "aa-ItemActionButton"
107- title = "Remove this search"
108- onClick = { ( event ) => {
109- event . preventDefault ( ) ;
110- event . stopPropagation ( ) ;
111- onRemove ( item . id ) ;
112- } }
113- >
114- < svg
115- viewBox = "0 0 24 24"
116- width = "18"
117- height = "18"
118- fill = "currentColor"
100+ < div className = "aa-ItemActions" >
101+ < button
102+ className = "aa-ItemActionButton"
103+ title = "Remove this search"
104+ onClick = { ( event ) => {
105+ event . preventDefault ( ) ;
106+ event . stopPropagation ( ) ;
107+ onRemove ( item . id ) ;
108+ } }
119109 >
120- < path d = "M18 7v13c0 0.276-0.111 0.525-0.293 0.707s-0.431 0.293-0.707 0.293h-10c-0.276 0-0.525-0.111-0.707-0.293s-0.293-0.431-0.293-0.707v-13zM17 5v-1c0-0.828-0.337-1.58-0.879-2.121s-1.293-0.879-2.121-0.879h-4c-0.828 0-1.58 0.337-2.121 0.879s-0.879 1.293-0.879 2.121v1h-4c-0.552 0-1 0.448-1 1s0.448 1 1 1h1v13c0 0.828 0.337 1.58 0.879 2.121s1.293 0.879 2.121 0.879h10c0.828 0 1.58-0.337 2.121-0.879s0.879-1.293 0.879-2.121v-13h1c0.552 0 1-0.448 1-1s-0.448-1-1-1zM9 5v-1c0-0.276 0.111-0.525 0.293-0.707s0.431-0.293 0.707-0.293h4c0.276 0 0.525 0.111 0.707 0.293s0.293 0.431 0.293 0.707v1zM9 11v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1zM13 11v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1z" />
121- </ svg >
122- </ button >
123- </ div >
124- </ a >
125- ) ;
110+ < svg
111+ viewBox = "0 0 24 24"
112+ width = "18"
113+ height = "18"
114+ fill = "currentColor"
115+ >
116+ < path d = "M18 7v13c0 0.276-0.111 0.525-0.293 0.707s-0.431 0.293-0.707 0.293h-10c-0.276 0-0.525-0.111-0.707-0.293s-0.293-0.431-0.293-0.707v-13zM17 5v-1c0-0.828-0.337-1.58-0.879-2.121s-1.293-0.879-2.121-0.879h-4c-0.828 0-1.58 0.337-2.121 0.879s-0.879 1.293-0.879 2.121v1h-4c-0.552 0-1 0.448-1 1s0.448 1 1 1h1v13c0 0.828 0.337 1.58 0.879 2.121s1.293 0.879 2.121 0.879h10c0.828 0 1.58-0.337 2.121-0.879s0.879-1.293 0.879-2.121v-13h1c0.552 0 1-0.448 1-1s-0.448-1-1-1zM9 5v-1c0-0.276 0.111-0.525 0.293-0.707s0.431-0.293 0.707-0.293h4c0.276 0 0.525 0.111 0.707 0.293s0.293 0.431 0.293 0.707v1zM9 11v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1zM13 11v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1z" />
117+ </ svg >
118+ </ button >
119+ </ div >
120+ </ a >
121+ ) ;
122+ } ,
126123 } ,
127- } ,
128- } ;
129- } ,
130- } ) ;
124+ } ;
125+ } ,
126+ } ) ;
131127 const { getAlgoliaSearchParams, ...data } = plugin . data ;
132128
133129 return {
0 commit comments