@@ -22,11 +22,11 @@ function __classPrivateFieldGet(receiver, state, kind, f) {
2222 return kind === "m" ? f : kind === "a" ? f . call ( receiver ) : f ? f . value : state . get ( receiver ) ;
2323}
2424
25- var _default_1_instances , _default_1_getCommonConfig , _default_1_createAutocomplete , _default_1_createAutocompleteWithHtmlContents , _default_1_createAutocompleteWithRemoteData , _default_1_stripTags , _default_1_mergeObjects , _default_1_createTomSelect , _default_1_dispatchEvent ;
25+ var _instances , _getCommonConfig , _createAutocomplete , _createAutocompleteWithHtmlContents , _createAutocompleteWithRemoteData , _stripTags , _mergeObjects , _createTomSelect , _dispatchEvent ;
2626class default_1 extends Controller {
2727 constructor ( ) {
2828 super ( ...arguments ) ;
29- _default_1_instances . add ( this ) ;
29+ _instances . add ( this ) ;
3030 }
3131 initialize ( ) {
3232 this . element . setAttribute ( 'data-live-ignore' , '' ) ;
@@ -39,14 +39,14 @@ class default_1 extends Controller {
3939 }
4040 connect ( ) {
4141 if ( this . urlValue ) {
42- this . tomSelect = __classPrivateFieldGet ( this , _default_1_instances , "m" , _default_1_createAutocompleteWithRemoteData ) . call ( this , this . urlValue , this . minCharactersValue ) ;
42+ this . tomSelect = __classPrivateFieldGet ( this , _instances , "m" , _createAutocompleteWithRemoteData ) . call ( this , this . urlValue , this . minCharactersValue ) ;
4343 return ;
4444 }
4545 if ( this . optionsAsHtmlValue ) {
46- this . tomSelect = __classPrivateFieldGet ( this , _default_1_instances , "m" , _default_1_createAutocompleteWithHtmlContents ) . call ( this ) ;
46+ this . tomSelect = __classPrivateFieldGet ( this , _instances , "m" , _createAutocompleteWithHtmlContents ) . call ( this ) ;
4747 return ;
4848 }
49- this . tomSelect = __classPrivateFieldGet ( this , _default_1_instances , "m" , _default_1_createAutocomplete ) . call ( this ) ;
49+ this . tomSelect = __classPrivateFieldGet ( this , _instances , "m" , _createAutocomplete ) . call ( this ) ;
5050 }
5151 disconnect ( ) {
5252 this . tomSelect . revertSettings . innerHTML = this . element . innerHTML ;
@@ -65,14 +65,19 @@ class default_1 extends Controller {
6565 return this . element ;
6666 }
6767 get preload ( ) {
68- if ( this . preloadValue == 'false' )
68+ if ( ! this . hasPreloadValue ) {
69+ return 'focus' ;
70+ }
71+ if ( this . preloadValue == 'false' ) {
6972 return false ;
70- if ( this . preloadValue == 'true' )
73+ }
74+ if ( this . preloadValue == 'true' ) {
7175 return true ;
76+ }
7277 return this . preloadValue ;
7378 }
7479}
75- _default_1_instances = new WeakSet ( ) , _default_1_getCommonConfig = function _default_1_getCommonConfig ( ) {
80+ _instances = new WeakSet ( ) , _getCommonConfig = function _getCommonConfig ( ) {
7681 const plugins = { } ;
7782 const isMultiple = ! this . selectElement || this . selectElement . multiple ;
7883 if ( ! this . formElement . disabled && ! isMultiple ) {
@@ -87,7 +92,7 @@ _default_1_instances = new WeakSet(), _default_1_getCommonConfig = function _def
8792 const render = {
8893 no_results : ( ) => {
8994 return `<div class="no-results">${ this . noResultsFoundTextValue } </div>` ;
90- }
95+ } ,
9196 } ;
9297 const config = {
9398 render : render ,
@@ -104,19 +109,19 @@ _default_1_instances = new WeakSet(), _default_1_getCommonConfig = function _def
104109 if ( ! this . selectElement && ! this . urlValue ) {
105110 config . shouldLoad = ( ) => false ;
106111 }
107- return __classPrivateFieldGet ( this , _default_1_instances , "m" , _default_1_mergeObjects ) . call ( this , config , this . tomSelectOptionsValue ) ;
108- } , _default_1_createAutocomplete = function _default_1_createAutocomplete ( ) {
109- const config = __classPrivateFieldGet ( this , _default_1_instances , "m" , _default_1_mergeObjects ) . call ( this , __classPrivateFieldGet ( this , _default_1_instances , "m" , _default_1_getCommonConfig ) . call ( this ) , {
112+ return __classPrivateFieldGet ( this , _instances , "m" , _mergeObjects ) . call ( this , config , this . tomSelectOptionsValue ) ;
113+ } , _createAutocomplete = function _createAutocomplete ( ) {
114+ const config = __classPrivateFieldGet ( this , _instances , "m" , _mergeObjects ) . call ( this , __classPrivateFieldGet ( this , _instances , "m" , _getCommonConfig ) . call ( this ) , {
110115 maxOptions : this . selectElement ? this . selectElement . options . length : 50 ,
111116 } ) ;
112- return __classPrivateFieldGet ( this , _default_1_instances , "m" , _default_1_createTomSelect ) . call ( this , config ) ;
113- } , _default_1_createAutocompleteWithHtmlContents = function _default_1_createAutocompleteWithHtmlContents ( ) {
114- const config = __classPrivateFieldGet ( this , _default_1_instances , "m" , _default_1_mergeObjects ) . call ( this , __classPrivateFieldGet ( this , _default_1_instances , "m" , _default_1_getCommonConfig ) . call ( this ) , {
117+ return __classPrivateFieldGet ( this , _instances , "m" , _createTomSelect ) . call ( this , config ) ;
118+ } , _createAutocompleteWithHtmlContents = function _createAutocompleteWithHtmlContents ( ) {
119+ const config = __classPrivateFieldGet ( this , _instances , "m" , _mergeObjects ) . call ( this , __classPrivateFieldGet ( this , _instances , "m" , _getCommonConfig ) . call ( this ) , {
115120 maxOptions : this . selectElement ? this . selectElement . options . length : 50 ,
116121 score : ( search ) => {
117122 const scoringFunction = this . tomSelect . getScoreFunction ( search ) ;
118123 return ( item ) => {
119- return scoringFunction ( Object . assign ( Object . assign ( { } , item ) , { text : __classPrivateFieldGet ( this , _default_1_instances , "m" , _default_1_stripTags ) . call ( this , item . text ) } ) ) ;
124+ return scoringFunction ( Object . assign ( Object . assign ( { } , item ) , { text : __classPrivateFieldGet ( this , _instances , "m" , _stripTags ) . call ( this , item . text ) } ) ) ;
120125 } ;
121126 } ,
122127 render : {
@@ -125,21 +130,24 @@ _default_1_instances = new WeakSet(), _default_1_getCommonConfig = function _def
125130 } ,
126131 option : function ( item ) {
127132 return `<div>${ item . text } </div>` ;
128- }
133+ } ,
129134 } ,
130135 } ) ;
131- return __classPrivateFieldGet ( this , _default_1_instances , "m" , _default_1_createTomSelect ) . call ( this , config ) ;
132- } , _default_1_createAutocompleteWithRemoteData = function _default_1_createAutocompleteWithRemoteData ( autocompleteEndpointUrl , minCharacterLength ) {
133- const config = __classPrivateFieldGet ( this , _default_1_instances , "m" , _default_1_mergeObjects ) . call ( this , __classPrivateFieldGet ( this , _default_1_instances , "m" , _default_1_getCommonConfig ) . call ( this ) , {
136+ return __classPrivateFieldGet ( this , _instances , "m" , _createTomSelect ) . call ( this , config ) ;
137+ } , _createAutocompleteWithRemoteData = function _createAutocompleteWithRemoteData ( autocompleteEndpointUrl , minCharacterLength ) {
138+ const config = __classPrivateFieldGet ( this , _instances , "m" , _mergeObjects ) . call ( this , __classPrivateFieldGet ( this , _instances , "m" , _getCommonConfig ) . call ( this ) , {
134139 firstUrl : ( query ) => {
135140 const separator = autocompleteEndpointUrl . includes ( '?' ) ? '&' : '?' ;
136141 return `${ autocompleteEndpointUrl } ${ separator } query=${ encodeURIComponent ( query ) } ` ;
137142 } ,
138143 load : function ( query , callback ) {
139144 const url = this . getUrl ( query ) ;
140145 fetch ( url )
141- . then ( response => response . json ( ) )
142- . then ( json => { this . setNextUrl ( query , json . next_page ) ; callback ( json . results ) ; } )
146+ . then ( ( response ) => response . json ( ) )
147+ . then ( ( json ) => {
148+ this . setNextUrl ( query , json . next_page ) ;
149+ callback ( json . results ) ;
150+ } )
143151 . catch ( ( ) => callback ( ) ) ;
144152 } ,
145153 shouldLoad : function ( query ) {
@@ -167,17 +175,17 @@ _default_1_instances = new WeakSet(), _default_1_getCommonConfig = function _def
167175 } ,
168176 preload : this . preload ,
169177 } ) ;
170- return __classPrivateFieldGet ( this , _default_1_instances , "m" , _default_1_createTomSelect ) . call ( this , config ) ;
171- } , _default_1_stripTags = function _default_1_stripTags ( string ) {
178+ return __classPrivateFieldGet ( this , _instances , "m" , _createTomSelect ) . call ( this , config ) ;
179+ } , _stripTags = function _stripTags ( string ) {
172180 return string . replace ( / ( < ( [ ^ > ] + ) > ) / gi, '' ) ;
173- } , _default_1_mergeObjects = function _default_1_mergeObjects ( object1 , object2 ) {
181+ } , _mergeObjects = function _mergeObjects ( object1 , object2 ) {
174182 return Object . assign ( Object . assign ( { } , object1 ) , object2 ) ;
175- } , _default_1_createTomSelect = function _default_1_createTomSelect ( options ) {
176- __classPrivateFieldGet ( this , _default_1_instances , "m" , _default_1_dispatchEvent ) . call ( this , 'autocomplete:pre-connect' , { options } ) ;
183+ } , _createTomSelect = function _createTomSelect ( options ) {
184+ __classPrivateFieldGet ( this , _instances , "m" , _dispatchEvent ) . call ( this , 'autocomplete:pre-connect' , { options } ) ;
177185 const tomSelect = new TomSelect ( this . formElement , options ) ;
178- __classPrivateFieldGet ( this , _default_1_instances , "m" , _default_1_dispatchEvent ) . call ( this , 'autocomplete:connect' , { tomSelect, options } ) ;
186+ __classPrivateFieldGet ( this , _instances , "m" , _dispatchEvent ) . call ( this , 'autocomplete:connect' , { tomSelect, options } ) ;
179187 return tomSelect ;
180- } , _default_1_dispatchEvent = function _default_1_dispatchEvent ( name , payload ) {
188+ } , _dispatchEvent = function _dispatchEvent ( name , payload ) {
181189 this . element . dispatchEvent ( new CustomEvent ( name , { detail : payload , bubbles : true } ) ) ;
182190} ;
183191default_1 . values = {
0 commit comments