catchup-library-web 1.20.26 → 1.20.28

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
@@ -4424,46 +4424,67 @@ var import_react13 = require("react");
4424
4424
  var import_jsx_runtime23 = require("react/jsx-runtime");
4425
4425
  var MediaDropdown = ({ id, answer, optionList }) => {
4426
4426
  const [showDropdown, setShowDropdown] = (0, import_react13.useState)(false);
4427
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
4428
- "div",
4429
- {
4430
- className: "w-full relative",
4431
- onMouseEnter: () => {
4432
- setShowDropdown(true);
4433
- },
4434
- onMouseLeave: () => {
4427
+ const dropdownRef = (0, import_react13.useRef)(null);
4428
+ (0, import_react13.useEffect)(() => {
4429
+ const handleClickOutside = (event) => {
4430
+ if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
4435
4431
  setShowDropdown(false);
4436
- },
4437
- children: [
4438
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "w-full flex flex-col items-center justify-center", children: answer }),
4439
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4440
- "ul",
4432
+ }
4433
+ };
4434
+ if (showDropdown) {
4435
+ document.addEventListener("mousedown", handleClickOutside);
4436
+ document.addEventListener("touchstart", handleClickOutside);
4437
+ }
4438
+ return () => {
4439
+ document.removeEventListener("mousedown", handleClickOutside);
4440
+ document.removeEventListener("touchstart", handleClickOutside);
4441
+ };
4442
+ }, [showDropdown]);
4443
+ const handleToggleDropdown = (e) => {
4444
+ e.stopPropagation();
4445
+ setShowDropdown((prev) => !prev);
4446
+ };
4447
+ const handleOptionClick = (option, e) => {
4448
+ e.stopPropagation();
4449
+ if (option.onClick) {
4450
+ option.onClick(e);
4451
+ }
4452
+ setShowDropdown(false);
4453
+ };
4454
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { ref: dropdownRef, className: "w-full relative", children: [
4455
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4456
+ "div",
4457
+ {
4458
+ className: "w-full flex flex-col items-center justify-center cursor-pointer",
4459
+ onClick: handleToggleDropdown,
4460
+ children: answer
4461
+ }
4462
+ ),
4463
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4464
+ "ul",
4465
+ {
4466
+ className: `absolute ${showDropdown ? "opacity-100 visible" : "opacity-0 invisible"} flex flex-col items-center w-[300px] rounded-catchup-xlarge border-3 transition-all duration-300 border-catchup-blue bg-catchup-white px-4 py-4 translate-x-1/2 right-1/2 mt-2 z-10`,
4467
+ children: optionList.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
4468
+ "li",
4441
4469
  {
4442
- className: `absolute ${showDropdown ? "opacity-100 visible" : "opacity-0 invisible"} flex flex-col items-center w-[300px] rounded-catchup-xlarge border-3 transition-all duration-300 border-catchup-blue bg-catchup-white px-4 py-4 translate-x-1/2 right-1/2 mt-2 z-10`,
4443
- children: optionList.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
4444
- "li",
4445
- {
4446
- className: `${option.listItemClassNames ? option.listItemClassNames : ""}`,
4447
- children: [
4448
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4449
- "div",
4450
- {
4451
- className: `w-full flex flex-col my-2 ${option.divClassNames ? option.divClassNames : ""}`,
4452
- onClick: option.onClick,
4453
- children: option.media
4454
- }
4455
- ),
4456
- index !== optionList.length - 1 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "w-full border my-1 border-catchup-light-blue rounded-catchup-full" }) : null
4457
- ]
4458
- },
4459
- option.id
4460
- ))
4461
- }
4462
- )
4463
- ]
4464
- },
4465
- id
4466
- );
4470
+ className: `${option.listItemClassNames ? option.listItemClassNames : ""}`,
4471
+ children: [
4472
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4473
+ "div",
4474
+ {
4475
+ className: `w-full flex flex-col my-2 cursor-pointer ${option.divClassNames ? option.divClassNames : ""}`,
4476
+ onClick: (e) => handleOptionClick(option, e),
4477
+ children: option.media
4478
+ }
4479
+ ),
4480
+ index !== optionList.length - 1 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "w-full border my-1 border-catchup-light-blue rounded-catchup-full" }) : null
4481
+ ]
4482
+ },
4483
+ option.id
4484
+ ))
4485
+ }
4486
+ )
4487
+ ] }, id);
4467
4488
  };
