catchup-library-web 2.7.7 → 2.7.8

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.
package/dist/index.js CHANGED
@@ -6393,7 +6393,8 @@ var MCMAActivityMaterialContent = ({
6393
6393
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "hidden md:block flex-shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DividerLine_default, {}) }),
6394
6394
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "flex-1 min-h-0 overflow-y-auto", children: checkCanAnswerQuestion() ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "flex flex-row w-full flex-wrap ", children: materialMap[materialKey].map(
6395
6395
  (materialSubKey, index2) => {
6396
- const foundAnswer = displayAnswerMap[materialKey].find(
6396
+ const currentDisplayAnswerList = displayAnswerMap[materialKey] || [];
6397
+ const foundAnswer = currentDisplayAnswerList.find(
6397
6398
  (learnerAnswer) => learnerAnswer === materialSubKey
6398
6399
  );
6399
6400
  const learnerAnswerState = !isPreview ? "HIDDEN" : materialSubKey !== foundAnswer ? "EMPTY" : checkAnswerState(correctAnswerList, foundAnswer);
@@ -6411,7 +6412,7 @@ var MCMAActivityMaterialContent = ({
6411
6412
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6412
6413
  BaseImage_default,
6413
6414
  {
6414
- src: displayAnswerMap[materialKey].includes(materialSubKey) ? "/icons/checkbox.webp" : "/icons/checkbox-empty.webp",
6415
+ src: currentDisplayAnswerList.includes(materialSubKey) ? "/icons/checkbox.webp" : "/icons/checkbox-empty.webp",
6415
6416
  alt: "checkbox",
6416
6417
  size: "small",
6417
6418
  onClick: () => {
@@ -6442,7 +6443,7 @@ var MCMAActivityMaterialContent = ({
6442
6443
  );
6443
6444
  }
6444
6445
  ) }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: "text-xl", children: constructInputWithSpecialExpressionList(
6445
- displayAnswerMap[materialKey]
6446
+ displayAnswerMap[materialKey] || ""
6446
6447
  ).map((inputPart, index2) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
6447
6448
  "span",
6448
6449
  {
@@ -7639,8 +7640,12 @@ var ActivityPreviewByData = ({
7639
7640
  if (optionList.length === 0) return;
7640
7641
  setSelectedType(optionList[0].id);
7641
7642
  }, [optionList]);
7643
+ const prevDataStringRef = (0, import_react27.useRef)("");
7642
7644
  (0, import_react27.useEffect)(() => {
7643
7645
  if (activityTemplateTypeList.length === 0) return;
7646
+ const dataString = JSON.stringify(data);
7647
+ if (dataString === prevDataStringRef.current) return;
7648
+ prevDataStringRef.current = dataString;
7644
7649
  const currentAnswerMapMap = {};
7645
7650
  for (const activityTemplateMap of activityTemplateTypeList) {
7646
7651
  if (answerType === activityTemplateMap.type) {
package/dist/index.mjs CHANGED
@@ -6153,7 +6153,8 @@ var MCMAActivityMaterialContent = ({
6153
6153
  /* @__PURE__ */ jsx36("div", { className: "hidden md:block flex-shrink-0", children: /* @__PURE__ */ jsx36(DividerLine_default, {}) }),
6154
6154
  /* @__PURE__ */ jsx36("div", { className: "flex-1 min-h-0 overflow-y-auto", children: checkCanAnswerQuestion() ? /* @__PURE__ */ jsx36("div", { className: "flex flex-row w-full flex-wrap ", children: materialMap[materialKey].map(
6155
6155
  (materialSubKey, index2) => {
6156
- const foundAnswer = displayAnswerMap[materialKey].find(
6156
+ const currentDisplayAnswerList = displayAnswerMap[materialKey] || [];
6157
+ const foundAnswer = currentDisplayAnswerList.find(
6157
6158
  (learnerAnswer) => learnerAnswer === materialSubKey
6158
6159
  );
6159
6160
  const learnerAnswerState = !isPreview ? "HIDDEN" : materialSubKey !== foundAnswer ? "EMPTY" : checkAnswerState(correctAnswerList, foundAnswer);
@@ -6171,7 +6172,7 @@ var MCMAActivityMaterialContent = ({
6171
6172
  /* @__PURE__ */ jsx36(
6172
6173
  BaseImage_default,
6173
6174
  {
6174
- src: displayAnswerMap[materialKey].includes(materialSubKey) ? "/icons/checkbox.webp" : "/icons/checkbox-empty.webp",
6175
+ src: currentDisplayAnswerList.includes(materialSubKey) ? "/icons/checkbox.webp" : "/icons/checkbox-empty.webp",
6175
6176
  alt: "checkbox",
6176
6177
  size: "small",
6177
6178
  onClick: () => {
@@ -6202,7 +6203,7 @@ var MCMAActivityMaterialContent = ({
6202
6203
  );
6203
6204
  }
6204
6205
  ) }) : /* @__PURE__ */ jsx36("p", { className: "text-xl", children: constructInputWithSpecialExpressionList(
6205
- displayAnswerMap[materialKey]
6206
+ displayAnswerMap[materialKey] || ""
6206
6207
  ).map((inputPart, index2) => /* @__PURE__ */ jsx36(
6207
6208
  "span",
6208
6209
  {
@@ -7282,7 +7283,7 @@ var ActivityEvaluationRubricContent = ({
7282
7283
  var ActivityEvaluationRubricContent_default = ActivityEvaluationRubricContent;
7283
7284
 
7284
7285
  // src/components/activities/ActivityPreviewByData.tsx
7285
- import { useEffect as useEffect16, useState as useState26 } from "react";
7286
+ import { useEffect as useEffect16, useRef as useRef8, useState as useState26 } from "react";
7286
7287
 
7287
7288
  // src/components/boxes/SelectionBox.tsx
7288
7289
  import { jsx as jsx48, jsxs as jsxs38 } from "react/jsx-runtime";
@@ -7399,8 +7400,12 @@ var ActivityPreviewByData = ({
7399
7400
  if (optionList.length === 0) return;
7400
7401
  setSelectedType(optionList[0].id);
7401
7402
  }, [optionList]);
7403
+ const prevDataStringRef = useRef8("");
7402
7404
  useEffect16(() => {
7403
7405
  if (activityTemplateTypeList.length === 0) return;
7406
+ const dataString = JSON.stringify(data);
7407
+ if (dataString === prevDataStringRef.current) return;
7408
+ prevDataStringRef.current = dataString;
7404
7409
  const currentAnswerMapMap = {};
7405
7410
  for (const activityTemplateMap of activityTemplateTypeList) {
7406
7411
  if (answerType === activityTemplateMap.type) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "catchup-library-web",
3
- "version": "2.7.7",
3
+ "version": "2.7.8",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,4 +1,4 @@
1
- import { useEffect, useState } from "react";
1
+ import { useEffect, useRef, useState } from "react";
2
2
  import DropdownActivityContent from "./DropdownActivityContent";
3
3
  import FillInTheBlanksActivityContent from "./FillInTheBlanksActivityContent";
4
4
  import GroupingActivityContent from "./GroupingActivityContent";
@@ -102,8 +102,12 @@ const ActivityPreviewByData = ({
102
102
  setSelectedType(optionList[0].id);
103
103
  }, [optionList]);
104
104
 
105
+ const prevDataStringRef = useRef<string>("");
105
106
  useEffect(() => {
106
107
  if (activityTemplateTypeList.length === 0) return;
108
+ const dataString = JSON.stringify(data);
109
+ if (dataString === prevDataStringRef.current) return;
110
+ prevDataStringRef.current = dataString;
107
111
  const currentAnswerMapMap: any = {};
108
112
  for (const activityTemplateMap of activityTemplateTypeList) {
109
113
  if (answerType === activityTemplateMap.type) {
@@ -56,7 +56,8 @@ const MCMAActivityMaterialContent = ({
56
56
  <div className="flex flex-row w-full flex-wrap ">
57
57
  {materialMap[materialKey].map(
58
58
  (materialSubKey: string, index: number) => {
59
- const foundAnswer = displayAnswerMap[materialKey].find(
59
+ const currentDisplayAnswerList = displayAnswerMap[materialKey] || [];
60
+ const foundAnswer = currentDisplayAnswerList.find(
60
61
  (learnerAnswer: string) => learnerAnswer === materialSubKey
61
62
  );
62
63
  const learnerAnswerState = !isPreview
@@ -84,7 +85,7 @@ const MCMAActivityMaterialContent = ({
84
85
  >
85
86
  <BaseImage
86
87
  src={
87
- displayAnswerMap[materialKey].includes(materialSubKey)
88
+ currentDisplayAnswerList.includes(materialSubKey)
88
89
  ? "/icons/checkbox.webp"
89
90
  : "/icons/checkbox-empty.webp"
90
91
  }
@@ -131,7 +132,7 @@ const MCMAActivityMaterialContent = ({
131
132
  ) : (
132
133
  <p key={materialKey} className="text-xl">
133
134
  {constructInputWithSpecialExpressionList(
134
- displayAnswerMap[materialKey]
135
+ displayAnswerMap[materialKey] || ""
135
136
  ).map((inputPart, index) => (
136
137
  <span
137
138
  key={index}