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