/** * @file * * Mocks of the lookup, visibility, style and event helpers Obsidian adds to `HTMLElement.prototype`. */ import type { DelegatedListener } from '../internal/delegated-event-registry.mjs'; /** * Finds the first descendant matching a selector. * * @param selector - The CSS selector to match. * @returns The first matching element. The mock throws when nothing matches. */ export declare function find(this: HTMLElement, selector: string): HTMLElement; /** * Finds every descendant matching a selector. * * @param selector - The CSS selector to match. * @returns The matching elements, in document order. */ export declare function findAll(this: HTMLElement, selector: string): HTMLElement[]; /** * Finds every element matching a selector, including the element itself. * * @param selector - The CSS selector to match. * @returns The element itself first when it matches, followed by the matching descendants. */ export declare function findAllSelf(this: HTMLElement, selector: string): HTMLElement[]; /** * Hides the element by setting its inline `display` to `none`. */ export declare function hide(this: HTMLElement): void; /** * Checks whether the element is shown: attached to the DOM with no ancestor hidden by `display: none`. The mock * relies on `offsetParent`, which jsdom leaves `null`, so it reports `false` unless a test defines `offsetParent`. * * @returns `true` when the element has an offset parent. */ export declare function isShown(this: HTMLElement): boolean; /** * Removes a delegated event listener registered with {@link on}. As in Obsidian, every registration whose selector, * listener and options are all identical to the ones given is removed. * * @param type - The event type the listener was registered for. * @param selector - The selector the listener was registered with. * @param listener - The listener to remove. * @param options - The options the listener was registered with, compared by identity. */ export declare function off(this: HTMLElement, type: string, selector: string, listener: unknown, options?: AddEventListenerOptions | boolean): void; /** * Adds a delegated event listener, as Obsidian does: it is called only for events whose target, or an ancestor of * it up to this element, matches `selector`, with that matching element as `delegateTarget`. The registration is * kept in `_EVENTS`. * * @param type - The event type to listen for. * @param selector - The CSS selector events are filtered by. * @param listener - The listener to call, with the element as `this`. * @param options - Standard `addEventListener` options. */ export declare function on(this: HTMLElement, type: string, selector: string, listener: DelegatedListener, options?: AddEventListenerOptions | boolean): void; /** * Listens for clicks on the element. The mock registers a plain `click` listener, which cannot be removed. * * @param listener - The listener to call with each click, with the element as `this`. * @param options - Standard `addEventListener` options. */ export declare function onClickEvent(this: HTMLElement, listener: (this: HTMLElement, $event: MouseEvent) => unknown, options?: AddEventListenerOptions | boolean): void; /** * Calls a listener when the element is inserted into the DOM. The mock observes nothing: it calls the listener once, * immediately. * * @param listener - The callback to call when the element is inserted. * @param _once - Whether the listener fires only once. Unused by the mock. * @returns A function that removes the handler; a no-op in the mock. */ export declare function onNodeInserted(this: HTMLElement, listener: () => unknown, _once?: boolean): () => void; /** * Calls a listener when the element is migrated to another window. The mock never calls it, since tests have a * single window. * * @param _listener - The callback to call with the new window. Never called by the mock. * @returns A function that removes the handler; a no-op in the mock. */ export declare function onWindowMigrated(this: HTMLElement, _listener: (win: Window) => unknown): () => void; /** * Sets CSS properties, including custom properties such as `--size`, on the element's inline style. * * @param props - Property names mapped to the values to set. */ export declare function setCssProps(this: HTMLElement, props: Record): void; /** * Assigns camelCase style declarations to the element's inline style. * * @param styles - The style declarations to assign. */ export declare function setCssStyles(this: HTMLElement, styles: Partial): void; /** * Shows the element by clearing its inline `display`. */ export declare function show(this: HTMLElement): void; /** * Shows or hides the element through its inline `display`. * * @param showValue - `true` to show the element, `false` to hide it. */ export declare function toggle(this: HTMLElement, showValue: boolean): void; /** * Shows or hides the element through its inline `visibility`, so it keeps its place in the layout. * * @param visible - `true` for `visible`, `false` for `hidden`. */ export declare function toggleVisibility(this: HTMLElement, visible: boolean): void; /** * Dispatches a bubbling, cancelable event of the given type on the element. * * @param eventType - The event type to dispatch, such as `change`. */ export declare function trigger(this: HTMLElement, eventType: string): void;