Skip to main content

Fetch Autocomplete Field

Displaying an autocomplete field with an the request handling pre-making. The field can returns data with onFetchData callback function and can also returns option selected with this associated the data on click of the option displayed by the filed with the onOptionSubmit callback function.

Storybook Docs

Props

NameTypeDefaultDescription
deDebouncenumber1000Time before the string written in the field is taken into account. If the user modifies the field value before the end of the delay, the delay starts again from the beginning
minValueLengthnumber5Minimum length of the field value for started the request
placeholderstring"89 Pall Mall, St. James's, London SW1Y 5HS, United Kingdom"Value of the placeholder field
onOptionSubmit(value: IValue<T>) => void-Callback function called when an option of the field is selected. The function returns IValue<T>
onFetchData(value: string) => Promise<IValue<T>[]>-Callback function called when the request returns data
...--extends autocomplete Props

IFetchOption

NameTypeDefaultDescription
key *string-Key of option
value *string-Value of option

IValue<T>

NameTypeDefaultDescription
label *string-Label displayed on options list and returned by the onFetchData function
Value *T-The request data part corresponding to the selected option associated with the label