/** * @file * * Mock of Obsidian's `ConfirmationModal`, a modal with a row of action buttons. */ import type { ConfirmationButton as ConfirmationButtonOriginal, ConfirmationModal as ConfirmationModalOriginal } from 'obsidian'; import type { App } from './App.cjs'; import { Modal } from './Modal.cjs'; /** * Mock of Obsidian's `ConfirmationModal`. * * Buttons are created in {@link ConfirmationModal.buttonContainerEl} and checkboxes in the content element, so a * test can find and drive them; the cancel button is not rendered. */ export declare class ConfirmationModal extends Modal { /** * The element holding the modal's action buttons. */ buttonContainerEl: HTMLElement; /** * Creates the modal and its button container. * * @param app - The app the modal belongs to. */ constructor(app: App); /** * Mock-only factory: creates a confirmation modal, spyable via `vi.spyOn(ConfirmationModal, 'create2__')`. The * numbered subclass variant of `create__`. * * @param app - The app the modal belongs to. * @returns The new confirmation modal. */ static create2__(app: App): ConfirmationModal; /** * Mock-only: views a value typed as Obsidian's `ConfirmationModal` as this mock. The numbered subclass variant of * `fromOriginalType__`. * * @param value - The value typed as the original `ConfirmationModal`. * @returns The same object, typed as the mock. */ static fromOriginalType2__(value: ConfirmationModalOriginal): ConfirmationModal; /** * Adds an action button to the button container. * * @param callback - Called immediately with the new button, to configure it. * @returns This modal, for chaining. */ addButton(callback: (button: ConfirmationButtonOriginal) => unknown): this; /** * Adds a button that closes the modal. A no-op in the mock: no button is created. * * @param _text - The button label. * @returns This modal, for chaining. */ addCancelButton(_text?: string): this; /** * Adds a labeled checkbox to the modal's content. * * @param label - The checkbox label; the mock sets it as the input's `aria-label`. * @param callback - Called with the checked state whenever the checkbox changes. * @returns This modal, for chaining. */ addCheckbox(label: string, callback: (value: boolean) => unknown): this; /** * Adds a CSS class to the modal's container element. * * @param cls - The class to add. * @returns This modal, for chaining. */ addClass(cls: string): this; /** * Mock-only: views this mock as Obsidian's `ConfirmationModal` type. The numbered subclass variant of * `asOriginalType__`. * * @returns The same object, typed as the original `ConfirmationModal`. */ asOriginalType2__(): ConfirmationModalOriginal; /** * Mock-only construction hook, called at the end of the constructor; a no-op meant for * `vi.spyOn(ConfirmationModal.prototype, 'constructor2__')`. * * @param _app - The app the modal was created with. */ constructor2__(_app: App): void; }