import type { JSX } from 'solid-js'; export interface AutocompleteStateProperties { isSelected: (value: T) => boolean; select: (value: T) => void; hasSelected: () => boolean; isActive: (value: T) => boolean; hasActive: () => boolean; focus: (value: T) => void; blur: () => void; disabled: () => boolean; query: () => string; setQuery: (value: string) => void; matches: (value: T) => boolean; hasQuery: () => boolean; } export interface SingleAutocompleteStateControlledOptions { multiple?: false; toggleable?: boolean; /** `undefined` means nothing is selected, which is also what `toggleable` produces. */ value: T | undefined; matchBy: (value: T, query: string) => boolean; onChange?: (value?: T) => void; disabled?: boolean; by?: (a: T, b: T) => boolean; } export interface SingleAutocompleteStateUncontrolledOptions { multiple?: false; toggleable?: boolean; /** `undefined` starts with nothing selected. */ defaultValue: T | undefined; matchBy: (value: T, query: string) => boolean; onChange?: (value?: T) => void; disabled?: boolean; by?: (a: T, b: T) => boolean; } export type SingleAutocompleteStateOptions = SingleAutocompleteStateControlledOptions | SingleAutocompleteStateUncontrolledOptions; /** * Creates a single-selection state with a debounced text query on top. Backs * `Combobox` and `Command`. * * The required `matchBy` decides which values survive the current query. * Writes to the query are debounced by 250ms, so `query()` lags typing. * * @see {@link https://github.com/lxsmnsyc/terracotta/blob/main/docs/states.md#autocomplete-state} */ export declare function createSingleAutocompleteState(options: SingleAutocompleteStateOptions): AutocompleteStateProperties; export interface MultipleAutocompleteStateControlledOptions { multiple: true; toggleable?: boolean; value: T[]; matchBy: (value: T, query: string) => boolean; onChange?: (value: T[]) => void; disabled?: boolean; by?: (a: T, b: T) => boolean; } export interface MultipleAutocompleteStateUncontrolledOptions { multiple: true; toggleable?: boolean; defaultValue: T[]; matchBy: (value: T, query: string) => boolean; onChange?: (value: T[]) => void; disabled?: boolean; by?: (a: T, b: T) => boolean; } export type MultipleAutocompleteStateOptions = MultipleAutocompleteStateControlledOptions | MultipleAutocompleteStateUncontrolledOptions; /** * Creates a multiple-selection state with a debounced text query on top. * Requires `multiple: true`. * * The required `matchBy` decides which values survive the current query. * Writes to the query are debounced by 250ms, so `query()` lags typing. * * @see {@link https://github.com/lxsmnsyc/terracotta/blob/main/docs/states.md#autocomplete-state} */ export declare function createMultipleAutocompleteState(options: MultipleAutocompleteStateOptions): AutocompleteStateProperties; export interface AutocompleteStateRenderProps { children?: JSX.Element | ((state: AutocompleteStateProperties) => JSX.Element); } export interface AutocompleteStateProviderProps extends AutocompleteStateRenderProps { state: AutocompleteStateProperties; } export declare function AutocompleteStateProvider(props: AutocompleteStateProviderProps): JSX.Element; /** * Reads the nearest autocomplete state from context. Throws when there is * none. * * @see {@link https://github.com/lxsmnsyc/terracotta/blob/main/docs/states.md#autocomplete-state} */ export declare function useAutocompleteState(): AutocompleteStateProperties; /** * Passes the nearest autocomplete state to a render prop. A function child is * treated as a render prop only when it declares exactly one parameter. * * @see {@link https://github.com/lxsmnsyc/terracotta/blob/main/docs/states.md#autocomplete-state} */ export declare function AutocompleteStateChild(props: AutocompleteStateRenderProps): JSX.Element; //# sourceMappingURL=create-autocomplete-state.d.ts.map