assets/javascripts/bootstrap.js in bootstrap-5.0.2 vs assets/javascripts/bootstrap.js in bootstrap-5.1.0

- old
+ new

@@ -1,7 +1,7 @@ /*! - * Bootstrap v5.0.2 (https://getbootstrap.com/) + * Bootstrap v5.1.0 (https://getbootstrap.com/) * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@popperjs/core')) : @@ -31,86 +31,14 @@ var Popper__namespace = /*#__PURE__*/_interopNamespace(Popper); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): dom/selector-engine.js + * Bootstrap (v5.1.0): util/index.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ - - /** - * ------------------------------------------------------------------------ - * Constants - * ------------------------------------------------------------------------ - */ - const NODE_TEXT = 3; - const SelectorEngine = { - find(selector, element = document.documentElement) { - return [].concat(...Element.prototype.querySelectorAll.call(element, selector)); - }, - - findOne(selector, element = document.documentElement) { - return Element.prototype.querySelector.call(element, selector); - }, - - children(element, selector) { - return [].concat(...element.children).filter(child => child.matches(selector)); - }, - - parents(element, selector) { - const parents = []; - let ancestor = element.parentNode; - - while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) { - if (ancestor.matches(selector)) { - parents.push(ancestor); - } - - ancestor = ancestor.parentNode; - } - - return parents; - }, - - prev(element, selector) { - let previous = element.previousElementSibling; - - while (previous) { - if (previous.matches(selector)) { - return [previous]; - } - - previous = previous.previousElementSibling; - } - - return []; - }, - - next(element, selector) { - let next = element.nextElementSibling; - - while (next) { - if (next.matches(selector)) { - return [next]; - } - - next = next.nextElementSibling; - } - - return []; - } - - }; - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): util/index.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - const MAX_UID = 1000000; const MILLISECONDS_MULTIPLIER = 1000; const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp) const toType = obj => { @@ -218,11 +146,11 @@ // it's a jQuery object or a node element return obj.jquery ? obj[0] : obj; } if (typeof obj === 'string' && obj.length > 0) { - return SelectorEngine.findOne(obj); + return document.querySelector(obj); } return null; }; @@ -284,13 +212,25 @@ return findShadowRoot(element.parentNode); }; const noop = () => {}; + /** + * Trick to restart an element's animation + * + * @param {HTMLElement} element + * @return void + * + * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation + */ - const reflow = element => element.offsetHeight; + const reflow = element => { + // eslint-disable-next-line no-unused-expressions + element.offsetHeight; + }; + const getjQuery = () => { const { jQuery } = window; @@ -402,11 +342,11 @@ return list[Math.max(0, Math.min(index, listLength - 1))]; }; /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): dom/event-handler.js + * Bootstrap (v5.1.0): dom/event-handler.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -691,11 +631,11 @@ }; /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): dom/data.js + * Bootstrap (v5.1.0): dom/data.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** @@ -745,21 +685,21 @@ }; /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): base-component.js + * Bootstrap (v5.1.0): base-component.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ * Constants * ------------------------------------------------------------------------ */ - const VERSION = '5.0.2'; + const VERSION = '5.1.0'; class BaseComponent { constructor(element) { element = getElement(element); @@ -784,11 +724,11 @@ } /** Static */ static getInstance(element) { - return Data.get(element, this.DATA_KEY); + return Data.get(getElement(element), this.DATA_KEY); } static getOrCreateInstance(element, config = {}) { return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null); } @@ -811,107 +751,114 @@ } /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): alert.js + * Bootstrap (v5.1.0): util/component-functions.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ + + const enableDismissTrigger = (component, method = 'hide') => { + const clickEvent = `click.dismiss${component.EVENT_KEY}`; + const name = component.NAME; + EventHandler.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) { + if (['A', 'AREA'].includes(this.tagName)) { + event.preventDefault(); + } + + if (isDisabled(this)) { + return; + } + + const target = getElementFromSelector(this) || this.closest(`.${name}`); + const instance = component.getOrCreateInstance(target); // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method + + instance[method](); + }); + }; + /** + * -------------------------------------------------------------------------- + * Bootstrap (v5.1.0): alert.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + * -------------------------------------------------------------------------- + */ + /** * ------------------------------------------------------------------------ * Constants * ------------------------------------------------------------------------ */ - const NAME$c = 'alert'; - const DATA_KEY$b = 'bs.alert'; - const EVENT_KEY$b = `.${DATA_KEY$b}`; - const DATA_API_KEY$8 = '.data-api'; - const SELECTOR_DISMISS = '[data-bs-dismiss="alert"]'; - const EVENT_CLOSE = `close${EVENT_KEY$b}`; - const EVENT_CLOSED = `closed${EVENT_KEY$b}`; - const EVENT_CLICK_DATA_API$7 = `click${EVENT_KEY$b}${DATA_API_KEY$8}`; - const CLASS_NAME_ALERT = 'alert'; - const CLASS_NAME_FADE$6 = 'fade'; - const CLASS_NAME_SHOW$9 = 'show'; + const NAME$d = 'alert'; + const DATA_KEY$c = 'bs.alert'; + const EVENT_KEY$c = `.${DATA_KEY$c}`; + const EVENT_CLOSE = `close${EVENT_KEY$c}`; + const EVENT_CLOSED = `closed${EVENT_KEY$c}`; + const CLASS_NAME_FADE$5 = 'fade'; + const CLASS_NAME_SHOW$8 = 'show'; /** * ------------------------------------------------------------------------ * Class Definition * ------------------------------------------------------------------------ */ class Alert extends BaseComponent { // Getters static get NAME() { - return NAME$c; + return NAME$d; } // Public - close(element) { - const rootElement = element ? this._getRootElement(element) : this._element; + close() { + const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE); - const customEvent = this._triggerCloseEvent(rootElement); - - if (customEvent === null || customEvent.defaultPrevented) { + if (closeEvent.defaultPrevented) { return; } - this._removeElement(rootElement); - } // Private + this._element.classList.remove(CLASS_NAME_SHOW$8); + const isAnimated = this._element.classList.contains(CLASS_NAME_FADE$5); - _getRootElement(element) { - return getElementFromSelector(element) || element.closest(`.${CLASS_NAME_ALERT}`); - } + this._queueCallback(() => this._destroyElement(), this._element, isAnimated); + } // Private - _triggerCloseEvent(element) { - return EventHandler.trigger(element, EVENT_CLOSE); - } - _removeElement(element) { - element.classList.remove(CLASS_NAME_SHOW$9); - const isAnimated = element.classList.contains(CLASS_NAME_FADE$6); + _destroyElement() { + this._element.remove(); - this._queueCallback(() => this._destroyElement(element), element, isAnimated); - } - - _destroyElement(element) { - element.remove(); - EventHandler.trigger(element, EVENT_CLOSED); + EventHandler.trigger(this._element, EVENT_CLOSED); + this.dispose(); } // Static static jQueryInterface(config) { return this.each(function () { const data = Alert.getOrCreateInstance(this); - if (config === 'close') { - data[config](this); + if (typeof config !== 'string') { + return; } - }); - } - static handleDismiss(alertInstance) { - return function (event) { - if (event) { - event.preventDefault(); + if (data[config] === undefined || config.startsWith('_') || config === 'constructor') { + throw new TypeError(`No method named "${config}"`); } - alertInstance.close(this); - }; + data[config](this); + }); } } /** * ------------------------------------------------------------------------ * Data Api implementation * ------------------------------------------------------------------------ */ - EventHandler.on(document, EVENT_CLICK_DATA_API$7, SELECTOR_DISMISS, Alert.handleDismiss(new Alert())); + enableDismissTrigger(Alert, 'close'); /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ * add .Alert to jQuery only if jQuery is present @@ -919,37 +866,37 @@ defineJQueryPlugin(Alert); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): button.js + * Bootstrap (v5.1.0): button.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ * Constants * ------------------------------------------------------------------------ */ - const NAME$b = 'button'; - const DATA_KEY$a = 'bs.button'; - const EVENT_KEY$a = `.${DATA_KEY$a}`; + const NAME$c = 'button'; + const DATA_KEY$b = 'bs.button'; + const EVENT_KEY$b = `.${DATA_KEY$b}`; const DATA_API_KEY$7 = '.data-api'; const CLASS_NAME_ACTIVE$3 = 'active'; const SELECTOR_DATA_TOGGLE$5 = '[data-bs-toggle="button"]'; - const EVENT_CLICK_DATA_API$6 = `click${EVENT_KEY$a}${DATA_API_KEY$7}`; + const EVENT_CLICK_DATA_API$6 = `click${EVENT_KEY$b}${DATA_API_KEY$7}`; /** * ------------------------------------------------------------------------ * Class Definition * ------------------------------------------------------------------------ */ class Button extends BaseComponent { // Getters static get NAME() { - return NAME$b; + return NAME$c; } // Public toggle() { // Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method @@ -990,11 +937,11 @@ defineJQueryPlugin(Button); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): dom/manipulator.js + * Bootstrap (v5.1.0): dom/manipulator.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ function normalizeData(val) { if (val === 'true') { @@ -1048,12 +995,12 @@ }, offset(element) { const rect = element.getBoundingClientRect(); return { - top: rect.top + document.body.scrollTop, - left: rect.left + document.body.scrollLeft + top: rect.top + window.pageYOffset, + left: rect.left + window.pageXOffset }; }, position(element) { return { @@ -1064,38 +1011,108 @@ }; /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): carousel.js + * Bootstrap (v5.1.0): dom/selector-engine.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ + const NODE_TEXT = 3; + const SelectorEngine = { + find(selector, element = document.documentElement) { + return [].concat(...Element.prototype.querySelectorAll.call(element, selector)); + }, + + findOne(selector, element = document.documentElement) { + return Element.prototype.querySelector.call(element, selector); + }, + + children(element, selector) { + return [].concat(...element.children).filter(child => child.matches(selector)); + }, + + parents(element, selector) { + const parents = []; + let ancestor = element.parentNode; + + while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) { + if (ancestor.matches(selector)) { + parents.push(ancestor); + } + + ancestor = ancestor.parentNode; + } + + return parents; + }, + + prev(element, selector) { + let previous = element.previousElementSibling; + + while (previous) { + if (previous.matches(selector)) { + return [previous]; + } + + previous = previous.previousElementSibling; + } + + return []; + }, + + next(element, selector) { + let next = element.nextElementSibling; + + while (next) { + if (next.matches(selector)) { + return [next]; + } + + next = next.nextElementSibling; + } + + return []; + }, + + focusableChildren(element) { + const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(', '); + return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el)); + } + + }; + /** + * -------------------------------------------------------------------------- + * Bootstrap (v5.1.0): carousel.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + * -------------------------------------------------------------------------- + */ + /** * ------------------------------------------------------------------------ * Constants * ------------------------------------------------------------------------ */ - const NAME$a = 'carousel'; - const DATA_KEY$9 = 'bs.carousel'; - const EVENT_KEY$9 = `.${DATA_KEY$9}`; + const NAME$b = 'carousel'; + const DATA_KEY$a = 'bs.carousel'; + const EVENT_KEY$a = `.${DATA_KEY$a}`; const DATA_API_KEY$6 = '.data-api'; const ARROW_LEFT_KEY = 'ArrowLeft'; const ARROW_RIGHT_KEY = 'ArrowRight'; const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch const SWIPE_THRESHOLD = 40; - const Default$9 = { + const Default$a = { interval: 5000, keyboard: true, slide: false, pause: 'hover', wrap: true, touch: true }; - const DefaultType$9 = { + const DefaultType$a = { interval: '(number|boolean)', keyboard: 'boolean', slide: '(boolean|string)', pause: '(string|boolean)', wrap: 'boolean', @@ -1107,23 +1124,23 @@ const DIRECTION_RIGHT = 'right'; const KEY_TO_DIRECTION = { [ARROW_LEFT_KEY]: DIRECTION_RIGHT, [ARROW_RIGHT_KEY]: DIRECTION_LEFT }; - const EVENT_SLIDE = `slide${EVENT_KEY$9}`; - const EVENT_SLID = `slid${EVENT_KEY$9}`; - const EVENT_KEYDOWN = `keydown${EVENT_KEY$9}`; - const EVENT_MOUSEENTER = `mouseenter${EVENT_KEY$9}`; - const EVENT_MOUSELEAVE = `mouseleave${EVENT_KEY$9}`; - const EVENT_TOUCHSTART = `touchstart${EVENT_KEY$9}`; - const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY$9}`; - const EVENT_TOUCHEND = `touchend${EVENT_KEY$9}`; - const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY$9}`; - const EVENT_POINTERUP = `pointerup${EVENT_KEY$9}`; - const EVENT_DRAG_START = `dragstart${EVENT_KEY$9}`; - const EVENT_LOAD_DATA_API$2 = `load${EVENT_KEY$9}${DATA_API_KEY$6}`; - const EVENT_CLICK_DATA_API$5 = `click${EVENT_KEY$9}${DATA_API_KEY$6}`; + const EVENT_SLIDE = `slide${EVENT_KEY$a}`; + const EVENT_SLID = `slid${EVENT_KEY$a}`; + const EVENT_KEYDOWN = `keydown${EVENT_KEY$a}`; + const EVENT_MOUSEENTER = `mouseenter${EVENT_KEY$a}`; + const EVENT_MOUSELEAVE = `mouseleave${EVENT_KEY$a}`; + const EVENT_TOUCHSTART = `touchstart${EVENT_KEY$a}`; + const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY$a}`; + const EVENT_TOUCHEND = `touchend${EVENT_KEY$a}`; + const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY$a}`; + const EVENT_POINTERUP = `pointerup${EVENT_KEY$a}`; + const EVENT_DRAG_START = `dragstart${EVENT_KEY$a}`; + const EVENT_LOAD_DATA_API$2 = `load${EVENT_KEY$a}${DATA_API_KEY$6}`; + const EVENT_CLICK_DATA_API$5 = `click${EVENT_KEY$a}${DATA_API_KEY$6}`; const CLASS_NAME_CAROUSEL = 'carousel'; const CLASS_NAME_ACTIVE$2 = 'active'; const CLASS_NAME_SLIDE = 'slide'; const CLASS_NAME_END = 'carousel-item-end'; const CLASS_NAME_START = 'carousel-item-start'; @@ -1166,15 +1183,15 @@ this._addEventListeners(); } // Getters static get Default() { - return Default$9; + return Default$a; } static get NAME() { - return NAME$a; + return NAME$b; } // Public next() { this._slide(ORDER_NEXT); @@ -1248,15 +1265,15 @@ this._slide(order, this._items[index]); } // Private _getConfig(config) { - config = { ...Default$9, + config = { ...Default$a, ...Manipulator.getDataAttributes(this._element), ...(typeof config === 'object' ? config : {}) }; - typeCheckConfig(NAME$a, config, DefaultType$9); + typeCheckConfig(NAME$b, config, DefaultType$a); return config; } _handleSwipe() { const absDeltax = Math.abs(this.touchDeltaX); @@ -1609,41 +1626,42 @@ defineJQueryPlugin(Carousel); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): collapse.js + * Bootstrap (v5.1.0): collapse.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ * Constants * ------------------------------------------------------------------------ */ - const NAME$9 = 'collapse'; - const DATA_KEY$8 = 'bs.collapse'; - const EVENT_KEY$8 = `.${DATA_KEY$8}`; + const NAME$a = 'collapse'; + const DATA_KEY$9 = 'bs.collapse'; + const EVENT_KEY$9 = `.${DATA_KEY$9}`; const DATA_API_KEY$5 = '.data-api'; - const Default$8 = { + const Default$9 = { toggle: true, - parent: '' + parent: null }; - const DefaultType$8 = { + const DefaultType$9 = { toggle: 'boolean', - parent: '(string|element)' + parent: '(null|element)' }; - const EVENT_SHOW$5 = `show${EVENT_KEY$8}`; - const EVENT_SHOWN$5 = `shown${EVENT_KEY$8}`; - const EVENT_HIDE$5 = `hide${EVENT_KEY$8}`; - const EVENT_HIDDEN$5 = `hidden${EVENT_KEY$8}`; - const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$8}${DATA_API_KEY$5}`; - const CLASS_NAME_SHOW$8 = 'show'; + const EVENT_SHOW$5 = `show${EVENT_KEY$9}`; + const EVENT_SHOWN$5 = `shown${EVENT_KEY$9}`; + const EVENT_HIDE$5 = `hide${EVENT_KEY$9}`; + const EVENT_HIDDEN$5 = `hidden${EVENT_KEY$9}`; + const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$9}${DATA_API_KEY$5}`; + const CLASS_NAME_SHOW$7 = 'show'; const CLASS_NAME_COLLAPSE = 'collapse'; const CLASS_NAME_COLLAPSING = 'collapsing'; const CLASS_NAME_COLLAPSED = 'collapsed'; + const CLASS_NAME_HORIZONTAL = 'collapse-horizontal'; const WIDTH = 'width'; const HEIGHT = 'height'; const SELECTOR_ACTIVES = '.show, .collapsing'; const SELECTOR_DATA_TOGGLE$4 = '[data-bs-toggle="collapse"]'; /** @@ -1655,11 +1673,11 @@ class Collapse extends BaseComponent { constructor(element, config) { super(element); this._isTransitioning = false; this._config = this._getConfig(config); - this._triggerArray = SelectorEngine.find(`${SELECTOR_DATA_TOGGLE$4}[href="#${this._element.id}"],` + `${SELECTOR_DATA_TOGGLE$4}[data-bs-target="#${this._element.id}"]`); + this._triggerArray = []; const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$4); for (let i = 0, len = toggleList.length; i < len; i++) { const elem = toggleList[i]; const selector = getSelectorFromElement(elem); @@ -1670,64 +1688,55 @@ this._triggerArray.push(elem); } } - this._parent = this._config.parent ? this._getParent() : null; + this._initializeChildren(); if (!this._config.parent) { - this._addAriaAndCollapsedClass(this._element, this._triggerArray); + this._addAriaAndCollapsedClass(this._triggerArray, this._isShown()); } if (this._config.toggle) { this.toggle(); } } // Getters static get Default() { - return Default$8; + return Default$9; } static get NAME() { - return NAME$9; + return NAME$a; } // Public toggle() { - if (this._element.classList.contains(CLASS_NAME_SHOW$8)) { + if (this._isShown()) { this.hide(); } else { this.show(); } } show() { - if (this._isTransitioning || this._element.classList.contains(CLASS_NAME_SHOW$8)) { + if (this._isTransitioning || this._isShown()) { return; } - let actives; + let actives = []; let activesData; - if (this._parent) { - actives = SelectorEngine.find(SELECTOR_ACTIVES, this._parent).filter(elem => { - if (typeof this._config.parent === 'string') { - return elem.getAttribute('data-bs-parent') === this._config.parent; - } - - return elem.classList.contains(CLASS_NAME_COLLAPSE); - }); - - if (actives.length === 0) { - actives = null; - } + if (this._config.parent) { + const children = SelectorEngine.find(`.${CLASS_NAME_COLLAPSE} .${CLASS_NAME_COLLAPSE}`, this._config.parent); + actives = SelectorEngine.find(SELECTOR_ACTIVES, this._config.parent).filter(elem => !children.includes(elem)); // remove children if greater depth } const container = SelectorEngine.findOne(this._selector); - if (actives) { + if (actives.length) { const tempActiveData = actives.find(elem => container !== elem); activesData = tempActiveData ? Collapse.getInstance(tempActiveData) : null; if (activesData && activesData._isTransitioning) { return; @@ -1738,46 +1747,42 @@ if (startEvent.defaultPrevented) { return; } - if (actives) { - actives.forEach(elemActive => { - if (container !== elemActive) { - Collapse.collapseInterface(elemActive, 'hide'); - } + actives.forEach(elemActive => { + if (container !== elemActive) { + Collapse.getOrCreateInstance(elemActive, { + toggle: false + }).hide(); + } - if (!activesData) { - Data.set(elemActive, DATA_KEY$8, null); - } - }); - } + if (!activesData) { + Data.set(elemActive, DATA_KEY$9, null); + } + }); const dimension = this._getDimension(); this._element.classList.remove(CLASS_NAME_COLLAPSE); this._element.classList.add(CLASS_NAME_COLLAPSING); this._element.style[dimension] = 0; - if (this._triggerArray.length) { - this._triggerArray.forEach(element => { - element.classList.remove(CLASS_NAME_COLLAPSED); - element.setAttribute('aria-expanded', true); - }); - } + this._addAriaAndCollapsedClass(this._triggerArray, true); - this.setTransitioning(true); + this._isTransitioning = true; const complete = () => { + this._isTransitioning = false; + this._element.classList.remove(CLASS_NAME_COLLAPSING); - this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$8); + this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7); this._element.style[dimension] = ''; - this.setTransitioning(false); EventHandler.trigger(this._element, EVENT_SHOWN$5); }; const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1); const scrollSize = `scroll${capitalizedDimension}`; @@ -1786,11 +1791,11 @@ this._element.style[dimension] = `${this._element[scrollSize]}px`; } hide() { - if (this._isTransitioning || !this._element.classList.contains(CLASS_NAME_SHOW$8)) { + if (this._isTransitioning || !this._isShown()) { return; } const startEvent = EventHandler.trigger(this._element, EVENT_HIDE$5); @@ -1803,30 +1808,27 @@ this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`; reflow(this._element); this._element.classList.add(CLASS_NAME_COLLAPSING); - this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$8); + this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7); const triggerArrayLength = this._triggerArray.length; - if (triggerArrayLength > 0) { - for (let i = 0; i < triggerArrayLength; i++) { - const trigger = this._triggerArray[i]; - const elem = getElementFromSelector(trigger); + for (let i = 0; i < triggerArrayLength; i++) { + const trigger = this._triggerArray[i]; + const elem = getElementFromSelector(trigger); - if (elem && !elem.classList.contains(CLASS_NAME_SHOW$8)) { - trigger.classList.add(CLASS_NAME_COLLAPSED); - trigger.setAttribute('aria-expanded', false); - } + if (elem && !this._isShown(elem)) { + this._addAriaAndCollapsedClass([trigger], false); } } - this.setTransitioning(true); + this._isTransitioning = true; const complete = () => { - this.setTransitioning(false); + this._isTransitioning = false; this._element.classList.remove(CLASS_NAME_COLLAPSING); this._element.classList.add(CLASS_NAME_COLLAPSE); @@ -1836,49 +1838,51 @@ this._element.style[dimension] = ''; this._queueCallback(complete, this._element, true); } - setTransitioning(isTransitioning) { - this._isTransitioning = isTransitioning; + _isShown(element = this._element) { + return element.classList.contains(CLASS_NAME_SHOW$7); } // Private _getConfig(config) { - config = { ...Default$8, + config = { ...Default$9, + ...Manipulator.getDataAttributes(this._element), ...config }; config.toggle = Boolean(config.toggle); // Coerce string values - typeCheckConfig(NAME$9, config, DefaultType$8); + config.parent = getElement(config.parent); + typeCheckConfig(NAME$a, config, DefaultType$9); return config; } _getDimension() { - return this._element.classList.contains(WIDTH) ? WIDTH : HEIGHT; + return this._element.classList.contains(CLASS_NAME_HORIZONTAL) ? WIDTH : HEIGHT; } - _getParent() { - let { - parent - } = this._config; - parent = getElement(parent); - const selector = `${SELECTOR_DATA_TOGGLE$4}[data-bs-parent="${parent}"]`; - SelectorEngine.find(selector, parent).forEach(element => { + _initializeChildren() { + if (!this._config.parent) { + return; + } + + const children = SelectorEngine.find(`.${CLASS_NAME_COLLAPSE} .${CLASS_NAME_COLLAPSE}`, this._config.parent); + SelectorEngine.find(SELECTOR_DATA_TOGGLE$4, this._config.parent).filter(elem => !children.includes(elem)).forEach(element => { const selected = getElementFromSelector(element); - this._addAriaAndCollapsedClass(selected, [element]); + if (selected) { + this._addAriaAndCollapsedClass([element], this._isShown(selected)); + } }); - return parent; } - _addAriaAndCollapsedClass(element, triggerArray) { - if (!element || !triggerArray.length) { + _addAriaAndCollapsedClass(triggerArray, isOpen) { + if (!triggerArray.length) { return; } - const isOpen = element.classList.contains(CLASS_NAME_SHOW$8); triggerArray.forEach(elem => { if (isOpen) { elem.classList.remove(CLASS_NAME_COLLAPSED); } else { elem.classList.add(CLASS_NAME_COLLAPSED); @@ -1887,37 +1891,27 @@ elem.setAttribute('aria-expanded', isOpen); }); } // Static - static collapseInterface(element, config) { - let data = Collapse.getInstance(element); - const _config = { ...Default$8, - ...Manipulator.getDataAttributes(element), - ...(typeof config === 'object' && config ? config : {}) - }; + static jQueryInterface(config) { + return this.each(function () { + const _config = {}; - if (!data && _config.toggle && typeof config === 'string' && /show|hide/.test(config)) { - _config.toggle = false; - } - - if (!data) { - data = new Collapse(element, _config); - } - - if (typeof config === 'string') { - if (typeof data[config] === 'undefined') { - throw new TypeError(`No method named "${config}"`); + if (typeof config === 'string' && /show|hide/.test(config)) { + _config.toggle = false; } - data[config](); - } - } + const data = Collapse.getOrCreateInstance(this, _config); - static jQueryInterface(config) { - return this.each(function () { - Collapse.collapseInterface(this, config); + if (typeof config === 'string') { + if (typeof data[config] === 'undefined') { + throw new TypeError(`No method named "${config}"`); + } + + data[config](); + } }); } } /** @@ -1931,30 +1925,16 @@ // preventDefault only for <a> elements (which change the URL) not inside the collapsible element if (event.target.tagName === 'A' || event.delegateTarget && event.delegateTarget.tagName === 'A') { event.preventDefault(); } - const triggerData = Manipulator.getDataAttributes(this); const selector = getSelectorFromElement(this); const selectorElements = SelectorEngine.find(selector); selectorElements.forEach(element => { - const data = Collapse.getInstance(element); - let config; - - if (data) { - // update parent attribute - if (data._parent === null && typeof triggerData.parent === 'string') { - data._config.parent = triggerData.parent; - data._parent = data._getParent(); - } - - config = 'toggle'; - } else { - config = triggerData; - } - - Collapse.collapseInterface(element, config); + Collapse.getOrCreateInstance(element, { + toggle: false + }).toggle(); }); }); /** * ------------------------------------------------------------------------ * jQuery @@ -1964,41 +1944,40 @@ defineJQueryPlugin(Collapse); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): dropdown.js + * Bootstrap (v5.1.0): dropdown.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ * Constants * ------------------------------------------------------------------------ */ - const NAME$8 = 'dropdown'; - const DATA_KEY$7 = 'bs.dropdown'; - const EVENT_KEY$7 = `.${DATA_KEY$7}`; + const NAME$9 = 'dropdown'; + const DATA_KEY$8 = 'bs.dropdown'; + const EVENT_KEY$8 = `.${DATA_KEY$8}`; const DATA_API_KEY$4 = '.data-api'; const ESCAPE_KEY$2 = 'Escape'; const SPACE_KEY = 'Space'; - const TAB_KEY = 'Tab'; + const TAB_KEY$1 = 'Tab'; const ARROW_UP_KEY = 'ArrowUp'; const ARROW_DOWN_KEY = 'ArrowDown'; const RIGHT_MOUSE_BUTTON = 2; // MouseEvent.button value for the secondary button, usually the right button const REGEXP_KEYDOWN = new RegExp(`${ARROW_UP_KEY}|${ARROW_DOWN_KEY}|${ESCAPE_KEY$2}`); - const EVENT_HIDE$4 = `hide${EVENT_KEY$7}`; - const EVENT_HIDDEN$4 = `hidden${EVENT_KEY$7}`; - const EVENT_SHOW$4 = `show${EVENT_KEY$7}`; - const EVENT_SHOWN$4 = `shown${EVENT_KEY$7}`; - const EVENT_CLICK = `click${EVENT_KEY$7}`; - const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$7}${DATA_API_KEY$4}`; - const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$7}${DATA_API_KEY$4}`; - const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$7}${DATA_API_KEY$4}`; - const CLASS_NAME_SHOW$7 = 'show'; + const EVENT_HIDE$4 = `hide${EVENT_KEY$8}`; + const EVENT_HIDDEN$4 = `hidden${EVENT_KEY$8}`; + const EVENT_SHOW$4 = `show${EVENT_KEY$8}`; + const EVENT_SHOWN$4 = `shown${EVENT_KEY$8}`; + const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$8}${DATA_API_KEY$4}`; + const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$8}${DATA_API_KEY$4}`; + const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$8}${DATA_API_KEY$4}`; + const CLASS_NAME_SHOW$6 = 'show'; const CLASS_NAME_DROPUP = 'dropup'; const CLASS_NAME_DROPEND = 'dropend'; const CLASS_NAME_DROPSTART = 'dropstart'; const CLASS_NAME_NAVBAR = 'navbar'; const SELECTOR_DATA_TOGGLE$3 = '[data-bs-toggle="dropdown"]'; @@ -2009,19 +1988,19 @@ const PLACEMENT_TOPEND = isRTL() ? 'top-start' : 'top-end'; const PLACEMENT_BOTTOM = isRTL() ? 'bottom-end' : 'bottom-start'; const PLACEMENT_BOTTOMEND = isRTL() ? 'bottom-start' : 'bottom-end'; const PLACEMENT_RIGHT = isRTL() ? 'left-start' : 'right-start'; const PLACEMENT_LEFT = isRTL() ? 'right-start' : 'left-start'; - const Default$7 = { + const Default$8 = { offset: [0, 2], boundary: 'clippingParents', reference: 'toggle', display: 'dynamic', popperConfig: null, autoClose: true }; - const DefaultType$7 = { + const DefaultType$8 = { offset: '(array|string|function)', boundary: '(string|element)', reference: '(string|element|object)', display: 'string', popperConfig: '(null|object|function)', @@ -2038,84 +2017,50 @@ super(element); this._popper = null; this._config = this._getConfig(config); this._menu = this._getMenuElement(); this._inNavbar = this._detectNavbar(); - - this._addEventListeners(); } // Getters static get Default() { - return Default$7; + return Default$8; } static get DefaultType() { - return DefaultType$7; + return DefaultType$8; } static get NAME() { - return NAME$8; + return NAME$9; } // Public toggle() { - if (isDisabled(this._element)) { - return; - } - - const isActive = this._element.classList.contains(CLASS_NAME_SHOW$7); - - if (isActive) { - this.hide(); - return; - } - - this.show(); + return this._isShown() ? this.hide() : this.show(); } show() { - if (isDisabled(this._element) || this._menu.classList.contains(CLASS_NAME_SHOW$7)) { + if (isDisabled(this._element) || this._isShown(this._menu)) { return; } - const parent = Dropdown.getParentFromElement(this._element); const relatedTarget = { relatedTarget: this._element }; const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$4, relatedTarget); if (showEvent.defaultPrevented) { return; - } // Totally disable Popper for Dropdowns in Navbar + } + const parent = Dropdown.getParentFromElement(this._element); // Totally disable Popper for Dropdowns in Navbar if (this._inNavbar) { Manipulator.setDataAttribute(this._menu, 'popper', 'none'); } else { - if (typeof Popper__namespace === 'undefined') { - throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)'); - } - - let referenceElement = this._element; - - if (this._config.reference === 'parent') { - referenceElement = parent; - } else if (isElement(this._config.reference)) { - referenceElement = getElement(this._config.reference); - } else if (typeof this._config.reference === 'object') { - referenceElement = this._config.reference; - } - - const popperConfig = this._getPopperConfig(); - - const isDisplayStatic = popperConfig.modifiers.find(modifier => modifier.name === 'applyStyles' && modifier.enabled === false); - this._popper = Popper__namespace.createPopper(referenceElement, this._menu, popperConfig); - - if (isDisplayStatic) { - Manipulator.setDataAttribute(this._menu, 'popper', 'static'); - } + this._createPopper(parent); } // If this is a touch-enabled device we add extra // empty mouseover listeners to the body's immediate children; // only needed because of broken event delegation on iOS // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html @@ -2126,19 +2071,19 @@ this._element.focus(); this._element.setAttribute('aria-expanded', true); - this._menu.classList.toggle(CLASS_NAME_SHOW$7); + this._menu.classList.add(CLASS_NAME_SHOW$6); - this._element.classList.toggle(CLASS_NAME_SHOW$7); + this._element.classList.add(CLASS_NAME_SHOW$6); EventHandler.trigger(this._element, EVENT_SHOWN$4, relatedTarget); } hide() { - if (isDisabled(this._element) || !this._menu.classList.contains(CLASS_NAME_SHOW$7)) { + if (isDisabled(this._element) || !this._isShown(this._menu)) { return; } const relatedTarget = { relatedTarget: this._element @@ -2162,17 +2107,10 @@ this._popper.update(); } } // Private - _addEventListeners() { - EventHandler.on(this._element, EVENT_CLICK, event => { - event.preventDefault(); - this.toggle(); - }); - } - _completeHide(relatedTarget) { const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$4, relatedTarget); if (hideEvent.defaultPrevented) { return; @@ -2186,13 +2124,13 @@ if (this._popper) { this._popper.destroy(); } - this._menu.classList.remove(CLASS_NAME_SHOW$7); + this._menu.classList.remove(CLASS_NAME_SHOW$6); - this._element.classList.remove(CLASS_NAME_SHOW$7); + this._element.classList.remove(CLASS_NAME_SHOW$6); this._element.setAttribute('aria-expanded', 'false'); Manipulator.removeDataAttribute(this._menu, 'popper'); EventHandler.trigger(this._element, EVENT_HIDDEN$4, relatedTarget); @@ -2201,20 +2139,49 @@ _getConfig(config) { config = { ...this.constructor.Default, ...Manipulator.getDataAttributes(this._element), ...config }; - typeCheckConfig(NAME$8, config, this.constructor.DefaultType); + typeCheckConfig(NAME$9, config, this.constructor.DefaultType); if (typeof config.reference === 'object' && !isElement(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') { // Popper virtual elements require a getBoundingClientRect method - throw new TypeError(`${NAME$8.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`); + throw new TypeError(`${NAME$9.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`); } return config; } + _createPopper(parent) { + if (typeof Popper__namespace === 'undefined') { + throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)'); + } + + let referenceElement = this._element; + + if (this._config.reference === 'parent') { + referenceElement = parent; + } else if (isElement(this._config.reference)) { + referenceElement = getElement(this._config.reference); + } else if (typeof this._config.reference === 'object') { + referenceElement = this._config.reference; + } + + const popperConfig = this._getPopperConfig(); + + const isDisplayStatic = popperConfig.modifiers.find(modifier => modifier.name === 'applyStyles' && modifier.enabled === false); + this._popper = Popper__namespace.createPopper(referenceElement, this._menu, popperConfig); + + if (isDisplayStatic) { + Manipulator.setDataAttribute(this._menu, 'popper', 'static'); + } + } + + _isShown(element = this._element) { + return element.classList.contains(CLASS_NAME_SHOW$6); + } + _getMenuElement() { return SelectorEngine.next(this._element, SELECTOR_MENU)[0]; } _getPlacement() { @@ -2300,30 +2267,28 @@ getNextActiveElement(items, target, key === ARROW_DOWN_KEY, !items.includes(target)).focus(); } // Static - static dropdownInterface(element, config) { - const data = Dropdown.getOrCreateInstance(element, config); + static jQueryInterface(config) { + return this.each(function () { + const data = Dropdown.getOrCreateInstance(this, config); - if (typeof config === 'string') { + if (typeof config !== 'string') { + return; + } + if (typeof data[config] === 'undefined') { throw new TypeError(`No method named "${config}"`); } data[config](); - } - } - - static jQueryInterface(config) { - return this.each(function () { - Dropdown.dropdownInterface(this, config); }); } static clearMenus(event) { - if (event && (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY)) { + if (event && (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY$1)) { return; } const toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE$3); @@ -2332,11 +2297,11 @@ if (!context || context._config.autoClose === false) { continue; } - if (!context._element.classList.contains(CLASS_NAME_SHOW$7)) { + if (!context._isShown()) { continue; } const relatedTarget = { relatedTarget: context._element @@ -2349,11 +2314,11 @@ if (composedPath.includes(context._element) || context._config.autoClose === 'inside' && !isMenuTarget || context._config.autoClose === 'outside' && isMenuTarget) { continue; } // Tab navigation through the dropdown menu or events from contained inputs shouldn't close the menu - if (context._menu.contains(event.target) && (event.type === 'keyup' && event.key === TAB_KEY || /input|select|option|textarea|form/i.test(event.target.tagName))) { + if (context._menu.contains(event.target) && (event.type === 'keyup' && event.key === TAB_KEY$1 || /input|select|option|textarea|form/i.test(event.target.tagName))) { continue; } if (event.type === 'click') { relatedTarget.clickEvent = event; @@ -2378,11 +2343,11 @@ // - If trigger inside the menu => not a dropdown command if (/input|textarea/i.test(event.target.tagName) ? event.key === SPACE_KEY || event.key !== ESCAPE_KEY$2 && (event.key !== ARROW_DOWN_KEY && event.key !== ARROW_UP_KEY || event.target.closest(SELECTOR_MENU)) : !REGEXP_KEYDOWN.test(event.key)) { return; } - const isActive = this.classList.contains(CLASS_NAME_SHOW$7); + const isActive = this.classList.contains(CLASS_NAME_SHOW$6); if (!isActive && event.key === ESCAPE_KEY$2) { return; } @@ -2391,24 +2356,24 @@ if (isDisabled(this)) { return; } - const getToggleButton = () => this.matches(SELECTOR_DATA_TOGGLE$3) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE$3)[0]; + const getToggleButton = this.matches(SELECTOR_DATA_TOGGLE$3) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE$3)[0]; + const instance = Dropdown.getOrCreateInstance(getToggleButton); if (event.key === ESCAPE_KEY$2) { - getToggleButton().focus(); - Dropdown.clearMenus(); + instance.hide(); return; } if (event.key === ARROW_UP_KEY || event.key === ARROW_DOWN_KEY) { if (!isActive) { - getToggleButton().click(); + instance.show(); } - Dropdown.getInstance(getToggleButton())._selectMenuItem(event); + instance._selectMenuItem(event); return; } if (!isActive || event.key === SPACE_KEY) { @@ -2428,11 +2393,11 @@ EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler); EventHandler.on(document, EVENT_CLICK_DATA_API$3, Dropdown.clearMenus); EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus); EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$3, function (event) { event.preventDefault(); - Dropdown.dropdownInterface(this); + Dropdown.getOrCreateInstance(this).toggle(); }); /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ @@ -2441,11 +2406,11 @@ defineJQueryPlugin(Dropdown); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): util/scrollBar.js + * Bootstrap (v5.1.0): util/scrollBar.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'; const SELECTOR_STICKY_CONTENT = '.sticky-top'; @@ -2545,33 +2510,34 @@ } /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): util/backdrop.js + * Bootstrap (v5.1.0): util/backdrop.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ - const Default$6 = { + const Default$7 = { + className: 'modal-backdrop', isVisible: true, // if false, we use the backdrop helper without adding any element to the dom isAnimated: false, rootElement: 'body', // give the choice to place backdrop under different elements clickCallback: null }; - const DefaultType$6 = { + const DefaultType$7 = { + className: 'string', isVisible: 'boolean', isAnimated: 'boolean', rootElement: '(element|string)', clickCallback: '(function|null)' }; - const NAME$7 = 'backdrop'; - const CLASS_NAME_BACKDROP = 'modal-backdrop'; - const CLASS_NAME_FADE$5 = 'fade'; - const CLASS_NAME_SHOW$6 = 'show'; - const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$7}`; + const NAME$8 = 'backdrop'; + const CLASS_NAME_FADE$4 = 'fade'; + const CLASS_NAME_SHOW$5 = 'show'; + const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$8}`; class Backdrop { constructor(config) { this._config = this._getConfig(config); this._isAppended = false; @@ -2588,11 +2554,11 @@ if (this._config.isAnimated) { reflow(this._getElement()); } - this._getElement().classList.add(CLASS_NAME_SHOW$6); + this._getElement().classList.add(CLASS_NAME_SHOW$5); this._emulateAnimation(() => { execute(callback); }); } @@ -2601,11 +2567,11 @@ if (!this._config.isVisible) { execute(callback); return; } - this._getElement().classList.remove(CLASS_NAME_SHOW$6); + this._getElement().classList.remove(CLASS_NAME_SHOW$5); this._emulateAnimation(() => { this.dispose(); execute(callback); }); @@ -2613,38 +2579,38 @@ _getElement() { if (!this._element) { const backdrop = document.createElement('div'); - backdrop.className = CLASS_NAME_BACKDROP; + backdrop.className = this._config.className; if (this._config.isAnimated) { - backdrop.classList.add(CLASS_NAME_FADE$5); + backdrop.classList.add(CLASS_NAME_FADE$4); } this._element = backdrop; } return this._element; } _getConfig(config) { - config = { ...Default$6, + config = { ...Default$7, ...(typeof config === 'object' ? config : {}) }; // use getElement() with the default "body" to get a fresh Element on each instantiation config.rootElement = getElement(config.rootElement); - typeCheckConfig(NAME$7, config, DefaultType$6); + typeCheckConfig(NAME$8, config, DefaultType$7); return config; } _append() { if (this._isAppended) { return; } - this._config.rootElement.appendChild(this._getElement()); + this._config.rootElement.append(this._getElement()); EventHandler.on(this._getElement(), EVENT_MOUSEDOWN, () => { execute(this._config.clickCallback); }); this._isAppended = true; @@ -2668,11 +2634,114 @@ } /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): modal.js + * Bootstrap (v5.1.0): util/focustrap.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + const Default$6 = { + trapElement: null, + // The element to trap focus inside of + autofocus: true + }; + const DefaultType$6 = { + trapElement: 'element', + autofocus: 'boolean' + }; + const NAME$7 = 'focustrap'; + const DATA_KEY$7 = 'bs.focustrap'; + const EVENT_KEY$7 = `.${DATA_KEY$7}`; + const EVENT_FOCUSIN$1 = `focusin${EVENT_KEY$7}`; + const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$7}`; + const TAB_KEY = 'Tab'; + const TAB_NAV_FORWARD = 'forward'; + const TAB_NAV_BACKWARD = 'backward'; + + class FocusTrap { + constructor(config) { + this._config = this._getConfig(config); + this._isActive = false; + this._lastTabNavDirection = null; + } + + activate() { + const { + trapElement, + autofocus + } = this._config; + + if (this._isActive) { + return; + } + + if (autofocus) { + trapElement.focus(); + } + + EventHandler.off(document, EVENT_KEY$7); // guard against infinite focus loop + + EventHandler.on(document, EVENT_FOCUSIN$1, event => this._handleFocusin(event)); + EventHandler.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event)); + this._isActive = true; + } + + deactivate() { + if (!this._isActive) { + return; + } + + this._isActive = false; + EventHandler.off(document, EVENT_KEY$7); + } // Private + + + _handleFocusin(event) { + const { + target + } = event; + const { + trapElement + } = this._config; + + if (target === document || target === trapElement || trapElement.contains(target)) { + return; + } + + const elements = SelectorEngine.focusableChildren(trapElement); + + if (elements.length === 0) { + trapElement.focus(); + } else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) { + elements[elements.length - 1].focus(); + } else { + elements[0].focus(); + } + } + + _handleKeydown(event) { + if (event.key !== TAB_KEY) { + return; + } + + this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD; + } + + _getConfig(config) { + config = { ...Default$6, + ...(typeof config === 'object' ? config : {}) + }; + typeCheckConfig(NAME$7, config, DefaultType$6); + return config; + } + + } + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v5.1.0): modal.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -2698,25 +2767,23 @@ const EVENT_HIDE$3 = `hide${EVENT_KEY$6}`; const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY$6}`; const EVENT_HIDDEN$3 = `hidden${EVENT_KEY$6}`; const EVENT_SHOW$3 = `show${EVENT_KEY$6}`; const EVENT_SHOWN$3 = `shown${EVENT_KEY$6}`; - const EVENT_FOCUSIN$2 = `focusin${EVENT_KEY$6}`; const EVENT_RESIZE = `resize${EVENT_KEY$6}`; - const EVENT_CLICK_DISMISS$2 = `click.dismiss${EVENT_KEY$6}`; + const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY$6}`; const EVENT_KEYDOWN_DISMISS$1 = `keydown.dismiss${EVENT_KEY$6}`; const EVENT_MOUSEUP_DISMISS = `mouseup.dismiss${EVENT_KEY$6}`; const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY$6}`; const EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$6}${DATA_API_KEY$3}`; const CLASS_NAME_OPEN = 'modal-open'; - const CLASS_NAME_FADE$4 = 'fade'; - const CLASS_NAME_SHOW$5 = 'show'; + const CLASS_NAME_FADE$3 = 'fade'; + const CLASS_NAME_SHOW$4 = 'show'; const CLASS_NAME_STATIC = 'modal-static'; const SELECTOR_DIALOG = '.modal-dialog'; const SELECTOR_MODAL_BODY = '.modal-body'; const SELECTOR_DATA_TOGGLE$2 = '[data-bs-toggle="modal"]'; - const SELECTOR_DATA_DISMISS$2 = '[data-bs-dismiss="modal"]'; /** * ------------------------------------------------------------------------ * Class Definition * ------------------------------------------------------------------------ */ @@ -2725,10 +2792,11 @@ constructor(element, config) { super(element); this._config = this._getConfig(config); this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element); this._backdrop = this._initializeBackDrop(); + this._focustrap = this._initializeFocusTrap(); this._isShown = false; this._ignoreBackdropClick = false; this._isTransitioning = false; this._scrollBar = new ScrollBarHelper(); } // Getters @@ -2774,11 +2842,10 @@ this._setEscapeEvent(); this._setResizeEvent(); - EventHandler.on(this._element, EVENT_CLICK_DISMISS$2, SELECTOR_DATA_DISMISS$2, event => this.hide(event)); EventHandler.on(this._dialog, EVENT_MOUSEDOWN_DISMISS, () => { EventHandler.one(this._element, EVENT_MOUSEUP_DISMISS, event => { if (event.target === this._element) { this._ignoreBackdropClick = true; } @@ -2786,15 +2853,11 @@ }); this._showBackdrop(() => this._showElement(relatedTarget)); } - hide(event) { - if (event && ['A', 'AREA'].includes(event.target.tagName)) { - event.preventDefault(); - } - + hide() { if (!this._isShown || this._isTransitioning) { return; } const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$3); @@ -2813,33 +2876,28 @@ this._setEscapeEvent(); this._setResizeEvent(); - EventHandler.off(document, EVENT_FOCUSIN$2); + this._focustrap.deactivate(); - this._element.classList.remove(CLASS_NAME_SHOW$5); + this._element.classList.remove(CLASS_NAME_SHOW$4); - EventHandler.off(this._element, EVENT_CLICK_DISMISS$2); + EventHandler.off(this._element, EVENT_CLICK_DISMISS); EventHandler.off(this._dialog, EVENT_MOUSEDOWN_DISMISS); this._queueCallback(() => this._hideModal(), this._element, isAnimated); } dispose() { [window, this._dialog].forEach(htmlElement => EventHandler.off(htmlElement, EVENT_KEY$6)); this._backdrop.dispose(); - super.dispose(); - /** - * `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API` - * Do not move `document` in `htmlElements` array - * It will remove `EVENT_CLICK_DATA_API` event that should remain - */ + this._focustrap.deactivate(); - EventHandler.off(document, EVENT_FOCUSIN$2); + super.dispose(); } handleUpdate() { this._adjustDialog(); } // Private @@ -2851,10 +2909,16 @@ // 'static' option will be translated to true, and booleans will keep their value isAnimated: this._isAnimated() }); } + _initializeFocusTrap() { + return new FocusTrap({ + trapElement: this._element + }); + } + _getConfig(config) { config = { ...Default$5, ...Manipulator.getDataAttributes(this._element), ...(typeof config === 'object' ? config : {}) }; @@ -2867,11 +2931,11 @@ const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog); if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { // Don't move modal's DOM position - document.body.appendChild(this._element); + document.body.append(this._element); } this._element.style.display = 'block'; this._element.removeAttribute('aria-hidden'); @@ -2888,19 +2952,15 @@ if (isAnimated) { reflow(this._element); } - this._element.classList.add(CLASS_NAME_SHOW$5); + this._element.classList.add(CLASS_NAME_SHOW$4); - if (this._config.focus) { - this._enforceFocus(); - } - const transitionComplete = () => { if (this._config.focus) { - this._element.focus(); + this._focustrap.activate(); } this._isTransitioning = false; EventHandler.trigger(this._element, EVENT_SHOWN$3, { relatedTarget @@ -2908,20 +2968,10 @@ }; this._queueCallback(transitionComplete, this._dialog, isAnimated); } - _enforceFocus() { - EventHandler.off(document, EVENT_FOCUSIN$2); // guard against infinite focus loop - - EventHandler.on(document, EVENT_FOCUSIN$2, event => { - if (document !== event.target && this._element !== event.target && !this._element.contains(event.target)) { - this._element.focus(); - } - }); - } - _setEscapeEvent() { if (this._isShown) { EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS$1, event => { if (this._config.keyboard && event.key === ESCAPE_KEY$1) { event.preventDefault(); @@ -2964,11 +3014,11 @@ EventHandler.trigger(this._element, EVENT_HIDDEN$3); }); } _showBackdrop(callback) { - EventHandler.on(this._element, EVENT_CLICK_DISMISS$2, event => { + EventHandler.on(this._element, EVENT_CLICK_DISMISS, event => { if (this._ignoreBackdropClick) { this._ignoreBackdropClick = false; return; } @@ -2985,11 +3035,11 @@ this._backdrop.show(callback); } _isAnimated() { - return this._element.classList.contains(CLASS_NAME_FADE$4); + return this._element.classList.contains(CLASS_NAME_FADE$3); } _triggerBackdropTransition() { const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED); @@ -3096,10 +3146,11 @@ }); }); const data = Modal.getOrCreateInstance(target); data.toggle(this); }); + enableDismissTrigger(Modal); /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ * add .Modal to jQuery only if jQuery is present @@ -3107,11 +3158,11 @@ defineJQueryPlugin(Modal); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): offcanvas.js + * Bootstrap (v5.1.0): offcanvas.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -3133,21 +3184,19 @@ const DefaultType$4 = { backdrop: 'boolean', keyboard: 'boolean', scroll: 'boolean' }; - const CLASS_NAME_SHOW$4 = 'show'; + const CLASS_NAME_SHOW$3 = 'show'; + const CLASS_NAME_BACKDROP = 'offcanvas-backdrop'; const OPEN_SELECTOR = '.offcanvas.show'; const EVENT_SHOW$2 = `show${EVENT_KEY$5}`; const EVENT_SHOWN$2 = `shown${EVENT_KEY$5}`; const EVENT_HIDE$2 = `hide${EVENT_KEY$5}`; const EVENT_HIDDEN$2 = `hidden${EVENT_KEY$5}`; - const EVENT_FOCUSIN$1 = `focusin${EVENT_KEY$5}`; const EVENT_CLICK_DATA_API$1 = `click${EVENT_KEY$5}${DATA_API_KEY$2}`; - const EVENT_CLICK_DISMISS$1 = `click.dismiss${EVENT_KEY$5}`; const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY$5}`; - const SELECTOR_DATA_DISMISS$1 = '[data-bs-dismiss="offcanvas"]'; const SELECTOR_DATA_TOGGLE$1 = '[data-bs-toggle="offcanvas"]'; /** * ------------------------------------------------------------------------ * Class Definition * ------------------------------------------------------------------------ @@ -3157,10 +3206,11 @@ constructor(element, config) { super(element); this._config = this._getConfig(config); this._isShown = false; this._backdrop = this._initializeBackDrop(); + this._focustrap = this._initializeFocusTrap(); this._addEventListeners(); } // Getters @@ -3195,23 +3245,25 @@ this._backdrop.show(); if (!this._config.scroll) { new ScrollBarHelper().hide(); - - this._enforceFocusOnElement(this._element); } this._element.removeAttribute('aria-hidden'); this._element.setAttribute('aria-modal', true); this._element.setAttribute('role', 'dialog'); - this._element.classList.add(CLASS_NAME_SHOW$4); + this._element.classList.add(CLASS_NAME_SHOW$3); const completeCallBack = () => { + if (!this._config.scroll) { + this._focustrap.activate(); + } + EventHandler.trigger(this._element, EVENT_SHOWN$2, { relatedTarget }); }; @@ -3227,17 +3279,17 @@ if (hideEvent.defaultPrevented) { return; } - EventHandler.off(document, EVENT_FOCUSIN$1); + this._focustrap.deactivate(); this._element.blur(); this._isShown = false; - this._element.classList.remove(CLASS_NAME_SHOW$4); + this._element.classList.remove(CLASS_NAME_SHOW$3); this._backdrop.hide(); const completeCallback = () => { this._element.setAttribute('aria-hidden', true); @@ -3259,12 +3311,13 @@ } dispose() { this._backdrop.dispose(); + this._focustrap.deactivate(); + super.dispose(); - EventHandler.off(document, EVENT_FOCUSIN$1); } // Private _getConfig(config) { config = { ...Default$4, @@ -3275,30 +3328,25 @@ return config; } _initializeBackDrop() { return new Backdrop({ + className: CLASS_NAME_BACKDROP, isVisible: this._config.backdrop, isAnimated: true, rootElement: this._element.parentNode, clickCallback: () => this.hide() }); } - _enforceFocusOnElement(element) { - EventHandler.off(document, EVENT_FOCUSIN$1); // guard against infinite focus loop - - EventHandler.on(document, EVENT_FOCUSIN$1, event => { - if (document !== event.target && element !== event.target && !element.contains(event.target)) { - element.focus(); - } + _initializeFocusTrap() { + return new FocusTrap({ + trapElement: this._element }); - element.focus(); } _addEventListeners() { - EventHandler.on(this._element, EVENT_CLICK_DISMISS$1, SELECTOR_DATA_DISMISS$1, () => this.hide()); EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => { if (this._config.keyboard && event.key === ESCAPE_KEY) { this.hide(); } }); @@ -3355,21 +3403,22 @@ const data = Offcanvas.getOrCreateInstance(target); data.toggle(this); }); EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => SelectorEngine.find(OPEN_SELECTOR).forEach(el => Offcanvas.getOrCreateInstance(el).show())); + enableDismissTrigger(Offcanvas); /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ */ defineJQueryPlugin(Offcanvas); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): util/sanitizer.js + * Bootstrap (v5.1.0): util/sanitizer.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ const uriAttrs = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']); const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i; @@ -3478,11 +3527,11 @@ return createdDocument.body.innerHTML; } /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): tooltip.js + * Bootstrap (v5.1.0): tooltip.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -3492,11 +3541,10 @@ const NAME$4 = 'tooltip'; const DATA_KEY$4 = 'bs.tooltip'; const EVENT_KEY$4 = `.${DATA_KEY$4}`; const CLASS_PREFIX$1 = 'bs-tooltip'; - const BSCLS_PREFIX_REGEX$1 = new RegExp(`(^|\\s)${CLASS_PREFIX$1}\\S+`, 'g'); const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']); const DefaultType$3 = { animation: 'boolean', template: 'string', title: '(string|element|function)', @@ -3551,16 +3599,18 @@ FOCUSIN: `focusin${EVENT_KEY$4}`, FOCUSOUT: `focusout${EVENT_KEY$4}`, MOUSEENTER: `mouseenter${EVENT_KEY$4}`, MOUSELEAVE: `mouseleave${EVENT_KEY$4}` }; - const CLASS_NAME_FADE$3 = 'fade'; + const CLASS_NAME_FADE$2 = 'fade'; const CLASS_NAME_MODAL = 'modal'; - const CLASS_NAME_SHOW$3 = 'show'; + const CLASS_NAME_SHOW$2 = 'show'; const HOVER_STATE_SHOW = 'show'; const HOVER_STATE_OUT = 'out'; const SELECTOR_TOOLTIP_INNER = '.tooltip-inner'; + const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`; + const EVENT_MODAL_HIDE = 'hide.bs.modal'; const TRIGGER_HOVER = 'hover'; const TRIGGER_FOCUS = 'focus'; const TRIGGER_CLICK = 'click'; const TRIGGER_MANUAL = 'manual'; /** @@ -3633,11 +3683,11 @@ context._enter(null, context); } else { context._leave(null, context); } } else { - if (this.getTipElement().classList.contains(CLASS_NAME_SHOW$3)) { + if (this.getTipElement().classList.contains(CLASS_NAME_SHOW$2)) { this._leave(null, this); return; } @@ -3645,11 +3695,11 @@ } } dispose() { clearTimeout(this._timeout); - EventHandler.off(this._element.closest(`.${CLASS_NAME_MODAL}`), 'hide.bs.modal', this._hideModalHandler); + EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler); if (this.tip) { this.tip.remove(); } @@ -3681,14 +3731,12 @@ const tipId = getUID(this.constructor.NAME); tip.setAttribute('id', tipId); this._element.setAttribute('aria-describedby', tipId); - this.setContent(); - if (this._config.animation) { - tip.classList.add(CLASS_NAME_FADE$3); + tip.classList.add(CLASS_NAME_FADE$2); } const placement = typeof this._config.placement === 'function' ? this._config.placement.call(this, tip, this._element) : this._config.placement; const attachment = this._getAttachment(placement); @@ -3699,23 +3747,24 @@ container } = this._config; Data.set(tip, this.constructor.DATA_KEY, this); if (!this._element.ownerDocument.documentElement.contains(this.tip)) { - container.appendChild(tip); + container.append(tip); EventHandler.trigger(this._element, this.constructor.Event.INSERTED); } if (this._popper) { this._popper.update(); } else { this._popper = Popper__namespace.createPopper(this._element, tip, this._getPopperConfig(attachment)); } - tip.classList.add(CLASS_NAME_SHOW$3); - const customClass = typeof this._config.customClass === 'function' ? this._config.customClass() : this._config.customClass; + tip.classList.add(CLASS_NAME_SHOW$2); + const customClass = this._resolvePossibleFunction(this._config.customClass); + if (customClass) { tip.classList.add(...customClass.split(' ')); } // If this is a touch-enabled device we add extra // empty mouseover listeners to the body's immediate children; // only needed because of broken event delegation on iOS @@ -3736,11 +3785,11 @@ if (prevHoverState === HOVER_STATE_OUT) { this._leave(null, this); } }; - const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE$3); + const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE$2); this._queueCallback(complete, this.tip, isAnimated); } hide() { @@ -3776,21 +3825,21 @@ if (hideEvent.defaultPrevented) { return; } - tip.classList.remove(CLASS_NAME_SHOW$3); // If this is a touch-enabled device we remove the extra + tip.classList.remove(CLASS_NAME_SHOW$2); // If this is a touch-enabled device we remove the extra // empty mouseover listeners we added for iOS support if ('ontouchstart' in document.documentElement) { [].concat(...document.body.children).forEach(element => EventHandler.off(element, 'mouseover', noop)); } this._activeTrigger[TRIGGER_CLICK] = false; this._activeTrigger[TRIGGER_FOCUS] = false; this._activeTrigger[TRIGGER_HOVER] = false; - const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE$3); + const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE$2); this._queueCallback(complete, this.tip, isAnimated); this._hoverState = ''; } @@ -3811,20 +3860,33 @@ return this.tip; } const element = document.createElement('div'); element.innerHTML = this._config.template; - this.tip = element.children[0]; + const tip = element.children[0]; + this.setContent(tip); + tip.classList.remove(CLASS_NAME_FADE$2, CLASS_NAME_SHOW$2); + this.tip = tip; return this.tip; } - setContent() { - const tip = this.getTipElement(); - this.setElementContent(SelectorEngine.findOne(SELECTOR_TOOLTIP_INNER, tip), this.getTitle()); - tip.classList.remove(CLASS_NAME_FADE$3, CLASS_NAME_SHOW$3); + setContent(tip) { + this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TOOLTIP_INNER); } + _sanitizeAndSetContent(template, content, selector) { + const templateElement = SelectorEngine.findOne(selector, template); + + if (!content && templateElement) { + templateElement.remove(); + return; + } // we use append for html objects to maintain js events + + + this.setElementContent(templateElement, content); + } + setElementContent(element, content) { if (element === null) { return; } @@ -3832,11 +3894,11 @@ content = getElement(content); // content is a DOM node or a jQuery if (this._config.html) { if (content.parentNode !== element) { element.innerHTML = ''; - element.appendChild(content); + element.append(content); } } else { element.textContent = content.textContent; } @@ -3853,17 +3915,13 @@ element.textContent = content; } } getTitle() { - let title = this._element.getAttribute('data-bs-original-title'); + const title = this._element.getAttribute('data-bs-original-title') || this._config.title; - if (!title) { - title = typeof this._config.title === 'function' ? this._config.title.call(this._element) : this._config.title; - } - - return title; + return this._resolvePossibleFunction(title); } updateAttachment(attachment) { if (attachment === 'right') { return 'end'; @@ -3876,19 +3934,11 @@ return attachment; } // Private _initializeOnDelegatedTarget(event, context) { - const dataKey = this.constructor.DATA_KEY; - context = context || Data.get(event.delegateTarget, dataKey); - - if (!context) { - context = new this.constructor(event.delegateTarget, this._getDelegateConfig()); - Data.set(event.delegateTarget, dataKey, context); - } - - return context; + return context || this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig()); } _getOffset() { const { offset @@ -3903,10 +3953,14 @@ } return offset; } + _resolvePossibleFunction(content) { + return typeof content === 'function' ? content.call(this._element) : content; + } + _getPopperConfig(attachment) { const defaultBsPopperConfig = { placement: attachment, modifiers: [{ name: 'flip', @@ -3944,11 +3998,11 @@ ...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig) }; } _addAttachmentClass(attachment) { - this.getTipElement().classList.add(`${CLASS_PREFIX$1}-${this.updateAttachment(attachment)}`); + this.getTipElement().classList.add(`${this._getBasicClassPrefix()}-${this.updateAttachment(attachment)}`); } _getAttachment(placement) { return AttachmentMap[placement.toUpperCase()]; } @@ -3971,11 +4025,11 @@ if (this._element) { this.hide(); } }; - EventHandler.on(this._element.closest(`.${CLASS_NAME_MODAL}`), 'hide.bs.modal', this._hideModalHandler); + EventHandler.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler); if (this._config.selector) { this._config = { ...this._config, trigger: 'manual', selector: '' @@ -4006,11 +4060,11 @@ if (event) { context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true; } - if (context.getTipElement().classList.contains(CLASS_NAME_SHOW$3) || context._hoverState === HOVER_STATE_SHOW) { + if (context.getTipElement().classList.contains(CLASS_NAME_SHOW$2) || context._hoverState === HOVER_STATE_SHOW) { context._hoverState = HOVER_STATE_SHOW; return; } clearTimeout(context._timeout); @@ -4102,30 +4156,36 @@ } _getDelegateConfig() { const config = {}; - if (this._config) { - for (const key in this._config) { - if (this.constructor.Default[key] !== this._config[key]) { - config[key] = this._config[key]; - } + for (const key in this._config) { + if (this.constructor.Default[key] !== this._config[key]) { + config[key] = this._config[key]; } - } + } // In the future can be replaced with: + // const keysWithDifferentValues = Object.entries(this._config).filter(entry => this.constructor.Default[entry[0]] !== this._config[entry[0]]) + // `Object.fromEntries(keysWithDifferentValues)` + return config; } _cleanTipClass() { const tip = this.getTipElement(); - const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX$1); + const basicClassPrefixRegex = new RegExp(`(^|\\s)${this._getBasicClassPrefix()}\\S+`, 'g'); + const tabClass = tip.getAttribute('class').match(basicClassPrefixRegex); if (tabClass !== null && tabClass.length > 0) { tabClass.map(token => token.trim()).forEach(tClass => tip.classList.remove(tClass)); } } + _getBasicClassPrefix() { + return CLASS_PREFIX$1; + } + _handlePopperPlacementChange(popperData) { const { state } = popperData; @@ -4166,11 +4226,11 @@ defineJQueryPlugin(Tooltip); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): popover.js + * Bootstrap (v5.1.0): popover.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -4180,11 +4240,10 @@ const NAME$3 = 'popover'; const DATA_KEY$3 = 'bs.popover'; const EVENT_KEY$3 = `.${DATA_KEY$3}`; const CLASS_PREFIX = 'bs-popover'; - const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g'); const Default$2 = { ...Tooltip.Default, placement: 'right', offset: [0, 8], trigger: 'click', content: '', @@ -4203,12 +4262,10 @@ FOCUSIN: `focusin${EVENT_KEY$3}`, FOCUSOUT: `focusout${EVENT_KEY$3}`, MOUSEENTER: `mouseenter${EVENT_KEY$3}`, MOUSELEAVE: `mouseleave${EVENT_KEY$3}` }; - const CLASS_NAME_FADE$2 = 'fade'; - const CLASS_NAME_SHOW$2 = 'show'; const SELECTOR_TITLE = '.popover-header'; const SELECTOR_CONTENT = '.popover-body'; /** * ------------------------------------------------------------------------ * Class Definition @@ -4236,59 +4293,23 @@ isWithContent() { return this.getTitle() || this._getContent(); } - getTipElement() { - if (this.tip) { - return this.tip; - } + setContent(tip) { + this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TITLE); - this.tip = super.getTipElement(); - - if (!this.getTitle()) { - SelectorEngine.findOne(SELECTOR_TITLE, this.tip).remove(); - } - - if (!this._getContent()) { - SelectorEngine.findOne(SELECTOR_CONTENT, this.tip).remove(); - } - - return this.tip; - } - - setContent() { - const tip = this.getTipElement(); // we use append for html objects to maintain js events - - this.setElementContent(SelectorEngine.findOne(SELECTOR_TITLE, tip), this.getTitle()); - - let content = this._getContent(); - - if (typeof content === 'function') { - content = content.call(this._element); - } - - this.setElementContent(SelectorEngine.findOne(SELECTOR_CONTENT, tip), content); - tip.classList.remove(CLASS_NAME_FADE$2, CLASS_NAME_SHOW$2); + this._sanitizeAndSetContent(tip, this._getContent(), SELECTOR_CONTENT); } // Private - _addAttachmentClass(attachment) { - this.getTipElement().classList.add(`${CLASS_PREFIX}-${this.updateAttachment(attachment)}`); - } - _getContent() { - return this._element.getAttribute('data-bs-content') || this._config.content; + return this._resolvePossibleFunction(this._config.content); } - _cleanTipClass() { - const tip = this.getTipElement(); - const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX); - - if (tabClass !== null && tabClass.length > 0) { - tabClass.map(token => token.trim()).forEach(tClass => tip.classList.remove(tClass)); - } + _getBasicClassPrefix() { + return CLASS_PREFIX; } // Static static jQueryInterface(config) { return this.each(function () { @@ -4315,11 +4336,11 @@ defineJQueryPlugin(Popover); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): scrollspy.js + * Bootstrap (v5.1.0): scrollspy.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -4349,10 +4370,11 @@ const SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]'; const SELECTOR_NAV_LIST_GROUP$1 = '.nav, .list-group'; const SELECTOR_NAV_LINKS = '.nav-link'; const SELECTOR_NAV_ITEMS = '.nav-item'; const SELECTOR_LIST_ITEMS = '.list-group-item'; + const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}, .${CLASS_NAME_DROPDOWN_ITEM}`; const SELECTOR_DROPDOWN$1 = '.dropdown'; const SELECTOR_DROPDOWN_TOGGLE$1 = '.dropdown-toggle'; const METHOD_OFFSET = 'offset'; const METHOD_POSITION = 'position'; /** @@ -4364,11 +4386,10 @@ class ScrollSpy extends BaseComponent { constructor(element, config) { super(element); this._scrollElement = this._element.tagName === 'BODY' ? window : this._element; this._config = this._getConfig(config); - this._selector = `${this._config.target} ${SELECTOR_NAV_LINKS}, ${this._config.target} ${SELECTOR_LIST_ITEMS}, ${this._config.target} .${CLASS_NAME_DROPDOWN_ITEM}`; this._offsets = []; this._targets = []; this._activeTarget = null; this._scrollHeight = 0; EventHandler.on(this._scrollElement, EVENT_SCROLL, () => this._process()); @@ -4392,11 +4413,11 @@ const offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method; const offsetBase = offsetMethod === METHOD_POSITION ? this._getScrollTop() : 0; this._offsets = []; this._targets = []; this._scrollHeight = this._getScrollHeight(); - const targets = SelectorEngine.find(this._selector); + const targets = SelectorEngine.find(SELECTOR_LINK_ITEMS, this._config.target); targets.map(element => { const targetSelector = getSelectorFromElement(element); const target = targetSelector ? SelectorEngine.findOne(targetSelector) : null; if (target) { @@ -4424,24 +4445,11 @@ _getConfig(config) { config = { ...Default$1, ...Manipulator.getDataAttributes(this._element), ...(typeof config === 'object' && config ? config : {}) }; - - if (typeof config.target !== 'string' && isElement(config.target)) { - let { - id - } = config.target; - - if (!id) { - id = getUID(NAME$2); - config.target.id = id; - } - - config.target = `#${id}`; - } - + config.target = getElement(config.target) || document.documentElement; typeCheckConfig(NAME$2, config, DefaultType$1); return config; } _getScrollTop() { @@ -4497,20 +4505,17 @@ _activate(target) { this._activeTarget = target; this._clear(); - const queries = this._selector.split(',').map(selector => `${selector}[data-bs-target="${target}"],${selector}[href="${target}"]`); + const queries = SELECTOR_LINK_ITEMS.split(',').map(selector => `${selector}[data-bs-target="${target}"],${selector}[href="${target}"]`); + const link = SelectorEngine.findOne(queries.join(','), this._config.target); + link.classList.add(CLASS_NAME_ACTIVE$1); - const link = SelectorEngine.findOne(queries.join(',')); - if (link.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) { SelectorEngine.findOne(SELECTOR_DROPDOWN_TOGGLE$1, link.closest(SELECTOR_DROPDOWN$1)).classList.add(CLASS_NAME_ACTIVE$1); - link.classList.add(CLASS_NAME_ACTIVE$1); } else { - // Set triggered link as active - link.classList.add(CLASS_NAME_ACTIVE$1); SelectorEngine.parents(link, SELECTOR_NAV_LIST_GROUP$1).forEach(listGroup => { // Set triggered links parents as active // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor SelectorEngine.prev(listGroup, `${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`).forEach(item => item.classList.add(CLASS_NAME_ACTIVE$1)); // Handle special case when .nav-link is inside .nav-item @@ -4524,11 +4529,11 @@ relatedTarget: target }); } _clear() { - SelectorEngine.find(this._selector).filter(node => node.classList.contains(CLASS_NAME_ACTIVE$1)).forEach(node => node.classList.remove(CLASS_NAME_ACTIVE$1)); + SelectorEngine.find(SELECTOR_LINK_ITEMS, this._config.target).filter(node => node.classList.contains(CLASS_NAME_ACTIVE$1)).forEach(node => node.classList.remove(CLASS_NAME_ACTIVE$1)); } // Static static jQueryInterface(config) { return this.each(function () { @@ -4566,11 +4571,11 @@ defineJQueryPlugin(ScrollSpy); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): tab.js + * Bootstrap (v5.1.0): tab.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -4764,11 +4769,11 @@ defineJQueryPlugin(Tab); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): toast.js + * Bootstrap (v5.1.0): toast.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -4777,21 +4782,21 @@ */ const NAME = 'toast'; const DATA_KEY = 'bs.toast'; const EVENT_KEY = `.${DATA_KEY}`; - const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY}`; const EVENT_MOUSEOVER = `mouseover${EVENT_KEY}`; const EVENT_MOUSEOUT = `mouseout${EVENT_KEY}`; const EVENT_FOCUSIN = `focusin${EVENT_KEY}`; const EVENT_FOCUSOUT = `focusout${EVENT_KEY}`; const EVENT_HIDE = `hide${EVENT_KEY}`; const EVENT_HIDDEN = `hidden${EVENT_KEY}`; const EVENT_SHOW = `show${EVENT_KEY}`; const EVENT_SHOWN = `shown${EVENT_KEY}`; const CLASS_NAME_FADE = 'fade'; - const CLASS_NAME_HIDE = 'hide'; + const CLASS_NAME_HIDE = 'hide'; // @deprecated - kept here only for backwards compatibility + const CLASS_NAME_SHOW = 'show'; const CLASS_NAME_SHOWING = 'showing'; const DefaultType = { animation: 'boolean', autohide: 'boolean', @@ -4800,11 +4805,10 @@ const Default = { animation: true, autohide: true, delay: 5000 }; - const SELECTOR_DATA_DISMISS = '[data-bs-dismiss="toast"]'; /** * ------------------------------------------------------------------------ * Class Definition * ------------------------------------------------------------------------ */ @@ -4848,21 +4852,22 @@ } const complete = () => { this._element.classList.remove(CLASS_NAME_SHOWING); - this._element.classList.add(CLASS_NAME_SHOW); - EventHandler.trigger(this._element, EVENT_SHOWN); this._maybeScheduleHide(); }; - this._element.classList.remove(CLASS_NAME_HIDE); + this._element.classList.remove(CLASS_NAME_HIDE); // @deprecated + reflow(this._element); + this._element.classList.add(CLASS_NAME_SHOW); + this._element.classList.add(CLASS_NAME_SHOWING); this._queueCallback(complete, this._element, this._config.animation); } @@ -4876,16 +4881,21 @@ if (hideEvent.defaultPrevented) { return; } const complete = () => { - this._element.classList.add(CLASS_NAME_HIDE); + this._element.classList.add(CLASS_NAME_HIDE); // @deprecated + + this._element.classList.remove(CLASS_NAME_SHOWING); + + this._element.classList.remove(CLASS_NAME_SHOW); + EventHandler.trigger(this._element, EVENT_HIDDEN); }; - this._element.classList.remove(CLASS_NAME_SHOW); + this._element.classList.add(CLASS_NAME_SHOWING); this._queueCallback(complete, this._element, this._config.animation); } dispose() { @@ -4949,11 +4959,10 @@ this._maybeScheduleHide(); } _setListeners() { - EventHandler.on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, () => this.hide()); EventHandler.on(this._element, EVENT_MOUSEOVER, event => this._onInteraction(event, true)); EventHandler.on(this._element, EVENT_MOUSEOUT, event => this._onInteraction(event, false)); EventHandler.on(this._element, EVENT_FOCUSIN, event => this._onInteraction(event, true)); EventHandler.on(this._element, EVENT_FOCUSOUT, event => this._onInteraction(event, false)); } @@ -4977,22 +4986,23 @@ } }); } } + + enableDismissTrigger(Toast); /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ * add .Toast to jQuery only if jQuery is present */ - defineJQueryPlugin(Toast); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.2): index.umd.js + * Bootstrap (v5.1.0): index.umd.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ var index_umd = { Alert,