/** * @file * * Mock of Obsidian's `SettingGroup`, a titled group of setting rows. */ import type { ExtraButtonComponent as ExtraButtonComponentOriginal, SearchComponent as SearchComponentOriginal, SettingGroup as SettingGroupOriginal, Setting as SettingOriginal } from 'obsidian'; import type { BaseComponent } from './BaseComponent.mjs'; import { Setting } from './Setting.mjs'; /** * Mock of Obsidian's `SettingGroup`, which groups setting rows under an optional heading. * * The DOM mirrors Obsidian's: {@link SettingGroup.groupEl} holds a search container (`.setting-group-search`), * {@link SettingGroup.listEl}, and a heading row (a name and {@link SettingGroup.controlEl}) that is attached at the * top of the group only while it has a heading or a control. Every added row or control is handed to its callback synchronously. */ export declare class SettingGroup { /** * The components added to the group itself (its search input and extra buttons), in the order they were added. */ components: BaseComponent[]; /** * The element in the heading row that holds the group's extra buttons. */ controlEl: HTMLDivElement; /** * The group's outer element, holding the heading, the search container and the list. */ groupEl: HTMLDivElement; /** * The element the group's settings are added to. */ listEl: HTMLDivElement; /** * The setting rows added with {@link SettingGroup.addSetting}, in order. */ settings: Setting[]; private readonly headerEl; private readonly headerInnerEl; private readonly searchContainerEl; /** * Creates the group inside `containerEl`, without a heading. * * @param containerEl - The element to create the group in. */ constructor(containerEl: HTMLElement); /** * Mock-only factory: creates a setting group, spyable via `vi.spyOn(SettingGroup, 'create__')`. * * @param containerEl - The element to create the group in. * @returns The new setting group. */ static create__(containerEl: HTMLElement): SettingGroup; /** * Mock-only: views a value typed as Obsidian's `SettingGroup` as this mock. * * @param value - The value typed as the original `SettingGroup`. * @returns The same object, typed as the mock. */ static fromOriginalType__(value: SettingGroupOriginal): SettingGroup; /** * Adds CSS classes to the group's outer element. * * @param classes - The class names to add. * @returns This group, for chaining. */ addClass(...classes: string[]): this; /** * Adds an extra (icon) button to the group's heading row, attaching the heading row if it is not already shown. * * @param callback - Called with the new button, to configure it. * @returns This group, for chaining. */ addExtraButton(callback: (component: ExtraButtonComponentOriginal) => unknown): this; /** * Adds a search input to the group's search container, at the start of the group, for filtering its rows or for * quick entry. * * @param callback - Called with the new search component, to configure it. * @returns This group, for chaining. */ addSearch(callback: (component: SearchComponentOriginal) => unknown): this; /** * Adds a setting row to the group's list. * * @param callback - Called with the new setting, to configure it. * @returns This group, for chaining. */ addSetting(callback: (setting: SettingOriginal) => void): this; /** * Mock-only: views this mock as Obsidian's `SettingGroup` type. * * @returns The same object, typed as the original `SettingGroup`. */ asOriginalType__(): SettingGroupOriginal; /** * Mock-only construction hook, called at the end of the constructor; a no-op meant for * `vi.spyOn(SettingGroup.prototype, 'constructor__')`. * * @param _containerEl - The element the group was created in. */ constructor__(_containerEl: HTMLElement): void; /** * Sets the group's heading. The heading row is attached at the top of {@link SettingGroup.groupEl} while the * heading is non-empty or {@link SettingGroup.controlEl} holds a control, and detached otherwise. * * Obsidian tests whether the heading row is shown with `isShown()`, which is always `false` without layout, so the * mock tests whether the row is attached instead. * * @param text - The heading, as text or as a fragment. * @returns This group, for chaining. */ setHeading(text: DocumentFragment | string): this; private showHeader; }