@nualang/nualang-ui-components 0.1.1245 → 0.1.1246

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.
@@ -42,7 +42,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
42
42
 
43
43
  const useStyles = (0, _mui.makeStyles)()(theme => ({
44
44
  appBar: {
45
- position: "sticky",
45
+ position: "relative",
46
46
  paddingTop: `env(safe-area-inset-top)`,
47
47
  paddingRight: `env(safe-area-inset-right)`,
48
48
  paddingLeft: `env(safe-area-inset-left)`
@@ -244,6 +244,7 @@ function Listener({
244
244
  const {
245
245
  classes
246
246
  } = useStyles();
247
+ const scrollRef = (0, _react.useRef)(null);
247
248
  const [wordBankTooltipOpen, setWordBankTooltipOpen] = (0, _react.useState)(false);
248
249
  const initialVoiceSpeed = topicInfo && topicInfo.voiceSpeed ? topicInfo.voiceSpeed : "";
249
250
  const exerciseState = (0, _useExerciseState.default)({
@@ -470,6 +471,14 @@ function Listener({
470
471
  (0, _react.useEffect)(() => {
471
472
  assignment ? setIsAssignmentExercise(true) : setIsAssignmentExercise(false);
472
473
  }, [assignment]);
474
+ (0, _react.useEffect)(() => {
475
+ if (scrollRef.current && useWordBank) {
476
+ scrollRef.current.scroll({
477
+ top: scrollRef.current.scrollHeight,
478
+ behavior: "smooth"
479
+ });
480
+ }
481
+ }, [useWordBank]);
473
482
  (0, _react.useEffect)(() => {
474
483
  if (open && !run && !localStorage.getItem(`listening-exercise-tour-completed`)) {
475
484
  setJoyrideState(prevState => ({
@@ -535,6 +544,9 @@ function Listener({
535
544
  const goBackToAssignment = () => {
536
545
  navigate(`/classrooms/${classroomId}#Assignments`);
537
546
  };
547
+ const noListeningWords = !listeningWords || listeningWords.length === 0;
548
+ const isWordBankMode = useWordBank && isWordBankEnabled;
549
+ const isSubmitAnswerDisabled = isWordBankMode ? !isWordBankAttemptChanged || noListeningWords : !listeningText && noListeningWords;
538
550
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Dialog, {
539
551
  fullScreen: true,
540
552
  open: open,
@@ -644,9 +656,13 @@ function Listener({
644
656
  })
645
657
  })]
646
658
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
659
+ ref: scrollRef,
647
660
  sx: {
661
+ overflowY: 'auto',
648
662
  flexGrow: 1,
649
- overflowY: 'auto'
663
+ display: 'flex',
664
+ justifyContent: 'center',
665
+ alignItems: 'center'
650
666
  },
651
667
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Grid, {
652
668
  container: true,
@@ -927,38 +943,13 @@ function Listener({
927
943
  exercise: exerciseName,
928
944
  languageInformation: languageInformation,
929
945
  nualaCelebratingImage: getNualaCelebratingImage()
930
- }), useWordBank && isWordBankEnabled ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
931
- sx: {
932
- position: 'sticky',
933
- bottom: 0,
934
- zIndex: 1100,
935
- backgroundColor: theme => theme.palette.background.paper
936
- },
937
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExerciseBottomBar.default, {
938
- t: t,
939
- listeningWords: listeningWords,
940
- handleSubmit: () => handleContinue(false),
941
- handleSkip: () => handleContinue(true),
942
- isSubmitAnswerAllowed: true,
943
- isSubmitAnswerDisabled: !isWordBankAttemptChanged || !listeningWords || listeningWords.length === 0,
944
- useWordBank: useWordBank
945
- })
946
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
947
- sx: {
948
- position: 'sticky',
949
- bottom: 0,
950
- zIndex: 1100,
951
- backgroundColor: theme => theme.palette.background.paper
952
- },
953
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExerciseBottomBar.default, {
954
- t: t,
955
- listeningWords: listeningWords,
956
- handleSubmit: () => handleContinue(false),
957
- handleSkip: () => handleContinue(true),
958
- isSubmitAnswerAllowed: true,
959
- isSubmitAnswerDisabled: !listeningText && (!listeningWords || listeningWords.length === 0),
960
- useWordBank: useWordBank
961
- })
946
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExerciseBottomBar.default, {
947
+ t: t,
948
+ listeningWords: listeningWords,
949
+ handleSubmit: () => handleContinue(false),
950
+ handleSkip: () => handleContinue(true),
951
+ isSubmitAnswerAllowed: true,
952
+ isSubmitAnswerDisabled: isSubmitAnswerDisabled
962
953
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_CompletedExcercise.default, {
963
954
  open: isCompletionModalOpen,
964
955
  restartExcercise: handleRestartExercise,
@@ -176,6 +176,7 @@ function Pronouncer({
176
176
  classes,
177
177
  cx
178
178
  } = useStyles();
179
+ const scrollRef = (0, _react.useRef)(null);
179
180
  const [viewMoreTranslations, setViewMoreTranslations] = (0, _react.useState)(false);
180
181
  const [currentPhraseText, setCurrentPhraseText] = (0, _react.useState)("");
181
182
  const {
@@ -222,6 +223,12 @@ function Pronouncer({
222
223
  }, [open, recognizing, finalTranscript]);
223
224
  (0, _react.useEffect)(() => {
224
225
  let timer;
226
+ if (scrollRef.current && (interimTranscript || finalTranscript)) {
227
+ scrollRef.current.scroll({
228
+ top: scrollRef.current.scrollHeight,
229
+ behavior: "smooth"
230
+ });
231
+ }
225
232
  if (recognizing && interimTranscript === "" && finalTranscript === "") {
226
233
  // Set a timer to stop listening if no audio is detected after 10 seconds
227
234
  timer = setTimeout(() => {
@@ -479,6 +486,13 @@ function Pronouncer({
479
486
  onClose: handleClose,
480
487
  TransitionComponent: Transition,
481
488
  "aria-labelledby": "pronunciation-exercise-dialog",
489
+ PaperProps: {
490
+ sx: {
491
+ display: 'flex',
492
+ flexDirection: 'column',
493
+ height: '100%'
494
+ }
495
+ },
482
496
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.AppBar, {
483
497
  className: classes.appBar,
484
498
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Toolbar, {
@@ -574,240 +588,250 @@ function Pronouncer({
574
588
  exercise: "Pronunciation"
575
589
  })
576
590
  })]
577
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Grid, {
578
- container: true,
579
- className: classes.root,
580
- direction: "column",
581
- justifyContent: "center",
582
- alignItems: "center",
583
- spacing: 2,
591
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
592
+ ref: scrollRef,
584
593
  sx: {
585
- maxWidth: "lg",
586
- mx: "auto"
594
+ overflowY: 'auto',
595
+ flexGrow: 1,
596
+ display: 'flex',
597
+ justifyContent: 'center',
598
+ alignItems: 'center'
587
599
  },
588
- component: "main",
589
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
590
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
591
- title: t("pronounce_this_phrase"),
592
- placement: "top",
593
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
594
- variant: "h6",
595
- component: "h2",
596
- color: "inherit",
597
- children: t("pronounce_this_phrase", {
598
- lng: languageTag
600
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Grid, {
601
+ container: true,
602
+ className: classes.root,
603
+ direction: "column",
604
+ justifyContent: "center",
605
+ alignItems: "center",
606
+ spacing: 2,
607
+ sx: {
608
+ maxWidth: "lg",
609
+ mx: "auto"
610
+ },
611
+ component: "main",
612
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
613
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
614
+ title: t("pronounce_this_phrase"),
615
+ placement: "top",
616
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
617
+ variant: "h6",
618
+ component: "h2",
619
+ color: "inherit",
620
+ children: t("pronounce_this_phrase", {
621
+ lng: languageTag
622
+ })
599
623
  })
600
624
  })
601
- })
602
- }), image ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
603
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
604
- sx: {
605
- textAlign: "center",
606
- mx: "auto"
607
- },
608
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
609
- src: image,
610
- className: classes.image,
611
- alt: ""
612
- })
613
- })
614
- }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
615
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Grid, {
616
- container: true,
617
- direction: "row",
618
- justifyContent: "center",
619
- alignItems: "center",
620
- spacing: "1",
621
- children: [question && question.pronunciations && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
622
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
623
- variant: "body1",
624
- color: "textSecondary",
625
- gutterBottom: true,
626
- children: question && question.pronunciations[0]
625
+ }), image ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
626
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
627
+ sx: {
628
+ textAlign: "center",
629
+ mx: "auto"
630
+ },
631
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
632
+ src: image,
633
+ className: classes.image,
634
+ alt: ""
627
635
  })
628
- }), question && question.pronunciations && question.pronunciations[1] && !viewMoreTranslations && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
629
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
630
- title: t("see_more_pronunciations"),
631
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
636
+ })
637
+ }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
638
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Grid, {
639
+ container: true,
640
+ direction: "row",
641
+ justifyContent: "center",
642
+ alignItems: "center",
643
+ spacing: "1",
644
+ children: [question && question.pronunciations && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
645
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
646
+ variant: "body1",
632
647
  color: "textSecondary",
633
- edge: "end",
634
- size: "small",
635
- onClick: () => handleMoreTranslations(),
636
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_MoreHoriz.default, {})
648
+ gutterBottom: true,
649
+ children: question && question.pronunciations[0]
637
650
  })
638
- })
639
- }), viewMoreTranslations && question.pronunciations && question.pronunciations[1] && question.pronunciations.map((t, index) => {
640
- if (index === 0) {
641
- return null;
642
- } else {
643
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
644
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
645
- variant: "body1",
651
+ }), question && question.pronunciations && question.pronunciations[1] && !viewMoreTranslations && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
652
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
653
+ title: t("see_more_pronunciations"),
654
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
646
655
  color: "textSecondary",
647
- gutterBottom: true,
648
- children: ["| ", t]
656
+ edge: "end",
657
+ size: "small",
658
+ onClick: () => handleMoreTranslations(),
659
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_MoreHoriz.default, {})
649
660
  })
650
- });
651
- }
652
- })]
653
- })
654
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
655
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
656
- container: true,
657
- spacing: 1,
658
- justifyContent: "center",
659
- alignItems: "center",
660
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
661
- sx: {
662
- display: "flex",
663
- justifyContent: "center",
664
- flexDirection: "row",
665
- spacing: "5px"
666
- },
667
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
668
- sx: {
669
- display: "flex",
670
- justifyContent: "center"
671
- },
672
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
673
- src: getVoiceImage(),
674
- className: classes.nualaSpeaking,
675
- alt: ""
676
661
  })
