bootstrap 5.0.0.beta2 → 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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/assets/javascripts/bootstrap-sprockets.js +8 -7
  4. data/assets/javascripts/bootstrap.js +2525 -2460
  5. data/assets/javascripts/bootstrap.min.js +2 -2
  6. data/assets/javascripts/bootstrap/alert.js +77 -179
  7. data/assets/javascripts/bootstrap/base-component.js +140 -38
  8. data/assets/javascripts/bootstrap/button.js +54 -100
  9. data/assets/javascripts/bootstrap/carousel.js +335 -451
  10. data/assets/javascripts/bootstrap/collapse.js +195 -303
  11. data/assets/javascripts/bootstrap/dom/data.js +34 -47
  12. data/assets/javascripts/bootstrap/dom/event-handler.js +95 -90
  13. data/assets/javascripts/bootstrap/dom/manipulator.js +23 -21
  14. data/assets/javascripts/bootstrap/dom/selector-engine.js +20 -28
  15. data/assets/javascripts/bootstrap/dropdown.js +323 -358
  16. data/assets/javascripts/bootstrap/modal.js +537 -489
  17. data/assets/javascripts/bootstrap/offcanvas.js +720 -0
  18. data/assets/javascripts/bootstrap/popover.js +112 -180
  19. data/assets/javascripts/bootstrap/scrollspy.js +167 -235
  20. data/assets/javascripts/bootstrap/tab.js +121 -188
  21. data/assets/javascripts/bootstrap/toast.js +166 -243
  22. data/assets/javascripts/bootstrap/tooltip.js +333 -495
  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/_accordion.scss +24 -32
  27. data/assets/stylesheets/bootstrap/_buttons.scss +2 -0
  28. data/assets/stylesheets/bootstrap/_card.scss +6 -6
  29. data/assets/stylesheets/bootstrap/_carousel.scss +2 -2
  30. data/assets/stylesheets/bootstrap/_dropdown.scss +14 -23
  31. data/assets/stylesheets/bootstrap/_functions.scss +61 -3
  32. data/assets/stylesheets/bootstrap/_images.scss +1 -1
  33. data/assets/stylesheets/bootstrap/_list-group.scss +16 -5
  34. data/assets/stylesheets/bootstrap/_mixins.scss +1 -0
  35. data/assets/stylesheets/bootstrap/_modal.scss +8 -24
  36. data/assets/stylesheets/bootstrap/_nav.scss +7 -0
  37. data/assets/stylesheets/bootstrap/_navbar.scss +2 -0
  38. data/assets/stylesheets/bootstrap/_offcanvas.scss +79 -0
  39. data/assets/stylesheets/bootstrap/_popover.scss +10 -10
  40. data/assets/stylesheets/bootstrap/_progress.scss +3 -0
  41. data/assets/stylesheets/bootstrap/_reboot.scss +7 -21
  42. data/assets/stylesheets/bootstrap/_spinners.scss +6 -2
  43. data/assets/stylesheets/bootstrap/_tables.scss +1 -0
  44. data/assets/stylesheets/bootstrap/_toasts.scss +1 -1
  45. data/assets/stylesheets/bootstrap/_tooltip.scss +4 -4
  46. data/assets/stylesheets/bootstrap/_transitions.scss +2 -0
  47. data/assets/stylesheets/bootstrap/_utilities.scss +65 -37
  48. data/assets/stylesheets/bootstrap/_variables.scss +162 -50
  49. data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +1 -1
  50. data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +3 -1
  51. data/assets/stylesheets/bootstrap/forms/_form-check.scss +1 -1
  52. data/assets/stylesheets/bootstrap/forms/_form-control.scss +0 -4
  53. data/assets/stylesheets/bootstrap/forms/_form-range.scss +1 -1
  54. data/assets/stylesheets/bootstrap/forms/_form-select.scss +3 -0
  55. data/assets/stylesheets/bootstrap/mixins/_alert.scss +2 -0
  56. data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +2 -0
  57. data/assets/stylesheets/bootstrap/mixins/_buttons.scss +7 -2
  58. data/assets/stylesheets/bootstrap/mixins/_caret.scss +2 -0
  59. data/assets/stylesheets/bootstrap/mixins/_color-scheme.scss +7 -0
  60. data/assets/stylesheets/bootstrap/mixins/_forms.scss +25 -5
  61. data/assets/stylesheets/bootstrap/mixins/_grid.scss +23 -11
  62. data/assets/stylesheets/bootstrap/mixins/_list-group.scss +2 -0
  63. data/assets/stylesheets/bootstrap/mixins/_pagination.scss +2 -0
  64. data/assets/stylesheets/bootstrap/vendor/_rfs.scss +55 -13
  65. data/bootstrap.gemspec +1 -1
  66. data/lib/bootstrap/version.rb +2 -2
  67. data/tasks/updater/js.rb +1 -1
  68. data/tasks/updater/network.rb +7 -1
  69. metadata +9 -6
