@scrippsproduct/networks-ui-library 1.1.0-alpha.10 → 1.1.0-alpha.13
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,13 +1,13 @@
|
|
|
1
1
|
import { jsxs as o, jsx as a, Fragment as I } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { statesForCustomList as
|
|
2
|
+
import { useRef as T, useState as $, useEffect as x } from "react";
|
|
3
|
+
import { statesForCustomList as k } from "../../data-resources/FakeDataResource.js";
|
|
4
4
|
import { publish as V } from "../../utils/events.js";
|
|
5
|
-
import { classes as
|
|
5
|
+
import { classes as r } from "../../utils/helpers.js";
|
|
6
6
|
import { Input as j } from "../Input/Input.js";
|
|
7
7
|
import { CustomDataList as z } from "../CustomDataList/CustomDataList.js";
|
|
8
8
|
import { ActionButton as K } from "../ActionButton/ActionButton.js";
|
|
9
|
-
import { ResultsTable as
|
|
10
|
-
import { AdBlock as
|
|
9
|
+
import { ResultsTable as F } from "../ResultsTable/ResultsTable.js";
|
|
10
|
+
import { AdBlock as Y } from "../AdBlock/AdBlock.js";
|
|
11
11
|
import '../../assets/ChannelSearch.css';const n = {
|
|
12
12
|
"channel-search": "_channel-search_1kyd9_6",
|
|
13
13
|
"channel-search__inputs": "_channel-search__inputs_1kyd9_19",
|
|
@@ -18,13 +18,13 @@ import '../../assets/ChannelSearch.css';const n = {
|
|
|
18
18
|
"channel-search__label": "_channel-search__label_1kyd9_90"
|
|
19
19
|
};
|
|
20
20
|
function M({
|
|
21
|
-
network:
|
|
22
|
-
baseApiUrl:
|
|
23
|
-
allowZipcodeSearch:
|
|
24
|
-
allowStateSearch:
|
|
25
|
-
compactLayout:
|
|
26
|
-
allowAutoScroll:
|
|
27
|
-
autoScrollOffset:
|
|
21
|
+
network: l,
|
|
22
|
+
baseApiUrl: N,
|
|
23
|
+
allowZipcodeSearch: u = !0,
|
|
24
|
+
allowStateSearch: p = !0,
|
|
25
|
+
compactLayout: _ = !1,
|
|
26
|
+
allowAutoScroll: w = !0,
|
|
27
|
+
autoScrollOffset: v = 25,
|
|
28
28
|
ad: i = {
|
|
29
29
|
campaign: "",
|
|
30
30
|
source: "",
|
|
@@ -32,9 +32,9 @@ function M({
|
|
|
32
32
|
content: ""
|
|
33
33
|
}
|
|
34
34
|
}) {
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const e = `${
|
|
35
|
+
const C = T(""), m = async (c = { type: "", term: "" }) => {
|
|
36
|
+
const g = async () => {
|
|
37
|
+
const e = `${N}/${l.slug}?${c.type}=${c.term}`;
|
|
38
38
|
try {
|
|
39
39
|
const t = await fetch(e);
|
|
40
40
|
return t.ok ? (await t.json()).map((s) => ({
|
|
@@ -47,24 +47,24 @@ function M({
|
|
|
47
47
|
return console.error(t), [];
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
-
return
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
const
|
|
50
|
+
return c.term === "" ? [] : await g();
|
|
51
|
+
}, S = async (c) => {
|
|
52
|
+
c.preventDefault();
|
|
53
|
+
const g = new FormData(document.getElementById("channel-search"));
|
|
54
54
|
let e = {};
|
|
55
|
-
for (let [t,
|
|
55
|
+
for (let [t, h] of g.entries())
|
|
56
56
|
e = {
|
|
57
57
|
...e,
|
|
58
|
-
[t]:
|
|
58
|
+
[t]: h
|
|
59
59
|
};
|
|
60
60
|
if (e.zipcode && (e == null ? void 0 : e.zipcode) !== "") {
|
|
61
|
-
const t = await
|
|
62
|
-
|
|
61
|
+
const t = await m({ type: "zip", term: e.zipcode });
|
|
62
|
+
d(t.length === 0 ? [] : t), f(!0);
|
|
63
63
|
} else if (e.state && (e == null ? void 0 : e.state) !== "") {
|
|
64
|
-
const t =
|
|
65
|
-
|
|
64
|
+
const t = k.find((h) => Number.parseInt(h.id, 10) === Number.parseInt(e.state, 10));
|
|
65
|
+
C.current = t === void 0 ? "" : t.label, d(await m({ type: "state", term: t == null ? void 0 : t.value })), f(!0);
|
|
66
66
|
} else
|
|
67
|
-
|
|
67
|
+
d(await m()), f(!1);
|
|
68
68
|
setTimeout(() => {
|
|
69
69
|
V("scripps:action:completed");
|
|
70
70
|
}, 250);
|
|
@@ -85,39 +85,37 @@ function M({
|
|
|
85
85
|
title: "Cable/Satellite",
|
|
86
86
|
resultKey: "provider"
|
|
87
87
|
}
|
|
88
|
-
], [
|
|
88
|
+
], [R, d] = $([]), [b, f] = $(!1), y = T(null);
|
|
89
89
|
return x(() => {
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
b && w && setTimeout(() => {
|
|
91
|
+
y.current !== null && window.scroll({
|
|
92
92
|
left: 0,
|
|
93
|
-
top:
|
|
93
|
+
top: y.current.getBoundingClientRect().y + window.pageYOffset - v,
|
|
94
94
|
behavior: "smooth"
|
|
95
95
|
});
|
|
96
|
-
}, 100)
|
|
97
|
-
|
|
98
|
-
})();
|
|
99
|
-
}), /* @__PURE__ */ o("channel-search__wrapper", { children: [
|
|
96
|
+
}, 100);
|
|
97
|
+
}, [b, w, v]), /* @__PURE__ */ o("channel-search__wrapper", { children: [
|
|
100
98
|
/* @__PURE__ */ o(
|
|
101
99
|
"form",
|
|
102
100
|
{
|
|
103
|
-
className:
|
|
101
|
+
className: r([
|
|
104
102
|
n["channel-search"],
|
|
105
103
|
"channel-search"
|
|
106
104
|
]),
|
|
107
105
|
id: "channel-search",
|
|
108
106
|
children: [
|
|
109
|
-
/* @__PURE__ */ o("span", { className:
|
|
110
|
-
|
|
107
|
+
/* @__PURE__ */ o("span", { className: r([n["channel-search__label"], "channel-search__label"]), children: [
|
|
108
|
+
l.brand_name,
|
|
111
109
|
" Channel Search:"
|
|
112
110
|
] }),
|
|
113
|
-
/* @__PURE__ */ o("span", { className:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
/* @__PURE__ */ o("span", { className: r([n["channel-search__inputs"], "channel-search__inputs"]), children: [
|
|
112
|
+
u && /* @__PURE__ */ a(j, { name: "zipcode", placeholder: "Enter ZIP Code", showValidation: !1 }),
|
|
113
|
+
u && p && "or",
|
|
114
|
+
p && /* @__PURE__ */ a(
|
|
117
115
|
z,
|
|
118
116
|
{
|
|
119
117
|
name: "state",
|
|
120
|
-
options:
|
|
118
|
+
options: k,
|
|
121
119
|
placeholder: "Select Your State",
|
|
122
120
|
showValidation: !1
|
|
123
121
|
}
|
|
@@ -126,40 +124,40 @@ function M({
|
|
|
126
124
|
/* @__PURE__ */ a(
|
|
127
125
|
K,
|
|
128
126
|
{
|
|
129
|
-
classname:
|
|
127
|
+
classname: r(["channel-search__submit-btn", n["channel-search__submit-btn"]]),
|
|
130
128
|
label: "Submit",
|
|
131
129
|
type: "submit",
|
|
132
|
-
onClick:
|
|
130
|
+
onClick: S
|
|
133
131
|
}
|
|
134
132
|
)
|
|
135
133
|
]
|
|
136
134
|
}
|
|
137
135
|
),
|
|
138
|
-
|
|
136
|
+
b && /* @__PURE__ */ o(I, { children: [
|
|
139
137
|
/* @__PURE__ */ a(
|
|
140
138
|
"div",
|
|
141
139
|
{
|
|
142
|
-
className:
|
|
140
|
+
className: r([
|
|
143
141
|
n["results-table__header"],
|
|
144
142
|
"search-results-header",
|
|
145
|
-
|
|
143
|
+
_ ? n["results-table__header--compact"] : ""
|
|
146
144
|
]),
|
|
147
|
-
ref:
|
|
148
|
-
children:
|
|
145
|
+
ref: y,
|
|
146
|
+
children: R.length > 1 ? `${p && !u ? C.current : "Your"} ${l.brand_name} Channels` : `Your ${l.brand_name} Channel`
|
|
149
147
|
}
|
|
150
148
|
),
|
|
151
149
|
/* @__PURE__ */ a(
|
|
152
|
-
|
|
150
|
+
F,
|
|
153
151
|
{
|
|
154
152
|
columns: B,
|
|
155
|
-
compactLayout:
|
|
156
|
-
noResultsMsg: `Sorry there are no channels carrying ${
|
|
157
|
-
results:
|
|
153
|
+
compactLayout: _,
|
|
154
|
+
noResultsMsg: `Sorry there are no channels carrying ${l.brand_name} in your area at this time.`,
|
|
155
|
+
results: R
|
|
158
156
|
}
|
|
159
157
|
)
|
|
160
158
|
] }),
|
|
161
|
-
!
|
|
162
|
-
|
|
159
|
+
!_ && /* @__PURE__ */ a("div", { className: r([n["ad-wrapper"], "ad-wrapper"]), children: /* @__PURE__ */ a(
|
|
160
|
+
Y,
|
|
163
161
|
{
|
|
164
162
|
ad: {
|
|
165
163
|
header: "Fall in love with subscription-free TV.",
|
|
@@ -1,68 +1,68 @@
|
|
|
1
1
|
import { jsx as t, jsxs as b } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as d, useCallback as
|
|
2
|
+
import { useRef as d, useCallback as g, useEffect as h } from "react";
|
|
3
3
|
import { f as w } from "../../format-YhWt2D8M.mjs";
|
|
4
|
-
import { l
|
|
4
|
+
import { l } from "../../logger-C0N7U0YY.mjs";
|
|
5
5
|
import { classes as L } from "../../utils/helpers.js";
|
|
6
6
|
import { ScheduleProvider as E } from "./ScheduleContext.js";
|
|
7
7
|
import { useScheduleContext as T } from "./useScheduleContext.js";
|
|
8
8
|
import { DateNavigation as k } from "../DateNavigation/DateNavigation.js";
|
|
9
9
|
import { ScheduleList as q } from "../ScheduleList/ScheduleList.js";
|
|
10
|
-
|
|
10
|
+
l.setComponent("ScheduleLayout");
|
|
11
11
|
import '../../assets/ScheduleLayout.css';function x({
|
|
12
12
|
handleScheduleClicks: f = () => !0
|
|
13
13
|
}) {
|
|
14
|
-
const { currentDate:
|
|
15
|
-
|
|
16
|
-
const
|
|
14
|
+
const { currentDate: r } = T(), n = d(null), p = d(0), o = d(null), c = d(null), i = d(null), u = g((a) => {
|
|
15
|
+
l.log("Determining pointer position for date: ", a);
|
|
16
|
+
const s = () => {
|
|
17
17
|
let e;
|
|
18
|
-
const v = document.querySelector(`.date-navigation__day[aria-controls="${w(
|
|
19
|
-
if (v && (e = v.parentElement), e &&
|
|
20
|
-
const
|
|
21
|
-
p.current =
|
|
18
|
+
const v = document.querySelector(`.date-navigation__day[aria-controls="${w(a, "yyyy-MM-dd")}"]`);
|
|
19
|
+
if (v && (e = v.parentElement), e && n.current) {
|
|
20
|
+
const S = e.offsetLeft + e.offsetWidth / 2;
|
|
21
|
+
p.current = S, n.current.style.setProperty(
|
|
22
22
|
"--pointer-position",
|
|
23
|
-
`${
|
|
23
|
+
`${S}px`
|
|
24
24
|
);
|
|
25
25
|
}
|
|
26
|
-
},
|
|
27
|
-
|
|
26
|
+
}, y = () => {
|
|
27
|
+
l.log("Scrolling schedule list to top"), c.current || (c.current = document.querySelector(".schedule-list")), i.current || (i.current = document.querySelector("sticky-content-wrapper")), l.log("Schedule list element: ", c.current), l.log("Sticky wrapper element: ", i.current);
|
|
28
28
|
const e = document.querySelector(".mobile-nav");
|
|
29
|
-
|
|
29
|
+
c.current && i.current && (l.log("Mobile nav element: ", e), window.scrollTo({
|
|
30
30
|
behavior: "auto",
|
|
31
|
-
top: e && window.getComputedStyle(e).display !== "none" ?
|
|
31
|
+
top: e && window.getComputedStyle(e).display !== "none" ? c.current.offsetTop - i.current.offsetHeight - e.offsetHeight - 8 : c.current.offsetTop - i.current.offsetHeight - 16,
|
|
32
32
|
left: 0
|
|
33
33
|
}));
|
|
34
34
|
};
|
|
35
|
-
if (!
|
|
35
|
+
if (!n.current) {
|
|
36
36
|
const e = setInterval(() => {
|
|
37
|
-
|
|
37
|
+
n.current = document.querySelector(".date-navigation__list"), n.current && (clearInterval(e), c.current = document.querySelector(".schedule-list"), i.current = document.querySelector("sticky-content-wrapper"), s(), y());
|
|
38
38
|
}, 100);
|
|
39
39
|
setTimeout(() => {
|
|
40
40
|
clearInterval(e);
|
|
41
41
|
}, 3e3);
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
}, []), m =
|
|
44
|
+
s(), y();
|
|
45
|
+
}, []), m = g(() => {
|
|
46
46
|
o.current && clearTimeout(o.current), o.current = window.setTimeout(() => {
|
|
47
|
-
|
|
47
|
+
u(r);
|
|
48
48
|
}, 250);
|
|
49
|
-
}, [
|
|
50
|
-
return
|
|
49
|
+
}, [r, u]);
|
|
50
|
+
return h(() => (window.addEventListener("resize", m), () => {
|
|
51
51
|
window.removeEventListener("resize", m), o.current && clearTimeout(o.current);
|
|
52
|
-
}), [
|
|
53
|
-
const
|
|
54
|
-
|
|
52
|
+
}), [u, m]), h(() => {
|
|
53
|
+
const a = document.querySelector(".header-divider"), s = document.querySelector("sticky-content-wrapper");
|
|
54
|
+
s && a && new IntersectionObserver(
|
|
55
55
|
([e]) => {
|
|
56
|
-
e.intersectionRatio < 1 ?
|
|
56
|
+
e.intersectionRatio < 1 ? s.dataset.pinnedState = "pinned" : s.dataset.pinnedState = "unpinned";
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
threshold: [1],
|
|
60
60
|
rootMargin: "-37px"
|
|
61
61
|
}
|
|
62
|
-
).observe(
|
|
63
|
-
}, []),
|
|
64
|
-
|
|
65
|
-
}, [
|
|
62
|
+
).observe(a);
|
|
63
|
+
}, []), h(() => {
|
|
64
|
+
u(r);
|
|
65
|
+
}, [r, u]), /* @__PURE__ */ b("schedule-layout", { children: [
|
|
66
66
|
/* @__PURE__ */ t("sticky-content-wrapper", { "data-pinned-state": "unpinned", children: /* @__PURE__ */ t(
|
|
67
67
|
"content-constrainer",
|
|
68
68
|
{
|
|
@@ -75,13 +75,13 @@ import '../../assets/ScheduleLayout.css';function x({
|
|
|
75
75
|
children: /* @__PURE__ */ t(k, {})
|
|
76
76
|
}
|
|
77
77
|
) }),
|
|
78
|
-
/* @__PURE__ */ t("section", { className: "page-section", id: "schedule-section", children: /* @__PURE__ */ t("content-constrainer", { class: "content-constrainer--no-border schedule-content-constrainer", children: /* @__PURE__ */ t("div", { id: w(
|
|
78
|
+
/* @__PURE__ */ t("section", { className: "page-section", id: "schedule-section", children: /* @__PURE__ */ t("content-constrainer", { class: "content-constrainer--no-border schedule-content-constrainer", children: /* @__PURE__ */ t("div", { id: w(r, "yyyy-MM-dd"), role: "tabpanel", children: /* @__PURE__ */ t(q, { handleClicks: f }) }) }) })
|
|
79
79
|
] });
|
|
80
80
|
}
|
|
81
81
|
function N({
|
|
82
82
|
fetchSchedule: f,
|
|
83
|
-
initialSchedule:
|
|
84
|
-
weeks:
|
|
83
|
+
initialSchedule: r = [],
|
|
84
|
+
weeks: n = [],
|
|
85
85
|
handleScheduleClicks: p = () => !0,
|
|
86
86
|
handleDateChanged: o = () => !0
|
|
87
87
|
}) {
|
|
@@ -90,8 +90,8 @@ function N({
|
|
|
90
90
|
{
|
|
91
91
|
fetchSchedule: f,
|
|
92
92
|
handleDateChanged: o,
|
|
93
|
-
initialSchedule:
|
|
94
|
-
weeks:
|
|
93
|
+
initialSchedule: r,
|
|
94
|
+
weeks: n,
|
|
95
95
|
children: /* @__PURE__ */ t(x, { handleScheduleClicks: p })
|
|
96
96
|
}
|
|
97
97
|
);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ScheduleItem } from '../types';
|
|
2
|
+
type UseGetScheduleParams = {
|
|
3
|
+
dateStr: string;
|
|
4
|
+
schedEndpoint: string;
|
|
5
|
+
network?: string | null;
|
|
6
|
+
showEpisodeNumber?: boolean;
|
|
7
|
+
showUpcoming?: boolean;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param {*} param0
|
|
12
|
+
* @param {string} param0.dateStr - The date to get the schedule for
|
|
13
|
+
* @param {string} param0.schedEndpoint - The endpoint to get the schedule from
|
|
14
|
+
* @param {string|null} param0.network - The network to get the schedule for
|
|
15
|
+
* @param {boolean} param0.showEpisodeNumber - Whether episode numbers should be shown
|
|
16
|
+
*
|
|
17
|
+
* @returns {Object[]|{ queryStatus: 'no-results' }} - Array of objects or an object with a queryStatus of 'no-results'
|
|
18
|
+
*/
|
|
19
|
+
declare const useGetSchedule: ({ dateStr, schedEndpoint, network, showEpisodeNumber, showUpcoming, }: UseGetScheduleParams) => Promise<ScheduleItem[] | [{
|
|
20
|
+
queryStatus: string;
|
|
21
|
+
}]>;
|
|
22
|
+
export default useGetSchedule;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { a as p } from "../add-UWUc_nrO.mjs";
|
|
2
|
+
import { f as d } from "../format-YhWt2D8M.mjs";
|
|
3
|
+
import { determineSeasonNumber as S, determineEpisodeNumber as _, determineSeasonNumberFromSeriesPrefix as b } from "../utils/series-helpers.js";
|
|
4
|
+
import { convert12to24 as O } from "../utils/helpers.js";
|
|
5
|
+
import { determineIfShowIsOnNow as v } from "../utils/date-helpers.js";
|
|
6
|
+
import { g as x } from "../index-0wieGV50.mjs";
|
|
7
|
+
const P = async ({
|
|
8
|
+
dateStr: o,
|
|
9
|
+
schedEndpoint: h,
|
|
10
|
+
network: $ = null,
|
|
11
|
+
showEpisodeNumber: u = !1,
|
|
12
|
+
showUpcoming: w = !1
|
|
13
|
+
}) => {
|
|
14
|
+
const c = x("America/New_York", new Date(o)) / 36e5, T = d(/* @__PURE__ */ new Date(`${o}T00:00:00`), "yyyy-MM-dd"), i = d(new Date(p(/* @__PURE__ */ new Date(`${o}T00:00:00`), { days: 1 })), "yyyy-MM-dd"), m = (s) => {
|
|
15
|
+
const e = /* @__PURE__ */ new Date(`${o}T06:00:00-0${c * -1}:00`), r = /* @__PURE__ */ new Date(`${i}T06:00:00-0${c * -1}:00`);
|
|
16
|
+
return s.filter((n) => {
|
|
17
|
+
if (!(n != null && n.start_ts_parse)) return !1;
|
|
18
|
+
const l = (n == null ? void 0 : n.start_ts_parse) * 1e3;
|
|
19
|
+
return l >= e.valueOf() && l < r.valueOf();
|
|
20
|
+
});
|
|
21
|
+
}, y = async () => {
|
|
22
|
+
let s = [], e = {
|
|
23
|
+
next: null,
|
|
24
|
+
results: []
|
|
25
|
+
}, r = 0, f = "";
|
|
26
|
+
const n = T, l = i;
|
|
27
|
+
do {
|
|
28
|
+
f = `${h}/${$}?ordering=start_ts_parse&start_date__range=${n},${l}&limit=100&offset=${r}`;
|
|
29
|
+
try {
|
|
30
|
+
const t = await fetch(f);
|
|
31
|
+
if (t != null && t.ok)
|
|
32
|
+
e = await t.json(), s = [...s, ...e.results];
|
|
33
|
+
else {
|
|
34
|
+
console.error(`An error was returned from fetch. HTTP Response Code: ', ${t == null ? void 0 : t.status}`);
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
} catch (t) {
|
|
38
|
+
console.error("Fetch failed with error:", t);
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
r += 100;
|
|
42
|
+
} while (e.next !== null);
|
|
43
|
+
return s.length === 0 ? void 0 : m(s).map((t) => ({
|
|
44
|
+
...t,
|
|
45
|
+
showUpcoming: w
|
|
46
|
+
}));
|
|
47
|
+
}, D = (s) => s.filter((e) => {
|
|
48
|
+
if (e.series_prefix === null && e.title_code === null) return !1;
|
|
49
|
+
const r = /* @__PURE__ */ new Date();
|
|
50
|
+
return e.start_ts_parse ? !!(e.start_ts_parse * 1e3 > r.valueOf() || v(`${e.start_date_parse}T${O(e.start_time)}`, e.element_length)) : !1;
|
|
51
|
+
}).map((e) => {
|
|
52
|
+
let r = "";
|
|
53
|
+
return e.series_prefix === null ? r = u ? `${S(e)}${_(e)}` : "" : r = u ? `${b(e)}${_(e)}` : "", {
|
|
54
|
+
...e,
|
|
55
|
+
episode_number: r
|
|
56
|
+
};
|
|
57
|
+
}), a = await y();
|
|
58
|
+
return a === void 0 || a.length === 0 ? [{ queryStatus: "no-results" }] : D(a);
|
|
59
|
+
};
|
|
60
|
+
export {
|
|
61
|
+
P as default
|
|
62
|
+
};
|
package/package.json
CHANGED