PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.0.0
GenerateBlocks v2.0.0
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / pattern-library / components / pattern-search.js
generateblocks / src / pattern-library / components Last commit date
add-library.js 2 years ago category-list.js 1 year ago insert-pattern.js 2 years ago library-cache.js 2 years ago library-layout.js 1 year ago library-provider.js 2 years ago library-selector.js 1 year ago manage-libraries.js 2 years ago pattern-details-header.js 1 year ago pattern-details.js 1 year ago pattern-list.js 1 year ago pattern-search.js 2 years ago pattern.js 1 year ago selected-patterns.js 1 year ago
pattern-search.js
29 lines
1 import { SearchControl } from '@wordpress/components';
2 import { useState, useEffect } from '@wordpress/element';
3 import { useDebounce } from '@wordpress/compose';
4 import { useLibrary } from './library-provider';
5
6 export default function PatternSearch( { onChange } ) {
7 const { setSearch, activeLibrary } = useLibrary();
8 const [ searchInput, setSearchInput ] = useState( '' );
9 const setDebouncedInput = useDebounce( setSearch, 500 );
10
11 useEffect( () => {
12 setDebouncedInput( searchInput );
13 }, [ searchInput ] );
14
15 useEffect( () => {
16 setSearchInput( '' );
17 }, [ activeLibrary?.id ] );
18
19 return (
20 <SearchControl
21 value={ searchInput }
22 onChange={ ( value ) => {
23 onChange( value );
24 setSearchInput( value );
25 } }
26 />
27 );
28 }
29