@@ -1,62 +1,23 @@
1
1
  /*!
2
- * Bootstrap button.js v5.0.0-beta2 (https://getbootstrap.com/)
2
+ * Bootstrap button.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('./dom/data.js'), require('./dom/event-handler.js'), require('./base-component.js')) :
8
- typeof define === 'function' && define.amd ? define(['./dom/data', './dom/event-handler', './base-component'], factory) :
9
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Button = factory(global.Data, global.EventHandler, global.Base));
10
- }(this, (function (Data, EventHandler, BaseComponent) { 'use strict';
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/selector-engine.js'), require('./dom/event-handler.js'), require('./base-component.js')) :
8
+ typeof define === 'function' && define.amd ? define(['./dom/selector-engine', './dom/event-handler', './base-component'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Button = factory(global.SelectorEngine, global.EventHandler, global.Base));
10
+ }(this, (function (SelectorEngine, EventHandler, 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 BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
17
16
 
18
- function _defineProperties(target, props) {
19
- for (var i = 0; i < props.length; i++) {
20
- var descriptor = props[i];
21
- descriptor.enumerable = descriptor.enumerable || false;
22
- descriptor.configurable = true;
23
- if ("value" in descriptor) descriptor.writable = true;
24
- Object.defineProperty(target, descriptor.key, descriptor);
25
- }
26
- }
27
-
28
- function _createClass(Constructor, protoProps, staticProps) {
29
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
30
- if (staticProps) _defineProperties(Constructor, staticProps);
31
- return Constructor;
32
- }
33
-
34
- function _inheritsLoose(subClass, superClass) {
35
- subClass.prototype = Object.create(superClass.prototype);
36
- subClass.prototype.constructor = subClass;
37
-
38
- _setPrototypeOf(subClass, superClass);
39
- }
40
-
41
- function _setPrototypeOf(o, p) {
42
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
43
- o.__proto__ = p;
44
- return o;
45
- };
46
-
47
- return _setPrototypeOf(o, p);
48
- }
49
-
50
- /**
51
- * --------------------------------------------------------------------------
52
- * Bootstrap (v5.0.0-beta2): util/index.js
53
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
54
- * --------------------------------------------------------------------------
55
- */
56
-
57
- var getjQuery = function getjQuery() {
58
- var _window = window,
59
- jQuery = _window.jQuery;
17
+ const getjQuery = () => {
18
+ const {
19
+ jQuery
20
+ } = window;
60
21
 
61
22
  if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
62
23
  return jQuery;
@@ -65,27 +26,35 @@
65
26
  return null;
66
27
  };
67
28
 
68
- var onDOMContentLoaded = function onDOMContentLoaded(callback) {
29
+ const DOMContentLoadedCallbacks = [];
30
+
31
+ const onDOMContentLoaded = callback => {
69
32
  if (document.readyState === 'loading') {
70
- document.addEventListener('DOMContentLoaded', callback);
33
+ // add listener on the first call when the document is in loading state
34
+ if (!DOMContentLoadedCallbacks.length) {
35
+ document.addEventListener('DOMContentLoaded', () => {
36
+ DOMContentLoadedCallbacks.forEach(callback => callback());
37
+ });
38
+ }
39
+
40
+ DOMContentLoadedCallbacks.push(callback);
71
41
  } else {
72
42
  callback();
73
43
  }
74
44
  };
75
45
 
76
- document.documentElement.dir === 'rtl';
77
-
78
- var defineJQueryPlugin = function defineJQueryPlugin(name, plugin) {
79
- onDOMContentLoaded(function () {
80
- var $ = getjQuery();
46
+ const defineJQueryPlugin = plugin => {
47
+ onDOMContentLoaded(() => {
48
+ const $ = getjQuery();
81
49
  /* istanbul ignore if */
82
50
 
83
51
  if ($) {
84
- var JQUERY_NO_CONFLICT = $.fn[name];
52
+ const name = plugin.NAME;
53
+ const JQUERY_NO_CONFLICT = $.fn[name];
85
54
  $.fn[name] = plugin.jQueryInterface;
86
55
  $.fn[name].Constructor = plugin;
87
56
 
88
- $.fn[name].noConflict = function () {
57
+ $.fn[name].noConflict = () => {
89
58
  $.fn[name] = JQUERY_NO_CONFLICT;
90
59
  return plugin.jQueryInterface;
91
60
  };
@@ -93,65 +62,55 @@
93
62
  });
94
63
  };
95
64
 
65
+ /**
66
+ * --------------------------------------------------------------------------
67
+ * Bootstrap (v5.0.2): button.js
68
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
69
+ * --------------------------------------------------------------------------
70
+ */
96
71
  /**
97
72
  * ------------------------------------------------------------------------
98
73
  * Constants
99
74
  * ------------------------------------------------------------------------
100
75
  */
101
76
 
102
- var NAME = 'button';
103
- var DATA_KEY = 'bs.button';
104
- var EVENT_KEY = "." + DATA_KEY;
105
- var DATA_API_KEY = '.data-api';
106
- var CLASS_NAME_ACTIVE = 'active';
107
- var SELECTOR_DATA_TOGGLE = '[data-bs-toggle="button"]';
108
- var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY;
77
+ const NAME = 'button';
78
+ const DATA_KEY = 'bs.button';
79
+ const EVENT_KEY = `.${DATA_KEY}`;
80
+ const DATA_API_KEY = '.data-api';
81
+ const CLASS_NAME_ACTIVE = 'active';
82
+ const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="button"]';
83
+ const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
109
84
  /**
110
85
  * ------------------------------------------------------------------------
111
86
  * Class Definition
112
87
  * ------------------------------------------------------------------------
113
88
  */
114
89
 
115
- var Button = /*#__PURE__*/function (_BaseComponent) {
116
- _inheritsLoose(Button, _BaseComponent);
90
+ class Button extends BaseComponent__default['default'] {
91
+ // Getters
92
+ static get NAME() {
93
+ return NAME;
94
+ } // Public
117
95
 
118
- function Button() {
119
- return _BaseComponent.apply(this, arguments) || this;
120
- }
121
96
 
122
- var _proto = Button.prototype;
123
-
124
- // Public
125
- _proto.toggle = function toggle() {
97
+ toggle() {
126
98
  // Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method
127
99
  this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE));
128
100
  } // Static
129
- ;
130
101
 
131
- Button.jQueryInterface = function jQueryInterface(config) {
132
- return this.each(function () {
133
- var data = Data__default['default'].getData(this, DATA_KEY);
134
102
 
135
- if (!data) {
136
- data = new Button(this);
137
- }
103
+ static jQueryInterface(config) {
104
+ return this.each(function () {
105
+ const data = Button.getOrCreateInstance(this);
138
106
 
139
107
  if (config === 'toggle') {
140
108
  data[config]();
141
109
  }
142
110
  });
143
- };
144
-
145
- _createClass(Button, null, [{
146
- key: "DATA_KEY",
147
- get: // Getters
148
- function get() {
149
- return DATA_KEY;
150
- }
151
- }]);
111
+ }
152
112
 
153
- return Button;
154
- }(BaseComponent__default['default']);
113
+ }
155
114
  /**
156
115
  * ------------------------------------------------------------------------
157
116
  * Data Api implementation
@@ -159,15 +118,10 @@
159
118
  */
160
119
 
161
120
 
162
- EventHandler__default['default'].on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
121
+ EventHandler__default['default'].on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, event => {
163
122
  event.preventDefault();
164
- var button = event.target.closest(SELECTOR_DATA_TOGGLE);
165
- var data = Data__default['default'].getData(button, DATA_KEY);
166
-
167
- if (!data) {
168
- data = new Button(button);
169
- }
170
-
123
+ const button = event.target.closest(SELECTOR_DATA_TOGGLE);
124
+ const data = Button.getOrCreateInstance(button);
171
125
  data.toggle();
172
126
  });
173
127
  /**
@@ -177,7 +131,7 @@
177
131
  * add .Button to jQuery only if jQuery is present
178
132
  */
179
133
 
180
- defineJQueryPlugin(NAME, Button);
134
+ defineJQueryPlugin(Button);
181
135
 
182
136
  return Button;
183
137
 
@@ -1,94 +1,36 @@
1
1
  /*!
2
- * Bootstrap carousel.js v5.0.0-beta2 (https://getbootstrap.com/)
2
+ * Bootstrap carousel.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('./dom/data.js'), 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/data', './dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) :
9
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Carousel = factory(global.Data, global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base));
10
- }(this, (function (Data, EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict';
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.Carousel = factory(global.SelectorEngine, global.EventHandler, global.Manipulator, global.Base));
10
+ }(this, (function (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
 
14
- var Data__default = /*#__PURE__*/_interopDefaultLegacy(Data);
14
+ var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
15
15
  var EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
16
16
  var Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
17
- var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
18
17
  var BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
19
18
 
20
- function _defineProperties(target, props) {
21
- for (var i = 0; i < props.length; i++) {
22
- var descriptor = props[i];
23
- descriptor.enumerable = descriptor.enumerable || false;
24
- descriptor.configurable = true;
25
- if ("value" in descriptor) descriptor.writable = true;
26
- Object.defineProperty(target, descriptor.key, descriptor);
27
- }
28
- }
29
-
30
- function _createClass(Constructor, protoProps, staticProps) {
31
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
32
- if (staticProps) _defineProperties(Constructor, staticProps);
33
- return Constructor;
34
- }
35
-
36
- function _extends() {
37
- _extends = Object.assign || function (target) {
38
- for (var i = 1; i < arguments.length; i++) {
39
- var source = arguments[i];
40
-
41
- for (var key in source) {
42
- if (Object.prototype.hasOwnProperty.call(source, key)) {
43
- target[key] = source[key];
44
- }
45
- }
46
- }
47
-
48
- return target;
49
- };
50
-
51
- return _extends.apply(this, arguments);
52
- }
53
-
54
- function _inheritsLoose(subClass, superClass) {
55
- subClass.prototype = Object.create(superClass.prototype);
56
- subClass.prototype.constructor = subClass;
57
-
58
- _setPrototypeOf(subClass, superClass);
59
- }
60
-
61
- function _setPrototypeOf(o, p) {
62
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
63
- o.__proto__ = p;
64
- return o;
65
- };
66
-
67
- return _setPrototypeOf(o, p);
68
- }
69
-
70
- /**
71
- * --------------------------------------------------------------------------
72
- * Bootstrap (v5.0.0-beta2): util/index.js
73
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
74
- * --------------------------------------------------------------------------
75
- */
76
- var MILLISECONDS_MULTIPLIER = 1000;
77
- var TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
19
+ const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
78
20
 
79
- var toType = function toType(obj) {
21
+ const toType = obj => {
80
22
  if (obj === null || obj === undefined) {
81
- return "" + obj;
23
+ return `${obj}`;
82
24
  }
83
25
 
84
26
  return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
85
27
  };
86
28
 
87
- var getSelector = function getSelector(element) {
88
- var selector = element.getAttribute('data-bs-target');
29
+ const getSelector = element => {
30
+ let selector = element.getAttribute('data-bs-target');
89
31
 
90
32
  if (!selector || selector === '#') {
91
- var hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes,
33
+ let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes,
92
34
  // so everything starting with `#` or `.`. If a "real" URL is used as the selector,
93
35
  // `document.querySelector` will rightfully complain it is invalid.
94
36
  // See https://github.com/twbs/bootstrap/issues/32273
@@ -99,7 +41,7 @@
99
41
 
100
42
 
101
43
  if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) {
102
- hrefAttr = '#' + hrefAttr.split('#')[1];
44
+ hrefAttr = `#${hrefAttr.split('#')[1]}`;
103
45
  }
104
46
 
105
47
  selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
@@ -108,93 +50,53 @@
108
50
  return selector;
109
51
  };
110
52
 
111
- var getElementFromSelector = function getElementFromSelector(element) {
112
- var selector = getSelector(element);
53
+ const getElementFromSelector = element => {
54
+ const selector = getSelector(element);
113
55
  return selector ? document.querySelector(selector) : null;
114
56
  };
115
57
 
116
- var getTransitionDurationFromElement = function getTransitionDurationFromElement(element) {
117
- if (!element) {
118
- return 0;
119
- } // Get transition-duration of the element
120
-
121
-
122
- var _window$getComputedSt = window.getComputedStyle(element),
123
- transitionDuration = _window$getComputedSt.transitionDuration,
124
- transitionDelay = _window$getComputedSt.transitionDelay;
125
-
126
- var floatTransitionDuration = Number.parseFloat(transitionDuration);
127
- var floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
128
-
129
- if (!floatTransitionDuration && !floatTransitionDelay) {
130
- return 0;
131
- } // If multiple durations are defined, take the first
132
-
133
-
134
- transitionDuration = transitionDuration.split(',')[0];
135
- transitionDelay = transitionDelay.split(',')[0];
136
- return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
137
- };
138
-
139
- var triggerTransitionEnd = function triggerTransitionEnd(element) {
58
+ const triggerTransitionEnd = element => {
140
59
  element.dispatchEvent(new Event(TRANSITION_END));
141
60
  };
142
61
 
143
- var isElement = function isElement(obj) {
144
- return (obj[0] || obj).nodeType;
145
- };
146
-
147
- var emulateTransitionEnd = function emulateTransitionEnd(element, duration) {
148
- var called = false;
149
- var durationPadding = 5;
150
- var emulatedDuration = duration + durationPadding;
62
+ const isElement = obj => {
63
+ if (!obj || typeof obj !== 'object') {
64
+ return false;
65
+ }
151
66
 
152
- function listener() {
153
- called = true;
154
- element.removeEventListener(TRANSITION_END, listener);
67
+ if (typeof obj.jquery !== 'undefined') {
68
+ obj = obj[0];
155
69
  }
156
70
 
157
- element.addEventListener(TRANSITION_END, listener);
158
- setTimeout(function () {
159
- if (!called) {
160
- triggerTransitionEnd(element);
161
- }
162
- }, emulatedDuration);
71
+ return typeof obj.nodeType !== 'undefined';
163
72
  };
164
73
 
165
- var typeCheckConfig = function typeCheckConfig(componentName, config, configTypes) {
166
- Object.keys(configTypes).forEach(function (property) {
167
- var expectedTypes = configTypes[property];
168
- var value = config[property];
169
- var valueType = value && isElement(value) ? 'element' : toType(value);
74
+ const typeCheckConfig = (componentName, config, configTypes) => {
75
+ Object.keys(configTypes).forEach(property => {
76
+ const expectedTypes = configTypes[property];
77
+ const value = config[property];
78
+ const valueType = value && isElement(value) ? 'element' : toType(value);
170
79
 
171
80
  if (!new RegExp(expectedTypes).test(valueType)) {
172
- throw new TypeError(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
81
+ throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
173
82
  }
174
83
  });
175
84
  };
176
85
 
177
- var isVisible = function isVisible(element) {
178
- if (!element) {
86
+ const isVisible = element => {
87
+ if (!isElement(element) || element.getClientRects().length === 0) {
179
88
  return false;
180
89
  }
181
90
 
182
- if (element.style && element.parentNode && element.parentNode.style) {
183
- var elementStyle = getComputedStyle(element);
184
- var parentNodeStyle = getComputedStyle(element.parentNode);
185
- return elementStyle.display !== 'none' && parentNodeStyle.display !== 'none' && elementStyle.visibility !== 'hidden';
186
- }
187
-
188
- return false;
91
+ return getComputedStyle(element).getPropertyValue('visibility') === 'visible';
189
92
  };
190
93
 
191
- var reflow = function reflow(element) {
192
- return element.offsetHeight;
193
- };
94
+ const reflow = element => element.offsetHeight;
194
95
 
195
- var getjQuery = function getjQuery() {
196
- var _window = window,
197
- jQuery = _window.jQuery;
96
+ const getjQuery = () => {
97
+ const {
98
+ jQuery
99
+ } = window;
198
100
 
199
101
  if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
200
102
  return jQuery;
@@ -203,50 +105,93 @@
203
105
  return null;
204
106
  };
205
107
 
206
- var onDOMContentLoaded = function onDOMContentLoaded(callback) {
108
+ const DOMContentLoadedCallbacks = [];
109
+
110
+ const onDOMContentLoaded = callback => {
207
111
  if (document.readyState === 'loading') {
208
- document.addEventListener('DOMContentLoaded', callback);
112
+ // add listener on the first call when the document is in loading state
113
+ if (!DOMContentLoadedCallbacks.length) {
114
+ document.addEventListener('DOMContentLoaded', () => {
115
+ DOMContentLoadedCallbacks.forEach(callback => callback());
116
+ });
117
+ }
118
+
119
+ DOMContentLoadedCallbacks.push(callback);
209
120
  } else {
210
121
  callback();
211
122
  }
212
123
  };
213
124
 
214
- var isRTL = document.documentElement.dir === 'rtl';
125
+ const isRTL = () => document.documentElement.dir === 'rtl';
215
126
 
216
- var defineJQueryPlugin = function defineJQueryPlugin(name, plugin) {
217
- onDOMContentLoaded(function () {
218
- var $ = getjQuery();
127
+ const defineJQueryPlugin = plugin => {
128
+ onDOMContentLoaded(() => {
129
+ const $ = getjQuery();
219
130
  /* istanbul ignore if */
220
131
 
221
132
  if ($) {
222
- var JQUERY_NO_CONFLICT = $.fn[name];
133
+ const name = plugin.NAME;
134
+ const JQUERY_NO_CONFLICT = $.fn[name];
223
135
  $.fn[name] = plugin.jQueryInterface;
224
136
  $.fn[name].Constructor = plugin;
225
137
 
226
- $.fn[name].noConflict = function () {
138
+ $.fn[name].noConflict = () => {
227
139
  $.fn[name] = JQUERY_NO_CONFLICT;
228
140
  return plugin.jQueryInterface;
229
141
  };
230
142
  }
231
143
  });
232
144
  };
145
+ /**
146
+ * Return the previous/next element of a list.
147
+ *
148
+ * @param {array} list The list of elements
149
+ * @param activeElement The active element
150
+ * @param shouldGetNext Choose to get next or previous element
151
+ * @param isCycleAllowed
152
+ * @return {Element|elem} The proper element
153
+ */
154
+
155
+
156
+ const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
157
+ 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
158
+
159
+ if (index === -1) {
160
+ return list[!shouldGetNext && isCycleAllowed ? list.length - 1 : 0];
161
+ }
162
+
163
+ const listLength = list.length;
164
+ index += shouldGetNext ? 1 : -1;
233
165
 
166
+ if (isCycleAllowed) {
167
+ index = (index + listLength) % listLength;
168
+ }
169
+
170
+ return list[Math.max(0, Math.min(index, listLength - 1))];
171
+ };
172
+
173
+ /**
174
+ * --------------------------------------------------------------------------
175
+ * Bootstrap (v5.0.2): carousel.js
176
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
177
+ * --------------------------------------------------------------------------
178
+ */
234
179
  /**
235
180
  * ------------------------------------------------------------------------
236
181
  * Constants
237
182
  * ------------------------------------------------------------------------
238
183
  */
239
184
 
240
- var NAME = 'carousel';
241
- var DATA_KEY = 'bs.carousel';
242
- var EVENT_KEY = "." + DATA_KEY;
243
- var DATA_API_KEY = '.data-api';
244
- var ARROW_LEFT_KEY = 'ArrowLeft';
245
- var ARROW_RIGHT_KEY = 'ArrowRight';
246
- var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
185
+ const NAME = 'carousel';
186
+ const DATA_KEY = 'bs.carousel';
187
+ const EVENT_KEY = `.${DATA_KEY}`;
188
+ const DATA_API_KEY = '.data-api';
189
+ const ARROW_LEFT_KEY = 'ArrowLeft';
190
+ const ARROW_RIGHT_KEY = 'ArrowRight';
191
+ const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
247
192
 
248
- var SWIPE_THRESHOLD = 40;
249
- var Default = {
193
+ const SWIPE_THRESHOLD = 40;
194
+ const Default = {
250
195
  interval: 5000,
251
196
  keyboard: true,
252
197
  slide: false,
@@ -254,7 +199,7 @@
254
199
  wrap: true,
255
200
  touch: true
256
201
  };
257
- var DefaultType = {
202
+ const DefaultType = {
258
203
  interval: '(number|boolean)',
259
204
  keyboard: 'boolean',
260
205
  slide: '(boolean|string)',
@@ -262,98 +207,98 @@
262
207
  wrap: 'boolean',
263
208
  touch: 'boolean'
264
209
  };
265
- var DIRECTION_NEXT = 'next';
266
- var DIRECTION_PREV = 'prev';
267
- var DIRECTION_LEFT = 'left';
268
- var DIRECTION_RIGHT = 'right';
269
- var EVENT_SLIDE = "slide" + EVENT_KEY;
270
- var EVENT_SLID = "slid" + EVENT_KEY;
271
- var EVENT_KEYDOWN = "keydown" + EVENT_KEY;
272
- var EVENT_MOUSEENTER = "mouseenter" + EVENT_KEY;
273
- var EVENT_MOUSELEAVE = "mouseleave" + EVENT_KEY;
274
- var EVENT_TOUCHSTART = "touchstart" + EVENT_KEY;
275
- var EVENT_TOUCHMOVE = "touchmove" + EVENT_KEY;
276
- var EVENT_TOUCHEND = "touchend" + EVENT_KEY;
277
- var EVENT_POINTERDOWN = "pointerdown" + EVENT_KEY;
278
- var EVENT_POINTERUP = "pointerup" + EVENT_KEY;
279
- var EVENT_DRAG_START = "dragstart" + EVENT_KEY;
280
- var EVENT_LOAD_DATA_API = "load" + EVENT_KEY + DATA_API_KEY;
281
- var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY;
282
- var CLASS_NAME_CAROUSEL = 'carousel';
283
- var CLASS_NAME_ACTIVE = 'active';
284
- var CLASS_NAME_SLIDE = 'slide';
285
- var CLASS_NAME_END = 'carousel-item-end';
286
- var CLASS_NAME_START = 'carousel-item-start';
287
- var CLASS_NAME_NEXT = 'carousel-item-next';
288
- var CLASS_NAME_PREV = 'carousel-item-prev';
289
- var CLASS_NAME_POINTER_EVENT = 'pointer-event';
290
- var SELECTOR_ACTIVE = '.active';
291
- var SELECTOR_ACTIVE_ITEM = '.active.carousel-item';
292
- var SELECTOR_ITEM = '.carousel-item';
293
- var SELECTOR_ITEM_IMG = '.carousel-item img';
294
- var SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev';
295
- var SELECTOR_INDICATORS = '.carousel-indicators';
296
- var SELECTOR_INDICATOR = '[data-bs-target]';
297
- var SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
298
- var SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
299
- var POINTER_TYPE_TOUCH = 'touch';
300
- var POINTER_TYPE_PEN = 'pen';
210
+ const ORDER_NEXT = 'next';
211
+ const ORDER_PREV = 'prev';
212
+ const DIRECTION_LEFT = 'left';
213
+ const DIRECTION_RIGHT = 'right';
214
+ const KEY_TO_DIRECTION = {
215
+ [ARROW_LEFT_KEY]: DIRECTION_RIGHT,
216
+ [ARROW_RIGHT_KEY]: DIRECTION_LEFT
217
+ };
218
+ const EVENT_SLIDE = `slide${EVENT_KEY}`;
219
+ const EVENT_SLID = `slid${EVENT_KEY}`;
220
+ const EVENT_KEYDOWN = `keydown${EVENT_KEY}`;
221
+ const EVENT_MOUSEENTER = `mouseenter${EVENT_KEY}`;
222
+ const EVENT_MOUSELEAVE = `mouseleave${EVENT_KEY}`;
223
+ const EVENT_TOUCHSTART = `touchstart${EVENT_KEY}`;
224
+ const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY}`;
225
+ const EVENT_TOUCHEND = `touchend${EVENT_KEY}`;
226
+ const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY}`;
227
+ const EVENT_POINTERUP = `pointerup${EVENT_KEY}`;
228
+ const EVENT_DRAG_START = `dragstart${EVENT_KEY}`;
229
+ const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`;
230
+ const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
231
+ const CLASS_NAME_CAROUSEL = 'carousel';
232
+ const CLASS_NAME_ACTIVE = 'active';
233
+ const CLASS_NAME_SLIDE = 'slide';
234
+ const CLASS_NAME_END = 'carousel-item-end';
235
+ const CLASS_NAME_START = 'carousel-item-start';
236
+ const CLASS_NAME_NEXT = 'carousel-item-next';
237
+ const CLASS_NAME_PREV = 'carousel-item-prev';
238
+ const CLASS_NAME_POINTER_EVENT = 'pointer-event';
239
+ const SELECTOR_ACTIVE = '.active';
240
+ const SELECTOR_ACTIVE_ITEM = '.active.carousel-item';
241
+ const SELECTOR_ITEM = '.carousel-item';
242
+ const SELECTOR_ITEM_IMG = '.carousel-item img';
243
+ const SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev';
244
+ const SELECTOR_INDICATORS = '.carousel-indicators';
245
+ const SELECTOR_INDICATOR = '[data-bs-target]';
246
+ const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
247
+ const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
248
+ const POINTER_TYPE_TOUCH = 'touch';
249
+ const POINTER_TYPE_PEN = 'pen';
301
250
  /**
302
251
  * ------------------------------------------------------------------------
303
252
  * Class Definition
304
253
  * ------------------------------------------------------------------------
305
254
  */
306
255
 
307
- var Carousel = /*#__PURE__*/function (_BaseComponent) {
308
- _inheritsLoose(Carousel, _BaseComponent);
309
-
310
- function Carousel(element, config) {
311
- var _this;
312
-
313
- _this = _BaseComponent.call(this, element) || this;
314
- _this._items = null;
315
- _this._interval = null;
316
- _this._activeElement = null;
317
- _this._isPaused = false;
318
- _this._isSliding = false;
319
- _this.touchTimeout = null;
320
- _this.touchStartX = 0;
321
- _this.touchDeltaX = 0;
322
- _this._config = _this._getConfig(config);
323
- _this._indicatorsElement = SelectorEngine__default['default'].findOne(SELECTOR_INDICATORS, _this._element);
324
- _this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
325
- _this._pointerEvent = Boolean(window.PointerEvent);
326
-
327
- _this._addEventListeners();
328
-
329
- return _this;
256
+ class Carousel extends BaseComponent__default['default'] {
257
+ constructor(element, config) {
258
+ super(element);
259
+ this._items = null;
260
+ this._interval = null;
261
+ this._activeElement = null;
262
+ this._isPaused = false;
263
+ this._isSliding = false;
264
+ this.touchTimeout = null;
265
+ this.touchStartX = 0;
266
+ this.touchDeltaX = 0;
267
+ this._config = this._getConfig(config);
268
+ this._indicatorsElement = SelectorEngine__default['default'].findOne(SELECTOR_INDICATORS, this._element);
269
+ this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
270
+ this._pointerEvent = Boolean(window.PointerEvent);
271
+
272
+ this._addEventListeners();
330
273
  } // Getters
331
274
 
332
275
 
333
- var _proto = Carousel.prototype;
276
+ static get Default() {
277
+ return Default;
278
+ }
334
279
 
335
- // Public
336
- _proto.next = function next() {
337
- if (!this._isSliding) {
338
- this._slide(DIRECTION_NEXT);
339
- }
340
- };
280
+ static get NAME() {
281
+ return NAME;
282
+ } // Public
341
283
 
342
- _proto.nextWhenVisible = function nextWhenVisible() {
284
+
285
+ next() {
286
+ this._slide(ORDER_NEXT);
287
+ }
288
+
289
+ nextWhenVisible() {
343
290
  // Don't call next when the page isn't visible
344
291
  // or the carousel or its parent isn't visible
345
292
  if (!document.hidden && isVisible(this._element)) {
346
293
  this.next();
347
294
  }
348
- };
295
+ }
349
296
 
350
- _proto.prev = function prev() {
351
- if (!this._isSliding) {
352
- this._slide(DIRECTION_PREV);
353
- }
354
- };
297
+ prev() {
298
+ this._slide(ORDER_PREV);
299
+ }
355
300
 
356
- _proto.pause = function pause(event) {
301
+ pause(event) {
357
302
  if (!event) {
358
303
  this._isPaused = true;
359
304
  }
@@ -365,9 +310,9 @@
365
310
 
366
311
  clearInterval(this._interval);
367
312
  this._interval = null;
368
- };
313
+ }
369
314
 
370
- _proto.cycle = function cycle(event) {
315
+ cycle(event) {
371
316
  if (!event) {
372
317
  this._isPaused = false;
373
318
  }
@@ -382,23 +327,19 @@
382
327
 
383
328
  this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
384
329
  }
385
- };
386
-
387
- _proto.to = function to(index) {
388
- var _this2 = this;
330
+ }
389
331
 
332
+ to(index) {
390
333
  this._activeElement = SelectorEngine__default['default'].findOne(SELECTOR_ACTIVE_ITEM, this._element);
391
334
 
392
- var activeIndex = this._getItemIndex(this._activeElement);
335
+ const activeIndex = this._getItemIndex(this._activeElement);
393
336
 
394
337
  if (index > this._items.length - 1 || index < 0) {
395
338
  return;
396
339
  }
397
340
 
398
341
  if (this._isSliding) {
399
- EventHandler__default['default'].one(this._element, EVENT_SLID, function () {
400
- return _this2.to(index);
401
- });
342
+ EventHandler__default['default'].one(this._element, EVENT_SLID, () => this.to(index));
402
343
  return;
403
344
  }
404
345
 
@@ -408,110 +349,75 @@
408
349
  return;
409
350
  }
410
351
 
411
- var direction = index > activeIndex ? DIRECTION_NEXT : DIRECTION_PREV;
352
+ const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV;
412
353
 
413
- this._slide(direction, this._items[index]);
414
- };
415
-
416
- _proto.dispose = function dispose() {
417
- _BaseComponent.prototype.dispose.call(this);
418
-
419
- EventHandler__default['default'].off(this._element, EVENT_KEY);
420
- this._items = null;
421
- this._config = null;
422
- this._interval = null;
423
- this._isPaused = null;
424
- this._isSliding = null;
425
- this._activeElement = null;
426
- this._indicatorsElement = null;
354
+ this._slide(order, this._items[index]);
427
355
  } // Private
428
- ;
429
356
 
430
- _proto._getConfig = function _getConfig(config) {
431
- config = _extends({}, Default, config);
357
+
358
+ _getConfig(config) {
359
+ config = { ...Default,
360
+ ...Manipulator__default['default'].getDataAttributes(this._element),
361
+ ...(typeof config === 'object' ? config : {})
362
+ };
432
363
  typeCheckConfig(NAME, config, DefaultType);
433
364
  return config;
434
- };
365
+ }
435
366
 
436
- _proto._handleSwipe = function _handleSwipe() {
437
- var absDeltax = Math.abs(this.touchDeltaX);
367
+ _handleSwipe() {
368
+ const absDeltax = Math.abs(this.touchDeltaX);
438
369
 
439
370
  if (absDeltax <= SWIPE_THRESHOLD) {
440
371
  return;
441
372
  }
442
373
 
443
- var direction = absDeltax / this.touchDeltaX;
444
- this.touchDeltaX = 0; // swipe left
445
-
446
- if (direction > 0) {
447
- if (isRTL) {
448
- this.next();
449
- } else {
450
- this.prev();
451
- }
452
- } // swipe right
453
-
374
+ const direction = absDeltax / this.touchDeltaX;
375
+ this.touchDeltaX = 0;
454
376
 
455
- if (direction < 0) {
456
- if (isRTL) {
457
- this.prev();
458
- } else {
459
- this.next();
460
- }
377
+ if (!direction) {
378
+ return;
461
379
  }
462
- };
463
380
 
464
- _proto._addEventListeners = function _addEventListeners() {
465
- var _this3 = this;
381
+ this._slide(direction > 0 ? DIRECTION_RIGHT : DIRECTION_LEFT);
382
+ }
466
383
 
384
+ _addEventListeners() {
467
385
  if (this._config.keyboard) {
468
- EventHandler__default['default'].on(this._element, EVENT_KEYDOWN, function (event) {
469
- return _this3._keydown(event);
470
- });
386
+ EventHandler__default['default'].on(this._element, EVENT_KEYDOWN, event => this._keydown(event));
471
387
  }
472
388
 
473
389
  if (this._config.pause === 'hover') {
474
- EventHandler__default['default'].on(this._element, EVENT_MOUSEENTER, function (event) {
475
- return _this3.pause(event);
476
- });
477
- EventHandler__default['default'].on(this._element, EVENT_MOUSELEAVE, function (event) {
478
- return _this3.cycle(event);
479
- });
390
+ EventHandler__default['default'].on(this._element, EVENT_MOUSEENTER, event => this.pause(event));
391
+ EventHandler__default['default'].on(this._element, EVENT_MOUSELEAVE, event => this.cycle(event));
480
392
  }
481
393
 
482
394
  if (this._config.touch && this._touchSupported) {
483
395
  this._addTouchEventListeners();
484
396
  }
485
- };
486
-
487
- _proto._addTouchEventListeners = function _addTouchEventListeners() {
488
- var _this4 = this;
397
+ }
489
398
 
490
- var start = function start(event) {
491
- if (_this4._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)) {
492
- _this4.touchStartX = event.clientX;
493
- } else if (!_this4._pointerEvent) {
494
- _this4.touchStartX = event.touches[0].clientX;
399
+ _addTouchEventListeners() {
400
+ const start = event => {
401
+ if (this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)) {
402
+ this.touchStartX = event.clientX;
403
+ } else if (!this._pointerEvent) {
404
+ this.touchStartX = event.touches[0].clientX;
495
405
  }
496
406
  };
497
407
 
498
- var move = function move(event) {
408
+ const move = event => {
499
409
  // ensure swiping with one touch and not pinching
500
- if (event.touches && event.touches.length > 1) {
501
- _this4.touchDeltaX = 0;
502
- } else {
503
- _this4.touchDeltaX = event.touches[0].clientX - _this4.touchStartX;
504
- }
410
+ this.touchDeltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this.touchStartX;
505
411
  };
506
412
 
507
- var end = function end(event) {
508
- if (_this4._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)) {
509
- _this4.touchDeltaX = event.clientX - _this4.touchStartX;
413
+ const end = event => {
414
+ if (this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)) {
415
+ this.touchDeltaX = event.clientX - this.touchStartX;
510
416
  }
511
417
 
512
- _this4._handleSwipe();
418
+ this._handleSwipe();
513
419
 
514
- if (_this4._config.pause === 'hover') {
420
+ if (this._config.pause === 'hover') {
515
421
  // If it's a touch-enabled device, mouseenter/leave are fired as
516
422
  // part of the mouse compatibility events on first tap - the carousel
517
423
  // would stop cycling until user tapped out of it;
@@ -519,114 +425,77 @@
519
425
  // (as if it's the second time we tap on it, mouseenter compat event
520
426
  // is NOT fired) and after a timeout (to allow for mouse compatibility
521
427
  // events to fire) we explicitly restart cycling
522
- _this4.pause();
428
+ this.pause();
523
429
 
524
- if (_this4.touchTimeout) {
525
- clearTimeout(_this4.touchTimeout);
430
+ if (this.touchTimeout) {
431
+ clearTimeout(this.touchTimeout);
526
432
  }
527
433
 
528
- _this4.touchTimeout = setTimeout(function (event) {
529
- return _this4.cycle(event);
530
- }, TOUCHEVENT_COMPAT_WAIT + _this4._config.interval);
434
+ this.touchTimeout = setTimeout(event => this.cycle(event), TOUCHEVENT_COMPAT_WAIT + this._config.interval);
531
435
  }
532
436
  };
533
437
 
534
- SelectorEngine__default['default'].find(SELECTOR_ITEM_IMG, this._element).forEach(function (itemImg) {
535
- EventHandler__default['default'].on(itemImg, EVENT_DRAG_START, function (e) {
536
- return e.preventDefault();
537
- });
438
+ SelectorEngine__default['default'].find(SELECTOR_ITEM_IMG, this._element).forEach(itemImg => {
439
+ EventHandler__default['default'].on(itemImg, EVENT_DRAG_START, e => e.preventDefault());
538
440
  });
539
441
 
540
442
  if (this._pointerEvent) {
541
- EventHandler__default['default'].on(this._element, EVENT_POINTERDOWN, function (event) {
542
- return start(event);
543
- });
544
- EventHandler__default['default'].on(this._element, EVENT_POINTERUP, function (event) {
545
- return end(event);
546
- });
443
+ EventHandler__default['default'].on(this._element, EVENT_POINTERDOWN, event => start(event));
444
+ EventHandler__default['default'].on(this._element, EVENT_POINTERUP, event => end(event));
547
445
 
548
446
  this._element.classList.add(CLASS_NAME_POINTER_EVENT);
549
447
  } else {
550
- EventHandler__default['default'].on(this._element, EVENT_TOUCHSTART, function (event) {
551
- return start(event);
552
- });
553
- EventHandler__default['default'].on(this._element, EVENT_TOUCHMOVE, function (event) {
554
- return move(event);
555
- });
556
- EventHandler__default['default'].on(this._element, EVENT_TOUCHEND, function (event) {
557
- return end(event);
558
- });
448
+ EventHandler__default['default'].on(this._element, EVENT_TOUCHSTART, event => start(event));
449
+ EventHandler__default['default'].on(this._element, EVENT_TOUCHMOVE, event => move(event));
450
+ EventHandler__default['default'].on(this._element, EVENT_TOUCHEND, event => end(event));
559
451
  }
560
- };
452
+ }
561
453
 
562
- _proto._keydown = function _keydown(event) {
454
+ _keydown(event) {
563
455
  if (/input|textarea/i.test(event.target.tagName)) {
564
456
  return;
565
457
  }
566
458
 
567
- if (event.key === ARROW_LEFT_KEY) {
568
- event.preventDefault();
459
+ const direction = KEY_TO_DIRECTION[event.key];
569
460
 
570
- if (isRTL) {
571
- this.next();
572
- } else {
573
- this.prev();
574
- }
575
- } else if (event.key === ARROW_RIGHT_KEY) {
461
+ if (direction) {
576
462
  event.preventDefault();
577
463
 
578
- if (isRTL) {
579
- this.prev();
580
- } else {
581
- this.next();
582
- }
464
+ this._slide(direction);
583
465
  }
584
- };
466
+ }
585
467
 
586
- _proto._getItemIndex = function _getItemIndex(element) {
468
+ _getItemIndex(element) {
587
469
  this._items = element && element.parentNode ? SelectorEngine__default['default'].find(SELECTOR_ITEM, element.parentNode) : [];
588
470
  return this._items.indexOf(element);
589
- };
590
-
591
- _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
592
- var isNextDirection = direction === DIRECTION_NEXT;
593
- var isPrevDirection = direction === DIRECTION_PREV;
594
-
595
- var activeIndex = this._getItemIndex(activeElement);
596
-
597
- var lastItemIndex = this._items.length - 1;
598
- var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
599
-
600
- if (isGoingToWrap && !this._config.wrap) {
601
- return activeElement;
602
- }
471
+ }
603
472
 
604
- var delta = direction === DIRECTION_PREV ? -1 : 1;
605
- var itemIndex = (activeIndex + delta) % this._items.length;
606
- return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
607
- };
473
+ _getItemByOrder(order, activeElement) {
474
+ const isNext = order === ORDER_NEXT;
475
+ return getNextActiveElement(this._items, activeElement, isNext, this._config.wrap);
476
+ }
608
477
 
609
- _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
610
- var targetIndex = this._getItemIndex(relatedTarget);
478
+ _triggerSlideEvent(relatedTarget, eventDirectionName) {
479
+ const targetIndex = this._getItemIndex(relatedTarget);
611
480
 
612
- var fromIndex = this._getItemIndex(SelectorEngine__default['default'].findOne(SELECTOR_ACTIVE_ITEM, this._element));
481
+ const fromIndex = this._getItemIndex(SelectorEngine__default['default'].findOne(SELECTOR_ACTIVE_ITEM, this._element));
613
482
 
614
483
  return EventHandler__default['default'].trigger(this._element, EVENT_SLIDE, {
615
- relatedTarget: relatedTarget,
484
+ relatedTarget,
616
485
  direction: eventDirectionName,
617
486
  from: fromIndex,
618
487
  to: targetIndex
619
488
  });
620
- };
489
+ }
621
490
 
622
- _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
491
+ _setActiveIndicatorElement(element) {
623
492
  if (this._indicatorsElement) {
624
- var activeIndicator = SelectorEngine__default['default'].findOne(SELECTOR_ACTIVE, this._indicatorsElement);
493
+ const activeIndicator = SelectorEngine__default['default'].findOne(SELECTOR_ACTIVE, this._indicatorsElement);
625
494
  activeIndicator.classList.remove(CLASS_NAME_ACTIVE);
626
495
  activeIndicator.removeAttribute('aria-current');
627
- var indicators = SelectorEngine__default['default'].find(SELECTOR_INDICATOR, this._indicatorsElement);
496
+ const indicators = SelectorEngine__default['default'].find(SELECTOR_INDICATOR, this._indicatorsElement);
628
497
 
629
- for (var i = 0; i < indicators.length; i++) {
498
+ for (let i = 0; i < indicators.length; i++) {
630
499
  if (Number.parseInt(indicators[i].getAttribute('data-bs-slide-to'), 10) === this._getItemIndex(element)) {
631
500
  indicators[i].classList.add(CLASS_NAME_ACTIVE);
632
501
  indicators[i].setAttribute('aria-current', 'true');
@@ -634,16 +503,16 @@
634
503
  }
635
504
  }
636
505
  }
637
- };
506
+ }
638
507
 
639
- _proto._updateInterval = function _updateInterval() {
640
- var element = this._activeElement || SelectorEngine__default['default'].findOne(SELECTOR_ACTIVE_ITEM, this._element);
508
+ _updateInterval() {
509
+ const element = this._activeElement || SelectorEngine__default['default'].findOne(SELECTOR_ACTIVE_ITEM, this._element);
641
510
 
642
511
  if (!element) {
643
512
  return;
644
513
  }
645
514
 
646
- var elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10);
515
+ const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10);
647
516
 
648
517
  if (elementInterval) {
649
518
  this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
@@ -651,30 +520,36 @@
651
520
  } else {
652
521
  this._config.interval = this._config.defaultInterval || this._config.interval;
653
522
  }
654
- };
523
+ }
524
+
525
+ _slide(directionOrOrder, element) {
526
+ const order = this._directionToOrder(directionOrOrder);
655
527
 
656
- _proto._slide = function _slide(direction, element) {
657
- var _this5 = this;
528
+ const activeElement = SelectorEngine__default['default'].findOne(SELECTOR_ACTIVE_ITEM, this._element);
658
529
 
659
- var activeElement = SelectorEngine__default['default'].findOne(SELECTOR_ACTIVE_ITEM, this._element);
530
+ const activeElementIndex = this._getItemIndex(activeElement);
660
531
 
661
- var activeElementIndex = this._getItemIndex(activeElement);
532
+ const nextElement = element || this._getItemByOrder(order, activeElement);
662
533
 
663
- var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
534
+ const nextElementIndex = this._getItemIndex(nextElement);
664
535
 
665
- var nextElementIndex = this._getItemIndex(nextElement);
536
+ const isCycling = Boolean(this._interval);
537
+ const isNext = order === ORDER_NEXT;
538
+ const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END;
539
+ const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
666
540
 
667
- var isCycling = Boolean(this._interval);
668
- var directionalClassName = direction === DIRECTION_NEXT ? CLASS_NAME_START : CLASS_NAME_END;
669
- var orderClassName = direction === DIRECTION_NEXT ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
670
- var eventDirectionName = direction === DIRECTION_NEXT ? DIRECTION_LEFT : DIRECTION_RIGHT;
541
+ const eventDirectionName = this._orderToDirection(order);
671
542
 
672
543
  if (nextElement && nextElement.classList.contains(CLASS_NAME_ACTIVE)) {
673
544
  this._isSliding = false;
674
545
  return;
675
546
  }
676
547
 
677
- var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
548
+ if (this._isSliding) {
549
+ return;
550
+ }
551
+
552
+ const slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
678
553
 
679
554
  if (slideEvent.defaultPrevented) {
680
555
  return;
@@ -695,65 +570,86 @@
695
570
 
696
571
  this._activeElement = nextElement;
697
572
 
573
+ const triggerSlidEvent = () => {
574
+ EventHandler__default['default'].trigger(this._element, EVENT_SLID, {
575
+ relatedTarget: nextElement,
576
+ direction: eventDirectionName,
577
+ from: activeElementIndex,
578
+ to: nextElementIndex
579
+ });
580
+ };
581
+
698
582
  if (this._element.classList.contains(CLASS_NAME_SLIDE)) {
699
583
  nextElement.classList.add(orderClassName);
700
584
  reflow(nextElement);
701
585
  activeElement.classList.add(directionalClassName);
702
586
  nextElement.classList.add(directionalClassName);
703
- var transitionDuration = getTransitionDurationFromElement(activeElement);
704
- EventHandler__default['default'].one(activeElement, 'transitionend', function () {
587
+
588
+ const completeCallBack = () => {
705
589
  nextElement.classList.remove(directionalClassName, orderClassName);
706
590
  nextElement.classList.add(CLASS_NAME_ACTIVE);
707
591
  activeElement.classList.remove(CLASS_NAME_ACTIVE, orderClassName, directionalClassName);
708
- _this5._isSliding = false;
709
- setTimeout(function () {
710
- EventHandler__default['default'].trigger(_this5._element, EVENT_SLID, {
711
- relatedTarget: nextElement,
712
- direction: eventDirectionName,
713
- from: activeElementIndex,
714
- to: nextElementIndex
715
- });
716
- }, 0);
717
- });
718
- emulateTransitionEnd(activeElement, transitionDuration);
592
+ this._isSliding = false;
593
+ setTimeout(triggerSlidEvent, 0);
594
+ };
595
+
596
+ this._queueCallback(completeCallBack, activeElement, true);
719
597
  } else {
720
598
  activeElement.classList.remove(CLASS_NAME_ACTIVE);
721
599
  nextElement.classList.add(CLASS_NAME_ACTIVE);
722
600
  this._isSliding = false;
723
- EventHandler__default['default'].trigger(this._element, EVENT_SLID, {
724
- relatedTarget: nextElement,
725
- direction: eventDirectionName,
726
- from: activeElementIndex,
727
- to: nextElementIndex
728
- });
601
+ triggerSlidEvent();
729
602
  }
730
603
 
731
604
  if (isCycling) {
732
605
  this.cycle();
733
606
  }
734
- } // Static
735
- ;
607
+ }
736
608
 
737
- Carousel.carouselInterface = function carouselInterface(element, config) {
738
- var data = Data__default['default'].getData(element, DATA_KEY);
609
+ _directionToOrder(direction) {
610
+ if (![DIRECTION_RIGHT, DIRECTION_LEFT].includes(direction)) {
611
+ return direction;
612
+ }
739
613
 
740
- var _config = _extends({}, Default, Manipulator__default['default'].getDataAttributes(element));
614
+ if (isRTL()) {
615
+ return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT;
616
+ }
741
617
 
742
- if (typeof config === 'object') {
743
- _config = _extends({}, _config, config);
618
+ return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV;
619
+ }
620
+
621
+ _orderToDirection(order) {
622
+ if (![ORDER_NEXT, ORDER_PREV].includes(order)) {
623
+ return order;
624
+ }
625
+
626
+ if (isRTL()) {
627
+ return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT;
744
628
  }
745
629
 
746
- var action = typeof config === 'string' ? config : _config.slide;
630
+ return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT;
631
+ } // Static
632
+
633
+
634
+ static carouselInterface(element, config) {
635
+ const data = Carousel.getOrCreateInstance(element, config);
636
+ let {
637
+ _config
638
+ } = data;
747
639
 
748
- if (!data) {
749
- data = new Carousel(element, _config);
640
+ if (typeof config === 'object') {
641
+ _config = { ..._config,
642
+ ...config
643
+ };
750
644
  }
751
645
 
646
+ const action = typeof config === 'string' ? config : _config.slide;
647
+
752
648
  if (typeof config === 'number') {
753
649
  data.to(config);
754
650
  } else if (typeof action === 'string') {
755
651
  if (typeof data[action] === 'undefined') {
756
- throw new TypeError("No method named \"" + action + "\"");
652
+ throw new TypeError(`No method named "${action}"`);
757
653
  }
758
654
 
759
655
  data[action]();
@@ -761,24 +657,25 @@
761
657
  data.pause();
762
658
  data.cycle();
763
659
  }
764
- };
660
+ }
765
661
 
766
- Carousel.jQueryInterface = function jQueryInterface(config) {
662
+ static jQueryInterface(config) {
767
663
  return this.each(function () {
768
664
  Carousel.carouselInterface(this, config);
769
665
  });
770
- };
666
+ }
771
667
 
772
- Carousel.dataApiClickHandler = function dataApiClickHandler(event) {
773
- var target = getElementFromSelector(this);
668
+ static dataApiClickHandler(event) {
669
+ const target = getElementFromSelector(this);
774
670
 
775
671
  if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
776
672
  return;
777
673
  }
778
674
 
779
- var config = _extends({}, Manipulator__default['default'].getDataAttributes(target), Manipulator__default['default'].getDataAttributes(this));
780
-
781
- var slideIndex = this.getAttribute('data-bs-slide-to');
675
+ const config = { ...Manipulator__default['default'].getDataAttributes(target),
676
+ ...Manipulator__default['default'].getDataAttributes(this)
677
+ };
678
+ const slideIndex = this.getAttribute('data-bs-slide-to');
782
679
 
783
680
  if (slideIndex) {
784
681
  config.interval = false;
@@ -787,26 +684,13 @@
787
684
  Carousel.carouselInterface(target, config);
788
685
 
789
686
  if (slideIndex) {
790
- Data__default['default'].getData(target, DATA_KEY).to(slideIndex);
687
+ Carousel.getInstance(target).to(slideIndex);
791
688
  }
792
689
 
793
690
  event.preventDefault();
794
- };
795
-
796
- _createClass(Carousel, null, [{
797
- key: "Default",
798
- get: function get() {
799
- return Default;
800
- }
801
- }, {
802
- key: "DATA_KEY",
803
- get: function get() {
804
- return DATA_KEY;
805
- }
806
- }]);
691
+ }
807
692
 
808
- return Carousel;
809
- }(BaseComponent__default['default']);
693
+ }
810
694
  /**
811
695
  * ------------------------------------------------------------------------
812
696
  * Data Api implementation
@@ -815,11 +699,11 @@
815
699
 
816
700
 
817
701
  EventHandler__default['default'].on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler);
818
- EventHandler__default['default'].on(window, EVENT_LOAD_DATA_API, function () {
819
- var carousels = SelectorEngine__default['default'].find(SELECTOR_DATA_RIDE);
702
+ EventHandler__default['default'].on(window, EVENT_LOAD_DATA_API, () => {
703
+ const carousels = SelectorEngine__default['default'].find(SELECTOR_DATA_RIDE);
820
704
 
821
- for (var i = 0, len = carousels.length; i < len; i++) {
822
- Carousel.carouselInterface(carousels[i], Data__default['default'].getData(carousels[i], DATA_KEY));
705
+ for (let i = 0, len = carousels.length; i < len; i++) {
706
+ Carousel.carouselInterface(carousels[i], Carousel.getInstance(carousels[i]));
823
707
  }
824
708
  });
825
709
  /**
@@ -829,7 +713,7 @@
829
713
  * add .Carousel to jQuery only if jQuery is present
830
714
  */
831
715
 
832
- defineJQueryPlugin(NAME, Carousel);
716
+ defineJQueryPlugin(Carousel);
833
717
 
834
718
  return Carousel;
835
719