@streamlayer/react-ui 0.68.0 → 0.68.2

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,12 +1,12 @@
1
- import { jsx as i, jsxs as g, Fragment as O } from "react/jsx-runtime";
2
- import { useState as l, useCallback as C, useMemo as n } from "react";
3
- import { QuestionType as v } from "@streamlayer/sdk-web-types";
4
- import { SDKScrollContainer as b } from "../../app/styles.js";
5
- import { ExpiredAlert as u } from "./expired-alert/index.js";
6
- import { Feedback as M } from "./feedback/index.js";
7
- import { Container as j, Content as k, Title as D, Options as P } from "./styles.js";
8
- import { VotingOption as F } from "./vote-option/index.js";
9
- import { WinBar as L } from "./win-bar/index.js";
1
+ import { jsx as a, jsxs as C, Fragment as S } from "react/jsx-runtime";
2
+ import { useState as l, useCallback as v, useMemo as n } from "react";
3
+ import { QuestionType as p } from "@streamlayer/sdk-web-types";
4
+ import { SDKScrollContainer as P } from "../../app/styles.js";
5
+ import { ExpiredAlert as b } from "./expired-alert/index.js";
6
+ import { Feedback as u } from "./feedback/index.js";
7
+ import { Container as D, Content as L, Title as M, Options as j } from "./styles.js";
8
+ import { VotingOption as k } from "./vote-option/index.js";
9
+ import { WinBar as F } from "./win-bar/index.js";
10
10
  import "@linaria/react";
11
11
  import "../../icons/index.js";
12
12
  import "./expired-alert/styles.js";
@@ -18,73 +18,76 @@ import "../../timer/index.js";
18
18
  import "react-countdown-circle-timer";
19
19
  import "../../theme/constants.js";
20
20
  import "./win-bar/styles.js";
