@nualang/nualang-ui-components 0.1.1214 → 0.1.1216

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.
@@ -16,6 +16,8 @@ var _mui = require("tss-react/mui");
16
16
  var _ArrowDropDown = _interopRequireDefault(require("@mui/icons-material/ArrowDropDown"));
17
17
  var _ArrowDropUp = _interopRequireDefault(require("@mui/icons-material/ArrowDropUp"));
18
18
  var _dayjs = _interopRequireDefault(require("dayjs"));
19
+ var _SelectExercise = _interopRequireDefault(require("../SelectExercise/SelectExercise"));
20
+ var _Queries = require("@nualang/nualang-api-and-queries/Queries");
19
21
  var _jsxRuntime = require("react/jsx-runtime");
20
22
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
21
23
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
@@ -39,20 +41,92 @@ function Transition(props) {
39
41
  function CreateAssignmentScreen({
40
42
  t,
41
43
  classrooms = [],
44
+ classroom,
45
+ getClassroomMembers,
42
46
  open,
43
- handleClose
47
+ handleClose,
48
+ getCourseSections,
49
+ getRoleplays,
50
+ createAssignment,
51
+ username,
52
+ getMemberDetails,
53
+ getClassroom,
54
+ getCourses
44
55
  }) {
45
56
  const {
46
57
  classes
47
58
  } = useStyles();
59
+ const [selectedExercises, setSelectedExercises] = (0, _react.useState)([]);
60
+ const [members, setMembers] = (0, _react.useState)([]);
48
61
  const [assignment, setAssignment] = (0, _react.useState)({
49
- classroom: "",
50
- students: [],
62
+ classroomId: "",
63
+ assignedStudents: members?.map(member => member.memberId),
51
64
  title: "",
52
- description: "",
53
- assignDate: (0, _dayjs.default)(),
54
- dueDate: (0, _dayjs.default)().add(1, "day")
65
+ instructions: "",
66
+ type: "assignment",
67
+ scheduleDate: (0, _dayjs.default)(),
68
+ dueDate: (0, _dayjs.default)().add(1, "day"),
69
+ exercises: selectedExercises
55
70
  });
71
+ const classroomQuery = _Queries.classrooms.useClassroom(async classroomId => {
72
+ const response = await getClassroom(classroomId);
73
+ return response;
74
+ }, {
75
+ classroomId: assignment.classroomId
76
+ }, {
77
+ enabled: !!assignment.classroomId
78
+ });
79
+ const selectedClassroom = (0, _react.useMemo)(() => classroomQuery.isSuccess && classroomQuery.data.Item ? classroomQuery.data.Item : {}, [classroomQuery.data, classroomQuery.isSuccess]);
80
+ const coursesQuery = _Queries.courses.useCourses(async filters => {
81
+ const response = await getCourses(filters);
82
+ return response;
83
+ }, {
84
+ filters: {
85
+ courseIds: selectedClassroom?.courses?.toString()
86
+ }
87
+ }, {
88
+ enabled: !!assignment.classroomId
89
+ });
90
+ const membersQuery = _Queries.classrooms.useClassroomMembers(async (classroomId, username) => {
91
+ const response = await getClassroomMembers(classroomId, username);
92
+ return response;
93
+ }, {
94
+ classroomId: assignment.classroomId,
95
+ username: username
96
+ }, {
97
+ enabled: !!assignment.classroomId
98
+ });
99
+ const selectedCourses = (0, _react.useMemo)(() => coursesQuery.isSuccess && Array.isArray(coursesQuery.data.Items) && coursesQuery.data.Items.length ? coursesQuery.data.Items : [], [coursesQuery.data, coursesQuery.isSuccess]);
100
+ const selectedMembers = (0, _react.useMemo)(() => membersQuery.isSuccess && Array.isArray(membersQuery.data.Items) && membersQuery.data.Items.length ? membersQuery.data.Items : [], [membersQuery.data, membersQuery.isSuccess]);
101
+ const classroomMembers = async selectedMembers => {
102
+ const formattedMembers = await getMemberDetails(selectedMembers);
103
+ setMembers(formattedMembers);
104
+ };
105
+ (0, _react.useEffect)(() => {
106
+ classroomMembers(selectedMembers);
107
+ }, [selectedMembers]);
108
+ (0, _react.useEffect)(() => {
109
+ setAssignment(prev => ({
110
+ ...prev,
111
+ exercises: selectedExercises
112
+ }));
113
+ }, [selectedExercises]);
114
+ (0, _react.useEffect)(() => {
115
+ setAssignment(prev => ({
116
+ ...prev,
117
+ assignedStudents: members?.map(member => member.memberId)
118
+ }));
119
+ }, [members]);
120
+ (0, _react.useEffect)(() => {
121
+ setAssignment(prev => ({
122
+ ...prev,
123
+ classroomId: classroom
124
+ }));
125
+ }, [classroom]);
126
+ const [isSelectExerciseOpen, setIsSelectExerciseOpen] = (0, _react.useState)(false);
127
+ const handleCloseSelectExercise = () => {
128
+ setIsSelectExerciseOpen(false);
129
+ };
56
130
  const [anchorEl, setAnchorEl] = (0, _react.useState)(null);
57
131
  const handleMenuOpen = event => {
58
132
  setAnchorEl(event.currentTarget);
@@ -63,17 +137,17 @@ function CreateAssignmentScreen({
63
137
  const handleChange = field => event => {
64
138
  let value = event?.target?.value ?? event;
65
139
  setAssignment(prev => {
66
- if (field === "students") {
140
+ if (field === "assignedStudents") {
67
141
  return {
68
142
  ...prev,
69
- students: typeof value === "string" ? value.split(",") : value
143
+ assignedStudents: typeof value === "string" ? value.split(",") : value
70
144
  };
71
145
  }
72
146
  if (field === "classroom") {
73
147
  return {
74
148
  ...prev,
75
- classroom: value,
76
- students: []
149
+ classroomId: value,
150
+ assignedStudents: []
77
151
  };
78
152
  }
79
153
  return {
@@ -82,8 +156,10 @@ function CreateAssignmentScreen({
82
156
  };
83
157
  });
84
158
  };
85
- const selectedClassroom = classrooms.find(c => c.id === assignment.classroom);
86
- const studentsInClassroom = selectedClassroom ? selectedClassroom.students : [];
159
+ const handleCreateAssignment = () => {
160
+ createAssignment(assignment);
161
+ handleClose();
162
+ };
87
163
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Dialog, {
88
164
  fullScreen: true,
89
165
  open: open,
@@ -102,7 +178,6 @@ function CreateAssignmentScreen({
102
178
  variant: "h5",
103
179
  fontWeight: "bold",
104
180
  textAlign: "center",
105
- mb: 1,
106
181
  children: t("create_assignment")
107
182
  })]
108
183
  })
@@ -129,30 +204,47 @@ function CreateAssignmentScreen({
129
204
  variant: "outlined",
130
205
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.InputLabel, {
131
206
  id: "classroom-label",
207
+ required: true,
132
208
  children: t("select_classroom")
133
209
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Select, {
134
210
  labelId: "classroom-label",
135
211
  id: "classroom",
136
- value: assignment.classroom,
212
+ value: assignment.classroomId,
137
213
  label: t("select_classroom"),
138
- onChange: handleChange("classroom"),
214
+ onChange: handleChange("classroomId"),
215
+ required: true,
216
+ disabled: classroom,
139
217
  children: classrooms.map(classroom => /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.MenuItem, {
140
- value: classroom.id,
141
- children: classroom.name
142
- }, classroom.id))
218
+ value: classroom.classroomId,
219
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
220
+ sx: {
221
+ display: "flex",
222
+ alignItems: "center",
223
+ gap: 0.5
224
+ },
225
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemAvatar, {
226
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Avatar, {
227
+ src: classroom.picture
228
+ })
229
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemText, {
230
+ primary: classroom.classroomName
231
+ })]
232
+ })
233
+ }, classroom.classroomId))
143
234
  })]
