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:
Diffstat (limited to 'js/dist/base-component.js')
-rw-r--r--js/dist/base-component.js157
1 files changed, 37 insertions, 120 deletions
diff --git a/js/dist/base-component.js b/js/dist/base-component.js
index efa333ba64..ec3ec5fe4c 100644
--- a/js/dist/base-component.js
+++ b/js/dist/base-component.js
@@ -1,158 +1,75 @@
/*!
- * Bootstrap base-component.js v5.1.3 (https://getbootstrap.com/)
- * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
+ * Bootstrap base-component.js v5.2.0-beta1 (https://getbootstrap.com/)
+ * Copyright 2011-2022 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('./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));
-})(this, (function (Data, EventHandler) { 'use strict';
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data'), require('./util/index'), require('./dom/event-handler'), require('./util/config')) :
+ typeof define === 'function' && define.amd ? define(['./dom/data', './util/index', './dom/event-handler', './util/config'], factory) :
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.BaseComponent = factory(global.Data, global.Index, global.EventHandler, global.Config));
+})(this, (function (Data, index, EventHandler, Config) { 'use strict';
const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
const Data__default = /*#__PURE__*/_interopDefaultLegacy(Data);
const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
+ const Config__default = /*#__PURE__*/_interopDefaultLegacy(Config);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.1.3): util/index.js
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
- * --------------------------------------------------------------------------
- */
- 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) {
- return document.querySelector(obj);
- }
-
- return null;
- };
-
- const execute = callback => {
- if (typeof callback === 'function') {
- callback();
- }
- };
-
- const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
- if (!waitForTransition) {
- execute(callback);
- return;
- }
-
- const durationPadding = 5;
- const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
- let called = false;
-
- const handler = ({
- target
- }) => {
- if (target !== transitionElement) {
- return;
- }
-
- called = true;
- transitionElement.removeEventListener(TRANSITION_END, handler);
- execute(callback);
- };
-
- transitionElement.addEventListener(TRANSITION_END, handler);
- setTimeout(() => {
- if (!called) {
- triggerTransitionEnd(transitionElement);
- }
- }, emulatedDuration);
- };
-
- /**
- * --------------------------------------------------------------------------
- * Bootstrap (v5.1.3): base-component.js
+ * Bootstrap (v5.2.0-beta1): base-component.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
- const VERSION = '5.1.3';
+ const VERSION = '5.2.0-beta1';
+ /**
+ * Class definition
+ */
- class BaseComponent {
- constructor(element) {
- element = getElement(element);
+ class BaseComponent extends Config__default.default {
+ constructor(element, config) {
+ super();
+ element = index.getElement(element);
if (!element) {
return;
}
this._element = element;
+ this._config = this._getConfig(config);
Data__default.default.set(this._element, this.constructor.DATA_KEY, this);
- }
+ } // Public
+
dispose() {
Data__default.default.remove(this._element, this.constructor.DATA_KEY);
EventHandler__default.default.off(this._element, this.constructor.EVENT_KEY);
- Object.getOwnPropertyNames(this).forEach(propertyName => {
+
+ for (const propertyName of Object.getOwnPropertyNames(this)) {
this[propertyName] = null;
- });
+ }
}
_queueCallback(callback, element, isAnimated = true) {
- executeAfterTransition(callback, element, isAnimated);
+ index.executeAfterTransition(callback, element, isAnimated);
}
- /** Static */
+
+ _getConfig(config) {
+ config = this._mergeConfigObj(config, this._element);
+ config = this._configAfterMerge(config);
+
+ this._typeCheckConfig(config);
+
+ return config;
+ } // Static
static getInstance(element) {
- return Data__default.default.get(getElement(element), this.DATA_KEY);
+ return Data__default.default.get(index.getElement(element), this.DATA_KEY);
}
static getOrCreateInstance(element, config = {}) {
@@ -163,10 +80,6 @@
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}`;
}
@@ -175,6 +88,10 @@
return `.${this.DATA_KEY}`;
}
+ static eventName(name) {
+ return `${name}${this.EVENT_KEY}`;
+ }
+
}
return BaseComponent;