diff --git a/packages/components/src/autocomplete/README.md b/packages/components/src/autocomplete/README.md index 102f88d4532501..fe7a467dfd30ba 100644 --- a/packages/components/src/autocomplete/README.md +++ b/packages/components/src/autocomplete/README.md @@ -1,5 +1,4 @@ -Autocomplete -============ +# Autocomplete This component is used to provide autocompletion support for a child input component. @@ -105,33 +104,59 @@ Whether to apply debouncing for the autocompleter. Set to true to enable debounc - Type: `Boolean` - Required: No -### Examples +## Usage The following is a contrived completer for fresh fruit. ```jsx -const fruitCompleter = { - name: 'fruit', - // The prefix that triggers this completer - triggerPrefix: '~', - // The option data - options: [ - { visual: '🍎', name: 'Apple' }, - { visual: '🍊', name: 'Orange' }, - { visual: '🍇', name: 'Grapes' }, - ], - // Returns a label for an option like "🍊 Orange" - getOptionLabel: option => [ - { option.visual }, - option.name - ], - // Declares that options should be matched by their name - getOptionKeywords: option => [ option.name ], - // Declares that the Grapes option is disabled - isOptionDisabled: option => option.name === 'Grapes', - // Declares completions should be inserted as abbreviations - getOptionCompletion: option => ( - { option.visual } - ), +import { Autocomplete } from '@wordpress/components'; + +function FreshFruitAutocomplete() { + const autocompleters = [ + { + name: 'fruit', + // The prefix that triggers this completer + triggerPrefix: '~', + // The option data + options: [ + { visual: '🍎', name: 'Apple', id: 1 }, + { visual: '🍊', name: 'Orange', id: 2 }, + { visual: '🍇', name: 'Grapes', id: 3 }, + ], + // Returns a label for an option like "🍊 Orange" + getOptionLabel: option => ( + + { option.visual }{ option.name } + + ), + // Declares that options should be matched by their name + getOptionKeywords: option => [ option.name ], + // Declares that the Grapes option is disabled + isOptionDisabled: option => option.name === 'Grapes', + // Declares completions should be inserted as abbreviations + getOptionCompletion: option => ( + { option.visual } + ), + } + ]; + + return ( +
+ + { ( { isExpanded, listBoxId, activeId } ) => ( +
+
+ ) } +
+

Type ~ for triggering the autocomplete.

+
+ ); }; ``` diff --git a/packages/components/src/base-control/README.md b/packages/components/src/base-control/README.md index ac2dc6249714a1..1dd091908176d1 100644 --- a/packages/components/src/base-control/README.md +++ b/packages/components/src/base-control/README.md @@ -1,5 +1,4 @@ -BaseControl -======= +# BaseControl BaseControl component is used to generate labels and help text for components handling user inputs. @@ -8,17 +7,21 @@ BaseControl component is used to generate labels and help text for components ha Render a BaseControl for a textarea input: ```jsx - -