/** * @file * * Mock of Obsidian's `PopoverSuggest`, the base class for type-ahead suggestion popovers. */ import type { PopoverSuggest as PopoverSuggestOriginal } from 'obsidian'; import type { App } from './App.mjs'; import { Scope } from './Scope.mjs'; /** * Mock of Obsidian's `PopoverSuggest`, the base class for adding a type-ahead popover. * * No popover is rendered: opening and closing only toggle {@link PopoverSuggest.isOpen}. * * @typeParam T - The type of a suggestion item. */ export declare abstract class PopoverSuggest { /** * The app instance. */ app: App; /** * Whether the popover is currently open. */ isOpen: boolean; /** * The keymap scope active while the popover is open. */ scope: Scope; /** * Creates the suggestion popover. * * @param app - The app instance. * @param scope - The keymap scope to use; a new scope is created when omitted. */ constructor(app: App, scope?: Scope); /** * Mock-only: views a value typed as Obsidian's `PopoverSuggest` as this mock. * * @typeParam T - The type of a suggestion item. * @param value - The value typed as the original `PopoverSuggest`. * @returns The same object, typed as the mock. */ static fromOriginalType__(value: PopoverSuggestOriginal): PopoverSuggest; /** * Mock-only: views this mock as Obsidian's `PopoverSuggest` type. * * @returns The same object, typed as the original `PopoverSuggest`. */ asOriginalType__(): PopoverSuggestOriginal; /** * Closes the popover. The mock only clears {@link PopoverSuggest.isOpen}. */ close(): void; /** * Mock-only construction hook, called at the end of the constructor; a no-op meant for * `vi.spyOn(PopoverSuggest.prototype, 'constructor__')`. * * @param _app - The app the popover was created with. * @param _scope - The scope the popover was created with, if any. */ constructor__(_app: App, _scope?: Scope): void; /** * Handles the history-back action (the back gesture or the mobile back button) while the popover is the topmost * history handler. As in Obsidian, it closes the popover. */ onHistoryBack(): void; /** * Opens the popover. The mock only sets {@link PopoverSuggest.isOpen}. */ open(): void; /** * Renders one suggestion into its list item element. * * @param value - The suggestion to render. * @param el - The element to render it into. */ abstract renderSuggestion(value: T, el: HTMLElement): void; /** * Called when the user picks a suggestion, by click or keyboard. * * @param value - The chosen suggestion. * @param $event - The event that picked it. */ abstract selectSuggestion(value: T, $event: KeyboardEvent | MouseEvent): void; }