bootstrap 5.0.0 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/assets/javascripts/bootstrap/alert.js +77 -106
  4. data/assets/javascripts/bootstrap/base-component.js +126 -7
  5. data/assets/javascripts/bootstrap/button.js +24 -24
  6. data/assets/javascripts/bootstrap/carousel.js +115 -128
  7. data/assets/javascripts/bootstrap/collapse.js +119 -176
  8. data/assets/javascripts/bootstrap/dom/data.js +2 -2
  9. data/assets/javascripts/bootstrap/dom/event-handler.js +3 -4
  10. data/assets/javascripts/bootstrap/dom/manipulator.js +4 -4
  11. data/assets/javascripts/bootstrap/dom/selector-engine.js +47 -5
  12. data/assets/javascripts/bootstrap/dropdown.js +142 -130
  13. data/assets/javascripts/bootstrap/modal.js +376 -171
  14. data/assets/javascripts/bootstrap/offcanvas.js +328 -133
  15. data/assets/javascripts/bootstrap/popover.js +27 -59
  16. data/assets/javascripts/bootstrap/scrollspy.js +51 -56
  17. data/assets/javascripts/bootstrap/tab.js +39 -66
  18. data/assets/javascripts/bootstrap/toast.js +175 -86
  19. data/assets/javascripts/bootstrap/tooltip.js +141 -185
  20. data/assets/javascripts/bootstrap-sprockets.js +6 -6
  21. data/assets/javascripts/bootstrap.js +1031 -1026
  22. data/assets/javascripts/bootstrap.min.js +2 -2
  23. data/assets/stylesheets/_bootstrap-grid.scss +3 -1
  24. data/assets/stylesheets/_bootstrap-reboot.scss +2 -4
  25. data/assets/stylesheets/_bootstrap.scss +2 -1
  26. data/assets/stylesheets/bootstrap/_card.scss +7 -6
  27. data/assets/stylesheets/bootstrap/_carousel.scss +2 -2
  28. data/assets/stylesheets/bootstrap/_dropdown.scss +4 -4
  29. data/assets/stylesheets/bootstrap/_functions.scss +100 -3
  30. data/assets/stylesheets/bootstrap/_grid.scss +11 -0
  31. data/assets/stylesheets/bootstrap/_helpers.scss +2 -0
  32. data/assets/stylesheets/bootstrap/_images.scss +1 -1
  33. data/assets/stylesheets/bootstrap/_list-group.scss +5 -5
  34. data/assets/stylesheets/bootstrap/_mixins.scss +1 -0
  35. data/assets/stylesheets/bootstrap/_modal.scss +7 -26
  36. data/assets/stylesheets/bootstrap/_navbar.scss +30 -1
  37. data/assets/stylesheets/bootstrap/_offcanvas.scss +8 -2
  38. data/assets/stylesheets/bootstrap/_placeholders.scss +51 -0
  39. data/assets/stylesheets/bootstrap/_popover.scss +10 -10
  40. data/assets/stylesheets/bootstrap/_reboot.scss +12 -8
  41. data/assets/stylesheets/bootstrap/_root.scss +40 -2
  42. data/assets/stylesheets/bootstrap/_tables.scss +1 -0
  43. data/assets/stylesheets/bootstrap/_toasts.scss +3 -3
  44. data/assets/stylesheets/bootstrap/_tooltip.scss +4 -4
  45. data/assets/stylesheets/bootstrap/_transitions.scss +6 -0
  46. data/assets/stylesheets/bootstrap/_utilities.scss +44 -8
  47. data/assets/stylesheets/bootstrap/_variables.scss +200 -25
  48. data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +1 -1
  49. data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +3 -1
  50. data/assets/stylesheets/bootstrap/forms/_form-check.scss +1 -1
  51. data/assets/stylesheets/bootstrap/forms/_form-control.scss +6 -6
  52. data/assets/stylesheets/bootstrap/forms/_form-range.scss +1 -1
  53. data/assets/stylesheets/bootstrap/forms/_form-select.scss +3 -0
  54. data/assets/stylesheets/bootstrap/helpers/_stacks.scss +15 -0
  55. data/assets/stylesheets/bootstrap/helpers/_vr.scss +8 -0
  56. data/assets/stylesheets/bootstrap/mixins/_backdrop.scss +14 -0
  57. data/assets/stylesheets/bootstrap/mixins/_buttons.scss +1 -1
  58. data/assets/stylesheets/bootstrap/mixins/_forms.scss +8 -1
  59. data/assets/stylesheets/bootstrap/mixins/_grid.scss +33 -8
  60. data/assets/stylesheets/bootstrap/mixins/_utilities.scss +27 -6
  61. data/assets/stylesheets/bootstrap/vendor/_rfs.scss +55 -13
  62. data/bootstrap.gemspec +3 -3
  63. data/lib/bootstrap/version.rb +2 -2
  64. data/tasks/updater/js.rb +6 -2
  65. metadata +12 -8
