bootstrap-italia 2.13.4 → 2.14.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.
- package/dist/_virtual/_commonjsHelpers.js +6 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/bootstrap-italia.esm.js +1 -2
- package/dist/bootstrap-italia.esm.js.map +1 -1
- package/dist/css/bootstrap-italia.min.css +1 -1
- package/dist/css/bootstrap-italia.min.css.map +1 -1
- package/dist/js/bootstrap-italia.bundle.min.js +14 -8
- package/dist/js/bootstrap-italia.min.js +4 -4
- package/dist/plugins/back-to-top.js +0 -6
- package/dist/plugins/back-to-top.js.map +1 -1
- package/dist/plugins/button.js +3 -3
- package/dist/plugins/button.js.map +1 -1
- package/dist/plugins/carousel.js +183 -402
- package/dist/plugins/carousel.js.map +1 -1
- package/dist/plugins/forward.js.map +1 -1
- package/dist/plugins/header-sticky.js +1 -7
- package/dist/plugins/header-sticky.js.map +1 -1
- package/dist/plugins/input-label.js +5 -1
- package/dist/plugins/input-label.js.map +1 -1
- package/dist/plugins/input-number.js +5 -7
- package/dist/plugins/input-number.js.map +1 -1
- package/dist/plugins/masonry.js +8 -1
- package/dist/plugins/masonry.js.map +1 -1
- package/dist/plugins/select-autocomplete.js +66 -17
- package/dist/plugins/select-autocomplete.js.map +1 -1
- package/dist/plugins/tooltip.js +10 -0
- package/dist/plugins/tooltip.js.map +1 -1
- package/dist/plugins/track-focus.js +0 -6
- package/dist/plugins/track-focus.js.map +1 -1
- package/dist/plugins/util/pageScroll.js +1 -1
- package/dist/plugins/util/pageScroll.js.map +1 -1
- package/dist/plugins/vendor/accessible-autocomplete.js +9 -0
- package/dist/plugins/vendor/accessible-autocomplete.js.map +1 -0
- package/dist/svg/sprites.svg +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -3
- package/src/js/bootstrap-italia.entry.js +0 -2
- package/src/js/bootstrap-italia.esm.js +1 -2
- package/src/js/icons.js +9 -0
- package/src/js/plugins/back-to-top.js +0 -6
- package/src/js/plugins/button.js +3 -3
- package/src/js/plugins/carousel.js +184 -402
- package/src/js/plugins/forward.js +0 -1
- package/src/js/plugins/header-sticky.js +1 -7
- package/src/js/plugins/input-label.js +5 -1
- package/src/js/plugins/input-number.js +5 -7
- package/src/js/plugins/masonry.js +8 -1
- package/src/js/plugins/select-autocomplete.js +67 -17
- package/src/js/plugins/tooltip.js +10 -0
- package/src/js/plugins/track-focus.js +0 -6
- package/src/js/plugins/util/pageScroll.js +1 -1
- package/src/js/plugins/vendor/accessible-autocomplete.js +1 -0
- package/src/js/version.js +1 -1
- package/src/scss/base/_variables.scss +1 -1
- package/src/scss/base/_version.scss +1 -1
- package/src/scss/components/_buttons.scss +1 -1
- package/src/scss/components/_carousel.scss +7 -235
- package/src/scss/components/_navigation.scss +1 -1
- package/src/scss/components/_tab.scss +4 -4
- package/src/scss/forms/_accessible-autocomplete.scss +0 -19
- package/src/scss/forms/_form-input-number.scss +1 -1
- package/src/scss/forms/_form-input-upload.scss +1 -1
- package/src/scss/forms/_form-toggles.scss +1 -1
- package/src/scss/forms/_forms.scss +2 -1
- package/src/scss/forms/_just-validate.scss +4 -4
- package/src/scss/utilities/focus.scss +26 -16
- package/src/svg/it-bluesky.svg +4 -0
- package/src/svg/it-car.svg +4 -0
- package/src/svg/it-cart.svg +5 -0
- package/src/svg/it-file-docx.svg +12 -0
- package/src/svg/it-file-image.svg +5 -0
- package/src/svg/it-file-signed.svg +16 -0
- package/src/svg/it-file-xlsx.svg +11 -0
- package/src/svg/it-sign.svg +8 -0
- package/src/svg/it-spotify.svg +4 -0
- package/types/index.d.ts +0 -2
- package/types/plugins/carousel.d.ts +42 -2
- package/dist/plugins/carousel-bi.js +0 -226
- package/dist/plugins/carousel-bi.js.map +0 -1
- package/dist/plugins/util/swipe.js +0 -150
- package/dist/plugins/util/swipe.js.map +0 -1
- package/src/js/plugins/carousel-bi.js +0 -225
- package/types/plugins/carousel-bi.d.ts +0 -57
package/dist/plugins/carousel.js
CHANGED
|
@@ -1,449 +1,230 @@
|
|
|
1
|
-
import
|
|
2
|
-
import EventHandler from './dom/event-handler.js';
|
|
3
|
-
import Manipulator from './dom/manipulator.js';
|
|
4
|
-
import SelectorEngine from './dom/selector-engine.js';
|
|
5
|
-
import Swipe from './util/swipe.js';
|
|
1
|
+
import Splide from '@splidejs/splide';
|
|
6
2
|
import BaseComponent from './base-component.js';
|
|
3
|
+
import SelectorEngine from './dom/selector-engine.js';
|
|
4
|
+
import EventHandler from './dom/event-handler.js';
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
* --------------------------------------------------------------------------
|
|
10
8
|
* Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
|
|
11
9
|
* Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS
|
|
12
10
|
* Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)
|
|
13
|
-
* This a fork of Bootstrap: Initial license and original file name below
|
|
14
|
-
* Bootstrap (v5.2.3): carousel.js
|
|
15
|
-
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
16
11
|
* --------------------------------------------------------------------------
|
|
17
12
|
*/
|
|
18
13
|
|
|
19
14
|
|
|
20
|
-
/**
|
|
21
|
-
* Constants
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
15
|
const NAME = 'carousel';
|
|
25
16
|
const DATA_KEY = 'bs.carousel';
|
|
26
17
|
const EVENT_KEY = `.${DATA_KEY}`;
|
|
27
18
|
const DATA_API_KEY = '.data-api';
|
|
28
19
|
|
|
29
|
-
const ARROW_LEFT_KEY = 'ArrowLeft';
|
|
30
|
-
const ARROW_RIGHT_KEY = 'ArrowRight';
|
|
31
|
-
const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
|
|
32
|
-
|
|
33
|
-
const ORDER_NEXT = 'next';
|
|
34
|
-
const ORDER_PREV = 'prev';
|
|
35
|
-
const DIRECTION_LEFT = 'left';
|
|
36
|
-
const DIRECTION_RIGHT = 'right';
|
|
37
|
-
|
|
38
|
-
const EVENT_SLIDE = `slide${EVENT_KEY}`;
|
|
39
|
-
const EVENT_SLID = `slid${EVENT_KEY}`;
|
|
40
|
-
const EVENT_KEYDOWN = `keydown${EVENT_KEY}`;
|
|
41
|
-
const EVENT_MOUSEENTER = `mouseenter${EVENT_KEY}`;
|
|
42
|
-
const EVENT_MOUSELEAVE = `mouseleave${EVENT_KEY}`;
|
|
43
|
-
const EVENT_DRAG_START = `dragstart${EVENT_KEY}`;
|
|
44
20
|
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`;
|
|
45
|
-
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
|
|
46
|
-
|
|
47
|
-
const CLASS_NAME_CAROUSEL = 'carousel';
|
|
48
|
-
const CLASS_NAME_ACTIVE = 'active';
|
|
49
|
-
const CLASS_NAME_SLIDE = 'slide';
|
|
50
|
-
const CLASS_NAME_END = 'carousel-item-end';
|
|
51
|
-
const CLASS_NAME_START = 'carousel-item-start';
|
|
52
|
-
const CLASS_NAME_NEXT = 'carousel-item-next';
|
|
53
|
-
const CLASS_NAME_PREV = 'carousel-item-prev';
|
|
54
|
-
|
|
55
|
-
const SELECTOR_ACTIVE = '.active';
|
|
56
|
-
const SELECTOR_ITEM = '.carousel-item';
|
|
57
|
-
const SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM;
|
|
58
|
-
const SELECTOR_ITEM_IMG = '.carousel-item img';
|
|
59
|
-
const SELECTOR_INDICATORS = '.carousel-indicators';
|
|
60
|
-
const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
|
|
61
|
-
const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
|
|
62
|
-
|
|
63
|
-
const KEY_TO_DIRECTION = {
|
|
64
|
-
[ARROW_LEFT_KEY]: DIRECTION_RIGHT,
|
|
65
|
-
[ARROW_RIGHT_KEY]: DIRECTION_LEFT,
|
|
66
|
-
};
|
|
67
21
|
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
22
|
+
const SELECTOR_CAROUSEL = '[data-bs-carousel-splide]';
|
|
23
|
+
|
|
24
|
+
const CONFIG_DEFAULT = {
|
|
25
|
+
slideFocus: false,
|
|
26
|
+
rewind: true,
|
|
27
|
+
perMove: 1,
|
|
28
|
+
i18n: {
|
|
29
|
+
prev: 'Slide precedente',
|
|
30
|
+
next: 'Slide successiva',
|
|
31
|
+
first: 'Vai alla prima slide',
|
|
32
|
+
last: 'Vai all’ultima slide',
|
|
33
|
+
slideX: 'Vai alla slide %s',
|
|
34
|
+
pageX: 'Vai a pagina %s',
|
|
35
|
+
play: 'Attiva autoplay',
|
|
36
|
+
pause: 'Pausa autoplay',
|
|
37
|
+
carousel: 'Carosello',
|
|
38
|
+
select: 'Seleziona una slide da mostrare',
|
|
39
|
+
slide: 'slide',
|
|
40
|
+
slideLabel: '%s di %s',
|
|
41
|
+
},
|
|
75
42
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
43
|
+
const CONFIGS = {
|
|
44
|
+
'it-carousel-landscape-abstract-three-cols': {
|
|
45
|
+
type: 'slide',
|
|
46
|
+
perPage: 3,
|
|
47
|
+
gap: 24,
|
|
48
|
+
padding: { left: 0, right: 0 },
|
|
49
|
+
arrows: false,
|
|
50
|
+
breakpoints: {
|
|
51
|
+
768: {
|
|
52
|
+
perPage: 1,
|
|
53
|
+
gap: 24,
|
|
54
|
+
padding: { left: 0, right: 0 },
|
|
55
|
+
arrows: false,
|
|
56
|
+
},
|
|
57
|
+
992: {
|
|
58
|
+
perPage: 2,
|
|
59
|
+
gap: 24,
|
|
60
|
+
padding: { left: 40, right: 40 },
|
|
61
|
+
arrows: false,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
'it-carousel-landscape-abstract-three-cols-arrow-visible': {
|
|
66
|
+
type: 'slide',
|
|
67
|
+
perPage: 3,
|
|
68
|
+
gap: 24,
|
|
69
|
+
padding: { left: 0, right: 0 },
|
|
70
|
+
arrows: true,
|
|
71
|
+
breakpoints: {
|
|
72
|
+
768: {
|
|
73
|
+
perPage: 1,
|
|
74
|
+
gap: 24,
|
|
75
|
+
padding: { left: 40, right: 40 },
|
|
76
|
+
arrows: true,
|
|
77
|
+
},
|
|
78
|
+
992: {
|
|
79
|
+
perPage: 2,
|
|
80
|
+
gap: 24,
|
|
81
|
+
padding: { left: 40, right: 40 },
|
|
82
|
+
arrows: true,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
'it-big-img': {
|
|
87
|
+
type: 'loop',
|
|
88
|
+
perPage: 1,
|
|
89
|
+
gap: 48,
|
|
90
|
+
padding: { left: 320, right: 320 },
|
|
91
|
+
arrows: false,
|
|
92
|
+
breakpoints: {
|
|
93
|
+
768: {
|
|
94
|
+
perPage: 1,
|
|
95
|
+
gap: 0,
|
|
96
|
+
padding: { left: 0, right: 0 },
|
|
97
|
+
arrows: false,
|
|
98
|
+
},
|
|
99
|
+
992: {
|
|
100
|
+
perPage: 1,
|
|
101
|
+
gap: 24,
|
|
102
|
+
padding: { left: 160, right: 160 },
|
|
103
|
+
arrows: false,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
'it-standard-image': {
|
|
108
|
+
type: 'loop',
|
|
109
|
+
perPage: 3,
|
|
110
|
+
gap: 24,
|
|
111
|
+
padding: { left: 48, right: 48 },
|
|
112
|
+
arrows: false,
|
|
113
|
+
breakpoints: {
|
|
114
|
+
768: {
|
|
115
|
+
perPage: 1,
|
|
116
|
+
gap: 24,
|
|
117
|
+
padding: { left: 40, right: 40 },
|
|
118
|
+
arrows: false,
|
|
119
|
+
},
|
|
120
|
+
992: {
|
|
121
|
+
perPage: 2,
|
|
122
|
+
gap: 24,
|
|
123
|
+
padding: { left: 48, right: 48 },
|
|
124
|
+
arrows: false,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
'it-carousel-landscape-abstract': {
|
|
129
|
+
type: 'slide',
|
|
130
|
+
perPage: 1,
|
|
131
|
+
gap: 24,
|
|
132
|
+
padding: { left: 0, right: 0 },
|
|
133
|
+
arrows: false,
|
|
134
|
+
breakpoints: {
|
|
135
|
+
768: {
|
|
136
|
+
perPage: 1,
|
|
137
|
+
gap: 24,
|
|
138
|
+
padding: { left: 0, right: 0 },
|
|
139
|
+
arrows: false,
|
|
140
|
+
},
|
|
141
|
+
992: {
|
|
142
|
+
perPage: 1,
|
|
143
|
+
gap: 24,
|
|
144
|
+
padding: { left: 24, right: 24 },
|
|
145
|
+
arrows: false,
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
'it-calendar-wrapper': {
|
|
150
|
+
type: 'slide',
|
|
151
|
+
perPage: 4,
|
|
152
|
+
gap: 0,
|
|
153
|
+
padding: { left: 0, right: 0 },
|
|
154
|
+
arrows: false,
|
|
155
|
+
breakpoints: {
|
|
156
|
+
560: {
|
|
157
|
+
perPage: 1,
|
|
158
|
+
gap: 0,
|
|
159
|
+
padding: { left: 24, right: 24 },
|
|
160
|
+
arrows: false,
|
|
161
|
+
},
|
|
162
|
+
768: {
|
|
163
|
+
perPage: 2,
|
|
164
|
+
gap: 0,
|
|
165
|
+
padding: { left: 0, right: 0 },
|
|
166
|
+
arrows: false,
|
|
167
|
+
},
|
|
168
|
+
992: {
|
|
169
|
+
perPage: 3,
|
|
170
|
+
gap: 0,
|
|
171
|
+
padding: { left: 0, right: 0 },
|
|
172
|
+
arrows: false,
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
84
176
|
};
|
|
85
177
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
178
|
+
class CarouselBI extends BaseComponent {
|
|
179
|
+
constructor(element) {
|
|
180
|
+
super(element);
|
|
181
|
+
this._config = this._getConfig();
|
|
182
|
+
this._splide = new Splide(this._element, this._config);
|
|
89
183
|
|
|
90
|
-
|
|
91
|
-
constructor(element, config) {
|
|
92
|
-
super(element, config);
|
|
93
|
-
|
|
94
|
-
this._interval = null;
|
|
95
|
-
this._activeElement = null;
|
|
96
|
-
this._isSliding = false;
|
|
97
|
-
this.touchTimeout = null;
|
|
98
|
-
this._swipeHelper = null;
|
|
99
|
-
|
|
100
|
-
this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
|
|
101
|
-
this._addEventListeners();
|
|
102
|
-
|
|
103
|
-
if (this._config.ride === CLASS_NAME_CAROUSEL) {
|
|
104
|
-
this.cycle();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Getters
|
|
109
|
-
static get Default() {
|
|
110
|
-
return Default
|
|
184
|
+
this._init();
|
|
111
185
|
}
|
|
112
186
|
|
|
113
|
-
|
|
114
|
-
|
|
187
|
+
dispose() {
|
|
188
|
+
this._splide.destroy();
|
|
189
|
+
super.dispose();
|
|
115
190
|
}
|
|
191
|
+
// Getters
|
|
116
192
|
|
|
117
193
|
static get NAME() {
|
|
118
194
|
return NAME
|
|
119
195
|
}
|
|
120
196
|
|
|
121
197
|
// Public
|
|
122
|
-
next() {
|
|
123
|
-
this._slide(ORDER_NEXT);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
nextWhenVisible() {
|
|
127
|
-
// FIXME TODO use `document.visibilityState`
|
|
128
|
-
// Don't call next when the page isn't visible
|
|
129
|
-
// or the carousel or its parent isn't visible
|
|
130
|
-
if (!document.hidden && isVisible(this._element)) {
|
|
131
|
-
this.next();
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
prev() {
|
|
136
|
-
this._slide(ORDER_PREV);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
pause() {
|
|
140
|
-
if (this._isSliding) {
|
|
141
|
-
triggerTransitionEnd(this._element);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
this._clearInterval();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
cycle() {
|
|
148
|
-
this._clearInterval();
|
|
149
|
-
this._updateInterval();
|
|
150
|
-
|
|
151
|
-
this._interval = setInterval(() => this.nextWhenVisible(), this._config.interval);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
_maybeEnableCycle() {
|
|
155
|
-
if (!this._config.ride) {
|
|
156
|
-
return
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (this._isSliding) {
|
|
160
|
-
EventHandler.one(this._element, EVENT_SLID, () => this.cycle());
|
|
161
|
-
return
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
this.cycle();
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
to(index) {
|
|
168
|
-
const items = this._getItems();
|
|
169
|
-
if (index > items.length - 1 || index < 0) {
|
|
170
|
-
return
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (this._isSliding) {
|
|
174
|
-
EventHandler.one(this._element, EVENT_SLID, () => this.to(index));
|
|
175
|
-
return
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const activeIndex = this._getItemIndex(this._getActive());
|
|
179
|
-
if (activeIndex === index) {
|
|
180
|
-
return
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV;
|
|
184
|
-
|
|
185
|
-
this._slide(order, items[index]);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
dispose() {
|
|
189
|
-
if (this._swipeHelper) {
|
|
190
|
-
this._swipeHelper.dispose();
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
super.dispose();
|
|
194
|
-
}
|
|
195
198
|
|
|
196
199
|
// Private
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return config
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
_addEventListeners() {
|
|
203
|
-
if (this._config.keyboard) {
|
|
204
|
-
EventHandler.on(this._element, EVENT_KEYDOWN, (event) => this._keydown(event));
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
if (this._config.pause === 'hover') {
|
|
208
|
-
EventHandler.on(this._element, EVENT_MOUSEENTER, () => this.pause());
|
|
209
|
-
EventHandler.on(this._element, EVENT_MOUSELEAVE, () => this._maybeEnableCycle());
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (this._config.touch && Swipe.isSupported()) {
|
|
213
|
-
this._addTouchEventListeners();
|
|
214
|
-
}
|
|
200
|
+
_init() {
|
|
201
|
+
this._splide.mount();
|
|
215
202
|
}
|
|
216
203
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const endCallBack = () => {
|
|
223
|
-
if (this._config.pause !== 'hover') {
|
|
224
|
-
return
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// If it's a touch-enabled device, mouseenter/leave are fired as
|
|
228
|
-
// part of the mouse compatibility events on first tap - the carousel
|
|
229
|
-
// would stop cycling until user tapped out of it;
|
|
230
|
-
// here, we listen for touchend, explicitly pause the carousel
|
|
231
|
-
// (as if it's the second time we tap on it, mouseenter compat event
|
|
232
|
-
// is NOT fired) and after a timeout (to allow for mouse compatibility
|
|
233
|
-
// events to fire) we explicitly restart cycling
|
|
234
|
-
|
|
235
|
-
this.pause();
|
|
236
|
-
if (this.touchTimeout) {
|
|
237
|
-
clearTimeout(this.touchTimeout);
|
|
204
|
+
_getConfig() {
|
|
205
|
+
let conf = Object.assign({}, CONFIG_DEFAULT);
|
|
206
|
+
Object.keys(CONFIGS).forEach((classKey) => {
|
|
207
|
+
if (this._element.classList.contains(classKey)) {
|
|
208
|
+
conf = Object.assign({}, conf, CONFIGS[classKey]);
|
|
238
209
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
const swipeConfig = {
|
|
244
|
-
leftCallback: () => this._slide(this._directionToOrder(DIRECTION_LEFT)),
|
|
245
|
-
rightCallback: () => this._slide(this._directionToOrder(DIRECTION_RIGHT)),
|
|
246
|
-
endCallback: endCallBack,
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
this._swipeHelper = new Swipe(this._element, swipeConfig);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
_keydown(event) {
|
|
253
|
-
if (/input|textarea/i.test(event.target.tagName)) {
|
|
254
|
-
return
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
const direction = KEY_TO_DIRECTION[event.key];
|
|
258
|
-
if (direction) {
|
|
259
|
-
event.preventDefault();
|
|
260
|
-
this._slide(this._directionToOrder(direction));
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
_getItemIndex(element) {
|
|
265
|
-
return this._getItems().indexOf(element)
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
_setActiveIndicatorElement(index) {
|
|
269
|
-
if (!this._indicatorsElement) {
|
|
270
|
-
return
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE, this._indicatorsElement);
|
|
274
|
-
|
|
275
|
-
activeIndicator.classList.remove(CLASS_NAME_ACTIVE);
|
|
276
|
-
activeIndicator.removeAttribute('aria-current');
|
|
277
|
-
|
|
278
|
-
const newActiveIndicator = SelectorEngine.findOne(`[data-bs-slide-to="${index}"]`, this._indicatorsElement);
|
|
279
|
-
|
|
280
|
-
if (newActiveIndicator) {
|
|
281
|
-
newActiveIndicator.classList.add(CLASS_NAME_ACTIVE);
|
|
282
|
-
newActiveIndicator.setAttribute('aria-current', 'true');
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
_updateInterval() {
|
|
287
|
-
const element = this._activeElement || this._getActive();
|
|
288
|
-
|
|
289
|
-
if (!element) {
|
|
290
|
-
return
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10);
|
|
294
|
-
|
|
295
|
-
this._config.interval = elementInterval || this._config.defaultInterval;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
_slide(order, element = null) {
|
|
299
|
-
if (this._isSliding) {
|
|
300
|
-
return
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
const activeElement = this._getActive();
|
|
304
|
-
const isNext = order === ORDER_NEXT;
|
|
305
|
-
const nextElement = element || getNextActiveElement(this._getItems(), activeElement, isNext, this._config.wrap);
|
|
306
|
-
|
|
307
|
-
if (nextElement === activeElement) {
|
|
308
|
-
return
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
const nextElementIndex = this._getItemIndex(nextElement);
|
|
312
|
-
|
|
313
|
-
const triggerEvent = (eventName) => {
|
|
314
|
-
return EventHandler.trigger(this._element, eventName, {
|
|
315
|
-
relatedTarget: nextElement,
|
|
316
|
-
direction: this._orderToDirection(order),
|
|
317
|
-
from: this._getItemIndex(activeElement),
|
|
318
|
-
to: nextElementIndex,
|
|
319
|
-
})
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
const slideEvent = triggerEvent(EVENT_SLIDE);
|
|
323
|
-
|
|
324
|
-
if (slideEvent.defaultPrevented) {
|
|
325
|
-
return
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
if (!activeElement || !nextElement) {
|
|
329
|
-
// Some weirdness is happening, so we bail
|
|
330
|
-
// todo: change tests that use empty divs to avoid this check
|
|
331
|
-
return
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
const isCycling = Boolean(this._interval);
|
|
335
|
-
this.pause();
|
|
336
|
-
|
|
337
|
-
this._isSliding = true;
|
|
338
|
-
|
|
339
|
-
this._setActiveIndicatorElement(nextElementIndex);
|
|
340
|
-
this._activeElement = nextElement;
|
|
341
|
-
|
|
342
|
-
const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END;
|
|
343
|
-
const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
|
|
344
|
-
|
|
345
|
-
nextElement.classList.add(orderClassName);
|
|
346
|
-
|
|
347
|
-
reflow(nextElement);
|
|
348
|
-
|
|
349
|
-
activeElement.classList.add(directionalClassName);
|
|
350
|
-
nextElement.classList.add(directionalClassName);
|
|
351
|
-
|
|
352
|
-
const completeCallBack = () => {
|
|
353
|
-
nextElement.classList.remove(directionalClassName, orderClassName);
|
|
354
|
-
nextElement.classList.add(CLASS_NAME_ACTIVE);
|
|
355
|
-
|
|
356
|
-
activeElement.classList.remove(CLASS_NAME_ACTIVE, orderClassName, directionalClassName);
|
|
357
|
-
|
|
358
|
-
this._isSliding = false;
|
|
359
|
-
|
|
360
|
-
triggerEvent(EVENT_SLID);
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
this._queueCallback(completeCallBack, activeElement, this._isAnimated());
|
|
364
|
-
|
|
365
|
-
if (isCycling) {
|
|
366
|
-
this.cycle();
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
_isAnimated() {
|
|
371
|
-
return this._element.classList.contains(CLASS_NAME_SLIDE)
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
_getActive() {
|
|
375
|
-
return SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element)
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
_getItems() {
|
|
379
|
-
return SelectorEngine.find(SELECTOR_ITEM, this._element)
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
_clearInterval() {
|
|
383
|
-
if (this._interval) {
|
|
384
|
-
clearInterval(this._interval);
|
|
385
|
-
this._interval = null;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
_directionToOrder(direction) {
|
|
390
|
-
if (isRTL()) {
|
|
391
|
-
return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
_orderToDirection(order) {
|
|
398
|
-
if (isRTL()) {
|
|
399
|
-
return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT
|
|
210
|
+
});
|
|
211
|
+
return conf
|
|
403
212
|
}
|
|
404
213
|
}
|
|
405
214
|
|
|
406
215
|
/**
|
|
407
|
-
*
|
|
216
|
+
* ------------------------------------------------------------------------
|
|
217
|
+
* Data Api implementation
|
|
218
|
+
* ------------------------------------------------------------------------
|
|
408
219
|
*/
|
|
409
|
-
|
|
410
220
|
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
411
|
-
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, function (event) {
|
|
412
|
-
const target = getElementFromSelector(this);
|
|
413
|
-
|
|
414
|
-
if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
|
|
415
|
-
return
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
event.preventDefault();
|
|
419
|
-
|
|
420
|
-
const carousel = Carousel.getOrCreateInstance(target);
|
|
421
|
-
const slideIndex = this.getAttribute('data-bs-slide-to');
|
|
422
|
-
|
|
423
|
-
if (slideIndex) {
|
|
424
|
-
carousel.to(slideIndex);
|
|
425
|
-
carousel._maybeEnableCycle();
|
|
426
|
-
return
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
if (Manipulator.getDataAttribute(this, 'slide') === 'next') {
|
|
430
|
-
carousel.next();
|
|
431
|
-
carousel._maybeEnableCycle();
|
|
432
|
-
return
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
carousel.prev();
|
|
436
|
-
carousel._maybeEnableCycle();
|
|
437
|
-
});
|
|
438
|
-
|
|
439
221
|
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
|
|
440
|
-
const carousels = SelectorEngine.find(
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
}
|
|
222
|
+
const carousels = SelectorEngine.find(SELECTOR_CAROUSEL);
|
|
223
|
+
carousels.forEach((carousel) => {
|
|
224
|
+
CarouselBI.getOrCreateInstance(carousel);
|
|
225
|
+
});
|
|
445
226
|
});
|
|
446
227
|
}
|
|
447
228
|
|
|
448
|
-
export {
|
|
229
|
+
export { CarouselBI as default };
|
|
449
230
|
//# sourceMappingURL=carousel.js.map
|