@m4l/components 1.0.0 → 1.0.2
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/components/AccountPopover/{index.efc74d5c.js → index.ec031003.js} +5 -3
- package/components/AppBar/{index.fc126a22.js → index.1499770b.js} +4 -4
- package/components/DragResizeWindow/{index.46b380e1.js → index.5e316291.js} +3 -3
- package/components/DynamicFilter/{index.d9168c12.js → index.05e15fb8.js} +28 -211
- package/components/FieldLabel/{index.f9cdcc27.js → index.400a46e0.js} +4 -4
- package/components/GridLayout/{index.bb3b7769.js → index.7156fbc9.js} +2 -2
- package/components/GridLayout/subcomponents/Griditem/{index.bb23f651.js → index.8946f18e.js} +4 -4
- package/components/GridLayout/subcomponents/Responsive/{index.b8a2a121.js → index.3c68f0cb.js} +2 -2
- package/components/GridLayout/subcomponents/SizeProvider/{index.094bc6b5.js → index.a5b2190d.js} +1 -1
- package/components/HamburgerMenu/{index.5997af31.js → index.d57bca4c.js} +3 -3
- package/components/HelperText/{index.be949cdf.js → index.651a9b4b.js} +1 -1
- package/components/Icon/index.2e8ec5a1.js +209 -0
- package/components/Image/index.0d32558e.js +168 -0
- package/components/LoadingError/{index.9f00c83c.js → index.d137be81.js} +5 -4
- package/components/MFLoader/{index.402c1acc.js → index.2038aa6c.js} +3 -3
- package/components/ModalDialog/{index.ea9189c3.js → index.85d30f10.js} +4 -4
- package/components/NavLink/{index.4e548cee.js → index.badec599.js} +2 -2
- package/components/NoItemSelected/{index.418c8316.js → index.008154ce.js} +2 -2
- package/components/ObjectLogs/{index.bfa7dad3.js → index.65a6b1bc.js} +8 -7
- package/components/PDFViewer/{index.bb2eca5a.js → index.9677b02a.js} +2 -2
- package/components/Page/index.7482cf60.js +98 -0
- package/components/PaperForm/{index.8121e3da.js → index.e04f9f1f.js} +2 -2
- package/components/Period/{index.5233694b.js → index.3d695534.js} +8 -103
- package/components/PrintingSystem/{index.fb176a93.js → index.89493ad6.js} +15 -14
- package/components/PrintingSystem/subcomponents/BodyNode/{index.c1d61038.js → index.fdd8cebb.js} +1 -1
- package/components/PrintingSystem/subcomponents/ChartNode/{index.18bd9bad.js → index.12293a60.js} +1 -1
- package/components/PrintingSystem/subcomponents/DividerNode/{index.67d9f1b4.js → index.7fdad1df.js} +1 -1
- package/components/PrintingSystem/subcomponents/FooterNode/{index.eaee152a.js → index.fcaf9b2f.js} +1 -1
- package/components/PrintingSystem/subcomponents/GridNode/{index.f5f63a2a.js → index.03148990.js} +1 -1
- package/components/PrintingSystem/subcomponents/HeaderNode/{index.7de4e411.js → index.691b5c38.js} +1 -1
- package/components/PrintingSystem/subcomponents/PaperNode/{index.f9ccf22b.js → index.3699b685.js} +1 -1
- package/components/PrintingSystem/subcomponents/PropertyValueNode/{index.f2f2e903.js → index.bcc87da8.js} +1 -1
- package/components/PrintingSystem/subcomponents/SectionNode/{index.540a4b19.js → index.659f28e5.js} +1 -1
- package/components/PrintingSystem/subcomponents/TextBoxNode/{index.41e7fcb0.js → index.137ebb7a.js} +1 -1
- package/components/PropertyValue/{index.9572c347.js → index.e31d4282.js} +3 -3
- package/components/Resizeable/{index.1f0c1359.js → index.8c72e36a.js} +1 -1
- package/components/ScrollBar/{index.adf0eade.js → index.9bfcc74f.js} +1 -1
- package/components/SideBar/{index.629ba840.js → index.004a2de1.js} +7 -31
- package/components/SplitLayout/{index.74091a81.js → index.aed78a1f.js} +1 -1
- package/components/ToastContainer/{index.f9b507b9.js → index.586b1194.js} +3 -3
- package/components/areas/constants.630a4f42.js +293 -0
- package/components/areas/contexts/AreasContext/{index.bb316000.js → index.81b748ec.js} +4 -4
- package/components/areas/{dictionary.7e74022a.js → dictionary.19b25583.js} +26 -34
- package/components/areas/hooks/useAreas/{index.e24bd74d.js → index.b02d5bdc.js} +1 -1
- package/components/hook-form/HelperError/index.fd10c3ab.js +19 -0
- package/components/hook-form/RHFAutocompleteAsync/index.ea3ba7a7.js +160 -0
- package/components/hook-form/RHFCheckbox/index.9ac452cc.js +143 -0
- package/components/hook-form/RHFColorPicker/index.25e4e643.js +191 -0
- package/components/hook-form/RHFDateTime/index.31a0537d.js +190 -0
- package/components/hook-form/RHFMultiCheckbox/index.437e6ba3.js +34 -0
- package/components/hook-form/RHFPeriod/index.c8868100.js +105 -0
- package/components/hook-form/RHFRadioGroup/index.11c0add8.js +35 -0
- package/components/hook-form/RHFSelect/index.c6c60ecc.js +29 -0
- package/components/hook-form/RHFTextField/index.2ae1f130.js +326 -0
- package/components/{Image/index.36a3d440.js → hook-form/RHFUpload/index.9eeaee0f.js} +32 -232
- package/components/maps/components/GpsTools/index.ef751d28.js +251 -0
- package/components/maps/{index.8ec46ce4.js → index.ba1ccfad.js} +21 -555
- package/components/modal/{WindowBase.a3ac7adc.js → WindowBase.c1e879e4.js} +4 -3
- package/components/modal/{WindowConfirm.e35da619.js → WindowConfirm.1a123368.js} +6 -6
- package/components/modal/{index.a0e30c8b.js → index.7ca17f55.js} +1 -1
- package/components/mui_extended/Accordion/index.391679d1.js +143 -0
- package/components/mui_extended/Avatar/index.3ba36655.js +63 -0
- package/components/mui_extended/Badge/index.3465d7fb.js +31 -0
- package/components/mui_extended/BoxIcon/index.d61e7ac5.js +22 -0
- package/components/mui_extended/Breadcrumbs/index.4a44883c.js +87 -0
- package/components/mui_extended/Button/index.a7dc6ef0.js +289 -0
- package/components/mui_extended/CheckBox/index.c5c8721c.js +76 -0
- package/components/mui_extended/CircularProgress/index.967e70b7.js +8 -0
- package/components/mui_extended/IconButton/index.87f4726c.js +120 -0
- package/components/{LinearProgressIndeterminate/index.de9d447c.js → mui_extended/LinearProgress/index.52edc848.js} +11 -4
- package/components/mui_extended/LinkWithRoute/index.288c51f3.js +15 -0
- package/components/{Page/index.fdf04592.js → mui_extended/Pager/index.46aec921.js} +9 -98
- package/components/mui_extended/Popover/index.8e5ac765.js +1041 -0
- package/components/mui_extended/Stack/index.fe363ca5.js +31 -0
- package/components/{maps/components/GpsTools/index.75880ce0.js → mui_extended/Tab/index.ad88441e.js} +674 -239
- package/components/mui_extended/ToggleButton/index.38ca2330.js +18 -0
- package/components/mui_extended/ToggleIconButton/index.7fbece74.js +24 -0
- package/components/mui_extended/Tooltip/index.49bb5ee1.js +40 -0
- package/components/mui_extended/Typography/index.2a1c68f8.js +55 -0
- package/components/popups/PopupsProvider/{index.18669fb4.js → index.3b43e55f.js} +1 -1
- package/components/popups/PopupsViewer/{index.ba354267.js → index.fb3f0c48.js} +5 -4
- package/contexts/ModalContext/{index.cf02e6bd.js → index.82f61407.js} +1 -1
- package/contexts/RHFormContext/{index.dc955a09.js → index.e942a298.js} +1 -1
- package/hooks/useFormAddEdit/{index.f156a2cd.js → index.fa430551.js} +2 -2
- package/hooks/useModal/{index.ef54bcf2.js → index.9fe41bde.js} +3 -3
- package/index.js +266 -239
- package/package.json +1 -1
- package/{react-draggable.5331add7.js → react-draggable.2df3b71a.js} +1 -1
- package/{react-resizable.37bfb965.js → react-resizable.c60f3843.js} +2 -2
- package/utils/{index.9ee4c99a.js → index.0660ee9c.js} +9 -62
- package/{vendor.a1ce6777.js → vendor.3eadfa16.js} +746 -3011
- package/components/Icon/index.d5fed418.js +0 -420
- package/components/LanguagePopover/index.e6fa2336.js +0 -184
- package/components/areas/constants.5387d83e.js +0 -412
- package/hooks/useTab/index.bce8b99e.js +0 -12
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
3
|
+
import { FormGroup, FormControlLabel, Checkbox } from "@mui/material";
|
|
4
|
+
function RHFMultiCheckbox({ name, options, ...other }) {
|
|
5
|
+
const { control } = useFormContext();
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
|
+
Controller,
|
|
8
|
+
{
|
|
9
|
+
name,
|
|
10
|
+
control,
|
|
11
|
+
render: ({ field }) => {
|
|
12
|
+
const onSelected = (option) => field.value.includes(option) ? field.value.filter((value) => value !== option) : [...field.value, option];
|
|
13
|
+
return /* @__PURE__ */ jsx(FormGroup, { children: options.map((option) => /* @__PURE__ */ jsx(
|
|
14
|
+
FormControlLabel,
|
|
15
|
+
{
|
|
16
|
+
control: /* @__PURE__ */ jsx(
|
|
17
|
+
Checkbox,
|
|
18
|
+
{
|
|
19
|
+
checked: field.value.includes(option),
|
|
20
|
+
onChange: () => field.onChange(onSelected(option))
|
|
21
|
+
}
|
|
22
|
+
),
|
|
23
|
+
label: option,
|
|
24
|
+
...other
|
|
25
|
+
},
|
|
26
|
+
option
|
|
27
|
+
)) });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
RHFMultiCheckbox as R
|
|
34
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { styled } from "@mui/material/styles";
|
|
3
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
4
|
+
import { H as HelperText } from "../../HelperText/index.651a9b4b.js";
|
|
5
|
+
import { generateUtilityClasses, generateUtilityClass } from "@mui/material";
|
|
6
|
+
import { unstable_composeClasses } from "@mui/base";
|
|
7
|
+
import { useModuleSkeleton } from "@m4l/core";
|
|
8
|
+
import { c as useFormFocus } from "../../../vendor.3eadfa16.js";
|
|
9
|
+
import { F as FieldLabel } from "../../FieldLabel/index.400a46e0.js";
|
|
10
|
+
import { P as Period } from "../../Period/index.3d695534.js";
|
|
11
|
+
const RHFPeriodRoot = styled("div")(({ theme }) => ({
|
|
12
|
+
width: "100%",
|
|
13
|
+
display: "flex",
|
|
14
|
+
flexDirection: "column",
|
|
15
|
+
justifyContent: "center",
|
|
16
|
+
alignItems: "flex-start",
|
|
17
|
+
gap: theme.spacing(1),
|
|
18
|
+
...theme.components?.M4LRHFPeriod?.styleOverrides
|
|
19
|
+
}));
|
|
20
|
+
const componentName = "M4LRHFPeriod";
|
|
21
|
+
generateUtilityClasses(componentName, [
|
|
22
|
+
"root",
|
|
23
|
+
"isFocus",
|
|
24
|
+
"isTabSelected"
|
|
25
|
+
]);
|
|
26
|
+
function getRHFPeriodUtilityClass(slot) {
|
|
27
|
+
return generateUtilityClass(componentName, slot);
|
|
28
|
+
}
|
|
29
|
+
const RHFPeriodUtilityClasses = (ownerState) => {
|
|
30
|
+
const slots = {
|
|
31
|
+
root: ["root", ownerState.isFocus && "isFocus", ownerState.isTabSelected && "isTabSelected"]
|
|
32
|
+
};
|
|
33
|
+
const composedClasses = unstable_composeClasses(slots, getRHFPeriodUtilityClass, {});
|
|
34
|
+
return {
|
|
35
|
+
...composedClasses
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
const RHFPeriod = (props) => {
|
|
39
|
+
const {
|
|
40
|
+
name,
|
|
41
|
+
readOnly,
|
|
42
|
+
skeletonWidth,
|
|
43
|
+
skeletonHeight,
|
|
44
|
+
state,
|
|
45
|
+
label,
|
|
46
|
+
mandatory,
|
|
47
|
+
mandatoryMessage,
|
|
48
|
+
helperMessage,
|
|
49
|
+
size
|
|
50
|
+
} = props;
|
|
51
|
+
const { control } = useFormContext();
|
|
52
|
+
const isSkeleton = useModuleSkeleton();
|
|
53
|
+
const { isFocus, isTabSelected, handlerFocus, handlerOnKeyUp, handlerOnBlur } = useFormFocus();
|
|
54
|
+
const ownerState = {
|
|
55
|
+
isFocus: !isSkeleton ? isFocus : false,
|
|
56
|
+
isTabSelected: !isSkeleton ? isTabSelected : false
|
|
57
|
+
};
|
|
58
|
+
const classes = RHFPeriodUtilityClasses(ownerState);
|
|
59
|
+
return /* @__PURE__ */ jsx(
|
|
60
|
+
RHFPeriodRoot,
|
|
61
|
+
{
|
|
62
|
+
className: classes.root,
|
|
63
|
+
tabIndex: 0,
|
|
64
|
+
onFocus: handlerFocus,
|
|
65
|
+
onBlur: handlerOnBlur,
|
|
66
|
+
onKeyUp: handlerOnKeyUp,
|
|
67
|
+
children: /* @__PURE__ */ jsx(
|
|
68
|
+
Controller,
|
|
69
|
+
{
|
|
70
|
+
name,
|
|
71
|
+
control,
|
|
72
|
+
render: ({ field: { onChange, value }, fieldState: { error } }) => {
|
|
73
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
74
|
+
label && /* @__PURE__ */ jsx(
|
|
75
|
+
FieldLabel,
|
|
76
|
+
{
|
|
77
|
+
label,
|
|
78
|
+
mandatory,
|
|
79
|
+
mandatoryMessage,
|
|
80
|
+
helperMessage
|
|
81
|
+
}
|
|
82
|
+
),
|
|
83
|
+
/* @__PURE__ */ jsx(
|
|
84
|
+
Period,
|
|
85
|
+
{
|
|
86
|
+
value,
|
|
87
|
+
onChange,
|
|
88
|
+
state: !!error === true ? "error" : state,
|
|
89
|
+
readOnly,
|
|
90
|
+
skeletonWidth,
|
|
91
|
+
skeletonHeight,
|
|
92
|
+
size
|
|
93
|
+
}
|
|
94
|
+
),
|
|
95
|
+
error && /* @__PURE__ */ jsx(HelperText, { variant: "error", message: error.message || "" })
|
|
96
|
+
] });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
export {
|
|
104
|
+
RHFPeriod as R
|
|
105
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
3
|
+
import { RadioGroup, FormControlLabel, Radio, FormHelperText } from "@mui/material";
|
|
4
|
+
function RHFRadioGroup({
|
|
5
|
+
name,
|
|
6
|
+
options,
|
|
7
|
+
getOptionLabel,
|
|
8
|
+
getOptionValue,
|
|
9
|
+
...other
|
|
10
|
+
}) {
|
|
11
|
+
const { control } = useFormContext();
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
Controller,
|
|
14
|
+
{
|
|
15
|
+
name,
|
|
16
|
+
control,
|
|
17
|
+
render: ({ field, fieldState: { error } }) => /* @__PURE__ */ jsxs("div", { children: [
|
|
18
|
+
/* @__PURE__ */ jsx(RadioGroup, { ...field, row: true, ...other, children: options.map((option) => /* @__PURE__ */ jsx(
|
|
19
|
+
FormControlLabel,
|
|
20
|
+
{
|
|
21
|
+
defaultValue: field.value,
|
|
22
|
+
value: getOptionValue(option),
|
|
23
|
+
control: /* @__PURE__ */ jsx(Radio, {}),
|
|
24
|
+
label: getOptionLabel(option)
|
|
25
|
+
},
|
|
26
|
+
getOptionValue(option)
|
|
27
|
+
)) }),
|
|
28
|
+
!!error && /* @__PURE__ */ jsx(FormHelperText, { error: true, sx: { px: 2 }, children: error.message })
|
|
29
|
+
] })
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
RHFRadioGroup as R
|
|
35
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
3
|
+
import { TextField } from "@mui/material";
|
|
4
|
+
function RHFSelect({ name, children, ...other }) {
|
|
5
|
+
const { control } = useFormContext();
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
|
+
Controller,
|
|
8
|
+
{
|
|
9
|
+
name,
|
|
10
|
+
control,
|
|
11
|
+
render: ({ field, fieldState: { error } }) => /* @__PURE__ */ jsx(
|
|
12
|
+
TextField,
|
|
13
|
+
{
|
|
14
|
+
...field,
|
|
15
|
+
select: true,
|
|
16
|
+
fullWidth: true,
|
|
17
|
+
SelectProps: { native: true },
|
|
18
|
+
error: !!error,
|
|
19
|
+
helperText: error?.message,
|
|
20
|
+
...other,
|
|
21
|
+
children
|
|
22
|
+
}
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
RHFSelect as R
|
|
29
|
+
};
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useModuleSkeleton, useEnvironment } from "@m4l/core";
|
|
3
|
+
import { Skeleton, generateUtilityClasses, TextField, InputAdornment, generateUtilityClass } from "@mui/material";
|
|
4
|
+
import { forwardRef, useState, useEffect } from "react";
|
|
5
|
+
import { I as IconButton } from "../../mui_extended/IconButton/index.87f4726c.js";
|
|
6
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
7
|
+
import { styled } from "@mui/material/styles";
|
|
8
|
+
import { T as TEST_PROP_ID } from "../../areas/constants.630a4f42.js";
|
|
9
|
+
import { unstable_composeClasses } from "@mui/base";
|
|
10
|
+
import { g as getComponentUtilityClass } from "../../../utils/index.0660ee9c.js";
|
|
11
|
+
import { H as HelperText } from "../../HelperText/index.651a9b4b.js";
|
|
12
|
+
import { useResponsiveDesktop } from "@m4l/graphics";
|
|
13
|
+
import { c as useFormFocus } from "../../../vendor.3eadfa16.js";
|
|
14
|
+
import { F as FieldLabel } from "../../FieldLabel/index.400a46e0.js";
|
|
15
|
+
const SkeletonTextFieldRoot = styled("div")(() => ({
|
|
16
|
+
display: "flex",
|
|
17
|
+
flexDirection: "column",
|
|
18
|
+
width: "100%",
|
|
19
|
+
gap: "4px"
|
|
20
|
+
}));
|
|
21
|
+
const WrapperSkeletonRHFTextField = styled("div")(({ theme }) => ({
|
|
22
|
+
display: "flex",
|
|
23
|
+
width: "100%",
|
|
24
|
+
alignItems: "center",
|
|
25
|
+
justifyContent: "space-between",
|
|
26
|
+
border: `1px solid ${theme.vars.palette.divider}`,
|
|
27
|
+
padding: "12px 14px",
|
|
28
|
+
borderRadius: theme.spacing(1),
|
|
29
|
+
gap: "4px"
|
|
30
|
+
}));
|
|
31
|
+
const RHFTEXTFIELD_ROOT_TEST_ID = "RHFTextFieldRoot";
|
|
32
|
+
const RHFTEXTFIELD_INPUT_TEST_ID = "RHFTextFieldInput";
|
|
33
|
+
const RHFTEXTFIELD_PREFIX = "RHFTextField";
|
|
34
|
+
const getNameDataTestId$1 = (KEY) => {
|
|
35
|
+
return `${RHFTEXTFIELD_PREFIX}-${KEY}`;
|
|
36
|
+
};
|
|
37
|
+
const SkeletonTextField = (props) => {
|
|
38
|
+
const { skeletonWidth, skeletonHeight, ownerState, classes, hasLabel } = props;
|
|
39
|
+
const { type: variant } = ownerState;
|
|
40
|
+
return /* @__PURE__ */ jsxs(SkeletonTextFieldRoot, { children: [
|
|
41
|
+
(hasLabel || hasLabel?.length === 0) && /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "30%", height: "16px" }),
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
WrapperSkeletonRHFTextField,
|
|
44
|
+
{
|
|
45
|
+
className: classes.skeleton,
|
|
46
|
+
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameDataTestId$1("skeleton") } : {},
|
|
47
|
+
children: variant === "text" ? /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: skeletonWidth, height: skeletonHeight }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
48
|
+
/* @__PURE__ */ jsx(Skeleton, { variant: "text", width: skeletonWidth, height: skeletonHeight }),
|
|
49
|
+
/* @__PURE__ */ jsx(Skeleton, { variant: "circular", width: "16px", height: "16px" })
|
|
50
|
+
] })
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
] });
|
|
54
|
+
};
|
|
55
|
+
const RHFTextFieldRoot = styled("div")(({ theme }) => ({
|
|
56
|
+
...theme.components?.M4LRHFTextField?.styleOverrides
|
|
57
|
+
}));
|
|
58
|
+
styled("div")(({ theme }) => ({
|
|
59
|
+
display: "flex",
|
|
60
|
+
width: "100%",
|
|
61
|
+
alignItems: "center",
|
|
62
|
+
border: `1px solid ${theme.vars.palette.divider}`,
|
|
63
|
+
padding: "12px 14px",
|
|
64
|
+
borderRadius: theme.spacing(1)
|
|
65
|
+
}));
|
|
66
|
+
const componentName = "M4LRHFTextField";
|
|
67
|
+
generateUtilityClasses(
|
|
68
|
+
componentName,
|
|
69
|
+
[
|
|
70
|
+
"root",
|
|
71
|
+
"label",
|
|
72
|
+
"skeleton",
|
|
73
|
+
"variantText",
|
|
74
|
+
"variantPassword",
|
|
75
|
+
"variantInfo",
|
|
76
|
+
"isDisabled",
|
|
77
|
+
"variantSuccess",
|
|
78
|
+
"variantWarning",
|
|
79
|
+
"variantError",
|
|
80
|
+
"sizeSmall",
|
|
81
|
+
"sizeMedium",
|
|
82
|
+
"isFocus",
|
|
83
|
+
"isTabSelected"
|
|
84
|
+
]
|
|
85
|
+
);
|
|
86
|
+
const getRHFTextFieldClassesByState = (ownerState) => {
|
|
87
|
+
const slots = {
|
|
88
|
+
root: [
|
|
89
|
+
"root",
|
|
90
|
+
ownerState.type === "password" ? "variantPassword" : "variantText",
|
|
91
|
+
ownerState.size === "small" && "sizeSmall",
|
|
92
|
+
ownerState.size === "medium" && "sizeMedium",
|
|
93
|
+
ownerState.isFocus && "isFocus",
|
|
94
|
+
ownerState.isTabSelected && "isTabSelected",
|
|
95
|
+
ownerState.disabled && "isDisabled",
|
|
96
|
+
ownerState.variant === "info" && "variantInfo",
|
|
97
|
+
ownerState.variant === "success" && "variantSuccess",
|
|
98
|
+
ownerState.variant === "warning" && "variantWarning",
|
|
99
|
+
ownerState.variant === "error" && "variantError"
|
|
100
|
+
],
|
|
101
|
+
label: ["label"],
|
|
102
|
+
skeleton: ["skeleton"]
|
|
103
|
+
};
|
|
104
|
+
const composedClasses = unstable_composeClasses(slots, getComponentUtilityClass(componentName), {});
|
|
105
|
+
return {
|
|
106
|
+
...composedClasses
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
const RHFTextField = forwardRef((props, ref) => {
|
|
110
|
+
const {
|
|
111
|
+
name: nameRHF,
|
|
112
|
+
autoComplete = "off",
|
|
113
|
+
skeletonWidth = "100%",
|
|
114
|
+
skeletonHeight = "18px",
|
|
115
|
+
type,
|
|
116
|
+
label,
|
|
117
|
+
size = "small",
|
|
118
|
+
startIcon,
|
|
119
|
+
endIcon,
|
|
120
|
+
variant,
|
|
121
|
+
helperMessage = "",
|
|
122
|
+
disabled,
|
|
123
|
+
mandatory,
|
|
124
|
+
mandatoryMessage,
|
|
125
|
+
helperText,
|
|
126
|
+
...other
|
|
127
|
+
} = props;
|
|
128
|
+
const {
|
|
129
|
+
control,
|
|
130
|
+
formState: { errors }
|
|
131
|
+
} = useFormContext();
|
|
132
|
+
const [currentVariant, setCurrentVariant] = useState(null);
|
|
133
|
+
const { isFocus, isTabSelected, handlerFocus, handlerOnKeyUp, handlerOnBlur } = useFormFocus();
|
|
134
|
+
const isDesktop = useResponsiveDesktop();
|
|
135
|
+
const isSkeleton = useModuleSkeleton();
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
if (errors[nameRHF]) {
|
|
138
|
+
setCurrentVariant("error");
|
|
139
|
+
} else if (variant) {
|
|
140
|
+
setCurrentVariant(variant);
|
|
141
|
+
} else {
|
|
142
|
+
setCurrentVariant(null);
|
|
143
|
+
}
|
|
144
|
+
}, [errors[nameRHF], variant, control]);
|
|
145
|
+
const ownerState = {
|
|
146
|
+
type: type === "password" ? "password" : "text",
|
|
147
|
+
size: !isDesktop ? "medium" : size,
|
|
148
|
+
isFocus: !isSkeleton ? isFocus : false,
|
|
149
|
+
isTabSelected: !isSkeleton ? isTabSelected : false,
|
|
150
|
+
variant: currentVariant,
|
|
151
|
+
disabled
|
|
152
|
+
};
|
|
153
|
+
const classes = getRHFTextFieldClassesByState(ownerState);
|
|
154
|
+
return /* @__PURE__ */ jsx(
|
|
155
|
+
RHFTextFieldRoot,
|
|
156
|
+
{
|
|
157
|
+
className: classes.root,
|
|
158
|
+
tabIndex: 0,
|
|
159
|
+
onFocus: handlerFocus,
|
|
160
|
+
onBlur: handlerOnBlur,
|
|
161
|
+
onKeyUp: handlerOnKeyUp,
|
|
162
|
+
role: "textbox",
|
|
163
|
+
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: `${RHFTEXTFIELD_ROOT_TEST_ID}_${nameRHF}` } : {},
|
|
164
|
+
children: !isSkeleton ? /* @__PURE__ */ jsx(
|
|
165
|
+
Controller,
|
|
166
|
+
{
|
|
167
|
+
name: nameRHF,
|
|
168
|
+
control,
|
|
169
|
+
render: ({ field: { onChange, value, name, ref: inputRef }, fieldState: { error } }) => {
|
|
170
|
+
const onInternalChange = (event) => {
|
|
171
|
+
if (type === "number") {
|
|
172
|
+
if (event.target.value) {
|
|
173
|
+
onChange(Number(event.target.value));
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
onChange(event);
|
|
178
|
+
};
|
|
179
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
180
|
+
label && /* @__PURE__ */ jsx(
|
|
181
|
+
FieldLabel,
|
|
182
|
+
{
|
|
183
|
+
label,
|
|
184
|
+
mandatory,
|
|
185
|
+
mandatoryMessage,
|
|
186
|
+
helperMessage
|
|
187
|
+
}
|
|
188
|
+
),
|
|
189
|
+
/* @__PURE__ */ jsx(
|
|
190
|
+
TextField,
|
|
191
|
+
{
|
|
192
|
+
variant: "outlined",
|
|
193
|
+
disabled,
|
|
194
|
+
ref,
|
|
195
|
+
inputRef,
|
|
196
|
+
InputLabelProps: { shrink: true },
|
|
197
|
+
autoComplete,
|
|
198
|
+
onChange: onInternalChange,
|
|
199
|
+
value: type === "number" ? isNaN(value) ? 0 : value : value || "",
|
|
200
|
+
name,
|
|
201
|
+
inputProps: {
|
|
202
|
+
...process.env.NODE_ENV !== "production" ? {
|
|
203
|
+
[TEST_PROP_ID]: `${RHFTEXTFIELD_INPUT_TEST_ID}_${name}`
|
|
204
|
+
} : {}
|
|
205
|
+
},
|
|
206
|
+
fullWidth: true,
|
|
207
|
+
error: !!error,
|
|
208
|
+
type,
|
|
209
|
+
...startIcon || endIcon ? {
|
|
210
|
+
InputProps: {
|
|
211
|
+
...{
|
|
212
|
+
...startIcon ? {
|
|
213
|
+
startAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "start", children: startIcon })
|
|
214
|
+
} : {},
|
|
215
|
+
...endIcon ? {
|
|
216
|
+
endAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: endIcon })
|
|
217
|
+
} : {}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
} : {},
|
|
221
|
+
...other
|
|
222
|
+
}
|
|
223
|
+
),
|
|
224
|
+
currentVariant ? /* @__PURE__ */ jsx(
|
|
225
|
+
HelperText,
|
|
226
|
+
{
|
|
227
|
+
variant: currentVariant,
|
|
228
|
+
message: currentVariant !== "error" ? helperMessage : error?.message
|
|
229
|
+
}
|
|
230
|
+
) : null
|
|
231
|
+
] });
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
) : /* @__PURE__ */ jsx(
|
|
235
|
+
SkeletonTextField,
|
|
236
|
+
{
|
|
237
|
+
classes,
|
|
238
|
+
skeletonWidth,
|
|
239
|
+
skeletonHeight,
|
|
240
|
+
ownerState,
|
|
241
|
+
hasLabel: label
|
|
242
|
+
}
|
|
243
|
+
)
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
});
|
|
247
|
+
RHFTextField.displayName = "RHFTextField";
|
|
248
|
+
const RHFTextFieldPasswordRoot = styled("div")(({ theme }) => ({
|
|
249
|
+
...theme.components?.M4LRHFTextFieldPassword?.styleOverrides
|
|
250
|
+
}));
|
|
251
|
+
generateUtilityClasses(
|
|
252
|
+
"M4LRHFTextFieldPassword",
|
|
253
|
+
[
|
|
254
|
+
"root"
|
|
255
|
+
]
|
|
256
|
+
);
|
|
257
|
+
function getRHFTextFieldPasswordUtilityClass(slot) {
|
|
258
|
+
return generateUtilityClass("M4LRHFTextFieldPassword", slot);
|
|
259
|
+
}
|
|
260
|
+
const useUtilityClasses = () => {
|
|
261
|
+
const slots = {
|
|
262
|
+
root: ["root"]
|
|
263
|
+
};
|
|
264
|
+
const composedClasses = unstable_composeClasses(slots, getRHFTextFieldPasswordUtilityClass, {});
|
|
265
|
+
return {
|
|
266
|
+
...composedClasses
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
const RHFTEXTFIELDPASSWORD_PREFIX = "RHFTextFieldPassword";
|
|
270
|
+
const getNameDataTestId = (KEY) => {
|
|
271
|
+
return `${RHFTEXTFIELDPASSWORD_PREFIX}-${KEY}`;
|
|
272
|
+
};
|
|
273
|
+
const RHFTextFieldPassword = (props) => {
|
|
274
|
+
const {
|
|
275
|
+
name,
|
|
276
|
+
label,
|
|
277
|
+
skeletonWidth,
|
|
278
|
+
skeletonHeight,
|
|
279
|
+
size,
|
|
280
|
+
mandatory,
|
|
281
|
+
mandatoryMessage,
|
|
282
|
+
helperMessage
|
|
283
|
+
} = props;
|
|
284
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
285
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
286
|
+
const classes = useUtilityClasses();
|
|
287
|
+
return /* @__PURE__ */ jsx(
|
|
288
|
+
RHFTextFieldPasswordRoot,
|
|
289
|
+
{
|
|
290
|
+
className: classes.root,
|
|
291
|
+
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameDataTestId("root") } : {},
|
|
292
|
+
children: /* @__PURE__ */ jsx(
|
|
293
|
+
RHFTextField,
|
|
294
|
+
{
|
|
295
|
+
name,
|
|
296
|
+
label,
|
|
297
|
+
type: showPassword ? "text" : "password",
|
|
298
|
+
autoComplete: "on",
|
|
299
|
+
skeletonWidth,
|
|
300
|
+
skeletonHeight,
|
|
301
|
+
size,
|
|
302
|
+
mandatory,
|
|
303
|
+
mandatoryMessage,
|
|
304
|
+
helperMessage,
|
|
305
|
+
InputProps: {
|
|
306
|
+
endAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx(
|
|
307
|
+
IconButton,
|
|
308
|
+
{
|
|
309
|
+
onClick: () => setShowPassword(!showPassword),
|
|
310
|
+
variant: "line",
|
|
311
|
+
src: showPassword ? `${host_static_assets}/${environment_assets}/frontend/domain/host/login/assets/icons/eye.svg` : `${host_static_assets}/${environment_assets}/frontend/domain/host/login/assets/icons/eye_off.svg`
|
|
312
|
+
}
|
|
313
|
+
) })
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
)
|
|
317
|
+
}
|
|
318
|
+
);
|
|
319
|
+
};
|
|
320
|
+
export {
|
|
321
|
+
RHFTextField as R,
|
|
322
|
+
RHFTEXTFIELD_ROOT_TEST_ID as a,
|
|
323
|
+
RHFTEXTFIELD_INPUT_TEST_ID as b,
|
|
324
|
+
RHFTEXTFIELD_PREFIX as c,
|
|
325
|
+
RHFTextFieldPassword as d
|
|
326
|
+
};
|