import type { JSX } from "@solidjs/web"; import { type Accessor } from "solid-js"; import { type MaybeAccessor } from "../internals/maybe-accessor.js"; import { type Group } from "./internals/resolve-value-label.js"; export type ComboboxSelectionMode = "none" | "single" | "multiple"; export type ComboboxChangeReason = "item-press" | "clear-press" | "input-change" | "escape-key" | "outside-press" | "imperative"; export interface CreateComboboxOptions { /** * Current selected value. Consumer-owned signal. Writes happen via * `onValueChange` — the primitive does NOT keep an internal copy. */ value: MaybeAccessor; onValueChange?: (value: Value | Value[] | null, reason: ComboboxChangeReason) => void; /** * Current input text. Consumer-owned signal. When omitted, a computed * default derives the display text from the selected value's label in * single-select mode. */ inputValue?: MaybeAccessor; onInputValueChange?: (value: string, reason: ComboboxChangeReason) => void; /** Open state. Consumer-owned signal. */ open: MaybeAccessor; onOpenChange?: (open: boolean, reason: ComboboxChangeReason) => 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; /** Selection mode. @default "single" */ selectionMode?: MaybeAccessor; /** `true` is shorthand for `selectionMode: "multiple"`. */ multiple?: MaybeAccessor; disabled?: MaybeAccessor; readOnly?: MaybeAccessor; /** * Whether the user has typed anything since the popup last opened. When * `false` in single-select mode, opening with a committed value shows the * full list (filtering is bypassed) instead of just the matching item. * @default false */ queryChangedAfterOpen?: MaybeAccessor; /** Converts object items to a display string. */ itemToStringLabel?: MaybeAccessor<((item: Value) => string) | undefined>; /** Converts object items to a form-submission string. */ itemToStringValue?: MaybeAccessor<((item: Value) => string) | undefined>; /** Custom item equality. Defaults to `Object.is`. */ isItemEqualToValue?: MaybeAccessor<((item: Value, value: Value) => boolean) | undefined>; } export interface ComboboxApi { /** Reactive accessor for the current selected value. */ value: Accessor; /** Reactive accessor for the current input text. */ inputValue: Accessor; /** Reactive accessor for the open state. */ open: Accessor; /** Current selection mode. */ selectionMode: 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; /** Check whether a given item value is currently selected. */ isItemSelected: (item: Value) => boolean; /** Pure event-emitter — fire `onValueChange`. Consumer owns the signal write. */ setValue: (next: Value | Value[] | null, reason?: ComboboxChangeReason) => void; /** Pure event-emitter — fire `onInputValueChange`. */ setInputValue: (next: string, reason?: ComboboxChangeReason) => void; /** Pure event-emitter — fire `onOpenChange`. */ setOpen: (next: boolean, reason?: ComboboxChangeReason) => void; /** * Context provider. Wrap a subtree to make the api discoverable via * `useCombobox()` without prop-drilling. */ Provider: (props: { children: JSX.Element; }) => JSX.Element; } export declare function useCombobox(): ComboboxApi; /** * Solid 2-native headless primitive for the combobox selection + filtering * logic. Owns: value / inputValue / open state, items / filteredItems / * query derivation, and `isItemSelected`. DOM concerns (floating-ui * positioning, input element, keyboard nav, portal) live in the structural * `` wrapper that composes this primitive. */ export declare function createCombobox(options: CreateComboboxOptions): ComboboxApi; //# sourceMappingURL=create-combobox.d.ts.map