44import { Autocomplete , GridLayout , ListBox , ListBoxItem , Size , useFilter , Virtualizer } from 'react-aria-components' ;
55import CheckmarkCircle from '@react-spectrum/s2/icons/CheckmarkCircle' ;
66import Close from '@react-spectrum/s2/icons/Close' ;
7- import { Content , Heading , IllustratedMessage , pressScale , SearchField , Skeleton , Text , ToastQueue } from '@react-spectrum/s2' ;
7+ import { Content , Heading , IllustratedMessage , Link , pressScale , SearchField , Skeleton , Text , ToastQueue } from '@react-spectrum/s2' ;
88import { focusRing , iconStyle , style } from '@react-spectrum/s2/style' with { type : 'macro' } ;
99import { iconAliases } from './iconAliases.js' ;
1010// @ts -ignore
1111import icons from '/packages/@react-spectrum/s2/s2wf-icons/*.svg' ;
12- import InfoCircle from '@react-spectrum/s2/icons/InfoCircle ' ;
12+ import { InfoMessage } from './colorSearchData ' ;
1313// eslint-disable-next-line monorepo/no-internal-import
1414import NoSearchResults from '@react-spectrum/s2/illustrations/linear/NoSearchResults' ;
1515import React , { useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
@@ -19,14 +19,19 @@ export const iconList = Object.keys(icons).map(name => ({id: name.replace(/^S2_I
1919export function useIconFilter ( ) {
2020 let { contains} = useFilter ( { sensitivity : 'base' } ) ;
2121 return useCallback ( ( textValue : string , inputValue : string ) => {
22+ const trimmedInput = inputValue . trim ( ) ;
23+ // If input is empty after trimming, show all items
24+ if ( ! trimmedInput ) {
25+ return true ;
26+ }
2227 // Check for alias matches
2328 for ( const alias of Object . keys ( iconAliases ) ) {
24- if ( contains ( alias , inputValue ) && iconAliases [ alias ] . includes ( textValue ) ) {
29+ if ( contains ( alias , trimmedInput ) && iconAliases [ alias ] . includes ( textValue ) ) {
2530 return true ;
2631 }
2732 }
2833 // Also compare for substrings in the icon's actual name
29- return textValue != null && contains ( textValue , inputValue ) ;
34+ return textValue != null && contains ( textValue , trimmedInput ) ;
3035 } , [ contains ] ) ;
3136}
3237
@@ -57,15 +62,6 @@ export function useCopyImport() {
5762 return { copiedId, handleCopyImport} ;
5863}
5964
60- function CopyInfoMessage ( ) {
61- return (
62- < div className = { style ( { display : 'flex' , alignItems : 'center' , justifyContent : 'center' , gap : 4 } ) } >
63- < InfoCircle styles = { iconStyle ( { size : 'XS' } ) } />
64- < span className = { style ( { font : 'ui' } ) } > Press an item to copy its import statement</ span >
65- </ div >
66- ) ;
67- }
68-
6965interface IconListBoxProps {
7066 items : typeof iconList ,
7167 copiedId : string | null ,
@@ -133,7 +129,7 @@ export function IconSearchView({filteredItems, listBoxClassName}: IconSearchView
133129
134130 return (
135131 < >
136- < CopyInfoMessage / >
132+ < InfoMessage > Press an item to copy its import statement. See < Link href = "icons" > Icons </ Link > for more information. </ InfoMessage >
137133 < IconListBox items = { filteredItems } copiedId = { copiedId } onAction = { handleCopyImport } listBoxClassName = { listBoxClassName } />
138134 </ >
139135 ) ;
@@ -236,7 +232,7 @@ export function IconsPageSearch() {
236232 < Autocomplete filter = { filter } >
237233 < div className = { style ( { display : 'flex' , flexDirection : 'column' , gap : 8 } ) } >
238234 < SearchField size = "L" aria-label = "Search icons" placeholder = "Search icons" />
239- < CopyInfoMessage / >
235+ < InfoMessage > Press an item to copy its import statement. See < Link href = "icons" > Icons </ Link > for more information. </ InfoMessage >
240236 < IconListBox
241237 items = { iconList }
242238 copiedId = { copiedId }
0 commit comments