144
235
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, {
145
236
  label: t("assignment_title"),
146
237
  fullWidth: true,
147
238
  value: assignment.title,
148
- onChange: handleChange("title")
239
+ onChange: handleChange("title"),
240
+ required: true
149
241
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, {
150
242
  label: t("assignment_description"),
151
243
  fullWidth: true,
152
244
  multiline: true,
153
245
  rows: 3,
154
- value: assignment.description,
155
- onChange: handleChange("description")
246
+ value: assignment.instructions,
247
+ onChange: handleChange("instructions")
156
248
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
157
249
  variant: "outlined",
158
250
  color: "primary",
@@ -160,6 +252,7 @@ function CreateAssignmentScreen({
160
252
  width: "fit-content"
161
253
  },
162
254
  startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Add.default, {}),
255
+ onClick: () => setIsSelectExerciseOpen(true),
163
256
  children: t("add_exercise")
164
257
  })]
165
258
  })
@@ -180,31 +273,33 @@ function CreateAssignmentScreen({
180
273
  },
181
274
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.FormControl, {
182
275
  fullWidth: true,
183
- disabled: !assignment.classroom,
276
+ disabled: !assignment.classroomId,
184
277
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.InputLabel, {
185
- id: "students-label",
186
- children: t("select_students")
278
+ id: "members-label",
279
+ required: true,
280
+ children: t("select_members")
187
281
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Select, {
188
- labelId: "students-label",
189
- id: "students",
190
- label: t("select_students"),
282
+ labelId: "members-label",
283
+ id: "assignedStudents",
284
+ label: t("select_members"),
191
285
  multiple: true,
192
- value: assignment.students,
193
- onChange: handleChange("students"),
194
- renderValue: selected => studentsInClassroom.filter(student => selected.includes(student.id)).map(s => s.name).join(", "),
195
- children: studentsInClassroom.map(student => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.MenuItem, {
196
- value: student.id,
286
+ required: true,
287
+ value: assignment.assignedStudents,
288
+ onChange: handleChange("assignedStudents"),
289
+ renderValue: selected => selected.map(memberId => members?.find(member => member.memberId === memberId)).map(member => member?.username).join(", "),
290
+ children: members?.map(member => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.MenuItem, {
291
+ value: member.memberId,
197
292
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Avatar, {
198
- src: student.userImage,
293
+ src: member.userImage,
199
294
  sx: {
200
295
  mr: 2
201
296
  }
202
297
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemText, {
203
- primary: student.name
298
+ primary: member.username
204
299
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Checkbox, {
205
- checked: assignment.students.includes(student.id)
300
+ checked: assignment.assignedStudents?.includes(member.memberId)
206
301
  })]
207
- }, student.id))
302
+ }, member.memberId))
208
303
  })]
