@nualang/nualang-ui-components 0.1.1367 → 0.1.1369

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.
@@ -370,6 +370,7 @@ function PhraseList({
370
370
  voiceOptions: voices,
371
371
  isUserInternal: isUserInternal,
372
372
  onSubmit: onSubmit,
373
+ handleSpeak: handleSpeak,
373
374
  fileSizeLimit: fileSizeLimit,
374
375
  verificationStatus: verificationStatus
375
376
  })
@@ -5,6 +5,27 @@ import InputHelper from "../InputHelper/InputHelper";
5
5
  import VoiceSelector from "../VoiceSelector/VoiceSelector";
6
6
  import ImageSelector from "../ImageSelector/ImageSelector";
7
7
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
8
+ const GAMES = [{
9
+ gameId: "translation",
10
+ nameKey: "translation",
11
+ hasKeyboard: true,
12
+ hasWordBank: true
13
+ }, {
14
+ gameId: "listening",
15
+ nameKey: "listening",
16
+ hasKeyboard: false,
17
+ hasWordBank: true
18
+ }, {
19
+ gameId: "pronunciation",
20
+ nameKey: "pronunciation",
21
+ hasKeyboard: false,
22
+ hasWordBank: false
23
+ }, {
24
+ gameId: "meaning",
25
+ nameKey: "meaning",
26
+ hasKeyboard: false,
27
+ hasWordBank: false
28
+ }];
8
29
  const useStyles = makeStyles()(theme => ({
9
30
  padding: {
10
31
  padding: theme.spacing(2, 3)
@@ -22,20 +43,7 @@ const useStyles = makeStyles()(theme => ({
22
43
  }));
23
44
  export default function UpdatePhraseList({
24
45
  t = text => text,
25
- initialValues = {
26
- phraseListName: "",
27
- description: "",
28
- shuffleEnabled: "enabled",
29
- voice: null,
30
- voicePitch: null,
31
- voiceLanguageCode: null,
32
- translationEnabled: "enabled",
33
- listeningEnabled: "enabled",
34
- pronunciationEnabled: "enabled",
35
- buildMeaningEnabled: "disabled",
36
- readAndWriteEnabled: "disabled",
37
- listenAndSpeakEnabled: "disabled"
38
- },
46
+ initialValues: rawInitialValues = {},
39
47
  onSubmit,
40
48
  learnLang,
41
49
  isUserInternal,
@@ -48,13 +56,25 @@ export default function UpdatePhraseList({
48
56
  const {
49
57
  classes
50
58
  } = useStyles();
59
+ const initialValues = {
60
+ phraseListName: "",
61
+ description: "",
62
+ shuffleEnabled: "enabled",
63
+ voice: null,
64
+ voicePitch: null,
65
+ voiceLanguageCode: null,
66
+ hiddenPhraseGroupGames: {},
67
+ isKeyboardHiddenPhraseGroupGames: {},
68
+ hiddenWordBankPhraseGroupGames: {},
69
+ ...rawInitialValues
70
+ };
51
71
  return /*#__PURE__*/_jsx("div", {
52
72
  className: classes.container,
53
73
  children: /*#__PURE__*/_jsx(Formik, {
54
74
  initialValues: initialValues,
55
75
  enableReinitialize: enableReinitialize,
56
76
  onSubmit: onSubmit,
57
- render: ({
77
+ children: ({
58
78
  handleChange,
59
79
  handleSubmit,
60
80
  handleBlur,
@@ -62,16 +82,17 @@ export default function UpdatePhraseList({
62
82
  dirty,
63
83
  values,
64
84
  errors,
65
- touched
85
+ touched,
86
+ setFieldValue
66
87
  }) => /*#__PURE__*/_jsx("form", {
67
88
  onSubmit: handleSubmit,
68
- children: /*#__PURE__*/_jsx(Grid, {
89
+ children: /*#__PURE__*/_jsxs(Grid, {
69
90
  container: true,
70
91
  sx: {
71
92
  width: "100%"
72
93
  },
73
94
  spacing: 1,
74
- children: /*#__PURE__*/_jsx(Grid, {
95
+ children: [/*#__PURE__*/_jsx(Grid, {
75
96
  size: 12,
76
97
  children: /*#__PURE__*/_jsxs(Card, {
77
98
  children: [/*#__PURE__*/_jsx(CardHeader, {
@@ -164,6 +185,253 @@ export default function UpdatePhraseList({
164
185
  })]
165
186
  })]
166
187
  })
188
+ })]
189
+ })
190
+ }), /*#__PURE__*/_jsx(Grid, {
191
+ size: 12,
192
+ children: /*#__PURE__*/_jsxs(Card, {
193
+ children: [/*#__PURE__*/_jsx(CardHeader, {
194
+ title: /*#__PURE__*/_jsx(Typography, {
195
+ variant: "h5",
196
+ component: "h2",
197
+ children: t("exercise_settings")
198
+ }),
199
+ className: classes.padding
200
+ }), /*#__PURE__*/_jsx(Divider, {}), /*#__PURE__*/_jsx(CardContent, {
201
+ className: classes.formContent,
202
+ children: /*#__PURE__*/_jsxs(Grid, {
203
+ container: true,
204
+ sx: {
205
+ width: "100%"
206
+ },
207
+ spacing: 2,
208
+ children: [/*#__PURE__*/_jsx(Grid, {
209
+ size: 12,
210
+ children: /*#__PURE__*/_jsxs(FormControl, {
211
+ component: "fieldset",
212
+ children: [/*#__PURE__*/_jsx(FormLabel, {
213
+ component: "legend",
214
+ children: t("shuffle_phrases")
215
+ }), /*#__PURE__*/_jsx(Typography, {
216
+ color: "textSecondary",
217
+ children: t("shuffle_phrases_desc")
218
+ }), /*#__PURE__*/_jsxs(RadioGroup, {
219
+ row: true,
220
+ "aria-label": "shuffleEnabled",
221
+ name: "shuffleEnabled",
222
+ value: values.shuffleEnabled,
223
+ onChange: handleChange,
224
+ onBlur: handleBlur,
225
+ children: [/*#__PURE__*/_jsx(FormControlLabel, {
226
+ value: "enabled",
227
+ control: /*#__PURE__*/_jsx(Radio, {}),
228
+ label: t("enabled")
229
+ }), /*#__PURE__*/_jsx(FormControlLabel, {
230
+ value: "disabled",
231
+ control: /*#__PURE__*/_jsx(Radio, {}),
232
+ label: t("disabled")
233
+ })]
234
+ })]
235
+ })
236
+ }), learnLang !== "irish" && /*#__PURE__*/_jsxs(Grid, {
237
+ size: 12,
238
+ children: [/*#__PURE__*/_jsx(Typography, {
239
+ gutterBottom: true,
240
+ children: t("excercise_voice_desc")
241
+ }), /*#__PURE__*/_jsx(VoiceSelector, {
242
+ id: "voice",
243
+ name: "voice",
244
+ "data-cy": "voice",
245
+ margin: "normal",
246
+ variant: "outlined",
247
+ fullWidth: true,
248
+ required: learnLang !== "irish",
249
+ t: t,
250
+ voices: voiceOptions,
251
+ label: t("excercise_voice"),
252
+ value: values.voice,
253
+ onChange: e => {
254
+ if (e && e.target && e.target.value) {
255
+ const voiceSelected = e.target.value;
256
+ const voiceOptionElem = document.getElementById(`voice-${voiceSelected}`);
257
+ const languageCode = voiceOptionElem.getAttribute("data-language-code");
258
+ handleChange({
259
+ target: {
260
+ name: "voice",
261
+ value: voiceSelected
262
+ }
263
+ });
264
+ handleSpeak && handleSpeak({
265
+ text: voiceSelected,
266
+ learnLanguage: learnLang,
267
+ voiceName: voiceSelected,
268
+ languageCode
269
+ });
270
+ handleChange({
271
+ target: {
272
+ name: "voiceLanguageCode",
273
+ value: languageCode
274
+ }
275
+ });
276
+ handleChange({
277
+ target: {
278
+ name: "voicePitch",
279
+ value: null
280
+ }
281
+ });
282
+ }
283
+ },
284
+ onVoicePitchChange: e => {
285
+ if (e && e.target) {
286
+ handleChange(e);
287
+ handleSpeak && handleSpeak({
288
+ text: values.voiceLanguageCode ? t("voice_pitch_example", {
289
+ name: values.voice,
290
+ lng: values.voiceLanguageCode?.substring(0, 2)
291
+ }) : values.voice,
292
+ learnLanguage: learnLang,
293
+ voiceName: values.voice,
294
+ languageCode: values.voiceLanguageCode,
295
+ pitch: e.target.value
296
+ });
297
+ }
298
+ },
299
+ onBlur: handleBlur,
300
+ helperText: touched.voice ? errors.voice : "",
301
+ error: touched.voice && Boolean(errors.voice),
302
+ voicePitch: values.voicePitch,
303
+ isUserInternal: isUserInternal
304
+ })]
305
+ }), /*#__PURE__*/_jsxs(Grid, {
306
+ size: 12,
307
+ children: [/*#__PURE__*/_jsx(Typography, {
308
+ variant: "subtitle1",
309
+ gutterBottom: true,
310
+ sx: {
311
+ fontWeight: "bold"
312
+ },
313
+ children: t("excercise_visibility")
314
+ }), /*#__PURE__*/_jsx(Grid, {
315
+ container: true,
316
+ sx: {
317
+ width: "100%"
318
+ },
319
+ spacing: 1,
320
+ children: GAMES.map(({
321
+ gameId,
322
+ nameKey,
323
+ hasKeyboard,
324
+ hasWordBank
325
+ }) => {
326
+ const isHidden = values.hiddenPhraseGroupGames?.[gameId] || false;
327
+ const isKeyboardHidden = values.isKeyboardHiddenPhraseGroupGames?.[gameId] || false;
328
+ const isWordBankHidden = values.hiddenWordBankPhraseGroupGames?.[gameId] || false;
329
+ return /*#__PURE__*/_jsxs(_Fragment, {
330
+ children: [/*#__PURE__*/_jsx(Grid, {
331
+ size: 12,
332
+ children: /*#__PURE__*/_jsxs(FormControl, {
333
+ component: "fieldset",
334
+ children: [/*#__PURE__*/_jsx(FormLabel, {
335
+ component: "legend",
336
+ children: t(nameKey)
337
+ }), /*#__PURE__*/_jsxs(RadioGroup, {
338
+ row: true,
339
+ value: isHidden ? "disabled" : "enabled",
340
+ onChange: e => setFieldValue("hiddenPhraseGroupGames", {
341
+ ...values.hiddenPhraseGroupGames,
342
+ [gameId]: e.target.value === "disabled"
343
+ }),
344
+ children: [/*#__PURE__*/_jsx(FormControlLabel, {
345
+ value: "enabled",
346
+ control: /*#__PURE__*/_jsx(Radio, {}),
347
+ label: t("enabled")
348
+ }), /*#__PURE__*/_jsx(FormControlLabel, {
349
+ value: "disabled",
350
+ control: /*#__PURE__*/_jsx(Radio, {}),
351
+ label: t("disabled")
352
+ })]
353
+ })]
354
+ })
355
+ }, gameId), hasKeyboard && /*#__PURE__*/_jsx(Grid, {
356
+ size: 12,
357
+ children: /*#__PURE__*/_jsxs(FormControl, {
358
+ component: "fieldset",
359
+ sx: {
360
+ pl: 2
361
+ },
362
+ children: [/*#__PURE__*/_jsx(FormLabel, {
363
+ component: "legend",
364
+ children: t("keyboard")
365
+ }), /*#__PURE__*/_jsxs(RadioGroup, {
366
+ row: true,
367
+ value: isKeyboardHidden ? "disabled" : "enabled",
368
+ onChange: e => {
369
+ const disabling = e.target.value === "disabled";
370
+ setFieldValue("isKeyboardHiddenPhraseGroupGames", {
371
+ ...values.isKeyboardHiddenPhraseGroupGames,
372
+ [gameId]: disabling
373
+ });
374
+ if (disabling && isWordBankHidden) {
375
+ setFieldValue("hiddenWordBankPhraseGroupGames", {
376
+ ...values.hiddenWordBankPhraseGroupGames,
377
+ [gameId]: false
378
+ });
379
+ }
380
+ },
381
+ children: [/*#__PURE__*/_jsx(FormControlLabel, {
382
+ value: "enabled",
383
+ control: /*#__PURE__*/_jsx(Radio, {}),
384
+ label: t("enabled")
385
+ }), /*#__PURE__*/_jsx(FormControlLabel, {
386
+ value: "disabled",
387
+ control: /*#__PURE__*/_jsx(Radio, {}),
388
+ label: t("disabled")
389
+ })]
390
+ })]
391
+ })
392
+ }, `${gameId}-keyboard`), hasWordBank && /*#__PURE__*/_jsx(Grid, {
393
+ size: 12,
394
+ children: /*#__PURE__*/_jsxs(FormControl, {
395
+ component: "fieldset",
396
+ sx: {
397
+ pl: 2
398
+ },
399
+ children: [/*#__PURE__*/_jsx(FormLabel, {
400
+ component: "legend",
401
+ children: t("word_bank")
402
+ }), /*#__PURE__*/_jsxs(RadioGroup, {
403
+ row: true,
404
+ value: isWordBankHidden ? "disabled" : "enabled",
405
+ onChange: e => {
406
+ const disabling = e.target.value === "disabled";
407
+ setFieldValue("hiddenWordBankPhraseGroupGames", {
408
+ ...values.hiddenWordBankPhraseGroupGames,
409
+ [gameId]: disabling
410
+ });
411
+ if (disabling && isKeyboardHidden) {
412
+ setFieldValue("isKeyboardHiddenPhraseGroupGames", {
413
+ ...values.isKeyboardHiddenPhraseGroupGames,
414
+ [gameId]: false
415
+ });
416
+ }
417
+ },
418
+ children: [/*#__PURE__*/_jsx(FormControlLabel, {
419
+ value: "enabled",
420
+ control: /*#__PURE__*/_jsx(Radio, {}),
421
+ label: t("enabled")
422
+ }), /*#__PURE__*/_jsx(FormControlLabel, {
423
+ value: "disabled",
424
+ control: /*#__PURE__*/_jsx(Radio, {}),
425
+ label: t("disabled")
426
+ })]
427
+ })]
428
+ })
429
+ }, `${gameId}-wordbank`)]
430
+ });
431
+ })
432
+ })]
433
+ })]
434
+ })
167
435
  }), /*#__PURE__*/_jsx(Divider, {}), /*#__PURE__*/_jsx(CardActions, {
168
436
  className: classes.padding,
169
437
  children: /*#__PURE__*/_jsx(Button, {
@@ -175,7 +443,7 @@ export default function UpdatePhraseList({
175
443
  })
176
444
  })]
177
445
  })
178
- })
446
+ })]
179
447
  })
180
448
  })
181
449
  })
@@ -152,7 +152,7 @@ function PhraseListSelection({
152
152
  topicId,
153
153
  filters: {
154
154
  limit: 1000,
155
- returnvalues: "phrases"
155
+ includePhrases: "true"
156
156
  }
157
157
  }, {
158
158
  enabled: !!courseId && !!sectionId && !!topicId && isExpanded
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nualang/nualang-ui-components",
3
- "version": "0.1.1367",
3
+ "version": "0.1.1369",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "files": [