@@ -13,7 +13,7 @@ import {
13
13
isAndroid ,
14
14
} from "@ui5/webcomponents-base/dist/Device.js" ;
15
15
import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js" ;
16
- import { getFeature , getComponentFeature } from "@ui5/webcomponents-base/dist/FeaturesRegistry.js" ;
16
+ import { getFeature } from "@ui5/webcomponents-base/dist/FeaturesRegistry.js" ;
17
17
import {
18
18
isUp ,
19
19
isDown ,
@@ -199,9 +199,8 @@ type InputSuggestionScrollEventDetail = {
199
199
staticAreaTemplate : InputPopoverTemplate ,
200
200
styles : inputStyles ,
201
201
staticAreaStyles : [ ResponsivePopoverCommonCss , ValueStateMessageCss , SuggestionsCss ] ,
202
- features : [ "InputSuggestions" ] ,
203
202
get dependencies ( ) {
204
- const Suggestions = getComponentFeature < typeof InputSuggestions > ( "InputSuggestions" ) ;
203
+ const Suggestions = getFeature < typeof InputSuggestions > ( "InputSuggestions" ) ;
205
204
return ( [ Popover , Icon ] as Array < typeof UI5Element > ) . concat ( Suggestions ? Suggestions . dependencies : [ ] ) ;
206
205
} ,
207
206
} )
@@ -651,7 +650,7 @@ class Input extends UI5Element implements SuggestionComponent, IFormElement {
651
650
652
651
if ( this . showSuggestions ) {
653
652
this . enableSuggestions ( ) ;
654
- this . suggestionObjects = this . Suggestions ? .defaultSlotProperties ( this . typedInValue ) || [ ] ;
653
+ this . suggestionObjects = this . Suggestions ! . defaultSlotProperties ( this . typedInValue ) ;
655
654
}
656
655
657
656
this . _effectiveShowClearIcon = ( this . showClearIcon && ! ! this . value && ! this . readonly && ! this . disabled ) ;
@@ -695,10 +694,6 @@ class Input extends UI5Element implements SuggestionComponent, IFormElement {
695
694
}
696
695
}
697
696
698
- get _effectiveShowSuggestions ( ) {
699
- return ! ! ( this . showSuggestions && this . Suggestions ) ;
700
- }
701
-
702
697
async onAfterRendering ( ) {
703
698
const innerInput = this . getInputDOMRefSync ( ) ! ;
704
699
@@ -794,13 +789,13 @@ class Input extends UI5Element implements SuggestionComponent, IFormElement {
794
789
}
795
790
796
791
_handleUp ( e : KeyboardEvent ) {
797
- if ( this . Suggestions ? .isOpened ( ) ) {
792
+ if ( this . Suggestions && this . Suggestions . isOpened ( ) ) {
798
793
this . Suggestions . onUp ( e ) ;
799
794
}
800
795
}
801
796
802
797
_handleDown ( e : KeyboardEvent ) {
803
- if ( this . Suggestions ? .isOpened ( ) ) {
798
+ if ( this . Suggestions && this . Suggestions . isOpened ( ) ) {
804
799
this . Suggestions . onDown ( e ) ;
805
800
}
806
801
}
@@ -818,8 +813,8 @@ class Input extends UI5Element implements SuggestionComponent, IFormElement {
818
813
}
819
814
820
815
_handleEnter ( e : KeyboardEvent ) {
821
- // if a group item is focused, this is false
822
- const suggestionItemPressed = ! ! ( this . Suggestions ?. onEnter ( e ) ) ;
816
+ const suggestionItemPressed = ! ! ( this . Suggestions && this . Suggestions . onEnter ( e ) ) ;
817
+
823
818
const innerInput = this . getInputDOMRefSync ( ) ! ;
824
819
// Check for autocompleted item
825
820
const matchingItem = this . suggestionItems . find ( item => {
@@ -855,29 +850,29 @@ class Input extends UI5Element implements SuggestionComponent, IFormElement {
855
850
856
851
_handlePageUp ( e : KeyboardEvent ) {
857
852
if ( this . _isSuggestionsFocused ) {
858
- this . Suggestions ? .onPageUp ( e ) ;
853
+ this . Suggestions ! . onPageUp ( e ) ;
859
854
} else {
860
855
e . preventDefault ( ) ;
861
856
}
862
857
}
863
858
864
859
_handlePageDown ( e : KeyboardEvent ) {
865
860
if ( this . _isSuggestionsFocused ) {
866
- this . Suggestions ? .onPageDown ( e ) ;
861
+ this . Suggestions ! . onPageDown ( e ) ;
867
862
} else {
868
863
e . preventDefault ( ) ;
869
864
}
870
865
}
871
866
872
867
_handleHome ( e : KeyboardEvent ) {
873
868
if ( this . _isSuggestionsFocused ) {
874
- this . Suggestions ? .onHome ( e ) ;
869
+ this . Suggestions ! . onHome ( e ) ;
875
870
}
876
871
}
877
872
878
873
_handleEnd ( e : KeyboardEvent ) {
879
874
if ( this . _isSuggestionsFocused ) {
880
- this . Suggestions ? .onEnd ( e ) ;
875
+ this . Suggestions ! . onEnd ( e ) ;
881
876
}
882
877
}
883
878
@@ -894,7 +889,7 @@ class Input extends UI5Element implements SuggestionComponent, IFormElement {
894
889
return ;
895
890
}
896
891
897
- if ( isOpen && this . Suggestions ? ._isItemOnTarget ( ) ) {
892
+ if ( isOpen && this . Suggestions ! . _isItemOnTarget ( ) ) {
898
893
// Restore the value.
899
894
this . value = this . typedInValue || this . valueBeforeItemPreview ;
900
895
@@ -980,8 +975,8 @@ class Input extends UI5Element implements SuggestionComponent, IFormElement {
980
975
this . _isValueStateFocused = false ;
981
976
this . hasSuggestionItemSelected = false ;
982
977
983
- this . Suggestions ? ._deselectItems ( ) ;
984
- this . Suggestions ? ._clearItemFocus ( ) ;
978
+ this . Suggestions . _deselectItems ( ) ;
979
+ this . Suggestions . _clearItemFocus ( ) ;
985
980
}
986
981
987
982
_click ( ) {
@@ -1216,9 +1211,12 @@ class Input extends UI5Element implements SuggestionComponent, IFormElement {
1216
1211
return ;
1217
1212
}
1218
1213
1219
- const Suggestions = getComponentFeature < typeof InputSuggestions > ( "InputSuggestions" ) ;
1214
+ const Suggestions = getFeature < typeof InputSuggestions > ( "InputSuggestions" ) ;
1215
+
1220
1216
if ( Suggestions ) {
1221
1217
this . Suggestions = new Suggestions ( this , "suggestionItems" , true , false ) ;
1218
+ } else {
1219
+ throw new Error ( `You have to import "@ui5/webcomponents/dist/features/InputSuggestions.js" module to use ui5-input suggestions` ) ;
1222
1220
}
1223
1221
}
1224
1222
@@ -1399,7 +1397,7 @@ class Input extends UI5Element implements SuggestionComponent, IFormElement {
1399
1397
return Promise . resolve ( false ) ;
1400
1398
}
1401
1399
1402
- return this . Suggestions ? ._isScrollable ( ) ;
1400
+ return this . Suggestions . _isScrollable ( ) ;
1403
1401
}
1404
1402
1405
1403
getInputId ( ) {
@@ -1627,7 +1625,7 @@ class Input extends UI5Element implements SuggestionComponent, IFormElement {
1627
1625
}
1628
1626
1629
1627
get availableSuggestionsCount ( ) {
1630
- if ( this . showSuggestions && ( this . value || this . Suggestions ? .isOpened ( ) ) ) {
1628
+ if ( this . showSuggestions && ( this . value || this . Suggestions ! . isOpened ( ) ) ) {
1631
1629
const nonGroupItems = this . suggestionObjects . filter ( item => ! item . groupItem ) ;
1632
1630
1633
1631
switch ( nonGroupItems . length ) {
@@ -1654,7 +1652,7 @@ class Input extends UI5Element implements SuggestionComponent, IFormElement {
1654
1652
}
1655
1653
1656
1654
get _isSuggestionsFocused ( ) {
1657
- return ! this . focused && this . Suggestions ? .isOpened ( ) ;
1655
+ return ! this . focused && this . Suggestions && this . Suggestions . isOpened ( ) ;
1658
1656
}
1659
1657
1660
1658
/**
@@ -1737,7 +1735,12 @@ class Input extends UI5Element implements SuggestionComponent, IFormElement {
1737
1735
}
1738
1736
1739
1737
static async onDefine ( ) {
1740
- Input . i18nBundle = await getI18nBundle ( "@ui5/webcomponents" ) ;
1738
+ const Suggestions = getFeature < typeof InputSuggestions > ( "InputSuggestions" ) ;
1739
+
1740
+ [ Input . i18nBundle ] = await Promise . all ( [
1741
+ getI18nBundle ( "@ui5/webcomponents" ) ,
1742
+ Suggestions ? Suggestions . init ( ) : Promise . resolve ( ) ,
1743
+ ] ) ;
1741
1744
}
1742
1745
}
1743
1746
0 commit comments