@100mslive/roomkit-react 0.3.22-alpha.3 → 0.3.22-alpha.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Accordion/Accordion.d.ts +322 -134
- package/dist/Accordion/index.d.ts +322 -134
- package/dist/Avatar/Avatar.d.ts +141 -47
- package/dist/Button/Button.d.ts +141 -47
- package/dist/Checkbox/Checkbox.d.ts +322 -134
- package/dist/Collapsible/Collapsible.d.ts +483 -201
- package/dist/Divider/Divider.d.ts +322 -134
- package/dist/Dropdown/Dropdown.d.ts +1932 -804
- package/dist/Fieldset/Fieldset.d.ts +141 -47
- package/dist/Footer/Footer.d.ts +1288 -536
- package/dist/{HLSView-EYGGK6BH.js → HLSView-CSOBLYBP.js} +24 -38
- package/dist/HLSView-CSOBLYBP.js.map +7 -0
- package/dist/{PDFView-RMR33QH4.css → HLSView-QZMIDGI4.css} +3 -3
- package/dist/{LeaveScreen-ZAG5UJZL.css.map → HLSView-QZMIDGI4.css.map} +1 -1
- package/dist/IconButton/IconButton.d.ts +141 -47
- package/dist/Input/Input.d.ts +926 -362
- package/dist/Label/Label.d.ts +141 -47
- package/dist/Layout/Box.d.ts +141 -47
- package/dist/Layout/Flex.d.ts +141 -47
- package/dist/Link/Link.d.ts +141 -47
- package/dist/Modal/Dialog.d.ts +987 -329
- package/dist/Modal/DialogContent.d.ts +1127 -469
- package/dist/Pagination/StyledPagination.d.ts +644 -268
- package/dist/Popover/index.d.ts +483 -201
- package/dist/Prebuilt/IconButton.d.ts +322 -134
- package/dist/Prebuilt/components/Chat/ChatBody.d.ts +322 -134
- package/dist/Prebuilt/components/Leave/LeaveAtoms.d.ts +805 -335
- package/dist/Prebuilt/components/Settings/common.d.ts +322 -134
- package/dist/Progress/index.d.ts +322 -134
- package/dist/RadioGroup/RadioGroup.d.ts +483 -201
- package/dist/ReactSelect/ReactSelect.d.ts +1610 -670
- package/dist/Select/Select.d.ts +483 -201
- package/dist/Sheet/Sheet.d.ts +987 -329
- package/dist/Slider/Slider.d.ts +141 -47
- package/dist/Stats/StyledStats.d.ts +966 -402
- package/dist/Switch/Switch.d.ts +141 -47
- package/dist/Tabs/Tabs.d.ts +644 -268
- package/dist/Text/Text.d.ts +141 -47
- package/dist/TextArea/TextArea.d.ts +141 -47
- package/dist/Theme/base.config.d.ts +78 -26
- package/dist/Theme/stitches.config.d.ts +1514 -1067
- package/dist/TileMenu/StyledMenuTile.d.ts +1127 -469
- package/dist/Toast/Toast.d.ts +946 -382
- package/dist/Video/Video.d.ts +141 -47
- package/dist/VideoList/StyledVideoList.d.ts +483 -201
- package/dist/VideoTile/StyledVideoTile.d.ts +1610 -670
- package/dist/chunk-4VBHLZDR.js +34747 -0
- package/dist/chunk-4VBHLZDR.js.map +7 -0
- package/dist/index.cjs.css +2 -2
- package/dist/index.cjs.css.map +1 -1
- package/dist/index.cjs.js +22358 -22561
- package/dist/index.cjs.js.map +4 -4
- package/dist/index.css +2 -2
- package/dist/index.css.map +1 -1
- package/dist/index.js +15 -25
- package/dist/meta.cjs.json +5299 -5657
- package/dist/meta.esbuild.json +6290 -9146
- package/package.json +8 -8
- package/src/Avatar/Avatar.tsx +1 -1
- package/src/Popover/Popover.stories.tsx +1 -1
- package/src/Prebuilt/App.tsx +2 -6
- package/src/Prebuilt/components/Chat/Chat.tsx +8 -12
- package/src/Prebuilt/components/Chat/ChatFooter.tsx +1 -1
- package/src/Prebuilt/components/Notifications/Notifications.tsx +159 -13
- package/src/Prebuilt/components/Notifications/PeerNotifications.tsx +2 -9
- package/src/Prebuilt/components/Notifications/ReconnectNotifications.tsx +5 -1
- package/src/Prebuilt/components/Notifications/TrackBulkUnmuteModal.tsx +5 -7
- package/src/Prebuilt/components/Notifications/TrackNotifications.tsx +1 -23
- package/src/Prebuilt/components/Notifications/TrackUnmuteModal.tsx +5 -13
- package/src/Prebuilt/components/StatsForNerds.jsx +3 -32
- package/src/Prebuilt/components/VideoLayouts/GridLayout.tsx +31 -43
- package/src/Prebuilt/components/VideoLayouts/ProminenceLayout.tsx +2 -2
- package/src/Prebuilt/components/VirtualBackground/VBOption.tsx +1 -3
- package/src/Prebuilt/components/VirtualBackground/VBPicker.tsx +0 -6
- package/src/Prebuilt/layouts/HLSView.jsx +0 -1
- package/src/Prebuilt/layouts/PDFView.jsx +0 -1
- package/src/Prebuilt/layouts/SidePane.tsx +6 -12
- package/src/Prebuilt/layouts/VideoStreamingSection.tsx +34 -35
- package/dist/ConferenceScreen-CSVWECB5.js +0 -1778
- package/dist/ConferenceScreen-CSVWECB5.js.map +0 -7
- package/dist/ConferenceScreen-YRURU3RV.css +0 -2780
- package/dist/ConferenceScreen-YRURU3RV.css.map +0 -7
- package/dist/EmbedView-N2E4DZQA.js +0 -17
- package/dist/EmbedView-N2E4DZQA.js.map +0 -7
- package/dist/EmbedView-S54NTHF5.css +0 -2780
- package/dist/EmbedView-S54NTHF5.css.map +0 -7
- package/dist/EmojiReaction-3X4ST4AU.js +0 -11
- package/dist/EmojiReaction-3X4ST4AU.js.map +0 -7
- package/dist/HLSView-EYGGK6BH.js.map +0 -7
- package/dist/HLSView-LBTFLMI4.css +0 -2780
- package/dist/HLSView-LBTFLMI4.css.map +0 -7
- package/dist/LeaveScreen-D6XU64JL.js +0 -556
- package/dist/LeaveScreen-D6XU64JL.js.map +0 -7
- package/dist/LeaveScreen-ZAG5UJZL.css +0 -2780
- package/dist/MoreSettings-R7B4BSNT.css +0 -2780
- package/dist/MoreSettings-R7B4BSNT.css.map +0 -7
- package/dist/MoreSettings-TBJVM7OY.js +0 -16
- package/dist/MoreSettings-TBJVM7OY.js.map +0 -7
- package/dist/PDFView-JOIJDP65.js +0 -84
- package/dist/PDFView-JOIJDP65.js.map +0 -7
- package/dist/PDFView-RMR33QH4.css.map +0 -7
- package/dist/Polls-IN3V2HFI.js +0 -1584
- package/dist/Polls-IN3V2HFI.js.map +0 -7
- package/dist/Polls-JW7JWGTE.css +0 -2780
- package/dist/Polls-JW7JWGTE.css.map +0 -7
- package/dist/Prebuilt/components/Notifications/DeviceChangeNotifications.d.ts +0 -1
- package/dist/Prebuilt/components/Notifications/ErrorNotifications.d.ts +0 -1
- package/dist/Prebuilt/components/Notifications/MessageNotifications.d.ts +0 -1
- package/dist/Prebuilt/components/Notifications/PollNotificationModal.d.ts +0 -1
- package/dist/Prebuilt/components/Notifications/RoleChangeNotification.d.ts +0 -1
- package/dist/RaiseHand-WES4KKMD.js +0 -10
- package/dist/RaiseHand-WES4KKMD.js.map +0 -7
- package/dist/RoleProminence-4ZBDBCMU.css +0 -2780
- package/dist/RoleProminence-4ZBDBCMU.css.map +0 -7
- package/dist/RoleProminence-PB32DLIB.js +0 -116
- package/dist/RoleProminence-PB32DLIB.js.map +0 -7
- package/dist/RoomDetailsPane-CZH2SNLE.js +0 -53
- package/dist/RoomDetailsPane-CZH2SNLE.js.map +0 -7
- package/dist/RoomDetailsPane-XWH2KEFI.css +0 -2780
- package/dist/RoomDetailsPane-XWH2KEFI.css.map +0 -7
- package/dist/ScreenshareLayout-XVENPVK3.js +0 -358
- package/dist/ScreenshareLayout-XVENPVK3.js.map +0 -7
- package/dist/ScreenshareLayout-YUW3KHAB.css +0 -2780
- package/dist/ScreenshareLayout-YUW3KHAB.css.map +0 -7
- package/dist/SidePaneTabs-QXCDHOGG.js +0 -1354
- package/dist/SidePaneTabs-QXCDHOGG.js.map +0 -7
- package/dist/SidePaneTabs-WQGVOWRP.css +0 -2780
- package/dist/SidePaneTabs-WQGVOWRP.css.map +0 -7
- package/dist/VBPicker-XN74N67R.js +0 -322
- package/dist/VBPicker-XN74N67R.js.map +0 -7
- package/dist/VBPicker-YDM2YIOM.css +0 -2780
- package/dist/VBPicker-YDM2YIOM.css.map +0 -7
- package/dist/WaitingView-77PRTIBV.js +0 -10
- package/dist/WaitingView-77PRTIBV.js.map +0 -7
- package/dist/WhiteboardLayout-FZC7SOSG.js +0 -96
- package/dist/WhiteboardLayout-FZC7SOSG.js.map +0 -7
- package/dist/WhiteboardLayout-MNTUWEVK.css +0 -2780
- package/dist/WhiteboardLayout-MNTUWEVK.css.map +0 -7
- package/dist/android-perm-1.png +0 -0
- package/dist/audio-level.png +0 -0
- package/dist/chunk-26D5FDBW.js +0 -16812
- package/dist/chunk-26D5FDBW.js.map +0 -7
- package/dist/chunk-2J5WS52X.js +0 -2595
- package/dist/chunk-2J5WS52X.js.map +0 -7
- package/dist/chunk-2LWOQMYY.js +0 -30
- package/dist/chunk-2LWOQMYY.js.map +0 -7
- package/dist/chunk-3MRQJSIY.js +0 -171
- package/dist/chunk-3MRQJSIY.js.map +0 -7
- package/dist/chunk-4X4WB7X3.js +0 -98
- package/dist/chunk-4X4WB7X3.js.map +0 -7
- package/dist/chunk-7QZJMUHM.js +0 -90
- package/dist/chunk-7QZJMUHM.js.map +0 -7
- package/dist/chunk-ABCV7TX5.js +0 -71
- package/dist/chunk-ABCV7TX5.js.map +0 -7
- package/dist/chunk-BQOT4DK7.js +0 -418
- package/dist/chunk-BQOT4DK7.js.map +0 -7
- package/dist/chunk-ENHSO6YN.js +0 -6337
- package/dist/chunk-ENHSO6YN.js.map +0 -7
- package/dist/chunk-JKWX7W4K.js +0 -161
- package/dist/chunk-JKWX7W4K.js.map +0 -7
- package/dist/chunk-LO4BXA4G.js +0 -114
- package/dist/chunk-LO4BXA4G.js.map +0 -7
- package/dist/chunk-MRVWNFXC.js +0 -59
- package/dist/chunk-MRVWNFXC.js.map +0 -7
- package/dist/chunk-OA4HW7HW.js +0 -262
- package/dist/chunk-OA4HW7HW.js.map +0 -7
- package/dist/chunk-PJQSPAFZ.js +0 -178
- package/dist/chunk-PJQSPAFZ.js.map +0 -7
- package/dist/chunk-QHQKY35W.js +0 -830
- package/dist/chunk-QHQKY35W.js.map +0 -7
- package/dist/chunk-QKXHQ6DV.js +0 -254
- package/dist/chunk-QKXHQ6DV.js.map +0 -7
- package/dist/chunk-RTWNTT77.js +0 -62
- package/dist/chunk-RTWNTT77.js.map +0 -7
- package/dist/chunk-TBXRX6MK.js +0 -576
- package/dist/chunk-TBXRX6MK.js.map +0 -7
- package/dist/chunk-TCOPR3BK.js +0 -487
- package/dist/chunk-TCOPR3BK.js.map +0 -7
- package/dist/chunk-VKORP2LF.js +0 -41
- package/dist/chunk-VKORP2LF.js.map +0 -7
- package/dist/chunk-YYVDCP5Z.js +0 -136
- package/dist/chunk-YYVDCP5Z.js.map +0 -7
- package/dist/empty-chat.svg +0 -12
- package/dist/ios-perm-0.png +0 -0
- package/dist/pdf-share.png +0 -0
- package/dist/screen-share.png +0 -0
- package/dist/transaction_error.svg +0 -12
- package/src/Prebuilt/components/Notifications/DeviceChangeNotifications.tsx +0 -18
- package/src/Prebuilt/components/Notifications/ErrorNotifications.tsx +0 -56
- package/src/Prebuilt/components/Notifications/MessageNotifications.tsx +0 -24
- package/src/Prebuilt/components/Notifications/PollNotificationModal.tsx +0 -71
- package/src/Prebuilt/components/Notifications/RoleChangeNotification.tsx +0 -24
package/dist/Polls-IN3V2HFI.js
DELETED
@@ -1,1584 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
Button,
|
3
|
-
Checkbox,
|
4
|
-
Dialog,
|
5
|
-
DialogDropdownTrigger,
|
6
|
-
Input,
|
7
|
-
Label,
|
8
|
-
Loading,
|
9
|
-
Progress,
|
10
|
-
RadioGroup,
|
11
|
-
Switch,
|
12
|
-
TextArea,
|
13
|
-
getFormattedTime,
|
14
|
-
useDropdownSelection,
|
15
|
-
usePollViewToggle,
|
16
|
-
useSidepaneToggle
|
17
|
-
} from "./chunk-26D5FDBW.js";
|
18
|
-
import {
|
19
|
-
Text
|
20
|
-
} from "./chunk-JKWX7W4K.js";
|
21
|
-
import {
|
22
|
-
Dropdown
|
23
|
-
} from "./chunk-BQOT4DK7.js";
|
24
|
-
import {
|
25
|
-
Box,
|
26
|
-
Flex
|
27
|
-
} from "./chunk-7QZJMUHM.js";
|
28
|
-
import {
|
29
|
-
IconButton,
|
30
|
-
IconButton_default,
|
31
|
-
Tooltip,
|
32
|
-
checkCorrectAnswer,
|
33
|
-
getIndexToShow,
|
34
|
-
getPeerResponses,
|
35
|
-
isValidTextInput,
|
36
|
-
slideLeftAndFade,
|
37
|
-
usePollViewState
|
38
|
-
} from "./chunk-ENHSO6YN.js";
|
39
|
-
import {
|
40
|
-
POLL_STATE,
|
41
|
-
POLL_VIEWS,
|
42
|
-
QUESTION_TYPE_TITLE,
|
43
|
-
__async,
|
44
|
-
__spreadProps,
|
45
|
-
__spreadValues,
|
46
|
-
init_define_process_env
|
47
|
-
} from "./chunk-TBXRX6MK.js";
|
48
|
-
|
49
|
-
// src/Prebuilt/components/Polls/Polls.tsx
|
50
|
-
init_define_process_env();
|
51
|
-
import React22 from "react";
|
52
|
-
|
53
|
-
// src/Prebuilt/components/Polls/CreatePollQuiz/PollsQuizMenu.tsx
|
54
|
-
init_define_process_env();
|
55
|
-
import React3, { useEffect, useMemo, useRef, useState } from "react";
|
56
|
-
import {
|
57
|
-
selectLocalPeerRoleName,
|
58
|
-
selectPermissions as selectPermissions2,
|
59
|
-
selectPolls,
|
60
|
-
useHMSActions,
|
61
|
-
useHMSStore as useHMSStore2
|
62
|
-
} from "@100mslive/react-sdk";
|
63
|
-
import { QuestionIcon, StatsIcon } from "@100mslive/react-icons";
|
64
|
-
|
65
|
-
// src/Prebuilt/components/Streaming/Common.jsx
|
66
|
-
init_define_process_env();
|
67
|
-
import React from "react";
|
68
|
-
import { selectPermissions, useHMSStore } from "@100mslive/react-sdk";
|
69
|
-
import { ChevronLeftIcon, ChevronRightIcon, CrossIcon, RecordIcon } from "@100mslive/react-icons";
|
70
|
-
var ContentHeader = ({ onBack, onClose, title = "", content }) => {
|
71
|
-
return /* @__PURE__ */ React.createElement(
|
72
|
-
Flex,
|
73
|
-
{
|
74
|
-
css: { w: "100%", py: "$8", px: "$10", cursor: "pointer", borderBottom: "1px solid $border_bright", mb: "$8" }
|
75
|
-
},
|
76
|
-
onBack ? /* @__PURE__ */ React.createElement(
|
77
|
-
Flex,
|
78
|
-
{
|
79
|
-
align: "center",
|
80
|
-
css: {
|
81
|
-
mr: "$8",
|
82
|
-
color: "$on_surface_high"
|
83
|
-
},
|
84
|
-
onClick: onBack,
|
85
|
-
"data-testid": "go_back"
|
86
|
-
},
|
87
|
-
/* @__PURE__ */ React.createElement(ChevronLeftIcon, null)
|
88
|
-
) : null,
|
89
|
-
/* @__PURE__ */ React.createElement(Box, { css: { flex: "1 1 0", display: "flex", alignItems: "center" } }, title ? /* @__PURE__ */ React.createElement(
|
90
|
-
Text,
|
91
|
-
{
|
92
|
-
variant: "tiny",
|
93
|
-
css: {
|
94
|
-
textTransform: "uppercase",
|
95
|
-
fontWeight: "$semiBold",
|
96
|
-
color: "$on_surface_medium"
|
97
|
-
}
|
98
|
-
},
|
99
|
-
title
|
100
|
-
) : null, /* @__PURE__ */ React.createElement(Text, { variant: "h6" }, content)),
|
101
|
-
onClose ? /* @__PURE__ */ React.createElement(IconButton, { onClick: onClose, css: { alignSelf: "flex-start" }, "data-testid": "close_stream_section" }, /* @__PURE__ */ React.createElement(CrossIcon, null)) : null
|
102
|
-
);
|
103
|
-
};
|
104
|
-
var Container = ({ children, rounded = false }) => {
|
105
|
-
return /* @__PURE__ */ React.createElement(
|
106
|
-
Box,
|
107
|
-
{
|
108
|
-
css: {
|
109
|
-
size: "100%",
|
110
|
-
zIndex: 2,
|
111
|
-
position: "absolute",
|
112
|
-
top: 0,
|
113
|
-
left: 0,
|
114
|
-
bg: "$surface_dim",
|
115
|
-
transform: "translateX(10%)",
|
116
|
-
animation: `${slideLeftAndFade("10%")} 100ms ease-out forwards`,
|
117
|
-
display: "flex",
|
118
|
-
flexDirection: "column",
|
119
|
-
borderRadius: rounded ? "$2" : "0"
|
120
|
-
}
|
121
|
-
},
|
122
|
-
children
|
123
|
-
);
|
124
|
-
};
|
125
|
-
var ErrorText = ({ error }) => {
|
126
|
-
if (!error) {
|
127
|
-
return null;
|
128
|
-
}
|
129
|
-
return /* @__PURE__ */ React.createElement(Text, { variant: "sm", css: { my: "$4", color: "$alert_error_default" } }, error);
|
130
|
-
};
|
131
|
-
|
132
|
-
// src/Prebuilt/components/Polls/common/StatusIndicator.tsx
|
133
|
-
init_define_process_env();
|
134
|
-
import React2 from "react";
|
135
|
-
var statusMap = {
|
136
|
-
created: "DRAFT" /* DRAFT */,
|
137
|
-
started: "LIVE" /* LIVE */,
|
138
|
-
stopped: "ENDED" /* ENDED */
|
139
|
-
};
|
140
|
-
var StatusIndicator = ({ status }) => {
|
141
|
-
if (!status)
|
142
|
-
return null;
|
143
|
-
return /* @__PURE__ */ React2.createElement(Flex, { align: "center" }, /* @__PURE__ */ React2.createElement(
|
144
|
-
Flex,
|
145
|
-
{
|
146
|
-
css: {
|
147
|
-
backgroundColor: statusMap[status] === "LIVE" /* LIVE */ ? "$alert_error_default" : "$secondary_default",
|
148
|
-
p: "$2 $4",
|
149
|
-
borderRadius: "$0"
|
150
|
-
}
|
151
|
-
},
|
152
|
-
/* @__PURE__ */ React2.createElement(
|
153
|
-
Text,
|
154
|
-
{
|
155
|
-
variant: "caption",
|
156
|
-
css: {
|
157
|
-
fontWeight: "$semiBold",
|
158
|
-
color: "$on_primary_high"
|
159
|
-
}
|
160
|
-
},
|
161
|
-
statusMap[status]
|
162
|
-
)
|
163
|
-
));
|
164
|
-
};
|
165
|
-
|
166
|
-
// src/Prebuilt/components/Polls/CreatePollQuiz/PollsQuizMenu.tsx
|
167
|
-
var PollsQuizMenu = () => {
|
168
|
-
const togglePollView = usePollViewToggle();
|
169
|
-
const permissions = useHMSStore2(selectPermissions2);
|
170
|
-
return /* @__PURE__ */ React3.createElement(Container, { rounded: true }, /* @__PURE__ */ React3.createElement(ContentHeader, { content: "Polls and Quizzes", onClose: togglePollView }), /* @__PURE__ */ React3.createElement(Flex, { direction: "column", css: { px: "$10", pb: "$10", overflowY: "auto" } }, (permissions == null ? void 0 : permissions.pollWrite) && /* @__PURE__ */ React3.createElement(AddMenu, null), /* @__PURE__ */ React3.createElement(PrevMenu, null)));
|
171
|
-
};
|
172
|
-
function InteractionSelectionCard({
|
173
|
-
title,
|
174
|
-
icon,
|
175
|
-
active,
|
176
|
-
onClick
|
177
|
-
}) {
|
178
|
-
const activeBorderStyle = active ? "$space$px solid $primary_default" : "$space$px solid $border_bright";
|
179
|
-
return /* @__PURE__ */ React3.createElement(
|
180
|
-
Flex,
|
181
|
-
{
|
182
|
-
onClick,
|
183
|
-
css: {
|
184
|
-
border: activeBorderStyle,
|
185
|
-
p: "$4",
|
186
|
-
r: "$2",
|
187
|
-
w: "100%",
|
188
|
-
cursor: "pointer"
|
189
|
-
},
|
190
|
-
align: "center"
|
191
|
-
},
|
192
|
-
/* @__PURE__ */ React3.createElement(
|
193
|
-
Flex,
|
194
|
-
{
|
195
|
-
css: {
|
196
|
-
border: activeBorderStyle,
|
197
|
-
p: "$4",
|
198
|
-
bg: "$surface_bright",
|
199
|
-
c: "$on_surface_high",
|
200
|
-
r: "$0"
|
201
|
-
}
|
202
|
-
},
|
203
|
-
icon
|
204
|
-
),
|
205
|
-
/* @__PURE__ */ React3.createElement(Text, { variant: "sub1", css: { ml: "$md" } }, title)
|
206
|
-
);
|
207
|
-
}
|
208
|
-
var AddMenu = () => {
|
209
|
-
const actions = useHMSActions();
|
210
|
-
const [title, setTitle] = useState("");
|
211
|
-
const localPeerRoleName = useHMSStore2(selectLocalPeerRoleName);
|
212
|
-
const [hideVoteCount, setHideVoteCount] = useState(false);
|
213
|
-
const [error, setError] = useState();
|
214
|
-
const [titleError, setTitleError] = useState("");
|
215
|
-
const { setPollState } = usePollViewState();
|
216
|
-
const [interactionType, setInteractionType] = useState("Poll" /* POLL */);
|
217
|
-
const inputRef = useRef(null);
|
218
|
-
useEffect(() => {
|
219
|
-
if (inputRef.current) {
|
220
|
-
inputRef.current.focus();
|
221
|
-
}
|
222
|
-
}, [interactionType]);
|
223
|
-
const handleCreate = (id) => {
|
224
|
-
setPollState({
|
225
|
-
[POLL_STATE.pollInView]: id,
|
226
|
-
[POLL_STATE.view]: POLL_VIEWS.CREATE_QUESTIONS
|
227
|
-
});
|
228
|
-
};
|
229
|
-
const validateTitle = useMemo(() => {
|
230
|
-
if (!isValidTextInput(title)) {
|
231
|
-
if (title) {
|
232
|
-
setTitleError("The title should have between 2-100 characters");
|
233
|
-
}
|
234
|
-
return true;
|
235
|
-
} else {
|
236
|
-
setTitleError("");
|
237
|
-
return false;
|
238
|
-
}
|
239
|
-
}, [title]);
|
240
|
-
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(Text, { variant: "caption", css: { c: "$on_surface_medium", mb: "$md" } }, "Select the type you want to continue with"), /* @__PURE__ */ React3.createElement(Flex, { css: { w: "100%", gap: "$10", mb: "$md" } }, /* @__PURE__ */ React3.createElement(
|
241
|
-
InteractionSelectionCard,
|
242
|
-
{
|
243
|
-
title: "Poll" /* POLL */,
|
244
|
-
icon: /* @__PURE__ */ React3.createElement(StatsIcon, { width: 32, height: 32 }),
|
245
|
-
onClick: () => setInteractionType("Poll" /* POLL */),
|
246
|
-
active: interactionType === "Poll" /* POLL */
|
247
|
-
}
|
248
|
-
), /* @__PURE__ */ React3.createElement(
|
249
|
-
InteractionSelectionCard,
|
250
|
-
{
|
251
|
-
title: "Quiz" /* QUIZ */,
|
252
|
-
icon: /* @__PURE__ */ React3.createElement(QuestionIcon, { width: 32, height: 32 }),
|
253
|
-
onClick: () => setInteractionType("Quiz" /* QUIZ */),
|
254
|
-
active: interactionType === "Quiz" /* QUIZ */
|
255
|
-
}
|
256
|
-
)), /* @__PURE__ */ React3.createElement(Flex, { direction: "column", css: { mb: "$10" } }, /* @__PURE__ */ React3.createElement(Text, { variant: "body2", css: { mb: "$4" } }, `Name this ${interactionType.toLowerCase()}`), /* @__PURE__ */ React3.createElement(
|
257
|
-
Input,
|
258
|
-
{
|
259
|
-
ref: inputRef,
|
260
|
-
type: "text",
|
261
|
-
placeholder: "Enter a name to continue",
|
262
|
-
value: title,
|
263
|
-
onChange: (event) => setTitle(event.target.value.trimStart()),
|
264
|
-
css: {
|
265
|
-
backgroundColor: "$surface_bright",
|
266
|
-
border: "1px solid $border_default"
|
267
|
-
}
|
268
|
-
}
|
269
|
-
), /* @__PURE__ */ React3.createElement(Flex, { align: "center", css: { mt: "$10" } }, /* @__PURE__ */ React3.createElement(Switch, { onCheckedChange: (value) => setHideVoteCount(value), css: { mr: "$6" } }), /* @__PURE__ */ React3.createElement(Text, { variant: "body2", css: { c: "$on_surface_medium" } }, "Hide Vote Count")), /* @__PURE__ */ React3.createElement(
|
270
|
-
Button,
|
271
|
-
{
|
272
|
-
variant: "primary",
|
273
|
-
disabled: validateTitle,
|
274
|
-
css: { mt: "$10" },
|
275
|
-
onClick: () => __async(void 0, null, function* () {
|
276
|
-
const id = Date.now().toString();
|
277
|
-
yield actions.interactivityCenter.createPoll({
|
278
|
-
id,
|
279
|
-
title,
|
280
|
-
anonymous: false,
|
281
|
-
rolesThatCanViewResponses: hideVoteCount && localPeerRoleName ? [localPeerRoleName] : void 0,
|
282
|
-
// @ts-ignore
|
283
|
-
type: interactionType.toLowerCase()
|
284
|
-
}).then(() => handleCreate(id)).catch((err) => setError(err.message));
|
285
|
-
})
|
286
|
-
},
|
287
|
-
"Create ",
|
288
|
-
interactionType
|
289
|
-
), /* @__PURE__ */ React3.createElement(ErrorText, { error: error || titleError })));
|
290
|
-
};
|
291
|
-
var PrevMenu = () => {
|
292
|
-
const hmsActions = useHMSActions();
|
293
|
-
const polls = useHMSStore2(selectPolls);
|
294
|
-
const sortedPolls = useMemo(
|
295
|
-
() => {
|
296
|
-
var _a;
|
297
|
-
return (_a = polls == null ? void 0 : polls.sort((a, b) => {
|
298
|
-
var _a2, _b, _c, _d;
|
299
|
-
return (((_b = (_a2 = b == null ? void 0 : b.createdAt) == null ? void 0 : _a2.getTime) == null ? void 0 : _b.call(_a2)) || 0) - (((_d = (_c = a == null ? void 0 : a.createdAt) == null ? void 0 : _c.getTime) == null ? void 0 : _d.call(_c)) || 0);
|
300
|
-
})) == null ? void 0 : _a.sort((a, b) => ((b == null ? void 0 : b.state) === "started" ? 1 : 0) - ((a == null ? void 0 : a.state) === "started" ? 1 : 0));
|
301
|
-
},
|
302
|
-
[polls]
|
303
|
-
);
|
304
|
-
const permissions = useHMSStore2(selectPermissions2);
|
305
|
-
useEffect(() => {
|
306
|
-
const updatePolls = () => __async(void 0, null, function* () {
|
307
|
-
yield hmsActions.interactivityCenter.getPolls();
|
308
|
-
});
|
309
|
-
updatePolls();
|
310
|
-
}, [hmsActions.interactivityCenter]);
|
311
|
-
return (polls == null ? void 0 : polls.length) ? /* @__PURE__ */ React3.createElement(
|
312
|
-
Flex,
|
313
|
-
{
|
314
|
-
direction: "column",
|
315
|
-
css: __spreadValues({
|
316
|
-
width: "100%"
|
317
|
-
}, (permissions == null ? void 0 : permissions.pollWrite) ? { borderTop: "$space$px solid $border_bright", paddingTop: "$10" } : {})
|
318
|
-
},
|
319
|
-
/* @__PURE__ */ React3.createElement(Text, { variant: "h6", css: { c: "$on_surface_high" } }, "Previous Polls and Quizzes"),
|
320
|
-
/* @__PURE__ */ React3.createElement(Flex, { direction: "column", css: { gap: "$10", mt: "$8" } }, sortedPolls == null ? void 0 : sortedPolls.map((poll) => /* @__PURE__ */ React3.createElement(InteractionCard, { key: poll.id, id: poll.id, title: poll.title, status: poll.state })))
|
321
|
-
) : null;
|
322
|
-
};
|
323
|
-
var InteractionCard = ({ id, title, status }) => {
|
324
|
-
const { setPollState } = usePollViewState();
|
325
|
-
return /* @__PURE__ */ React3.createElement(Flex, { direction: "column", css: { backgroundColor: "$surface_bright", borderRadius: "$1", p: "$8" } }, /* @__PURE__ */ React3.createElement(Flex, { css: { w: "100%", justifyContent: "space-between", mb: "$sm" } }, /* @__PURE__ */ React3.createElement(Text, { variant: "sub1", css: { c: "$on_surface_high", fontWeight: "$semiBold" } }, title), /* @__PURE__ */ React3.createElement(StatusIndicator, { status })), /* @__PURE__ */ React3.createElement(Flex, { css: { w: "100%", gap: "$4" }, justify: "end" }, /* @__PURE__ */ React3.createElement(
|
326
|
-
Button,
|
327
|
-
{
|
328
|
-
variant: "primary",
|
329
|
-
onClick: () => setPollState({
|
330
|
-
[POLL_STATE.pollInView]: id,
|
331
|
-
[POLL_STATE.view]: status === "created" ? POLL_VIEWS.CREATE_QUESTIONS : POLL_VIEWS.VOTE
|
332
|
-
})
|
333
|
-
},
|
334
|
-
"View"
|
335
|
-
)));
|
336
|
-
};
|
337
|
-
|
338
|
-
// src/Prebuilt/components/Polls/CreateQuestions/CreateQuestions.jsx
|
339
|
-
init_define_process_env();
|
340
|
-
import React13, { useMemo as useMemo3, useState as useState3 } from "react";
|
341
|
-
import { v4 as uuid } from "uuid";
|
342
|
-
import { selectPollByID, useHMSActions as useHMSActions2, useHMSStore as useHMSStore3, useRecordingStreaming } from "@100mslive/react-sdk";
|
343
|
-
import { AddCircleIcon as AddCircleIcon2 } from "@100mslive/react-icons";
|
344
|
-
|
345
|
-
// src/Prebuilt/components/Polls/CreateQuestions/QuestionForm.tsx
|
346
|
-
init_define_process_env();
|
347
|
-
import React11, { useCallback, useRef as useRef2, useState as useState2 } from "react";
|
348
|
-
import { AddCircleIcon, TrashIcon as TrashIcon2 } from "@100mslive/react-icons";
|
349
|
-
|
350
|
-
// src/Prebuilt/components/Polls/CreateQuestions/DeleteQuestionModal.tsx
|
351
|
-
init_define_process_env();
|
352
|
-
import React4 from "react";
|
353
|
-
import { AlertTriangleIcon, CrossIcon as CrossIcon2 } from "@100mslive/react-icons";
|
354
|
-
var DeleteQuestionModal = ({
|
355
|
-
open,
|
356
|
-
setOpen,
|
357
|
-
removeQuestion
|
358
|
-
}) => {
|
359
|
-
return /* @__PURE__ */ React4.createElement(Dialog.Root, { open }, /* @__PURE__ */ React4.createElement(Dialog.Overlay, null), /* @__PURE__ */ React4.createElement(Dialog.Portal, null, /* @__PURE__ */ React4.createElement(Dialog.Content, { css: { p: "$10" } }, /* @__PURE__ */ React4.createElement(Box, null, /* @__PURE__ */ React4.createElement(
|
360
|
-
Flex,
|
361
|
-
{
|
362
|
-
css: {
|
363
|
-
color: "$alert_error_default",
|
364
|
-
display: "flex",
|
365
|
-
alignItems: "center"
|
366
|
-
}
|
367
|
-
},
|
368
|
-
/* @__PURE__ */ React4.createElement(AlertTriangleIcon, { style: { marginRight: "0.5rem" } }),
|
369
|
-
/* @__PURE__ */ React4.createElement(Text, { variant: "lg", css: { color: "inherit", fontWeight: "$semiBold" } }, "Delete Question?"),
|
370
|
-
/* @__PURE__ */ React4.createElement(
|
371
|
-
Box,
|
372
|
-
{
|
373
|
-
css: {
|
374
|
-
ml: "auto",
|
375
|
-
color: "$on_surface_medium",
|
376
|
-
"&:hover": { color: "$on_surface_high", cursor: "pointer" }
|
377
|
-
},
|
378
|
-
onClick: () => setOpen(false)
|
379
|
-
},
|
380
|
-
/* @__PURE__ */ React4.createElement(CrossIcon2, null)
|
381
|
-
)
|
382
|
-
), /* @__PURE__ */ React4.createElement(Text, { variant: "sm", css: { color: "$on_surface_medium", mb: "$8", mt: "$4" } }, "The question will be deleted. You can't undo this action."), /* @__PURE__ */ React4.createElement(Flex, { css: { w: "100%", mt: "$12", gap: "$md" } }, /* @__PURE__ */ React4.createElement(
|
383
|
-
Button,
|
384
|
-
{
|
385
|
-
variant: "standard",
|
386
|
-
outlined: true,
|
387
|
-
onClick: () => setOpen(false),
|
388
|
-
css: { w: "100%", fontSize: "$md", fontWeight: "$semiBold" }
|
389
|
-
},
|
390
|
-
"Cancel"
|
391
|
-
), /* @__PURE__ */ React4.createElement(
|
392
|
-
Button,
|
393
|
-
{
|
394
|
-
css: { w: "100%", fontSize: "$md", fontWeight: "$semiBold" },
|
395
|
-
variant: "danger",
|
396
|
-
onClick: () => {
|
397
|
-
removeQuestion();
|
398
|
-
setOpen(false);
|
399
|
-
}
|
400
|
-
},
|
401
|
-
"Delete"
|
402
|
-
))))));
|
403
|
-
};
|
404
|
-
|
405
|
-
// src/Prebuilt/components/Polls/common/Line.tsx
|
406
|
-
init_define_process_env();
|
407
|
-
import React5 from "react";
|
408
|
-
var Line = () => /* @__PURE__ */ React5.createElement(Flex, { css: { w: "100%", borderBottom: "1px solid $border_bright", h: "1px", my: "$8" } });
|
409
|
-
|
410
|
-
// src/Prebuilt/components/Polls/common/MultipleChoiceOptions.jsx
|
411
|
-
init_define_process_env();
|
412
|
-
import React9 from "react";
|
413
|
-
import { CheckCircleIcon, CheckIcon } from "@100mslive/react-icons";
|
414
|
-
|
415
|
-
// src/Prebuilt/components/Polls/common/OptionInputWithDelete.tsx
|
416
|
-
init_define_process_env();
|
417
|
-
import React6 from "react";
|
418
|
-
import { TrashIcon } from "@100mslive/react-icons";
|
419
|
-
var OptionInputWithDelete = ({
|
420
|
-
index,
|
421
|
-
option,
|
422
|
-
handleOptionTextChange,
|
423
|
-
removeOption
|
424
|
-
}) => {
|
425
|
-
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(
|
426
|
-
Input,
|
427
|
-
{
|
428
|
-
placeholder: `Option ${index + 1}`,
|
429
|
-
css: {
|
430
|
-
w: "100%",
|
431
|
-
backgroundColor: "$surface_bright",
|
432
|
-
border: "1px solid $border_bright"
|
433
|
-
},
|
434
|
-
value: (option == null ? void 0 : option.text) || "",
|
435
|
-
key: index,
|
436
|
-
onChange: (event) => handleOptionTextChange(index, event.target.value.trimStart()),
|
437
|
-
maxLength: 250
|
438
|
-
}
|
439
|
-
), /* @__PURE__ */ React6.createElement(IconButton_default, { onClick: () => removeOption(index), css: { bg: "transparent", border: "none" } }, /* @__PURE__ */ React6.createElement(TrashIcon, null)));
|
440
|
-
};
|
441
|
-
|
442
|
-
// src/Prebuilt/components/Polls/common/VoteCount.tsx
|
443
|
-
init_define_process_env();
|
444
|
-
import React7 from "react";
|
445
|
-
var VoteCount = ({ voteCount }) => {
|
446
|
-
return /* @__PURE__ */ React7.createElement(Flex, { css: { alignItems: "center" } }, voteCount ? /* @__PURE__ */ React7.createElement(Text, { variant: "sm", css: { color: "$on_surface_medium" } }, voteCount, "\xA0", voteCount === 1 ? "vote" : "votes") : null);
|
447
|
-
};
|
448
|
-
|
449
|
-
// src/Prebuilt/components/Polls/common/VoteProgress.tsx
|
450
|
-
init_define_process_env();
|
451
|
-
import React8 from "react";
|
452
|
-
var VoteProgress = ({ option, totalResponses }) => {
|
453
|
-
const showProgress = typeof option.voteCount === "number" && typeof totalResponses === "number" && totalResponses > 0;
|
454
|
-
const progressValue = 100 * (option.voteCount || 0) / totalResponses;
|
455
|
-
return showProgress ? /* @__PURE__ */ React8.createElement(Progress.Root, { value: progressValue, css: { mt: "$4" } }, /* @__PURE__ */ React8.createElement(
|
456
|
-
Progress.Content,
|
457
|
-
{
|
458
|
-
style: {
|
459
|
-
transform: `translateX(-${100 - progressValue}%)`
|
460
|
-
}
|
461
|
-
}
|
462
|
-
)) : null;
|
463
|
-
};
|
464
|
-
|
465
|
-
// src/Prebuilt/components/Polls/common/MultipleChoiceOptions.jsx
|
466
|
-
var MultipleChoiceOptions = ({
|
467
|
-
questionIndex,
|
468
|
-
options,
|
469
|
-
canRespond,
|
470
|
-
totalResponses,
|
471
|
-
selectedOptions,
|
472
|
-
setSelectedOptions,
|
473
|
-
showVoteCount,
|
474
|
-
isQuiz,
|
475
|
-
correctOptionIndexes,
|
476
|
-
localPeerResponse,
|
477
|
-
isStopped
|
478
|
-
}) => {
|
479
|
-
const handleCheckedChange = (checked, index) => {
|
480
|
-
const newSelected = new Set(selectedOptions);
|
481
|
-
if (checked) {
|
482
|
-
newSelected.add(index);
|
483
|
-
} else {
|
484
|
-
newSelected.delete(index);
|
485
|
-
}
|
486
|
-
setSelectedOptions(newSelected);
|
487
|
-
};
|
488
|
-
return /* @__PURE__ */ React9.createElement(Flex, { direction: "column", css: { gap: "$md", w: "100%", mb: "$md" } }, options.map((option) => {
|
489
|
-
var _a;
|
490
|
-
return /* @__PURE__ */ React9.createElement(Flex, { align: "center", key: `${questionIndex}-${option.index}`, css: { w: "100%", gap: "$4" } }, !isStopped || !isQuiz ? /* @__PURE__ */ React9.createElement(
|
491
|
-
Checkbox.Root,
|
492
|
-
{
|
493
|
-
id: `${questionIndex}-${option.index}`,
|
494
|
-
disabled: !canRespond,
|
495
|
-
checked: (_a = localPeerResponse == null ? void 0 : localPeerResponse.options) == null ? void 0 : _a.includes(option.index),
|
496
|
-
onCheckedChange: (checked) => handleCheckedChange(checked, option.index),
|
497
|
-
css: {
|
498
|
-
cursor: canRespond ? "pointer" : "not-allowed",
|
499
|
-
flexShrink: 0
|
500
|
-
}
|
501
|
-
},
|
502
|
-
/* @__PURE__ */ React9.createElement(Checkbox.Indicator, null, /* @__PURE__ */ React9.createElement(CheckIcon, { width: 16, height: 16 }))
|
503
|
-
) : null, isStopped && (correctOptionIndexes == null ? void 0 : correctOptionIndexes.includes(option.index)) ? /* @__PURE__ */ React9.createElement(Flex, { align: "center", css: { color: "$on_surface_high" } }, /* @__PURE__ */ React9.createElement(CheckCircleIcon, { height: 20, width: 20 })) : null, /* @__PURE__ */ React9.createElement(Flex, { direction: "column", css: { flexGrow: "1" } }, /* @__PURE__ */ React9.createElement(Flex, { css: { w: "100%" } }, /* @__PURE__ */ React9.createElement(Text, { css: { display: "flex", flexGrow: "1" } }, /* @__PURE__ */ React9.createElement(Label, { htmlFor: `${questionIndex}-${option.index}` }, option.text)), showVoteCount && /* @__PURE__ */ React9.createElement(VoteCount, { voteCount: option.voteCount })), showVoteCount && /* @__PURE__ */ React9.createElement(VoteProgress, { option, totalResponses })), isStopped && isQuiz && (localPeerResponse == null ? void 0 : localPeerResponse.options.includes(option.index)) ? /* @__PURE__ */ React9.createElement(Text, { variant: "sm", css: { color: "$on_surface_medium", maxWidth: "max-content" } }, "Your Answer") : null);
|
504
|
-
}));
|
505
|
-
};
|
506
|
-
var MultipleChoiceOptionInputs = ({ isQuiz, options, selectAnswer, handleOptionTextChange, removeOption }) => {
|
507
|
-
return /* @__PURE__ */ React9.createElement(Flex, { direction: "column", css: { gap: "$md", w: "100%", mb: "$md" } }, options.map((option, index) => {
|
508
|
-
return /* @__PURE__ */ React9.createElement(Flex, { align: "center", key: index, css: { w: "100%", gap: "$4" } }, isQuiz && /* @__PURE__ */ React9.createElement(
|
509
|
-
Checkbox.Root,
|
510
|
-
{
|
511
|
-
onCheckedChange: (checked) => selectAnswer(checked, index),
|
512
|
-
checked: option.isCorrectAnswer,
|
513
|
-
css: {
|
514
|
-
cursor: "pointer",
|
515
|
-
width: "$9"
|
516
|
-
}
|
517
|
-
},
|
518
|
-
/* @__PURE__ */ React9.createElement(Checkbox.Indicator, null, /* @__PURE__ */ React9.createElement(CheckIcon, { width: 16, height: 16 }))
|
519
|
-
), /* @__PURE__ */ React9.createElement(
|
520
|
-
OptionInputWithDelete,
|
521
|
-
{
|
522
|
-
index,
|
523
|
-
option,
|
524
|
-
handleOptionTextChange,
|
525
|
-
removeOption
|
526
|
-
}
|
527
|
-
));
|
528
|
-
}));
|
529
|
-
};
|
530
|
-
|
531
|
-
// src/Prebuilt/components/Polls/common/SingleChoiceOptions.jsx
|
532
|
-
init_define_process_env();
|
533
|
-
import React10 from "react";
|
534
|
-
import { CheckCircleIcon as CheckCircleIcon2 } from "@100mslive/react-icons";
|
535
|
-
var SingleChoiceOptions = ({
|
536
|
-
questionIndex,
|
537
|
-
options,
|
538
|
-
canRespond,
|
539
|
-
setAnswer,
|
540
|
-
totalResponses,
|
541
|
-
showVoteCount,
|
542
|
-
correctOptionIndex,
|
543
|
-
isStopped,
|
544
|
-
isQuiz,
|
545
|
-
localPeerResponse
|
546
|
-
}) => {
|
547
|
-
return /* @__PURE__ */ React10.createElement(RadioGroup.Root, { value: localPeerResponse == null ? void 0 : localPeerResponse.option, onValueChange: (value) => setAnswer(value) }, /* @__PURE__ */ React10.createElement(Flex, { direction: "column", css: { gap: "$md", w: "100%", mb: "$md" } }, options.map((option) => {
|
548
|
-
return /* @__PURE__ */ React10.createElement(Flex, { align: "center", key: `${questionIndex}-${option.index}`, css: { w: "100%", gap: "$4" } }, !isStopped || !isQuiz ? /* @__PURE__ */ React10.createElement(
|
549
|
-
RadioGroup.Item,
|
550
|
-
{
|
551
|
-
css: {
|
552
|
-
background: "none",
|
553
|
-
h: "$9",
|
554
|
-
w: "$9",
|
555
|
-
border: "2px solid",
|
556
|
-
borderColor: "$on_surface_high",
|
557
|
-
display: "flex",
|
558
|
-
flexShrink: 0,
|
559
|
-
pt: "$1",
|
560
|
-
justifyContent: "center",
|
561
|
-
alignItems: "center",
|
562
|
-
cursor: canRespond ? "pointer" : "not-allowed",
|
563
|
-
'&[data-state="checked"]': {
|
564
|
-
borderColor: "$primary_bright",
|
565
|
-
borderWidth: "2px"
|
566
|
-
}
|
567
|
-
},
|
568
|
-
disabled: !canRespond,
|
569
|
-
value: option.index,
|
570
|
-
id: `${questionIndex}-${option.index}`
|
571
|
-
},
|
572
|
-
/* @__PURE__ */ React10.createElement(
|
573
|
-
RadioGroup.Indicator,
|
574
|
-
{
|
575
|
-
css: {
|
576
|
-
h: "80%",
|
577
|
-
w: "80%",
|
578
|
-
background: "$primary_bright",
|
579
|
-
borderRadius: "$round"
|
580
|
-
}
|
581
|
-
}
|
582
|
-
)
|
583
|
-
) : null, isStopped && correctOptionIndex === option.index && isQuiz ? /* @__PURE__ */ React10.createElement(Flex, { css: { color: "$on_surface_high" } }, /* @__PURE__ */ React10.createElement(CheckCircleIcon2, { height: 20, width: 20 })) : null, /* @__PURE__ */ React10.createElement(Flex, { direction: "column", css: { flexGrow: "1" } }, /* @__PURE__ */ React10.createElement(Flex, { css: { w: "100%" } }, /* @__PURE__ */ React10.createElement(Text, { css: { display: "flex", flexGrow: "1", color: "$on_surface_high" } }, /* @__PURE__ */ React10.createElement(Label, { style: { color: "inherit" }, htmlFor: `${questionIndex}-${option.index}` }, option.text)), showVoteCount && /* @__PURE__ */ React10.createElement(VoteCount, { voteCount: option.voteCount })), showVoteCount && /* @__PURE__ */ React10.createElement(VoteProgress, { option, totalResponses })), isStopped && isQuiz && (localPeerResponse == null ? void 0 : localPeerResponse.option) === option.index ? /* @__PURE__ */ React10.createElement(Text, { variant: "sm", css: { color: "$on_surface_medium", maxWidth: "max-content" } }, "Your Answer") : null);
|
584
|
-
})));
|
585
|
-
};
|
586
|
-
var SingleChoiceOptionInputs = ({ isQuiz, options, selectAnswer, handleOptionTextChange, removeOption }) => {
|
587
|
-
const correctOptionIndex = options.findIndex((option) => option.isCorrectAnswer);
|
588
|
-
return /* @__PURE__ */ React10.createElement(RadioGroup.Root, { value: correctOptionIndex, onValueChange: selectAnswer }, /* @__PURE__ */ React10.createElement(Flex, { direction: "column", css: { gap: "$md", w: "100%", mb: "$md" } }, options.map((option, index) => {
|
589
|
-
return /* @__PURE__ */ React10.createElement(Flex, { align: "center", key: `option-${index}`, css: { w: "100%", gap: "$4" } }, isQuiz && /* @__PURE__ */ React10.createElement(
|
590
|
-
RadioGroup.Item,
|
591
|
-
{
|
592
|
-
css: {
|
593
|
-
background: "none",
|
594
|
-
w: "$9",
|
595
|
-
border: "2px solid",
|
596
|
-
borderColor: "$on_surface_high",
|
597
|
-
display: "flex",
|
598
|
-
justifyContent: "center",
|
599
|
-
alignItems: "center",
|
600
|
-
cursor: "pointer",
|
601
|
-
'&[data-state="checked"]': {
|
602
|
-
borderColor: "$primary_bright",
|
603
|
-
borderWidth: "2px"
|
604
|
-
}
|
605
|
-
},
|
606
|
-
value: index
|
607
|
-
},
|
608
|
-
/* @__PURE__ */ React10.createElement(
|
609
|
-
RadioGroup.Indicator,
|
610
|
-
{
|
611
|
-
css: {
|
612
|
-
h: "80%",
|
613
|
-
w: "80%",
|
614
|
-
background: "$primary_bright",
|
615
|
-
borderRadius: "$round"
|
616
|
-
}
|
617
|
-
}
|
618
|
-
)
|
619
|
-
), /* @__PURE__ */ React10.createElement(
|
620
|
-
OptionInputWithDelete,
|
621
|
-
{
|
622
|
-
index,
|
623
|
-
option,
|
624
|
-
handleOptionTextChange,
|
625
|
-
removeOption
|
626
|
-
}
|
627
|
-
));
|
628
|
-
})));
|
629
|
-
};
|
630
|
-
|
631
|
-
// src/Prebuilt/components/Polls/CreateQuestions/QuestionForm.tsx
|
632
|
-
var QuestionForm = ({
|
633
|
-
question,
|
634
|
-
index,
|
635
|
-
length,
|
636
|
-
onSave,
|
637
|
-
removeQuestion,
|
638
|
-
isQuiz
|
639
|
-
}) => {
|
640
|
-
var _a;
|
641
|
-
const ref = useRef2(null);
|
642
|
-
const selectionBg = useDropdownSelection();
|
643
|
-
const [openDelete, setOpenDelete] = useState2(false);
|
644
|
-
const [open, setOpen] = useState2(false);
|
645
|
-
const [type, setType] = useState2(question.type || "single-choice" /* SINGLE_CHOICE */);
|
646
|
-
const [text, setText] = useState2(question.text);
|
647
|
-
const [weight, setWeight] = useState2(isQuiz ? 10 : 1);
|
648
|
-
const [options, setOptions] = useState2(
|
649
|
-
(question == null ? void 0 : question.options) || [
|
650
|
-
{ text: "", isCorrectAnswer: false },
|
651
|
-
{ text: "", isCorrectAnswer: false }
|
652
|
-
]
|
653
|
-
);
|
654
|
-
const isValid = isValidQuestion({
|
655
|
-
text,
|
656
|
-
type,
|
657
|
-
options,
|
658
|
-
weight,
|
659
|
-
isQuiz
|
660
|
-
});
|
661
|
-
const handleOptionTextChange = useCallback(
|
662
|
-
(index2, text2) => {
|
663
|
-
setOptions((options2) => [...options2.slice(0, index2), __spreadProps(__spreadValues({}, options2[index2]), { text: text2 }), ...options2.slice(index2 + 1)]);
|
664
|
-
},
|
665
|
-
[setOptions]
|
666
|
-
);
|
667
|
-
const removeOption = useCallback(
|
668
|
-
(index2) => setOptions((options2) => {
|
669
|
-
const newOptions = [...options2];
|
670
|
-
newOptions.splice(index2, 1);
|
671
|
-
return newOptions;
|
672
|
-
}),
|
673
|
-
[setOptions]
|
674
|
-
);
|
675
|
-
const selectSingleChoiceAnswer = useCallback(
|
676
|
-
(answerIndex) => {
|
677
|
-
if (!isQuiz) {
|
678
|
-
return;
|
679
|
-
}
|
680
|
-
setOptions(
|
681
|
-
(options2) => options2.map((option, index2) => __spreadProps(__spreadValues({}, option), {
|
682
|
-
isCorrectAnswer: index2 === answerIndex
|
683
|
-
}))
|
684
|
-
);
|
685
|
-
},
|
686
|
-
[setOptions, isQuiz]
|
687
|
-
);
|
688
|
-
const selectMultipleChoiceAnswer = useCallback(
|
689
|
-
(checked, index2) => {
|
690
|
-
if (!isQuiz) {
|
691
|
-
return;
|
692
|
-
}
|
693
|
-
setOptions((options2) => [
|
694
|
-
...options2.slice(0, index2),
|
695
|
-
__spreadProps(__spreadValues({}, options2[index2]), { isCorrectAnswer: checked }),
|
696
|
-
...options2.slice(index2 + 1)
|
697
|
-
]);
|
698
|
-
},
|
699
|
-
[setOptions, isQuiz]
|
700
|
-
);
|
701
|
-
return /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(Text, { variant: "overline", css: { c: "$on_surface_low", textTransform: "uppercase" } }, "Question ", index + 1, " of ", length), /* @__PURE__ */ React11.createElement(Text, { variant: "body2", css: { mt: "$4", mb: "$md" } }, "Question Type"), /* @__PURE__ */ React11.createElement(Dropdown.Root, { open, onOpenChange: setOpen }, /* @__PURE__ */ React11.createElement(
|
702
|
-
DialogDropdownTrigger,
|
703
|
-
{
|
704
|
-
ref,
|
705
|
-
title: QUESTION_TYPE_TITLE[type],
|
706
|
-
css: {
|
707
|
-
backgroundColor: "$surface_bright",
|
708
|
-
border: "1px solid $border_bright"
|
709
|
-
},
|
710
|
-
open
|
711
|
-
}
|
712
|
-
), /* @__PURE__ */ React11.createElement(Dropdown.Portal, null, /* @__PURE__ */ React11.createElement(Dropdown.Content, { align: "start", sideOffset: 8, css: { w: (_a = ref.current) == null ? void 0 : _a.clientWidth, zIndex: 1e3 } }, Object.keys(QUESTION_TYPE_TITLE).map((value) => {
|
713
|
-
return /* @__PURE__ */ React11.createElement(
|
714
|
-
Dropdown.Item,
|
715
|
-
{
|
716
|
-
key: value,
|
717
|
-
onSelect: () => setType(value),
|
718
|
-
css: {
|
719
|
-
px: "$9",
|
720
|
-
bg: type === value ? selectionBg : void 0
|
721
|
-
}
|
722
|
-
},
|
723
|
-
QUESTION_TYPE_TITLE[value]
|
724
|
-
);
|
725
|
-
})))), /* @__PURE__ */ React11.createElement(
|
726
|
-
TextArea,
|
727
|
-
{
|
728
|
-
maxLength: 1024,
|
729
|
-
placeholder: "Ask a question",
|
730
|
-
css: {
|
731
|
-
mt: "$md",
|
732
|
-
backgroundColor: "$surface_bright",
|
733
|
-
border: "1px solid $border_bright",
|
734
|
-
minHeight: "$14",
|
735
|
-
resize: "vertical",
|
736
|
-
maxHeight: "$32"
|
737
|
-
},
|
738
|
-
value: text,
|
739
|
-
onChange: (event) => setText(event.target.value.trimStart())
|
740
|
-
}
|
741
|
-
), /* @__PURE__ */ React11.createElement(Text, { variant: "xs", css: { color: "$on_surface_medium", textAlign: "end", mt: "$4" } }, (text == null ? void 0 : text.length) || 0, "/1024"), /* @__PURE__ */ React11.createElement(Line, null), type === "single-choice" /* SINGLE_CHOICE */ || type === "multiple-choice" /* MULTIPLE_CHOICE */ ? /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(Text, { variant: "body2", css: { mb: "$6", c: "$on_surface_medium" } }, "Options"), isQuiz && /* @__PURE__ */ React11.createElement(Text, { variant: "xs", css: { c: "$on_surface_medium", mb: "$md" } }, type === "single-choice" /* SINGLE_CHOICE */ ? "Use the radio buttons to indicate the correct answer" : "Use the checkboxes to indicate the correct answer(s)"), type === "single-choice" /* SINGLE_CHOICE */ && /* @__PURE__ */ React11.createElement(
|
742
|
-
SingleChoiceOptionInputs,
|
743
|
-
{
|
744
|
-
isQuiz,
|
745
|
-
options,
|
746
|
-
selectAnswer: selectSingleChoiceAnswer,
|
747
|
-
handleOptionTextChange,
|
748
|
-
removeOption
|
749
|
-
}
|
750
|
-
), type === "multiple-choice" /* MULTIPLE_CHOICE */ && /* @__PURE__ */ React11.createElement(
|
751
|
-
MultipleChoiceOptionInputs,
|
752
|
-
{
|
753
|
-
isQuiz,
|
754
|
-
options,
|
755
|
-
selectAnswer: selectMultipleChoiceAnswer,
|
756
|
-
handleOptionTextChange,
|
757
|
-
removeOption
|
758
|
-
}
|
759
|
-
), (options == null ? void 0 : options.length) < 20 && /* @__PURE__ */ React11.createElement(
|
760
|
-
Flex,
|
761
|
-
{
|
762
|
-
css: {
|
763
|
-
c: "$on_surface_medium",
|
764
|
-
cursor: "pointer",
|
765
|
-
"&:hover": { c: "$on_surface_high" }
|
766
|
-
},
|
767
|
-
onClick: () => setOptions([...options, { text: "", isCorrectAnswer: false }])
|
768
|
-
},
|
769
|
-
/* @__PURE__ */ React11.createElement(AddCircleIcon, { style: { position: "relative", left: "-2px" } }),
|
770
|
-
/* @__PURE__ */ React11.createElement(
|
771
|
-
Text,
|
772
|
-
{
|
773
|
-
variant: "sm",
|
774
|
-
css: {
|
775
|
-
ml: "$4",
|
776
|
-
c: "inherit"
|
777
|
-
}
|
778
|
-
},
|
779
|
-
"Add an option"
|
780
|
-
)
|
781
|
-
), /* @__PURE__ */ React11.createElement(Line, null), isQuiz ? /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(Flex, { justify: "between", align: "center", css: { gap: "$6", w: "100%" } }, /* @__PURE__ */ React11.createElement(Text, { variant: "sm", css: { color: "$on_surface_medium" } }, "Point Weightage"), /* @__PURE__ */ React11.createElement(
|
782
|
-
Input,
|
783
|
-
{
|
784
|
-
type: "number",
|
785
|
-
value: weight,
|
786
|
-
min: 1,
|
787
|
-
max: 999,
|
788
|
-
onChange: (e) => setWeight(Math.min(Number(e.target.value), 999)),
|
789
|
-
css: {
|
790
|
-
backgroundColor: "$surface_bright",
|
791
|
-
border: "1px solid $border_bright",
|
792
|
-
maxWidth: "$20"
|
793
|
-
}
|
794
|
-
}
|
795
|
-
))) : null) : null, /* @__PURE__ */ React11.createElement(Flex, { justify: "end", align: "center", css: { mt: "$12", gap: "$8" } }, /* @__PURE__ */ React11.createElement(IconButton, { css: { border: "1px solid $border_bright" } }, /* @__PURE__ */ React11.createElement(TrashIcon2, { onClick: () => setOpenDelete(!open) })), /* @__PURE__ */ React11.createElement(
|
796
|
-
Tooltip,
|
797
|
-
{
|
798
|
-
disabled: isValid,
|
799
|
-
title: options.length < 2 ? "At least two options must be added" : `Please fill all the fields ${isQuiz ? "and mark the correct answer(s)" : ""} to continue`,
|
800
|
-
boxCss: { maxWidth: "$40" }
|
801
|
-
},
|
802
|
-
/* @__PURE__ */ React11.createElement(
|
803
|
-
Button,
|
804
|
-
{
|
805
|
-
variant: "standard",
|
806
|
-
disabled: !isValid,
|
807
|
-
onClick: () => {
|
808
|
-
onSave({
|
809
|
-
saved: true,
|
810
|
-
text,
|
811
|
-
type,
|
812
|
-
options,
|
813
|
-
skippable: false,
|
814
|
-
draftID: question.draftID,
|
815
|
-
weight
|
816
|
-
});
|
817
|
-
}
|
818
|
-
},
|
819
|
-
"Save"
|
820
|
-
)
|
821
|
-
)), /* @__PURE__ */ React11.createElement(DeleteQuestionModal, { open: openDelete, setOpen: setOpenDelete, removeQuestion }));
|
822
|
-
};
|
823
|
-
var isValidQuestion = ({
|
824
|
-
text,
|
825
|
-
type,
|
826
|
-
options,
|
827
|
-
weight,
|
828
|
-
isQuiz = false
|
829
|
-
}) => {
|
830
|
-
if (!isValidTextInput(text) || !type) {
|
831
|
-
return false;
|
832
|
-
}
|
833
|
-
const everyOptionHasText = options.length > 1 && options.every((option) => option && isValidTextInput(option.text, 1));
|
834
|
-
const hasCorrectAnswer = options.some((option) => option.isCorrectAnswer);
|
835
|
-
if (!isQuiz) {
|
836
|
-
return everyOptionHasText;
|
837
|
-
}
|
838
|
-
if (isQuiz && weight < 1) {
|
839
|
-
return false;
|
840
|
-
}
|
841
|
-
return everyOptionHasText && hasCorrectAnswer;
|
842
|
-
};
|
843
|
-
|
844
|
-
// src/Prebuilt/components/Polls/CreateQuestions/SavedQuestion.tsx
|
845
|
-
init_define_process_env();
|
846
|
-
import React12, { useMemo as useMemo2 } from "react";
|
847
|
-
import { CheckCircleIcon as CheckCircleIcon3 } from "@100mslive/react-icons";
|
848
|
-
var SavedQuestion = ({
|
849
|
-
question,
|
850
|
-
index,
|
851
|
-
length,
|
852
|
-
convertToDraft
|
853
|
-
}) => {
|
854
|
-
var _a;
|
855
|
-
const answerArray = useMemo2(() => {
|
856
|
-
var _a2;
|
857
|
-
const updatedAnswerArray = [];
|
858
|
-
const { option, options } = (_a2 = question == null ? void 0 : question.answer) != null ? _a2 : {};
|
859
|
-
if (option) {
|
860
|
-
updatedAnswerArray.push(option);
|
861
|
-
}
|
862
|
-
if (options) {
|
863
|
-
updatedAnswerArray.push(...options);
|
864
|
-
}
|
865
|
-
return updatedAnswerArray;
|
866
|
-
}, [question == null ? void 0 : question.answer]);
|
867
|
-
return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(Text, { variant: "overline", css: { c: "$on_surface_low", textTransform: "uppercase" } }, "Question ", index + 1, " of ", length, ": ", QUESTION_TYPE_TITLE[question.type]), /* @__PURE__ */ React12.createElement(Text, { variant: "body2", css: { mt: "$4", mb: "$md" } }, question.text), (_a = question.options) == null ? void 0 : _a.map((option, index2) => /* @__PURE__ */ React12.createElement(Flex, { key: `${option.text}-${index2}`, css: { alignItems: "center", my: "$xs" } }, /* @__PURE__ */ React12.createElement(Text, { variant: "body2", css: { c: "$on_surface_medium" } }, option.text), (answerArray.includes(index2 + 1) || option.isCorrectAnswer) && /* @__PURE__ */ React12.createElement(Flex, { css: { color: "$alert_success", mx: "$xs" } }, /* @__PURE__ */ React12.createElement(CheckCircleIcon3, { height: 24, width: 24 })))), question.skippable ? /* @__PURE__ */ React12.createElement(Text, { variant: "sm", css: { color: "$on_surface_low", my: "$md" } }, "Not required to answer") : null, /* @__PURE__ */ React12.createElement(Flex, { justify: "end", css: { w: "100%", alignItems: "center" } }, /* @__PURE__ */ React12.createElement(Button, { variant: "standard", css: { fontWeight: "$semiBold" }, onClick: () => convertToDraft(question.draftID) }, "Edit")));
|
868
|
-
};
|
869
|
-
|
870
|
-
// src/Prebuilt/components/Polls/CreateQuestions/CreateQuestions.jsx
|
871
|
-
var getEditableFormat = (questions) => {
|
872
|
-
const editableQuestions = questions.map((question) => {
|
873
|
-
return __spreadProps(__spreadValues({}, question), { saved: true, draftID: uuid() });
|
874
|
-
});
|
875
|
-
return editableQuestions;
|
876
|
-
};
|
877
|
-
function CreateQuestions() {
|
878
|
-
var _a, _b, _c, _d;
|
879
|
-
const actions = useHMSActions2();
|
880
|
-
const { isHLSRunning } = useRecordingStreaming();
|
881
|
-
const togglePollView = usePollViewToggle();
|
882
|
-
const { pollInView: id, setPollView } = usePollViewState();
|
883
|
-
const interaction = useHMSStore3(selectPollByID(id));
|
884
|
-
const [questions, setQuestions] = useState3(
|
885
|
-
((_a = interaction.questions) == null ? void 0 : _a.length) ? getEditableFormat(interaction.questions) : [{ draftID: uuid() }]
|
886
|
-
);
|
887
|
-
const isValidPoll = useMemo3(() => questions.length > 0 && questions.every(isValidQuestion), [questions]);
|
888
|
-
const launchPoll = () => __async(this, null, function* () {
|
889
|
-
yield actions.interactivityCenter.startPoll(id);
|
890
|
-
yield sendTimedMetadata(id);
|
891
|
-
setPollView(POLL_VIEWS.VOTE);
|
892
|
-
});
|
893
|
-
const sendTimedMetadata = (poll_id) => __async(this, null, function* () {
|
894
|
-
if (poll_id && isHLSRunning) {
|
895
|
-
try {
|
896
|
-
yield actions.sendHLSTimedMetadata([
|
897
|
-
{
|
898
|
-
payload: `poll:${poll_id}`,
|
899
|
-
duration: 100
|
900
|
-
}
|
901
|
-
]);
|
902
|
-
} catch (e) {
|
903
|
-
console.error(e);
|
904
|
-
}
|
905
|
-
}
|
906
|
-
});
|
907
|
-
const headingTitle = (interaction == null ? void 0 : interaction.type) ? ((_c = (_b = interaction == null ? void 0 : interaction.type) == null ? void 0 : _b[0]) == null ? void 0 : _c.toUpperCase()) + ((_d = interaction == null ? void 0 : interaction.type) == null ? void 0 : _d.slice(1)) : "Polls and Quizzes";
|
908
|
-
const isQuiz = (interaction == null ? void 0 : interaction.type) === "quiz";
|
909
|
-
return /* @__PURE__ */ React13.createElement(Container, { rounded: true }, /* @__PURE__ */ React13.createElement(
|
910
|
-
ContentHeader,
|
911
|
-
{
|
912
|
-
content: headingTitle,
|
913
|
-
onClose: togglePollView,
|
914
|
-
onBack: () => setPollView(POLL_VIEWS.CREATE_POLL_QUIZ)
|
915
|
-
}
|
916
|
-
), /* @__PURE__ */ React13.createElement(Flex, { direction: "column", css: { p: "$10", overflowY: "auto" } }, /* @__PURE__ */ React13.createElement(Flex, { direction: "column" }, questions.map((question, index) => /* @__PURE__ */ React13.createElement(
|
917
|
-
QuestionCard,
|
918
|
-
{
|
919
|
-
key: question.draftID,
|
920
|
-
question,
|
921
|
-
index,
|
922
|
-
length: questions.length,
|
923
|
-
onSave: (questionParams) => __async(this, null, function* () {
|
924
|
-
const updatedQuestions = [...questions.slice(0, index), questionParams, ...questions.slice(index + 1)];
|
925
|
-
setQuestions(updatedQuestions);
|
926
|
-
const validQuestions = updatedQuestions.filter((question2) => isValidQuestion(question2));
|
927
|
-
yield actions.interactivityCenter.addQuestionsToPoll(id, validQuestions);
|
928
|
-
}),
|
929
|
-
isQuiz,
|
930
|
-
removeQuestion: (questionID) => __async(this, null, function* () {
|
931
|
-
const updatedQuestions = questions.filter((questionFromSet) => questionID !== (questionFromSet == null ? void 0 : questionFromSet.draftID));
|
932
|
-
setQuestions(updatedQuestions);
|
933
|
-
const validQuestions = updatedQuestions.filter((question2) => isValidQuestion(question2));
|
934
|
-
yield actions.interactivityCenter.addQuestionsToPoll(id, validQuestions);
|
935
|
-
}),
|
936
|
-
convertToDraft: (questionID) => setQuestions((prev) => {
|
937
|
-
const copyOfQuestions = [...prev];
|
938
|
-
copyOfQuestions.forEach((question2) => {
|
939
|
-
if (questionID && question2.draftID === questionID) {
|
940
|
-
question2.saved = false;
|
941
|
-
}
|
942
|
-
});
|
943
|
-
return copyOfQuestions;
|
944
|
-
})
|
945
|
-
}
|
946
|
-
))), /* @__PURE__ */ React13.createElement(
|
947
|
-
Flex,
|
948
|
-
{
|
949
|
-
css: {
|
950
|
-
c: "$on_surface_low",
|
951
|
-
my: "$sm",
|
952
|
-
cursor: "pointer",
|
953
|
-
"&:hover": { c: "$on_surface_medium" }
|
954
|
-
},
|
955
|
-
onClick: () => setQuestions([...questions, { draftID: uuid() }])
|
956
|
-
},
|
957
|
-
/* @__PURE__ */ React13.createElement(AddCircleIcon2, null),
|
958
|
-
/* @__PURE__ */ React13.createElement(Text, { variant: "body1", css: { ml: "$md", c: "$inherit" } }, "Add another question")
|
959
|
-
), /* @__PURE__ */ React13.createElement(Flex, { css: { w: "100%" }, justify: "end" }, /* @__PURE__ */ React13.createElement(Button, { disabled: !isValidPoll, onClick: () => __async(this, null, function* () {
|
960
|
-
return launchPoll();
|
961
|
-
}) }, "Launch ", interaction == null ? void 0 : interaction.type))));
|
962
|
-
}
|
963
|
-
var QuestionCard = ({ question, onSave, index, length, removeQuestion, isQuiz, convertToDraft }) => {
|
964
|
-
return /* @__PURE__ */ React13.createElement(Flex, { direction: "column", css: { p: "$md", bg: "$surface_default", r: "$1", mb: "$sm" } }, question.saved ? /* @__PURE__ */ React13.createElement(SavedQuestion, { question, index, length, convertToDraft }) : /* @__PURE__ */ React13.createElement(
|
965
|
-
QuestionForm,
|
966
|
-
{
|
967
|
-
question,
|
968
|
-
removeQuestion: () => removeQuestion(question.draftID),
|
969
|
-
onSave: (params) => onSave(params),
|
970
|
-
index,
|
971
|
-
length,
|
972
|
-
isQuiz
|
973
|
-
}
|
974
|
-
));
|
975
|
-
};
|
976
|
-
|
977
|
-
// src/Prebuilt/components/Polls/Voting/LeaderboardSummary.tsx
|
978
|
-
init_define_process_env();
|
979
|
-
import React17, { useState as useState5 } from "react";
|
980
|
-
import { selectPollByID as selectPollByID3, useHMSStore as useHMSStore6 } from "@100mslive/react-sdk";
|
981
|
-
import { ChevronLeftIcon as ChevronLeftIcon2, ChevronRightIcon as ChevronRightIcon2, CrossIcon as CrossIcon3 } from "@100mslive/react-icons";
|
982
|
-
|
983
|
-
// src/Prebuilt/components/Polls/Voting/LeaderboardEntry.tsx
|
984
|
-
init_define_process_env();
|
985
|
-
import React14 from "react";
|
986
|
-
import { CheckCircleIcon as CheckCircleIcon4, ClockIcon, TrophyFilledIcon } from "@100mslive/react-icons";
|
987
|
-
var positionColorMap = { 1: "#D69516", 2: "#3E3E3E", 3: "#583B0F" };
|
988
|
-
var LeaderboardEntry = ({
|
989
|
-
position,
|
990
|
-
score,
|
991
|
-
questionCount,
|
992
|
-
correctResponses,
|
993
|
-
userName,
|
994
|
-
maxPossibleScore,
|
995
|
-
duration
|
996
|
-
}) => {
|
997
|
-
return /* @__PURE__ */ React14.createElement(Flex, { align: "center", justify: "between", css: { my: "$8" } }, /* @__PURE__ */ React14.createElement(Flex, { align: "center", css: { gap: "$6" } }, /* @__PURE__ */ React14.createElement(
|
998
|
-
Flex,
|
999
|
-
{
|
1000
|
-
align: "center",
|
1001
|
-
justify: "center",
|
1002
|
-
css: {
|
1003
|
-
backgroundColor: positionColorMap[position] || "",
|
1004
|
-
h: "$10",
|
1005
|
-
w: "$10",
|
1006
|
-
borderRadius: "$round",
|
1007
|
-
color: position > 3 ? "$on_surface_low" : "#FFF",
|
1008
|
-
fontSize: "$xs",
|
1009
|
-
fontWeight: "$semiBold"
|
1010
|
-
}
|
1011
|
-
},
|
1012
|
-
position
|
1013
|
-
), /* @__PURE__ */ React14.createElement(Box, null, /* @__PURE__ */ React14.createElement(Text, { variant: "sm", css: { fontWeight: "$semiBold", color: "$on_surface_high" } }, userName), /* @__PURE__ */ React14.createElement(Text, { variant: "sm", css: { mt: "$1" } }, score, " / ", maxPossibleScore, " points"))), /* @__PURE__ */ React14.createElement(Flex, { align: "center", css: { gap: "$4", color: "$on_surface_medium" } }, position === 1 && score ? /* @__PURE__ */ React14.createElement(TrophyFilledIcon, { height: 16, width: 16 }) : null, questionCount ? /* @__PURE__ */ React14.createElement(React14.Fragment, null, /* @__PURE__ */ React14.createElement(CheckCircleIcon4, { height: 16, width: 16 }), /* @__PURE__ */ React14.createElement(Text, { variant: "xs" }, correctResponses, "/", questionCount)) : null, duration ? /* @__PURE__ */ React14.createElement(Flex, { align: "center", css: { gap: "$2", color: "$on_surface_medium" } }, /* @__PURE__ */ React14.createElement(ClockIcon, { height: 16, width: 16 }), /* @__PURE__ */ React14.createElement(Text, { variant: "xs" }, getFormattedTime(duration))) : null));
|
1014
|
-
};
|
1015
|
-
|
1016
|
-
// src/Prebuilt/components/Polls/Voting/PeerParticipationSummary.tsx
|
1017
|
-
init_define_process_env();
|
1018
|
-
import React16 from "react";
|
1019
|
-
import { selectLocalPeerID, useHMSStore as useHMSStore5 } from "@100mslive/react-sdk";
|
1020
|
-
|
1021
|
-
// src/Prebuilt/components/Polls/Voting/StatisticBox.tsx
|
1022
|
-
init_define_process_env();
|
1023
|
-
import React15 from "react";
|
1024
|
-
var StatisticBox = ({ title, value = 0 }) => {
|
1025
|
-
if (!value && !(typeof value === "number")) {
|
1026
|
-
return /* @__PURE__ */ React15.createElement(React15.Fragment, null);
|
1027
|
-
}
|
1028
|
-
return /* @__PURE__ */ React15.createElement(Box, { css: { p: "$8", background: "$surface_default", borderRadius: "$1", w: "100%" } }, /* @__PURE__ */ React15.createElement(
|
1029
|
-
Text,
|
1030
|
-
{
|
1031
|
-
variant: "tiny",
|
1032
|
-
css: { textTransform: "uppercase", color: "$on_surface_medium", fontWeight: "$semiBold", my: "$4" }
|
1033
|
-
},
|
1034
|
-
title
|
1035
|
-
), /* @__PURE__ */ React15.createElement(Text, { css: { fontWeight: "$semiBold" } }, value));
|
1036
|
-
};
|
1037
|
-
|
1038
|
-
// src/Prebuilt/components/Polls/Voting/useQuizSummary.tsx
|
1039
|
-
init_define_process_env();
|
1040
|
-
import { useEffect as useEffect2, useState as useState4 } from "react";
|
1041
|
-
import {
|
1042
|
-
selectPollByID as selectPollByID2,
|
1043
|
-
useHMSActions as useHMSActions3,
|
1044
|
-
useHMSStore as useHMSStore4
|
1045
|
-
} from "@100mslive/react-sdk";
|
1046
|
-
var useQuizSummary = (quizID) => {
|
1047
|
-
const hmsActions = useHMSActions3();
|
1048
|
-
const quiz = useHMSStore4(selectPollByID2(quizID));
|
1049
|
-
const [quizLeaderboard, setQuizLeaderboard] = useState4();
|
1050
|
-
const summary = (quizLeaderboard == null ? void 0 : quizLeaderboard.summary) || {
|
1051
|
-
totalUsers: 0,
|
1052
|
-
votedUsers: 0,
|
1053
|
-
avgScore: 0,
|
1054
|
-
avgTime: 0,
|
1055
|
-
correctUsers: 0
|
1056
|
-
};
|
1057
|
-
const [calculations, setCalculations] = useState4({ maxPossibleScore: 0, totalResponses: 0 });
|
1058
|
-
useEffect2(() => {
|
1059
|
-
const fetchLeaderboardData = () => __async(void 0, null, function* () {
|
1060
|
-
var _a;
|
1061
|
-
if (!quizLeaderboard && quiz && !(quiz == null ? void 0 : quiz.anonymous) && quiz.state === "stopped") {
|
1062
|
-
const leaderboardData = yield hmsActions.interactivityCenter.fetchLeaderboard(quiz.id, 0, 50);
|
1063
|
-
const { maxPossibleScore, totalResponses } = ((_a = quiz == null ? void 0 : quiz.questions) == null ? void 0 : _a.reduce((accumulator, question) => {
|
1064
|
-
var _a2;
|
1065
|
-
accumulator.maxPossibleScore += question.weight || 0;
|
1066
|
-
accumulator.totalResponses += ((_a2 = question == null ? void 0 : question.responses) == null ? void 0 : _a2.length) || 0;
|
1067
|
-
return accumulator;
|
1068
|
-
}, calculations)) || calculations;
|
1069
|
-
setQuizLeaderboard(leaderboardData);
|
1070
|
-
setCalculations({ maxPossibleScore, totalResponses });
|
1071
|
-
}
|
1072
|
-
});
|
1073
|
-
fetchLeaderboardData();
|
1074
|
-
}, [quiz, hmsActions.interactivityCenter, quizLeaderboard, calculations]);
|
1075
|
-
return {
|
1076
|
-
quizLeaderboard,
|
1077
|
-
summary,
|
1078
|
-
maxPossibleScore: calculations.maxPossibleScore,
|
1079
|
-
totalResponses: calculations.totalResponses
|
1080
|
-
};
|
1081
|
-
};
|
1082
|
-
|
1083
|
-
// src/Prebuilt/components/Polls/Voting/PeerParticipationSummary.tsx
|
1084
|
-
var PeerParticipationSummary = ({ quiz }) => {
|
1085
|
-
const localPeerId = useHMSStore5(selectLocalPeerID);
|
1086
|
-
const { quizLeaderboard, summary } = useQuizSummary(quiz.id);
|
1087
|
-
if (quiz.state !== "stopped") {
|
1088
|
-
return /* @__PURE__ */ React16.createElement(React16.Fragment, null);
|
1089
|
-
}
|
1090
|
-
const isLocalPeerQuizCreator = localPeerId === quiz.startedBy;
|
1091
|
-
const peerEntry = quizLeaderboard == null ? void 0 : quizLeaderboard.entries.find((entry) => {
|
1092
|
-
var _a;
|
1093
|
-
return ((_a = entry.peer) == null ? void 0 : _a.peerid) === localPeerId;
|
1094
|
-
});
|
1095
|
-
const boxes = isLocalPeerQuizCreator ? [
|
1096
|
-
{
|
1097
|
-
title: "Voted",
|
1098
|
-
value: `${summary.totalUsers ? (100 * summary.votedUsers / summary.totalUsers).toFixed(0) : 0}% (${summary.votedUsers}/${summary.totalUsers})`
|
1099
|
-
},
|
1100
|
-
{
|
1101
|
-
title: "Correct Answers",
|
1102
|
-
value: `${summary.totalUsers ? (100 * summary.correctUsers / summary.totalUsers).toFixed(0) : 0}% (${summary.correctUsers}/${summary.totalUsers})`
|
1103
|
-
},
|
1104
|
-
// Time in ms
|
1105
|
-
{ title: "Avg. Time Taken", value: getFormattedTime(summary.avgTime) },
|
1106
|
-
{
|
1107
|
-
title: "Avg. Score",
|
1108
|
-
value: Number.isInteger(summary.avgScore) ? summary.avgScore : summary.avgScore.toFixed(2)
|
1109
|
-
}
|
1110
|
-
] : [
|
1111
|
-
{ title: "Your rank", value: (peerEntry == null ? void 0 : peerEntry.position) || "-" },
|
1112
|
-
{ title: "Points", value: (peerEntry == null ? void 0 : peerEntry.score) || 0 },
|
1113
|
-
// Time in ms
|
1114
|
-
{ title: "Time Taken", value: getFormattedTime(peerEntry == null ? void 0 : peerEntry.duration) },
|
1115
|
-
{
|
1116
|
-
title: "Correct Answers",
|
1117
|
-
value: (peerEntry == null ? void 0 : peerEntry.totalResponses) ? `${peerEntry == null ? void 0 : peerEntry.correctResponses}/${peerEntry.totalResponses}` : "-"
|
1118
|
-
}
|
1119
|
-
];
|
1120
|
-
return /* @__PURE__ */ React16.createElement(Box, null, /* @__PURE__ */ React16.createElement(Text, { css: { fontWeight: "$semiBold", my: "$8" } }, "Participation Summary"), /* @__PURE__ */ React16.createElement(Box, { css: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: "$4" } }, boxes.map((box) => /* @__PURE__ */ React16.createElement(StatisticBox, { key: box.title, title: box.title, value: box.value }))));
|
1121
|
-
};
|
1122
|
-
|
1123
|
-
// src/Prebuilt/components/Polls/Voting/LeaderboardSummary.tsx
|
1124
|
-
var LeaderboardSummary = ({ pollID }) => {
|
1125
|
-
var _a, _b;
|
1126
|
-
const quiz = useHMSStore6(selectPollByID3(pollID));
|
1127
|
-
const { quizLeaderboard, maxPossibleScore } = useQuizSummary(pollID);
|
1128
|
-
const [viewAllEntries, setViewAllEntries] = useState5(false);
|
1129
|
-
const { setPollView } = usePollViewState();
|
1130
|
-
const toggleSidepane = useSidepaneToggle();
|
1131
|
-
if (!quiz || !quizLeaderboard)
|
1132
|
-
return /* @__PURE__ */ React17.createElement(Flex, { align: "center", justify: "center", css: { size: "100%" } }, /* @__PURE__ */ React17.createElement(Loading, null));
|
1133
|
-
const questionCount = ((_a = quiz.questions) == null ? void 0 : _a.length) || 0;
|
1134
|
-
return /* @__PURE__ */ React17.createElement(Container, { rounded: true }, /* @__PURE__ */ React17.createElement(Flex, { direction: "column", css: { size: "100%", p: "$8" } }, /* @__PURE__ */ React17.createElement(Flex, { justify: "between", align: "center", css: { pb: "$6", borderBottom: "1px solid $border_bright", mb: "$8" } }, /* @__PURE__ */ React17.createElement(Flex, { align: "center", css: { gap: "$4" } }, /* @__PURE__ */ React17.createElement(
|
1135
|
-
Flex,
|
1136
|
-
{
|
1137
|
-
css: { color: "$on_surface_medium", "&:hover": { color: "$on_surface_high", cursor: "pointer" } },
|
1138
|
-
onClick: () => setPollView(POLL_VIEWS.VOTE)
|
1139
|
-
},
|
1140
|
-
/* @__PURE__ */ React17.createElement(ChevronLeftIcon2, null)
|
1141
|
-
), /* @__PURE__ */ React17.createElement(Text, { variant: "lg", css: { fontWeight: "$semiBold" } }, quiz.title), /* @__PURE__ */ React17.createElement(StatusIndicator, { status: quiz.state })), /* @__PURE__ */ React17.createElement(
|
1142
|
-
Flex,
|
1143
|
-
{
|
1144
|
-
css: { color: "$on_surface_medium", "&:hover": { color: "$on_surface_high", cursor: "pointer" } },
|
1145
|
-
onClick: toggleSidepane
|
1146
|
-
},
|
1147
|
-
/* @__PURE__ */ React17.createElement(CrossIcon3, null)
|
1148
|
-
)), /* @__PURE__ */ React17.createElement(Box, { css: { overflowY: "auto", mr: "-$4", pr: "$4" } }, !viewAllEntries ? /* @__PURE__ */ React17.createElement(PeerParticipationSummary, { quiz }) : null, /* @__PURE__ */ React17.createElement(Text, { variant: "sm", css: { fontWeight: "$semiBold", mt: "$4" } }, "Leaderboard"), /* @__PURE__ */ React17.createElement(Text, { variant: "xs", css: { color: "$on_surface_medium" } }, "Based on score and time taken to cast the correct answer"), /* @__PURE__ */ React17.createElement(
|
1149
|
-
Box,
|
1150
|
-
{
|
1151
|
-
css: {
|
1152
|
-
mt: "$8",
|
1153
|
-
overflowY: "auto",
|
1154
|
-
flex: viewAllEntries ? "1 1 0" : "unset",
|
1155
|
-
mr: viewAllEntries ? "-$6" : "unset",
|
1156
|
-
px: viewAllEntries ? "0" : "$4",
|
1157
|
-
pr: viewAllEntries ? "$6" : "$4",
|
1158
|
-
backgroundColor: viewAllEntries ? "" : "$surface_default",
|
1159
|
-
borderRadius: "$1"
|
1160
|
-
}
|
1161
|
-
},
|
1162
|
-
(quizLeaderboard == null ? void 0 : quizLeaderboard.entries) && quizLeaderboard.entries.slice(0, viewAllEntries ? void 0 : 5).map((question) => /* @__PURE__ */ React17.createElement(
|
1163
|
-
LeaderboardEntry,
|
1164
|
-
{
|
1165
|
-
key: question.position,
|
1166
|
-
position: question.position,
|
1167
|
-
score: question.score,
|
1168
|
-
questionCount,
|
1169
|
-
correctResponses: question.correctResponses,
|
1170
|
-
userName: question.peer.username || "",
|
1171
|
-
maxPossibleScore,
|
1172
|
-
duration: question.duration
|
1173
|
-
}
|
1174
|
-
)),
|
1175
|
-
((_b = quizLeaderboard == null ? void 0 : quizLeaderboard.entries) == null ? void 0 : _b.length) > 5 && !viewAllEntries ? /* @__PURE__ */ React17.createElement(
|
1176
|
-
Flex,
|
1177
|
-
{
|
1178
|
-
align: "center",
|
1179
|
-
justify: "end",
|
1180
|
-
css: {
|
1181
|
-
w: "100%",
|
1182
|
-
borderTop: "1px solid $border_bright",
|
1183
|
-
cursor: "pointer",
|
1184
|
-
color: "$on_surface_high",
|
1185
|
-
p: "$6 $2"
|
1186
|
-
},
|
1187
|
-
onClick: () => setViewAllEntries(true)
|
1188
|
-
},
|
1189
|
-
/* @__PURE__ */ React17.createElement(Text, { variant: "sm" }, "View All"),
|
1190
|
-
" ",
|
1191
|
-
/* @__PURE__ */ React17.createElement(ChevronRightIcon2, null)
|
1192
|
-
) : null
|
1193
|
-
))));
|
1194
|
-
};
|
1195
|
-
|
1196
|
-
// src/Prebuilt/components/Polls/Voting/Voting.tsx
|
1197
|
-
init_define_process_env();
|
1198
|
-
import React21, { useEffect as useEffect5, useRef as useRef4, useState as useState8 } from "react";
|
1199
|
-
import {
|
1200
|
-
selectLocalPeer as selectLocalPeer2,
|
1201
|
-
selectPeerNameByID,
|
1202
|
-
selectPermissions as selectPermissions3,
|
1203
|
-
selectPollByID as selectPollByID4,
|
1204
|
-
useHMSActions as useHMSActions5,
|
1205
|
-
useHMSStore as useHMSStore8
|
1206
|
-
} from "@100mslive/react-sdk";
|
1207
|
-
import { ChevronLeftIcon as ChevronLeftIcon3, CrossIcon as CrossIcon4 } from "@100mslive/react-icons";
|
1208
|
-
|
1209
|
-
// src/Prebuilt/components/Polls/Voting/StandardVoting.tsx
|
1210
|
-
init_define_process_env();
|
1211
|
-
import React19 from "react";
|
1212
|
-
|
1213
|
-
// src/Prebuilt/components/Polls/Voting/QuestionCard.jsx
|
1214
|
-
init_define_process_env();
|
1215
|
-
import React18, { useCallback as useCallback2, useEffect as useEffect3, useMemo as useMemo4, useRef as useRef3, useState as useState6 } from "react";
|
1216
|
-
import { match } from "ts-pattern";
|
1217
|
-
import { selectLocalPeer, selectLocalPeerRoleName as selectLocalPeerRoleName2, useHMSActions as useHMSActions4, useHMSStore as useHMSStore7 } from "@100mslive/react-sdk";
|
1218
|
-
import { CheckCircleIcon as CheckCircleIcon5, ChevronDownIcon, CrossCircleIcon } from "@100mslive/react-icons";
|
1219
|
-
var QuestionCard2 = ({
|
1220
|
-
pollID,
|
1221
|
-
isQuiz,
|
1222
|
-
startedBy,
|
1223
|
-
pollState,
|
1224
|
-
index,
|
1225
|
-
totalQuestions,
|
1226
|
-
result,
|
1227
|
-
type,
|
1228
|
-
text,
|
1229
|
-
options = [],
|
1230
|
-
answer,
|
1231
|
-
localPeerResponse,
|
1232
|
-
updateSavedResponses,
|
1233
|
-
rolesThatCanViewResponses
|
1234
|
-
}) => {
|
1235
|
-
const actions = useHMSActions4();
|
1236
|
-
const localPeer = useHMSStore7(selectLocalPeer);
|
1237
|
-
const isLocalPeerCreator = (localPeer == null ? void 0 : localPeer.id) === startedBy;
|
1238
|
-
const localPeerRoleName = useHMSStore7(selectLocalPeerRoleName2);
|
1239
|
-
const roleCanViewResponse = !rolesThatCanViewResponses || rolesThatCanViewResponses.length === 0 || rolesThatCanViewResponses.includes(localPeerRoleName || "");
|
1240
|
-
const [localPeerChoice, setLocalPeerChoice] = useState6(localPeerResponse);
|
1241
|
-
useEffect3(() => {
|
1242
|
-
setLocalPeerChoice(localPeerResponse);
|
1243
|
-
}, [localPeerResponse]);
|
1244
|
-
const showVoteCount = roleCanViewResponse && (localPeerChoice || isLocalPeerCreator && pollState === "stopped") && !isQuiz;
|
1245
|
-
const isLive = pollState === "started";
|
1246
|
-
const pollEnded = pollState === "stopped";
|
1247
|
-
const canRespond = isLive && !localPeerChoice;
|
1248
|
-
const startTime = useRef3(Date.now());
|
1249
|
-
const isCorrectAnswer = checkCorrectAnswer(answer, localPeerChoice, type);
|
1250
|
-
const [singleOptionAnswer, setSingleOptionAnswer] = useState6();
|
1251
|
-
const [multipleOptionAnswer, setMultipleOptionAnswer] = useState6(/* @__PURE__ */ new Set());
|
1252
|
-
const [showOptions, setShowOptions] = useState6(true);
|
1253
|
-
const respondedToQuiz = isQuiz && localPeerChoice && !localPeerChoice.skipped;
|
1254
|
-
const isValidVote = useMemo4(() => {
|
1255
|
-
if (type === "single-choice" /* SINGLE_CHOICE */) {
|
1256
|
-
return singleOptionAnswer !== void 0;
|
1257
|
-
} else if (type === "multiple-choice" /* MULTIPLE_CHOICE */) {
|
1258
|
-
return multipleOptionAnswer.size > 0;
|
1259
|
-
}
|
1260
|
-
}, [singleOptionAnswer, multipleOptionAnswer, type]);
|
1261
|
-
const handleVote = useCallback2(() => __async(void 0, null, function* () {
|
1262
|
-
if (!isValidVote) {
|
1263
|
-
return;
|
1264
|
-
}
|
1265
|
-
const submittedResponse = {
|
1266
|
-
questionIndex: index,
|
1267
|
-
option: singleOptionAnswer,
|
1268
|
-
options: Array.from(multipleOptionAnswer),
|
1269
|
-
duration: Date.now() - startTime.current
|
1270
|
-
};
|
1271
|
-
yield actions.interactivityCenter.addResponsesToPoll(pollID, [submittedResponse]);
|
1272
|
-
updateSavedResponses((prev) => {
|
1273
|
-
const prevCopy = __spreadValues({}, prev);
|
1274
|
-
prevCopy[index] = { option: singleOptionAnswer, options: Array.from(multipleOptionAnswer) };
|
1275
|
-
return prevCopy;
|
1276
|
-
});
|
1277
|
-
startTime.current = Date.now();
|
1278
|
-
}), [
|
1279
|
-
isValidVote,
|
1280
|
-
index,
|
1281
|
-
singleOptionAnswer,
|
1282
|
-
multipleOptionAnswer,
|
1283
|
-
actions.interactivityCenter,
|
1284
|
-
pollID,
|
1285
|
-
updateSavedResponses
|
1286
|
-
]);
|
1287
|
-
return /* @__PURE__ */ React18.createElement(
|
1288
|
-
Box,
|
1289
|
-
{
|
1290
|
-
css: {
|
1291
|
-
backgroundColor: "$surface_bright",
|
1292
|
-
borderRadius: "$1",
|
1293
|
-
p: "$md",
|
1294
|
-
mt: "$md",
|
1295
|
-
border: respondedToQuiz && !isLive ? `1px solid ${isCorrectAnswer ? "$alert_success" : "$alert_error_default"}` : "none"
|
1296
|
-
}
|
1297
|
-
},
|
1298
|
-
/* @__PURE__ */ React18.createElement(Flex, { align: "center", justify: "between" }, /* @__PURE__ */ React18.createElement(
|
1299
|
-
Text,
|
1300
|
-
{
|
1301
|
-
variant: "caption",
|
1302
|
-
css: {
|
1303
|
-
color: match({ respondedToQuiz, isLive, isCorrectAnswer }).when(
|
1304
|
-
({ respondedToQuiz: respondedToQuiz2, isLive: isLive2 }) => respondedToQuiz2 && !isLive2,
|
1305
|
-
({ isCorrectAnswer: isCorrectAnswer2 }) => isCorrectAnswer2 ? "$alert_success" : "$alert_error_default"
|
1306
|
-
).otherwise(() => "$on_surface_low"),
|
1307
|
-
fontWeight: "$semiBold",
|
1308
|
-
display: "flex",
|
1309
|
-
alignItems: "center",
|
1310
|
-
gap: "$4"
|
1311
|
-
}
|
1312
|
-
},
|
1313
|
-
match({ respondedToQuiz, pollEnded, isCorrectAnswer }).when(
|
1314
|
-
({ respondedToQuiz: respondedToQuiz2, pollEnded: pollEnded2 }) => respondedToQuiz2 && pollEnded2,
|
1315
|
-
({ isCorrectAnswer: isCorrectAnswer2 }) => {
|
1316
|
-
return isCorrectAnswer2 ? /* @__PURE__ */ React18.createElement(CheckCircleIcon5, { height: 16, width: 16 }) : /* @__PURE__ */ React18.createElement(CrossCircleIcon, { height: 16, width: 16 });
|
1317
|
-
}
|
1318
|
-
).otherwise(() => null),
|
1319
|
-
"QUESTION ",
|
1320
|
-
index,
|
1321
|
-
" OF ",
|
1322
|
-
totalQuestions,
|
1323
|
-
": ",
|
1324
|
-
type.toUpperCase()
|
1325
|
-
)),
|
1326
|
-
/* @__PURE__ */ React18.createElement(Flex, { justify: "between", css: { my: "$md" } }, /* @__PURE__ */ React18.createElement(Text, { css: { color: "$on_surface_high" } }, text), /* @__PURE__ */ React18.createElement(
|
1327
|
-
Box,
|
1328
|
-
{
|
1329
|
-
css: { color: "$on_surface_medium", "&:hover": { color: "$on_surface_high", cursor: "pointer" } },
|
1330
|
-
onClick: () => setShowOptions((prev) => !prev)
|
1331
|
-
},
|
1332
|
-
/* @__PURE__ */ React18.createElement(
|
1333
|
-
ChevronDownIcon,
|
1334
|
-
{
|
1335
|
-
style: { transform: showOptions ? "rotate(180deg)" : "rotate(0deg)", transition: "transform 0.3s ease" }
|
1336
|
-
}
|
1337
|
-
)
|
1338
|
-
)),
|
1339
|
-
/* @__PURE__ */ React18.createElement(
|
1340
|
-
Box,
|
1341
|
-
{
|
1342
|
-
css: { maxHeight: showOptions ? "$80" : "0", transition: "max-height 0.3s ease", overflowY: "auto", mb: "$4" }
|
1343
|
-
},
|
1344
|
-
type === "single-choice" /* SINGLE_CHOICE */ ? /* @__PURE__ */ React18.createElement(
|
1345
|
-
SingleChoiceOptions,
|
1346
|
-
{
|
1347
|
-
key: index,
|
1348
|
-
questionIndex: index,
|
1349
|
-
isQuiz,
|
1350
|
-
canRespond,
|
1351
|
-
correctOptionIndex: answer == null ? void 0 : answer.option,
|
1352
|
-
options,
|
1353
|
-
setAnswer: setSingleOptionAnswer,
|
1354
|
-
totalResponses: result == null ? void 0 : result.totalResponses,
|
1355
|
-
showVoteCount,
|
1356
|
-
localPeerResponse: localPeerChoice,
|
1357
|
-
isStopped: pollState === "stopped"
|
1358
|
-
}
|
1359
|
-
) : null,
|
1360
|
-
type === "multiple-choice" /* MULTIPLE_CHOICE */ ? /* @__PURE__ */ React18.createElement(
|
1361
|
-
MultipleChoiceOptions,
|
1362
|
-
{
|
1363
|
-
questionIndex: index,
|
1364
|
-
isQuiz,
|
1365
|
-
canRespond,
|
1366
|
-
correctOptionIndexes: answer == null ? void 0 : answer.options,
|
1367
|
-
options,
|
1368
|
-
selectedOptions: multipleOptionAnswer,
|
1369
|
-
setSelectedOptions: setMultipleOptionAnswer,
|
1370
|
-
totalResponses: result == null ? void 0 : result.totalResponses,
|
1371
|
-
showVoteCount,
|
1372
|
-
localPeerResponse: localPeerChoice,
|
1373
|
-
isStopped: pollState === "stopped"
|
1374
|
-
}
|
1375
|
-
) : null
|
1376
|
-
),
|
1377
|
-
isLive && /* @__PURE__ */ React18.createElement(QuestionActions, { isValidVote, onVote: handleVote, response: localPeerChoice, isQuiz })
|
1378
|
-
);
|
1379
|
-
};
|
1380
|
-
var QuestionActions = ({ isValidVote, response, isQuiz, onVote }) => {
|
1381
|
-
return /* @__PURE__ */ React18.createElement(Flex, { align: "center", justify: "end", css: { gap: "$4", w: "100%" } }, response ? /* @__PURE__ */ React18.createElement(Text, { css: { fontWeight: "$semiBold", color: "$on_surface_medium" } }, response.skipped ? "Skipped" : null, isQuiz && !response.skipped ? "Answered" : null, !isQuiz && !response.skipped ? "Voted" : null) : /* @__PURE__ */ React18.createElement(Button, { css: { p: "$xs $10", fontWeight: "$semiBold" }, disabled: !isValidVote, onClick: onVote }, isQuiz ? "Answer" : "Vote"));
|
1382
|
-
};
|
1383
|
-
|
1384
|
-
// src/Prebuilt/components/Polls/Voting/StandardVoting.tsx
|
1385
|
-
var StandardView = ({
|
1386
|
-
poll,
|
1387
|
-
localPeerResponses,
|
1388
|
-
updateSavedResponses
|
1389
|
-
}) => {
|
1390
|
-
var _a;
|
1391
|
-
if (!(poll == null ? void 0 : poll.questions)) {
|
1392
|
-
return null;
|
1393
|
-
}
|
1394
|
-
const isQuiz = poll.type === "quiz";
|
1395
|
-
const isStopped = poll.state === "stopped";
|
1396
|
-
return /* @__PURE__ */ React19.createElement(React19.Fragment, null, isQuiz && isStopped ? /* @__PURE__ */ React19.createElement(PeerParticipationSummary, { quiz: poll }) : null, (_a = poll.questions) == null ? void 0 : _a.map((question, index) => {
|
1397
|
-
var _a2;
|
1398
|
-
return /* @__PURE__ */ React19.createElement(
|
1399
|
-
QuestionCard2,
|
1400
|
-
{
|
1401
|
-
pollID: poll.id,
|
1402
|
-
isQuiz,
|
1403
|
-
startedBy: poll.startedBy,
|
1404
|
-
pollState: poll.state,
|
1405
|
-
key: `${question.text}-${index}`,
|
1406
|
-
index: question.index,
|
1407
|
-
text: question.text,
|
1408
|
-
type: question.type,
|
1409
|
-
result: question.result,
|
1410
|
-
totalQuestions: ((_a2 = poll.questions) == null ? void 0 : _a2.length) || 0,
|
1411
|
-
options: question.options,
|
1412
|
-
localPeerResponse: localPeerResponses == null ? void 0 : localPeerResponses[question.index],
|
1413
|
-
answer: question.answer,
|
1414
|
-
updateSavedResponses,
|
1415
|
-
rolesThatCanViewResponses: poll.rolesThatCanViewResponses
|
1416
|
-
}
|
1417
|
-
);
|
1418
|
-
}));
|
1419
|
-
};
|
1420
|
-
|
1421
|
-
// src/Prebuilt/components/Polls/Voting/TimedVoting.tsx
|
1422
|
-
init_define_process_env();
|
1423
|
-
import React20, { useEffect as useEffect4, useState as useState7 } from "react";
|
1424
|
-
var TimedView = ({
|
1425
|
-
poll,
|
1426
|
-
localPeerResponses,
|
1427
|
-
updateSavedResponses
|
1428
|
-
}) => {
|
1429
|
-
var _a, _b, _c;
|
1430
|
-
const [currentIndex, setCurrentIndex] = useState7(getIndexToShow(localPeerResponses));
|
1431
|
-
const activeQuestion = (_a = poll.questions) == null ? void 0 : _a.find((question) => question.index === currentIndex);
|
1432
|
-
const attemptedAll = (((_b = poll.questions) == null ? void 0 : _b.length) || 0) < currentIndex;
|
1433
|
-
useEffect4(() => {
|
1434
|
-
setCurrentIndex(getIndexToShow(localPeerResponses));
|
1435
|
-
}, [localPeerResponses]);
|
1436
|
-
if (!activeQuestion && !attemptedAll || !((_c = poll.questions) == null ? void 0 : _c.length)) {
|
1437
|
-
return null;
|
1438
|
-
}
|
1439
|
-
return /* @__PURE__ */ React20.createElement(React20.Fragment, null, poll.questions.map((question) => {
|
1440
|
-
var _a2;
|
1441
|
-
return attemptedAll || (activeQuestion == null ? void 0 : activeQuestion.index) === question.index ? /* @__PURE__ */ React20.createElement(
|
1442
|
-
QuestionCard2,
|
1443
|
-
{
|
1444
|
-
key: question.index,
|
1445
|
-
pollID: poll.id,
|
1446
|
-
isQuiz: poll.type === "quiz",
|
1447
|
-
startedBy: poll.startedBy,
|
1448
|
-
pollState: poll.state,
|
1449
|
-
index: question.index,
|
1450
|
-
text: question.text,
|
1451
|
-
type: question.type,
|
1452
|
-
result: question == null ? void 0 : question.result,
|
1453
|
-
totalQuestions: ((_a2 = poll.questions) == null ? void 0 : _a2.length) || 0,
|
1454
|
-
options: question.options,
|
1455
|
-
localPeerResponse: localPeerResponses == null ? void 0 : localPeerResponses[question.index],
|
1456
|
-
answer: question.answer,
|
1457
|
-
rolesThatCanViewResponses: poll.rolesThatCanViewResponses,
|
1458
|
-
updateSavedResponses
|
1459
|
-
}
|
1460
|
-
) : null;
|
1461
|
-
}));
|
1462
|
-
};
|
1463
|
-
|
1464
|
-
// src/Prebuilt/components/Polls/Voting/Voting.tsx
|
1465
|
-
var Voting = ({ id, toggleVoting }) => {
|
1466
|
-
const actions = useHMSActions5();
|
1467
|
-
const poll = useHMSStore8(selectPollByID4(id));
|
1468
|
-
const pollCreatorName = useHMSStore8(selectPeerNameByID(poll == null ? void 0 : poll.createdBy));
|
1469
|
-
const permissions = useHMSStore8(selectPermissions3);
|
1470
|
-
const canEndActivity = !!(permissions == null ? void 0 : permissions.pollWrite);
|
1471
|
-
const { setPollView } = usePollViewState();
|
1472
|
-
const showSingleView = (poll == null ? void 0 : poll.type) === "quiz" && poll.state === "started";
|
1473
|
-
const fetchedInitialResponses = useRef4(false);
|
1474
|
-
const [savedResponses, setSavedResponses] = useState8({});
|
1475
|
-
const localPeer = useHMSStore8(selectLocalPeer2);
|
1476
|
-
const localPeerId = localPeer == null ? void 0 : localPeer.id;
|
1477
|
-
const customerUserId = localPeer == null ? void 0 : localPeer.customerUserId;
|
1478
|
-
useEffect5(() => {
|
1479
|
-
fetchedInitialResponses.current = false;
|
1480
|
-
setSavedResponses({});
|
1481
|
-
}, [id, setSavedResponses]);
|
1482
|
-
useEffect5(() => {
|
1483
|
-
const getResponses = () => __async(void 0, null, function* () {
|
1484
|
-
if (poll && actions.interactivityCenter && !fetchedInitialResponses.current) {
|
1485
|
-
yield actions.interactivityCenter.getPollResponses(poll, true);
|
1486
|
-
fetchedInitialResponses.current = true;
|
1487
|
-
}
|
1488
|
-
});
|
1489
|
-
getResponses();
|
1490
|
-
}, [poll, actions.interactivityCenter]);
|
1491
|
-
useEffect5(() => {
|
1492
|
-
if (poll == null ? void 0 : poll.questions) {
|
1493
|
-
const localPeerResponses = getPeerResponses(poll.questions, localPeerId, customerUserId);
|
1494
|
-
localPeerResponses == null ? void 0 : localPeerResponses.forEach((response) => {
|
1495
|
-
if (response) {
|
1496
|
-
setSavedResponses((prev) => {
|
1497
|
-
var _a, _b, _c;
|
1498
|
-
const prevCopy = __spreadValues({}, prev);
|
1499
|
-
prevCopy[(_a = response[0]) == null ? void 0 : _a.questionIndex] = { option: (_b = response[0]) == null ? void 0 : _b.option, options: (_c = response[0]) == null ? void 0 : _c.options };
|
1500
|
-
return prevCopy;
|
1501
|
-
});
|
1502
|
-
}
|
1503
|
-
});
|
1504
|
-
}
|
1505
|
-
}, [localPeerId, poll == null ? void 0 : poll.questions, id, customerUserId]);
|
1506
|
-
if (!poll) {
|
1507
|
-
return null;
|
1508
|
-
}
|
1509
|
-
const canViewLeaderboard = poll.type === "quiz" && poll.state === "stopped" && !poll.anonymous;
|
1510
|
-
return /* @__PURE__ */ React21.createElement(Container, { rounded: true }, /* @__PURE__ */ React21.createElement(
|
1511
|
-
Flex,
|
1512
|
-
{
|
1513
|
-
align: "center",
|
1514
|
-
css: {
|
1515
|
-
gap: "$4",
|
1516
|
-
py: "$6",
|
1517
|
-
px: "$8",
|
1518
|
-
my: "$4",
|
1519
|
-
w: "100%",
|
1520
|
-
color: "$on_surface_high",
|
1521
|
-
borderBottom: "1px solid $border_default"
|
1522
|
-
}
|
1523
|
-
},
|
1524
|
-
/* @__PURE__ */ React21.createElement(
|
1525
|
-
Flex,
|
1526
|
-
{
|
1527
|
-
onClick: () => setPollView(POLL_VIEWS.CREATE_POLL_QUIZ),
|
1528
|
-
css: { cursor: "pointer", c: "$on_surface_medium", "&:hover": { color: "$on_surface_high" } }
|
1529
|
-
},
|
1530
|
-
/* @__PURE__ */ React21.createElement(ChevronLeftIcon3, null)
|
1531
|
-
),
|
1532
|
-
/* @__PURE__ */ React21.createElement(Text, { variant: "h6" }, poll.title),
|
1533
|
-
/* @__PURE__ */ React21.createElement(StatusIndicator, { status: poll.state }),
|
1534
|
-
/* @__PURE__ */ React21.createElement(
|
1535
|
-
Box,
|
1536
|
-
{
|
1537
|
-
css: {
|
1538
|
-
marginLeft: "auto",
|
1539
|
-
cursor: "pointer",
|
1540
|
-
"&:hover": { opacity: "0.8" },
|
1541
|
-
height: "fit-content"
|
1542
|
-
}
|
1543
|
-
},
|
1544
|
-
/* @__PURE__ */ React21.createElement(CrossIcon4, { onClick: toggleVoting })
|
1545
|
-
)
|
1546
|
-
), /* @__PURE__ */ React21.createElement(Flex, { direction: "column", css: { p: "$8 $10", flex: "1 1 0", overflowY: "auto" } }, poll.state === "started" ? /* @__PURE__ */ React21.createElement(Text, { css: { color: "$on_surface_medium", fontWeight: "$semiBold" } }, pollCreatorName || "Participant", " started a ", poll.type) : null, showSingleView ? /* @__PURE__ */ React21.createElement(TimedView, { poll, localPeerResponses: savedResponses, updateSavedResponses: setSavedResponses }) : /* @__PURE__ */ React21.createElement(StandardView, { poll, localPeerResponses: savedResponses, updateSavedResponses: setSavedResponses })), /* @__PURE__ */ React21.createElement(
|
1547
|
-
Flex,
|
1548
|
-
{
|
1549
|
-
css: { w: "100%", justifyContent: "end", alignItems: "center", p: "$8", borderTop: "1px solid $border_bright" }
|
1550
|
-
},
|
1551
|
-
poll.state === "started" && canEndActivity && /* @__PURE__ */ React21.createElement(
|
1552
|
-
Button,
|
1553
|
-
{
|
1554
|
-
variant: "danger",
|
1555
|
-
css: { fontWeight: "$semiBold", w: "max-content" },
|
1556
|
-
onClick: () => actions.interactivityCenter.stopPoll(id)
|
1557
|
-
},
|
1558
|
-
"End ",
|
1559
|
-
poll.type
|
1560
|
-
),
|
1561
|
-
canViewLeaderboard ? /* @__PURE__ */ React21.createElement(Button, { css: { fontWeight: "$semiBold", w: "max-content" }, onClick: () => setPollView(POLL_VIEWS.RESULTS) }, "View Leaderboard") : null
|
1562
|
-
));
|
1563
|
-
};
|
1564
|
-
|
1565
|
-
// src/Prebuilt/components/Polls/Polls.tsx
|
1566
|
-
var Polls = () => {
|
1567
|
-
const togglePollView = usePollViewToggle();
|
1568
|
-
const { pollInView: pollID, view } = usePollViewState();
|
1569
|
-
if (view === POLL_VIEWS.CREATE_POLL_QUIZ) {
|
1570
|
-
return /* @__PURE__ */ React22.createElement(PollsQuizMenu, null);
|
1571
|
-
} else if (view === POLL_VIEWS.CREATE_QUESTIONS) {
|
1572
|
-
return /* @__PURE__ */ React22.createElement(CreateQuestions, null);
|
1573
|
-
} else if (view === POLL_VIEWS.VOTE) {
|
1574
|
-
return /* @__PURE__ */ React22.createElement(Voting, { toggleVoting: togglePollView, id: pollID });
|
1575
|
-
} else if (view === POLL_VIEWS.RESULTS) {
|
1576
|
-
return /* @__PURE__ */ React22.createElement(LeaderboardSummary, { pollID });
|
1577
|
-
} else {
|
1578
|
-
return null;
|
1579
|
-
}
|
1580
|
-
};
|
1581
|
-
export {
|
1582
|
-
Polls
|
1583
|
-
};
|
1584
|
-
//# sourceMappingURL=Polls-IN3V2HFI.js.map
|