@m4l/components 0.1.27 → 0.1.28
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.228dcb5a.js +42 -35
- package/commonjs.565e6834.js +5 -5
- package/components/CommonActions/components/ActionCancel/index.e498eeb2.js +17 -0
- package/components/CommonActions/components/ActionFormCancel/index.4ff0ad73.js +64 -0
- package/components/CommonActions/components/ActionFormIntro/index.ca4d2674.js +28 -22
- package/components/CommonActions/components/ActionIntro/index.60ef7bd7.js +18 -0
- package/components/CommonActions/components/Actions/index.0645e30f.js +867 -0
- package/components/DataGrid/index.76d8fd25.js +1075 -0
- package/components/DynamicFilter/index.342ba5fe.js +1577 -0
- package/components/ErrorLabel/index.c8615f16.js +13 -12
- package/components/Icon/index.619c31c4.js +65 -53
- package/components/Image/index.93d5f37f.js +190 -0
- package/components/Loadable/index.f5518558.js +8 -8
- package/components/ModalDialog/index.9ea10764.js +184 -0
- package/components/NoItemSelected/{index.9609a7f7.js → index.46d2f632.js} +52 -41
- package/components/ObjectLogs/index.f941fb79.js +288 -0
- package/components/Page/index.4237c241.js +22 -20
- package/components/PaperForm/index.ec9cb8c9.js +66 -59
- package/components/Period/index.2941fbda.js +249 -0
- package/components/PropertyValue/index.dfcfe1ba.js +95 -65
- package/components/Resizeable/index.45995d2b.js +19 -19
- package/components/ScrollBar/index.39eeb2de.js +26 -21
- package/components/ScrollToTop/index.e06f98f6.js +8 -7
- package/components/SplitLayout/index.4032673d.js +35 -33
- package/components/animate/LoadingScreen/index.1d0c4307.js +33 -33
- package/components/animate/MotionContainer/index.8d9f9d80.js +25 -22
- package/components/animate/MotionLazyContainer/index.572dd012.js +10 -10
- package/components/animate/features.0fbf41e1.js +3 -3
- package/components/animate/variants/bounce.784aaaaa.js +16 -13
- package/components/animate/variants/container.11f82b76.js +8 -6
- package/components/animate/variants/fade.b561c0fc.js +32 -28
- package/components/animate/variants/transition.bd46b9ce.js +17 -12
- package/components/formatters/BooleanFormatter/index.8da35c9c.js +46 -33
- package/components/formatters/DateFormatter/index.1b9baacc.js +49 -37
- package/components/formatters/index.689a8086.js +119 -0
- package/components/hook-form/RHFAutocomplete/index.59a68f9f.js +224 -0
- package/components/hook-form/RHFAutocompleteAsync/index.c3083062.js +87 -0
- package/components/hook-form/RHFCheckbox/index.6dcec9e2.js +49 -39
- package/components/hook-form/RHFDateTime/index.9231a7c7.js +69 -56
- package/components/hook-form/RHFMultiCheckbox/index.2680b3b6.js +23 -23
- package/components/hook-form/RHFPeriod/index.64a228d5.js +55 -0
- package/components/hook-form/RHFRadioGroup/index.b3335e13.js +29 -29
- package/components/hook-form/RHFSelect/index.b6ca8bb2.js +24 -24
- package/components/hook-form/RHFTextField/index.f9aaaa90.js +110 -93
- package/components/hook-form/RHFUpload/{index.ec4d5326.js → index.d5cc7c13.js} +151 -130
- package/components/mui_extended/Accordion/index.a02ac6ae.js +73 -69
- package/components/mui_extended/Avatar/index.fe06afd7.js +44 -34
- package/components/mui_extended/BoxIcon/index.e638ecc8.js +10 -10
- package/components/mui_extended/Breadcrumbs/index.5e37d903.js +49 -44
- package/components/mui_extended/Button/index.53b56958.js +178 -0
- package/components/mui_extended/CircularProgress/index.ad569afd.js +8 -6
- package/components/mui_extended/IconButton/index.a321e5cb.js +82 -67
- package/components/mui_extended/LinkWithRoute/index.16436ab8.js +25 -21
- package/components/mui_extended/Pager/index.c0865b70.js +141 -0
- package/components/mui_extended/Popover/index.705275a4.js +278 -0
- package/components/mui_extended/Tab/index.e0653a0a.js +25 -21
- package/components/mui_extended/Typography/index.e5494696.js +25 -21
- package/contexts/ModalContext/index.b92fa565.js +153 -0
- package/contexts/ModalContext/{components → subcomponents}/ContentConfirm/index.d.ts +0 -0
- package/contexts/ModalContext/{components → subcomponents}/ContentConfirm/styles.d.ts +0 -0
- package/contexts/ModalContext/{components → subcomponents}/ContentConfirm/types.d.ts +0 -0
- package/contexts/RHFormContext/index.b142190a.js +63 -0
- package/hooks/useFormAddEdit/index.d4845f1a.js +40 -22
- package/hooks/useModal/index.5fee01a3.js +11 -0
- package/index.js +153 -153
- package/package.json +2 -1
- package/react-data-grid.d46d625e.js +2206 -1663
- package/react-draggable.20e95c61.js +800 -553
- package/react-json-view.f56a7f8e.js +2344 -2340
- package/react-resizable.5277deaf.js +470 -298
- package/react-splitter-layout.7810ac1b.js +130 -128
- package/utils/index.214d9542.js +500 -354
- package/components/CommonActions/components/ActionCancel/index.431160ba.js +0 -17
- package/components/CommonActions/components/ActionFormCancel/index.6a0f34aa.js +0 -49
- package/components/CommonActions/components/ActionIntro/index.85557b90.js +0 -18
- package/components/CommonActions/components/Actions/index.edeb05c2.js +0 -742
- package/components/DataGrid/index.2ce9da7d.js +0 -894
- package/components/DynamicFilter/index.e1d4a948.js +0 -1157
- package/components/Image/index.c9da2d5a.js +0 -152
- package/components/ModalDialog/index.ad61757f.js +0 -168
- package/components/ObjectLogs/index.6ebaec71.js +0 -266
- package/components/Period/index.81de7941.js +0 -175
- package/components/contexts/RHFormContext/index.33dba822.js +0 -56
- package/components/formatters/index.c2a9b55d.js +0 -106
- package/components/hook-form/RHFAutocomplete/index.5eee9d7c.js +0 -174
- package/components/hook-form/RHFAutocompleteAsync/index.757b5080.js +0 -65
- package/components/hook-form/RHFPeriod/index.e08fb1ab.js +0 -51
- package/components/mui_extended/Button/index.51dae0bb.js +0 -144
- package/components/mui_extended/Pager/index.1dc45f5e.js +0 -126
- package/components/mui_extended/Popover/index.cb2ccc66.js +0 -252
- package/contexts/ModalContext/index.9ebc793c.js +0 -136
- package/hooks/useModal/index.34f5978e.js +0 -11
- package/node_modules.168cb897.js +0 -55
|
@@ -1,28 +1,32 @@
|
|
|
1
|
-
import { useModuleSkeleton
|
|
2
|
-
import { Skeleton
|
|
3
|
-
import { styled
|
|
4
|
-
import { jsx
|
|
5
|
-
const
|
|
6
|
-
theme
|
|
1
|
+
import { useModuleSkeleton } from "@m4l/core";
|
|
2
|
+
import { Skeleton, Tab as Tab$1 } from "@mui/material";
|
|
3
|
+
import { styled } from "@mui/material/styles";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
const SKTTabWrapper = styled("div")(({
|
|
6
|
+
theme
|
|
7
7
|
}) => ({
|
|
8
|
-
padding:
|
|
8
|
+
padding: theme.spacing(1.5, 2)
|
|
9
9
|
}));
|
|
10
|
-
function
|
|
10
|
+
function Tab(props) {
|
|
11
11
|
const {
|
|
12
|
-
SKTWidth
|
|
13
|
-
SKTHeight
|
|
14
|
-
...
|
|
15
|
-
} =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
SKTWidth,
|
|
13
|
+
SKTHeight,
|
|
14
|
+
...other
|
|
15
|
+
} = props;
|
|
16
|
+
const isSkeleton = useModuleSkeleton();
|
|
17
|
+
if (isSkeleton) {
|
|
18
|
+
return /* @__PURE__ */ jsx(SKTTabWrapper, {
|
|
19
|
+
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
20
|
+
variant: "text",
|
|
21
|
+
width: SKTWidth,
|
|
22
|
+
height: SKTHeight
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return /* @__PURE__ */ jsx(Tab$1, {
|
|
27
|
+
...other
|
|
24
28
|
});
|
|
25
29
|
}
|
|
26
30
|
export {
|
|
27
|
-
|
|
31
|
+
Tab as T
|
|
28
32
|
};
|
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
import { useModuleSkeleton
|
|
2
|
-
import { Skeleton
|
|
3
|
-
import { jsx
|
|
4
|
-
const
|
|
1
|
+
import { useModuleSkeleton } from "@m4l/core";
|
|
2
|
+
import { Skeleton, Typography as Typography$1 } from "@mui/material";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
const SkeletonTypography = (props) => {
|
|
5
5
|
const {
|
|
6
|
-
skeletonWidth
|
|
7
|
-
skeletongHeight
|
|
8
|
-
} =
|
|
9
|
-
return /* @__PURE__ */
|
|
6
|
+
skeletonWidth,
|
|
7
|
+
skeletongHeight
|
|
8
|
+
} = props;
|
|
9
|
+
return /* @__PURE__ */ jsx(Skeleton, {
|
|
10
10
|
variant: "text",
|
|
11
|
-
width:
|
|
12
|
-
height:
|
|
11
|
+
width: skeletonWidth,
|
|
12
|
+
height: skeletongHeight
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
|
-
function
|
|
15
|
+
function Typography(props) {
|
|
16
16
|
const {
|
|
17
|
-
skeletonWidth
|
|
18
|
-
skeletongHeight
|
|
19
|
-
...
|
|
20
|
-
} =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
skeletonWidth = "100%",
|
|
18
|
+
skeletongHeight = "18px",
|
|
19
|
+
...other
|
|
20
|
+
} = props;
|
|
21
|
+
const isSkeleton = useModuleSkeleton();
|
|
22
|
+
if (isSkeleton) {
|
|
23
|
+
return /* @__PURE__ */ jsx(SkeletonTypography, {
|
|
24
|
+
skeletonWidth,
|
|
25
|
+
skeletongHeight
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return /* @__PURE__ */ jsx(Typography$1, {
|
|
25
29
|
className: "m4l_typography",
|
|
26
|
-
...
|
|
30
|
+
...other
|
|
27
31
|
});
|
|
28
32
|
}
|
|
29
33
|
export {
|
|
30
|
-
|
|
34
|
+
Typography as T
|
|
31
35
|
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { createContext, useState } from "react";
|
|
2
|
+
import { useEnvironment, voidFunction } from "@m4l/core";
|
|
3
|
+
import { Typography } from "@mui/material";
|
|
4
|
+
import { styled } from "@mui/material/styles";
|
|
5
|
+
import { B as BoxIcon } from "../../components/mui_extended/BoxIcon/index.e638ecc8.js";
|
|
6
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
7
|
+
import { M as ModalDialog } from "../../components/ModalDialog/index.9ea10764.js";
|
|
8
|
+
import { A as ActionIntro } from "../../components/CommonActions/components/ActionIntro/index.60ef7bd7.js";
|
|
9
|
+
import { A as ActionCancel } from "../../components/CommonActions/components/ActionCancel/index.e498eeb2.js";
|
|
10
|
+
import { b as getVariantColor } from "../../utils/index.214d9542.js";
|
|
11
|
+
const WrapperContentConfirm = styled("div")(() => ({
|
|
12
|
+
display: "flex",
|
|
13
|
+
flexDirection: "column",
|
|
14
|
+
height: "100%"
|
|
15
|
+
}));
|
|
16
|
+
const ModalContent = styled("div")(({
|
|
17
|
+
theme
|
|
18
|
+
}) => ({
|
|
19
|
+
display: "flex",
|
|
20
|
+
flexDirection: "column",
|
|
21
|
+
justifyContent: "center",
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
gridGap: theme.spacing(5),
|
|
24
|
+
flexGrow: 1,
|
|
25
|
+
[theme.breakpoints.up("sm")]: {
|
|
26
|
+
display: "grid",
|
|
27
|
+
flexDirection: "row",
|
|
28
|
+
gridTemplateColumns: "1fr 1fr"
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
const IllustrationContainer = styled("div")(({
|
|
32
|
+
theme,
|
|
33
|
+
variant
|
|
34
|
+
}) => ({
|
|
35
|
+
display: "flex",
|
|
36
|
+
justifyContent: "center",
|
|
37
|
+
alignItems: "center",
|
|
38
|
+
"& > span": {
|
|
39
|
+
background: variant === "warning" ? theme.palette.warning.main : variant === "delete" ? theme.palette.error.main : variant === "info" ? theme.palette.info.main : "theme.palette.text.primary"
|
|
40
|
+
}
|
|
41
|
+
}));
|
|
42
|
+
const MessageContainer = styled("div")(() => ({
|
|
43
|
+
display: "flex",
|
|
44
|
+
alignItems: "center"
|
|
45
|
+
}));
|
|
46
|
+
const ContentConfirm = (props) => {
|
|
47
|
+
const {
|
|
48
|
+
variant = "info",
|
|
49
|
+
msg = "Are you sure you want to perform this action? Once complete, the information will be deleted."
|
|
50
|
+
} = props;
|
|
51
|
+
const {
|
|
52
|
+
host_static_assets,
|
|
53
|
+
environment_assets
|
|
54
|
+
} = useEnvironment();
|
|
55
|
+
const illustrationWarning = `${host_static_assets}/${environment_assets}/frontend/components/dialog/assets/icons/illustration_confirm_warning.svg`;
|
|
56
|
+
const illustrationError = `${host_static_assets}/${environment_assets}/frontend/components/dialog/assets/icons/illustration_confirm_danger.svg`;
|
|
57
|
+
const illustrationInfo = `${host_static_assets}/${environment_assets}/frontend/components/dialog/assets/icons/illustration_confirm_info.svg`;
|
|
58
|
+
return /* @__PURE__ */ jsx(WrapperContentConfirm, {
|
|
59
|
+
children: /* @__PURE__ */ jsxs(ModalContent, {
|
|
60
|
+
children: [/* @__PURE__ */ jsx(IllustrationContainer, {
|
|
61
|
+
variant,
|
|
62
|
+
children: /* @__PURE__ */ jsx(BoxIcon, {
|
|
63
|
+
src: variant === "warning" ? illustrationWarning : variant === "delete" ? illustrationError : illustrationInfo,
|
|
64
|
+
sx: {
|
|
65
|
+
width: "230px",
|
|
66
|
+
height: "194px"
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
}), /* @__PURE__ */ jsx(MessageContainer, {
|
|
70
|
+
children: /* @__PURE__ */ jsx(Typography, {
|
|
71
|
+
variant: "body1",
|
|
72
|
+
children: msg
|
|
73
|
+
})
|
|
74
|
+
})]
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const ModalContext = createContext(null);
|
|
79
|
+
function ModalProvider({
|
|
80
|
+
children
|
|
81
|
+
}) {
|
|
82
|
+
const [modalOptions, setModalOptions] = useState({
|
|
83
|
+
open: false,
|
|
84
|
+
withClose: true,
|
|
85
|
+
onQueryClose: voidFunction,
|
|
86
|
+
title: "",
|
|
87
|
+
iconComponent: void 0,
|
|
88
|
+
contentComponent: void 0,
|
|
89
|
+
variant: void 0
|
|
90
|
+
});
|
|
91
|
+
const [hasChanges, setHasChanges] = useState(false);
|
|
92
|
+
const openModal = (modalOpenProps) => {
|
|
93
|
+
setModalOptions({
|
|
94
|
+
open: true,
|
|
95
|
+
...modalOpenProps
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
const openModalConfirm = (modalOpenConfirmProps) => {
|
|
99
|
+
const {
|
|
100
|
+
variant = "warning",
|
|
101
|
+
title,
|
|
102
|
+
msg,
|
|
103
|
+
onClickIntro,
|
|
104
|
+
onClickCancel = closeModal
|
|
105
|
+
} = modalOpenConfirmProps;
|
|
106
|
+
const onClickIntroClose = () => {
|
|
107
|
+
onClickIntro && onClickIntro();
|
|
108
|
+
closeModal();
|
|
109
|
+
};
|
|
110
|
+
setModalOptions({
|
|
111
|
+
open: true,
|
|
112
|
+
title,
|
|
113
|
+
variant,
|
|
114
|
+
contentComponent: /* @__PURE__ */ jsx(ContentConfirm, {
|
|
115
|
+
variant,
|
|
116
|
+
msg
|
|
117
|
+
}),
|
|
118
|
+
actions: /* @__PURE__ */ jsxs(Fragment, {
|
|
119
|
+
children: [/* @__PURE__ */ jsx(ActionCancel, {
|
|
120
|
+
onClick: onClickCancel
|
|
121
|
+
}), " ", /* @__PURE__ */ jsx(ActionIntro, {
|
|
122
|
+
onClick: onClickIntroClose,
|
|
123
|
+
color: getVariantColor(variant)
|
|
124
|
+
})]
|
|
125
|
+
})
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
const closeModal = () => {
|
|
129
|
+
setModalOptions((last) => ({
|
|
130
|
+
...last,
|
|
131
|
+
open: false
|
|
132
|
+
}));
|
|
133
|
+
setHasChanges(false);
|
|
134
|
+
};
|
|
135
|
+
const setChanges = () => {
|
|
136
|
+
setHasChanges(true);
|
|
137
|
+
};
|
|
138
|
+
return /* @__PURE__ */ jsxs(ModalContext.Provider, {
|
|
139
|
+
value: {
|
|
140
|
+
...modalOptions,
|
|
141
|
+
openModal,
|
|
142
|
+
openModalConfirm,
|
|
143
|
+
closeModal,
|
|
144
|
+
hasChanges,
|
|
145
|
+
setChanges
|
|
146
|
+
},
|
|
147
|
+
children: [children, /* @__PURE__ */ jsx(ModalDialog, {})]
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
export {
|
|
151
|
+
ModalContext as M,
|
|
152
|
+
ModalProvider as a
|
|
153
|
+
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { useForm, FormProvider } from "react-hook-form";
|
|
3
|
+
import { yupResolver } from "@hookform/resolvers/yup";
|
|
4
|
+
import { styled } from "@mui/material/styles";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
const WrapperFormProvider = styled("form")(({
|
|
7
|
+
theme
|
|
8
|
+
}) => ({
|
|
9
|
+
display: "flex",
|
|
10
|
+
marginBottom: theme.spacing(1),
|
|
11
|
+
flexDirection: "column",
|
|
12
|
+
width: "100%",
|
|
13
|
+
overflow: "auto",
|
|
14
|
+
maxWidth: theme.stretch ? "unset" : "900px",
|
|
15
|
+
padding: theme.spacing(3)
|
|
16
|
+
}));
|
|
17
|
+
function RHFormProvider(props) {
|
|
18
|
+
const {
|
|
19
|
+
children,
|
|
20
|
+
onSubmit,
|
|
21
|
+
values,
|
|
22
|
+
validationSchema,
|
|
23
|
+
statusLoad = "ready"
|
|
24
|
+
} = props;
|
|
25
|
+
const methods = useForm({
|
|
26
|
+
resolver: yupResolver(validationSchema),
|
|
27
|
+
defaultValues: values
|
|
28
|
+
});
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (statusLoad === "reload_values_provider") {
|
|
31
|
+
const keys = Object.keys(values);
|
|
32
|
+
keys.forEach((key) => {
|
|
33
|
+
methods.setValue(key, values[key], {
|
|
34
|
+
shouldValidate: false,
|
|
35
|
+
shouldDirty: false,
|
|
36
|
+
shouldTouch: false
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
}, [methods, statusLoad, values]);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (statusLoad === "ready") {
|
|
44
|
+
console.log("useEffect FormProvider Ready", statusLoad);
|
|
45
|
+
methods.setValue("statusLoad", "ready", {
|
|
46
|
+
shouldValidate: false,
|
|
47
|
+
shouldDirty: false,
|
|
48
|
+
shouldTouch: false
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}, [statusLoad]);
|
|
52
|
+
return /* @__PURE__ */ jsx(FormProvider, {
|
|
53
|
+
...methods,
|
|
54
|
+
children: /* @__PURE__ */ jsx(WrapperFormProvider, {
|
|
55
|
+
id: "formProvider",
|
|
56
|
+
onSubmit: methods.handleSubmit(onSubmit),
|
|
57
|
+
children
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
RHFormProvider as R
|
|
63
|
+
};
|
|
@@ -1,26 +1,44 @@
|
|
|
1
|
-
import { useNetwork
|
|
2
|
-
import { useState
|
|
3
|
-
const
|
|
4
|
-
const { initialValues
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { useNetwork, useFlags } from "@m4l/core";
|
|
2
|
+
import { useState, useEffect } from "react";
|
|
3
|
+
const useFormAddEdit = (props) => {
|
|
4
|
+
const { initialValues, objectId, endPoint, formatDataEnpoint } = props;
|
|
5
|
+
const [formValues, setFormValues] = useState(initialValues);
|
|
6
|
+
const [statusLoad, setStatusLoad] = useState(
|
|
7
|
+
objectId === void 0 ? "new" : "edit"
|
|
8
|
+
);
|
|
9
|
+
const { networkOperation } = useNetwork();
|
|
10
|
+
const { addFlag } = useFlags();
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
let mounted = true;
|
|
13
|
+
if (statusLoad === "edit") {
|
|
14
|
+
networkOperation({
|
|
15
|
+
method: "GET",
|
|
16
|
+
endPoint: `${endPoint}/${objectId}`
|
|
17
|
+
}).then(
|
|
18
|
+
(response) => {
|
|
19
|
+
if (mounted) {
|
|
20
|
+
if (formatDataEnpoint) {
|
|
21
|
+
setFormValues(formatDataEnpoint(response));
|
|
22
|
+
} else {
|
|
23
|
+
setFormValues(response);
|
|
24
|
+
}
|
|
25
|
+
setStatusLoad("reload_values_provider");
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
() => {
|
|
29
|
+
setStatusLoad("error");
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
} else if (statusLoad === "new" || statusLoad === "reload_values_provider") {
|
|
33
|
+
addFlag("form_loaded");
|
|
34
|
+
setStatusLoad("ready");
|
|
35
|
+
}
|
|
36
|
+
return () => {
|
|
37
|
+
mounted = false;
|
|
21
38
|
};
|
|
22
|
-
}, [
|
|
39
|
+
}, [statusLoad]);
|
|
40
|
+
return { formValues, statusLoad };
|
|
23
41
|
};
|
|
24
42
|
export {
|
|
25
|
-
|
|
43
|
+
useFormAddEdit as u
|
|
26
44
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { M as ModalContext } from "../../contexts/ModalContext/index.b92fa565.js";
|
|
3
|
+
function useModal() {
|
|
4
|
+
const context = useContext(ModalContext);
|
|
5
|
+
if (!context)
|
|
6
|
+
throw new Error("useModal context must be use inside ModalContext");
|
|
7
|
+
return context;
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
useModal as u
|
|
11
|
+
};
|