@coreui/coreui 4.1.6 → 4.2.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 (203) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +62 -10
  3. package/dist/css/coreui-grid.css +22 -4
  4. package/dist/css/coreui-grid.css.map +1 -1
  5. package/dist/css/coreui-grid.min.css +2 -2
  6. package/dist/css/coreui-grid.min.css.map +1 -1
  7. package/dist/css/coreui-grid.rtl.css +23 -5
  8. package/dist/css/coreui-grid.rtl.css.map +1 -1
  9. package/dist/css/coreui-grid.rtl.min.css +3 -3
  10. package/dist/css/coreui-grid.rtl.min.css.map +1 -1
  11. package/dist/css/coreui-reboot.css +34 -41
  12. package/dist/css/coreui-reboot.css.map +1 -1
  13. package/dist/css/coreui-reboot.min.css +2 -2
  14. package/dist/css/coreui-reboot.min.css.map +1 -1
  15. package/dist/css/coreui-reboot.rtl.css +34 -42
  16. package/dist/css/coreui-reboot.rtl.css.map +1 -1
  17. package/dist/css/coreui-reboot.rtl.min.css +3 -3
  18. package/dist/css/coreui-reboot.rtl.min.css.map +1 -1
  19. package/dist/css/coreui-utilities.css +278 -163
  20. package/dist/css/coreui-utilities.css.map +1 -1
  21. package/dist/css/coreui-utilities.min.css +2 -2
  22. package/dist/css/coreui-utilities.min.css.map +1 -1
  23. package/dist/css/coreui-utilities.rtl.css +273 -164
  24. package/dist/css/coreui-utilities.rtl.css.map +1 -1
  25. package/dist/css/coreui-utilities.rtl.min.css +3 -3
  26. package/dist/css/coreui-utilities.rtl.min.css.map +1 -1
  27. package/dist/css/coreui.css +2177 -1240
  28. package/dist/css/coreui.css.map +1 -1
  29. package/dist/css/coreui.min.css +2 -2
  30. package/dist/css/coreui.min.css.map +1 -1
  31. package/dist/css/coreui.rtl.css +2159 -1228
  32. package/dist/css/coreui.rtl.css.map +1 -1
  33. package/dist/css/coreui.rtl.min.css +3 -3
  34. package/dist/css/coreui.rtl.min.css.map +1 -1
  35. package/dist/js/coreui.bundle.js +2095 -1906
  36. package/dist/js/coreui.bundle.js.map +1 -1
  37. package/dist/js/coreui.bundle.min.js +2 -2
  38. package/dist/js/coreui.bundle.min.js.map +1 -1
  39. package/dist/js/coreui.esm.js +2098 -1909
  40. package/dist/js/coreui.esm.js.map +1 -1
  41. package/dist/js/coreui.esm.min.js +2 -2
  42. package/dist/js/coreui.esm.min.js.map +1 -1
  43. package/dist/js/coreui.js +2099 -1910
  44. package/dist/js/coreui.js.map +1 -1
  45. package/dist/js/coreui.min.js +2 -2
  46. package/dist/js/coreui.min.js.map +1 -1
  47. package/js/dist/alert.js +10 -148
  48. package/js/dist/alert.js.map +1 -1
  49. package/js/dist/base-component.js +36 -122
  50. package/js/dist/base-component.js.map +1 -1
  51. package/js/dist/button.js +9 -76
  52. package/js/dist/button.js.map +1 -1
  53. package/js/dist/carousel.js +212 -507
  54. package/js/dist/carousel.js.map +1 -1
  55. package/js/dist/collapse.js +64 -251
  56. package/js/dist/collapse.js.map +1 -1
  57. package/js/dist/dom/data.js +2 -4
  58. package/js/dist/dom/data.js.map +1 -1
  59. package/js/dist/dom/event-handler.js +82 -133
  60. package/js/dist/dom/event-handler.js.map +1 -1
  61. package/js/dist/dom/manipulator.js +22 -26
  62. package/js/dist/dom/manipulator.js.map +1 -1
  63. package/js/dist/dom/selector-engine.js +16 -81
  64. package/js/dist/dom/selector-engine.js.map +1 -1
  65. package/js/dist/dropdown.js +99 -338
  66. package/js/dist/dropdown.js.map +1 -1
  67. package/js/dist/modal.js +106 -774
  68. package/js/dist/modal.js.map +1 -1
  69. package/js/dist/navigation.js +309 -0
  70. package/js/dist/navigation.js.map +1 -0
  71. package/js/dist/offcanvas.js +88 -680
  72. package/js/dist/offcanvas.js.map +1 -1
  73. package/js/dist/popover.js +35 -120
  74. package/js/dist/popover.js.map +1 -1
  75. package/js/dist/scrollspy.js +178 -264
  76. package/js/dist/scrollspy.js.map +1 -1
  77. package/js/dist/sidebar.js +347 -0
  78. package/js/dist/sidebar.js.map +1 -0
  79. package/js/dist/tab.js +226 -216
  80. package/js/dist/tab.js.map +1 -1
  81. package/js/dist/toast.js +27 -216
  82. package/js/dist/toast.js.map +1 -1
  83. package/js/dist/tooltip.js +271 -618
  84. package/js/dist/tooltip.js.map +1 -1
  85. package/js/dist/util/backdrop.js +166 -0
  86. package/js/dist/util/backdrop.js.map +1 -0
  87. package/js/dist/util/component-functions.js +47 -0
  88. package/js/dist/util/component-functions.js.map +1 -0
  89. package/js/dist/util/config.js +80 -0
  90. package/js/dist/util/config.js.map +1 -0
  91. package/js/dist/util/focustrap.js +130 -0
  92. package/js/dist/util/focustrap.js.map +1 -0
  93. package/js/dist/util/index.js +354 -0
  94. package/js/dist/util/index.js.map +1 -0
  95. package/js/dist/util/sanitizer.js +126 -0
  96. package/js/dist/util/sanitizer.js.map +1 -0
  97. package/js/dist/util/scrollbar.js +139 -0
  98. package/js/dist/util/scrollbar.js.map +1 -0
  99. package/js/dist/util/swipe.js +156 -0
  100. package/js/dist/util/swipe.js.map +1 -0
  101. package/js/dist/util/template-factory.js +178 -0
  102. package/js/dist/util/template-factory.js.map +1 -0
  103. package/js/src/alert.js +3 -15
  104. package/js/src/base-component.js +28 -18
  105. package/js/src/button.js +3 -15
  106. package/js/src/carousel.js +203 -320
  107. package/js/src/collapse.js +61 -94
  108. package/js/src/dom/data.js +1 -3
  109. package/js/src/dom/event-handler.js +74 -107
  110. package/js/src/dom/manipulator.js +22 -31
  111. package/js/src/dom/selector-engine.js +10 -19
  112. package/js/src/dropdown.js +84 -138
  113. package/js/src/modal.js +94 -158
  114. package/js/src/navigation.js +12 -13
  115. package/js/src/offcanvas.js +71 -60
  116. package/js/src/popover.js +31 -62
  117. package/js/src/scrollspy.js +166 -171
  118. package/js/src/sidebar.js +5 -8
  119. package/js/src/tab.js +201 -110
  120. package/js/src/toast.js +19 -41
  121. package/js/src/tooltip.js +264 -374
  122. package/js/src/util/backdrop.js +55 -36
  123. package/js/src/util/component-functions.js +1 -1
  124. package/js/src/util/config.js +66 -0
  125. package/js/src/util/focustrap.js +38 -28
  126. package/js/src/util/index.js +41 -57
  127. package/js/src/util/sanitizer.js +9 -17
  128. package/js/src/util/scrollbar.js +47 -30
  129. package/js/src/util/swipe.js +146 -0
  130. package/js/src/util/template-factory.js +160 -0
  131. package/package.json +37 -37
  132. package/scss/_accordion.scss +53 -25
  133. package/scss/_alert.scss +29 -9
  134. package/scss/_badge.scss +15 -6
  135. package/scss/_breadcrumb.scss +23 -11
  136. package/scss/_button-group.scss +3 -0
  137. package/scss/_buttons.scss +77 -50
  138. package/scss/_callout.scss +18 -6
  139. package/scss/_card.scss +55 -37
  140. package/scss/_carousel.scss +6 -6
  141. package/scss/_close.scss +4 -4
  142. package/scss/_containers.scss +1 -1
  143. package/scss/_dropdown.scss +86 -64
  144. package/scss/_footer.scss +15 -5
  145. package/scss/_functions.scss +11 -24
  146. package/scss/_grid.scss +3 -3
  147. package/scss/_header.scss +59 -34
  148. package/scss/_helpers.scss +1 -0
  149. package/scss/_images.scss +3 -3
  150. package/scss/_list-group.scss +47 -29
  151. package/scss/_maps.scss +54 -0
  152. package/scss/_modal.scss +70 -43
  153. package/scss/_nav.scss +53 -20
  154. package/scss/_navbar.scss +84 -94
  155. package/scss/_offcanvas.scss +120 -60
  156. package/scss/_pagination.scss +66 -21
  157. package/scss/_popover.scss +90 -52
  158. package/scss/_progress.scss +20 -9
  159. package/scss/_reboot.scss +31 -58
  160. package/scss/_root.scss +41 -19
  161. package/scss/_spinners.scss +37 -21
  162. package/scss/_subheader.scss +9 -9
  163. package/scss/_tables.scss +34 -36
  164. package/scss/_toasts.scss +35 -19
  165. package/scss/_tooltip.scss +61 -56
  166. package/scss/_utilities.scss +42 -25
  167. package/scss/_variables.scss +169 -148
  168. package/scss/coreui-grid.rtl.scss +1 -1
  169. package/scss/coreui-grid.scss +2 -1
  170. package/scss/coreui-reboot.rtl.scss +1 -1
  171. package/scss/coreui-reboot.scss +1 -1
  172. package/scss/coreui-utilities.rtl.scss +1 -1
  173. package/scss/coreui-utilities.scss +2 -1
  174. package/scss/coreui.rtl.scss +1 -1
  175. package/scss/coreui.scss +2 -1
  176. package/scss/forms/_floating-labels.scss +14 -3
  177. package/scss/forms/_form-check.scss +41 -18
  178. package/scss/forms/_form-control.scss +25 -50
  179. package/scss/forms/_form-range.scss +8 -8
  180. package/scss/forms/_form-select.scss +8 -8
  181. package/scss/forms/_form-text.scss +1 -1
  182. package/scss/forms/_input-group.scss +3 -3
  183. package/scss/forms/_labels.scss +2 -2
  184. package/scss/helpers/_color-bg.scss +10 -0
  185. package/scss/helpers/_colored-links.scss +2 -2
  186. package/scss/helpers/_position.scss +7 -1
  187. package/scss/helpers/_ratio.scss +2 -2
  188. package/scss/helpers/_vr.scss +1 -0
  189. package/scss/mixins/_alert.scss +10 -10
  190. package/scss/mixins/_breakpoints.scss +8 -8
  191. package/scss/mixins/_buttons.scss +45 -47
  192. package/scss/mixins/_container.scss +4 -2
  193. package/scss/mixins/_css-vars.scss +47 -47
  194. package/scss/mixins/_forms.scss +8 -0
  195. package/scss/mixins/_gradients.scss +1 -1
  196. package/scss/mixins/_grid.scss +11 -11
  197. package/scss/mixins/_list-group.scss +7 -9
  198. package/scss/mixins/_pagination.scss +4 -25
  199. package/scss/mixins/_table-variants.scss +20 -12
  200. package/scss/mixins/_utilities.scss +8 -3
  201. package/scss/sidebar/_sidebar-narrow.scss +10 -10
  202. package/scss/sidebar/_sidebar-nav.scss +37 -32
  203. package/scss/sidebar/_sidebar.scss +110 -56
