import { Evented } from "../events.js"; export interface SuggestOptions { debounceMs?: number; minLength?: number; limit?: number; } export interface SuggestContext { limit?: number; /** Cancels this request with AbortError, including while waiting for debounce. */ signal?: AbortSignal; [key: string]: unknown; } export type SuggestFetcher = (query: string, context: SuggestContext) => Promise | TResult[] | null | undefined; export declare class SuggestProvider { #private; readonly fetcher: SuggestFetcher; readonly options: Required; constructor(fetcher: SuggestFetcher, options?: SuggestOptions); /** * Supersedes the previous request; cancellation rejects with `AbortError`, never `[]`. * Calling a destroyed provider rejects with `DestroyedError` instead: the request never * started, and no retry against this provider can succeed. */ suggest(query: string, context?: SuggestContext): Promise; /** Cancels pending work but leaves this provider reusable. */ cancel(): this; destroy(): void; } export declare function createSuggestProvider(fetcher: SuggestFetcher, options?: SuggestOptions): SuggestProvider; export interface SuggestWidgetOptions { input: HTMLInputElement | string; list?: HTMLElement | string; provider: SuggestProvider; label?: (item: TResult) => string; onSelect?: (item: TResult) => void; context?: (query: string) => SuggestContext; activeClassName?: string; emptyText?: string; } export interface SuggestWidgetEventMap { cancel: {}; select: { item: TResult; index: number; }; loading: { query: string; }; results: { query: string; items: TResult[]; }; abort: { query: string; error: unknown; }; error: { query: string; error: unknown; }; } export declare class SuggestWidget extends Evented> { #private; readonly input: HTMLInputElement; readonly list: HTMLElement; readonly provider: SuggestProvider; readonly label: (item: TResult) => string; readonly onSelect: (item: TResult) => void; readonly context: (query: string) => SuggestContext; readonly activeClassName: string; readonly emptyText: string; readonly _unsub: Array<() => void>; readonly _itemUnsub: Array<() => void>; results: TResult[]; activeIndex: number; get isDestroyed(): boolean; constructor(options: SuggestWidgetOptions); /** Runs a suggestion pass for the input's current value. */ attach(): this; /** Cancels pending work and clears the list. Safe to call after `destroy()`. */ cancel(): this; /** Terminal and idempotent. Afterwards `attach` and `select` throw; `cancel` stays a no-op. */ destroy(): void; select(index?: number): this; } export declare function createSuggestWidget(options: SuggestWidgetOptions): SuggestWidget; //# sourceMappingURL=suggest.d.ts.map