2021-02-10 11:14:51 -05:00
|
|
|
/*!
|
2021-10-05 11:50:18 -04:00
|
|
|
* Bootstrap base-component.js v5.1.2 (https://getbootstrap.com/)
|
2021-02-10 11:14:51 -05:00
|
|
|
* 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) {
|
2021-08-04 11:41:51 -04:00
|
|
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js')) :
|
|
|
|
typeof define === 'function' && define.amd ? define(['./dom/data', './dom/event-handler'], factory) :
|
|
|
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Base = factory(global.Data, global.EventHandler));
|
2021-10-05 11:50:18 -04:00
|
|
|
})(this, (function (Data, EventHandler) { 'use strict';
|
2021-02-10 11:14:51 -05:00
|
|
|
|
2021-10-05 11:50:18 -04:00
|
|
|
const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
|
2021-02-10 11:14:51 -05:00
|
|
|
|
2021-10-05 11:50:18 -04:00
|
|
|
const Data__default = /*#__PURE__*/_interopDefaultLegacy(Data);
|
|
|
|
const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
|
2021-02-10 11:14:51 -05:00
|
|
|
|
2021-08-04 11:41:51 -04:00
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
2021-10-05 11:50:18 -04:00
|
|
|
* Bootstrap (v5.1.2): util/index.js
|
2021-08-04 11:41:51 -04:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*/
|
2021-05-13 12:22:20 -04:00
|
|
|
const MILLISECONDS_MULTIPLIER = 1000;
|
|
|
|
const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
|
|
|
|
|
|
|
|
const getTransitionDurationFromElement = element => {
|
|
|
|
if (!element) {
|
|
|
|
return 0;
|
|
|
|
} // Get transition-duration of the element
|
|
|
|
|
|
|
|
|
|
|
|
let {
|
|
|
|
transitionDuration,
|
|
|
|
transitionDelay
|
|
|
|
} = window.getComputedStyle(element);
|
|
|
|
const floatTransitionDuration = Number.parseFloat(transitionDuration);
|
|
|
|
const floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
|
|
|
|
|
|
|
|
if (!floatTransitionDuration && !floatTransitionDelay) {
|
|
|
|
return 0;
|
|
|
|
} // If multiple durations are defined, take the first
|
|
|
|
|
|
|
|
|
|
|
|
transitionDuration = transitionDuration.split(',')[0];
|
|
|
|
transitionDelay = transitionDelay.split(',')[0];
|
|
|
|
return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
|
|
|
|
};
|
|
|
|
|
|
|
|
const triggerTransitionEnd = element => {
|
|
|
|
element.dispatchEvent(new Event(TRANSITION_END));
|
|
|
|
};
|
|
|
|
|
|
|
|
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) {
|
2021-08-04 11:41:51 -04:00
|
|
|
return document.querySelector(obj);
|
2021-05-13 12:22:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
2021-06-22 14:29:16 -04:00
|
|
|
const execute = callback => {
|
|
|
|
if (typeof callback === 'function') {
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
|
|
|
|
if (!waitForTransition) {
|
|
|
|
execute(callback);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-05-13 12:22:20 -04:00
|
|
|
const durationPadding = 5;
|
2021-06-22 14:29:16 -04:00
|
|
|
const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
|
|
|
|
let called = false;
|
|
|
|
|
|
|
|
const handler = ({
|
|
|
|
target
|
|
|
|
}) => {
|
|
|
|
if (target !== transitionElement) {
|
|
|
|
return;
|
|
|
|
}
|
2021-05-13 12:22:20 -04:00
|
|
|
|
|
|
|
called = true;
|
2021-06-22 14:29:16 -04:00
|
|
|
transitionElement.removeEventListener(TRANSITION_END, handler);
|
|
|
|
execute(callback);
|
|
|
|
};
|
2021-05-13 12:22:20 -04:00
|
|
|
|
2021-06-22 14:29:16 -04:00
|
|
|
transitionElement.addEventListener(TRANSITION_END, handler);
|
2021-05-13 12:22:20 -04:00
|
|
|
setTimeout(() => {
|
|
|
|
if (!called) {
|
2021-06-22 14:29:16 -04:00
|
|
|
triggerTransitionEnd(transitionElement);
|
2021-05-13 12:22:20 -04:00
|
|
|
}
|
|
|
|
}, emulatedDuration);
|
|
|
|
};
|
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
2021-10-05 11:50:18 -04:00
|
|
|
* Bootstrap (v5.1.2): base-component.js
|
2021-03-23 12:26:54 -04:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*/
|
2021-02-10 11:14:51 -05:00
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
* Constants
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2021-10-05 11:50:18 -04:00
|
|
|
const VERSION = '5.1.2';
|
2021-03-23 12:26:54 -04:00
|
|
|
|
|
|
|
class BaseComponent {
|
|
|
|
constructor(element) {
|
2021-05-13 12:22:20 -04:00
|
|
|
element = getElement(element);
|
2021-02-10 11:14:51 -05:00
|
|
|
|
|
|
|
if (!element) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._element = element;
|
2021-10-05 11:50:18 -04:00
|
|
|
Data__default.default.set(this._element, this.constructor.DATA_KEY, this);
|
2021-02-10 11:14:51 -05:00
|
|
|
}
|
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
dispose() {
|
2021-10-05 11:50:18 -04:00
|
|
|
Data__default.default.remove(this._element, this.constructor.DATA_KEY);
|
|
|
|
EventHandler__default.default.off(this._element, this.constructor.EVENT_KEY);
|
2021-05-13 12:22:20 -04:00
|
|
|
Object.getOwnPropertyNames(this).forEach(propertyName => {
|
|
|
|
this[propertyName] = null;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_queueCallback(callback, element, isAnimated = true) {
|
2021-06-22 14:29:16 -04:00
|
|
|
executeAfterTransition(callback, element, isAnimated);
|
2021-02-10 11:14:51 -05:00
|
|
|
}
|
|
|
|
/** Static */
|
|
|
|
|
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
static getInstance(element) {
|
2021-10-05 11:50:18 -04:00
|
|
|
return Data__default.default.get(getElement(element), this.DATA_KEY);
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2021-02-10 11:14:51 -05:00
|
|
|
|
2021-06-22 14:29:16 -04:00
|
|
|
static getOrCreateInstance(element, config = {}) {
|
|
|
|
return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null);
|
|
|
|
}
|
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
static get VERSION() {
|
|
|
|
return VERSION;
|
|
|
|
}
|
|
|
|
|
2021-05-13 12:22:20 -04:00
|
|
|
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}`;
|
|
|
|
}
|
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2021-02-10 11:14:51 -05:00
|
|
|
|
|
|
|
return BaseComponent;
|
|
|
|
|
2021-10-05 11:50:18 -04:00
|
|
|
}));
|
2021-02-10 11:14:51 -05:00
|
|
|
//# sourceMappingURL=base-component.js.map
|