mirror of
https://github.com/twbs/bootstrap.git
synced 2024-11-29 11:24:18 +01:00
6e1f75f420
* Release v5.3.3 * Dist --------- Co-authored-by: XhmikosR <xhmikosr@gmail.com>
85 lines
2.8 KiB
JavaScript
85 lines
2.8 KiB
JavaScript
/*!
|
|
* Bootstrap base-component.js v5.3.3 (https://getbootstrap.com/)
|
|
* Copyright 2011-2024 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'), require('./util/config.js'), require('./util/index.js')) :
|
|
typeof define === 'function' && define.amd ? define(['./dom/data', './dom/event-handler', './util/config', './util/index'], factory) :
|
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.BaseComponent = factory(global.Data, global.EventHandler, global.Config, global.Index));
|
|
})(this, (function (Data, EventHandler, Config, index_js) { 'use strict';
|
|
|
|
/**
|
|
* --------------------------------------------------------------------------
|
|
* Bootstrap base-component.js
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
* --------------------------------------------------------------------------
|
|
*/
|
|
|
|
|
|
/**
|
|
* Constants
|
|
*/
|
|
|
|
const VERSION = '5.3.3';
|
|
|
|
/**
|
|
* Class definition
|
|
*/
|
|
|
|
class BaseComponent extends Config {
|
|
constructor(element, config) {
|
|
super();
|
|
element = index_js.getElement(element);
|
|
if (!element) {
|
|
return;
|
|
}
|
|
this._element = element;
|
|
this._config = this._getConfig(config);
|
|
Data.set(this._element, this.constructor.DATA_KEY, this);
|
|
}
|
|
|
|
// Public
|
|
dispose() {
|
|
Data.remove(this._element, this.constructor.DATA_KEY);
|
|
EventHandler.off(this._element, this.constructor.EVENT_KEY);
|
|
for (const propertyName of Object.getOwnPropertyNames(this)) {
|
|
this[propertyName] = null;
|
|
}
|
|
}
|
|
_queueCallback(callback, element, isAnimated = true) {
|
|
index_js.executeAfterTransition(callback, element, isAnimated);
|
|
}
|
|
_getConfig(config) {
|
|
config = this._mergeConfigObj(config, this._element);
|
|
config = this._configAfterMerge(config);
|
|
this._typeCheckConfig(config);
|
|
return config;
|
|
}
|
|
|
|
// Static
|
|
static getInstance(element) {
|
|
return Data.get(index_js.getElement(element), this.DATA_KEY);
|
|
}
|
|
static getOrCreateInstance(element, config = {}) {
|
|
return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null);
|
|
}
|
|
static get VERSION() {
|
|
return VERSION;
|
|
}
|
|
static get DATA_KEY() {
|
|
return `bs.${this.NAME}`;
|
|
}
|
|
static get EVENT_KEY() {
|
|
return `.${this.DATA_KEY}`;
|
|
}
|
|
static eventName(name) {
|
|
return `${name}${this.EVENT_KEY}`;
|
|
}
|
|
}
|
|
|
|
return BaseComponent;
|
|
|
|
}));
|
|
//# sourceMappingURL=base-component.js.map
|