@@ -1,23 +1,21 @@
1
1
  /*!
2
- * Bootstrap popover.js v5.0.0 (https://getbootstrap.com/)
2
+ * Bootstrap popover.js v5.1.1 (https://getbootstrap.com/)
3
3
  * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
4
4
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
5
  */
6
6
  (function (global, factory) {
7
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/selector-engine.js'), require('./tooltip.js')) :
8
- typeof define === 'function' && define.amd ? define(['./dom/data', './dom/selector-engine', './tooltip'], factory) :
9
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Popover = factory(global.Data, global.SelectorEngine, global.Tooltip));
10
- }(this, (function (Data, SelectorEngine, Tooltip) { 'use strict';
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./tooltip.js')) :
8
+ typeof define === 'function' && define.amd ? define(['./tooltip'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Popover = factory(global.Tooltip));
10
+ }(this, (function (Tooltip) { 'use strict';
11
11
 
12
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
13
 
14
- var Data__default = /*#__PURE__*/_interopDefaultLegacy(Data);
15
- var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
16
14
  var Tooltip__default = /*#__PURE__*/_interopDefaultLegacy(Tooltip);
17
15
 
18
16
  /**
19
17
  * --------------------------------------------------------------------------
20
- * Bootstrap (v5.0.0): util/index.js
18
+ * Bootstrap (v5.1.1): util/index.js
21
19
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
22
20
  * --------------------------------------------------------------------------
23
21
  */
@@ -34,20 +32,30 @@
34
32
  return null;
35
33
  };
36
34
 
35
+ const DOMContentLoadedCallbacks = [];
36
+
37
37
  const onDOMContentLoaded = callback => {
38
38
  if (document.readyState === 'loading') {
39
- document.addEventListener('DOMContentLoaded', callback);
39
+ // add listener on the first call when the document is in loading state
40
+ if (!DOMContentLoadedCallbacks.length) {
41
+ document.addEventListener('DOMContentLoaded', () => {
42
+ DOMContentLoadedCallbacks.forEach(callback => callback());
43
+ });
44
+ }
45
+
46
+ DOMContentLoadedCallbacks.push(callback);
40
47
  } else {
41
48
  callback();
42
49
  }
43
50
  };
44
51
 
45
- const defineJQueryPlugin = (name, plugin) => {
52
+ const defineJQueryPlugin = plugin => {
46
53
  onDOMContentLoaded(() => {
47
54
  const $ = getjQuery();
48
55
  /* istanbul ignore if */
49
56
 
50
57
  if ($) {
58
+ const name = plugin.NAME;
51
59
  const JQUERY_NO_CONFLICT = $.fn[name];
52
60
  $.fn[name] = plugin.jQueryInterface;
53
61
  $.fn[name].Constructor = plugin;
@@ -62,7 +70,7 @@
62
70
 
63
71
  /**
64
72
  * --------------------------------------------------------------------------
65
- * Bootstrap (v5.0.0): popover.js
73
+ * Bootstrap (v5.1.1): popover.js
66
74
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
67
75
  * --------------------------------------------------------------------------
68
76
  */
@@ -76,7 +84,6 @@
76
84
  const DATA_KEY = 'bs.popover';
77
85
  const EVENT_KEY = `.${DATA_KEY}`;
78
86
  const CLASS_PREFIX = 'bs-popover';
79
- const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g');
80
87
  const Default = { ...Tooltip__default['default'].Default,
81
88
  placement: 'right',
82
89
  offset: [0, 8],
@@ -99,8 +106,6 @@
99
106
  MOUSEENTER: `mouseenter${EVENT_KEY}`,
100
107
  MOUSELEAVE: `mouseleave${EVENT_KEY}`
101
108
  };
102
- const CLASS_NAME_FADE = 'fade';
103
- const CLASS_NAME_SHOW = 'show';
104
109
  const SELECTOR_TITLE = '.popover-header';
105
110
  const SELECTOR_CONTENT = '.popover-body';
106
111
  /**
@@ -119,18 +124,10 @@
119
124
  return NAME;
120
125
  }
121
126
 
122
- static get DATA_KEY() {
123
- return DATA_KEY;
124
- }
125
-
126
127
  static get Event() {
127
128
  return Event;
128
129
  }
129
130
 
130
- static get EVENT_KEY() {
131
- return EVENT_KEY;
132
- }
133
-
134
131
  static get DefaultType() {
135
132
  return DefaultType;
136
133
  } // Overrides
@@ -140,54 +137,25 @@
140
137
  return this.getTitle() || this._getContent();
141
138
  }
142
139
 
143
- setContent() {
144
- const tip = this.getTipElement(); // we use append for html objects to maintain js events
145
-
146
- this.setElementContent(SelectorEngine__default['default'].findOne(SELECTOR_TITLE, tip), this.getTitle());
147
-
148
- let content = this._getContent();
149
-
150
- if (typeof content === 'function') {
151
- content = content.call(this._element);
152
- }
140
+ setContent(tip) {
141
+ this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TITLE);
153
142
 
154
- this.setElementContent(SelectorEngine__default['default'].findOne(SELECTOR_CONTENT, tip), content);
155
- tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW);
143
+ this._sanitizeAndSetContent(tip, this._getContent(), SELECTOR_CONTENT);
156
144
  } // Private
157
145
 
158
146
 
159
- _addAttachmentClass(attachment) {
160
- this.getTipElement().classList.add(`${CLASS_PREFIX}-${this.updateAttachment(attachment)}`);
161
- }
162
-
163
147
  _getContent() {
164
- return this._element.getAttribute('data-bs-content') || this.config.content;
148
+ return this._resolvePossibleFunction(this._config.content);
165
149
  }
166
150
 
167
- _cleanTipClass() {
168
- const tip = this.getTipElement();
169
- const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX);
170
-
171
- if (tabClass !== null && tabClass.length > 0) {
172
- tabClass.map(token => token.trim()).forEach(tClass => tip.classList.remove(tClass));
173
- }
151
+ _getBasicClassPrefix() {
152
+ return CLASS_PREFIX;
174
153
  } // Static
175
154
 
176
155
 
177
156
  static jQueryInterface(config) {
178
157
  return this.each(function () {
179
- let data = Data__default['default'].get(this, DATA_KEY);
180
-
181
- const _config = typeof config === 'object' ? config : null;
182
-
183
- if (!data && /dispose|hide/.test(config)) {
184
- return;
185
- }
186
-
187
- if (!data) {
188
- data = new Popover(this, _config);
189
- Data__default['default'].set(this, DATA_KEY, data);
190
- }
158
+ const data = Popover.getOrCreateInstance(this, config);
191
159
 
192
160
  if (typeof config === 'string') {
193
161
  if (typeof data[config] === 'undefined') {
@@ -208,7 +176,7 @@
208
176
  */
209
177
 
210
178
 
211
- defineJQueryPlugin(NAME, Popover);
179
+ defineJQueryPlugin(Popover);
212
180
 
213
181
  return Popover;
214
182
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Bootstrap scrollspy.js v5.0.0 (https://getbootstrap.com/)
2
+ * Bootstrap scrollspy.js v5.1.1 (https://getbootstrap.com/)
3
3
  * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
4
4
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
5
  */
@@ -18,11 +18,10 @@
18
18
 
19
19
  /**
20
20
  * --------------------------------------------------------------------------
21
- * Bootstrap (v5.0.0): util/index.js
21
+ * Bootstrap (v5.1.1): util/index.js
22
22
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
23
23
  * --------------------------------------------------------------------------
24
24
  */
25
- const MAX_UID = 1000000;
26
25
 
27
26
  const toType = obj => {
28
27
  if (obj === null || obj === undefined) {
@@ -31,20 +30,6 @@
31
30
 
32
31
  return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
33
32
  };
34
- /**
35
- * --------------------------------------------------------------------------
36
- * Public Util Api
37
- * --------------------------------------------------------------------------
38
- */
39
-
40
-
41
- const getUID = prefix => {
42
- do {
43
- prefix += Math.floor(Math.random() * MAX_UID);
44
- } while (document.getElementById(prefix));
45
-
46
- return prefix;
47
- };
48
33
 
49
34
  const getSelector = element => {
50
35
  let selector = element.getAttribute('data-bs-target');
@@ -80,7 +65,30 @@
80
65
  return null;
81
66
  };
82
67
 
83
- const isElement = obj => (obj[0] || obj).nodeType;
68
+ const isElement = obj => {
69
+ if (!obj || typeof obj !== 'object') {
70
+ return false;
71
+ }
72
+
73
+ if (typeof obj.jquery !== 'undefined') {
74
+ obj = obj[0];
75
+ }
76
+
77
+ return typeof obj.nodeType !== 'undefined';
78
+ };
79
+
80
+ const getElement = obj => {
81
+ if (isElement(obj)) {
82
+ // it's a jQuery object or a node element
83
+ return obj.jquery ? obj[0] : obj;
84
+ }
85
+
86
+ if (typeof obj === 'string' && obj.length > 0) {
87
+ return document.querySelector(obj);
88
+ }
89
+
90
+ return null;
91
+ };
84
92
 
85
93
  const typeCheckConfig = (componentName, config, configTypes) => {
86
94
  Object.keys(configTypes).forEach(property => {
@@ -106,20 +114,30 @@
106
114
  return null;
107
115
  };
108
116
 
117
+ const DOMContentLoadedCallbacks = [];
118
+
109
119
  const onDOMContentLoaded = callback => {
110
120
  if (document.readyState === 'loading') {
111
- document.addEventListener('DOMContentLoaded', callback);
121
+ // add listener on the first call when the document is in loading state
122
+ if (!DOMContentLoadedCallbacks.length) {
123
+ document.addEventListener('DOMContentLoaded', () => {
124
+ DOMContentLoadedCallbacks.forEach(callback => callback());
125
+ });
126
+ }
127
+
128
+ DOMContentLoadedCallbacks.push(callback);
112
129
  } else {
113
130
  callback();
114
131
  }
115
132
  };
116
133
 
117
- const defineJQueryPlugin = (name, plugin) => {
134
+ const defineJQueryPlugin = plugin => {
118
135
  onDOMContentLoaded(() => {
119
136
  const $ = getjQuery();
120
137
  /* istanbul ignore if */
121
138
 
122
139
  if ($) {
140
+ const name = plugin.NAME;
123
141
  const JQUERY_NO_CONFLICT = $.fn[name];
124
142
  $.fn[name] = plugin.jQueryInterface;
125
143
  $.fn[name].Constructor = plugin;
@@ -134,7 +152,7 @@
134
152
 
135
153
  /**
136
154
  * --------------------------------------------------------------------------
137
- * Bootstrap (v5.0.0): scrollspy.js
155
+ * Bootstrap (v5.1.1): scrollspy.js
138
156
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
139
157
  * --------------------------------------------------------------------------
140
158
  */
@@ -168,6 +186,7 @@
168
186
  const SELECTOR_NAV_LINKS = '.nav-link';
169
187
  const SELECTOR_NAV_ITEMS = '.nav-item';
170
188
  const SELECTOR_LIST_ITEMS = '.list-group-item';
189
+ const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}, .${CLASS_NAME_DROPDOWN_ITEM}`;
171
190
  const SELECTOR_DROPDOWN = '.dropdown';
172
191
  const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
173
192
  const METHOD_OFFSET = 'offset';
@@ -183,7 +202,6 @@
183
202
  super(element);
184
203
  this._scrollElement = this._element.tagName === 'BODY' ? window : this._element;
185
204
  this._config = this._getConfig(config);
186
- this._selector = `${this._config.target} ${SELECTOR_NAV_LINKS}, ${this._config.target} ${SELECTOR_LIST_ITEMS}, ${this._config.target} .${CLASS_NAME_DROPDOWN_ITEM}`;
187
205
  this._offsets = [];
188
206
  this._targets = [];
189
207
  this._activeTarget = null;
@@ -199,8 +217,8 @@
199
217
  return Default;
200
218
  }
201
219
 
202
- static get DATA_KEY() {
203
- return DATA_KEY;
220
+ static get NAME() {
221
+ return NAME;
204
222
  } // Public
205
223
 
206
224
 
@@ -211,7 +229,7 @@
211
229
  this._offsets = [];
212
230
  this._targets = [];
213
231
  this._scrollHeight = this._getScrollHeight();
214
- const targets = SelectorEngine__default['default'].find(this._selector);
232
+ const targets = SelectorEngine__default['default'].find(SELECTOR_LINK_ITEMS, this._config.target);
215
233
  targets.map(element => {
216
234
  const targetSelector = getSelectorFromElement(element);
217
235
  const target = targetSelector ? SelectorEngine__default['default'].findOne(targetSelector) : null;
@@ -233,15 +251,8 @@
233
251
  }
234
252
 
235
253
  dispose() {
236
- super.dispose();
237
254
  EventHandler__default['default'].off(this._scrollElement, EVENT_KEY);
238
- this._scrollElement = null;
239
- this._config = null;
240
- this._selector = null;
241
- this._offsets = null;
242
- this._targets = null;
243
- this._activeTarget = null;
244
- this._scrollHeight = null;
255
+ super.dispose();
245
256
  } // Private
246
257
 
247
258
 
@@ -250,20 +261,7 @@
250
261
  ...Manipulator__default['default'].getDataAttributes(this._element),
251
262
  ...(typeof config === 'object' && config ? config : {})
252
263
  };
253
-
254
- if (typeof config.target !== 'string' && isElement(config.target)) {
255
- let {
256
- id
257
- } = config.target;
258
-
259
- if (!id) {
260
- id = getUID(NAME);
261
- config.target.id = id;
262
- }
263
-
264
- config.target = `#${id}`;
265
- }
266
-
264
+ config.target = getElement(config.target) || document.documentElement;
267
265
  typeCheckConfig(NAME, config, DefaultType);
268
266
  return config;
269
267
  }
@@ -323,16 +321,13 @@
323
321
 
324
322
  this._clear();
325
323
 
326
- const queries = this._selector.split(',').map(selector => `${selector}[data-bs-target="${target}"],${selector}[href="${target}"]`);
327
-
328
- const link = SelectorEngine__default['default'].findOne(queries.join(','));
324
+ const queries = SELECTOR_LINK_ITEMS.split(',').map(selector => `${selector}[data-bs-target="${target}"],${selector}[href="${target}"]`);
325
+ const link = SelectorEngine__default['default'].findOne(queries.join(','), this._config.target);
326
+ link.classList.add(CLASS_NAME_ACTIVE);
329
327
 
330
328
  if (link.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) {
331
329
  SelectorEngine__default['default'].findOne(SELECTOR_DROPDOWN_TOGGLE, link.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE);
332
- link.classList.add(CLASS_NAME_ACTIVE);
333
330
  } else {
334
- // Set triggered link as active
335
- link.classList.add(CLASS_NAME_ACTIVE);
336
331
  SelectorEngine__default['default'].parents(link, SELECTOR_NAV_LIST_GROUP).forEach(listGroup => {
337
332
  // Set triggered links parents as active
338
333
  // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
@@ -350,13 +345,13 @@
350
345
  }
351
346
 
352
347
  _clear() {
353
- SelectorEngine__default['default'].find(this._selector).filter(node => node.classList.contains(CLASS_NAME_ACTIVE)).forEach(node => node.classList.remove(CLASS_NAME_ACTIVE));
348
+ SelectorEngine__default['default'].find(SELECTOR_LINK_ITEMS, this._config.target).filter(node => node.classList.contains(CLASS_NAME_ACTIVE)).forEach(node => node.classList.remove(CLASS_NAME_ACTIVE));
354
349
  } // Static
355
350
 
356
351
 
357
352
  static jQueryInterface(config) {
358
353
  return this.each(function () {
359
- const data = ScrollSpy.getInstance(this) || new ScrollSpy(this, typeof config === 'object' ? config : {});
354
+ const data = ScrollSpy.getOrCreateInstance(this, config);
360
355
 
361
356
  if (typeof config !== 'string') {
362
357
  return;
@@ -388,7 +383,7 @@
388
383
  * add .ScrollSpy to jQuery only if jQuery is present
389
384
  */
390
385
 
391
- defineJQueryPlugin(NAME, ScrollSpy);
386
+ defineJQueryPlugin(ScrollSpy);
392
387
 
393
388
  return ScrollSpy;
394
389
 
@@ -1,29 +1,26 @@
1
1
  /*!
2
- * Bootstrap tab.js v5.0.0 (https://getbootstrap.com/)
2
+ * Bootstrap tab.js v5.1.1 (https://getbootstrap.com/)
3
3
  * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
4
4
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
5
  */
6
6
  (function (global, factory) {
7
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js'), require('./dom/selector-engine.js'), require('./base-component.js')) :
8
- typeof define === 'function' && define.amd ? define(['./dom/data', './dom/event-handler', './dom/selector-engine', './base-component'], factory) :
9
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tab = factory(global.Data, global.EventHandler, global.SelectorEngine, global.Base));
10
- }(this, (function (Data, EventHandler, SelectorEngine, BaseComponent) { 'use strict';
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/event-handler.js'), require('./dom/selector-engine.js'), require('./base-component.js')) :
8
+ typeof define === 'function' && define.amd ? define(['./dom/event-handler', './dom/selector-engine', './base-component'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tab = factory(global.EventHandler, global.SelectorEngine, global.Base));
10
+ }(this, (function (EventHandler, SelectorEngine, BaseComponent) { 'use strict';
11
11
 
12
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
13
 
14
- var Data__default = /*#__PURE__*/_interopDefaultLegacy(Data);
15
14
  var EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
16
15
  var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
17
16
  var BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
18
17
 
19
18
  /**
20
19
  * --------------------------------------------------------------------------
21
- * Bootstrap (v5.0.0): util/index.js
20
+ * Bootstrap (v5.1.1): util/index.js
22
21
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
23
22
  * --------------------------------------------------------------------------
24
23
  */
25
- const MILLISECONDS_MULTIPLIER = 1000;
26
- const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
27
24
 
28
25
  const getSelector = element => {
29
26
  let selector = element.getAttribute('data-bs-target');
@@ -54,51 +51,6 @@
54
51
  return selector ? document.querySelector(selector) : null;
55
52
  };
56
53
 
57
- const getTransitionDurationFromElement = element => {
58
- if (!element) {
59
- return 0;
60
- } // Get transition-duration of the element
61
-
62
-
63
- let {
64
- transitionDuration,
65
- transitionDelay
66
- } = window.getComputedStyle(element);
67
- const floatTransitionDuration = Number.parseFloat(transitionDuration);
68
- const floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
69
-
70
- if (!floatTransitionDuration && !floatTransitionDelay) {
71
- return 0;
72
- } // If multiple durations are defined, take the first
73
-
74
-
75
- transitionDuration = transitionDuration.split(',')[0];
76
- transitionDelay = transitionDelay.split(',')[0];
77
- return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
78
- };
79
-
80
- const triggerTransitionEnd = element => {
81
- element.dispatchEvent(new Event(TRANSITION_END));
82
- };
83
-
84
- const emulateTransitionEnd = (element, duration) => {
85
- let called = false;
86
- const durationPadding = 5;
87
- const emulatedDuration = duration + durationPadding;
88
-
89
- function listener() {
90
- called = true;
91
- element.removeEventListener(TRANSITION_END, listener);
92
- }
93
-
94
- element.addEventListener(TRANSITION_END, listener);
95
- setTimeout(() => {
96
- if (!called) {
97
- triggerTransitionEnd(element);
98
- }
99
- }, emulatedDuration);
100
- };
101
-
102
54
  const isDisabled = element => {
103
55
  if (!element || element.nodeType !== Node.ELEMENT_NODE) {
104
56
  return true;
@@ -114,8 +66,20 @@
114
66
 
115
67
  return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
116
68
  };
69
+ /**
70
+ * Trick to restart an element's animation
71
+ *
72
+ * @param {HTMLElement} element
73
+ * @return void
74
+ *
75
+ * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
76
+ */
77
+
117
78
 
118
- const reflow = element => element.offsetHeight;
79
+ const reflow = element => {
80
+ // eslint-disable-next-line no-unused-expressions
81
+ element.offsetHeight;
82
+ };
119
83
 
120
84
  const getjQuery = () => {
121
85
  const {
@@ -129,20 +93,30 @@
129
93
  return null;
130
94
  };
131
95
 
96
+ const DOMContentLoadedCallbacks = [];
97
+
132
98
  const onDOMContentLoaded = callback => {
133
99
  if (document.readyState === 'loading') {
134
- document.addEventListener('DOMContentLoaded', callback);
100
+ // add listener on the first call when the document is in loading state
101
+ if (!DOMContentLoadedCallbacks.length) {
102
+ document.addEventListener('DOMContentLoaded', () => {
103
+ DOMContentLoadedCallbacks.forEach(callback => callback());
104
+ });
105
+ }
106
+
107
+ DOMContentLoadedCallbacks.push(callback);
135
108
  } else {
136
109
  callback();
137
110
  }
138
111
  };
139
112
 
140
- const defineJQueryPlugin = (name, plugin) => {
113
+ const defineJQueryPlugin = plugin => {
141
114
  onDOMContentLoaded(() => {
142
115
  const $ = getjQuery();
143
116
  /* istanbul ignore if */
144
117
 
145
118
  if ($) {
119
+ const name = plugin.NAME;
146
120
  const JQUERY_NO_CONFLICT = $.fn[name];
147
121
  $.fn[name] = plugin.jQueryInterface;
148
122
  $.fn[name].Constructor = plugin;
@@ -157,7 +131,7 @@
157
131
 
158
132
  /**
159
133
  * --------------------------------------------------------------------------
160
- * Bootstrap (v5.0.0): tab.js
134
+ * Bootstrap (v5.1.1): tab.js
161
135
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
162
136
  * --------------------------------------------------------------------------
163
137
  */
@@ -195,8 +169,8 @@
195
169
 
196
170
  class Tab extends BaseComponent__default['default'] {
197
171
  // Getters
198
- static get DATA_KEY() {
199
- return DATA_KEY;
172
+ static get NAME() {
173
+ return NAME;
200
174
  } // Public
201
175
 
202
176
 
@@ -254,10 +228,9 @@
254
228
  const complete = () => this._transitionComplete(element, active, callback);
255
229
 
256
230
  if (active && isTransitioning) {
257
- const transitionDuration = getTransitionDurationFromElement(active);
258
231
  active.classList.remove(CLASS_NAME_SHOW);
259
- EventHandler__default['default'].one(active, 'transitionend', complete);
260
- emulateTransitionEnd(active, transitionDuration);
232
+
233
+ this._queueCallback(complete, element, true);
261
234
  } else {
262
235
  complete();
263
236
  }
@@ -313,7 +286,7 @@
313
286
 
314
287
  static jQueryInterface(config) {
315
288
  return this.each(function () {
316
- const data = Data__default['default'].get(this, DATA_KEY) || new Tab(this);
289
+ const data = Tab.getOrCreateInstance(this);
317
290
 
318
291
  if (typeof config === 'string') {
319
292
  if (typeof data[config] === 'undefined') {
@@ -342,7 +315,7 @@
342
315
  return;
343
316
  }
344
317
 
345
- const data = Data__default['default'].get(this, DATA_KEY) || new Tab(this);
318
+ const data = Tab.getOrCreateInstance(this);
346
319
  data.show();
347
320
  });
348
321
  /**
@@ -352,7 +325,7 @@
352
325
  * add .Tab to jQuery only if jQuery is present
353
326
  */
354
327
 
355
- defineJQueryPlugin(NAME, Tab);
328
+ defineJQueryPlugin(Tab);
356
329
 
357
330
  return Tab;
358
331