/** * @file * * Mock of Obsidian's `TextComponent`, a single-line text input. */ import type { TextComponent as TextComponentOriginal } from 'obsidian'; import { AbstractTextComponent } from './AbstractTextComponent.mjs'; /** * Mock of Obsidian's `TextComponent`: a text component backed by an ``. * * Function listeners added to the input with `addEventListener` are also recorded in * {@link TextComponent.eventListeners__}, so a test can fire them with {@link TextComponent.simulateEvent__}. */ export declare class TextComponent extends AbstractTextComponent { /** * Mock-only: the function listeners added to the input, keyed by event type, in registration order. */ eventListeners__: Record void)[]>; /** * Creates a text input, appends it to the container and wraps its `addEventListener` to record listeners. * * @param containerEl - The element to create the input in. */ constructor(containerEl: HTMLElement); /** * Mock-only factory: creates a text input, spyable via `vi.spyOn(TextComponent, 'create__')`. * * @param containerEl - The element to create the input in. * @returns The new text component. */ static create__(containerEl: HTMLElement): TextComponent; /** * Mock-only: views a value typed as Obsidian's `TextComponent` as this mock. * * @param value - The value typed as the original `TextComponent`. * @returns The same object, typed as the mock. */ static fromOriginalType4__(value: TextComponentOriginal): TextComponent; /** * Mock-only: views this mock as Obsidian's `TextComponent` type. * * @returns The same object, typed as the original `TextComponent`. */ asOriginalType4__(): TextComponentOriginal; /** * Mock-only construction hook, called at the end of the constructor; a no-op meant for * `vi.spyOn(TextComponent.prototype, 'constructor4__')`. * * @param _containerEl - The container the input was created in. */ constructor4__(_containerEl: HTMLElement): void; /** * Registers the callback invoked when the value changes, replacing any previous one. * * @param callback - Called with the new value. * @returns This component, for chaining. */ onChange(callback: (value: string) => unknown): this; /** * Mock-only: fires an event by calling every listener recorded for it, synchronously and in registration order. * No DOM event is dispatched. * * @param $event - The event type, such as `'keydown'`. * @param $arguments - The arguments passed to each listener. */ simulateEvent__($event: string, ...$arguments: unknown[]): void; }