import type { JSX } from "@solidjs/web"; import { type Accessor } from "solid-js"; import { type Group } from "../combobox/internals/resolve-value-label.js"; import { type MaybeAccessor } from "../internals/maybe-accessor.js"; export type AutocompleteMode = "list" | "both" | "inline" | "none"; export type AutocompleteChangeReason = "item-press" | "input-change" | "escape-key" | "outside-press" | "imperative"; export interface CreateAutocompleteOptions { /** * Input value (the text in the autocomplete input). Consumer-owned signal. * Writes happen via `onValueChange` — the primitive does NOT keep an internal * copy. */ value: MaybeAccessor; onValueChange?: (value: string, reason: AutocompleteChangeReason) => void; /** Open state. Consumer-owned signal. */ open: MaybeAccessor; onOpenChange?: (open: boolean, reason: AutocompleteChangeReason) => void; /** Items to filter. Flat array or grouped (`{ items: [...] }`). */ items?: MaybeAccessor[] | undefined>; /** * Filter function. Pass `null` to disable filtering. Defaults to an * `Intl.Collator`-backed "contains" filter. */ filter?: MaybeAccessor<((item: Value, query: string, itemToStringLabel?: (item: Value) => string) => boolean) | null | undefined> | undefined; /** Locale for the default `Intl.Collator`. */ locale?: MaybeAccessor; /** * Filtering and inline-autocomplete mode. * @default "list" */ mode?: MaybeAccessor; disabled?: MaybeAccessor; readOnly?: MaybeAccessor; /** Converts object items to a display string. */ itemToStringLabel?: MaybeAccessor<((item: Value) => string) | undefined>; /** Custom item equality. Defaults to `Object.is`. */ isItemEqualToValue?: MaybeAccessor<((item: Value, value: Value) => boolean) | undefined>; } export interface AutocompleteApi { /** Reactive accessor for the current input value. */ value: Accessor; /** Reactive accessor for the open state. */ open: Accessor; /** Current mode. */ mode: Accessor; disabled: Accessor; readOnly: Accessor; /** All items (before filtering). */ items: Accessor[] | undefined>; /** Items after applying the filter against the current query. */ filteredItems: Accessor[]>; /** Flat version of `filteredItems` (groups are unwrapped). */ flatFilteredItems: Accessor; /** Trimmed query string used for filtering. */ query: Accessor; /** Whether the items list is grouped. */ isGrouped: Accessor; /** Label accessor for rendering item text. */ itemLabel: (item: Value) => string; /** Pure event-emitter — fire `onValueChange`. Consumer owns the signal write. */ setValue: (next: string, reason?: AutocompleteChangeReason) => void; /** Pure event-emitter — fire `onOpenChange`. */ setOpen: (next: boolean, reason?: AutocompleteChangeReason) => void; /** * Context provider. Wrap a subtree to make the api discoverable via * `useAutocomplete()` without prop-drilling. */ Provider: (props: { children: JSX.Element; }) => JSX.Element; } export declare function useAutocomplete(): AutocompleteApi; /** * Solid 2-native headless primitive for autocomplete selection + filtering * logic. Autocomplete is the "input value is the source of truth" variant: * there is no separate selected-value state — the input text IS the value. * Owns: value / open state, items / filteredItems / query derivation, and * item label helpers. DOM concerns (floating-ui, input element, keyboard nav, * portal) live in the structural `` wrapper. */ export declare function createAutocomplete(options: CreateAutocompleteOptions): AutocompleteApi; //# sourceMappingURL=create-autocomplete.d.ts.map