UNPKG

@yamada-ui/autocomplete

Version:

Yamada UI autocomplete component

140 lines (137 loc) 4.31 kB
import * as _yamada_ui_core from '@yamada-ui/core'; import { ThemeProps, HTMLUIProps } from '@yamada-ui/core'; import { MotionProps } from '@yamada-ui/motion'; import { PortalProps } from '@yamada-ui/portal'; import { FC, MouseEventHandler, ReactNode } from 'react'; import { AutocompleteCreateProps } from './autocomplete-create.js'; import { AutocompleteEmptyProps } from './autocomplete-empty.js'; import { AutocompleteIconProps } from './autocomplete-icon.js'; import { AutocompleteListProps } from './autocomplete-list.js'; import { UseAutocompleteProps } from './use-autocomplete.js'; import '@yamada-ui/use-descendant'; import '@yamada-ui/form-control'; import '@yamada-ui/popover'; import '@yamada-ui/utils'; import './autocomplete-option.js'; import './use-autocomplete-option.js'; import './autocomplete-option-group.js'; import './use-autocomplete-option-group.js'; interface MultiAutocompleteOptions { /** * If `true`, display the select clear icon. * * @default true */ clearable?: boolean; /** * If `true`, the list element will be closed when value is selected. * * @default false */ closeOnSelect?: boolean; /** * The custom display value to use. */ component?: FC<{ index: number; label: string; value: number | string; onRemove: MouseEventHandler<HTMLElement>; }>; /** * The border color when the input is invalid. */ errorBorderColor?: string; /** * The border color when the input is focused. */ focusBorderColor?: string; /** * The footer of the autocomplete content element. */ footer?: FC<{ value: string[] | undefined; onClose: () => void; }> | ReactNode; /** * The header of the autocomplete content element. */ header?: FC<{ value: string[] | undefined; onClose: () => void; }> | ReactNode; /** * If `true`, display the select clear icon. * * @default true * * @deprecated Use `clearable` instead. */ isClearable?: boolean; /** * If `true`, keep the placeholder. * * @default false */ keepPlaceholder?: boolean; /** * The visual separator between each value. * * @default ',' */ separator?: string; /** * Props for multi autocomplete clear icon element. */ clearIconProps?: AutocompleteIconProps; /** * Props for multi autocomplete container element. */ containerProps?: Omit<HTMLUIProps, "children">; /** * Props for multi autocomplete content element. */ contentProps?: Omit<MotionProps, "children">; /** * Props for autocomplete create element. */ createProps?: Omit<AutocompleteCreateProps, "children">; /** * Props for autocomplete empty element. */ emptyProps?: Omit<AutocompleteEmptyProps, "children">; /** * Props for multi autocomplete field element. */ fieldProps?: Omit<MultiAutocompleteFieldProps, "children" | "component" | "inputProps" | "keepPlaceholder" | "separator">; /** * Props for multi autocomplete icon element. */ iconProps?: AutocompleteIconProps; /** * Props for multi autocomplete input element. */ inputProps?: HTMLUIProps<"input">; /** * Props for multi autocomplete list element. */ listProps?: Omit<AutocompleteListProps, "children">; /** * Props to be forwarded to the portal component. * * @default '{ disabled: true }' * */ portalProps?: Omit<PortalProps, "children">; } interface MultiAutocompleteProps extends ThemeProps<"MultiAutocomplete">, Omit<UseAutocompleteProps<string[]>, "closeOnSelect">, MultiAutocompleteOptions { } /** * `MultiAutocomplete` is a component used to display suggestions based on user text input and to obtain multiple values. * * @see Docs https://yamada-ui.com/components/forms/multi-autocomplete */ declare const MultiAutocomplete: _yamada_ui_core.Component<"input", MultiAutocompleteProps>; interface MultiAutocompleteFieldProps extends HTMLUIProps, Pick<MultiAutocompleteProps, "component" | "inputProps" | "keepPlaceholder" | "separator"> { } export { MultiAutocomplete, type MultiAutocompleteProps };