677
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
662
+ }), viewMoreTranslations && question.pronunciations && question.pronunciations[1] && question.pronunciations.map((t, index) => {
663
+ if (index === 0) {
664
+ return null;
665
+ } else {
666
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
667
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
668
+ variant: "body1",
669
+ color: "textSecondary",
670
+ gutterBottom: true,
671
+ children: ["| ", t]
672
+ })
673
+ });
674
+ }
675
+ })]
676
+ })
677
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
678
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
679
+ container: true,
680
+ spacing: 1,
681
+ justifyContent: "center",
682
+ alignItems: "center",
683
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
678
684
  sx: {
679
- display: "grid",
680
- justifyContent: "flex-end",
681
- marginLeft: 1
685
+ display: "flex",
686
+ justifyContent: "center",
687
+ flexDirection: "row",
688
+ spacing: "5px"
682
689
  },
683
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ChatBubble.default, {
684
- id: "currentPhrase",
685
- handleTranslate: handleTranslate,
686
- handleSpeak: handleSpeak,
687
- clearQueue: clearQueue,
688
- stopAudio: stopAudio,
689
- learnLang: learnLang,
690
- voice: voice || null,
691
- voicePitch: voicePitch || null,
692
- voiceSpeed: voiceSpeed,
693
- forLang: forLang,
694
- wordList: currentPhrase ? (0, _utils.removeExtraWhiteSpaces)(currentPhrase.phrase).split(" ") : [],
695
- disableTranslation: false,
696
- isMessage: false,
697
- muteSound: muteSound,
698
- t: t
699
- }), learnLang !== "irish" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
700
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_WaveFormLite.default, {
701
- src: pollyResult ? pollyResult : "",
702
- controls: false,
703
- isSpeaking: isSpeaking,
704
- recognizing: recognizing,
705
- muteAudio: true,
706
- handleSpeak: () => {
707
- speak(currentPhrase.phrase, voice, false, "#currentPhrase", voiceLanguageCode, false, voicePitch);
708
- },
709
- theme: theme
690
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
691
+ sx: {
692
+ display: "flex",
693
+ justifyContent: "center"
694
+ },
695
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
696
+ src: getVoiceImage(),
697
+ className: classes.nualaSpeaking,
698
+ alt: ""
710
699
  })
