@scrippsproduct/networks-ui-library 1.0.18-dev.0 → 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.
@@ -1,16 +1,16 @@
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 = {
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
+ function de({
11
+ id: g,
12
+ slides: x,
13
+ options: I = {
14
14
  paginationType: "dots",
15
15
  showControls: !0,
16
16
  controlArrowSize: 48,
@@ -31,189 +31,157 @@ function pe({
31
31
  wrapAround: !0
32
32
  }
33
33
  }) {
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
- showControls: !1,
41
- showPagination: !1,
42
- cellsPerSlide: 1,
43
- cellsPosition: o.current.wrapAround ? "center" : "flex-start",
44
- gutterSize: 10
45
- }), e.current = {
46
- ...o.current,
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,
47
40
  showControls: !1,
48
41
  showPagination: !1,
49
42
  cellsPerSlide: 1,
50
- cellsPosition: o.current.wrapAround ? "center" : "flex-start",
43
+ cellsPosition: l.current.wrapAround ? "center" : "flex-start",
51
44
  gutterSize: 10
52
- }) : L.matches ? o.current.cellsPerSlide !== 1 ? (d({
53
- ...o.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
- }), e.current = {
58
- ...o.current,
59
- cellsPerSlide: 2,
60
- showControls: !1,
61
- gutterSize: 10
62
- }) : (d({
63
- ...o.current,
50
+ } : e.current = {
51
+ ...l.current,
64
52
  showControls: !1,
65
53
  gutterSize: 10
66
- }), e.current = {
67
- ...o.current,
68
- showControls: !1,
69
- gutterSize: 10
70
- }) : R.matches ? o.current.cellsPerSlide !== 1 && o.current.cellsPerSlide !== 2 ? (d({
71
- ...o.current,
72
- cellsPerSlide: 3,
73
- showControls: !1,
74
- gutterSize: 10
75
- }), e.current = {
76
- ...o.current,
54
+ } : E.matches ? l.current.cellsPerSlide !== 1 && l.current.cellsPerSlide !== 2 ? e.current = {
55
+ ...l.current,
77
56
  cellsPerSlide: 3,
78
57
  showControls: !1,
79
58
  gutterSize: 10
80
- }) : (d({
81
- ...o.current,
59
+ } : e.current = {
60
+ ...l.current,
82
61
  showControls: !1,
83
62
  gutterSize: 10
84
- }), e.current = {
85
- ...o.current,
86
- showControls: !1,
87
- gutterSize: 10
88
- }) : I.matches ? o.current.showPagination ? (d({
89
- ...o.current,
63
+ } : L.matches ? l.current.showPagination ? e.current = {
64
+ ...l.current,
90
65
  showControls: !1
91
- }), e.current = {
92
- ...o.current,
93
- showControls: !1
94
- }) : (d({
95
- ...o.current
96
- }), e.current = {
97
- ...o.current
98
- }) : (d({
99
- ...o.current
100
- }), e.current = {
101
- ...o.current
102
- });
66
+ } : e.current = {
67
+ ...l.current
68
+ } : e.current = {
69
+ ...l.current
70
+ };
103
71
  };
104
- n();
105
- const l = () => {
106
- q((h) => h + 1), n();
72
+ t();
73
+ const n = () => {
74
+ U((u) => u + 1), t();
107
75
  };
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);
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);
110
78
  };
111
79
  }, []);
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
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
121
89
  };
122
90
  }
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(() => {
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(() => {
126
94
  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", () => {
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", () => {
133
101
  r.current.handleScrollEnd();
134
102
  }, { once: !0 });
135
- }, [m]), A = f(() => {
136
- m(), u.current.addEventListener("scrollend", () => {
137
- r.current.handleScrollEnd(), u.current.addEventListener("scroll", A, { once: !0 });
103
+ }, [f]), v = d(() => {
104
+ f(), i.current.addEventListener("scrollend", () => {
105
+ r.current.handleScrollEnd(), i.current.addEventListener("scroll", v, { once: !0 });
138
106
  }, { once: !0 });
139
- }, [m]), X = () => {
107
+ }, [f]), q = () => {
140
108
  r.current && e.current.autoplay && r.current.clearTimer();
141
- }, z = f(() => {
109
+ }, y = d(() => {
142
110
  //! make sure class is only instantiated once because of reacts
143
111
  //! "strict" mode double do hocus pocus
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,
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({
114
+ carouselEl: R.current,
115
+ scrollerEl: i.current,
116
+ paginationEl: $.current,
117
+ slides: m.current,
150
118
  navBtnEls: {
151
- next: M.current,
152
- previous: y.current
119
+ next: T.current,
120
+ previous: S.current
153
121
  },
154
- id: w.current,
122
+ id: p.current,
155
123
  options: {
156
124
  autoplay: e.current.autoplay,
157
- wrapAround: e.current.wrapAround && g.current.length > e.current.cellsPerSlide,
125
+ wrapAround: e.current.wrapAround && m.current.length > e.current.cellsPerSlide,
158
126
  showPagination: e.current.showPagination,
159
127
  delay: e.current.autoplayDelay,
160
128
  slideGutterSize: e.current.gutterSize,
161
129
  slideAspectRatio: e.current.slideAspectRatio,
162
- showControls: e.current.showControls && g.current.length > e.current.cellsPerSlide,
130
+ showControls: e.current.showControls && m.current.length > e.current.cellsPerSlide,
163
131
  cellsPerSlide: e.current.cellsPerSlide
164
132
  }
165
133
  });
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());
134
+ }, [D]), V = d(() => {
135
+ i.current.addEventListener("scroll", v, { once: !0 });
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());
172
140
  }, 100);
173
141
  } else {
174
- let n = setInterval(() => {
175
- u.current !== null && (clearInterval(n), z());
142
+ let t = setInterval(() => {
143
+ i.current !== null && (clearInterval(t), y());
176
144
  }, 100);
177
145
  }
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)`;
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)`;
184
152
  }
185
- B();
153
+ j();
186
154
  }
187
155
  return () => {
188
- X();
156
+ q();
189
157
  };
190
- }, [B, t]), /* @__PURE__ */ s(ee, { children: t !== null && /* @__PURE__ */ G(
158
+ }, [j, e]), /* @__PURE__ */ o(X, { children: e.current !== null && /* @__PURE__ */ K(
191
159
  "div",
192
160
  {
193
- className: i.carousel,
194
- id: w.current,
195
- ref: T,
161
+ className: a.carousel,
162
+ id: p.current,
163
+ ref: R,
196
164
  tabIndex: -1,
197
165
  role: "region",
198
166
  "aria-roledescription": "carousel",
199
- "aria-label": t.title,
200
- onKeyDown: J,
167
+ "aria-label": e.current.title,
168
+ onKeyDown: F,
201
169
  style: {
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
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
210
178
  },
211
179
  children: [
212
- /* @__PURE__ */ s(
180
+ /* @__PURE__ */ o(
213
181
  "ol",
214
182
  {
215
- className: i.carousel__scroller,
216
- ref: u,
183
+ className: a.carousel__scroller,
184
+ ref: i,
217
185
  role: "group",
218
186
  "aria-label": "Items Scroller",
219
187
  "aria-live": "Polite",
@@ -224,29 +192,29 @@ function pe({
224
192
  onMouseLeave: () => {
225
193
  e.current.autoplay && r.current !== null && r.current.startTimer();
226
194
  },
227
- onTouchStart: Q,
228
- "data-scrollbar": t.showScrollbar,
229
- children: O.length > 0 && O.map((n, l) => /* @__PURE__ */ s(
230
- te,
195
+ onTouchStart: W,
196
+ "data-scrollbar": e.current.showScrollbar,
197
+ children: M.length > 0 && M.map((t, n) => /* @__PURE__ */ o(
198
+ Z,
231
199
  {
232
- slide: n,
233
- index: l,
234
- currentIndex: t.wrapAround ? 1 : 0,
235
- variableHeight: t.variableHeight
200
+ slide: t,
201
+ index: n,
202
+ currentIndex: e.current.wrapAround ? 1 : 0,
203
+ variableHeight: e.current.variableHeight
236
204
  },
237
- `carousel${C}-slide${l}`
205
+ `carousel${g}-slide${n}`
238
206
  ))
239
207
  }
240
208
  ),
241
- t.showControls && $.length > e.current.cellsPerSlide && /* @__PURE__ */ G("div", { className: i["carousel-controls"], children: [
242
- /* @__PURE__ */ s(
209
+ e.current.showControls && x.length > e.current.cellsPerSlide && /* @__PURE__ */ K("div", { className: a["carousel-controls"], children: [
210
+ /* @__PURE__ */ o(
243
211
  "button",
244
212
  {
245
213
  type: "button",
246
- ref: y,
214
+ ref: S,
247
215
  title: "Previous Item",
248
- className: E([i["carousel-controls__btn"], i["carousel-controls__previous"], "carousel-controls__previous"]),
249
- "aria-controls": w.current,
216
+ className: _([a["carousel-controls__btn"], a["carousel-controls__previous"], "carousel-controls__previous"]),
217
+ "aria-controls": p.current,
250
218
  "aria-label": "Previous Item",
251
219
  onClick: () => {
252
220
  r.current.determineScrollAction(-1);
@@ -257,17 +225,17 @@ function pe({
257
225
  onMouseLeave: () => {
258
226
  e.current.autoplay && r.current !== null && r.current.startTimer();
259
227
  },
260
- children: /* @__PURE__ */ s("i", { "aria-hidden": "true", children: /* @__PURE__ */ s(le, { width: t.controlArrowSize, height: t.controlArrowSize }) })
228
+ children: /* @__PURE__ */ o("i", { "aria-hidden": "true", children: /* @__PURE__ */ o(re, { width: e.current.controlArrowSize, height: e.current.controlArrowSize }) })
261
229
  }
262
230
  ),
263
- /* @__PURE__ */ s(
231
+ /* @__PURE__ */ o(
264
232
  "button",
265
233
  {
266
234
  type: "button",
267
- ref: M,
235
+ ref: T,
268
236
  title: "Next Item",
269
- className: E([i["carousel-controls__btn"], i["carousel-controls__next"], "carousel-controls__next"]),
270
- "aria-controls": w.current,
237
+ className: _([a["carousel-controls__btn"], a["carousel-controls__next"], "carousel-controls__next"]),
238
+ "aria-controls": p.current,
271
239
  "aria-label": "Next Item",
272
240
  onClick: () => {
273
241
  r.current.determineScrollAction(1);
@@ -278,27 +246,27 @@ function pe({
278
246
  onMouseLeave: () => {
279
247
  e.current.autoplay && r.current !== null && r.current.startTimer();
280
248
  },
281
- children: /* @__PURE__ */ s("i", { "aria-hidden": "true", children: /* @__PURE__ */ s(oe, { width: t.controlArrowSize, height: t.controlArrowSize }) })
249
+ children: /* @__PURE__ */ o("i", { "aria-hidden": "true", children: /* @__PURE__ */ o(te, { width: e.current.controlArrowSize, height: e.current.controlArrowSize }) })
282
250
  }
283
251
  )
284
252
  ] }),
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(
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(
286
254
  "li",
287
255
  {
288
- className: E([i["carousel-nav__item"], "carousel-nav__item"]),
289
- "data-current": l === 0 ? "true" : "false",
256
+ className: _([a["carousel-nav__item"], "carousel-nav__item"]),
257
+ "data-current": n === 0 ? "true" : "false",
290
258
  onClick: () => {
291
- r.current.navigateToIndex(l);
259
+ r.current.navigateToIndex(n);
292
260
  },
293
- title: `Navigate to slide ${l + 1}`
261
+ title: `Navigate to slide ${n + 1}`
294
262
  },
295
- `carousel${w}-nav-${l}`
263
+ `carousel${p}-nav-${n}`
296
264
  )) }) })
297
265
  ]
298
266
  }
299
267
  ) });
300
268
  }
301
269
  export {
302
- pe as Carousel,
303
- pe as default
270
+ de as Carousel,
271
+ de as default
304
272
  };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.18-dev.0",
2
+ "version": "1.0.18-dev.1",
3
3
  "name": "@scrippsproduct/networks-ui-library",
4
4
  "description": "React Component Library for use in Scripps Networks external applications",
5
5
  "author": {