@@ -66,11 +66,9 @@ const StyledNoResults = styled.li`
6666 padding-left: 3px;
6767` ;
6868
69- const ContentSearchNoResults : React . FC = ( ) => (
70- < StyledNoResults className = "tenup-content-search-list-item components-button" >
71- { __ ( 'Nothing found.' , '10up-block-components' ) }
72- </ StyledNoResults >
73- ) ;
69+ export type ContentSearchOptions = {
70+ inputDelay : number ;
71+ } ;
7472
7573export interface ContentSearchProps {
7674 onSelectItem : ( item : NormalizedSuggestion ) => void ;
@@ -85,8 +83,15 @@ export interface ContentSearchProps {
8583 renderItemType ?: ( props : NormalizedSuggestion ) => string ;
8684 renderItem ?: ( props : RenderItemComponentProps ) => JSX . Element ;
8785 fetchInitialResults ?: boolean ;
86+ options ?: ContentSearchOptions ;
8887}
8988
89+ const ContentSearchNoResults : React . FC = ( ) => (
90+ < StyledNoResults className = "tenup-content-search-list-item components-button" >
91+ { __ ( 'Nothing found.' , '10up-block-components' ) }
92+ </ StyledNoResults >
93+ ) ;
94+
9095const ContentSearch : React . FC < ContentSearchProps > = ( {
9196 onSelectItem = ( ) => {
9297 console . log ( 'Select!' ) ; // eslint-disable-line no-console
@@ -102,8 +107,11 @@ const ContentSearch: React.FC<ContentSearchProps> = ({
102107 renderItemType = undefined ,
103108 renderItem : SearchResultItem = SearchItem ,
104109 fetchInitialResults,
110+ options,
105111} ) => {
106- const [ searchInput , setSearchString , searchString ] = useDebouncedInput ( '' ) ;
112+ const debounceOptions =
113+ options && options . inputDelay ? { delay : options . inputDelay } : undefined ;
114+ const [ searchInput , setSearchString , searchString ] = useDebouncedInput ( '' , debounceOptions ) ;
107115 const [ isFocused , setIsFocused ] = useState ( false ) ;
108116 const searchContainer = useRef < HTMLDivElement > ( null ) ;
109117
0 commit comments