import * as _yamada_ui_core from '@yamada-ui/core'; import { HTMLUIProps, PropGetter } from '@yamada-ui/core'; import * as _yamada_ui_use_descendant from '@yamada-ui/use-descendant'; import * as react from 'react'; import { ChangeEvent, ReactElement, FocusEvent, DOMAttributes, MouseEvent } from 'react'; import { FormControlOptions } from '@yamada-ui/form-control'; import { ComboBoxProps, PopoverProps } from '@yamada-ui/popover'; import { Union } from '@yamada-ui/utils'; import { AutocompleteOptionProps } from './autocomplete-option.mjs'; import { AutocompleteOptionGroupProps } from './autocomplete-option-group.mjs'; import './use-autocomplete-option.mjs'; import './use-autocomplete-option-group.mjs'; interface AutocompleteItemWithValue extends AutocompleteOptionProps { label?: string; value?: string; } interface AutocompleteItemWithItems extends AutocompleteOptionGroupProps, Pick { items?: AutocompleteItemWithValue[]; } type AutocompleteItem = AutocompleteItemWithItems | AutocompleteItemWithValue; type MaybeValue = string | string[]; interface UseAutocompleteBaseProps extends ComboBoxProps, FormControlOptions { /** * If `true`, enables the creation of autocomplete option. * * @default false */ allowCreate?: boolean; /** * If `true`, enables the free input. */ allowFree?: boolean; /** * If `true`, the list element will be closed when value is selected. * * @default true */ closeOnSelect?: boolean; /** * The initial value of the autocomplete. */ defaultValue?: T; /** * The message displayed when the search yields no hits. * * @default 'No results found' */ emptyMessage?: string; /** * Function to format text when search input. */ format?: (value: string) => string; /** * The position to be inserted when the autocomplete option is created. * * @default 'first' */ insertPositionItem?: [string, "first" | "last"] | Union<"first" | "last">; /** * If provided, generate options based on items. */ items?: AutocompleteItem[]; /** * The maximum selectable value. */ maxSelectValues?: number; /** * If `true`, the selected item(s) will be excluded from the list. * * @default false */ omitSelectedValues?: boolean; /** * The value of the autocomplete. */ value?: T; /** * Props for select option element. */ optionProps?: Omit; /** * The callback invoked when value state changes. */ onChange?: (value: T) => void; /** * The callback invoked when autocomplete option created. */ onCreate?: (newItem: AutocompleteItem, newItems: AutocompleteItem[]) => void; /** * The callback invoked when search input. */ onSearch?: (ev: ChangeEvent) => void; } interface UseAutocompleteProps extends Omit, "disabled" | "list" | "readOnly" | "required" | "size" | keyof UseAutocompleteBaseProps>, UseAutocompleteBaseProps { } declare const useAutocomplete: (props: UseAutocompleteProps) => { allowCreate: boolean; allowFree: boolean; allSelected: boolean; children: string | number | boolean | ReactElement> | Iterable | undefined; closeOnSelect: boolean; descendants: { count: (filter?: _yamada_ui_use_descendant.FilterDescendant | undefined) => number; destroy: () => void; enabledCount: (filter?: _yamada_ui_use_descendant.FilterDescendant | undefined) => number; enabledFirstValue: (filter?: _yamada_ui_use_descendant.FilterDescendant | undefined) => _yamada_ui_use_descendant.Descendant | undefined; enabledIndexOf: (node?: HTMLElement | null | undefined, filter?: _yamada_ui_use_descendant.FilterDescendant | undefined) => number; enabledLastValue: (filter?: _yamada_ui_use_descendant.FilterDescendant | undefined) => _yamada_ui_use_descendant.Descendant | undefined; enabledNextValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant | undefined; enabledPrevValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant | undefined; enabledValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant | undefined) => _yamada_ui_use_descendant.Descendant | undefined; enabledValues: (filter?: _yamada_ui_use_descendant.FilterDescendant | undefined) => _yamada_ui_use_descendant.Descendant[]; firstValue: (filter?: _yamada_ui_use_descendant.FilterDescendant | undefined) => _yamada_ui_use_descendant.Descendant | undefined; indexOf: (node?: HTMLElement | null | undefined) => number; lastValue: (filter?: _yamada_ui_use_descendant.FilterDescendant | undefined) => _yamada_ui_use_descendant.Descendant | undefined; nextValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant | undefined; prevValue: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant | undefined, loop?: boolean) => _yamada_ui_use_descendant.Descendant | undefined; register: (nodeOrOptions?: HTMLElement | { id?: string; disabled?: boolean; filter?: _yamada_ui_use_descendant.FilterDescendant | undefined; } | null | undefined) => void | ((node: HTMLElement | null) => void); unregister: (node?: HTMLElement | undefined) => void; value: (index: number, filter?: _yamada_ui_use_descendant.FilterDescendant | undefined) => _yamada_ui_use_descendant.Descendant | undefined; values: (filter?: _yamada_ui_use_descendant.FilterDescendant | undefined) => _yamada_ui_use_descendant.Descendant[]; }; empty: boolean; emptyMessage: string; focusedIndex: number; hit: boolean; inputRef: react.RefObject; inputValue: string; label: T | undefined; omitSelectedValues: boolean; open: boolean; pickOptions: (value: string) => void; rebirthOptions: (runFocus?: boolean) => void; setFocusedIndex: react.Dispatch>; value: T; formControlProps: { _active?: ({} & _yamada_ui_core.CSSUIObject) | undefined; _focus?: ({} & _yamada_ui_core.CSSUIObject) | undefined; _focusVisible?: ({} & _yamada_ui_core.CSSUIObject) | undefined; _hover?: ({} & _yamada_ui_core.CSSUIObject) | undefined; _invalid?: ({} & _yamada_ui_core.CSSUIObject) | undefined; disabled: boolean | undefined; readOnly: boolean | undefined; required: boolean | undefined; "aria-disabled": boolean | undefined; "aria-invalid": boolean | undefined; "aria-required": boolean | undefined; onBlur: (event: FocusEvent) => void; "data-readonly": boolean | "false" | "true"; }; getContainerProps: PropGetter<"div", undefined>; getFieldProps: PropGetter<"div", undefined>; getPopoverProps: (props?: PopoverProps) => PopoverProps; inputProps: DOMAttributes; optionProps: Omit | undefined; onChange: (newValue: string, runRebirth?: boolean) => void; onClear: (ev: MouseEvent) => void; onClose: () => void; onCompositionEnd: () => void; onCompositionStart: () => void; onCreate: () => void; onFocusFirst: () => void; onFocusLast: () => void; onFocusNext: (index?: number) => void; onFocusPrev: (index?: number) => void; onFocusSelected: () => void; onOpen: () => void; onSearch: (ev: ChangeEvent) => void; }; type UseAutocompleteReturn = ReturnType; declare const useAutocompleteInput: () => { getInputProps: PropGetter<"input", undefined>; }; type UseAutocompleteInputReturn = ReturnType; export { type AutocompleteItem, type UseAutocompleteInputReturn, type UseAutocompleteProps, type UseAutocompleteReturn, useAutocomplete, useAutocompleteInput };