700
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
701
+ sx: {
702
+ display: "grid",
703
+ justifyContent: "flex-end",
704
+ marginLeft: 1
705
+ },
706
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ChatBubble.default, {
707
+ id: "currentPhrase",
708
+ handleTranslate: handleTranslate,
709
+ handleSpeak: handleSpeak,
710
+ clearQueue: clearQueue,
711
+ stopAudio: stopAudio,
712
+ learnLang: learnLang,
713
+ voice: voice || null,
714
+ voicePitch: voicePitch || null,
715
+ voiceSpeed: voiceSpeed,
716
+ forLang: forLang,
717
+ wordList: currentPhrase ? (0, _utils.removeExtraWhiteSpaces)(currentPhrase.phrase).split(" ") : [],
718
+ disableTranslation: false,
719
+ isMessage: false,
720
+ muteSound: muteSound,
721
+ t: t
722
+ }), learnLang !== "irish" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
723
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_WaveFormLite.default, {
724
+ src: pollyResult ? pollyResult : "",
725
+ controls: false,
726
+ isSpeaking: isSpeaking,
727
+ recognizing: recognizing,
728
+ muteAudio: true,
729
+ handleSpeak: () => {
730
+ speak(currentPhrase.phrase, voice, false, "#currentPhrase", voiceLanguageCode, false, voicePitch);
731
+ },
732
+ theme: theme
733
+ })
734
+ })]
711
735
  })]