209
304
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_LocalizationProvider.LocalizationProvider, {
210
305
  dateAdapter: _AdapterDayjs.AdapterDayjs,
@@ -236,6 +331,7 @@ function CreateAssignmentScreen({
236
331
  sx: {
237
332
  marginRight: 2
238
333
  },
334
+ onClick: handleClose,
239
335
  children: t("cancel")
240
336
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.ButtonGroup, {
241
337
  variant: "contained",
@@ -244,7 +340,8 @@ function CreateAssignmentScreen({
244
340
  borderRadius: 10
245
341
  },
246
342
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
247
- disabled: !assignment.students.length || !assignment.assignDate || !assignment.dueDate || !assignment.title || !assignment.classroom,
343
+ disabled: !assignment.assignedStudents?.length || !assignment.scheduleDate || !assignment.dueDate || !assignment.title || !assignment.classroomId || !assignment.exercises?.length,
344
+ onClick: handleCreateAssignment,
248
345
  children: t("assign")
249
346
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
250
347
  color: "primary",
@@ -253,7 +350,7 @@ function CreateAssignmentScreen({
253
350
  minWidth: "40px",
254
351
  padding: "6px"
255
352
  },
256
- disabled: !assignment.students.length || !assignment.assignDate || !assignment.dueDate || !assignment.title || !assignment.classroom,
353
+ disabled: !assignment.assignedStudents?.length || !assignment.scheduleDate || !assignment.dueDate || !assignment.title || !assignment.classroomId || !assignment.exercises?.length,
257
354
  children: anchorEl ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ArrowDropUp.default, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ArrowDropDown.default, {})
258
355
  })]
259
356
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Popover, {
@@ -278,21 +375,39 @@ function CreateAssignmentScreen({
278
375
  dateAdapter: _AdapterDayjs.AdapterDayjs,
279
376
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DatePicker.DatePicker, {
280
377
  label: t("assign_date"),
281
- value: assignment.assignDate,
378
+ value: assignment.scheduleDate,
282
379
  onChange: date => setAssignment(prev => ({
283
380
  ...prev,
284
- assignDate: date
381
+ scheduleDate: date
285
382
  }))
286
383
  })
287
384
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
288
385
  variant: "outlined",
289
386
  color: "primary",
290
387
  fullWidth: true,
388
+ onClick: () => {
389
+ handleCreateAssignment;
390
+ handleMenuClose();
391
+ },
291
392
  children: t("schedule_assignment")
292
393
  })]
293
394
  })
294
395
  })]
