diff --git a/.vscode/settings.json b/.vscode/settings.json index 69a50b5..3a595b0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,6 +11,7 @@ "handelnavigate", "Karim", "katex", + "Latext", "Popconfirm", "queryqlent", "registraion", diff --git a/package-lock.json b/package-lock.json index ce553f9..013e1ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,6 +36,8 @@ "react-query": "^3.39.3", "react-router-dom": "^6.23.1", "react-toastify": "^9.1.3", + "react-window": "^1.8.10", + "react-window-dynamic": "^1.8.0-alpha.2", "reactstrap": "^9.2.2", "sass": "^1.77.4", "yup": "^1.4.0", @@ -52,6 +54,7 @@ "@types/react-helmet": "^6.1.11", "@types/react-katex": "^3.0.4", "@types/react-latex": "^2.0.3", + "@types/react-window": "^1.8.8", "@vitejs/plugin-legacy": "^5.4.1", "@vitejs/plugin-react": "^4.3.0", "jest": "^29.7.0", @@ -3660,6 +3663,15 @@ "redux": "^4.0.0" } }, + "node_modules/@types/react-window": { + "version": "1.8.8", + "resolved": "https://registry.npmjs.org/@types/react-window/-/react-window-1.8.8.tgz", + "integrity": "sha512-8Ls660bHR1AUA2kuRvVG9D/4XpRC6wjAaPT9dil7Ckc76eP9TKWZwwmgfq8Q1LANX3QNDnoU4Zp48A3w+zK69Q==", + "dev": true, + "dependencies": { + "@types/react": "*" + } + }, "node_modules/@types/stack-utils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", @@ -9112,6 +9124,38 @@ "react-dom": ">=16.6.0" } }, + "node_modules/react-window": { + "version": "1.8.10", + "resolved": "https://registry.npmjs.org/react-window/-/react-window-1.8.10.tgz", + "integrity": "sha512-Y0Cx+dnU6NLa5/EvoHukUD0BklJ8qITCtVEPY1C/nL8wwoZ0b5aEw8Ff1dOVHw7fCzMt55XfJDd8S8W8LCaUCg==", + "dependencies": { + "@babel/runtime": "^7.0.0", + "memoize-one": ">=3.1.1 <6" + }, + "engines": { + "node": ">8.0.0" + }, + "peerDependencies": { + "react": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/react-window-dynamic": { + "version": "1.8.0-alpha.2", + "resolved": "https://registry.npmjs.org/react-window-dynamic/-/react-window-dynamic-1.8.0-alpha.2.tgz", + "integrity": "sha512-PYR1nu5kzEr+PDg9/+19uTqO1OqUCckYE5dDpjFpEGBtVTcq4smxE3jXhk+zLi4AOZlLVr9pJIjwPL68zwq5Ww==", + "dependencies": { + "@babel/runtime": "^7.0.0", + "memoize-one": ">=3.1.1 <6" + }, + "engines": { + "node": ">8.0.0" + }, + "peerDependencies": { + "react": "^15.0.0 || ^16.0.0", + "react-dom": "^15.0.0 || ^16.0.0" + } + }, "node_modules/reactstrap": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/reactstrap/-/reactstrap-9.2.2.tgz", @@ -13436,6 +13480,15 @@ "redux": "^4.0.0" } }, + "@types/react-window": { + "version": "1.8.8", + "resolved": "https://registry.npmjs.org/@types/react-window/-/react-window-1.8.8.tgz", + "integrity": "sha512-8Ls660bHR1AUA2kuRvVG9D/4XpRC6wjAaPT9dil7Ckc76eP9TKWZwwmgfq8Q1LANX3QNDnoU4Zp48A3w+zK69Q==", + "dev": true, + "requires": { + "@types/react": "*" + } + }, "@types/stack-utils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", @@ -17409,6 +17462,24 @@ "prop-types": "^15.6.2" } }, + "react-window": { + "version": "1.8.10", + "resolved": "https://registry.npmjs.org/react-window/-/react-window-1.8.10.tgz", + "integrity": "sha512-Y0Cx+dnU6NLa5/EvoHukUD0BklJ8qITCtVEPY1C/nL8wwoZ0b5aEw8Ff1dOVHw7fCzMt55XfJDd8S8W8LCaUCg==", + "requires": { + "@babel/runtime": "^7.0.0", + "memoize-one": ">=3.1.1 <6" + } + }, + "react-window-dynamic": { + "version": "1.8.0-alpha.2", + "resolved": "https://registry.npmjs.org/react-window-dynamic/-/react-window-dynamic-1.8.0-alpha.2.tgz", + "integrity": "sha512-PYR1nu5kzEr+PDg9/+19uTqO1OqUCckYE5dDpjFpEGBtVTcq4smxE3jXhk+zLi4AOZlLVr9pJIjwPL68zwq5Ww==", + "requires": { + "@babel/runtime": "^7.0.0", + "memoize-one": ">=3.1.1 <6" + } + }, "reactstrap": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/reactstrap/-/reactstrap-9.2.2.tgz", diff --git a/package.json b/package.json index 537ae72..cf0a973 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,8 @@ "react-query": "^3.39.3", "react-router-dom": "^6.23.1", "react-toastify": "^9.1.3", + "react-window": "^1.8.10", + "react-window-dynamic": "^1.8.0-alpha.2", "reactstrap": "^9.2.2", "sass": "^1.77.4", "yup": "^1.4.0", @@ -73,6 +75,7 @@ "@types/react-helmet": "^6.1.11", "@types/react-katex": "^3.0.4", "@types/react-latex": "^2.0.3", + "@types/react-window": "^1.8.8", "@vitejs/plugin-legacy": "^5.4.1", "@vitejs/plugin-react": "^4.3.0", "jest": "^29.7.0", diff --git a/src/Components/CustomFields/ImageBoxField/ImageBoxField.tsx b/src/Components/CustomFields/ImageBoxField/ImageBoxField.tsx index 6287c81..2f8a3cd 100644 --- a/src/Components/CustomFields/ImageBoxField/ImageBoxField.tsx +++ b/src/Components/CustomFields/ImageBoxField/ImageBoxField.tsx @@ -62,7 +62,8 @@ const ImageBoxField = ({ name }: any) => { fileInputRef.current.value = ""; } }; - + console.log(name); + return (
{handleDeleteChoice()}} >
- {t("header.delete_choice")}
-
- {t("header.delete_choice")}
-
{handleDeleteChoice()}} >
+ {t("header.delete_choice")}
+
+ {t("header.delete_choice")}
+
-
{handleDeleteQuestion()}}>
diff --git a/src/Pages/Admin/question/Model/Malty/QuestionFIeld/QuestionList.tsx b/src/Pages/Admin/question/Model/Malty/QuestionFIeld/QuestionList.tsx
new file mode 100644
index 0000000..89d547a
--- /dev/null
+++ b/src/Pages/Admin/question/Model/Malty/QuestionFIeld/QuestionList.tsx
@@ -0,0 +1,9 @@
+import React from 'react'
+
+const QuestionList = () => {
+ return (
+
+
+
+
+ {Row}
+
+
+{/* {(values?.Questions || [])?.map(
+ (item: Choice, parent_index: number) => {
+ return (
+ (null);
+
+ const getItemSize = useCallback((index: number) => {
+ const question = questions[index];
+ let height = 300; // Base height for QuestionField
+
+ height += (question.answers?.length || 0) * 212; // Height for each answer
+ if (question.answers?.length < 5) height += 40; // "Add new choice" button
+ if (ShowHint) height += 80; // Hint field
+ height += 50; // MaltySelectTag
+
+ return height;
+ }, [questions, ShowHint]);
+
+ const itemData = useMemo(() => ({
+ values,
+ setFieldValue,
+ ShowHint,
+ t
+ }), [values, setFieldValue, ShowHint, t]);
+
+ useEffect(() => {
+ if (listRef.current) {
+ listRef.current.resetAfterIndex(0);
+ }
+ }, [questions, ShowHint]);
+
+ return (
+
+ {Row}
+
+ );
+}, (prevProps, nextProps) => prevProps.values.Questions === nextProps.values.Questions);
+
+export default Questions;
\ No newline at end of file
diff --git a/src/Pages/Admin/question/Model/ModelForm.tsx b/src/Pages/Admin/question/Model/ModelForm.tsx
index 8599dfc..6265ae2 100644
--- a/src/Pages/Admin/question/Model/ModelForm.tsx
+++ b/src/Pages/Admin/question/Model/ModelForm.tsx
@@ -1,17 +1,18 @@
import { Row } from "reactstrap";
import ValidationField from "../../../../Components/ValidationField/ValidationField";
-import { useFormikContext } from "formik";
+import { Field, useFormikContext } from "formik";
import { FaCirclePlus } from "react-icons/fa6";
import { useTranslation } from "react-i18next";
import { useObjectToEdit } from "../../../../zustand/ObjectToEditState";
import { useEffect } from "react";
import Choices from "./Field/Choices";
-import ImageBoxField from "../../../../Components/CustomFields/ImageBoxField/ImageBoxField";
import SelectTag from "../../../../Components/CustomFields/SelectTag";
import useKeyCombination from "../../../../Hooks/useKeyCombination";
import { CombinationKeyEnum } from "../../../../enums/CombinationKeyEnum";
import { toast } from "react-toastify";
import LaTeXInput from "../../../../Components/LatextInput/LaTeXInput";
+import LaTeXInputMemo from "../../../../Components/LatextInput/LaTeXInputMemo";
+import ImageBoxFieldMemo from "../../../../Components/CustomFields/ImageBoxField/ImageBoxFieldMemo";
const Form = () => {
const [t] = useTranslation();
@@ -51,9 +52,16 @@ const Form = () => {
return (