bootstrap-italia 2.13.3 → 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/util/youtube-video.js +1 -2
- package/dist/plugins/util/youtube-video.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/util/youtube-video.js +1 -2
- 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 +3 -3
- 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
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path
|
|
3
|
+
d="m 13.120885,21.853286 c 1.160992,-0.136494 2.152377,-0.421473 3.168213,-0.910717 0.490934,-0.236441 0.716368,-0.365176 1.188481,-0.678689 1.407816,-0.934879 2.533421,-2.187724 3.313746,-3.68834 1.5267,-2.935945 1.473462,-6.507325 -0.140005,-9.3919553 C 20.188273,6.3557303 19.674851,5.6782687 18.995459,4.9986738 18.31786,4.3208738 17.643467,3.8101432 16.810932,3.3442899 15.09102,2.3818962 13.117519,1.9637986 11.12144,2.1389384 8.1055523,2.4035583 5.3709224,4.040957 3.7138912,6.5743147 2.8336618,7.9200562 2.3304663,9.3289241 2.1413606,10.977153 c -0.054873,0.478272 -0.055207,1.541878 -6.38e-4,2.034732 0.2642094,2.386277 1.2678521,4.455384 2.961052,6.104496 1.6485183,1.605596 3.8091959,2.585966 6.1001234,2.767828 0.39729,0.03154 1.54503,0.01306 1.918987,-0.03092 z m 2.720048,-5.186816 c -0.0404,-0.01251 -0.174892,-0.08128 -0.298842,-0.152957 -0.281331,-0.162686 -0.937499,-0.480489 -1.22005,-0.590904 -1.197019,-0.467772 -2.442447,-0.689085 -3.867248,-0.687213 -1.0342399,0.0014 -2.0683112,0.116656 -3.1561659,0.351904 -0.3518688,0.07609 -0.5157442,0.08494 -0.6560686,0.03542 -0.1330592,-0.04695 -0.221875,-0.118841 -0.3163777,-0.256075 -0.1583064,-0.229888 -0.1205593,-0.534587 0.093518,-0.75489 0.1242315,-0.127844 0.2236629,-0.159783 0.9317349,-0.299283 1.9106394,-0.376422 3.6667643,-0.422083 5.3098403,-0.13806 1.024302,0.177061 2.028897,0.506539 2.95429,0.968921 0.788091,0.393778 0.979983,0.555372 1.015481,0.855153 0.02797,0.236266 -0.125421,0.514905 -0.345211,0.627049 -0.107178,0.05468 -0.332838,0.07545 -0.444901,0.04093 z m 1.000017,-2.653097 c -0.04671,-0.0179 -0.174799,-0.08565 -0.284635,-0.150538 C 15.930063,13.492882 15.035523,13.107469 14.270775,12.87811 11.999529,12.196932 9.4512211,12.120483 7.2927877,12.66877 6.6412833,12.834266 6.6283354,12.836399 6.467563,12.804765 6.0905074,12.730575 5.8615047,12.470696 5.8396804,12.092232 c -0.012555,-0.217716 0.045958,-0.386755 0.1889272,-0.545795 0.1375526,-0.153015 0.2678139,-0.217047 0.659837,-0.324354 1.1970677,-0.32767 2.3077203,-0.469622 3.6743964,-0.469622 0.966416,0 1.564514,0.04872 2.49854,0.203538 1.365982,0.226412 2.660863,0.638002 3.799313,1.207648 0.796544,0.398566 1.023298,0.553057 1.127387,0.768109 0.185151,0.382531 0.02931,0.842889 -0.351499,1.038344 -0.146295,0.07509 -0.454275,0.09746 -0.595632,0.04327 z m 1.337758,-3.003555 C 18.107898,10.998198 17.97643,10.948158 17.879866,10.896076 17.522779,10.703488 16.777835,10.34685 16.51209,10.241262 14.052898,9.2641531 10.686796,8.9454149 7.7882028,9.415191 7.433655,9.4726526 6.839179,9.6063546 6.5508827,9.6934736 5.996251,9.8610736 5.6191808,9.7788706 5.3532254,9.4323762 5.2182943,9.2565838 5.1583418,9.0747997 5.1571452,8.8378335 5.1561756,8.6458298 5.1621049,8.6179364 5.2340292,8.4761441 5.3244998,8.2977894 5.5167929,8.1022477 5.686055,8.0164814 5.9951974,7.8598371 7.2630397,7.5840382 8.1330204,7.4841828 9.8787011,7.283816 11.512776,7.2909124 13.209188,7.5062274 c 2.127987,0.2700925 3.98106,0.8335648 5.404268,1.6433011 0.34548,0.1965618 0.461786,0.3032603 0.570605,0.5234771 0.08193,0.165804 0.08656,0.187016 0.08656,0.3959904 0,0.208345 -0.0048,0.23053 -0.0852,0.393213 -0.199309,0.403333 -0.59024,0.61598 -1.006726,0.547609 z" />
|
|
4
|
+
</svg>
|
package/types/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { Accordion } from './plugins/accordion'
|
|
|
3
3
|
import { BackToTop } from './plugins/back-to-top'
|
|
4
4
|
import { Button } from './plugins/button'
|
|
5
5
|
import { Carousel } from './plugins/carousel'
|
|
6
|
-
import { CarouselBI } from './plugins/carousel-bi'
|
|
7
6
|
import { Collapse } from './plugins/collapse'
|
|
8
7
|
import { Cookiebar } from './plugins/cookiebar'
|
|
9
8
|
import { Dimmer } from './plugins/dimmer'
|
|
@@ -46,7 +45,6 @@ export {
|
|
|
46
45
|
BackToTop,
|
|
47
46
|
Button,
|
|
48
47
|
Carousel,
|
|
49
|
-
CarouselBI,
|
|
50
48
|
Collapse,
|
|
51
49
|
Cookiebar,
|
|
52
50
|
Dimmer,
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { default as BaseComponent } from 'bootstrap/js/dist/base-component'
|
|
2
2
|
import { type GetInstanceFactory, type GetOrCreateInstanceFactory } from 'bootstrap/js/dist/base-component';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import Splide from '@splidejs/splide'
|
|
5
|
+
|
|
6
|
+
declare class Carousel extends BaseComponent {
|
|
7
|
+
|
|
5
8
|
/**
|
|
6
9
|
* Static method which allows you to get the instance associated
|
|
7
10
|
* with a DOM element.
|
|
@@ -12,6 +15,43 @@ declare class Carousel extends BSCarousel {
|
|
|
12
15
|
* a DOM element, or create a new one in case it wasn’t initialised
|
|
13
16
|
*/
|
|
14
17
|
static getOrCreateInstance: GetOrCreateInstanceFactory<Carousel>;
|
|
18
|
+
|
|
19
|
+
static get NAME(): string
|
|
20
|
+
|
|
21
|
+
constructor(element: HTMLElement)
|
|
22
|
+
|
|
23
|
+
_config: {
|
|
24
|
+
slideFocus: boolean
|
|
25
|
+
i18n: {
|
|
26
|
+
prev: string
|
|
27
|
+
next: string
|
|
28
|
+
first: string
|
|
29
|
+
last: string
|
|
30
|
+
slideX: string
|
|
31
|
+
pageX: string
|
|
32
|
+
play: string
|
|
33
|
+
pause: string
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
_splide: Splide
|
|
37
|
+
|
|
38
|
+
dispose(): void
|
|
39
|
+
|
|
40
|
+
_init(): void
|
|
41
|
+
|
|
42
|
+
_getConfig(): {
|
|
43
|
+
slideFocus: boolean
|
|
44
|
+
i18n: {
|
|
45
|
+
prev: string
|
|
46
|
+
next: string
|
|
47
|
+
first: string
|
|
48
|
+
last: string
|
|
49
|
+
slideX: string
|
|
50
|
+
pageX: string
|
|
51
|
+
play: string
|
|
52
|
+
pause: string
|
|
53
|
+
}
|
|
54
|
+
}
|
|
15
55
|
}
|
|
16
56
|
|
|
17
57
|
export { Carousel }
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import Splide from '@splidejs/splide';
|
|
2
|
-
import BaseComponent from './base-component.js';
|
|
3
|
-
import SelectorEngine from './dom/selector-engine.js';
|
|
4
|
-
import EventHandler from './dom/event-handler.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* --------------------------------------------------------------------------
|
|
8
|
-
* Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
|
|
9
|
-
* Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS
|
|
10
|
-
* Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)
|
|
11
|
-
* --------------------------------------------------------------------------
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const NAME = 'carousel';
|
|
16
|
-
const DATA_KEY = 'bs.carousel';
|
|
17
|
-
const EVENT_KEY = `.${DATA_KEY}`;
|
|
18
|
-
const DATA_API_KEY = '.data-api';
|
|
19
|
-
|
|
20
|
-
//const EVENT_SCROLL = `scroll${EVENT_KEY}`
|
|
21
|
-
|
|
22
|
-
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`;
|
|
23
|
-
|
|
24
|
-
const SELECTOR_CAROUSEL = '[data-bs-carousel-splide]';
|
|
25
|
-
|
|
26
|
-
const CONFIG_DEFAULT = {
|
|
27
|
-
slideFocus: true,
|
|
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
|
-
},
|
|
38
|
-
};
|
|
39
|
-
const CONFIGS = {
|
|
40
|
-
'it-carousel-landscape-abstract-three-cols': {
|
|
41
|
-
type: 'slide',
|
|
42
|
-
perPage: 3,
|
|
43
|
-
gap: 24,
|
|
44
|
-
padding: { left: 0, right: 0 },
|
|
45
|
-
arrows: false,
|
|
46
|
-
breakpoints: {
|
|
47
|
-
768: {
|
|
48
|
-
perPage: 1,
|
|
49
|
-
gap: 24,
|
|
50
|
-
padding: { left: 0, right: 0 },
|
|
51
|
-
arrows: false,
|
|
52
|
-
},
|
|
53
|
-
992: {
|
|
54
|
-
perPage: 2,
|
|
55
|
-
gap: 24,
|
|
56
|
-
padding: { left: 40, right: 40 },
|
|
57
|
-
arrows: false,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
'it-carousel-landscape-abstract-three-cols-arrow-visible': {
|
|
62
|
-
type: 'slide',
|
|
63
|
-
perPage: 3,
|
|
64
|
-
gap: 24,
|
|
65
|
-
padding: { left: 0, right: 0 },
|
|
66
|
-
arrows: true,
|
|
67
|
-
breakpoints: {
|
|
68
|
-
768: {
|
|
69
|
-
perPage: 1,
|
|
70
|
-
gap: 24,
|
|
71
|
-
padding: { left: 40, right: 40 },
|
|
72
|
-
arrows: true,
|
|
73
|
-
},
|
|
74
|
-
992: {
|
|
75
|
-
perPage: 2,
|
|
76
|
-
gap: 24,
|
|
77
|
-
padding: { left: 40, right: 40 },
|
|
78
|
-
arrows: true,
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
'it-big-img': {
|
|
83
|
-
type: 'loop',
|
|
84
|
-
perPage: 1,
|
|
85
|
-
gap: 48,
|
|
86
|
-
padding: { left: 320, right: 320 },
|
|
87
|
-
arrows: false,
|
|
88
|
-
breakpoints: {
|
|
89
|
-
768: {
|
|
90
|
-
perPage: 1,
|
|
91
|
-
gap: 0,
|
|
92
|
-
padding: { left: 0, right: 0 },
|
|
93
|
-
arrows: false,
|
|
94
|
-
},
|
|
95
|
-
992: {
|
|
96
|
-
perPage: 1,
|
|
97
|
-
gap: 24,
|
|
98
|
-
padding: { left: 160, right: 160 },
|
|
99
|
-
arrows: false,
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
'it-standard-image': {
|
|
104
|
-
type: 'loop',
|
|
105
|
-
perPage: 3,
|
|
106
|
-
gap: 24,
|
|
107
|
-
padding: { left: 48, right: 48 },
|
|
108
|
-
arrows: false,
|
|
109
|
-
breakpoints: {
|
|
110
|
-
768: {
|
|
111
|
-
perPage: 1,
|
|
112
|
-
gap: 24,
|
|
113
|
-
padding: { left: 40, right: 40 },
|
|
114
|
-
arrows: false,
|
|
115
|
-
},
|
|
116
|
-
992: {
|
|
117
|
-
perPage: 2,
|
|
118
|
-
gap: 24,
|
|
119
|
-
padding: { left: 48, right: 48 },
|
|
120
|
-
arrows: false,
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
'it-carousel-landscape-abstract': {
|
|
125
|
-
type: 'slide',
|
|
126
|
-
perPage: 1,
|
|
127
|
-
gap: 24,
|
|
128
|
-
padding: { left: 0, right: 0 },
|
|
129
|
-
arrows: false,
|
|
130
|
-
breakpoints: {
|
|
131
|
-
768: {
|
|
132
|
-
perPage: 1,
|
|
133
|
-
gap: 24,
|
|
134
|
-
padding: { left: 0, right: 0 },
|
|
135
|
-
arrows: false,
|
|
136
|
-
},
|
|
137
|
-
992: {
|
|
138
|
-
perPage: 1,
|
|
139
|
-
gap: 24,
|
|
140
|
-
padding: { left: 24, right: 24 },
|
|
141
|
-
arrows: false,
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
'it-calendar-wrapper': {
|
|
146
|
-
type: 'slide',
|
|
147
|
-
perPage: 4,
|
|
148
|
-
gap: 0,
|
|
149
|
-
padding: { left: 0, right: 0 },
|
|
150
|
-
arrows: false,
|
|
151
|
-
breakpoints: {
|
|
152
|
-
560: {
|
|
153
|
-
perPage: 1,
|
|
154
|
-
gap: 0,
|
|
155
|
-
padding: { left: 24, right: 24 },
|
|
156
|
-
arrows: false,
|
|
157
|
-
},
|
|
158
|
-
768: {
|
|
159
|
-
perPage: 2,
|
|
160
|
-
gap: 0,
|
|
161
|
-
padding: { left: 0, right: 0 },
|
|
162
|
-
arrows: false,
|
|
163
|
-
},
|
|
164
|
-
992: {
|
|
165
|
-
perPage: 3,
|
|
166
|
-
gap: 0,
|
|
167
|
-
padding: { left: 0, right: 0 },
|
|
168
|
-
arrows: false,
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
class CarouselBI extends BaseComponent {
|
|
175
|
-
constructor(element) {
|
|
176
|
-
super(element);
|
|
177
|
-
this._config = this._getConfig();
|
|
178
|
-
this._splide = new Splide(this._element, this._config);
|
|
179
|
-
|
|
180
|
-
this._init();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
dispose() {
|
|
184
|
-
this._splide.destroy();
|
|
185
|
-
super.dispose();
|
|
186
|
-
}
|
|
187
|
-
// Getters
|
|
188
|
-
|
|
189
|
-
static get NAME() {
|
|
190
|
-
return NAME
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// Public
|
|
194
|
-
|
|
195
|
-
// Private
|
|
196
|
-
_init() {
|
|
197
|
-
this._splide.mount();
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
_getConfig() {
|
|
201
|
-
let conf = Object.assign({}, CONFIG_DEFAULT);
|
|
202
|
-
Object.keys(CONFIGS).forEach((classKey) => {
|
|
203
|
-
if (this._element.classList.contains(classKey)) {
|
|
204
|
-
conf = Object.assign({}, conf, CONFIGS[classKey]);
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
return conf
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* ------------------------------------------------------------------------
|
|
213
|
-
* Data Api implementation
|
|
214
|
-
* ------------------------------------------------------------------------
|
|
215
|
-
*/
|
|
216
|
-
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
217
|
-
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
|
|
218
|
-
const carousels = SelectorEngine.find(SELECTOR_CAROUSEL);
|
|
219
|
-
carousels.forEach((carousel) => {
|
|
220
|
-
CarouselBI.getOrCreateInstance(carousel);
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
export { CarouselBI as default };
|
|
226
|
-
//# sourceMappingURL=carousel-bi.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"carousel-bi.js","sources":["../../src/js/plugins/carousel-bi.js"],"sourcesContent":["/**\n * --------------------------------------------------------------------------\n * Bootstrap Italia (https://italia.github.io/bootstrap-italia/)\n * Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS\n * Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport Splide from '@splidejs/splide'\n\nimport BaseComponent from './base-component.js'\nimport SelectorEngine from './dom/selector-engine'\nimport EventHandler from './dom/event-handler'\n\nconst NAME = 'carousel'\nconst DATA_KEY = 'bs.carousel'\nconst EVENT_KEY = `.${DATA_KEY}`\nconst DATA_API_KEY = '.data-api'\n\n//const EVENT_SCROLL = `scroll${EVENT_KEY}`\n\nconst EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`\n\nconst SELECTOR_CAROUSEL = '[data-bs-carousel-splide]'\n\nconst CONFIG_DEFAULT = {\n slideFocus: true,\n i18n: {\n prev: 'Slide precedente',\n next: 'Slide successiva',\n first: 'Vai alla prima slide',\n last: 'Vai all’ultima slide',\n slideX: 'Vai alla slide %s',\n pageX: 'Vai a pagina %s',\n play: 'Attiva autoplay',\n pause: 'Pausa autoplay',\n },\n}\nconst CONFIGS = {\n 'it-carousel-landscape-abstract-three-cols': {\n type: 'slide',\n perPage: 3,\n gap: 24,\n padding: { left: 0, right: 0 },\n arrows: false,\n breakpoints: {\n 768: {\n perPage: 1,\n gap: 24,\n padding: { left: 0, right: 0 },\n arrows: false,\n },\n 992: {\n perPage: 2,\n gap: 24,\n padding: { left: 40, right: 40 },\n arrows: false,\n },\n },\n },\n 'it-carousel-landscape-abstract-three-cols-arrow-visible': {\n type: 'slide',\n perPage: 3,\n gap: 24,\n padding: { left: 0, right: 0 },\n arrows: true,\n breakpoints: {\n 768: {\n perPage: 1,\n gap: 24,\n padding: { left: 40, right: 40 },\n arrows: true,\n },\n 992: {\n perPage: 2,\n gap: 24,\n padding: { left: 40, right: 40 },\n arrows: true,\n },\n },\n },\n 'it-big-img': {\n type: 'loop',\n perPage: 1,\n gap: 48,\n padding: { left: 320, right: 320 },\n arrows: false,\n breakpoints: {\n 768: {\n perPage: 1,\n gap: 0,\n padding: { left: 0, right: 0 },\n arrows: false,\n },\n 992: {\n perPage: 1,\n gap: 24,\n padding: { left: 160, right: 160 },\n arrows: false,\n },\n },\n },\n 'it-standard-image': {\n type: 'loop',\n perPage: 3,\n gap: 24,\n padding: { left: 48, right: 48 },\n arrows: false,\n breakpoints: {\n 768: {\n perPage: 1,\n gap: 24,\n padding: { left: 40, right: 40 },\n arrows: false,\n },\n 992: {\n perPage: 2,\n gap: 24,\n padding: { left: 48, right: 48 },\n arrows: false,\n },\n },\n },\n 'it-carousel-landscape-abstract': {\n type: 'slide',\n perPage: 1,\n gap: 24,\n padding: { left: 0, right: 0 },\n arrows: false,\n breakpoints: {\n 768: {\n perPage: 1,\n gap: 24,\n padding: { left: 0, right: 0 },\n arrows: false,\n },\n 992: {\n perPage: 1,\n gap: 24,\n padding: { left: 24, right: 24 },\n arrows: false,\n },\n },\n },\n 'it-calendar-wrapper': {\n type: 'slide',\n perPage: 4,\n gap: 0,\n padding: { left: 0, right: 0 },\n arrows: false,\n breakpoints: {\n 560: {\n perPage: 1,\n gap: 0,\n padding: { left: 24, right: 24 },\n arrows: false,\n },\n 768: {\n perPage: 2,\n gap: 0,\n padding: { left: 0, right: 0 },\n arrows: false,\n },\n 992: {\n perPage: 3,\n gap: 0,\n padding: { left: 0, right: 0 },\n arrows: false,\n },\n },\n },\n}\n\nclass CarouselBI extends BaseComponent {\n constructor(element) {\n super(element)\n this._config = this._getConfig()\n this._splide = new Splide(this._element, this._config)\n\n this._init()\n }\n\n dispose() {\n this._splide.destroy()\n super.dispose()\n }\n // Getters\n\n static get NAME() {\n return NAME\n }\n\n // Public\n\n // Private\n _init() {\n this._splide.mount()\n }\n\n _getConfig() {\n let conf = Object.assign({}, CONFIG_DEFAULT)\n Object.keys(CONFIGS).forEach((classKey) => {\n if (this._element.classList.contains(classKey)) {\n conf = Object.assign({}, conf, CONFIGS[classKey])\n }\n })\n return conf\n }\n}\n\n/**\n * ------------------------------------------------------------------------\n * Data Api implementation\n * ------------------------------------------------------------------------\n */\nif (typeof window !== 'undefined' && typeof document !== 'undefined') {\n EventHandler.on(window, EVENT_LOAD_DATA_API, () => {\n const carousels = SelectorEngine.find(SELECTOR_CAROUSEL)\n carousels.forEach((carousel) => {\n CarouselBI.getOrCreateInstance(carousel)\n })\n })\n}\n\nexport default CarouselBI\n"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;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ACpC,MAAM,UAAU,CAAC,mBAAmB,CAAC,QAAQ;AAC7C,KAAK;AACL,GAAG;AACH;;;;"}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import Config from './config.js';
|
|
2
|
-
import EventHandler from '../dom/event-handler.js';
|
|
3
|
-
import { execute } from './index.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* --------------------------------------------------------------------------
|
|
7
|
-
* Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
|
|
8
|
-
* Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS
|
|
9
|
-
* Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)
|
|
10
|
-
* This a fork of Bootstrap: Initial license and original file name below
|
|
11
|
-
* Bootstrap (v5.2.3): util/swipe.js
|
|
12
|
-
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
13
|
-
* --------------------------------------------------------------------------
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Constants
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
const NAME = 'swipe';
|
|
22
|
-
const EVENT_KEY = '.bs.swipe';
|
|
23
|
-
const EVENT_TOUCHSTART = `touchstart${EVENT_KEY}`;
|
|
24
|
-
const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY}`;
|
|
25
|
-
const EVENT_TOUCHEND = `touchend${EVENT_KEY}`;
|
|
26
|
-
const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY}`;
|
|
27
|
-
const EVENT_POINTERUP = `pointerup${EVENT_KEY}`;
|
|
28
|
-
const POINTER_TYPE_TOUCH = 'touch';
|
|
29
|
-
const POINTER_TYPE_PEN = 'pen';
|
|
30
|
-
const CLASS_NAME_POINTER_EVENT = 'pointer-event';
|
|
31
|
-
const SWIPE_THRESHOLD = 40;
|
|
32
|
-
|
|
33
|
-
const Default = {
|
|
34
|
-
endCallback: null,
|
|
35
|
-
leftCallback: null,
|
|
36
|
-
rightCallback: null,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const DefaultType = {
|
|
40
|
-
endCallback: '(function|null)',
|
|
41
|
-
leftCallback: '(function|null)',
|
|
42
|
-
rightCallback: '(function|null)',
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Class definition
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
class Swipe extends Config {
|
|
50
|
-
constructor(element, config) {
|
|
51
|
-
super();
|
|
52
|
-
this._element = element;
|
|
53
|
-
|
|
54
|
-
if (!element || !Swipe.isSupported()) {
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
this._config = this._getConfig(config);
|
|
59
|
-
this._deltaX = 0;
|
|
60
|
-
this._supportPointerEvents = Boolean(window.PointerEvent);
|
|
61
|
-
this._initEvents();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Getters
|
|
65
|
-
static get Default() {
|
|
66
|
-
return Default
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
static get DefaultType() {
|
|
70
|
-
return DefaultType
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
static get NAME() {
|
|
74
|
-
return NAME
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Public
|
|
78
|
-
dispose() {
|
|
79
|
-
EventHandler.off(this._element, EVENT_KEY);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Private
|
|
83
|
-
_start(event) {
|
|
84
|
-
if (!this._supportPointerEvents) {
|
|
85
|
-
this._deltaX = event.touches[0].clientX;
|
|
86
|
-
|
|
87
|
-
return
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (this._eventIsPointerPenTouch(event)) {
|
|
91
|
-
this._deltaX = event.clientX;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
_end(event) {
|
|
96
|
-
if (this._eventIsPointerPenTouch(event)) {
|
|
97
|
-
this._deltaX = event.clientX - this._deltaX;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
this._handleSwipe();
|
|
101
|
-
execute(this._config.endCallback);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
_move(event) {
|
|
105
|
-
this._deltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this._deltaX;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
_handleSwipe() {
|
|
109
|
-
const absDeltaX = Math.abs(this._deltaX);
|
|
110
|
-
|
|
111
|
-
if (absDeltaX <= SWIPE_THRESHOLD) {
|
|
112
|
-
return
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const direction = absDeltaX / this._deltaX;
|
|
116
|
-
|
|
117
|
-
this._deltaX = 0;
|
|
118
|
-
|
|
119
|
-
if (!direction) {
|
|
120
|
-
return
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
_initEvents() {
|
|
127
|
-
if (this._supportPointerEvents) {
|
|
128
|
-
EventHandler.on(this._element, EVENT_POINTERDOWN, (event) => this._start(event));
|
|
129
|
-
EventHandler.on(this._element, EVENT_POINTERUP, (event) => this._end(event));
|
|
130
|
-
|
|
131
|
-
this._element.classList.add(CLASS_NAME_POINTER_EVENT);
|
|
132
|
-
} else {
|
|
133
|
-
EventHandler.on(this._element, EVENT_TOUCHSTART, (event) => this._start(event));
|
|
134
|
-
EventHandler.on(this._element, EVENT_TOUCHMOVE, (event) => this._move(event));
|
|
135
|
-
EventHandler.on(this._element, EVENT_TOUCHEND, (event) => this._end(event));
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
_eventIsPointerPenTouch(event) {
|
|
140
|
-
return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Static
|
|
144
|
-
static isSupported() {
|
|
145
|
-
return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export { Swipe as default };
|
|
150
|
-
//# sourceMappingURL=swipe.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"swipe.js","sources":["../../../src/js/plugins/util/swipe.js"],"sourcesContent":["/**\n * --------------------------------------------------------------------------\n * Bootstrap Italia (https://italia.github.io/bootstrap-italia/)\n * Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS\n * Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)\n * This a fork of Bootstrap: Initial license and original file name below\n * Bootstrap (v5.2.3): util/swipe.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport Config from './config'\nimport EventHandler from '../dom/event-handler'\nimport { execute } from './index'\n\n/**\n * Constants\n */\n\nconst NAME = 'swipe'\nconst EVENT_KEY = '.bs.swipe'\nconst EVENT_TOUCHSTART = `touchstart${EVENT_KEY}`\nconst EVENT_TOUCHMOVE = `touchmove${EVENT_KEY}`\nconst EVENT_TOUCHEND = `touchend${EVENT_KEY}`\nconst EVENT_POINTERDOWN = `pointerdown${EVENT_KEY}`\nconst EVENT_POINTERUP = `pointerup${EVENT_KEY}`\nconst POINTER_TYPE_TOUCH = 'touch'\nconst POINTER_TYPE_PEN = 'pen'\nconst CLASS_NAME_POINTER_EVENT = 'pointer-event'\nconst SWIPE_THRESHOLD = 40\n\nconst Default = {\n endCallback: null,\n leftCallback: null,\n rightCallback: null,\n}\n\nconst DefaultType = {\n endCallback: '(function|null)',\n leftCallback: '(function|null)',\n rightCallback: '(function|null)',\n}\n\n/**\n * Class definition\n */\n\nclass Swipe extends Config {\n constructor(element, config) {\n super()\n this._element = element\n\n if (!element || !Swipe.isSupported()) {\n return\n }\n\n this._config = this._getConfig(config)\n this._deltaX = 0\n this._supportPointerEvents = Boolean(window.PointerEvent)\n this._initEvents()\n }\n\n // Getters\n static get Default() {\n return Default\n }\n\n static get DefaultType() {\n return DefaultType\n }\n\n static get NAME() {\n return NAME\n }\n\n // Public\n dispose() {\n EventHandler.off(this._element, EVENT_KEY)\n }\n\n // Private\n _start(event) {\n if (!this._supportPointerEvents) {\n this._deltaX = event.touches[0].clientX\n\n return\n }\n\n if (this._eventIsPointerPenTouch(event)) {\n this._deltaX = event.clientX\n }\n }\n\n _end(event) {\n if (this._eventIsPointerPenTouch(event)) {\n this._deltaX = event.clientX - this._deltaX\n }\n\n this._handleSwipe()\n execute(this._config.endCallback)\n }\n\n _move(event) {\n this._deltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this._deltaX\n }\n\n _handleSwipe() {\n const absDeltaX = Math.abs(this._deltaX)\n\n if (absDeltaX <= SWIPE_THRESHOLD) {\n return\n }\n\n const direction = absDeltaX / this._deltaX\n\n this._deltaX = 0\n\n if (!direction) {\n return\n }\n\n execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback)\n }\n\n _initEvents() {\n if (this._supportPointerEvents) {\n EventHandler.on(this._element, EVENT_POINTERDOWN, (event) => this._start(event))\n EventHandler.on(this._element, EVENT_POINTERUP, (event) => this._end(event))\n\n this._element.classList.add(CLASS_NAME_POINTER_EVENT)\n } else {\n EventHandler.on(this._element, EVENT_TOUCHSTART, (event) => this._start(event))\n EventHandler.on(this._element, EVENT_TOUCHMOVE, (event) => this._move(event))\n EventHandler.on(this._element, EVENT_TOUCHEND, (event) => this._end(event))\n }\n }\n\n _eventIsPointerPenTouch(event) {\n return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)\n }\n\n // Static\n static isSupported() {\n return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0\n }\n}\n\nexport default Swipe\n"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AAC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