/*! * Bootstrap Native Collapse v5.1.10 (https://thednp.github.io/bootstrap.native/) * Copyright 2026 © thednp * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ "use strict"; import { Data, ObjectKeys, Timer, addClass, ariaExpanded, closest, createCustomEvent, dispatchEvent, emulateTransitionEnd, getAttribute, getDocument, getInstance, hasClass, isElement, isHTMLElement, isString, mouseclickEvent, noop, normalizeOptions, querySelector, querySelectorAll, reflow, removeClass, setAttribute, setElementStyle } from "@thednp/shorty"; import { addListener, removeListener } from "@thednp/event-listener"; //#region src/strings/dataBsToggle.ts /** * Global namespace for most components `toggle` option. */ const dataBsToggle = "data-bs-toggle"; //#endregion //#region src/strings/collapsingClass.ts /** * Global namespace for most components `collapsing` class. * As used by `Collapse` / `Tab`. */ const collapsingClass = "collapsing"; //#endregion //#region src/strings/showClass.ts /** * Global namespace for most components `show` class. */ const showClass = "show"; //#endregion //#region src/strings/collapseString.ts /** @type {string} */ const collapseString = "collapse"; //#endregion //#region src/strings/collapseComponent.ts /** @type {string} */ const collapseComponent = "Collapse"; //#endregion //#region src/strings/dataBsTarget.ts /** * Global namespace for most components `target` option. */ const dataBsTarget = "data-bs-target"; //#endregion //#region src/strings/dataBsParent.ts /** * Global namespace for most components `parent` option. */ const dataBsParent = "data-bs-parent"; //#endregion //#region src/strings/dataBsContainer.ts /** * Global namespace for most components `container` option. */ const dataBsContainer = "data-bs-container"; //#endregion //#region src/util/getTargetElement.ts /** * Returns the `Element` that THIS one targets * via `data-bs-target`, `href`, `data-bs-parent` or `data-bs-container`. * * @param element the target element * @returns the query result */ const getTargetElement = (element) => { const targetAttr = [ dataBsTarget, dataBsParent, dataBsContainer, "href" ]; const doc = getDocument(element); return targetAttr.map((att) => { const attValue = getAttribute(element, att); if (attValue) return att === "data-bs-parent" ? closest(element, attValue) : querySelector(attValue, doc); return null; }).filter((x) => x)[0]; }; //#endregion //#region src/version.ts const Version = "5.1.10"; //#endregion //#region src/components/base-component.ts /** Returns a new `BaseComponent` instance. */ var BaseComponent = class { /** * @param target `Element` or selector string * @param config component instance options */ constructor(target, config) { let element; try { if (isElement(target)) element = target; else if (isString(target)) { element = querySelector(target); if (!element) throw Error(`"${target}" is not a valid selector.`); } else throw Error(`your target is not an instance of HTMLElement.`); } catch (e) { throw Error(`${this.name} Error: ${e.message}`); } const prevInstance = Data.get(element, this.name); if (prevInstance) prevInstance._toggleEventListeners(); this.element = element; this.options = this.defaults && ObjectKeys(this.defaults).length ? normalizeOptions(element, this.defaults, config || {}, "bs") : {}; Data.set(element, this.name, this); } get version() { return Version; } get name() { return "BaseComponent"; } get defaults() { return {}; } /** just to have something to extend from */ _toggleEventListeners = () => {}; /** Removes component from target element. */ dispose() { Data.remove(this.element, this.name); ObjectKeys(this).forEach((prop) => { delete this[prop]; }); } }; //#endregion //#region src/util/isDisabled.ts /** * Check if interactive element is disabled. * @param target either a `