@nualang/nualang-ui-components 0.1.1273 → 0.1.1274

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.
@@ -221,7 +221,11 @@ function Bot({
221
221
  tabIndex: 0,
222
222
  verificationStatus: verificationStatus,
223
223
  gameAward: gameAward,
224
- badgeSize: "small"
224
+ badgeSize: "small",
225
+ sx: theme => ({
226
+ backgroundColor: theme.palette.mode === "dark" ? "#ffffff" : "#bdbdbd",
227
+ color: theme.palette.mode === "dark" ? theme.palette.background.default : "white"
228
+ })
225
229
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardElements.CardAvatar, {
226
230
  sx: theme => ({
227
231
  backgroundColor: theme.palette.mode === "dark" ? "#ffffff" : "#bdbdbd",
@@ -402,7 +402,7 @@ function CourseCard({
402
402
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardElements.CardAvatar, {
403
403
  sx: theme => ({
404
404
  backgroundColor: theme.palette.mode === "dark" ? "#ffffff" : "#bdbdbd",
405
- color: theme.palette.mode === "dark" ? "#ffffff" : "#bdbdbd"
405
+ color: theme.palette.mode === "dark" ? theme.palette.background.default : "white"
406
406
  }),
407
407
  "aria-label": `${t("go_to")} ${createdByName || `${courseName} ${t("creator")}`} ${t("profile")}`,
408
408
  title: createdByName || `${courseName} creator`,
@@ -220,7 +220,11 @@ function Roleplay({
220
220
  tabIndex: 0,
221
221
  verificationStatus: verificationStatus,
222
222
  gameAward: gameAward,
223
- badgeSize: "small"
223
+ badgeSize: "small",
224
+ sx: theme => ({
225
+ backgroundColor: theme.palette.mode === "dark" ? "#ffffff" : "#bdbdbd",
226
+ color: theme.palette.mode === "dark" ? "#ffffff" : "#bdbdbd"
227
+ })
224
228
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardElements.CardAvatar, {
225
229
  sx: theme => ({
226
230
  backgroundColor: theme.palette.mode === "dark" ? "#ffffff" : "#bdbdbd",
@@ -112,7 +112,11 @@ function Topic({
112
112
  tabIndex: 0,
113
113
  verificationStatus: verificationStatus,
114
114
  gameAward: gameAward,
115
- badgeSize: "small"
115
+ badgeSize: "small",
116
+ sx: theme => ({
117
+ backgroundColor: theme.palette.mode === "dark" ? "#ffffff" : "#bdbdbd",
118
+ color: theme.palette.mode === "dark" ? "#ffffff" : "#bdbdbd"
119
+ })
116
120
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardElements.CardAvatar, {
117
121
  sx: theme => ({
118
122
  backgroundColor: theme.palette.mode === "dark" ? "#ffffff" : "#bdbdbd",
@@ -68,24 +68,34 @@ function Messages({
68
68
  const {
69
69
  classes
70
70
  } = useStyles();
71
+
72
+ // Creates a unique string from each message's loading state and text to ensure the scroll effect runs when content updates, even if array length doesn't change.
73
+ const messagesScrollKey = (0, _react.useMemo)(() => {
74
+ if (!Array.isArray(messages)) return "";
75
+ return messages.map(m => {
76
+ const isLoading = m?.isLoading ?? false;
77
+ const text = m?.text ?? (isLoading ? "Loading ..." : "");
78
+ return `${isLoading}-${text}`;
79
+ }).join("|");
80
+ }, [messages]);
71
81
  (0, _react.useEffect)(() => {
72
82
  if (!disableScroll) {
73
83
  const messagesElement = document.getElementById("messages");
74
84
  const gameContainer = document.getElementById("gameContainer");
75
85
  setTimeout(() => {
76
- messagesElement.scrollTo({
86
+ messagesElement?.scrollTo({
77
87
  top: messagesElement.scrollHeight,
78
88
  behavior: "smooth"
79
89
  });
80
90
  if (isLiveGame) {
81
- gameContainer.scrollTo({
91
+ gameContainer?.scrollTo({
82
92
  top: gameContainer.scrollHeight,
83
93
  behavior: "smooth"
84
94
  });
85
95
  }
86
96
  }, 0);
87
97
  }
88
- }, [disableScroll, messages.length, currentMessage, isTimeUp]);
98
+ }, [disableScroll, messages.length, messagesScrollKey, currentMessage, isTimeUp]);
89
99
  const onDragEnd = result => {
90
100
  const {
91
101
  active,
@@ -376,20 +376,22 @@ function Bot({
376
376
  //returning the ending variable text(s) of the bot e.g. ['The conversation has ended.']
377
377
  return botEndingTextArray.length > 0 ? botEndingTextArray : null;
378
378
  };
379
+ const normalizeAndStrip = text => {
380
+ return text.trim().normalize("NFC").toLowerCase().replace(/[^\p{L}\p{N}\s]/gu, "");
381
+ };
379
382
  (0, _react.useEffect)(() => {
380
383
  if (bot && bot.riveFile) {
381
384
  const botEndingTextArray = getBotRiveScriptEndingText(bot.riveFile);
382
- const normalizedCurrentPhrase = currentPhrase.trim().normalize();
383
- const normalizedEndingVars = botEndingTextArray.map(varString => varString.trim().normalize());
384
-
385
- //Checking if the current phrase text and the bot end text is the same
386
- if (normalizedEndingVars.includes(normalizedCurrentPhrase)) {
385
+ const normalizedCurrentPhrase = normalizeAndStrip(currentPhrase);
386
+ const normalizedEndingVars = botEndingTextArray.map(text => normalizeAndStrip(text));
387
+ const isEndingPhraseMatched = normalizedEndingVars.some(ending => normalizedCurrentPhrase.includes(ending));
388
+ if (isEndingPhraseMatched && !isSpeaking) {
387
389
  setTimeout(() => {
388
390
  handleCompleteExercise();
389
391
  }, 2000);
390
392
  }
391
393
  }
392
- }, [currentPhrase, bot]);
394
+ }, [currentPhrase, bot, isSpeaking]);
393
395
  (0, _react.useEffect)(() => {
394
396
  if (open && !run && !localStorage.getItem(`bot-exercise-tour-completed`)) {
395
397
  setJoyrideState(prevState => ({
@@ -1238,8 +1238,16 @@ function Classroom({
1238
1238
  role: "link",
1239
1239
  tabIndex: 0,
1240
1240
  verificationStatus: verificationStatus,
1241
- gameAward: gameAward
1241
+ gameAward: gameAward,
1242
+ sx: theme => ({
1243
+ backgroundColor: theme.palette.mode === "dark" ? "#ffffff" : "#bdbdbd",
1244
+ color: theme.palette.mode === "dark" ? "#ffffff" : "#bdbdbd"
1245
+ })
1242
1246
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardElements.CardAvatar, {
1247
+ sx: theme => ({
1248
+ backgroundColor: theme.palette.mode === "dark" ? "#ffffff" : "#bdbdbd",
1249
+ color: theme.palette.mode === "dark" ? theme.palette.background.default : "white"
1250
+ }),
1243
1251
  "aria-label": `Open ${classroomName} creator's profile`,
1244
1252
  className: classes.cardTopAvatar,
1245
1253
  alt: `${classroomName} creator`,
@@ -751,7 +751,11 @@ function Course({
751
751
  role: "link",
752
752
  tabIndex: 0,
753
753
  verificationStatus: verificationStatus,
754
- gameAward: gameAward
754
+ gameAward: gameAward,
755
+ sx: theme => ({
756
+ backgroundColor: theme.palette.mode === "dark" ? "#ffffff" : "#bdbdbd",
757
+ color: theme.palette.mode === "dark" ? "#ffffff" : "#bdbdbd"
758
+ })
755
759
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardElements.CardAvatar, {
756
760
  "aria-label": `Open ${courseName} creator's profile`,
757
761
  title: createdByName || `${courseName} creator`,
@@ -767,6 +771,10 @@ function Course({
767
771
  tabIndex: 0,
768
772
  verificationStatus: verificationStatus,
769
773
  gameAward: gameAward,
774
+ sx: theme => ({
775
+ backgroundColor: theme.palette.mode === "dark" ? "#ffffff" : "#bdbdbd",
776
+ color: theme.palette.mode === "dark" ? theme.palette.background.default : "white"
777
+ }),
770
778
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Person.default, {
771
779
  fontSize: "large"
772
780
  })
@@ -952,12 +952,16 @@ function Topic({
952
952
  tabIndex: 0,
953
953
  verificationStatus: verificationStatus,
954
954
  gameAward: gameAward,
955
- title: createdByName || `${topicName} creator`
955
+ title: createdByName || `${topicName} creator`,
956
+ sx: theme => ({
957
+ backgroundColor: theme.palette.mode === "dark" ? "#ffffff" : "#bdbdbd",
958
+ color: theme.palette.mode === "dark" ? "#ffffff" : "#bdbdbd"
959
+ })
956
960
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardElements.CardAvatar, {
957
961
  "aria-label": `${t("go_to")} ${createdByName || `${topicName} ${t("creator")}`} ${t("profile")}`,
958
962
  sx: theme => ({
959
- backgroundColor: theme.palette.mode === "dark" ? "white" : "",
960
- color: theme.palette.mode === "dark" ? theme.palette.background.default : ""
963
+ backgroundColor: theme.palette.mode === "dark" ? "#ffffff" : "#bdbdbd",
964
+ color: theme.palette.mode === "dark" ? theme.palette.background.default : "white"
961
965
  }),
962
966
  alt: "",
963
967
  className: classes.cardTopAvatar,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nualang/nualang-ui-components",
3
- "version": "0.1.1273",
3
+ "version": "0.1.1274",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist",