@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,16 +1,16 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { v as h, d as m, b as
|
|
1
|
+
import { jsx as a, jsxs as B } from "react/jsx-runtime";
|
|
2
|
+
import { v as h, d as m, b as I, a as v, i as r, r as l, g as n, s as c, w as u } from "../../react.esm-S2Q_NbYC.mjs";
|
|
3
3
|
import "../../index-BZQHStQa.mjs";
|
|
4
|
-
import { PromotionsRowModule as
|
|
4
|
+
import { PromotionsRowModule as s } from "./PromotionsRowModule.js";
|
|
5
5
|
h.mock("../PromotionsRowBlock", () => ({
|
|
6
|
-
default: ({ children: o, gap: e }) => /* @__PURE__ */
|
|
6
|
+
default: ({ children: o, gap: e }) => /* @__PURE__ */ a("div", { "data-gap": e, "data-testid": "promotions-row-block", children: o })
|
|
7
7
|
}));
|
|
8
8
|
h.mock("../ImageCard", () => ({
|
|
9
|
-
default: ({ image: o, title: e, content: i, cta: p, relatedResourceId: y, classname: T, overlayContent:
|
|
9
|
+
default: ({ image: o, title: e, content: i, cta: p, relatedResourceId: y, classname: T, overlayContent: C }) => /* @__PURE__ */ B(
|
|
10
10
|
"div",
|
|
11
11
|
{
|
|
12
12
|
"data-classname": T,
|
|
13
|
-
"data-content": i,
|
|
13
|
+
"data-content": typeof i == "string" ? i : void 0,
|
|
14
14
|
"data-cta-text": p == null ? void 0 : p.label,
|
|
15
15
|
"data-image-url": o.url,
|
|
16
16
|
"data-related-id": y,
|
|
@@ -19,7 +19,8 @@ h.mock("../ImageCard", () => ({
|
|
|
19
19
|
children: [
|
|
20
20
|
"ImageCard: ",
|
|
21
21
|
e,
|
|
22
|
-
|
|
22
|
+
i,
|
|
23
|
+
C
|
|
23
24
|
]
|
|
24
25
|
}
|
|
25
26
|
)
|
|
@@ -58,62 +59,62 @@ const g = {
|
|
|
58
59
|
...e
|
|
59
60
|
});
|
|
60
61
|
m("PromotionsRowModule", () => {
|
|
61
|
-
|
|
62
|
+
I(() => {
|
|
62
63
|
h.clearAllMocks();
|
|
63
64
|
}), v(() => {
|
|
64
65
|
h.clearAllMocks();
|
|
65
66
|
}), m("Basic Rendering", () => {
|
|
66
|
-
|
|
67
|
-
const o = [t("1")], { container: e } =
|
|
68
|
-
|
|
69
|
-
}),
|
|
67
|
+
r("should render section with promotions-row class", () => {
|
|
68
|
+
const o = [t("1")], { container: e } = l(/* @__PURE__ */ a(s, { promos: o })), i = e.querySelector("section.promotions-row");
|
|
69
|
+
n(i).toBeInTheDocument();
|
|
70
|
+
}), r("should render title when provided", () => {
|
|
70
71
|
const o = [t("1")];
|
|
71
|
-
|
|
72
|
-
}),
|
|
72
|
+
l(/* @__PURE__ */ a(s, { promos: o, title: "Special Offers" })), n(c.getByRole("heading", { name: "Special Offers" })).toBeInTheDocument();
|
|
73
|
+
}), r("should render title as h2 element", () => {
|
|
73
74
|
const o = [t("1")];
|
|
74
|
-
|
|
75
|
-
const e =
|
|
76
|
-
|
|
77
|
-
}),
|
|
75
|
+
l(/* @__PURE__ */ a(s, { promos: o, title: "Special Offers" }));
|
|
76
|
+
const e = c.getByRole("heading", { name: "Special Offers", level: 2 });
|
|
77
|
+
n(e).toBeInTheDocument();
|
|
78
|
+
}), r("should apply correct classes to title", () => {
|
|
78
79
|
const o = [t("1")];
|
|
79
|
-
|
|
80
|
-
const e =
|
|
81
|
-
|
|
82
|
-
}),
|
|
83
|
-
const o = [t("1")], { container: e } =
|
|
84
|
-
|
|
80
|
+
l(/* @__PURE__ */ a(s, { promos: o, title: "Special Offers" }));
|
|
81
|
+
const e = c.getByRole("heading", { name: "Special Offers" });
|
|
82
|
+
n(e).toHaveClass("h2", "promotions-row__header");
|
|
83
|
+
}), r("should render empty title when not provided", () => {
|
|
84
|
+
const o = [t("1")], { container: e } = l(/* @__PURE__ */ a(s, { promos: o })), i = e.querySelector("h2");
|
|
85
|
+
n(i).toHaveTextContent("");
|
|
85
86
|
});
|
|
86
87
|
}), m("PromotionsRowBlock Rendering (≤4 promos)", () => {
|
|
87
|
-
|
|
88
|
+
r("should render PromotionsRowBlock with single promo", () => {
|
|
88
89
|
const o = [t("1")];
|
|
89
|
-
|
|
90
|
-
}),
|
|
90
|
+
l(/* @__PURE__ */ a(s, { promos: o })), n(c.getByTestId("promotions-row-block")).toBeInTheDocument();
|
|
91
|
+
}), r("should render PromotionsRowBlock with 2 promos", () => {
|
|
91
92
|
const o = [t("1"), t("2")];
|
|
92
|
-
|
|
93
|
-
}),
|
|
93
|
+
l(/* @__PURE__ */ a(s, { promos: o })), n(c.getByTestId("promotions-row-block")).toBeInTheDocument();
|
|
94
|
+
}), r("should render PromotionsRowBlock with exactly 4 promos", () => {
|
|
94
95
|
const o = [
|
|
95
96
|
t("1"),
|
|
96
97
|
t("2"),
|
|
97
98
|
t("3"),
|
|
98
99
|
t("4")
|
|
99
100
|
];
|
|
100
|
-
|
|
101
|
-
}),
|
|
101
|
+
l(/* @__PURE__ */ a(s, { promos: o })), n(c.getByTestId("promotions-row-block")).toBeInTheDocument();
|
|
102
|
+
}), r("should apply 2rem gap to PromotionsRowBlock", () => {
|
|
102
103
|
const o = [t("1")];
|
|
103
|
-
|
|
104
|
-
const e =
|
|
105
|
-
|
|
106
|
-
}),
|
|
104
|
+
l(/* @__PURE__ */ a(s, { promos: o }));
|
|
105
|
+
const e = c.getByTestId("promotions-row-block");
|
|
106
|
+
n(e).toHaveAttribute("data-gap", "2rem");
|
|
107
|
+
}), r("should not render Carousel when promos ≤ 4", () => {
|
|
107
108
|
const o = [
|
|
108
109
|
t("1"),
|
|
109
110
|
t("2"),
|
|
110
111
|
t("3"),
|
|
111
112
|
t("4")
|
|
112
113
|
];
|
|
113
|
-
|
|
114
|
+
l(/* @__PURE__ */ a(s, { promos: o })), n(c.queryByTestId("carousel")).not.toBeInTheDocument();
|
|
114
115
|
});
|
|
115
116
|
}), m("Carousel Rendering (>4 promos)", () => {
|
|
116
|
-
|
|
117
|
+
r("should render Carousel when promos > 4", async () => {
|
|
117
118
|
const o = [
|
|
118
119
|
t("1"),
|
|
119
120
|
t("2"),
|
|
@@ -121,79 +122,92 @@ m("PromotionsRowModule", () => {
|
|
|
121
122
|
t("4"),
|
|
122
123
|
t("5")
|
|
123
124
|
];
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
l(/* @__PURE__ */ a(s, { promos: o })), await u(() => {
|
|
126
|
+
n(c.getByTestId("carousel")).toBeInTheDocument();
|
|
126
127
|
});
|
|
127
|
-
}),
|
|
128
|
+
}), r("should render h1 title for carousel view", async () => {
|
|
128
129
|
const o = Array.from({ length: 5 }, (e, i) => t(`${i + 1}`));
|
|
129
|
-
|
|
130
|
-
const e =
|
|
131
|
-
|
|
130
|
+
l(/* @__PURE__ */ a(s, { promos: o, title: "Carousel Title" })), await u(() => {
|
|
131
|
+
const e = c.getByRole("heading", { name: "Carousel Title", level: 1 });
|
|
132
|
+
n(e).toBeInTheDocument();
|
|
132
133
|
});
|
|
133
|
-
}),
|
|
134
|
+
}), r("should apply h3 class to carousel title", async () => {
|
|
134
135
|
const o = Array.from({ length: 5 }, (e, i) => t(`${i + 1}`));
|
|
135
|
-
|
|
136
|
-
const e =
|
|
137
|
-
|
|
136
|
+
l(/* @__PURE__ */ a(s, { promos: o, title: "Carousel Title" })), await u(() => {
|
|
137
|
+
const e = c.getByRole("heading", { name: "Carousel Title" });
|
|
138
|
+
n(e).toHaveClass("h3", "promotions-row__header");
|
|
138
139
|
});
|
|
139
|
-
}),
|
|
140
|
+
}), r("should not render PromotionsRowBlock when carousel is shown", async () => {
|
|
140
141
|
const o = Array.from({ length: 5 }, (e, i) => t(`${i + 1}`));
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}),
|
|
144
|
-
}),
|
|
142
|
+
l(/* @__PURE__ */ a(s, { promos: o })), await u(() => {
|
|
143
|
+
n(c.getByTestId("carousel")).toBeInTheDocument();
|
|
144
|
+
}), n(c.queryByTestId("promotions-row-block")).not.toBeInTheDocument();
|
|
145
|
+
}), r("should pass correct number of cells to Carousel", async () => {
|
|
145
146
|
const o = Array.from({ length: 6 }, (e, i) => t(`${i + 1}`));
|
|
146
|
-
|
|
147
|
-
const e =
|
|
148
|
-
|
|
147
|
+
l(/* @__PURE__ */ a(s, { promos: o })), await u(() => {
|
|
148
|
+
const e = c.getByTestId("carousel");
|
|
149
|
+
n(e).toHaveAttribute("data-cells-count", "6");
|
|
149
150
|
});
|
|
150
151
|
});
|
|
151
152
|
}), m("ImageCard Rendering", () => {
|
|
152
|
-
|
|
153
|
+
r("should render ImageCard for each promo", () => {
|
|
153
154
|
const o = [
|
|
154
155
|
t("1"),
|
|
155
156
|
t("2"),
|
|
156
157
|
t("3")
|
|
157
158
|
];
|
|
158
|
-
|
|
159
|
-
const e =
|
|
160
|
-
|
|
161
|
-
}),
|
|
159
|
+
l(/* @__PURE__ */ a(s, { promos: o }));
|
|
160
|
+
const e = c.getAllByTestId("image-card");
|
|
161
|
+
n(e).toHaveLength(3);
|
|
162
|
+
}), r("should pass image prop to ImageCard", () => {
|
|
162
163
|
const o = [t("1")];
|
|
163
|
-
|
|
164
|
-
const e =
|
|
165
|
-
|
|
166
|
-
}),
|
|
164
|
+
l(/* @__PURE__ */ a(s, { promos: o }));
|
|
165
|
+
const e = c.getByTestId("image-card");
|
|
166
|
+
n(e).toHaveAttribute("data-image-url", g.url);
|
|
167
|
+
}), r("should pass title prop to ImageCard", () => {
|
|
167
168
|
const o = [t("1", { title: "Special Promo" })];
|
|
168
|
-
|
|
169
|
-
const e =
|
|
170
|
-
|
|
171
|
-
}),
|
|
169
|
+
l(/* @__PURE__ */ a(s, { promos: o }));
|
|
170
|
+
const e = c.getByTestId("image-card");
|
|
171
|
+
n(e).toHaveAttribute("data-title", "Special Promo");
|
|
172
|
+
}), r("should pass content prop to ImageCard", () => {
|
|
172
173
|
const o = [t("1", { content: "Special content" })];
|
|
173
|
-
|
|
174
|
-
const e =
|
|
175
|
-
|
|
176
|
-
}),
|
|
174
|
+
l(/* @__PURE__ */ a(s, { promos: o, shouldClampContent: !1 }));
|
|
175
|
+
const e = c.getByTestId("image-card");
|
|
176
|
+
n(e).toHaveAttribute("data-content", "Special content");
|
|
177
|
+
}), r("should wrap content in a clamped-content div when shouldClampContent is true", () => {
|
|
178
|
+
const o = [t("1", { content: "Special content" })], { container: e } = l(
|
|
179
|
+
/* @__PURE__ */ a(s, { shouldClampContent: !0, promos: o })
|
|
180
|
+
), i = e.querySelector(".promotions-row__clamped-content");
|
|
181
|
+
n(i).toBeInTheDocument(), n(i).toHaveTextContent("Special content");
|
|
182
|
+
}), r("should wrap content in a clamped-content div by default", () => {
|
|
183
|
+
const o = [t("1", { content: "Special content" })], { container: e } = l(/* @__PURE__ */ a(s, { promos: o })), i = e.querySelector(".promotions-row__clamped-content");
|
|
184
|
+
n(i).toBeInTheDocument(), n(i).toHaveTextContent("Special content");
|
|
185
|
+
}), r("should not wrap content when shouldClampContent is false", () => {
|
|
186
|
+
const o = [t("1", { content: "Special content" })], { container: e } = l(
|
|
187
|
+
/* @__PURE__ */ a(s, { promos: o, shouldClampContent: !1 })
|
|
188
|
+
), i = e.querySelector(".promotions-row__clamped-content");
|
|
189
|
+
n(i).not.toBeInTheDocument();
|
|
190
|
+
}), r("should pass cta prop to ImageCard", () => {
|
|
177
191
|
const o = [t("1")];
|
|
178
|
-
|
|
179
|
-
const e =
|
|
180
|
-
|
|
181
|
-
}),
|
|
192
|
+
l(/* @__PURE__ */ a(s, { promos: o }));
|
|
193
|
+
const e = c.getByTestId("image-card");
|
|
194
|
+
n(e).toHaveAttribute("data-cta-text", d.label);
|
|
195
|
+
}), r("should pass relatedResourceId to ImageCard", () => {
|
|
182
196
|
const o = [t("test-id-123")];
|
|
183
|
-
|
|
184
|
-
const e =
|
|
185
|
-
|
|
186
|
-
}),
|
|
197
|
+
l(/* @__PURE__ */ a(s, { promos: o }));
|
|
198
|
+
const e = c.getByTestId("image-card");
|
|
199
|
+
n(e).toHaveAttribute("data-related-id", "test-id-123");
|
|
200
|
+
}), r("should pass classname to ImageCard when provided", () => {
|
|
187
201
|
const o = [t("1", { classname: "custom-class" })];
|
|
188
|
-
|
|
189
|
-
const e =
|
|
190
|
-
|
|
202
|
+
l(/* @__PURE__ */ a(s, { promos: o }));
|
|
203
|
+
const e = c.getByTestId("image-card");
|
|
204
|
+
n(e).toHaveAttribute("data-classname", "custom-class");
|
|
191
205
|
});
|
|
192
206
|
}), m("CtaBlock Overlay Content", () => {
|
|
193
|
-
|
|
207
|
+
r("should not render CtaBlock when overlayContent is not provided", () => {
|
|
194
208
|
const o = [t("1")];
|
|
195
|
-
|
|
196
|
-
}),
|
|
209
|
+
l(/* @__PURE__ */ a(s, { promos: o })), n(c.queryByTestId("cta-block")).not.toBeInTheDocument();
|
|
210
|
+
}), r("should render CtaBlock when overlayContent is provided", () => {
|
|
197
211
|
const o = [t("1", {
|
|
198
212
|
overlayContent: {
|
|
199
213
|
title: "Overlay Title",
|
|
@@ -201,69 +215,69 @@ m("PromotionsRowModule", () => {
|
|
|
201
215
|
cta: d
|
|
202
216
|
}
|
|
203
217
|
})];
|
|
204
|
-
|
|
205
|
-
}),
|
|
218
|
+
l(/* @__PURE__ */ a(s, { promos: o })), n(c.getByTestId("cta-block")).toBeInTheDocument();
|
|
219
|
+
}), r("should pass overlayContent title to CtaBlock", () => {
|
|
206
220
|
const o = [t("1", {
|
|
207
221
|
overlayContent: {
|
|
208
222
|
title: "Overlay Title",
|
|
209
223
|
cta: d
|
|
210
224
|
}
|
|
211
225
|
})];
|
|
212
|
-
|
|
213
|
-
const e =
|
|
214
|
-
|
|
215
|
-
}),
|
|
226
|
+
l(/* @__PURE__ */ a(s, { promos: o }));
|
|
227
|
+
const e = c.getByTestId("cta-block");
|
|
228
|
+
n(e).toHaveAttribute("data-title", "Overlay Title");
|
|
229
|
+
}), r("should pass overlayContent cta to CtaBlock", () => {
|
|
216
230
|
const o = [t("1", {
|
|
217
231
|
overlayContent: {
|
|
218
232
|
cta: d
|
|
219
233
|
}
|
|
220
234
|
})];
|
|
221
|
-
|
|
222
|
-
const e =
|
|
223
|
-
|
|
224
|
-
}),
|
|
235
|
+
l(/* @__PURE__ */ a(s, { promos: o }));
|
|
236
|
+
const e = c.getByTestId("cta-block");
|
|
237
|
+
n(e).toHaveAttribute("data-cta-text", d.label);
|
|
238
|
+
}), r("should render multiple CtaBlocks for multiple promos with overlayContent", () => {
|
|
225
239
|
const o = [
|
|
226
240
|
t("1", { overlayContent: { title: "Overlay 1", cta: d } }),
|
|
227
241
|
t("2", { overlayContent: { title: "Overlay 2", cta: d } }),
|
|
228
242
|
t("3", { overlayContent: { title: "Overlay 3", cta: d } })
|
|
229
243
|
];
|
|
230
|
-
|
|
231
|
-
const e =
|
|
232
|
-
|
|
244
|
+
l(/* @__PURE__ */ a(s, { promos: o }));
|
|
245
|
+
const e = c.getAllByTestId("cta-block");
|
|
246
|
+
n(e).toHaveLength(3);
|
|
233
247
|
});
|
|
234
248
|
}), m("HandleClicks Prop", () => {
|
|
235
|
-
|
|
249
|
+
r("should use provided handleClicks function", () => {
|
|
236
250
|
const o = h.fn(), e = [t("1")];
|
|
237
|
-
|
|
238
|
-
}),
|
|
251
|
+
l(/* @__PURE__ */ a(s, { handleClicks: o, promos: e })), n(c.getByTestId("image-card")).toBeInTheDocument();
|
|
252
|
+
}), r("should use default handleClicks when not provided", () => {
|
|
239
253
|
const o = [t("1")];
|
|
240
|
-
|
|
241
|
-
}),
|
|
254
|
+
l(/* @__PURE__ */ a(s, { promos: o })), n(c.getByTestId("image-card")).toBeInTheDocument();
|
|
255
|
+
}), r("should use default handleClicks when null", () => {
|
|
242
256
|
const o = [t("1")];
|
|
243
|
-
|
|
257
|
+
l(/* @__PURE__ */ a(s, { handleClicks: null, promos: o })), n(c.getByTestId("image-card")).toBeInTheDocument();
|
|
244
258
|
});
|
|
245
259
|
}), m("Edge Cases", () => {
|
|
246
|
-
|
|
247
|
-
const { container: o } =
|
|
248
|
-
|
|
249
|
-
}),
|
|
250
|
-
|
|
260
|
+
r("should handle empty promos array", () => {
|
|
261
|
+
const { container: o } = l(/* @__PURE__ */ a(s, { promos: [] })), e = o.querySelector("section.promotions-row");
|
|
262
|
+
n(e).toBeInTheDocument();
|
|
263
|
+
}), r("should handle promos without optional fields", () => {
|
|
264
|
+
l(/* @__PURE__ */ a(s, { promos: [{
|
|
251
265
|
id: "1",
|
|
252
266
|
image: g
|
|
253
|
-
}] })),
|
|
254
|
-
}),
|
|
255
|
-
const o = "This is a very long title ".repeat(10).trim(), e = [t("1")], { container: i } =
|
|
256
|
-
|
|
257
|
-
}),
|
|
267
|
+
}] })), n(c.getByTestId("image-card")).toBeInTheDocument();
|
|
268
|
+
}), r("should handle very long title", () => {
|
|
269
|
+
const o = "This is a very long title ".repeat(10).trim(), e = [t("1")], { container: i } = l(/* @__PURE__ */ a(s, { promos: e, title: o })), p = i.querySelector("h2");
|
|
270
|
+
n(p).toHaveTextContent(o);
|
|
271
|
+
}), r("should handle special characters in title", () => {
|
|
258
272
|
const o = 'Special & "Quoted" Title <test>', e = [t("1")];
|
|
259
|
-
|
|
260
|
-
}),
|
|
273
|
+
l(/* @__PURE__ */ a(s, { promos: e, title: o })), n(c.getByRole("heading", { name: o })).toBeInTheDocument();
|
|
274
|
+
}), r("should handle many promos (>10)", async () => {
|
|
261
275
|
const o = Array.from({ length: 15 }, (e, i) => t(`${i + 1}`));
|
|
262
|
-
|
|
263
|
-
const e =
|
|
264
|
-
|
|
276
|
+
l(/* @__PURE__ */ a(s, { promos: o })), await u(() => {
|
|
277
|
+
const e = c.getByTestId("carousel");
|
|
278
|
+
n(e).toHaveAttribute("data-cells-count", "15");
|
|
265
279
|
});
|
|
266
|
-
}),
|
|
280
|
+
}), r("should handle promos with undefined overlayContent properties", () => {
|
|
267
281
|
const o = [t("1", {
|
|
268
282
|
overlayContent: {
|
|
269
283
|
title: void 0,
|
|
@@ -271,29 +285,29 @@ m("PromotionsRowModule", () => {
|
|
|
271
285
|
cta: void 0
|
|
272
286
|
}
|
|
273
287
|
})];
|
|
274
|
-
|
|
288
|
+
l(/* @__PURE__ */ a(s, { promos: o })), n(c.getByTestId("cta-block")).toBeInTheDocument();
|
|
275
289
|
});
|
|
276
290
|
}), m("Conditional Rendering Logic", () => {
|
|
277
|
-
|
|
278
|
-
const { rerender: o } =
|
|
279
|
-
|
|
291
|
+
r("should switch from PromotionsRowBlock to Carousel when promos increase", async () => {
|
|
292
|
+
const { rerender: o } = l(/* @__PURE__ */ a(s, { promos: [t("1")] }));
|
|
293
|
+
n(c.getByTestId("promotions-row-block")).toBeInTheDocument();
|
|
280
294
|
const e = Array.from({ length: 5 }, (i, p) => t(`${p + 1}`));
|
|
281
|
-
o(/* @__PURE__ */ s
|
|
282
|
-
|
|
283
|
-
}),
|
|
284
|
-
}),
|
|
285
|
-
const o = [t("1")], { container: e } =
|
|
286
|
-
|
|
287
|
-
}),
|
|
288
|
-
const o = Array.from({ length: 5 }, (p, y) => t(`${y + 1}`)), { container: e } =
|
|
295
|
+
o(/* @__PURE__ */ a(s, { promos: e })), await u(() => {
|
|
296
|
+
n(c.getByTestId("carousel")).toBeInTheDocument();
|
|
297
|
+
}), n(c.queryByTestId("promotions-row-block")).not.toBeInTheDocument();
|
|
298
|
+
}), r("should render section element for PromotionsRowBlock view", () => {
|
|
299
|
+
const o = [t("1")], { container: e } = l(/* @__PURE__ */ a(s, { promos: o })), i = e.querySelector("section");
|
|
300
|
+
n(i).toBeInTheDocument();
|
|
301
|
+
}), r("should not render section element for Carousel view", async () => {
|
|
302
|
+
const o = Array.from({ length: 5 }, (p, y) => t(`${y + 1}`)), { container: e } = l(/* @__PURE__ */ a(s, { promos: o }));
|
|
289
303
|
await u(() => {
|
|
290
|
-
|
|
304
|
+
n(c.getByTestId("carousel")).toBeInTheDocument();
|
|
291
305
|
});
|
|
292
306
|
const i = e.querySelector("section");
|
|
293
|
-
|
|
307
|
+
n(i).not.toBeInTheDocument();
|
|
294
308
|
});
|
|
295
309
|
}), m("Integration", () => {
|
|
296
|
-
|
|
310
|
+
r("should render complete module with all elements", () => {
|
|
297
311
|
const o = [
|
|
298
312
|
t("1", {
|
|
299
313
|
title: "Promo 1",
|
|
@@ -305,28 +319,28 @@ m("PromotionsRowModule", () => {
|
|
|
305
319
|
content: "Content 2"
|
|
306
320
|
})
|
|
307
321
|
];
|
|
308
|
-
|
|
309
|
-
}),
|
|
322
|
+
l(/* @__PURE__ */ a(s, { promos: o, title: "Test Module" })), n(c.getByRole("heading", { name: "Test Module" })).toBeInTheDocument(), n(c.getByTestId("promotions-row-block")).toBeInTheDocument(), n(c.getAllByTestId("image-card")).toHaveLength(2), n(c.getByTestId("cta-block")).toBeInTheDocument();
|
|
323
|
+
}), r("should render carousel with all promos when count > 4", async () => {
|
|
310
324
|
const o = Array.from(
|
|
311
325
|
{ length: 8 },
|
|
312
326
|
(e, i) => t(`${i + 1}`, { title: `Promo ${i + 1}` })
|
|
313
327
|
);
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
const e =
|
|
317
|
-
|
|
328
|
+
l(/* @__PURE__ */ a(s, { promos: o, title: "Carousel Module" })), await u(() => {
|
|
329
|
+
n(c.getByRole("heading", { name: "Carousel Module", level: 1 })).toBeInTheDocument();
|
|
330
|
+
const e = c.getByTestId("carousel");
|
|
331
|
+
n(e).toHaveAttribute("data-cells-count", "8");
|
|
318
332
|
});
|
|
319
|
-
}),
|
|
333
|
+
}), r("should handle mix of promos with and without overlayContent", () => {
|
|
320
334
|
const o = [
|
|
321
335
|
t("1", { overlayContent: { title: "Overlay 1", cta: d } }),
|
|
322
336
|
t("2"),
|
|
323
337
|
t("3", { overlayContent: { title: "Overlay 3", cta: d } })
|
|
324
338
|
];
|
|
325
|
-
|
|
339
|
+
l(/* @__PURE__ */ a(s, { promos: o })), n(c.getAllByTestId("image-card")).toHaveLength(3), n(c.getAllByTestId("cta-block")).toHaveLength(2);
|
|
326
340
|
});
|
|
327
341
|
}), m("Type Safety", () => {
|
|
328
|
-
|
|
329
|
-
|
|
342
|
+
r("should accept valid Promo array", () => {
|
|
343
|
+
l(/* @__PURE__ */ a(s, { promos: [
|
|
330
344
|
{
|
|
331
345
|
id: "1",
|
|
332
346
|
title: "Promo 1",
|
|
@@ -338,12 +352,12 @@ m("PromotionsRowModule", () => {
|
|
|
338
352
|
id: "2",
|
|
339
353
|
image: g
|
|
340
354
|
}
|
|
341
|
-
] })),
|
|
342
|
-
}),
|
|
355
|
+
] })), n(c.getAllByTestId("image-card")).toHaveLength(2);
|
|
356
|
+
}), r("should accept handleClicks function with correct signature", () => {
|
|
343
357
|
const o = (i) => {
|
|
344
358
|
console.warn(i);
|
|
345
359
|
}, e = [t("1")];
|
|
346
|
-
|
|
360
|
+
l(/* @__PURE__ */ a(s, { handleClicks: o, promos: e })), n(c.getByTestId("image-card")).toBeInTheDocument();
|
|
347
361
|
});
|
|
348
362
|
});
|
|
349
363
|
});
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useRef as i, useEffect as o } from "react";
|
|
2
|
-
const
|
|
2
|
+
const u = ({ messageId: c = 1192723 }) => {
|
|
3
3
|
const s = i(c);
|
|
4
4
|
return o(() => {
|
|
5
5
|
const t = (e) => {
|
|
6
6
|
var a;
|
|
7
|
-
e.preventDefault(), (a = window._sp_) != null && a.usnat ? window._sp_.usnat.loadPrivacyManagerModal(s.current) : console.warn("Sourcepoint usnat not found.");
|
|
7
|
+
e instanceof MouseEvent && e.preventDefault(), (a = window._sp_) != null && a.usnat ? window._sp_.usnat.loadPrivacyManagerModal(s.current) : console.warn("Sourcepoint usnat not found.");
|
|
8
8
|
};
|
|
9
9
|
let n = 0;
|
|
10
10
|
const r = setInterval(() => {
|
|
11
11
|
n++;
|
|
12
12
|
const e = document.querySelector(".privacy-preferences-trigger");
|
|
13
|
-
e && !e.getAttribute("data-sp-listener-added") ? (e.addEventListener("click", t), e.setAttribute("data-sp-listener-added",
|
|
13
|
+
e && !e.getAttribute("data-sp-listener-added") ? (e.addEventListener("click", t), e.setAttribute("data-sp-listener-added", "true"), clearInterval(r)) : e && e.getAttribute("data-sp-listener-added") && clearInterval(r), n > 1e3 && (clearInterval(r), console.warn("Privacy preference button not found."));
|
|
14
14
|
}, 100);
|
|
15
15
|
return () => {
|
|
16
16
|
const e = document.querySelector(".privacy-preferences-trigger");
|
|
@@ -19,5 +19,5 @@ const d = ({ messageId: c = 1192723 }) => {
|
|
|
19
19
|
}), null;
|
|
20
20
|
};
|
|
21
21
|
export {
|
|
22
|
-
|
|
22
|
+
u as default
|
|
23
23
|
};
|
|
@@ -8,10 +8,10 @@ export default class CarouselUtils {
|
|
|
8
8
|
currentIndex: number;
|
|
9
9
|
slideEls: HTMLElement[];
|
|
10
10
|
navBtnEls: CarouselNavBtnEls;
|
|
11
|
-
currentIntersecting: IntersectionObserverEntry |
|
|
11
|
+
currentIntersecting: IntersectionObserverEntry | null;
|
|
12
12
|
options: CarouselOptions;
|
|
13
|
-
timer:
|
|
14
|
-
timerInterval: number
|
|
13
|
+
timer: ReturnType<typeof setInterval> | null;
|
|
14
|
+
timerInterval: number;
|
|
15
15
|
slideGutterSize: number;
|
|
16
16
|
showPagination: boolean | undefined;
|
|
17
17
|
isInitialScroll: boolean;
|
|
@@ -53,4 +53,9 @@ export default class CarouselUtils {
|
|
|
53
53
|
* @returns void
|
|
54
54
|
*/
|
|
55
55
|
handleScrollEnd(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Cleans up the timer and disconnects the IntersectionObserver.
|
|
58
|
+
* Call this when the carousel is unmounted.
|
|
59
|
+
*/
|
|
60
|
+
destroy(): void;
|
|
56
61
|
}
|
|
@@ -4,5 +4,5 @@ interface PaginationProps {
|
|
|
4
4
|
carouselId: string;
|
|
5
5
|
ref?: React.Ref<HTMLOListElement>;
|
|
6
6
|
}
|
|
7
|
-
export declare function Pagination({ slides, carouselId, ref }: PaginationProps):
|
|
7
|
+
export declare function Pagination({ slides, carouselId, ref }: PaginationProps): JSX.Element;
|
|
8
8
|
export default Pagination;
|
|
@@ -20,7 +20,8 @@ type Promo = {
|
|
|
20
20
|
type PromotionsRowModuleProps = {
|
|
21
21
|
title?: string;
|
|
22
22
|
promos: Promo[];
|
|
23
|
+
shouldClampContent?: boolean;
|
|
23
24
|
handleClicks?: ((eventDetails: HandleClicksDetails) => void) | null;
|
|
24
25
|
};
|
|
25
|
-
export declare function PromotionsRowModule({ title, promos, handleClicks, }: PromotionsRowModuleProps): JSX.Element;
|
|
26
|
+
export declare function PromotionsRowModule({ title, promos, shouldClampContent, handleClicks, }: PromotionsRowModuleProps): JSX.Element;
|
|
26
27
|
export default PromotionsRowModule;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
_sp_?: {
|
|
4
|
+
usnat?: {
|
|
5
|
+
loadPrivacyManagerModal: (messageId: number) => void;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
}
|
|
2
10
|
/**
|
|
3
11
|
* Custom hook to trigger the Sourcepoint privacy manager modal.
|
|
4
12
|
* @param {*} param0 - Configuration object.
|
|
@@ -7,4 +15,7 @@ export default useSourcePointPrivacyTrigger;
|
|
|
7
15
|
*
|
|
8
16
|
* @returns void
|
|
9
17
|
*/
|
|
10
|
-
declare
|
|
18
|
+
declare const useSourcePointPrivacyTrigger: ({ messageId }: {
|
|
19
|
+
messageId?: number | undefined;
|
|
20
|
+
}) => null;
|
|
21
|
+
export default useSourcePointPrivacyTrigger;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.0.
|
|
2
|
+
"version": "2.0.5",
|
|
3
3
|
"name": "@scrippsproduct/networks-ui-library",
|
|
4
4
|
"description": "React Component Library for use in Scripps Networks external applications",
|
|
5
5
|
"author": {
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"react-datepicker": "^7.2.0",
|
|
39
39
|
"react-feather": "^2.0.10",
|
|
40
40
|
"react-ga4": "^2.1.0",
|
|
41
|
-
"sass-embedded": "^1.80.7"
|
|
41
|
+
"sass-embedded": "^1.80.7",
|
|
42
|
+
"scrollyfills": "^1.0.4"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
45
|
"react": "^19.0.0",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import './assets/Carousel.css';const _ = "_carousel_2eeiv_2", e = "_carousel__scroller_2eeiv_12", o = {
|
|
2
|
-
carousel: _,
|
|
3
|
-
carousel__scroller: e,
|
|
4
|
-
"carousel-controls": "_carousel-controls_2eeiv_39",
|
|
5
|
-
"carousel-controls__previous": "_carousel-controls__previous_2eeiv_43",
|
|
6
|
-
"carousel-controls__next": "_carousel-controls__next_2eeiv_50",
|
|
7
|
-
"carousel-controls__btn": "_carousel-controls__btn_2eeiv_57",
|
|
8
|
-
"carousel-nav": "_carousel-nav_2eeiv_84",
|
|
9
|
-
"carousel-nav__list": "_carousel-nav__list_2eeiv_88",
|
|
10
|
-
"carousel-nav__item": "_carousel-nav__item_2eeiv_97"
|
|
11
|
-
};
|
|
12
|
-
export {
|
|
13
|
-
o as c
|
|
14
|
-
};
|