trithuc-mvc-react 2.8.3 → 2.8.5
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,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Grid2, Table, TableBody, TableCell, TableContainer, TableRow, Typography, useMediaQuery, useTheme } from "@mui/material";
|
|
2
2
|
import TablePaginationCustom from "../table/TablePagination";
|
|
3
3
|
import { useEffect, useMemo, useState } from "react";
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Grid2, Table, TableBody, TableCell, TableContainer, TableRow, Typography, useMediaQuery, useTheme } from "@mui/material";
|
|
2
2
|
import TablePaginationCustom from "../table/TablePagination";
|
|
3
3
|
import { useEffect, useMemo, useState } from "react";
|
|
4
4
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Checkbox, IconButton, Switch, TableCell, TableRow, Tooltip, Toolbar, useMediaQuery, Box, Grid } from "@mui/material";
|
|
2
|
-
import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline";
|
|
3
1
|
import { EditOutlined } from "@mui/icons-material";
|
|
4
|
-
import
|
|
2
|
+
import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline";
|
|
5
3
|
import RemoveRedEyeOutlinedIcon from "@mui/icons-material/RemoveRedEyeOutlined";
|
|
6
|
-
import {
|
|
4
|
+
import { Box, IconButton, Switch, TableCell, TableRow, Toolbar, Tooltip, useMediaQuery } from "@mui/material";
|
|
7
5
|
import { styled, useTheme } from "@mui/material/styles";
|
|
8
|
-
import MoreMenu from "../MoreMenu";
|
|
9
6
|
import { useMemo } from "react";
|
|
7
|
+
import { usePermission } from "../../hooks";
|
|
8
|
+
import MoreMenu from "../MoreMenu";
|
|
9
|
+
import { useDataTable } from "./hooks";
|
|
10
10
|
|
|
11
11
|
export const TableRowRenderSM = ({
|
|
12
12
|
index,
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { Box }
|
|
2
|
-
|
|
3
|
-
import Grid from "@mui/material/Unstable_Grid2"; // Grid version 2
|
|
1
|
+
import { Box,Grid2 } from "@mui/material";
|
|
2
|
+
|
|
4
3
|
import PropTypes from "prop-types";
|
|
4
|
+
import { FormProvider, useForm } from "react-hook-form";
|
|
5
5
|
|
|
6
6
|
import moment from "moment/moment";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
import FormField from "./FormField";
|
|
10
8
|
import { yupResolver } from "@hookform/resolvers/yup";
|
|
9
|
+
import FormField from "./FormField";
|
|
11
10
|
DynamicForm.propTypes = {
|
|
12
11
|
fields: PropTypes.array
|
|
13
12
|
};
|
|
14
13
|
function DynamicForm({ fields, elementSize = "medium", submitRef, validationSchema, onSubmit }) {
|
|
15
|
-
|
|
16
14
|
const methods = useForm({ defaultValues: {}, resolver: yupResolver(validationSchema) });
|
|
17
15
|
|
|
18
16
|
const handleSubmit = (data) => {
|
|
@@ -30,8 +28,8 @@ function DynamicForm({ fields, elementSize = "medium", submitRef, validationSche
|
|
|
30
28
|
data[keyValueLabel] = datas.find((item) => item[keyValue] == data[field])?.[keyLabel];
|
|
31
29
|
}
|
|
32
30
|
});
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
|
|
32
|
+
onSubmit(data);
|
|
35
33
|
};
|
|
36
34
|
|
|
37
35
|
return (
|
|
@@ -81,11 +79,11 @@ function DynamicForm({ fields, elementSize = "medium", submitRef, validationSche
|
|
|
81
79
|
size={elementSize}
|
|
82
80
|
required={required}
|
|
83
81
|
/>
|
|
84
|
-
</
|
|
82
|
+
</Grid2>
|
|
85
83
|
);
|
|
86
84
|
}
|
|
87
85
|
)}
|
|
88
|
-
</
|
|
86
|
+
</Grid2>
|
|
89
87
|
<button ref={submitRef} type="submit" style={{ display: "none" }} />
|
|
90
88
|
</Box>
|
|
91
89
|
</FormProvider>
|
|
@@ -12,15 +12,14 @@ import {
|
|
|
12
12
|
Switch,
|
|
13
13
|
TextField
|
|
14
14
|
} from "@mui/material";
|
|
15
|
-
import { Controller,
|
|
16
|
-
|
|
17
|
-
import PropTypes from "prop-types";
|
|
15
|
+
import { Controller, useFormContext } from "react-hook-form";
|
|
16
|
+
|
|
18
17
|
import { DatePicker } from "@mui/x-date-pickers";
|
|
19
|
-
import { useCallback, useEffect, } from "react";
|
|
20
18
|
import moment from "moment/moment";
|
|
19
|
+
import PropTypes from "prop-types";
|
|
20
|
+
import { useCallback, useEffect } from "react";
|
|
21
21
|
import { DEFAULT_DATE_FORMAT } from "../../constants";
|
|
22
22
|
|
|
23
|
-
|
|
24
23
|
FormField.propTypes = {
|
|
25
24
|
datas: PropTypes.array,
|
|
26
25
|
loading: PropTypes.bool
|
|
@@ -57,7 +56,6 @@ function FormField({
|
|
|
57
56
|
}
|
|
58
57
|
}, []);
|
|
59
58
|
|
|
60
|
-
|
|
61
59
|
switch (type) {
|
|
62
60
|
case "textarea":
|
|
63
61
|
return (
|
|
@@ -130,7 +128,9 @@ function FormField({
|
|
|
130
128
|
value={getValueObject(value)}
|
|
131
129
|
fullWidth
|
|
132
130
|
getOptionLabel={(option) => option[keyLabel]}
|
|
133
|
-
renderInput={(params) =>
|
|
131
|
+
renderInput={(params) => (
|
|
132
|
+
<TextField {...params} label={label} error={Boolean(error)} helperText={error?.message} />
|
|
133
|
+
)}
|
|
134
134
|
/>
|
|
135
135
|
);
|
|
136
136
|
}}
|
|
@@ -218,18 +218,17 @@ function FormField({
|
|
|
218
218
|
format={DEFAULT_DATE_FORMAT}
|
|
219
219
|
slotProps={{
|
|
220
220
|
textField: {
|
|
221
|
-
fullWidth: true,
|
|
221
|
+
fullWidth: true,
|
|
222
|
+
error: Boolean(error),
|
|
222
223
|
helperText: error?.message
|
|
223
224
|
},
|
|
224
225
|
popper: {
|
|
225
226
|
disablePortal: false,
|
|
226
227
|
popperOptions: {
|
|
227
|
-
strategy:
|
|
228
|
-
}
|
|
228
|
+
strategy: "fixed"
|
|
229
|
+
}
|
|
229
230
|
}
|
|
230
231
|
}}
|
|
231
|
-
|
|
232
|
-
|
|
233
232
|
/>
|
|
234
233
|
);
|
|
235
234
|
}}
|