@@ -453,6 +453,15 @@ <h3>Input with open suggestions on focusin</h3>
453453 < br >
454454 < br >
455455
456+ < h3 > Input with Dynamic Suggestions Triggering (Threshold = 3)</ h3 >
457+ < ui5-input id ="dynamicTriggerInput " placeholder ="Type at least 3 characters to see suggestions... " show-suggestions > </ ui5-input >
458+ < div >
459+ < small > Suggestions will appear after typing 3 or more characters</ small >
460+ </ div >
461+
462+ < br >
463+ < br >
464+
456465 < h3 > Input - showing wrapping</ h3 >
457466 < ui5-input show-suggestions id ="input-change-wrapping ">
458467 < ui5-suggestion-item text ="Item that does not wrap "> </ ui5-suggestion-item >
@@ -1113,6 +1122,46 @@ <h3>Input Composition</h3>
11131122 document . getElementById ( "prevent-input-event-clear-icon" ) . addEventListener ( "ui5-input" , event => {
11141123 event . preventDefault ( ) ;
11151124 } ) ;
1125+
1126+ // Dynamic Suggestions Triggering with Threshold
1127+ const dynamicTriggerInput = document . getElementById ( "dynamicTriggerInput" ) ;
1128+ const THRESHOLD = 3 ;
1129+
1130+ const countriesForDynamicTrigger = [
1131+ "Albania" , "Andorra" , "Armenia" , "Austria" , "Azerbaijan" ,
1132+ "Belarus" , "Belgium" , "Bosnia and Herzegovina" , "Bulgaria" ,
1133+ "Croatia" , "Cyprus" , "Czech Republic" , "Denmark" ,
1134+ "Estonia" , "Finland" , "France" , "Georgia" , "Germany" , "Greece" ,
1135+ "Hungary" , "Iceland" , "Ireland" , "Italy" , "Kazakhstan" ,
1136+ "Kosovo" , "Latvia" , "Liechtenstein" , "Lithuania" , "Luxembourg" ,
1137+ "Malta" , "Moldova" , "Monaco" , "Montenegro" , "Netherlands" ,
1138+ "North Macedonia" , "Norway" , "Poland" , "Portugal" , "Romania" ,
1139+ "Russia" , "San Marino" , "Serbia" , "Slovakia" , "Slovenia" ,
1140+ "Spain" , "Sweden" , "Switzerland" , "Turkey" , "Ukraine" ,
1141+ "United Kingdom" , "Vatican City"
1142+ ] ;
1143+
1144+ dynamicTriggerInput . addEventListener ( "input" , ( ) => {
1145+ const value = dynamicTriggerInput . value ;
1146+
1147+ while ( dynamicTriggerInput . lastChild ) {
1148+ dynamicTriggerInput . removeChild ( dynamicTriggerInput . lastChild ) ;
1149+ }
1150+
1151+ if ( value . length >= THRESHOLD ) {
1152+ dynamicTriggerInput . showSuggestions = true ;
1153+
1154+ const filteredCountries = countriesForDynamicTrigger . filter ( country =>
1155+ country . toLowerCase ( ) . startsWith ( value . toLowerCase ( ) )
1156+ ) ;
1157+
1158+ filteredCountries . forEach ( country => {
1159+ const suggestion = document . createElement ( "ui5-suggestion-item" ) ;
1160+ suggestion . text = country ;
1161+ dynamicTriggerInput . appendChild ( suggestion ) ;
1162+ } ) ;
1163+ }
1164+ } ) ;
11161165 </ script >
11171166</ body >
11181167
0 commit comments