bootstrap 4.3.0 → 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 (158) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +17 -2
  3. data/CHANGELOG.md +2 -14
  4. data/README.md +7 -4
  5. data/assets/javascripts/bootstrap/alert.js +173 -137
  6. data/assets/javascripts/bootstrap/base-component.js +182 -0
  7. data/assets/javascripts/bootstrap/button.js +102 -143
  8. data/assets/javascripts/bootstrap/carousel.js +481 -410
  9. data/assets/javascripts/bootstrap/collapse.js +340 -274
  10. data/assets/javascripts/bootstrap/dom/data.js +68 -0
  11. data/assets/javascripts/bootstrap/dom/event-handler.js +322 -0
  12. data/assets/javascripts/bootstrap/dom/manipulator.js +88 -0
  13. data/assets/javascripts/bootstrap/dom/selector-engine.js +127 -0
  14. data/assets/javascripts/bootstrap/dropdown.js +494 -400
  15. data/assets/javascripts/bootstrap/modal.js +834 -450
  16. data/assets/javascripts/bootstrap/offcanvas.js +866 -0
  17. data/assets/javascripts/bootstrap/popover.js +122 -199
  18. data/assets/javascripts/bootstrap/scrollspy.js +257 -241
  19. data/assets/javascripts/bootstrap/tab.js +219 -155
  20. data/assets/javascripts/bootstrap/toast.js +330 -190
  21. data/assets/javascripts/bootstrap/tooltip.js +710 -472
  22. data/assets/javascripts/bootstrap-global-this-define.js +6 -0
  23. data/assets/javascripts/bootstrap-global-this-undefine.js +2 -0
  24. data/assets/javascripts/bootstrap-sprockets.js +8 -1
  25. data/assets/javascripts/bootstrap.js +3547 -2809
  26. data/assets/javascripts/bootstrap.min.js +4 -4
  27. data/assets/stylesheets/_bootstrap-grid.scss +54 -18
  28. data/assets/stylesheets/_bootstrap-reboot.scss +7 -4
  29. data/assets/stylesheets/_bootstrap.scss +20 -11
  30. data/assets/stylesheets/bootstrap/_accordion.scss +118 -0
  31. data/assets/stylesheets/bootstrap/_alert.scss +15 -9
  32. data/assets/stylesheets/bootstrap/_badge.scss +2 -27
  33. data/assets/stylesheets/bootstrap/_breadcrumb.scss +5 -18
  34. data/assets/stylesheets/bootstrap/_button-group.scss +21 -45
  35. data/assets/stylesheets/bootstrap/_buttons.scss +28 -54
  36. data/assets/stylesheets/bootstrap/_card.scss +52 -125
  37. data/assets/stylesheets/bootstrap/_carousel.scss +70 -38
  38. data/assets/stylesheets/bootstrap/_close.scss +30 -31
  39. data/assets/stylesheets/bootstrap/_containers.scss +41 -0
  40. data/assets/stylesheets/bootstrap/_dropdown.scss +88 -39
  41. data/assets/stylesheets/bootstrap/_forms.scss +9 -330
  42. data/assets/stylesheets/bootstrap/_functions.scss +237 -27
  43. data/assets/stylesheets/bootstrap/_grid.scss +14 -33
  44. data/assets/stylesheets/bootstrap/_helpers.scss +9 -0
  45. data/assets/stylesheets/bootstrap/_images.scss +3 -3
  46. data/assets/stylesheets/bootstrap/_list-group.scss +61 -36
  47. data/assets/stylesheets/bootstrap/_mixins.scss +12 -16
  48. data/assets/stylesheets/bootstrap/_modal.scss +64 -84
  49. data/assets/stylesheets/bootstrap/_nav.scss +29 -10
  50. data/assets/stylesheets/bootstrap/_navbar.scss +93 -52
  51. data/assets/stylesheets/bootstrap/_offcanvas.scss +83 -0
  52. data/assets/stylesheets/bootstrap/_pagination.scss +13 -22
  53. data/assets/stylesheets/bootstrap/_placeholders.scss +51 -0
  54. data/assets/stylesheets/bootstrap/_popover.scss +29 -42
  55. data/assets/stylesheets/bootstrap/_progress.scss +10 -5
  56. data/assets/stylesheets/bootstrap/_reboot.scss +350 -208
  57. data/assets/stylesheets/bootstrap/_root.scss +42 -8
  58. data/assets/stylesheets/bootstrap/_spinners.scss +21 -7
  59. data/assets/stylesheets/bootstrap/_tables.scss +80 -114
  60. data/assets/stylesheets/bootstrap/_toasts.scss +21 -14
  61. data/assets/stylesheets/bootstrap/_tooltip.scss +21 -21
  62. data/assets/stylesheets/bootstrap/_transitions.scss +8 -1
  63. data/assets/stylesheets/bootstrap/_type.scss +40 -61
  64. data/assets/stylesheets/bootstrap/_utilities.scss +630 -17
  65. data/assets/stylesheets/bootstrap/_variables.scss +993 -487
  66. data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +18 -0
  67. data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +63 -0
  68. data/assets/stylesheets/bootstrap/forms/_form-check.scss +152 -0
  69. data/assets/stylesheets/bootstrap/forms/_form-control.scss +219 -0
  70. data/assets/stylesheets/bootstrap/forms/_form-range.scss +91 -0
  71. data/assets/stylesheets/bootstrap/forms/_form-select.scss +70 -0
  72. data/assets/stylesheets/bootstrap/forms/_form-text.scss +11 -0
  73. data/assets/stylesheets/bootstrap/forms/_input-group.scss +121 -0
  74. data/assets/stylesheets/bootstrap/forms/_labels.scss +36 -0
  75. data/assets/stylesheets/bootstrap/forms/_validation.scss +12 -0
  76. data/assets/stylesheets/bootstrap/{utilities → helpers}/_clearfix.scss +0 -0
  77. data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +12 -0
  78. data/assets/stylesheets/bootstrap/helpers/_position.scss +30 -0
  79. data/assets/stylesheets/bootstrap/helpers/_ratio.scss +26 -0
  80. data/assets/stylesheets/bootstrap/helpers/_stacks.scss +15 -0
  81. data/assets/stylesheets/bootstrap/helpers/_stretched-link.scss +15 -0
  82. data/assets/stylesheets/bootstrap/helpers/_text-truncation.scss +7 -0
  83. data/assets/stylesheets/bootstrap/helpers/_visually-hidden.scss +8 -0
  84. data/assets/stylesheets/bootstrap/helpers/_vr.scss +8 -0
  85. data/assets/stylesheets/bootstrap/mixins/_alert.scss +3 -5
  86. data/assets/stylesheets/bootstrap/mixins/_backdrop.scss +14 -0
  87. data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +37 -22
  88. data/assets/stylesheets/bootstrap/mixins/_box-shadow.scss +7 -9
  89. data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +14 -10
  90. data/assets/stylesheets/bootstrap/mixins/_buttons.scss +77 -51
  91. data/assets/stylesheets/bootstrap/mixins/_caret.scss +10 -8
  92. data/assets/stylesheets/bootstrap/mixins/_clearfix.scss +2 -0
  93. data/assets/stylesheets/bootstrap/mixins/_color-scheme.scss +7 -0
  94. data/assets/stylesheets/bootstrap/mixins/_container.scss +9 -0
  95. data/assets/stylesheets/bootstrap/mixins/_forms.scss +67 -115
  96. data/assets/stylesheets/bootstrap/mixins/_gradients.scss +13 -11
  97. data/assets/stylesheets/bootstrap/mixins/_grid.scss +131 -32
  98. data/assets/stylesheets/bootstrap/mixins/_image.scss +0 -20
  99. data/assets/stylesheets/bootstrap/mixins/_list-group.scss +5 -2
  100. data/assets/stylesheets/bootstrap/mixins/_pagination.scss +17 -8
  101. data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +1 -1
  102. data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +21 -0
  103. data/assets/stylesheets/bootstrap/mixins/_transition.scss +18 -8
  104. data/assets/stylesheets/bootstrap/mixins/_utilities.scss +89 -0
  105. data/assets/stylesheets/bootstrap/mixins/_visually-hidden.scss +29 -0
  106. data/assets/stylesheets/bootstrap/utilities/_api.scss +47 -0
  107. data/assets/stylesheets/bootstrap/vendor/_rfs.scss +274 -132
  108. data/bootstrap.gemspec +4 -6
  109. data/lib/bootstrap/version.rb +2 -2
  110. data/tasks/updater/js.rb +25 -6
  111. data/tasks/updater/network.rb +8 -2
  112. data/test/dummy_rails/app/assets/config/manifest.js +3 -0
  113. data/test/dummy_rails/app/assets/javascripts/application.js +4 -3
  114. data/test/dummy_rails/app/assets/stylesheets/.browserslistrc +1 -0
  115. data/test/dummy_rails/app/views/layouts/application.html.erb +3 -1
  116. data/test/dummy_rails/app/views/pages/root.html +89 -0
  117. data/test/dummy_rails/config/application.rb +0 -3
  118. data/test/gemfiles/rails_6_0.gemfile +7 -0
  119. data/test/gemfiles/rails_6_1.gemfile +7 -0
  120. data/test/support/dummy_rails_integration.rb +3 -1
  121. data/test/test_helper.rb +18 -13
  122. metadata +61 -79
  123. data/assets/javascripts/bootstrap/util.js +0 -171
  124. data/assets/stylesheets/bootstrap/_code.scss +0 -48
  125. data/assets/stylesheets/bootstrap/_custom-forms.scss +0 -507
  126. data/assets/stylesheets/bootstrap/_input-group.scss +0 -193
  127. data/assets/stylesheets/bootstrap/_jumbotron.scss +0 -17
  128. data/assets/stylesheets/bootstrap/_media.scss +0 -8
  129. data/assets/stylesheets/bootstrap/_print.scss +0 -141
  130. data/assets/stylesheets/bootstrap/mixins/_background-variant.scss +0 -21
  131. data/assets/stylesheets/bootstrap/mixins/_badge.scss +0 -17
  132. data/assets/stylesheets/bootstrap/mixins/_float.scss +0 -14
  133. data/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +0 -66
  134. data/assets/stylesheets/bootstrap/mixins/_hover.scss +0 -37
  135. data/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +0 -10
  136. data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +0 -33
  137. data/assets/stylesheets/bootstrap/mixins/_size.scss +0 -7
  138. data/assets/stylesheets/bootstrap/mixins/_table-row.scss +0 -39
  139. data/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +0 -16
  140. data/assets/stylesheets/bootstrap/mixins/_text-hide.scss +0 -11
  141. data/assets/stylesheets/bootstrap/mixins/_visibility.scss +0 -8
  142. data/assets/stylesheets/bootstrap/utilities/_align.scss +0 -8
  143. data/assets/stylesheets/bootstrap/utilities/_background.scss +0 -19
  144. data/assets/stylesheets/bootstrap/utilities/_borders.scss +0 -75
  145. data/assets/stylesheets/bootstrap/utilities/_display.scss +0 -26
  146. data/assets/stylesheets/bootstrap/utilities/_embed.scss +0 -39
  147. data/assets/stylesheets/bootstrap/utilities/_flex.scss +0 -51
  148. data/assets/stylesheets/bootstrap/utilities/_float.scss +0 -11
  149. data/assets/stylesheets/bootstrap/utilities/_overflow.scss +0 -5
  150. data/assets/stylesheets/bootstrap/utilities/_position.scss +0 -32
  151. data/assets/stylesheets/bootstrap/utilities/_screenreaders.scss +0 -11
  152. data/assets/stylesheets/bootstrap/utilities/_shadows.scss +0 -6
  153. data/assets/stylesheets/bootstrap/utilities/_sizing.scss +0 -20
  154. data/assets/stylesheets/bootstrap/utilities/_spacing.scss +0 -73
  155. data/assets/stylesheets/bootstrap/utilities/_stretched-link.scss +0 -19
  156. data/assets/stylesheets/bootstrap/utilities/_text.scss +0 -72
  157. data/assets/stylesheets/bootstrap/utilities/_visibility.scss +0 -13
  158. data/test/dummy_rails/app/views/pages/root.html.slim +0 -58
