@100mslive/roomkit-react 0.2.2-alpha.5 → 0.2.2-alpha.6
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{HLSView-HMMJY2KC.js → HLSView-U346BIZQ.js} +2 -2
- package/dist/Prebuilt/components/Chat/ChatActions.d.ts +1 -1
- package/dist/{chunk-YOFFMNAR.js → chunk-DY3FWEXJ.js} +257 -230
- package/dist/{chunk-YOFFMNAR.js.map → chunk-DY3FWEXJ.js.map} +3 -3
- package/dist/index.cjs.js +485 -457
- package/dist/index.cjs.js.map +3 -3
- package/dist/index.js +1 -1
- package/dist/meta.cjs.json +34 -24
- package/dist/meta.esbuild.json +40 -30
- package/package.json +6 -6
- package/src/Prebuilt/common/utils.js +13 -0
- package/src/Prebuilt/components/Chat/ChatActions.tsx +3 -3
- package/src/Prebuilt/components/Chat/ChatBody.tsx +9 -5
- package/src/Prebuilt/components/Polls/Voting/LeaderboardEntry.tsx +1 -1
- package/src/Prebuilt/components/Polls/Voting/PeerParticipationSummary.tsx +1 -1
- package/src/Prebuilt/components/Polls/Voting/QuestionCard.jsx +2 -8
- package/src/Prebuilt/components/Polls/Voting/StatisticBox.tsx +1 -1
- package/src/Prebuilt/components/Polls/Voting/TimedVoting.tsx +31 -20
- package/src/Prebuilt/components/Polls/Voting/Voting.tsx +7 -8
- package/src/Prebuilt/components/Polls/common/MultipleChoiceOptions.jsx +2 -2
- package/src/Prebuilt/components/Polls/common/SingleChoiceOptions.jsx +4 -5
- /package/dist/{HLSView-HMMJY2KC.js.map → HLSView-U346BIZQ.js.map} +0 -0
@@ -1,33 +1,44 @@
|
|
1
1
|
import React, { useState } from 'react';
|
2
|
-
import { HMSPoll } from '@100mslive/react-sdk';
|
2
|
+
import { HMSPoll, selectLocalPeerID, useHMSStore } from '@100mslive/react-sdk';
|
3
3
|
// @ts-ignore
|
4
4
|
import { QuestionCard } from './QuestionCard';
|
5
|
+
// @ts-ignore
|
6
|
+
import { getLastAttemptedIndex } from '../../../common/utils';
|
5
7
|
|
6
8
|
export const TimedView = ({ poll }: { poll: HMSPoll }) => {
|
7
|
-
|
8
|
-
const
|
9
|
+
const localPeerId = useHMSStore(selectLocalPeerID);
|
10
|
+
const lastAttemptedIndex = getLastAttemptedIndex(poll.questions, localPeerId, '');
|
11
|
+
const [currentIndex, setCurrentIndex] = useState(lastAttemptedIndex);
|
9
12
|
const activeQuestion = poll.questions?.find(question => question.index === currentIndex);
|
13
|
+
const attemptedAll = poll.questions?.length === lastAttemptedIndex - 1;
|
10
14
|
|
11
|
-
if (!activeQuestion) {
|
15
|
+
if (!activeQuestion || !poll.questions?.length) {
|
12
16
|
return null;
|
13
17
|
}
|
14
18
|
|
15
19
|
return (
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
20
|
+
<>
|
21
|
+
{poll.questions.map(question => {
|
22
|
+
return attemptedAll || activeQuestion.index === question.index ? (
|
23
|
+
<QuestionCard
|
24
|
+
key={question.index}
|
25
|
+
pollID={poll.id}
|
26
|
+
isQuiz={poll.type === 'quiz'}
|
27
|
+
startedBy={poll.startedBy}
|
28
|
+
pollState={poll.state}
|
29
|
+
index={question.index}
|
30
|
+
text={question.text}
|
31
|
+
type={question.type}
|
32
|
+
result={question?.result}
|
33
|
+
totalQuestions={poll.questions?.length || 0}
|
34
|
+
options={question.options}
|
35
|
+
responses={question.responses}
|
36
|
+
answer={question.answer}
|
37
|
+
setCurrentIndex={setCurrentIndex}
|
38
|
+
rolesThatCanViewResponses={poll.rolesThatCanViewResponses}
|
39
|
+
/>
|
40
|
+
) : null;
|
41
|
+
})}
|
42
|
+
</>
|
32
43
|
);
|
33
44
|
};
|
@@ -68,7 +68,7 @@ export const Voting = ({ id, toggleVoting }: { id: string; toggleVoting: () => v
|
|
68
68
|
</Box>
|
69
69
|
</Flex>
|
70
70
|
|
71
|
-
<Flex direction="column" css={{ p: '$8 $10', overflowY: 'auto' }}>
|
71
|
+
<Flex direction="column" css={{ p: '$8 $10', flex: '1 1 0', overflowY: 'auto' }}>
|
72
72
|
{poll.state === 'started' ? (
|
73
73
|
<Text css={{ color: '$on_surface_medium', fontWeight: '$semiBold' }}>
|
74
74
|
{pollCreatorName || 'Participant'} started a {poll.type}
|
@@ -76,22 +76,21 @@ export const Voting = ({ id, toggleVoting }: { id: string; toggleVoting: () => v
|
|
76
76
|
) : null}
|
77
77
|
|
78
78
|
{showSingleView ? <TimedView poll={poll} /> : <StandardView poll={poll} />}
|
79
|
-
|
79
|
+
</Flex>
|
80
|
+
<Flex
|
81
|
+
css={{ w: '100%', justifyContent: 'end', alignItems: 'center', p: '$8', borderTop: '1px solid $border_bright' }}
|
82
|
+
>
|
80
83
|
{poll.state === 'started' && canEndActivity && (
|
81
84
|
<Button
|
82
85
|
variant="danger"
|
83
|
-
css={{ fontWeight: '$semiBold', w: 'max-content'
|
86
|
+
css={{ fontWeight: '$semiBold', w: 'max-content' }}
|
84
87
|
onClick={() => actions.interactivityCenter.stopPoll(id)}
|
85
88
|
>
|
86
89
|
End {poll.type}
|
87
90
|
</Button>
|
88
91
|
)}
|
89
|
-
|
90
92
|
{canViewLeaderboard ? (
|
91
|
-
<Button
|
92
|
-
css={{ fontWeight: '$semiBold', w: 'max-content', ml: 'auto', mt: '$8' }}
|
93
|
-
onClick={() => setPollView(POLL_VIEWS.RESULTS)}
|
94
|
-
>
|
93
|
+
<Button css={{ fontWeight: '$semiBold', w: 'max-content' }} onClick={() => setPollView(POLL_VIEWS.RESULTS)}>
|
95
94
|
View Leaderboard
|
96
95
|
</Button>
|
97
96
|
) : null}
|
@@ -52,7 +52,7 @@ export const MultipleChoiceOptions = ({
|
|
52
52
|
|
53
53
|
{isStopped && correctOptionIndexes?.includes(option.index) ? (
|
54
54
|
<Flex css={{ color: '$on_surface_high' }}>
|
55
|
-
<CheckCircleIcon />
|
55
|
+
<CheckCircleIcon height={20} width={20} />
|
56
56
|
</Flex>
|
57
57
|
) : null}
|
58
58
|
|
@@ -83,7 +83,7 @@ export const MultipleChoiceOptionInputs = ({ isQuiz, options, selectAnswer, hand
|
|
83
83
|
<Flex direction="column" css={{ gap: '$md', w: '100%', mb: '$md' }}>
|
84
84
|
{options.map((option, index) => {
|
85
85
|
return (
|
86
|
-
<Flex align="center" key={index} css={{ w: '100%', gap: '$
|
86
|
+
<Flex align="center" key={index} css={{ w: '100%', gap: '$4' }}>
|
87
87
|
{isQuiz && (
|
88
88
|
<Checkbox.Root
|
89
89
|
onCheckedChange={checked => selectAnswer(checked, index)}
|
@@ -17,14 +17,13 @@ export const SingleChoiceOptions = ({
|
|
17
17
|
isStopped,
|
18
18
|
isQuiz,
|
19
19
|
localPeerResponse,
|
20
|
-
answer,
|
21
20
|
}) => {
|
22
21
|
return (
|
23
|
-
<RadioGroup.Root value={
|
22
|
+
<RadioGroup.Root value={localPeerResponse?.option} onValueChange={value => setAnswer(value)}>
|
24
23
|
<Flex direction="column" css={{ gap: '$md', w: '100%', mb: '$md' }}>
|
25
24
|
{options.map(option => {
|
26
25
|
return (
|
27
|
-
<Flex align="start" key={`${questionIndex}-${option.index}`} css={{ w: '100%', gap: '$
|
26
|
+
<Flex align="start" key={`${questionIndex}-${option.index}`} css={{ w: '100%', gap: '$4' }}>
|
28
27
|
{!isStopped || !isQuiz ? (
|
29
28
|
<RadioGroup.Item
|
30
29
|
css={{
|
@@ -59,7 +58,7 @@ export const SingleChoiceOptions = ({
|
|
59
58
|
|
60
59
|
{isStopped && correctOptionIndex === option.index && isQuiz ? (
|
61
60
|
<Flex css={{ color: '$on_surface_high' }}>
|
62
|
-
<CheckCircleIcon />
|
61
|
+
<CheckCircleIcon height={20} width={20} />
|
63
62
|
</Flex>
|
64
63
|
) : null}
|
65
64
|
|
@@ -95,7 +94,7 @@ export const SingleChoiceOptionInputs = ({ isQuiz, options, selectAnswer, handle
|
|
95
94
|
<Flex direction="column" css={{ gap: '$md', w: '100%', mb: '$md' }}>
|
96
95
|
{options.map((option, index) => {
|
97
96
|
return (
|
98
|
-
<Flex align="center" key={`option-${index}`} css={{ w: '100%', gap: '$
|
97
|
+
<Flex align="center" key={`option-${index}`} css={{ w: '100%', gap: '$4' }}>
|
99
98
|
{isQuiz && (
|
100
99
|
<RadioGroup.Item
|
101
100
|
css={{
|
File without changes
|