@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.
- package/lib/ui/app/Features/Gamification/Leaderboard.d.ts +1 -0
- package/lib/ui/app/Features/Gamification/Leaderboard.js +18 -11
- package/lib/ui/app/Features/Gamification/Tabs.js +65 -37
- package/lib/ui/app/Features/Gamification/gamification-feature.js +1 -0
- package/lib/ui/app/Features/Gamification/index.js +3 -2
- package/lib/ui/gamification/leaderboard/index.d.ts +2 -0
- package/lib/ui/gamification/leaderboard/index.js +20 -18
- package/lib/ui/gamification/vote/feedback/index.d.ts +1 -0
- package/lib/ui/gamification/vote/feedback/index.js +33 -32
- package/lib/ui/gamification/vote/index.js +73 -71
- package/lib/ui/gamification/vote/vote-option/index.d.ts +1 -0
- package/lib/ui/gamification/vote/vote-option/index.js +53 -50
- package/package.json +9 -7
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useStore as
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
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
|
|
18
|
-
const { data: e } =
|
|
19
|
-
|
|
20
|
-
|
|
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__ */
|
|
34
|
+
) : /* @__PURE__ */ l(d, { deepLink: r.deepLink });
|
|
28
35
|
};
|
|
29
36
|
export {
|
|
30
|
-
|
|
37
|
+
F as Leaderboard
|
|
31
38
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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
|
|
50
|
-
gamification:
|
|
50
|
+
const Lr = ({
|
|
51
|
+
gamification: i
|
|
51
52
|
}) => {
|
|
52
|
-
const [o,
|
|
53
|
-
|
|
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__ */
|
|
61
|
-
|
|
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
|
-
|
|
100
|
+
paddingTop: "12px"
|
|
64
101
|
},
|
|
65
|
-
children: /* @__PURE__ */
|
|
66
|
-
|
|
67
|
-
toggleActivePage: e
|
|
102
|
+
children: /* @__PURE__ */ t(w, {
|
|
103
|
+
userSummary: i.userSummary
|
|
68
104
|
})
|
|
69
|
-
}),
|
|
70
|
-
children:
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
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
|
-
},
|
|
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
|
-
|
|
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
|
|
3
|
-
import { FixedSizeList as
|
|
4
|
-
import
|
|
5
|
-
import { LeaderboardItem as
|
|
6
|
-
import { ScrollContainer as
|
|
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
|
|
12
|
+
const F = ({
|
|
13
13
|
items: r,
|
|
14
14
|
currentUserId: i,
|
|
15
15
|
openItemDetail: m,
|
|
16
|
-
fetchMore: n
|
|
17
|
-
|
|
18
|
-
|
|
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:
|
|
24
|
-
|
|
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:
|
|
30
|
+
ref: a,
|
|
29
31
|
itemCount: r.length,
|
|
30
|
-
width:
|
|
31
|
-
height:
|
|
32
|
-
children: ({ index: t, style:
|
|
33
|
-
|
|
32
|
+
width: d,
|
|
33
|
+
height: l,
|
|
34
|
+
children: ({ index: t, style: h }) => /* @__PURE__ */ o(
|
|
35
|
+
L,
|
|
34
36
|
{
|
|
35
|
-
style: { ...
|
|
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
|
-
|
|
49
|
+
F as LeaderboardList
|
|
48
50
|
};
|
|
@@ -1,65 +1,66 @@
|
|
|
1
|
-
import { jsxs as r, Fragment as
|
|
2
|
-
import { QuestionType as
|
|
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
|
|
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
|
|
7
|
+
const B = ({
|
|
8
8
|
feedbackMessages: e,
|
|
9
|
-
questionVotedCorrectly:
|
|
10
|
-
questionVoted:
|
|
11
|
-
questionType:
|
|
12
|
-
hasCorrectAnswer:
|
|
13
|
-
questionStatus:
|
|
14
|
-
showExpiredNotification:
|
|
9
|
+
questionVotedCorrectly: I,
|
|
10
|
+
questionVoted: a,
|
|
11
|
+
questionType: c,
|
|
12
|
+
hasCorrectAnswer: F,
|
|
13
|
+
questionStatus: S,
|
|
14
|
+
showExpiredNotification: u,
|
|
15
15
|
showClosedNotificationTrivia: w,
|
|
16
|
-
votedInCurrentRender:
|
|
17
|
-
votedAfterQuestionClosed:
|
|
18
|
-
enteredAnActiveQuestion:
|
|
16
|
+
votedInCurrentRender: m,
|
|
17
|
+
votedAfterQuestionClosed: y,
|
|
18
|
+
enteredAnActiveQuestion: E,
|
|
19
|
+
marketClosed: N
|
|
19
20
|
}) => {
|
|
20
|
-
const
|
|
21
|
-
if (!
|
|
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
|
|
24
|
-
return /* @__PURE__ */ r(
|
|
25
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
47
|
-
/* @__PURE__ */ i(
|
|
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
|
-
|
|
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(
|
|
55
|
-
/* @__PURE__ */ i(h, { "data-feedbackType":
|
|
56
|
-
/* @__PURE__ */ i("div", { children: /* @__PURE__ */ r(
|
|
57
|
-
/* @__PURE__ */ i(
|
|
58
|
-
/* @__PURE__ */ i(d, { children:
|
|
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
|
-
|
|
65
|
+
B as Feedback
|
|
65
66
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import {
|
|
4
|
-
import { SDKScrollContainer as
|
|
5
|
-
import { ExpiredAlert as
|
|
6
|
-
import { Feedback as
|
|
7
|
-
import { Container as
|
|
8
|
-
import { VotingOption as
|
|
9
|
-
import { WinBar as
|
|
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
|
|
22
|
-
var
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
28
|
-
|
|
29
|
-
}, []),
|
|
27
|
+
const M = A((i) => {
|
|
28
|
+
b(i), P(!0);
|
|
29
|
+
}, []), q = A(
|
|
30
30
|
async (i) => {
|
|
31
|
-
if (
|
|
31
|
+
if (d) {
|
|
32
32
|
const f = i.currentTarget.value;
|
|
33
|
-
|
|
33
|
+
O(f), await v(d, f);
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
|
-
[
|
|
37
|
-
),
|
|
38
|
-
|
|
39
|
-
}, [
|
|
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
|
-
),
|
|
42
|
+
), h = o(
|
|
43
43
|
() => !!(t != null && t.answers.find((i) => i.correct === !0)),
|
|
44
44
|
[t]
|
|
45
|
-
),
|
|
45
|
+
), C = o(
|
|
46
46
|
() => t == null ? void 0 : t.answers.find((i) => i.correct === !0),
|
|
47
47
|
[t]
|
|
48
|
-
),
|
|
48
|
+
), B = o(() => t ? t.answers.map((i) => {
|
|
49
49
|
var f;
|
|
50
50
|
return {
|
|
51
51
|
...i,
|
|
52
52
|
questionVoted: !!r,
|
|
53
|
-
youSelected:
|
|
54
|
-
isLoading:
|
|
55
|
-
hasCorrectAnswer:
|
|
53
|
+
youSelected: x === i.id,
|
|
54
|
+
isLoading: I,
|
|
55
|
+
hasCorrectAnswer: h,
|
|
56
56
|
questionType: t.type,
|
|
57
|
-
answerTimeExpired:
|
|
58
|
-
questionStatus:
|
|
57
|
+
answerTimeExpired: s,
|
|
58
|
+
questionStatus: e,
|
|
59
59
|
imageMode: (f = t.appearance) == null ? void 0 : f.images,
|
|
60
|
-
onVote:
|
|
60
|
+
onVote: q
|
|
61
61
|
};
|
|
62
62
|
}) : [], [
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
h,
|
|
64
|
+
s,
|
|
65
|
+
I,
|
|
66
66
|
t,
|
|
67
67
|
r,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
]),
|
|
72
|
-
if (!(
|
|
73
|
-
return
|
|
74
|
-
}, [
|
|
75
|
-
return /* @__PURE__ */
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
|
|
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:
|
|
79
|
+
feedbackMessages: F,
|
|
80
80
|
questionVoted: !!r,
|
|
81
81
|
questionVotedCorrectly: r == null ? void 0 : r.correct,
|
|
82
|
-
questionType:
|
|
83
|
-
hasCorrectAnswer:
|
|
84
|
-
questionStatus:
|
|
85
|
-
showExpiredNotification:
|
|
86
|
-
showClosedNotificationTrivia:
|
|
87
|
-
votedInCurrentRender:
|
|
88
|
-
votedAfterQuestionClosed:
|
|
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 !==
|
|
93
|
-
|
|
93
|
+
t.type !== c.PREDICTION && /* @__PURE__ */ a(
|
|
94
|
+
tt,
|
|
94
95
|
{
|
|
95
|
-
title:
|
|
96
|
-
points:
|
|
97
|
-
onTimerExpired:
|
|
96
|
+
title: H,
|
|
97
|
+
points: W,
|
|
98
|
+
onTimerExpired: j,
|
|
98
99
|
questionType: t.type,
|
|
99
|
-
isTimer: !
|
|
100
|
+
isTimer: !I,
|
|
100
101
|
isPlayingTimer: !r,
|
|
101
|
-
timerDuration:
|
|
102
|
+
timerDuration: K ? 0 : Number(((k = t == null ? void 0 : t.appearance) == null ? void 0 : k.autoHideInterval) || "30")
|
|
102
103
|
}
|
|
103
104
|
),
|
|
104
|
-
|
|
105
|
-
|
|
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__ */
|
|
111
|
-
/* @__PURE__ */
|
|
112
|
-
/* @__PURE__ */
|
|
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:
|
|
117
|
-
votedAfterQuestionClosed:
|
|
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
|
-
|
|
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
|
|
2
|
-
import { QuestionImages as s,
|
|
3
|
-
import { AnimatedCounter as
|
|
4
|
-
import { IconDefault as
|
|
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
|
|
10
|
-
[s.CENTERED]: (t) => /* @__PURE__ */
|
|
11
|
-
[s.TRANSPARENT]: (t) => /* @__PURE__ */
|
|
12
|
-
[s.ROUNDED]: (t) => /* @__PURE__ */
|
|
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
|
-
},
|
|
16
|
-
if (t ===
|
|
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 ===
|
|
19
|
-
if (
|
|
20
|
-
return
|
|
21
|
-
if (
|
|
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 ===
|
|
25
|
-
},
|
|
24
|
+
return t === i.TRIVIA && o && n ? e ? "correct" : "incorrect" : "unset";
|
|
25
|
+
}, F = ({
|
|
26
26
|
questionType: t,
|
|
27
|
-
questionVoted:
|
|
27
|
+
questionVoted: c,
|
|
28
28
|
correct: e,
|
|
29
|
-
hasCorrectAnswer:
|
|
29
|
+
hasCorrectAnswer: n,
|
|
30
30
|
questionStatus: o
|
|
31
|
-
}) => t ===
|
|
32
|
-
var
|
|
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:
|
|
35
|
+
id: c,
|
|
36
36
|
icon: e,
|
|
37
|
-
text:
|
|
37
|
+
text: n,
|
|
38
38
|
percentageDecimal: o,
|
|
39
39
|
// extra props
|
|
40
|
-
onVote:
|
|
40
|
+
onVote: T,
|
|
41
41
|
markThatVoted: D,
|
|
42
|
-
youSelected:
|
|
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:
|
|
46
|
-
answerTimeExpired:
|
|
47
|
-
questionStatus:
|
|
48
|
-
isLoading:
|
|
49
|
-
questionType:
|
|
50
|
-
correct:
|
|
51
|
-
hasCorrectAnswer:
|
|
52
|
-
votedAfterQuestionClosed:
|
|
53
|
-
enteredAnActiveQuestion:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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:
|
|
59
|
-
"data-selected":
|
|
59
|
+
value: c,
|
|
60
|
+
"data-selected": f,
|
|
60
61
|
"data-answerState": l,
|
|
61
|
-
disabled: a ||
|
|
62
|
-
"data-isNotChecked": a && !
|
|
63
|
-
onClick: (
|
|
64
|
-
D(
|
|
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__ */
|
|
68
|
-
/* @__PURE__ */
|
|
69
|
-
e &&
|
|
70
|
-
/* @__PURE__ */
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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-
|
|
50
|
-
"@streamlayer/sdk-web-
|
|
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.
|
|
95
|
+
"@streamlayer/react": "^0.33.1"
|
|
94
96
|
}
|
|
95
97
|
}
|