2021-02-10 17:14:51 +01:00
|
|
|
/*!
|
2024-02-20 16:14:29 +01:00
|
|
|
* Bootstrap base-component.js v5.3.3 (https://getbootstrap.com/)
|
|
|
|
* Copyright 2011-2024 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
2021-02-10 17:14:51 +01:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
|
|
*/
|
|
|
|
(function (global, factory) {
|
2023-04-03 09:26:50 +02:00
|
|
|
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';
|
2021-02-10 17:14:51 +01:00
|
|
|
|
2021-08-04 17:41:51 +02:00
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
2023-03-24 15:30:16 +01:00
|
|
|
* Bootstrap base-component.js
|
2021-03-23 17:26:54 +01:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*/
|
2022-12-24 17:37:22 +01:00
|
|
|
|
2023-05-30 17:15:55 +02:00
|
|
|
|
2021-02-10 17:14:51 +01:00
|
|
|
/**
|
|
|
|
* Constants
|
|
|
|
*/
|
|
|
|
|
2024-02-20 16:14:29 +01:00
|
|
|
const VERSION = '5.3.3';
|
2022-12-24 17:37:22 +01:00
|
|
|
|
2022-05-13 08:07:23 +02:00
|
|
|
/**
|
|
|
|
* Class definition
|
|
|
|
*/
|
2021-03-23 17:26:54 +01:00
|
|
|
|
2022-12-24 17:37:22 +01:00
|
|
|
class BaseComponent extends Config {
|
2022-05-13 08:07:23 +02:00
|
|
|
constructor(element, config) {
|
|
|
|
super();
|
2022-12-24 17:37:22 +01:00
|
|
|
element = index_js.getElement(element);
|
2021-02-10 17:14:51 +01:00
|
|
|
if (!element) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this._element = element;
|
2022-05-13 08:07:23 +02:00
|
|
|
this._config = this._getConfig(config);
|
2022-12-24 17:37:22 +01:00
|
|
|
Data.set(this._element, this.constructor.DATA_KEY, this);
|
|
|
|
}
|
2021-02-10 17:14:51 +01:00
|
|
|
|
2022-12-24 17:37:22 +01:00
|
|
|
// Public
|
2021-03-23 17:26:54 +01:00
|
|
|
dispose() {
|
2022-12-24 17:37:22 +01:00
|
|
|
Data.remove(this._element, this.constructor.DATA_KEY);
|
|
|
|
EventHandler.off(this._element, this.constructor.EVENT_KEY);
|
2022-05-13 08:07:23 +02:00
|
|
|
for (const propertyName of Object.getOwnPropertyNames(this)) {
|
2021-05-13 18:22:20 +02:00
|
|
|
this[propertyName] = null;
|
2022-05-13 08:07:23 +02:00
|
|
|
}
|
2021-05-13 18:22:20 +02:00
|
|
|
}
|
|
|
|
_queueCallback(callback, element, isAnimated = true) {
|
2022-12-24 17:37:22 +01:00
|
|
|
index_js.executeAfterTransition(callback, element, isAnimated);
|
2021-02-10 17:14:51 +01:00
|
|
|
}
|
2022-05-13 08:07:23 +02:00
|
|
|
_getConfig(config) {
|
|
|
|
config = this._mergeConfigObj(config, this._element);
|
|
|
|
config = this._configAfterMerge(config);
|
|
|
|
this._typeCheckConfig(config);
|
|
|
|
return config;
|
2022-12-24 17:37:22 +01:00
|
|
|
}
|
2021-02-10 17:14:51 +01:00
|
|
|
|
2022-12-24 17:37:22 +01:00
|
|
|
// Static
|
2021-03-23 17:26:54 +01:00
|
|
|
static getInstance(element) {
|
2022-12-24 17:37:22 +01:00
|
|
|
return Data.get(index_js.getElement(element), this.DATA_KEY);
|
2021-03-23 17:26:54 +01:00
|
|
|
}
|
2021-06-22 20:29:16 +02:00
|
|
|
static getOrCreateInstance(element, config = {}) {
|
|
|
|
return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null);
|
|
|
|
}
|
2021-03-23 17:26:54 +01:00
|
|
|
static get VERSION() {
|
|
|
|
return VERSION;
|
|
|
|
}
|
2021-05-13 18:22:20 +02:00
|
|
|
static get DATA_KEY() {
|
|
|
|
return `bs.${this.NAME}`;
|
|
|
|
}
|
|
|
|
static get EVENT_KEY() {
|
|
|
|
return `.${this.DATA_KEY}`;
|
|
|
|
}
|
2022-05-13 08:07:23 +02:00
|
|
|
static eventName(name) {
|
|
|
|
return `${name}${this.EVENT_KEY}`;
|
|
|
|
}
|
2021-03-23 17:26:54 +01:00
|
|
|
}
|
2021-02-10 17:14:51 +01:00
|
|
|
|
|
|
|
return BaseComponent;
|
|
|
|
|
2021-10-05 17:50:18 +02:00
|
|
|
}));
|
2021-02-10 17:14:51 +01:00
|
|
|
//# sourceMappingURL=base-component.js.map
|