/**
* @file
*
* Mock of Obsidian's `AbstractInputSuggest`, the type-ahead popover attached to a text input.
*/
import type { AbstractInputSuggest as AbstractInputSuggestOriginal } from 'obsidian';
import type { App } from './App.cjs';
import { PopoverSuggest } from './PopoverSuggest.cjs';
/**
* Mock of Obsidian's `AbstractInputSuggest`, which adds type-ahead suggestions to an `` or a
* `
` with `contentEditable` set.
*
* The mock reads and writes the element's value, and records the selection callback in
* {@link AbstractInputSuggest.selectCb}, which {@link AbstractInputSuggest.selectSuggestion} calls; no popover is
* shown.
*
* @typeParam T - The type of a suggestion.
*/
export declare abstract class AbstractInputSuggest extends PopoverSuggest {
/**
* The maximum number of suggestions rendered at once; `0` disables the limit. Defaults to `100`.
*/
limit: number;
/**
* The callback last registered through {@link AbstractInputSuggest.onSelect}, or `undefined` when none was.
* {@link AbstractInputSuggest.selectSuggestion} calls it.
*/
selectCb?: (value: T, $event: KeyboardEvent | MouseEvent) => unknown;
/**
* The text input element this suggest is attached to.
*/
readonly textInputEl: HTMLDivElement | HTMLInputElement;
/**
* Attaches the suggest to a text input.
*
* @param app - The app instance.
* @param textInputEl - An `` text box or a `
` with `contentEditable` set.
*/
constructor(app: App, textInputEl: HTMLDivElement | HTMLInputElement);
/**
* Mock-only: views a value typed as Obsidian's `AbstractInputSuggest` as this mock.
*
* @typeParam T - The type of a suggestion.
* @param value - The value typed as the original `AbstractInputSuggest`.
* @returns The same object, typed as the mock.
*/
static fromOriginalType2__(value: AbstractInputSuggestOriginal): AbstractInputSuggest;
/**
* Mock-only: views this mock as Obsidian's `AbstractInputSuggest` type.
*
* @returns The same object, typed as the original `AbstractInputSuggest`.
*/
asOriginalType2__(): AbstractInputSuggestOriginal;
/**
* Mock-only construction hook, called at the end of the constructor; a no-op meant for
* `vi.spyOn(AbstractInputSuggest.prototype, 'constructor2__')`.
*
* @param _app - The app the suggest was created with.
* @param _textInputEl - The text input element the suggest was attached to.
*/
constructor2__(_app: App, _textInputEl: HTMLDivElement | HTMLInputElement): void;
/**
* Gets the value from the input element.
*
* @returns The ``'s value, or the `
`'s text content.
*/
getValue(): string;
/**
* Registers a callback to handle the user selecting a suggestion. It is stored in
* {@link AbstractInputSuggest.selectCb}, replacing any earlier one.
*
* @param callback - Called with the selected suggestion and the event that selected it.
* @returns This suggest, for chaining.
*/
onSelect(callback: (value: T, $event: KeyboardEvent | MouseEvent) => unknown): this;
/**
* Called when the user picks a suggestion, by click or keyboard. As in Obsidian, it calls the callback registered
* through {@link AbstractInputSuggest.onSelect}, if any.
*
* @param value - The chosen suggestion.
* @param $event - The event that picked it.
*/
selectSuggestion(value: T, $event: KeyboardEvent | MouseEvent): void;
/**
* Sets the value into the input element. No `input` event is dispatched.
*
* @param value - The new value: the ``'s value, or the `
`'s text content.
*/
setValue(value: string): void;
/**
* Computes the suggestions for a query.
*
* @param query - The text typed into the input element.
* @returns The matching suggestions, directly or as a promise.
*/
protected abstract getSuggestions(query: string): Promise | T[];
}