@@ -1,219 +1,25 @@
1
1
  /*!
2
- * CoreUI carousel.js v4.1.6 (https://coreui.io)
2
+ * CoreUI carousel.js v4.2.2 (https://coreui.io)
3
3
  * Copyright 2022 The CoreUI Team (https://github.com/orgs/coreui/people)
4
4
  * Licensed under MIT (https://coreui.io)
5
5
  */
6
6
  (function (global, factory) {
7
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js'), require('./base-component.js')) :
8
- typeof define === 'function' && define.amd ? define(['./dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) :
9
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Carousel = factory(global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base));
10
- })(this, (function (EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict';
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./util/index'), require('./dom/event-handler'), require('./dom/manipulator'), require('./dom/selector-engine'), require('./util/swipe'), require('./base-component')) :
8
+ typeof define === 'function' && define.amd ? define(['./util/index', './dom/event-handler', './dom/manipulator', './dom/selector-engine', './util/swipe', './base-component'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Carousel = factory(global.Index, global.EventHandler, global.Manipulator, global.SelectorEngine, global.Swipe, global.BaseComponent));
10
+ })(this, (function (index, EventHandler, Manipulator, SelectorEngine, Swipe, BaseComponent) { 'use strict';
11
11
 
12
12
  const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
13
13
 
14
14
  const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
15
15
  const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
16
16
  const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
17
+ const Swipe__default = /*#__PURE__*/_interopDefaultLegacy(Swipe);
17
18
  const BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
18
19
 
19
20
  /**
20
21
  * --------------------------------------------------------------------------
21
- * CoreUI (v4.1.6): alert.js
22
- * Licensed under MIT (https://coreui.io/license)
23
- *
24
- * This component is a modified version of the Bootstrap's util/index.js
25
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
26
- * --------------------------------------------------------------------------
27
- */
28
- const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
29
-
30
- const toType = object => {
31
- if (object === null || object === undefined) {
32
- return `${object}`;
33
- }
34
-
35
- return Object.prototype.toString.call(object).match(/\s([a-z]+)/i)[1].toLowerCase();
36
- };
37
-
38
- const getSelector = element => {
39
- let selector = element.getAttribute('data-coreui-target');
40
-
41
- if (!selector || selector === '#') {
42
- let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes,
43
- // so everything starting with `#` or `.`. If a "real" URL is used as the selector,
44
- // `document.querySelector` will rightfully complain it is invalid.
45
- // See https://github.com/twbs/bootstrap/issues/32273
46
-
47
- if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) {
48
- return null;
49
- } // Just in case some CMS puts out a full URL with the anchor appended
50
-
51
-
52
- if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) {
53
- hrefAttr = `#${hrefAttr.split('#')[1]}`;
54
- }
55
-
56
- selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
57
- }
58
-
59
- return selector;
60
- };
61
-
62
- const getElementFromSelector = element => {
63
- const selector = getSelector(element);
64
- return selector ? document.querySelector(selector) : null;
65
- };
66
-
67
- const triggerTransitionEnd = element => {
68
- element.dispatchEvent(new Event(TRANSITION_END));
69
- };
70
-
71
- const isElement = obj => {
72
- if (!obj || typeof obj !== 'object') {
73
- return false;
74
- }
75
-
76
- if (typeof obj.jquery !== 'undefined') {
77
- obj = obj[0];
78
- }
79
-
80
- return typeof obj.nodeType !== 'undefined';
81
- };
82
-
83
- const typeCheckConfig = (componentName, config, configTypes) => {
84
- Object.keys(configTypes).forEach(property => {
85
- const expectedTypes = configTypes[property];
86
- const value = config[property];
87
- const valueType = value && isElement(value) ? 'element' : toType(value);
88
-
89
- if (!new RegExp(expectedTypes).test(valueType)) {
90
- throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
91
- }
92
- });
93
- };
94
-
95
- const isVisible = element => {
96
- if (!isElement(element) || element.getClientRects().length === 0) {
97
- return false;
98
- }
99
-
100
- const elementIsVisible = getComputedStyle(element).getPropertyValue('visibility') === 'visible'; // Handle `details` element as its content may falsie appear visible when it is closed
101
-
102
- const closedDetails = element.closest('details:not([open])');
103
-
104
- if (!closedDetails) {
105
- return elementIsVisible;
106
- }
107
-
108
- if (closedDetails !== element) {
109
- const summary = element.closest('summary');
110
-
111
- if (summary && summary.parentNode !== closedDetails) {
112
- return false;
113
- }
114
-
115
- if (summary === null) {
116
- return false;
117
- }
118
- }
119
-
120
- return elementIsVisible;
121
- };
122
- /**
123
- * Trick to restart an element's animation
124
- *
125
- * @param {HTMLElement} element
126
- * @return void
127
- *
128
- * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
129
- */
130
-
131
-
132
- const reflow = element => {
133
- // eslint-disable-next-line no-unused-expressions
134
- element.offsetHeight;
135
- };
136
-
137
- const getjQuery = () => {
138
- const {
139
- jQuery
140
- } = window;
141
-
142
- if (jQuery && !document.body.hasAttribute('data-coreui-no-jquery')) {
143
- return jQuery;
144
- }
145
-
146
- return null;
147
- };
148
-
149
- const DOMContentLoadedCallbacks = [];
150
-
151
- const onDOMContentLoaded = callback => {
152
- if (document.readyState === 'loading') {
153
- // add listener on the first call when the document is in loading state
154
- if (!DOMContentLoadedCallbacks.length) {
155
- document.addEventListener('DOMContentLoaded', () => {
156
- DOMContentLoadedCallbacks.forEach(callback => callback());
157
- });
158
- }
159
-
160
- DOMContentLoadedCallbacks.push(callback);
161
- } else {
162
- callback();
163
- }
164
- };
165
-
166
- const isRTL = () => document.documentElement.dir === 'rtl';
167
-
168
- const defineJQueryPlugin = plugin => {
169
- onDOMContentLoaded(() => {
170
- const $ = getjQuery();
171
- /* istanbul ignore if */
172
-
173
- if ($) {
174
- const name = plugin.NAME;
175
- const JQUERY_NO_CONFLICT = $.fn[name];
176
- $.fn[name] = plugin.jQueryInterface;
177
- $.fn[name].Constructor = plugin;
178
-
179
- $.fn[name].noConflict = () => {
180
- $.fn[name] = JQUERY_NO_CONFLICT;
181
- return plugin.jQueryInterface;
182
- };
183
- }
184
- });
185
- };
186
- /**
187
- * Return the previous/next element of a list.
188
- *
189
- * @param {array} list The list of elements
190
- * @param activeElement The active element
191
- * @param shouldGetNext Choose to get next or previous element
192
- * @param isCycleAllowed
193
- * @return {Element|elem} The proper element
194
- */
195
-
196
-
197
- const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
198
- let index = list.indexOf(activeElement); // if the element does not exist in the list return an element depending on the direction and if cycle is allowed
199
-
200
- if (index === -1) {
201
- return list[!shouldGetNext && isCycleAllowed ? list.length - 1 : 0];
202
- }
203
-
204
- const listLength = list.length;
205
- index += shouldGetNext ? 1 : -1;
206
-
207
- if (isCycleAllowed) {
208
- index = (index + listLength) % listLength;
209
- }
210
-
211
- return list[Math.max(0, Math.min(index, listLength - 1))];
212
- };
213
-
214
- /**
215
- * --------------------------------------------------------------------------
216
- * CoreUI (v4.1.6): carousel.js
22
+ * CoreUI (v4.2.2): carousel.js
217
23
  * Licensed under MIT (https://coreui.io/license)
218
24
  *
219
25
  * This component is a modified version of the Bootstrap's carousel.js
@@ -221,9 +27,7 @@
221
27
  * --------------------------------------------------------------------------
222
28
  */
223
29
  /**
224
- * ------------------------------------------------------------------------
225
30
  * Constants
226
- * ------------------------------------------------------------------------
227
31
  */
228
32
 
229
33
  const NAME = 'carousel';
@@ -234,41 +38,15 @@
234
38
  const ARROW_RIGHT_KEY = 'ArrowRight';
235
39
  const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
236
40
 
237
- const SWIPE_THRESHOLD = 40;
238
- const Default = {
239
- interval: 5000,
240
- keyboard: true,
241
- slide: false,
242
- pause: 'hover',
243
- wrap: true,
244
- touch: true
245
- };
246
- const DefaultType = {
247
- interval: '(number|boolean)',
248
- keyboard: 'boolean',
249
- slide: '(boolean|string)',
250
- pause: '(string|boolean)',
251
- wrap: 'boolean',
252
- touch: 'boolean'
253
- };
254
41
  const ORDER_NEXT = 'next';
255
42
  const ORDER_PREV = 'prev';
256
43
  const DIRECTION_LEFT = 'left';
257
44
  const DIRECTION_RIGHT = 'right';
258
- const KEY_TO_DIRECTION = {
259
- [ARROW_LEFT_KEY]: DIRECTION_RIGHT,
260
- [ARROW_RIGHT_KEY]: DIRECTION_LEFT
261
- };
262
45
  const EVENT_SLIDE = `slide${EVENT_KEY}`;
263
46
  const EVENT_SLID = `slid${EVENT_KEY}`;
264
47
  const EVENT_KEYDOWN = `keydown${EVENT_KEY}`;
265
48
  const EVENT_MOUSEENTER = `mouseenter${EVENT_KEY}`;
266
49
  const EVENT_MOUSELEAVE = `mouseleave${EVENT_KEY}`;
267
- const EVENT_TOUCHSTART = `touchstart${EVENT_KEY}`;
268
- const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY}`;
269
- const EVENT_TOUCHEND = `touchend${EVENT_KEY}`;
270
- const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY}`;
271
- const EVENT_POINTERUP = `pointerup${EVENT_KEY}`;
272
50
  const EVENT_DRAG_START = `dragstart${EVENT_KEY}`;
273
51
  const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`;
274
52
  const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
@@ -279,41 +57,53 @@
279
57
  const CLASS_NAME_START = 'carousel-item-start';
280
58
  const CLASS_NAME_NEXT = 'carousel-item-next';
281
59
  const CLASS_NAME_PREV = 'carousel-item-prev';
282
- const CLASS_NAME_POINTER_EVENT = 'pointer-event';
283
60
  const SELECTOR_ACTIVE = '.active';
284
- const SELECTOR_ACTIVE_ITEM = '.active.carousel-item';
285
61
  const SELECTOR_ITEM = '.carousel-item';
62
+ const SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM;
286
63
  const SELECTOR_ITEM_IMG = '.carousel-item img';
287
- const SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev';
288
64
  const SELECTOR_INDICATORS = '.carousel-indicators';
289
- const SELECTOR_INDICATOR = '[data-coreui-target]';
290
65
  const SELECTOR_DATA_SLIDE = '[data-coreui-slide], [data-coreui-slide-to]';
291
66
  const SELECTOR_DATA_RIDE = '[data-coreui-ride="carousel"]';
292
- const POINTER_TYPE_TOUCH = 'touch';
293
- const POINTER_TYPE_PEN = 'pen';
67
+ const KEY_TO_DIRECTION = {
68
+ [ARROW_LEFT_KEY]: DIRECTION_RIGHT,
69
+ [ARROW_RIGHT_KEY]: DIRECTION_LEFT
70
+ };
71
+ const Default = {
72
+ interval: 5000,
73
+ keyboard: true,
74
+ pause: 'hover',
75
+ ride: false,
76
+ touch: true,
77
+ wrap: true
78
+ };
79
+ const DefaultType = {
80
+ interval: '(number|boolean)',
81
+ // TODO:v6 remove boolean support
82
+ keyboard: 'boolean',
83
+ pause: '(string|boolean)',
84
+ ride: '(boolean|string)',
85
+ touch: 'boolean',
86
+ wrap: 'boolean'
87
+ };
294
88
  /**
295
- * ------------------------------------------------------------------------
296
- * Class Definition
297
- * ------------------------------------------------------------------------
89
+ * Class definition
298
90
  */
299
91
 
300
92
  class Carousel extends BaseComponent__default.default {
301
93
  constructor(element, config) {
302
- super(element);
303
- this._items = null;
94
+ super(element, config);
304
95
  this._interval = null;
305
96
  this._activeElement = null;
306
- this._isPaused = false;
307
97
  this._isSliding = false;
308
98
  this.touchTimeout = null;
309
- this.touchStartX = 0;
310
- this.touchDeltaX = 0;
311
- this._config = this._getConfig(config);
99
+ this._swipeHelper = null;
312
100
  this._indicatorsElement = SelectorEngine__default.default.findOne(SELECTOR_INDICATORS, this._element);
313
- this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
314
- this._pointerEvent = Boolean(window.PointerEvent);
315
101
 
316
102
  this._addEventListeners();
103
+
104
+ if (this._config.ride === CLASS_NAME_CAROUSEL) {
105
+ this.cycle();
106
+ }
317
107
  } // Getters
318
108
 
319
109
 
@@ -321,6 +111,10 @@
321
111
  return Default;
322
112
  }
323
113
 
114
+ static get DefaultType() {
115
+ return DefaultType;
116
+ }
117
+
324
118
  static get NAME() {
325
119
  return NAME;
326
120
  } // Public
@@ -331,9 +125,10 @@
331
125
  }
332
126
 
333
127
  nextWhenVisible() {
128
+ // FIXME TODO use `document.visibilityState`
334
129
  // Don't call next when the page isn't visible
335
130
  // or the carousel or its parent isn't visible
336
- if (!document.hidden && isVisible(this._element)) {
131
+ if (!document.hidden && index.isVisible(this._element)) {
337
132
  this.next();
338
133
  }
339
134
  }
@@ -342,43 +137,39 @@
342
137
  this._slide(ORDER_PREV);
343
138
  }
344
139
 
345
- pause(event) {
346
- if (!event) {
347
- this._isPaused = true;
140
+ pause() {
141
+ if (this._isSliding) {
142
+ index.triggerTransitionEnd(this._element);
348
143
  }
349
144
 
350
- if (SelectorEngine__default.default.findOne(SELECTOR_NEXT_PREV, this._element)) {
351
- triggerTransitionEnd(this._element);
352
- this.cycle(true);
353
- }
145
+ this._clearInterval();
146
+ }
354
147
 
355
- clearInterval(this._interval);
356
- this._interval = null;
148
+ cycle() {
149
+ this._clearInterval();
150
+
151
+ this._updateInterval();
152
+
153
+ this._interval = setInterval(() => this.nextWhenVisible(), this._config.interval);
357
154
  }
358
155
 
359
- cycle(event) {
360
- if (!event) {
361
- this._isPaused = false;
156
+ _maybeEnableCycle() {
157
+ if (!this._config.ride) {
158
+ return;
362
159
  }
363
160
 
364
- if (this._interval) {
365
- clearInterval(this._interval);
366
- this._interval = null;
161
+ if (this._isSliding) {
162
+ EventHandler__default.default.one(this._element, EVENT_SLID, () => this.cycle());
163
+ return;
367
164
  }
368
165
 
369
- if (this._config && this._config.interval && !this._isPaused) {
370
- this._updateInterval();
371
-
372
- this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
373
- }
166
+ this.cycle();
374
167
  }
375
168
 
376
169
  to(index) {
377
- this._activeElement = SelectorEngine__default.default.findOne(SELECTOR_ACTIVE_ITEM, this._element);
170
+ const items = this._getItems();
378
171
 
379
- const activeIndex = this._getItemIndex(this._activeElement);
380
-
381
- if (index > this._items.length - 1 || index < 0) {
172
+ if (index > items.length - 1 || index < 0) {
382
173
  return;
383
174
  }
384
175
 
@@ -387,42 +178,29 @@
387
178
  return;
388
179
  }
389
180
 
181
+ const activeIndex = this._getItemIndex(this._getActive());
182
+
390
183
  if (activeIndex === index) {
391
- this.pause();
392
- this.cycle();
393
184
  return;
394
185
  }
395
186
 
396
187
  const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV;
397
188
 
398
- this._slide(order, this._items[index]);
399
- } // Private
400
-
401
-
402
- _getConfig(config) {
403
- config = { ...Default,
404
- ...Manipulator__default.default.getDataAttributes(this._element),
405
- ...(typeof config === 'object' ? config : {})
406
- };
407
- typeCheckConfig(NAME, config, DefaultType);
408
- return config;
189
+ this._slide(order, items[index]);
409
190
  }
410
191
 
411
- _handleSwipe() {
412
- const absDeltax = Math.abs(this.touchDeltaX);
413
-
414
- if (absDeltax <= SWIPE_THRESHOLD) {
415
- return;
192
+ dispose() {
193
+ if (this._swipeHelper) {
194
+ this._swipeHelper.dispose();
416
195
  }
417
196
 
418
- const direction = absDeltax / this.touchDeltaX;
419
- this.touchDeltaX = 0;
197
+ super.dispose();
198
+ } // Private
420
199
 
421
- if (!direction) {
422
- return;
423
- }
424
200
 
425
- this._slide(direction > 0 ? DIRECTION_RIGHT : DIRECTION_LEFT);
201
+ _configAfterMerge(config) {
202
+ config.defaultInterval = config.interval;
203
+ return config;
426
204
  }
427
205
 
428
206
  _addEventListeners() {
@@ -431,72 +209,47 @@
431
209
  }
432
210
 
433
211
  if (this._config.pause === 'hover') {
434
- EventHandler__default.default.on(this._element, EVENT_MOUSEENTER, event => this.pause(event));
435
- EventHandler__default.default.on(this._element, EVENT_MOUSELEAVE, event => this.cycle(event));
212
+ EventHandler__default.default.on(this._element, EVENT_MOUSEENTER, () => this.pause());
213
+ EventHandler__default.default.on(this._element, EVENT_MOUSELEAVE, () => this._maybeEnableCycle());
436
214
  }
437
215
 
438
- if (this._config.touch && this._touchSupported) {
216
+ if (this._config.touch && Swipe__default.default.isSupported()) {
439
217
  this._addTouchEventListeners();
440
218
  }
441
219
  }
442
220
 
443
221
  _addTouchEventListeners() {
444
- const hasPointerPenTouch = event => {
445
- return this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH);
446
- };
447
-
448
- const start = event => {
449
- if (hasPointerPenTouch(event)) {
450
- this.touchStartX = event.clientX;
451
- } else if (!this._pointerEvent) {
452
- this.touchStartX = event.touches[0].clientX;
453
- }
454
- };
455
-
456
- const move = event => {
457
- // ensure swiping with one touch and not pinching
458
- this.touchDeltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this.touchStartX;
459
- };
460
-
461
- const end = event => {
462
- if (hasPointerPenTouch(event)) {
463
- this.touchDeltaX = event.clientX - this.touchStartX;
464
- }
222
+ for (const img of SelectorEngine__default.default.find(SELECTOR_ITEM_IMG, this._element)) {
223
+ EventHandler__default.default.on(img, EVENT_DRAG_START, event => event.preventDefault());
224
+ }
465
225
 
466
- this._handleSwipe();
226
+ const endCallBack = () => {
227
+ if (this._config.pause !== 'hover') {
228
+ return;
229
+ } // If it's a touch-enabled device, mouseenter/leave are fired as
230
+ // part of the mouse compatibility events on first tap - the carousel
231
+ // would stop cycling until user tapped out of it;
232
+ // here, we listen for touchend, explicitly pause the carousel
233
+ // (as if it's the second time we tap on it, mouseenter compat event
234
+ // is NOT fired) and after a timeout (to allow for mouse compatibility
235
+ // events to fire) we explicitly restart cycling
467
236
 
468
- if (this._config.pause === 'hover') {
469
- // If it's a touch-enabled device, mouseenter/leave are fired as
470
- // part of the mouse compatibility events on first tap - the carousel
471
- // would stop cycling until user tapped out of it;
472
- // here, we listen for touchend, explicitly pause the carousel
473
- // (as if it's the second time we tap on it, mouseenter compat event
474
- // is NOT fired) and after a timeout (to allow for mouse compatibility
475
- // events to fire) we explicitly restart cycling
476
- this.pause();
477
237
 
478
- if (this.touchTimeout) {
479
- clearTimeout(this.touchTimeout);
480
- }
238
+ this.pause();
481
239
 
482
- this.touchTimeout = setTimeout(event => this.cycle(event), TOUCHEVENT_COMPAT_WAIT + this._config.interval);
240
+ if (this.touchTimeout) {
241
+ clearTimeout(this.touchTimeout);
483
242
  }
484
- };
485
-
486
- SelectorEngine__default.default.find(SELECTOR_ITEM_IMG, this._element).forEach(itemImg => {
487
- EventHandler__default.default.on(itemImg, EVENT_DRAG_START, event => event.preventDefault());
488
- });
489
243
 
490
- if (this._pointerEvent) {
491
- EventHandler__default.default.on(this._element, EVENT_POINTERDOWN, event => start(event));
492
- EventHandler__default.default.on(this._element, EVENT_POINTERUP, event => end(event));
244
+ this.touchTimeout = setTimeout(() => this._maybeEnableCycle(), TOUCHEVENT_COMPAT_WAIT + this._config.interval);
245
+ };
493
246
 
494
- this._element.classList.add(CLASS_NAME_POINTER_EVENT);
495
- } else {
496
- EventHandler__default.default.on(this._element, EVENT_TOUCHSTART, event => start(event));
497
- EventHandler__default.default.on(this._element, EVENT_TOUCHMOVE, event => move(event));
498
- EventHandler__default.default.on(this._element, EVENT_TOUCHEND, event => end(event));
499
- }
247
+ const swipeConfig = {
248
+ leftCallback: () => this._slide(this._directionToOrder(DIRECTION_LEFT)),
249
+ rightCallback: () => this._slide(this._directionToOrder(DIRECTION_RIGHT)),
250
+ endCallback: endCallBack
251
+ };
252
+ this._swipeHelper = new Swipe__default.default(this._element, swipeConfig);
500
253
  }
501
254
 
502
255
  _keydown(event) {
@@ -509,95 +262,67 @@
509
262
  if (direction) {
510
263
  event.preventDefault();
511
264
 
512
- this._slide(direction);
265
+ this._slide(this._directionToOrder(direction));
513
266
  }
514
267
  }
515
268
 
516
269
  _getItemIndex(element) {
517
- this._items = element && element.parentNode ? SelectorEngine__default.default.find(SELECTOR_ITEM, element.parentNode) : [];
518
- return this._items.indexOf(element);
519
- }
520
-
521
- _getItemByOrder(order, activeElement) {
522
- const isNext = order === ORDER_NEXT;
523
- return getNextActiveElement(this._items, activeElement, isNext, this._config.wrap);
270
+ return this._getItems().indexOf(element);
524
271
  }
525
272
 
526
- _triggerSlideEvent(relatedTarget, eventDirectionName) {
527
- const targetIndex = this._getItemIndex(relatedTarget);
528
-
529
- const fromIndex = this._getItemIndex(SelectorEngine__default.default.findOne(SELECTOR_ACTIVE_ITEM, this._element));
273
+ _setActiveIndicatorElement(index) {
274
+ if (!this._indicatorsElement) {
275
+ return;
276
+ }
530
277
 
531
- return EventHandler__default.default.trigger(this._element, EVENT_SLIDE, {
532
- relatedTarget,
533
- direction: eventDirectionName,
534
- from: fromIndex,
535
- to: targetIndex
536
- });
537
- }
278
+ const activeIndicator = SelectorEngine__default.default.findOne(SELECTOR_ACTIVE, this._indicatorsElement);
279
+ activeIndicator.classList.remove(CLASS_NAME_ACTIVE);
280
+ activeIndicator.removeAttribute('aria-current');
281
+ const newActiveIndicator = SelectorEngine__default.default.findOne(`[data-coreui-slide-to="${index}"]`, this._indicatorsElement);
538
282
 
539
- _setActiveIndicatorElement(element) {
540
- if (this._indicatorsElement) {
541
- const activeIndicator = SelectorEngine__default.default.findOne(SELECTOR_ACTIVE, this._indicatorsElement);
542
- activeIndicator.classList.remove(CLASS_NAME_ACTIVE);
543
- activeIndicator.removeAttribute('aria-current');
544
- const indicators = SelectorEngine__default.default.find(SELECTOR_INDICATOR, this._indicatorsElement); // eslint-disable-next-line unicorn/no-for-loop
545
-
546
- for (let i = 0; i < indicators.length; i++) {
547
- if (Number.parseInt(indicators[i].getAttribute('data-coreui-slide-to'), 10) === this._getItemIndex(element)) {
548
- indicators[i].classList.add(CLASS_NAME_ACTIVE);
549
- indicators[i].setAttribute('aria-current', 'true');
550
- break;
551
- }
552
- }
283
+ if (newActiveIndicator) {
284
+ newActiveIndicator.classList.add(CLASS_NAME_ACTIVE);
285
+ newActiveIndicator.setAttribute('aria-current', 'true');
553
286
  }
554
287
  }
555
288
 
556
289
  _updateInterval() {
557
- const element = this._activeElement || SelectorEngine__default.default.findOne(SELECTOR_ACTIVE_ITEM, this._element);
290
+ const element = this._activeElement || this._getActive();
558
291
 
559
292
  if (!element) {
560
293
  return;
561
294
  }
562
295
 
563
296
  const elementInterval = Number.parseInt(element.getAttribute('data-coreui-interval'), 10);
564
-
565
- if (elementInterval) {
566
- this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
567
- this._config.interval = elementInterval;
568
- } else {
569
- this._config.interval = this._config.defaultInterval || this._config.interval;
570
- }
297
+ this._config.interval = elementInterval || this._config.defaultInterval;
571
298
  }
572
299
 
573
- _slide(directionOrOrder, element) {
574
- const order = this._directionToOrder(directionOrOrder);
575
-
576
- const activeElement = SelectorEngine__default.default.findOne(SELECTOR_ACTIVE_ITEM, this._element);
577
-
578
- const activeElementIndex = this._getItemIndex(activeElement);
579
-
580
- const nextElement = element || this._getItemByOrder(order, activeElement);
300
+ _slide(order, element = null) {
301
+ if (this._isSliding) {
302
+ return;
303
+ }
581
304
 
582
- const nextElementIndex = this._getItemIndex(nextElement);
305
+ const activeElement = this._getActive();
583
306
 
584
- const isCycling = Boolean(this._interval);
585
307
  const isNext = order === ORDER_NEXT;
586
- const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END;
587
- const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
308
+ const nextElement = element || index.getNextActiveElement(this._getItems(), activeElement, isNext, this._config.wrap);
588
309
 
589
- const eventDirectionName = this._orderToDirection(order);
590
-
591
- if (nextElement && nextElement.classList.contains(CLASS_NAME_ACTIVE)) {
592
- this._isSliding = false;
310
+ if (nextElement === activeElement) {
593
311
  return;
594
312
  }
595
313
 
596
- if (this._isSliding) {
597
- return;
598
- }
314
+ const nextElementIndex = this._getItemIndex(nextElement);
315
+
316
+ const triggerEvent = eventName => {
317
+ return EventHandler__default.default.trigger(this._element, eventName, {
318
+ relatedTarget: nextElement,
319
+ direction: this._orderToDirection(order),
320
+ from: this._getItemIndex(activeElement),
321
+ to: nextElementIndex
322
+ });
323
+ };
599
324
 
600
- const slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
325
+ const slideEvent = triggerEvent(EVENT_SLIDE);
601
326
 
602
327
  if (slideEvent.defaultPrevented) {
603
328
  return;
@@ -605,61 +330,60 @@
605
330
 
606
331
  if (!activeElement || !nextElement) {
607
332
  // Some weirdness is happening, so we bail
333
+ // todo: change tests that use empty divs to avoid this check
608
334
  return;
609
335
  }
610
336
 
337
+ const isCycling = Boolean(this._interval);
338
+ this.pause();
611
339
  this._isSliding = true;
612
340
 
613
- if (isCycling) {
614
- this.pause();
615
- }
616
-
617
- this._setActiveIndicatorElement(nextElement);
341
+ this._setActiveIndicatorElement(nextElementIndex);
618
342
 
619
343
  this._activeElement = nextElement;
344
+ const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END;
345
+ const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
346
+ nextElement.classList.add(orderClassName);
347
+ index.reflow(nextElement);
348
+ activeElement.classList.add(directionalClassName);
349
+ nextElement.classList.add(directionalClassName);
620
350
 
621
- const triggerSlidEvent = () => {
622
- EventHandler__default.default.trigger(this._element, EVENT_SLID, {
623
- relatedTarget: nextElement,
624
- direction: eventDirectionName,
625
- from: activeElementIndex,
626
- to: nextElementIndex
627
- });
628
- };
629
-
630
- if (this._element.classList.contains(CLASS_NAME_SLIDE)) {
631
- nextElement.classList.add(orderClassName);
632
- reflow(nextElement);
633
- activeElement.classList.add(directionalClassName);
634
- nextElement.classList.add(directionalClassName);
635
-
636
- const completeCallBack = () => {
637
- nextElement.classList.remove(directionalClassName, orderClassName);
638
- nextElement.classList.add(CLASS_NAME_ACTIVE);
639
- activeElement.classList.remove(CLASS_NAME_ACTIVE, orderClassName, directionalClassName);
640
- this._isSliding = false;
641
- setTimeout(triggerSlidEvent, 0);
642
- };
643
-
644
- this._queueCallback(completeCallBack, activeElement, true);
645
- } else {
646
- activeElement.classList.remove(CLASS_NAME_ACTIVE);
351
+ const completeCallBack = () => {
352
+ nextElement.classList.remove(directionalClassName, orderClassName);
647
353
  nextElement.classList.add(CLASS_NAME_ACTIVE);
354
+ activeElement.classList.remove(CLASS_NAME_ACTIVE, orderClassName, directionalClassName);
648
355
  this._isSliding = false;
649
- triggerSlidEvent();
650
- }
356
+ triggerEvent(EVENT_SLID);
357
+ };
358
+
359
+ this._queueCallback(completeCallBack, activeElement, this._isAnimated());
651
360
 
652
361
  if (isCycling) {
653
362
  this.cycle();
654
363
  }
655
364
  }
656
365
 
657
- _directionToOrder(direction) {
658
- if (![DIRECTION_RIGHT, DIRECTION_LEFT].includes(direction)) {
659
- return direction;
366
+ _isAnimated() {
367
+ return this._element.classList.contains(CLASS_NAME_SLIDE);
368
+ }
369
+
370
+ _getActive() {
371
+ return SelectorEngine__default.default.findOne(SELECTOR_ACTIVE_ITEM, this._element);
372
+ }
373
+
374
+ _getItems() {
375
+ return SelectorEngine__default.default.find(SELECTOR_ITEM, this._element);
376
+ }
377
+
378
+ _clearInterval() {
379
+ if (this._interval) {
380
+ clearInterval(this._interval);
381
+ this._interval = null;
660
382
  }
383
+ }
661
384
 
662
- if (isRTL()) {
385
+ _directionToOrder(direction) {
386
+ if (index.isRTL()) {
663
387
  return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT;
664
388
  }
665
389
 
@@ -667,11 +391,7 @@
667
391
  }
668
392
 
669
393
  _orderToDirection(order) {
670
- if (![ORDER_NEXT, ORDER_PREV].includes(order)) {
671
- return order;
672
- }
673
-
674
- if (isRTL()) {
394
+ if (index.isRTL()) {
675
395
  return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT;
676
396
  }
677
397
 
@@ -679,89 +399,74 @@
679
399
  } // Static
680
400
 
681
401
 
682
- static carouselInterface(element, config) {
683
- const data = Carousel.getOrCreateInstance(element, config);
684
- let {
685
- _config
686
- } = data;
687
-
688
- if (typeof config === 'object') {
689
- _config = { ..._config,
690
- ...config
691
- };
692
- }
693
-
694
- const action = typeof config === 'string' ? config : _config.slide;
402
+ static jQueryInterface(config) {
403
+ return this.each(function () {
404
+ const data = Carousel.getOrCreateInstance(this, config);
695
405
 
696
- if (typeof config === 'number') {
697
- data.to(config);
698
- } else if (typeof action === 'string') {
699
- if (typeof data[action] === 'undefined') {
700
- throw new TypeError(`No method named "${action}"`);
406
+ if (typeof config === 'number') {
407
+ data.to(config);
408
+ return;
701
409
  }
702
410
 
703
- data[action]();
704
- } else if (_config.interval && _config.ride) {
705
- data.pause();
706
- data.cycle();
707
- }
708
- }
411
+ if (typeof config === 'string') {
412
+ if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
413
+ throw new TypeError(`No method named "${config}"`);
414
+ }
709
415
 
710
- static jQueryInterface(config) {
711
- return this.each(function () {
712
- Carousel.carouselInterface(this, config);
416
+ data[config]();
417
+ }
713
418
  });
714
419
  }
715
420
 
716
- static dataApiClickHandler(event) {
717
- const target = getElementFromSelector(this);
421
+ }
422
+ /**
423
+ * Data API implementation
424
+ */
425
+
718
426
 
719
- if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
720
- return;
721
- }
427
+ EventHandler__default.default.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, function (event) {
428
+ const target = index.getElementFromSelector(this);
722
429
 
723
- const config = { ...Manipulator__default.default.getDataAttributes(target),
724
- ...Manipulator__default.default.getDataAttributes(this)
725
- };
726
- const slideIndex = this.getAttribute('data-coreui-slide-to');
430
+ if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
431
+ return;
432
+ }
727
433
 
728
- if (slideIndex) {
729
- config.interval = false;
730
- }
434
+ event.preventDefault();
435
+ const carousel = Carousel.getOrCreateInstance(target);
436
+ const slideIndex = this.getAttribute('data-coreui-slide-to');
731
437
 
732
- Carousel.carouselInterface(target, config);
438
+ if (slideIndex) {
439
+ carousel.to(slideIndex);
733
440
 
734
- if (slideIndex) {
735
- Carousel.getInstance(target).to(slideIndex);
736
- }
441
+ carousel._maybeEnableCycle();
737
442
 
738
- event.preventDefault();
443
+ return;
739
444
  }
740
445
 
741
- }
742
- /**
743
- * ------------------------------------------------------------------------
744
- * Data Api implementation
745
- * ------------------------------------------------------------------------
746
- */
446
+ if (Manipulator__default.default.getDataAttribute(this, 'slide') === 'next') {
447
+ carousel.next();
747
448
 
449
+ carousel._maybeEnableCycle();
748
450
 
749
- EventHandler__default.default.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler);
451
+ return;
452
+ }
453
+
454
+ carousel.prev();
455
+
456
+ carousel._maybeEnableCycle();
457
+ });
750
458
  EventHandler__default.default.on(window, EVENT_LOAD_DATA_API, () => {
751
459
  const carousels = SelectorEngine__default.default.find(SELECTOR_DATA_RIDE);
752
460
 
753
- for (let i = 0, len = carousels.length; i < len; i++) {
754
- Carousel.carouselInterface(carousels[i], Carousel.getInstance(carousels[i]));
461
+ for (const carousel of carousels) {
462
+ Carousel.getOrCreateInstance(carousel);
755
463
  }
756
464
  });
757
465
  /**
758
- * ------------------------------------------------------------------------
759
466
  * jQuery
760
- * ------------------------------------------------------------------------
761
- * add .Carousel to jQuery only if jQuery is present
762
467
  */
763
468
 
764
- defineJQueryPlugin(Carousel);
469
+ index.defineJQueryPlugin(Carousel);
765
470
 
766
471
  return Carousel;
767
472