@scrippsproduct/networks-ui-library 1.0.17-dev.1 → 1.0.18-dev.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/Carousel.module-DOrBKQEQ.mjs +14 -0
- package/dist/assets/Carousel.css +1 -1
- package/dist/components/Carousel/Carousel.d.ts +0 -1
- package/dist/components/Carousel/Carousel.js +158 -148
- package/dist/components/Carousel/CarouselUtils.class.js +78 -79
- package/dist/components/Carousel/navigations/Pagination.js +1 -1
- package/package.json +1 -1
- package/dist/Carousel.module-CzL9vVtu.mjs +0 -14
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import './assets/Carousel.css';const _ = "_carousel_60lzn_1", l = "_carousel__scroller_60lzn_11", o = {
|
|
2
|
+
carousel: _,
|
|
3
|
+
carousel__scroller: l,
|
|
4
|
+
"carousel-controls": "_carousel-controls_60lzn_38",
|
|
5
|
+
"carousel-controls__btn": "_carousel-controls__btn_60lzn_42",
|
|
6
|
+
"carousel-controls__previous": "_carousel-controls__previous_60lzn_67",
|
|
7
|
+
"carousel-controls__next": "_carousel-controls__next_60lzn_74",
|
|
8
|
+
"carousel-nav": "_carousel-nav_60lzn_86",
|
|
9
|
+
"carousel-nav__list": "_carousel-nav__list_60lzn_90",
|
|
10
|
+
"carousel-nav__item": "_carousel-nav__item_60lzn_99"
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
o as c
|
|
14
|
+
};
|
package/dist/assets/Carousel.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._carousel_60lzn_1{--_carousel-scrollbar-gutter: 1.75rem;--_carousel-pagination-size: 1rem;--_slide-gap: 1.5rem;position:relative;display:grid;grid-template-columns:1fr;grid-template-rows:[carousel-scroller] 1fr [carousel-pagination]}._carousel__scroller_60lzn_11{display:flex;box-sizing:border-box;overflow-x:auto;scroll-behavior:smooth;overscroll-behavior-x:contain;scroll-snap-type:x mandatory;scroll-padding-inline:var(--_carousel-gutters);padding-inline:var(--_carousel-gutters);scrollbar-width:none;list-style:none;margin:0}._carousel__scroller_60lzn_11[data-scrollbar=true]{scrollbar-width:auto;overflow-x:scroll}._carousel__scroller_60lzn_11:not([data-scrollbar=true])::-webkit-scrollbar{display:none}._carousel__scroller_60lzn_11::-webkit-scrollbar{display:auto}._carousel-controls_60lzn_38{display:contents}._carousel-controls__btn_60lzn_42{position:absolute;top:50%;transform:translateY(var(--_controls-transform));border-radius:50%;background-color:#fff6;color:#000;aspect-ratio:1;border:1px solid transparent;padding:0;overflow:hidden;z-index:1;cursor:pointer;transition:opacity .325s ease-out}._carousel-controls__btn_60lzn_42>i>svg{display:block;block-size:auto;max-inline-size:100%;stroke:currentColor}._carousel-controls__btn_60lzn_42[disabled]{opacity:0}._carousel-controls__previous_60lzn_67{inset-inline-start:var(--_control-btns-offset-x)}._carousel-controls__previous_60lzn_67 svg{transform:translate(-2px)}._carousel-controls__next_60lzn_74{inset-inline-end:var(--_control-btns-offset-x)}._carousel-controls__next_60lzn_74 svg{transform:translate(2px)}._carousel-controls__btn_60lzn_42[disabled]{cursor:not-allowed;transition-delay:0s}._carousel-nav_60lzn_86{margin-top:0}._carousel-nav__list_60lzn_90{display:flex;gap:1rem;justify-content:center;align-items:flex-start;list-style:none;padding:0}._carousel-nav__item_60lzn_99{flex-basis:1rem;min-width:1rem;max-width:1rem;height:1rem;background-color:transparent;border-radius:50%;border:1px solid rgba(65,65,65,.1)}._carousel-nav__item_60lzn_99[data-current=true]{background-color:#8080801a}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as c, useState as
|
|
3
|
-
import
|
|
4
|
-
import { CarouselSlide as
|
|
5
|
-
import { chunkArray as
|
|
6
|
-
import { c as
|
|
7
|
-
import { C as
|
|
8
|
-
import { C as
|
|
9
|
-
const
|
|
10
|
-
function
|
|
11
|
-
id:
|
|
12
|
-
slides:
|
|
13
|
-
options:
|
|
1
|
+
import { jsx as s, Fragment as ee, jsxs as G } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as c, useState as v, useEffect as H, useCallback as f } from "react";
|
|
3
|
+
import re from "./CarouselUtils.class.js";
|
|
4
|
+
import { CarouselSlide as te } from "../CarouselSlide/CarouselSlide.js";
|
|
5
|
+
import { chunkArray as ne, classes as E } from "../../utils/helpers.js";
|
|
6
|
+
import { c as i } from "../../Carousel.module-DOrBKQEQ.mjs";
|
|
7
|
+
import { C as le } from "../../chevron-left-DmvQntvu.mjs";
|
|
8
|
+
import { C as oe } from "../../chevron-right-CaAz6ISN.mjs";
|
|
9
|
+
const x = window.matchMedia("(width <= 600px)"), L = window.matchMedia("(width <= 800px"), R = window.matchMedia("(width <= 1024px"), I = window.matchMedia("(width <= 1280px");
|
|
10
|
+
function pe({
|
|
11
|
+
id: C,
|
|
12
|
+
slides: $,
|
|
13
|
+
options: P = {
|
|
14
14
|
paginationType: "dots",
|
|
15
15
|
showControls: !0,
|
|
16
16
|
controlArrowSize: 48,
|
|
@@ -28,267 +28,277 @@ function de({
|
|
|
28
28
|
cellsPerSlide: 1,
|
|
29
29
|
cellAspectRatio: "4/2",
|
|
30
30
|
cellsPosition: "center",
|
|
31
|
-
groupSlides: !0,
|
|
32
31
|
wrapAround: !0
|
|
33
32
|
}
|
|
34
33
|
}) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
console.log(`Carousel component with id: ${C} initialized`);
|
|
35
|
+
const w = c(`carousel-${C}`), T = c(null), u = c(null), N = c(null), g = c($), M = c(null), y = c(null), r = c(null), e = c(P), o = c(P), U = c(P.showPagination), k = c("-50%"), [O, F] = v([]), [t, d] = v(null), [D, W] = v([]), [V, q] = v(0);
|
|
36
|
+
H(() => {
|
|
37
|
+
const n = () => {
|
|
38
|
+
x.matches ? (d({
|
|
39
|
+
...o.current,
|
|
40
40
|
showControls: !1,
|
|
41
41
|
showPagination: !1,
|
|
42
42
|
cellsPerSlide: 1,
|
|
43
|
-
cellsPosition:
|
|
43
|
+
cellsPosition: o.current.wrapAround ? "center" : "flex-start",
|
|
44
44
|
gutterSize: 10
|
|
45
45
|
}), e.current = {
|
|
46
|
-
...
|
|
46
|
+
...o.current,
|
|
47
47
|
showControls: !1,
|
|
48
48
|
showPagination: !1,
|
|
49
49
|
cellsPerSlide: 1,
|
|
50
|
-
cellsPosition:
|
|
50
|
+
cellsPosition: o.current.wrapAround ? "center" : "flex-start",
|
|
51
51
|
gutterSize: 10
|
|
52
|
-
}
|
|
53
|
-
...
|
|
52
|
+
}) : L.matches ? o.current.cellsPerSlide !== 1 ? (d({
|
|
53
|
+
...o.current,
|
|
54
54
|
cellsPerSlide: 2,
|
|
55
55
|
showControls: !1,
|
|
56
56
|
gutterSize: 10
|
|
57
57
|
}), e.current = {
|
|
58
|
-
...
|
|
58
|
+
...o.current,
|
|
59
59
|
cellsPerSlide: 2,
|
|
60
60
|
showControls: !1,
|
|
61
61
|
gutterSize: 10
|
|
62
62
|
}) : (d({
|
|
63
|
-
...
|
|
63
|
+
...o.current,
|
|
64
64
|
showControls: !1,
|
|
65
65
|
gutterSize: 10
|
|
66
66
|
}), e.current = {
|
|
67
|
-
...
|
|
67
|
+
...o.current,
|
|
68
68
|
showControls: !1,
|
|
69
69
|
gutterSize: 10
|
|
70
|
-
}) :
|
|
71
|
-
...
|
|
70
|
+
}) : R.matches ? o.current.cellsPerSlide !== 1 && o.current.cellsPerSlide !== 2 ? (d({
|
|
71
|
+
...o.current,
|
|
72
72
|
cellsPerSlide: 3,
|
|
73
73
|
showControls: !1,
|
|
74
74
|
gutterSize: 10
|
|
75
75
|
}), e.current = {
|
|
76
|
-
...
|
|
76
|
+
...o.current,
|
|
77
77
|
cellsPerSlide: 3,
|
|
78
78
|
showControls: !1,
|
|
79
79
|
gutterSize: 10
|
|
80
80
|
}) : (d({
|
|
81
|
-
...
|
|
81
|
+
...o.current,
|
|
82
82
|
showControls: !1,
|
|
83
83
|
gutterSize: 10
|
|
84
84
|
}), e.current = {
|
|
85
|
-
...
|
|
85
|
+
...o.current,
|
|
86
86
|
showControls: !1,
|
|
87
87
|
gutterSize: 10
|
|
88
|
-
}) :
|
|
89
|
-
...
|
|
88
|
+
}) : I.matches ? o.current.showPagination ? (d({
|
|
89
|
+
...o.current,
|
|
90
90
|
showControls: !1
|
|
91
91
|
}), e.current = {
|
|
92
|
-
...
|
|
92
|
+
...o.current,
|
|
93
93
|
showControls: !1
|
|
94
|
-
}) : d({
|
|
95
|
-
...
|
|
94
|
+
}) : (d({
|
|
95
|
+
...o.current
|
|
96
|
+
}), e.current = {
|
|
97
|
+
...o.current
|
|
98
|
+
}) : (d({
|
|
99
|
+
...o.current
|
|
100
|
+
}), e.current = {
|
|
101
|
+
...o.current
|
|
96
102
|
});
|
|
97
|
-
}
|
|
103
|
+
};
|
|
104
|
+
n();
|
|
105
|
+
const l = () => {
|
|
106
|
+
q((h) => h + 1), n();
|
|
107
|
+
};
|
|
108
|
+
return x.addEventListener("change", l), L.addEventListener("change", l), R.addEventListener("change", l), I.addEventListener("change", l), () => {
|
|
109
|
+
x.removeEventListener("change", l), L.removeEventListener("change", l), R.removeEventListener("change", l), I.removeEventListener("change", l);
|
|
110
|
+
};
|
|
98
111
|
}, []);
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
let
|
|
103
|
-
for (let
|
|
104
|
-
|
|
105
|
-
for (let S = 0; S <=
|
|
106
|
-
|
|
107
|
-
props:
|
|
112
|
+
const j = f((n, l) => {
|
|
113
|
+
const h = ne(l, n);
|
|
114
|
+
W([...h]);
|
|
115
|
+
let p = [];
|
|
116
|
+
for (let a = 0; a <= h.length - 1; a++) {
|
|
117
|
+
p[a] = {}, p[a].ariaLabel = `${a + 1} of ${h.length}`, p[a].layout = h[a][0].layout, p[a].cells = [];
|
|
118
|
+
for (let S = 0; S <= h[a].length - 1; S++)
|
|
119
|
+
p[a].cells[S] = {
|
|
120
|
+
props: h[a][S].props
|
|
108
121
|
};
|
|
109
122
|
}
|
|
110
|
-
const
|
|
111
|
-
return
|
|
112
|
-
}, []),
|
|
113
|
-
e.current.autoplay &&
|
|
114
|
-
}, []),
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
}, [
|
|
119
|
-
|
|
120
|
-
|
|
123
|
+
const _ = [...p], b = [...p], Y = _.slice(-1), Z = _.slice(0);
|
|
124
|
+
return b.push(Z[0]), b.unshift(Y[0]), e.current.wrapAround && n.length > l ? b : _;
|
|
125
|
+
}, []), m = f(() => {
|
|
126
|
+
e.current.autoplay && r.current.clearTimer();
|
|
127
|
+
}, []), J = f((n) => {
|
|
128
|
+
m();
|
|
129
|
+
const l = n.key;
|
|
130
|
+
l === "ArrowLeft" ? (n.preventDefault(), r.current.determineScrollAction(-1)) : l === "ArrowRight" && (n.preventDefault(), r.current.determineScrollAction(1));
|
|
131
|
+
}, [m]), Q = f(() => {
|
|
132
|
+
m(), u.current.addEventListener("scrollend", () => {
|
|
133
|
+
r.current.handleScrollEnd();
|
|
121
134
|
}, { once: !0 });
|
|
122
|
-
}, [
|
|
123
|
-
|
|
124
|
-
|
|
135
|
+
}, [m]), A = f(() => {
|
|
136
|
+
m(), u.current.addEventListener("scrollend", () => {
|
|
137
|
+
r.current.handleScrollEnd(), u.current.addEventListener("scroll", A, { once: !0 });
|
|
125
138
|
}, { once: !0 });
|
|
126
|
-
}, [
|
|
127
|
-
|
|
128
|
-
},
|
|
139
|
+
}, [m]), X = () => {
|
|
140
|
+
r.current && e.current.autoplay && r.current.clearTimer();
|
|
141
|
+
}, z = f(() => {
|
|
129
142
|
//! make sure class is only instantiated once because of reacts
|
|
130
143
|
//! "strict" mode double do hocus pocus
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
144
|
+
var n, l;
|
|
145
|
+
r.current !== null && V > 0 && ((l = (n = r.current).clearTimer) == null || l.call(n), r.current = null), r.current = new re({
|
|
146
|
+
carouselEl: T.current,
|
|
147
|
+
scrollerEl: u.current,
|
|
148
|
+
paginationEl: N.current,
|
|
149
|
+
slides: g.current,
|
|
136
150
|
navBtnEls: {
|
|
137
|
-
next:
|
|
138
|
-
previous:
|
|
151
|
+
next: M.current,
|
|
152
|
+
previous: y.current
|
|
139
153
|
},
|
|
140
|
-
id:
|
|
154
|
+
id: w.current,
|
|
141
155
|
options: {
|
|
142
156
|
autoplay: e.current.autoplay,
|
|
143
|
-
wrapAround: e.current.wrapAround &&
|
|
157
|
+
wrapAround: e.current.wrapAround && g.current.length > e.current.cellsPerSlide,
|
|
144
158
|
showPagination: e.current.showPagination,
|
|
145
159
|
delay: e.current.autoplayDelay,
|
|
146
160
|
slideGutterSize: e.current.gutterSize,
|
|
147
161
|
slideAspectRatio: e.current.slideAspectRatio,
|
|
148
|
-
showControls: e.current.showControls &&
|
|
162
|
+
showControls: e.current.showControls && g.current.length > e.current.cellsPerSlide,
|
|
149
163
|
cellsPerSlide: e.current.cellsPerSlide
|
|
150
164
|
}
|
|
151
|
-
})
|
|
152
|
-
}, []),
|
|
153
|
-
|
|
154
|
-
}, [
|
|
155
|
-
if (j(
|
|
156
|
-
let
|
|
157
|
-
|
|
165
|
+
});
|
|
166
|
+
}, [V]), K = f(() => {
|
|
167
|
+
u.current.addEventListener("scroll", A, { once: !0 });
|
|
168
|
+
}, [A]), B = f(() => {
|
|
169
|
+
if (F(j(g.current, e.current.cellsPerSlide)), g.current.length > e.current.cellsPerSlide) {
|
|
170
|
+
let n = setInterval(() => {
|
|
171
|
+
u.current !== null && (y.current !== null && e.current.showControls || !e.current.showControls) && (clearInterval(n), K(), z());
|
|
158
172
|
}, 100);
|
|
159
173
|
} else {
|
|
160
|
-
let
|
|
161
|
-
|
|
174
|
+
let n = setInterval(() => {
|
|
175
|
+
u.current !== null && (clearInterval(n), z());
|
|
162
176
|
}, 100);
|
|
163
177
|
}
|
|
164
|
-
}, [
|
|
165
|
-
return
|
|
166
|
-
if (
|
|
167
|
-
if (
|
|
168
|
-
let
|
|
169
|
-
|
|
178
|
+
}, [j, K, z]);
|
|
179
|
+
return H(() => {
|
|
180
|
+
if (t !== null) {
|
|
181
|
+
if (t.showControls) {
|
|
182
|
+
let n = 0;
|
|
183
|
+
t.showPagination && (n = n + 25), t.showScrollbar && (n = n + 6), k.current = `calc(-50% - ${n}px)`;
|
|
170
184
|
}
|
|
171
|
-
|
|
185
|
+
B();
|
|
172
186
|
}
|
|
173
187
|
return () => {
|
|
174
|
-
|
|
188
|
+
X();
|
|
175
189
|
};
|
|
176
|
-
}, [
|
|
190
|
+
}, [B, t]), /* @__PURE__ */ s(ee, { children: t !== null && /* @__PURE__ */ G(
|
|
177
191
|
"div",
|
|
178
192
|
{
|
|
179
|
-
className:
|
|
180
|
-
id:
|
|
181
|
-
ref:
|
|
193
|
+
className: i.carousel,
|
|
194
|
+
id: w.current,
|
|
195
|
+
ref: T,
|
|
182
196
|
tabIndex: -1,
|
|
183
197
|
role: "region",
|
|
184
198
|
"aria-roledescription": "carousel",
|
|
185
|
-
"aria-label":
|
|
186
|
-
onKeyDown:
|
|
199
|
+
"aria-label": t.title,
|
|
200
|
+
onKeyDown: J,
|
|
187
201
|
style: {
|
|
188
|
-
"--_carousel-gutters":
|
|
189
|
-
"--_slide-aspect-ratio":
|
|
190
|
-
"--_cell-aspect-ratio":
|
|
191
|
-
"--_slide-cell-size": `${100 /
|
|
192
|
-
"--_cells-position":
|
|
193
|
-
"--_control-btns-offset-x": `${
|
|
194
|
-
"--_slide-gap": `${
|
|
195
|
-
"--_controls-transform":
|
|
202
|
+
"--_carousel-gutters": t.wrapAround ? `${t.gutterSize <= 25 ? t.gutterSize : 25}%` : `0 ${t.gutterSize <= 25 ? t.gutterSize : 25}%`,
|
|
203
|
+
"--_slide-aspect-ratio": t.slideAspectRatio,
|
|
204
|
+
"--_cell-aspect-ratio": t.cellAspectRatio,
|
|
205
|
+
"--_slide-cell-size": `${100 / t.cellsPerSlide}%`,
|
|
206
|
+
"--_cells-position": t.cellsPosition,
|
|
207
|
+
"--_control-btns-offset-x": `${t.controlButtonsOffset}rem`,
|
|
208
|
+
"--_slide-gap": `${t.slideGap}rem`,
|
|
209
|
+
"--_controls-transform": k.current
|
|
196
210
|
},
|
|
197
211
|
children: [
|
|
198
|
-
/* @__PURE__ */
|
|
212
|
+
/* @__PURE__ */ s(
|
|
199
213
|
"ol",
|
|
200
214
|
{
|
|
201
|
-
className:
|
|
202
|
-
ref:
|
|
215
|
+
className: i.carousel__scroller,
|
|
216
|
+
ref: u,
|
|
203
217
|
role: "group",
|
|
204
218
|
"aria-label": "Items Scroller",
|
|
205
219
|
"aria-live": "Polite",
|
|
206
220
|
tabIndex: 0,
|
|
207
221
|
onMouseEnter: () => {
|
|
208
|
-
e.current.autoplay &&
|
|
222
|
+
e.current.autoplay && r.current !== null && r.current.clearTimer();
|
|
209
223
|
},
|
|
210
224
|
onMouseLeave: () => {
|
|
211
|
-
e.current.autoplay &&
|
|
225
|
+
e.current.autoplay && r.current !== null && r.current.startTimer();
|
|
212
226
|
},
|
|
213
|
-
onTouchStart:
|
|
214
|
-
"data-scrollbar":
|
|
215
|
-
children:
|
|
216
|
-
|
|
227
|
+
onTouchStart: Q,
|
|
228
|
+
"data-scrollbar": t.showScrollbar,
|
|
229
|
+
children: O.length > 0 && O.map((n, l) => /* @__PURE__ */ s(
|
|
230
|
+
te,
|
|
217
231
|
{
|
|
218
|
-
slide:
|
|
219
|
-
index:
|
|
220
|
-
currentIndex:
|
|
221
|
-
variableHeight:
|
|
232
|
+
slide: n,
|
|
233
|
+
index: l,
|
|
234
|
+
currentIndex: t.wrapAround ? 1 : 0,
|
|
235
|
+
variableHeight: t.variableHeight
|
|
222
236
|
},
|
|
223
|
-
`carousel${
|
|
237
|
+
`carousel${C}-slide${l}`
|
|
224
238
|
))
|
|
225
239
|
}
|
|
226
240
|
),
|
|
227
|
-
|
|
228
|
-
/* @__PURE__ */
|
|
241
|
+
t.showControls && $.length > e.current.cellsPerSlide && /* @__PURE__ */ G("div", { className: i["carousel-controls"], children: [
|
|
242
|
+
/* @__PURE__ */ s(
|
|
229
243
|
"button",
|
|
230
244
|
{
|
|
231
245
|
type: "button",
|
|
232
|
-
ref:
|
|
246
|
+
ref: y,
|
|
233
247
|
title: "Previous Item",
|
|
234
|
-
className:
|
|
235
|
-
|
|
236
|
-
a["carousel-controls__previous"],
|
|
237
|
-
"carousel-controls__previous"
|
|
238
|
-
]),
|
|
239
|
-
"aria-controls": m.current,
|
|
248
|
+
className: E([i["carousel-controls__btn"], i["carousel-controls__previous"], "carousel-controls__previous"]),
|
|
249
|
+
"aria-controls": w.current,
|
|
240
250
|
"aria-label": "Previous Item",
|
|
241
251
|
onClick: () => {
|
|
242
|
-
|
|
252
|
+
r.current.determineScrollAction(-1);
|
|
243
253
|
},
|
|
244
254
|
onMouseEnter: () => {
|
|
245
|
-
e.current.autoplay &&
|
|
255
|
+
e.current.autoplay && r.current !== null && r.current.clearTimer();
|
|
246
256
|
},
|
|
247
257
|
onMouseLeave: () => {
|
|
248
|
-
e.current.autoplay &&
|
|
258
|
+
e.current.autoplay && r.current !== null && r.current.startTimer();
|
|
249
259
|
},
|
|
250
|
-
children: /* @__PURE__ */
|
|
260
|
+
children: /* @__PURE__ */ s("i", { "aria-hidden": "true", children: /* @__PURE__ */ s(le, { width: t.controlArrowSize, height: t.controlArrowSize }) })
|
|
251
261
|
}
|
|
252
262
|
),
|
|
253
|
-
/* @__PURE__ */
|
|
263
|
+
/* @__PURE__ */ s(
|
|
254
264
|
"button",
|
|
255
265
|
{
|
|
256
266
|
type: "button",
|
|
257
|
-
ref:
|
|
267
|
+
ref: M,
|
|
258
268
|
title: "Next Item",
|
|
259
|
-
className:
|
|
260
|
-
"aria-controls":
|
|
269
|
+
className: E([i["carousel-controls__btn"], i["carousel-controls__next"], "carousel-controls__next"]),
|
|
270
|
+
"aria-controls": w.current,
|
|
261
271
|
"aria-label": "Next Item",
|
|
262
272
|
onClick: () => {
|
|
263
|
-
|
|
273
|
+
r.current.determineScrollAction(1);
|
|
264
274
|
},
|
|
265
275
|
onMouseEnter: () => {
|
|
266
|
-
e.current.autoplay &&
|
|
276
|
+
e.current.autoplay && r.current !== null && r.current.clearTimer();
|
|
267
277
|
},
|
|
268
278
|
onMouseLeave: () => {
|
|
269
|
-
e.current.autoplay &&
|
|
279
|
+
e.current.autoplay && r.current !== null && r.current.startTimer();
|
|
270
280
|
},
|
|
271
|
-
children: /* @__PURE__ */
|
|
281
|
+
children: /* @__PURE__ */ s("i", { "aria-hidden": "true", children: /* @__PURE__ */ s(oe, { width: t.controlArrowSize, height: t.controlArrowSize }) })
|
|
272
282
|
}
|
|
273
283
|
)
|
|
274
284
|
] }),
|
|
275
|
-
|
|
285
|
+
U.current && D.length > 1 && /* @__PURE__ */ s("div", { className: [i["carousel-nav"], "carousel-nav"].join(" "), children: /* @__PURE__ */ s("ol", { className: i["carousel-nav__list"], ref: N, children: D.map((n, l) => /* @__PURE__ */ s(
|
|
276
286
|
"li",
|
|
277
287
|
{
|
|
278
|
-
className:
|
|
279
|
-
"data-current":
|
|
288
|
+
className: E([i["carousel-nav__item"], "carousel-nav__item"]),
|
|
289
|
+
"data-current": l === 0 ? "true" : "false",
|
|
280
290
|
onClick: () => {
|
|
281
|
-
|
|
291
|
+
r.current.navigateToIndex(l);
|
|
282
292
|
},
|
|
283
|
-
title: `Navigate to slide ${
|
|
293
|
+
title: `Navigate to slide ${l + 1}`
|
|
284
294
|
},
|
|
285
|
-
`carousel${
|
|
295
|
+
`carousel${w}-nav-${l}`
|
|
286
296
|
)) }) })
|
|
287
297
|
]
|
|
288
298
|
}
|
|
289
299
|
) });
|
|
290
300
|
}
|
|
291
301
|
export {
|
|
292
|
-
|
|
293
|
-
|
|
302
|
+
pe as Carousel,
|
|
303
|
+
pe as default
|
|
294
304
|
};
|
|
@@ -1,55 +1,54 @@
|
|
|
1
|
-
var
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var g = (r) => {
|
|
2
|
+
throw TypeError(r);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var i = (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
let
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
this.carouselEl = t, this.scrollerEl = s, this.paginationEl = a, this.slides = O, this.currentIndex = 0, this.slideEls = [...s.children], this.navBtnEls = P, this.currentIntersecting = {}, this.options = n, n.autoplay && (this.timer = null, this.timerInterval = (n == null ? void 0 : n.delay) ?? 3500, this.startTimer()), this.slideGutterSize = (n == null ? void 0 : n.slideGutterSize) ?? 25, this.showPagination = n == null ? void 0 : n.showPagination, this.isInitialScroll = !0, this.totalSlideEls = this.slideEls.length, this.totalSlides = Math.ceil(this.slides.length / this.options.cellsPerSlide), i(this, e, T).call(this), i(this, e, L).call(this), i(this, e, S).call(this);
|
|
4
|
+
var L = (r, t, e) => t.has(r) || g("Cannot " + e);
|
|
5
|
+
var b = (r, t, e) => t.has(r) ? g("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e);
|
|
6
|
+
var i = (r, t, e) => (L(r, t, "access private method"), e);
|
|
7
|
+
let u = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
const B = new Event("scrollend"), p = /* @__PURE__ */ new Set();
|
|
9
|
+
function o(r, t, e) {
|
|
10
|
+
let l = r[t];
|
|
11
|
+
r[t] = function() {
|
|
12
|
+
let a = Array.prototype.slice.apply(arguments, [0]);
|
|
13
|
+
l.apply(this, a), a.unshift(l), e.apply(this, a);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function E(r, t) {
|
|
17
|
+
if (t !== "scroll" && t !== "scrollend")
|
|
18
|
+
return;
|
|
19
|
+
let e = u.get(this);
|
|
20
|
+
if (e === void 0) {
|
|
21
|
+
let l = 0;
|
|
22
|
+
e = {
|
|
23
|
+
scrollListener: () => {
|
|
24
|
+
clearTimeout(l), l = setTimeout(() => {
|
|
25
|
+
p.size ? setTimeout(e.scrollListener, 100) : (this.dispatchEvent(B), l = 0);
|
|
26
|
+
}, 100);
|
|
27
|
+
},
|
|
28
|
+
listeners: 0
|
|
29
|
+
// Count of number of listeners.
|
|
30
|
+
}, r.apply(this, ["scroll", e.scrollListener]), u.set(this, e);
|
|
31
|
+
}
|
|
32
|
+
e.listeners++;
|
|
33
|
+
}
|
|
34
|
+
function m(r, t) {
|
|
35
|
+
if (t !== "scroll" && t !== "scrollend")
|
|
36
|
+
return;
|
|
37
|
+
let e = u.get(this);
|
|
38
|
+
e !== void 0 && (e[t]--, !(--e.listeners > 0) && (r.apply(this, ["scroll", e.scrollListener]), u.delete(this)));
|
|
39
|
+
}
|
|
40
|
+
const z = "onscrollend" in window;
|
|
41
|
+
var s, x, A, w, d, h, c, y, I, T;
|
|
42
|
+
class P {
|
|
43
|
+
constructor({ carouselEl: t, scrollerEl: e, paginationEl: l, slides: a, navBtnEls: S = { next: {}, previous: {} }, options: n }) {
|
|
44
|
+
b(this, s);
|
|
45
|
+
z || (document.addEventListener("touchstart", (f) => {
|
|
46
|
+
for (let v of f.changedTouches)
|
|
47
|
+
p.add(v.identifier);
|
|
48
|
+
}, { passive: !0 }), document.addEventListener("touchend", (f) => {
|
|
49
|
+
for (let v of f.changedTouches)
|
|
50
|
+
p.delete(v.identifier);
|
|
51
|
+
}, { passive: !0 }), o(Element.prototype, "addEventListener", E), o(window, "addEventListener", E), o(document, "addEventListener", E), o(Element.prototype, "removeEventListener", m), o(window, "removeEventListener", m), o(document, "removeEventListener", m)), this.carouselEl = t, this.scrollerEl = e, this.paginationEl = l, this.slides = a, this.currentIndex = 0, this.slideEls = [...e.children], this.navBtnEls = S, this.currentIntersecting = {}, this.options = n, n.autoplay && (this.timer = null, this.timerInterval = (n == null ? void 0 : n.delay) ?? 3500, this.startTimer()), this.slideGutterSize = (n == null ? void 0 : n.slideGutterSize) ?? 25, this.showPagination = n == null ? void 0 : n.showPagination, this.isInitialScroll = !0, this.totalSlideEls = this.slideEls.length, this.totalSlides = Math.ceil(this.slides.length / this.options.cellsPerSlide), i(this, s, x).call(this), i(this, s, w).call(this), i(this, s, A).call(this);
|
|
53
52
|
}
|
|
54
53
|
/**
|
|
55
54
|
* starts the autoplay timer
|
|
@@ -73,7 +72,7 @@ class N {
|
|
|
73
72
|
* @param {number} dir - a number representing the direction of scroll 1 for forward, -1 for backward
|
|
74
73
|
*/
|
|
75
74
|
determineScrollAction(t) {
|
|
76
|
-
this.options.autoplay && this.timer !== null && this.clearTimer(), t === 1 ? this.currentIndex === this.totalSlides - 1 ? this.options.wrapAround && (this.scrollerEl.style.scrollBehavior = "auto", this.scrollerEl.scrollTo(0, 0), i(this,
|
|
75
|
+
this.options.autoplay && this.timer !== null && this.clearTimer(), t === 1 ? this.currentIndex === this.totalSlides - 1 ? this.options.wrapAround && (this.scrollerEl.style.scrollBehavior = "auto", this.scrollerEl.scrollTo(0, 0), i(this, s, h).call(this, t), this.currentIndex = 0) : (i(this, s, h).call(this, t), this.currentIndex += 1) : t === -1 && (this.currentIndex === 0 ? this.options.wrapAround && (this.scrollerEl.style.scrollBehavior = "auto", this.scrollerEl.scrollTo(99999, 0), this.currentIndex = this.totalSlides - 1, i(this, s, h).call(this, t)) : (i(this, s, h).call(this, t), this.currentIndex -= 1)), this.options.autoplay && this.timer === null && this.startTimer();
|
|
77
76
|
}
|
|
78
77
|
/**
|
|
79
78
|
* Navigates the carousel to a specific index
|
|
@@ -84,8 +83,8 @@ class N {
|
|
|
84
83
|
navigateToIndex(t) {
|
|
85
84
|
if (t === this.currentIndex) return;
|
|
86
85
|
this.options.autoplay && this.clearTimer();
|
|
87
|
-
let
|
|
88
|
-
this.currentIndex = t, i(this,
|
|
86
|
+
let e = t > this.currentIndex ? t - this.currentIndex : this.currentIndex - t, l = t > this.currentIndex ? 1 : -1;
|
|
87
|
+
this.currentIndex = t, i(this, s, h).call(this, l, e), this.options.autoplay && this.startTimer(), i(this, s, c).call(this);
|
|
89
88
|
}
|
|
90
89
|
/**
|
|
91
90
|
* Returns the current index of the carousel
|
|
@@ -103,22 +102,22 @@ class N {
|
|
|
103
102
|
if (this.timer === null && this.options.autoplay && this.startTimer(), this.currentIntersecting.target) {
|
|
104
103
|
const t = Number.parseInt(this.currentIntersecting.target.getAttribute("data-index"), 10);
|
|
105
104
|
if (!this.options.wrapAround) {
|
|
106
|
-
this.currentIndex = t, i(this,
|
|
105
|
+
this.currentIndex = t, i(this, s, c).call(this);
|
|
107
106
|
return;
|
|
108
107
|
}
|
|
109
|
-
t === 0 ? (this.currentIndex = this.slides.length - 1, i(this,
|
|
108
|
+
t === 0 ? (this.currentIndex = this.slides.length - 1, i(this, s, d).call(this, { scrollport: this.scrollerEl, element: this.slideEls[this.totalSlides] })) : t === this.totalSlideEls - 1 ? (this.currentIndex = 0, i(this, s, d).call(this, { scrollport: this.scrollerEl, element: this.slideEls[1] })) : this.currentIndex = t - 1;
|
|
110
109
|
}
|
|
111
|
-
i(this,
|
|
110
|
+
i(this, s, c).call(this);
|
|
112
111
|
}
|
|
113
112
|
}
|
|
114
|
-
|
|
113
|
+
s = new WeakSet(), /**
|
|
115
114
|
* adds an observer to the scroller element that we can use to
|
|
116
115
|
* determine which slide is intersecting
|
|
117
116
|
*/
|
|
118
|
-
|
|
117
|
+
x = function() {
|
|
119
118
|
this.carouselObserver = new IntersectionObserver((t) => {
|
|
120
|
-
for (let
|
|
121
|
-
|
|
119
|
+
for (let e of t)
|
|
120
|
+
e.isIntersecting && (this.currentIntersecting = e);
|
|
122
121
|
}, {
|
|
123
122
|
root: this.scrollerEl,
|
|
124
123
|
threshold: 0.8
|
|
@@ -126,30 +125,30 @@ T = function() {
|
|
|
126
125
|
}, /**
|
|
127
126
|
* sets listeners on the slide elements for the observer
|
|
128
127
|
*/
|
|
129
|
-
|
|
128
|
+
A = function() {
|
|
130
129
|
for (let t of this.slideEls)
|
|
131
130
|
this.carouselObserver.observe(t);
|
|
132
131
|
}, /**
|
|
133
132
|
* sets some intial settings for the carousel based on some of the options
|
|
134
133
|
*/
|
|
135
|
-
|
|
136
|
-
this.options.wrapAround ? (this.scrollerEl.style.scrollBehavior = "auto", this.scrollerEl.scrollTo(-9999, 0), i(this,
|
|
134
|
+
w = function() {
|
|
135
|
+
this.options.wrapAround ? (this.scrollerEl.style.scrollBehavior = "auto", this.scrollerEl.scrollTo(-9999, 0), i(this, s, d).call(this, { scrollport: this.scrollerEl, element: this.scrollerEl.children[1] })) : this.options.showControls ? (this.navBtnEls.previous.setAttribute("disabled", !0), i(this, s, c).call(this)) : i(this, s, I).call(this), this.totalSlides === 1 && this.slideEls[0].removeAttribute("inert");
|
|
137
136
|
}, /**
|
|
138
137
|
* Scrolls the carousel to a specific child element
|
|
139
138
|
* @param {*} param0 - an object containing the scrollport element and the child element to scroll to
|
|
140
139
|
*/
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
t.style.scrollBehavior = "auto", t.scrollTo(Math.abs(t.offsetLeft -
|
|
140
|
+
d = function({ scrollport: t, element: e }) {
|
|
141
|
+
const l = this.slideGutterSize * 2 / 100;
|
|
142
|
+
t.style.scrollBehavior = "auto", t.scrollTo(Math.abs(t.offsetLeft - e.offsetLeft + e.clientWidth * l), 0);
|
|
144
143
|
}, /**
|
|
145
144
|
* Scrolls the carousel in a specified direction by a specified distance
|
|
146
145
|
*
|
|
147
146
|
* @param {number} dir - a number representing the direction of scroll 1 for forward, -1 for backward
|
|
148
147
|
* @param {number} distance - a number representing the number of slides to scroll
|
|
149
148
|
*/
|
|
150
|
-
|
|
149
|
+
h = function(t, e = 1) {
|
|
151
150
|
this.scrollerEl.style.scrollBehavior = "smooth", this.scrollerEl.scrollBy({
|
|
152
|
-
left: this.scrollerEl.clientWidth * ((100 - this.slideGutterSize * 2) / 100) *
|
|
151
|
+
left: this.scrollerEl.clientWidth * ((100 - this.slideGutterSize * 2) / 100) * e * t,
|
|
153
152
|
top: 0,
|
|
154
153
|
behavior: "smooth"
|
|
155
154
|
});
|
|
@@ -159,29 +158,29 @@ f = function(t, s = 1) {
|
|
|
159
158
|
* add methods here to have them sync
|
|
160
159
|
* when scroller is scrolled
|
|
161
160
|
*/
|
|
162
|
-
|
|
163
|
-
i(this,
|
|
161
|
+
c = function() {
|
|
162
|
+
i(this, s, I).call(this), this.showPagination && i(this, s, T).call(this), this.options.wrapAround || i(this, s, y).call(this);
|
|
164
163
|
}, /**
|
|
165
164
|
* Sets the control arrow buttons to disabled if the carousel is at the start or end
|
|
166
165
|
*/
|
|
167
|
-
|
|
166
|
+
y = function() {
|
|
168
167
|
this.navBtnEls.previous && this.navBtnEls.next && (this.navBtnEls.previous.removeAttribute("disabled"), this.navBtnEls.next.removeAttribute("disabled"), this.currentIndex === 0 && this.navBtnEls.previous.toggleAttribute("disabled"), this.currentIndex === this.slideEls.length - 1 && this.navBtnEls.next.toggleAttribute("disabled"));
|
|
169
168
|
}, /**
|
|
170
169
|
* Sets the inert attribute on all slides that are not the current slide
|
|
171
170
|
*/
|
|
172
|
-
|
|
171
|
+
I = function() {
|
|
173
172
|
const t = this.options.wrapAround ? this.currentIndex + 1 : this.currentIndex;
|
|
174
|
-
this.slideEls.length === 1 ? this.slideEls[0].removeAttribute("inert") : this.slideEls.forEach((
|
|
175
|
-
|
|
173
|
+
this.slideEls.length === 1 ? this.slideEls[0].removeAttribute("inert") : this.slideEls.forEach((e, l) => {
|
|
174
|
+
e.toggleAttribute("inert", l !== t);
|
|
176
175
|
});
|
|
177
176
|
}, /**
|
|
178
177
|
* Sets the pagination indicator to the current slide
|
|
179
178
|
*/
|
|
180
|
-
|
|
181
|
-
[...this.paginationEl.children].forEach((t,
|
|
182
|
-
|
|
179
|
+
T = function() {
|
|
180
|
+
[...this.paginationEl.children].forEach((t, e) => {
|
|
181
|
+
e === this.currentIndex ? t.setAttribute("data-current", "true") : t.setAttribute("data-current", "false");
|
|
183
182
|
});
|
|
184
183
|
};
|
|
185
184
|
export {
|
|
186
|
-
|
|
185
|
+
P as default
|
|
187
186
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import o from "react";
|
|
3
|
-
import { c as r } from "../../../Carousel.module-
|
|
3
|
+
import { c as r } from "../../../Carousel.module-DOrBKQEQ.mjs";
|
|
4
4
|
const n = o.forwardRef(({ slides: t, carouselId: l }, s) => /* @__PURE__ */ e("div", { className: `${r["carousel-nav"]} carousel-nav`, children: /* @__PURE__ */ e("ol", { className: r["carousel-nav__list"], ref: s, children: t.map((c, a) => /* @__PURE__ */ e(
|
|
5
5
|
"li",
|
|
6
6
|
{
|
package/package.json
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import './assets/Carousel.css';const _ = "_carousel_idy2d_1", o = "_carousel__scroller_idy2d_11", s = {
|
|
2
|
-
carousel: _,
|
|
3
|
-
carousel__scroller: o,
|
|
4
|
-
"carousel-controls": "_carousel-controls_idy2d_39",
|
|
5
|
-
"carousel-controls__btn": "_carousel-controls__btn_idy2d_43",
|
|
6
|
-
"carousel-controls__previous": "_carousel-controls__previous_idy2d_68",
|
|
7
|
-
"carousel-controls__next": "_carousel-controls__next_idy2d_75",
|
|
8
|
-
"carousel-nav": "_carousel-nav_idy2d_87",
|
|
9
|
-
"carousel-nav__list": "_carousel-nav__list_idy2d_91",
|
|
10
|
-
"carousel-nav__item": "_carousel-nav__item_idy2d_100"
|
|
11
|
-
};
|
|
12
|
-
export {
|
|
13
|
-
s as c
|
|
14
|
-
};
|