/** * @file * * Mock of Obsidian's `ExtraButtonComponent`, the small icon button at the end of a setting row. */ import type { ExtraButtonComponent as ExtraButtonComponentOriginal, TooltipOptions as TooltipOptionsOriginal } from 'obsidian'; import { BaseComponent } from './BaseComponent.mjs'; /** * Mock of Obsidian's `ExtraButtonComponent`. * * As in Obsidian, a click on {@link ExtraButtonComponent.extraSettingsEl}, or Enter or Space pressed on it, runs the * handler unless the button is disabled. {@link ExtraButtonComponent.simulateClick__} does the same without an event. */ export declare class ExtraButtonComponent extends BaseComponent { /** * The click handler registered with {@link ExtraButtonComponent.onClick}, if any. */ changeCallback?: () => unknown; /** * The element the icon button renders into. */ extraSettingsEl: HTMLElement; /** * Creates the button inside a container, focusable, with its click and keyboard listeners. * * @param containerEl - The element the button element is appended to. */ constructor(containerEl: HTMLElement); /** * Mock-only factory: creates an extra button, spyable via `vi.spyOn(ExtraButtonComponent, 'create__')`. * * @param containerEl - The element the button element is appended to. * @returns The new extra button. */ static create__(containerEl: HTMLElement): ExtraButtonComponent; /** * Mock-only: views a value typed as Obsidian's `ExtraButtonComponent` as this mock. The numbered subclass variant * of `fromOriginalType__`. * * @param value - The value typed as the original `ExtraButtonComponent`. * @returns The same object, typed as the mock. */ static fromOriginalType2__(value: ExtraButtonComponentOriginal): ExtraButtonComponent; /** * Mock-only: views this mock as Obsidian's `ExtraButtonComponent` type. The numbered subclass variant of * `asOriginalType__`. * * @returns The same object, typed as the original `ExtraButtonComponent`. */ asOriginalType2__(): ExtraButtonComponentOriginal; /** * Mock-only construction hook, called at the end of the constructor; a no-op meant for * `vi.spyOn(ExtraButtonComponent.prototype, 'constructor2__')`. * * @param _containerEl - The container the button was created in. */ constructor2__(_containerEl: HTMLElement): void; /** * Sets the handler run when the button is clicked, replacing any previous one. * * @param callback - The click handler. * @returns This button, for chaining. */ onClick(callback: () => unknown): this; /** * Enables or disables the button. A disabled button gets the `is-disabled` class, leaves the tab order, and ignores * clicks. * * @param disabled - Whether the button is disabled. * @returns This button, for chaining. */ setDisabled(disabled: boolean): this; /** * Sets the button's icon, by id from Obsidian's built-in or added icons. Obsidian renders the icon; the mock only * records its id in the element's `data-icon` attribute. * * @param icon - The icon id. * @returns This button, for chaining. */ setIcon(icon: string): this; /** * Sets the button's tooltip on {@link ExtraButtonComponent.extraSettingsEl} through `setTooltip`, as Obsidian does. * * @param tooltip - The tooltip text. * @param options - Tooltip placement and behavior options. * @returns This button, for chaining. */ setTooltip(tooltip: string, options?: TooltipOptionsOriginal): this; /** * Mock-only: simulates a click by calling the handler set with {@link ExtraButtonComponent.onClick}, if any, unless * the button is disabled. */ simulateClick__(): void; }