4468
4489
  var MediaDropdown_default = MediaDropdown;
4469
4490
 
package/dist/index.mjs CHANGED
@@ -4103,7 +4103,7 @@ var InputGroup = ({
4103
4103
  var InputGroup_default = InputGroup;
4104
4104
 
4105
4105
  // src/components/activities/material-contents/DropdownActivityMaterialContent.tsx
4106
- import { useEffect as useEffect5 } from "react";
4106
+ import { useEffect as useEffect6 } from "react";
4107
4107
  import { useState as useState15 } from "react";
4108
4108
 
4109
4109
  // src/utilization/AppUtilization.ts
@@ -4204,55 +4204,76 @@ var getColorByIndex = (index) => {
4204
4204
  };
4205
4205
 
4206
4206
  // src/components/dropdowns/MediaDropdown.tsx
4207
- import { useState as useState13 } from "react";
4207
+ import { useState as useState13, useEffect as useEffect4, useRef as useRef2 } from "react";
4208
4208
  import { jsx as jsx23, jsxs as jsxs13 } from "react/jsx-runtime";
4209
4209
  var MediaDropdown = ({ id, answer, optionList }) => {
4210
4210
  const [showDropdown, setShowDropdown] = useState13(false);
4211
- return /* @__PURE__ */ jsxs13(
4212
- "div",
4213
- {
4214
- className: "w-full relative",
4215
- onMouseEnter: () => {
4216
- setShowDropdown(true);
4217
- },
4218
- onMouseLeave: () => {
4211
+ const dropdownRef = useRef2(null);
4212
+ useEffect4(() => {
4213
+ const handleClickOutside = (event) => {
4214
+ if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
4219
4215
  setShowDropdown(false);
4220
- },
4221
- children: [
4222
- /* @__PURE__ */ jsx23("div", { className: "w-full flex flex-col items-center justify-center", children: answer }),
4223
- /* @__PURE__ */ jsx23(
4224
- "ul",
4216
+ }
4217
+ };
4218
+ if (showDropdown) {
4219
+ document.addEventListener("mousedown", handleClickOutside);
4220
+ document.addEventListener("touchstart", handleClickOutside);
4221
+ }
4222
+ return () => {
4223
+ document.removeEventListener("mousedown", handleClickOutside);
4224
+ document.removeEventListener("touchstart", handleClickOutside);
4225
+ };
4226
+ }, [showDropdown]);
4227
+ const handleToggleDropdown = (e) => {
4228
+ e.stopPropagation();
4229
+ setShowDropdown((prev) => !prev);
4230
+ };
4231
+ const handleOptionClick = (option, e) => {
4232
+ e.stopPropagation();
4233
+ if (option.onClick) {
4234
+ option.onClick(e);
4235
+ }
4236
+ setShowDropdown(false);
4237
+ };
4238
+ return /* @__PURE__ */ jsxs13("div", { ref: dropdownRef, className: "w-full relative", children: [
4239
+ /* @__PURE__ */ jsx23(
4240
+ "div",
4241
+ {
4242
+ className: "w-full flex flex-col items-center justify-center cursor-pointer",
4243
+ onClick: handleToggleDropdown,
4244
+ children: answer
4245
+ }
4246
+ ),
4247
+ /* @__PURE__ */ jsx23(
4248
+ "ul",
4249
+ {
4250
+ className: `absolute ${showDropdown ? "opacity-100 visible" : "opacity-0 invisible"} flex flex-col items-center w-[300px] rounded-catchup-xlarge border-3 transition-all duration-300 border-catchup-blue bg-catchup-white px-4 py-4 translate-x-1/2 right-1/2 mt-2 z-10`,
4251
+ children: optionList.map((option, index) => /* @__PURE__ */ jsxs13(
4252
+ "li",
4225
4253
  {
4226
- className: `absolute ${showDropdown ? "opacity-100 visible" : "opacity-0 invisible"} flex flex-col items-center w-[300px] rounded-catchup-xlarge border-3 transition-all duration-300 border-catchup-blue bg-catchup-white px-4 py-4 translate-x-1/2 right-1/2 mt-2 z-10`,
4227
- children: optionList.map((option, index) => /* @__PURE__ */ jsxs13(
4228
- "li",
4229
- {
4230
- className: `${option.listItemClassNames ? option.listItemClassNames : ""}`,
4231
- children: [
4232
- /* @__PURE__ */ jsx23(
4233
- "div",
4234
- {
4235
- className: `w-full flex flex-col my-2 ${option.divClassNames ? option.divClassNames : ""}`,
4236
- onClick: option.onClick,
4237
- children: option.media
4238
- }
4239
- ),
4240
- index !== optionList.length - 1 ? /* @__PURE__ */ jsx23("div", { className: "w-full border my-1 border-catchup-light-blue rounded-catchup-full" }) : null
4241
- ]
4242
- },
4243
- option.id
4244
- ))
4245
- }
4246
- )
4247
- ]
4248
- },
4249
- id
4250
- );
4254
+ className: `${option.listItemClassNames ? option.listItemClassNames : ""}`,
4255
+ children: [
4256
+ /* @__PURE__ */ jsx23(
4257
+ "div",
4258
+ {
4259
+ className: `w-full flex flex-col my-2 cursor-pointer ${option.divClassNames ? option.divClassNames : ""}`,
4260
+ onClick: (e) => handleOptionClick(option, e),
4261
+ children: option.media
4262
+ }
4263
+ ),
4264
+ index !== optionList.length - 1 ? /* @__PURE__ */ jsx23("div", { className: "w-full border my-1 border-catchup-light-blue rounded-catchup-full" }) : null
4265
+ ]
4266
+ },
4267
+ option.id
4268
+ ))
4269
+ }
4270
+ )
4271
+ ] }, id);
4251
4272
  };
