trithuc-mvc-react 3.5.1 → 3.5.3

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.
@@ -64,16 +64,19 @@ const DataTable = ({ multipleActions = [], page, setPage = () => {}, disableEdit
64
64
  const [openDialog, setOpenDialog] = useState(false);
65
65
  const [deleteId, setDeleteId] = useState(null);
66
66
 
67
- const [orderBy, setOrderBy] = useState("");
67
+ const [orderBy, setOrderBy] = useState(null);
68
68
  const [order, setOrder] = useState("asc");
69
69
 
70
70
  useEffect(() => {
71
71
  if (!Array.isArray(columns) || columns.length === 0) return;
72
72
 
73
- const defaultSortColumn = columns.find((c) => c.defaultSort) || columns[0];
73
+ const defaultSortColumn = columns.find((c) => c.defaultSort);
74
74
 
75
- setOrderBy(defaultSortColumn.field);
76
- setOrder(defaultSortColumn.defaultOrder || "asc");
75
+ // Chỉ set khi thực sự có defaultSort
76
+ if (defaultSortColumn) {
77
+ setOrderBy(defaultSortColumn.field);
78
+ setOrder(defaultSortColumn.defaultOrder || "asc");
79
+ }
77
80
  }, [columns]);
78
81
 
79
82
  const handleRequestSort = (event, property) => {
@@ -62,16 +62,19 @@ const DataTableSM = ({ multipleActions = [], page, setPage = () => {}, disableEd
62
62
  const [rowsPerPage, setRowsPerPage] = useState(defaultRowsPerPage);
63
63
  const [openDialog, setOpenDialog] = useState(false);
64
64
  const [deleteId, setDeleteId] = useState(null);
65
- const [orderBy, setOrderBy] = useState("");
65
+ const [orderBy, setOrderBy] = useState(null);
66
66
  const [order, setOrder] = useState("asc");
67
67
 
68
68
  useEffect(() => {
69
69
  if (!Array.isArray(columns) || columns.length === 0) return;
70
70
 
71
- const defaultSortColumn = columns.find((c) => c.defaultSort) || columns[0];
71
+ const defaultSortColumn = columns.find((c) => c.defaultSort);
72
72
 
73
- setOrderBy(defaultSortColumn.field);
74
- setOrder(defaultSortColumn.defaultOrder || "asc");
73
+ // Chỉ set khi thực sự có defaultSort
74
+ if (defaultSortColumn) {
75
+ setOrderBy(defaultSortColumn.field);
76
+ setOrder(defaultSortColumn.defaultOrder || "asc");
77
+ }
75
78
  }, [columns]);
76
79
 
77
80
  const handleRequestSort = (event, property) => {
@@ -1,98 +1,98 @@
1
- import { Modal, Box, CircularProgress, Typography } from "@mui/material";
2
- import { useEffect, useState } from "react";
3
- import HubOutlinedIcon from "@mui/icons-material/HubOutlined";
4
-
5
- const LoadingOverlay = ({ open, text }) => {
6
- const [progress, setProgress] = useState(0);
7
-
8
- useEffect(() => {
9
- if (!open) {
10
- setProgress(0);
11
- return;
12
- }
13
-
14
- const timer = setInterval(() => {
15
- setProgress((p) => (p < 96 ? p + Math.random() * 3 : p));
16
- }, 420);
17
-
18
- return () => clearInterval(timer);
19
- }, [open]);
20
-
21
- return (
22
- <Modal open={open} sx={{ zIndex: 99999 }}>
23
- <Box
24
- display="flex"
25
- alignItems="center"
26
- justifyContent="center"
27
- height="100vh"
28
- sx={{
29
- backdropFilter: "blur(8px)",
30
- backgroundColor: "rgba(225,235,245,0.65)"
31
- }}
32
- >
33
- <Box
34
- sx={{
35
- width: 320,
36
- px: 4,
37
- py: 4,
38
- borderRadius: 3,
39
- background: "linear-gradient(180deg, rgba(255,255,255,0.96), rgba(240,247,255,0.96))",
40
- boxShadow: "0 25px 50px rgba(0,60,120,0.25)",
41
- border: "1px solid rgba(0,120,200,0.2)",
42
- color: "#0d2b45",
43
- textAlign: "center"
44
- }}
45
- >
46
- {/* ICON */}
47
- <Box
48
- sx={{
49
- width: 60,
50
- height: 60,
51
- borderRadius: "50%",
52
- mx: "auto",
53
- mb: 2.5,
54
- background: "linear-gradient(135deg, rgba(0,150,255,0.18), rgba(0,200,255,0.28))",
55
- display: "flex",
56
- alignItems: "center",
57
- justifyContent: "center",
58
- animation: "pulse 2.4s infinite",
59
- "@keyframes pulse": {
60
- "0%": { boxShadow: "0 0 0 0 rgba(0,150,255,0.45)" },
61
- "70%": { boxShadow: "0 0 0 20px rgba(0,150,255,0)" },
62
- "100%": { boxShadow: "0 0 0 0 rgba(0,150,255,0)" }
63
- }
64
- }}
65
- >
66
- <HubOutlinedIcon sx={{ fontSize: 30, color: "#0277bd" }} />
67
- </Box>
68
-
69
- <Typography fontSize="1rem" fontWeight={600}>
70
- {text || "Đang khởi tạo dữ liệu hệ thống"}
71
- </Typography>
72
-
73
- <Typography fontSize="0.75rem" color="rgba(13,43,69,0.7)" mt={0.6}>
74
- Nền tảng số đang xử lý và kết nối dữ liệu
75
- </Typography>
76
-
77
- <Box mt={3}>
78
- <CircularProgress
79
- variant="determinate"
80
- value={Math.min(progress, 100)}
81
- size={50}
82
- thickness={4}
83
- sx={{
84
- color: "#0288d1",
85
- mb: 1
86
- }}
87
- />
88
- <Typography fontSize="0.8rem" fontWeight={500}>
89
- {Math.floor(progress)}%
90
- </Typography>
91
- </Box>
92
- </Box>
93
- </Box>
94
- </Modal>
95
- );
96
- };
97
-
98
- export default LoadingOverlay;
1
+ import { Modal, Box, CircularProgress, Typography } from "@mui/material";
2
+ import { useEffect, useState } from "react";
3
+ import HubOutlinedIcon from "@mui/icons-material/HubOutlined";
4
+
5
+ const LoadingOverlay = ({ open, text }) => {
6
+ const [progress, setProgress] = useState(0);
7
+
8
+ useEffect(() => {
9
+ if (!open) {
10
+ setProgress(0);
11
+ return;
12
+ }
13
+
14
+ const timer = setInterval(() => {
15
+ setProgress((p) => (p < 96 ? p + Math.random() * 3 : p));
16
+ }, 420);
17
+
18
+ return () => clearInterval(timer);
19
+ }, [open]);
20
+
21
+ return (
22
+ <Modal open={open} sx={{ zIndex: 99999 }}>
23
+ <Box
24
+ display="flex"
25
+ alignItems="center"
26
+ justifyContent="center"
27
+ height="100vh"
28
+ sx={{
29
+ backdropFilter: "blur(8px)",
30
+ backgroundColor: "rgba(225,235,245,0.65)"
31
+ }}
32
+ >
33
+ <Box
34
+ sx={{
35
+ width: 320,
36
+ px: 4,
37
+ py: 4,
38
+ borderRadius: 3,
39
+ background: "linear-gradient(180deg, rgba(255,255,255,0.96), rgba(240,247,255,0.96))",
40
+ boxShadow: "0 25px 50px rgba(0,60,120,0.25)",
41
+ border: "1px solid rgba(0,120,200,0.2)",
42
+ color: "#0d2b45",
43
+ textAlign: "center"
44
+ }}
45
+ >
46
+ {/* ICON */}
47
+ <Box
48
+ sx={{
49
+ width: 60,
50
+ height: 60,
51
+ borderRadius: "50%",
52
+ mx: "auto",
53
+ mb: 2.5,
54
+ background: "linear-gradient(135deg, rgba(0,150,255,0.18), rgba(0,200,255,0.28))",
55
+ display: "flex",
56
+ alignItems: "center",
57
+ justifyContent: "center",
58
+ animation: "pulse 2.4s infinite",
59
+ "@keyframes pulse": {
60
+ "0%": { boxShadow: "0 0 0 0 rgba(0,150,255,0.45)" },
61
+ "70%": { boxShadow: "0 0 0 20px rgba(0,150,255,0)" },
62
+ "100%": { boxShadow: "0 0 0 0 rgba(0,150,255,0)" }
63
+ }
64
+ }}
65
+ >
66
+ <HubOutlinedIcon sx={{ fontSize: 30, color: "#0277bd" }} />
67
+ </Box>
68
+
69
+ <Typography fontSize="1rem" fontWeight={600}>
70
+ {text || "Đang khởi tạo dữ liệu hệ thống"}
71
+ </Typography>
72
+
73
+ <Typography fontSize="0.75rem" color="rgba(13,43,69,0.7)" mt={0.6}>
74
+ Nền tảng số đang xử lý và kết nối dữ liệu
75
+ </Typography>
76
+
77
+ <Box mt={3}>
78
+ <CircularProgress
79
+ variant="determinate"
80
+ value={Math.min(progress, 100)}
81
+ size={50}
82
+ thickness={4}
83
+ sx={{
84
+ color: "#0288d1",
85
+ mb: 1
86
+ }}
87
+ />
88
+ <Typography fontSize="0.8rem" fontWeight={500}>
89
+ {Math.floor(progress)}%
90
+ </Typography>
91
+ </Box>
92
+ </Box>
93
+ </Box>
94
+ </Modal>
95
+ );
96
+ };
97
+
98
+ export default LoadingOverlay;
@@ -1,23 +1,23 @@
1
- import { useEffect } from "react";
2
-
3
- /**
4
- * Chặn navigate (reload / close tab) khi shouldBlock = true
5
- */
6
- const useBlockNavigation = (shouldBlock) => {
7
- useEffect(() => {
8
- if (!shouldBlock) return;
9
-
10
- const handleBeforeUnload = (event) => {
11
- event.preventDefault();
12
- event.returnValue = ""; // Bắt buộc cho Chrome
13
- };
14
-
15
- window.addEventListener("beforeunload", handleBeforeUnload);
16
-
17
- return () => {
18
- window.removeEventListener("beforeunload", handleBeforeUnload);
19
- };
20
- }, [shouldBlock]);
21
- };
22
-
23
- export default useBlockNavigation;
1
+ import { useEffect } from "react";
2
+
3
+ /**
4
+ * Chặn navigate (reload / close tab) khi shouldBlock = true
5
+ */
6
+ const useBlockNavigation = (shouldBlock) => {
7
+ useEffect(() => {
8
+ if (!shouldBlock) return;
9
+
10
+ const handleBeforeUnload = (event) => {
11
+ event.preventDefault();
12
+ event.returnValue = ""; // Bắt buộc cho Chrome
13
+ };
14
+
15
+ window.addEventListener("beforeunload", handleBeforeUnload);
16
+
17
+ return () => {
18
+ window.removeEventListener("beforeunload", handleBeforeUnload);
19
+ };
20
+ }, [shouldBlock]);
21
+ };
22
+
23
+ export default useBlockNavigation;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trithuc-mvc-react",
3
- "version": "3.5.1",
3
+ "version": "3.5.3",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -31,9 +31,7 @@
31
31
  "eslint": "^9.24.0",
32
32
  "eslint-plugin-react": "^7.37.5",
33
33
  "eslint-plugin-react-hooks": "^5.2.0",
34
- "eslint-plugin-react-refresh": "^0.4.19",
35
- "react": "^18.3.1",
36
- "react-dom": "^18.3.1"
34
+ "eslint-plugin-react-refresh": "^0.4.19"
37
35
  },
38
36
  "peerDependencies": {
39
37
  "@mui/icons-material": "^7.0.2",
@@ -44,8 +42,8 @@
44
42
  "@mui/x-tree-view": "^7.28.1",
45
43
  "dayjs": "^1.11.13",
46
44
  "material-ui-confirm": "^4.0.0",
47
- "react": ">=16",
48
- "react-dom": ">=16",
45
+ "react": ">=18",
46
+ "react-dom": ">=18",
49
47
  "react-hook-form": "^7.55.0",
50
48
  "react-query": "^3.39.3",
51
49
  "react-toastify": "^11.0.5"