@streamlayer/react-ui 1.20.0 → 1.21.0

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.
@@ -41,26 +41,26 @@ const R = "data:image/svg+xml,%3csvg%20width='92'%20height='19'%20viewBox='0%200
41
41
  propsAsIs: !1
42
42
  }), q = ({
43
43
  deepLink: l,
44
- onboardingOpts: r,
44
+ onboardingOpts: C,
45
45
  notification: i,
46
- gamification: c,
46
+ gamification: p,
47
47
  loading: s,
48
48
  sdk: a
49
49
  }) => {
50
- var d, o, m, h, g, V, L;
51
- const p = x(c.friends.getStore()), [u, e] = I(void 0), f = S(() => {
52
- var n, b;
53
- const C = a.getInviter();
54
- return C ? (b = (n = p.data) == null ? void 0 : n.find(({
50
+ var o, m, h, g, V, L, n;
51
+ const d = x(p.friends.getStore()), [e, f] = I(void 0), u = S(() => {
52
+ var c, b;
53
+ const r = a.getInviter();
54
+ return r ? (b = (c = d.data) == null ? void 0 : c.find(({
55
55
  slId: k
56
- }) => k === C)) == null ? void 0 : b.name : "";
57
- }, [p.data, a]);
56
+ }) => k === r)) == null ? void 0 : b.name : "";
57
+ }, [d.data, a]);
58
58
  return B(() => {
59
- const C = l.$store.subscribe((n) => {
60
- n && e(n.data);
59
+ const r = l.$store.subscribe((c) => {
60
+ c && f(c.data);
61
61
  });
62
62
  return () => {
63
- C();
63
+ r();
64
64
  };
65
65
  }, [l.$store]), /* @__PURE__ */ t(W, {
66
66
  children: /* @__PURE__ */ t(E, {
@@ -75,45 +75,44 @@ const R = "data:image/svg+xml,%3csvg%20width='92'%20height='19'%20viewBox='0%200
75
75
  label: "Top the leader board and best your friends.",
76
76
  icon: "icon-trophy"
77
77
  }],
78
- rulesBtnLabel: (d = r.rules) == null ? void 0 : d.buttonLabel,
79
- rulesTitle: (o = r.rules) == null ? void 0 : o.heading,
78
+ rulesBtnLabel: (o = C.rules) == null ? void 0 : o.buttonLabel,
79
+ rulesTitle: (m = C.rules) == null ? void 0 : m.heading,
80
80
  termsTitle: "Terms and Conditions",
81
- termsText: (m = r.rules) == null ? void 0 : m.terms,
81
+ termsText: (h = C.rules) == null ? void 0 : h.terms,
82
82
  steps: H,
83
- primaryColor: (h = r.inviteCard) == null ? void 0 : h.iconColor,
84
- inviteLink: u,
85
- inviteCardTitle: (g = r.inviteCard) == null ? void 0 : g.heading,
86
- inviteCardSubtext: (V = r.inviteCard) == null ? void 0 : V.subtext,
87
- inviteCardBtnLabel: (L = r.inviteCard) == null ? void 0 : L.buttonLabel,
83
+ primaryColor: (g = C.inviteCard) == null ? void 0 : g.iconColor,
84
+ inviteLink: e,
85
+ inviteCardTitle: (V = C.inviteCard) == null ? void 0 : V.heading,
86
+ inviteCardSubtext: (L = C.inviteCard) == null ? void 0 : L.subtext,
87
+ inviteCardBtnLabel: (n = C.inviteCard) == null ? void 0 : n.buttonLabel,
88
88
  onClose: () => {
89
- var C;
90
- (C = i.close) == null || C.call(i);
89
+ var r;
90
+ (r = i.close) == null || r.call(i);
91
91
  },
92
- gamification: c,
92
+ gamification: p,
93
93
  sdk: a,
94
- inviterName: f
94
+ inviterName: u
95
95
  })
96
96
  });
97
97
  }, r2 = ({
98
98
  sdk: l,
99
- notification: r,
99
+ notification: C,
100
100
  saveHeight: i,
101
- style: c,
101
+ style: p,
102
102
  appNode: s,
103
- sdkInDesktopView: a,
104
- responsiveStore: p
103
+ responsiveStore: a
105
104
  }) => {
106
105
  var L;
107
- const u = A(null), e = r.data.onboarding, [f, d] = I(e == null ? void 0 : e.instantOpen), o = l.getFeature(j.GAMES), m = S(() => H == null ? void 0 : H.map(({
108
- graphicSrc: C
109
- }) => C), []), {
106
+ const d = A(null), e = C.data.onboarding, [f, u] = I(e == null ? void 0 : e.instantOpen), o = l.getFeature(j.GAMES), m = S(() => H == null ? void 0 : H.map(({
107
+ graphicSrc: n
108
+ }) => n), []), {
110
109
  screen: h
111
- } = x(p, {
110
+ } = x(a, {
112
111
  keys: ["screen"]
113
112
  });
114
113
  (L = e == null ? void 0 : e.titleCard) != null && L.media && (e.titleCard.media.sponsorLogo = R), _(() => {
115
- var C;
116
- i(((C = u.current) == null ? void 0 : C.getBoundingClientRect().height) || 0);
114
+ var n;
115
+ i(((n = d.current) == null ? void 0 : n.getBoundingClientRect().height) || 0);
117
116
  }, [i]);
118
117
  const {
119
118
  loading: g,
@@ -121,10 +120,10 @@ const R = "data:image/svg+xml,%3csvg%20width='92'%20height='19'%20viewBox='0%200
121
120
  } = T(m);
122
121
  return f && o && e && s.current && !V ? /* @__PURE__ */ t(G, {
123
122
  container: s,
124
- useContainer: !a,
123
+ useContainer: !1,
125
124
  children: /* @__PURE__ */ t(q, {
126
- notification: r,
127
- setOpened: d,
125
+ notification: C,
126
+ setOpened: u,
128
127
  gamification: o,
129
128
  onboardingOpts: e,
130
129
  deepLink: o.deepLink,
@@ -133,7 +132,7 @@ const R = "data:image/svg+xml,%3csvg%20width='92'%20height='19'%20viewBox='0%200
133
132
  })
134
133
  }) : /* @__PURE__ */ Z(w, {
135
134
  children: [/* @__PURE__ */ t(y, {
136
- ref: u,
135
+ ref: d,
137
136
  style: {
138
137
  position: "absolute",
139
138
  visibility: "hidden"
@@ -146,14 +145,14 @@ const R = "data:image/svg+xml,%3csvg%20width='92'%20height='19'%20viewBox='0%200
146
145
  onboarding: e
147
146
  })
148
147
  }), /* @__PURE__ */ t(O, {
149
- style: c,
150
- hiding: r.hiding,
148
+ style: p,
149
+ hiding: C.hiding,
151
150
  children: /* @__PURE__ */ t(y, {
152
151
  children: /* @__PURE__ */ t(M, {
153
- close: r.close,
152
+ close: C.close,
154
153
  action: () => {
155
- var n;
156
- d(!0), (((n = s.current) == null ? void 0 : n.getBoundingClientRect().y) || 0) < 0 && F(s, h.size, {
154
+ var r;
155
+ u(!0), (((r = s.current) == null ? void 0 : r.getBoundingClientRect().y) || 0) < 0 && F(s, h.size, {
157
156
  behavior: "smooth"
158
157
  });
159
158
  },
@@ -1,82 +1,77 @@
1
- import { jsxs as f, Fragment as D, jsx as c } from "react/jsx-runtime";
2
- import { cx as N } from "@linaria/core";
1
+ import { jsxs as g, Fragment as V, jsx as c } from "react/jsx-runtime";
2
+ import { cx as D } from "@linaria/core";
3
3
  import { useMastersContext as T } from "../useMastersContext.js";
4
4
  import { scrollIntoAppView as q } from "../useSdkScroll.js";
5
- import { useState as p, useMemo as E, useEffect as h, useRef as O, useCallback as w } from "react";
5
+ import { useState as f, useMemo as E, useEffect as h, useRef as O, useCallback as w } from "react";
6
6
  import { r as b } from "../../../index-DALxy-8N.js";
7
- import { useStore as g } from "@streamlayer/react-polyfills";
7
+ import { useStore as p } from "@streamlayer/react-polyfills";
8
8
  import { eventBus as C } from "@streamlayer/sdk-web-interfaces";
9
9
  import { NotificationType as a } from "@streamlayer/sdk-web-notifications";
10
10
  import { QuestionTypeData as R } from "../../../ui/gamification/constants.js";
11
- import { Notification as V } from "../../../ui/gamification/question/notification/index.js";
11
+ import { Notification as N } from "../../../ui/gamification/question/notification/index.js";
12
12
  import { PredictionResult as P } from "../../../ui/gamification/question/notification/prediction-result/index.js";
13
13
  import { Onboarding as x } from "./Onboarding/index.js";
14
14
  import { HiddenContainer as A, Container as B, InnerContainer as H, NotificationRefreshing as Q, Pill as U } from "./styles.js";
15
15
  const j = (n) => {
16
- const [t, u] = p(0), i = O(null), d = w((r) => {
17
- i.current = r;
16
+ const [t, u] = f(0), i = O(null), l = w((o) => {
17
+ i.current = o;
18
18
  }, []);
19
19
  h(() => {
20
- var l;
21
- const r = (l = i.current) == null ? void 0 : l.getBoundingClientRect();
22
- r && u(r.height);
20
+ var d;
21
+ const o = (d = i.current) == null ? void 0 : d.getBoundingClientRect();
22
+ o && u(o.height);
23
23
  }, [n]);
24
- const o = w((r) => {
25
- u(r);
24
+ const r = w((o) => {
25
+ u(o);
26
26
  }, []);
27
- return [d, t, o];
27
+ return [l, t, r];
28
28
  }, z = ({
29
29
  sdk: n,
30
30
  notification: t,
31
31
  appNode: u,
32
32
  responsiveStore: i
33
33
  }) => {
34
- var s, e;
34
+ var m, s;
35
35
  const {
36
- sdkInDesktopView: d
37
- } = g(i, {
38
- keys: ["sdkInDesktopView"]
39
- }), {
40
- sdk: o
41
- } = T(), [r, l, m] = j(t.id);
42
- return t.type === a.QUESTION ? /* @__PURE__ */ f(D, {
36
+ sdk: l
37
+ } = T(), [r, o, d] = j(t.id);
38
+ return t.type === a.QUESTION ? /* @__PURE__ */ g(V, {
43
39
  children: [/* @__PURE__ */ c(A, {
44
40
  ref: r,
45
- children: /* @__PURE__ */ c(V, {
41
+ children: /* @__PURE__ */ c(N, {
46
42
  ...t
47
43
  })
48
- }), /* @__PURE__ */ f(B, {
44
+ }), /* @__PURE__ */ g(B, {
49
45
  style: {
50
- height: t.hiding ? 0 : l
46
+ height: t.hiding ? 0 : o
51
47
  },
52
48
  hiding: t.hiding,
53
49
  children: [/* @__PURE__ */ c(H, {
54
50
  style: {
55
51
  height: "100%"
56
52
  },
57
- children: /* @__PURE__ */ c(V, {
53
+ children: /* @__PURE__ */ c(N, {
58
54
  ...t,
59
- controlVideo: o == null ? void 0 : o.controlVideoPlayer
55
+ controlVideo: l == null ? void 0 : l.controlVideoPlayer
60
56
  })
61
57
  }), /* @__PURE__ */ c(Q, {}, t.id)]
62
58
  })]
63
- }) : t.type === a.QUESTION_RESOLVED && ((e = (s = t.data) == null ? void 0 : s.question) != null && e.predictionResult) ? /* @__PURE__ */ c(P, {
59
+ }) : t.type === a.QUESTION_RESOLVED && ((s = (m = t.data) == null ? void 0 : m.question) != null && s.predictionResult) ? /* @__PURE__ */ c(P, {
64
60
  style: {
65
- height: t.hiding ? 0 : l
61
+ height: t.hiding ? 0 : o
66
62
  },
67
- saveHeight: m,
63
+ saveHeight: d,
68
64
  close: t.close,
69
65
  hiding: t.hiding,
70
66
  ...t.data.question,
71
67
  mastersApp: !0
72
68
  }) : t.type === a.ONBOARDING ? /* @__PURE__ */ c(x, {
73
69
  style: {
74
- height: t.hiding ? 0 : l
70
+ height: t.hiding ? 0 : o
75
71
  },
76
- saveHeight: m,
72
+ saveHeight: d,
77
73
  sdk: n,
78
74
  notification: t,
79
- sdkInDesktopView: d,
80
75
  appNode: u,
81
76
  responsiveStore: i
82
77
  }) : null;
@@ -85,47 +80,47 @@ const j = (n) => {
85
80
  setPill: t,
86
81
  appNode: u,
87
82
  headerNode: i,
88
- scrollNode: d,
89
- responsiveStore: o,
90
- scrollStore: r
83
+ scrollNode: l,
84
+ responsiveStore: r,
85
+ scrollStore: o
91
86
  }) => {
92
- var k, y;
87
+ var y, I;
93
88
  const {
94
- screen: l
95
- } = g(o, {
89
+ screen: d
90
+ } = p(r, {
96
91
  keys: ["screen"]
97
92
  }), {
98
93
  tabsShown: m,
99
94
  scrollPosition: s
100
- } = g(r, {
95
+ } = p(o, {
101
96
  keys: ["tabsShown", "scrollPosition"]
102
97
  });
103
98
  h(() => {
104
- o.get().sdkInDesktopView ? s < 50 && t(null) : s > -50 && t(null);
105
- }, [s, o, t]);
106
- const e = o.get().sdkInDesktopView ? u : i;
99
+ r.get().sdkInDesktopView ? s < 50 && t(null) : s > -50 && t(null);
100
+ }, [s, r, t]);
101
+ const e = r.get().sdkInDesktopView ? u : i;
107
102
  return !n || !e.current ? null : b.createPortal(/* @__PURE__ */ c(U, {
108
- title: n.type === a.QUESTION_RESOLVED ? "Prediction result" : `New ${((y = R[(k = n.data) == null ? void 0 : k.questionType]) == null ? void 0 : y.label) || "notification"}`,
103
+ title: n.type === a.QUESTION_RESOLVED ? "Prediction result" : `New ${((I = R[(y = n.data) == null ? void 0 : y.questionType]) == null ? void 0 : I.label) || "notification"}`,
109
104
  onClick: () => {
110
- var I;
111
- o.get().sdkInDesktopView ? (I = d.current) == null || I.scrollTo({
105
+ var k;
106
+ r.get().sdkInDesktopView ? (k = l.current) == null || k.scrollTo({
112
107
  top: 0,
113
108
  behavior: "smooth"
114
- }) : q(u, l.size, {
109
+ }) : q(u, d.size, {
115
110
  behavior: "smooth"
116
111
  }), t(null);
117
112
  },
118
- className: N(m && F, "sl-pill-button")
113
+ className: D(m && F, "sl-pill-button")
119
114
  }), e.current);
120
115
  }, it = ({
121
116
  sdk: n,
122
117
  headerNode: t,
123
118
  scrollNode: u,
124
119
  responsiveStore: i,
125
- appNode: d,
126
- scrollStore: o
120
+ appNode: l,
121
+ scrollStore: r
127
122
  }) => {
128
- const [r] = p(n.getNotificationsStore()), l = g(r), [m, s] = p(null), e = E(() => n.getActiveNotification(), [n, l]);
123
+ const [o] = f(n.getNotificationsStore()), d = p(o), [m, s] = f(null), e = E(() => n.getActiveNotification(), [n, d]);
129
124
  return h(() => {
130
125
  e && C.emit("notification", {
131
126
  action: "rendered",
@@ -136,25 +131,25 @@ const j = (n) => {
136
131
  });
137
132
  }, [e]), h(() => {
138
133
  e && (i.get().sdkInDesktopView || i.get().sdkInView) && (!i.get().sdkInDesktopView && i.get().sdkInView && s(e), i.get().sdkInDesktopView && window.requestAnimationFrame(() => {
139
- o.get().scrollPosition !== 0 && s(e);
134
+ r.get().scrollPosition !== 0 && s(e);
140
135
  }));
141
136
  }, [e]), h(() => {
142
137
  e || s(null);
143
- }, [e]), /* @__PURE__ */ f(D, {
138
+ }, [e]), /* @__PURE__ */ g(V, {
144
139
  children: [!m && e && /* @__PURE__ */ c(z, {
145
140
  headerNode: t,
146
- appNode: d,
141
+ appNode: l,
147
142
  sdk: n,
148
143
  notification: e,
149
144
  responsiveStore: i
150
145
  }), m && /* @__PURE__ */ c(L, {
151
146
  pill: m,
152
147
  setPill: s,
153
- appNode: d,
148
+ appNode: l,
154
149
  notification: e,
155
150
  headerNode: t,
156
151
  scrollNode: u,
157
- scrollStore: o,
152
+ scrollStore: r,
158
153
  responsiveStore: i
159
154
  })]
160
155
  });
@@ -19,35 +19,25 @@ import { StreamLayerMastersThemeProvider as se } from "../../ui/theme/masters.js
19
19
  const B = ({ sdk: e, className: t }) => {
20
20
  const [, r] = y(e);
21
21
  return /* @__PURE__ */ a(k, { className: t, feature: r, sdk: e });
22
- }, K = ({ sdk: e, className: t, appNode: r, responsiveStore: n }) => {
23
- const s = c(e.featuresList.getStore());
24
- return s ? Array.from(s, (o) => {
25
- const i = e.getFeature(o);
26
- return i ? /* @__PURE__ */ a(
27
- z,
28
- {
29
- className: t,
30
- appNode: r,
31
- feature: i,
32
- responsiveStore: n,
33
- sdk: e
34
- },
35
- o
36
- ) : null;
22
+ }, K = ({ sdk: e, className: t, appNode: r }) => {
23
+ const o = c(e.featuresList.getStore());
24
+ return o ? Array.from(o, (n) => {
25
+ const s = e.getFeature(n);
26
+ return s ? /* @__PURE__ */ a(z, { className: t, appNode: r, feature: s, sdk: e }, n) : null;
37
27
  }) : null;
38
28
  }, O = (e) => {
39
- const [t, r] = b(!S(v().size)), n = d(null);
29
+ const [t, r] = b(!S(v().size)), o = d(null);
40
30
  return p(() => {
41
- const s = A(() => {
42
- const o = v();
43
- r(!S(o.size));
31
+ const n = A(() => {
32
+ const s = v();
33
+ r(!S(s.size));
44
34
  }, 200);
45
- return window.addEventListener("resize", s), () => {
46
- window.removeEventListener("resize", s);
35
+ return window.addEventListener("resize", n), () => {
36
+ window.removeEventListener("resize", n);
47
37
  };
48
- }, []), h(n, { enabled: !0, event: "click", listener: F }), /* @__PURE__ */ a(M, { ref: n, ...e, isMobile: t });
38
+ }, []), h(o, { enabled: !0, event: "click", listener: F }), /* @__PURE__ */ a(M, { ref: o, ...e, isMobile: t });
49
39
  }, R = ({ sdk: e }) => {
50
- const t = d(null), r = c(e.status), n = c(e.sdkStore.slStreamId), s = d(null), [o] = D(t), [i, l] = x(t, o), m = r === "ready" && !!n.data;
40
+ const t = d(null), r = c(e.status), o = c(e.sdkStore.slStreamId), n = d(null), [s] = D(t), [i, l] = x(t, s), m = r === "ready" && !!o.data;
51
41
  return p(() => {
52
42
  window.requestAnimationFrame(() => {
53
43
  e.initializeApp().then(() => {
@@ -57,33 +47,33 @@ const B = ({ sdk: e, className: t }) => {
57
47
  }, [e]), h(t, { enabled: !0, event: "click", listener: F }), p(() => {
58
48
  import("./Features/Gamification/gamification-feature.js");
59
49
  }, []), /* @__PURE__ */ f(L, { ref: t, children: [
60
- /* @__PURE__ */ a(C, { className: w(u, "sl-hide-on-modal"), ref: s }),
50
+ /* @__PURE__ */ a(C, { className: w(u, "sl-hide-on-modal"), ref: n }),
61
51
  /* @__PURE__ */ f(N, { "data-nav": !0, className: "sl-hide-on-modal", ref: i, children: [
62
52
  m && /* @__PURE__ */ a(
63
53
  P,
64
54
  {
65
55
  sdk: e,
66
56
  scrollNode: i,
67
- headerNode: s,
57
+ headerNode: n,
68
58
  appNode: t,
69
59
  scrollStore: l,
70
- responsiveStore: o
60
+ responsiveStore: s
71
61
  }
72
62
  ),
73
63
  m && /* @__PURE__ */ a(B, { className: u, sdk: e }),
74
- m && /* @__PURE__ */ a(K, { responsiveStore: o, appNode: t, className: u, sdk: e })
64
+ m && /* @__PURE__ */ a(K, { appNode: t, className: u, sdk: e })
75
65
  ] })
76
66
  ] });
77
67
  }, re = ({ sdk: e, betPack: t }) => {
78
- const [r, n] = b(t), o = !!c(e.userId()), i = E(() => ({ sdk: e }), [e]);
68
+ const [r, o] = b(t), s = !!c(e.userId()), i = E(() => ({ sdk: e }), [e]);
79
69
  return /* @__PURE__ */ f(g.Provider, { value: i, children: [
80
- r && o && /* @__PURE__ */ a(
70
+ r && s && /* @__PURE__ */ a(
81
71
  O,
82
72
  {
83
73
  sdk: e,
84
- onEvent: ({ type: l }) => l === "slOpenGameCenter" ? n(!1) : () => {
74
+ onEvent: ({ type: l }) => l === "slOpenGameCenter" ? o(!1) : () => {
85
75
  },
86
- close: () => n(!1)
76
+ close: () => o(!1)
87
77
  }
88
78
  ),
89
79
  !r && /* @__PURE__ */ a(R, { sdk: e })
@@ -0,0 +1,3 @@
1
+ export declare const useOrientation: () => {
2
+ orientation: string;
3
+ };
@@ -0,0 +1,12 @@
1
+ import { useState as i, useEffect as o } from "react";
2
+ const a = () => {
3
+ const [t, n] = i(""), e = () => {
4
+ window.screen.orientation.type.includes("landscape") || Math.abs(window.orientation) === 90 ? n("landscape") : n("portrait");
5
+ };
6
+ return o(() => (window.screen.orientation.addEventListener("change", e), window.addEventListener("orientationchange", e), e(), () => {
7
+ window.screen.orientation.removeEventListener("change", e), window.removeEventListener("orientationchange", e);
8
+ }), []), { orientation: t };
9
+ };
10
+ export {
11
+ a as useOrientation
12
+ };