/** * @file * * Mock of Obsidian's `FuzzySuggestModal`, the suggestion modal that fuzzy-matches items by their text. */ import type { FuzzyMatch as FuzzyMatchOriginal, FuzzySuggestModal as FuzzySuggestModalOriginal } from 'obsidian'; import type { App } from './App.cjs'; import { SuggestModal } from './SuggestModal.cjs'; /** * Mock of Obsidian's `FuzzySuggestModal`. * * Suggestions are `FuzzyMatch` wrappers around the items; choosing one unwraps it and forwards the item to * {@link FuzzySuggestModal.onChooseItem}. * * @typeParam T - The type of the items being suggested. */ export declare abstract class FuzzySuggestModal extends SuggestModal> { /** * Creates a fuzzy suggestion modal. * * @param app - The app the modal belongs to. */ constructor(app: App); /** * Mock-only: views a value typed as Obsidian's `FuzzySuggestModal` as this mock. * * @typeParam T - The type of the items being suggested. * @param value - The value typed as the original `FuzzySuggestModal`. * @returns The same object, typed as the mock. */ static fromOriginalType3__(value: FuzzySuggestModalOriginal): FuzzySuggestModal; /** * Mock-only: views this mock as Obsidian's `FuzzySuggestModal` type. * * @returns The same object, typed as the original `FuzzySuggestModal`. */ asOriginalType3__(): FuzzySuggestModalOriginal; /** * Mock-only construction hook, called at the end of the constructor; a no-op meant for * `vi.spyOn(FuzzySuggestModal.prototype, 'constructor3__')`. * * @param _app - The app the modal was created with. */ constructor3__(_app: App): void; /** * Gets every item the modal can suggest. Abstract in Obsidian; subclasses override it. * * @returns An empty list in the mock. */ getItems(): T[]; /** * Gets the text an item is fuzzy-matched and displayed by. Abstract in Obsidian; subclasses override it. * * @param _item - The item to describe. * @returns An empty string in the mock. */ getItemText(_item: T): string; /** * Called when the user chooses an item. Abstract in Obsidian; a no-op in the mock until a subclass overrides it. * * @param _item - The chosen item. * @param _event - The keyboard or mouse event that made the choice. */ onChooseItem(_item: T, _event: KeyboardEvent | MouseEvent): void; /** * Called when the user chooses a suggestion; unwraps the fuzzy match and forwards its item to * {@link FuzzySuggestModal.onChooseItem}. * * @param item - The chosen fuzzy match. * @param $event - The keyboard or mouse event that made the choice. */ onChooseSuggestion(item: FuzzyMatchOriginal, $event: KeyboardEvent | MouseEvent): void; }