bootstrap 5.0.2 → 5.1.0

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/assets/javascripts/bootstrap-sprockets.js +7 -7
  4. data/assets/javascripts/bootstrap.js +590 -580
  5. data/assets/javascripts/bootstrap.min.js +2 -2
  6. data/assets/javascripts/bootstrap/alert.js +73 -43
  7. data/assets/javascripts/bootstrap/base-component.js +15 -10
  8. data/assets/javascripts/bootstrap/button.js +13 -6
  9. data/assets/javascripts/bootstrap/carousel.js +26 -8
  10. data/assets/javascripts/bootstrap/collapse.js +96 -114
  11. data/assets/javascripts/bootstrap/dom/data.js +2 -2
  12. data/assets/javascripts/bootstrap/dom/event-handler.js +9 -2
  13. data/assets/javascripts/bootstrap/dom/manipulator.js +4 -4
  14. data/assets/javascripts/bootstrap/dom/selector-engine.js +47 -5
  15. data/assets/javascripts/bootstrap/dropdown.js +66 -74
  16. data/assets/javascripts/bootstrap/modal.js +198 -52
  17. data/assets/javascripts/bootstrap/offcanvas.js +177 -31
  18. data/assets/javascripts/bootstrap/popover.js +19 -52
  19. data/assets/javascripts/bootstrap/scrollspy.js +28 -47
  20. data/assets/javascripts/bootstrap/tab.js +27 -8
  21. data/assets/javascripts/bootstrap/toast.js +108 -13
  22. data/assets/javascripts/bootstrap/tooltip.js +57 -47
  23. data/assets/stylesheets/_bootstrap-grid.scss +1 -1
  24. data/assets/stylesheets/_bootstrap-reboot.scss +1 -1
  25. data/assets/stylesheets/_bootstrap.scss +2 -1
  26. data/assets/stylesheets/bootstrap/_card.scss +2 -1
  27. data/assets/stylesheets/bootstrap/_functions.scss +45 -12
  28. data/assets/stylesheets/bootstrap/_grid.scss +11 -0
  29. data/assets/stylesheets/bootstrap/_helpers.scss +2 -0
  30. data/assets/stylesheets/bootstrap/_mixins.scss +1 -0
  31. data/assets/stylesheets/bootstrap/_modal.scss +1 -11
  32. data/assets/stylesheets/bootstrap/_navbar.scss +30 -1
  33. data/assets/stylesheets/bootstrap/_offcanvas.scss +4 -0
  34. data/assets/stylesheets/bootstrap/_placeholders.scss +51 -0
  35. data/assets/stylesheets/bootstrap/_reboot.scss +12 -8
  36. data/assets/stylesheets/bootstrap/_root.scss +39 -2
  37. data/assets/stylesheets/bootstrap/_toasts.scss +2 -2
  38. data/assets/stylesheets/bootstrap/_transitions.scss +6 -0
  39. data/assets/stylesheets/bootstrap/_utilities.scss +44 -8
  40. data/assets/stylesheets/bootstrap/_variables.scss +167 -6
  41. data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +1 -1
  42. data/assets/stylesheets/bootstrap/forms/_form-control.scss +1 -1
  43. data/assets/stylesheets/bootstrap/helpers/_stacks.scss +15 -0
  44. data/assets/stylesheets/bootstrap/helpers/_vr.scss +8 -0
  45. data/assets/stylesheets/bootstrap/mixins/_backdrop.scss +14 -0
  46. data/assets/stylesheets/bootstrap/mixins/_grid.scss +25 -7
  47. data/assets/stylesheets/bootstrap/mixins/_utilities.scss +27 -6
  48. data/bootstrap.gemspec +3 -3
  49. data/lib/bootstrap/version.rb +2 -2
  50. data/tasks/updater/js.rb +6 -2
  51. metadata +11 -7
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Bootstrap data.js v5.0.2 (https://getbootstrap.com/)
2
+ * Bootstrap data.js v5.1.0 (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.2): dom/data.js
14
+ * Bootstrap (v5.1.0): 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.2 (https://getbootstrap.com/)
2
+ * Bootstrap event-handler.js v5.1.0 (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
  */
@@ -9,6 +9,13 @@
9
9
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.EventHandler = factory());
10
10
  }(this, (function () { 'use strict';
11
11
 
12
+ /**
13
+ * --------------------------------------------------------------------------
14
+ * Bootstrap (v5.1.0): util/index.js
15
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
16
+ * --------------------------------------------------------------------------
17
+ */
18
+
12
19
  const getjQuery = () => {
13
20
  const {
14
21
  jQuery
@@ -23,7 +30,7 @@
23
30
 
24
31
  /**
25
32
  * --------------------------------------------------------------------------
26
- * Bootstrap (v5.0.2): dom/event-handler.js
33
+ * Bootstrap (v5.1.0): dom/event-handler.js
27
34
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
28
35
  * --------------------------------------------------------------------------
29
36
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Bootstrap manipulator.js v5.0.2 (https://getbootstrap.com/)
2
+ * Bootstrap manipulator.js v5.1.0 (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.2): dom/manipulator.js
14
+ * Bootstrap (v5.1.0): dom/manipulator.js
15
15
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
16
16
  * --------------------------------------------------------------------------
17
17
  */
@@ -69,8 +69,8 @@
69
69
  offset(element) {
70
70
  const rect = element.getBoundingClientRect();
71
71
  return {
72
- top: rect.top + document.body.scrollTop,
73
- left: rect.left + document.body.scrollLeft
72
+ top: rect.top + window.pageYOffset,
73
+ left: rect.left + window.pageXOffset
74
74
  };
75
75
  },
76
76
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Bootstrap selector-engine.js v5.0.2 (https://getbootstrap.com/)
2
+ * Bootstrap selector-engine.js v5.1.0 (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,15 +11,52 @@
11
11
 
12
12
  /**
13
13
  * --------------------------------------------------------------------------
14
- * Bootstrap (v5.0.2): dom/selector-engine.js
14
+ * Bootstrap (v5.1.0): util/index.js
15
15
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
16
16
  * --------------------------------------------------------------------------
17
17
  */
18
18
 
19
+ const isElement = obj => {
20
+ if (!obj || typeof obj !== 'object') {
21
+ return false;
22
+ }
23
+
24
+ if (typeof obj.jquery !== 'undefined') {
25
+ obj = obj[0];
26
+ }
27
+
28
+ return typeof obj.nodeType !== 'undefined';
29
+ };
30
+
31
+ const isVisible = element => {
32
+ if (!isElement(element) || element.getClientRects().length === 0) {
33
+ return false;
34
+ }
35
+
36
+ return getComputedStyle(element).getPropertyValue('visibility') === 'visible';
37
+ };
38
+
39
+ const isDisabled = element => {
40
+ if (!element || element.nodeType !== Node.ELEMENT_NODE) {
41
+ return true;
42
+ }
43
+
44
+ if (element.classList.contains('disabled')) {
45
+ return true;
46
+ }
47
+
48
+ if (typeof element.disabled !== 'undefined') {
49
+ return element.disabled;
50
+ }
51
+
52
+ return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
53
+ };
54
+
19
55
  /**
20
- * ------------------------------------------------------------------------
21
- * Constants
22
- * ------------------------------------------------------------------------
56
+ * --------------------------------------------------------------------------
57
+ * Bootstrap (v5.1.0): dom/selector-engine.js
58
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
59
+ * --------------------------------------------------------------------------
23
60
  */
24
61
  const NODE_TEXT = 3;
25
62
  const SelectorEngine = {
@@ -76,6 +113,11 @@
76
113
  }
77
114
 
78
115
  return [];
116
+ },
117
+
118
+ focusableChildren(element) {
119
+ const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(', ');
120
+ return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el));
79
121
  }
80
122
 
81
123
  };
@@ -1,13 +1,13 @@
1
1
  /*!
2
- * Bootstrap dropdown.js v5.0.2 (https://getbootstrap.com/)
2
+ * Bootstrap dropdown.js v5.1.0 (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/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';
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@popperjs/core'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js'), require('./base-component.js')) :
8
+ typeof define === 'function' && define.amd ? define(['@popperjs/core', './dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Dropdown = factory(global.Popper, global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base));
10
+ }(this, (function (Popper, EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict';
11
11
 
12
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
13
 
@@ -32,11 +32,18 @@
32
32
  }
33
33
 
34
34
  var Popper__namespace = /*#__PURE__*/_interopNamespace(Popper);
35
- var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
36
35
  var EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
37
36
  var Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
37
+ var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
38
38
  var BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
39
39
 
40
+ /**
41
+ * --------------------------------------------------------------------------
42
+ * Bootstrap (v5.1.0): util/index.js
43
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
44
+ * --------------------------------------------------------------------------
45
+ */
46
+
40
47
  const toType = obj => {
41
48
  if (obj === null || obj === undefined) {
42
49
  return `${obj}`;
@@ -93,7 +100,7 @@
93
100
  }
94
101
 
95
102
  if (typeof obj === 'string' && obj.length > 0) {
96
- return SelectorEngine__default['default'].findOne(obj);
103
+ return document.querySelector(obj);
97
104
  }
98
105
 
99
106
  return null;
@@ -216,7 +223,7 @@
216
223
 
217
224
  /**
218
225
  * --------------------------------------------------------------------------
219
- * Bootstrap (v5.0.2): dropdown.js
226
+ * Bootstrap (v5.1.0): dropdown.js
220
227
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
221
228
  * --------------------------------------------------------------------------
222
229
  */
@@ -242,7 +249,6 @@
242
249
  const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
243
250
  const EVENT_SHOW = `show${EVENT_KEY}`;
244
251
  const EVENT_SHOWN = `shown${EVENT_KEY}`;
245
- const EVENT_CLICK = `click${EVENT_KEY}`;
246
252
  const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
247
253
  const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY}${DATA_API_KEY}`;
248
254
  const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY}${DATA_API_KEY}`;
@@ -290,8 +296,6 @@
290
296
  this._config = this._getConfig(config);
291
297
  this._menu = this._getMenuElement();
292
298
  this._inNavbar = this._detectNavbar();
293
-
294
- this._addEventListeners();
295
299
  } // Getters
296
300
 
297
301
 
@@ -309,26 +313,14 @@
309
313
 
310
314
 
311
315
  toggle() {
312
- if (isDisabled(this._element)) {
313
- return;
314
- }
315
-
316
- const isActive = this._element.classList.contains(CLASS_NAME_SHOW);
317
-
318
- if (isActive) {
319
- this.hide();
320
- return;
321
- }
322
-
323
- this.show();
316
+ return this._isShown() ? this.hide() : this.show();
324
317
  }
325
318
 
326
319
  show() {
327
- if (isDisabled(this._element) || this._menu.classList.contains(CLASS_NAME_SHOW)) {
320
+ if (isDisabled(this._element) || this._isShown(this._menu)) {
328
321
  return;
329
322
  }
330
323
 
331
- const parent = Dropdown.getParentFromElement(this._element);
332
324
  const relatedTarget = {
333
325
  relatedTarget: this._element
334
326
  };
@@ -336,34 +328,14 @@
336
328
 
337
329
  if (showEvent.defaultPrevented) {
338
330
  return;
339
- } // Totally disable Popper for Dropdowns in Navbar
331
+ }
340
332
 
333
+ const parent = Dropdown.getParentFromElement(this._element); // Totally disable Popper for Dropdowns in Navbar
341
334
 
342
335
  if (this._inNavbar) {
343
336
  Manipulator__default['default'].setDataAttribute(this._menu, 'popper', 'none');
344
337
  } else {
345
- if (typeof Popper__namespace === 'undefined') {
346
- throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)');
347
- }
348
-
349
- let referenceElement = this._element;
350
-
351
- if (this._config.reference === 'parent') {
352
- referenceElement = parent;
353
- } else if (isElement(this._config.reference)) {
354
- referenceElement = getElement(this._config.reference);
355
- } else if (typeof this._config.reference === 'object') {
356
- referenceElement = this._config.reference;
357
- }
358
-
359
- const popperConfig = this._getPopperConfig();
360
-
361
- const isDisplayStatic = popperConfig.modifiers.find(modifier => modifier.name === 'applyStyles' && modifier.enabled === false);
362
- this._popper = Popper__namespace.createPopper(referenceElement, this._menu, popperConfig);
363
-
364
- if (isDisplayStatic) {
365
- Manipulator__default['default'].setDataAttribute(this._menu, 'popper', 'static');
366
- }
338
+ this._createPopper(parent);
367
339
  } // If this is a touch-enabled device we add extra
368
340
  // empty mouseover listeners to the body's immediate children;
369
341
  // only needed because of broken event delegation on iOS
@@ -378,15 +350,15 @@
378
350
 
379
351
  this._element.setAttribute('aria-expanded', true);
380
352
 
381
- this._menu.classList.toggle(CLASS_NAME_SHOW);
353
+ this._menu.classList.add(CLASS_NAME_SHOW);
382
354
 
383
- this._element.classList.toggle(CLASS_NAME_SHOW);
355
+ this._element.classList.add(CLASS_NAME_SHOW);
384
356
 
385
357
  EventHandler__default['default'].trigger(this._element, EVENT_SHOWN, relatedTarget);
386
358
  }
387
359
 
388
360
  hide() {
389
- if (isDisabled(this._element) || !this._menu.classList.contains(CLASS_NAME_SHOW)) {
361
+ if (isDisabled(this._element) || !this._isShown(this._menu)) {
390
362
  return;
391
363
  }
392
364
 
@@ -414,13 +386,6 @@
414
386
  } // Private
415
387
 
416
388
 
417
- _addEventListeners() {
418
- EventHandler__default['default'].on(this._element, EVENT_CLICK, event => {
419
- event.preventDefault();
420
- this.toggle();
421
- });
422
- }
423
-
424
389
  _completeHide(relatedTarget) {
425
390
  const hideEvent = EventHandler__default['default'].trigger(this._element, EVENT_HIDE, relatedTarget);
426
391
 
@@ -463,6 +428,35 @@
463
428
  return config;
464
429
  }
465
430
 
431
+ _createPopper(parent) {
432
+ if (typeof Popper__namespace === 'undefined') {
433
+ throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)');
434
+ }
435
+
436
+ let referenceElement = this._element;
437
+
438
+ if (this._config.reference === 'parent') {
439
+ referenceElement = parent;
440
+ } else if (isElement(this._config.reference)) {
441
+ referenceElement = getElement(this._config.reference);
442
+ } else if (typeof this._config.reference === 'object') {
443
+ referenceElement = this._config.reference;
444
+ }
445
+
446
+ const popperConfig = this._getPopperConfig();
447
+
448
+ const isDisplayStatic = popperConfig.modifiers.find(modifier => modifier.name === 'applyStyles' && modifier.enabled === false);
449
+ this._popper = Popper__namespace.createPopper(referenceElement, this._menu, popperConfig);
450
+
451
+ if (isDisplayStatic) {
452
+ Manipulator__default['default'].setDataAttribute(this._menu, 'popper', 'static');
453
+ }
454
+ }
455
+
456
+ _isShown(element = this._element) {
457
+ return element.classList.contains(CLASS_NAME_SHOW);
458
+ }
459
+
466
460
  _getMenuElement() {
467
461
  return SelectorEngine__default['default'].next(this._element, SELECTOR_MENU)[0];
468
462
  }
@@ -552,21 +546,19 @@
552
546
  } // Static
553
547
 
554
548
 
555
- static dropdownInterface(element, config) {
556
- const data = Dropdown.getOrCreateInstance(element, config);
549
+ static jQueryInterface(config) {
550
+ return this.each(function () {
551
+ const data = Dropdown.getOrCreateInstance(this, config);
552
+
553
+ if (typeof config !== 'string') {
554
+ return;
555
+ }
557
556
 
558
- if (typeof config === 'string') {
559
557
  if (typeof data[config] === 'undefined') {
560
558
  throw new TypeError(`No method named "${config}"`);
561
559
  }
562
560
 
563
561
  data[config]();
564
- }
565
- }
566
-
567
- static jQueryInterface(config) {
568
- return this.each(function () {
569
- Dropdown.dropdownInterface(this, config);
570
562
  });
571
563
  }
572
564
 
@@ -584,7 +576,7 @@
584
576
  continue;
585
577
  }
586
578
 
587
- if (!context._element.classList.contains(CLASS_NAME_SHOW)) {
579
+ if (!context._isShown()) {
588
580
  continue;
589
581
  }
590
582
 
@@ -643,20 +635,20 @@
643
635
  return;
644
636
  }
645
637
 
646
- const getToggleButton = () => this.matches(SELECTOR_DATA_TOGGLE) ? this : SelectorEngine__default['default'].prev(this, SELECTOR_DATA_TOGGLE)[0];
638
+ const getToggleButton = this.matches(SELECTOR_DATA_TOGGLE) ? this : SelectorEngine__default['default'].prev(this, SELECTOR_DATA_TOGGLE)[0];
639
+ const instance = Dropdown.getOrCreateInstance(getToggleButton);
647
640
 
648
641
  if (event.key === ESCAPE_KEY) {
649
- getToggleButton().focus();
650
- Dropdown.clearMenus();
642
+ instance.hide();
651
643
  return;
652
644
  }
653
645
 
654
646
  if (event.key === ARROW_UP_KEY || event.key === ARROW_DOWN_KEY) {
655
647
  if (!isActive) {
656
- getToggleButton().click();
648
+ instance.show();
657
649
  }
658
650
 
659
- Dropdown.getInstance(getToggleButton())._selectMenuItem(event);
651
+ instance._selectMenuItem(event);
660
652
 
661
653
  return;
662
654
  }
@@ -680,7 +672,7 @@
680
672
  EventHandler__default['default'].on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
681
673
  EventHandler__default['default'].on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
682
674
  event.preventDefault();
683
- Dropdown.dropdownInterface(this);
675
+ Dropdown.getOrCreateInstance(this).toggle();
684
676
  });
685
677
  /**
686
678
  * ------------------------------------------------------------------------
@@ -1,21 +1,27 @@
1
1
  /*!
2
- * Bootstrap modal.js v5.0.2 (https://getbootstrap.com/)
2
+ * Bootstrap modal.js v5.1.0 (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/selector-engine.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./base-component.js')) :
8
- typeof define === 'function' && define.amd ? define(['./dom/selector-engine', './dom/event-handler', './dom/manipulator', './base-component'], factory) :
9
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Modal = factory(global.SelectorEngine, global.EventHandler, global.Manipulator, global.Base));
10
- }(this, (function (SelectorEngine, EventHandler, Manipulator, BaseComponent) { 'use strict';
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js'), require('./base-component.js')) :
8
+ typeof define === 'function' && define.amd ? define(['./dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Modal = factory(global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base));
10
+ }(this, (function (EventHandler, Manipulator, 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 SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
15
14
  var EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
16
15
  var Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
16
+ var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
17
17
  var BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
18
18
 
19
+ /**
20
+ * --------------------------------------------------------------------------
21
+ * Bootstrap (v5.1.0): util/index.js
22
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
23
+ * --------------------------------------------------------------------------
24
+ */
19
25
  const MILLISECONDS_MULTIPLIER = 1000;
20
26
  const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
21
27
 
@@ -102,7 +108,7 @@
102
108
  }
