components/SearchField
import { … } from 'zidane-ui'ui/src/components/SearchField.tsx
Components#
SearchFieldComponent#
A list's search field: a well with the magnifier. Escape clears it, instead of closing the surface it sits in.
function SearchField(props: SearchFieldProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | SearchFieldProps | Component props. |
Returns
ElementProps
| Name | Type | Default | Description |
|---|---|---|---|
| autoFocus? | boolean | false | Takes focus when it mounts (the search at the top of a menu). |
| className? | string | Extra classes on the root. | |
| label | string | Its accessible name and placeholder, from the area's labels. | |
| onKeyDown? | (event: KeyboardEvent<HTMLInputElement>) => void | Keys the field leaves to its list (ArrowDown into the rows, Enter to pick the first). | |
| onQuery | (query: string) => void | Called with the new query. | |
| query | string | The query. | |
| size? | 'sm' | 'md' | 'md' | Its height: |
| style? | CSSProperties | Inline styles on the root element. | |
| variant? | 'well' | 'strip' | 'well' |
|
Functions#
filterByQueryFunction#
The items whose words hold the query, in any case. An empty query keeps them all.
function filterByQuery<T>(
list: readonly T[],
query: string,
words: (item: T) => readonly (string | undefined)[],
): readonly T[]Type parameters
| Name | Description |
|---|---|
| T |
Parameters
| Name | Type | Description |
|---|---|---|
| list | readonly T[] | The items. |
| query | string | The query. |
| words | (item: T) => readonly (string | undefined)[] | An item's words. |
Returns
readonly T[]Interfaces#
SearchFieldPropsInterface#
Props for SearchField.
interface SearchFieldPropsProperties
| Name | Type | Default | Description |
|---|---|---|---|
| autoFocus? | boolean | false | Takes focus when it mounts (the search at the top of a menu). |
| className? | string | Extra classes on the root. | |
| label | string | Its accessible name and placeholder, from the area's labels. | |
| onKeyDown? | (event: KeyboardEvent<HTMLInputElement>) => void | Keys the field leaves to its list (ArrowDown into the rows, Enter to pick the first). | |
| onQuery | (query: string) => void | Called with the new query. | |
| query | string | The query. | |
| size? | 'sm' | 'md' | 'md' | Its height: |
| style? | CSSProperties | Inline styles on the root element. | |
| variant? | 'well' | 'strip' | 'well' |
|