trithuc-mvc-react 3.3.7 → 3.3.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.
@@ -1,12 +1,13 @@
1
1
  import { EditOutlined } from "@mui/icons-material";
2
2
  import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline";
3
3
  import RemoveRedEyeOutlinedIcon from "@mui/icons-material/RemoveRedEyeOutlined";
4
- import { Box, Button, Grid, Switch, TableCell, TableRow, Toolbar, useMediaQuery } from "@mui/material";
4
+ import { Box, Button, Grid, Switch, TableCell, TableRow, Toolbar, Typography, useMediaQuery } from "@mui/material";
5
5
  import { styled, useTheme } from "@mui/material/styles";
6
6
  import { useMemo } from "react";
7
7
  import { usePermission } from "../../hooks";
8
8
  import MoreMenu from "../MoreMenu";
9
9
  import { useDataTable } from "./hooks";
10
+ import { fontSize } from "@mui/system";
10
11
 
11
12
  export const TableRowRenderSM = ({
12
13
  index,
@@ -56,105 +57,139 @@ export const TableRowRenderSM = ({
56
57
  overflowWrap: "break-word"
57
58
  }}
58
59
  >
59
- {/* Hiển thị các cột dữ liệu */}
60
- {columns.map(({ field, label, type = "text", valueGetter = (row) => row[field], renderCell, valueFormat = (e) => e }) => {
61
- const value = renderCell ? renderCell(row) : valueFormat(valueGetter(row));
62
- return (
63
- <div key={`${row[selectedField]}-${field}`}>
64
- <strong>{label}: </strong>
65
- {value}
66
- </div>
67
- );
68
- })}
69
-
70
- {/* Công tắc trạng thái */}
71
- {!disableStatus && canEdit && (
72
- <Box sx={{ mt: 1 }}>
73
- <Switch
74
- checked={row[statusKey]}
75
- onChange={() => onChangeStatus(row[selectedField])}
76
- inputProps={{ "aria-label": "controlled" }}
77
- />
78
- </Box>
79
- )}
60
+ <Box
61
+ display="flex"
62
+ flexDirection="column"
63
+ gap={1}
64
+ border="1px solid"
65
+ borderColor="divider"
66
+ borderRadius={2}
67
+ boxShadow={1}
68
+ p={2}
69
+ bgcolor="background.paper"
70
+ sx={{
71
+ transition: "all 0.2s ease",
72
+ "&:hover": {
73
+ boxShadow: 3,
74
+ borderColor: "primary.light"
75
+ }
76
+ }}
77
+ >
78
+ {/* Hiển thị các cột dữ liệu */}
79
+ <Grid container spacing={1}>
80
+ {columns.map(
81
+ ({ field, label, type = "text", valueGetter = (row) => row[field], renderCell, valueFormat = (e) => e }) => {
82
+ const value = renderCell ? renderCell(row) : valueFormat(valueGetter(row));
83
+ return (
84
+ <Grid size={12} key={`${row[selectedField]}-${field}`}>
85
+ <strong>{label}: </strong> {value}
86
+ </Grid>
87
+ );
88
+ }
89
+ )}
90
+ </Grid>
91
+ {/* Công tắc trạng thái */}
92
+ {!disableStatus && canEdit && (
93
+ <Box sx={{ mt: 1 }}>
94
+ <Switch
95
+ checked={row[statusKey]}
96
+ onChange={() => onChangeStatus(row[selectedField])}
97
+ inputProps={{ "aria-label": "controlled" }}
98
+ />
99
+ </Box>
100
+ )}
80
101
 
81
- {/* Các nút thao tác */}
82
- <Grid container spacing={0.5} sx={{ width: "100%", pt: 2, pb: 2 }}>
83
- {!disableCellThaoTac && (
84
- <>
85
- {!disableEdit && canEdit && (
86
- <Grid size={4}>
102
+ {/* Các nút thao tác */}
103
+ <Box
104
+ mt={2}
105
+ pt={1}
106
+ display="flex"
107
+ gap={1}
108
+ flexWrap="wrap"
109
+ justifyContent="flex-end"
110
+ borderTop="1px solid"
111
+ borderColor="divider"
112
+ >
113
+ {!disableCellThaoTac && (
114
+ <>
115
+ {!disableEdit && canEdit && (
87
116
  <Button
88
- fullWidth
89
117
  size="small"
90
- variant="outlined"
118
+ variant="contained"
91
119
  color="primary"
92
120
  onClick={() => onEdit(row)}
93
- startIcon={<EditOutlined fontSize="inherit" />}
94
- sx={buttonStyle}
121
+ startIcon={<EditOutlined />}
122
+ sx={modernButtonStyle}
95
123
  >
96
124
  Cập nhật
97
125
  </Button>
98
- </Grid>
99
- )}
100
- {canView && !tableActions?.some(({ permissionType }) => permissionType === "view") && (
101
- <Grid size={4}>
126
+ )}
127
+
128
+ {canView && !tableActions?.some(({ permissionType }) => permissionType === "view") && (
102
129
  <Button
103
- fullWidth
104
130
  size="small"
105
131
  variant="outlined"
106
132
  color="info"
107
133
  onClick={() => onView(row)}
108
134
  startIcon={<RemoveRedEyeOutlinedIcon />}
109
- sx={buttonStyle}
135
+ sx={modernButtonStyle}
110
136
  >
111
137
  Xem
112
138
  </Button>
113
- </Grid>
114
- )}
115
- {!disableDelete && canDelete && (
116
- <Grid size={4}>
139
+ )}
140
+
141
+ {!disableDelete && canDelete && (
117
142
  <Button
118
- fullWidth
119
143
  size="small"
120
144
  variant="outlined"
121
145
  color="error"
122
146
  onClick={() => onDelete(row[selectedField])}
123
- startIcon={<DeleteOutlineIcon fontSize="inherit" />}
124
- sx={buttonStyle}
147
+ startIcon={<DeleteOutlineIcon />}
148
+ sx={modernButtonStyle}
125
149
  >
126
150
  Xóa
127
151
  </Button>
128
- </Grid>
129
- )}
130
- {tableActionsOnTable.map(
131
- ({ title, size, onClick, element, visible = true }, idx) =>
132
- (typeof visible === "function" ? visible(row) : visible) && (
133
- <Grid key={row.Id} size={4}>
152
+ )}
153
+
154
+ {tableActionsOnTable.map(
155
+ ({ title, size, onClick, element, visible = true }, idx) =>
156
+ (typeof visible === "function" ? visible(row) : visible) && (
134
157
  <Button
135
- fullWidth
136
158
  key={idx}
137
159
  size="small"
138
160
  variant="outlined"
139
161
  onClick={() => onClick(row)}
140
162
  startIcon={element}
141
- sx={{
142
- ...buttonStyle
143
- }}
163
+ sx={modernButtonStyle}
144
164
  >
145
165
  {title === "xem chi tiết" ? "Xem" : title}
146
166
  </Button>
147
- </Grid>
148
- )
149
- )}
150
- <MoreMenu actions={tableActionsOnMoreMenu} data={row} />
151
- </>
152
- )}
153
- </Grid>
167
+ )
168
+ )}
169
+
170
+ <MoreMenu actions={tableActionsOnMoreMenu} data={row} />
171
+ </>
172
+ )}
173
+ </Box>
174
+ </Box>
154
175
  </TableCell>
155
176
  </TableRow>
156
177
  );
157
178
  };
179
+ const modernButtonStyle = {
180
+ fontWeight: 400,
181
+ fontSize: "0.7rem",
182
+ borderRadius: 2,
183
+ minWidth: 90,
184
+ textTransform: "none",
185
+ px: 1,
186
+ py: 0.5,
187
+ boxShadow: "none",
188
+ transition: "all 0.2s ease-in-out",
189
+ "&:hover": {
190
+ boxShadow: "0px 2px 6px rgba(0,0,0,0.1)"
191
+ }
192
+ };
158
193
 
159
194
  // Button style dùng chung
160
195
  const buttonStyle = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trithuc-mvc-react",
3
- "version": "3.3.7",
3
+ "version": "3.3.8",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"