@@ -1,87 +1,215 @@
1
1
  /*!
2
- * Bootstrap carousel.js v4.3.0 (https://getbootstrap.com/)
3
- * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
4
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
2
+ * Bootstrap carousel.js v5.1.0 (https://getbootstrap.com/)
3
+ * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
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('jquery'), require('./util.js')) :
8
- typeof define === 'function' && define.amd ? define(['jquery', './util.js'], factory) :
9
- (global = global || self, global.Carousel = factory(global.jQuery, global.Util));
10
- }(this, function ($, Util) { 'use strict';
11
-
12
- $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
13
- Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util;
14
-
15
- function _defineProperties(target, props) {
16
- for (var i = 0; i < props.length; i++) {
17
- var descriptor = props[i];
18
- descriptor.enumerable = descriptor.enumerable || false;
19
- descriptor.configurable = true;
20
- if ("value" in descriptor) descriptor.writable = true;
21
- Object.defineProperty(target, descriptor.key, descriptor);
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.Carousel = factory(global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base));
10
+ }(this, (function (EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict';
11
+
12
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
+
14
+ var EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
15
+ var Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
16
+ var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
17
+ var BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
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
+ */
25
+ const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
26
+
27
+ const toType = obj => {
28
+ if (obj === null || obj === undefined) {
29
+ return `${obj}`;
22
30
  }
23
- }
24
31
 
25
- function _createClass(Constructor, protoProps, staticProps) {
26
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
27
- if (staticProps) _defineProperties(Constructor, staticProps);
28
- return Constructor;
29
- }
32
+ return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
33
+ };
30
34
 
31
- function _defineProperty(obj, key, value) {
32
- if (key in obj) {
33
- Object.defineProperty(obj, key, {
34
- value: value,
35
- enumerable: true,
36
- configurable: true,
37
- writable: true
38
- });
35
+ const getSelector = element => {
36
+ let selector = element.getAttribute('data-bs-target');
37
+
38
+ if (!selector || selector === '#') {
39
+ let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes,
40
+ // so everything starting with `#` or `.`. If a "real" URL is used as the selector,
41
+ // `document.querySelector` will rightfully complain it is invalid.
42
+ // See https://github.com/twbs/bootstrap/issues/32273
43
+
44
+ if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) {
45
+ return null;
46
+ } // Just in case some CMS puts out a full URL with the anchor appended
47
+
48
+
49
+ if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) {
50
+ hrefAttr = `#${hrefAttr.split('#')[1]}`;
51
+ }
52
+
53
+ selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
54
+ }
55
+
56
+ return selector;
57
+ };
58
+
59
+ const getElementFromSelector = element => {
60
+ const selector = getSelector(element);
61
+ return selector ? document.querySelector(selector) : null;
62
+ };
63
+
64
+ const triggerTransitionEnd = element => {
65
+ element.dispatchEvent(new Event(TRANSITION_END));
66
+ };
67
+
68
+ const isElement = obj => {
69
+ if (!obj || typeof obj !== 'object') {
70
+ return false;
71
+ }
72
+
73
+ if (typeof obj.jquery !== 'undefined') {
74
+ obj = obj[0];
75
+ }
76
+
77
+ return typeof obj.nodeType !== 'undefined';
78
+ };
79
+
80
+ const typeCheckConfig = (componentName, config, configTypes) => {
81
+ Object.keys(configTypes).forEach(property => {
82
+ const expectedTypes = configTypes[property];
83
+ const value = config[property];
84
+ const valueType = value && isElement(value) ? 'element' : toType(value);
85
+
86
+ if (!new RegExp(expectedTypes).test(valueType)) {
87
+ throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
88
+ }
89
+ });
90
+ };
91
+
92
+ const isVisible = element => {
93
+ if (!isElement(element) || element.getClientRects().length === 0) {
94
+ return false;
95
+ }
96
+
97
+ return getComputedStyle(element).getPropertyValue('visibility') === 'visible';
98
+ };
99
+ /**
100
+ * Trick to restart an element's animation
101
+ *
102
+ * @param {HTMLElement} element
103
+ * @return void
104
+ *
105
+ * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
106
+ */
107
+
108
+
109
+ const reflow = element => {
110
+ // eslint-disable-next-line no-unused-expressions
111
+ element.offsetHeight;
112
+ };
113
+
114
+ const getjQuery = () => {
115
+ const {
116
+ jQuery
117
+ } = window;
118
+
119
+ if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
120
+ return jQuery;
121
+ }
122
+
123
+ return null;
124
+ };
125
+
126
+ const DOMContentLoadedCallbacks = [];
127
+
128
+ const onDOMContentLoaded = callback => {
129
+ if (document.readyState === 'loading') {
130
+ // add listener on the first call when the document is in loading state
131
+ if (!DOMContentLoadedCallbacks.length) {
132
+ document.addEventListener('DOMContentLoaded', () => {
133
+ DOMContentLoadedCallbacks.forEach(callback => callback());
134
+ });
135
+ }
136
+
137
+ DOMContentLoadedCallbacks.push(callback);
39
138
  } else {
40
- obj[key] = value;
139
+ callback();
41
140
  }
141
+ };
42
142
 
43
- return obj;
44
- }
143
+ const isRTL = () => document.documentElement.dir === 'rtl';
144
+
145
+ const defineJQueryPlugin = plugin => {
146
+ onDOMContentLoaded(() => {
147
+ const $ = getjQuery();
148
+ /* istanbul ignore if */
45
149
 
46
- function _objectSpread(target) {
47
- for (var i = 1; i < arguments.length; i++) {
48
- var source = arguments[i] != null ? arguments[i] : {};
49
- var ownKeys = Object.keys(source);
150
+ if ($) {
151
+ const name = plugin.NAME;
152
+ const JQUERY_NO_CONFLICT = $.fn[name];
153
+ $.fn[name] = plugin.jQueryInterface;
154
+ $.fn[name].Constructor = plugin;
50
155
 
51
- if (typeof Object.getOwnPropertySymbols === 'function') {
52
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
53
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
54
- }));
156
+ $.fn[name].noConflict = () => {
157
+ $.fn[name] = JQUERY_NO_CONFLICT;
158
+ return plugin.jQueryInterface;
159
+ };
55
160
  }
161
+ });
162
+ };
163
+ /**
164
+ * Return the previous/next element of a list.
165
+ *
166
+ * @param {array} list The list of elements
167
+ * @param activeElement The active element
168
+ * @param shouldGetNext Choose to get next or previous element
169
+ * @param isCycleAllowed
170
+ * @return {Element|elem} The proper element
171
+ */
56
172
 
57
- ownKeys.forEach(function (key) {
58
- _defineProperty(target, key, source[key]);
59
- });
173
+
174
+ const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
175
+ 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
176
+
177
+ if (index === -1) {
178
+ return list[!shouldGetNext && isCycleAllowed ? list.length - 1 : 0];
60
179
  }
61
180
 
62
- return target;
63
- }
181
+ const listLength = list.length;
182
+ index += shouldGetNext ? 1 : -1;
64
183
 
184
+ if (isCycleAllowed) {
185
+ index = (index + listLength) % listLength;
186
+ }
187
+
188
+ return list[Math.max(0, Math.min(index, listLength - 1))];
189
+ };
190
+
191
+ /**
192
+ * --------------------------------------------------------------------------
193
+ * Bootstrap (v5.1.0): carousel.js
194
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
195
+ * --------------------------------------------------------------------------
196
+ */
65
197
  /**
66
198
  * ------------------------------------------------------------------------
67
199
  * Constants
68
200
  * ------------------------------------------------------------------------
69
201
  */
70
202
 
71
- var NAME = 'carousel';
72
- var VERSION = '4.3.0';
73
- var DATA_KEY = 'bs.carousel';
74
- var EVENT_KEY = "." + DATA_KEY;
75
- var DATA_API_KEY = '.data-api';
76
- var JQUERY_NO_CONFLICT = $.fn[NAME];
77
- var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
78
-
79
- var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
80
-
81
- var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
203
+ const NAME = 'carousel';
204
+ const DATA_KEY = 'bs.carousel';
205
+ const EVENT_KEY = `.${DATA_KEY}`;
206
+ const DATA_API_KEY = '.data-api';
207
+ const ARROW_LEFT_KEY = 'ArrowLeft';
208
+ const ARROW_RIGHT_KEY = 'ArrowRight';
209
+ const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
82
210
 
83
- var SWIPE_THRESHOLD = 40;
84
- var Default = {
211
+ const SWIPE_THRESHOLD = 40;
212
+ const Default = {
85
213
  interval: 5000,
86
214
  keyboard: true,
87
215
  slide: false,
@@ -89,7 +217,7 @@
89
217
  wrap: true,
90
218
  touch: true
91
219
  };
92
- var DefaultType = {
220
+ const DefaultType = {
93
221
  interval: '(number|boolean)',
94
222
  keyboard: 'boolean',
95
223
  slide: '(boolean|string)',
@@ -97,63 +225,55 @@
97
225
  wrap: 'boolean',
98
226
  touch: 'boolean'
99
227
  };
100
- var Direction = {
101
- NEXT: 'next',
102
- PREV: 'prev',
103
- LEFT: 'left',
104
- RIGHT: 'right'
105
- };
106
- var Event = {
107
- SLIDE: "slide" + EVENT_KEY,
108
- SLID: "slid" + EVENT_KEY,
109
- KEYDOWN: "keydown" + EVENT_KEY,
110
- MOUSEENTER: "mouseenter" + EVENT_KEY,
111
- MOUSELEAVE: "mouseleave" + EVENT_KEY,
112
- TOUCHSTART: "touchstart" + EVENT_KEY,
113
- TOUCHMOVE: "touchmove" + EVENT_KEY,
114
- TOUCHEND: "touchend" + EVENT_KEY,
115
- POINTERDOWN: "pointerdown" + EVENT_KEY,
116
- POINTERUP: "pointerup" + EVENT_KEY,
117
- DRAG_START: "dragstart" + EVENT_KEY,
118
- LOAD_DATA_API: "load" + EVENT_KEY + DATA_API_KEY,
119
- CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
120
- };
121
- var ClassName = {
122
- CAROUSEL: 'carousel',
123
- ACTIVE: 'active',
124
- SLIDE: 'slide',
125
- RIGHT: 'carousel-item-right',
126
- LEFT: 'carousel-item-left',
127
- NEXT: 'carousel-item-next',
128
- PREV: 'carousel-item-prev',
129
- ITEM: 'carousel-item',
130
- POINTER_EVENT: 'pointer-event'
131
- };
132
- var Selector = {
133
- ACTIVE: '.active',
134
- ACTIVE_ITEM: '.active.carousel-item',
135
- ITEM: '.carousel-item',
136
- ITEM_IMG: '.carousel-item img',
137
- NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
138
- INDICATORS: '.carousel-indicators',
139
- DATA_SLIDE: '[data-slide], [data-slide-to]',
140
- DATA_RIDE: '[data-ride="carousel"]'
141
- };
142
- var PointerType = {
143
- TOUCH: 'touch',
144
- PEN: 'pen'
145
- /**
146
- * ------------------------------------------------------------------------
147
- * Class Definition
148
- * ------------------------------------------------------------------------
149
- */
150
-
228
+ const ORDER_NEXT = 'next';
229
+ const ORDER_PREV = 'prev';
230
+ const DIRECTION_LEFT = 'left';
231
+ const DIRECTION_RIGHT = 'right';
232
+ const KEY_TO_DIRECTION = {
233
+ [ARROW_LEFT_KEY]: DIRECTION_RIGHT,
234
+ [ARROW_RIGHT_KEY]: DIRECTION_LEFT
151
235
  };
236
+ const EVENT_SLIDE = `slide${EVENT_KEY}`;
237
+ const EVENT_SLID = `slid${EVENT_KEY}`;
238
+ const EVENT_KEYDOWN = `keydown${EVENT_KEY}`;
239
+ const EVENT_MOUSEENTER = `mouseenter${EVENT_KEY}`;
240
+ const EVENT_MOUSELEAVE = `mouseleave${EVENT_KEY}`;
241
+ const EVENT_TOUCHSTART = `touchstart${EVENT_KEY}`;
242
+ const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY}`;
243
+ const EVENT_TOUCHEND = `touchend${EVENT_KEY}`;
244
+ const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY}`;
245
+ const EVENT_POINTERUP = `pointerup${EVENT_KEY}`;
246
+ const EVENT_DRAG_START = `dragstart${EVENT_KEY}`;
247
+ const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`;
248
+ const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
249
+ const CLASS_NAME_CAROUSEL = 'carousel';
250
+ const CLASS_NAME_ACTIVE = 'active';
251
+ const CLASS_NAME_SLIDE = 'slide';
252
+ const CLASS_NAME_END = 'carousel-item-end';
253
+ const CLASS_NAME_START = 'carousel-item-start';
254
+ const CLASS_NAME_NEXT = 'carousel-item-next';
255
+ const CLASS_NAME_PREV = 'carousel-item-prev';
256
+ const CLASS_NAME_POINTER_EVENT = 'pointer-event';
257
+ const SELECTOR_ACTIVE = '.active';
258
+ const SELECTOR_ACTIVE_ITEM = '.active.carousel-item';
259
+ const SELECTOR_ITEM = '.carousel-item';
260
+ const SELECTOR_ITEM_IMG = '.carousel-item img';
261
+ const SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev';
262
+ const SELECTOR_INDICATORS = '.carousel-indicators';
263
+ const SELECTOR_INDICATOR = '[data-bs-target]';
264
+ const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
265
+ const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
266
+ const POINTER_TYPE_TOUCH = 'touch';
267
+ const POINTER_TYPE_PEN = 'pen';
268
+ /**
269
+ * ------------------------------------------------------------------------
270
+ * Class Definition
271
+ * ------------------------------------------------------------------------
272
+ */
152
273
 
153
- var Carousel =
154
- /*#__PURE__*/
155
- function () {
156
- function Carousel(element, config) {
274
+ class Carousel extends BaseComponent__default['default'] {
275
+ constructor(element, config) {
276
+ super(element);
157
277
  this._items = null;
158
278
  this._interval = null;
159
279
  this._activeElement = null;
@@ -163,53 +283,54 @@
163
283
  this.touchStartX = 0;
164
284
  this.touchDeltaX = 0;
165
285
  this._config = this._getConfig(config);
166
- this._element = element;
167
- this._indicatorsElement = this._element.querySelector(Selector.INDICATORS);
286
+ this._indicatorsElement = SelectorEngine__default['default'].findOne(SELECTOR_INDICATORS, this._element);
168
287
  this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
169
- this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
288
+ this._pointerEvent = Boolean(window.PointerEvent);
170
289
 
171
290
  this._addEventListeners();
172
291
  } // Getters
173
292
 
174
293
 
175
- var _proto = Carousel.prototype;
294
+ static get Default() {
295
+ return Default;
296
+ }
297
+
298
+ static get NAME() {
299
+ return NAME;
300
+ } // Public
176
301
 
177
- // Public
178
- _proto.next = function next() {
179
- if (!this._isSliding) {
180
- this._slide(Direction.NEXT);
181
- }
182
- };
183
302
 
184
- _proto.nextWhenVisible = function nextWhenVisible() {
303
+ next() {
304
+ this._slide(ORDER_NEXT);
305
+ }
306
+
307
+ nextWhenVisible() {
185
308
  // Don't call next when the page isn't visible
186
309
  // or the carousel or its parent isn't visible
187
- if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
310
+ if (!document.hidden && isVisible(this._element)) {
188
311
  this.next();
189
312
  }
190
- };
313
+ }
191
314
 
192
- _proto.prev = function prev() {
193
- if (!this._isSliding) {
194
- this._slide(Direction.PREV);
195
- }
196
- };
315
+ prev() {
316
+ this._slide(ORDER_PREV);
317
+ }
197
318
 
198
- _proto.pause = function pause(event) {
319
+ pause(event) {
199
320
  if (!event) {
200
321
  this._isPaused = true;
201
322
  }
202
323
 
203
- if (this._element.querySelector(Selector.NEXT_PREV)) {
204
- Util.triggerTransitionEnd(this._element);
324
+ if (SelectorEngine__default['default'].findOne(SELECTOR_NEXT_PREV, this._element)) {
325
+ triggerTransitionEnd(this._element);
205
326
  this.cycle(true);
206
327
  }
207
328
 
208
329
  clearInterval(this._interval);
209
330
  this._interval = null;
210
- };
331
+ }
211
332
 
212
- _proto.cycle = function cycle(event) {
333
+ cycle(event) {
213
334
  if (!event) {
214
335
  this._isPaused = false;
215
336
  }
@@ -219,26 +340,24 @@
219
340
  this._interval = null;
220
341
  }
221
342
 
222
- if (this._config.interval && !this._isPaused) {
343
+ if (this._config && this._config.interval && !this._isPaused) {
344
+ this._updateInterval();
345
+
223
346
  this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
224
347
  }
225
- };
226
-
227
- _proto.to = function to(index) {
228
- var _this = this;
348
+ }
229
349
 
230
- this._activeElement = this._element.querySelector(Selector.ACTIVE_ITEM);
350
+ to(index) {
351
+ this._activeElement = SelectorEngine__default['default'].findOne(SELECTOR_ACTIVE_ITEM, this._element);
231
352
 
232
- var activeIndex = this._getItemIndex(this._activeElement);
353
+ const activeIndex = this._getItemIndex(this._activeElement);
233
354
 
234
355
  if (index > this._items.length - 1 || index < 0) {
235
356
  return;
236
357
  }
237
358
 
238
359
  if (this._isSliding) {
239
- $(this._element).one(Event.SLID, function () {
240
- return _this.to(index);
241
- });
360
+ EventHandler__default['default'].one(this._element, EVENT_SLID, () => this.to(index));
242
361
  return;
243
362
  }
244
363
 
@@ -248,104 +367,75 @@
248
367
  return;
249
368
  }
250
369
 
251
- var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
252
-
253
- this._slide(direction, this._items[index]);
254
- };
370
+ const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV;
255
371
 
256
- _proto.dispose = function dispose() {
257
- $(this._element).off(EVENT_KEY);
258
- $.removeData(this._element, DATA_KEY);
259
- this._items = null;
260
- this._config = null;
261
- this._element = null;
262
- this._interval = null;
263
- this._isPaused = null;
264
- this._isSliding = null;
265
- this._activeElement = null;
266
- this._indicatorsElement = null;
372
+ this._slide(order, this._items[index]);
267
373
  } // Private
268
- ;
269
374
 
270
- _proto._getConfig = function _getConfig(config) {
271
- config = _objectSpread({}, Default, config);
272
- Util.typeCheckConfig(NAME, config, DefaultType);
375
+
376
+ _getConfig(config) {
377
+ config = { ...Default,
378
+ ...Manipulator__default['default'].getDataAttributes(this._element),
379
+ ...(typeof config === 'object' ? config : {})
380
+ };
381
+ typeCheckConfig(NAME, config, DefaultType);
273
382
  return config;
274
- };
383
+ }
275
384
 
276
- _proto._handleSwipe = function _handleSwipe() {
277
- var absDeltax = Math.abs(this.touchDeltaX);
385
+ _handleSwipe() {
386
+ const absDeltax = Math.abs(this.touchDeltaX);
278
387
 
279
388
  if (absDeltax <= SWIPE_THRESHOLD) {
280
389
  return;
281
390
  }
282
391
 
283
- var direction = absDeltax / this.touchDeltaX; // swipe left
284
-
285
- if (direction > 0) {
286
- this.prev();
287
- } // swipe right
288
-
392
+ const direction = absDeltax / this.touchDeltaX;
393
+ this.touchDeltaX = 0;
289
394
 
290
- if (direction < 0) {
291
- this.next();
395
+ if (!direction) {
396
+ return;
292
397
  }
293
- };
294
398
 
295
- _proto._addEventListeners = function _addEventListeners() {
296
- var _this2 = this;
399
+ this._slide(direction > 0 ? DIRECTION_RIGHT : DIRECTION_LEFT);
400
+ }
297
401
 
402
+ _addEventListeners() {
298
403
  if (this._config.keyboard) {
299
- $(this._element).on(Event.KEYDOWN, function (event) {
300
- return _this2._keydown(event);
301
- });
404
+ EventHandler__default['default'].on(this._element, EVENT_KEYDOWN, event => this._keydown(event));
302
405
  }
303
406
 
304
407
  if (this._config.pause === 'hover') {
305
- $(this._element).on(Event.MOUSEENTER, function (event) {
306
- return _this2.pause(event);
307
- }).on(Event.MOUSELEAVE, function (event) {
308
- return _this2.cycle(event);
309
- });
408
+ EventHandler__default['default'].on(this._element, EVENT_MOUSEENTER, event => this.pause(event));
409
+ EventHandler__default['default'].on(this._element, EVENT_MOUSELEAVE, event => this.cycle(event));
310
410
  }
311
411
 
312
- if (this._config.touch) {
412
+ if (this._config.touch && this._touchSupported) {
313
413
  this._addTouchEventListeners();
314
414
  }
315
- };
316
-
317
- _proto._addTouchEventListeners = function _addTouchEventListeners() {
318
- var _this3 = this;
319
-
320
- if (!this._touchSupported) {
321
- return;
322
- }
415
+ }
323
416
 
324
- var start = function start(event) {
325
- if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
326
- _this3.touchStartX = event.originalEvent.clientX;
327
- } else if (!_this3._pointerEvent) {
328
- _this3.touchStartX = event.originalEvent.touches[0].clientX;
417
+ _addTouchEventListeners() {
418
+ const start = event => {
419
+ if (this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)) {
420
+ this.touchStartX = event.clientX;
421
+ } else if (!this._pointerEvent) {
422
+ this.touchStartX = event.touches[0].clientX;
329
423
  }
330
424
  };
331
425
 
332
- var move = function move(event) {
426
+ const move = event => {
333
427
  // ensure swiping with one touch and not pinching
334
- if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
335
- _this3.touchDeltaX = 0;
336
- } else {
337
- _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
338
- }
428
+ this.touchDeltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this.touchStartX;
339
429
  };
340
430
 
341
- var end = function end(event) {
342
- if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
343
- _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
431
+ const end = event => {
432
+ if (this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)) {
433
+ this.touchDeltaX = event.clientX - this.touchStartX;
344
434
  }
345
435
 
346
- _this3._handleSwipe();
436
+ this._handleSwipe();
347
437
 
348
- if (_this3._config.pause === 'hover') {
438
+ if (this._config.pause === 'hover') {
349
439
  // If it's a touch-enabled device, mouseenter/leave are fired as
350
440
  // part of the mouse compatibility events on first tap - the carousel
351
441
  // would stop cycling until user tapped out of it;
@@ -353,149 +443,133 @@
353
443
  // (as if it's the second time we tap on it, mouseenter compat event
354
444
  // is NOT fired) and after a timeout (to allow for mouse compatibility
355
445
  // events to fire) we explicitly restart cycling
356
- _this3.pause();
446
+ this.pause();
357
447
 
358
- if (_this3.touchTimeout) {
359
- clearTimeout(_this3.touchTimeout);
448
+ if (this.touchTimeout) {
449
+ clearTimeout(this.touchTimeout);
360
450
  }
361
451
 
362
- _this3.touchTimeout = setTimeout(function (event) {
363
- return _this3.cycle(event);
364
- }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
452
+ this.touchTimeout = setTimeout(event => this.cycle(event), TOUCHEVENT_COMPAT_WAIT + this._config.interval);
365
453
  }
366
454
  };
367
455
 
368
- $(this._element.querySelectorAll(Selector.ITEM_IMG)).on(Event.DRAG_START, function (e) {
369
- return e.preventDefault();
456
+ SelectorEngine__default['default'].find(SELECTOR_ITEM_IMG, this._element).forEach(itemImg => {
457
+ EventHandler__default['default'].on(itemImg, EVENT_DRAG_START, e => e.preventDefault());
370
458
  });
371
459
 
372
460
  if (this._pointerEvent) {
373
- $(this._element).on(Event.POINTERDOWN, function (event) {
374
- return start(event);
375
- });
376
- $(this._element).on(Event.POINTERUP, function (event) {
377
- return end(event);
378
- });
461
+ EventHandler__default['default'].on(this._element, EVENT_POINTERDOWN, event => start(event));
462
+ EventHandler__default['default'].on(this._element, EVENT_POINTERUP, event => end(event));
379
463
 
380
- this._element.classList.add(ClassName.POINTER_EVENT);
464
+ this._element.classList.add(CLASS_NAME_POINTER_EVENT);
381
465
  } else {
382
- $(this._element).on(Event.TOUCHSTART, function (event) {
383
- return start(event);
384
- });
385
- $(this._element).on(Event.TOUCHMOVE, function (event) {
386
- return move(event);
387
- });
388
- $(this._element).on(Event.TOUCHEND, function (event) {
389
- return end(event);
390
- });
466
+ EventHandler__default['default'].on(this._element, EVENT_TOUCHSTART, event => start(event));
467
+ EventHandler__default['default'].on(this._element, EVENT_TOUCHMOVE, event => move(event));
468
+ EventHandler__default['default'].on(this._element, EVENT_TOUCHEND, event => end(event));
391
469
  }
392
- };
470
+ }
393
471
 
394
- _proto._keydown = function _keydown(event) {
472
+ _keydown(event) {
395
473
  if (/input|textarea/i.test(event.target.tagName)) {
396
474
  return;
397
475
  }
398
476
 
399
- switch (event.which) {
400
- case ARROW_LEFT_KEYCODE:
401
- event.preventDefault();
402
- this.prev();
403
- break;
477
+ const direction = KEY_TO_DIRECTION[event.key];
404
478
 
405
- case ARROW_RIGHT_KEYCODE:
406
- event.preventDefault();
407
- this.next();
408
- break;
479
+ if (direction) {
480
+ event.preventDefault();
409
481
 
410
- default:
482
+ this._slide(direction);
411
483
  }
412
- };
484
+ }
413
485
 
414
- _proto._getItemIndex = function _getItemIndex(element) {
415
- this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector.ITEM)) : [];
486
+ _getItemIndex(element) {
487
+ this._items = element && element.parentNode ? SelectorEngine__default['default'].find(SELECTOR_ITEM, element.parentNode) : [];
416
488
  return this._items.indexOf(element);
417
- };
418
-
419
- _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
420
- var isNextDirection = direction === Direction.NEXT;
421
- var isPrevDirection = direction === Direction.PREV;
422
-
423
- var activeIndex = this._getItemIndex(activeElement);
424
-
425
- var lastItemIndex = this._items.length - 1;
426
- var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
427
-
428
- if (isGoingToWrap && !this._config.wrap) {
429
- return activeElement;
430
- }
489
+ }
431
490
 
432
- var delta = direction === Direction.PREV ? -1 : 1;
433
- var itemIndex = (activeIndex + delta) % this._items.length;
434
- return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
435
- };
491
+ _getItemByOrder(order, activeElement) {
492
+ const isNext = order === ORDER_NEXT;
493
+ return getNextActiveElement(this._items, activeElement, isNext, this._config.wrap);
494
+ }
436
495
 
437
- _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
438
- var targetIndex = this._getItemIndex(relatedTarget);
496
+ _triggerSlideEvent(relatedTarget, eventDirectionName) {
497
+ const targetIndex = this._getItemIndex(relatedTarget);
439
498
 
440
- var fromIndex = this._getItemIndex(this._element.querySelector(Selector.ACTIVE_ITEM));
499
+ const fromIndex = this._getItemIndex(SelectorEngine__default['default'].findOne(SELECTOR_ACTIVE_ITEM, this._element));
441
500
 
442
- var slideEvent = $.Event(Event.SLIDE, {
443
- relatedTarget: relatedTarget,
501
+ return EventHandler__default['default'].trigger(this._element, EVENT_SLIDE, {
502
+ relatedTarget,
444
503
  direction: eventDirectionName,
445
504
  from: fromIndex,
446
505
  to: targetIndex
447
506
  });
448
- $(this._element).trigger(slideEvent);
449
- return slideEvent;
450
- };
507
+ }
451
508
 
452
- _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
509
+ _setActiveIndicatorElement(element) {
453
510
  if (this._indicatorsElement) {
454
- var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector.ACTIVE));
455
- $(indicators).removeClass(ClassName.ACTIVE);
511
+ const activeIndicator = SelectorEngine__default['default'].findOne(SELECTOR_ACTIVE, this._indicatorsElement);
512
+ activeIndicator.classList.remove(CLASS_NAME_ACTIVE);
513
+ activeIndicator.removeAttribute('aria-current');
514
+ const indicators = SelectorEngine__default['default'].find(SELECTOR_INDICATOR, this._indicatorsElement);
515
+
516
+ for (let i = 0; i < indicators.length; i++) {
517
+ if (Number.parseInt(indicators[i].getAttribute('data-bs-slide-to'), 10) === this._getItemIndex(element)) {
518
+ indicators[i].classList.add(CLASS_NAME_ACTIVE);
519
+ indicators[i].setAttribute('aria-current', 'true');
520
+ break;
521
+ }
522
+ }
523
+ }
524
+ }
456
525
 
457
- var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
526
+ _updateInterval() {
527
+ const element = this._activeElement || SelectorEngine__default['default'].findOne(SELECTOR_ACTIVE_ITEM, this._element);
458
528
 
459
- if (nextIndicator) {
460
- $(nextIndicator).addClass(ClassName.ACTIVE);
461
- }
529
+ if (!element) {
530
+ return;
462
531
  }
463
- };
464
532
 
465
- _proto._slide = function _slide(direction, element) {
466
- var _this4 = this;
533
+ const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10);
467
534
 
468
- var activeElement = this._element.querySelector(Selector.ACTIVE_ITEM);
535
+ if (elementInterval) {
536
+ this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
537
+ this._config.interval = elementInterval;
538
+ } else {
539
+ this._config.interval = this._config.defaultInterval || this._config.interval;
540
+ }
541
+ }
469
542
 
470
- var activeElementIndex = this._getItemIndex(activeElement);
543
+ _slide(directionOrOrder, element) {
544
+ const order = this._directionToOrder(directionOrOrder);
471
545
 
472
- var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
546
+ const activeElement = SelectorEngine__default['default'].findOne(SELECTOR_ACTIVE_ITEM, this._element);
473
547
 
474
- var nextElementIndex = this._getItemIndex(nextElement);
548
+ const activeElementIndex = this._getItemIndex(activeElement);
475
549
 
476
- var isCycling = Boolean(this._interval);
477
- var directionalClassName;
478
- var orderClassName;
479
- var eventDirectionName;
550
+ const nextElement = element || this._getItemByOrder(order, activeElement);
480
551
 
481
- if (direction === Direction.NEXT) {
482
- directionalClassName = ClassName.LEFT;
483
- orderClassName = ClassName.NEXT;
484
- eventDirectionName = Direction.LEFT;
485
- } else {
486
- directionalClassName = ClassName.RIGHT;
487
- orderClassName = ClassName.PREV;
488
- eventDirectionName = Direction.RIGHT;
489
- }
552
+ const nextElementIndex = this._getItemIndex(nextElement);
490
553
 
491
- if (nextElement && $(nextElement).hasClass(ClassName.ACTIVE)) {
554
+ const isCycling = Boolean(this._interval);
555
+ const isNext = order === ORDER_NEXT;
556
+ const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END;
557
+ const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
558
+
559
+ const eventDirectionName = this._orderToDirection(order);
560
+
561
+ if (nextElement && nextElement.classList.contains(CLASS_NAME_ACTIVE)) {
492
562
  this._isSliding = false;
493
563
  return;
494
564
  }
495
565
 
496
- var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
566
+ if (this._isSliding) {
567
+ return;
568
+ }
569
+
570
+ const slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
497
571
 
498
- if (slideEvent.isDefaultPrevented()) {
572
+ if (slideEvent.defaultPrevented) {
499
573
  return;
500
574
  }
501
575
 
@@ -512,125 +586,129 @@
512
586
 
513
587
  this._setActiveIndicatorElement(nextElement);
514
588
 
515
- var slidEvent = $.Event(Event.SLID, {
516
- relatedTarget: nextElement,
517
- direction: eventDirectionName,
518
- from: activeElementIndex,
519
- to: nextElementIndex
520
- });
589
+ this._activeElement = nextElement;
521
590
 
522
- if ($(this._element).hasClass(ClassName.SLIDE)) {
523
- $(nextElement).addClass(orderClassName);
524
- Util.reflow(nextElement);
525
- $(activeElement).addClass(directionalClassName);
526
- $(nextElement).addClass(directionalClassName);
527
- var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
528
-
529
- if (nextElementInterval) {
530
- this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
531
- this._config.interval = nextElementInterval;
532
- } else {
533
- this._config.interval = this._config.defaultInterval || this._config.interval;
534
- }
591
+ const triggerSlidEvent = () => {
592
+ EventHandler__default['default'].trigger(this._element, EVENT_SLID, {
593
+ relatedTarget: nextElement,
594
+ direction: eventDirectionName,
595
+ from: activeElementIndex,
596
+ to: nextElementIndex
597
+ });
598
+ };
535
599
 
536
- var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
537
- $(activeElement).one(Util.TRANSITION_END, function () {
538
- $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName.ACTIVE);
539
- $(activeElement).removeClass(ClassName.ACTIVE + " " + orderClassName + " " + directionalClassName);
540
- _this4._isSliding = false;
541
- setTimeout(function () {
542
- return $(_this4._element).trigger(slidEvent);
543
- }, 0);
544
- }).emulateTransitionEnd(transitionDuration);
600
+ if (this._element.classList.contains(CLASS_NAME_SLIDE)) {
601
+ nextElement.classList.add(orderClassName);
602
+ reflow(nextElement);
603
+ activeElement.classList.add(directionalClassName);
604
+ nextElement.classList.add(directionalClassName);
605
+
606
+ const completeCallBack = () => {
607
+ nextElement.classList.remove(directionalClassName, orderClassName);
608
+ nextElement.classList.add(CLASS_NAME_ACTIVE);
609
+ activeElement.classList.remove(CLASS_NAME_ACTIVE, orderClassName, directionalClassName);
610
+ this._isSliding = false;
611
+ setTimeout(triggerSlidEvent, 0);
612
+ };
613
+
614
+ this._queueCallback(completeCallBack, activeElement, true);
545
615
  } else {
546
- $(activeElement).removeClass(ClassName.ACTIVE);
547
- $(nextElement).addClass(ClassName.ACTIVE);
616
+ activeElement.classList.remove(CLASS_NAME_ACTIVE);
617
+ nextElement.classList.add(CLASS_NAME_ACTIVE);
548
618
  this._isSliding = false;
549
- $(this._element).trigger(slidEvent);
619
+ triggerSlidEvent();
550
620
  }
551
621
 
552
622
  if (isCycling) {
553
623
  this.cycle();
554
624
  }
555
- } // Static
556
- ;
625
+ }
557
626
 
558
- Carousel._jQueryInterface = function _jQueryInterface(config) {
559
- return this.each(function () {
560
- var data = $(this).data(DATA_KEY);
627
+ _directionToOrder(direction) {
628
+ if (![DIRECTION_RIGHT, DIRECTION_LEFT].includes(direction)) {
629
+ return direction;
630
+ }
561
631
 
562
- var _config = _objectSpread({}, Default, $(this).data());
632
+ if (isRTL()) {
633
+ return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT;
634
+ }
563
635
 
564
- if (typeof config === 'object') {
565
- _config = _objectSpread({}, _config, config);
566
- }
636
+ return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV;
637
+ }
567
638
 
568
- var action = typeof config === 'string' ? config : _config.slide;
639
+ _orderToDirection(order) {
640
+ if (![ORDER_NEXT, ORDER_PREV].includes(order)) {
641
+ return order;
642
+ }
569
643
 
570
- if (!data) {
571
- data = new Carousel(this, _config);
572
- $(this).data(DATA_KEY, data);
573
- }
644
+ if (isRTL()) {
645
+ return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT;
646
+ }
574
647
 
575
- if (typeof config === 'number') {
576
- data.to(config);
577
- } else if (typeof action === 'string') {
578
- if (typeof data[action] === 'undefined') {
579
- throw new TypeError("No method named \"" + action + "\"");
580
- }
648
+ return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT;
649
+ } // Static
581
650
 
582
- data[action]();
583
- } else if (_config.interval && _config.ride) {
584
- data.pause();
585
- data.cycle();
586
- }
587
- });
588
- };
589
651
 
590
- Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
591
- var selector = Util.getSelectorFromElement(this);
652
+ static carouselInterface(element, config) {
653
+ const data = Carousel.getOrCreateInstance(element, config);
654
+ let {
655
+ _config
656
+ } = data;
592
657
 
593
- if (!selector) {
594
- return;
658
+ if (typeof config === 'object') {
659
+ _config = { ..._config,
660
+ ...config
661
+ };
595
662
  }
596
663
 
597
- var target = $(selector)[0];
664
+ const action = typeof config === 'string' ? config : _config.slide;
598
665
 
599
- if (!target || !$(target).hasClass(ClassName.CAROUSEL)) {
600
- return;
666
+ if (typeof config === 'number') {
667
+ data.to(config);
668
+ } else if (typeof action === 'string') {
669
+ if (typeof data[action] === 'undefined') {
670
+ throw new TypeError(`No method named "${action}"`);
671
+ }
672
+
673
+ data[action]();
674
+ } else if (_config.interval && _config.ride) {
675
+ data.pause();
676
+ data.cycle();
601
677
  }
678
+ }
602
679
 
603
- var config = _objectSpread({}, $(target).data(), $(this).data());
680
+ static jQueryInterface(config) {
681
+ return this.each(function () {
682
+ Carousel.carouselInterface(this, config);
683
+ });
684
+ }
604
685
 
605
- var slideIndex = this.getAttribute('data-slide-to');
686
+ static dataApiClickHandler(event) {
687
+ const target = getElementFromSelector(this);
688
+
689
+ if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
690
+ return;
691
+ }
692
+
693
+ const config = { ...Manipulator__default['default'].getDataAttributes(target),
694
+ ...Manipulator__default['default'].getDataAttributes(this)
695
+ };
696
+ const slideIndex = this.getAttribute('data-bs-slide-to');
606
697
 
607
698
  if (slideIndex) {
608
699
  config.interval = false;
609
700
  }
610
701
 
611
- Carousel._jQueryInterface.call($(target), config);
702
+ Carousel.carouselInterface(target, config);
612
703
 
613
704
  if (slideIndex) {
614
- $(target).data(DATA_KEY).to(slideIndex);
705
+ Carousel.getInstance(target).to(slideIndex);
615
706
  }
616
707
 
617
708
  event.preventDefault();
618
- };
619
-
620
- _createClass(Carousel, null, [{
621
- key: "VERSION",
622
- get: function get() {
623
- return VERSION;
624
- }
625
- }, {
626
- key: "Default",
627
- get: function get() {
628
- return Default;
629
- }
630
- }]);
709
+ }
631
710
 
632
- return Carousel;
633
- }();
711
+ }
634
712
  /**
635
713
  * ------------------------------------------------------------------------
636
714
  * Data Api implementation
@@ -638,30 +716,23 @@
638
716
  */
639
717
 
640
718
 
641
- $(document).on(Event.CLICK_DATA_API, Selector.DATA_SLIDE, Carousel._dataApiClickHandler);
642
- $(window).on(Event.LOAD_DATA_API, function () {
643
- var carousels = [].slice.call(document.querySelectorAll(Selector.DATA_RIDE));
644
-
645
- for (var i = 0, len = carousels.length; i < len; i++) {
646
- var $carousel = $(carousels[i]);
719
+ EventHandler__default['default'].on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler);
720
+ EventHandler__default['default'].on(window, EVENT_LOAD_DATA_API, () => {
721
+ const carousels = SelectorEngine__default['default'].find(SELECTOR_DATA_RIDE);
647
722
 
648
- Carousel._jQueryInterface.call($carousel, $carousel.data());
723
+ for (let i = 0, len = carousels.length; i < len; i++) {
724
+ Carousel.carouselInterface(carousels[i], Carousel.getInstance(carousels[i]));
649
725
  }
650
726
  });
651
727
  /**
652
728
  * ------------------------------------------------------------------------
653
729
  * jQuery
654
730
  * ------------------------------------------------------------------------
731
+ * add .Carousel to jQuery only if jQuery is present
655
732
  */
656
733
 
657
- $.fn[NAME] = Carousel._jQueryInterface;
658
- $.fn[NAME].Constructor = Carousel;
659
-
660
- $.fn[NAME].noConflict = function () {
661
- $.fn[NAME] = JQUERY_NO_CONFLICT;
662
- return Carousel._jQueryInterface;
663
- };
734
+ defineJQueryPlugin(Carousel);
664
735
 
665
736
  return Carousel;
666
737
 
667
- }));
738
+ })));