21
- const st = ({ openedQuestion: t, vote: f, close: p }) => {
22
- var q;
23
- const E = t.subject, V = t.type, m = (q = t.options) == null ? void 0 : q.options, [s, A] = l(!1), [d, T] = l(!1), [w, h] = l(""), e = t == null ? void 0 : t.id, y = C(
21
+ const mt = ({ openedQuestion: t, vote: f, close: T }) => {
22
+ var x;
23
+ const E = t.subject, V = t.type, c = (x = t.options) == null ? void 0 : x.options, [m, A] = l(!1), [y, d] = l(!1), [w, h] = l(""), e = t == null ? void 0 : t.id, g = v(
24
24
  async (r) => {
25
25
  if (e) {
26
- const c = r.currentTarget.value;
27
- h(c), T(!0), await f(e, c), T(!1);
26
+ const s = r.currentTarget.value;
27
+ h(s), d(!0), await f(e, s), d(!1);
28
28
  }
29
29
  },
30
30
  [e, h, f]
31
- ), I = C(() => {
32
- A(!0), setTimeout(p, 3e3);
33
- }, [p]), a = n(
31
+ ), I = v(() => {
32
+ A(!0), setTimeout(T, 3e3);
33
+ }, [T]), i = n(
34
34
  () => t == null ? void 0 : t.answers.find((r) => r.youVoted === !0),
35
35
  [t]
36
36
  ), o = n(
37
37
  () => !!(t != null && t.answers.find((r) => r.correct === !0)),
38
38
  [t]
39
- ), S = n(() => t ? t.answers.map((r) => {
40
- var c;
39
+ ), O = n(() => t ? t.answers.map((r) => {
40
+ var s;
41
41
  return {
42
42
  ...r,
43
- questionVoted: !!a,
43
+ questionVoted: !!i,
44
44
  youSelected: w === r.id,
45
- isLoading: d,
45
+ isLoading: y,
46
46
  hasCorrectAnswer: o,
47
47
  questionType: t.type,
48
- answerTimeExpired: s,
48
+ answerTimeExpired: m,
49
49
  questionStatus: t.status,
50
- imageMode: (c = t.appearance) == null ? void 0 : c.images,
50
+ imageMode: (s = t.appearance) == null ? void 0 : s.images,
51
51
  // ToDo: Figure out why imageMode is not in the response
52
- onVote: y
52
+ onVote: g
53
53
  };
54
- }) : [], [o, s, d, t, a, y, w]), x = m && (m.case === "trivia" || m.case === "prediction") ? m.value : void 0;
55
- return /* @__PURE__ */ i(b, { "data-question-header": "true", children: /* @__PURE__ */ i(j, { children: /* @__PURE__ */ g(k, { children: [
56
- x && /* @__PURE__ */ i(
57
- M,
54
+ }) : [], [o, m, y, t, i, g, w]), q = c && (c.case === "trivia" || c.case === "prediction") ? c.value : void 0;
55
+ return /* @__PURE__ */ a(P, { "data-question-header": "true", children: /* @__PURE__ */ a(D, { children: /* @__PURE__ */ C(L, { children: [
56
+ q && /* @__PURE__ */ a(
57
+ u,
58
58
  {
59
- feedbackMessages: x,
60
- questionVoted: !!a,
61
- questionVotedCorrectly: a == null ? void 0 : a.correct,
59
+ feedbackMessages: q,
60
+ questionVoted: !!i,
61
+ questionVotedCorrectly: i == null ? void 0 : i.correct,
62
62
  questionType: V,
63
63
  hasCorrectAnswer: o,
64
64
  questionStatus: t.status
65
65
  }
66
66
  ),
67
- t.type !== v.PREDICTION && /* @__PURE__ */ i(
68
- L,
67
+ t.type !== p.PREDICTION && /* @__PURE__ */ a(
68
+ F,
69
69
  {
70
- title: s ? "Time expired" : "To win",
71
- points: s ? void 0 : 100,
70
+ title: m ? "Time expired" : t.type === p.POLL ? "Time remaining" : "To win",
71
+ points: m ? void 0 : 100,
72
72
  onTimerExpired: I,
73
- isTimer: !0
73
+ questionType: t.type,
74
+ isTimer: !0,
75
+ isPlayingTimer: !i,
76
+ timerDuration: i ? 0 : 30
74
77
  }
75
78
  ),
76
- s ? /* @__PURE__ */ i(
77
- u,
79
+ m ? /* @__PURE__ */ a(
80
+ b,
78
81
  {
79
82
  title: "More to come...",
80
83
  description: "Watch for additional enhanced stream interactive experience."
81
84
  }
82
- ) : /* @__PURE__ */ g(O, { children: [
83
- /* @__PURE__ */ i(D, { "data-isPrediction": t.type === v.PREDICTION, children: E }),
84
- /* @__PURE__ */ i(P, { children: S.map((r) => /* @__PURE__ */ i(F, { ...r }, r.id)) })
85
+ ) : /* @__PURE__ */ C(S, { children: [
86
+ /* @__PURE__ */ a(M, { "data-isPrediction": t.type === p.PREDICTION, children: E }),
87
+ /* @__PURE__ */ a(j, { children: O.map((r) => /* @__PURE__ */ a(k, { ...r }, r.id)) })
85
88
  ] })
86
89
  ] }) }) });
87
90
  };
88
91
  export {
89
- st as Vote
92
+ mt as Vote
90
93
  };
@@ -1,9 +1,12 @@
1
1
  /// <reference types="react" />
2
+ import { QuestionType } from '@streamlayer/sdk-web-types';
2
3
  interface WinBarProps {
3
4
  title?: string;
4
5
  points?: number;
5
6
  isPlayingTimer?: boolean;
6
7
  isTimer?: boolean;
8
+ questionType?: QuestionType;
9
+ timerDuration?: number;
7
10
  onTimerExpired?: () => void;
8
11
  }
9
12
  export declare const WinBar: React.FC<WinBarProps>;
@@ -1,24 +1,33 @@
1
- import { jsxs as r, jsx as i, Fragment as c } from "react/jsx-runtime";
2
- import { Timer as p } from "../../../timer/index.js";
3
- import { WinBarContainer as d, Content as h, Title as l, WinIcon as s, Points as a, PointsCount as P, PointsUnits as f } from "./styles.js";
1
+ import { jsxs as r, jsx as i, Fragment as d } from "react/jsx-runtime";
2
+ import { QuestionType as s } from "@streamlayer/sdk-web-types";
3
+ import { Timer as h } from "../../../timer/index.js";
4
+ import { WinBarContainer as l, Content as a, Title as P, WinIcon as f, Points as u, PointsCount as T, PointsUnits as x } from "./styles.js";
4
5
  import "@linaria/react";
5
6
  import "react";
6
7
  import "react-countdown-circle-timer";
7
8
  import "../../../theme/constants.js";
8
9
  import "../../../icons/index.js";
9
- const B = ({ title: n, points: o, isPlayingTimer: t, isTimer: e, onTimerExpired: m }) => /* @__PURE__ */ r(d, { children: [
10
- /* @__PURE__ */ r(h, { children: [
11
- n && /* @__PURE__ */ i(l, { children: n }),
12
- o !== void 0 && /* @__PURE__ */ r(c, { children: [
13
- /* @__PURE__ */ i(s, { name: "icon-trophy" }),
14
- /* @__PURE__ */ r(a, { children: [
15
- /* @__PURE__ */ i(P, { children: o }),
16
- /* @__PURE__ */ i(f, { children: "PTS" })
10
+ const I = ({
11
+ title: n,
12
+ points: o,
13
+ isPlayingTimer: t,
14
+ isTimer: e,
15
+ questionType: m,
16
+ timerDuration: p,
17
+ onTimerExpired: c
18
+ }) => /* @__PURE__ */ r(l, { children: [
19
+ /* @__PURE__ */ r(a, { children: [
20
+ n && /* @__PURE__ */ i(P, { children: n }),
21
+ o !== void 0 && m !== s.POLL && /* @__PURE__ */ r(d, { children: [
22
+ /* @__PURE__ */ i(f, { name: "icon-trophy" }),
23
+ /* @__PURE__ */ r(u, { children: [
24
+ /* @__PURE__ */ i(T, { children: o }),
25
+ /* @__PURE__ */ i(x, { children: "PTS" })
17
26
  ] })
18
27
  ] })
19
28
  ] }),
20
- e && /* @__PURE__ */ i(p, { isPlaying: t, onTimerExpired: m })
29
+ e && /* @__PURE__ */ i(h, { isPlaying: t, onTimerExpired: c, duration: p })
21
30
  ] });
22
31
  export {
23
- B as WinBar
32
+ I as WinBar
24
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamlayer/react-ui",
3
- "version": "0.68.0",
3
+ "version": "0.68.2",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "typings": "./lib/index.d.ts",
@@ -89,6 +89,6 @@
89
89
  "vite-plugin-svgr": "^4.1.0",
90
90
  "vite-svg-loader": "^4.0.0",
91
91
  "vite-tsconfig-paths": "^4.2.1",
92
- "@streamlayer/react": "^0.31.0"
92
+ "@streamlayer/react": "^0.31.2"
93
93
  }
94
94
  }