4252
4273
  var MediaDropdown_default = MediaDropdown;
4253
4274
 
4254
4275
  // src/components/activities/material-contents/ShowMaterialMediaByContentType.tsx
4255
- import { useEffect as useEffect4, useRef as useRef2, useState as useState14 } from "react";
4276
+ import { useEffect as useEffect5, useRef as useRef3, useState as useState14 } from "react";
4256
4277
  import Modal3 from "react-modal";
4257
4278
  import { Fragment as Fragment2, jsx as jsx24, jsxs as jsxs14 } from "react/jsx-runtime";
4258
4279
  var ShowMaterialMediaByContentType = ({
@@ -4264,9 +4285,9 @@ var ShowMaterialMediaByContentType = ({
4264
4285
  const [showFullScreen, setShowFullScreen] = useState14(false);
4265
4286
  const [selectedFullScreenItem, setSelectedFullScreenItem] = useState14(null);
4266
4287
  const [isLoaded, setIsLoaded] = useState14(false);
4267
- const imageRef = useRef2(null);
4268
- const videoRef = useRef2(null);
4269
- useEffect4(() => {
4288
+ const imageRef = useRef3(null);
4289
+ const videoRef = useRef3(null);
4290
+ useEffect5(() => {
4270
4291
  setIsLoaded(false);
4271
4292
  }, []);
4272
4293
  const RenderShowFullScreenItem = () => {
@@ -4405,7 +4426,7 @@ var DropdownActivityMaterialContent = ({
4405
4426
  showCorrectAnswer
4406
4427
  }) => {
4407
4428
  const [updated, setUpdated] = useState15(false);
4408
- useEffect5(() => {
4429
+ useEffect6(() => {
4409
4430
  if (!showCorrectAnswer) return;
4410
4431
  const foundAnswer = answer.data.find(
4411
4432
  (answerData) => answerData.type === "DROPDOWN"
@@ -4418,7 +4439,7 @@ var DropdownActivityMaterialContent = ({
4418
4439
  onChange(answer, 0, Object.keys(materialMap[0])[0]);
4419
4440
  setUpdated(true);
4420
4441
  }, [showCorrectAnswer]);
4421
- useEffect5(() => {
4442
+ useEffect6(() => {
4422
4443
  if (!updated) return;
4423
4444
  setUpdated(false);
4424
4445
  }, [updated]);
@@ -4548,7 +4569,7 @@ var DropdownActivityMaterialContent = ({
4548
4569
  var DropdownActivityMaterialContent_default = DropdownActivityMaterialContent;
4549
4570
 
4550
4571
  // src/components/activities/DropdownActivityContent.tsx
4551
- import { useState as useState16, useEffect as useEffect6 } from "react";
4572
+ import { useState as useState16, useEffect as useEffect7 } from "react";
4552
4573
  import { jsx as jsx26, jsxs as jsxs16 } from "react/jsx-runtime";
4553
4574
  var DropdownActivityContent = ({
4554
4575
  answer,
@@ -4571,7 +4592,7 @@ var DropdownActivityContent = ({
4571
4592
  );
4572
4593
  return answer.data[foundIndex].answerMap;
4573
4594
  }
4574
- useEffect6(() => {
4595
+ useEffect7(() => {
4575
4596
  setCurrentAnswerMap(retrieveCurrentAnswerMap());
4576
4597
  }, [answer]);
4577
4598
  const handleDropdownAnswerOnChange = (answerObj, key, value) => {
@@ -4624,7 +4645,7 @@ var DropdownActivityContent_default = DropdownActivityContent;
4624
4645
  // src/components/activities/material-contents/FillInTheBlanksActivityMaterialContent.tsx
4625
4646
  import { InlineMath as InlineMath4 } from "react-katex";
4626
4647
  import { useState as useState17 } from "react";
4627
- import { useEffect as useEffect7 } from "react";
4648
+ import { useEffect as useEffect8 } from "react";
4628
4649
  import { useDrop as useDrop2 } from "react-dnd";
4629
4650
 
4630
4651
  // src/components/dnds/DraggableItem.tsx
@@ -4661,7 +4682,7 @@ var DraggableItem = ({
4661
4682
  var DraggableItem_default = DraggableItem;
4662
4683
 
4663
4684
  // src/components/dnds/DroppableItem.tsx
4664
- import { useRef as useRef3 } from "react";
4685
+ import { useRef as useRef4 } from "react";
4665
4686
  import { useDrop } from "react-dnd";
4666
4687
  import { jsx as jsx28 } from "react/jsx-runtime";
4667
4688
  var DroppableItem = ({
@@ -4672,7 +4693,7 @@ var DroppableItem = ({
4672
4693
  target,
4673
4694
  setTarget
4674
4695
  }) => {
4675
- const ref = useRef3(null);
4696
+ const ref = useRef4(null);
4676
4697
  const [, drop] = useDrop({
4677
4698
  accept: type,
4678
4699
  hover() {
@@ -4735,10 +4756,10 @@ var FillInTheBlanksActivityMaterialContent = ({
4735
4756
  canDrop: monitor.canDrop()
4736
4757
  })
4737
4758
  });
4738
- useEffect7(() => {
4759
+ useEffect8(() => {
4739
4760
  setShuffleOptionList(shuffleArray(optionList));
4740
4761
  }, []);
4741
- useEffect7(() => {
4762
+ useEffect8(() => {
4742
4763
  if (!showCorrectAnswer) return;
4743
4764
  const foundAnswer = answer.data.find(
4744
4765
  (answerData) => answerData.type === "FILL_IN_THE_BLANKS"
@@ -4925,7 +4946,7 @@ var FillInTheBlanksActivityMaterialContent = ({
4925
4946
  var FillInTheBlanksActivityMaterialContent_default = FillInTheBlanksActivityMaterialContent;
4926
4947
 
4927
4948
  // src/components/activities/FillInTheBlanksActivityContent.tsx
4928
- import { useState as useState18, useEffect as useEffect8 } from "react";
4949
+ import { useState as useState18, useEffect as useEffect9 } from "react";
4929
4950
  import { jsx as jsx31, jsxs as jsxs18 } from "react/jsx-runtime";
4930
4951
  var FillInTheBlanksActivityContent = ({
4931
4952
  answer,
@@ -4955,7 +4976,7 @@ var FillInTheBlanksActivityContent = ({
4955
4976
  );
4956
4977
  return answer.data[foundIndex].answerMap;
4957
4978
  }
4958
- useEffect8(() => {
4979
+ useEffect9(() => {
4959
4980
  setCurrentAnswerMap(retrieveCurrentAnswerMap());
4960
4981
  }, [answer]);
4961
4982
  const constructAnswerOptionList = () => {
@@ -5025,7 +5046,7 @@ var FillInTheBlanksActivityContent = ({
5025
5046
  var FillInTheBlanksActivityContent_default = FillInTheBlanksActivityContent;
5026
5047
 
5027
5048
  // src/components/activities/material-contents/GroupingActivityMaterialContent.tsx
5028
- import { useEffect as useEffect9, useRef as useRef4, useState as useState19 } from "react";
5049
+ import { useEffect as useEffect10, useRef as useRef5, useState as useState19 } from "react";
5029
5050
  import { useDrop as useDrop3 } from "react-dnd";
5030
5051
  import { InlineMath as InlineMath5 } from "react-katex";
5031
5052
  import { Fragment as Fragment3, jsx as jsx32, jsxs as jsxs19 } from "react/jsx-runtime";
@@ -5052,8 +5073,8 @@ var GroupingActivityMaterialContent = ({
5052
5073
  canDrop: monitor.canDrop()
5053
5074
  })
5054
5075
  });
5055
- const ref = useRef4(null);
5056
- useEffect9(() => {
5076
+ const ref = useRef5(null);
5077
+ useEffect10(() => {
5057
5078
  const shuffleArray2 = (array) => {
5058
5079
  if (!isShuffled) {
5059
5080
  const copyArray = JSON.parse(JSON.stringify(array));
@@ -5074,7 +5095,7 @@ var GroupingActivityMaterialContent = ({
5074
5095
  });
5075
5096
  setShuffledMaterialList(shuffleArray2(materialList));
5076
5097
  }, []);
5077
- useEffect9(() => {
5098
+ useEffect10(() => {
5078
5099
  if (!showCorrectAnswer) return;
5079
5100
  answer.data.find(
5080
5101
  (answerData) => answerData.type === "GROUPING"
@@ -5322,7 +5343,7 @@ var GroupingActivityContent = ({
5322
5343
  var GroupingActivityContent_default = GroupingActivityContent;
5323
5344
 
5324
5345
  // src/components/activities/material-contents/MatchingActivityMaterialContent.tsx
5325
- import { useEffect as useEffect10, useRef as useRef5, useState as useState20 } from "react";
5346
+ import { useEffect as useEffect11, useRef as useRef6, useState as useState20 } from "react";
5326
5347
  import { useDrop as useDrop4 } from "react-dnd";
5327
5348
  import { InlineMath as InlineMath6 } from "react-katex";
5328
5349
  import { Fragment as Fragment5, jsx as jsx34, jsxs as jsxs21 } from "react/jsx-runtime";
@@ -5349,8 +5370,8 @@ var MatchingActivityMaterialContent = ({
5349
5370
  canDrop: monitor.canDrop()
5350
5371
  })
5351
5372
  });
5352
- const itemsRef = useRef5(null);
5353
- useEffect10(() => {
5373
+ const itemsRef = useRef6(null);
5374
+ useEffect11(() => {
5354
5375
  const shuffleArray2 = (array) => {
5355
5376
  if (!isShuffled) {
5356
5377
  const copyArray = JSON.parse(JSON.stringify(array));
@@ -5369,7 +5390,7 @@ var MatchingActivityMaterialContent = ({
5369
5390
  });
5370
5391
  setShuffledMaterialList(shuffleArray2(materialList));
5371
5392
  }, []);
5372
- useEffect10(() => {
5393
+ useEffect11(() => {
5373
5394
  if (!showCorrectAnswer) return;
5374
5395
  answer.data.find(
5375
5396
  (answerData) => answerData.type === "MATCHING"
@@ -6094,12 +6115,12 @@ var OpenEndedActivityContent = ({
6094
6115
  var OpenEndedActivityContent_default = OpenEndedActivityContent;
6095
6116
 
6096
6117
  // src/components/activities/material-contents/OrderingActivityMaterialContent.tsx
6097
- import { useEffect as useEffect12, useState as useState22 } from "react";
6118
+ import { useEffect as useEffect13, useState as useState22 } from "react";
6098
6119
  import { useDrop as useDrop6 } from "react-dnd";
6099
6120
  import { InlineMath as InlineMath9 } from "react-katex";
6100
6121
 
6101
6122
  // src/hooks/useScreenSize.ts
6102
- import { useState as useState21, useEffect as useEffect11 } from "react";
6123
+ import { useState as useState21, useEffect as useEffect12 } from "react";
6103
6124
  var useScreenSize = () => {
6104
6125
  const [containerSize, setContainerSize] = useState21({
6105
6126
  width: 0,
@@ -6109,7 +6130,7 @@ var useScreenSize = () => {
6109
6130
  width: window.innerWidth,
6110
6131
  height: window.innerHeight
6111
6132
  });
6112
- useEffect11(() => {
6133
+ useEffect12(() => {
6113
6134
  const handleResize = () => {
6114
6135
  setScreenSize({
6115
6136
  width: window.innerWidth,
@@ -6134,7 +6155,7 @@ var useScreenSize = () => {
6134
6155
  var useScreenSize_default = useScreenSize;
6135
6156
 
6136
6157
  // src/components/dnds/DraggableDroppableItem.tsx
6137
- import { useRef as useRef6 } from "react";
6158
+ import { useRef as useRef7 } from "react";
6138
6159
  import { useDrag as useDrag2, useDrop as useDrop5 } from "react-dnd";
6139
6160
  import { jsx as jsx42 } from "react/jsx-runtime";
6140
6161
  var DraggableDroppableItem = ({
@@ -6146,7 +6167,7 @@ var DraggableDroppableItem = ({
6146
6167
  target,
6147
6168
  setTarget
6148
6169
  }) => {
6149
- const ref = useRef6(null);
6170
+ const ref = useRef7(null);
6150
6171
  const [, drop] = useDrop5({
6151
6172
  accept: type,
6152
6173
  hover() {
@@ -6209,7 +6230,7 @@ var OrderingActivityMaterialContent = ({
6209
6230
  canDrop: monitor.canDrop()
6210
6231
  })
6211
6232
  });
6212
- useEffect12(() => {
6233
+ useEffect13(() => {
6213
6234
  if (!screenSize) return;
6214
6235
  if (screenSize.width <= 1024) {
6215
6236
  setView("TABLET");
@@ -6217,7 +6238,7 @@ var OrderingActivityMaterialContent = ({
6217
6238
  setView("PC");
6218
6239
  }
6219
6240
  }, [screenSize]);
6220
- useEffect12(() => {
6241
+ useEffect13(() => {
6221
6242
  if (!showCorrectAnswer) return;
6222
6243
  const answerMap2 = answer.data.find(
6223
6244
  (answerData) => answerData.type === "ORDERING"
@@ -6405,7 +6426,7 @@ var OrderingActivityContent = ({
6405
6426
  var OrderingActivityContent_default = OrderingActivityContent;
6406
6427
 
6407
6428
  // src/components/activities/material-contents/TrueFalseActivityMaterialContent.tsx
6408
- import { useEffect as useEffect13, useState as useState23 } from "react";
6429
+ import { useEffect as useEffect14, useState as useState23 } from "react";
6409
6430
  import { InlineMath as InlineMath10 } from "react-katex";
6410
6431
  import { Fragment as Fragment10, jsx as jsx45, jsxs as jsxs31 } from "react/jsx-runtime";
6411
6432
  var TrueFalseActivityMaterialContent = ({
@@ -6420,7 +6441,7 @@ var TrueFalseActivityMaterialContent = ({
6420
6441
  }) => {
6421
6442
  const { screenSize } = useScreenSize_default();
6422
6443
  const [shuffleOptionList, setShuffleOptionList] = useState23([]);
6423
- useEffect13(() => {
6444
+ useEffect14(() => {
6424
6445
  const optionList = [];
6425
6446
  optionList.push(...materialMap.trueList);
6426
6447
  optionList.push(...materialMap.falseList);
@@ -6430,7 +6451,7 @@ var TrueFalseActivityMaterialContent = ({
6430
6451
  setShuffleOptionList(shuffleArray(optionList));
6431
6452
  }
6432
6453
  }, []);
6433
- useEffect13(() => {
6454
+ useEffect14(() => {
6434
6455
  if (!showCorrectAnswer) return;
6435
6456
  answer.data.find(
6436
6457
  (answerData) => answerData.type === "TRUE_FALSE"
@@ -6740,7 +6761,7 @@ var ActivityEvaluationRubricContent = ({
6740
6761
  var ActivityEvaluationRubricContent_default = ActivityEvaluationRubricContent;
6741
6762
 
6742
6763
  // src/components/activities/ActivityPreviewByData.tsx
6743
- import { useEffect as useEffect14, useState as useState24 } from "react";
6764
+ import { useEffect as useEffect15, useState as useState24 } from "react";
6744
6765
 
6745
6766
  // src/components/boxes/SelectionBox.tsx
6746
6767
  import { jsx as jsx49, jsxs as jsxs35 } from "react/jsx-runtime";
@@ -6795,11 +6816,11 @@ var ActivityPreviewByData = ({
6795
6816
  const [key, setKey] = useState24((/* @__PURE__ */ new Date()).getTime());
6796
6817
  const [selectedType, setSelectedType] = useState24(null);
6797
6818
  const [optionList, setOptionList] = useState24([]);
6798
- useEffect14(() => {
6819
+ useEffect15(() => {
6799
6820
  if (!data) return;
6800
6821
  setKey((/* @__PURE__ */ new Date()).getTime());
6801
6822
  }, [data]);
6802
- useEffect14(() => {
6823
+ useEffect15(() => {
6803
6824
  if (!typeOptionList) return;
6804
6825
  if (typeOptionList.length === 0) return;
6805
6826
  let foundTypeOption;
@@ -6814,7 +6835,7 @@ var ActivityPreviewByData = ({
6814
6835
  setSelectedType(typeOptionList[0].id);
6815
6836
  }
6816
6837
  }, [typeOptionList, lockedType]);
6817
- useEffect14(() => {
6838
+ useEffect15(() => {
6818
6839
  if (!data) return;
6819
6840
  if (!typeOptionList) return;
6820
6841
  if (typeOptionList.length === 0) return;
@@ -6997,7 +7018,7 @@ var ActivityPreviewByData = ({
6997
7018
  var ActivityPreviewByData_default = ActivityPreviewByData;
6998
7019
 
6999
7020
  // src/components/activities/ActivityPreviewByAnswerData.tsx
7000
- import { useEffect as useEffect15, useState as useState25 } from "react";
7021
+ import { useEffect as useEffect16, useState as useState25 } from "react";
7001
7022
  import { Fragment as Fragment12, jsx as jsx51, jsxs as jsxs37 } from "react/jsx-runtime";
7002
7023
  var ActivityPreviewByAnswerData = ({
7003
7024
  data,
@@ -7016,7 +7037,7 @@ var ActivityPreviewByAnswerData = ({
7016
7037
  const [selectedType, setSelectedType] = useState25(null);
7017
7038
  const [optionList, setOptionList] = useState25([]);
7018
7039
  const [answer, setAnswer] = useState25({ data: [] });
7019
- useEffect15(() => {
7040
+ useEffect16(() => {
7020
7041
  if (!data) return;
7021
7042
  setKey((/* @__PURE__ */ new Date()).getTime());
7022
7043
  }, [data]);
@@ -7029,7 +7050,7 @@ var ActivityPreviewByAnswerData = ({
7029
7050
  }
7030
7051
  return null;
7031
7052
  };
7032
- useEffect15(() => {
7053
+ useEffect16(() => {
7033
7054
  if (!data) return;
7034
7055
  const constructAnswerBasedOnData2 = () => {
7035
7056
  const newAnswer = { data: [] };
@@ -7068,7 +7089,7 @@ var ActivityPreviewByAnswerData = ({
7068
7089
  };
7069
7090
  constructAnswerBasedOnData2();
7070
7091
  }, [data, lockedType]);
7071
- useEffect15(() => {
7092
+ useEffect16(() => {
7072
7093
  if (!data || !answer.data.length) return;
7073
7094
  let currentTypeOptionList = typeOptionList || answer.data.map((item) => ({
7074
7095
  id: item.type,
@@ -7235,7 +7256,7 @@ var LeftTextRightInputGroup = ({
7235
7256
  var LeftTextRightInputGroup_default = LeftTextRightInputGroup;
7236
7257
 
7237
7258
  // src/components/groups/PageTravelGroup.tsx
7238
- import { useEffect as useEffect16, useState as useState26 } from "react";
7259
+ import { useEffect as useEffect17, useState as useState26 } from "react";
7239
7260
  import { jsx as jsx55, jsxs as jsxs40 } from "react/jsx-runtime";
7240
7261
  var PageTravelGroup = ({
7241
7262
  isImageProcessing,
@@ -7247,11 +7268,11 @@ var PageTravelGroup = ({
7247
7268
  }) => {
7248
7269
  const [totalPageNumber, setTotalPageNumber] = useState26(0);
7249
7270
  const [newPageNumber, setNewPageNumber] = useState26(0);
7250
- useEffect16(() => {
7271
+ useEffect17(() => {
7251
7272
  if (!initialTotalPageNumber) return;
7252
7273
  setTotalPageNumber(initialTotalPageNumber);
7253
7274
  }, [initialTotalPageNumber]);
7254
- useEffect16(() => {
7275
+ useEffect17(() => {
7255
7276
  setNewPageNumber(pageNumber + 1);
7256
7277
  }, [pageNumber]);
7257
7278
  return /* @__PURE__ */ jsxs40("div", { className: "flex-1 flex flex-row justify-center items-center flex-wrap", children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "catchup-library-web",
3
- "version": "1.20.26",
3
+ "version": "1.20.28",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -13,7 +13,9 @@
13
13
  "dependencies": {
14
14
  "@types/lodash": "^4.17.20",
15
15
  "lodash": "^4.17.21",
16
- "mathlive": "^0.105.3"
16
+ "mathlive": "^0.105.3",
17
+ "react-dnd-html5-backend": "^16.0.1",
18
+ "react-dnd-touch-backend": "^16.0.1"
17
19
  },
18
20
  "peerDependencies": {
19
21
  "i18next": ">=22.0.0",
@@ -1,21 +1,53 @@
1
- import { useState } from "react";
1
+ import { useState, useEffect, useRef } from "react";
2
2
  import { IDropdownProps } from "../../properties/DropdownProperties";
3
3
 
4
4
  const MediaDropdown = ({ id, answer, optionList }: IDropdownProps) => {
5
5
  const [showDropdown, setShowDropdown] = useState<boolean>(false);
6
+ const dropdownRef = useRef<HTMLDivElement>(null);
6
7
 
7
- return (
8
- <div
9
- key={id}
10
- className="w-full relative"
11
- onMouseEnter={() => {
12
- setShowDropdown(true);
13
- }}
14
- onMouseLeave={() => {
8
+ useEffect(() => {
9
+ const handleClickOutside = (event: MouseEvent | TouchEvent) => {
10
+ if (
11
+ dropdownRef.current &&
12
+ !dropdownRef.current.contains(event.target as Node)
13
+ ) {
15
14
  setShowDropdown(false);
16
- }}
17
- >
18
- <div className="w-full flex flex-col items-center justify-center">
15
+ }
16
+ };
17
+
18
+ if (showDropdown) {
19
+ document.addEventListener("mousedown", handleClickOutside);
20
+ document.addEventListener("touchstart", handleClickOutside);
21
+ }
22
+
23
+ return () => {
24
+ document.removeEventListener("mousedown", handleClickOutside);
25
+ document.removeEventListener("touchstart", handleClickOutside);
26
+ };
27
+ }, [showDropdown]);
28
+
29
+ const handleToggleDropdown = (e: React.MouseEvent | React.TouchEvent) => {
30
+ e.stopPropagation();
31
+ setShowDropdown((prev) => !prev);
32
+ };
33
+
34
+ const handleOptionClick = (
35
+ option: any,
36
+ e: React.MouseEvent | React.TouchEvent
37
+ ) => {
38
+ e.stopPropagation();
39
+ if (option.onClick) {
40
+ option.onClick(e);
41
+ }
42
+ setShowDropdown(false);
43
+ };
44
+
45
+ return (
46
+ <div key={id} ref={dropdownRef} className="w-full relative">
47
+ <div
48
+ className="w-full flex flex-col items-center justify-center cursor-pointer"
49
+ onClick={handleToggleDropdown}
50
+ >
19
51
  {answer}
20
52
  </div>
21
53
  <ul
@@ -31,10 +63,10 @@ const MediaDropdown = ({ id, answer, optionList }: IDropdownProps) => {
31
63
  }`}
32
64
  >
33
65
  <div
34
- className={`w-full flex flex-col my-2 ${
66
+ className={`w-full flex flex-col my-2 cursor-pointer ${
35
67
  option.divClassNames ? option.divClassNames : ""
36
68
  }`}
37
- onClick={option.onClick}
69
+ onClick={(e) => handleOptionClick(option, e)}
38
70
  >
39
71
  {option.media}
40
72
  </div>