bootstrap 4.6.0 → 5.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +61 -0
  3. data/Gemfile +1 -0
  4. data/README.md +33 -6
  5. data/Rakefile +10 -1
  6. data/assets/javascripts/bootstrap/alert.js +53 -155
  7. data/assets/javascripts/bootstrap/base-component.js +83 -0
  8. data/assets/javascripts/bootstrap/button.js +43 -198
  9. data/assets/javascripts/bootstrap/carousel.js +285 -550
  10. data/assets/javascripts/bootstrap/collapse.js +169 -323
  11. data/assets/javascripts/bootstrap/dom/data.js +62 -0
  12. data/assets/javascripts/bootstrap/dom/event-handler.js +236 -0
  13. data/assets/javascripts/bootstrap/dom/manipulator.js +71 -0
  14. data/assets/javascripts/bootstrap/dom/selector-engine.js +103 -0
  15. data/assets/javascripts/bootstrap/dropdown.js +300 -467
  16. data/assets/javascripts/bootstrap/modal.js +226 -575
  17. data/assets/javascripts/bootstrap/offcanvas.js +245 -0
  18. data/assets/javascripts/bootstrap/popover.js +61 -205
  19. data/assets/javascripts/bootstrap/scrollspy.js +216 -287
  20. data/assets/javascripts/bootstrap/tab.js +226 -203
  21. data/assets/javascripts/bootstrap/toast.js +136 -209
  22. data/assets/javascripts/bootstrap/tooltip.js +411 -757
  23. data/assets/javascripts/bootstrap/util/backdrop.js +139 -0
  24. data/assets/javascripts/bootstrap/util/component-functions.js +41 -0
  25. data/assets/javascripts/bootstrap/util/config.js +67 -0
  26. data/assets/javascripts/bootstrap/util/focustrap.js +113 -0
  27. data/assets/javascripts/bootstrap/util/index.js +281 -0
  28. data/assets/javascripts/bootstrap/util/sanitizer.js +110 -0
  29. data/assets/javascripts/bootstrap/util/scrollbar.js +112 -0
  30. data/assets/javascripts/bootstrap/util/swipe.js +134 -0
  31. data/assets/javascripts/bootstrap/util/template-factory.js +150 -0
  32. data/assets/javascripts/bootstrap-global-this-define.js +6 -0
  33. data/assets/javascripts/bootstrap-global-this-undefine.js +2 -0
  34. data/assets/javascripts/bootstrap-sprockets.js +23 -7
  35. data/assets/javascripts/bootstrap.js +3649 -3587
  36. data/assets/javascripts/bootstrap.min.js +3 -3
  37. data/assets/stylesheets/_bootstrap-grid.scss +53 -21
  38. data/assets/stylesheets/_bootstrap-reboot.scss +5 -7
  39. data/assets/stylesheets/_bootstrap-utilities.scss +19 -0
  40. data/assets/stylesheets/_bootstrap.scss +21 -13
  41. data/assets/stylesheets/bootstrap/_accordion.scss +158 -0
  42. data/assets/stylesheets/bootstrap/_alert.scss +32 -16
  43. data/assets/stylesheets/bootstrap/_badge.scss +15 -31
  44. data/assets/stylesheets/bootstrap/_breadcrumb.scss +22 -24
  45. data/assets/stylesheets/bootstrap/_button-group.scss +27 -48
  46. data/assets/stylesheets/bootstrap/_buttons.scss +136 -71
  47. data/assets/stylesheets/bootstrap/_card.scss +66 -113
  48. data/assets/stylesheets/bootstrap/_carousel.scss +83 -36
  49. data/assets/stylesheets/bootstrap/_close.scss +51 -28
  50. data/assets/stylesheets/bootstrap/_containers.scss +41 -0
  51. data/assets/stylesheets/bootstrap/_dropdown.scss +129 -71
  52. data/assets/stylesheets/bootstrap/_forms.scss +9 -347
  53. data/assets/stylesheets/bootstrap/_functions.scss +181 -23
  54. data/assets/stylesheets/bootstrap/_grid.scss +18 -52
  55. data/assets/stylesheets/bootstrap/_helpers.scss +12 -0
  56. data/assets/stylesheets/bootstrap/_images.scss +1 -1
  57. data/assets/stylesheets/bootstrap/_list-group.scss +77 -34
  58. data/assets/stylesheets/bootstrap/_maps.scss +174 -0
  59. data/assets/stylesheets/bootstrap/_mixins.scss +10 -15
  60. data/assets/stylesheets/bootstrap/_modal.scss +107 -110
  61. data/assets/stylesheets/bootstrap/_nav.scss +102 -25
  62. data/assets/stylesheets/bootstrap/_navbar.scss +129 -172
  63. data/assets/stylesheets/bootstrap/_offcanvas.scss +146 -0
  64. data/assets/stylesheets/bootstrap/_pagination.scss +72 -37
  65. data/assets/stylesheets/bootstrap/_placeholders.scss +51 -0
  66. data/assets/stylesheets/bootstrap/_popover.scss +99 -73
  67. data/assets/stylesheets/bootstrap/_progress.scss +35 -14
  68. data/assets/stylesheets/bootstrap/_reboot.scss +319 -192
  69. data/assets/stylesheets/bootstrap/_root.scss +177 -9
  70. data/assets/stylesheets/bootstrap/_spinners.scss +44 -24
  71. data/assets/stylesheets/bootstrap/_tables.scss +101 -115
  72. data/assets/stylesheets/bootstrap/_toasts.scss +54 -27
  73. data/assets/stylesheets/bootstrap/_tooltip.scss +67 -63
  74. data/assets/stylesheets/bootstrap/_transitions.scss +8 -1
  75. data/assets/stylesheets/bootstrap/_type.scss +40 -59
  76. data/assets/stylesheets/bootstrap/_utilities.scss +806 -18
  77. data/assets/stylesheets/bootstrap/_variables-dark.scss +87 -0
  78. data/assets/stylesheets/bootstrap/_variables.scss +1216 -615
  79. data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +95 -0
  80. data/assets/stylesheets/bootstrap/forms/_form-check.scss +189 -0
  81. data/assets/stylesheets/bootstrap/forms/_form-control.scss +214 -0
  82. data/assets/stylesheets/bootstrap/forms/_form-range.scss +91 -0
  83. data/assets/stylesheets/bootstrap/forms/_form-select.scss +80 -0
  84. data/assets/stylesheets/bootstrap/forms/_form-text.scss +11 -0
  85. data/assets/stylesheets/bootstrap/forms/_input-group.scss +132 -0
  86. data/assets/stylesheets/bootstrap/forms/_labels.scss +36 -0
  87. data/assets/stylesheets/bootstrap/forms/_validation.scss +12 -0
  88. data/assets/stylesheets/bootstrap/helpers/_color-bg.scss +7 -0
  89. data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +30 -0
  90. data/assets/stylesheets/bootstrap/helpers/_focus-ring.scss +5 -0
  91. data/assets/stylesheets/bootstrap/helpers/_icon-link.scss +25 -0
  92. data/assets/stylesheets/bootstrap/helpers/_position.scss +36 -0
  93. data/assets/stylesheets/bootstrap/helpers/_ratio.scss +26 -0
  94. data/assets/stylesheets/bootstrap/helpers/_stacks.scss +15 -0
  95. data/assets/stylesheets/bootstrap/helpers/_stretched-link.scss +15 -0
  96. data/assets/stylesheets/bootstrap/helpers/_text-truncation.scss +7 -0
  97. data/assets/stylesheets/bootstrap/helpers/_visually-hidden.scss +8 -0
  98. data/assets/stylesheets/bootstrap/helpers/_vr.scss +8 -0
  99. data/assets/stylesheets/bootstrap/mixins/_alert.scss +11 -6
  100. data/assets/stylesheets/bootstrap/mixins/_backdrop.scss +14 -0
  101. data/assets/stylesheets/bootstrap/mixins/_banner.scss +7 -0
  102. data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +10 -8
  103. data/assets/stylesheets/bootstrap/mixins/_box-shadow.scss +7 -9
  104. data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +20 -16
  105. data/assets/stylesheets/bootstrap/mixins/_buttons.scss +60 -100
  106. data/assets/stylesheets/bootstrap/mixins/_caret.scss +34 -27
  107. data/assets/stylesheets/bootstrap/mixins/_clearfix.scss +2 -0
  108. data/assets/stylesheets/bootstrap/mixins/_color-mode.scss +21 -0
  109. data/assets/stylesheets/bootstrap/mixins/_color-scheme.scss +7 -0
  110. data/assets/stylesheets/bootstrap/mixins/_container.scss +11 -0
  111. data/assets/stylesheets/bootstrap/mixins/_forms.scss +53 -85
  112. data/assets/stylesheets/bootstrap/mixins/_gradients.scss +13 -11
  113. data/assets/stylesheets/bootstrap/mixins/_grid.scss +119 -37
  114. data/assets/stylesheets/bootstrap/mixins/_image.scss +1 -21
  115. data/assets/stylesheets/bootstrap/mixins/_list-group.scss +7 -2
  116. data/assets/stylesheets/bootstrap/mixins/_lists.scss +1 -1
  117. data/assets/stylesheets/bootstrap/mixins/_pagination.scss +7 -19
  118. data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +3 -3
  119. data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +24 -0
  120. data/assets/stylesheets/bootstrap/mixins/_transition.scss +1 -1
  121. data/assets/stylesheets/bootstrap/mixins/_utilities.scss +97 -0
  122. data/assets/stylesheets/bootstrap/mixins/_visually-hidden.scss +33 -0
  123. data/assets/stylesheets/bootstrap/utilities/_api.scss +47 -0
  124. data/assets/stylesheets/bootstrap/vendor/_rfs.scss +276 -132
  125. data/bootstrap.gemspec +6 -7
  126. data/lib/bootstrap/engine.rb +7 -1
  127. data/lib/bootstrap/version.rb +2 -2
  128. data/tasks/updater/js.rb +31 -7
  129. data/tasks/updater/network.rb +9 -3
  130. data/tasks/updater/scss.rb +2 -2
  131. data/tasks/updater.rb +2 -2
  132. data/test/dummy_rails/app/assets/javascripts/application.js +4 -3
  133. data/test/dummy_rails/app/views/layouts/application.html.erb +3 -1
  134. data/test/dummy_rails/app/views/pages/root.html +89 -0
  135. data/test/dummy_rails/config/application.rb +0 -3
  136. data/test/gemfiles/rails_4_2.gemfile +1 -1
  137. data/test/gemfiles/rails_5_0.gemfile +1 -1
  138. data/test/gemfiles/rails_5_1.gemfile +1 -1
  139. data/test/gemfiles/rails_5_2.gemfile +8 -0
  140. data/test/gemfiles/rails_6_0.gemfile +1 -0
  141. data/test/gemfiles/rails_6_1.gemfile +8 -0
  142. data/test/gemfiles/rails_7_0_dartsass.gemfile +8 -0
  143. data/test/gemfiles/rails_7_0_sassc.gemfile +8 -0
  144. data/test/test_helper.rb +3 -2
  145. metadata +97 -85
  146. data/.travis.yml +0 -31
  147. data/assets/javascripts/bootstrap/util.js +0 -192
  148. data/assets/stylesheets/bootstrap/_code.scss +0 -48
  149. data/assets/stylesheets/bootstrap/_custom-forms.scss +0 -526
  150. data/assets/stylesheets/bootstrap/_input-group.scss +0 -208
  151. data/assets/stylesheets/bootstrap/_jumbotron.scss +0 -17
  152. data/assets/stylesheets/bootstrap/_media.scss +0 -8
  153. data/assets/stylesheets/bootstrap/_print.scss +0 -141
  154. data/assets/stylesheets/bootstrap/mixins/_background-variant.scss +0 -23
  155. data/assets/stylesheets/bootstrap/mixins/_badge.scss +0 -17
  156. data/assets/stylesheets/bootstrap/mixins/_float.scss +0 -14
  157. data/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +0 -80
  158. data/assets/stylesheets/bootstrap/mixins/_hover.scss +0 -37
  159. data/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +0 -11
  160. data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +0 -34
  161. data/assets/stylesheets/bootstrap/mixins/_size.scss +0 -7
  162. data/assets/stylesheets/bootstrap/mixins/_table-row.scss +0 -39
  163. data/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +0 -17
  164. data/assets/stylesheets/bootstrap/mixins/_text-hide.scss +0 -11
  165. data/assets/stylesheets/bootstrap/mixins/_visibility.scss +0 -8
  166. data/assets/stylesheets/bootstrap/utilities/_align.scss +0 -8
  167. data/assets/stylesheets/bootstrap/utilities/_background.scss +0 -19
  168. data/assets/stylesheets/bootstrap/utilities/_borders.scss +0 -75
  169. data/assets/stylesheets/bootstrap/utilities/_display.scss +0 -26
  170. data/assets/stylesheets/bootstrap/utilities/_embed.scss +0 -39
  171. data/assets/stylesheets/bootstrap/utilities/_flex.scss +0 -51
  172. data/assets/stylesheets/bootstrap/utilities/_float.scss +0 -11
  173. data/assets/stylesheets/bootstrap/utilities/_interactions.scss +0 -5
  174. data/assets/stylesheets/bootstrap/utilities/_overflow.scss +0 -5
  175. data/assets/stylesheets/bootstrap/utilities/_position.scss +0 -32
  176. data/assets/stylesheets/bootstrap/utilities/_screenreaders.scss +0 -11
  177. data/assets/stylesheets/bootstrap/utilities/_shadows.scss +0 -6
  178. data/assets/stylesheets/bootstrap/utilities/_sizing.scss +0 -20
  179. data/assets/stylesheets/bootstrap/utilities/_spacing.scss +0 -73
  180. data/assets/stylesheets/bootstrap/utilities/_stretched-link.scss +0 -19
  181. data/assets/stylesheets/bootstrap/utilities/_text.scss +0 -72
  182. data/assets/stylesheets/bootstrap/utilities/_visibility.scss +0 -13
  183. data/test/dummy_rails/app/views/pages/root.html.slim +0 -58
  184. /data/assets/stylesheets/bootstrap/{utilities → helpers}/_clearfix.scss +0 -0
@@ -1,652 +1,387 @@
1
1
  /*!
2
- * Bootstrap carousel.js v4.6.0 (https://getbootstrap.com/)
3
- * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
2
+ * Bootstrap carousel.js v5.3.2 (https://getbootstrap.com/)
3
+ * Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
4
4
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
5
  */
6
6
  (function (global, factory) {
7
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('./util.js')) :
8
- typeof define === 'function' && define.amd ? define(['jquery', './util'], factory) :
9
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Carousel = factory(global.jQuery, global.Util));
10
- }(this, (function ($, Util) { 'use strict';
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./base-component.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js'), require('./util/index.js'), require('./util/swipe.js')) :
8
+ typeof define === 'function' && define.amd ? define(['./base-component', './dom/event-handler', './dom/manipulator', './dom/selector-engine', './util/index', './util/swipe'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Carousel = factory(global.BaseComponent, global.EventHandler, global.Manipulator, global.SelectorEngine, global.Index, global.Swipe));
10
+ })(this, (function (BaseComponent, EventHandler, Manipulator, SelectorEngine, index_js, Swipe) { 'use strict';
11
11
 
12
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
-
14
- var $__default = /*#__PURE__*/_interopDefaultLegacy($);
15
- var Util__default = /*#__PURE__*/_interopDefaultLegacy(Util);
16
-
17
- function _defineProperties(target, props) {
18
- for (var i = 0; i < props.length; i++) {
19
- var descriptor = props[i];
20
- descriptor.enumerable = descriptor.enumerable || false;
21
- descriptor.configurable = true;
22
- if ("value" in descriptor) descriptor.writable = true;
23
- Object.defineProperty(target, descriptor.key, descriptor);
24
- }
25
- }
26
-
27
- function _createClass(Constructor, protoProps, staticProps) {
28
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
29
- if (staticProps) _defineProperties(Constructor, staticProps);
30
- return Constructor;
31
- }
32
-
33
- function _extends() {
34
- _extends = Object.assign || function (target) {
35
- for (var i = 1; i < arguments.length; i++) {
36
- var source = arguments[i];
37
-
38
- for (var key in source) {
39
- if (Object.prototype.hasOwnProperty.call(source, key)) {
40
- target[key] = source[key];
41
- }
42
- }
43
- }
44
-
45
- return target;
46
- };
12
+ /**
13
+ * --------------------------------------------------------------------------
14
+ * Bootstrap carousel.js
15
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
16
+ * --------------------------------------------------------------------------
17
+ */
47
18
 
48
- return _extends.apply(this, arguments);
49
- }
50
19
 
51
20
  /**
52
- * ------------------------------------------------------------------------
53
21
  * Constants
54
- * ------------------------------------------------------------------------
55
22
  */
56
23
 
57
- var NAME = 'carousel';
58
- var VERSION = '4.6.0';
59
- var DATA_KEY = 'bs.carousel';
60
- var EVENT_KEY = "." + DATA_KEY;
61
- var DATA_API_KEY = '.data-api';
62
- var JQUERY_NO_CONFLICT = $__default['default'].fn[NAME];
63
- var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
64
-
65
- var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
66
-
67
- var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
68
-
69
- var SWIPE_THRESHOLD = 40;
70
- var Default = {
24
+ const NAME = 'carousel';
25
+ const DATA_KEY = 'bs.carousel';
26
+ const EVENT_KEY = `.${DATA_KEY}`;
27
+ const DATA_API_KEY = '.data-api';
28
+ const ARROW_LEFT_KEY = 'ArrowLeft';
29
+ const ARROW_RIGHT_KEY = 'ArrowRight';
30
+ const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
31
+
32
+ const ORDER_NEXT = 'next';
33
+ const ORDER_PREV = 'prev';
34
+ const DIRECTION_LEFT = 'left';
35
+ const DIRECTION_RIGHT = 'right';
36
+ const EVENT_SLIDE = `slide${EVENT_KEY}`;
37
+ const EVENT_SLID = `slid${EVENT_KEY}`;
38
+ const EVENT_KEYDOWN = `keydown${EVENT_KEY}`;
39
+ const EVENT_MOUSEENTER = `mouseenter${EVENT_KEY}`;
40
+ const EVENT_MOUSELEAVE = `mouseleave${EVENT_KEY}`;
41
+ const EVENT_DRAG_START = `dragstart${EVENT_KEY}`;
42
+ const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`;
43
+ const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
44
+ const CLASS_NAME_CAROUSEL = 'carousel';
45
+ const CLASS_NAME_ACTIVE = 'active';
46
+ const CLASS_NAME_SLIDE = 'slide';
47
+ const CLASS_NAME_END = 'carousel-item-end';
48
+ const CLASS_NAME_START = 'carousel-item-start';
49
+ const CLASS_NAME_NEXT = 'carousel-item-next';
50
+ const CLASS_NAME_PREV = 'carousel-item-prev';
51
+ const SELECTOR_ACTIVE = '.active';
52
+ const SELECTOR_ITEM = '.carousel-item';
53
+ const SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM;
54
+ const SELECTOR_ITEM_IMG = '.carousel-item img';
55
+ const SELECTOR_INDICATORS = '.carousel-indicators';
56
+ const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
57
+ const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
58
+ const KEY_TO_DIRECTION = {
59
+ [ARROW_LEFT_KEY]: DIRECTION_RIGHT,
60
+ [ARROW_RIGHT_KEY]: DIRECTION_LEFT
61
+ };
62
+ const Default = {
71
63
  interval: 5000,
72
64
  keyboard: true,
73
- slide: false,
74
65
  pause: 'hover',
75
- wrap: true,
76
- touch: true
66
+ ride: false,
67
+ touch: true,
68
+ wrap: true
77
69
  };
78
- var DefaultType = {
70
+ const DefaultType = {
79
71
  interval: '(number|boolean)',
72
+ // TODO:v6 remove boolean support
80
73
  keyboard: 'boolean',
81
- slide: '(boolean|string)',
82
74
  pause: '(string|boolean)',
83
- wrap: 'boolean',
84
- touch: 'boolean'
85
- };
86
- var DIRECTION_NEXT = 'next';
87
- var DIRECTION_PREV = 'prev';
88
- var DIRECTION_LEFT = 'left';
89
- var DIRECTION_RIGHT = 'right';
90
- var EVENT_SLIDE = "slide" + EVENT_KEY;
91
- var EVENT_SLID = "slid" + EVENT_KEY;
92
- var EVENT_KEYDOWN = "keydown" + EVENT_KEY;
93
- var EVENT_MOUSEENTER = "mouseenter" + EVENT_KEY;
94
- var EVENT_MOUSELEAVE = "mouseleave" + EVENT_KEY;
95
- var EVENT_TOUCHSTART = "touchstart" + EVENT_KEY;
96
- var EVENT_TOUCHMOVE = "touchmove" + EVENT_KEY;
97
- var EVENT_TOUCHEND = "touchend" + EVENT_KEY;
98
- var EVENT_POINTERDOWN = "pointerdown" + EVENT_KEY;
99
- var EVENT_POINTERUP = "pointerup" + EVENT_KEY;
100
- var EVENT_DRAG_START = "dragstart" + EVENT_KEY;
101
- var EVENT_LOAD_DATA_API = "load" + EVENT_KEY + DATA_API_KEY;
102
- var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY;
103
- var CLASS_NAME_CAROUSEL = 'carousel';
104
- var CLASS_NAME_ACTIVE = 'active';
105
- var CLASS_NAME_SLIDE = 'slide';
106
- var CLASS_NAME_RIGHT = 'carousel-item-right';
107
- var CLASS_NAME_LEFT = 'carousel-item-left';
108
- var CLASS_NAME_NEXT = 'carousel-item-next';
109
- var CLASS_NAME_PREV = 'carousel-item-prev';
110
- var CLASS_NAME_POINTER_EVENT = 'pointer-event';
111
- var SELECTOR_ACTIVE = '.active';
112
- var SELECTOR_ACTIVE_ITEM = '.active.carousel-item';
113
- var SELECTOR_ITEM = '.carousel-item';
114
- var SELECTOR_ITEM_IMG = '.carousel-item img';
115
- var SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev';
116
- var SELECTOR_INDICATORS = '.carousel-indicators';
117
- var SELECTOR_DATA_SLIDE = '[data-slide], [data-slide-to]';
118
- var SELECTOR_DATA_RIDE = '[data-ride="carousel"]';
119
- var PointerType = {
120
- TOUCH: 'touch',
121
- PEN: 'pen'
75
+ ride: '(boolean|string)',
76
+ touch: 'boolean',
77
+ wrap: 'boolean'
122
78
  };
79
+
123
80
  /**
124
- * ------------------------------------------------------------------------
125
- * Class Definition
126
- * ------------------------------------------------------------------------
81
+ * Class definition
127
82
  */
128
83
 
129
- var Carousel = /*#__PURE__*/function () {
130
- function Carousel(element, config) {
131
- this._items = null;
84
+ class Carousel extends BaseComponent {
85
+ constructor(element, config) {
86
+ super(element, config);
132
87
  this._interval = null;
133
88
  this._activeElement = null;
134
- this._isPaused = false;
135
89
  this._isSliding = false;
136
90
  this.touchTimeout = null;
137
- this.touchStartX = 0;
138
- this.touchDeltaX = 0;
139
- this._config = this._getConfig(config);
140
- this._element = element;
141
- this._indicatorsElement = this._element.querySelector(SELECTOR_INDICATORS);
142
- this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
143
- this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
144
-
91
+ this._swipeHelper = null;
92
+ this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
145
93
  this._addEventListeners();
146
- } // Getters
147
-
94
+ if (this._config.ride === CLASS_NAME_CAROUSEL) {
95
+ this.cycle();
96
+ }
97
+ }
148
98
 
149
- var _proto = Carousel.prototype;
99
+ // Getters
100
+ static get Default() {
101
+ return Default;
102
+ }
103
+ static get DefaultType() {
104
+ return DefaultType;
105
+ }
106
+ static get NAME() {
107
+ return NAME;
108
+ }
150
109
 
151
110
  // Public
152
- _proto.next = function next() {
153
- if (!this._isSliding) {
154
- this._slide(DIRECTION_NEXT);
155
- }
156
- };
157
-
158
- _proto.nextWhenVisible = function nextWhenVisible() {
159
- var $element = $__default['default'](this._element); // Don't call next when the page isn't visible
111
+ next() {
112
+ this._slide(ORDER_NEXT);
113
+ }
114
+ nextWhenVisible() {
115
+ // FIXME TODO use `document.visibilityState`
116
+ // Don't call next when the page isn't visible
160
117
  // or the carousel or its parent isn't visible
161
-
162
- if (!document.hidden && $element.is(':visible') && $element.css('visibility') !== 'hidden') {
118
+ if (!document.hidden && index_js.isVisible(this._element)) {
163
119
  this.next();
164
120
  }
165
- };
166
-
167
- _proto.prev = function prev() {
168
- if (!this._isSliding) {
169
- this._slide(DIRECTION_PREV);
170
- }
171
- };
172
-
173
- _proto.pause = function pause(event) {
174
- if (!event) {
175
- this._isPaused = true;
176
- }
177
-
178
- if (this._element.querySelector(SELECTOR_NEXT_PREV)) {
179
- Util__default['default'].triggerTransitionEnd(this._element);
180
- this.cycle(true);
181
- }
182
-
183
- clearInterval(this._interval);
184
- this._interval = null;
185
- };
186
-
187
- _proto.cycle = function cycle(event) {
188
- if (!event) {
189
- this._isPaused = false;
121
+ }
122
+ prev() {
123
+ this._slide(ORDER_PREV);
124
+ }
125
+ pause() {
126
+ if (this._isSliding) {
127
+ index_js.triggerTransitionEnd(this._element);
190
128
  }
191
-
192
- if (this._interval) {
193
- clearInterval(this._interval);
194
- this._interval = null;
129
+ this._clearInterval();
130
+ }
131
+ cycle() {
132
+ this._clearInterval();
133
+ this._updateInterval();
134
+ this._interval = setInterval(() => this.nextWhenVisible(), this._config.interval);
135
+ }
136
+ _maybeEnableCycle() {
137
+ if (!this._config.ride) {
138
+ return;
195
139
  }
196
-
197
- if (this._config.interval && !this._isPaused) {
198
- this._updateInterval();
199
-
200
- this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
140
+ if (this._isSliding) {
141
+ EventHandler.one(this._element, EVENT_SLID, () => this.cycle());
142
+ return;
201
143
  }
202
- };
203
-
204
- _proto.to = function to(index) {
205
- var _this = this;
206
-
207
- this._activeElement = this._element.querySelector(SELECTOR_ACTIVE_ITEM);
208
-
209
- var activeIndex = this._getItemIndex(this._activeElement);
210
-
211
- if (index > this._items.length - 1 || index < 0) {
144
+ this.cycle();
145
+ }
146
+ to(index) {
147
+ const items = this._getItems();
148
+ if (index > items.length - 1 || index < 0) {
212
149
  return;
213
150
  }
214
-
215
151
  if (this._isSliding) {
216
- $__default['default'](this._element).one(EVENT_SLID, function () {
217
- return _this.to(index);
218
- });
152
+ EventHandler.one(this._element, EVENT_SLID, () => this.to(index));
219
153
  return;
220
154
  }
221
-
155
+ const activeIndex = this._getItemIndex(this._getActive());
222
156
  if (activeIndex === index) {
223
- this.pause();
224
- this.cycle();
225
- return;
226
- }
227
-
228
- var direction = index > activeIndex ? DIRECTION_NEXT : DIRECTION_PREV;
229
-
230
- this._slide(direction, this._items[index]);
231
- };
232
-
233
- _proto.dispose = function dispose() {
234
- $__default['default'](this._element).off(EVENT_KEY);
235
- $__default['default'].removeData(this._element, DATA_KEY);
236
- this._items = null;
237
- this._config = null;
238
- this._element = null;
239
- this._interval = null;
240
- this._isPaused = null;
241
- this._isSliding = null;
242
- this._activeElement = null;
243
- this._indicatorsElement = null;
244
- } // Private
245
- ;
246
-
247
- _proto._getConfig = function _getConfig(config) {
248
- config = _extends({}, Default, config);
249
- Util__default['default'].typeCheckConfig(NAME, config, DefaultType);
250
- return config;
251
- };
252
-
253
- _proto._handleSwipe = function _handleSwipe() {
254
- var absDeltax = Math.abs(this.touchDeltaX);
255
-
256
- if (absDeltax <= SWIPE_THRESHOLD) {
257
157
  return;
258
158
  }
259
-
260
- var direction = absDeltax / this.touchDeltaX;
261
- this.touchDeltaX = 0; // swipe left
262
-
263
- if (direction > 0) {
264
- this.prev();
265
- } // swipe right
266
-
267
-
268
- if (direction < 0) {
269
- this.next();
159
+ const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV;
160
+ this._slide(order, items[index]);
161
+ }
162
+ dispose() {
163
+ if (this._swipeHelper) {
164
+ this._swipeHelper.dispose();
270
165
  }
271
- };
272
-
273
- _proto._addEventListeners = function _addEventListeners() {
274
- var _this2 = this;
166
+ super.dispose();
167
+ }
275
168
 
169
+ // Private
170
+ _configAfterMerge(config) {
171
+ config.defaultInterval = config.interval;
172
+ return config;
173
+ }
174
+ _addEventListeners() {
276
175
  if (this._config.keyboard) {
277
- $__default['default'](this._element).on(EVENT_KEYDOWN, function (event) {
278
- return _this2._keydown(event);
279
- });
176
+ EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event));
280
177
  }
281
-
282
178
  if (this._config.pause === 'hover') {
283
- $__default['default'](this._element).on(EVENT_MOUSEENTER, function (event) {
284
- return _this2.pause(event);
285
- }).on(EVENT_MOUSELEAVE, function (event) {
286
- return _this2.cycle(event);
287
- });
179
+ EventHandler.on(this._element, EVENT_MOUSEENTER, () => this.pause());
180
+ EventHandler.on(this._element, EVENT_MOUSELEAVE, () => this._maybeEnableCycle());
288
181
  }
289
-
290
- if (this._config.touch) {
182
+ if (this._config.touch && Swipe.isSupported()) {
291
183
  this._addTouchEventListeners();
292
184
  }
293
- };
294
-
295
- _proto._addTouchEventListeners = function _addTouchEventListeners() {
296
- var _this3 = this;
297
-
298
- if (!this._touchSupported) {
299
- return;
185
+ }
186
+ _addTouchEventListeners() {
187
+ for (const img of SelectorEngine.find(SELECTOR_ITEM_IMG, this._element)) {
188
+ EventHandler.on(img, EVENT_DRAG_START, event => event.preventDefault());
300
189
  }
301
-
302
- var start = function start(event) {
303
- if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
304
- _this3.touchStartX = event.originalEvent.clientX;
305
- } else if (!_this3._pointerEvent) {
306
- _this3.touchStartX = event.originalEvent.touches[0].clientX;
307
- }
308
- };
309
-
310
- var move = function move(event) {
311
- // ensure swiping with one touch and not pinching
312
- if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
313
- _this3.touchDeltaX = 0;
314
- } else {
315
- _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
190
+ const endCallBack = () => {
191
+ if (this._config.pause !== 'hover') {
192
+ return;
316
193
  }
317
- };
318
-
319
- var end = function end(event) {
320
- if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
321
- _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
322
- }
323
-
324
- _this3._handleSwipe();
325
194
 
326
- if (_this3._config.pause === 'hover') {
327
- // If it's a touch-enabled device, mouseenter/leave are fired as
328
- // part of the mouse compatibility events on first tap - the carousel
329
- // would stop cycling until user tapped out of it;
330
- // here, we listen for touchend, explicitly pause the carousel
331
- // (as if it's the second time we tap on it, mouseenter compat event
332
- // is NOT fired) and after a timeout (to allow for mouse compatibility
333
- // events to fire) we explicitly restart cycling
334
- _this3.pause();
195
+ // If it's a touch-enabled device, mouseenter/leave are fired as
196
+ // part of the mouse compatibility events on first tap - the carousel
197
+ // would stop cycling until user tapped out of it;
198
+ // here, we listen for touchend, explicitly pause the carousel
199
+ // (as if it's the second time we tap on it, mouseenter compat event
200
+ // is NOT fired) and after a timeout (to allow for mouse compatibility
201
+ // events to fire) we explicitly restart cycling
335
202
 
336
- if (_this3.touchTimeout) {
337
- clearTimeout(_this3.touchTimeout);
338
- }
339
-
340
- _this3.touchTimeout = setTimeout(function (event) {
341
- return _this3.cycle(event);
342
- }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
203
+ this.pause();
204
+ if (this.touchTimeout) {
205
+ clearTimeout(this.touchTimeout);
343
206
  }
207
+ this.touchTimeout = setTimeout(() => this._maybeEnableCycle(), TOUCHEVENT_COMPAT_WAIT + this._config.interval);
344
208
  };
345
-
346
- $__default['default'](this._element.querySelectorAll(SELECTOR_ITEM_IMG)).on(EVENT_DRAG_START, function (e) {
347
- return e.preventDefault();
348
- });
349
-
350
- if (this._pointerEvent) {
351
- $__default['default'](this._element).on(EVENT_POINTERDOWN, function (event) {
352
- return start(event);
353
- });
354
- $__default['default'](this._element).on(EVENT_POINTERUP, function (event) {
355
- return end(event);
356
- });
357
-
358
- this._element.classList.add(CLASS_NAME_POINTER_EVENT);
359
- } else {
360
- $__default['default'](this._element).on(EVENT_TOUCHSTART, function (event) {
361
- return start(event);
362
- });
363
- $__default['default'](this._element).on(EVENT_TOUCHMOVE, function (event) {
364
- return move(event);
365
- });
366
- $__default['default'](this._element).on(EVENT_TOUCHEND, function (event) {
367
- return end(event);
368
- });
369
- }
370
- };
371
-
372
- _proto._keydown = function _keydown(event) {
209
+ const swipeConfig = {
210
+ leftCallback: () => this._slide(this._directionToOrder(DIRECTION_LEFT)),
211
+ rightCallback: () => this._slide(this._directionToOrder(DIRECTION_RIGHT)),
212
+ endCallback: endCallBack
213
+ };
214
+ this._swipeHelper = new Swipe(this._element, swipeConfig);
215
+ }
216
+ _keydown(event) {
373
217
  if (/input|textarea/i.test(event.target.tagName)) {
374
218
  return;
375
219
  }
376
-
377
- switch (event.which) {
378
- case ARROW_LEFT_KEYCODE:
379
- event.preventDefault();
380
- this.prev();
381
- break;
382
-
383
- case ARROW_RIGHT_KEYCODE:
384
- event.preventDefault();
385
- this.next();
386
- break;
220
+ const direction = KEY_TO_DIRECTION[event.key];
221
+ if (direction) {
222
+ event.preventDefault();
223
+ this._slide(this._directionToOrder(direction));
387
224
  }
388
- };
389
-
390
- _proto._getItemIndex = function _getItemIndex(element) {
391
- this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(SELECTOR_ITEM)) : [];
392
- return this._items.indexOf(element);
393
- };
394
-
395
- _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
396
- var isNextDirection = direction === DIRECTION_NEXT;
397
- var isPrevDirection = direction === DIRECTION_PREV;
398
-
399
- var activeIndex = this._getItemIndex(activeElement);
400
-
401
- var lastItemIndex = this._items.length - 1;
402
- var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
403
-
404
- if (isGoingToWrap && !this._config.wrap) {
405
- return activeElement;
225
+ }
226
+ _getItemIndex(element) {
227
+ return this._getItems().indexOf(element);
228
+ }
229
+ _setActiveIndicatorElement(index) {
230
+ if (!this._indicatorsElement) {
231
+ return;
406
232
  }
407
-
408
- var delta = direction === DIRECTION_PREV ? -1 : 1;
409
- var itemIndex = (activeIndex + delta) % this._items.length;
410
- return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
411
- };
412
-
413
- _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
414
- var targetIndex = this._getItemIndex(relatedTarget);
415
-
416
- var fromIndex = this._getItemIndex(this._element.querySelector(SELECTOR_ACTIVE_ITEM));
417
-
418
- var slideEvent = $__default['default'].Event(EVENT_SLIDE, {
419
- relatedTarget: relatedTarget,
420
- direction: eventDirectionName,
421
- from: fromIndex,
422
- to: targetIndex
423
- });
424
- $__default['default'](this._element).trigger(slideEvent);
425
- return slideEvent;
426
- };
427
-
428
- _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
429
- if (this._indicatorsElement) {
430
- var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(SELECTOR_ACTIVE));
431
- $__default['default'](indicators).removeClass(CLASS_NAME_ACTIVE);
432
-
433
- var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
434
-
435
- if (nextIndicator) {
436
- $__default['default'](nextIndicator).addClass(CLASS_NAME_ACTIVE);
437
- }
233
+ const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE, this._indicatorsElement);
234
+ activeIndicator.classList.remove(CLASS_NAME_ACTIVE);
235
+ activeIndicator.removeAttribute('aria-current');
236
+ const newActiveIndicator = SelectorEngine.findOne(`[data-bs-slide-to="${index}"]`, this._indicatorsElement);
237
+ if (newActiveIndicator) {
238
+ newActiveIndicator.classList.add(CLASS_NAME_ACTIVE);
239
+ newActiveIndicator.setAttribute('aria-current', 'true');
438
240
  }
439
- };
440
-
441
- _proto._updateInterval = function _updateInterval() {
442
- var element = this._activeElement || this._element.querySelector(SELECTOR_ACTIVE_ITEM);
443
-
241
+ }
242
+ _updateInterval() {
243
+ const element = this._activeElement || this._getActive();
444
244
  if (!element) {
445
245
  return;
446
246
  }
447
-
448
- var elementInterval = parseInt(element.getAttribute('data-interval'), 10);
449
-
450
- if (elementInterval) {
451
- this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
452
- this._config.interval = elementInterval;
453
- } else {
454
- this._config.interval = this._config.defaultInterval || this._config.interval;
455
- }
456
- };
457
-
458
- _proto._slide = function _slide(direction, element) {
459
- var _this4 = this;
460
-
461
- var activeElement = this._element.querySelector(SELECTOR_ACTIVE_ITEM);
462
-
463
- var activeElementIndex = this._getItemIndex(activeElement);
464
-
465
- var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
466
-
467
- var nextElementIndex = this._getItemIndex(nextElement);
468
-
469
- var isCycling = Boolean(this._interval);
470
- var directionalClassName;
471
- var orderClassName;
472
- var eventDirectionName;
473
-
474
- if (direction === DIRECTION_NEXT) {
475
- directionalClassName = CLASS_NAME_LEFT;
476
- orderClassName = CLASS_NAME_NEXT;
477
- eventDirectionName = DIRECTION_LEFT;
478
- } else {
479
- directionalClassName = CLASS_NAME_RIGHT;
480
- orderClassName = CLASS_NAME_PREV;
481
- eventDirectionName = DIRECTION_RIGHT;
247
+ const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10);
248
+ this._config.interval = elementInterval || this._config.defaultInterval;
249
+ }
250
+ _slide(order, element = null) {
251
+ if (this._isSliding) {
252
+ return;
482
253
  }
483
-
484
- if (nextElement && $__default['default'](nextElement).hasClass(CLASS_NAME_ACTIVE)) {
485
- this._isSliding = false;
254
+ const activeElement = this._getActive();
255
+ const isNext = order === ORDER_NEXT;
256
+ const nextElement = element || index_js.getNextActiveElement(this._getItems(), activeElement, isNext, this._config.wrap);
257
+ if (nextElement === activeElement) {
486
258
  return;
487
259
  }
488
-
489
- var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
490
-
491
- if (slideEvent.isDefaultPrevented()) {
260
+ const nextElementIndex = this._getItemIndex(nextElement);
261
+ const triggerEvent = eventName => {
262
+ return EventHandler.trigger(this._element, eventName, {
263
+ relatedTarget: nextElement,
264
+ direction: this._orderToDirection(order),
265
+ from: this._getItemIndex(activeElement),
266
+ to: nextElementIndex
267
+ });
268
+ };
269
+ const slideEvent = triggerEvent(EVENT_SLIDE);
270
+ if (slideEvent.defaultPrevented) {
492
271
  return;
493
272
  }
494
-
495
273
  if (!activeElement || !nextElement) {
496
274
  // Some weirdness is happening, so we bail
275
+ // TODO: change tests that use empty divs to avoid this check
497
276
  return;
498
277
  }
499
-
278
+ const isCycling = Boolean(this._interval);
279
+ this.pause();
500
280
  this._isSliding = true;
501
-
502
- if (isCycling) {
503
- this.pause();
504
- }
505
-
506
- this._setActiveIndicatorElement(nextElement);
507
-
281
+ this._setActiveIndicatorElement(nextElementIndex);
508
282
  this._activeElement = nextElement;
509
- var slidEvent = $__default['default'].Event(EVENT_SLID, {
510
- relatedTarget: nextElement,
511
- direction: eventDirectionName,
512
- from: activeElementIndex,
513
- to: nextElementIndex
514
- });
515
-
516
- if ($__default['default'](this._element).hasClass(CLASS_NAME_SLIDE)) {
517
- $__default['default'](nextElement).addClass(orderClassName);
518
- Util__default['default'].reflow(nextElement);
519
- $__default['default'](activeElement).addClass(directionalClassName);
520
- $__default['default'](nextElement).addClass(directionalClassName);
521
- var transitionDuration = Util__default['default'].getTransitionDurationFromElement(activeElement);
522
- $__default['default'](activeElement).one(Util__default['default'].TRANSITION_END, function () {
523
- $__default['default'](nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(CLASS_NAME_ACTIVE);
524
- $__default['default'](activeElement).removeClass(CLASS_NAME_ACTIVE + " " + orderClassName + " " + directionalClassName);
525
- _this4._isSliding = false;
526
- setTimeout(function () {
527
- return $__default['default'](_this4._element).trigger(slidEvent);
528
- }, 0);
529
- }).emulateTransitionEnd(transitionDuration);
530
- } else {
531
- $__default['default'](activeElement).removeClass(CLASS_NAME_ACTIVE);
532
- $__default['default'](nextElement).addClass(CLASS_NAME_ACTIVE);
283
+ const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END;
284
+ const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
285
+ nextElement.classList.add(orderClassName);
286
+ index_js.reflow(nextElement);
287
+ activeElement.classList.add(directionalClassName);
288
+ nextElement.classList.add(directionalClassName);
289
+ const completeCallBack = () => {
290
+ nextElement.classList.remove(directionalClassName, orderClassName);
291
+ nextElement.classList.add(CLASS_NAME_ACTIVE);
292
+ activeElement.classList.remove(CLASS_NAME_ACTIVE, orderClassName, directionalClassName);
533
293
  this._isSliding = false;
534
- $__default['default'](this._element).trigger(slidEvent);
535
- }
536
-
294
+ triggerEvent(EVENT_SLID);
295
+ };
296
+ this._queueCallback(completeCallBack, activeElement, this._isAnimated());
537
297
  if (isCycling) {
538
298
  this.cycle();
539
299
  }
540
- } // Static
541
- ;
300
+ }
301
+ _isAnimated() {
302
+ return this._element.classList.contains(CLASS_NAME_SLIDE);
303
+ }
304
+ _getActive() {
305
+ return SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
306
+ }
307
+ _getItems() {
308
+ return SelectorEngine.find(SELECTOR_ITEM, this._element);
309
+ }
310
+ _clearInterval() {
311
+ if (this._interval) {
312
+ clearInterval(this._interval);
313
+ this._interval = null;
314
+ }
315
+ }
316
+ _directionToOrder(direction) {
317
+ if (index_js.isRTL()) {
318
+ return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT;
319
+ }
320
+ return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV;
321
+ }
322
+ _orderToDirection(order) {
323
+ if (index_js.isRTL()) {
324
+ return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT;
325
+ }
326
+ return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT;
327
+ }
542
328
 
543
- Carousel._jQueryInterface = function _jQueryInterface(config) {
329
+ // Static
330
+ static jQueryInterface(config) {
544
331
  return this.each(function () {
545
- var data = $__default['default'](this).data(DATA_KEY);
546
-
547
- var _config = _extends({}, Default, $__default['default'](this).data());
548
-
549
- if (typeof config === 'object') {
550
- _config = _extends({}, _config, config);
551
- }
552
-
553
- var action = typeof config === 'string' ? config : _config.slide;
554
-
555
- if (!data) {
556
- data = new Carousel(this, _config);
557
- $__default['default'](this).data(DATA_KEY, data);
558
- }
559
-
332
+ const data = Carousel.getOrCreateInstance(this, config);
560
333
  if (typeof config === 'number') {
561
334
  data.to(config);
562
- } else if (typeof action === 'string') {
563
- if (typeof data[action] === 'undefined') {
564
- throw new TypeError("No method named \"" + action + "\"");
335
+ return;
336
+ }
337
+ if (typeof config === 'string') {
338
+ if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
339
+ throw new TypeError(`No method named "${config}"`);
565
340
  }
566
-
567
- data[action]();
568
- } else if (_config.interval && _config.ride) {
569
- data.pause();
570
- data.cycle();
341
+ data[config]();
571
342
  }
572
343
  });
573
- };
574
-
575
- Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
576
- var selector = Util__default['default'].getSelectorFromElement(this);
577
-
578
- if (!selector) {
579
- return;
580
- }
581
-
582
- var target = $__default['default'](selector)[0];
583
-
584
- if (!target || !$__default['default'](target).hasClass(CLASS_NAME_CAROUSEL)) {
585
- return;
586
- }
587
-
588
- var config = _extends({}, $__default['default'](target).data(), $__default['default'](this).data());
589
-
590
- var slideIndex = this.getAttribute('data-slide-to');
591
-
592
- if (slideIndex) {
593
- config.interval = false;
594
- }
595
-
596
- Carousel._jQueryInterface.call($__default['default'](target), config);
597
-
598
- if (slideIndex) {
599
- $__default['default'](target).data(DATA_KEY).to(slideIndex);
600
- }
601
-
602
- event.preventDefault();
603
- };
604
-
605
- _createClass(Carousel, null, [{
606
- key: "VERSION",
607
- get: function get() {
608
- return VERSION;
609
- }
610
- }, {
611
- key: "Default",
612
- get: function get() {
613
- return Default;
614
- }
615
- }]);
344
+ }
345
+ }
616
346
 
617
- return Carousel;
618
- }();
619
347
  /**
620
- * ------------------------------------------------------------------------
621
- * Data Api implementation
622
- * ------------------------------------------------------------------------
348
+ * Data API implementation
623
349
  */
624
350
 
625
-
626
- $__default['default'](document).on(EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, Carousel._dataApiClickHandler);
627
- $__default['default'](window).on(EVENT_LOAD_DATA_API, function () {
628
- var carousels = [].slice.call(document.querySelectorAll(SELECTOR_DATA_RIDE));
629
-
630
- for (var i = 0, len = carousels.length; i < len; i++) {
631
- var $carousel = $__default['default'](carousels[i]);
632
-
633
- Carousel._jQueryInterface.call($carousel, $carousel.data());
351
+ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, function (event) {
352
+ const target = SelectorEngine.getElementFromSelector(this);
353
+ if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
354
+ return;
355
+ }
356
+ event.preventDefault();
357
+ const carousel = Carousel.getOrCreateInstance(target);
358
+ const slideIndex = this.getAttribute('data-bs-slide-to');
359
+ if (slideIndex) {
360
+ carousel.to(slideIndex);
361
+ carousel._maybeEnableCycle();
362
+ return;
363
+ }
364
+ if (Manipulator.getDataAttribute(this, 'slide') === 'next') {
365
+ carousel.next();
366
+ carousel._maybeEnableCycle();
367
+ return;
368
+ }
369
+ carousel.prev();
370
+ carousel._maybeEnableCycle();
371
+ });
372
+ EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
373
+ const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE);
374
+ for (const carousel of carousels) {
375
+ Carousel.getOrCreateInstance(carousel);
634
376
  }
635
377
  });
378
+
636
379
  /**
637
- * ------------------------------------------------------------------------
638
380
  * jQuery
639
- * ------------------------------------------------------------------------
640
381
  */
641
382
 
642
- $__default['default'].fn[NAME] = Carousel._jQueryInterface;
643
- $__default['default'].fn[NAME].Constructor = Carousel;
644
-
645
- $__default['default'].fn[NAME].noConflict = function () {
646
- $__default['default'].fn[NAME] = JQUERY_NO_CONFLICT;
647
- return Carousel._jQueryInterface;
648
- };
383
+ index_js.defineJQueryPlugin(Carousel);
649
384
 
650
385
  return Carousel;
651
386
 
652
- })));
387
+ }));