@@ -796,6 +796,39 @@ define([
796
796
&& ! ( event instanceof KeyboardEvent ) ;
797
797
} ,
798
798
799
+ /**
800
+ * Controls the render of the selectable redirect Autocomplete menu item
801
+ * @param html Tagged template function
802
+ * @param state
803
+ * @returns {* }
804
+ */
805
+ getRedirectItemTemplate ( { html, state} ) {
806
+ return html `
807
+ < div className ="aa-ItemWrapper ">
808
+ < div className ="aa-ItemContent ">
809
+ < div className ="aa-ItemIcon aa-ItemIcon--noBorder ">
810
+ < svg viewBox ="0 0 24 24 " fill ="currentColor ">
811
+ < path
812
+ d ="M16.041 15.856c-0.034 0.026-0.067 0.055-0.099 0.087s-0.060 0.064-0.087 0.099c-1.258 1.213-2.969 1.958-4.855 1.958-1.933 0-3.682-0.782-4.95-2.050s-2.050-3.017-2.050-4.95 0.782-3.682 2.050-4.95 3.017-2.050 4.95-2.050 3.682 0.782 4.95 2.050 2.050 3.017 2.050 4.95c0 1.886-0.745 3.597-1.959 4.856zM21.707 20.293l-3.675-3.675c1.231-1.54 1.968-3.493 1.968-5.618 0-2.485-1.008-4.736-2.636-6.364s-3.879-2.636-6.364-2.636-4.736 1.008-6.364 2.636-2.636 3.879-2.636 6.364 1.008 4.736 2.636 6.364 3.879 2.636 6.364 2.636c2.125 0 4.078-0.737 5.618-1.968l3.675 3.675c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414z "> </ path >
813
+ </ svg >
814
+ </ div >
815
+ < div className ="aa-ItemContentBody ">
816
+ < div className ="aa-ItemContentTitle "> < a className ="aa-ItemLink "> ${ state . query } </ a >
817
+ </ div >
818
+ </ div >
819
+ </ div >
820
+ < div className ="aa-ItemActions ">
821
+ < div className ="aa-ItemActionButton ">
822
+ < svg viewBox ="0 0 24 24 " fill ="none " stroke ="currentColor " strokeWidth ="2 "
823
+ strokeLinecap ="round " strokeLinejoin ="round ">
824
+ < line x1 ="5 " y1 ="12 " x2 ="19 " y2 ="12 "> </ line >
825
+ < polyline points ="12 5 19 12 12 19 "> </ polyline >
826
+ </ svg >
827
+ </ div >
828
+ </ div >
829
+ </ div > ` ;
830
+ } ,
831
+
799
832
buildRedirectPlugin ( ) {
800
833
const onRedirect = ( redirects , { event, navigator, state } ) => {
801
834
const item = redirects . find ( ( r ) => r . sourceId === 'products' ) ;
@@ -812,16 +845,15 @@ define([
812
845
} ;
813
846
814
847
const params = {
815
- onRedirect
816
- } ;
817
-
818
- if ( ! algoliaConfig . autocomplete . redirects . showSelectableRedirect ) {
819
- params . templates = {
820
- item ( { html, state} ) {
821
- return html `` ;
848
+ onRedirect,
849
+ templates : {
850
+ item : ( { html, state} ) => {
851
+ return ( algoliaConfig . autocomplete . redirects . showSelectableRedirect )
852
+ ? this . getRedirectItemTemplate ( { html, state} )
853
+ : html `` ;
822
854
}
823
- } ;
824
- }
855
+ }
856
+ } ;
825
857
826
858
return redirectUrlPlugin . createRedirectUrlPlugin ( params ) ;
827
859
} ,
0 commit comments