@@ -47,21 +47,20 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
4747 return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ;
4848} ;
4949
50- function _empty ( ) { } function _awaitIgnored ( value , direct ) {
50+ function _await ( value , then , direct ) {
51+ if ( direct ) {
52+ return then ? then ( value ) : value ;
53+ } if ( ! value || ! value . then ) {
54+ value = Promise . resolve ( value ) ;
55+ } return then ? value . then ( then ) : value ;
56+ } function _empty ( ) { } function _awaitIgnored ( value , direct ) {
5157 if ( ! direct ) {
5258 return value && value . then ? value . then ( _empty ) : Promise . resolve ( ) ;
5359 }
5460} function _invoke ( body , then ) {
5561 var result = body ( ) ; if ( result && result . then ) {
56-
5762 return result . then ( then ) ;
5863 } return then ( result ) ;
59- } function _await ( value , then , direct ) {
60- if ( direct ) {
61- return then ? then ( value ) : value ;
62- } if ( ! value || ! value . then ) {
63- value = Promise . resolve ( value ) ;
64- } return then ? value . then ( then ) : value ;
6564} function _invokeIgnored ( body ) {
6665 var result = body ( ) ; if ( result && result . then ) {
6766 return result . then ( _empty ) ;
@@ -71,9 +70,11 @@ function _empty() {}function _awaitIgnored(value, direct) {
7170 var result = body ( ) ;
7271 } catch ( e ) {
7372 return recover ( e ) ;
74- } if ( result && result . then ) {
73+ }
74+ if ( result && result . then ) {
7575 return result . then ( void 0 , recover ) ;
76- } return result ;
76+ }
77+ return result ;
7778} function _finally ( body , finalizer ) {
7879 try {
7980 var result = body ( ) ;
@@ -270,10 +271,23 @@ function _empty() {}function _awaitIgnored(value, direct) {
270271 this . controlScheme = Object . assign ( { } , defaultControls , this . controls ) ;
271272 } ,
272273 mounted : function mounted ( ) {
273- this . inputElement = this . $refs [ 'inputSlot' ] . querySelector ( 'input' ) ;
274+ try {
275+ var _this3 = this ;
274276
275- this . setInputAriaAttributes ( ) ;
276- this . prepareEventHandlers ( true ) ;
277+ return _await ( _this3 . $slots . default , function ( ) {
278+
279+ _this3 . inputElement = _this3 . $refs [ 'inputSlot' ] . querySelector ( 'input' ) ;
280+
281+ if ( _this3 . inputElement ) {
282+ _this3 . setInputAriaAttributes ( ) ;
283+ _this3 . prepareEventHandlers ( true ) ;
284+ } else {
285+ console . error ( 'No input element found' ) ;
286+ }
287+ } ) ;
288+ } catch ( e ) {
289+ return Promise . reject ( e ) ;
290+ }
277291 } ,
278292 beforeDestroy : function beforeDestroy ( ) {
279293 this . prepareEventHandlers ( false ) ;
@@ -326,10 +340,10 @@ function _empty() {}function _awaitIgnored(value, direct) {
326340 return true ;
327341 } ,
328342 miscSlotsAreEmpty : function miscSlotsAreEmpty ( ) {
329- var _this2 = this ;
343+ var _this4 = this ;
330344
331345 var slots = [ 'misc-item-above' , 'misc-item-below' ] . map ( function ( s ) {
332- return _this2 . $scopedSlots [ s ] ;
346+ return _this4 . $scopedSlots [ s ] ;
333347 } ) ;
334348
335349 if ( slots . every ( function ( s ) {
@@ -381,12 +395,12 @@ function _empty() {}function _awaitIgnored(value, direct) {
381395 this . setText ( this . displayProperty ( suggestion ) ) ;
382396 } ,
383397 setText : function setText ( text ) {
384- var _this3 = this ;
398+ var _this5 = this ;
385399
386400 this . $nextTick ( function ( ) {
387- _this3 . inputElement . value = text ;
388- _this3 . text = text ;
389- _this3 . $emit ( 'input' , text ) ;
401+ _this5 . inputElement . value = text ;
402+ _this5 . text = text ;
403+ _this5 . $emit ( 'input' , text ) ;
390404 } ) ;
391405 } ,
392406 select : function select ( item ) {
@@ -429,17 +443,17 @@ function _empty() {}function _awaitIgnored(value, direct) {
429443 } ,
430444 showSuggestions : function showSuggestions ( ) {
431445 try {
432- var _this5 = this ;
446+ var _this7 = this ;
433447
434448 return _invoke ( function ( ) {
435- if ( _this5 . suggestions . length === 0 && _this5 . minLength <= _this5 . textLength ) {
449+ if ( _this7 . suggestions . length === 0 && _this7 . minLength <= _this7 . textLength ) {
436450 // try show misc slots while researching
437- _this5 . showList ( ) ;
438- return _awaitIgnored ( _this5 . research ( ) ) ;
451+ _this7 . showList ( ) ;
452+ return _awaitIgnored ( _this7 . research ( ) ) ;
439453 }
440454 } , function ( ) {
441455
442- _this5 . showList ( ) ;
456+ _this7 . showList ( ) ;
443457 } ) ;
444458 } catch ( e ) {
445459 return Promise . reject ( e ) ;
@@ -518,7 +532,7 @@ function _empty() {}function _awaitIgnored(value, direct) {
518532 this . isClicking = false ;
519533 } ,
520534 onBlur : function onBlur ( e ) {
521- var _this6 = this ;
535+ var _this8 = this ;
522536
523537 if ( this . isInFocus ) {
524538
@@ -534,7 +548,7 @@ function _empty() {}function _awaitIgnored(value, direct) {
534548 } else if ( e && e . isTrusted && ! this . isTabbed ) {
535549 this . isFalseFocus = true ;
536550 setTimeout ( function ( ) {
537- _this6 . inputElement . focus ( ) ;
551+ _this8 . inputElement . focus ( ) ;
538552 } , 0 ) ;
539553 }
540554 } else {
@@ -545,7 +559,9 @@ function _empty() {}function _awaitIgnored(value, direct) {
545559 this . isTabbed = false ;
546560 } ,
547561 onFocus : function onFocus ( e ) {
548- this . isInFocus = true ; // Only emit, if it was a native input focus
562+ this . isInFocus = true ;
563+
564+ // Only emit, if it was a native input focus
549565 if ( e && ! this . isFalseFocus ) {
550566 this . $emit ( 'focus' , e ) ;
551567 }
@@ -585,68 +601,68 @@ function _empty() {}function _awaitIgnored(value, direct) {
585601 } ,
586602 research : function research ( ) {
587603 try {
588- var _this8 = this ;
604+ var _this10 = this ;
589605
590606 return _finally ( function ( ) {
591607 return _catch ( function ( ) {
592608 return _invokeIgnored ( function ( ) {
593- if ( _this8 . canSend ) {
594- _this8 . canSend = false ;
609+ if ( _this10 . canSend ) {
610+ _this10 . canSend = false ;
595611 // @TODO : fix when promises will be cancelable (never :D)
596- var textBeforeRequest = _this8 . text ;
597- return _await ( _this8 . getSuggestions ( _this8 . text ) , function ( newList ) {
598- if ( textBeforeRequest === _this8 . text ) {
599- _this8 . $set ( _this8 , 'suggestions' , newList ) ;
612+ var textBeforeRequest = _this10 . text ;
613+ return _await ( _this10 . getSuggestions ( _this10 . text ) , function ( newList ) {
614+ if ( textBeforeRequest === _this10 . text ) {
615+ _this10 . $set ( _this10 , 'suggestions' , newList ) ;
600616 }
601617 } ) ;
602618 }
603619 } ) ;
604620 } , function ( e ) {
605- _this8 . clearSuggestions ( ) ;
621+ _this10 . clearSuggestions ( ) ;
606622 throw e ;
607623 } ) ;
608624 } , function ( ) {
609- _this8 . canSend = true ;
625+ _this10 . canSend = true ;
610626
611- if ( _this8 . suggestions . length === 0 && _this8 . miscSlotsAreEmpty ( ) ) {
612- _this8 . hideList ( ) ;
613- } else if ( _this8 . isInFocus ) {
614- _this8 . showList ( ) ;
627+ if ( _this10 . suggestions . length === 0 && _this10 . miscSlotsAreEmpty ( ) ) {
628+ _this10 . hideList ( ) ;
629+ } else if ( _this10 . isInFocus ) {
630+ _this10 . showList ( ) ;
615631 }
616632
617- return _this8 . suggestions ;
633+ return _this10 . suggestions ;
618634 } ) ;
619635 } catch ( e ) {
620636 return Promise . reject ( e ) ;
621637 }
622638 } ,
623639 getSuggestions : function getSuggestions ( value ) {
624640 try {
625- var _this10 = this ;
641+ var _this12 = this ;
626642
627643 value = value || '' ;
628644
629- if ( value . length < _this10 . minLength ) {
645+ if ( value . length < _this12 . minLength ) {
630646 return [ ] ;
631647 }
632648
633- _this10 . selected = null ;
649+ _this12 . selected = null ;
634650
635651 // Start request if can
636- if ( _this10 . listIsRequest ) {
637- _this10 . $emit ( 'request-start' , value ) ;
652+ if ( _this12 . listIsRequest ) {
653+ _this12 . $emit ( 'request-start' , value ) ;
638654 }
639655
640656 var result = [ ] ;
641657 return _finally ( function ( ) {
642658 return _catch ( function ( ) {
643659 return _invoke ( function ( ) {
644- if ( _this10 . listIsRequest ) {
645- return _await ( _this10 . list ( value ) , function ( _this9 $list) {
646- result = _this9 $list || [ ] ;
660+ if ( _this12 . listIsRequest ) {
661+ return _await ( _this12 . list ( value ) , function ( _this11 $list) {
662+ result = _this11 $list || [ ] ;
647663 } ) ;
648664 } else {
649- result = _this10 . list ;
665+ result = _this12 . list ;
650666 }
651667 } , function ( ) {
652668
@@ -655,28 +671,28 @@ function _empty() {}function _awaitIgnored(value, direct) {
655671 result = [ result ] ;
656672 }
657673
658- _this10 . isPlainSuggestion = _typeof ( result [ 0 ] ) !== 'object' || Array . isArray ( result [ 0 ] ) ;
674+ _this12 . isPlainSuggestion = _typeof ( result [ 0 ] ) !== 'object' || Array . isArray ( result [ 0 ] ) ;
659675
660- if ( _this10 . filterByQuery ) {
676+ if ( _this12 . filterByQuery ) {
661677 result = result . filter ( function ( el ) {
662- return _this10 . filter ( el , value ) ;
678+ return _this12 . filter ( el , value ) ;
663679 } ) ;
664680 }
665681
666- if ( _this10 . listIsRequest ) {
667- _this10 . $emit ( 'request-done' , result ) ;
682+ if ( _this12 . listIsRequest ) {
683+ _this12 . $emit ( 'request-done' , result ) ;
668684 }
669685 } ) ;
670686 } , function ( e ) {
671- if ( _this10 . listIsRequest ) {
672- _this10 . $emit ( 'request-failed' , e ) ;
687+ if ( _this12 . listIsRequest ) {
688+ _this12 . $emit ( 'request-failed' , e ) ;
673689 } else {
674690 throw e ;
675691 }
676692 } ) ;
677693 } , function ( ) {
678- if ( _this10 . maxSuggestions ) {
679- result . splice ( _this10 . maxSuggestions ) ;
694+ if ( _this12 . maxSuggestions ) {
695+ result . splice ( _this12 . maxSuggestions ) ;
680696 }
681697
682698 return result ;
0 commit comments