@m4l/components 0.1.13 → 0.1.15
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/assets/Logo/index.js +91 -0
- package/commonjs.js +9 -0
- package/components/CommonActions/components/ActionCancel/index.js +15 -0
- package/components/CommonActions/components/ActionFormCancel/index.js +62 -0
- package/components/CommonActions/components/ActionFormIntro/index.js +35 -0
- package/components/CommonActions/components/ActionIntro/index.js +16 -0
- package/components/CommonActions/components/Actions/index.js +859 -0
- package/components/CompanyLogo/{index.f81c179c.js → index.js} +48 -42
- package/components/DataGrid/index.js +1067 -0
- package/components/DynamicFilter/index.js +1573 -0
- package/components/ErrorLabel/index.js +18 -0
- package/components/Icon/index.js +80 -0
- package/components/Image/index.js +128 -0
- package/components/LanguagePopover/index.js +93 -0
- package/components/Loadable/index.js +13 -0
- package/components/ModalDialog/index.js +180 -0
- package/components/NoItemSelected/{index.12f0ca67.js → index.js} +50 -43
- package/components/ObjectLogs/index.js +284 -0
- package/components/Page/index.js +36 -0
- package/components/PaperForm/index.js +110 -0
- package/components/Period/index.js +230 -0
- package/components/PropertyValue/index.js +142 -0
- package/components/Resizeable/{index.45995d2b.js → index.js} +19 -21
- package/components/ScrollBar/index.js +52 -0
- package/components/ScrollToTop/index.js +10 -0
- package/components/SplitLayout/{index.4032673d.js → index.js} +35 -35
- package/components/animate/LoadingScreen/{index.f1cec7db.js → index.js} +27 -29
- package/components/animate/MotionContainer/index.js +31 -0
- package/components/animate/MotionLazyContainer/index.js +13 -0
- package/components/animate/features.js +2 -0
- package/components/animate/variants/{bounce.784aaaaa.js → bounce.js} +16 -15
- package/components/animate/variants/container.js +20 -0
- package/components/animate/variants/fade.js +61 -0
- package/components/animate/variants/{index.7a912140.js → index.js} +0 -0
- package/components/animate/variants/transition.js +16 -0
- package/components/formatters/BooleanFormatter/index.js +52 -0
- package/components/formatters/DateFormatter/index.js +66 -0
- package/components/formatters/index.js +112 -0
- package/components/hook-form/FormProvider/index.js +61 -0
- package/components/hook-form/RHFAutocomplete/index.js +144 -0
- package/components/hook-form/RHFAutocompleteAsync/index.js +191 -0
- package/components/hook-form/RHFCheckbox/index.js +65 -0
- package/components/hook-form/RHFDateTime/index.js +79 -0
- package/components/hook-form/RHFMultiCheckbox/index.js +32 -0
- package/components/hook-form/RHFPeriod/index.js +47 -0
- package/components/hook-form/RHFRadioGroup/index.js +41 -0
- package/components/hook-form/RHFSelect/index.js +34 -0
- package/components/hook-form/RHFTextField/index.js +87 -0
- package/components/hook-form/RHFUpload/index.js +255 -0
- package/components/mui_extended/Accordion/index.js +105 -0
- package/components/mui_extended/Avatar/index.js +33 -0
- package/components/mui_extended/BoxIcon/index.js +20 -0
- package/components/mui_extended/Breadcrumbs/index.js +92 -0
- package/components/mui_extended/Button/index.js +131 -0
- package/components/mui_extended/IconButton/index.js +108 -0
- package/components/mui_extended/LinkWithRoute/index.js +30 -0
- package/components/mui_extended/MenuPopover/index.js +135 -0
- package/components/mui_extended/Pager/index.js +137 -0
- package/components/mui_extended/Tab/index.js +30 -0
- package/components/mui_extended/Typography/index.js +21 -0
- package/contexts/ModalContext/index.js +165 -0
- package/hooks/useFormAddEdit/index.js +42 -0
- package/hooks/useModal/index.js +4 -0
- package/index.js +70 -162
- package/lodash.js +62 -0
- package/node_modules.js +54 -0
- package/package.json +2 -1
- package/react-data-grid.js +2652 -0
- package/react-draggable.js +960 -0
- package/react-json-view.js +2764 -0
- package/react-lazy-load-image-component.js +792 -0
- package/react-resizable.js +541 -0
- package/react-splitter-layout.js +165 -0
- package/utils/index.js +572 -0
- package/assets/Logo/index.228dcb5a.js +0 -86
- package/commonjs.565e6834.js +0 -12
- package/components/CommonActions/components/ActionCancel/index.cba1b460.js +0 -17
- package/components/CommonActions/components/ActionFormCancel/index.be2fe891.js +0 -49
- package/components/CommonActions/components/ActionFormIntro/index.ca4d2674.js +0 -31
- package/components/CommonActions/components/ActionIntro/index.cc4b1e0e.js +0 -18
- package/components/CommonActions/components/Actions/index.e8148d98.js +0 -743
- package/components/DataGrid/index.b688877d.js +0 -894
- package/components/DynamicFilter/index.82ce857e.js +0 -1158
- package/components/ErrorLabel/index.c8615f16.js +0 -19
- package/components/Icon/index.cbca79b0.js +0 -70
- package/components/Image/index.e790b50b.js +0 -122
- package/components/LanguagePopover/index.3d9611cb.js +0 -87
- package/components/Loadable/index.f5518558.js +0 -15
- package/components/ModalDialog/index.3850c053.js +0 -168
- package/components/ObjectLogs/index.27ef875d.js +0 -266
- package/components/Page/index.6d69977e.js +0 -35
- package/components/PaperForm/index.d7c74064.js +0 -105
- package/components/Period/index.5e68286a.js +0 -160
- package/components/PropertyValue/index.ab3dd7e9.js +0 -116
- package/components/ScrollBar/index.39eeb2de.js +0 -49
- package/components/ScrollToTop/index.e06f98f6.js +0 -11
- package/components/animate/MotionContainer/index.8d9f9d80.js +0 -30
- package/components/animate/MotionLazyContainer/index.572dd012.js +0 -15
- package/components/animate/features.0fbf41e1.js +0 -5
- package/components/animate/variants/container.11f82b76.js +0 -20
- package/components/animate/variants/fade.b561c0fc.js +0 -59
- package/components/animate/variants/transition.bd46b9ce.js +0 -15
- package/components/formatters/BooleanFormatter/index.cca53b7f.js +0 -42
- package/components/formatters/DateFormatter/index.ad8d9b8e.js +0 -57
- package/components/formatters/index.55856d65.js +0 -106
- package/components/hook-form/FormProvider/index.257acd9f.js +0 -55
- package/components/hook-form/RHFAutocomplete/index.6ed76d4c.js +0 -122
- package/components/hook-form/RHFAutocompleteAsync/index.8f2c97ea.js +0 -153
- package/components/hook-form/RHFCheckbox/index.f9ce6c39.js +0 -59
- package/components/hook-form/RHFDateTime/index.fc5cbafe.js +0 -68
- package/components/hook-form/RHFMultiCheckbox/index.2680b3b6.js +0 -34
- package/components/hook-form/RHFPeriod/index.23c254e9.js +0 -45
- package/components/hook-form/RHFRadioGroup/index.b3335e13.js +0 -43
- package/components/hook-form/RHFSelect/index.b6ca8bb2.js +0 -36
- package/components/hook-form/RHFTextField/index.4c455f75.js +0 -77
- package/components/hook-form/RHFUpload/index.ed3d739f.js +0 -244
- package/components/mui_extended/Accordion/index.2116e423.js +0 -103
- package/components/mui_extended/Avatar/index.0a2a4523.js +0 -32
- package/components/mui_extended/BoxIcon/index.e638ecc8.js +0 -22
- package/components/mui_extended/Breadcrumbs/index.5e37d903.js +0 -89
- package/components/mui_extended/Button/index.84d8898c.js +0 -110
- package/components/mui_extended/IconButton/index.88f3aadb.js +0 -98
- package/components/mui_extended/LinkWithRoute/index.d4b263de.js +0 -28
- package/components/mui_extended/MenuPopover/index.488fc536.js +0 -131
- package/components/mui_extended/Pager/index.0576814f.js +0 -126
- package/components/mui_extended/Tab/index.e0653a0a.js +0 -28
- package/components/mui_extended/Typography/index.0c4604b3.js +0 -22
- package/contexts/ModalContext/index.2188b69e.js +0 -150
- package/hooks/useFormAddEdit/index.d4845f1a.js +0 -26
- package/hooks/useModal/index.6571d2d9.js +0 -6
- package/lodash.e09401f0.js +0 -32
- package/node_modules.168cb897.js +0 -55
- package/react-data-grid.d46d625e.js +0 -2115
- package/react-draggable.20e95c61.js +0 -714
- package/react-json-view.f56a7f8e.js +0 -2762
- package/react-lazy-load-image-component.45b56650.js +0 -784
- package/react-resizable.5277deaf.js +0 -371
- package/react-splitter-layout.7810ac1b.js +0 -165
- package/utils/index.214d9542.js +0 -435
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
2
|
+
import { styled } from "@mui/material/styles";
|
|
3
|
+
import { Skeleton, FormControlLabel, Checkbox } from "@mui/material";
|
|
4
|
+
import { useModuleSkeleton } from "@m4l/core";
|
|
5
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
6
|
+
const WrapperSKTRHFCheckbox = styled("div")(() => ({
|
|
7
|
+
display: "flex",
|
|
8
|
+
justifyContent: "center",
|
|
9
|
+
alignItems: "center",
|
|
10
|
+
padding: "8px"
|
|
11
|
+
}));
|
|
12
|
+
const SKTCheckSkeleton = styled(Skeleton)(() => ({
|
|
13
|
+
width: "20px",
|
|
14
|
+
height: "20px",
|
|
15
|
+
borderRadius: "4px"
|
|
16
|
+
}));
|
|
17
|
+
const ErrorLabel = styled("p")(({
|
|
18
|
+
theme
|
|
19
|
+
}) => ({
|
|
20
|
+
...theme.typography.caption,
|
|
21
|
+
color: theme.palette.error.main,
|
|
22
|
+
marginRight: 14,
|
|
23
|
+
marginLeft: 14
|
|
24
|
+
}));
|
|
25
|
+
function RHFCheckbox({
|
|
26
|
+
name,
|
|
27
|
+
sizeCheck = "small",
|
|
28
|
+
...other
|
|
29
|
+
}) {
|
|
30
|
+
const {
|
|
31
|
+
control
|
|
32
|
+
} = useFormContext();
|
|
33
|
+
const isSkeleton = useModuleSkeleton();
|
|
34
|
+
return /* @__PURE__ */ jsx(FormControlLabel, {
|
|
35
|
+
control: /* @__PURE__ */ jsx(Controller, {
|
|
36
|
+
name,
|
|
37
|
+
control,
|
|
38
|
+
render: ({
|
|
39
|
+
field,
|
|
40
|
+
fieldState: {
|
|
41
|
+
error
|
|
42
|
+
}
|
|
43
|
+
}) => {
|
|
44
|
+
if (isSkeleton) {
|
|
45
|
+
return /* @__PURE__ */ jsx(WrapperSKTRHFCheckbox, {
|
|
46
|
+
children: /* @__PURE__ */ jsx(SKTCheckSkeleton, {
|
|
47
|
+
variant: "rectangular"
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
52
|
+
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
53
|
+
size: sizeCheck,
|
|
54
|
+
...field,
|
|
55
|
+
checked: field.value
|
|
56
|
+
}), error?.message && /* @__PURE__ */ jsx(ErrorLabel, {
|
|
57
|
+
children: error?.message + ""
|
|
58
|
+
})]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}),
|
|
62
|
+
...other
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export { RHFCheckbox as R };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
2
|
+
import { Skeleton, TextField } from "@mui/material";
|
|
3
|
+
import { styled } from "@mui/material/styles";
|
|
4
|
+
import { DateTimePicker } from "@mui/x-date-pickers";
|
|
5
|
+
import { useModuleSkeleton, useEnvironment } from "@m4l/core";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
const SKTRHFWrapperTextField = styled("div")(({
|
|
8
|
+
theme
|
|
9
|
+
}) => ({
|
|
10
|
+
display: "flex",
|
|
11
|
+
width: "100%",
|
|
12
|
+
alignItems: "center",
|
|
13
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
14
|
+
padding: "12px 14px",
|
|
15
|
+
borderRadius: theme.spacing(1)
|
|
16
|
+
}));
|
|
17
|
+
function RHFDateTime(props) {
|
|
18
|
+
const {
|
|
19
|
+
name,
|
|
20
|
+
autoComplete = "off",
|
|
21
|
+
skeletonProps: skeletoProps = {}
|
|
22
|
+
} = props;
|
|
23
|
+
const {
|
|
24
|
+
width = "100%",
|
|
25
|
+
height = 14
|
|
26
|
+
} = skeletoProps;
|
|
27
|
+
const isSkeleton = useModuleSkeleton();
|
|
28
|
+
const {
|
|
29
|
+
control
|
|
30
|
+
} = useFormContext();
|
|
31
|
+
const {
|
|
32
|
+
dfnsFormat: {
|
|
33
|
+
datetime_format,
|
|
34
|
+
datetime_mask
|
|
35
|
+
}
|
|
36
|
+
} = useEnvironment();
|
|
37
|
+
if (isSkeleton) {
|
|
38
|
+
return /* @__PURE__ */ jsx(SKTRHFWrapperTextField, {
|
|
39
|
+
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
40
|
+
variant: "text",
|
|
41
|
+
width,
|
|
42
|
+
height
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
47
|
+
name,
|
|
48
|
+
control,
|
|
49
|
+
render: ({
|
|
50
|
+
field,
|
|
51
|
+
fieldState: {
|
|
52
|
+
error
|
|
53
|
+
}
|
|
54
|
+
}) => {
|
|
55
|
+
return /* @__PURE__ */ jsx(DateTimePicker, {
|
|
56
|
+
ampm: false,
|
|
57
|
+
inputFormat: datetime_format,
|
|
58
|
+
mask: datetime_mask,
|
|
59
|
+
label: "",
|
|
60
|
+
value: field.value,
|
|
61
|
+
onChange: (value) => {
|
|
62
|
+
if (!isNaN(value)) {
|
|
63
|
+
field.onChange(value);
|
|
64
|
+
} else {
|
|
65
|
+
field.onChange(void 0);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
renderInput: (params) => /* @__PURE__ */ jsx(TextField, {
|
|
69
|
+
autoComplete,
|
|
70
|
+
fullWidth: true,
|
|
71
|
+
error: !!error,
|
|
72
|
+
helperText: error?.message,
|
|
73
|
+
...params
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
export { RHFDateTime as R };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
2
|
+
import { FormGroup, FormControlLabel, Checkbox } from "@mui/material";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
function RHFMultiCheckbox({
|
|
5
|
+
name,
|
|
6
|
+
options,
|
|
7
|
+
...other
|
|
8
|
+
}) {
|
|
9
|
+
const {
|
|
10
|
+
control
|
|
11
|
+
} = useFormContext();
|
|
12
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
13
|
+
name,
|
|
14
|
+
control,
|
|
15
|
+
render: ({
|
|
16
|
+
field
|
|
17
|
+
}) => {
|
|
18
|
+
const onSelected = (option) => field.value.includes(option) ? field.value.filter((value) => value !== option) : [...field.value, option];
|
|
19
|
+
return /* @__PURE__ */ jsx(FormGroup, {
|
|
20
|
+
children: options.map((option) => /* @__PURE__ */ jsx(FormControlLabel, {
|
|
21
|
+
control: /* @__PURE__ */ jsx(Checkbox, {
|
|
22
|
+
checked: field.value.includes(option),
|
|
23
|
+
onChange: () => field.onChange(onSelected(option))
|
|
24
|
+
}),
|
|
25
|
+
label: option,
|
|
26
|
+
...other
|
|
27
|
+
}, option))
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export { RHFMultiCheckbox as R };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { styled } from "@mui/material";
|
|
2
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
3
|
+
import { E as ErrorLabel } from "../../ErrorLabel/index.js";
|
|
4
|
+
import { P as Period } from "../../Period/index.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
const Wrapper = styled("div")(({
|
|
7
|
+
theme
|
|
8
|
+
}) => ({
|
|
9
|
+
width: "100%",
|
|
10
|
+
display: "flex",
|
|
11
|
+
flexDirection: "column",
|
|
12
|
+
justifyContent: "center",
|
|
13
|
+
alignItems: "flex-start",
|
|
14
|
+
gap: theme.spacing(1)
|
|
15
|
+
}));
|
|
16
|
+
const RHFPeriod = (props) => {
|
|
17
|
+
const {
|
|
18
|
+
name
|
|
19
|
+
} = props;
|
|
20
|
+
const {
|
|
21
|
+
control
|
|
22
|
+
} = useFormContext();
|
|
23
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
24
|
+
name,
|
|
25
|
+
control,
|
|
26
|
+
render: ({
|
|
27
|
+
field: {
|
|
28
|
+
onChange,
|
|
29
|
+
value
|
|
30
|
+
},
|
|
31
|
+
fieldState: {
|
|
32
|
+
error
|
|
33
|
+
}
|
|
34
|
+
}) => {
|
|
35
|
+
return /* @__PURE__ */ jsxs(Wrapper, {
|
|
36
|
+
children: [/* @__PURE__ */ jsx(Period, {
|
|
37
|
+
value,
|
|
38
|
+
onChange,
|
|
39
|
+
error: !!error
|
|
40
|
+
}), error && /* @__PURE__ */ jsx(ErrorLabel, {
|
|
41
|
+
message: error.message || ""
|
|
42
|
+
})]
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
export { RHFPeriod as R };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
2
|
+
import { RadioGroup, FormControlLabel, Radio, FormHelperText } from "@mui/material";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
function RHFRadioGroup({
|
|
5
|
+
name,
|
|
6
|
+
options,
|
|
7
|
+
getOptionLabel,
|
|
8
|
+
...other
|
|
9
|
+
}) {
|
|
10
|
+
const {
|
|
11
|
+
control
|
|
12
|
+
} = useFormContext();
|
|
13
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
14
|
+
name,
|
|
15
|
+
control,
|
|
16
|
+
render: ({
|
|
17
|
+
field,
|
|
18
|
+
fieldState: {
|
|
19
|
+
error
|
|
20
|
+
}
|
|
21
|
+
}) => /* @__PURE__ */ jsxs("div", {
|
|
22
|
+
children: [/* @__PURE__ */ jsx(RadioGroup, {
|
|
23
|
+
...field,
|
|
24
|
+
row: true,
|
|
25
|
+
...other,
|
|
26
|
+
children: options.map((option, index) => /* @__PURE__ */ jsx(FormControlLabel, {
|
|
27
|
+
value: option,
|
|
28
|
+
control: /* @__PURE__ */ jsx(Radio, {}),
|
|
29
|
+
label: getOptionLabel?.length ? getOptionLabel[index] : option
|
|
30
|
+
}, option))
|
|
31
|
+
}), !!error && /* @__PURE__ */ jsx(FormHelperText, {
|
|
32
|
+
error: true,
|
|
33
|
+
sx: {
|
|
34
|
+
px: 2
|
|
35
|
+
},
|
|
36
|
+
children: error.message
|
|
37
|
+
})]
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export { RHFRadioGroup as R };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
2
|
+
import { TextField } from "@mui/material";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
function RHFSelect({
|
|
5
|
+
name,
|
|
6
|
+
children,
|
|
7
|
+
...other
|
|
8
|
+
}) {
|
|
9
|
+
const {
|
|
10
|
+
control
|
|
11
|
+
} = useFormContext();
|
|
12
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
13
|
+
name,
|
|
14
|
+
control,
|
|
15
|
+
render: ({
|
|
16
|
+
field,
|
|
17
|
+
fieldState: {
|
|
18
|
+
error
|
|
19
|
+
}
|
|
20
|
+
}) => /* @__PURE__ */ jsx(TextField, {
|
|
21
|
+
...field,
|
|
22
|
+
select: true,
|
|
23
|
+
fullWidth: true,
|
|
24
|
+
SelectProps: {
|
|
25
|
+
native: true
|
|
26
|
+
},
|
|
27
|
+
error: !!error,
|
|
28
|
+
helperText: error?.message,
|
|
29
|
+
...other,
|
|
30
|
+
children
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export { RHFSelect as R };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
2
|
+
import { Skeleton, TextField } from "@mui/material";
|
|
3
|
+
import { styled } from "@mui/material/styles";
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
import { useModuleSkeleton } from "@m4l/core";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
const SKTRHFWrapperTextField = styled("div")(({
|
|
8
|
+
theme
|
|
9
|
+
}) => ({
|
|
10
|
+
display: "flex",
|
|
11
|
+
width: "100%",
|
|
12
|
+
alignItems: "center",
|
|
13
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
14
|
+
padding: "12px 14px",
|
|
15
|
+
borderRadius: theme.spacing(1)
|
|
16
|
+
}));
|
|
17
|
+
const RHFTextField = forwardRef((props, inputRef) => {
|
|
18
|
+
const {
|
|
19
|
+
name: nameRHF,
|
|
20
|
+
autoComplete = "off",
|
|
21
|
+
skeletonProps: skeletoProps = {},
|
|
22
|
+
type,
|
|
23
|
+
...other
|
|
24
|
+
} = props;
|
|
25
|
+
const {
|
|
26
|
+
width = "100%",
|
|
27
|
+
height = 14
|
|
28
|
+
} = skeletoProps;
|
|
29
|
+
const isSkeleton = useModuleSkeleton();
|
|
30
|
+
const {
|
|
31
|
+
control
|
|
32
|
+
} = useFormContext();
|
|
33
|
+
if (isSkeleton) {
|
|
34
|
+
return /* @__PURE__ */ jsx(SKTRHFWrapperTextField, {
|
|
35
|
+
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
36
|
+
variant: "text",
|
|
37
|
+
width,
|
|
38
|
+
height
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
43
|
+
name: nameRHF,
|
|
44
|
+
control,
|
|
45
|
+
render: ({
|
|
46
|
+
field: {
|
|
47
|
+
onChange,
|
|
48
|
+
onBlur,
|
|
49
|
+
value,
|
|
50
|
+
name,
|
|
51
|
+
ref
|
|
52
|
+
},
|
|
53
|
+
fieldState: {
|
|
54
|
+
error
|
|
55
|
+
}
|
|
56
|
+
}) => {
|
|
57
|
+
const onInternalChange = (event) => {
|
|
58
|
+
if (type === "number") {
|
|
59
|
+
if (event.target.value) {
|
|
60
|
+
onChange(Number(event.target.value));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
onChange(event);
|
|
65
|
+
};
|
|
66
|
+
return /* @__PURE__ */ jsx(
|
|
67
|
+
TextField,
|
|
68
|
+
{
|
|
69
|
+
inputRef,
|
|
70
|
+
autoComplete,
|
|
71
|
+
onChange: onInternalChange,
|
|
72
|
+
onBlur,
|
|
73
|
+
value,
|
|
74
|
+
name,
|
|
75
|
+
ref,
|
|
76
|
+
fullWidth: true,
|
|
77
|
+
error: !!error,
|
|
78
|
+
helperText: error?.message,
|
|
79
|
+
type,
|
|
80
|
+
...other
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
RHFTextField.displayName = "RHFTextField";
|
|
87
|
+
export { RHFTextField as R };
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { styled as styled$1, FormHelperText } from "@mui/material";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
4
|
+
import { i as isString_1 } from "../../../lodash.js";
|
|
5
|
+
import { useDropzone } from "react-dropzone";
|
|
6
|
+
import { styled, alpha } from "@mui/material/styles";
|
|
7
|
+
import { I as Image } from "../../Image/index.js";
|
|
8
|
+
import { useEnvironment, useModuleDictionary } from "@m4l/core";
|
|
9
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
10
|
+
import "../../../react-lazy-load-image-component.js";
|
|
11
|
+
const RootStyle = styled("div")(({
|
|
12
|
+
theme
|
|
13
|
+
}) => ({
|
|
14
|
+
width: "inherit",
|
|
15
|
+
height: "100%",
|
|
16
|
+
minWidth: theme.spacing(20),
|
|
17
|
+
margin: "auto",
|
|
18
|
+
borderRadius: theme.spacing(1),
|
|
19
|
+
padding: theme.spacing(1),
|
|
20
|
+
border: `1px dashed ${theme.palette.grey[50032]}`
|
|
21
|
+
}));
|
|
22
|
+
const DropZoneStyle = styled("div")(({
|
|
23
|
+
theme
|
|
24
|
+
}) => ({
|
|
25
|
+
zIndex: 0,
|
|
26
|
+
width: "100%",
|
|
27
|
+
height: "100%",
|
|
28
|
+
outline: "none",
|
|
29
|
+
display: "flex",
|
|
30
|
+
overflow: "hidden",
|
|
31
|
+
borderRadius: theme.spacing(1),
|
|
32
|
+
position: "relative",
|
|
33
|
+
alignItems: "center",
|
|
34
|
+
justifyContent: "center",
|
|
35
|
+
"& > *": {
|
|
36
|
+
width: "100%",
|
|
37
|
+
height: "100%"
|
|
38
|
+
},
|
|
39
|
+
"&:hover": {
|
|
40
|
+
cursor: "pointer",
|
|
41
|
+
"& .placeholder": {
|
|
42
|
+
zIndex: 9
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
46
|
+
const PlaceholderStyle = styled("div")(({
|
|
47
|
+
theme
|
|
48
|
+
}) => ({
|
|
49
|
+
"&:hover": {
|
|
50
|
+
opacity: 1
|
|
51
|
+
},
|
|
52
|
+
display: "flex",
|
|
53
|
+
justifyContent: "center",
|
|
54
|
+
position: "absolute",
|
|
55
|
+
zIndex: "2",
|
|
56
|
+
inset: "0",
|
|
57
|
+
transition: theme.transitions.create("opacity", {
|
|
58
|
+
easing: theme.transitions.easing.easeInOut,
|
|
59
|
+
duration: theme.transitions.duration.shorter
|
|
60
|
+
}),
|
|
61
|
+
overflow: "auto"
|
|
62
|
+
}));
|
|
63
|
+
const ContainerUploadBody = styled("div")(({
|
|
64
|
+
theme
|
|
65
|
+
}) => ({
|
|
66
|
+
padding: theme.spacing(3, 5),
|
|
67
|
+
display: "flex",
|
|
68
|
+
flexWrap: "wrap",
|
|
69
|
+
justifyContent: "center",
|
|
70
|
+
width: "100%",
|
|
71
|
+
height: "100%",
|
|
72
|
+
gap: theme.spacing(3)
|
|
73
|
+
}));
|
|
74
|
+
const Containermessage = styled("div")(({
|
|
75
|
+
theme
|
|
76
|
+
}) => ({
|
|
77
|
+
display: "flex",
|
|
78
|
+
justifyContent: "center",
|
|
79
|
+
flexDirection: "column",
|
|
80
|
+
gap: theme.spacing(3)
|
|
81
|
+
}));
|
|
82
|
+
const ContainerTitle = styled("span")(({
|
|
83
|
+
theme
|
|
84
|
+
}) => ({
|
|
85
|
+
...theme.typography.subtitle2,
|
|
86
|
+
width: "fit-content"
|
|
87
|
+
}));
|
|
88
|
+
const ContainerDescription = styled("span")(({
|
|
89
|
+
theme
|
|
90
|
+
}) => ({
|
|
91
|
+
...theme.typography.body2,
|
|
92
|
+
minWidth: theme.spacing(20)
|
|
93
|
+
}));
|
|
94
|
+
const ContainerConditions = styled("span")(({
|
|
95
|
+
theme
|
|
96
|
+
}) => ({
|
|
97
|
+
...theme.typography.caption,
|
|
98
|
+
width: "fit-content"
|
|
99
|
+
}));
|
|
100
|
+
const WrapperImage = styled("div")(({
|
|
101
|
+
theme
|
|
102
|
+
}) => ({
|
|
103
|
+
display: "flex",
|
|
104
|
+
alignItems: "center",
|
|
105
|
+
maxWidth: theme.spacing(20)
|
|
106
|
+
}));
|
|
107
|
+
styled("div")(() => ({
|
|
108
|
+
width: "100%",
|
|
109
|
+
height: "100%",
|
|
110
|
+
position: "absolute",
|
|
111
|
+
inset: "0",
|
|
112
|
+
display: "flex",
|
|
113
|
+
justifyContent: "center",
|
|
114
|
+
alignItems: "center"
|
|
115
|
+
}));
|
|
116
|
+
function UploadImage({
|
|
117
|
+
error,
|
|
118
|
+
file,
|
|
119
|
+
helperText,
|
|
120
|
+
sx,
|
|
121
|
+
...other
|
|
122
|
+
}) {
|
|
123
|
+
const {
|
|
124
|
+
getRootProps,
|
|
125
|
+
getInputProps,
|
|
126
|
+
isDragActive,
|
|
127
|
+
isDragReject
|
|
128
|
+
} = useDropzone({
|
|
129
|
+
multiple: false,
|
|
130
|
+
...other
|
|
131
|
+
});
|
|
132
|
+
const {
|
|
133
|
+
host_static_assets,
|
|
134
|
+
environment_assets
|
|
135
|
+
} = useEnvironment();
|
|
136
|
+
const {
|
|
137
|
+
getLabel
|
|
138
|
+
} = useModuleDictionary();
|
|
139
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
140
|
+
children: [/* @__PURE__ */ jsx(RootStyle, {
|
|
141
|
+
id: "RootStyle",
|
|
142
|
+
sx: {
|
|
143
|
+
...(isDragReject || error) && {
|
|
144
|
+
borderColor: "error.light"
|
|
145
|
+
},
|
|
146
|
+
...sx
|
|
147
|
+
},
|
|
148
|
+
children: /* @__PURE__ */ jsxs(DropZoneStyle, {
|
|
149
|
+
id: "DropZoneStyle",
|
|
150
|
+
...getRootProps(),
|
|
151
|
+
sx: {
|
|
152
|
+
...isDragActive && {
|
|
153
|
+
opacity: 0.72
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
157
|
+
...getInputProps()
|
|
158
|
+
}), file && /* @__PURE__ */ jsx(Image, {
|
|
159
|
+
alt: "avatar",
|
|
160
|
+
src: isString_1(file) ? file : file.preview,
|
|
161
|
+
sx: {
|
|
162
|
+
zIndex: 8
|
|
163
|
+
}
|
|
164
|
+
}), /* @__PURE__ */ jsx(PlaceholderStyle, {
|
|
165
|
+
id: "PlaceholderStyle",
|
|
166
|
+
className: "placeholder",
|
|
167
|
+
sx: {
|
|
168
|
+
...file ? {
|
|
169
|
+
bgcolor: alpha("#161C24", 0.72),
|
|
170
|
+
color: "common.white",
|
|
171
|
+
opacity: 0
|
|
172
|
+
} : {
|
|
173
|
+
opacity: 1
|
|
174
|
+
},
|
|
175
|
+
...(isDragReject || error) && {
|
|
176
|
+
bgcolor: "error.lighter",
|
|
177
|
+
borderColor: "error.light",
|
|
178
|
+
color: "error.main"
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
children: /* @__PURE__ */ jsxs(ContainerUploadBody, {
|
|
182
|
+
className: "ContainerUploadBody",
|
|
183
|
+
children: [/* @__PURE__ */ jsx(WrapperImage, {
|
|
184
|
+
children: /* @__PURE__ */ jsx(Image, {
|
|
185
|
+
src: `${host_static_assets}/${environment_assets}/frontend/components/upload_image/assets/img/upload_image_illustration.svg`,
|
|
186
|
+
effect: "opacity",
|
|
187
|
+
width: "100%",
|
|
188
|
+
height: "auto",
|
|
189
|
+
mb: 1
|
|
190
|
+
})
|
|
191
|
+
}), /* @__PURE__ */ jsxs(Containermessage, {
|
|
192
|
+
children: [/* @__PURE__ */ jsx(ContainerTitle, {
|
|
193
|
+
children: file ? getLabel("upload_image.title_update") : getLabel("upload_image.title_upload")
|
|
194
|
+
}), /* @__PURE__ */ jsx(ContainerDescription, {
|
|
195
|
+
children: getLabel("upload_image.description")
|
|
196
|
+
}), /* @__PURE__ */ jsx(ContainerConditions, {
|
|
197
|
+
children: getLabel("upload_image.conditions")
|
|
198
|
+
})]
|
|
199
|
+
})]
|
|
200
|
+
})
|
|
201
|
+
})]
|
|
202
|
+
})
|
|
203
|
+
}), helperText && helperText]
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
const WrapperRHFUploadImage = styled$1("div")(() => ({
|
|
207
|
+
width: "inherit",
|
|
208
|
+
height: "inherit",
|
|
209
|
+
padding: "1px"
|
|
210
|
+
}));
|
|
211
|
+
function RHFUploadImage({
|
|
212
|
+
name,
|
|
213
|
+
...other
|
|
214
|
+
}) {
|
|
215
|
+
const {
|
|
216
|
+
control,
|
|
217
|
+
setValue
|
|
218
|
+
} = useFormContext();
|
|
219
|
+
const handleDrop = useCallback((acceptedFiles) => {
|
|
220
|
+
const file = acceptedFiles[0];
|
|
221
|
+
if (file) {
|
|
222
|
+
setValue(name, Object.assign(file, {
|
|
223
|
+
preview: URL.createObjectURL(file)
|
|
224
|
+
}));
|
|
225
|
+
}
|
|
226
|
+
}, [setValue]);
|
|
227
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
228
|
+
name,
|
|
229
|
+
control,
|
|
230
|
+
render: ({
|
|
231
|
+
field,
|
|
232
|
+
fieldState: {
|
|
233
|
+
error
|
|
234
|
+
}
|
|
235
|
+
}) => {
|
|
236
|
+
const checkError = !!error && !field.value;
|
|
237
|
+
return /* @__PURE__ */ jsxs(WrapperRHFUploadImage, {
|
|
238
|
+
children: [/* @__PURE__ */ jsx(UploadImage, {
|
|
239
|
+
onDrop: handleDrop,
|
|
240
|
+
error: checkError,
|
|
241
|
+
...other,
|
|
242
|
+
file: field.value
|
|
243
|
+
}), checkError && /* @__PURE__ */ jsx(FormHelperText, {
|
|
244
|
+
error: true,
|
|
245
|
+
sx: {
|
|
246
|
+
px: 2,
|
|
247
|
+
textAlign: "center"
|
|
248
|
+
},
|
|
249
|
+
children: error.message
|
|
250
|
+
})]
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
export { RHFUploadImage as R };
|