295
- }), ";"]
396
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectExercise.default, {
397
+ t: t,
398
+ open: isSelectExerciseOpen,
399
+ handleClose: handleCloseSelectExercise,
400
+ courses: selectedCourses,
401
+ getCourseSections: getCourseSections,
402
+ getRoleplays: getRoleplays,
403
+ username: username,
404
+ useCase: "assignment",
405
+ selectedExercises: selectedExercises,
406
+ setSelectedExercises: setSelectedExercises,
407
+ isAssignment: true
408
+ }), selectedExercises?.map(exercise => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
409
+ children: [exercise.name ? exercise.name : exercise.game, " | ", exercise.courseSectionTopicId ? exercise.courseSectionTopicId : exercise.roleplayId]
410
+ }))]
296
411
  });
297
412
  }
298
413
  CreateAssignmentScreen.propTypes = {
@@ -20,10 +20,12 @@ function SelectExercise({
20
20
  getRoleplays,
21
21
  handleCreateGame,
22
22
  username,
23
- useCase = "live"
23
+ useCase = "live",
24
+ selectedExercises = [],
25
+ setSelectedExercises,
26
+ isAssignment
24
27
  }) {
25
28
  const [isExerciseSelected, setIsExerciseSelected] = (0, _react.useState)(false);
26
- const [selectedExercises, setSelectedExercises] = (0, _react.useState)([]);
27
29
  const handleSelectExercise = (exercises = []) => {
28
30
  setSelectedExercises(prevSelectedExercises => {
29
31
  let updatedExercises = [...prevSelectedExercises];
@@ -39,12 +41,18 @@ function SelectExercise({
39
41
  return updatedExercises;
40
42
  });
41
43
  };
44
+ const handleSubmitExercises = () => {
45
+ setSelectedExercises(selectedExercises);
46
+ handleClose();
47
+ };
42
48
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ResponsiveDialog.default, {
43
49
  open: open,
44
50
  handleClose: handleClose,
45
51
  dialogTitle: useCase === "live" ? t("play_live") : t("assignment"),
46
52
  maxWidth: "md",
47
- handleSubmit: useCase === "live" ? null : () => {},
53
+ handleSubmit: useCase === "live" ? null : () => {
54
+ handleSubmitExercises();
55
+ },
48
56
  submitText: useCase === "live" ? null : t("add_exercises"),
49
57
  isSubmitDisabled: selectedExercises.length === 0,
50
58
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.DialogContentText, {
@@ -63,7 +71,8 @@ function SelectExercise({
63
71
  isDialogOpen: open,
64
72
  useCase: useCase,
65
73
  selectedExercises: selectedExercises,
66
- handleSelectExercise: useCase === "assignment" ? handleSelectExercise : null
74
+ handleSelectExercise: useCase === "assignment" ? handleSelectExercise : null,
75
+ isAssignment: isAssignment
67
76
  })
68
77
  })]
69
78
  });
@@ -42,13 +42,15 @@ const AssignmentCardsList = ({
42
42
  }), !isCreator ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
43
43
  sx: {
44
44
  textAlign: "center",
45
- mt: 2
45
+ mt: 2,
46
+ width: '70%'
46
47
  },
47
48
  children: t("no_assignments_description")
48
49
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
49
50
  sx: {
50
51
  textAlign: "center",
51
- mt: 2
52
+ mt: 2,
53
+ width: '70%'
52
54
  },
53
55
  children: t("assignments_description")
54
56
  }), isCreator && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
@@ -111,7 +111,7 @@ function Exercise({
111
111
  }), name.toLowerCase() === "roleplays" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemIcon, {
112
112
  children: roleplaysOpen ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandLess.default, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandMore.default, {})
