@streamlayer/react-ui 0.75.1 → 0.76.1

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.
Files changed (39) hide show
  1. package/lib/assets/style.css +1 -1
  2. package/lib/ui/app/Features/Gamification/Question.js +41 -32
  3. package/lib/ui/app/Features/Gamification/QuestionsList.js +10 -2
  4. package/lib/ui/app/Features/Gamification/Tabs.js +15 -7
  5. package/lib/ui/app/Features/Gamification/gamification-feature.js +10 -0
  6. package/lib/ui/app/Features/Gamification/index.js +12 -2
  7. package/lib/ui/app/Notifications/index.js +4 -2
  8. package/lib/ui/app/masters.js +4 -2
  9. package/lib/ui/gamification/question/list/index.js +22 -10
  10. package/lib/ui/gamification/question/notification/index.js +13 -11
  11. package/lib/ui/gamification/question/notification/tweet/index.d.ts +1 -1
  12. package/lib/ui/gamification/question/notification/tweet/index.js +10 -18
  13. package/lib/ui/gamification/question/notification/tweet/styles.d.ts +0 -3
  14. package/lib/ui/gamification/question/notification/tweet/styles.js +10 -25
  15. package/lib/ui/gamification/question/twitter/index.d.ts +4 -2
  16. package/lib/ui/gamification/question/twitter/index.js +33 -9
  17. package/lib/ui/gamification/question/twitter/styles.d.ts +2 -0
  18. package/lib/ui/gamification/question/twitter/styles.js +16 -6
  19. package/lib/ui/gamification/vote/feedback/index.d.ts +4 -1
  20. package/lib/ui/gamification/vote/feedback/index.js +50 -29
  21. package/lib/ui/gamification/vote/index.js +86 -69
  22. package/lib/ui/gamification/vote/insight-details/styles.js +2 -2
  23. package/lib/ui/gamification/vote/twitter-details/index.d.ts +1 -1
  24. package/lib/ui/gamification/vote/twitter-details/index.js +28 -6
  25. package/lib/ui/gamification/vote/twitter-details/styles.d.ts +2 -0
  26. package/lib/ui/gamification/vote/twitter-details/styles.js +12 -2
  27. package/lib/ui/gamification/vote/vote-option/index.d.ts +3 -0
  28. package/lib/ui/gamification/vote/vote-option/index.js +50 -45
  29. package/lib/ui/icons/index.d.ts +1 -0
  30. package/lib/ui/icons/index.js +14 -13
  31. package/lib/ui/questions/insight/styles.js +8 -8
  32. package/lib/ui/questions/twitter/account/index.js +15 -9
  33. package/lib/ui/questions/twitter/account/styles.d.ts +1 -0
  34. package/lib/ui/questions/twitter/account/styles.js +21 -13
  35. package/lib/ui/questions/twitter/index.d.ts +3 -6
  36. package/lib/ui/questions/twitter/index.js +8 -13
  37. package/lib/ui/questions/twitter/styles.d.ts +0 -3
  38. package/lib/ui/questions/twitter/styles.js +8 -23
  39. package/package.json +8 -8
@@ -1,12 +1,12 @@
1
- import { jsx as a, jsxs as C, Fragment as u } from "react/jsx-runtime";
2
- import { useState as S, useCallback as V, useMemo as m } from "react";
3
- import { QuestionStatus as M, QuestionType as y } from "@streamlayer/sdk-web-types";
4
- import { SDKScrollContainer as j } from "../../app/styles.js";
5
- import { ExpiredAlert as k } from "./expired-alert/index.js";
6
- import { Feedback as N } from "./feedback/index.js";
7
- import { Container as R, Content as B, Title as F, Options as W } from "./styles.js";
8
- import { VotingOption as H } from "./vote-option/index.js";
9
- import { WinBar as K } from "./win-bar/index.js";
1
+ import { jsx as a, jsxs as I, Fragment as F } from "react/jsx-runtime";
2
+ import { useState as m, useEffect as L, useCallback as y, useMemo as c } from "react";
3
+ import { QuestionStatus as S, QuestionType as w } from "@streamlayer/sdk-web-types";
4
+ import { SDKScrollContainer as W } from "../../app/styles.js";
5
+ import { ExpiredAlert as H } from "./expired-alert/index.js";
6
+ import { Feedback as K } from "./feedback/index.js";
7
+ import { Container as Y, Content as z, Title as G, Options as J } from "./styles.js";
8
+ import { VotingOption as U } from "./vote-option/index.js";
9
+ import { WinBar as X } from "./win-bar/index.js";
10
10
  import "@linaria/react";