103
109
 
104
110
  if (typeof obj === 'string' && obj.length > 0) {
105
- return SelectorEngine__default['default'].findOne(obj);
111
+ return document.querySelector(obj);
106
112
  }
107
113
 
108
114
  return null;
@@ -128,7 +134,35 @@
128
134
  return getComputedStyle(element).getPropertyValue('visibility') === 'visible';
129
135
  };
130
136
 
131
- const reflow = element => element.offsetHeight;
137
+ const isDisabled = element => {
138
+ if (!element || element.nodeType !== Node.ELEMENT_NODE) {
139
+ return true;
140
+ }
141
+
142
+ if (element.classList.contains('disabled')) {
143
+ return true;
144
+ }
145
+
146
+ if (typeof element.disabled !== 'undefined') {
147
+ return element.disabled;
148
+ }
149
+
150
+ return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
151
+ };
152
+ /**
153
+ * Trick to restart an element's animation
154
+ *
155
+ * @param {HTMLElement} element
156
+ * @return void
157
+ *
158
+ * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
159
+ */
160
+
161
+
162
+ const reflow = element => {
163
+ // eslint-disable-next-line no-unused-expressions
164
+ element.offsetHeight;
165
+ };
132
166
 
133
167
  const getjQuery = () => {
134
168
  const {
@@ -218,7 +252,7 @@
218
252
 
219
253
  /**
220
254
  * --------------------------------------------------------------------------
221
- * Bootstrap (v5.0.2): util/scrollBar.js
255
+ * Bootstrap (v5.1.0): util/scrollBar.js
222
256
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
223
257
  * --------------------------------------------------------------------------
224
258
  */
@@ -322,11 +356,12 @@
322
356
 
323
357
  /**
324
358
  * --------------------------------------------------------------------------
325
- * Bootstrap (v5.0.2): util/backdrop.js
359
+ * Bootstrap (v5.1.0): util/backdrop.js
326
360
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
327
361
  * --------------------------------------------------------------------------
328
362
  */
329
- const Default$1 = {
363
+ const Default$2 = {
364
+ className: 'modal-backdrop',
330
365
  isVisible: true,
331
366
  // if false, we use the backdrop helper without adding any element to the dom
332
367
  isAnimated: false,
@@ -334,17 +369,17 @@
334
369
  // give the choice to place backdrop under different elements
335
370
  clickCallback: null
336
371
  };
337
- const DefaultType$1 = {
372
+ const DefaultType$2 = {
373
+ className: 'string',
338
374
  isVisible: 'boolean',
339
375
  isAnimated: 'boolean',
340
376
  rootElement: '(element|string)',
341
377
  clickCallback: '(function|null)'
342
378
  };
343
- const NAME$1 = 'backdrop';
344
- const CLASS_NAME_BACKDROP = 'modal-backdrop';
379
+ const NAME$2 = 'backdrop';
345
380
  const CLASS_NAME_FADE$1 = 'fade';
346
381
  const CLASS_NAME_SHOW$1 = 'show';
347
- const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$1}`;
382
+ const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$2}`;
348
383
 
349
384
  class Backdrop {
350
385
  constructor(config) {
@@ -390,7 +425,7 @@
390
425
  _getElement() {
391
426
  if (!this._element) {
392
427
  const backdrop = document.createElement('div');
393
- backdrop.className = CLASS_NAME_BACKDROP;
428
+ backdrop.className = this._config.className;
394
429
 
395
430
  if (this._config.isAnimated) {
396
431
  backdrop.classList.add(CLASS_NAME_FADE$1);
@@ -403,12 +438,12 @@
403
438
  }
404
439
 
405
440
  _getConfig(config) {
406
- config = { ...Default$1,
441
+ config = { ...Default$2,
407
442
  ...(typeof config === 'object' ? config : {})
408
443
  }; // use getElement() with the default "body" to get a fresh Element on each instantiation
409
444
 
410
445
  config.rootElement = getElement(config.rootElement);
411
- typeCheckConfig(NAME$1, config, DefaultType$1);
446
+ typeCheckConfig(NAME$2, config, DefaultType$2);
412
447
  return config;
413
448
  }
414
449
 
@@ -417,7 +452,7 @@
417
452
  return;
418
453
  }
419
454
 
420
- this._config.rootElement.appendChild(this._getElement());
455
+ this._config.rootElement.append(this._getElement());
421
456
 
422
457
  EventHandler__default['default'].on(this._getElement(), EVENT_MOUSEDOWN, () => {
423
458
  execute(this._config.clickCallback);
@@ -445,7 +480,136 @@
445
480
 
446
481
  /**
447
482
  * --------------------------------------------------------------------------
448
- * Bootstrap (v5.0.2): modal.js
483
+ * Bootstrap (v5.1.0): util/focustrap.js
484
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
485
+ * --------------------------------------------------------------------------
486
+ */
487
+ const Default$1 = {
488
+ trapElement: null,
489
+ // The element to trap focus inside of
490
+ autofocus: true
491
+ };
492
+ const DefaultType$1 = {
493
+ trapElement: 'element',
494
+ autofocus: 'boolean'
495
+ };
496
+ const NAME$1 = 'focustrap';
497
+ const DATA_KEY$1 = 'bs.focustrap';
498
+ const EVENT_KEY$1 = `.${DATA_KEY$1}`;
499
+ const EVENT_FOCUSIN = `focusin${EVENT_KEY$1}`;
500
+ const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$1}`;
501
+ const TAB_KEY = 'Tab';
502
+ const TAB_NAV_FORWARD = 'forward';
503
+ const TAB_NAV_BACKWARD = 'backward';
504
+
505
+ class FocusTrap {
506
+ constructor(config) {
507
+ this._config = this._getConfig(config);
508
+ this._isActive = false;
509
+ this._lastTabNavDirection = null;
510
+ }
511
+
512
+ activate() {
513
+ const {
514
+ trapElement,
515
+ autofocus
516
+ } = this._config;
517
+
518
+ if (this._isActive) {
519
+ return;
520
+ }
521
+
522
+ if (autofocus) {
523
+ trapElement.focus();
524
+ }
525
+
526
+ EventHandler__default['default'].off(document, EVENT_KEY$1); // guard against infinite focus loop
527
+
528
+ EventHandler__default['default'].on(document, EVENT_FOCUSIN, event => this._handleFocusin(event));
529
+ EventHandler__default['default'].on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event));
530
+ this._isActive = true;
531
+ }
532
+
533
+ deactivate() {
534
+ if (!this._isActive) {
535
+ return;
536
+ }
537
+
538
+ this._isActive = false;
539
+ EventHandler__default['default'].off(document, EVENT_KEY$1);
540
+ } // Private
541
+
542
+
543
+ _handleFocusin(event) {
544
+ const {
545
+ target
546
+ } = event;
547
+ const {
548
+ trapElement
549
+ } = this._config;
550
+
551
+ if (target === document || target === trapElement || trapElement.contains(target)) {
552
+ return;
553
+ }
554
+
555
+ const elements = SelectorEngine__default['default'].focusableChildren(trapElement);
556
+
557
+ if (elements.length === 0) {
558
+ trapElement.focus();
559
+ } else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) {
560
+ elements[elements.length - 1].focus();
561
+ } else {
562
+ elements[0].focus();
563
+ }
564
+ }
565
+
566
+ _handleKeydown(event) {
567
+ if (event.key !== TAB_KEY) {
568
+ return;
569
+ }
570
+
571
+ this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD;
572
+ }
573
+
574
+ _getConfig(config) {
575
+ config = { ...Default$1,
576
+ ...(typeof config === 'object' ? config : {})
577
+ };
578
+ typeCheckConfig(NAME$1, config, DefaultType$1);
579
+ return config;
580
+ }
581
+
582
+ }
583
+
584
+ /**
585
+ * --------------------------------------------------------------------------
586
+ * Bootstrap (v5.1.0): util/component-functions.js
587
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
588
+ * --------------------------------------------------------------------------
589
+ */
590
+
591
+ const enableDismissTrigger = (component, method = 'hide') => {
592
+ const clickEvent = `click.dismiss${component.EVENT_KEY}`;
593
+ const name = component.NAME;
594
+ EventHandler__default['default'].on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
595
+ if (['A', 'AREA'].includes(this.tagName)) {
596
+ event.preventDefault();
597
+ }
598
+
599
+ if (isDisabled(this)) {
600
+ return;
601
+ }
602
+
603
+ const target = getElementFromSelector(this) || this.closest(`.${name}`);
604
+ const instance = component.getOrCreateInstance(target); // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
605
+
606
+ instance[method]();
607
+ });
608
+ };
609
+
610
+ /**
611
+ * --------------------------------------------------------------------------
612
+ * Bootstrap (v5.1.0): modal.js
449
613
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
450
614
  * --------------------------------------------------------------------------
451
615
  */
@@ -475,7 +639,6 @@
475
639
  const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
476
640
  const EVENT_SHOW = `show${EVENT_KEY}`;
477
641
  const EVENT_SHOWN = `shown${EVENT_KEY}`;
478
- const EVENT_FOCUSIN = `focusin${EVENT_KEY}`;
479
642
  const EVENT_RESIZE = `resize${EVENT_KEY}`;
480
643
  const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY}`;
481
644
  const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY}`;
@@ -489,7 +652,6 @@
489
652
  const SELECTOR_DIALOG = '.modal-dialog';
490
653
  const SELECTOR_MODAL_BODY = '.modal-body';
491
654
  const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="modal"]';
492
- const SELECTOR_DATA_DISMISS = '[data-bs-dismiss="modal"]';
493
655
  /**
494
656
  * ------------------------------------------------------------------------
495
657
  * Class Definition
@@ -502,6 +664,7 @@
502
664
  this._config = this._getConfig(config);
503
665
  this._dialog = SelectorEngine__default['default'].findOne(SELECTOR_DIALOG, this._element);
504
666
  this._backdrop = this._initializeBackDrop();
667
+ this._focustrap = this._initializeFocusTrap();
505
668
  this._isShown = false;
506
669
  this._ignoreBackdropClick = false;
507
670
  this._isTransitioning = false;
@@ -551,7 +714,6 @@
551
714
 
552
715
  this._setResizeEvent();
553
716
 
554
- EventHandler__default['default'].on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, event => this.hide(event));
555
717
  EventHandler__default['default'].on(this._dialog, EVENT_MOUSEDOWN_DISMISS, () => {
556
718
  EventHandler__default['default'].one(this._element, EVENT_MOUSEUP_DISMISS, event => {
557
719
  if (event.target === this._element) {
@@ -563,11 +725,7 @@
563
725
  this._showBackdrop(() => this._showElement(relatedTarget));
564
726
  }
565
727
 
566
- hide(event) {
567
- if (event && ['A', 'AREA'].includes(event.target.tagName)) {
568
- event.preventDefault();
569
- }
570
-
728
+ hide() {
571
729
  if (!this._isShown || this._isTransitioning) {
572
730
  return;
573
731
  }
@@ -590,7 +748,7 @@
590
748
 
591
749
  this._setResizeEvent();
592
750
 
593
- EventHandler__default['default'].off(document, EVENT_FOCUSIN);
751
+ this._focustrap.deactivate();
594
752
 
595
753
  this._element.classList.remove(CLASS_NAME_SHOW);
596
754
 
@@ -605,14 +763,9 @@
605
763
 
606
764
  this._backdrop.dispose();
607
765
 
608
- super.dispose();
609
- /**
610
- * `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API`
611
- * Do not move `document` in `htmlElements` array
612
- * It will remove `EVENT_CLICK_DATA_API` event that should remain
613
- */
766
+ this._focustrap.deactivate();
614
767
 
615
- EventHandler__default['default'].off(document, EVENT_FOCUSIN);
768
+ super.dispose();
616
769
  }
617
770
 
618
771
  handleUpdate() {
@@ -628,6 +781,12 @@
628
781
  });
629
782
  }
630
783
 
784
+ _initializeFocusTrap() {
785
+ return new FocusTrap({
786
+ trapElement: this._element
787
+ });
788
+ }
789
+
631
790
  _getConfig(config) {
632
791
  config = { ...Default,
633
792
  ...Manipulator__default['default'].getDataAttributes(this._element),
@@ -644,7 +803,7 @@
644
803
 
645
804
  if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
646
805
  // Don't move modal's DOM position
647
- document.body.appendChild(this._element);
806
+ document.body.append(this._element);
648
807
  }
649
808
 
650
809
  this._element.style.display = 'block';
@@ -667,13 +826,9 @@
667
826
 
668
827
  this._element.classList.add(CLASS_NAME_SHOW);
669
828
 
670
- if (this._config.focus) {
671
- this._enforceFocus();
672
- }
673
-
674
829
  const transitionComplete = () => {
675
830
  if (this._config.focus) {
676
- this._element.focus();
831
+ this._focustrap.activate();
677
832
  }
678
833
 
679
834
  this._isTransitioning = false;
@@ -685,16 +840,6 @@
685
840
  this._queueCallback(transitionComplete, this._dialog, isAnimated);
686
841
  }
687
842
 
688
- _enforceFocus() {
689
- EventHandler__default['default'].off(document, EVENT_FOCUSIN); // guard against infinite focus loop
690
-
691
- EventHandler__default['default'].on(document, EVENT_FOCUSIN, event => {
692
- if (document !== event.target && this._element !== event.target && !this._element.contains(event.target)) {
693
- this._element.focus();
694
- }
695
- });
696
- }
697
-
698
843
  _setEscapeEvent() {
699
844
  if (this._isShown) {
700
845
  EventHandler__default['default'].on(this._element, EVENT_KEYDOWN_DISMISS, event => {
@@ -873,6 +1018,7 @@
873
1018
  const data = Modal.getOrCreateInstance(target);
874
1019
  data.toggle(this);
875
1020
  });
1021
+ enableDismissTrigger(Modal);
876
1022
  /**
877
1023
  * ------------------------------------------------------------------------
878
1024
  * jQuery