@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,160 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useCallback, useEffect } from "react";
|
|
3
|
+
import { useNetwork, getPropertyByString } from "@m4l/core";
|
|
4
|
+
import debounce from "lodash/debounce";
|
|
5
|
+
import { styled } from "@mui/material/styles";
|
|
6
|
+
import { generateUtilityClasses, generateUtilityClass } from "@mui/material";
|
|
7
|
+
import { unstable_composeClasses } from "@mui/base";
|
|
8
|
+
import { T as TEST_PROP_ID } from "../../areas/constants.630a4f42.js";
|
|
9
|
+
import { R as RHFAutocomplete } from "../../../vendor.3eadfa16.js";
|
|
10
|
+
import { e as getRHFAutocompleteComponentsDictionary } from "../../areas/dictionary.19b25583.js";
|
|
11
|
+
styled("div")(() => ({
|
|
12
|
+
display: "flex",
|
|
13
|
+
width: "100%",
|
|
14
|
+
flexDirection: "column"
|
|
15
|
+
}));
|
|
16
|
+
styled("div")(({ theme }) => ({
|
|
17
|
+
display: "flex",
|
|
18
|
+
justifyContent: "flex-end",
|
|
19
|
+
paddingRight: `${theme.spacing(2)}`,
|
|
20
|
+
[theme.breakpoints.down("md")]: {
|
|
21
|
+
justifyContent: "flex-start"
|
|
22
|
+
}
|
|
23
|
+
}));
|
|
24
|
+
styled("div")(({ theme }) => ({
|
|
25
|
+
width: "100%",
|
|
26
|
+
display: "grid",
|
|
27
|
+
gridTemplateColumns: "1fr auto",
|
|
28
|
+
gridGap: theme.spacing(2),
|
|
29
|
+
alignItems: "center",
|
|
30
|
+
height: `${theme.spacing(4.5)}`,
|
|
31
|
+
border: `1px solid ${theme.vars.palette.divider}`,
|
|
32
|
+
borderRadius: `${theme.spacing(1)}`,
|
|
33
|
+
padding: `0 ${theme.spacing(2)}`,
|
|
34
|
+
[theme.breakpoints.down("md")]: {
|
|
35
|
+
width: "100%"
|
|
36
|
+
}
|
|
37
|
+
}));
|
|
38
|
+
const RHFAutocompleteAsyncRoot = styled("div")(({ theme }) => ({
|
|
39
|
+
...theme.components?.M4LRHFAutocompleteAsync?.styleOverrides
|
|
40
|
+
}));
|
|
41
|
+
const componentName = "M4LRHFAutocompleteAsync";
|
|
42
|
+
generateUtilityClasses(
|
|
43
|
+
componentName,
|
|
44
|
+
[
|
|
45
|
+
"root"
|
|
46
|
+
]
|
|
47
|
+
);
|
|
48
|
+
function getRHFAutocompleteAsyncClassesUtilityClass(slot) {
|
|
49
|
+
return generateUtilityClass(componentName, slot);
|
|
50
|
+
}
|
|
51
|
+
const useUtilityClasses = () => {
|
|
52
|
+
const slots = {
|
|
53
|
+
root: ["root"]
|
|
54
|
+
};
|
|
55
|
+
const composedClasses = unstable_composeClasses(slots, getRHFAutocompleteAsyncClassesUtilityClass, {});
|
|
56
|
+
return {
|
|
57
|
+
...composedClasses
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
const RHFAUTOCOMPLETEASYNC_PREFIX = "RHFAutocompleteAsync";
|
|
61
|
+
const getNameDataTestId = (KEY) => {
|
|
62
|
+
return `${RHFAUTOCOMPLETEASYNC_PREFIX}-${KEY}`;
|
|
63
|
+
};
|
|
64
|
+
function RHFAutocompleteAsync(props) {
|
|
65
|
+
const {
|
|
66
|
+
name,
|
|
67
|
+
endPoint,
|
|
68
|
+
timeout = 5e3,
|
|
69
|
+
parms,
|
|
70
|
+
resultField = "data",
|
|
71
|
+
size,
|
|
72
|
+
isRemote = true,
|
|
73
|
+
onChangeFilterParms,
|
|
74
|
+
...other
|
|
75
|
+
} = props;
|
|
76
|
+
const { networkOperation } = useNetwork();
|
|
77
|
+
const [options, setOptions] = useState([]);
|
|
78
|
+
const [open, setOpen] = useState(false);
|
|
79
|
+
const [loading, setIsloading] = useState(false);
|
|
80
|
+
const [canLoadOptions, setCanLoadOptions] = useState(true);
|
|
81
|
+
const [filterParms, setFilterParms] = useState({});
|
|
82
|
+
const debouncedFilter = useCallback(
|
|
83
|
+
debounce(
|
|
84
|
+
(newFilterParms) => {
|
|
85
|
+
setCanLoadOptions(true);
|
|
86
|
+
setFilterParms(newFilterParms);
|
|
87
|
+
},
|
|
88
|
+
300
|
|
89
|
+
),
|
|
90
|
+
[]
|
|
91
|
+
);
|
|
92
|
+
const onChangeFilterParmsLocal = (newValue) => {
|
|
93
|
+
if (onChangeFilterParms) {
|
|
94
|
+
debouncedFilter(onChangeFilterParms(newValue));
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
setCanLoadOptions(true);
|
|
99
|
+
}, [parms, endPoint]);
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
if (!open || loading) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (!canLoadOptions) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
setIsloading(true);
|
|
108
|
+
setOptions([]);
|
|
109
|
+
setCanLoadOptions(false);
|
|
110
|
+
networkOperation({
|
|
111
|
+
method: "GET",
|
|
112
|
+
endPoint,
|
|
113
|
+
timeout,
|
|
114
|
+
parms: { ...parms, ...filterParms },
|
|
115
|
+
isRemote
|
|
116
|
+
}).then((response) => {
|
|
117
|
+
const valueMaybeArray = getPropertyByString(response, resultField);
|
|
118
|
+
const newOptions = Array.isArray(valueMaybeArray) ? valueMaybeArray : [];
|
|
119
|
+
setOptions(newOptions);
|
|
120
|
+
}).catch(() => {
|
|
121
|
+
setCanLoadOptions(true);
|
|
122
|
+
}).finally(() => {
|
|
123
|
+
setIsloading(false);
|
|
124
|
+
});
|
|
125
|
+
return () => {
|
|
126
|
+
};
|
|
127
|
+
}, [open, parms, filterParms, endPoint]);
|
|
128
|
+
const classes = useUtilityClasses();
|
|
129
|
+
return /* @__PURE__ */ jsx(
|
|
130
|
+
RHFAutocompleteAsyncRoot,
|
|
131
|
+
{
|
|
132
|
+
className: classes.root,
|
|
133
|
+
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameDataTestId("root") } : {},
|
|
134
|
+
children: /* @__PURE__ */ jsx(
|
|
135
|
+
RHFAutocomplete,
|
|
136
|
+
{
|
|
137
|
+
name,
|
|
138
|
+
loading,
|
|
139
|
+
options,
|
|
140
|
+
onChangeFilterParmsLocal: onChangeFilterParms ? onChangeFilterParmsLocal : void 0,
|
|
141
|
+
size,
|
|
142
|
+
onOpen: () => {
|
|
143
|
+
setOpen(true);
|
|
144
|
+
},
|
|
145
|
+
onClose: () => {
|
|
146
|
+
setOpen(false);
|
|
147
|
+
},
|
|
148
|
+
...other
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
function getRHFAutocompleteAsyncComponentsDictionary() {
|
|
155
|
+
return getRHFAutocompleteComponentsDictionary();
|
|
156
|
+
}
|
|
157
|
+
export {
|
|
158
|
+
RHFAutocompleteAsync as R,
|
|
159
|
+
getRHFAutocompleteAsyncComponentsDictionary as g
|
|
160
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
3
|
+
import { styled } from "@mui/material/styles";
|
|
4
|
+
import { Skeleton, generateUtilityClasses, generateUtilityClass } from "@mui/material";
|
|
5
|
+
import { unstable_composeClasses } from "@mui/base";
|
|
6
|
+
import { H as HelperText } from "../../HelperText/index.651a9b4b.js";
|
|
7
|
+
import { T as TEST_PROP_ID } from "../../areas/constants.630a4f42.js";
|
|
8
|
+
import { useResponsiveDesktop } from "@m4l/graphics";
|
|
9
|
+
import { useModuleSkeleton } from "@m4l/core";
|
|
10
|
+
import { c as useFormFocus } from "../../../vendor.3eadfa16.js";
|
|
11
|
+
import { C as CheckBox } from "../../mui_extended/CheckBox/index.c5c8721c.js";
|
|
12
|
+
const RHFCheckboxRoot = styled("div")(({ theme }) => ({
|
|
13
|
+
...theme.components?.M4LRHFCheckbox?.styleOverrides
|
|
14
|
+
}));
|
|
15
|
+
styled("div")(() => ({
|
|
16
|
+
display: "flex",
|
|
17
|
+
justifyContent: "center",
|
|
18
|
+
alignItems: "center",
|
|
19
|
+
padding: "8px"
|
|
20
|
+
}));
|
|
21
|
+
styled(Skeleton)(() => ({
|
|
22
|
+
width: "20px",
|
|
23
|
+
height: "20px",
|
|
24
|
+
borderRadius: "4px"
|
|
25
|
+
}));
|
|
26
|
+
const ContainerCheckTypography = styled("div")(() => ({
|
|
27
|
+
display: "flex",
|
|
28
|
+
alignItems: "center"
|
|
29
|
+
}));
|
|
30
|
+
generateUtilityClasses("M4LRHFCheckbox", [
|
|
31
|
+
"root",
|
|
32
|
+
"checkTypography",
|
|
33
|
+
"skeleton",
|
|
34
|
+
"small",
|
|
35
|
+
"medium",
|
|
36
|
+
"stateDisabled",
|
|
37
|
+
"stateError",
|
|
38
|
+
"isFocus",
|
|
39
|
+
"isTabSelected"
|
|
40
|
+
]);
|
|
41
|
+
function getRHFCheckboxUtilityClass(slot) {
|
|
42
|
+
return generateUtilityClass("M4LRHFCheckbox", slot);
|
|
43
|
+
}
|
|
44
|
+
const useUtilityClasses = (ownerState) => {
|
|
45
|
+
const slots = {
|
|
46
|
+
root: [
|
|
47
|
+
"root",
|
|
48
|
+
ownerState.isFocus && "isFocus",
|
|
49
|
+
ownerState.isTabSelected && "isTabSelected",
|
|
50
|
+
ownerState.sizeCheck === "small" && "small",
|
|
51
|
+
ownerState.sizeCheck === "medium" && "medium",
|
|
52
|
+
ownerState.disabled && "stateDisabled",
|
|
53
|
+
ownerState.error && "stateError"
|
|
54
|
+
],
|
|
55
|
+
skeleton: ["skeleton"],
|
|
56
|
+
checkTypography: [
|
|
57
|
+
"checkTypography",
|
|
58
|
+
ownerState.sizeCheck === "small" ? "small" : "medium",
|
|
59
|
+
ownerState.disabled && "stateDisabled"
|
|
60
|
+
]
|
|
61
|
+
};
|
|
62
|
+
const composedClasses = unstable_composeClasses(slots, getRHFCheckboxUtilityClass, {});
|
|
63
|
+
return {
|
|
64
|
+
...composedClasses
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
const RHFCHEKCBOX_PREFIX = "RHFCheckbox";
|
|
68
|
+
const getNameDataTestId = (KEY, NAME) => {
|
|
69
|
+
return `${RHFCHEKCBOX_PREFIX}-${NAME}-${KEY}`;
|
|
70
|
+
};
|
|
71
|
+
function RHFCheckbox(props) {
|
|
72
|
+
const {
|
|
73
|
+
name,
|
|
74
|
+
sizeCheck = "small",
|
|
75
|
+
label,
|
|
76
|
+
disabled = false,
|
|
77
|
+
mandatory,
|
|
78
|
+
mandatoryMessage,
|
|
79
|
+
helperMessage
|
|
80
|
+
} = props;
|
|
81
|
+
const {
|
|
82
|
+
control,
|
|
83
|
+
formState: { errors }
|
|
84
|
+
} = useFormContext();
|
|
85
|
+
const isSkeleton = useModuleSkeleton();
|
|
86
|
+
const { isFocus, isTabSelected, handlerFocus, handlerOnKeyUp, handlerOnBlur } = useFormFocus();
|
|
87
|
+
const isDesktop = useResponsiveDesktop();
|
|
88
|
+
const ownerState = {
|
|
89
|
+
isFocus: !isSkeleton ? isFocus : false,
|
|
90
|
+
isTabSelected: !isSkeleton ? isTabSelected : false,
|
|
91
|
+
sizeCheck: !isDesktop ? "medium" : sizeCheck,
|
|
92
|
+
disabled,
|
|
93
|
+
error: errors[name] ? true : false
|
|
94
|
+
};
|
|
95
|
+
const classes = useUtilityClasses(ownerState);
|
|
96
|
+
return /* @__PURE__ */ jsx(
|
|
97
|
+
RHFCheckboxRoot,
|
|
98
|
+
{
|
|
99
|
+
className: classes.root,
|
|
100
|
+
onFocus: handlerFocus,
|
|
101
|
+
onBlur: handlerOnBlur,
|
|
102
|
+
onKeyUp: handlerOnKeyUp,
|
|
103
|
+
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameDataTestId("root", name) } : {},
|
|
104
|
+
children: /* @__PURE__ */ jsx(
|
|
105
|
+
Controller,
|
|
106
|
+
{
|
|
107
|
+
name,
|
|
108
|
+
control,
|
|
109
|
+
render: ({ field: { onChange, value }, fieldState: { error } }) => {
|
|
110
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
111
|
+
/* @__PURE__ */ jsx(
|
|
112
|
+
ContainerCheckTypography,
|
|
113
|
+
{
|
|
114
|
+
className: classes.checkTypography,
|
|
115
|
+
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameDataTestId("checkTypography", name) } : {},
|
|
116
|
+
children: /* @__PURE__ */ jsx(
|
|
117
|
+
CheckBox,
|
|
118
|
+
{
|
|
119
|
+
size: sizeCheck,
|
|
120
|
+
onChange,
|
|
121
|
+
checked: value,
|
|
122
|
+
disabled: disabled ? true : false,
|
|
123
|
+
disableRipple: true,
|
|
124
|
+
label,
|
|
125
|
+
mandatory,
|
|
126
|
+
mandatoryMessage,
|
|
127
|
+
helperMessage,
|
|
128
|
+
htmlFor: name
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
error?.message && /* @__PURE__ */ jsx(HelperText, { variant: "error", message: error?.message + "" })
|
|
134
|
+
] });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
export {
|
|
142
|
+
RHFCheckbox as R
|
|
143
|
+
};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useFormContext, useWatch, Controller } from "react-hook-form";
|
|
4
|
+
import { useModuleSkeleton, useEnvironment, useModuleDictionary } from "@m4l/core";
|
|
5
|
+
import { SketchPicker } from "react-color";
|
|
6
|
+
import { H as HelperText } from "../../HelperText/index.651a9b4b.js";
|
|
7
|
+
import { generateUtilityClasses, generateUtilityClass, styled, Skeleton } from "@mui/material";
|
|
8
|
+
import { unstable_composeClasses } from "@mui/base";
|
|
9
|
+
import { useTheme } from "@mui/material/styles";
|
|
10
|
+
import { useResponsiveDesktop } from "@m4l/graphics";
|
|
11
|
+
import { c as useFormFocus } from "../../../vendor.3eadfa16.js";
|
|
12
|
+
import { F as FieldLabel } from "../../FieldLabel/index.400a46e0.js";
|
|
13
|
+
import { P as Popover } from "../../mui_extended/Popover/index.8e5ac765.js";
|
|
14
|
+
import { I as Icon } from "../../Icon/index.2e8ec5a1.js";
|
|
15
|
+
import { B as Button } from "../../mui_extended/Button/index.a7dc6ef0.js";
|
|
16
|
+
const componentName = "M4LRHFColorPicker";
|
|
17
|
+
const colorPickerClasses = generateUtilityClasses(componentName, [
|
|
18
|
+
"root",
|
|
19
|
+
"popoverRoot",
|
|
20
|
+
"containerFieldColor",
|
|
21
|
+
"fieldColor",
|
|
22
|
+
"containerPicker",
|
|
23
|
+
"skeleton",
|
|
24
|
+
"sizeSmall",
|
|
25
|
+
"sizeMedium",
|
|
26
|
+
"isFocus",
|
|
27
|
+
"isTabSelected"
|
|
28
|
+
]);
|
|
29
|
+
function getRHFColorPickerUtilityClass(slot) {
|
|
30
|
+
return generateUtilityClass(componentName, slot);
|
|
31
|
+
}
|
|
32
|
+
const useUtilityClasses = (owmerState) => {
|
|
33
|
+
const slots = {
|
|
34
|
+
root: [
|
|
35
|
+
"root",
|
|
36
|
+
owmerState.isFocus && "isFocus",
|
|
37
|
+
owmerState.isTabSelected && "isTabSelected",
|
|
38
|
+
owmerState.size === "small" && "sizeSmall",
|
|
39
|
+
owmerState.size === "medium" && "sizeMedium"
|
|
40
|
+
],
|
|
41
|
+
popoverRoot: ["popoverRoot"],
|
|
42
|
+
containerFieldColor: ["containerFieldColor"],
|
|
43
|
+
fieldColor: ["boxColor"],
|
|
44
|
+
containerPicker: ["containerPicker"],
|
|
45
|
+
skeleton: ["skeleton"]
|
|
46
|
+
};
|
|
47
|
+
const composedClasses = unstable_composeClasses(slots, getRHFColorPickerUtilityClass, {});
|
|
48
|
+
return {
|
|
49
|
+
...composedClasses
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const RHFColorPickerRoot = styled("div")(({ theme }) => ({
|
|
53
|
+
...theme.components?.M4LRHFColorPicker?.styleOverrides
|
|
54
|
+
}));
|
|
55
|
+
const RHFColorPickerSkeleton = (props) => {
|
|
56
|
+
const { label } = props;
|
|
57
|
+
return /* @__PURE__ */ jsxs("div", { className: colorPickerClasses.skeleton, children: [
|
|
58
|
+
label && /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "30%", height: "14px" }),
|
|
59
|
+
/* @__PURE__ */ jsx(
|
|
60
|
+
Skeleton,
|
|
61
|
+
{
|
|
62
|
+
className: colorPickerClasses.skeleton,
|
|
63
|
+
variant: "rectangular",
|
|
64
|
+
width: 20,
|
|
65
|
+
height: 20
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
] });
|
|
69
|
+
};
|
|
70
|
+
const RHFColorPicker = (props) => {
|
|
71
|
+
const { name, size = "small", label, mandatory, mandatoryMessage, helperMessage } = props;
|
|
72
|
+
const { control, setValue, trigger } = useFormContext();
|
|
73
|
+
const isSkeleton = useModuleSkeleton();
|
|
74
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
75
|
+
const { isFocus, isTabSelected, handlerFocus, handlerOnKeyUp, handlerOnBlur } = useFormFocus();
|
|
76
|
+
const theme = useTheme();
|
|
77
|
+
const currentColor = useWatch({
|
|
78
|
+
name,
|
|
79
|
+
control
|
|
80
|
+
});
|
|
81
|
+
const isDesktop = useResponsiveDesktop();
|
|
82
|
+
const [tempColor, setTempColor] = useState(() => currentColor || "#ffffff");
|
|
83
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
84
|
+
const { getLabel } = useModuleDictionary();
|
|
85
|
+
const handleColorChange = (color) => {
|
|
86
|
+
setTempColor(color.hex);
|
|
87
|
+
};
|
|
88
|
+
const handleApprove = () => {
|
|
89
|
+
setAnchorEl(null);
|
|
90
|
+
if (tempColor !== currentColor) {
|
|
91
|
+
setValue(name, tempColor);
|
|
92
|
+
trigger(name);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const ownerState = {
|
|
96
|
+
isFocus: !isSkeleton ? isFocus : false,
|
|
97
|
+
isTabSelected: !isSkeleton ? isTabSelected : false,
|
|
98
|
+
size: isDesktop ? size : "medium"
|
|
99
|
+
};
|
|
100
|
+
const classes = useUtilityClasses(ownerState);
|
|
101
|
+
return /* @__PURE__ */ jsx(
|
|
102
|
+
RHFColorPickerRoot,
|
|
103
|
+
{
|
|
104
|
+
className: classes.root,
|
|
105
|
+
tabIndex: 0,
|
|
106
|
+
onFocus: handlerFocus,
|
|
107
|
+
onBlur: handlerOnBlur,
|
|
108
|
+
onKeyUp: handlerOnKeyUp,
|
|
109
|
+
children: !isSkeleton ? /* @__PURE__ */ jsx(
|
|
110
|
+
Controller,
|
|
111
|
+
{
|
|
112
|
+
name,
|
|
113
|
+
control,
|
|
114
|
+
defaultValue: "",
|
|
115
|
+
render: ({ field: { value }, fieldState: { error } }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
116
|
+
label && /* @__PURE__ */ jsx(
|
|
117
|
+
FieldLabel,
|
|
118
|
+
{
|
|
119
|
+
label,
|
|
120
|
+
mandatory,
|
|
121
|
+
mandatoryMessage,
|
|
122
|
+
helperMessage
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
/* @__PURE__ */ jsxs(
|
|
126
|
+
"div",
|
|
127
|
+
{
|
|
128
|
+
role: "button",
|
|
129
|
+
tabIndex: 0,
|
|
130
|
+
className: classes.containerFieldColor,
|
|
131
|
+
onClick: (event) => setAnchorEl(event.currentTarget),
|
|
132
|
+
children: [
|
|
133
|
+
/* @__PURE__ */ jsx(
|
|
134
|
+
"div",
|
|
135
|
+
{
|
|
136
|
+
className: classes.fieldColor,
|
|
137
|
+
style: {
|
|
138
|
+
backgroundColor: value
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
/* @__PURE__ */ jsx(
|
|
143
|
+
Icon,
|
|
144
|
+
{
|
|
145
|
+
src: `${host_static_assets}/${environment_assets}/frontend/components/rhfcolorpicker/assets/icons/chevron_right.svg`
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
),
|
|
151
|
+
error?.message && /* @__PURE__ */ jsx(HelperText, { variant: "error", message: error?.message + "" }),
|
|
152
|
+
/* @__PURE__ */ jsx(
|
|
153
|
+
Popover,
|
|
154
|
+
{
|
|
155
|
+
open: Boolean(anchorEl),
|
|
156
|
+
arrowType: "top-center",
|
|
157
|
+
className: classes.popoverRoot,
|
|
158
|
+
anchorEl,
|
|
159
|
+
onClose: () => setAnchorEl(null),
|
|
160
|
+
anchorOrigin: {
|
|
161
|
+
vertical: "bottom",
|
|
162
|
+
horizontal: "center"
|
|
163
|
+
},
|
|
164
|
+
transformOrigin: {
|
|
165
|
+
vertical: "top",
|
|
166
|
+
horizontal: "center"
|
|
167
|
+
},
|
|
168
|
+
sx: {
|
|
169
|
+
mt: "12px",
|
|
170
|
+
ml: -1.25,
|
|
171
|
+
...theme.components?.M4LRHFColorPickerPopoverRoot?.styleOverrides
|
|
172
|
+
},
|
|
173
|
+
children: /* @__PURE__ */ jsxs("div", { className: classes.containerPicker, children: [
|
|
174
|
+
/* @__PURE__ */ jsx(SketchPicker, { color: tempColor, onChange: handleColorChange, disableAlpha: true }),
|
|
175
|
+
/* @__PURE__ */ jsx(Button, { variant: "contained", onClick: handleApprove, children: getLabel("rhfcolorpicker.accept") })
|
|
176
|
+
] })
|
|
177
|
+
}
|
|
178
|
+
)
|
|
179
|
+
] })
|
|
180
|
+
}
|
|
181
|
+
) : /* @__PURE__ */ jsx(RHFColorPickerSkeleton, { label })
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
};
|
|
185
|
+
function getRHFColorPickerComponentsDictionary() {
|
|
186
|
+
return ["rhfcolorpicker"];
|
|
187
|
+
}
|
|
188
|
+
export {
|
|
189
|
+
RHFColorPicker as R,
|
|
190
|
+
getRHFColorPickerComponentsDictionary as g
|
|
191
|
+
};
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
3
|
+
import { DateTimePicker } from "@mui/x-date-pickers";
|
|
4
|
+
import { useEnvironment, useModuleSkeleton } from "@m4l/core";
|
|
5
|
+
import { Skeleton, generateUtilityClasses, generateUtilityClass, styled } from "@mui/material";
|
|
6
|
+
import { useFormatter, useResponsiveDesktop } from "@m4l/graphics";
|
|
7
|
+
import { useState, useEffect } from "react";
|
|
8
|
+
import { unstable_composeClasses } from "@mui/base";
|
|
9
|
+
import clsx from "clsx";
|
|
10
|
+
import { H as HelperText } from "../../HelperText/index.651a9b4b.js";
|
|
11
|
+
import { T as TEST_PROP_ID } from "../../areas/constants.630a4f42.js";
|
|
12
|
+
import { c as useFormFocus } from "../../../vendor.3eadfa16.js";
|
|
13
|
+
import { F as FieldLabel } from "../../FieldLabel/index.400a46e0.js";
|
|
14
|
+
import { I as Icon } from "../../Icon/index.2e8ec5a1.js";
|
|
15
|
+
const SkeletonRHFDateTime = (props) => {
|
|
16
|
+
const { skeletonWidth, skeletonHeight, className, label } = props;
|
|
17
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
18
|
+
label && /* @__PURE__ */ jsx(Skeleton, { variant: "text", height: "14px", width: "30%" }),
|
|
19
|
+
/* @__PURE__ */ jsxs("div", { className: className.skeleton, children: [
|
|
20
|
+
/* @__PURE__ */ jsx(Skeleton, { variant: "text", width: skeletonWidth, height: skeletonHeight }),
|
|
21
|
+
/* @__PURE__ */ jsx(Skeleton, { variant: "circular" })
|
|
22
|
+
] })
|
|
23
|
+
] });
|
|
24
|
+
};
|
|
25
|
+
const componentName = "M4LRHFDateTime";
|
|
26
|
+
generateUtilityClasses(componentName, [
|
|
27
|
+
"root",
|
|
28
|
+
"skeleton",
|
|
29
|
+
"small",
|
|
30
|
+
"medium",
|
|
31
|
+
"isFocus",
|
|
32
|
+
"isTabSelected",
|
|
33
|
+
"isDisabled",
|
|
34
|
+
"variantInfo",
|
|
35
|
+
"variantSuccess",
|
|
36
|
+
"variantWarning",
|
|
37
|
+
"variantError"
|
|
38
|
+
]);
|
|
39
|
+
function getRHFCheckboxUtilityClass(slot) {
|
|
40
|
+
return generateUtilityClass(componentName, slot);
|
|
41
|
+
}
|
|
42
|
+
const useUtilityClasses = (ownerState) => {
|
|
43
|
+
const slots = {
|
|
44
|
+
root: [
|
|
45
|
+
"root",
|
|
46
|
+
ownerState.size === "small" && "small",
|
|
47
|
+
ownerState.size === "medium" && "medium",
|
|
48
|
+
ownerState.isFocus && "isFocus",
|
|
49
|
+
ownerState.isTabSelected && "isTabSelected",
|
|
50
|
+
ownerState.disabled && "isDisabled",
|
|
51
|
+
ownerState.variant === "info" && "variantInfo",
|
|
52
|
+
ownerState.variant === "success" && "variantSuccess",
|
|
53
|
+
ownerState.variant === "warning" && "variantWarning",
|
|
54
|
+
ownerState.variant === "error" && "variantError"
|
|
55
|
+
],
|
|
56
|
+
skeleton: ["skeleton"]
|
|
57
|
+
};
|
|
58
|
+
const composedClasses = unstable_composeClasses(slots, getRHFCheckboxUtilityClass, {});
|
|
59
|
+
return {
|
|
60
|
+
...composedClasses
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
const RHFDateTimeRoot = styled("div")(({ theme }) => ({
|
|
64
|
+
...theme.components?.M4LRHFDateTime?.styleOverrides
|
|
65
|
+
}));
|
|
66
|
+
const RHFDATETIME_PREFIX = "RHFDateTime";
|
|
67
|
+
const getNameRHFDateTimeDataTestId = (KEY) => {
|
|
68
|
+
return `${RHFDATETIME_PREFIX}-${KEY}`;
|
|
69
|
+
};
|
|
70
|
+
function RHFDateTime(props) {
|
|
71
|
+
const {
|
|
72
|
+
name: nameRHF,
|
|
73
|
+
disabled,
|
|
74
|
+
size = "small",
|
|
75
|
+
variant,
|
|
76
|
+
skeletonWidth = "50%",
|
|
77
|
+
skeletonHeight = 14,
|
|
78
|
+
className,
|
|
79
|
+
label,
|
|
80
|
+
helperMessage,
|
|
81
|
+
mandatory,
|
|
82
|
+
mandatoryMessage
|
|
83
|
+
} = props;
|
|
84
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
85
|
+
const resourceIcon = () => {
|
|
86
|
+
return /* @__PURE__ */ jsx(
|
|
87
|
+
Icon,
|
|
88
|
+
{
|
|
89
|
+
src: `${host_static_assets}/${environment_assets}/frontend/components/rhfdate/ended_at.svg`
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
const [currentVariant, setCurrentVariant] = useState(void 0);
|
|
94
|
+
const { isFocus, isTabSelected, handlerFocus, handlerOnKeyUp, handlerOnBlur } = useFormFocus();
|
|
95
|
+
const {
|
|
96
|
+
control,
|
|
97
|
+
formState: { errors }
|
|
98
|
+
} = useFormContext();
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (errors[nameRHF]) {
|
|
101
|
+
setCurrentVariant("error");
|
|
102
|
+
} else if (variant) {
|
|
103
|
+
setCurrentVariant(variant);
|
|
104
|
+
} else {
|
|
105
|
+
setCurrentVariant(void 0);
|
|
106
|
+
}
|
|
107
|
+
}, [errors[nameRHF], variant, control]);
|
|
108
|
+
const isSkeleton = useModuleSkeleton();
|
|
109
|
+
const {
|
|
110
|
+
dateFormatter: { datetimeFormat }
|
|
111
|
+
} = useFormatter();
|
|
112
|
+
const isDesktop = useResponsiveDesktop();
|
|
113
|
+
const ownerState = {
|
|
114
|
+
isFocus: !isSkeleton ? isFocus : false,
|
|
115
|
+
isTabSelected: !isSkeleton ? isTabSelected : false,
|
|
116
|
+
disabled,
|
|
117
|
+
size: isDesktop ? size : "medium",
|
|
118
|
+
variant: currentVariant
|
|
119
|
+
};
|
|
120
|
+
const classes = useUtilityClasses(ownerState);
|
|
121
|
+
return /* @__PURE__ */ jsx(
|
|
122
|
+
RHFDateTimeRoot,
|
|
123
|
+
{
|
|
124
|
+
className: clsx(classes.root, className),
|
|
125
|
+
tabIndex: 0,
|
|
126
|
+
onFocus: handlerFocus,
|
|
127
|
+
onBlur: handlerOnBlur,
|
|
128
|
+
onKeyUp: handlerOnKeyUp,
|
|
129
|
+
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameRHFDateTimeDataTestId("root") } : {},
|
|
130
|
+
children: !isSkeleton ? /* @__PURE__ */ jsx(
|
|
131
|
+
Controller,
|
|
132
|
+
{
|
|
133
|
+
name: nameRHF,
|
|
134
|
+
control,
|
|
135
|
+
render: ({ field: { value, onChange, ref }, fieldState: { error } }) => {
|
|
136
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
137
|
+
label && /* @__PURE__ */ jsx(
|
|
138
|
+
FieldLabel,
|
|
139
|
+
{
|
|
140
|
+
label,
|
|
141
|
+
mandatory,
|
|
142
|
+
mandatoryMessage,
|
|
143
|
+
helperMessage
|
|
144
|
+
}
|
|
145
|
+
),
|
|
146
|
+
/* @__PURE__ */ jsx(
|
|
147
|
+
DateTimePicker,
|
|
148
|
+
{
|
|
149
|
+
sx: {
|
|
150
|
+
"& .MuiTouchRipple-root": {
|
|
151
|
+
display: "none"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
inputRef: ref,
|
|
155
|
+
ampm: true,
|
|
156
|
+
value,
|
|
157
|
+
onChange: (newValue) => {
|
|
158
|
+
onChange(newValue);
|
|
159
|
+
},
|
|
160
|
+
slots: {
|
|
161
|
+
openPickerIcon: resourceIcon
|
|
162
|
+
},
|
|
163
|
+
slotProps: {
|
|
164
|
+
textField: {
|
|
165
|
+
onFocus: handlerFocus,
|
|
166
|
+
onBlur: handlerOnBlur
|
|
167
|
+
},
|
|
168
|
+
field: { format: datetimeFormat }
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
),
|
|
172
|
+
error?.message && /* @__PURE__ */ jsx(HelperText, { variant: "error", message: error?.message + "" })
|
|
173
|
+
] });
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
) : /* @__PURE__ */ jsx(
|
|
177
|
+
SkeletonRHFDateTime,
|
|
178
|
+
{
|
|
179
|
+
skeletonWidth,
|
|
180
|
+
skeletonHeight,
|
|
181
|
+
className: classes,
|
|
182
|
+
label
|
|
183
|
+
}
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
export {
|
|
189
|
+
RHFDateTime as R
|
|
190
|
+
};
|