@scrippsproduct/networks-ui-library 2.0.4 → 2.0.5
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.
- package/dist/Carousel.module-Nwf_zL9b.mjs +14 -0
- package/dist/assets/Carousel.css +1 -1
- package/dist/assets/FindUs.css +1 -1
- package/dist/assets/LogoListItem.css +1 -1
- package/dist/components/AnchorTag/AnchorTag.js +12 -12
- package/dist/components/AnchorTag/AnchorTag.test.js +9 -19
- package/dist/components/BCVideoPlayer/BCVideoPlayer.js +58 -46
- package/dist/components/BCVideoPlayer/BCVideoPlayer.test.js +3 -3
- package/dist/components/Carousel/Carousel.js +37 -36
- package/dist/components/Carousel/Carousel.test.js +71 -68
- package/dist/components/Carousel/CarouselUtils.class.js +104 -97
- package/dist/components/Carousel/navigations/Pagination.js +2 -2
- package/dist/components/Carousel/navigations/Pagination.test.js +23 -23
- package/dist/components/CarouselSlide/CarouselSlide.test.js +58 -57
- package/dist/components/FindUs/FindUs.js +119 -90
- package/dist/components/GridList/GridList.js +6 -6
- package/dist/components/ImageCard/ImageCardCore.js +65 -69
- package/dist/components/ImageCard/ImageCardCore.test.js +2 -2
- package/dist/components/LogoListItem/LogoListItem.js +13 -13
- package/dist/components/PromotionsRowModule/PromotionsRowModule.js +42 -38
- package/dist/components/PromotionsRowModule/PromotionsRowModule.test.js +163 -149
- package/dist/hooks/useSourcepointPrivacyTrigger.js +4 -4
- package/dist/src/components/Carousel/CarouselUtils.class.d.ts +8 -3
- package/dist/src/components/Carousel/navigations/Pagination.d.ts +1 -1
- package/dist/src/components/PromotionsRowModule/PromotionsRowModule.d.ts +2 -1
- package/dist/src/hooks/useSourcepointPrivacyTrigger.d.ts +13 -2
- package/package.json +3 -2
- package/dist/Carousel.module-BsPaZX5L.mjs +0 -14
|
@@ -1,82 +1,78 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
throw TypeError(
|
|
1
|
+
var T = Object.defineProperty;
|
|
2
|
+
var g = (r) => {
|
|
3
|
+
throw TypeError(r);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
e = {
|
|
25
|
-
scrollListener: () => {
|
|
26
|
-
clearTimeout(n), n = setTimeout(() => {
|
|
27
|
-
I.size ? setTimeout(e.scrollListener, 100) : (this.dispatchEvent(P), n = 0);
|
|
5
|
+
var B = (r, t, e) => t in r ? T(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
6
|
+
var n = (r, t, e) => B(r, typeof t != "symbol" ? t + "" : t, e), L = (r, t, e) => t.has(r) || g("Cannot " + e);
|
|
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
|
+
var l = (r, t, e) => (L(r, t, "access private method"), e);
|
|
9
|
+
if (typeof window < "u" && !("onscrollend" in window)) {
|
|
10
|
+
let e = function(o, i, p) {
|
|
11
|
+
let d = o[i];
|
|
12
|
+
o[i] = function() {
|
|
13
|
+
let a = Array.prototype.slice.apply(arguments, [0]);
|
|
14
|
+
d.apply(this, a), a.unshift(d), p.apply(this, a);
|
|
15
|
+
};
|
|
16
|
+
}, h = function(o, i, p, d) {
|
|
17
|
+
if (i != "scroll" && i != "scrollend") return;
|
|
18
|
+
let a = this, u = t.get(a);
|
|
19
|
+
if (u === void 0) {
|
|
20
|
+
let m = 0;
|
|
21
|
+
u = { scrollListener: (O) => {
|
|
22
|
+
clearTimeout(m), m = setTimeout(() => {
|
|
23
|
+
r.size ? setTimeout(u.scrollListener, 100) : (a && a.dispatchEvent(new Event("scrollend")), m = 0);
|
|
28
24
|
}, 100);
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
25
|
+
}, listeners: 0 }, o.apply(a, ["scroll", u.scrollListener, { passive: !0 }]), t.set(a, u);
|
|
26
|
+
}
|
|
27
|
+
u.listeners++;
|
|
28
|
+
}, c = function(o, i, p) {
|
|
29
|
+
if (i != "scroll" && i != "scrollend") return;
|
|
30
|
+
let d = this, a = t.get(d);
|
|
31
|
+
a !== void 0 && (--a.listeners > 0 || (o.apply(d, ["scroll", a.scrollListener]), t.delete(d)));
|
|
32
|
+
};
|
|
33
|
+
const r = /* @__PURE__ */ new Set();
|
|
34
|
+
document.addEventListener("touchstart", (o) => {
|
|
35
|
+
for (let i of o.changedTouches) r.add(i.identifier);
|
|
36
|
+
}, { passive: !0 }), document.addEventListener("touchend", (o) => {
|
|
37
|
+
for (let i of o.changedTouches) r.delete(i.identifier);
|
|
38
|
+
}, { passive: !0 }), document.addEventListener("touchcancel", (o) => {
|
|
39
|
+
for (let i of o.changedTouches) r.delete(i.identifier);
|
|
40
|
+
}, { passive: !0 });
|
|
41
|
+
let t = /* @__PURE__ */ new WeakMap();
|
|
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);
|
|
40
43
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
class M {
|
|
44
|
+
var s, E, b, x, y, f, v, S, I, A;
|
|
45
|
+
class C {
|
|
44
46
|
constructor({
|
|
45
47
|
carouselEl: t,
|
|
46
48
|
scrollerEl: e,
|
|
47
|
-
paginationEl:
|
|
49
|
+
paginationEl: h,
|
|
48
50
|
cells: c,
|
|
49
|
-
navBtnEls:
|
|
51
|
+
navBtnEls: o = {
|
|
50
52
|
next: {},
|
|
51
53
|
previous: {}
|
|
52
54
|
},
|
|
53
|
-
options:
|
|
55
|
+
options: i
|
|
54
56
|
}) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
for (let E of v.changedTouches)
|
|
75
|
-
I.add(E.identifier);
|
|
76
|
-
}, { passive: !0 }), document.addEventListener("touchend", (v) => {
|
|
77
|
-
for (let E of v.changedTouches)
|
|
78
|
-
I.delete(E.identifier);
|
|
79
|
-
}, { passive: !0 }), h(Element.prototype, "addEventListener", m), h(window, "addEventListener", m), h(document, "addEventListener", m), h(Element.prototype, "removeEventListener", p), h(window, "removeEventListener", p), h(document, "removeEventListener", p)), this.carouselEl = t, this.scrollerEl = e, this.paginationEl = n, this.currentIndex = 0, this.navBtnEls = B, this.currentIntersecting = {}, this.options = o, o.autoplay && (this.timer = null, this.timerInterval = (o == null ? void 0 : o.delay) ?? 3500, this.startTimer()), this.slideGutterSize = (o == null ? void 0 : o.slideGutterSize) ?? 25, this.showPagination = o == null ? void 0 : o.showPagination, this.isInitialScroll = !0, this.cells = c, this.slideEls = [...e.children], this.totalSlideEls = this.slideEls.length, this.totalSlides = Math.ceil(this.cells.length / (this.options.cellsPerSlide ?? 1)), r(this, s, w).call(this), r(this, s, S).call(this), r(this, s, A).call(this);
|
|
57
|
+
w(this, s);
|
|
58
|
+
n(this, "carouselEl");
|
|
59
|
+
n(this, "scrollerEl");
|
|
60
|
+
n(this, "paginationEl");
|
|
61
|
+
n(this, "cells");
|
|
62
|
+
n(this, "currentIndex");
|
|
63
|
+
n(this, "slideEls");
|
|
64
|
+
n(this, "navBtnEls");
|
|
65
|
+
n(this, "currentIntersecting");
|
|
66
|
+
n(this, "options");
|
|
67
|
+
n(this, "timer");
|
|
68
|
+
n(this, "timerInterval");
|
|
69
|
+
n(this, "slideGutterSize");
|
|
70
|
+
n(this, "showPagination");
|
|
71
|
+
n(this, "isInitialScroll");
|
|
72
|
+
n(this, "totalSlideEls");
|
|
73
|
+
n(this, "totalSlides");
|
|
74
|
+
n(this, "carouselObserver");
|
|
75
|
+
this.carouselEl = t, this.scrollerEl = e, this.paginationEl = h, this.currentIndex = 0, this.navBtnEls = o, this.currentIntersecting = null, this.options = i, this.timer = null, this.timerInterval = (i == null ? void 0 : i.delay) ?? 3500, i.autoplay && this.startTimer(), this.slideGutterSize = (i == null ? void 0 : i.slideGutterSize) ?? 25, this.showPagination = i == null ? void 0 : i.showPagination, this.isInitialScroll = !0, this.cells = c, this.slideEls = [...e.children], this.totalSlideEls = this.slideEls.length, this.totalSlides = Math.ceil(this.cells.length / (this.options.cellsPerSlide ?? 1)), this.options.wrapAround && this.totalSlideEls !== this.totalSlides + 2 && console.warn("CarouselUtils: expected two sentinel slides in wrapAround mode; wrap-around navigation may misbehave."), l(this, s, b).call(this), l(this, s, y).call(this), l(this, s, x).call(this);
|
|
80
76
|
}
|
|
81
77
|
/**
|
|
82
78
|
* starts the autoplay timer
|
|
@@ -100,7 +96,7 @@ class M {
|
|
|
100
96
|
* @param {number} dir - a number representing the direction of scroll 1 for forward, -1 for backward
|
|
101
97
|
*/
|
|
102
98
|
determineScrollAction(t) {
|
|
103
|
-
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),
|
|
99
|
+
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), l(this, s, f).call(this, t), this.currentIndex = 0) : (l(this, s, f).call(this, t), this.currentIndex += 1) : t === -1 && (this.currentIndex === 0 ? this.options.wrapAround && (this.scrollerEl.style.scrollBehavior = "auto", this.scrollerEl.scrollTo(this.scrollerEl.scrollWidth, 0), this.currentIndex = this.totalSlides - 1, l(this, s, f).call(this, t)) : (l(this, s, f).call(this, t), this.currentIndex -= 1)), this.options.autoplay && this.timer === null && this.startTimer();
|
|
104
100
|
}
|
|
105
101
|
/**
|
|
106
102
|
* Navigates the carousel to a specific index
|
|
@@ -111,8 +107,8 @@ class M {
|
|
|
111
107
|
navigateToIndex(t) {
|
|
112
108
|
if (t === this.currentIndex) return;
|
|
113
109
|
this.options.autoplay && this.clearTimer();
|
|
114
|
-
let e = t > this.currentIndex ? t - this.currentIndex : this.currentIndex - t,
|
|
115
|
-
this.currentIndex = t,
|
|
110
|
+
let e = t > this.currentIndex ? t - this.currentIndex : this.currentIndex - t, h = t > this.currentIndex ? 1 : -1;
|
|
111
|
+
this.currentIndex = t, l(this, s, f).call(this, h, e), this.options.autoplay && this.startTimer(), l(this, s, v).call(this);
|
|
116
112
|
}
|
|
117
113
|
/**
|
|
118
114
|
* Returns the current index of the carousel
|
|
@@ -127,29 +123,38 @@ class M {
|
|
|
127
123
|
* @returns void
|
|
128
124
|
*/
|
|
129
125
|
handleScrollEnd() {
|
|
130
|
-
|
|
131
|
-
|
|
126
|
+
var t;
|
|
127
|
+
if (this.timer === null && this.options.autoplay && this.startTimer(), (t = this.currentIntersecting) != null && t.target) {
|
|
128
|
+
const e = Number.parseInt(this.currentIntersecting.target.getAttribute("data-index") ?? "0", 10);
|
|
132
129
|
if (!this.options.wrapAround) {
|
|
133
|
-
this.currentIndex =
|
|
130
|
+
this.currentIndex = e, l(this, s, v).call(this);
|
|
134
131
|
return;
|
|
135
132
|
}
|
|
136
|
-
|
|
133
|
+
e === 0 ? (this.currentIndex = this.totalSlides - 1, l(this, s, E).call(this, { scrollport: this.scrollerEl, element: this.slideEls[this.slideEls.length - 2] })) : e === this.totalSlideEls - 1 ? (this.currentIndex = 0, l(this, s, E).call(this, { scrollport: this.scrollerEl, element: this.slideEls[1] })) : this.currentIndex = e - 1;
|
|
137
134
|
}
|
|
138
|
-
|
|
135
|
+
l(this, s, v).call(this);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Cleans up the timer and disconnects the IntersectionObserver.
|
|
139
|
+
* Call this when the carousel is unmounted.
|
|
140
|
+
*/
|
|
141
|
+
destroy() {
|
|
142
|
+
var t;
|
|
143
|
+
this.clearTimer(), (t = this.carouselObserver) == null || t.disconnect();
|
|
139
144
|
}
|
|
140
145
|
}
|
|
141
146
|
s = new WeakSet(), /**
|
|
142
147
|
* Scrolls the carousel to a specific child element
|
|
143
148
|
* @param {*} param0 - an object containing the scrollport element and the child element to scroll to
|
|
144
149
|
*/
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
t.style.scrollBehavior = "auto", t.scrollTo(Math.abs(t.offsetLeft - e.offsetLeft + e.clientWidth *
|
|
150
|
+
E = function({ scrollport: t, element: e }) {
|
|
151
|
+
const h = this.slideGutterSize * 2 / 100;
|
|
152
|
+
t.style.scrollBehavior = "auto", t.scrollTo(Math.abs(t.offsetLeft - e.offsetLeft + e.clientWidth * h), 0);
|
|
148
153
|
}, /**
|
|
149
154
|
* adds an observer to the scroller element that we can use to
|
|
150
155
|
* determine which slide is intersecting
|
|
151
156
|
*/
|
|
152
|
-
|
|
157
|
+
b = function() {
|
|
153
158
|
this.carouselObserver = new IntersectionObserver((t) => {
|
|
154
159
|
for (let e of t)
|
|
155
160
|
e.isIntersecting && (this.currentIntersecting = e);
|
|
@@ -160,56 +165,58 @@ w = function() {
|
|
|
160
165
|
}, /**
|
|
161
166
|
* sets listeners on the slide elements for the observer
|
|
162
167
|
*/
|
|
163
|
-
|
|
168
|
+
x = function() {
|
|
164
169
|
for (let t of this.slideEls)
|
|
165
170
|
this.carouselObserver && this.carouselObserver.observe(t);
|
|
166
171
|
}, /**
|
|
167
|
-
* sets some
|
|
172
|
+
* sets some initial settings for the carousel based on some of the options
|
|
168
173
|
*/
|
|
169
|
-
|
|
174
|
+
y = function() {
|
|
170
175
|
var t, e;
|
|
171
|
-
this.options.wrapAround ? (this.scrollerEl.style.scrollBehavior = "auto", this.scrollerEl.scrollTo(
|
|
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");
|
|
172
177
|
}, /**
|
|
173
178
|
* Scrolls the carousel in a specified direction by a specified distance
|
|
174
179
|
*
|
|
175
180
|
* @param {number} dir - a number representing the direction of scroll 1 for forward, -1 for backward
|
|
176
181
|
* @param {number} distance - a number representing the number of slides to scroll
|
|
177
182
|
*/
|
|
178
|
-
|
|
183
|
+
f = function(t, e = 1) {
|
|
184
|
+
var c;
|
|
185
|
+
const h = ((c = this.slideEls[0]) == null ? void 0 : c.getBoundingClientRect().width) ?? 0;
|
|
179
186
|
this.scrollerEl.style.scrollBehavior = "smooth", this.scrollerEl.scrollBy({
|
|
180
|
-
left:
|
|
187
|
+
left: h * e * t,
|
|
181
188
|
top: 0,
|
|
182
189
|
behavior: "smooth"
|
|
183
190
|
});
|
|
184
191
|
}, /**
|
|
185
|
-
*
|
|
192
|
+
* Synchronizes various elements of the carousel
|
|
186
193
|
*
|
|
187
194
|
* add methods here to have them sync
|
|
188
195
|
* when scroller is scrolled
|
|
189
196
|
*/
|
|
190
|
-
|
|
191
|
-
|
|
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);
|
|
192
199
|
}, /**
|
|
193
200
|
* Sets the control arrow buttons to disabled if the carousel is at the start or end
|
|
194
201
|
*/
|
|
195
|
-
|
|
196
|
-
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.
|
|
202
|
+
S = function() {
|
|
203
|
+
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.totalSlides - 1 && this.navBtnEls.next.toggleAttribute("disabled"));
|
|
197
204
|
}, /**
|
|
198
205
|
* Sets the inert attribute on all slides that are not the current slide
|
|
199
206
|
*/
|
|
200
|
-
|
|
207
|
+
I = function() {
|
|
201
208
|
const t = this.options.wrapAround ? this.currentIndex + 1 : this.currentIndex;
|
|
202
|
-
this.slideEls.length === 1 ? this.slideEls[0].removeAttribute("inert") : this.slideEls.forEach((e,
|
|
203
|
-
e.toggleAttribute("inert",
|
|
209
|
+
this.slideEls.length === 1 ? this.slideEls[0].removeAttribute("inert") : this.slideEls.forEach((e, h) => {
|
|
210
|
+
e.toggleAttribute("inert", h !== t);
|
|
204
211
|
});
|
|
205
212
|
}, /**
|
|
206
213
|
* Sets the pagination indicator to the current slide
|
|
207
214
|
*/
|
|
208
|
-
|
|
215
|
+
A = function() {
|
|
209
216
|
[...this.paginationEl.children].forEach((t, e) => {
|
|
210
|
-
|
|
217
|
+
t.toggleAttribute("data-current", e === this.currentIndex);
|
|
211
218
|
});
|
|
212
219
|
};
|
|
213
220
|
export {
|
|
214
|
-
|
|
221
|
+
C as default
|
|
215
222
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { c as r } from "../../../Carousel.module-
|
|
2
|
+
import { c as r } from "../../../Carousel.module-Nwf_zL9b.mjs";
|
|
3
3
|
function n({ slides: l, carouselId: s, ref: t }) {
|
|
4
4
|
return /* @__PURE__ */ e("div", { className: `${r["carousel-nav"]} carousel-nav`, children: /* @__PURE__ */ e("ol", { className: r["carousel-nav__list"], ref: t, children: l.map((o, a) => /* @__PURE__ */ e(
|
|
5
5
|
"li",
|
|
6
6
|
{
|
|
7
7
|
className: `${r["carousel-nav__item"]} carousel-nav__item`,
|
|
8
|
-
"data-current": a === 0 ? "
|
|
8
|
+
"data-current": a === 0 ? "" : void 0,
|
|
9
9
|
title: `Navigate to slide ${a + 1}`
|
|
10
10
|
},
|
|
11
11
|
`carousel${s}-nav-${a}`
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import { createRef as m } from "react";
|
|
3
|
-
import { d as c, i as l, r
|
|
3
|
+
import { d as c, i as l, r, s as a, g as t } from "../../../react.esm-S2Q_NbYC.mjs";
|
|
4
4
|
import "../../../index-BZQHStQa.mjs";
|
|
5
5
|
import { Pagination as i } from "./Pagination.js";
|
|
6
6
|
const n = Array.from({ length: 5 }), u = Array.from({ length: 1 });
|
|
7
7
|
c("Pagination", () => {
|
|
8
8
|
c("Rendering", () => {
|
|
9
9
|
l("renders the correct number of list items", () => {
|
|
10
|
-
|
|
10
|
+
r(/* @__PURE__ */ o(i, { carouselId: "test", slides: n }));
|
|
11
11
|
const e = a.getAllByRole("listitem");
|
|
12
12
|
t(e).toHaveLength(5);
|
|
13
13
|
}), l("renders nothing inside the list for empty slides", () => {
|
|
14
|
-
const { container: e } =
|
|
14
|
+
const { container: e } = r(/* @__PURE__ */ o(i, { carouselId: "test", slides: [] })), s = e.querySelector("ol");
|
|
15
15
|
t(s).toBeInTheDocument(), t(s == null ? void 0 : s.children).toHaveLength(0);
|
|
16
16
|
}), l("renders the outer nav div", () => {
|
|
17
|
-
const { container: e } =
|
|
17
|
+
const { container: e } = r(/* @__PURE__ */ o(i, { carouselId: "test", slides: n })), s = e.querySelector(".carousel-nav");
|
|
18
18
|
t(s).toBeInTheDocument();
|
|
19
19
|
}), l("renders an ordered list", () => {
|
|
20
|
-
|
|
21
|
-
const { container: e } =
|
|
20
|
+
r(/* @__PURE__ */ o(i, { carouselId: "test", slides: n })), t(a.getByRole("list")).toBeInTheDocument();
|
|
21
|
+
const { container: e } = r(/* @__PURE__ */ o(i, { carouselId: "test", slides: n }));
|
|
22
22
|
t(e.querySelector("ol")).toBeInTheDocument();
|
|
23
23
|
}), l("renders the correct number of items for a single slide", () => {
|
|
24
|
-
|
|
24
|
+
r(/* @__PURE__ */ o(i, { carouselId: "test", slides: u })), t(a.getAllByRole("listitem")).toHaveLength(1);
|
|
25
25
|
}), l("renders the correct number of items for many slides", () => {
|
|
26
26
|
const e = Array.from({ length: 12 });
|
|
27
|
-
|
|
27
|
+
r(/* @__PURE__ */ o(i, { carouselId: "test", slides: e })), t(a.getAllByRole("listitem")).toHaveLength(12);
|
|
28
28
|
});
|
|
29
29
|
}), c("data-current attribute", () => {
|
|
30
|
-
l(
|
|
31
|
-
|
|
30
|
+
l("sets data-current on the first item", () => {
|
|
31
|
+
r(/* @__PURE__ */ o(i, { carouselId: "test", slides: n }));
|
|
32
32
|
const e = a.getAllByRole("listitem");
|
|
33
|
-
t(e[0]).toHaveAttribute("data-current"
|
|
34
|
-
}), l(
|
|
35
|
-
|
|
33
|
+
t(e[0]).toHaveAttribute("data-current");
|
|
34
|
+
}), l("does not set data-current on items after the first", () => {
|
|
35
|
+
r(/* @__PURE__ */ o(i, { carouselId: "test", slides: n }));
|
|
36
36
|
const e = a.getAllByRole("listitem");
|
|
37
37
|
for (let s = 1; s < e.length; s++)
|
|
38
|
-
t(e[s]).toHaveAttribute("data-current"
|
|
39
|
-
}), l(
|
|
40
|
-
|
|
38
|
+
t(e[s]).not.toHaveAttribute("data-current");
|
|
39
|
+
}), l("sets data-current on the single item when there is one slide", () => {
|
|
40
|
+
r(/* @__PURE__ */ o(i, { carouselId: "test", slides: u }));
|
|
41
41
|
const e = a.getByRole("listitem");
|
|
42
|
-
t(e).toHaveAttribute("data-current"
|
|
42
|
+
t(e).toHaveAttribute("data-current");
|
|
43
43
|
});
|
|
44
44
|
}), c("title attribute", () => {
|
|
45
45
|
l("sets the correct title on each item (1-indexed)", () => {
|
|
46
|
-
|
|
46
|
+
r(/* @__PURE__ */ o(i, { carouselId: "test", slides: n })), a.getAllByRole("listitem").forEach((s, d) => {
|
|
47
47
|
t(s).toHaveAttribute("title", `Navigate to slide ${d + 1}`);
|
|
48
48
|
});
|
|
49
49
|
}), l('sets title="Navigate to slide 1" on a single-slide pagination', () => {
|
|
50
|
-
|
|
50
|
+
r(/* @__PURE__ */ o(i, { carouselId: "test", slides: u })), t(a.getByRole("listitem")).toHaveAttribute("title", "Navigate to slide 1");
|
|
51
51
|
});
|
|
52
52
|
}), c("carouselId in keys", () => {
|
|
53
53
|
l("uses carouselId in the rendered item titles to distinguish instances", () => {
|
|
54
|
-
const { container: e } =
|
|
54
|
+
const { container: e } = r(/* @__PURE__ */ o(i, { carouselId: "alpha", slides: n })), { container: s } = r(/* @__PURE__ */ o(i, { carouselId: "beta", slides: n }));
|
|
55
55
|
t(e.querySelectorAll("li")).toHaveLength(5), t(s.querySelectorAll("li")).toHaveLength(5);
|
|
56
56
|
});
|
|
57
57
|
}), c("ref forwarding", () => {
|
|
58
58
|
l("forwards the ref to the <ol> element", () => {
|
|
59
|
-
const e = m(), { container: s } =
|
|
59
|
+
const e = m(), { container: s } = r(/* @__PURE__ */ o(i, { carouselId: "test", ref: e, slides: n })), d = s.querySelector("ol");
|
|
60
60
|
t(e.current).toBe(d);
|
|
61
61
|
}), l("ref is null when no ref is provided", () => {
|
|
62
|
-
const { container: e } =
|
|
62
|
+
const { container: e } = r(/* @__PURE__ */ o(i, { carouselId: "test", slides: n }));
|
|
63
63
|
t(e.querySelector("ol")).toBeInTheDocument();
|
|
64
64
|
});
|
|
65
65
|
});
|