@100mslive/react-native-room-kit 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/README.md +1 -1
  2. package/lib/commonjs/HMSRoomSetup.js +3 -5
  3. package/lib/commonjs/HMSRoomSetup.js.map +1 -1
  4. package/lib/commonjs/Icons/Check/assets/check-in-circle.png +0 -0
  5. package/lib/commonjs/Icons/Check/assets/check-in-circle@2x.png +0 -0
  6. package/lib/commonjs/Icons/Check/assets/check-in-circle@3x.png +0 -0
  7. package/lib/commonjs/Icons/Check/index.js +2 -1
  8. package/lib/commonjs/Icons/Check/index.js.map +1 -1
  9. package/lib/commonjs/Icons/CheckBox/index.js +8 -1
  10. package/lib/commonjs/Icons/CheckBox/index.js.map +1 -1
  11. package/lib/commonjs/components/CreatePoll.js +98 -52
  12. package/lib/commonjs/components/CreatePoll.js.map +1 -1
  13. package/lib/commonjs/components/GridView.js +4 -8
  14. package/lib/commonjs/components/GridView.js.map +1 -1
  15. package/lib/commonjs/components/HMSPollsQuizzesNotification.js +1 -1
  16. package/lib/commonjs/components/HMSPollsQuizzesNotification.js.map +1 -1
  17. package/lib/commonjs/components/PollAndQuizQuestionResponseCard.js +80 -32
  18. package/lib/commonjs/components/PollAndQuizQuestionResponseCard.js.map +1 -1
  19. package/lib/commonjs/components/PollAndQuizQuestionResponseCards.js +53 -0
  20. package/lib/commonjs/components/PollAndQuizQuestionResponseCards.js.map +1 -0
  21. package/lib/commonjs/components/PollAndQuizVoting.js +14 -15
  22. package/lib/commonjs/components/PollAndQuizVoting.js.map +1 -1
  23. package/lib/commonjs/components/PollQuestion.js +70 -14
  24. package/lib/commonjs/components/PollQuestion.js.map +1 -1
  25. package/lib/commonjs/components/PollQuestions.js +22 -8
  26. package/lib/commonjs/components/PollQuestions.js.map +1 -1
  27. package/lib/commonjs/components/PollsAndQuizzesModalContent.js +1 -1
  28. package/lib/commonjs/components/PollsAndQuizzesModalContent.js.map +1 -1
  29. package/lib/commonjs/components/PreviousPollsAndQuizzesList.js +2 -2
  30. package/lib/commonjs/components/PreviousPollsAndQuizzesList.js.map +1 -1
  31. package/lib/commonjs/components/QuizEndOptionsView.js +63 -0
  32. package/lib/commonjs/components/QuizEndOptionsView.js.map +1 -0
  33. package/lib/commonjs/components/RadioInput.js +9 -2
  34. package/lib/commonjs/components/RadioInput.js.map +1 -1
  35. package/lib/commonjs/components/RoomSettingsModalContent.js +1 -1
  36. package/lib/commonjs/components/RoomSettingsModalContent.js.map +1 -1
  37. package/lib/commonjs/components/TilesContainer.js +3 -4
  38. package/lib/commonjs/components/TilesContainer.js.map +1 -1
  39. package/lib/commonjs/hooks-util.js +1 -1
  40. package/lib/commonjs/hooks-util.js.map +1 -1
  41. package/lib/commonjs/redux/actionTypes.js +2 -0
  42. package/lib/commonjs/redux/actionTypes.js.map +1 -1
  43. package/lib/commonjs/redux/actions/index.js +14 -1
  44. package/lib/commonjs/redux/actions/index.js.map +1 -1
  45. package/lib/commonjs/redux/reducers/polls.js +30 -3
  46. package/lib/commonjs/redux/reducers/polls.js.map +1 -1
  47. package/lib/commonjs/utils/functions.js +48 -3
  48. package/lib/commonjs/utils/functions.js.map +1 -1
  49. package/lib/module/HMSRoomSetup.js +4 -6
  50. package/lib/module/HMSRoomSetup.js.map +1 -1
  51. package/lib/module/Icons/Check/assets/check-in-circle.png +0 -0
  52. package/lib/module/Icons/Check/assets/check-in-circle@2x.png +0 -0
  53. package/lib/module/Icons/Check/assets/check-in-circle@3x.png +0 -0
  54. package/lib/module/Icons/Check/index.js +2 -1
  55. package/lib/module/Icons/Check/index.js.map +1 -1
  56. package/lib/module/Icons/CheckBox/index.js +9 -2
  57. package/lib/module/Icons/CheckBox/index.js.map +1 -1
  58. package/lib/module/components/CreatePoll.js +99 -54
  59. package/lib/module/components/CreatePoll.js.map +1 -1
  60. package/lib/module/components/GridView.js +5 -9
  61. package/lib/module/components/GridView.js.map +1 -1
  62. package/lib/module/components/HMSPollsQuizzesNotification.js +1 -1
  63. package/lib/module/components/HMSPollsQuizzesNotification.js.map +1 -1
  64. package/lib/module/components/PollAndQuizQuestionResponseCard.js +81 -33
  65. package/lib/module/components/PollAndQuizQuestionResponseCard.js.map +1 -1
  66. package/lib/module/components/PollAndQuizQuestionResponseCards.js +44 -0
  67. package/lib/module/components/PollAndQuizQuestionResponseCards.js.map +1 -0
  68. package/lib/module/components/PollAndQuizVoting.js +16 -17
  69. package/lib/module/components/PollAndQuizVoting.js.map +1 -1
  70. package/lib/module/components/PollQuestion.js +73 -17
  71. package/lib/module/components/PollQuestion.js.map +1 -1
  72. package/lib/module/components/PollQuestions.js +23 -9
  73. package/lib/module/components/PollQuestions.js.map +1 -1
  74. package/lib/module/components/PollsAndQuizzesModalContent.js +1 -1
  75. package/lib/module/components/PollsAndQuizzesModalContent.js.map +1 -1
  76. package/lib/module/components/PreviousPollsAndQuizzesList.js +2 -2
  77. package/lib/module/components/PreviousPollsAndQuizzesList.js.map +1 -1
  78. package/lib/module/components/QuizEndOptionsView.js +54 -0
  79. package/lib/module/components/QuizEndOptionsView.js.map +1 -0
  80. package/lib/module/components/RadioInput.js +10 -3
  81. package/lib/module/components/RadioInput.js.map +1 -1
  82. package/lib/module/components/RoomSettingsModalContent.js +1 -1
  83. package/lib/module/components/RoomSettingsModalContent.js.map +1 -1
  84. package/lib/module/components/TilesContainer.js +5 -6
  85. package/lib/module/components/TilesContainer.js.map +1 -1
  86. package/lib/module/hooks-util.js +2 -4
  87. package/lib/module/hooks-util.js.map +1 -1
  88. package/lib/module/redux/actionTypes.js +2 -0
  89. package/lib/module/redux/actionTypes.js.map +1 -1
  90. package/lib/module/redux/actions/index.js +11 -0
  91. package/lib/module/redux/actions/index.js.map +1 -1
  92. package/lib/module/redux/reducers/polls.js +31 -4
  93. package/lib/module/redux/reducers/polls.js.map +1 -1
  94. package/lib/module/utils/functions.js +43 -3
  95. package/lib/module/utils/functions.js.map +1 -1
  96. package/lib/typescript/HMSRoomSetup.d.ts.map +1 -1
  97. package/lib/typescript/Icons/Check/index.d.ts +1 -0
  98. package/lib/typescript/Icons/Check/index.d.ts.map +1 -1
  99. package/lib/typescript/Icons/CheckBox/index.d.ts +1 -0
  100. package/lib/typescript/Icons/CheckBox/index.d.ts.map +1 -1
  101. package/lib/typescript/components/CreatePoll.d.ts.map +1 -1
  102. package/lib/typescript/components/GridView.d.ts.map +1 -1
  103. package/lib/typescript/components/PollAndQuizQuestionResponseCard.d.ts.map +1 -1
  104. package/lib/typescript/components/PollAndQuizQuestionResponseCards.d.ts +9 -0
  105. package/lib/typescript/components/PollAndQuizQuestionResponseCards.d.ts.map +1 -0
  106. package/lib/typescript/components/PollAndQuizVoting.d.ts.map +1 -1
  107. package/lib/typescript/components/PollQuestion.d.ts +1 -0
  108. package/lib/typescript/components/PollQuestion.d.ts.map +1 -1
  109. package/lib/typescript/components/PollQuestions.d.ts.map +1 -1
  110. package/lib/typescript/components/QuizEndOptionsView.d.ts +10 -0
  111. package/lib/typescript/components/QuizEndOptionsView.d.ts.map +1 -0
  112. package/lib/typescript/components/RadioInput.d.ts +1 -0
  113. package/lib/typescript/components/RadioInput.d.ts.map +1 -1
  114. package/lib/typescript/hooks-util.d.ts.map +1 -1
  115. package/lib/typescript/redux/actionTypes.d.ts +18 -3
  116. package/lib/typescript/redux/actionTypes.d.ts.map +1 -1
  117. package/lib/typescript/redux/actions/index.d.ts +3 -1
  118. package/lib/typescript/redux/actions/index.d.ts.map +1 -1
  119. package/lib/typescript/redux/reducers/polls.d.ts.map +1 -1
  120. package/lib/typescript/utils/functions.d.ts +6 -2
  121. package/lib/typescript/utils/functions.d.ts.map +1 -1
  122. package/package.json +2 -2
  123. package/src/HMSRoomSetup.tsx +7 -6
  124. package/src/Icons/Check/assets/check-in-circle.png +0 -0
  125. package/src/Icons/Check/assets/check-in-circle@2x.png +0 -0
  126. package/src/Icons/Check/assets/check-in-circle@3x.png +0 -0
  127. package/src/Icons/Check/index.tsx +9 -2
  128. package/src/Icons/CheckBox/index.tsx +16 -2
  129. package/src/components/CreatePoll.tsx +143 -70
  130. package/src/components/GridView.tsx +4 -14
  131. package/src/components/HMSPollsQuizzesNotification.tsx +1 -1
  132. package/src/components/PollAndQuizQuestionResponseCard.tsx +151 -48
  133. package/src/components/PollAndQuizQuestionResponseCards.tsx +62 -0
  134. package/src/components/PollAndQuizVoting.tsx +29 -25
  135. package/src/components/PollQuestion.tsx +140 -25
  136. package/src/components/PollQuestions.tsx +47 -29
  137. package/src/components/PollsAndQuizzesModalContent.tsx +1 -1
  138. package/src/components/PreviousPollsAndQuizzesList.tsx +2 -2
  139. package/src/components/QuizEndOptionsView.tsx +71 -0
  140. package/src/components/RadioInput.tsx +14 -2
  141. package/src/components/RoomSettingsModalContent.tsx +1 -1
  142. package/src/components/TilesContainer.tsx +4 -4
  143. package/src/hooks-util.ts +1 -3
  144. package/src/redux/actionTypes.ts +21 -1
  145. package/src/redux/actions/index.ts +22 -0
  146. package/src/redux/reducers/polls.ts +55 -5
  147. package/src/utils/functions.ts +90 -6
@@ -52,6 +52,8 @@ import type {
52
52
  AddPollQuestionResponseAction,
53
53
  SetPollQuestionResponseAction,
54
54
  RemovePollQuestionResponseAction,
55
+ SetQuestionPointWeightageAction,
56
+ SetQuestionCorrectOptionAction,
55
57
  } from '../actionTypes';
56
58
  import { MeetingState } from '../../types';
57
59
  import type { ChatState, Notification, PinnedMessage } from '../../types';
@@ -529,6 +531,15 @@ export const setPollQuestionTitle = (
529
531
  title,
530
532
  });
531
533
 
534
+ export const setPollQuestionPointWeightage = (
535
+ questionIndex: SetQuestionPointWeightageAction['questionIndex'],
536
+ pointWeightage: SetQuestionPointWeightageAction['pointWeightage']
537
+ ): SetQuestionPointWeightageAction => ({
538
+ type: PollsStateActionTypes.SET_POINT_WEIGHTAGE,
539
+ questionIndex,
540
+ pointWeightage,
541
+ });
542
+
532
543
  export const addPollQuestionOption = (
533
544
  questionIndex: AddQuestionOptionAction['questionIndex']
534
545
  ): AddQuestionOptionAction => ({
@@ -556,6 +567,17 @@ export const editPollQuestionOption = (
556
567
  option,
557
568
  });
558
569
 
570
+ export const setPollQuestionCorrectOption = (
571
+ questionIndex: SetQuestionCorrectOptionAction['questionIndex'],
572
+ optionIndex: SetQuestionCorrectOptionAction['optionIndex'],
573
+ correctOption: SetQuestionCorrectOptionAction['correctOption']
574
+ ): SetQuestionCorrectOptionAction => ({
575
+ type: PollsStateActionTypes.SET_QUESTION_CORRECT_OPTION,
576
+ questionIndex,
577
+ optionIndex,
578
+ correctOption,
579
+ });
580
+
559
581
  export const setPollQuestionSkippable = (
560
582
  questionIndex: SetQuestionSkippable['questionIndex'],
561
583
  skippable: boolean
@@ -1,4 +1,4 @@
1
- import { HMSPollQuestionType } from '@100mslive/react-native-hms';
1
+ import { HMSPollQuestionType, HMSPollType } from '@100mslive/react-native-hms';
2
2
  import type { HMSPoll } from '@100mslive/react-native-hms';
3
3
 
4
4
  import {
@@ -12,14 +12,18 @@ import type {
12
12
  PollsActionType,
13
13
  } from '../actionTypes';
14
14
 
15
- function getDefaultQuestionObj() {
15
+ function getDefaultQuestionObj(): PollQuestionUI {
16
16
  return {
17
17
  title: '',
18
18
  responseEditable: false,
19
19
  saved: false,
20
20
  skippable: false,
21
+ pointWeightage: '10',
21
22
  type: HMSPollQuestionType.singleChoice,
22
- options: ['', ''],
23
+ options: [
24
+ [false, ''],
25
+ [false, ''],
26
+ ],
23
27
  };
24
28
  }
25
29
 
@@ -40,6 +44,7 @@ type IntialStateType = {
40
44
  const INITIAL_STATE: IntialStateType = {
41
45
  pollName: '',
42
46
  pollConfig: {
47
+ type: HMSPollType.poll,
43
48
  voteCountHidden: false,
44
49
  resultsAnonymous: false,
45
50
  },
@@ -76,6 +81,10 @@ const hmsStatesReducer = (
76
81
  ...state.pollConfig,
77
82
  ...action.pollConfig,
78
83
  },
84
+ questions:
85
+ 'type' in action.pollConfig
86
+ ? state.questions.map((ques) => ({ ...ques, saved: false }))
87
+ : state.questions,
79
88
  selectedPollQuestionIndex: null,
80
89
  };
81
90
  case PollsStateActionTypes.SET_POLL_STAGE:
@@ -144,6 +153,18 @@ const hmsStatesReducer = (
144
153
  : question
145
154
  ),
146
155
  };
156
+ case PollsStateActionTypes.SET_POINT_WEIGHTAGE:
157
+ return {
158
+ ...state,
159
+ questions: state.questions.map((question, idx) =>
160
+ idx === action.questionIndex
161
+ ? {
162
+ ...question,
163
+ pointWeightage: action.pointWeightage,
164
+ }
165
+ : question
166
+ ),
167
+ };
147
168
  case PollsStateActionTypes.ADD_QUESTION_OPTION:
148
169
  return {
149
170
  ...state,
@@ -151,7 +172,7 @@ const hmsStatesReducer = (
151
172
  idx === action.questionIndex
152
173
  ? {
153
174
  ...question,
154
- options: [...(question.options || []), ''],
175
+ options: [...(question.options || []), [false, '']],
155
176
  }
156
177
  : question
157
178
  ),
@@ -180,12 +201,41 @@ const hmsStatesReducer = (
180
201
  options:
181
202
  question.options &&
182
203
  question.options.map((option, idx) =>
183
- idx === action.optionIndex ? action.option : option
204
+ idx === action.optionIndex
205
+ ? [option[0], action.option]
206
+ : option
184
207
  ),
185
208
  }
186
209
  : question
187
210
  ),
188
211
  };
212
+ case PollsStateActionTypes.SET_QUESTION_CORRECT_OPTION:
213
+ return {
214
+ ...state,
215
+ questions: state.questions.map((question, idx) =>
216
+ idx === action.questionIndex
217
+ ? {
218
+ ...question,
219
+ options:
220
+ question.options &&
221
+ question.options.map((option, idx) => {
222
+ if (
223
+ action.correctOption === false ||
224
+ question.type === HMSPollQuestionType.multipleChoice
225
+ ) {
226
+ return idx === action.optionIndex
227
+ ? [action.correctOption, option[1]]
228
+ : option;
229
+ }
230
+ return [
231
+ idx === action.optionIndex ? true : false,
232
+ option[1],
233
+ ];
234
+ }),
235
+ }
236
+ : question
237
+ ),
238
+ };
189
239
  case PollsStateActionTypes.SET_QUESTION_SKIPPABLE:
190
240
  return {
191
241
  ...state,
@@ -12,9 +12,15 @@ import {
12
12
  HMSTrackSource,
13
13
  HMSVideoTrack,
14
14
  HMSRole,
15
- HMSPollType,
15
+ HMSPollQuestionType,
16
+ } from '@100mslive/react-native-hms';
17
+ import type {
18
+ HMSPoll,
19
+ HMSPollQuestionAnswer,
20
+ HMSPollQuestionResponse,
21
+ HMSPollQuestion,
22
+ HMSPollQuestionOption,
16
23
  } from '@100mslive/react-native-hms';
17
- import type { HMSPoll } from '@100mslive/react-native-hms';
18
24
 
19
25
  import type { PeerTrackNode } from './types';
20
26
 
@@ -479,9 +485,87 @@ export const visiblePollsSelector = (
479
485
  isHLSViewer: boolean,
480
486
  hlsCuedPollIds: HMSPoll['pollId'][]
481
487
  ) => {
482
- return polls.filter(
483
- (poll) =>
484
- poll.type !== HMSPollType.quiz &&
485
- (isHLSViewer ? hlsCuedPollIds.includes(poll.pollId) : true) // Hiding quizzes from UI
488
+ return polls.filter((poll) =>
489
+ isHLSViewer ? hlsCuedPollIds.includes(poll.pollId) : true
486
490
  );
487
491
  };
492
+
493
+ export function checkIsSelected(
494
+ pollQuestion: HMSPollQuestion,
495
+ option: HMSPollQuestionOption,
496
+ selectedOptions: number | number[] | null
497
+ ) {
498
+ return pollQuestion.myResponses.length > 0
499
+ ? pollQuestion.type === HMSPollQuestionType.singleChoice
500
+ ? !!pollQuestion.myResponses.find((r) => r.option === option.index)
501
+ : !!pollQuestion.myResponses.find((r) =>
502
+ r.options ? r.options.includes(option.index) : false
503
+ )
504
+ : Array.isArray(selectedOptions)
505
+ ? selectedOptions.includes(option.index)
506
+ : selectedOptions === option.index;
507
+ }
508
+
509
+ export function checkIsCorrectAnswer(
510
+ questionType: HMSPollQuestionType,
511
+ myResponses: HMSPollQuestionResponse[] | undefined,
512
+ answer: HMSPollQuestionAnswer | undefined
513
+ ) {
514
+ if (!myResponses || myResponses.length < 0 || !answer) {
515
+ return false;
516
+ }
517
+ const correctAnswer =
518
+ questionType === HMSPollQuestionType.multipleChoice
519
+ ? answer.options
520
+ : answer.option;
521
+
522
+ if (correctAnswer === undefined) {
523
+ return false;
524
+ }
525
+ if (Array.isArray(correctAnswer)) {
526
+ return myResponses.every(
527
+ (r) =>
528
+ r.options &&
529
+ r.options.length === correctAnswer.length &&
530
+ r.options.every((o) => correctAnswer.includes(o))
531
+ );
532
+ }
533
+ return myResponses.every((r) => r.option === correctAnswer);
534
+ }
535
+
536
+ export function checkIsCorrectOption(
537
+ questionType: HMSPollQuestionType,
538
+ option: HMSPollQuestionOption,
539
+ answer: HMSPollQuestionAnswer | undefined
540
+ ) {
541
+ if (!answer) {
542
+ return false;
543
+ }
544
+ const correctAnswer =
545
+ questionType === HMSPollQuestionType.multipleChoice
546
+ ? answer.options
547
+ : answer.option;
548
+
549
+ if (correctAnswer === undefined) {
550
+ return false;
551
+ }
552
+ if (Array.isArray(correctAnswer)) {
553
+ return correctAnswer.includes(option.index);
554
+ }
555
+ return option.index === correctAnswer;
556
+ }
557
+
558
+ export function getLabelFromPollQuestionType(
559
+ type: HMSPollQuestionType
560
+ ): string {
561
+ switch (type) {
562
+ case HMSPollQuestionType.singleChoice:
563
+ return 'Single Choice';
564
+ case HMSPollQuestionType.multipleChoice:
565
+ return 'Multiple Choice';
566
+ case HMSPollQuestionType.longAnswer:
567
+ return 'Long Answer';
568
+ case HMSPollQuestionType.shortAnswer:
569
+ return 'Short Answer';
570
+ }
571
+ }