diff options
Diffstat (limited to 'dist/js/bootstrap.bundle.js')
-rw-r--r-- | dist/js/bootstrap.bundle.js | 706 |
1 files changed, 329 insertions, 377 deletions
diff --git a/dist/js/bootstrap.bundle.js b/dist/js/bootstrap.bundle.js index 27cf5047e8..852fc99625 100644 --- a/dist/js/bootstrap.bundle.js +++ b/dist/js/bootstrap.bundle.js @@ -1,5 +1,5 @@ /*! - * Bootstrap v5.0.0 (https://getbootstrap.com/) + * Bootstrap v5.0.1 (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) */ @@ -11,10 +11,82 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): util/index.js + * Bootstrap (v5.0.1): dom/selector-engine.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.1): 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) @@ -107,7 +179,30 @@ element.dispatchEvent(new Event(TRANSITION_END)); }; - const isElement$1 = obj => (obj[0] || obj).nodeType; + const isElement$1 = obj => { + if (!obj || typeof obj !== 'object') { + return false; + } + + if (typeof obj.jquery !== 'undefined') { + obj = obj[0]; + } + + return typeof obj.nodeType !== 'undefined'; + }; + + const getElement = obj => { + if (isElement$1(obj)) { + // 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 null; + }; const emulateTransitionEnd = (element, duration) => { let called = false; @@ -218,12 +313,13 @@ const isRTL = () => document.documentElement.dir === 'rtl'; - const defineJQueryPlugin = (name, plugin) => { + const defineJQueryPlugin = plugin => { onDOMContentLoaded(() => { const $ = getjQuery(); /* istanbul ignore if */ if ($) { + const name = plugin.NAME; const JQUERY_NO_CONFLICT = $.fn[name]; $.fn[name] = plugin.jQueryInterface; $.fn[name].Constructor = plugin; @@ -244,7 +340,7 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): dom/data.js + * Bootstrap (v5.0.1): dom/data.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -298,7 +394,7 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): dom/event-handler.js + * Bootstrap (v5.0.1): dom/event-handler.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -587,7 +683,7 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): base-component.js + * Bootstrap (v5.0.1): base-component.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -597,11 +693,11 @@ * ------------------------------------------------------------------------ */ - const VERSION = '5.0.0'; + const VERSION = '5.0.1'; class BaseComponent { constructor(element) { - element = typeof element === 'string' ? document.querySelector(element) : element; + element = getElement(element); if (!element) { return; @@ -613,8 +709,21 @@ dispose() { Data.remove(this._element, this.constructor.DATA_KEY); - EventHandler.off(this._element, `.${this.constructor.DATA_KEY}`); - this._element = null; + EventHandler.off(this._element, this.constructor.EVENT_KEY); + Object.getOwnPropertyNames(this).forEach(propertyName => { + this[propertyName] = null; + }); + } + + _queueCallback(callback, element, isAnimated = true) { + if (!isAnimated) { + execute(callback); + return; + } + + const transitionDuration = getTransitionDurationFromElement(element); + EventHandler.one(element, 'transitionend', () => execute(callback)); + emulateTransitionEnd(element, transitionDuration); } /** Static */ @@ -627,11 +736,23 @@ return VERSION; } + static get NAME() { + throw new Error('You have to implement the static method "NAME", for each component!'); + } + + static get DATA_KEY() { + return `bs.${this.NAME}`; + } + + static get EVENT_KEY() { + return `.${this.DATA_KEY}`; + } + } /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): alert.js + * Bootstrap (v5.0.1): alert.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -660,8 +781,8 @@ class Alert extends BaseComponent { // Getters - static get DATA_KEY() { - return DATA_KEY$b; + static get NAME() { + return NAME$c; } // Public @@ -688,16 +809,9 @@ _removeElement(element) { element.classList.remove(CLASS_NAME_SHOW$9); + const isAnimated = element.classList.contains(CLASS_NAME_FADE$6); - if (!element.classList.contains(CLASS_NAME_FADE$6)) { - this._destroyElement(element); - - return; - } - - const transitionDuration = getTransitionDurationFromElement(element); - EventHandler.one(element, 'transitionend', () => this._destroyElement(element)); - emulateTransitionEnd(element, transitionDuration); + this._queueCallback(() => this._destroyElement(element), element, isAnimated); } _destroyElement(element) { @@ -749,11 +863,11 @@ * add .Alert to jQuery only if jQuery is present */ - defineJQueryPlugin(NAME$c, Alert); + defineJQueryPlugin(Alert); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): button.js + * Bootstrap (v5.0.1): button.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -778,8 +892,8 @@ class Button extends BaseComponent { // Getters - static get DATA_KEY() { - return DATA_KEY$a; + static get NAME() { + return NAME$b; } // Public @@ -829,11 +943,11 @@ * add .Button to jQuery only if jQuery is present */ - defineJQueryPlugin(NAME$b, Button); + defineJQueryPlugin(Button); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): dom/manipulator.js + * Bootstrap (v5.0.1): dom/manipulator.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -907,78 +1021,7 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): dom/selector-engine.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.0): carousel.js + * Bootstrap (v5.0.1): carousel.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -1079,8 +1122,8 @@ return Default$9; } - static get DATA_KEY() { - return DATA_KEY$9; + static get NAME() { + return NAME$a; } // Public @@ -1158,17 +1201,6 @@ const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV; this._slide(order, this._items[index]); - } - - dispose() { - this._items = null; - this._config = null; - this._interval = null; - this._isPaused = null; - this._isSliding = null; - this._activeElement = null; - this._indicatorsElement = null; - super.dispose(); } // Private @@ -1397,37 +1429,35 @@ this._activeElement = nextElement; + const triggerSlidEvent = () => { + EventHandler.trigger(this._element, EVENT_SLID, { + relatedTarget: nextElement, + direction: eventDirectionName, + from: activeElementIndex, + to: nextElementIndex + }); + }; + if (this._element.classList.contains(CLASS_NAME_SLIDE)) { nextElement.classList.add(orderClassName); reflow(nextElement); activeElement.classList.add(directionalClassName); nextElement.classList.add(directionalClassName); - const transitionDuration = getTransitionDurationFromElement(activeElement); - EventHandler.one(activeElement, 'transitionend', () => { + + const completeCallBack = () => { nextElement.classList.remove(directionalClassName, orderClassName); nextElement.classList.add(CLASS_NAME_ACTIVE$2); activeElement.classList.remove(CLASS_NAME_ACTIVE$2, orderClassName, directionalClassName); this._isSliding = false; - setTimeout(() => { - EventHandler.trigger(this._element, EVENT_SLID, { - relatedTarget: nextElement, - direction: eventDirectionName, - from: activeElementIndex, - to: nextElementIndex - }); - }, 0); - }); - emulateTransitionEnd(activeElement, transitionDuration); + setTimeout(triggerSlidEvent, 0); + }; + + this._queueCallback(completeCallBack, activeElement, true); } else { activeElement.classList.remove(CLASS_NAME_ACTIVE$2); nextElement.classList.add(CLASS_NAME_ACTIVE$2); this._isSliding = false; - EventHandler.trigger(this._element, EVENT_SLID, { - relatedTarget: nextElement, - direction: eventDirectionName, - from: activeElementIndex, - to: nextElementIndex - }); + triggerSlidEvent(); } if (isCycling) { @@ -1546,11 +1576,11 @@ * add .Carousel to jQuery only if jQuery is present */ - defineJQueryPlugin(NAME$a, Carousel); + defineJQueryPlugin(Carousel); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): collapse.js + * Bootstrap (v5.0.1): collapse.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -1627,8 +1657,8 @@ return Default$8; } - static get DATA_KEY() { - return DATA_KEY$8; + static get NAME() { + return NAME$9; } // Public @@ -1720,9 +1750,9 @@ const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1); const scrollSize = `scroll${capitalizedDimension}`; - const transitionDuration = getTransitionDurationFromElement(this._element); - EventHandler.one(this._element, 'transitionend', complete); - emulateTransitionEnd(this._element, transitionDuration); + + this._queueCallback(complete, this._element, true); + this._element.style[dimension] = `${this._element[scrollSize]}px`; } @@ -1773,21 +1803,12 @@ }; this._element.style[dimension] = ''; - const transitionDuration = getTransitionDurationFromElement(this._element); - EventHandler.one(this._element, 'transitionend', complete); - emulateTransitionEnd(this._element, transitionDuration); + + this._queueCallback(complete, this._element, true); } setTransitioning(isTransitioning) { this._isTransitioning = isTransitioning; - } - - dispose() { - super.dispose(); - this._config = null; - this._parent = null; - this._triggerArray = null; - this._isTransitioning = null; } // Private @@ -1809,16 +1830,7 @@ let { parent } = this._config; - - if (isElement$1(parent)) { - // it's a jQuery object - if (typeof parent.jquery !== 'undefined' || typeof parent[0] !== 'undefined') { - parent = parent[0]; - } - } else { - parent = SelectorEngine.findOne(parent); - } - + parent = getElement(parent); const selector = `${SELECTOR_DATA_TOGGLE$4}[data-bs-parent="${parent}"]`; SelectorEngine.find(selector, parent).forEach(element => { const selected = getElementFromSelector(element); @@ -1919,7 +1931,7 @@ * add .Collapse to jQuery only if jQuery is present */ - defineJQueryPlugin(NAME$9, Collapse); + defineJQueryPlugin(Collapse); var top = 'top'; var bottom = 'bottom'; @@ -3677,7 +3689,7 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): dropdown.js + * Bootstrap (v5.0.1): dropdown.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -3764,8 +3776,8 @@ return DefaultType$7; } - static get DATA_KEY() { - return DATA_KEY$7; + static get NAME() { + return NAME$8; } // Public @@ -3812,11 +3824,7 @@ if (this._config.reference === 'parent') { referenceElement = parent; } else if (isElement$1(this._config.reference)) { - referenceElement = this._config.reference; // Check if it's jQuery element - - if (typeof this._config.reference.jquery !== 'undefined') { - referenceElement = this._config.reference[0]; - } + referenceElement = getElement(this._config.reference); } else if (typeof this._config.reference === 'object') { referenceElement = this._config.reference; } @@ -3863,12 +3871,8 @@ } dispose() { - this._menu = null; - if (this._popper) { this._popper.destroy(); - - this._popper = null; } super.dispose(); @@ -4054,14 +4058,8 @@ } static clearMenus(event) { - if (event) { - if (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY) { - return; - } - - if (/input|select|option|textarea|form/i.test(event.target.tagName)) { - return; - } + if (event && (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY)) { + return; } const toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE$3); @@ -4087,10 +4085,10 @@ if (composedPath.includes(context._element) || context._config.autoClose === 'inside' && !isMenuTarget || context._config.autoClose === 'outside' && isMenuTarget) { continue; - } // Tab navigation through the dropdown menu shouldn't close the menu + } // Tab navigation through the dropdown menu or events from contained inputs shouldn't close the menu - if (event.type === 'keyup' && event.key === TAB_KEY && context._menu.contains(event.target)) { + if (context._menu.contains(event.target) && (event.type === 'keyup' && event.key === TAB_KEY || /input|select|option|textarea|form/i.test(event.target.tagName))) { continue; } @@ -4176,11 +4174,11 @@ * add .Dropdown to jQuery only if jQuery is present */ - defineJQueryPlugin(NAME$8, Dropdown); + defineJQueryPlugin(Dropdown); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): util/scrollBar.js + * Bootstrap (v5.0.1): util/scrollBar.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -4254,7 +4252,7 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): util/backdrop.js + * Bootstrap (v5.0.1): util/backdrop.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -4338,6 +4336,7 @@ config = { ...Default$6, ...(typeof config === 'object' ? config : {}) }; + config.rootElement = config.rootElement || document.body; typeCheckConfig(NAME$7, config, DefaultType$6); return config; } @@ -4382,7 +4381,7 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): modal.js + * Bootstrap (v5.0.1): modal.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -4412,7 +4411,7 @@ 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$1 = `focusin${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_KEYDOWN_DISMISS$1 = `keydown.dismiss${EVENT_KEY$6}`; @@ -4449,8 +4448,8 @@ return Default$5; } - static get DATA_KEY() { - return DATA_KEY$6; + static get NAME() { + return NAME$6; } // Public @@ -4524,24 +4523,21 @@ this._setResizeEvent(); - EventHandler.off(document, EVENT_FOCUSIN$1); + EventHandler.off(document, EVENT_FOCUSIN$2); this._element.classList.remove(CLASS_NAME_SHOW$5); EventHandler.off(this._element, EVENT_CLICK_DISMISS$2); EventHandler.off(this._dialog, EVENT_MOUSEDOWN_DISMISS); - if (isAnimated) { - const transitionDuration = getTransitionDurationFromElement(this._element); - EventHandler.one(this._element, 'transitionend', event => this._hideModal(event)); - emulateTransitionEnd(this._element, transitionDuration); - } else { - this._hideModal(); - } + 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` @@ -4549,16 +4545,7 @@ * It will remove `EVENT_CLICK_DATA_API` event that should remain */ - EventHandler.off(document, EVENT_FOCUSIN$1); - this._config = null; - this._dialog = null; - - this._backdrop.dispose(); - - this._backdrop = null; - this._isShown = null; - this._ignoreBackdropClick = null; - this._isTransitioning = null; + EventHandler.off(document, EVENT_FOCUSIN$2); } handleUpdate() { @@ -4628,19 +4615,13 @@ }); }; - if (isAnimated) { - const transitionDuration = getTransitionDurationFromElement(this._dialog); - EventHandler.one(this._dialog, 'transitionend', transitionComplete); - emulateTransitionEnd(this._dialog, transitionDuration); - } else { - transitionComplete(); - } + this._queueCallback(transitionComplete, this._dialog, isAnimated); } _enforceFocus() { - EventHandler.off(document, EVENT_FOCUSIN$1); // guard against infinite focus loop + EventHandler.off(document, EVENT_FOCUSIN$2); // guard against infinite focus loop - EventHandler.on(document, EVENT_FOCUSIN$1, event => { + EventHandler.on(document, EVENT_FOCUSIN$2, event => { if (document !== event.target && this._element !== event.target && !this._element.contains(event.target)) { this._element.focus(); } @@ -4824,11 +4805,11 @@ * add .Modal to jQuery only if jQuery is present */ - defineJQueryPlugin(NAME$6, Modal); + defineJQueryPlugin(Modal); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): offcanvas.js + * Bootstrap (v5.0.1): offcanvas.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -4860,7 +4841,7 @@ 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 = `focusin${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}`; @@ -4883,12 +4864,12 @@ } // Getters - static get Default() { - return Default$4; + static get NAME() { + return NAME$5; } - static get DATA_KEY() { - return DATA_KEY$5; + static get Default() { + return Default$4; } // Public @@ -4934,9 +4915,7 @@ }); }; - const transitionDuration = getTransitionDurationFromElement(this._element); - EventHandler.one(this._element, 'transitionend', completeCallBack); - emulateTransitionEnd(this._element, transitionDuration); + this._queueCallback(completeCallBack, this._element, true); } hide() { @@ -4950,7 +4929,7 @@ return; } - EventHandler.off(document, EVENT_FOCUSIN); + EventHandler.off(document, EVENT_FOCUSIN$1); this._element.blur(); @@ -4976,18 +4955,14 @@ EventHandler.trigger(this._element, EVENT_HIDDEN$2); }; - const transitionDuration = getTransitionDurationFromElement(this._element); - EventHandler.one(this._element, 'transitionend', completeCallback); - emulateTransitionEnd(this._element, transitionDuration); + this._queueCallback(completeCallback, this._element, true); } dispose() { this._backdrop.dispose(); super.dispose(); - EventHandler.off(document, EVENT_FOCUSIN); - this._config = null; - this._backdrop = null; + EventHandler.off(document, EVENT_FOCUSIN$1); } // Private @@ -5010,9 +4985,9 @@ } _enforceFocusOnElement(element) { - EventHandler.off(document, EVENT_FOCUSIN); // guard against infinite focus loop + EventHandler.off(document, EVENT_FOCUSIN$1); // guard against infinite focus loop - EventHandler.on(document, EVENT_FOCUSIN, event => { + EventHandler.on(document, EVENT_FOCUSIN$1, event => { if (document !== event.target && element !== event.target && !element.contains(event.target)) { element.focus(); } @@ -5090,11 +5065,11 @@ * ------------------------------------------------------------------------ */ - defineJQueryPlugin(NAME$5, Offcanvas); + defineJQueryPlugin(Offcanvas); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): util/sanitizer.js + * Bootstrap (v5.0.1): util/sanitizer.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -5207,7 +5182,7 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): tooltip.js + * Bootstrap (v5.0.1): tooltip.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -5310,7 +5285,7 @@ this._activeTrigger = {}; this._popper = null; // Protected - this.config = this._getConfig(config); + this._config = this._getConfig(config); this.tip = null; this._setListeners(); @@ -5325,18 +5300,10 @@ return NAME$4; } - static get DATA_KEY() { - return DATA_KEY$4; - } - static get Event() { return Event$2; } - static get EVENT_KEY() { - return EVENT_KEY$4; - } - static get DefaultType() { return DefaultType$3; } // Public @@ -5388,18 +5355,10 @@ this.tip.parentNode.removeChild(this.tip); } - this._isEnabled = null; - this._timeout = null; - this._hoverState = null; - this._activeTrigger = null; - if (this._popper) { this._popper.destroy(); } - this._popper = null; - this.config = null; - this.tip = null; super.dispose(); } @@ -5428,18 +5387,19 @@ this.setContent(); - if (this.config.animation) { + if (this._config.animation) { tip.classList.add(CLASS_NAME_FADE$3); } - const placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this._element) : this.config.placement; + const placement = typeof this._config.placement === 'function' ? this._config.placement.call(this, tip, this._element) : this._config.placement; const attachment = this._getAttachment(placement); this._addAttachmentClass(attachment); - const container = this._getContainer(); - + const { + container + } = this._config; Data.set(tip, this.constructor.DATA_KEY, this); if (!this._element.ownerDocument.documentElement.contains(this.tip)) { @@ -5454,7 +5414,7 @@ } tip.classList.add(CLASS_NAME_SHOW$3); - const customClass = typeof this.config.customClass === 'function' ? this.config.customClass() : this.config.customClass; + const customClass = typeof this._config.customClass === 'function' ? this._config.customClass() : this._config.customClass; if (customClass) { tip.classList.add(...customClass.split(' ')); @@ -5480,13 +5440,9 @@ } }; - if (this.tip.classList.contains(CLASS_NAME_FADE$3)) { - const transitionDuration = getTransitionDurationFromElement(this.tip); - EventHandler.one(this.tip, 'transitionend', complete); - emulateTransitionEnd(this.tip, transitionDuration); - } else { - complete(); - } + const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE$3); + + this._queueCallback(complete, this.tip, isAnimated); } hide() { @@ -5534,14 +5490,9 @@ 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); - if (this.tip.classList.contains(CLASS_NAME_FADE$3)) { - const transitionDuration = getTransitionDurationFromElement(tip); - EventHandler.one(tip, 'transitionend', complete); - emulateTransitionEnd(tip, transitionDuration); - } else { - complete(); - } + this._queueCallback(complete, this.tip, isAnimated); this._hoverState = ''; } @@ -5563,7 +5514,7 @@ } const element = document.createElement('div'); - element.innerHTML = this.config.template; + element.innerHTML = this._config.template; this.tip = element.children[0]; return this.tip; } @@ -5579,13 +5530,10 @@ return; } - if (typeof content === 'object' && isElement$1(content)) { - if (content.jquery) { - content = content[0]; - } // content is a DOM node or a jQuery - + if (isElement$1(content)) { + content = getElement(content); // content is a DOM node or a jQuery - if (this.config.html) { + if (this._config.html) { if (content.parentNode !== element) { element.innerHTML = ''; element.appendChild(content); @@ -5597,9 +5545,9 @@ return; } - if (this.config.html) { - if (this.config.sanitize) { - content = sanitizeHtml(content, this.config.allowList, this.config.sanitizeFn); + if (this._config.html) { + if (this._config.sanitize) { + content = sanitizeHtml(content, this._config.allowList, this._config.sanitizeFn); } element.innerHTML = content; @@ -5612,7 +5560,7 @@ let title = this._element.getAttribute('data-bs-original-title'); if (!title) { - title = typeof this.config.title === 'function' ? this.config.title.call(this._element) : this.config.title; + title = typeof this._config.title === 'function' ? this._config.title.call(this._element) : this._config.title; } return title; @@ -5646,7 +5594,7 @@ _getOffset() { const { offset - } = this.config; + } = this._config; if (typeof offset === 'string') { return offset.split(',').map(val => Number.parseInt(val, 10)); @@ -5665,7 +5613,7 @@ modifiers: [{ name: 'flip', options: { - fallbackPlacements: this.config.fallbackPlacements + fallbackPlacements: this._config.fallbackPlacements } }, { name: 'offset', @@ -5675,7 +5623,7 @@ }, { name: 'preventOverflow', options: { - boundary: this.config.boundary + boundary: this._config.boundary } }, { name: 'arrow', @@ -5695,7 +5643,7 @@ } }; return { ...defaultBsPopperConfig, - ...(typeof this.config.popperConfig === 'function' ? this.config.popperConfig(defaultBsPopperConfig) : this.config.popperConfig) + ...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig) }; } @@ -5703,32 +5651,21 @@ this.getTipElement().classList.add(`${CLASS_PREFIX$1}-${this.updateAttachment(attachment)}`); } - _getContainer() { - if (this.config.container === false) { - return document.body; - } - - if (isElement$1(this.config.container)) { - return this.config.container; - } - - return SelectorEngine.findOne(this.config.container); - } - _getAttachment(placement) { return AttachmentMap[placement.toUpperCase()]; } _setListeners() { - const triggers = this.config.trigger.split(' '); + const triggers = this._config.trigger.split(' '); + triggers.forEach(trigger => { if (trigger === 'click') { - EventHandler.on(this._element, this.constructor.Event.CLICK, this.config.selector, event => this.toggle(event)); + EventHandler.on(this._element, this.constructor.Event.CLICK, this._config.selector, event => this.toggle(event)); } else if (trigger !== TRIGGER_MANUAL) { const eventIn = trigger === TRIGGER_HOVER ? this.constructor.Event.MOUSEENTER : this.constructor.Event.FOCUSIN; const eventOut = trigger === TRIGGER_HOVER ? this.constructor.Event.MOUSELEAVE : this.constructor.Event.FOCUSOUT; - EventHandler.on(this._element, eventIn, this.config.selector, event => this._enter(event)); - EventHandler.on(this._element, eventOut, this.config.selector, event => this._leave(event)); + EventHandler.on(this._element, eventIn, this._config.selector, event => this._enter(event)); + EventHandler.on(this._element, eventOut, this._config.selector, event => this._leave(event)); } }); @@ -5740,8 +5677,8 @@ EventHandler.on(this._element.closest(`.${CLASS_NAME_MODAL}`), 'hide.bs.modal', this._hideModalHandler); - if (this.config.selector) { - this.config = { ...this.config, + if (this._config.selector) { + this._config = { ...this._config, trigger: 'manual', selector: '' }; @@ -5781,7 +5718,7 @@ clearTimeout(context._timeout); context._hoverState = HOVER_STATE_SHOW; - if (!context.config.delay || !context.config.delay.show) { + if (!context._config.delay || !context._config.delay.show) { context.show(); return; } @@ -5790,7 +5727,7 @@ if (context._hoverState === HOVER_STATE_SHOW) { context.show(); } - }, context.config.delay.show); + }, context._config.delay.show); } _leave(event, context) { @@ -5807,7 +5744,7 @@ clearTimeout(context._timeout); context._hoverState = HOVER_STATE_OUT; - if (!context.config.delay || !context.config.delay.hide) { + if (!context._config.delay || !context._config.delay.hide) { context.hide(); return; } @@ -5816,7 +5753,7 @@ if (context._hoverState === HOVER_STATE_OUT) { context.hide(); } - }, context.config.delay.hide); + }, context._config.delay.hide); } _isWithActiveTrigger() { @@ -5836,15 +5773,11 @@ delete dataAttributes[dataAttr]; } }); - - if (config && typeof config.container === 'object' && config.container.jquery) { - config.container = config.container[0]; - } - config = { ...this.constructor.Default, ...dataAttributes, ...(typeof config === 'object' && config ? config : {}) }; + config.container = config.container === false ? document.body : getElement(config.container); if (typeof config.delay === 'number') { config.delay = { @@ -5873,10 +5806,10 @@ _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]; + if (this._config) { + for (const key in this._config) { + if (this.constructor.Default[key] !== this._config[key]) { + config[key] = this._config[key]; } } } @@ -5943,11 +5876,11 @@ */ - defineJQueryPlugin(NAME$4, Tooltip); + defineJQueryPlugin(Tooltip); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): popover.js + * Bootstrap (v5.0.1): popover.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -6004,18 +5937,10 @@ return NAME$3; } - static get DATA_KEY() { - return DATA_KEY$3; - } - static get Event() { return Event$1; } - static get EVENT_KEY() { - return EVENT_KEY$3; - } - static get DefaultType() { return DefaultType$2; } // Overrides @@ -6046,7 +5971,7 @@ } _getContent() { - return this._element.getAttribute('data-bs-content') || this.config.content; + return this._element.getAttribute('data-bs-content') || this._config.content; } _cleanTipClass() { @@ -6093,11 +6018,11 @@ */ - defineJQueryPlugin(NAME$3, Popover); + defineJQueryPlugin(Popover); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): scrollspy.js + * Bootstrap (v5.0.1): scrollspy.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -6162,8 +6087,8 @@ return Default$1; } - static get DATA_KEY() { - return DATA_KEY$2; + static get NAME() { + return NAME$2; } // Public @@ -6196,15 +6121,8 @@ } dispose() { - super.dispose(); EventHandler.off(this._scrollElement, EVENT_KEY$2); - this._scrollElement = null; - this._config = null; - this._selector = null; - this._offsets = null; - this._targets = null; - this._activeTarget = null; - this._scrollHeight = null; + super.dispose(); } // Private @@ -6351,11 +6269,11 @@ * add .ScrollSpy to jQuery only if jQuery is present */ - defineJQueryPlugin(NAME$2, ScrollSpy); + defineJQueryPlugin(ScrollSpy); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): tab.js + * Bootstrap (v5.0.1): tab.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -6393,8 +6311,8 @@ class Tab extends BaseComponent { // Getters - static get DATA_KEY() { - return DATA_KEY$1; + static get NAME() { + return NAME$1; } // Public @@ -6452,10 +6370,9 @@ const complete = () => this._transitionComplete(element, active, callback); if (active && isTransitioning) { - const transitionDuration = getTransitionDurationFromElement(active); active.classList.remove(CLASS_NAME_SHOW$1); - EventHandler.one(active, 'transitionend', complete); - emulateTransitionEnd(active, transitionDuration); + + this._queueCallback(complete, element, true); } else { complete(); } @@ -6550,11 +6467,11 @@ * add .Tab to jQuery only if jQuery is present */ - defineJQueryPlugin(NAME$1, Tab); + defineJQueryPlugin(Tab); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): toast.js + * Bootstrap (v5.0.1): toast.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -6568,6 +6485,10 @@ 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}`; @@ -6598,6 +6519,8 @@ super(element); this._config = this._getConfig(config); this._timeout = null; + this._hasMouseInteraction = false; + this._hasKeyboardInteraction = false; this._setListeners(); } // Getters @@ -6611,8 +6534,8 @@ return Default; } - static get DATA_KEY() { - return DATA_KEY; + static get NAME() { + return NAME; } // Public @@ -6636,11 +6559,7 @@ EventHandler.trigger(this._element, EVENT_SHOWN); - if (this._config.autohide) { - this._timeout = setTimeout(() => { - this.hide(); - }, this._config.delay); - } + this._maybeScheduleHide(); }; this._element.classList.remove(CLASS_NAME_HIDE); @@ -6649,13 +6568,7 @@ this._element.classList.add(CLASS_NAME_SHOWING); - if (this._config.animation) { - const transitionDuration = getTransitionDurationFromElement(this._element); - EventHandler.one(this._element, 'transitionend', complete); - emulateTransitionEnd(this._element, transitionDuration); - } else { - complete(); - } + this._queueCallback(complete, this._element, this._config.animation); } hide() { @@ -6677,13 +6590,7 @@ this._element.classList.remove(CLASS_NAME_SHOW); - if (this._config.animation) { - const transitionDuration = getTransitionDurationFromElement(this._element); - EventHandler.one(this._element, 'transitionend', complete); - emulateTransitionEnd(this._element, transitionDuration); - } else { - complete(); - } + this._queueCallback(complete, this._element, this._config.animation); } dispose() { @@ -6694,7 +6601,6 @@ } super.dispose(); - this._config = null; } // Private @@ -6707,8 +6613,54 @@ return config; } + _maybeScheduleHide() { + if (!this._config.autohide) { + return; + } + + if (this._hasMouseInteraction || this._hasKeyboardInteraction) { + return; + } + + this._timeout = setTimeout(() => { + this.hide(); + }, this._config.delay); + } + + _onInteraction(event, isInteracting) { + switch (event.type) { + case 'mouseover': + case 'mouseout': + this._hasMouseInteraction = isInteracting; + break; + + case 'focusin': + case 'focusout': + this._hasKeyboardInteraction = isInteracting; + break; + } + + if (isInteracting) { + this._clearTimeout(); + + return; + } + + const nextElement = event.relatedTarget; + + if (this._element === nextElement || this._element.contains(nextElement)) { + return; + } + + 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)); } _clearTimeout() { @@ -6746,11 +6698,11 @@ */ - defineJQueryPlugin(NAME, Toast); + defineJQueryPlugin(Toast); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.0): index.umd.js + * Bootstrap (v5.0.1): index.umd.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ |