@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.
@@ -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
+ };
@@ -1 +1 @@
1
- ._carousel_idy2d_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_idy2d_11{display:flex;box-sizing:border-box;overflow-x:auto;scroll-behavior:smooth;overscroll-behavior-x:contain;scroll-snap-type:x mandatory;scroll-snap-align:center;scroll-padding-inline:var(--_carousel-gutters);padding-inline:var(--_carousel-gutters);scrollbar-width:none;list-style:none;margin:0}._carousel__scroller_idy2d_11[data-scrollbar=true]{scrollbar-width:auto;overflow-x:scroll}._carousel__scroller_idy2d_11:not([data-scrollbar=true])::-webkit-scrollbar{display:none}._carousel__scroller_idy2d_11::-webkit-scrollbar{display:auto}._carousel-controls_idy2d_39{display:contents}._carousel-controls__btn_idy2d_43{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_idy2d_43>i>svg{display:block;block-size:auto;max-inline-size:100%;stroke:currentColor}._carousel-controls__btn_idy2d_43[disabled]{opacity:0}._carousel-controls__previous_idy2d_68{inset-inline-start:var(--_control-btns-offset-x)}._carousel-controls__previous_idy2d_68 svg{transform:translate(-2px)}._carousel-controls__next_idy2d_75{inset-inline-end:var(--_control-btns-offset-x)}._carousel-controls__next_idy2d_75 svg{transform:translate(2px)}._carousel-controls__btn_idy2d_43[disabled]{cursor:not-allowed;transition-delay:0s}._carousel-nav_idy2d_87{margin-top:0}._carousel-nav__list_idy2d_91{display:flex;gap:1rem;justify-content:center;align-items:flex-start;list-style:none;padding:0}._carousel-nav__item_idy2d_100{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_idy2d_100[data-current=true]{background-color:#8080801a}
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}
@@ -19,7 +19,6 @@ export function Carousel({ id, slides, options }: {
19
19
  cellsPerSlide: number;
20
20
  cellAspectRatio: string;
21
21
  cellsPosition: string;
22
- groupSlides: boolean;
23
22
  wrapAround: boolean;
24
23
  } | undefined;
25
24
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,16 +1,16 @@
1
- import { jsx as o, Fragment as W, jsxs as O } from "react/jsx-runtime";
2
- import { useRef as c, useState as A, useEffect as V, useCallback as u } from "react";
3
- import q from "./CarouselUtils.class.js";
4
- import { CarouselSlide as J } from "../CarouselSlide/CarouselSlide.js";
5
- import { chunkArray as Q, classes as z } from "../../utils/helpers.js";
6
- import { c as a } from "../../Carousel.module-CzL9vVtu.mjs";
7
- import { C as X } from "../../chevron-left-DmvQntvu.mjs";
8
- import { C as Y } from "../../chevron-right-CaAz6ISN.mjs";
9
- const Z = window.matchMedia("(max-width: 600px)"), ee = window.matchMedia("(max-width: 800px"), re = window.matchMedia("(max-width: 1024px"), te = window.matchMedia("(max-width: 1280px");
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: b,
13
- options: x = {
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
- const m = c(`carousel-${_}`), R = c(null), i = c(null), I = c(null), w = c(b), E = c(null), g = c(null), t = c(null), e = c(x), $ = c(x.showPagination), T = c("-50%"), [N, j] = A([]), [r, d] = A(null), [k, B] = A([]);
36
- V(() => {
37
- (() => {
38
- Z.matches ? (d({
39
- ...e.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,
40
40
  showControls: !1,
41
41
  showPagination: !1,
42
42
  cellsPerSlide: 1,
43
- cellsPosition: e.current.wrapAround ? "center" : "flex-start",
43
+ cellsPosition: l.current.wrapAround ? "center" : "flex-start",
44
44
  gutterSize: 10
45
- }), e.current = {
46
- ...e.current,
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
- }), e.current = {
58
- ...e.current,
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
- }) : re.matches ? e.current.cellsPerSlide > 3 ? (d({
71
- ...e.current,
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
- }), e.current = {
76
- ...e.current,
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
- }) : te.matches && e.current.showPagination ? (d({
89
- ...e.current,
63
+ } : L.matches ? l.current.showPagination ? e.current = {
64
+ ...l.current,
90
65
  showControls: !1
91
- }), e.current = {
92
- ...e.current,
93
- showControls: !1
94
- }) : d({
95
- ...e.current
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 L = u((l, n) => {
100
- const p = Q(n, l);
101
- B([...p]);
102
- let f = [];
103
- for (let s = 0; s <= p.length - 1; s++) {
104
- f[s] = {}, f[s].ariaLabel = `${s + 1} of ${p.length}`, f[s].layout = p[s][0].layout, f[s].cells = [];
105
- for (let S = 0; S <= p[s].length - 1; S++)
106
- f[s].cells[S] = {
107
- props: p[s][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
108
89
  };
109
90
  }
110
- const P = [...f], y = [...f], K = P.slice(-1), F = P.slice(0);
111
- return y.push(F[0]), y.unshift(K[0]), e.current.wrapAround && l.length > n ? y : P;
112
- }, []), h = u(() => {
113
- e.current.autoplay && t.current.clearTimer();
114
- }, []), G = u((l) => {
115
- h();
116
- const n = l.key;
117
- n === "ArrowLeft" ? (l.preventDefault(), t.current.determineScrollAction(-1)) : n === "ArrowRight" && (l.preventDefault(), t.current.determineScrollAction(1));
118
- }, [h]), H = u(() => {
119
- h(), i.current.addEventListener("scrollend", () => {
120
- t.current.handleScrollEnd();
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
- }, [h]), v = u(() => {
123
- h(), i.current.addEventListener("scrollend", () => {
124
- t.current.handleScrollEnd(), i.current.addEventListener("scroll", v, { once: !0 });
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
- }, [h]), U = () => {
127
- t.current && e.current.autoplay && t.current.clearTimer();
128
- }, C = u(() => {
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
- t.current === null && (t.current = new q({
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: I.current,
135
- slides: w.current,
116
+ paginationEl: $.current,
117
+ slides: m.current,
136
118
  navBtnEls: {
137
- next: E.current,
138
- previous: g.current
119
+ next: T.current,
120
+ previous: S.current
139
121
  },
140
- id: m.current,
122
+ id: p.current,
141
123
  options: {
142
124
  autoplay: e.current.autoplay,
143
- wrapAround: e.current.wrapAround && w.current.length > e.current.cellsPerSlide,
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 && w.current.length > e.current.cellsPerSlide,
130
+ showControls: e.current.showControls && m.current.length > e.current.cellsPerSlide,
149
131
  cellsPerSlide: e.current.cellsPerSlide
150
132
  }
151
- }));
152
- }, []), M = u(() => {
133
+ });
134
+ }, [D]), V = d(() => {
153
135
  i.current.addEventListener("scroll", v, { once: !0 });
154
- }, [v]), D = u(() => {
155
- if (j(L(w.current, e.current.cellsPerSlide)), w.current.length > e.current.cellsPerSlide) {
156
- let l = setInterval(() => {
157
- i.current !== null && (g.current !== null && e.current.showControls || !e.current.showControls) && (clearInterval(l), M(), C());
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 l = setInterval(() => {
161
- i.current !== null && (clearInterval(l), C());
142
+ let t = setInterval(() => {
143
+ i.current !== null && (clearInterval(t), y());
162
144
  }, 100);
163
145
  }
164
- }, [L, M, C]);
165
- return V(() => {
166
- if (r !== null) {
167
- if (r.showControls) {
168
- let l = 0;
169
- r.showPagination && (l = l + 25), r.showScrollbar && (l = l + 6), T.current = `calc(-50% - ${l}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)`;
170
152
  }
171
- D();
153
+ j();
172
154
  }
173
155
  return () => {
174
- U();
156
+ q();
175
157
  };
176
- }, [D, r]), /* @__PURE__ */ o(W, { children: r !== null && /* @__PURE__ */ O(
158
+ }, [j, e]), /* @__PURE__ */ o(X, { children: e.current !== null && /* @__PURE__ */ K(
177
159
  "div",
178
160
  {
179
161
  className: a.carousel,
180
- id: m.current,
162
+ id: p.current,
181
163
  ref: R,
182
164
  tabIndex: -1,
183
165
  role: "region",
184
166
  "aria-roledescription": "carousel",
185
- "aria-label": r.title,
186
- onKeyDown: G,
167
+ "aria-label": e.current.title,
168
+ onKeyDown: F,
187
169
  style: {
188
- "--_carousel-gutters": r.wrapAround ? `${r.gutterSize <= 25 ? r.gutterSize : 25}%` : `0 ${r.gutterSize <= 25 ? r.gutterSize : 25}%`,
189
- "--_slide-aspect-ratio": r.slideAspectRatio,
190
- "--_cell-aspect-ratio": r.cellAspectRatio,
191
- "--_slide-cell-size": `${100 / r.cellsPerSlide}%`,
192
- "--_cells-position": r.cellsPosition,
193
- "--_control-btns-offset-x": `${r.controlButtonsOffset}rem`,
194
- "--_slide-gap": `${r.slideGap}rem`,
195
- "--_controls-transform": T.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
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 && t.current !== null && t.current.clearTimer();
190
+ e.current.autoplay && r.current !== null && r.current.clearTimer();
209
191
  },
210
192
  onMouseLeave: () => {
211
- e.current.autoplay && t.current !== null && t.current.startTimer();
193
+ e.current.autoplay && r.current !== null && r.current.startTimer();
212
194
  },
213
- onTouchStart: H,
214
- "data-scrollbar": r.showScrollbar,
215
- children: N.length > 0 && N.map((l, n) => /* @__PURE__ */ o(
216
- J,
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: l,
200
+ slide: t,
219
201
  index: n,
220
- currentIndex: r.wrapAround ? 1 : 0,
221
- variableHeight: r.variableHeight
202
+ currentIndex: e.current.wrapAround ? 1 : 0,
203
+ variableHeight: e.current.variableHeight
222
204
  },
223
- `carousel${_}-slide${n}`
205
+ `carousel${g}-slide${n}`
224
206
  ))
225
207
  }
226
208
  ),
227
- r.showControls && b.length > e.current.cellsPerSlide && /* @__PURE__ */ O("div", { className: a["carousel-controls"], children: [
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: g,
214
+ ref: S,
233
215
  title: "Previous Item",
234
- className: z([
235
- a["carousel-controls__btn"],
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
- t.current.determineScrollAction(-1);
220
+ r.current.determineScrollAction(-1);
243
221
  },
244
222
  onMouseEnter: () => {
245
- e.current.autoplay && t.current !== null && t.current.clearTimer();
223
+ e.current.autoplay && r.current !== null && r.current.clearTimer();
246
224
  },
247
225
  onMouseLeave: () => {
248
- e.current.autoplay && t.current !== null && t.current.startTimer();
226
+ e.current.autoplay && r.current !== null && r.current.startTimer();
249
227
  },
250
- children: /* @__PURE__ */ o("i", { "aria-hidden": "true", children: /* @__PURE__ */ o(X, { width: r.controlArrowSize, height: r.controlArrowSize }) })
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: E,
235
+ ref: T,
258
236
  title: "Next Item",
259
- className: z([a["carousel-controls__btn"], a["carousel-controls__next"], "carousel-controls__next"]),
260
- "aria-controls": m.current,
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
- t.current.determineScrollAction(1);
241
+ r.current.determineScrollAction(1);
264
242
  },
265
243
  onMouseEnter: () => {
266
- e.current.autoplay && t.current !== null && t.current.clearTimer();
244
+ e.current.autoplay && r.current !== null && r.current.clearTimer();
267
245
  },
268
246
  onMouseLeave: () => {
269
- e.current.autoplay && t.current !== null && t.current.startTimer();
247
+ e.current.autoplay && r.current !== null && r.current.startTimer();
270
248
  },
271
- children: /* @__PURE__ */ o("i", { "aria-hidden": "true", children: /* @__PURE__ */ o(Y, { width: r.controlArrowSize, height: r.controlArrowSize }) })
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
- $.current && k.length > 1 && /* @__PURE__ */ o("div", { className: [a["carousel-nav"], "carousel-nav"].join(" "), children: /* @__PURE__ */ o("ol", { className: a["carousel-nav__list"], ref: I, children: k.map((l, n) => /* @__PURE__ */ o(
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: z([a["carousel-nav__item"], "carousel-nav__item"]),
256
+ className: _([a["carousel-nav__item"], "carousel-nav__item"]),
279
257
  "data-current": n === 0 ? "true" : "false",
280
258
  onClick: () => {
281
- t.current.navigateToIndex(n);
259
+ r.current.navigateToIndex(n);
282
260
  },
283
261
  title: `Navigate to slide ${n + 1}`
284
262
  },
285
- `carousel${m}-nav-${n}`
263
+ `carousel${p}-nav-${n}`
286
264
  )) }) })
287
265
  ]
288
266
  }
@@ -1,55 +1,54 @@
1
- var w = (o) => {
2
- throw TypeError(o);
1
+ var g = (r) => {
2
+ throw TypeError(r);
3
3
  };
4
- var G = (o, t, s) => t.has(o) || w("Cannot " + s);
5
- var y = (o, t, s) => t.has(o) ? w("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(o) : t.set(o, s);
6
- var i = (o, t, s) => (G(o, t, "access private method"), s);
7
- var e, T, S, L, p, f, v, B, A, z;
8
- class N {
9
- constructor({ carouselEl: t, scrollerEl: s, paginationEl: a, slides: O, navBtnEls: P = { next: {}, previous: {} }, options: n }) {
10
- y(this, e);
11
- if (!("onscrollend" in window)) {
12
- let d = function(h, r, b) {
13
- let c = h[r];
14
- h[r] = function() {
15
- let l = Array.prototype.slice.apply(arguments, [0]);
16
- c.apply(this, l), l.unshift(c), b.apply(this, l);
17
- };
18
- }, I = function(h, r, b, c) {
19
- if (r !== "scroll" && r !== "scrollend")
20
- return;
21
- let l = this, u = E.get(l);
22
- if (u === void 0) {
23
- let x = 0;
24
- u = {
25
- scrollListener: (W) => {
26
- clearTimeout(x), x = setTimeout(() => {
27
- m.size ? setTimeout(u.scrollListener, 100) : (l.dispatchEvent(C), x = 0);
28
- }, 100);
29
- },
30
- listeners: 0
31
- // Count of number of listeners.
32
- }, h.apply(l, ["scroll", u.scrollListener]), E.set(l, u);
33
- }
34
- u.listeners++;
35
- }, g = function(h, r, b) {
36
- if (r !== "scroll" && r !== "scrollend")
37
- return;
38
- let c = this, l = E.get(c);
39
- l !== void 0 && (l[r]--, !(--l.listeners > 0) && (h.apply(c, ["scroll", l.scrollListener]), E.delete(c)));
40
- };
41
- const C = new Event("scrollend"), m = /* @__PURE__ */ new Set();
42
- document.addEventListener("touchstart", (h) => {
43
- for (let r of h.changedTouches)
44
- m.add(r.identifier);
45
- }, { passive: !0 }), document.addEventListener("touchend", (h) => {
46
- for (let r of h.changedTouches)
47
- m.delete(r.identifier);
48
- }, { passive: !0 });
49
- let E = /* @__PURE__ */ new WeakMap();
50
- d(Element.prototype, "addEventListener", I), d(window, "addEventListener", I), d(document, "addEventListener", I), d(Element.prototype, "removeEventListener", g), d(window, "removeEventListener", g), d(document, "removeEventListener", g);
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, e, f).call(this, t), this.currentIndex = 0) : (i(this, e, f).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, e, f).call(this, t)) : (i(this, e, f).call(this, t), this.currentIndex -= 1)), this.options.autoplay && this.timer === null && this.startTimer();
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 s = t > this.currentIndex ? t - this.currentIndex : this.currentIndex - t, a = t > this.currentIndex ? 1 : -1;
88
- this.currentIndex = t, i(this, e, f).call(this, a, s), this.options.autoplay && this.startTimer(), i(this, e, v).call(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, e, v).call(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, e, p).call(this, { scrollport: this.scrollerEl, element: this.slideEls[this.totalSlides] })) : t === this.totalSlideEls - 1 ? (this.currentIndex = 0, i(this, e, p).call(this, { scrollport: this.scrollerEl, element: this.slideEls[1] })) : this.currentIndex = t - 1;
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, e, v).call(this);
110
+ i(this, s, c).call(this);
112
111
  }
113
112
  }
114
- e = new WeakSet(), /**
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
- T = function() {
117
+ x = function() {
119
118
  this.carouselObserver = new IntersectionObserver((t) => {
120
- for (let s of t)
121
- s.isIntersecting && (this.currentIntersecting = s);
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
- S = function() {
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
- L = function() {
136
- this.options.wrapAround ? (this.scrollerEl.style.scrollBehavior = "auto", this.scrollerEl.scrollTo(-9999, 0), i(this, e, p).call(this, { scrollport: this.scrollerEl, element: this.scrollerEl.children[1] })) : this.options.showControls ? (this.navBtnEls.previous.setAttribute("disabled", !0), i(this, e, v).call(this)) : i(this, e, A).call(this), this.totalSlides === 1 && this.slideEls[0].removeAttribute("inert");
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
- p = function({ scrollport: t, element: s }) {
142
- const a = this.slideGutterSize * 2 / 100;
143
- t.style.scrollBehavior = "auto", t.scrollTo(Math.abs(t.offsetLeft - s.offsetLeft + s.clientWidth * a), 0);
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
- f = function(t, s = 1) {
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) * s * t,
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
- v = function() {
163
- i(this, e, A).call(this), this.showPagination && i(this, e, z).call(this), this.options.wrapAround || i(this, e, B).call(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
- B = function() {
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
- A = function() {
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((s, a) => {
175
- s.toggleAttribute("inert", a !== t);
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
- z = function() {
181
- [...this.paginationEl.children].forEach((t, s) => {
182
- s === this.currentIndex ? t.setAttribute("data-current", "true") : t.setAttribute("data-current", "false");
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
- N as default
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-CzL9vVtu.mjs";
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,5 +1,5 @@
1
1
  {
2
- "version": "1.0.17",
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": {
@@ -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
- };