UNPKG

@coconut-software/ui

Version:

React components for faster and easier web development.

64 lines (63 loc) 2.62 kB
import type { ChangeEventHandler, Dispatch, FocusEventHandler, MouseEventHandler, MutableRefObject, PropsWithChildren, Ref } from 'react'; import type SvgIcon from '../SvgIcon/SvgIcon'; import type { TextInputColor, TextInputSize, TextInputVariant } from '../TextInput/styles'; import type { Actions } from './Actions'; export declare enum DisplayModes { Always = "always", WithTerm = "with-term", WithoutTerm = "without-term" } export interface AutocompleteProps { creatable?: boolean; clearable?: boolean; color?: TextInputColor; dataSet?: Record<string, string | undefined>; defaultDisplayValue?: string; defaultValue?: string; displayRef?: Ref<HTMLInputElement>; disabled?: boolean; endAdornment?: typeof SvgIcon | string; error?: boolean; helperText?: string; inputRef?: Ref<HTMLInputElement>; label: string; loading?: boolean; name?: string; onBlur?: FocusEventHandler<HTMLInputElement>; onChange: ChangeEventHandler<HTMLInputElement>; onFocus?: FocusEventHandler<HTMLInputElement>; onSelect?: MouseEventHandler<HTMLButtonElement>; select?: boolean; size?: TextInputSize; startAdornment?: typeof SvgIcon | string; variant?: TextInputVariant; } type AutocompleteState = { displayInputRef: MutableRefObject<HTMLInputElement>; groups: Record<string, { display: DisplayModes; hasChildren: boolean; }>; inputRef: MutableRefObject<HTMLInputElement>; label: string; minWidth: string; multi: boolean; onSelectRef: MutableRefObject<MouseEventHandler<HTMLButtonElement> | undefined>; searching: boolean; select: boolean; selectingRef: MutableRefObject<boolean>; value: string; }; type UseAutocompleteValues = [AutocompleteState, Dispatch<Actions>]; export declare const useAutocomplete: () => UseAutocompleteValues; declare function Autocomplete({ creatable, clearable, children, color, dataSet, defaultDisplayValue, defaultValue, disabled, displayRef, endAdornment, error, helperText, inputRef, label, loading, name, onBlur, onChange, onFocus, onSelect, select, size, startAdornment, variant, }: PropsWithChildren<AutocompleteProps>): JSX.Element; declare namespace Autocomplete { var Group: typeof import("./Group").default; var Suggestion: ({ children, disabled, displayValue, value, ...rest }: PropsWithChildren<SuggestionProps>) => JSX.Element; } interface SuggestionProps { disabled?: boolean; value: string; displayValue?: string; } export default Autocomplete;