712
- })]
736
+ })
713
737
  })
714
- })
715
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
716
- sx: {
717
- marginTop: 1
718
- },
719
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
720
- sx: theme => ({
721
- [theme.breakpoints.down("md")]: {
722
- height: "50px",
723
- width: "200px",
738
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
739
+ sx: {
740
+ marginTop: 1
741
+ },
742
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
743
+ sx: theme => ({
744
+ [theme.breakpoints.down("md")]: {
745
+ height: "50px",
746
+ width: "200px",
747
+ color: "white",
748
+ padding: 2,
749
+ fontSize: "16px",
750
+ borderRadius: 3
751
+ },
752
+ height: "70px",
753
+ width: "250px",
724
754
  color: "white",
725
- padding: 2,
726
- fontSize: "16px",
727
- borderRadius: 3
755
+ backgroundColor: recognizing ? "#d32f2f" : "#2d7b30",
756
+ padding: 1,
757
+ fontSize: "20px",
758
+ borderRadius: 5,
759
+ border: "1.5px solid transparent",
760
+ "&:hover": {
761
+ backgroundColor: recognizing ? "#d32f2f" : "#2d7b30",
762
+ border: "1.5px solid black"
763
+ }
764
+ }),
765
+ onClick: () => handleMic(currentPhrase ? currentPhrase.phrase : ""),
766
+ startIcon: recognizing ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_MicOff.default, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Mic.default, {}),
767
+ color: recognizing ? "error" : "success",
768
+ disabled: isSpeaking || !isSocketConnected || isRecognizingDisabled,
769
+ id: "voiceInput",
770
+ variant: "contained",
771
+ ref: btnRef,
772
+ children: recognizing ? t("click_to_stop") : t("click_to_start")
773
+ })
774
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
775
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
776
+ role: "status",
777
+ sx: {
778
+ mt: isListeningIndicatorTextVisible ? 3 : 0
728
779
  },
729
- height: "70px",
730
- width: "250px",
731
- color: "white",
732
- backgroundColor: recognizing ? "#d32f2f" : "#2d7b30",
733
- padding: 1,
780
+ textAlign: "center",
781
+ fontWeight: "bolder",
734
782
  fontSize: "20px",
