Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@gmail.com>2021-05-13 19:22:20 +0300
committerGitHub <noreply@github.com>2021-05-13 19:22:20 +0300
commit58b1be927f43c779377e478df2d119f2ddf956ca (patch)
treef7c6a32eeade29ac9306c20ec6dcad505a347ee5 /dist/js/bootstrap.esm.js
parent130a5ba1df272916dcc66f3fe1a36cfedcb7667b (diff)
Release v5.0.1 (#33972)v5.0.1
* Bump version to 5.0.1. * Dist
Diffstat (limited to 'dist/js/bootstrap.esm.js')
-rw-r--r--dist/js/bootstrap.esm.js704
1 files changed, 328 insertions, 376 deletions
diff --git a/dist/js/bootstrap.esm.js b/dist/js/bootstrap.esm.js
index 47e5a5430e..5f180da33c 100644
--- a/dist/js/bootstrap.esm.js
+++ b/dist/js/bootstrap.esm.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)
*/
@@ -7,10 +7,82 @@ import * as Popper from '@popperjs/core';
/**
* --------------------------------------------------------------------------
- * 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)
@@ -103,7 +175,30 @@ const triggerTransitionEnd = element => {
element.dispatchEvent(new Event(TRANSITION_END));
};
-const isElement = obj => (obj[0] || obj).nodeType;
+const isElement = 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(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;
@@ -214,12 +309,13 @@ const onDOMContentLoaded = callback => {
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;
@@ -240,7 +336,7 @@ const execute = callback => {
/**
* --------------------------------------------------------------------------
- * 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)
* --------------------------------------------------------------------------
*/
@@ -294,7 +390,7 @@ var Data = {
/**
* --------------------------------------------------------------------------
- * 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)
* --------------------------------------------------------------------------
*/
@@ -583,7 +679,7 @@ const EventHandler = {
/**
* --------------------------------------------------------------------------
- * 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)
* --------------------------------------------------------------------------
*/
@@ -593,11 +689,11 @@ const EventHandler = {
* ------------------------------------------------------------------------
*/
-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;
@@ -609,8 +705,21 @@ class BaseComponent {
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 */
@@ -623,11 +732,23 @@ class BaseComponent {
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)
* --------------------------------------------------------------------------
*/
@@ -656,8 +777,8 @@ const CLASS_NAME_SHOW$9 = 'show';
class Alert extends BaseComponent {
// Getters
- static get DATA_KEY() {
- return DATA_KEY$b;
+ static get NAME() {
+ return NAME$c;
} // Public
@@ -684,16 +805,9 @@ class Alert extends BaseComponent {
_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) {
@@ -745,11 +859,11 @@ EventHandler.on(document, EVENT_CLICK_DATA_API$7, SELECTOR_DISMISS, Alert.handle
* 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)
* --------------------------------------------------------------------------
*/
@@ -774,8 +888,8 @@ const EVENT_CLICK_DATA_API$6 = `click${EVENT_KEY$a}${DATA_API_KEY$7}`;
class Button extends BaseComponent {
// Getters
- static get DATA_KEY() {
- return DATA_KEY$a;
+ static get NAME() {
+ return NAME$b;
} // Public
@@ -825,11 +939,11 @@ EventHandler.on(document, EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$5, event
* 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)
* --------------------------------------------------------------------------
*/
@@ -903,78 +1017,7 @@ const Manipulator = {
/**
* --------------------------------------------------------------------------
- * 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)
* --------------------------------------------------------------------------
*/
@@ -1075,8 +1118,8 @@ class Carousel extends BaseComponent {
return Default$9;
}
- static get DATA_KEY() {
- return DATA_KEY$9;
+ static get NAME() {
+ return NAME$a;
} // Public
@@ -1154,17 +1197,6 @@ class Carousel extends BaseComponent {
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
@@ -1393,37 +1425,35 @@ class Carousel extends BaseComponent {
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) {
@@ -1542,11 +1572,11 @@ EventHandler.on(window, EVENT_LOAD_DATA_API$2, () => {
* 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)
* --------------------------------------------------------------------------
*/
@@ -1623,8 +1653,8 @@ class Collapse extends BaseComponent {
return Default$8;
}
- static get DATA_KEY() {
- return DATA_KEY$8;
+ static get NAME() {
+ return NAME$9;
} // Public
@@ -1716,9 +1746,9 @@ class Collapse extends BaseComponent {
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`;
}
@@ -1769,21 +1799,12 @@ class Collapse extends BaseComponent {
};
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
@@ -1805,16 +1826,7 @@ class Collapse extends BaseComponent {
let {
parent
} = this._config;
-
- if (isElement(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);
@@ -1915,11 +1927,11 @@ EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$4, functi
* add .Collapse to jQuery only if jQuery is present
*/
-defineJQueryPlugin(NAME$9, Collapse);
+defineJQueryPlugin(Collapse);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.0): dropdown.js
+ * Bootstrap (v5.0.1): dropdown.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -2006,8 +2018,8 @@ class Dropdown extends BaseComponent {
return DefaultType$7;
}
- static get DATA_KEY() {
- return DATA_KEY$7;
+ static get NAME() {
+ return NAME$8;
} // Public
@@ -2054,11 +2066,7 @@ class Dropdown extends BaseComponent {
if (this._config.reference === 'parent') {
referenceElement = parent;
} else if (isElement(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;
}
@@ -2105,12 +2113,8 @@ class Dropdown extends BaseComponent {
}
dispose() {
- this._menu = null;
-
if (this._popper) {
this._popper.destroy();
-
- this._popper = null;
}
super.dispose();
@@ -2296,14 +2300,8 @@ class Dropdown extends BaseComponent {
}
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);
@@ -2329,10 +2327,10 @@ class Dropdown extends BaseComponent {
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;
}
@@ -2418,11 +2416,11 @@ EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$3, functi
* 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)
* --------------------------------------------------------------------------
*/
@@ -2496,7 +2494,7 @@ const _resetElementAttributes = (selector, styleProp) => {
/**
* --------------------------------------------------------------------------
- * 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)
* --------------------------------------------------------------------------
*/
@@ -2580,6 +2578,7 @@ class Backdrop {
config = { ...Default$6,
...(typeof config === 'object' ? config : {})
};
+ config.rootElement = config.rootElement || document.body;
typeCheckConfig(NAME$7, config, DefaultType$6);
return config;
}
@@ -2624,7 +2623,7 @@ class Backdrop {
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.0): modal.js
+ * Bootstrap (v5.0.1): modal.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -2654,7 +2653,7 @@ 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$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}`;
@@ -2691,8 +2690,8 @@ class Modal extends BaseComponent {
return Default$5;
}
- static get DATA_KEY() {
- return DATA_KEY$6;
+ static get NAME() {
+ return NAME$6;
} // Public
@@ -2766,24 +2765,21 @@ class Modal extends BaseComponent {
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`
@@ -2791,16 +2787,7 @@ class Modal extends BaseComponent {
* 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() {
@@ -2870,19 +2857,13 @@ class Modal extends BaseComponent {
});
};
- 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();
}
@@ -3066,11 +3047,11 @@ EventHandler.on(document, EVENT_CLICK_DATA_API$2, SELECTOR_DATA_TOGGLE$2, functi
* 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)
* --------------------------------------------------------------------------
*/
@@ -3102,7 +3083,7 @@ 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 = `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}`;
@@ -3125,12 +3106,12 @@ class Offcanvas extends BaseComponent {
} // 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
@@ -3176,9 +3157,7 @@ class Offcanvas extends BaseComponent {
});
};
- const transitionDuration = getTransitionDurationFromElement(this._element);
- EventHandler.one(this._element, 'transitionend', completeCallBack);
- emulateTransitionEnd(this._element, transitionDuration);
+ this._queueCallback(completeCallBack, this._element, true);
}
hide() {
@@ -3192,7 +3171,7 @@ class Offcanvas extends BaseComponent {
return;
}
- EventHandler.off(document, EVENT_FOCUSIN);
+ EventHandler.off(document, EVENT_FOCUSIN$1);
this._element.blur();
@@ -3218,18 +3197,14 @@ class Offcanvas extends BaseComponent {
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
@@ -3252,9 +3227,9 @@ class Offcanvas extends BaseComponent {
}
_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();
}
@@ -3332,11 +3307,11 @@ EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => {
* ------------------------------------------------------------------------
*/
-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)
* --------------------------------------------------------------------------
*/
@@ -3449,7 +3424,7 @@ function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) {
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.0): tooltip.js
+ * Bootstrap (v5.0.1): tooltip.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -3552,7 +3527,7 @@ class Tooltip extends BaseComponent {
this._activeTrigger = {};
this._popper = null; // Protected
- this.config = this._getConfig(config);
+ this._config = this._getConfig(config);
this.tip = null;
this._setListeners();
@@ -3567,18 +3542,10 @@ class Tooltip extends BaseComponent {
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
@@ -3630,18 +3597,10 @@ class Tooltip extends BaseComponent {
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();
}
@@ -3670,18 +3629,19 @@ class Tooltip extends BaseComponent {
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)) {
@@ -3696,7 +3656,7 @@ class Tooltip extends BaseComponent {
}
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(' '));
@@ -3722,13 +3682,9 @@ class Tooltip extends BaseComponent {
}
};
- 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() {
@@ -3776,14 +3732,9 @@ class Tooltip extends BaseComponent {
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 = '';
}
@@ -3805,7 +3756,7 @@ class Tooltip extends BaseComponent {
}
const element = document.createElement('div');
- element.innerHTML = this.config.template;
+ element.innerHTML = this._config.template;
this.tip = element.children[0];
return this.tip;
}
@@ -3821,13 +3772,10 @@ class Tooltip extends BaseComponent {
return;
}
- if (typeof content === 'object' && isElement(content)) {
- if (content.jquery) {
- content = content[0];
- } // content is a DOM node or a jQuery
+ if (isElement(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);
@@ -3839,9 +3787,9 @@ class Tooltip extends BaseComponent {
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;
@@ -3854,7 +3802,7 @@ class Tooltip extends BaseComponent {
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;
@@ -3888,7 +3836,7 @@ class Tooltip extends BaseComponent {
_getOffset() {
const {
offset
- } = this.config;
+ } = this._config;
if (typeof offset === 'string') {
return offset.split(',').map(val => Number.parseInt(val, 10));
@@ -3907,7 +3855,7 @@ class Tooltip extends BaseComponent {
modifiers: [{
name: 'flip',
options: {
- fallbackPlacements: this.config.fallbackPlacements
+ fallbackPlacements: this._config.fallbackPlacements
}
}, {
name: 'offset',
@@ -3917,7 +3865,7 @@ class Tooltip extends BaseComponent {
}, {
name: 'preventOverflow',
options: {
- boundary: this.config.boundary
+ boundary: this._config.boundary
}
}, {
name: 'arrow',
@@ -3937,7 +3885,7 @@ class Tooltip extends BaseComponent {
}
};
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)
};
}
@@ -3945,32 +3893,21 @@ class Tooltip extends BaseComponent {
this.getTipElement().classList.add(`${CLASS_PREFIX$1}-${this.updateAttachment(attachment)}`);
}
- _getContainer() {
- if (this.config.container === false) {
- return document.body;
- }
-
- if (isElement(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));
}
});
@@ -3982,8 +3919,8 @@ class Tooltip extends BaseComponent {
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: ''
};
@@ -4023,7 +3960,7 @@ class Tooltip extends BaseComponent {
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;
}
@@ -4032,7 +3969,7 @@ class Tooltip extends BaseComponent {
if (context._hoverState === HOVER_STATE_SHOW) {
context.show();
}
- }, context.config.delay.show);
+ }, context._config.delay.show);
}
_leave(event, context) {
@@ -4049,7 +3986,7 @@ class Tooltip extends BaseComponent {
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;
}
@@ -4058,7 +3995,7 @@ class Tooltip extends BaseComponent {
if (context._hoverState === HOVER_STATE_OUT) {
context.hide();
}
- }, context.config.delay.hide);
+ }, context._config.delay.hide);
}
_isWithActiveTrigger() {
@@ -4078,15 +4015,11 @@ class Tooltip extends BaseComponent {
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 = {
@@ -4115,10 +4048,10 @@ class Tooltip extends BaseComponent {
_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];
}
}
}
@@ -4185,11 +4118,11 @@ class Tooltip extends BaseComponent {
*/
-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)
* --------------------------------------------------------------------------
*/
@@ -4246,18 +4179,10 @@ class Popover extends Tooltip {
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
@@ -4288,7 +4213,7 @@ class Popover extends Tooltip {
}
_getContent() {
- return this._element.getAttribute('data-bs-content') || this.config.content;
+ return this._element.getAttribute('data-bs-content') || this._config.content;
}
_cleanTipClass() {
@@ -4335,11 +4260,11 @@ class Popover extends Tooltip {
*/
-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)
* --------------------------------------------------------------------------
*/
@@ -4404,8 +4329,8 @@ class ScrollSpy extends BaseComponent {
return Default$1;
}
- static get DATA_KEY() {
- return DATA_KEY$2;
+ static get NAME() {
+ return NAME$2;
} // Public
@@ -4438,15 +4363,8 @@ class ScrollSpy extends BaseComponent {
}
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
@@ -4593,11 +4511,11 @@ EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
* 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)
* --------------------------------------------------------------------------
*/
@@ -4635,8 +4553,8 @@ const SELECTOR_DROPDOWN_ACTIVE_CHILD = ':scope > .dropdown-menu .active';
class Tab extends BaseComponent {
// Getters
- static get DATA_KEY() {
- return DATA_KEY$1;
+ static get NAME() {
+ return NAME$1;
} // Public
@@ -4694,10 +4612,9 @@ class Tab extends BaseComponent {
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();
}
@@ -4792,11 +4709,11 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (
* 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)
* --------------------------------------------------------------------------
*/
@@ -4810,6 +4727,10 @@ 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}`;
@@ -4840,6 +4761,8 @@ class Toast extends BaseComponent {
super(element);
this._config = this._getConfig(config);
this._timeout = null;
+ this._hasMouseInteraction = false;
+ this._hasKeyboardInteraction = false;
this._setListeners();
} // Getters
@@ -4853,8 +4776,8 @@ class Toast extends BaseComponent {
return Default;
}
- static get DATA_KEY() {
- return DATA_KEY;
+ static get NAME() {
+ return NAME;
} // Public
@@ -4878,11 +4801,7 @@ class Toast extends BaseComponent {
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);
@@ -4891,13 +4810,7 @@ class Toast extends BaseComponent {
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() {
@@ -4919,13 +4832,7 @@ class Toast extends BaseComponent {
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() {
@@ -4936,7 +4843,6 @@ class Toast extends BaseComponent {
}
super.dispose();
- this._config = null;
} // Private
@@ -4949,8 +4855,54 @@ class Toast extends BaseComponent {
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() {
@@ -4988,7 +4940,7 @@ class Toast extends BaseComponent {
*/
-defineJQueryPlugin(NAME, Toast);
+defineJQueryPlugin(Toast);
export { Alert, Button, Carousel, Collapse, Dropdown, Modal, Offcanvas, Popover, ScrollSpy, Tab, Toast, Tooltip };
//# sourceMappingURL=bootstrap.esm.js.map