2021-02-10 11:14:51 -05:00
|
|
|
/*!
|
2022-09-07 11:31:39 -04:00
|
|
|
* Bootstrap base-component.js v5.2.1 (https://getbootstrap.com/)
|
2022-05-13 02:07:23 -04:00
|
|
|
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
2021-02-10 11:14:51 -05:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
|
|
*/
|
|
|
|
(function (global, factory) {
|
2022-05-13 02:07:23 -04:00
|
|
|
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';
|
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);
|
2022-05-13 02:07:23 -04:00
|
|
|
const Config__default = /*#__PURE__*/_interopDefaultLegacy(Config);
|
2021-02-10 11:14:51 -05:00
|
|
|
|
2021-08-04 11:41:51 -04:00
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
2022-09-07 11:31:39 -04:00
|
|
|
* Bootstrap (v5.2.1): 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
|
|
|
|
*/
|
|
|
|
|
2022-09-07 11:31:39 -04:00
|
|
|
const VERSION = '5.2.1';
|
2022-05-13 02:07:23 -04:00
|
|
|
/**
|
|
|
|
* Class definition
|
|
|
|
*/
|
2021-03-23 12:26:54 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
class BaseComponent extends Config__default.default {
|
|
|
|
constructor(element, config) {
|
|
|
|
super();
|
|
|
|
element = index.getElement(element);
|
2021-02-10 11:14:51 -05:00
|
|
|
|
|
|
|
if (!element) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._element = element;
|
2022-05-13 02:07:23 -04:00
|
|
|
this._config = this._getConfig(config);
|
2021-10-05 11:50:18 -04:00
|
|
|
Data__default.default.set(this._element, this.constructor.DATA_KEY, this);
|
2022-05-13 02:07:23 -04:00
|
|
|
} // Public
|
|
|
|
|
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);
|
2022-05-13 02:07:23 -04:00
|
|
|
|
|
|
|
for (const propertyName of Object.getOwnPropertyNames(this)) {
|
2021-05-13 12:22:20 -04:00
|
|
|
this[propertyName] = null;
|
2022-05-13 02:07:23 -04:00
|
|
|
}
|
2021-05-13 12:22:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
_queueCallback(callback, element, isAnimated = true) {
|
2022-05-13 02:07:23 -04:00
|
|
|
index.executeAfterTransition(callback, element, isAnimated);
|
2021-02-10 11:14:51 -05:00
|
|
|
}
|
2022-05-13 02:07:23 -04:00
|
|
|
|
|
|
|
_getConfig(config) {
|
|
|
|
config = this._mergeConfigObj(config, this._element);
|
|
|
|
config = this._configAfterMerge(config);
|
|
|
|
|
|
|
|
this._typeCheckConfig(config);
|
|
|
|
|
|
|
|
return config;
|
|
|
|
} // Static
|
2021-02-10 11:14:51 -05:00
|
|
|
|
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
static getInstance(element) {
|
2022-05-13 02:07:23 -04:00
|
|
|
return Data__default.default.get(index.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 DATA_KEY() {
|
|
|
|
return `bs.${this.NAME}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
static get EVENT_KEY() {
|
|
|
|
return `.${this.DATA_KEY}`;
|
|
|
|
}
|
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
static eventName(name) {
|
|
|
|
return `${name}${this.EVENT_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
|