@streamlayer/react-ui 0.97.1 → 0.98.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.
@@ -1,82 +1,73 @@
1
- import { jsx as i, jsxs as n, Fragment as t } from "react/jsx-runtime";
2
- import { useRef as C } from "react";
3
- import { QuestionType as d } from "@streamlayer/sdk-web-types";
4
- import { SvgIcon as a } from "../../../icons/index.js";
5
- import { ShowInContainer as E, Container as K, IconPrediction as j, FeedbackDescription as l, FeedbackIconWrap as m, FeedbackHeader as F, FeedbackText as I, DynamicWrap as z, FeedbackTitle as G } from "./styles.js";
1
+ import { jsx as i, jsxs as n, Fragment as e } from "react/jsx-runtime";
2
+ import { QuestionType as r } from "@streamlayer/sdk-web-types";
3
+ import { SvgIcon as h } from "../../../icons/index.js";
4
+ import { ShowInContainer as C, Container as L, IconPrediction as W, FeedbackDescription as l, FeedbackIconWrap as a, FeedbackHeader as F, FeedbackText as k, DynamicWrap as Y, FeedbackTitle as E } from "./styles.js";
6
5
  import "@linaria/react";
6
+ import "react";
7
7
  import "../../../show-in/index.js";
8
8
  import "@linaria/core";