735
- borderRadius: 5,
736
- border: "1.5px solid transparent",
737
- "&:hover": {
738
- backgroundColor: recognizing ? "#d32f2f" : "#2d7b30",
739
- border: "1.5px solid black"
740
- }
741
- }),
742
- onClick: () => handleMic(currentPhrase ? currentPhrase.phrase : ""),
743
- startIcon: recognizing ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_MicOff.default, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Mic.default, {}),
744
- color: recognizing ? "error" : "success",
745
- disabled: isSpeaking || !isSocketConnected || isRecognizingDisabled,
746
- id: "voiceInput",
747
- variant: "contained",
748
- ref: btnRef,
749
- children: recognizing ? t("click_to_stop") : t("click_to_start")
750
- })
751
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
752
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
753
- role: "status",
754
- sx: {
755
- mt: isListeningIndicatorTextVisible ? 3 : 0
756
- },
757
- textAlign: "center",
758
- fontWeight: "bolder",
759
- fontSize: "20px",
760
- "aria-label": "Mic is",
761
- "aria-live": "polite",
762
- children: isListeningIndicatorTextVisible ? t("listening_indicator") : ""
763
- })
764
- }), finalTranscript || interimTranscript ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Grid, {
765
- alignItems: "center",
766
- className: classes.setWidth,
767
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
768
- title: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
769
- children: `Confidence: ${((transcriptConfidence || 0) * 100).toFixed(0)}%`
770
- }),
771
- open: isConfidenceOpen,
772
- onClose: handleCloseConfidence,
773
- onOpen: handleOpenConfidence,
774
- role: "status",
775
- "aria-live": "assertive",
776
- "aria-label": `Confidence: ${(transcriptConfidence * 100).toFixed(0)}%`,
777
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
778
- children: (finalTranscript || interimTranscript).split(" ").map((word, i) => {
779
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
780
- className: classes.finalTranscript,
781
- variant: "h5",
782
- color: phraseWordList[i] && checkIsPronunciationCorrect(word.trim(), {
783
- phrase: phraseWordList[i].trim(),
784
- alternativeVersions: currentPhrase.alternativeVersions ? currentPhrase.alternativeVersions.map(altAns => {
785
- return altAns ? (0, _utils.removeExtraWhiteSpaces)(altAns).split(" ")[i] : "";
786
- }) : []
787
- }) ? "secondary" : "",
788
- component: "span",
789
- children: word
790
- });
791
- })
783
+ "aria-label": "Mic is",
784
+ "aria-live": "polite",
785
+ children: isListeningIndicatorTextVisible ? t("listening_indicator") : ""
792
786
  })
793
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
794
- onClick: handleReset,
795
- size: "small",
796
- className: classes.listenButton,
797
- "aria-label": "Clear",
798
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Clear.default, {
799
- className: cx(classes.iconSmall)
787
+ }), finalTranscript || interimTranscript ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Grid, {
788
+ alignItems: "center",
789
+ className: classes.setWidth,
790
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
791
+ title: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
792
+ children: `Confidence: ${((transcriptConfidence || 0) * 100).toFixed(0)}%`
793
+ }),
794
+ open: isConfidenceOpen,
795
+ onClose: handleCloseConfidence,
796
+ onOpen: handleOpenConfidence,
797
+ role: "status",
798
+ "aria-live": "assertive",
799
+ "aria-label": `Confidence: ${(transcriptConfidence * 100).toFixed(0)}%`,
800
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
801
+ children: (finalTranscript || interimTranscript).split(" ").map((word, i) => {
802
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
803
+ className: classes.finalTranscript,
804
+ variant: "h5",
805
+ color: phraseWordList[i] && checkIsPronunciationCorrect(word.trim(), {
806
+ phrase: phraseWordList[i].trim(),
807
+ alternativeVersions: currentPhrase.alternativeVersions ? currentPhrase.alternativeVersions.map(altAns => {
808
+ return altAns ? (0, _utils.removeExtraWhiteSpaces)(altAns).split(" ")[i] : "";
809
+ }) : []
810
+ }) ? "secondary" : "",
811
+ component: "span",
812
+ children: word
813
+ });
814
+ })
815
+ })
816
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
817
+ onClick: handleReset,
818
+ size: "small",
819
+ className: classes.listenButton,
820
+ "aria-label": "Clear",
821
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Clear.default, {
822
+ className: cx(classes.iconSmall)
823
+ })
824
+ })]
825
+ }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
826
+ className: classes.waveform,
827
+ "aria-labelledby": finalTranscript,
828
+ children: attemptAudioURL && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Waveform.default, {
829
+ src: attemptAudioURL,
830
+ theme: theme,
831
+ controls: true
800
832
  })