113
113
  }), (name.toLowerCase() === "listening" || name.toLowerCase() === "translation" || name.toLowerCase() === "pronunciation") && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemIcon, {
114
- children: isAssignment ? isCreator ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Checkbox, {
114
+ children: isAssignment ? useCase === "assignment" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Checkbox, {
115
115
  checked: isAssignmentExerciseSelected,
116
116
  onClick: event => {
117
117
  event.stopPropagation();
@@ -1067,6 +1067,24 @@ function Classroom({
1067
1067
  tabIndex: tabs.findIndex(tab => tab.id === "Discuss"),
1068
1068
  variant: "extended"
1069
1069
  };
1070
+ const assignmentsFab = {
1071
+ color: "primary",
1072
+ loading,
1073
+ className: null,
1074
+ icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Add.default, {
1075
+ sx: {
1076
+ mr: 1
1077
+ }
1078
+ }),
1079
+ buttonText: t("create_assignment"),
1080
+ id: "assignments-fab",
1081
+ onClick: () => {
1082
+ handleCreateAssignment();
1083
+ },
1084
+ title: t("create_assignment"),
1085
+ tabIndex: tabs.findIndex(tab => tab.id === "Assignments"),
1086
+ variant: "extended"
1087
+ };
1070
1088
  const fabs = [[{
1071
1089
  color: "primary",
1072
1090
  className: null,
@@ -1076,7 +1094,7 @@ function Classroom({
1076
1094
  title: t("add_courses"),
1077
1095
  tabIndex: tabs.findIndex(tab => tab.id === "Courses"),
1078
1096
  variant: "circular"
1079
- }, vchatFab]];
1097
+ }, vchatFab, assignmentsFab]];
1080
1098
  let initialTabValue;
1081
1099
  if (window.location.hash) {
1082
1100
  const selectedTab = window.location.hash;
@@ -62,7 +62,7 @@ const CategoryListComponent = ({
62
62
  const isCategoriesLoading = categoriesQuery.isLoading;
63
63
  const categories = categoriesQuery.isSuccess && Array.isArray(categoriesQuery.data.Items) && categoriesQuery.data.Items.length ? categoriesQuery.data.Items : [];
64
64
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
65
- children: process.env.REACT_APP_STAGE === "dev" && (isCategoriesLoading || categories.length > 0) ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
65
+ children: isCategoriesLoading || categories.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
66
66
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
67
67
  pb: 2,
68
68
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
@@ -154,12 +154,22 @@ function useRecognition(props = {}) {
154
154
  */
155
155
  const initRecording = async (gcloudParams, onData, onError) => {
156
156
  try {
157
+ const {
158
+ mediaDevices
159
+ } = navigator;
160
+ const [availableMicrophones, activeMicrophone, sampleRate] = await (0, _index.getMicrophoneInfo)(mediaDevices);
157
161
  await setupAudioContext();
162
+ let sampleRateToUse = sampleRate;
163
+ if (sampleRate && sampleRate < 8000) {
164
+ sampleRateToUse = 8000;
165
+ } else if (sampleRate && sampleRate > 48000) {
166
+ sampleRateToUse = 48000;
167
+ }
158
168
  const handleSuccess = function (stream) {
159
169
  const gcloudConfig = {
160
170
  config: {
161
171
  encoding: "LINEAR16",
162
- sampleRateHertz: 16000,
172
+ sampleRateHertz: sampleRateToUse || 16000,
163
173
  languageCode: gcloudParams.languageCode || "en-US",
164
174
  profanityFilter: true,
165
175
  enableWordTimeOffsets: false,
@@ -172,7 +182,6 @@ function useRecognition(props = {}) {
172
182
  interimResults: gcloudParams.interimResults // If you want interim results, set this to true
173
183
  };
174
184
  socket.emit("startGoogleCloudStream", gcloudConfig, version); // init socket Google Speech Connection
175
-
176
185
  streamRef.current = stream;
177
186
  audioInputRef.current = audioContextRef.current.createMediaStreamSource(stream);
178
187
  serverErrorRef.current = null;
@@ -454,7 +454,12 @@ const getMicrophoneInfo = async mediaDevices => {
454
454
  const availableMicrophoneNames = microphones?.filter(device => device.deviceId !== "default").map(device => device.label).join(", ") || "No available microphones detected";
455
455
  const activeMicrophone = microphones?.length > 0 ? microphones.find(mic => mic.deviceId === "default") || microphones[0] : null;
456
456
  const activeMicrophoneName = activeMicrophone?.label.split("Default - ").pop() || "No active microphone detected";
457
- return [availableMicrophoneNames, activeMicrophoneName];
457
+
458
+ // Create an AudioContext with the stream from the active microphone
459
+
460
+ const capabilities = activeMicrophone.getCapabilities();
461
+ let sampleRate = capabilities?.sampleRate?.max || capabilities?.sampleRate?.exact;
462
+ return [availableMicrophoneNames, activeMicrophoneName, sampleRate];
458
463
  } catch (error) {
459
464
  console.error("Error accessing the microphone:", error);
460
465
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nualang/nualang-ui-components",
3
- "version": "0.1.1214",
3
+ "version": "0.1.1216",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist",