bootstrap 5.0.1 → 5.0.2

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/assets/javascripts/bootstrap-sprockets.js +7 -7
  4. data/assets/javascripts/bootstrap.js +332 -311
  5. data/assets/javascripts/bootstrap.min.js +2 -2
  6. data/assets/javascripts/bootstrap/alert.js +18 -17
  7. data/assets/javascripts/bootstrap/base-component.js +34 -25
  8. data/assets/javascripts/bootstrap/button.js +18 -19
  9. data/assets/javascripts/bootstrap/carousel.js +67 -52
  10. data/assets/javascripts/bootstrap/collapse.js +15 -6
  11. data/assets/javascripts/bootstrap/dom/data.js +2 -2
  12. data/assets/javascripts/bootstrap/dom/event-handler.js +2 -2
  13. data/assets/javascripts/bootstrap/dom/manipulator.js +2 -2
  14. data/assets/javascripts/bootstrap/dom/selector-engine.js +2 -2
  15. data/assets/javascripts/bootstrap/dropdown.js +61 -44
  16. data/assets/javascripts/bootstrap/modal.js +171 -108
  17. data/assets/javascripts/bootstrap/offcanvas.js +144 -95
  18. data/assets/javascripts/bootstrap/popover.js +35 -20
  19. data/assets/javascripts/bootstrap/scrollspy.js +14 -5
  20. data/assets/javascripts/bootstrap/tab.js +18 -10
  21. data/assets/javascripts/bootstrap/toast.js +17 -15
  22. data/assets/javascripts/bootstrap/tooltip.js +20 -21
  23. data/assets/stylesheets/_bootstrap-grid.scss +1 -1
  24. data/assets/stylesheets/_bootstrap-reboot.scss +1 -1
  25. data/assets/stylesheets/_bootstrap.scss +1 -1
  26. data/assets/stylesheets/bootstrap/_card.scss +5 -5
  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 +61 -3
  30. data/assets/stylesheets/bootstrap/_images.scss +1 -1
  31. data/assets/stylesheets/bootstrap/_modal.scss +4 -4
  32. data/assets/stylesheets/bootstrap/_offcanvas.scss +4 -2
  33. data/assets/stylesheets/bootstrap/_popover.scss +10 -10
  34. data/assets/stylesheets/bootstrap/_tables.scss +1 -1
  35. data/assets/stylesheets/bootstrap/_toasts.scss +1 -1
  36. data/assets/stylesheets/bootstrap/_tooltip.scss +4 -4
  37. data/assets/stylesheets/bootstrap/_variables.scss +22 -18
  38. data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +1 -1
  39. data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +3 -1
  40. data/assets/stylesheets/bootstrap/forms/_form-check.scss +1 -1
  41. data/assets/stylesheets/bootstrap/forms/_form-range.scss +1 -1
  42. data/assets/stylesheets/bootstrap/forms/_form-select.scss +3 -0
  43. data/assets/stylesheets/bootstrap/mixins/_buttons.scss +1 -1
  44. data/assets/stylesheets/bootstrap/mixins/_grid.scss +16 -9
  45. data/assets/stylesheets/bootstrap/vendor/_rfs.scss +55 -13
  46. data/lib/bootstrap/version.rb +2 -2
  47. metadata +2 -2
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Bootstrap collapse.js v5.0.1 (https://getbootstrap.com/)
2
+ * Bootstrap collapse.js v5.0.2 (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
  */
@@ -115,9 +115,18 @@
115
115
  return null;
116
116
  };
117
117
 
118
+ const DOMContentLoadedCallbacks = [];
119
+
118
120
  const onDOMContentLoaded = callback => {
119
121
  if (document.readyState === 'loading') {
120
- document.addEventListener('DOMContentLoaded', callback);
122
+ // add listener on the first call when the document is in loading state
123
+ if (!DOMContentLoadedCallbacks.length) {
124
+ document.addEventListener('DOMContentLoaded', () => {
125
+ DOMContentLoadedCallbacks.forEach(callback => callback());
126
+ });
127
+ }
128
+
129
+ DOMContentLoadedCallbacks.push(callback);
121
130
  } else {
122
131
  callback();
123
132
  }
@@ -144,7 +153,7 @@
144
153
 
145
154
  /**
146
155
  * --------------------------------------------------------------------------
147
- * Bootstrap (v5.0.1): collapse.js
156
+ * Bootstrap (v5.0.2): collapse.js
148
157
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
149
158
  * --------------------------------------------------------------------------
150
159
  */
@@ -260,7 +269,7 @@
260
269
 
261
270
  if (actives) {
262
271
  const tempActiveData = actives.find(elem => container !== elem);
263
- activesData = tempActiveData ? Data__default['default'].get(tempActiveData, DATA_KEY) : null;
272
+ activesData = tempActiveData ? Collapse.getInstance(tempActiveData) : null;
264
273
 
265
274
  if (activesData && activesData._isTransitioning) {
266
275
  return;
@@ -423,7 +432,7 @@
423
432
 
424
433
 
425
434
  static collapseInterface(element, config) {
426
- let data = Data__default['default'].get(element, DATA_KEY);
435
+ let data = Collapse.getInstance(element);
427
436
  const _config = { ...Default,
428
437
  ...Manipulator__default['default'].getDataAttributes(element),
429
438
  ...(typeof config === 'object' && config ? config : {})
@@ -470,7 +479,7 @@
470
479
  const selector = getSelectorFromElement(this);
471
480
  const selectorElements = SelectorEngine__default['default'].find(selector);
472
481
  selectorElements.forEach(element => {
473
- const data = Data__default['default'].get(element, DATA_KEY);
482
+ const data = Collapse.getInstance(element);
474
483
  let config;
475
484
 
476
485
  if (data) {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Bootstrap data.js v5.0.1 (https://getbootstrap.com/)
2
+ * Bootstrap data.js v5.0.2 (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
  */
@@ -11,7 +11,7 @@
11
11
 
12
12
  /**
13
13
  * --------------------------------------------------------------------------
14
- * Bootstrap (v5.0.1): dom/data.js
14
+ * Bootstrap (v5.0.2): dom/data.js
15
15
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
16
16
  * --------------------------------------------------------------------------
17
17
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Bootstrap event-handler.js v5.0.1 (https://getbootstrap.com/)
2
+ * Bootstrap event-handler.js v5.0.2 (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
  */
@@ -23,7 +23,7 @@
23
23
 
24
24
  /**
25
25
  * --------------------------------------------------------------------------
26
- * Bootstrap (v5.0.1): dom/event-handler.js
26
+ * Bootstrap (v5.0.2): dom/event-handler.js
27
27
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
28
28
  * --------------------------------------------------------------------------
29
29
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Bootstrap manipulator.js v5.0.1 (https://getbootstrap.com/)
2
+ * Bootstrap manipulator.js v5.0.2 (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
  */
@@ -11,7 +11,7 @@
11
11
 
12
12
  /**
13
13
  * --------------------------------------------------------------------------
14
- * Bootstrap (v5.0.1): dom/manipulator.js
14
+ * Bootstrap (v5.0.2): dom/manipulator.js
15
15
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
16
16
  * --------------------------------------------------------------------------
17
17
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Bootstrap selector-engine.js v5.0.1 (https://getbootstrap.com/)
2
+ * Bootstrap selector-engine.js v5.0.2 (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
  */
@@ -11,7 +11,7 @@
11
11
 
12
12
  /**
13
13
  * --------------------------------------------------------------------------
14
- * Bootstrap (v5.0.1): dom/selector-engine.js
14
+ * Bootstrap (v5.0.2): dom/selector-engine.js
15
15
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
16
16
  * --------------------------------------------------------------------------
17
17
  */
@@ -1,13 +1,13 @@
1
1
  /*!
2
- * Bootstrap dropdown.js v5.0.1 (https://getbootstrap.com/)
2
+ * Bootstrap dropdown.js v5.0.2 (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('@popperjs/core'), require('./dom/selector-engine.js'), require('./dom/data.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./base-component.js')) :
8
- typeof define === 'function' && define.amd ? define(['@popperjs/core', './dom/selector-engine', './dom/data', './dom/event-handler', './dom/manipulator', './base-component'], factory) :
9
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Dropdown = factory(global.Popper, global.SelectorEngine, global.Data, global.EventHandler, global.Manipulator, global.Base));
10
- }(this, (function (Popper, SelectorEngine, Data, EventHandler, Manipulator, BaseComponent) { 'use strict';
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@popperjs/core'), require('./dom/selector-engine.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./base-component.js')) :
8
+ typeof define === 'function' && define.amd ? define(['@popperjs/core', './dom/selector-engine', './dom/event-handler', './dom/manipulator', './base-component'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Dropdown = factory(global.Popper, global.SelectorEngine, global.EventHandler, global.Manipulator, global.Base));
10
+ }(this, (function (Popper, SelectorEngine, EventHandler, Manipulator, BaseComponent) { 'use strict';
11
11
 
12
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
13
 
@@ -33,7 +33,6 @@
33
33
 
34
34
  var Popper__namespace = /*#__PURE__*/_interopNamespace(Popper);
35
35
  var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
36
- var Data__default = /*#__PURE__*/_interopDefaultLegacy(Data);
37
36
  var EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
38
37
  var Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
39
38
  var BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
@@ -113,17 +112,11 @@
113
112
  };
114
113
 
115
114
  const isVisible = element => {
116
- if (!element) {
115
+ if (!isElement(element) || element.getClientRects().length === 0) {
117
116
  return false;
118
117
  }
119
118
 
120
- if (element.style && element.parentNode && element.parentNode.style) {
121
- const elementStyle = getComputedStyle(element);
122
- const parentNodeStyle = getComputedStyle(element.parentNode);
123
- return elementStyle.display !== 'none' && parentNodeStyle.display !== 'none' && elementStyle.visibility !== 'hidden';
124
- }
125
-
126
- return false;
119
+ return getComputedStyle(element).getPropertyValue('visibility') === 'visible';
127
120
  };
128
121
 
129
122
  const isDisabled = element => {
@@ -156,9 +149,18 @@
156
149
  return null;
157
150
  };
158
151
 
152
+ const DOMContentLoadedCallbacks = [];
153
+
159
154
  const onDOMContentLoaded = callback => {
160
155
  if (document.readyState === 'loading') {
161
- document.addEventListener('DOMContentLoaded', callback);
156
+ // add listener on the first call when the document is in loading state
157
+ if (!DOMContentLoadedCallbacks.length) {
158
+ document.addEventListener('DOMContentLoaded', () => {
159
+ DOMContentLoadedCallbacks.forEach(callback => callback());
160
+ });
161
+ }
162
+
163
+ DOMContentLoadedCallbacks.push(callback);
162
164
  } else {
163
165
  callback();
164
166
  }
@@ -184,10 +186,37 @@
184
186
  }
185
187
  });
186
188
  };
189
+ /**
190
+ * Return the previous/next element of a list.
191
+ *
192
+ * @param {array} list The list of elements
193
+ * @param activeElement The active element
194
+ * @param shouldGetNext Choose to get next or previous element
195
+ * @param isCycleAllowed
196
+ * @return {Element|elem} The proper element
197
+ */
198
+
199
+
200
+ const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
201
+ let index = list.indexOf(activeElement); // if the element does not exist in the list return an element depending on the direction and if cycle is allowed
202
+
203
+ if (index === -1) {
204
+ return list[!shouldGetNext && isCycleAllowed ? list.length - 1 : 0];
205
+ }
206
+
207
+ const listLength = list.length;
208
+ index += shouldGetNext ? 1 : -1;
209
+
210
+ if (isCycleAllowed) {
211
+ index = (index + listLength) % listLength;
212
+ }
213
+
214
+ return list[Math.max(0, Math.min(index, listLength - 1))];
215
+ };
187
216
 
188
217
  /**
189
218
  * --------------------------------------------------------------------------
190
- * Bootstrap (v5.0.1): dropdown.js
219
+ * Bootstrap (v5.0.2): dropdown.js
191
220
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
192
221
  * --------------------------------------------------------------------------
193
222
  */
@@ -507,38 +536,24 @@
507
536
  };
508
537
  }
509
538
 
510
- _selectMenuItem(event) {
539
+ _selectMenuItem({
540
+ key,
541
+ target
542
+ }) {
511
543
  const items = SelectorEngine__default['default'].find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(isVisible);
512
544
 
513
545
  if (!items.length) {
514
546
  return;
515
- }
516
-
517
- let index = items.indexOf(event.target); // Up
518
-
519
- if (event.key === ARROW_UP_KEY && index > 0) {
520
- index--;
521
- } // Down
547
+ } // if target isn't included in items (e.g. when expanding the dropdown)
548
+ // allow cycling to get the last item in case key equals ARROW_UP_KEY
522
549
 
523
550
 
524
- if (event.key === ARROW_DOWN_KEY && index < items.length - 1) {
525
- index++;
526
- } // index is -1 if the first keydown is an ArrowUp
527
-
528
-
529
- index = index === -1 ? 0 : index;
530
- items[index].focus();
551
+ getNextActiveElement(items, target, key === ARROW_DOWN_KEY, !items.includes(target)).focus();
531
552
  } // Static
532
553
 
533
554
 
534
555
  static dropdownInterface(element, config) {
535
- let data = Data__default['default'].get(element, DATA_KEY);
536
-
537
- const _config = typeof config === 'object' ? config : null;
538
-
539
- if (!data) {
540
- data = new Dropdown(element, _config);
541
- }
556
+ const data = Dropdown.getOrCreateInstance(element, config);
542
557
 
543
558
  if (typeof config === 'string') {
544
559
  if (typeof data[config] === 'undefined') {
@@ -563,7 +578,7 @@
563
578
  const toggles = SelectorEngine__default['default'].find(SELECTOR_DATA_TOGGLE);
564
579
 
565
580
  for (let i = 0, len = toggles.length; i < len; i++) {
566
- const context = Data__default['default'].get(toggles[i], DATA_KEY);
581
+ const context = Dropdown.getInstance(toggles[i]);
567
582
 
568
583
  if (!context || context._config.autoClose === false) {
569
584
  continue;
@@ -636,17 +651,19 @@
636
651
  return;
637
652
  }
638
653
 
639
- if (!isActive && (event.key === ARROW_UP_KEY || event.key === ARROW_DOWN_KEY)) {
640
- getToggleButton().click();
654
+ if (event.key === ARROW_UP_KEY || event.key === ARROW_DOWN_KEY) {
655
+ if (!isActive) {
656
+ getToggleButton().click();
657
+ }
658
+
659
+ Dropdown.getInstance(getToggleButton())._selectMenuItem(event);
660
+
641
661
  return;
642
662
  }
643
663
 
644
664
  if (!isActive || event.key === SPACE_KEY) {
645
665
  Dropdown.clearMenus();
646
- return;
647
666
  }
648
-
649
- Dropdown.getInstance(getToggleButton())._selectMenuItem(event);
650
667
  }
651
668
 
652
669
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Bootstrap modal.js v5.0.1 (https://getbootstrap.com/)
2
+ * Bootstrap modal.js v5.0.2 (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
  */
@@ -95,22 +95,17 @@
95
95
  return typeof obj.nodeType !== 'undefined';
96
96
  };
97
97
 
98
- const emulateTransitionEnd = (element, duration) => {
99
- let called = false;
100
- const durationPadding = 5;
101
- const emulatedDuration = duration + durationPadding;
98
+ const getElement = obj => {
99
+ if (isElement(obj)) {
100
+ // it's a jQuery object or a node element
101
+ return obj.jquery ? obj[0] : obj;
102
+ }
102
103
 
103
- function listener() {
104
- called = true;
105
- element.removeEventListener(TRANSITION_END, listener);
104
+ if (typeof obj === 'string' && obj.length > 0) {
105
+ return SelectorEngine__default['default'].findOne(obj);
106
106
  }
107
107
 
108
- element.addEventListener(TRANSITION_END, listener);
109
- setTimeout(() => {
110
- if (!called) {
111
- triggerTransitionEnd(element);
112
- }
113
- }, emulatedDuration);
108
+ return null;
114
109
  };
115
110
 
116
111
  const typeCheckConfig = (componentName, config, configTypes) => {
@@ -126,17 +121,11 @@
126
121
  };
127
122
 
128
123
  const isVisible = element => {
129
- if (!element) {
124
+ if (!isElement(element) || element.getClientRects().length === 0) {
130
125
  return false;
131
126
  }
132
127
 
133
- if (element.style && element.parentNode && element.parentNode.style) {
134
- const elementStyle = getComputedStyle(element);
135
- const parentNodeStyle = getComputedStyle(element.parentNode);
136
- return elementStyle.display !== 'none' && parentNodeStyle.display !== 'none' && elementStyle.visibility !== 'hidden';
137
- }
138
-
139
- return false;
128
+ return getComputedStyle(element).getPropertyValue('visibility') === 'visible';
140
129
  };
141
130
 
142
131
  const reflow = element => element.offsetHeight;
@@ -153,9 +142,18 @@
153
142
  return null;
154
143
  };
155
144
 
145
+ const DOMContentLoadedCallbacks = [];
146
+
156
147
  const onDOMContentLoaded = callback => {
157
148
  if (document.readyState === 'loading') {
158
- document.addEventListener('DOMContentLoaded', callback);
149
+ // add listener on the first call when the document is in loading state
150
+ if (!DOMContentLoadedCallbacks.length) {
151
+ document.addEventListener('DOMContentLoaded', () => {
152
+ DOMContentLoadedCallbacks.forEach(callback => callback());
153
+ });
154
+ }
155
+
156
+ DOMContentLoadedCallbacks.push(callback);
159
157
  } else {
160
158
  callback();
161
159
  }
@@ -188,83 +186,143 @@
188
186
  }
189
187
  };
190
188
 
189
+ const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
190
+ if (!waitForTransition) {
191
+ execute(callback);
192
+ return;
193
+ }
194
+
195
+ const durationPadding = 5;
196
+ const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
197
+ let called = false;
198
+
199
+ const handler = ({
200
+ target
201
+ }) => {
202
+ if (target !== transitionElement) {
203
+ return;
204
+ }
205
+
206
+ called = true;
207
+ transitionElement.removeEventListener(TRANSITION_END, handler);
208
+ execute(callback);
209
+ };
210
+
211
+ transitionElement.addEventListener(TRANSITION_END, handler);
212
+ setTimeout(() => {
213
+ if (!called) {
214
+ triggerTransitionEnd(transitionElement);
215
+ }
216
+ }, emulatedDuration);
217
+ };
218
+
191
219
  /**
192
220
  * --------------------------------------------------------------------------
193
- * Bootstrap (v5.0.1): util/scrollBar.js
221
+ * Bootstrap (v5.0.2): util/scrollBar.js
194
222
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
195
223
  * --------------------------------------------------------------------------
196
224
  */
197
225
  const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
198
226
  const SELECTOR_STICKY_CONTENT = '.sticky-top';
199
227
 
200
- const getWidth = () => {
201
- // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
202
- const documentWidth = document.documentElement.clientWidth;
203
- return Math.abs(window.innerWidth - documentWidth);
204
- };
228
+ class ScrollBarHelper {
229
+ constructor() {
230
+ this._element = document.body;
231
+ }
205
232
 
206
- const hide = (width = getWidth()) => {
207
- _disableOverFlow(); // give padding to element to balances the hidden scrollbar width
233
+ getWidth() {
234
+ // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
235
+ const documentWidth = document.documentElement.clientWidth;
236
+ return Math.abs(window.innerWidth - documentWidth);
237
+ }
208
238
 
239
+ hide() {
240
+ const width = this.getWidth();
209
241
 
210
- _setElementAttributes('body', 'paddingRight', calculatedValue => calculatedValue + width); // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements, to keep shown fullwidth
242
+ this._disableOverFlow(); // give padding to element to balance the hidden scrollbar width
211
243
 
212
244
 
213
- _setElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight', calculatedValue => calculatedValue + width);
245
+ this._setElementAttributes(this._element, 'paddingRight', calculatedValue => calculatedValue + width); // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth
214
246
 
215
- _setElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight', calculatedValue => calculatedValue - width);
216
- };
217
247
 
218
- const _disableOverFlow = () => {
219
- const actualValue = document.body.style.overflow;
248
+ this._setElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight', calculatedValue => calculatedValue + width);
220
249
 
221
- if (actualValue) {
222
- Manipulator__default['default'].setDataAttribute(document.body, 'overflow', actualValue);
250
+ this._setElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight', calculatedValue => calculatedValue - width);
223
251
  }
224
252
 
225
- document.body.style.overflow = 'hidden';
226
- };
253
+ _disableOverFlow() {
254
+ this._saveInitialAttribute(this._element, 'overflow');
227
255
 
228
- const _setElementAttributes = (selector, styleProp, callback) => {
229
- const scrollbarWidth = getWidth();
230
- SelectorEngine__default['default'].find(selector).forEach(element => {
231
- if (element !== document.body && window.innerWidth > element.clientWidth + scrollbarWidth) {
232
- return;
233
- }
256
+ this._element.style.overflow = 'hidden';
257
+ }
234
258
 
235
- const actualValue = element.style[styleProp];
236
- const calculatedValue = window.getComputedStyle(element)[styleProp];
237
- Manipulator__default['default'].setDataAttribute(element, styleProp, actualValue);
238
- element.style[styleProp] = `${callback(Number.parseFloat(calculatedValue))}px`;
239
- });
240
- };
259
+ _setElementAttributes(selector, styleProp, callback) {
260
+ const scrollbarWidth = this.getWidth();
241
261
 
242
- const reset = () => {
243
- _resetElementAttributes('body', 'overflow');
262
+ const manipulationCallBack = element => {
263
+ if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) {
264
+ return;
265
+ }
244
266
 
245
- _resetElementAttributes('body', 'paddingRight');
267
+ this._saveInitialAttribute(element, styleProp);
246
268
 
247
- _resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight');
269
+ const calculatedValue = window.getComputedStyle(element)[styleProp];
270
+ element.style[styleProp] = `${callback(Number.parseFloat(calculatedValue))}px`;
271
+ };
248
272
 
249
- _resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight');
250
- };
273
+ this._applyManipulationCallback(selector, manipulationCallBack);
274
+ }
251
275
 
252
- const _resetElementAttributes = (selector, styleProp) => {
253
- SelectorEngine__default['default'].find(selector).forEach(element => {
254
- const value = Manipulator__default['default'].getDataAttribute(element, styleProp);
276
+ reset() {
277
+ this._resetElementAttributes(this._element, 'overflow');
255
278
 
256
- if (typeof value === 'undefined') {
257
- element.style.removeProperty(styleProp);
279
+ this._resetElementAttributes(this._element, 'paddingRight');
280
+
281
+ this._resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight');
282
+
283
+ this._resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight');
284
+ }
285
+
286
+ _saveInitialAttribute(element, styleProp) {
287
+ const actualValue = element.style[styleProp];
288
+
289
+ if (actualValue) {
290
+ Manipulator__default['default'].setDataAttribute(element, styleProp, actualValue);
291
+ }
292
+ }
293
+
294
+ _resetElementAttributes(selector, styleProp) {
295
+ const manipulationCallBack = element => {
296
+ const value = Manipulator__default['default'].getDataAttribute(element, styleProp);
297
+
298
+ if (typeof value === 'undefined') {
299
+ element.style.removeProperty(styleProp);
300
+ } else {
301
+ Manipulator__default['default'].removeDataAttribute(element, styleProp);
302
+ element.style[styleProp] = value;
303
+ }
304
+ };
305
+
306
+ this._applyManipulationCallback(selector, manipulationCallBack);
307
+ }
308
+
309
+ _applyManipulationCallback(selector, callBack) {
310
+ if (isElement(selector)) {
311
+ callBack(selector);
258
312
  } else {
259
- Manipulator__default['default'].removeDataAttribute(element, styleProp);
260
- element.style[styleProp] = value;
313
+ SelectorEngine__default['default'].find(selector, this._element).forEach(callBack);
261
314
  }
262
- });
263
- };
315
+ }
316
+
317
+ isOverflowing() {
318
+ return this.getWidth() > 0;
319
+ }
320
+
321
+ }
264
322
 
265
323
  /**
266
324
  * --------------------------------------------------------------------------
267
- * Bootstrap (v5.0.1): util/backdrop.js
325
+ * Bootstrap (v5.0.2): util/backdrop.js
268
326
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
269
327
  * --------------------------------------------------------------------------
270
328
  */
@@ -272,14 +330,14 @@
272
330
  isVisible: true,
273
331
  // if false, we use the backdrop helper without adding any element to the dom
274
332
  isAnimated: false,
275
- rootElement: document.body,
333
+ rootElement: 'body',
276
334
  // give the choice to place backdrop under different elements
277
335
  clickCallback: null
278
336
  };
279
337
  const DefaultType$1 = {
280
338
  isVisible: 'boolean',
281
339
  isAnimated: 'boolean',
282
- rootElement: 'element',
340
+ rootElement: '(element|string)',
283
341
  clickCallback: '(function|null)'
284
342
  };
285
343
  const NAME$1 = 'backdrop';
@@ -347,8 +405,9 @@
347
405
  _getConfig(config) {
348
406
  config = { ...Default$1,
349
407
  ...(typeof config === 'object' ? config : {})
350
- };
351
- config.rootElement = config.rootElement || document.body;
408
+ }; // use getElement() with the default "body" to get a fresh Element on each instantiation
409
+
410
+ config.rootElement = getElement(config.rootElement);
352
411
  typeCheckConfig(NAME$1, config, DefaultType$1);
353
412
  return config;
354
413
  }
@@ -373,27 +432,20 @@
373
432
 
374
433
  EventHandler__default['default'].off(this._element, EVENT_MOUSEDOWN);
375
434
 
376
- this._getElement().parentNode.removeChild(this._element);
435
+ this._element.remove();
377
436
 
378
437
  this._isAppended = false;
379
438
  }
380
439
 
381
440
  _emulateAnimation(callback) {
382
- if (!this._config.isAnimated) {
383
- execute(callback);
384
- return;
385
- }
386
-
387
- const backdropTransitionDuration = getTransitionDurationFromElement(this._getElement());
388
- EventHandler__default['default'].one(this._getElement(), 'transitionend', () => execute(callback));
389
- emulateTransitionEnd(this._getElement(), backdropTransitionDuration);
441
+ executeAfterTransition(callback, this._getElement(), this._config.isAnimated);
390
442
  }
391
443
 
392
444
  }
393
445
 
394
446
  /**
395
447
  * --------------------------------------------------------------------------
396
- * Bootstrap (v5.0.1): modal.js
448
+ * Bootstrap (v5.0.2): modal.js
397
449
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
398
450
  * --------------------------------------------------------------------------
399
451
  */
@@ -453,6 +505,7 @@
453
505
  this._isShown = false;
454
506
  this._ignoreBackdropClick = false;
455
507
  this._isTransitioning = false;
508
+ this._scrollBar = new ScrollBarHelper();
456
509
  } // Getters
457
510
 
458
511
 
@@ -474,20 +527,22 @@
474
527
  return;
475
528
  }
476
529
 
477
- if (this._isAnimated()) {
478
- this._isTransitioning = true;
479
- }
480
-
481
530
  const showEvent = EventHandler__default['default'].trigger(this._element, EVENT_SHOW, {
482
531
  relatedTarget
483
532
  });
484
533
 
485
- if (this._isShown || showEvent.defaultPrevented) {
534
+ if (showEvent.defaultPrevented) {
486
535
  return;
487
536
  }
488
537
 
489
538
  this._isShown = true;
490
- hide();
539
+
540
+ if (this._isAnimated()) {
541
+ this._isTransitioning = true;
542
+ }
543
+
544
+ this._scrollBar.hide();
545
+
491
546
  document.body.classList.add(CLASS_NAME_OPEN);
492
547
 
493
548
  this._adjustDialog();
@@ -509,7 +564,7 @@
509
564
  }
510
565
 
511
566
  hide(event) {
512
- if (event) {
567
+ if (event && ['A', 'AREA'].includes(event.target.tagName)) {
513
568
  event.preventDefault();
514
569
  }
515
570
 
@@ -576,7 +631,7 @@
576
631
  _getConfig(config) {
577
632
  config = { ...Default,
578
633
  ...Manipulator__default['default'].getDataAttributes(this._element),
579
- ...config
634
+ ...(typeof config === 'object' ? config : {})
580
635
  };
581
636
  typeCheckConfig(NAME, config, DefaultType);
582
637
  return config;
@@ -679,7 +734,8 @@
679
734
 
680
735
  this._resetAdjustments();
681
736
 
682
- reset();
737
+ this._scrollBar.reset();
738
+
683
739
  EventHandler__default['default'].trigger(this._element, EVENT_HIDDEN);
684
740
  });
685
741
  }
@@ -716,27 +772,32 @@
716
772
  return;
717
773
  }
718
774
 
719
- const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
775
+ const {
776
+ classList,
777
+ scrollHeight,
778
+ style
779
+ } = this._element;
780
+ const isModalOverflowing = scrollHeight > document.documentElement.clientHeight; // return if the following background transition hasn't yet completed
781
+
782
+ if (!isModalOverflowing && style.overflowY === 'hidden' || classList.contains(CLASS_NAME_STATIC)) {
783
+ return;
784
+ }
720
785
 
721
786
  if (!isModalOverflowing) {
722
- this._element.style.overflowY = 'hidden';
787
+ style.overflowY = 'hidden';
723
788
  }
724
789
 
725
- this._element.classList.add(CLASS_NAME_STATIC);
790
+ classList.add(CLASS_NAME_STATIC);
726
791
 
727
- const modalTransitionDuration = getTransitionDurationFromElement(this._dialog);
728
- EventHandler__default['default'].off(this._element, 'transitionend');
729
- EventHandler__default['default'].one(this._element, 'transitionend', () => {
730
- this._element.classList.remove(CLASS_NAME_STATIC);
792
+ this._queueCallback(() => {
793
+ classList.remove(CLASS_NAME_STATIC);
731
794
 
732
795
  if (!isModalOverflowing) {
733
- EventHandler__default['default'].one(this._element, 'transitionend', () => {
734
- this._element.style.overflowY = '';
735
- });
736
- emulateTransitionEnd(this._element, modalTransitionDuration);
796
+ this._queueCallback(() => {
797
+ style.overflowY = '';
798
+ }, this._dialog);
737
799
  }
738
- });
739
- emulateTransitionEnd(this._element, modalTransitionDuration);
800
+ }, this._dialog);
740
801
 
741
802
  this._element.focus();
742
803
  } // ----------------------------------------------------------------------
@@ -746,7 +807,9 @@
746
807
 
747
808
  _adjustDialog() {
748
809
  const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
749
- const scrollbarWidth = getWidth();
810
+
811
+ const scrollbarWidth = this._scrollBar.getWidth();
812
+
750
813
  const isBodyOverflowing = scrollbarWidth > 0;
751
814
 
752
815
  if (!isBodyOverflowing && isModalOverflowing && !isRTL() || isBodyOverflowing && !isModalOverflowing && isRTL()) {
@@ -766,7 +829,7 @@
766
829
 
767
830
  static jQueryInterface(config, relatedTarget) {
768
831
  return this.each(function () {
769
- const data = Modal.getInstance(this) || new Modal(this, typeof config === 'object' ? config : {});
832
+ const data = Modal.getOrCreateInstance(this, config);
770
833
 
771
834
  if (typeof config !== 'string') {
772
835
  return;
@@ -807,7 +870,7 @@
807
870
  }
808
871
  });
809
872
  });
810
- const data = Modal.getInstance(target) || new Modal(target);
873
+ const data = Modal.getOrCreateInstance(target);
811
874
  data.toggle(this);
812
875
  });
813
876
  /**