@scrippsproduct/networks-ui-library 1.0.17 → 1.0.18-dev.1
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 +134 -156
- 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 o, Fragment as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import
|
|
4
|
-
import { CarouselSlide as
|
|
5
|
-
import { chunkArray as
|
|
6
|
-
import { c as a } from "../../Carousel.module-
|
|
7
|
-
import { C as
|
|
8
|
-
import { C as
|
|
9
|
-
const
|
|
1
|
+
import { jsx as o, Fragment as X, jsxs as K } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as s, useState as P, useEffect as B, useCallback as d } from "react";
|
|
3
|
+
import Y from "./CarouselUtils.class.js";
|
|
4
|
+
import { CarouselSlide as Z } from "../CarouselSlide/CarouselSlide.js";
|
|
5
|
+
import { chunkArray as ee, classes as _ } from "../../utils/helpers.js";
|
|
6
|
+
import { c as a } from "../../Carousel.module-DOrBKQEQ.mjs";
|
|
7
|
+
import { C as re } from "../../chevron-left-DmvQntvu.mjs";
|
|
8
|
+
import { C as te } from "../../chevron-right-CaAz6ISN.mjs";
|
|
9
|
+
const b = window.matchMedia("(width <= 600px)"), z = window.matchMedia("(width <= 800px"), E = window.matchMedia("(width <= 1024px"), L = window.matchMedia("(width <= 1280px");
|
|
10
10
|
function de({
|
|
11
|
-
id:
|
|
12
|
-
slides:
|
|
13
|
-
options:
|
|
11
|
+
id: g,
|
|
12
|
+
slides: x,
|
|
13
|
+
options: I = {
|
|
14
14
|
paginationType: "dots",
|
|
15
15
|
showControls: !0,
|
|
16
16
|
controlArrowSize: 48,
|
|
@@ -28,171 +28,153 @@ 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: ${g} initialized`);
|
|
35
|
+
const p = s(`carousel-${g}`), R = s(null), i = s(null), $ = s(null), m = s(x), T = s(null), S = s(null), r = s(null), e = s(I), l = s(I), N = s("-50%"), [M, G] = P([]), [k, H] = P([]), [D, U] = P(0);
|
|
36
|
+
B(() => {
|
|
37
|
+
const t = () => {
|
|
38
|
+
b.matches ? e.current = {
|
|
39
|
+
...l.current,
|
|
40
40
|
showControls: !1,
|
|
41
41
|
showPagination: !1,
|
|
42
42
|
cellsPerSlide: 1,
|
|
43
|
-
cellsPosition:
|
|
43
|
+
cellsPosition: l.current.wrapAround ? "center" : "flex-start",
|
|
44
44
|
gutterSize: 10
|
|
45
|
-
}
|
|
46
|
-
...
|
|
47
|
-
showControls: !1,
|
|
48
|
-
showPagination: !1,
|
|
49
|
-
cellsPerSlide: 1,
|
|
50
|
-
cellsPosition: e.current.wrapAround ? "center" : "flex-start",
|
|
51
|
-
gutterSize: 10
|
|
52
|
-
}, $.current = !1) : ee.matches ? e.current.cellsPerSlide > 2 ? (d({
|
|
53
|
-
...e.current,
|
|
45
|
+
} : z.matches ? l.current.cellsPerSlide !== 1 ? e.current = {
|
|
46
|
+
...l.current,
|
|
54
47
|
cellsPerSlide: 2,
|
|
55
48
|
showControls: !1,
|
|
56
49
|
gutterSize: 10
|
|
57
|
-
}
|
|
58
|
-
...
|
|
59
|
-
cellsPerSlide: 2,
|
|
60
|
-
showControls: !1,
|
|
61
|
-
gutterSize: 10
|
|
62
|
-
}) : (d({
|
|
63
|
-
...e.current,
|
|
64
|
-
showControls: !1,
|
|
65
|
-
gutterSize: 10
|
|
66
|
-
}), e.current = {
|
|
67
|
-
...e.current,
|
|
50
|
+
} : e.current = {
|
|
51
|
+
...l.current,
|
|
68
52
|
showControls: !1,
|
|
69
53
|
gutterSize: 10
|
|
70
|
-
}
|
|
71
|
-
...
|
|
54
|
+
} : E.matches ? l.current.cellsPerSlide !== 1 && l.current.cellsPerSlide !== 2 ? e.current = {
|
|
55
|
+
...l.current,
|
|
72
56
|
cellsPerSlide: 3,
|
|
73
57
|
showControls: !1,
|
|
74
58
|
gutterSize: 10
|
|
75
|
-
}
|
|
76
|
-
...
|
|
77
|
-
cellsPerSlide: 3,
|
|
78
|
-
showControls: !1,
|
|
79
|
-
gutterSize: 10
|
|
80
|
-
}) : (d({
|
|
81
|
-
...e.current,
|
|
82
|
-
showControls: !1,
|
|
83
|
-
gutterSize: 10
|
|
84
|
-
}), e.current = {
|
|
85
|
-
...e.current,
|
|
59
|
+
} : e.current = {
|
|
60
|
+
...l.current,
|
|
86
61
|
showControls: !1,
|
|
87
62
|
gutterSize: 10
|
|
88
|
-
}
|
|
89
|
-
...
|
|
63
|
+
} : L.matches ? l.current.showPagination ? e.current = {
|
|
64
|
+
...l.current,
|
|
90
65
|
showControls: !1
|
|
91
|
-
}
|
|
92
|
-
...
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
66
|
+
} : e.current = {
|
|
67
|
+
...l.current
|
|
68
|
+
} : e.current = {
|
|
69
|
+
...l.current
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
t();
|
|
73
|
+
const n = () => {
|
|
74
|
+
U((u) => u + 1), t();
|
|
75
|
+
};
|
|
76
|
+
return b.addEventListener("change", n), z.addEventListener("change", n), E.addEventListener("change", n), L.addEventListener("change", n), () => {
|
|
77
|
+
b.removeEventListener("change", n), z.removeEventListener("change", n), E.removeEventListener("change", n), L.removeEventListener("change", n);
|
|
78
|
+
};
|
|
98
79
|
}, []);
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
let
|
|
103
|
-
for (let
|
|
104
|
-
|
|
105
|
-
for (let
|
|
106
|
-
|
|
107
|
-
props:
|
|
80
|
+
const O = d((t, n) => {
|
|
81
|
+
const u = ee(n, t);
|
|
82
|
+
H([...u]);
|
|
83
|
+
let h = [];
|
|
84
|
+
for (let c = 0; c <= u.length - 1; c++) {
|
|
85
|
+
h[c] = {}, h[c].ariaLabel = `${c + 1} of ${u.length}`, h[c].layout = u[c][0].layout, h[c].cells = [];
|
|
86
|
+
for (let w = 0; w <= u[c].length - 1; w++)
|
|
87
|
+
h[c].cells[w] = {
|
|
88
|
+
props: u[c][w].props
|
|
108
89
|
};
|
|
109
90
|
}
|
|
110
|
-
const
|
|
111
|
-
return
|
|
112
|
-
}, []),
|
|
113
|
-
e.current.autoplay &&
|
|
114
|
-
}, []),
|
|
115
|
-
|
|
116
|
-
const n =
|
|
117
|
-
n === "ArrowLeft" ? (
|
|
118
|
-
}, [
|
|
119
|
-
|
|
120
|
-
|
|
91
|
+
const C = [...h], A = [...h], J = C.slice(-1), Q = C.slice(0);
|
|
92
|
+
return A.push(Q[0]), A.unshift(J[0]), e.current.wrapAround && t.length > n ? A : C;
|
|
93
|
+
}, []), f = d(() => {
|
|
94
|
+
e.current.autoplay && r.current.clearTimer();
|
|
95
|
+
}, []), F = d((t) => {
|
|
96
|
+
f();
|
|
97
|
+
const n = t.key;
|
|
98
|
+
n === "ArrowLeft" ? (t.preventDefault(), r.current.determineScrollAction(-1)) : n === "ArrowRight" && (t.preventDefault(), r.current.determineScrollAction(1));
|
|
99
|
+
}, [f]), W = d(() => {
|
|
100
|
+
f(), i.current.addEventListener("scrollend", () => {
|
|
101
|
+
r.current.handleScrollEnd();
|
|
121
102
|
}, { once: !0 });
|
|
122
|
-
}, [
|
|
123
|
-
|
|
124
|
-
|
|
103
|
+
}, [f]), v = d(() => {
|
|
104
|
+
f(), i.current.addEventListener("scrollend", () => {
|
|
105
|
+
r.current.handleScrollEnd(), i.current.addEventListener("scroll", v, { once: !0 });
|
|
125
106
|
}, { once: !0 });
|
|
126
|
-
}, [
|
|
127
|
-
|
|
128
|
-
},
|
|
107
|
+
}, [f]), q = () => {
|
|
108
|
+
r.current && e.current.autoplay && r.current.clearTimer();
|
|
109
|
+
}, y = d(() => {
|
|
129
110
|
//! make sure class is only instantiated once because of reacts
|
|
130
111
|
//! "strict" mode double do hocus pocus
|
|
131
|
-
|
|
112
|
+
var t, n;
|
|
113
|
+
r.current !== null && D > 0 && ((n = (t = r.current).clearTimer) == null || n.call(t), r.current = null), r.current = new Y({
|
|
132
114
|
carouselEl: R.current,
|
|
133
115
|
scrollerEl: i.current,
|
|
134
|
-
paginationEl:
|
|
135
|
-
slides:
|
|
116
|
+
paginationEl: $.current,
|
|
117
|
+
slides: m.current,
|
|
136
118
|
navBtnEls: {
|
|
137
|
-
next:
|
|
138
|
-
previous:
|
|
119
|
+
next: T.current,
|
|
120
|
+
previous: S.current
|
|
139
121
|
},
|
|
140
|
-
id:
|
|
122
|
+
id: p.current,
|
|
141
123
|
options: {
|
|
142
124
|
autoplay: e.current.autoplay,
|
|
143
|
-
wrapAround: e.current.wrapAround &&
|
|
125
|
+
wrapAround: e.current.wrapAround && m.current.length > e.current.cellsPerSlide,
|
|
144
126
|
showPagination: e.current.showPagination,
|
|
145
127
|
delay: e.current.autoplayDelay,
|
|
146
128
|
slideGutterSize: e.current.gutterSize,
|
|
147
129
|
slideAspectRatio: e.current.slideAspectRatio,
|
|
148
|
-
showControls: e.current.showControls &&
|
|
130
|
+
showControls: e.current.showControls && m.current.length > e.current.cellsPerSlide,
|
|
149
131
|
cellsPerSlide: e.current.cellsPerSlide
|
|
150
132
|
}
|
|
151
|
-
})
|
|
152
|
-
}, []),
|
|
133
|
+
});
|
|
134
|
+
}, [D]), V = d(() => {
|
|
153
135
|
i.current.addEventListener("scroll", v, { once: !0 });
|
|
154
|
-
}, [v]),
|
|
155
|
-
if (
|
|
156
|
-
let
|
|
157
|
-
i.current !== null && (
|
|
136
|
+
}, [v]), j = d(() => {
|
|
137
|
+
if (G(O(m.current, e.current.cellsPerSlide)), m.current.length > e.current.cellsPerSlide) {
|
|
138
|
+
let t = setInterval(() => {
|
|
139
|
+
i.current !== null && (S.current !== null && e.current.showControls || !e.current.showControls) && (clearInterval(t), V(), y());
|
|
158
140
|
}, 100);
|
|
159
141
|
} else {
|
|
160
|
-
let
|
|
161
|
-
i.current !== null && (clearInterval(
|
|
142
|
+
let t = setInterval(() => {
|
|
143
|
+
i.current !== null && (clearInterval(t), y());
|
|
162
144
|
}, 100);
|
|
163
145
|
}
|
|
164
|
-
}, [
|
|
165
|
-
return
|
|
166
|
-
if (
|
|
167
|
-
if (
|
|
168
|
-
let
|
|
169
|
-
|
|
146
|
+
}, [O, V, y]);
|
|
147
|
+
return B(() => {
|
|
148
|
+
if (e.current !== null) {
|
|
149
|
+
if (e.current.showControls) {
|
|
150
|
+
let t = 0;
|
|
151
|
+
e.current.showPagination && (t = t + 25), e.current.showScrollbar && (t = t + 6), N.current = `calc(-50% - ${t}px)`;
|
|
170
152
|
}
|
|
171
|
-
|
|
153
|
+
j();
|
|
172
154
|
}
|
|
173
155
|
return () => {
|
|
174
|
-
|
|
156
|
+
q();
|
|
175
157
|
};
|
|
176
|
-
}, [
|
|
158
|
+
}, [j, e]), /* @__PURE__ */ o(X, { children: e.current !== null && /* @__PURE__ */ K(
|
|
177
159
|
"div",
|
|
178
160
|
{
|
|
179
161
|
className: a.carousel,
|
|
180
|
-
id:
|
|
162
|
+
id: p.current,
|
|
181
163
|
ref: R,
|
|
182
164
|
tabIndex: -1,
|
|
183
165
|
role: "region",
|
|
184
166
|
"aria-roledescription": "carousel",
|
|
185
|
-
"aria-label":
|
|
186
|
-
onKeyDown:
|
|
167
|
+
"aria-label": e.current.title,
|
|
168
|
+
onKeyDown: F,
|
|
187
169
|
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":
|
|
170
|
+
"--_carousel-gutters": e.current.wrapAround ? `${e.current.gutterSize <= 25 ? e.current.gutterSize : 25}%` : `0 ${e.current.gutterSize <= 25 ? e.current.gutterSize : 25}%`,
|
|
171
|
+
"--_slide-aspect-ratio": e.current.slideAspectRatio,
|
|
172
|
+
"--_cell-aspect-ratio": e.current.cellAspectRatio,
|
|
173
|
+
"--_slide-cell-size": `${100 / e.current.cellsPerSlide}%`,
|
|
174
|
+
"--_cells-position": e.current.cellsPosition,
|
|
175
|
+
"--_control-btns-offset-x": `${e.current.controlButtonsOffset}rem`,
|
|
176
|
+
"--_slide-gap": `${e.current.slideGap}rem`,
|
|
177
|
+
"--_controls-transform": N.current
|
|
196
178
|
},
|
|
197
179
|
children: [
|
|
198
180
|
/* @__PURE__ */ o(
|
|
@@ -205,84 +187,80 @@ function de({
|
|
|
205
187
|
"aria-live": "Polite",
|
|
206
188
|
tabIndex: 0,
|
|
207
189
|
onMouseEnter: () => {
|
|
208
|
-
e.current.autoplay &&
|
|
190
|
+
e.current.autoplay && r.current !== null && r.current.clearTimer();
|
|
209
191
|
},
|
|
210
192
|
onMouseLeave: () => {
|
|
211
|
-
e.current.autoplay &&
|
|
193
|
+
e.current.autoplay && r.current !== null && r.current.startTimer();
|
|
212
194
|
},
|
|
213
|
-
onTouchStart:
|
|
214
|
-
"data-scrollbar":
|
|
215
|
-
children:
|
|
216
|
-
|
|
195
|
+
onTouchStart: W,
|
|
196
|
+
"data-scrollbar": e.current.showScrollbar,
|
|
197
|
+
children: M.length > 0 && M.map((t, n) => /* @__PURE__ */ o(
|
|
198
|
+
Z,
|
|
217
199
|
{
|
|
218
|
-
slide:
|
|
200
|
+
slide: t,
|
|
219
201
|
index: n,
|
|
220
|
-
currentIndex:
|
|
221
|
-
variableHeight:
|
|
202
|
+
currentIndex: e.current.wrapAround ? 1 : 0,
|
|
203
|
+
variableHeight: e.current.variableHeight
|
|
222
204
|
},
|
|
223
|
-
`carousel${
|
|
205
|
+
`carousel${g}-slide${n}`
|
|
224
206
|
))
|
|
225
207
|
}
|
|
226
208
|
),
|
|
227
|
-
|
|
209
|
+
e.current.showControls && x.length > e.current.cellsPerSlide && /* @__PURE__ */ K("div", { className: a["carousel-controls"], children: [
|
|
228
210
|
/* @__PURE__ */ o(
|
|
229
211
|
"button",
|
|
230
212
|
{
|
|
231
213
|
type: "button",
|
|
232
|
-
ref:
|
|
214
|
+
ref: S,
|
|
233
215
|
title: "Previous Item",
|
|
234
|
-
className:
|
|
235
|
-
|
|
236
|
-
a["carousel-controls__previous"],
|
|
237
|
-
"carousel-controls__previous"
|
|
238
|
-
]),
|
|
239
|
-
"aria-controls": m.current,
|
|
216
|
+
className: _([a["carousel-controls__btn"], a["carousel-controls__previous"], "carousel-controls__previous"]),
|
|
217
|
+
"aria-controls": p.current,
|
|
240
218
|
"aria-label": "Previous Item",
|
|
241
219
|
onClick: () => {
|
|
242
|
-
|
|
220
|
+
r.current.determineScrollAction(-1);
|
|
243
221
|
},
|
|
244
222
|
onMouseEnter: () => {
|
|
245
|
-
e.current.autoplay &&
|
|
223
|
+
e.current.autoplay && r.current !== null && r.current.clearTimer();
|
|
246
224
|
},
|
|
247
225
|
onMouseLeave: () => {
|
|
248
|
-
e.current.autoplay &&
|
|
226
|
+
e.current.autoplay && r.current !== null && r.current.startTimer();
|
|
249
227
|
},
|
|
250
|
-
children: /* @__PURE__ */ o("i", { "aria-hidden": "true", children: /* @__PURE__ */ o(
|
|
228
|
+
children: /* @__PURE__ */ o("i", { "aria-hidden": "true", children: /* @__PURE__ */ o(re, { width: e.current.controlArrowSize, height: e.current.controlArrowSize }) })
|
|
251
229
|
}
|
|
252
230
|
),
|
|
253
231
|
/* @__PURE__ */ o(
|
|
254
232
|
"button",
|
|
255
233
|
{
|
|
256
234
|
type: "button",
|
|
257
|
-
ref:
|
|
235
|
+
ref: T,
|
|
258
236
|
title: "Next Item",
|
|
259
|
-
className:
|
|
260
|
-
"aria-controls":
|
|
237
|
+
className: _([a["carousel-controls__btn"], a["carousel-controls__next"], "carousel-controls__next"]),
|
|
238
|
+
"aria-controls": p.current,
|
|
261
239
|
"aria-label": "Next Item",
|
|
262
240
|
onClick: () => {
|
|
263
|
-
|
|
241
|
+
r.current.determineScrollAction(1);
|
|
264
242
|
},
|
|
265
243
|
onMouseEnter: () => {
|
|
266
|
-
e.current.autoplay &&
|
|
244
|
+
e.current.autoplay && r.current !== null && r.current.clearTimer();
|
|
267
245
|
},
|
|
268
246
|
onMouseLeave: () => {
|
|
269
|
-
e.current.autoplay &&
|
|
247
|
+
e.current.autoplay && r.current !== null && r.current.startTimer();
|
|
270
248
|
},
|
|
271
|
-
children: /* @__PURE__ */ o("i", { "aria-hidden": "true", children: /* @__PURE__ */ o(
|
|
249
|
+
children: /* @__PURE__ */ o("i", { "aria-hidden": "true", children: /* @__PURE__ */ o(te, { width: e.current.controlArrowSize, height: e.current.controlArrowSize }) })
|
|
272
250
|
}
|
|
273
251
|
)
|
|
274
252
|
] }),
|
|
275
|
-
|
|
253
|
+
e.current.showPagination && k.length > 1 && /* @__PURE__ */ o("div", { className: [a["carousel-nav"], "carousel-nav"].join(" "), children: /* @__PURE__ */ o("ol", { className: a["carousel-nav__list"], ref: $, children: k.map((t, n) => /* @__PURE__ */ o(
|
|
276
254
|
"li",
|
|
277
255
|
{
|
|
278
|
-
className:
|
|
256
|
+
className: _([a["carousel-nav__item"], "carousel-nav__item"]),
|
|
279
257
|
"data-current": n === 0 ? "true" : "false",
|
|
280
258
|
onClick: () => {
|
|
281
|
-
|
|
259
|
+
r.current.navigateToIndex(n);
|
|
282
260
|
},
|
|
283
261
|
title: `Navigate to slide ${n + 1}`
|
|
284
262
|
},
|
|
285
|
-
`carousel${
|
|
263
|
+
`carousel${p}-nav-${n}`
|
|
286
264
|
)) }) })
|
|
287
265
|
]
|
|
288
266
|
}
|
|
@@ -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
|
-
};
|