@streamlayer/react-ui 0.80.1 → 0.81.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.
@@ -2,4 +2,5 @@
2
2
  import type { Gamification } from '@streamlayer/feature-gamification';
3
3
  export declare const Leaderboard: React.FC<{
4
4
  gamification: Gamification;
5
+ hideTabs: (hide: boolean) => void;
5
6
  }>;
@@ -1,7 +1,9 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import { useStore as o } from "@nanostores/react";
3
- import { LeaderboardList as p } from "../../../gamification/leaderboard/index.js";
4
- import { Friends as m } from "./Friends.js";
1
+ import { jsx as l } from "react/jsx-runtime";
2
+ import { useStore as i } from "@nanostores/react";
3
+ import n from "lodash.throttle";
4
+ import { useRef as p, useCallback as c } from "react";
5
+ import { LeaderboardList as f } from "../../../gamification/leaderboard/index.js";
6
+ import { Friends as d } from "./Friends.js";
5
7
  import "react-virtualized-auto-sizer";
6
8
  import "react-window";
7
9
  import "react-window-infinite-loader";
@@ -10,22 +12,27 @@ import "../../../../utils/common.js";
10
12
  import "../../../gamification/leaderboard/list-item/styles.js";
11
13
  import "@linaria/react";
12
14
  import "../../../icons/index.js";
13
- import "react";
14
15
  import "../../../gamification/leaderboard/styles.js";
15
16
  import "../../../gamification/onboarding/slides/onboarding-invite-card/index.js";
16
17
  import "../../../gamification/onboarding/slides/onboarding-invite-card/styles.js";
17
- const j = ({ gamification: r }) => {
18
- const { data: e } = o(r.leaderboardList.$store);
19
- return e != null && e.length ? /* @__PURE__ */ t(
20
- p,
18
+ const F = ({ gamification: r, hideTabs: o }) => {
19
+ const { data: e } = i(r.leaderboardList.$store), s = p(0), m = c(
20
+ n((t) => {
21
+ Math.abs(s.current - t.scrollOffset) < 112 || (s.current = t.scrollOffset, o(t.scrollOffset !== 0 && t.scrollDirection === "forward"));
22
+ }, 200),
23
+ [o]
24
+ );
25
+ return e != null && e.length ? /* @__PURE__ */ l(
26
+ f,
21
27
  {
22
28
  fetchMore: r.leaderboardList.fetchMore,
23
29
  items: e,
30
+ onScroll: m,
24
31
  openItemDetail: r.openUser,
25
32
  currentUserId: r.currentUserId.get()
26
33
  }
27
- ) : /* @__PURE__ */ t(m, { deepLink: r.deepLink });
34
+ ) : /* @__PURE__ */ l(d, { deepLink: r.deepLink });
28
35
  };
29
36
  export {
30
- j as Leaderboard
37
+ F as Leaderboard
31
38
  };
@@ -1,10 +1,11 @@
1
- import { jsx as r, jsxs as m, Fragment as s } from "react/jsx-runtime";
2
- import { useState as n } from "react";
3
- import { SDKScrollContainer as d, SDKWhiteContainer as p, SDKContentContainer as a } from "../../styles.js";
4
- import { ActivePages as i, Tabs as l } from "../../../gamification/tabs/index.js";
5
- import { Leaderboard as c } from "./Leaderboard.js";
6
- import { QuestionsList as h } from "./QuestionsList.js";
7
- import { UserSummary as u } from "./UserSummary.js";
1
+ import { jsxs as a, jsx as t } from "react/jsx-runtime";
2
+ import S from "lodash.throttle";
3
+ import { useState as d, useRef as u, useTransition as E, useCallback as y, useEffect as C } from "react";
4
+ import { SDKWhiteContainer as f, SDKScrollContainer as D, SDKContentContainer as L } from "../../styles.js";
5
+ import { ActivePages as s, Tabs as A } from "../../../gamification/tabs/index.js";
6
+ import { Leaderboard as P } from "./Leaderboard.js";
7
+ import { QuestionsList as R } from "./QuestionsList.js";
8
+ import { UserSummary as w } from "./UserSummary.js";
8
9
  import "@linaria/react";
9
10
  import "../../../gamification/tabs/styles.js";
10
11
  import "@nanostores/react";
@@ -46,49 +47,76 @@ import "../../../gamification/user-statistics/components/rank/styles.js";
46
47
  import "../../../gamification/user-statistics/components/statistic/index.js";
47
48
  import "../../../gamification/user-statistics/components/statistic/styles.js";
48
49
  import "../../../gamification/user-statistics/styles.js";
49
- const dr = ({
50
- gamification: t
50
+ const Lr = ({
51
+ gamification: i
51
52
  }) => {
52
- const [o, e] = n(i.HOME);
53
- return /* @__PURE__ */ r("div", {
53
+ const [h, b] = d(!1), [o, T] = d(s.HOME), m = u(null), e = u(0), [g, l] = E(), v = (r) => {
54
+ l(() => T(r));
55
+ }, p = (r) => {
56
+ l(() => b(r));
57
+ }, c = y(S(() => {
58
+ const r = m.current;
59
+ if (!r)
60
+ return;
61
+ const {
62
+ scrollTop: n
63
+ } = r;
64
+ if (n === 0) {
65
+ e.current = 0, p(!1);
66
+ return;
67
+ }
68
+ if (Math.abs(e.current - n) < 112)
69
+ return;
70
+ const x = e.current < n ? "forward" : "backward";
71
+ e.current = n, p(x === "forward");
72
+ }, 200), []);
73
+ return C(() => {
74
+ const r = m.current;
75
+ return r ? (o === s.HOME && r.addEventListener("scroll", c), () => {
76
+ r.removeEventListener("scroll", c);
77
+ }) : () => {
78
+ };
79
+ }, [o, c]), /* @__PURE__ */ a("div", {
54
80
  style: {
55
81
  height: "100%",
56
82
  display: "flex",
57
83
  flexDirection: "column",
58
84
  overflow: "hidden"
59
85
  },
60
- children: /* @__PURE__ */ m(d, {
61
- children: [/* @__PURE__ */ r(p, {
86
+ children: [g, /* @__PURE__ */ t(f, {
87
+ style: {
88
+ paddingBottom: "4px",
89
+ transition: "margin-top 0.2s ease-in-out",
90
+ marginTop: h ? "-56px" : "0px"
91
+ },
92
+ children: /* @__PURE__ */ t(A, {
93
+ activePage: o,
94
+ toggleActivePage: v
95
+ })
96
+ }), o === s.HOME && /* @__PURE__ */ a(D, {
97
+ ref: m,
98
+ children: [/* @__PURE__ */ t(f, {
62
99
  style: {
63
- paddingBottom: "4px"
100
+ paddingTop: "12px"
64
101
  },
65
- children: /* @__PURE__ */ r(l, {
66
- activePage: o,
67
- toggleActivePage: e
102
+ children: /* @__PURE__ */ t(w, {
103
+ userSummary: i.userSummary
68
104
  })
69
- }), o === i.HOME && /* @__PURE__ */ m(s, {
70
- children: [/* @__PURE__ */ r(p, {
71
- style: {
72
- paddingTop: "12px"
73
- },
74
- children: /* @__PURE__ */ r(u, {
75
- userSummary: t.userSummary
76
- })
77
- }), /* @__PURE__ */ r(a, {
78
- children: /* @__PURE__ */ r(h, {
79
- openQuestion: t.openQuestion,
80
- store: t.feedList.getStore()
81
- })
82
- })]
83
- }), o === i.LEADERBOARD && /* @__PURE__ */ r("div", {
84
- className: "c1bp9dj2",
85
- children: /* @__PURE__ */ r(c, {
86
- gamification: t
105
+ }), /* @__PURE__ */ t(L, {
106
+ children: /* @__PURE__ */ t(R, {
107
+ openQuestion: i.openQuestion,
108
+ store: i.feedList.getStore()
87
109
  })
88
110
  })]
89
- })
111
+ }), o === s.LEADERBOARD && /* @__PURE__ */ t("div", {
112
+ className: "c1bp9dj2",
113
+ children: /* @__PURE__ */ t(P, {
114
+ gamification: i,
115
+ hideTabs: p
116
+ })
117
+ })]
90
118
  });
91
119
  };
92
120
  export {
93
- dr as Tabs
121
+ Lr as Tabs
94
122
  };
@@ -48,6 +48,7 @@ import "../../../questions/twitter/account/styles.js";
48
48
  import "../../../questions/twitter/styles.js";
49
49
  import "../../../gamification/vote/twitter-details/styles.js";
50
50
  import "./Tabs.js";
51
+ import "lodash.throttle";
51
52
  import "../../../gamification/tabs/index.js";
52
53
  import "../../../gamification/tabs/styles.js";
53
54
  import "./Leaderboard.js";
@@ -47,6 +47,7 @@ import "../../../questions/twitter/account/index.js";
47
47
  import "../../../questions/twitter/account/styles.js";
48
48
  import "../../../questions/twitter/styles.js";
49
49
  import "../../../gamification/vote/twitter-details/styles.js";
50
+ import "lodash.throttle";
50
51
  import "../../../gamification/tabs/index.js";
51
52
  import "../../../gamification/tabs/styles.js";
52
53
  import "./Leaderboard.js";
@@ -86,7 +87,7 @@ const C = () => h, n = /* @__PURE__ */ s(C())({
86
87
  }) => {
87
88
  const i = r + t;
88
89
  return i === 0 ? 0 : Math.round(r / i * 100);
89
- }, Vr = ({
90
+ }, Wr = ({
90
91
  gamification: r,
91
92
  className: t
92
93
  }) => {
@@ -120,5 +121,5 @@ const C = () => h, n = /* @__PURE__ */ s(C())({
120
121
  });
121
122
  };
122
123
  export {
123
- Vr as GamificationOverlay
124
+ Wr as GamificationOverlay
124
125
  };
@@ -1,10 +1,12 @@
1
1
  /// <reference types="react" />
2
+ import { ListProps } from 'react-window';
2
3
  import { LeaderboardItemProps } from '../../gamification/leaderboard/list-item';
3
4
  type LeaderboardListProps = {
4
5
  items: Omit<LeaderboardItemProps, 'openItemDetail'>[];
5
6
  currentUserId?: string;
6
7
  openItemDetail: (id: string) => void;
7
8
  fetchMore: () => void;
9
+ onScroll?: ListProps['onScroll'];
8
10
  };
9
11
  export declare const LeaderboardList: React.FC<LeaderboardListProps>;
10
12
  export {};
@@ -1,38 +1,40 @@
1
1
  import { jsx as o } from "react/jsx-runtime";
2
- import h from "react-virtualized-auto-sizer";
3
- import { FixedSizeList as u } from "react-window";
4
- import f from "react-window-infinite-loader";
5
- import { LeaderboardItem as I } from "./list-item/index.js";
6
- import { ScrollContainer as L } from "./styles.js";
2
+ import u from "react-virtualized-auto-sizer";
3
+ import { FixedSizeList as f } from "react-window";
4
+ import I from "react-window-infinite-loader";
5
+ import { LeaderboardItem as L } from "./list-item/index.js";
6
+ import { ScrollContainer as c } from "./styles.js";
7
7
  import "../../../utils/common.js";
8
8
  import "./list-item/styles.js";
9
9
  import "@linaria/react";
10
10
  import "../../icons/index.js";
11
11
  import "react";
12
- const D = ({
12
+ const F = ({
13
13
  items: r,
14
14
  currentUserId: i,
15
15
  openItemDetail: m,
16
- fetchMore: n
17
- }) => /* @__PURE__ */ o(h, { children: ({ width: p, height: d }) => /* @__PURE__ */ o(
18
- f,
16
+ fetchMore: n,
17
+ onScroll: p
18
+ }) => /* @__PURE__ */ o(u, { children: ({ width: d, height: l }) => /* @__PURE__ */ o(
19
+ I,
19
20
  {
20
21
  isItemLoaded: (e) => e < r.length,
21
22
  itemCount: r.length + 1,
22
23
  loadMoreItems: n,
23
- children: ({ onItemsRendered: e, ref: l }) => /* @__PURE__ */ o(L, { children: /* @__PURE__ */ o(
24
- u,
24
+ children: ({ onItemsRendered: e, ref: a }) => /* @__PURE__ */ o(c, { children: /* @__PURE__ */ o(
25
+ f,
25
26
  {
26
27
  itemSize: 56,
28
+ onScroll: p,
27
29
  onItemsRendered: e,
28
- ref: l,
30
+ ref: a,
29
31
  itemCount: r.length,
30
- width: p,
31
- height: d,
32
- children: ({ index: t, style: a }) => /* @__PURE__ */ o(
33
- I,
32
+ width: d,
33
+ height: l,
34
+ children: ({ index: t, style: h }) => /* @__PURE__ */ o(
35
+ L,
34
36
  {
35
- style: { ...a, maxHeight: 48 },
37
+ style: { ...h, maxHeight: 48 },
36
38
  ...r[t],
37
39
  openItemDetail: () => m(r[t].userId),
38
40
  isCurrentUser: !!i && i === r[t].userId
@@ -44,5 +46,5 @@ const D = ({
44
46
  }
45
47
  ) });
46
48
  export {
47
- D as LeaderboardList
49
+ F as LeaderboardList
48
50
  };
@@ -15,6 +15,7 @@ interface FeedbackProps {
15
15
  votedInCurrentRender: boolean;
16
16
  votedAfterQuestionClosed: boolean;
17
17
  enteredAnActiveQuestion: boolean;
18
+ marketClosed: boolean;
18
19
  }
19
20
  export declare const Feedback: React.FC<FeedbackProps>;
20
21
  export {};
@@ -1,65 +1,66 @@
1
- import { jsxs as r, Fragment as o, jsx as i } from "react/jsx-runtime";
2
- import { QuestionType as t, QuestionStatus as R } from "@streamlayer/sdk-web-types";
1
+ import { jsxs as r, Fragment as t, jsx as i } from "react/jsx-runtime";
2
+ import { QuestionType as n, QuestionStatus as Q } from "@streamlayer/sdk-web-types";
3
3
  import { SvgIcon as l } from "../../../icons/index.js";
4
- import { Container as L, FeedbackIconWrap as h, FeedbackHeader as a, FeedbackDescription as d, FeedbackText as s, IconPrediction as N, FeedbackTitle as Q } from "./styles.js";
4
+ import { Container as f, FeedbackIconWrap as h, FeedbackHeader as p, FeedbackDescription as d, FeedbackText as s, IconPrediction as L, FeedbackTitle as j } from "./styles.js";
5
5
  import "@linaria/react";
6
6
  import "react";
7
- const Y = ({
7
+ const B = ({
8
8
  feedbackMessages: e,
9
- questionVotedCorrectly: P,
10
- questionVoted: m,
11
- questionType: n,
12
- hasCorrectAnswer: u,
13
- questionStatus: E,
14
- showExpiredNotification: I,
9
+ questionVotedCorrectly: I,
10
+ questionVoted: a,
11
+ questionType: c,
12
+ hasCorrectAnswer: F,
13
+ questionStatus: S,
14
+ showExpiredNotification: u,
15
15
  showClosedNotificationTrivia: w,
16
- votedInCurrentRender: p,
17
- votedAfterQuestionClosed: S,
18
- enteredAnActiveQuestion: x
16
+ votedInCurrentRender: m,
17
+ votedAfterQuestionClosed: y,
18
+ enteredAnActiveQuestion: E,
19
+ marketClosed: N
19
20
  }) => {
20
- const T = m && (n === t.TRIVIA || n === t.PREDICTION) && p && E !== R.RESOLVED, b = n === t.PREDICTION && !u, k = E === R.RESOLVED && n === t.PREDICTION && !m && !x || n === t.PREDICTION && S && p && x, D = T && b, O = T && u, y = m && n === t.POLL && p;
21
- if (!I && !w && !D && !O && !k && !y)
21
+ const b = a && (c === n.TRIVIA || c === n.PREDICTION) && m && S !== Q.RESOLVED, x = c === n.PREDICTION && !F, T = N && c === n.PREDICTION && !a && !E || c === n.PREDICTION && y && m && E, k = b && x, D = b && F, O = c === n.PREDICTION && a && m && F, R = a && c === n.POLL && m;
22
+ if (!u && !w && !k && !D && !T && !R && !O)
22
23
  return null;
23
- const F = P ? "correct" : "incorrect", c = P ? e == null ? void 0 : e.correctFeedback : e == null ? void 0 : e.incorrectFeedback;
24
- return /* @__PURE__ */ r(L, { "data-isPrediction": b, children: [
25
- I && /* @__PURE__ */ r(o, { children: [
24
+ const P = I ? "correct" : "incorrect", o = I ? e == null ? void 0 : e.correctFeedback : e == null ? void 0 : e.incorrectFeedback;
25
+ return /* @__PURE__ */ r(f, { "data-isPrediction": x, children: [
26
+ u && /* @__PURE__ */ r(t, { children: [
26
27
  /* @__PURE__ */ i(h, { children: /* @__PURE__ */ i(l, { name: "questionExpired" }) }),
27
28
  /* @__PURE__ */ r("div", { children: [
28
- /* @__PURE__ */ i(a, { children: /* @__PURE__ */ i(d, { children: "Question Expired" }) }),
29
+ /* @__PURE__ */ i(p, { children: /* @__PURE__ */ i(d, { children: "Question Expired" }) }),
29
30
  /* @__PURE__ */ i(s, { children: "You can still answer to see if you're correct, but no points are awarded for expired questions." })
30
31
  ] })
31
32
  ] }),
32
- w && /* @__PURE__ */ r(o, { children: [
33
+ w && /* @__PURE__ */ r(t, { children: [
33
34
  /* @__PURE__ */ i(h, { children: /* @__PURE__ */ i(l, { name: "questionExpired" }) }),
34
35
  /* @__PURE__ */ r("div", { children: [
35
- /* @__PURE__ */ i(a, { children: /* @__PURE__ */ i(d, { children: "Question Closed" }) }),
36
+ /* @__PURE__ */ i(p, { children: /* @__PURE__ */ i(d, { children: "Question Closed" }) }),
36
37
  /* @__PURE__ */ i(s, { children: "This question was answered after the moderator closed the question. So the points for this answer won’t tally." })
37
38
  ] })
38
39
  ] }),
39
- k && /* @__PURE__ */ r(o, { children: [
40
+ T && /* @__PURE__ */ r(t, { children: [
40
41
  /* @__PURE__ */ i(h, { children: /* @__PURE__ */ i(l, { name: "questionExpired" }) }),
41
42
  /* @__PURE__ */ r("div", { children: [
42
- /* @__PURE__ */ i(a, { children: /* @__PURE__ */ i(d, { children: "Question Closed" }) }),
43
+ /* @__PURE__ */ i(p, { children: /* @__PURE__ */ i(d, { children: "Question Closed" }) }),
43
44
  /* @__PURE__ */ i(s, { children: "This event has already taken place, so the ability to make a prediction on its outcome is no longer available." })
44
45
  ] })
45
46
  ] }),
46
- D && /* @__PURE__ */ r(o, { children: [
47
- /* @__PURE__ */ i(N, { name: "icon-prediction" }),
47
+ k && /* @__PURE__ */ r(t, { children: [
48
+ /* @__PURE__ */ i(L, { name: "icon-prediction" }),
48
49
  /* @__PURE__ */ i(d, { children: "Stay tuned to see if your prediction was correct." })
49
50
  ] }),
50
- y && /* @__PURE__ */ r(o, { children: [
51
+ R && /* @__PURE__ */ r(t, { children: [
51
52
  /* @__PURE__ */ i(h, { "data-feedbackType": "correct", children: /* @__PURE__ */ i(l, { name: "correct" }) }),
52
53
  /* @__PURE__ */ i(d, { children: "That's for answering. Please stay tuned for the next question." })
53
54
  ] }),
54
- O && /* @__PURE__ */ r(o, { children: [
55
- /* @__PURE__ */ i(h, { "data-feedbackType": F, children: /* @__PURE__ */ i(l, { name: F }) }),
56
- /* @__PURE__ */ i("div", { children: /* @__PURE__ */ r(a, { children: [
57
- /* @__PURE__ */ i(Q, { "data-feedbackType": F, children: c == null ? void 0 : c.title }),
58
- /* @__PURE__ */ i(d, { children: c == null ? void 0 : c.description })
55
+ (D || O) && /* @__PURE__ */ r(t, { children: [
56
+ /* @__PURE__ */ i(h, { "data-feedbackType": P, children: /* @__PURE__ */ i(l, { name: P }) }),
57
+ /* @__PURE__ */ i("div", { children: /* @__PURE__ */ r(p, { children: [
58
+ /* @__PURE__ */ i(j, { "data-feedbackType": P, children: o == null ? void 0 : o.title }),
59
+ /* @__PURE__ */ i(d, { children: o == null ? void 0 : o.description })
59
60
  ] }) })
60
61
  ] })
61
62
  ] });
62
63
  };
63
64
  export {
64
- Y as Feedback
65
+ B as Feedback
65
66
  };
@@ -1,12 +1,12 @@
1
- import { jsx as c, jsxs as D, Fragment as K } from "react/jsx-runtime";
2
- import { useState as l, useEffect as Y, useCallback as p, useMemo as m } from "react";
3
- import { QuestionStatus as V, QuestionType as o } from "@streamlayer/sdk-web-types";
4
- import { SDKScrollContainer as z } from "../../app/styles.js";
5
- import { ExpiredAlert as G } from "./expired-alert/index.js";
6
- import { Feedback as J } from "./feedback/index.js";
7
- import { Container as U, Content as X, Title as Z, Options as _ } from "./styles.js";
8
- import { VotingOption as $ } from "./vote-option/index.js";
9
- import { WinBar as Q } from "./win-bar/index.js";
1
+ import { jsx as a, jsxs as g, Fragment as Y } from "react/jsx-runtime";
2
+ import { useState as T, useEffect as z, useCallback as A, useMemo as o } from "react";
3
+ import { QuestionType as c, QuestionStatus as w } from "@streamlayer/sdk-web-types";
4
+ import { SDKScrollContainer as G } from "../../app/styles.js";
5
+ import { ExpiredAlert as J } from "./expired-alert/index.js";
6
+ import { Feedback as U } from "./feedback/index.js";
7
+ import { Container as X, Content as Z, Title as _, Options as $ } from "./styles.js";
8
+ import { VotingOption as Q } from "./vote-option/index.js";
9
+ import { WinBar as tt } from "./win-bar/index.js";
10
10
  import "@linaria/react";
11
11
  import "../../icons/index.js";
12
12
  import "./expired-alert/styles.js";
@@ -18,104 +18,106 @@ 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 pt = ({ openedQuestion: t, isLoading: y, vote: v, close: C }) => {
22
- var S, q;
23
- const g = t.subject, T = t.type, a = t.status, E = (S = t.options) == null ? void 0 : S.options, [d, b] = l(!1), [h, N] = l(!1), [n, P] = l(!0), [e, k] = l(!1), [u, x] = l(""), I = t == null ? void 0 : t.id;
24
- Y(() => {
25
- a === V.RESOLVED && P(!1);
21
+ const At = ({ openedQuestion: t, isLoading: I, vote: v, close: p }) => {
22
+ var D, k;
23
+ const N = t.subject, l = t.type, e = t.status, E = (D = t.options) == null ? void 0 : D.options, V = t.marketClosed, [R, P] = T(!1), [y, b] = T(!1), [n, u] = T(!0), [s, L] = T(!1), [x, O] = T(""), d = t == null ? void 0 : t.id;
24
+ z(() => {
25
+ l === c.PREDICTION ? V && u(!1) : e === w.RESOLVED && u(!1);
26
26
  }, []);
27
- const L = p((i) => {
28
- N(i), b(!0);
29
- }, []), R = p(
27
+ const M = A((i) => {
28
+ b(i), P(!0);
29
+ }, []), q = A(
30
30
  async (i) => {
31
- if (I) {
31
+ if (d) {
32
32
  const f = i.currentTarget.value;
33
- x(f), await v(I, f);
33
+ O(f), await v(d, f);
34
34
  }
35
35
  },
36
- [I, x, v]
37
- ), M = p(() => {
38
- k(!0), setTimeout(C, 3e3);
39
- }, [C]), r = m(
36
+ [d, O, v]
37
+ ), j = A(() => {
38
+ L(!0), setTimeout(p, 3e3);
39
+ }, [p]), r = o(
40
40
  () => t == null ? void 0 : t.answers.find((i) => i.youVoted === !0),
41
41
  [t]
42
- ), A = m(
42
+ ), h = o(
43
43
  () => !!(t != null && t.answers.find((i) => i.correct === !0)),
44
44
  [t]
45
- ), w = m(
45
+ ), C = o(
46
46
  () => t == null ? void 0 : t.answers.find((i) => i.correct === !0),
47
47
  [t]
48
- ), j = m(() => t ? t.answers.map((i) => {
48
+ ), B = o(() => t ? t.answers.map((i) => {
49
49
  var f;
50
50
  return {
51
51
  ...i,
52
52
  questionVoted: !!r,
53
- youSelected: u === i.id,
54
- isLoading: y,
55
- hasCorrectAnswer: A,
53
+ youSelected: x === i.id,
54
+ isLoading: I,
55
+ hasCorrectAnswer: h,
56
56
  questionType: t.type,
57
- answerTimeExpired: e,
58
- questionStatus: a,
57
+ answerTimeExpired: s,
58
+ questionStatus: e,
59
59
  imageMode: (f = t.appearance) == null ? void 0 : f.images,
60
- onVote: R
60
+ onVote: q
61
61
  };
62
62
  }) : [], [
63
- A,
64
- e,
65
- y,
63
+ h,
64
+ s,
65
+ I,
66
66
  t,
67
67
  r,
68
- a,
69
- R,
70
- u
71
- ]), B = E && (E.case === "trivia" || E.case === "prediction") ? E.value : void 0, s = a === V.RESOLVED && T === o.TRIVIA && !r && !n, O = T === o.TRIVIA && h && d && n, F = m(() => {
72
- if (!(s || e))
73
- return a === V.RESOLVED ? 0 : r ? r.correct ? r.points : 0 : w == null ? void 0 : w.points;
74
- }, [e, r, w, a, s]), W = m(() => s || e ? "Time expired" : t.type === o.POLL ? "Time remaining" : r ? "You won" : "To win", [e, t.type, r, s]), H = r || s || O || T === o.TRIVIA && a === V.RESOLVED && n;
75
- return /* @__PURE__ */ c(z, { "data-question-header": "true", children: /* @__PURE__ */ c(U, { children: /* @__PURE__ */ D(X, { children: [
76
- /* @__PURE__ */ c(
77
- J,
68
+ e,
69
+ q,
70
+ x
71
+ ]), F = E && (E.case === "trivia" || E.case === "prediction") ? E.value : void 0, m = e === w.RESOLVED && l === c.TRIVIA && !r && !n, S = l === c.TRIVIA && y && R && n, W = o(() => {
72
+ if (!(m || s))
73
+ return e === w.RESOLVED ? 0 : r ? r.correct ? r.points : 0 : C == null ? void 0 : C.points;
74
+ }, [s, r, C, e, m]), H = o(() => m || s ? "Time expired" : t.type === c.POLL ? "Time remaining" : r ? "You won" : "To win", [s, t.type, r, m]), K = r || m || S || l === c.TRIVIA && e === w.RESOLVED && n;
75
+ return /* @__PURE__ */ a(G, { "data-question-header": "true", children: /* @__PURE__ */ a(X, { children: /* @__PURE__ */ g(Z, { children: [
76
+ /* @__PURE__ */ a(
77
+ U,
78
78
  {
79
- feedbackMessages: B,
79
+ feedbackMessages: F,
80
80
  questionVoted: !!r,
81
81
  questionVotedCorrectly: r == null ? void 0 : r.correct,
82
- questionType: T,
83
- hasCorrectAnswer: A,
84
- questionStatus: a,
85
- showExpiredNotification: s,
86
- showClosedNotificationTrivia: O,
87
- votedInCurrentRender: d,
88
- votedAfterQuestionClosed: h,
89
- enteredAnActiveQuestion: n
82
+ questionType: l,
83
+ hasCorrectAnswer: h,
84
+ questionStatus: e,
85
+ showExpiredNotification: m,
86
+ showClosedNotificationTrivia: S,
87
+ votedInCurrentRender: R,
88
+ votedAfterQuestionClosed: y,
89
+ enteredAnActiveQuestion: n,
90
+ marketClosed: V
90
91
  }
91
92
  ),
92
- t.type !== o.PREDICTION && /* @__PURE__ */ c(
93
- Q,
93
+ t.type !== c.PREDICTION && /* @__PURE__ */ a(
94
+ tt,
94
95
  {
95
- title: W,
96
- points: F,
97
- onTimerExpired: M,
96
+ title: H,
97
+ points: W,
98
+ onTimerExpired: j,
98
99
  questionType: t.type,
99
- isTimer: !y,
100
+ isTimer: !I,
100
101
  isPlayingTimer: !r,
101
- timerDuration: H ? 0 : Number(((q = t == null ? void 0 : t.appearance) == null ? void 0 : q.autoHideInterval) || "30")
102
+ timerDuration: K ? 0 : Number(((k = t == null ? void 0 : t.appearance) == null ? void 0 : k.autoHideInterval) || "30")
102
103
  }
103
104
  ),
104
- e ? /* @__PURE__ */ c(
105
- G,
105
+ s ? /* @__PURE__ */ a(
106
+ J,
106
107
  {
107
108
  title: "More to come...",
108
109
  description: "Watch for additional enhanced stream interactive experience."
109
110
  }
110
- ) : /* @__PURE__ */ D(K, { children: [
111
- /* @__PURE__ */ c(Z, { "data-isPrediction": t.type === o.PREDICTION, children: g }),
112
- /* @__PURE__ */ c(_, { children: j.map((i) => /* @__PURE__ */ c(
113
- $,
111
+ ) : /* @__PURE__ */ g(Y, { children: [
112
+ /* @__PURE__ */ a(_, { "data-isPrediction": t.type === c.PREDICTION, children: N }),
113
+ /* @__PURE__ */ a($, { children: B.map((i) => /* @__PURE__ */ a(
114
+ Q,
114
115
  {
115
116
  ...i,
116
- markThatVoted: L,
117
- votedAfterQuestionClosed: h,
118
- enteredAnActiveQuestion: n
117
+ markThatVoted: M,
118
+ votedAfterQuestionClosed: y,
119
+ enteredAnActiveQuestion: n,
120
+ marketClosed: V
119
121
  },
120
122
  i.id
121
123
  )) })
@@ -123,5 +125,5 @@ const pt = ({ openedQuestion: t, isLoading: y, vote: v, close: C }) => {
123
125
  ] }) }) });
124
126
  };
125
127
  export {
126
- pt as Vote
128
+ At as Vote
127
129
  };
@@ -11,6 +11,7 @@ export type VotingOptionProps = ExtendedQuestionAnswer & {
11
11
  questionStatus: QuestionStatus;
12
12
  votedAfterQuestionClosed: boolean;
13
13
  enteredAnActiveQuestion: boolean;
14
+ marketClosed: boolean;
14
15
  onVote: (e: React.MouseEvent<HTMLButtonElement>) => void;
15
16
  markThatVoted: (votedAfterQuestionClosed: boolean) => void;
16
17
  };
@@ -1,76 +1,79 @@
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";
1
+ import { jsx as r, jsxs as m } from "react/jsx-runtime";
2
+ import { QuestionImages as s, QuestionType as i, QuestionStatus as p } from "@streamlayer/sdk-web-types";
3
+ import { AnimatedCounter as L } from "../../../animated-counter/index.js";
4
+ import { IconDefault as Q, IconContainer as v, IconWrap as B, IconCircle as V, ButtonContainer as b, ButtonPct as j, ButtonBody as U, Title as $, Indicators as M, CheckIcon as W, Percentage as y } 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 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 }),
9
+ const I = {
10
+ [s.CENTERED]: (t) => /* @__PURE__ */ r(Q, { alt: "option-icon", src: t }),
11
+ [s.TRANSPARENT]: (t) => /* @__PURE__ */ r(v, { children: /* @__PURE__ */ r(B, { style: { backgroundImage: `url(${t})` } }) }),
12
+ [s.ROUNDED]: (t) => /* @__PURE__ */ r(V, { alt: "option-icon", src: t }),
13
13
  [s.NONE]: () => null,
14
14
  [s.UNSET]: () => null
15
- }, y = ({ questionType: t, hasCorrectAnswer: i, correct: e, youVoted: r, questionVoted: o }) => {
16
- if (t === c.POLL && r)
15
+ }, z = ({ questionType: t, hasCorrectAnswer: c, correct: e, youVoted: n, questionVoted: o }) => {
16
+ if (t === i.POLL && n)
17
17
  return "correct";
18
- if (t === c.PREDICTION) {
19
- if (i && o)
20
- return r ? e ? "correct" : "incorrect" : "unset";
21
- if (r)
18
+ if (t === i.PREDICTION) {
19
+ if (c && o)
20
+ return n ? e ? "correct" : "incorrect" : "unset";
21
+ if (n)
22
22
  return "correct";
23
23
  }
24
- return t === c.TRIVIA && o && r ? e ? "correct" : "incorrect" : "unset";
25
- }, z = ({
24
+ return t === i.TRIVIA && o && n ? e ? "correct" : "incorrect" : "unset";
25
+ }, F = ({
26
26
  questionType: t,
27
- questionVoted: i,
27
+ questionVoted: c,
28
28
  correct: e,
29
- hasCorrectAnswer: r,
29
+ hasCorrectAnswer: n,
30
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;
31
+ }) => t === i.TRIVIA ? c && e : t === i.PREDICTION ? c && e && n || o === p.RESOLVED && e : !1, tt = (t) => {
32
+ var S;
33
33
  const {
34
34
  // option props
35
- id: i,
35
+ id: c,
36
36
  icon: e,
37
- text: r,
37
+ text: n,
38
38
  percentageDecimal: o,
39
39
  // extra props
40
- onVote: p,
40
+ onVote: T,
41
41
  markThatVoted: D,
42
- youSelected: E,
42
+ youSelected: f,
43
43
  questionVoted: a,
44
44
  // ToDo: Figure out why imageMode is not in the response, and delete default value
45
- imageMode: h,
46
- answerTimeExpired: T,
47
- questionStatus: d,
48
- isLoading: g,
49
- questionType: C,
50
- correct: w,
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,
45
+ imageMode: C,
46
+ answerTimeExpired: g,
47
+ questionStatus: h,
48
+ isLoading: w,
49
+ questionType: d,
50
+ correct: A,
51
+ hasCorrectAnswer: O,
52
+ votedAfterQuestionClosed: P,
53
+ enteredAnActiveQuestion: E,
54
+ marketClosed: N
55
+ } = t, l = z(t), k = F({ questionType: d, questionVoted: a, correct: A, hasCorrectAnswer: O, questionStatus: h }), u = N && d === i.PREDICTION, R = a || u;
56
+ return /* @__PURE__ */ m(
57
+ b,
57
58
  {
58
- value: i,
59
- "data-selected": E,
59
+ value: c,
60
+ "data-selected": f,
60
61
  "data-answerState": l,
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);
62
+ disabled: a || w || g || u && !E || u && E && P,
63
+ "data-isNotChecked": a && !f && l !== "incorrect",
64
+ onClick: (x) => {
65
+ D(
66
+ d === i.PREDICTION ? N : h === p.RESOLVED
67
+ ), T(x);
65
68
  },
66
69
  children: [
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: "%" }) })
70
+ /* @__PURE__ */ r(j, { "data-answerState": l, style: { width: `${R ? o : 0}%` } }),
71
+ /* @__PURE__ */ m(U, { children: [
72
+ e && C && ((S = I[C]) == null ? void 0 : S.call(I, e)),
73
+ /* @__PURE__ */ r($, { children: n }),
74
+ R && /* @__PURE__ */ m(M, { children: [
75
+ k && /* @__PURE__ */ r(W, { name: "selected" }),
76
+ /* @__PURE__ */ r(y, { children: /* @__PURE__ */ r(L, { value: o, suffix: "%" }) })
74
77
  ] })
75
78
  ] })
76
79
  ]
@@ -78,5 +81,5 @@ const m = {
78
81
  );
79
82
  };
80
83
  export {
81
- q as VotingOption
84
+ tt as VotingOption
82
85
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamlayer/react-ui",
3
- "version": "0.80.1",
3
+ "version": "0.81.1",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "typings": "./lib/index.d.ts",
@@ -37,19 +37,21 @@
37
37
  "peerDependencies": {
38
38
  "@lottiefiles/react-lottie-player": "*",
39
39
  "@streamlayer/sl-eslib": "^5.53.6",
40
+ "@types/lodash.throttle": "^4.1.9",
41
+ "lodash.throttle": "^4.1.1",
40
42
  "react-virtualized-auto-sizer": "^1.0.20",
41
43
  "react-window": "^1.8.9",
42
44
  "react-window-infinite-loader": "^1.0.9",
43
- "@streamlayer/feature-gamification": "^0.30.0",
45
+ "@streamlayer/feature-gamification": "^0.30.1",
44
46
  "@streamlayer/sdk-web": "^0.29.5",
45
47
  "@streamlayer/sdk-web-anonymous-auth": "^0.11.30",
46
48
  "@streamlayer/sdk-web-api": "^0.1.0",
47
- "@streamlayer/sdk-web-features": "^0.11.0",
48
49
  "@streamlayer/sdk-web-core": "^0.1.0",
49
- "@streamlayer/sdk-web-interfaces": "^0.18.16",
50
- "@streamlayer/sdk-web-notifications": "^0.1.0",
51
- "@streamlayer/sdk-web-storage": "^0.0.4",
50
+ "@streamlayer/sdk-web-features": "^0.11.1",
51
+ "@streamlayer/sdk-web-interfaces": "^0.18.17",
52
52
  "@streamlayer/sdk-web-logger": "^0.0.1",
53
+ "@streamlayer/sdk-web-notifications": "^0.0.1",
54
+ "@streamlayer/sdk-web-storage": "^0.0.4",
53
55
  "@streamlayer/sdk-web-types": "^0.1.0"
54
56
  },
55
57
  "nx": {
@@ -90,6 +92,6 @@
90
92
  "vite-plugin-svgr": "^4.1.0",
91
93
  "vite-svg-loader": "^4.0.0",
92
94
  "vite-tsconfig-paths": "^4.2.1",
93
- "@streamlayer/react": "^0.32.11"
95
+ "@streamlayer/react": "^0.33.1"
94
96
  }
95
97
  }