1+ import { getNavigator } from './getNavigator' ;
12import { InternalAutocompleteOptions , AutocompleteOptions } from './types' ;
23import {
34 generateAutocompleteId ,
@@ -9,7 +10,9 @@ import {
910export function getDefaultProps < TItem > (
1011 props : AutocompleteOptions < TItem >
1112) : InternalAutocompleteOptions < TItem > {
12- const environment : typeof window = ( typeof window !== 'undefined'
13+ const environment : InternalAutocompleteOptions <
14+ unknown
15+ > [ 'environment' ] = ( typeof window !== 'undefined'
1316 ? window
1417 : { } ) as typeof window ;
1518 const plugins = props . plugins || [ ] ;
@@ -38,6 +41,7 @@ export function getDefaultProps<TItem>(
3841 context : { } ,
3942 ...props . initialState ,
4043 } ,
44+ plugins,
4145 onStateChange ( params ) {
4246 props . onStateChange ?.( params ) ;
4347 plugins . forEach ( ( plugin ) => {
@@ -70,21 +74,8 @@ export function getDefaultProps<TItem>(
7074 ) ;
7175 } ,
7276 navigator : {
73- navigate ( { itemUrl } ) {
74- environment . location . assign ( itemUrl ) ;
75- } ,
76- navigateNewTab ( { itemUrl } ) {
77- const windowReference = environment . open ( itemUrl , '_blank' , 'noopener' ) ;
78-
79- if ( windowReference ) {
80- windowReference . focus ( ) ;
81- }
82- } ,
83- navigateNewWindow ( { itemUrl } ) {
84- environment . open ( itemUrl , '_blank' , 'noopener' ) ;
85- } ,
77+ ...getNavigator ( { environment } ) ,
8678 ...props . navigator ,
8779 } ,
88- plugins,
8980 } ;
9081}
0 commit comments