@streamlayer/react-ui 0.67.6 → 0.68.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.
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { CountUpProps } from 'react-countup';
3
+ export declare const AnimatedCounter: React.FC<Omit<CountUpProps, 'end' | 'start' | 'duration' | 'preserveValue'> & {
4
+ value?: number;
5
+ }>;
@@ -0,0 +1,9 @@
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import i from "react-countup";
3
+ const m = ({ value: e = 0, decimals: r, ...n }) => {
4
+ const [, t] = e.toString().split("."), o = r ?? ((t == null ? void 0 : t.length) || 0);
5
+ return /* @__PURE__ */ s(i, { end: e, ...n, duration: 1, decimals: o, enableScrollSpy: !1, preserveValue: !0 });
6
+ };
7
+ export {
8
+ m as AnimatedCounter
9
+ };
@@ -16,6 +16,8 @@ import "../../../gamification/vote/feedback/index.js";
16
16
  import "../../../gamification/vote/feedback/styles.js";
17
17
  import "../../../gamification/vote/styles.js";
18
18
  import "../../../gamification/vote/vote-option/index.js";
19
+ import "../../../animated-counter/index.js";
20
+ import "react-countup";
19
21
  import "../../../gamification/vote/vote-option/styles.js";
20
22
  import "../../../gamification/vote/win-bar/index.js";
21
23
  import "../../../timer/index.js";
@@ -54,7 +56,7 @@ const d = /* @__PURE__ */ n("div")({
54
56
  close: s,
55
57
  openedQuestion: o
56
58
  }) : null;
57
- }, M = ({
59
+ }, P = ({
58
60
  gamification: t
59
61
  }) => {
60
62
  var o;
@@ -76,5 +78,5 @@ const d = /* @__PURE__ */ n("div")({
76
78
  });
77
79
  };
78
80
  export {
79
- M as Question
81
+ P as Question
80
82
  };
@@ -26,6 +26,8 @@ import "../../../gamification/vote/feedback/index.js";
26
26
  import "../../../gamification/vote/feedback/styles.js";
27
27
  import "../../../gamification/vote/styles.js";
28
28
  import "../../../gamification/vote/vote-option/index.js";
29
+ import "../../../animated-counter/index.js";
30
+ import "react-countup";
29
31
  import "../../../gamification/vote/vote-option/styles.js";
30
32
  import "../../../gamification/vote/win-bar/index.js";
31
33
  import "../../../timer/index.js";
@@ -26,6 +26,8 @@ import "../../../gamification/vote/feedback/index.js";
26
26
  import "../../../gamification/vote/feedback/styles.js";
27
27
  import "../../../gamification/vote/styles.js";
28
28
  import "../../../gamification/vote/vote-option/index.js";
29
+ import "../../../animated-counter/index.js";
30
+ import "react-countup";
29
31
  import "../../../gamification/vote/vote-option/styles.js";
30
32
  import "../../../gamification/vote/win-bar/index.js";
31
33
  import "../../../timer/index.js";
@@ -73,7 +75,7 @@ const C = () => h, n = /* @__PURE__ */ s(C())({
73
75
  }) => {
74
76
  const i = r + t;
75
77
  return i === 0 ? 0 : Math.round(r / i * 100);
76
- }, yr = ({
78
+ }, Dr = ({
77
79
  gamification: r,
78
80
  className: t
79
81
  }) => {
@@ -107,5 +109,5 @@ const C = () => h, n = /* @__PURE__ */ s(C())({
107
109
  });
108
110
  };
109
111
  export {
110
- yr as GamificationOverlay
112
+ Dr as GamificationOverlay
111
113
  };
@@ -1,18 +1,19 @@
1
- import { jsxs as i, jsx as o } from "react/jsx-runtime";
2
- import { resetCss as r } from "../../theme/theme.js";
3
- import { formatDecimals as n } from "../../../utils/common.js";
4
- import { PointsContainer as s, PointsIcon as m, PointsSvg as e, PointsBody as p, PointsTitle as c, PointsValue as l } from "./styles.js";
1
+ import { jsxs as t, jsx as o } from "react/jsx-runtime";
2
+ import { AnimatedCounter as r } from "../../animated-counter/index.js";
3
+ import { resetCss as n } from "../../theme/theme.js";
4
+ import { PointsContainer as e, PointsIcon as s, PointsSvg as m, PointsBody as p, PointsTitle as l, PointsValue as c } from "./styles.js";
5
+ import "react-countup";
5
6
  import "../../theme/constants.js";
6
7
  import "@linaria/react";
7
8
  import "../../icons/index.js";
8
9
  import "react";
9
- const y = ({ points: t }) => /* @__PURE__ */ i(s, { className: r, children: [
10
- /* @__PURE__ */ o(m, { children: /* @__PURE__ */ o(e, { name: "icon-trophy" }) }),
11
- /* @__PURE__ */ i(p, { children: [
12
- /* @__PURE__ */ o(c, { children: "Total points" }),
13
- /* @__PURE__ */ o(l, { children: n(t) })
10
+ const v = ({ points: i }) => /* @__PURE__ */ t(e, { className: n, children: [
11
+ /* @__PURE__ */ o(s, { children: /* @__PURE__ */ o(m, { name: "icon-trophy" }) }),
12
+ /* @__PURE__ */ t(p, { children: [
13
+ /* @__PURE__ */ o(l, { children: "Total points" }),
14
+ /* @__PURE__ */ o(c, { children: /* @__PURE__ */ o(r, { value: i }) })
14
15
  ] })
15
16
  ] });
16
17
  export {
17
- y as Points
18
+ v as Points
18
19
  };
@@ -1,34 +1,36 @@
1
- import { jsx as i, jsxs as g, Fragment as O } from "react/jsx-runtime";
1
+ import { jsx as a, jsxs as q, Fragment as u } from "react/jsx-runtime";
2
2
  import { useState as l, useCallback as C, useMemo as n } from "react";
3
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";
4
+ import { SDKScrollContainer as O } from "../../app/styles.js";
5
+ import { ExpiredAlert as b } from "./expired-alert/index.js";
6
+ import { Feedback as D } from "./feedback/index.js";
7
+ import { Container as M, Content as P, Title as j, Options as k } from "./styles.js";
8
8
  import { VotingOption as F } from "./vote-option/index.js";
9
9
  import { WinBar as L } from "./win-bar/index.js";
10
10
  import "@linaria/react";
11
11
  import "../../icons/index.js";
12
12
  import "./expired-alert/styles.js";
13
13
  import "./feedback/styles.js";
14
+ import "../../animated-counter/index.js";
15
+ import "react-countup";
14
16
  import "./vote-option/styles.js";
15
17
  import "../../timer/index.js";
16
18
  import "react-countdown-circle-timer";
17
19
  import "../../theme/constants.js";
18
20
  import "./win-bar/styles.js";
19
- const it = ({ openedQuestion: t, vote: f, close: p }) => {
20
- var q;
21
- const E = t.subject, V = t.type, e = (q = t.options) == null ? void 0 : q.options, [s, A] = l(!1), [d, T] = l(!1), [w, h] = l(""), m = t == null ? void 0 : t.id, y = C(
21
+ const st = ({ openedQuestion: t, vote: f, close: p }) => {
22
+ var g;
23
+ const E = t.subject, V = t.type, m = (g = t.options) == null ? void 0 : g.options, [s, A] = l(!1), [T, d] = l(!1), [w, y] = l(""), e = t == null ? void 0 : t.id, h = C(
22
24
  async (r) => {
23
- if (m) {
25
+ if (e) {
24
26
  const c = r.currentTarget.value;
25
- h(c), T(!0), await f(m, c), T(!1);
27
+ y(c), d(!0), await f(e, c), d(!1);
26
28
  }
27
29
  },
28
- [m, h, f]
30
+ [e, y, f]
29
31
  ), I = C(() => {
30
32
  A(!0), setTimeout(p, 3e3);
31
- }, [p]), a = n(
33
+ }, [p]), i = n(
32
34
  () => t == null ? void 0 : t.answers.find((r) => r.youVoted === !0),
33
35
  [t]
34
36
  ), o = n(
@@ -38,51 +40,53 @@ const it = ({ openedQuestion: t, vote: f, close: p }) => {
38
40
  var c;
39
41
  return {
40
42
  ...r,
41
- questionVoted: !!a,
43
+ questionVoted: !!i,
42
44
  youSelected: w === r.id,
43
- isLoading: d,
45
+ isLoading: T,
44
46
  hasCorrectAnswer: o,
45
47
  questionType: t.type,
46
48
  answerTimeExpired: s,
47
49
  questionStatus: t.status,
48
50
  imageMode: (c = t.appearance) == null ? void 0 : c.images,
49
51
  // ToDo: Figure out why imageMode is not in the response
50
- onVote: y
52
+ onVote: h
51
53
  };
52
- }) : [], [o, s, d, t, a, y, w]), x = e && (e.case === "trivia" || e.case === "prediction") ? e.value : void 0;
53
- return /* @__PURE__ */ i(b, { "data-question-header": "true", children: /* @__PURE__ */ i(j, { children: /* @__PURE__ */ g(k, { children: [
54
- x && /* @__PURE__ */ i(
55
- M,
54
+ }) : [], [o, s, T, t, i, h, w]), x = m && (m.case === "trivia" || m.case === "prediction") ? m.value : void 0;
55
+ return /* @__PURE__ */ a(O, { "data-question-header": "true", children: /* @__PURE__ */ a(M, { children: /* @__PURE__ */ q(P, { children: [
56
+ x && /* @__PURE__ */ a(
57
+ D,
56
58
  {
57
59
  feedbackMessages: x,
58
- questionVoted: !!a,
59
- questionVotedCorrectly: a == null ? void 0 : a.correct,
60
+ questionVoted: !!i,
61
+ questionVotedCorrectly: i == null ? void 0 : i.correct,
60
62
  questionType: V,
61
63
  hasCorrectAnswer: o,
62
64
  questionStatus: t.status
63
65
  }
64
66
  ),
65
- t.type !== v.PREDICTION && /* @__PURE__ */ i(
67
+ t.type !== v.PREDICTION && /* @__PURE__ */ a(
66
68
  L,
67
69
  {
68
70
  title: s ? "Time expired" : "To win",
69
71
  points: s ? void 0 : 100,
70
72
  onTimerExpired: I,
71
- isTimer: !0
73
+ isTimer: !0,
74
+ isPlayingTimer: !i,
75
+ timerDuration: i ? 0 : 30
72
76
  }
73
77
  ),
74
- s ? /* @__PURE__ */ i(
75
- u,
78
+ s ? /* @__PURE__ */ a(
79
+ b,
76
80
  {
77
81
  title: "More to come...",
78
82
  description: "Watch for additional enhanced stream interactive experience."
79
83
  }
80
- ) : /* @__PURE__ */ g(O, { children: [
81
- /* @__PURE__ */ i(D, { "data-isPrediction": t.type === v.PREDICTION, children: E }),
82
- /* @__PURE__ */ i(P, { children: S.map((r) => /* @__PURE__ */ i(F, { ...r }, r.id)) })
84
+ ) : /* @__PURE__ */ q(u, { children: [
85
+ /* @__PURE__ */ a(j, { "data-isPrediction": t.type === v.PREDICTION, children: E }),
86
+ /* @__PURE__ */ a(k, { children: S.map((r) => /* @__PURE__ */ a(F, { ...r }, r.id)) })
83
87
  ] })
84
88
  ] }) }) });
85
89
  };
86
90
  export {
87
- it as Vote
91
+ st as Vote
88
92
  };
@@ -1,71 +1,70 @@
1
- import { jsx as i, jsxs as s } from "react/jsx-runtime";
2
- import { QuestionImages as a, QuestionStatus as h, QuestionType as o } from "@streamlayer/sdk-web-types";
3
- import { IconDefault as T, IconContainer as O, IconWrap as P, IconCircle as A, ButtonContainer as x, ButtonPct as L, ButtonBody as B, Title as k, Indicators as Q, CheckIcon as b, Percentage as j } from "./styles.js";
1
+ import { jsx as r, jsxs as l } from "react/jsx-runtime";
2
+ import { QuestionImages as a, QuestionStatus as h, QuestionType as c } from "@streamlayer/sdk-web-types";
3
+ import { AnimatedCounter as T } from "../../../animated-counter/index.js";
4
+ import { IconDefault as O, IconContainer as P, IconWrap as A, IconCircle as x, ButtonContainer as L, ButtonPct as B, ButtonBody as k, Title as Q, Indicators as b, CheckIcon as j, Percentage as U } from "./styles.js";
5
+ import "react-countup";
4
6
  import "@linaria/react";
5
7
  import "../../../icons/index.js";
6
8
  import "react";
7
9
  const u = {
8
- [a.CENTERED]: (t) => /* @__PURE__ */ i(T, { alt: "option-icon", src: t }),
9
- [a.TRANSPARENT]: (t) => /* @__PURE__ */ i(O, { children: /* @__PURE__ */ i(P, { style: { backgroundImage: `url(${t})` } }) }),
10
- [a.ROUNDED]: (t) => /* @__PURE__ */ i(A, { alt: "option-icon", src: t }),
10
+ [a.CENTERED]: (t) => /* @__PURE__ */ r(O, { alt: "option-icon", src: t }),
11
+ [a.TRANSPARENT]: (t) => /* @__PURE__ */ r(P, { children: /* @__PURE__ */ r(A, { style: { backgroundImage: `url(${t})` } }) }),
12
+ [a.ROUNDED]: (t) => /* @__PURE__ */ r(x, { alt: "option-icon", src: t }),
11
13
  [a.NONE]: () => null,
12
14
  [a.UNSET]: () => null
13
- }, U = ({ questionType: t, hasCorrectAnswer: c, correct: e, youVoted: n, questionVoted: r }) => {
14
- if (t === o.POLL && n)
15
+ }, V = ({ questionType: t, hasCorrectAnswer: o, correct: e, youVoted: n, questionVoted: i }) => {
16
+ if (t === c.POLL && n)
15
17
  return "correct";
16
- if (t === o.PREDICTION) {
17
- if (c && r)
18
+ if (t === c.PREDICTION) {
19
+ if (o && i)
18
20
  return n ? e ? "correct" : "incorrect" : e ? "correct" : "unset";
19
21
  if (n)
20
22
  return "correct";
21
23
  }
22
- return t === o.TRIVIA && r ? n ? e ? "correct" : "incorrect" : e ? "correct" : "unset" : "unset";
23
- }, V = ({
24
+ return t === c.TRIVIA && i ? n ? e ? "correct" : "incorrect" : e ? "correct" : "unset" : "unset";
25
+ }, $ = ({
24
26
  questionType: t,
25
- questionVoted: c,
27
+ questionVoted: o,
26
28
  correct: e,
27
29
  hasCorrectAnswer: n,
28
- questionStatus: r
29
- }) => t === o.TRIVIA ? c && e : t === o.PREDICTION ? c && e && n || r === h.RESOLVED && e : !1, F = (t) => {
30
+ questionStatus: i
31
+ }) => t === c.TRIVIA ? o && e : t === c.PREDICTION ? o && e && n || i === h.RESOLVED && e : !1, J = (t) => {
30
32
  var S;
31
33
  const {
32
34
  // option props
33
- id: c,
35
+ id: o,
34
36
  icon: e,
35
37
  text: n,
36
- percentageDecimal: r,
38
+ percentageDecimal: i,
37
39
  // extra props
38
- onVote: C,
39
- youSelected: R,
40
- questionVoted: l,
40
+ onVote: p,
41
+ youSelected: C,
42
+ questionVoted: s,
41
43
  // ToDo: Figure out why imageMode is not in the response, and delete default value
42
- imageMode: I,
43
- answerTimeExpired: g,
44
- questionStatus: d,
45
- isLoading: p,
46
- questionType: f,
44
+ imageMode: d,
45
+ answerTimeExpired: R,
46
+ questionStatus: f,
47
+ isLoading: g,
48
+ questionType: m,
47
49
  correct: w,
48
50
  hasCorrectAnswer: D
49
- } = t, m = U(t), N = V({ questionType: f, questionVoted: l, correct: w, hasCorrectAnswer: D, questionStatus: d }), E = l || d === h.RESOLVED && f === o.PREDICTION;
50
- return /* @__PURE__ */ s(
51
- x,
51
+ } = t, I = V(t), N = $({ questionType: m, questionVoted: s, correct: w, hasCorrectAnswer: D, questionStatus: f }), E = s || f === h.RESOLVED && m === c.PREDICTION;
52
+ return /* @__PURE__ */ l(
53
+ L,
52
54
  {
53
- value: c,
54
- "data-selected": R,
55
- "data-answerState": m,
56
- disabled: l || p || g,
57
- onClick: C,
55
+ value: o,
56
+ "data-selected": C,
57
+ "data-answerState": I,
58
+ disabled: s || g || R,
59
+ onClick: p,
58
60
  children: [
59
- E && /* @__PURE__ */ i(L, { "data-answerState": m, style: { width: `${r}%` } }),
60
- /* @__PURE__ */ s(B, { children: [
61
- e && I && ((S = u[I]) == null ? void 0 : S.call(u, e)),
62
- /* @__PURE__ */ i(k, { children: n }),
63
- E && /* @__PURE__ */ s(Q, { children: [
64
- N && /* @__PURE__ */ i(b, { name: "selected" }),
65
- /* @__PURE__ */ s(j, { children: [
66
- r,
67
- "%"
68
- ] })
61
+ E && /* @__PURE__ */ r(B, { "data-answerState": I, style: { width: `${i}%` } }),
62
+ /* @__PURE__ */ l(k, { children: [
63
+ e && d && ((S = u[d]) == null ? void 0 : S.call(u, e)),
64
+ /* @__PURE__ */ r(Q, { children: n }),
65
+ E && /* @__PURE__ */ l(b, { children: [
66
+ N && /* @__PURE__ */ r(j, { name: "selected" }),
67
+ /* @__PURE__ */ r(U, { children: /* @__PURE__ */ r(T, { value: i, suffix: "%" }) })
69
68
  ] })
70
69
  ] })
71
70
  ]
@@ -73,5 +72,5 @@ const u = {
73
72
  );
74
73
  };
75
74
  export {
76
- F as VotingOption
75
+ J as VotingOption
77
76
  };
@@ -4,6 +4,7 @@ interface WinBarProps {
4
4
  points?: number;
5
5
  isPlayingTimer?: boolean;
6
6
  isTimer?: boolean;
7
+ timerDuration?: number;
7
8
  onTimerExpired?: () => void;
8
9
  }
9
10
  export declare const WinBar: React.FC<WinBarProps>;
@@ -1,24 +1,31 @@
1
- import { jsxs as r, jsx as i, Fragment as c } from "react/jsx-runtime";
1
+ import { jsxs as r, jsx as i, Fragment as d } from "react/jsx-runtime";
2
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";
3
+ import { WinBarContainer as h, Content as l, Title as s, WinIcon as a, Points as P, PointsCount as f, PointsUnits as u } from "./styles.js";
4
4
  import "@linaria/react";
5
5
  import "react";
6
6
  import "react-countdown-circle-timer";
7
7
  import "../../../theme/constants.js";
8
8
  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" })
9
+ const v = ({
10
+ title: n,
11
+ points: o,
12
+ isPlayingTimer: t,
13
+ isTimer: e,
14
+ timerDuration: m,
15
+ onTimerExpired: c
16
+ }) => /* @__PURE__ */ r(h, { children: [
17
+ /* @__PURE__ */ r(l, { children: [
18
+ n && /* @__PURE__ */ i(s, { children: n }),
19
+ o !== void 0 && /* @__PURE__ */ r(d, { children: [
20
+ /* @__PURE__ */ i(a, { name: "icon-trophy" }),
21
+ /* @__PURE__ */ r(P, { children: [
22
+ /* @__PURE__ */ i(f, { children: o }),
23
+ /* @__PURE__ */ i(u, { children: "PTS" })
17
24
  ] })
18
25
  ] })
19
26
  ] }),
20
- e && /* @__PURE__ */ i(p, { isPlaying: t, onTimerExpired: m })
27
+ e && /* @__PURE__ */ i(p, { isPlaying: t, onTimerExpired: c, duration: m })
21
28
  ] });
22
29
  export {
23
- B as WinBar
30
+ v as WinBar
24
31
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamlayer/react-ui",
3
- "version": "0.67.6",
3
+ "version": "0.68.1",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "typings": "./lib/index.d.ts",
@@ -35,19 +35,19 @@
35
35
  "package.json"
36
36
  ],
37
37
  "peerDependencies": {
38
+ "@lottiefiles/react-lottie-player": "*",
38
39
  "@streamlayer/sl-eslib": "^5.53.6",
39
40
  "react-virtualized-auto-sizer": "^1.0.20",
40
41
  "react-window": "^1.8.9",
41
- "@lottiefiles/react-lottie-player": "*",
42
42
  "react-window-infinite-loader": "^1.0.9",
43
- "@streamlayer/feature-gamification": "^0.26.4",
44
- "@streamlayer/sdk-web": "^0.28.26",
45
- "@streamlayer/sdk-web-anonymous-auth": "^0.11.21",
43
+ "@streamlayer/feature-gamification": "^0.26.5",
44
+ "@streamlayer/sdk-web": "^0.28.27",
46
45
  "@streamlayer/sdk-web-api": "^0.0.1",
47
- "@streamlayer/sdk-web-core": "^0.0.2",
48
- "@streamlayer/sdk-web-features": "^0.10.29",
46
+ "@streamlayer/sdk-web-core": "^0.0.3",
47
+ "@streamlayer/sdk-web-features": "^0.10.30",
48
+ "@streamlayer/sdk-web-anonymous-auth": "^0.11.22",
49
49
  "@streamlayer/sdk-web-interfaces": "^0.0.1",
50
- "@streamlayer/sdk-web-notifications": "^0.13.2",
50
+ "@streamlayer/sdk-web-notifications": "^0.13.3",
51
51
  "@streamlayer/sdk-web-storage": "^0.0.4",
52
52
  "@streamlayer/sdk-web-types": "^0.0.1"
53
53
  },
@@ -80,6 +80,7 @@
80
80
  "react": "18.2.0",
81
81
  "react-auth-code-input": "^3.2.1",
82
82
  "react-countdown-circle-timer": "^3.2.1",
83
+ "react-countup": "^6.5.0",
83
84
  "react-phone-number-input": "^3.3.7",
84
85
  "rollup-plugin-node-polyfills": "^0.2.1",
85
86
  "tslib": "^2.6.2",
@@ -88,6 +89,6 @@
88
89
  "vite-plugin-svgr": "^4.1.0",
89
90
  "vite-svg-loader": "^4.0.0",
90
91
  "vite-tsconfig-paths": "^4.2.1",
91
- "@streamlayer/react": "^0.30.6"
92
+ "@streamlayer/react": "^0.31.1"
92
93
  }
93
94
  }