/** * Disclosure component. * * @augments IvComponent */ export class Disclosure extends IvComponent { /** @type {Readonly} */ static defaults: Readonly; /** * Returns the disclosure instance attached to `el`, if any. * * @param {Element} el Host element. * @returns {Disclosure|undefined} The instance or `undefined`. */ static get(el: Element): Disclosure | undefined; /** * Returns the existing instance or creates one. * * @param {Element} el Host element. * @param {Partial} [options] Options passed in JavaScript. * @returns {Disclosure} The instance. */ static getOrCreate(el: Element, options?: Partial): Disclosure; /** * Instantiates every `[data-iv-component="disclosure"]` inside `root`. * * @param {ParentNode} [root] Subtree to scan. * @returns {Disclosure[]} Newly created instances. */ static initAll(root?: ParentNode): Disclosure[]; /** * @param {Element} el A `
` element. * @param {Partial} [options] Options passed in JavaScript. * @throws {IvError} `invalid-element` when `el` is not a `
`. */ constructor(el: Element, options?: Partial); /** @type {boolean} Last committed state; guards the async `toggle`. */ _open: boolean; /** * The host element, typed as a details element. * * @returns {HTMLDetailsElement} The `
` element. */ get details(): HTMLDetailsElement; /** * Resolved options. * * @returns {Readonly} The options. */ get options(): Readonly; /** * Whether the disclosure is currently open. * * @returns {boolean} `true` when open. */ get isOpen(): boolean; /** * The `` of this disclosure, when present. * * @returns {HTMLElement|null} The summary element. */ get _summary(): HTMLElement | null; /** * Handles the native `toggle` event, i.e. a state change made by the user. * * @returns {void} */ _onToggle(): void; /** * Closes the disclosure when a click lands outside of it. * * @param {Event} event Click event. * @returns {void} */ _onDocumentClick(event: Event): void; /** * Closes the sibling `
` of the closest accordion. * * @returns {void} */ _closeSiblings(): void; /** * Opens the disclosure. Emits the cancelable `iv:open` first. * * @returns {void} */ open(): void; /** * Closes the disclosure. Emits the cancelable `iv:close` first. * * @param {DisclosureReason} [reason] Why the disclosure is closing. * @returns {void} */ close(reason?: DisclosureReason): void; /** * Opens the disclosure when closed, closes it when open. * * @returns {void} */ toggle(): void; } export type DisclosureOptions = { /** * Close the sibling `
` of the closest `.iv-accordion` when opening. */ exclusive: boolean; /** * Close when a click lands outside the element. */ closeOnOutside: boolean; }; export type DisclosureReason = "api" | "trigger" | "external"; import { IvComponent } from "../core/component.js";