@scrippsproduct/networks-ui-library 2.0.5 → 2.0.6-alpha.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.
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { jsx as l, Fragment as
|
|
2
|
-
import { useRef as a, useState as m, useEffect as
|
|
3
|
-
import { chunkArray as
|
|
4
|
-
import
|
|
5
|
-
import { CarouselSlide as
|
|
6
|
-
import { Loading as
|
|
1
|
+
import { jsx as l, Fragment as Z, jsxs as B } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as a, useState as m, useEffect as G, useCallback as u, Suspense as ee } from "react";
|
|
3
|
+
import { chunkArray as re, classes as g } from "../../utils/helpers.js";
|
|
4
|
+
import te from "./CarouselUtils.class.js";
|
|
5
|
+
import { CarouselSlide as ne } from "../CarouselSlide/CarouselSlide.js";
|
|
6
|
+
import { Loading as le } from "../Loading/Loading.js";
|
|
7
7
|
import { c as i } from "../../Carousel.module-Nwf_zL9b.mjs";
|
|
8
|
-
import { C as
|
|
9
|
-
import { C as
|
|
8
|
+
import { C as ce } from "../../chevron-left-D0UjbrKw.mjs";
|
|
9
|
+
import { C as oe } from "../../chevron-right-0ZF3LruR.mjs";
|
|
10
10
|
const A = window.matchMedia("(width <= 600px)"), P = window.matchMedia("(width <= 800px"), b = window.matchMedia("(width <= 1024px"), z = window.matchMedia("(width <= 1280px");
|
|
11
|
-
function
|
|
11
|
+
function ge({
|
|
12
12
|
id: E,
|
|
13
13
|
cells: L,
|
|
14
|
-
options:
|
|
14
|
+
options: x = {
|
|
15
15
|
paginationType: "dots",
|
|
16
16
|
showControls: !0,
|
|
17
17
|
controlArrowSize: 48,
|
|
@@ -32,8 +32,8 @@ function me({
|
|
|
32
32
|
wrapAround: !0
|
|
33
33
|
}
|
|
34
34
|
}) {
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const h = a(`carousel-${E}`), I = a(null), c = a(null), R = a(null), p = a([...L]), $ = a(null), w = a(null), r = a(null), e = a(x), o = a(x), N = a("-50%"), [T, H] = m([]), [M, U] = m([]), [k, q] = m(0), [F, D] = m(!1);
|
|
36
|
+
G(() => {
|
|
37
37
|
const t = () => {
|
|
38
38
|
A.matches ? e.current = {
|
|
39
39
|
...o.current,
|
|
@@ -71,33 +71,33 @@ function me({
|
|
|
71
71
|
};
|
|
72
72
|
t();
|
|
73
73
|
const n = () => {
|
|
74
|
-
|
|
74
|
+
q((s) => s + 1), t();
|
|
75
75
|
};
|
|
76
76
|
return A.addEventListener("change", n), P.addEventListener("change", n), b.addEventListener("change", n), z.addEventListener("change", n), () => {
|
|
77
77
|
A.removeEventListener("change", n), P.removeEventListener("change", n), b.removeEventListener("change", n), z.removeEventListener("change", n);
|
|
78
78
|
};
|
|
79
79
|
}, []);
|
|
80
80
|
const O = u((t, n) => {
|
|
81
|
-
const s =
|
|
82
|
-
|
|
81
|
+
const s = re(n, t);
|
|
82
|
+
U([...s]);
|
|
83
83
|
let y = [];
|
|
84
|
-
for (let
|
|
85
|
-
y[
|
|
86
|
-
ariaLabel: `${
|
|
87
|
-
layout: s[
|
|
84
|
+
for (let f = 0; f <= s.length - 1; f++)
|
|
85
|
+
y[f] = {
|
|
86
|
+
ariaLabel: `${f + 1} of ${s.length}`,
|
|
87
|
+
layout: s[f][0].layout || "",
|
|
88
88
|
cells: [
|
|
89
|
-
...s[
|
|
89
|
+
...s[f]
|
|
90
90
|
]
|
|
91
91
|
};
|
|
92
|
-
const _ = [...y], C = [...y],
|
|
93
|
-
return C.push(
|
|
92
|
+
const _ = [...y], C = [...y], X = _.slice(-1), Y = _.slice(0);
|
|
93
|
+
return C.push(Y[0]), C.unshift(X[0]), e.current.wrapAround && t.length > n ? C : _;
|
|
94
94
|
}, []), d = u(() => {
|
|
95
95
|
e.current.autoplay && r.current && r.current.clearTimer();
|
|
96
96
|
}, []), W = u((t) => {
|
|
97
97
|
d();
|
|
98
98
|
const n = t.key;
|
|
99
99
|
n === "ArrowLeft" ? (t.preventDefault(), r.current && r.current.determineScrollAction(-1)) : n === "ArrowRight" && (t.preventDefault(), r.current && r.current.determineScrollAction(1));
|
|
100
|
-
}, [d]),
|
|
100
|
+
}, [d]), J = u(() => {
|
|
101
101
|
d(), c.current !== null && c.current.addEventListener("scrollend", () => {
|
|
102
102
|
r.current && r.current.handleScrollEnd();
|
|
103
103
|
}, { once: !0 });
|
|
@@ -105,15 +105,15 @@ function me({
|
|
|
105
105
|
d(), c.current !== null && c.current.addEventListener("scrollend", () => {
|
|
106
106
|
r.current && r.current.handleScrollEnd(), c.current && c.current.addEventListener("scroll", S, { once: !0 });
|
|
107
107
|
}, { once: !0 });
|
|
108
|
-
}, [d]),
|
|
108
|
+
}, [d]), Q = () => {
|
|
109
109
|
var t;
|
|
110
110
|
(t = r.current) == null || t.destroy();
|
|
111
111
|
}, v = u(() => {
|
|
112
112
|
//! make sure class is only instantiated once because of reacts
|
|
113
113
|
//! "strict" mode double do hocus pocus
|
|
114
114
|
var t, n;
|
|
115
|
-
r.current !== null && k > 0 && ((n = (t = r.current).destroy) == null || n.call(t), r.current = null), D(!1), r.current = new
|
|
116
|
-
carouselEl:
|
|
115
|
+
r.current !== null && k > 0 && ((n = (t = r.current).destroy) == null || n.call(t), r.current = null), D(!1), r.current = new te({
|
|
116
|
+
carouselEl: I.current,
|
|
117
117
|
scrollerEl: c.current,
|
|
118
118
|
paginationEl: R.current,
|
|
119
119
|
cells: p.current,
|
|
@@ -121,7 +121,7 @@ function me({
|
|
|
121
121
|
next: $.current,
|
|
122
122
|
previous: w.current
|
|
123
123
|
},
|
|
124
|
-
id:
|
|
124
|
+
id: h.current,
|
|
125
125
|
options: {
|
|
126
126
|
autoplay: e.current.autoplay,
|
|
127
127
|
wrapAround: e.current.wrapAround && p.current.length > (e.current.cellsPerSlide || 1),
|
|
@@ -135,39 +135,42 @@ function me({
|
|
|
135
135
|
}), D(!0);
|
|
136
136
|
}, [k]), V = u(() => {
|
|
137
137
|
c.current && c.current.addEventListener("scroll", S, { once: !0 });
|
|
138
|
-
}, [S]), K =
|
|
138
|
+
}, [S]), K = () => {
|
|
139
|
+
var t;
|
|
140
|
+
return ((t = c.current) == null ? void 0 : t.querySelectorAll("[data-index]").length) ?? 0;
|
|
141
|
+
}, j = u(() => {
|
|
139
142
|
const t = O(p.current, e.current.cellsPerSlide ?? 1);
|
|
140
|
-
|
|
143
|
+
H(t);
|
|
141
144
|
const n = t.length;
|
|
142
145
|
if (p.current.length > (e.current.cellsPerSlide ?? 1)) {
|
|
143
146
|
let s = setInterval(() => {
|
|
144
|
-
c.current !== null &&
|
|
147
|
+
c.current !== null && K() >= n && (w.current !== null && e.current.showControls || !e.current.showControls) && (clearInterval(s), V(), v());
|
|
145
148
|
}, 100);
|
|
146
149
|
} else {
|
|
147
150
|
let s = setInterval(() => {
|
|
148
|
-
c.current !== null &&
|
|
151
|
+
c.current !== null && K() >= n && (clearInterval(s), v());
|
|
149
152
|
}, 100);
|
|
150
153
|
}
|
|
151
154
|
}, [O, V, v]);
|
|
152
|
-
return
|
|
155
|
+
return G(() => {
|
|
153
156
|
if (e.current !== null) {
|
|
154
157
|
if (e.current.showControls) {
|
|
155
158
|
let t = 0;
|
|
156
159
|
e.current.showPagination && (t = t + 25), e.current.showScrollbar && (t = t + 6), N.current = `calc(-50% - ${t}px)`;
|
|
157
160
|
}
|
|
158
|
-
|
|
161
|
+
j();
|
|
159
162
|
}
|
|
160
163
|
return () => {
|
|
161
|
-
|
|
164
|
+
Q();
|
|
162
165
|
};
|
|
163
|
-
}, [
|
|
166
|
+
}, [j, e]), /* @__PURE__ */ l(Z, { children: e.current !== null && /* @__PURE__ */ B(
|
|
164
167
|
"div",
|
|
165
168
|
{
|
|
166
169
|
"aria-label": e.current.title,
|
|
167
170
|
"aria-roledescription": "carousel",
|
|
168
171
|
className: i.carousel,
|
|
169
|
-
id:
|
|
170
|
-
ref:
|
|
172
|
+
id: h.current,
|
|
173
|
+
ref: I,
|
|
171
174
|
role: "region",
|
|
172
175
|
style: {
|
|
173
176
|
"--_carousel-gutters": e.current.wrapAround ? `${(e.current.gutterSize ?? 25) <= 25 ? e.current.gutterSize ?? 25 : 25}%` : `0 ${(e.current.gutterSize ?? 25) <= 25 ? e.current.gutterSize ?? 25 : 25}%`,
|
|
@@ -199,9 +202,9 @@ function me({
|
|
|
199
202
|
onMouseLeave: () => {
|
|
200
203
|
e.current.autoplay && r.current !== null && r.current.startTimer();
|
|
201
204
|
},
|
|
202
|
-
onTouchStart:
|
|
205
|
+
onTouchStart: J,
|
|
203
206
|
children: /* @__PURE__ */ l(
|
|
204
|
-
|
|
207
|
+
ee,
|
|
205
208
|
{
|
|
206
209
|
fallback: /* @__PURE__ */ l(
|
|
207
210
|
"li",
|
|
@@ -209,11 +212,11 @@ function me({
|
|
|
209
212
|
className: g([i["carousel__loading-slide"], "carousel__loading-slide"]),
|
|
210
213
|
role: "presentation",
|
|
211
214
|
style: { aspectRatio: "var(--_slide-aspect-ratio)", width: "100%" },
|
|
212
|
-
children: /* @__PURE__ */ l(
|
|
215
|
+
children: /* @__PURE__ */ l(le, {})
|
|
213
216
|
}
|
|
214
217
|
),
|
|
215
218
|
children: T.length > 0 && T.map((t, n) => /* @__PURE__ */ l(
|
|
216
|
-
|
|
219
|
+
ne,
|
|
217
220
|
{
|
|
218
221
|
currentIndex: e.current.wrapAround ? 1 : 0,
|
|
219
222
|
index: n,
|
|
@@ -226,11 +229,11 @@ function me({
|
|
|
226
229
|
)
|
|
227
230
|
}
|
|
228
231
|
),
|
|
229
|
-
e.current.showControls && L.length > (e.current.cellsPerSlide ?? 1) && /* @__PURE__ */
|
|
232
|
+
e.current.showControls && L.length > (e.current.cellsPerSlide ?? 1) && /* @__PURE__ */ B("div", { className: i["carousel-controls"], children: [
|
|
230
233
|
/* @__PURE__ */ l(
|
|
231
234
|
"button",
|
|
232
235
|
{
|
|
233
|
-
"aria-controls":
|
|
236
|
+
"aria-controls": h.current,
|
|
234
237
|
"aria-label": "Previous Item",
|
|
235
238
|
className: g([
|
|
236
239
|
i["carousel-controls__btn"],
|
|
@@ -249,13 +252,13 @@ function me({
|
|
|
249
252
|
onMouseLeave: () => {
|
|
250
253
|
e.current.autoplay && r.current !== null && r.current.startTimer();
|
|
251
254
|
},
|
|
252
|
-
children: /* @__PURE__ */ l("i", { "aria-hidden": "true", children: /* @__PURE__ */ l(
|
|
255
|
+
children: /* @__PURE__ */ l("i", { "aria-hidden": "true", children: /* @__PURE__ */ l(ce, { height: e.current.controlArrowSize, width: e.current.controlArrowSize }) })
|
|
253
256
|
}
|
|
254
257
|
),
|
|
255
258
|
/* @__PURE__ */ l(
|
|
256
259
|
"button",
|
|
257
260
|
{
|
|
258
|
-
"aria-controls":
|
|
261
|
+
"aria-controls": h.current,
|
|
259
262
|
"aria-label": "Next Item",
|
|
260
263
|
className: g([i["carousel-controls__btn"], i["carousel-controls__next"], "carousel-controls__next"]),
|
|
261
264
|
ref: $,
|
|
@@ -270,7 +273,7 @@ function me({
|
|
|
270
273
|
onMouseLeave: () => {
|
|
271
274
|
e.current.autoplay && r.current !== null && r.current.startTimer();
|
|
272
275
|
},
|
|
273
|
-
children: /* @__PURE__ */ l("i", { "aria-hidden": "true", children: /* @__PURE__ */ l(
|
|
276
|
+
children: /* @__PURE__ */ l("i", { "aria-hidden": "true", children: /* @__PURE__ */ l(oe, { height: e.current.controlArrowSize, width: e.current.controlArrowSize }) })
|
|
274
277
|
}
|
|
275
278
|
)
|
|
276
279
|
] }),
|
|
@@ -284,13 +287,13 @@ function me({
|
|
|
284
287
|
r.current && r.current.navigateToIndex(n);
|
|
285
288
|
}
|
|
286
289
|
},
|
|
287
|
-
`carousel${
|
|
290
|
+
`carousel${h}-nav-${n}`
|
|
288
291
|
)) }) })
|
|
289
292
|
]
|
|
290
293
|
}
|
|
291
294
|
) });
|
|
292
295
|
}
|
|
293
296
|
export {
|
|
294
|
-
|
|
295
|
-
|
|
297
|
+
ge as Carousel,
|
|
298
|
+
ge as default
|
|
296
299
|
};
|
|
@@ -7,25 +7,25 @@ var n = (r, t, e) => B(r, typeof t != "symbol" ? t + "" : t, e), L = (r, t, e) =
|
|
|
7
7
|
var w = (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);
|
|
8
8
|
var l = (r, t, e) => (L(r, t, "access private method"), e);
|
|
9
9
|
if (typeof window < "u" && !("onscrollend" in window)) {
|
|
10
|
-
let e = function(o, i,
|
|
10
|
+
let e = function(o, i, m) {
|
|
11
11
|
let d = o[i];
|
|
12
12
|
o[i] = function() {
|
|
13
13
|
let a = Array.prototype.slice.apply(arguments, [0]);
|
|
14
|
-
d.apply(this, a), a.unshift(d),
|
|
14
|
+
d.apply(this, a), a.unshift(d), m.apply(this, a);
|
|
15
15
|
};
|
|
16
|
-
}, h = function(o, i,
|
|
16
|
+
}, h = function(o, i, m, d) {
|
|
17
17
|
if (i != "scroll" && i != "scrollend") return;
|
|
18
18
|
let a = this, u = t.get(a);
|
|
19
19
|
if (u === void 0) {
|
|
20
|
-
let
|
|
20
|
+
let I = 0;
|
|
21
21
|
u = { scrollListener: (O) => {
|
|
22
|
-
clearTimeout(
|
|
23
|
-
r.size ? setTimeout(u.scrollListener, 100) : (a && a.dispatchEvent(new Event("scrollend")),
|
|
22
|
+
clearTimeout(I), I = setTimeout(() => {
|
|
23
|
+
r.size ? setTimeout(u.scrollListener, 100) : (a && a.dispatchEvent(new Event("scrollend")), I = 0);
|
|
24
24
|
}, 100);
|
|
25
25
|
}, listeners: 0 }, o.apply(a, ["scroll", u.scrollListener, { passive: !0 }]), t.set(a, u);
|
|
26
26
|
}
|
|
27
27
|
u.listeners++;
|
|
28
|
-
}, c = function(o, i,
|
|
28
|
+
}, c = function(o, i, m) {
|
|
29
29
|
if (i != "scroll" && i != "scrollend") return;
|
|
30
30
|
let d = this, a = t.get(d);
|
|
31
31
|
a !== void 0 && (--a.listeners > 0 || (o.apply(d, ["scroll", a.scrollListener]), t.delete(d)));
|
|
@@ -41,7 +41,7 @@ if (typeof window < "u" && !("onscrollend" in window)) {
|
|
|
41
41
|
let t = /* @__PURE__ */ new WeakMap();
|
|
42
42
|
e(Element.prototype, "addEventListener", h), e(window, "addEventListener", h), e(document, "addEventListener", h), e(Element.prototype, "removeEventListener", c), e(window, "removeEventListener", c), e(document, "removeEventListener", c);
|
|
43
43
|
}
|
|
44
|
-
var s, E, b, x, y, f, v, S,
|
|
44
|
+
var s, E, b, x, y, f, v, S, p, A;
|
|
45
45
|
class C {
|
|
46
46
|
constructor({
|
|
47
47
|
carouselEl: t,
|
|
@@ -173,7 +173,7 @@ x = function() {
|
|
|
173
173
|
*/
|
|
174
174
|
y = function() {
|
|
175
175
|
var t, e;
|
|
176
|
-
this.options.wrapAround ? (this.scrollerEl.style.scrollBehavior = "auto", this.scrollerEl.scrollTo(0, 0), l(this, s, E).call(this, { scrollport: this.scrollerEl, element: this.scrollerEl.children[1] })) : this.options.showControls ? (this.navBtnEls && ((t = this.navBtnEls) != null && t.previous) && ((e = this.navBtnEls) == null || e.previous.setAttribute("disabled", "disabled")), l(this, s, v).call(this)) : l(this, s,
|
|
176
|
+
this.options.wrapAround ? (this.scrollerEl.style.scrollBehavior = "auto", this.scrollerEl.scrollTo(0, 0), l(this, s, E).call(this, { scrollport: this.scrollerEl, element: this.scrollerEl.children[1] })) : this.options.showControls ? (this.navBtnEls && ((t = this.navBtnEls) != null && t.previous) && ((e = this.navBtnEls) == null || e.previous.setAttribute("disabled", "disabled")), l(this, s, v).call(this)) : l(this, s, p).call(this), this.totalSlideEls === 1 && l(this, s, p).call(this);
|
|
177
177
|
}, /**
|
|
178
178
|
* Scrolls the carousel in a specified direction by a specified distance
|
|
179
179
|
*
|
|
@@ -195,7 +195,7 @@ f = function(t, e = 1) {
|
|
|
195
195
|
* when scroller is scrolled
|
|
196
196
|
*/
|
|
197
197
|
v = function() {
|
|
198
|
-
l(this, s,
|
|
198
|
+
l(this, s, p).call(this), this.showPagination && l(this, s, A).call(this), this.options.wrapAround || l(this, s, S).call(this);
|
|
199
199
|
}, /**
|
|
200
200
|
* Sets the control arrow buttons to disabled if the carousel is at the start or end
|
|
201
201
|
*/
|
|
@@ -204,7 +204,7 @@ S = function() {
|
|
|
204
204
|
}, /**
|
|
205
205
|
* Sets the inert attribute on all slides that are not the current slide
|
|
206
206
|
*/
|
|
207
|
-
|
|
207
|
+
p = function() {
|
|
208
208
|
const t = this.options.wrapAround ? this.currentIndex + 1 : this.currentIndex;
|
|
209
209
|
this.slideEls.length === 1 ? this.slideEls[0].removeAttribute("inert") : this.slideEls.forEach((e, h) => {
|
|
210
210
|
e.toggleAttribute("inert", h !== t);
|
package/package.json
CHANGED