801
833
  })]
802
- }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
803
- className: classes.waveform,
804
- "aria-labelledby": finalTranscript,
805
- children: attemptAudioURL && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Waveform.default, {
806
- src: attemptAudioURL,
807
- theme: theme,
808
- controls: true
809
- })
810
- })]
834
+ })
811
835
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExerciseBottomBar.default, {
812
836
  t: t,
813
837
  handleSubmit: () => handleContinue(false, currentPhrase),
@@ -44,7 +44,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
44
44
 
45
45
  const useStyles = (0, _mui.makeStyles)()(theme => ({
46
46
  appBar: {
47
- position: "sticky",
47
+ position: "relative",
48
48
  paddingTop: `env(safe-area-inset-top)`,
49
49
  paddingRight: `env(safe-area-inset-right)`,
50
50
  paddingLeft: `env(safe-area-inset-left)`
@@ -252,6 +252,7 @@ function Translator({
252
252
  const {
253
253
  classes
254
254
  } = useStyles();
255
+ const scrollRef = (0, _react.useRef)(null);
255
256
  const [wordBankTooltipOpen, setWordBankTooltipOpen] = (0, _react.useState)(false);
256
257
  const initialVoiceSpeed = topicInfo && topicInfo.voiceSpeed ? topicInfo.voiceSpeed : "";
257
258
  const exerciseState = (0, _useExerciseState.default)({
@@ -464,6 +465,14 @@ function Translator({
464
465
  (0, _react.useEffect)(() => {
465
466
  checkAnswer && checkCompletionAndNotify();
466
467
  }, [checkAnswer]);
468
+ (0, _react.useEffect)(() => {
469
+ if (scrollRef.current && useWordBank) {
470
+ scrollRef.current.scroll({
471
+ top: scrollRef.current.scrollHeight,
472
+ behavior: "smooth"
473
+ });
474
+ }
475
+ }, [useWordBank]);
467
476
  (0, _react.useEffect)(() => {
468
477
  if (open && !run && !localStorage.getItem(`translation-exercise-tour-completed`)) {
469
478
  setJoyrideState(prevState => ({
@@ -542,6 +551,9 @@ function Translator({
542
551
  const goBackToAssignment = () => {
543
552
  navigate(`/classrooms/${classroomId}#Assignments`);
544
553
  };
554
+ const noTranslationWords = !translationWords || translationWords.length === 0;
555
+ const isWordBankMode = useWordBank && isWordBankEnabled;
556
+ const isSubmitAnswerDisabled = isWordBankMode ? !isWordBankAttemptChanged || noTranslationWords : !translationText && noTranslationWords;
545
557
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Dialog, {
546
558
  fullScreen: true,
547
559
  open: open,
@@ -652,9 +664,13 @@ function Translator({
652
664
  })
653
665
  })]
654
666
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
667
+ ref: scrollRef,
655
668
  sx: {
669
+ overflowY: 'auto',
656
670
  flexGrow: 1,
657
- overflowY: 'auto'
671
+ display: 'flex',
672
+ justifyContent: 'center',
673
+ alignItems: 'center'
658
674
  },
659
675
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Grid, {
660
676
  container: true,
@@ -907,38 +923,13 @@ function Translator({
907
923
  })]
908
924
  })]
909
925
  })
910
- }), useWordBank && isWordBankEnabled ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
911
- sx: {
912
- position: 'sticky',
913
- bottom: 0,
914
- zIndex: 1100,
915
- backgroundColor: theme => theme.palette.background.paper
916
- },
917
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExerciseBottomBar.default, {
918
- t: t,
919
- translationWords: translationWords,
920
- handleSubmit: () => handleContinue(false),
921
- handleSkip: () => handleContinue(true),
922
- isSubmitAnswerAllowed: true,
923
- isSubmitAnswerDisabled: !isWordBankAttemptChanged || !translationWords || translationWords.length === 0,
924
- useWordBank: useWordBank
925
- })
926
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
927
- sx: {
928
- position: 'sticky',
929
- bottom: 0,
930
- zIndex: 1100,
931
- backgroundColor: theme => theme.palette.background.paper
932
- },
933
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExerciseBottomBar.default, {
934
- t: t,
935
- translationWords: translationWords,
936
- handleSubmit: () => handleContinue(false),
937
- handleSkip: () => handleContinue(true),
938
- isSubmitAnswerAllowed: true,
939
- isSubmitAnswerDisabled: !translationText && (!translationWords || translationWords.length === 0),
940
- useWordBank: useWordBank
941
- })
926
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExerciseBottomBar.default, {
927
+ t: t,
928
+ translationWords: translationWords,
929
+ handleSubmit: () => handleContinue(false),
930
+ handleSkip: () => handleContinue(true),
931
+ isSubmitAnswerAllowed: true,
932
+ isSubmitAnswerDisabled: isSubmitAnswerDisabled
942
933
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_AnswerResult.default, {
943
934
  t: t,
944
935
  open: isCorrectResultOpen,
@@ -586,8 +586,7 @@ function LiveListener({
586
586
  listeningText: listeningText,
587
587
  listeningWords: listeningWords,
588
588
  setCurrentAnswer: setCurrentAnswer,
589
- exercise: exercise,
590
- useWordBank: useWordBank
589
+ exercise: exercise
591
590
  })]
592
591
  });
593
592
  }
@@ -708,8 +708,7 @@ function LiveTranslator({
708
708
  translationText: translationText,
709
709
  translationWords: translationWords,
710
710
  setCurrentAnswer: setCurrentAnswer,
711
- exercise: exercise,
712
- useWordBank: useWordBank
711
+ exercise: exercise
713
712
  })]
714
713
  });
715
714
  }
@@ -12,10 +12,7 @@ var _jsxRuntime = require("react/jsx-runtime");
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
13
  const useStyles = (0, _mui.makeStyles)()(theme => ({
14
14
  footer: {
15
- [theme.breakpoints.down("md")]: {
16
- padding: theme.spacing(2)
17
- },
18
- padding: theme.spacing(3),
15
+ padding: theme.spacing(2),
19
16
  borderTop: `2px solid ${theme.palette.grey[300]}`
20
17
  }
21
18
  }));
@@ -34,26 +31,17 @@ function ExerciseBottomBar({
34
31
  setCurrentAnswer,
35
32
  translationText,
36
33
  translationWords,
37
- exercise,
38
- useWordBank
34
+ exercise
39
35
  }) {
40
36
  const {
41
37
  classes
42
38
  } = useStyles();
43
- const submitButtonRef = (0, _react.useRef)(null);
44
39
  (0, _react.useEffect)(() => {
45
40
  if (isTimeUp) {
46
41
  handleSubmit();
47
42
  setIsAnswered(true);
48
43
  }
49
44
  }, [isTimeUp]);
50
- (0, _react.useEffect)(() => {
51
- if (submitButtonRef.current && useWordBank) {
52
- submitButtonRef.current.scrollIntoView({
53
- behavior: "smooth"
54
- });
55
- }
56
- }, [useWordBank]);
57
45
  const handleAnswerButtonClick = () => {
58
46
  if (isLive && isAnswered) {
59
47
  setIsAnswered(false);
@@ -85,7 +73,6 @@ function ExerciseBottomBar({
85
73
  })
86
74
  }), (isLive || isSubmitAnswerAllowed) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
87
75
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
88
- ref: submitButtonRef,
89
76
  color: isLive && isAnswered ? "primary" : "secondary",
90
77
  variant: isAnswered ? "outlined" : "contained",
91
78
  onClick: handleAnswerButtonClick,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nualang/nualang-ui-components",
3
- "version": "0.1.1245",
3
+ "version": "0.1.1246",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist",