1 | /*!
|
---|
2 | * Bootstrap base-component.js v5.3.3 (https://getbootstrap.com/)
|
---|
3 | * Copyright 2011-2024 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
---|
4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
---|
5 | */
|
---|
6 | (function (global, factory) {
|
---|
7 | 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')) :
|
---|
8 | typeof define === 'function' && define.amd ? define(['./dom/data', './dom/event-handler', './util/config', './util/index'], factory) :
|
---|
9 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.BaseComponent = factory(global.Data, global.EventHandler, global.Config, global.Index));
|
---|
10 | })(this, (function (Data, EventHandler, Config, index_js) { 'use strict';
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * --------------------------------------------------------------------------
|
---|
14 | * Bootstrap base-component.js
|
---|
15 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
---|
16 | * --------------------------------------------------------------------------
|
---|
17 | */
|
---|
18 |
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Constants
|
---|
22 | */
|
---|
23 |
|
---|
24 | const VERSION = '5.3.3';
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * Class definition
|
---|
28 | */
|
---|
29 |
|
---|
30 | class BaseComponent extends Config {
|
---|
31 | constructor(element, config) {
|
---|
32 | super();
|
---|
33 | element = index_js.getElement(element);
|
---|
34 | if (!element) {
|
---|
35 | return;
|
---|
36 | }
|
---|
37 | this._element = element;
|
---|
38 | this._config = this._getConfig(config);
|
---|
39 | Data.set(this._element, this.constructor.DATA_KEY, this);
|
---|
40 | }
|
---|
41 |
|
---|
42 | // Public
|
---|
43 | dispose() {
|
---|
44 | Data.remove(this._element, this.constructor.DATA_KEY);
|
---|
45 | EventHandler.off(this._element, this.constructor.EVENT_KEY);
|
---|
46 | for (const propertyName of Object.getOwnPropertyNames(this)) {
|
---|
47 | this[propertyName] = null;
|
---|
48 | }
|
---|
49 | }
|
---|
50 | _queueCallback(callback, element, isAnimated = true) {
|
---|
51 | index_js.executeAfterTransition(callback, element, isAnimated);
|
---|
52 | }
|
---|
53 | _getConfig(config) {
|
---|
54 | config = this._mergeConfigObj(config, this._element);
|
---|
55 | config = this._configAfterMerge(config);
|
---|
56 | this._typeCheckConfig(config);
|
---|
57 | return config;
|
---|
58 | }
|
---|
59 |
|
---|
60 | // Static
|
---|
61 | static getInstance(element) {
|
---|
62 | return Data.get(index_js.getElement(element), this.DATA_KEY);
|
---|
63 | }
|
---|
64 | static getOrCreateInstance(element, config = {}) {
|
---|
65 | return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null);
|
---|
66 | }
|
---|
67 | static get VERSION() {
|
---|
68 | return VERSION;
|
---|
69 | }
|
---|
70 | static get DATA_KEY() {
|
---|
71 | return `bs.${this.NAME}`;
|
---|
72 | }
|
---|
73 | static get EVENT_KEY() {
|
---|
74 | return `.${this.DATA_KEY}`;
|
---|
75 | }
|
---|
76 | static eventName(name) {
|
---|
77 | return `${name}${this.EVENT_KEY}`;
|
---|
78 | }
|
---|
79 | }
|
---|
80 |
|
---|
81 | return BaseComponent;
|
---|
82 |
|
---|
83 | }));
|
---|
84 | //# sourceMappingURL=base-component.js.map
|
---|