9
- const V = ({
10
- feedbackMessages: r,
11
- questionVotedCorrectly: x,
12
- questionVoted: p,
13
- questionType: e,
14
- hasCorrectAnswer: u,
15
- showExpiredNotification: w,
16
- showClosedNotificationTrivia: P,
17
- votedInCurrentRender: o,
18
- votedAfterQuestionClosed: H,
9
+ const _ = ({
10
+ feedbackMessages: t,
11
+ questionVotedCorrectly: u,
12
+ questionVoted: m,
13
+ questionType: d,
14
+ hasCorrectAnswer: b,
15
+ showExpiredNotification: x,
16
+ showClosedNotificationTrivia: I,
17
+ votedInCurrentRender: p,
18
+ votedAfterQuestionClosed: f,
19
19
  voteErrorMessage: c,
20
- enteredAnActiveQuestion: y,
21
- marketClosed: L,
22
- percentsAnimated: Y
20
+ enteredAnActiveQuestion: w,
21
+ marketClosed: Q,
22
+ percentsAnimated: j
23
23
  }) => {
24
- var Q;
25
- const f = p && (e === d.TRIVIA || e === d.PREDICTION), D = e === d.PREDICTION && !u, O = L && e === d.PREDICTION && !p && !y || e === d.PREDICTION && H && o && y, R = f && D, T = f && u, N = e === d.PREDICTION && p && o && u, S = p && e === d.POLL && o, b = x ? "correct" : "incorrect", h = x ? r == null ? void 0 : r.correctFeedback : r == null ? void 0 : r.incorrectFeedback, s = w || P || R || T || O || S || N || c, W = C(null), B = (Q = W.current) == null ? void 0 : Q.getBoundingClientRect().height, k = o && !Y;
26
- return s ? /* @__PURE__ */ i(
27
- E,
28
- {
29
- enabled: o && !k,
30
- replayKey: k,
31
- style: o ? { height: k ? 0 : B } : {},
32
- children: /* @__PURE__ */ n(K, { ref: W, "data-prediction": D, children: [
33
- c && /* @__PURE__ */ n(t, { children: [
34
- /* @__PURE__ */ i(j, { name: "questionExpired" }),
35
- /* @__PURE__ */ i(l, { children: c })
36
- ] }),
37
- !c && w && /* @__PURE__ */ n(t, { children: [
38
- /* @__PURE__ */ i(m, { children: /* @__PURE__ */ i(a, { name: "questionExpired" }) }),
39
- /* @__PURE__ */ n("div", { children: [
40
- /* @__PURE__ */ i(F, { children: /* @__PURE__ */ i(l, { children: "Question Expired" }) }),
41
- /* @__PURE__ */ i(I, { children: "You can still answer to see if you're correct, but no points are awarded for expired questions." })
42
- ] })
43
- ] }),
44
- !c && P && /* @__PURE__ */ n(t, { children: [
45
- /* @__PURE__ */ i(m, { children: /* @__PURE__ */ i(a, { name: "questionExpired" }) }),
46
- /* @__PURE__ */ n("div", { children: [
47
- /* @__PURE__ */ i(F, { children: /* @__PURE__ */ i(l, { children: "Question Closed" }) }),
48
- /* @__PURE__ */ i(I, { children: "This question was answered after the moderator closed the question. So the points for this answer won’t tally." })
49
- ] })
50
- ] }),
51
- !c && O && /* @__PURE__ */ n(t, { children: [
52
- /* @__PURE__ */ i(m, { children: /* @__PURE__ */ i(a, { name: "questionExpired" }) }),
53
- /* @__PURE__ */ n("div", { children: [
54
- /* @__PURE__ */ i(F, { children: /* @__PURE__ */ i(l, { children: "Question Closed" }) }),
55
- /* @__PURE__ */ i(I, { children: "This event has already taken place, so the ability to make a prediction on its outcome is no longer available." })
56
- ] })
57
- ] }),
58
- !c && R && /* @__PURE__ */ n(t, { children: [
59
- /* @__PURE__ */ i(j, { name: "icon-prediction" }),
60
- /* @__PURE__ */ n(l, { children: [
61
- "Your pick has been recorded. ",
62
- /* @__PURE__ */ i(z, { children: "We’ll notify you of the result." })
63
- ] })
64
- ] }),
65
- !c && S && /* @__PURE__ */ n(t, { children: [
66
- /* @__PURE__ */ i(m, { "data-feedback-type": "correct", children: /* @__PURE__ */ i(a, { name: "correct" }) }),
67
- /* @__PURE__ */ i(l, { children: "Thanks for answering. Please stay tuned for the next question." })
68
- ] }),
69
- !c && (T || N) && !P && /* @__PURE__ */ n(t, { children: [
70
- /* @__PURE__ */ i(m, { "data-feedback-type": b, children: /* @__PURE__ */ i(a, { name: b }) }),
71
- /* @__PURE__ */ i("div", { children: /* @__PURE__ */ n(F, { children: [
72
- /* @__PURE__ */ i(G, { "data-feedback-type": b, children: h == null ? void 0 : h.title }),
73
- /* @__PURE__ */ i(l, { children: h == null ? void 0 : h.description })
74
- ] }) })
75
- ] })
24
+ const D = m && (d === r.TRIVIA || d === r.PREDICTION), y = d === r.PREDICTION && !b, O = Q && d === r.PREDICTION && !m && !w || d === r.PREDICTION && f && p && w, R = D && y, T = D && b, N = d === r.PREDICTION && m && p && b, S = m && d === r.POLL && p, P = u ? "correct" : "incorrect", o = u ? t == null ? void 0 : t.correctFeedback : t == null ? void 0 : t.incorrectFeedback;
25
+ return x || I || R || T || O || S || N || c ? /* @__PURE__ */ i(C, { enabled: p, animate: j, children: /* @__PURE__ */ n(L, { "data-prediction": y, children: [
26
+ c && /* @__PURE__ */ n(e, { children: [
27
+ /* @__PURE__ */ i(W, { name: "questionExpired" }),
28
+ /* @__PURE__ */ i(l, { children: c })
29
+ ] }),
30
+ !c && x && /* @__PURE__ */ n(e, { children: [
31
+ /* @__PURE__ */ i(a, { children: /* @__PURE__ */ i(h, { name: "questionExpired" }) }),
32
+ /* @__PURE__ */ n("div", { children: [
33
+ /* @__PURE__ */ i(F, { children: /* @__PURE__ */ i(l, { children: "Question Expired" }) }),
34
+ /* @__PURE__ */ i(k, { children: "You can still answer to see if you're correct, but no points are awarded for expired questions." })
76
35
  ] })
77
- }
78
- ) : null;
36
+ ] }),
37
+ !c && I && /* @__PURE__ */ n(e, { children: [
38
+ /* @__PURE__ */ i(a, { children: /* @__PURE__ */ i(h, { name: "questionExpired" }) }),
39
+ /* @__PURE__ */ n("div", { children: [
40
+ /* @__PURE__ */ i(F, { children: /* @__PURE__ */ i(l, { children: "Question Closed" }) }),
41
+ /* @__PURE__ */ i(k, { children: "This question was answered after the moderator closed the question. So the points for this answer won’t tally." })
42
+ ] })
43
+ ] }),
44
+ !c && O && /* @__PURE__ */ n(e, { children: [
45
+ /* @__PURE__ */ i(a, { children: /* @__PURE__ */ i(h, { name: "questionExpired" }) }),
46
+ /* @__PURE__ */ n("div", { children: [
47
+ /* @__PURE__ */ i(F, { children: /* @__PURE__ */ i(l, { children: "Question Closed" }) }),
48
+ /* @__PURE__ */ i(k, { children: "This event has already taken place, so the ability to make a prediction on its outcome is no longer available." })
49
+ ] })
50
+ ] }),
51
+ !c && R && /* @__PURE__ */ n(e, { children: [
52
+ /* @__PURE__ */ i(W, { name: "icon-prediction" }),
53
+ /* @__PURE__ */ n(l, { children: [
54
+ "Your pick has been recorded. ",
55
+ /* @__PURE__ */ i(Y, { children: "We’ll notify you of the result." })
56
+ ] })
57
+ ] }),
58
+ !c && S && /* @__PURE__ */ n(e, { children: [
59
+ /* @__PURE__ */ i(a, { "data-feedback-type": "correct", children: /* @__PURE__ */ i(h, { name: "correct" }) }),
60
+ /* @__PURE__ */ i(l, { children: "Thanks for answering. Please stay tuned for the next question." })
61
+ ] }),
62
+ !c && (T || N) && !I && /* @__PURE__ */ n(e, { children: [
63
+ /* @__PURE__ */ i(a, { "data-feedback-type": P, children: /* @__PURE__ */ i(h, { name: P }) }),
64
+ /* @__PURE__ */ i("div", { children: /* @__PURE__ */ n(F, { children: [
65
+ /* @__PURE__ */ i(E, { "data-feedback-type": P, children: o == null ? void 0 : o.title }),
66
+ /* @__PURE__ */ i(l, { children: o == null ? void 0 : o.description })
67
+ ] }) })
68
+ ] })
69
+ ] }) }) : null;
79
70
  };
80
71
  export {
81
- V as Feedback
72
+ _ as Feedback
82
73
  };
@@ -1,6 +1,6 @@
1
1
  import { styled as s } from "@linaria/react";
2
2
  import { SvgIcon as e } from "../../../icons/index.js";
3
- import { ShowIn as a } from "../../../show-in/index.js";
3
+ import { GrowingShowIn as a } from "../../../show-in/index.js";
4
4
  import "react/jsx-runtime";
5
5
  import "react";
6
6
  import "@linaria/core";
@@ -1,11 +1,11 @@
1
- import { jsx as n, jsxs as B, Fragment as tt } from "react/jsx-runtime";
2
- import { useState as m, useEffect as g, useCallback as O, useRef as rt, useMemo as l } from "react";
3
- import { QuestionType as a, QuestionStatus as x } from "@streamlayer/sdk-web-types";
4
- import { ExpiredAlert as et } from "./expired-alert/index.js";
5
- import { Feedback as it } from "./feedback/index.js";
6
- import { QuestionScrollContainer as ot, Container as st, Content as at, Title as nt, Options as ct } from "./styles.js";
7
- import { VotingOption as mt } from "./vote-option/index.js";
8
- import { WinBar as lt } from "./win-bar/index.js";
1
+ import { jsx as a, jsxs as L, Fragment as rt } from "react/jsx-runtime";
2
+ import { useState as l, useEffect as x, useCallback as D, useRef as et, useMemo as f } from "react";
3
+ import { QuestionType as n, QuestionStatus as q } from "@streamlayer/sdk-web-types";
4
+ import { ExpiredAlert as it } from "./expired-alert/index.js";
5
+ import { Feedback as ot } from "./feedback/index.js";
6
+ import { QuestionScrollContainer as st, Container as nt, Content as at, Title as ct, Options as mt } from "./styles.js";
7
+ import { VotingOption as lt } from "./vote-option/index.js";
8
+ import { WinBar as ft } from "./win-bar/index.js";
9
9
  import "../../icons/index.js";
10
10
  import "@linaria/react";
11
11
  import "./expired-alert/styles.js";
@@ -20,132 +20,137 @@ import "../../timer/index.js";
20
20
  import "react-countdown-circle-timer";
21
21
  import "../../theme/constants.js";
22
22
  import "./win-bar/styles.js";
23
- const Nt = ({ openedQuestion: t, isLoading: E, vote: P, close: p }) => {
24
- var M, b;
25
- const L = t.subject, o = t.type, u = t.status, I = (M = t.options) == null ? void 0 : M.options, h = t.marketClosed, y = t.id, [V, W] = m(!1), [C, Y] = m(!1), [T, q] = m(!0), [c, F] = m(!1), [A, v] = m(""), [w, H] = m(""), [_, D] = m(!1);
26
- g(() => {
27
- w && D(!0);
28
- }, [w]), g(() => {
29
- o === a.PREDICTION ? h && q(!1) : u === x.RESOLVED && q(!1);
23
+ const kt = ({ openedQuestion: t, isLoading: h, vote: A, close: p }) => {
24
+ var B, W;
25
+ const Y = t.subject, o = t.type, d = t.status, E = (B = t.options) == null ? void 0 : B.options, y = t.marketClosed, C = t.id, [T, F] = l(!1), [V, H] = l(!1), [I, N] = l(!0), [c, _] = l(!1), [S, v] = l(""), [w, z] = l(""), [R, k] = l(!1);
26
+ x(() => {
27
+ o === n.PREDICTION ? y && N(!1) : d === q.RESOLVED && N(!1);
30
28
  }, []);
31
- const z = O((i) => {
32
- Y(i), W(!0);
33
- }, []), R = rt(!1), S = O(
34
- async (i) => {
35
- if (!R.current && (R.current = !0, y)) {
36
- const d = i.currentTarget.value;
37
- v(d);
29
+ const G = D((e) => {
30
+ H(e), F(!0);
31
+ }, []), g = et(!1), M = D(
32
+ async (e) => {
33
+ if (!g.current && (g.current = !0, C)) {
34
+ const m = e.currentTarget.value;
35
+ v(m);
38
36
  try {
39
- await P(y, d);
37
+ await A(C, m);
40
38
  } catch (j) {
41
- const Q = j.message === "already_voted" ? "You’ve already answered this question on other device. So the points for this answer won't tally." : "Something went wrong, please try again";
42
- H(Q), v(""), console.error("Error while voting", j), R.current = !1;
39
+ const tt = j.message === "already_voted" ? "You’ve already answered this question on other device. So the points for this answer won't tally." : "Something went wrong, please try again";
40
+ z(tt), v(""), console.error("Error while voting", j), g.current = !1;
43
41
  }
44
42
  }
45
43
  },
46
- [y, v, P]
47
- ), G = O(() => {
48
- F(!0), setTimeout(p, 3e3);
49
- }, [p]), r = l(
50
- () => t == null ? void 0 : t.answers.find((i) => i.youVoted === !0),
44
+ [C, v, A]
45
+ ), J = D(() => {
46
+ _(!0), setTimeout(p, 3e3);
47
+ }, [p]), r = f(
48
+ () => t == null ? void 0 : t.answers.find((e) => e.youVoted === !0),
51
49
  [t]
52
- ), s = l(
53
- () => !!(t != null && t.answers.find((i) => i.correct === !0)),
50
+ ), s = f(
51
+ () => !!(t != null && t.answers.find((e) => e.correct === !0)),
54
52
  [t]
55
- ), e = l(
56
- () => t == null ? void 0 : t.answers.find((i) => i.correct === !0),
53
+ ), i = f(
54
+ () => t == null ? void 0 : t.answers.find((e) => e.correct === !0),
57
55
  [t]
58
56
  );
59
- g(() => {
60
- let i;
61
- return o === a.PREDICTION && r && V && (i = setTimeout(p, 1e4)), () => {
62
- clearTimeout(i);
57
+ x(() => {
58
+ let e;
59
+ return o === n.PREDICTION && r && T && (e = setTimeout(p, 1e4)), () => {
60
+ clearTimeout(e);
63
61
  };
64
62
  }, [r]);
65
- const J = l(() => t ? t.answers.map((i) => {
66
- var d;
63
+ const O = f(() => t ? t.answers.map((e) => {
64
+ var m;
67
65
  return {
68
- ...i,
66
+ ...e,
69
67
  questionVoted: !!r,
70
- youSelected: A === i.id,
71
- isLoading: E,
68
+ youSelected: S === e.id,
69
+ isLoading: h,
72
70
  hasCorrectAnswer: s,
73
71
  questionType: t.type,
74
72
  answerTimeExpired: c,
75
- questionStatus: u,
76
- imageMode: (d = t.appearance) == null ? void 0 : d.images,
77
- onVote: S
73
+ questionStatus: d,
74
+ imageMode: (m = t.appearance) == null ? void 0 : m.images,
75
+ onVote: M
78
76
  };
79
77
  }) : [], [
80
78
  s,
81
79
  c,
82
- E,
80
+ h,
83
81
  t,
84
82
  r,
85
- u,
86
- S,
87
- A
88
- ]), K = I && (I.case === "trivia" || I.case === "prediction") ? I.value : void 0, f = u === x.RESOLVED && o === a.TRIVIA && !r && !T, N = o === a.TRIVIA && C && V && T, k = l(() => o === a.PREDICTION ? !!(r && !s || r && s && (e != null && e.youVoted)) : !0, [o, r, s, e]), U = l(() => {
89
- if (o === a.PREDICTION && r && (!s || s && (e != null && e.youVoted)))
83
+ d,
84
+ M,
85
+ S
86
+ ]);
87
+ x(() => {
88
+ const e = O.some(({ percentageDecimal: m }) => m !== 0);
89
+ w && !e && k(!0);
90
+ }, [O, w]);
91
+ const K = E && (E.case === "trivia" || E.case === "prediction") ? E.value : void 0, u = d === q.RESOLVED && o === n.TRIVIA && !r && !I, b = o === n.TRIVIA && V && T && I, P = f(() => o === n.PREDICTION ? !!(r && !s || r && s && (i != null && i.youVoted)) : !0, [o, r, s, i]), U = f(() => {
92
+ if (o === n.PREDICTION && r && (!s || s && (i != null && i.youVoted)))
90
93
  return r.points;
91
- if (!(f || c))
92
- return r ? r.correct ? r.pointsEarned : 0 : e == null ? void 0 : e.points;
93
- }, [c, r, e, f, o, s]), X = l(() => o === a.PREDICTION && r ? s ? s && (e != null && e.youVoted) ? "You won" : "" : "To win" : f || c ? "Time expired" : o === a.POLL ? "Time remaining" : r ? "You won" : "To win", [c, o, r, f, s, e]), Z = (o === a.TRIVIA || o === a.PREDICTION) && r && s && (e == null ? void 0 : e.youVoted), $ = r || f || N || o === a.TRIVIA && u === x.RESOLVED && T;
94
- return /* @__PURE__ */ n(ot, { children: /* @__PURE__ */ n(st, { children: /* @__PURE__ */ B(at, { children: [
95
- /* @__PURE__ */ n(
96
- it,
94
+ if (!(u || c))
95
+ return r ? r.correct ? r.pointsEarned : 0 : i == null ? void 0 : i.points;
96
+ }, [c, r, i, u, o, s]), X = f(() => o === n.PREDICTION && r ? s ? s && (i != null && i.youVoted) ? "You won" : "" : "To win" : u || c ? "Time expired" : o === n.POLL ? "Time remaining" : r ? "You won" : "To win", [c, o, r, u, s, i]), Z = !P || P && o === n.PREDICTION && T && !R, $ = (o === n.TRIVIA || o === n.PREDICTION) && r && s && (i == null ? void 0 : i.youVoted), Q = r || u || b || o === n.TRIVIA && d === q.RESOLVED && I;
97
+ return /* @__PURE__ */ a(st, { children: /* @__PURE__ */ a(nt, { children: /* @__PURE__ */ L(at, { children: [
98
+ /* @__PURE__ */ a(
99
+ ot,
97
100
  {
98
101
  feedbackMessages: K,
99
102
  questionVoted: !!r,
100
103
  questionVotedCorrectly: r == null ? void 0 : r.correct,
101
104
  questionType: o,
102
105
  hasCorrectAnswer: s,
103
- showExpiredNotification: f,
104
- showClosedNotificationTrivia: N,
105
- votedInCurrentRender: V,
106
- votedAfterQuestionClosed: C,
107
- enteredAnActiveQuestion: T,
108
- marketClosed: h,
109
- percentsAnimated: _,
106
+ showExpiredNotification: u,
107
+ showClosedNotificationTrivia: b,
108
+ votedInCurrentRender: T,
109
+ votedAfterQuestionClosed: V,
110
+ enteredAnActiveQuestion: I,
111
+ marketClosed: y,
112
+ percentsAnimated: R,
110
113
  voteErrorMessage: w
111
114
  }
112
115
  ),
113
- k && /* @__PURE__ */ n(
114
- lt,
116
+ P && /* @__PURE__ */ a(
117
+ ft,
115
118
  {
116
119
  title: X,
117
120
  points: U,
118
- onTimerExpired: G,
121
+ onTimerExpired: J,
119
122
  questionType: t.type,
120
- isTimer: !E,
123
+ isTimer: !h,
121
124
  isPlayingTimer: !r,
122
- animatePoints: Z,
123
- timerDuration: $ ? 0 : Number(((b = t == null ? void 0 : t.appearance) == null ? void 0 : b.autoHideInterval) || "30")
125
+ animatePoints: $,
126
+ timerDuration: Q ? 0 : Number(((W = t == null ? void 0 : t.appearance) == null ? void 0 : W.autoHideInterval) || "30"),
127
+ votedInCurrentRender: T,
128
+ percentsAnimated: R
124
129
  }
125
130
  ),
126
- c ? /* @__PURE__ */ n(
127
- et,
131
+ c ? /* @__PURE__ */ a(
132
+ it,
128
133
  {
129
134
  title: "More to come...",
130
135
  description: "Watch for additional enhanced stream interactive experience."
131
136
  }
132
- ) : /* @__PURE__ */ B(tt, { children: [
133
- /* @__PURE__ */ n(nt, { style: k ? {} : { marginTop: 0 }, children: L }),
134
- /* @__PURE__ */ n(ct, { children: J.map((i) => /* @__PURE__ */ n(
135
- mt,
137
+ ) : /* @__PURE__ */ L(rt, { children: [
138
+ /* @__PURE__ */ a(ct, { style: Z ? { marginTop: 0 } : {}, children: Y }),
139
+ /* @__PURE__ */ a(mt, { children: O.map((e) => /* @__PURE__ */ a(
140
+ lt,
136
141
  {
137
- ...i,
138
- markThatVoted: z,
139
- onPercentsAnimated: () => D(!0),
140
- votedAfterQuestionClosed: C,
141
- enteredAnActiveQuestion: T,
142
- marketClosed: h
142
+ ...e,
143
+ markThatVoted: G,
144
+ onPercentsAnimated: () => k(!0),
145
+ votedAfterQuestionClosed: V,
146
+ enteredAnActiveQuestion: I,
147
+ marketClosed: y
143
148
  },
144
- i.id
149
+ e.id
145
150
  )) })
146
151
  ] })
147
152
  ] }) }) });
148
153
  };
149
154
  export {
150
- Nt as Vote
155
+ kt as Vote
151
156
  };
@@ -1,4 +1,4 @@
1
- import { jsx as n, jsxs as u } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as u } from "react/jsx-runtime";
2
2
  import { useState as j, useLayoutEffect as U } from "react";
3
3
  import { QuestionImages as a, QuestionType as o, QuestionStatus as A } from "@streamlayer/sdk-web-types";
4
4
  import { AnimatedCounter as $ } from "../../../animated-counter/index.js";
@@ -7,35 +7,35 @@ import "react-countup";
7
7
  import "@linaria/react";
8
8
  import "../../../icons/index.js";
9
9
  const I = {
10
- [a.CENTERED]: (t) => /* @__PURE__ */ n(y, { alt: "option-icon", src: t }),
11
- [a.TRANSPARENT]: (t) => /* @__PURE__ */ n(F, { children: /* @__PURE__ */ n(M, { style: { backgroundImage: `url(${t})` } }) }),
12
- [a.ROUNDED]: (t) => /* @__PURE__ */ n(W, { alt: "option-icon", src: t }),
10
+ [a.CENTERED]: (t) => /* @__PURE__ */ e(y, { alt: "option-icon", src: t }),
11
+ [a.TRANSPARENT]: (t) => /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e(M, { style: { backgroundImage: `url(${t})` } }) }),
12
+ [a.ROUNDED]: (t) => /* @__PURE__ */ e(W, { alt: "option-icon", src: t }),
13
13
  [a.NONE]: () => null,
14
14
  [a.UNSET]: () => null
15
- }, _ = ({ questionType: t, hasCorrectAnswer: c, correct: r, youVoted: i, questionVoted: e }) => {
16
- if (t === o.POLL && i)
15
+ }, _ = ({ questionType: t, hasCorrectAnswer: c, correct: n, youVoted: r, questionVoted: i }) => {
16
+ if (t === o.POLL && r)
17
17
  return "correct";
18
18
  if (t === o.PREDICTION) {
19
- if (c && e)
20
- return i ? r ? "correct" : "incorrect" : "unset";
21
- if (i)
19
+ if (c && i)
20
+ return r ? n ? "correct" : "incorrect" : "unset";
21
+ if (r)
22
22
  return "correct";
23
23
  }
24
- return t === o.TRIVIA && e && i ? r ? "correct" : "incorrect" : "unset";
24
+ return t === o.TRIVIA && i && r ? n ? "correct" : "incorrect" : "unset";
25
25
  }, q = ({
26
26
  questionType: t,
27
27
  questionVoted: c,
28
- correct: r,
29
- hasCorrectAnswer: i,
30
- questionStatus: e
31
- }) => t === o.TRIVIA ? c && r : t === o.PREDICTION ? c && r && i || e === A.RESOLVED && r : !1, at = (t) => {
28
+ correct: n,
29
+ hasCorrectAnswer: r,
30
+ questionStatus: i
31
+ }) => t === o.TRIVIA ? c && n : t === o.PREDICTION ? c && n && r || i === A.RESOLVED && n : !1, at = (t) => {
32
32
  var T;
33
33
  const {
34
34
  // option props
35
35
  id: c,
36
- icon: r,
37
- text: i,
38
- percentageDecimal: e,
36
+ icon: n,
37
+ text: r,
38
+ percentageDecimal: i,
39
39
  points: N,
40
40
  // extra props
41
41
  onVote: S,
@@ -53,12 +53,12 @@ const I = {
53
53
  votedAfterQuestionClosed: x,
54
54
  enteredAnActiveQuestion: P,
55
55
  marketClosed: l
56
- } = t, [L, p] = j(e), m = _(t), Q = q({ questionType: d, questionVoted: s, correct: k, hasCorrectAnswer: v, questionStatus: C }), f = l && d === o.PREDICTION, R = s || f, B = d === o.PREDICTION && !s && !l, V = s && !E && m !== "incorrect";
56
+ } = t, [L, p] = j(0), m = _(t), Q = q({ questionType: d, questionVoted: s, correct: k, hasCorrectAnswer: v, questionStatus: C }), f = l && d === o.PREDICTION, R = s || f, B = d === o.PREDICTION && !s && !l, V = s && !E && m !== "incorrect";
57
57
  return U(() => {
58
- e > 0 && (p(0), requestAnimationFrame(() => {
59
- p(e);
60
- }));
61
- }, [e]), /* @__PURE__ */ u(
58
+ p(0), requestAnimationFrame(() => {
59
+ p(i);
60
+ });
61
+ }, [i]), /* @__PURE__ */ u(
62
62
  z,
63
63
  {
64
64
  value: c,
@@ -72,7 +72,7 @@ const I = {
72
72
  ), S(b);
73
73
  },
74
74
  children: [
75
- /* @__PURE__ */ n(
75
+ /* @__PURE__ */ e(
76
76
  G,
77
77
  {
78
78
  "data-answer-state": m,
@@ -81,15 +81,15 @@ const I = {
81
81
  }
82
82
  ),
83
83
  /* @__PURE__ */ u(H, { children: [
84
- r && h && ((T = I[h]) == null ? void 0 : T.call(I, r)),
85
- /* @__PURE__ */ n(J, { children: i }),
84
+ n && h && ((T = I[h]) == null ? void 0 : T.call(I, n)),
85
+ /* @__PURE__ */ e(J, { children: r }),
86
86
  B && /* @__PURE__ */ u("div", { children: [
87
87
  N,
88
- /* @__PURE__ */ n(K, { children: "pts" })
88
+ /* @__PURE__ */ e(K, { children: "pts" })
89
89
  ] }),
90
90
  R && /* @__PURE__ */ u(X, { children: [
91
- Q && /* @__PURE__ */ n(Y, { name: "selected" }),
92
- /* @__PURE__ */ n(Z, { children: /* @__PURE__ */ n($, { value: e, suffix: "%" }) })
91
+ Q && /* @__PURE__ */ e(Y, { name: "selected" }),
92
+ /* @__PURE__ */ e(Z, { children: /* @__PURE__ */ e($, { value: i, suffix: "%" }) })
93
93
  ] })
94
94
  ] })
95
95
  ]
@@ -8,6 +8,8 @@ interface WinBarProps {
8
8
  animatePoints?: boolean;
9
9
  questionType?: QuestionType;
10
10
  timerDuration?: number;
11
+ votedInCurrentRender: boolean;
12
+ percentsAnimated: boolean;
11
13
  onTimerExpired?: () => void;
12
14
  }
13
15
  export declare const WinBar: React.FC<WinBarProps>;
@@ -1,36 +1,55 @@
1
- import { jsxs as i, jsx as r, Fragment as p } from "react/jsx-runtime";
2
- import { QuestionType as o } from "@streamlayer/sdk-web-types";
3
- import { AnimatedCounter as s } from "../../../animated-counter/index.js";
4
- import { Timer as h } from "../../../timer/index.js";
5
- import { WinBarContainer as P, Content as C, Title as f, WinIcon as u, Points as I, PointsCount as y, PointsUnits as T } from "./styles.js";
1
+ import { jsx as r, jsxs as n, Fragment as C } from "react/jsx-runtime";
2
+ import { QuestionType as t } from "@streamlayer/sdk-web-types";
3
+ import { AnimatedCounter as P } from "../../../animated-counter/index.js";
4
+ import { Timer as s } from "../../../timer/index.js";
5
+ import { ShowInContainer as I, WinBarContainer as f, Content as u, Title as O, WinIcon as T, Points as j, PointsCount as x, PointsUnits as y } from "./styles.js";
6
6
  import "react-countup";
7
7
  import "@linaria/react";
8
8
  import "react";
9
9
  import "react-countdown-circle-timer";
10
10
  import "../../../theme/constants.js";
11
11
  import "../../../icons/index.js";
12
- const R = ({
12
+ import "../../../show-in/index.js";
13
+ import "@linaria/core";
14
+ const F = ({
13
15
  title: e,
14
- points: n,
16
+ points: o,
15
17
  isPlayingTimer: m,
16
- isTimer: c,
17
- animatePoints: a,
18
- questionType: t,
18
+ isTimer: a,
19
+ animatePoints: c,
20
+ questionType: i,
19
21
  timerDuration: d,
20
- onTimerExpired: l
21
- }) => /* @__PURE__ */ i(P, { style: { justifyContent: t === o.PREDICTION ? "center" : "space-between" }, children: [
22
- /* @__PURE__ */ i(C, { children: [
23
- e && /* @__PURE__ */ r(f, { children: e }),
24
- n !== void 0 && t !== o.POLL && /* @__PURE__ */ i(p, { children: [
25
- /* @__PURE__ */ r(u, { name: "icon-trophy" }),
26
- /* @__PURE__ */ i(I, { children: [
27
- /* @__PURE__ */ r(y, { children: a ? /* @__PURE__ */ r(s, { value: n, delay: 0.3 }) : n }),
28
- /* @__PURE__ */ r(T, { children: "PTS" })
29
- ] })
30
- ] })
31
- ] }),
32
- c && t !== o.PREDICTION && /* @__PURE__ */ r(h, { isPlaying: m, onTimerExpired: l, duration: d })
33
- ] });
22
+ votedInCurrentRender: l,
23
+ percentsAnimated: p,
24
+ onTimerExpired: h
25
+ }) => /* @__PURE__ */ r(
26
+ I,
27
+ {
28
+ enabled: i === t.PREDICTION && l,
29
+ animate: p,
30
+ children: /* @__PURE__ */ n(
31
+ f,
32
+ {
33
+ style: {
34
+ justifyContent: i === t.PREDICTION ? "center" : "space-between"
35
+ },
36
+ children: [
37
+ /* @__PURE__ */ n(u, { children: [
38
+ e && /* @__PURE__ */ r(O, { children: e }),
39
+ o !== void 0 && i !== t.POLL && /* @__PURE__ */ n(C, { children: [
40
+ /* @__PURE__ */ r(T, { name: "icon-trophy" }),
41
+ /* @__PURE__ */ n(j, { children: [
42
+ /* @__PURE__ */ r(x, { children: c ? /* @__PURE__ */ r(P, { value: o, delay: 0.3 }) : o }),
43
+ /* @__PURE__ */ r(y, { children: "PTS" })
44
+ ] })
45
+ ] })
46
+ ] }),
47
+ a && i !== t.PREDICTION && /* @__PURE__ */ r(s, { isPlaying: m, onTimerExpired: h, duration: d })
48
+ ]
49
+ }
50
+ )
51
+ }
52
+ );
34
53
  export {
35
- R as WinBar
54
+ F as WinBar
36
55
  };
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ export declare const ShowInContainer: any;
2
3
  export declare const WinBarContainer: import("@linaria/react").StyledComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown>>;
3
4
  export declare const Content: import("@linaria/react").StyledComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown>>;
4
5
  export declare const Title: import("@linaria/react").StyledComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown>>;