@@ -8,6 +8,7 @@ import {FetchPolicy, NetworkStatus, useResource} from '@clayui/data-provider';
88import  DropDown  from  '@clayui/drop-down' ; 
99import  Layout  from  '@clayui/layout' ; 
1010import  { FocusScope ,  useDebounce }  from  '@clayui/shared' ; 
11+ import  Sticker  from  '@clayui/sticker' ; 
1112import  React ,  { useEffect ,  useRef ,  useState }  from  'react' ; 
1213
1314import  ClayAutocomplete  from  '../src' ; 
@@ -47,7 +48,6 @@ export const Default = (args: any) => (
4748					</ label > 
4849					< ClayAutocomplete 
4950						aria-labelledby = "clay-autocomplete-label-1" 
50- 						displayType = "select" 
5151						id = "clay-autocomplete-1" 
5252						menuTrigger = { args . menuTrigger } 
5353						messages = { { 
@@ -164,8 +164,32 @@ export const Dynamic = () => (
164164) ; 
165165
166166export  const  CustomItem  =  ( )  =>  { 
167+ 	const  defaultItems  =  [ 
168+ 		'Access Board' , 
169+ 		'Debt and Claims' , 
170+ 		'Farm Service' , 
171+ 		'Fish and Wildlife' , 
172+ 		'Marine Mammal Commission' , 
173+ 		'Science and Technology' , 
174+ 	] ; 
175+ 	const  [ sticker ,  setSticker ]  =  useState ( null ) ; 
167176	const  [ value ,  setValue ]  =  useState ( '' ) ; 
168177
178+ 	useEffect ( ( )  =>  { 
179+ 		const  department  =  value [ 0 ] ; 
180+ 		const  index  =  defaultItems . indexOf ( value ) ; 
181+ 
182+ 		if  ( department  &&  index  >=  0 )  { 
183+ 			setSticker ( 
184+ 				< Sticker  displayType = { `outline-${ index }  }  size = "sm" > 
185+ 					{ department } 
186+ 				</ Sticker > 
187+ 			) ; 
188+ 		}  else  { 
189+ 			setSticker ( null ) ; 
190+ 		} 
191+ 	} ,  [ value ] ) ; 
192+ 
169193	return  ( 
170194		< div  className = "row" > 
171195			< div  className = "col-md-5" > 
@@ -175,47 +199,57 @@ export const CustomItem = () => {
175199							htmlFor = "clay-autocomplete-2" 
176200							id = "clay-autocomplete-label-2" 
177201						> 
178- 							Numbers (one-five) 
202+ 							Space 
179203						</ label > 
180204						< ClayAutocomplete 
181205							aria-labelledby = "clay-autocomplete-label-2" 
182- 							defaultItems = { [ 
183- 								'one' , 
184- 								'two' , 
185- 								'three' , 
186- 								'four' , 
187- 								'five' , 
188- 							] } 
206+ 							defaultItems = { defaultItems } 
207+ 							displayType = "select" 
189208							id = "clay-autocomplete-2" 
209+ 							insetItemBefore = { sticker } 
210+ 							menuTrigger = "focus" 
190211							messages = { { 
191212								listCount : '{0} option available.' , 
192213								listCountPlural : '{0} options available.' , 
193214								loading : 'Loading...' , 
194215								notFound : 'No results found' , 
195216							} } 
196217							onChange = { setValue } 
197- 							placeholder = "Enter  a number from One to Five " 
218+ 							placeholder = "Select  a Space " 
198219							value = { value } 
199220						> 
200- 							{ ( item )  =>  ( 
201- 								< ClayAutocomplete . Item 
202- 									key = { item } 
203- 									textValue = { item } 
204- 								> 
205- 									< Layout . ContentRow > 
206- 										< Layout . ContentCol  expand > 
207- 											< Text  size = { 3 } > 
208- 												< TextHighlight  match = { value } > 
209- 													{ item } 
210- 												</ TextHighlight > 
211- 											</ Text > 
212- 										</ Layout . ContentCol > 
213- 										< Layout . ContentCol > 
214- 											< Text  size = { 2 } > Description</ Text > 
215- 										</ Layout . ContentCol > 
216- 									</ Layout . ContentRow > 
217- 								</ ClayAutocomplete . Item > 
218- 							) } 
221+ 							{ ( item )  =>  { 
222+ 								const  deptLetter  =  item [ 0 ] ; 
223+ 
224+ 								return  ( 
225+ 									< ClayAutocomplete . Item 
226+ 										key = { item } 
227+ 										textValue = { item } 
228+ 									> 
229+ 										< Layout . ContentRow > 
230+ 											< Layout . ContentCol > 
231+ 												< Sticker 
232+ 													displayType = { `outline-${ defaultItems . indexOf (  
233+ 														item  
234+ 													) }  `} 
235+ 													size = "sm" 
236+ 												> 
237+ 													{ deptLetter } 
238+ 												</ Sticker > 
239+ 											</ Layout . ContentCol > 
240+ 											< Layout . ContentCol  expand > 
241+ 												< Text  size = { 3 } > 
242+ 													< TextHighlight 
243+ 														match = { value } 
244+ 													> 
245+ 														{ item } 
246+ 													</ TextHighlight > 
247+ 												</ Text > 
248+ 											</ Layout . ContentCol > 
249+ 										</ Layout . ContentRow > 
250+ 									</ ClayAutocomplete . Item > 
251+ 								) ; 
252+ 							} } 
219253						</ ClayAutocomplete > 
220254					</ div > 
221255				</ div > 
0 commit comments