@scrippsproduct/networks-ui-library 2.0.3-dev.0 → 2.0.4-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.
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as l, Fragment as Y, jsxs as j } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { chunkArray as ee, classes as
|
|
2
|
+
import { useRef as a, useState as m, useEffect as B, useCallback as u, Suspense as Z } from "react";
|
|
3
|
+
import { chunkArray as ee, classes as g } from "../../utils/helpers.js";
|
|
4
4
|
import re from "./CarouselUtils.class.js";
|
|
5
5
|
import { CarouselSlide as te } from "../CarouselSlide/CarouselSlide.js";
|
|
6
6
|
import { Loading as ne } from "../Loading/Loading.js";
|
|
7
|
-
import { c as
|
|
7
|
+
import { c as i } from "../../Carousel.module-BsPaZX5L.mjs";
|
|
8
8
|
import { C as le } from "../../chevron-left-D0UjbrKw.mjs";
|
|
9
9
|
import { C as ce } from "../../chevron-right-0ZF3LruR.mjs";
|
|
10
|
-
const
|
|
10
|
+
const A = window.matchMedia("(width <= 600px)"), P = window.matchMedia("(width <= 800px"), b = window.matchMedia("(width <= 1024px"), z = window.matchMedia("(width <= 1280px");
|
|
11
11
|
function me({
|
|
12
12
|
id: E,
|
|
13
13
|
cells: L,
|
|
@@ -32,10 +32,10 @@ function me({
|
|
|
32
32
|
wrapAround: !0
|
|
33
33
|
}
|
|
34
34
|
}) {
|
|
35
|
-
const f =
|
|
35
|
+
const f = a(`carousel-${E}`), x = a(null), c = a(null), R = a(null), p = a([...L]), T = a(null), w = a(null), r = a(null), e = a(I), o = a(I), $ = a("-50%"), [N, G] = m([]), [M, H] = m([]), [k, U] = m(0), [F, D] = m(!1);
|
|
36
36
|
B(() => {
|
|
37
37
|
const n = () => {
|
|
38
|
-
|
|
38
|
+
A.matches ? e.current = {
|
|
39
39
|
...o.current,
|
|
40
40
|
showControls: !1,
|
|
41
41
|
showPagination: !1,
|
|
@@ -73,24 +73,24 @@ function me({
|
|
|
73
73
|
const t = () => {
|
|
74
74
|
U((s) => s + 1), n();
|
|
75
75
|
};
|
|
76
|
-
return
|
|
77
|
-
|
|
76
|
+
return A.addEventListener("change", t), P.addEventListener("change", t), b.addEventListener("change", t), z.addEventListener("change", t), () => {
|
|
77
|
+
A.removeEventListener("change", t), P.removeEventListener("change", t), b.removeEventListener("change", t), z.removeEventListener("change", t);
|
|
78
78
|
};
|
|
79
79
|
}, []);
|
|
80
80
|
const O = u((n, t) => {
|
|
81
81
|
const s = ee(t, n);
|
|
82
82
|
H([...s]);
|
|
83
|
-
let
|
|
83
|
+
let y = [];
|
|
84
84
|
for (let h = 0; h <= s.length - 1; h++)
|
|
85
|
-
|
|
85
|
+
y[h] = {
|
|
86
86
|
ariaLabel: `${h + 1} of ${s.length}`,
|
|
87
87
|
layout: s[h][0].layout || "",
|
|
88
88
|
cells: [
|
|
89
89
|
...s[h]
|
|
90
90
|
]
|
|
91
91
|
};
|
|
92
|
-
const
|
|
93
|
-
return C.push(X[0]), C.unshift(Q[0]), e.current.wrapAround && n.length > t ? C :
|
|
92
|
+
const _ = [...y], C = [...y], Q = _.slice(-1), X = _.slice(0);
|
|
93
|
+
return C.push(X[0]), C.unshift(Q[0]), e.current.wrapAround && n.length > t ? C : _;
|
|
94
94
|
}, []), d = u(() => {
|
|
95
95
|
e.current.autoplay && r.current && r.current.clearTimer();
|
|
96
96
|
}, []), W = u((n) => {
|
|
@@ -101,13 +101,13 @@ function me({
|
|
|
101
101
|
d(), c.current !== null && c.current.addEventListener("scrollend", () => {
|
|
102
102
|
r.current && r.current.handleScrollEnd();
|
|
103
103
|
}, { once: !0 });
|
|
104
|
-
}, [d]),
|
|
104
|
+
}, [d]), S = u(() => {
|
|
105
105
|
d(), c.current !== null && c.current.addEventListener("scrollend", () => {
|
|
106
|
-
r.current && r.current.handleScrollEnd(), c.current && c.current.addEventListener("scroll",
|
|
106
|
+
r.current && r.current.handleScrollEnd(), c.current && c.current.addEventListener("scroll", S, { once: !0 });
|
|
107
107
|
}, { once: !0 });
|
|
108
108
|
}, [d]), J = () => {
|
|
109
109
|
r.current && e.current.autoplay && r.current.clearTimer();
|
|
110
|
-
},
|
|
110
|
+
}, v = u(() => {
|
|
111
111
|
//! make sure class is only instantiated once because of reacts
|
|
112
112
|
//! "strict" mode double do hocus pocus
|
|
113
113
|
var n, t;
|
|
@@ -118,7 +118,7 @@ function me({
|
|
|
118
118
|
cells: p.current,
|
|
119
119
|
navBtnEls: {
|
|
120
120
|
next: T.current,
|
|
121
|
-
previous:
|
|
121
|
+
previous: w.current
|
|
122
122
|
},
|
|
123
123
|
id: f.current,
|
|
124
124
|
options: {
|
|
@@ -133,21 +133,21 @@ function me({
|
|
|
133
133
|
}
|
|
134
134
|
}), D(!0);
|
|
135
135
|
}, [k]), V = u(() => {
|
|
136
|
-
c.current && c.current.addEventListener("scroll",
|
|
137
|
-
}, [
|
|
136
|
+
c.current && c.current.addEventListener("scroll", S, { once: !0 });
|
|
137
|
+
}, [S]), K = u(() => {
|
|
138
138
|
const n = O(p.current, e.current.cellsPerSlide ?? 1);
|
|
139
139
|
G(n);
|
|
140
140
|
const t = n.length;
|
|
141
141
|
if (p.current.length > (e.current.cellsPerSlide ?? 1)) {
|
|
142
142
|
let s = setInterval(() => {
|
|
143
|
-
c.current !== null && c.current.children.length >= t && (
|
|
143
|
+
c.current !== null && c.current.children.length >= t && (w.current !== null && e.current.showControls || !e.current.showControls) && (clearInterval(s), V(), v());
|
|
144
144
|
}, 100);
|
|
145
145
|
} else {
|
|
146
146
|
let s = setInterval(() => {
|
|
147
|
-
c.current !== null && c.current.children.length >= t && (clearInterval(s),
|
|
147
|
+
c.current !== null && c.current.children.length >= t && (clearInterval(s), v());
|
|
148
148
|
}, 100);
|
|
149
149
|
}
|
|
150
|
-
}, [O, V,
|
|
150
|
+
}, [O, V, v]);
|
|
151
151
|
return B(() => {
|
|
152
152
|
if (e.current !== null) {
|
|
153
153
|
if (e.current.showControls) {
|
|
@@ -164,7 +164,7 @@ function me({
|
|
|
164
164
|
{
|
|
165
165
|
"aria-label": e.current.title,
|
|
166
166
|
"aria-roledescription": "carousel",
|
|
167
|
-
className:
|
|
167
|
+
className: i.carousel,
|
|
168
168
|
id: f.current,
|
|
169
169
|
ref: x,
|
|
170
170
|
role: "region",
|
|
@@ -186,7 +186,7 @@ function me({
|
|
|
186
186
|
{
|
|
187
187
|
"aria-label": "Items Scroller",
|
|
188
188
|
"aria-live": "polite",
|
|
189
|
-
className:
|
|
189
|
+
className: i.carousel__scroller,
|
|
190
190
|
"data-scrollbar": e.current.showScrollbar,
|
|
191
191
|
ref: c,
|
|
192
192
|
role: "group",
|
|
@@ -205,9 +205,10 @@ function me({
|
|
|
205
205
|
fallback: /* @__PURE__ */ l(
|
|
206
206
|
"li",
|
|
207
207
|
{
|
|
208
|
+
className: g([i["carousel__loading-slide"], "carousel__loading-slide"]),
|
|
208
209
|
role: "presentation",
|
|
209
|
-
style: { aspectRatio:
|
|
210
|
-
children: /* @__PURE__ */ l(ne, {
|
|
210
|
+
style: { aspectRatio: "var(--_slide-aspect-ratio)", width: "100%" },
|
|
211
|
+
children: /* @__PURE__ */ l(ne, {})
|
|
211
212
|
}
|
|
212
213
|
),
|
|
213
214
|
children: N.length > 0 && N.map((n, t) => /* @__PURE__ */ l(
|
|
@@ -224,18 +225,18 @@ function me({
|
|
|
224
225
|
)
|
|
225
226
|
}
|
|
226
227
|
),
|
|
227
|
-
e.current.showControls && L.length > (e.current.cellsPerSlide ?? 1) && /* @__PURE__ */ j("div", { className:
|
|
228
|
+
e.current.showControls && L.length > (e.current.cellsPerSlide ?? 1) && /* @__PURE__ */ j("div", { className: i["carousel-controls"], children: [
|
|
228
229
|
/* @__PURE__ */ l(
|
|
229
230
|
"button",
|
|
230
231
|
{
|
|
231
232
|
"aria-controls": f.current,
|
|
232
233
|
"aria-label": "Previous Item",
|
|
233
|
-
className:
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
className: g([
|
|
235
|
+
i["carousel-controls__btn"],
|
|
236
|
+
i["carousel-controls__previous"],
|
|
236
237
|
"carousel-controls__previous"
|
|
237
238
|
]),
|
|
238
|
-
ref:
|
|
239
|
+
ref: w,
|
|
239
240
|
title: "Previous Item",
|
|
240
241
|
type: "button",
|
|
241
242
|
onClick: () => {
|
|
@@ -255,7 +256,7 @@ function me({
|
|
|
255
256
|
{
|
|
256
257
|
"aria-controls": f.current,
|
|
257
258
|
"aria-label": "Next Item",
|
|
258
|
-
className:
|
|
259
|
+
className: g([i["carousel-controls__btn"], i["carousel-controls__next"], "carousel-controls__next"]),
|
|
259
260
|
ref: T,
|
|
260
261
|
title: "Next Item",
|
|
261
262
|
type: "button",
|
|
@@ -272,10 +273,10 @@ function me({
|
|
|
272
273
|
}
|
|
273
274
|
)
|
|
274
275
|
] }),
|
|
275
|
-
e.current.showPagination && M.length > 1 && /* @__PURE__ */ l("div", { className: [
|
|
276
|
+
e.current.showPagination && M.length > 1 && /* @__PURE__ */ l("div", { className: [i["carousel-nav"], "carousel-nav"].join(" "), children: /* @__PURE__ */ l("ol", { className: i["carousel-nav__list"], ref: R, children: M.map((n, t) => /* @__PURE__ */ l(
|
|
276
277
|
"li",
|
|
277
278
|
{
|
|
278
|
-
className:
|
|
279
|
+
className: g([i["carousel-nav__item"], "carousel-nav__item"]),
|
|
279
280
|
"data-current": t === 0 ? "true" : "false",
|
|
280
281
|
title: `Navigate to slide ${t + 1}`,
|
|
281
282
|
onClick: () => {
|
package/package.json
CHANGED