11
11
  import "../../icons/index.js";
12
12
  import "./expired-alert/styles.js";
@@ -18,84 +18,101 @@ 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 er = ({ openedQuestion: r, isLoading: f, vote: w, close: h }) => {
22
- var n, v;
23
- const I = r.subject, O = r.type, l = (n = r.options) == null ? void 0 : n.options, [c, g] = S(!1), [q, x] = S(""), T = r == null ? void 0 : r.id, p = V(
24
- async (i) => {
25
- if (T) {
26
- const s = i.currentTarget.value;
27
- x(s), await w(T, s);
21
+ const Et = ({ openedQuestion: t, isLoading: o, vote: u, close: E }) => {
22
+ var q, x;
23
+ const p = t.subject, O = t.type, l = (q = t.options) == null ? void 0 : q.options, [d, g] = m(!1), [h, D] = m(!1), [v, R] = m(!0), [s, b] = m(!1), [C, V] = m(""), n = t == null ? void 0 : t.id;
24
+ L(() => {
25
+ t.status === S.RESOLVED && R(!1);
26
+ }, []);
27
+ const P = y((r) => {
28
+ D(r), g(!0);
29
+ }, []), A = y(
30
+ async (r) => {
31
+ if (n) {
32
+ const e = r.currentTarget.value;
33
+ V(e), await u(n, e);
28
34
  }
29
35
  },
30
- [T, x, w]
31
- ), b = V(() => {
32
- g(!0), setTimeout(h, 3e3);
33
- }, [h]), t = m(
34
- () => r == null ? void 0 : r.answers.find((i) => i.youVoted === !0),
35
- [r]
36
- ), o = m(
37
- () => !!(r != null && r.answers.find((i) => i.correct === !0)),
38
- [r]
39
- ), e = m(
40
- () => r == null ? void 0 : r.answers.find((i) => i.correct === !0),
41
- [r]
42
- ), A = m(() => r ? r.answers.map((i) => {
43
- var s;
36
+ [n, V, u]
37
+ ), k = y(() => {
38
+ b(!0), setTimeout(E, 3e3);
39
+ }, [E]), i = c(
40
+ () => t == null ? void 0 : t.answers.find((r) => r.youVoted === !0),
41
+ [t]
42
+ ), T = c(
43
+ () => !!(t != null && t.answers.find((r) => r.correct === !0)),
44
+ [t]
45
+ ), f = c(
46
+ () => t == null ? void 0 : t.answers.find((r) => r.correct === !0),
47
+ [t]
48
+ ), M = c(() => t ? t.answers.map((r) => {
49
+ var e;
44
50
  return {
45
- ...i,
46
- questionVoted: !!t,
47
- youSelected: q === i.id,
48
- isLoading: f,
49
- hasCorrectAnswer: o,
50
- questionType: r.type,
51
- answerTimeExpired: c,
52
- questionStatus: r.status,
53
- imageMode: (s = r.appearance) == null ? void 0 : s.images,
54
- // ToDo: Figure out why imageMode is not in the response
55
- onVote: p
51
+ ...r,
52
+ questionVoted: !!i,
53
+ youSelected: C === r.id,
54
+ isLoading: o,
55
+ hasCorrectAnswer: T,
56
+ questionType: t.type,
57
+ answerTimeExpired: s,
58
+ questionStatus: t.status,
59
+ imageMode: (e = t.appearance) == null ? void 0 : e.images,
60
+ onVote: A
56
61
  };
57
- }) : [], [o, c, f, r, t, p, q]), E = l && (l.case === "trivia" || l.case === "prediction") ? l.value : void 0, D = m(() => {
58
- if (r.status === M.RESOLVED)
62
+ }) : [], [T, s, o, t, i, A, C]), j = l && (l.case === "trivia" || l.case === "prediction") ? l.value : void 0, N = c(() => {
63
+ if (t.status === S.RESOLVED)
59
64
  return 0;
60
- if (!c)
61
- return t ? t.correct ? t.points : 0 : e == null ? void 0 : e.points;
62
- }, [c, t, e, r.status]), P = m(() => c ? "Time expired" : r.type === y.POLL ? "Time remaining" : t ? "You won" : "To win", [c, r.type, t]);
63
- return /* @__PURE__ */ a(j, { "data-question-header": "true", children: /* @__PURE__ */ a(R, { children: /* @__PURE__ */ C(B, { children: [
64
- E && /* @__PURE__ */ a(
65
- N,
65
+ if (!s)
66
+ return i ? i.correct ? i.points : 0 : f == null ? void 0 : f.points;
67
+ }, [s, i, f, t.status]), B = c(() => s ? "Time expired" : t.type === w.POLL ? "Time remaining" : i ? "You won" : "To win", [s, t.type, i]);
68
+ return /* @__PURE__ */ a(W, { "data-question-header": "true", children: /* @__PURE__ */ a(Y, { children: /* @__PURE__ */ I(z, { children: [
69
+ /* @__PURE__ */ a(
70
+ K,
66
71
  {
67
- feedbackMessages: E,
68
- questionVoted: !!t,
69
- questionVotedCorrectly: t == null ? void 0 : t.correct,
72
+ feedbackMessages: j,
73
+ questionVoted: !!i,
74
+ questionVotedCorrectly: i == null ? void 0 : i.correct,
70
75
  questionType: O,
71
- hasCorrectAnswer: o,
72
- questionStatus: r.status
76
+ hasCorrectAnswer: T,
77
+ questionStatus: t.status,
78
+ votedInCurrentRender: d,
79
+ votedAfterQuestionClosed: h,
80
+ enteredAnActiveQuestion: v
73
81
  }
74
82
  ),
75
- r.type !== y.PREDICTION && /* @__PURE__ */ a(
76
- K,
83
+ t.type !== w.PREDICTION && /* @__PURE__ */ a(
84
+ X,
77
85
  {
78
- title: P,
79
- points: D,
80
- onTimerExpired: b,
81
- questionType: r.type,
82
- isTimer: !f,
83
- isPlayingTimer: !t,
84
- timerDuration: t ? 0 : Number(((v = r == null ? void 0 : r.appearance) == null ? void 0 : v.autoHideInterval) || "30")
86
+ title: B,
87
+ points: N,
88
+ onTimerExpired: k,
89
+ questionType: t.type,
90
+ isTimer: !o,
91
+ isPlayingTimer: !i,
92
+ timerDuration: i ? 0 : Number(((x = t == null ? void 0 : t.appearance) == null ? void 0 : x.autoHideInterval) || "30")
85
93
  }
86
94
  ),
87
- c ? /* @__PURE__ */ a(
88
- k,
95
+ s ? /* @__PURE__ */ a(
96
+ H,
89
97
  {
90
98
  title: "More to come...",
91
99
  description: "Watch for additional enhanced stream interactive experience."
92
100
  }
93
- ) : /* @__PURE__ */ C(u, { children: [
94
- /* @__PURE__ */ a(F, { "data-isPrediction": r.type === y.PREDICTION, children: I }),
95
- /* @__PURE__ */ a(W, { children: A.map((i) => /* @__PURE__ */ a(H, { ...i }, i.id)) })
101
+ ) : /* @__PURE__ */ I(F, { children: [
102
+ /* @__PURE__ */ a(G, { "data-isPrediction": t.type === w.PREDICTION, children: p }),
103
+ /* @__PURE__ */ a(J, { children: M.map((r) => /* @__PURE__ */ a(
104
+ U,
105
+ {
106
+ ...r,
107
+ markThatVoted: P,
108
+ votedAfterQuestionClosed: h,
109
+ enteredAnActiveQuestion: v
110
+ },
111
+ r.id
112
+ )) })
96
113
  ] })
97
114
  ] }) }) });
98
115
  };
99
116
  export {
100
- er as Vote
117
+ Et as Vote
101
118
  };
@@ -3,12 +3,12 @@ const n = /* @__PURE__ */ s("div")({
3
3
  name: "Container",
4
4
  class: "c1euiow",
5
5
  propsAsIs: !1
6
- }), o = /* @__PURE__ */ s("a")({
6
+ }), a = /* @__PURE__ */ s("a")({
7
7
  name: "WebLinkBtn",
8
8
  class: "w19zie3h",
9
9
  propsAsIs: !1
10
10
  });
11
11
  export {
12
12
  n as Container,
13
- o as WebLinkBtn
13
+ a as WebLinkBtn
14
14
  };
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- import { TwitterContentProps } from '../../../questions/twitter';
2
+ import { type TwitterContentProps } from '../../../questions/twitter';
3
3
  export declare const TwitterDetails: React.FC<TwitterContentProps>;
@@ -1,13 +1,35 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import { TwitterContent as o } from "../../../questions/twitter/index.js";
3
- import { Container as i } from "./styles.js";
1
+ import { jsxs as m, jsx as o } from "react/jsx-runtime";
2
+ import { useMemo as n } from "react";
3
+ import { TwitterContent as a } from "../../../questions/twitter/index.js";
4
+ import { isValidDate as f, formatDate as l, formatTime as p } from "../../../../utils/common.js";
5
+ import { Container as s, DateTime as d, Quote as u } from "./styles.js";
4
6
  import "../../../questions/twitter/account/index.js";
5
7
  import "../../../icons/index.js";
6
8
  import "@linaria/react";
7
- import "react";
8
9
  import "../../../questions/twitter/account/styles.js";
9
10
  import "../../../questions/twitter/styles.js";
10
- const w = (r) => /* @__PURE__ */ t(i, { children: /* @__PURE__ */ t(o, { ...r }) });
11
+ const V = ({ created: t, ...i }) => {
12
+ const e = n(() => {
13
+ if (t) {
14
+ const r = new Date(t);
15
+ if (f(r))
16
+ return {
17
+ date: l(r),
18
+ time: p(r)
19
+ };
20
+ }
21
+ return null;
22
+ }, [t]);
23
+ return /* @__PURE__ */ m(s, { children: [
24
+ e && /* @__PURE__ */ m(d, { children: [
25
+ e.date,
26
+ " · ",
27
+ e.time
28
+ ] }),
29
+ i.title && /* @__PURE__ */ o(u, { children: i.title }),
30
+ /* @__PURE__ */ o(a, { ...i })
31
+ ] });
32
+ };
11
33
  export {
12
- w as TwitterDetails
34
+ V as TwitterDetails
13
35
  };
@@ -1,2 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  export declare const Container: import("@linaria/react").StyledComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown>>;
3
+ export declare const DateTime: import("@linaria/react").StyledComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown>>;
4
+ export declare const Quote: import("@linaria/react").StyledComponent<import("react").ClassAttributes<HTMLQuoteElement> & import("react").BlockquoteHTMLAttributes<HTMLQuoteElement> & Record<never, unknown>>;
@@ -1,9 +1,19 @@
1
1
  import { styled as s } from "@linaria/react";
2
- const t = /* @__PURE__ */ s("div")({
2
+ const o = /* @__PURE__ */ s("div")({
3
3
  name: "Container",
4
4
  class: "c1dcxmvf",
5
5
  propsAsIs: !1
6
+ }), t = /* @__PURE__ */ s("div")({
7
+ name: "DateTime",
8
+ class: "db4q22c",
9
+ propsAsIs: !1
10
+ }), a = /* @__PURE__ */ s("blockquote")({
11
+ name: "Quote",
12
+ class: "q111mmic",
13
+ propsAsIs: !1
6
14
  });
7
15
  export {
8
- t as Container
16
+ o as Container,
17
+ t as DateTime,
18
+ a as Quote
9
19
  };
@@ -9,6 +9,9 @@ export type VotingOptionProps = ExtendedQuestionAnswer & {
9
9
  imageMode?: QuestionImages;
10
10
  answerTimeExpired: boolean;
11
11
  questionStatus: QuestionStatus;
12
+ votedAfterQuestionClosed: boolean;
13
+ enteredAnActiveQuestion: boolean;
12
14
  onVote: (e: React.MouseEvent<HTMLButtonElement>) => void;
15
+ markThatVoted: (votedAfterQuestionClosed: boolean) => void;
13
16
  };
14
17
  export declare const VotingOption: React.FC<VotingOptionProps>;
@@ -1,71 +1,76 @@
1
- import { jsx as r, jsxs as u } from "react/jsx-runtime";
2
- import { QuestionImages as s, QuestionStatus as S, QuestionType as c } from "@streamlayer/sdk-web-types";
3
- import { AnimatedCounter as O } from "../../../animated-counter/index.js";
4
- import { IconDefault as P, IconContainer as A, IconWrap as k, IconCircle as x, ButtonContainer as L, ButtonPct as B, ButtonBody as Q, Title as b, Indicators as j, CheckIcon as v, Percentage as U } from "./styles.js";
1
+ import { jsx as n, jsxs as f } from "react/jsx-runtime";
2
+ import { QuestionImages as s, QuestionStatus as I, QuestionType as c } from "@streamlayer/sdk-web-types";
3
+ import { AnimatedCounter as x } from "../../../animated-counter/index.js";
4
+ import { IconDefault as L, IconContainer as Q, IconWrap as v, IconCircle as B, ButtonContainer as V, ButtonPct as b, ButtonBody as j, Title as U, Indicators as $, CheckIcon as M, Percentage as W } from "./styles.js";
5
5
  import "react-countup";
6
6
  import "@linaria/react";
7
7
  import "../../../icons/index.js";
8
8
  import "react";
9
- const d = {
10
- [s.CENTERED]: (t) => /* @__PURE__ */ r(P, { alt: "option-icon", src: t }),
11
- [s.TRANSPARENT]: (t) => /* @__PURE__ */ r(A, { children: /* @__PURE__ */ r(k, { style: { backgroundImage: `url(${t})` } }) }),
12
- [s.ROUNDED]: (t) => /* @__PURE__ */ r(x, { alt: "option-icon", src: t }),
9
+ const m = {
10
+ [s.CENTERED]: (t) => /* @__PURE__ */ n(L, { alt: "option-icon", src: t }),
11
+ [s.TRANSPARENT]: (t) => /* @__PURE__ */ n(Q, { children: /* @__PURE__ */ n(v, { style: { backgroundImage: `url(${t})` } }) }),
12
+ [s.ROUNDED]: (t) => /* @__PURE__ */ n(B, { alt: "option-icon", src: t }),
13
13
  [s.NONE]: () => null,
14
14
  [s.UNSET]: () => null
15
- }, V = ({ questionType: t, hasCorrectAnswer: o, correct: e, youVoted: n, questionVoted: i }) => {
16
- if (t === c.POLL && n)
15
+ }, y = ({ questionType: t, hasCorrectAnswer: i, correct: e, youVoted: r, questionVoted: o }) => {
16
+ if (t === c.POLL && r)
17
17
  return "correct";
18
18
  if (t === c.PREDICTION) {
19
- if (o && i)
20
- return n ? e ? "correct" : "incorrect" : "unset";
21
- if (n)
19
+ if (i && o)
20
+ return r ? e ? "correct" : "incorrect" : "unset";
21
+ if (r)
22
22
  return "correct";
23
23
  }
24
- return t === c.TRIVIA && i && n ? e ? "correct" : "incorrect" : "unset";
25
- }, $ = ({
24
+ return t === c.TRIVIA && o && r ? e ? "correct" : "incorrect" : "unset";
25
+ }, z = ({
26
26
  questionType: t,
27
- questionVoted: o,
27
+ questionVoted: i,
28
28
  correct: e,
29
- hasCorrectAnswer: n,
30
- questionStatus: i
31
- }) => t === c.TRIVIA ? o && e : t === c.PREDICTION ? o && e && n || i === S.RESOLVED && e : !1, X = (t) => {
32
- var N;
29
+ hasCorrectAnswer: r,
30
+ questionStatus: o
31
+ }) => t === c.TRIVIA ? i && e : t === c.PREDICTION ? i && e && r || o === I.RESOLVED && e : !1, q = (t) => {
32
+ var R;
33
33
  const {
34
34
  // option props
35
- id: o,
35
+ id: i,
36
36
  icon: e,
37
- text: n,
38
- percentageDecimal: i,
37
+ text: r,
38
+ percentageDecimal: o,
39
39
  // extra props
40
40
  onVote: p,
41
- youSelected: f,
41
+ markThatVoted: D,
42
+ youSelected: E,
42
43
  questionVoted: a,
43
44
  // ToDo: Figure out why imageMode is not in the response, and delete default value
44
- imageMode: m,
45
- answerTimeExpired: R,
46
- questionStatus: I,
45
+ imageMode: h,
46
+ answerTimeExpired: T,
47
+ questionStatus: d,
47
48
  isLoading: g,
48
- questionType: h,
49
+ questionType: C,
49
50
  correct: w,
50
- hasCorrectAnswer: D
51
- } = t, l = V(t), T = $({ questionType: h, questionVoted: a, correct: w, hasCorrectAnswer: D, questionStatus: I }), C = I === S.RESOLVED && h === c.PREDICTION, E = a || C;
52
- return /* @__PURE__ */ u(
53
- L,
51
+ hasCorrectAnswer: A,
52
+ votedAfterQuestionClosed: O,
53
+ enteredAnActiveQuestion: S
54
+ } = t, l = y(t), P = z({ questionType: C, questionVoted: a, correct: w, hasCorrectAnswer: A, questionStatus: d }), u = d === I.RESOLVED && C === c.PREDICTION, N = a || u;
55
+ return /* @__PURE__ */ f(
56
+ V,
54
57
  {
55
- value: o,
56
- "data-selected": f,
58
+ value: i,
59
+ "data-selected": E,
57
60
  "data-answerState": l,
58
- disabled: a || g || R || C,
59
- "data-isNotChecked": a && !f && l !== "incorrect",
60
- onClick: p,
61
+ disabled: a || g || T || u && !S || u && S && O,
62
+ "data-isNotChecked": a && !E && l !== "incorrect",
63
+ onClick: (k) => {
64
+ D(d === I.RESOLVED), p(k);
65
+ },
61
66
  children: [
62
- /* @__PURE__ */ r(B, { "data-answerState": l, style: { width: `${E ? i : 0}%` } }),
63
- /* @__PURE__ */ u(Q, { children: [
64
- e && m && ((N = d[m]) == null ? void 0 : N.call(d, e)),
65
- /* @__PURE__ */ r(b, { children: n }),
66
- E && /* @__PURE__ */ u(j, { children: [
67
- T && /* @__PURE__ */ r(v, { name: "selected" }),
68
- /* @__PURE__ */ r(U, { children: /* @__PURE__ */ r(O, { value: i, suffix: "%" }) })
67
+ /* @__PURE__ */ n(b, { "data-answerState": l, style: { width: `${N ? o : 0}%` } }),
68
+ /* @__PURE__ */ f(j, { children: [
69
+ e && h && ((R = m[h]) == null ? void 0 : R.call(m, e)),
70
+ /* @__PURE__ */ n(U, { children: r }),
71
+ N && /* @__PURE__ */ f($, { children: [
72
+ P && /* @__PURE__ */ n(M, { name: "selected" }),
73
+ /* @__PURE__ */ n(W, { children: /* @__PURE__ */ n(x, { value: o, suffix: "%" }) })
69
74
  ] })
70
75
  ] })
71
76
  ]
@@ -73,5 +78,5 @@ const d = {
73
78
  );
74
79
  };
75
80
  export {
76
- X as VotingOption
81
+ q as VotingOption
77
82
  };
@@ -46,6 +46,7 @@ export declare const icons: {
46
46
  circleClose: any;
47
47
  incorrectVoted: any;
48
48
  mastersLogo: any;
49
+ twitter: any;
49
50
  };
50
51
  export declare const Icon: React.FC<{
51
52
  name: keyof typeof icons;