@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 Y, jsxs as j } from "react/jsx-runtime";
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
- import re from "./CarouselUtils.class.js";
5
- import { CarouselSlide as te } from "../CarouselSlide/CarouselSlide.js";
6
- import { Loading as ne } from "../Loading/Loading.js";
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 le } from "../../chevron-left-D0UjbrKw.mjs";
9
- import { C as ce } from "../../chevron-right-0ZF3LruR.mjs";
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 me({
11
+ function ge({
12
12
  id: E,
13
13
  cells: L,
14
- options: I = {
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 f = a(`carousel-${E}`), x = a(null), c = a(null), R = a(null), p = a([...L]), $ = a(null), w = a(null), r = a(null), e = a(I), o = a(I), N = a("-50%"), [T, G] = m([]), [M, H] = m([]), [k, U] = m(0), [F, D] = m(!1);
36
- B(() => {
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
- U((s) => s + 1), t();
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 = ee(n, t);
82
- H([...s]);
81
+ const s = re(n, t);
82
+ U([...s]);
83
83
  let y = [];
84
- for (let h = 0; h <= s.length - 1; h++)
85
- y[h] = {
86
- ariaLabel: `${h + 1} of ${s.length}`,
87
- layout: s[h][0].layout || "",
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[h]
89
+ ...s[f]
90
90
  ]
91
91
  };
92
- const _ = [...y], C = [...y], Q = _.slice(-1), X = _.slice(0);
93
- return C.push(X[0]), C.unshift(Q[0]), e.current.wrapAround && t.length > n ? C : _;
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]), q = u(() => {
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]), J = () => {
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 re({
116
- carouselEl: x.current,
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: f.current,
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 = u(() => {
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
- G(t);
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 && c.current.children.length >= n && (w.current !== null && e.current.showControls || !e.current.showControls) && (clearInterval(s), V(), v());
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 && c.current.children.length >= n && (clearInterval(s), v());
151
+ c.current !== null && K() >= n && (clearInterval(s), v());
149
152
  }, 100);
150
153
  }
151
154
  }, [O, V, v]);
152
- return B(() => {
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
- K();
161
+ j();
159
162
  }
160
163
  return () => {
161
- J();
164
+ Q();
162
165
  };
163
- }, [K, e]), /* @__PURE__ */ l(Y, { children: e.current !== null && /* @__PURE__ */ j(
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: f.current,
170
- ref: x,
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: q,
205
+ onTouchStart: J,
203
206
  children: /* @__PURE__ */ l(
204
- Z,
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(ne, {})
215
+ children: /* @__PURE__ */ l(le, {})
213
216
  }
214
217
  ),
215
218
  children: T.length > 0 && T.map((t, n) => /* @__PURE__ */ l(
216
- te,
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__ */ j("div", { className: i["carousel-controls"], children: [
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": f.current,
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(le, { height: e.current.controlArrowSize, width: e.current.controlArrowSize }) })
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": f.current,
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(ce, { height: e.current.controlArrowSize, width: e.current.controlArrowSize }) })
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${f}-nav-${n}`
290
+ `carousel${h}-nav-${n}`
288
291
  )) }) })
289
292
  ]
290
293
  }
291
294
  ) });
292
295
  }
293
296
  export {
294
- me as Carousel,
295
- me as default
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, p) {
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), p.apply(this, a);
14
+ d.apply(this, a), a.unshift(d), m.apply(this, a);
15
15
  };
16
- }, h = function(o, i, p, d) {
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 m = 0;
20
+ let I = 0;
21
21
  u = { scrollListener: (O) => {
22
- clearTimeout(m), m = setTimeout(() => {
23
- r.size ? setTimeout(u.scrollListener, 100) : (a && a.dispatchEvent(new Event("scrollend")), m = 0);
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, p) {
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, I, A;
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, I).call(this), this.totalSlideEls === 1 && this.slideEls[0].removeAttribute("inert");
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, I).call(this), this.showPagination && l(this, s, A).call(this), this.options.wrapAround || l(this, s, S).call(this);
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
- I = function() {
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
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.0.5",
2
+ "version": "2.0.6-alpha.0",
3
3
  "name": "@scrippsproduct/networks-ui-library",
4
4
  "description": "React Component Library for use in Scripps Networks external applications",
5
5
  "author": {