@scrippsproduct/networks-ui-library 1.1.0-alpha.6 → 1.1.0-alpha.8

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.
@@ -7,11 +7,11 @@ type Day = {
7
7
  fullDateStr: string;
8
8
  };
9
9
  type ScheduleLayoutProps = {
10
- schedule?: ScheduleResponse;
10
+ fetchSchedule: (date: Date) => Promise<ScheduleResponse>;
11
+ initialSchedule?: ScheduleResponse;
11
12
  weeks?: Day[][];
12
13
  handleScheduleClicks?: (details: HandleClicksDetails) => boolean | void;
13
14
  handleDateChanged?: (date: Date) => boolean | void;
14
- fetchError?: boolean;
15
15
  };
16
- export declare function ScheduleLayout({ schedule, weeks, handleScheduleClicks, handleDateChanged, fetchError, }: ScheduleLayoutProps): JSX.Element;
16
+ export declare function ScheduleLayout({ fetchSchedule, initialSchedule, weeks, handleScheduleClicks, handleDateChanged, }: ScheduleLayoutProps): JSX.Element;
17
17
  export default ScheduleLayout;
@@ -1,33 +1,32 @@
1
- import { jsx as t, jsxs as L } from "react/jsx-runtime";
2
- import { useRef as d, useCallback as w, useEffect as v } from "react";
3
- import { f as b } from "../../format-YhWt2D8M.mjs";
4
- import { l as c } from "../../logger-C0N7U0YY.mjs";
5
- import { classes as E } from "../../utils/helpers.js";
6
- import { ScheduleProvider as T } from "./ScheduleContext.js";
7
- import { useScheduleContext as k } from "./useScheduleContext.js";
8
- import { DateNavigation as q } from "../DateNavigation/DateNavigation.js";
9
- import { ScheduleList as x } from "../ScheduleList/ScheduleList.js";
10
- c.setComponent("ScheduleLayout");
11
- import '../../assets/ScheduleLayout.css';function C({
12
- handleScheduleClicks: f = () => !0,
13
- fetchError: p = !1
1
+ import { jsx as t, jsxs as b } from "react/jsx-runtime";
2
+ import { useRef as d, useCallback as S, useEffect as y } from "react";
3
+ import { f as w } from "../../format-YhWt2D8M.mjs";
4
+ import { l as i } from "../../logger-C0N7U0YY.mjs";
5
+ import { classes as L } from "../../utils/helpers.js";
6
+ import { ScheduleProvider as E } from "./ScheduleContext.js";
7
+ import { useScheduleContext as T } from "./useScheduleContext.js";
8
+ import { DateNavigation as k } from "../DateNavigation/DateNavigation.js";
9
+ import { ScheduleList as q } from "../ScheduleList/ScheduleList.js";
10
+ i.setComponent("ScheduleLayout");
11
+ import '../../assets/ScheduleLayout.css';function x({
12
+ handleScheduleClicks: f = () => !0
14
13
  }) {
15
- const { currentDate: n } = k(), r = d(null), m = d(0), i = d(null), s = d(null), l = d(null), a = w((u) => {
16
- c.log("Determining pointer position for date: ", u);
17
- const o = () => {
14
+ const { currentDate: n } = T(), r = d(null), p = d(0), o = d(null), s = d(null), l = d(null), a = S((u) => {
15
+ i.log("Determining pointer position for date: ", u);
16
+ const c = () => {
18
17
  let e;
19
- const g = document.querySelector(`.date-navigation__day[aria-controls="${b(u, "yyyy-MM-dd")}"]`);
20
- if (g && (e = g.parentElement), e && r.current) {
21
- const S = e.offsetLeft + e.offsetWidth / 2;
22
- m.current = S, r.current.style.setProperty(
18
+ const v = document.querySelector(`.date-navigation__day[aria-controls="${w(u, "yyyy-MM-dd")}"]`);
19
+ if (v && (e = v.parentElement), e && r.current) {
20
+ const g = e.offsetLeft + e.offsetWidth / 2;
21
+ p.current = g, r.current.style.setProperty(
23
22
  "--pointer-position",
24
- `${S}px`
23
+ `${g}px`
25
24
  );
26
25
  }
27
- }, y = () => {
28
- c.log("Scrolling schedule list to top"), c.log("Schedule list element: ", s.current), c.log("Sticky wrapper element: ", l.current);
26
+ }, h = () => {
27
+ i.log("Scrolling schedule list to top"), i.log("Schedule list element: ", s.current), i.log("Sticky wrapper element: ", l.current);
29
28
  const e = document.querySelector(".mobile-nav");
30
- s.current && l.current && (c.log("Mobile nav element: ", e), window.scrollTo({
29
+ s.current && l.current && (i.log("Mobile nav element: ", e), window.scrollTo({
31
30
  behavior: "auto",
32
31
  top: e && window.getComputedStyle(e).display !== "none" ? s.current.offsetTop - l.current.offsetHeight - e.offsetHeight - 8 : s.current.offsetTop - l.current.offsetHeight - 16,
33
32
  left: 0
@@ -35,68 +34,69 @@ import '../../assets/ScheduleLayout.css';function C({
35
34
  };
36
35
  if (!r.current) {
37
36
  const e = setInterval(() => {
38
- r.current = document.querySelector(".date-navigation__list"), r.current && (clearInterval(e), s.current = document.querySelector(".schedule-list"), l.current = document.querySelector("sticky-content-wrapper"), o(), y());
37
+ r.current = document.querySelector(".date-navigation__list"), r.current && (clearInterval(e), s.current = document.querySelector(".schedule-list"), l.current = document.querySelector("sticky-content-wrapper"), c(), h());
39
38
  }, 100);
40
39
  setTimeout(() => {
41
40
  clearInterval(e);
42
41
  }, 3e3);
43
42
  return;
44
43
  }
45
- o(), y();
46
- }, []), h = w(() => {
47
- i.current && clearTimeout(i.current), i.current = window.setTimeout(() => {
44
+ c(), h();
45
+ }, []), m = S(() => {
46
+ o.current && clearTimeout(o.current), o.current = window.setTimeout(() => {
48
47
  a(n);
49
48
  }, 250);
50
49
  }, [n, a]);
51
- return v(() => (window.addEventListener("resize", h), () => {
52
- window.removeEventListener("resize", h), i.current && clearTimeout(i.current);
53
- }), [a, h]), v(() => {
54
- const u = document.querySelector(".header-divider"), o = document.querySelector("sticky-content-wrapper");
55
- o && u && new IntersectionObserver(
50
+ return y(() => (window.addEventListener("resize", m), () => {
51
+ window.removeEventListener("resize", m), o.current && clearTimeout(o.current);
52
+ }), [a, m]), y(() => {
53
+ const u = document.querySelector(".header-divider"), c = document.querySelector("sticky-content-wrapper");
54
+ c && u && new IntersectionObserver(
56
55
  ([e]) => {
57
- e.intersectionRatio < 1 ? o.dataset.pinnedState = "pinned" : o.dataset.pinnedState = "unpinned";
56
+ e.intersectionRatio < 1 ? c.dataset.pinnedState = "pinned" : c.dataset.pinnedState = "unpinned";
58
57
  },
59
58
  {
60
59
  threshold: [1],
61
60
  rootMargin: "-37px"
62
61
  }
63
62
  ).observe(u);
64
- }, []), v(() => {
63
+ }, []), y(() => {
65
64
  a(n);
66
- }, [n, a]), /* @__PURE__ */ L("schedule-layout", { children: [
65
+ }, [n, a]), /* @__PURE__ */ b("schedule-layout", { children: [
67
66
  /* @__PURE__ */ t("sticky-content-wrapper", { "data-pinned-state": "unpinned", children: /* @__PURE__ */ t(
68
67
  "content-constrainer",
69
68
  {
70
- class: E([
69
+ class: L([
71
70
  "content-constrainer--no-padding",
72
71
  "content-constrainer--no-border",
73
72
  "content-constrainer--lead-container",
74
73
  "schedule-date-nav-constrainer"
75
74
  ]),
76
- children: /* @__PURE__ */ t(q, {})
75
+ children: /* @__PURE__ */ t(k, {})
77
76
  }
78
77
  ) }),
79
- /* @__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: b(n, "yyyy-MM-dd"), role: "tabpanel", children: /* @__PURE__ */ t(x, { fetchError: p, handleClicks: f }) }) }) })
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(n, "yyyy-MM-dd"), role: "tabpanel", children: /* @__PURE__ */ t(q, { handleClicks: f }) }) }) })
80
79
  ] });
81
80
  }
82
- function O({
83
- schedule: f = [],
84
- weeks: p = [],
85
- handleScheduleClicks: n = () => !0,
86
- handleDateChanged: r = () => !0,
87
- fetchError: m = !1
81
+ function N({
82
+ fetchSchedule: f,
83
+ initialSchedule: n = [],
84
+ weeks: r = [],
85
+ handleScheduleClicks: p = () => !0,
86
+ handleDateChanged: o = () => !0
88
87
  }) {
89
88
  return /* @__PURE__ */ t(
90
- T,
89
+ E,
91
90
  {
92
- handleDateChanged: r,
93
- schedule: f,
94
- weeks: p,
95
- children: /* @__PURE__ */ t(C, { fetchError: m, handleScheduleClicks: n })
91
+ fetchSchedule: f,
92
+ handleDateChanged: o,
93
+ initialSchedule: n,
94
+ weeks: r,
95
+ children: /* @__PURE__ */ t(x, { handleScheduleClicks: p })
96
96
  }
97
97
  );
98
98
  }
99
99
  export {
100
- O as ScheduleLayout,
101
- O as default
100
+ N as ScheduleLayout,
101
+ N as default
102
102
  };
@@ -9,6 +9,7 @@ export declare function useScheduleContext(): {
9
9
  }[][];
10
10
  currentDate: Date;
11
11
  isLoading: boolean;
12
+ isError: boolean;
12
13
  setCurrentDate: (date: Date) => void;
13
14
  };
14
15
  export default useScheduleContext;
@@ -1,7 +1,6 @@
1
1
  import { HandleClicksDetails } from '../../types.d.ts';
2
2
  type ScheduleListProps = {
3
3
  handleClicks?: (details: HandleClicksDetails) => boolean | void;
4
- fetchError?: boolean;
5
4
  };
6
- export declare function ScheduleList({ handleClicks, fetchError, }: ScheduleListProps): JSX.Element;
5
+ export declare function ScheduleList({ handleClicks, }: ScheduleListProps): JSX.Element;
7
6
  export default ScheduleList;
@@ -1,12 +1,12 @@
1
- import { jsx as a, jsxs as y } from "react/jsx-runtime";
2
- import { useReducer as R, useState as A, useRef as w, useCallback as L, useEffect as v } from "react";
1
+ import { jsx as a, jsxs as g } from "react/jsx-runtime";
2
+ import { useReducer as R, useState as A, useRef as w, useCallback as L, useEffect as E } from "react";
3
3
  import { classes as T, getMinutesFromStr as u } from "../../utils/helpers.js";
4
4
  import { useScheduleContext as b } from "../ScheduleLayout/useScheduleContext.js";
5
5
  import { Loading as x } from "../Loading/Loading.js";
6
6
  import { SportsItem as D } from "./schedule-list-items/SportsItem.js";
7
7
  import { SeriesItem as M } from "./schedule-list-items/SeriesItem.js";
8
8
  import { MovieItem as k } from "./schedule-list-items/MovieItem.js";
9
- import '../../assets/ScheduleList.css';const f = {
9
+ import '../../assets/ScheduleList.css';const l = {
10
10
  "schedule-list__item": "_schedule-list__item_wmqq1_1",
11
11
  "schedule-list__airdate": "_schedule-list__airdate_wmqq1_14",
12
12
  "airdate-formatter__date": "_airdate-formatter__date_wmqq1_22",
@@ -24,8 +24,8 @@ import '../../assets/ScheduleList.css';const f = {
24
24
  function S(r) {
25
25
  return typeof r == "object" && !Array.isArray(r) && (r == null ? void 0 : r.queryStatus) && r.queryStatus === "no-results";
26
26
  }
27
- function C(r, p) {
28
- switch (p.type) {
27
+ function C(r, t) {
28
+ switch (t.type) {
29
29
  case "START_EXIT":
30
30
  return "exiting";
31
31
  case "EXIT_COMPLETE":
@@ -38,9 +38,9 @@ function C(r, p) {
38
38
  return r;
39
39
  }
40
40
  }
41
- const E = (r) => {
42
- var p, t, s, n, e, o, d, g, _, l, i;
43
- return (p = r.video) != null && p.brightcove_id ? {
41
+ const v = (r) => {
42
+ var t, s, y, n, e, o, d, f, _, p, i;
43
+ return (t = r.video) != null && t.brightcove_id ? {
44
44
  label: "Watch Preview",
45
45
  type: "play-video",
46
46
  href: "",
@@ -71,10 +71,10 @@ const E = (r) => {
71
71
  //'film',
72
72
  position: void 0
73
73
  //'inline',
74
- } : (((t = r == null ? void 0 : r.content) == null ? void 0 : t.external_link) !== void 0 && ((s = r == null ? void 0 : r.content) == null ? void 0 : s.external_link) !== "" || ((n = r == null ? void 0 : r.content) == null ? void 0 : n.slug) !== void 0 && ((e = r == null ? void 0 : r.content) == null ? void 0 : e.slug) !== "") && !((o = r == null ? void 0 : r.content) != null && o.prevent_detail_page) ? {
74
+ } : (((s = r == null ? void 0 : r.content) == null ? void 0 : s.external_link) !== void 0 && ((y = r == null ? void 0 : r.content) == null ? void 0 : y.external_link) !== "" || ((n = r == null ? void 0 : r.content) == null ? void 0 : n.slug) !== void 0 && ((e = r == null ? void 0 : r.content) == null ? void 0 : e.slug) !== "") && !((o = r == null ? void 0 : r.content) != null && o.prevent_detail_page) ? {
75
75
  label: (r == null ? void 0 : r.program_class) === "Episode" ? "View Series Details" : (r == null ? void 0 : r.program_class) === "Film" ? "View Movie Details" : "Learn More",
76
76
  type: (d = r == null ? void 0 : r.content) != null && d.external_link ? "external-link" : "internal-link",
77
- href: (g = r == null ? void 0 : r.content) != null && g.external_link ? (_ = r == null ? void 0 : r.content) == null ? void 0 : _.external_link : r.program_class === "Episode" ? `/show/${(l = r == null ? void 0 : r.content) == null ? void 0 : l.slug}` : `/movie/${(i = r == null ? void 0 : r.content) == null ? void 0 : i.slug}`,
77
+ href: (f = r == null ? void 0 : r.content) != null && f.external_link ? (_ = r == null ? void 0 : r.content) == null ? void 0 : _.external_link : r.program_class === "Episode" ? `/show/${(p = r == null ? void 0 : r.content) == null ? void 0 : p.slug}` : `/movie/${(i = r == null ? void 0 : r.content) == null ? void 0 : i.slug}`,
78
78
  position: "inline"
79
79
  } : {
80
80
  label: "",
@@ -84,24 +84,23 @@ const E = (r) => {
84
84
  };
85
85
  };
86
86
  function H({
87
- handleClicks: r = () => !0,
88
- fetchError: p = !1
87
+ handleClicks: r = () => !0
89
88
  }) {
90
- const { schedule: t, isLoading: s } = b(), [n, e] = R(C, "idle"), [o, d] = A(t), g = w(null), _ = w(null), l = L(() => {
89
+ const { schedule: t, isLoading: s, isError: y } = b(), [n, e] = R(C, "idle"), [o, d] = A(t), f = w(null), _ = w(null), p = L(() => {
91
90
  _.current && (clearTimeout(_.current), _.current = null), n === "exiting" ? e({ type: "EXIT_COMPLETE" }) : n === "entering" && e({ type: "ENTER_COMPLETE" });
92
91
  }, [n]);
93
- return v(() => {
94
- const i = g.current;
92
+ return E(() => {
93
+ const i = f.current;
95
94
  if (i)
96
- return i.addEventListener("animationend", l), () => {
97
- i.removeEventListener("animationend", l);
95
+ return i.addEventListener("animationend", p), () => {
96
+ i.removeEventListener("animationend", p);
98
97
  };
99
- }, [l]), v(() => {
98
+ }, [p]), E(() => {
100
99
  s && n === "idle" && e({ type: "START_EXIT" });
101
- }, [s, n]), v(() => {
100
+ }, [s, n]), E(() => {
102
101
  const i = S(t) || Array.isArray(t) && t.length >= 0;
103
102
  !s && n === "loading" && i && (d(t), e({ type: "SCHEDULE_LOADED" }));
104
- }, [s, n, t]), v(() => () => {
103
+ }, [s, n, t]), E(() => () => {
105
104
  _.current && clearTimeout(_.current);
106
105
  }, []), n === "loading" ? /* @__PURE__ */ a(
107
106
  "div",
@@ -114,36 +113,36 @@ function H({
114
113
  },
115
114
  children: /* @__PURE__ */ a(x, {})
116
115
  }
117
- ) : p ? /* @__PURE__ */ y("div", { className: "schedule-list__no-schedule", children: [
116
+ ) : y ? /* @__PURE__ */ g("div", { className: "schedule-list__no-schedule", children: [
118
117
  /* @__PURE__ */ a("h2", { children: "There was an error loading the schedule for this day." }),
119
- /* @__PURE__ */ y("p", { children: [
118
+ /* @__PURE__ */ g("p", { children: [
120
119
  "Please try again later. If this problem persists report it at ",
121
120
  /* @__PURE__ */ a("a", { href: "https://support.iontelevision.com/support/home", children: "our support page" }),
122
121
  "."
123
122
  ] })
124
- ] }) : S(o) ? /* @__PURE__ */ y(
123
+ ] }) : S(o) ? /* @__PURE__ */ g(
125
124
  "div",
126
125
  {
127
126
  className: T([
128
- f["schedule-list__no-schedule"],
127
+ l["schedule-list__no-schedule"],
129
128
  "schedule-list__no-schedule"
130
129
  ]),
131
130
  "data-state": n,
132
131
  style: { animationDelay: "500ms" },
133
132
  children: [
134
133
  /* @__PURE__ */ a("h2", { children: "There are no shows scheduled for this day." }),
135
- /* @__PURE__ */ y("p", { children: [
134
+ /* @__PURE__ */ g("p", { children: [
136
135
  "Please try again later. If this problem persists report it at ",
137
136
  /* @__PURE__ */ a("a", { href: "https://support.iontelevision.com/support/home", children: "our support page" }),
138
137
  "."
139
138
  ] })
140
139
  ]
141
140
  }
142
- ) : Array.isArray(o) && o.length === 0 ? /* @__PURE__ */ y(
141
+ ) : Array.isArray(o) && o.length === 0 ? /* @__PURE__ */ g(
143
142
  "div",
144
143
  {
145
144
  className: T([
146
- f["schedule-list__no-schedule"],
145
+ l["schedule-list__no-schedule"],
147
146
  "schedule-list__no-schedule"
148
147
  ]),
149
148
  "data-state": n,
@@ -155,39 +154,39 @@ function H({
155
154
  ) : /* @__PURE__ */ a(
156
155
  "ul",
157
156
  {
158
- className: `${f["schedule-list"]} schedule-list`,
157
+ className: `${l["schedule-list"]} schedule-list`,
159
158
  "data-state": n,
160
- ref: g,
159
+ ref: f,
161
160
  children: Array.isArray(o) && o.map((i) => {
162
- const c = u(i.element_length), q = E(i).type === "" ? [c, i.rating] : [c, i.rating, "&nbsp;"];
161
+ const c = u(i.element_length), q = v(i).type === "" ? [c, i.rating] : [c, i.rating, "&nbsp;"];
163
162
  return i.program_class === "Episode" ? /* @__PURE__ */ a(
164
163
  M,
165
164
  {
166
- determineCTA: E,
165
+ determineCTA: v,
167
166
  handleClicks: r,
168
167
  scheduleItem: i,
169
168
  strListArr: q,
170
- styles: f
169
+ styles: l
171
170
  },
172
171
  `schedule-list-${i.id}`
173
172
  ) : i.program_class === "Film" || i.program_class === "Movie" || i.program_class === "Special" ? /* @__PURE__ */ a(
174
173
  k,
175
174
  {
176
- determineCTA: E,
175
+ determineCTA: v,
177
176
  handleClicks: r,
178
177
  scheduleItem: i,
179
178
  strListArr: q,
180
- styles: f
179
+ styles: l
181
180
  },
182
181
  `schedule-list-${i.id}`
183
182
  ) : i.program_class === "Sports" ? /* @__PURE__ */ a(
184
183
  D,
185
184
  {
186
- determineCTA: E,
185
+ determineCTA: v,
187
186
  handleClicks: r,
188
187
  scheduleItem: i,
189
188
  strListArr: q,
190
- styles: f
189
+ styles: l
191
190
  },
192
191
  `schedule-list-${i.id}`
193
192
  ) : null;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.0-alpha.6",
2
+ "version": "1.1.0-alpha.8",
3
3
  "name": "@scrippsproduct/networks-ui-library",
4
4
  "description": "React Component Library for use in Scripps Networks external applications",
5
5
  "author": {
@@ -28,9 +28,10 @@
28
28
  "create-component": "node scripts/componentFolderBuilder.js",
29
29
  "reinstall-deps": "node ./reinstall-deps.js",
30
30
  "login": "npm login",
31
- "publish": "node scripts/publish-with-otp.mjs"
31
+ "custom-publish": "node scripts/publish-with-otp.mjs"
32
32
  },
33
33
  "dependencies": {
34
+ "@tanstack/react-query": "^5.90.12",
34
35
  "date-fns": "^3.6.0",
35
36
  "date-fns-tz": "^3.1.3",
36
37
  "html-react-parser": "^5.1.10",