@m4l/components 0.1.7 → 0.1.9
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/commonjs.js +1 -1
- package/components/CommonActions/components/Actions/index.js +42 -41
- package/components/DataGrid/components/editors/TextEditor/index.d.ts +6 -0
- package/components/DataGrid/formatters/columnNestedValueFormatter/index.d.ts +3 -0
- package/components/DataGrid/formatters/columnNestedValueFormatter/types.d.ts +5 -0
- package/components/DataGrid/formatters/columnPointsFormatter/index.d.ts +3 -0
- package/components/DataGrid/formatters/columnPointsFormatter/types.d.ts +6 -0
- package/components/DataGrid/formatters/columnUncertaintyFormatter/index.d.ts +3 -0
- package/components/DataGrid/formatters/columnUncertaintyFormatter/types.d.ts +7 -0
- package/components/DataGrid/formatters/index.d.ts +4 -0
- package/components/DataGrid/index.js +66 -4
- package/components/DataGrid/types.d.ts +5 -2
- package/components/DynamicFilter/index.js +8 -7
- package/components/ErrorLabel/index.d.ts +3 -0
- package/components/ErrorLabel/styles.d.ts +2 -0
- package/components/ErrorLabel/types.d.ts +3 -0
- package/components/LanguagePopover/index.js +3 -1
- package/components/ModalDialog/index.js +1 -1
- package/components/NoItemSelected/index.d.ts +1 -2
- package/components/NoItemSelected/index.js +3 -5
- package/components/PaperForm/components/Header.d.ts +3 -0
- package/components/PaperForm/index.js +39 -47
- package/components/PaperForm/styles.d.ts +2 -3
- package/components/PaperForm/types.d.ts +2 -2
- package/components/PropertyValue/index.js +38 -26
- package/components/PropertyValue/styles.d.ts +3 -4
- package/components/PropertyValue/types.d.ts +8 -9
- package/components/animate/variants/bounce.d.ts +1 -1
- package/components/animate/variants/container.d.ts +1 -1
- package/components/animate/variants/fade.d.ts +1 -1
- package/components/animate/variants/transition.d.ts +3 -3
- package/components/formatters/BooleanFormatter/index.js +4 -3
- package/components/formatters/BooleanFormatter/types.d.ts +1 -1
- package/components/formatters/PointsFormatter/index.d.ts +3 -0
- package/components/formatters/PointsFormatter/types.d.ts +7 -0
- package/components/formatters/PriceFormatter/index.d.ts +3 -0
- package/components/formatters/PriceFormatter/types.d.ts +5 -0
- package/components/formatters/UncertaintyFormatter/index.d.ts +3 -0
- package/components/formatters/UncertaintyFormatter/types.d.ts +14 -0
- package/components/formatters/index.d.ts +4 -0
- package/components/formatters/index.js +100 -4
- package/components/hook-form/FormProvider/index.js +19 -7
- package/components/hook-form/FormProvider/types.d.ts +4 -1
- package/components/hook-form/RHFAutocomplete/index.js +4 -2
- package/components/hook-form/RHFAutocomplete/types.d.ts +0 -1
- package/components/hook-form/RHFAutocompleteAsync/index.js +15 -5
- package/components/hook-form/RHFAutocompleteAsync/types.d.ts +1 -2
- package/components/hook-form/RHFCheckbox/index.d.ts +2 -1
- package/components/hook-form/RHFCheckbox/index.js +51 -30
- package/components/hook-form/RHFCheckbox/styles.d.ts +12 -1
- package/components/hook-form/RHFCheckbox/types.d.ts +0 -1
- package/components/hook-form/RHFDateTime/index.js +2 -2
- package/components/hook-form/RHFDateTime/types.d.ts +0 -1
- package/components/hook-form/RHFPeriod/dictionary.d.ts +3 -0
- package/components/hook-form/RHFPeriod/index.d.ts +3 -0
- package/components/hook-form/RHFPeriod/styles.d.ts +6 -0
- package/components/hook-form/RHFPeriod/types.d.ts +29 -0
- package/components/hook-form/RHFTextField/index.js +41 -17
- package/components/hook-form/RHFTextField/types.d.ts +0 -1
- package/components/hook-form/RHFUpload/index.js +5 -5
- package/components/hook-form/index.d.ts +4 -0
- package/components/index.d.ts +5 -1
- package/components/mui_extended/Accordion/components/AccordionLabel.d.ts +3 -0
- package/components/mui_extended/Accordion/index.js +74 -14
- package/components/mui_extended/Accordion/styles.d.ts +4 -0
- package/components/mui_extended/Accordion/types.d.ts +4 -1
- package/components/mui_extended/Button/index.js +25 -25
- package/components/mui_extended/Tab/index.d.ts +2 -1
- package/components/mui_extended/Tab/index.js +2 -1
- package/components/mui_extended/Tab/types.d.ts +5 -0
- package/components/mui_extended/index.d.ts +1 -0
- package/hooks/index.d.ts +2 -0
- package/hooks/useFormAddEdit/index.d.ts +6 -0
- package/hooks/useFormAddEdit/types.d.ts +8 -0
- package/index.d.ts +1 -1
- package/index.js +290 -20
- package/package.json +3 -3
- package/utils/index.js +0 -1
- package/components/NoItemSelected/types.d.ts +0 -10
- package/components/PaperForm/skeleton.d.ts +0 -6
- package/components/hook-form/RHFCheckbox/skeleton.d.ts +0 -2
package/index.js
CHANGED
|
@@ -1,40 +1,43 @@
|
|
|
1
1
|
export { I as IconButton, a as IconButtonAnimate } from "./components/mui_extended/IconButton/index.js";
|
|
2
2
|
import "framer-motion";
|
|
3
|
-
import "@mui/material";
|
|
4
|
-
import "react/jsx-runtime";
|
|
3
|
+
import { styled, Skeleton, Autocomplete, TextField } from "@mui/material";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
export { L as LoadingScreen } from "./components/animate/LoadingScreen/index.js";
|
|
6
|
-
import "react";
|
|
7
|
-
import "react-hook-form";
|
|
6
|
+
import { useMemo, useState, useEffect } from "react";
|
|
7
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
8
8
|
export { F as FormProvider } from "./components/hook-form/FormProvider/index.js";
|
|
9
|
-
import "@m4l/core";
|
|
9
|
+
import { useModuleDictionary, useModuleSkeleton, useEnvironment, useNetwork, useFlags } from "@m4l/core";
|
|
10
10
|
export { R as RHFAutocomplete } from "./components/hook-form/RHFAutocomplete/index.js";
|
|
11
11
|
export { R as RHFAutocompleteAsync } from "./components/hook-form/RHFAutocompleteAsync/index.js";
|
|
12
12
|
export { R as RHFCheckbox } from "./components/hook-form/RHFCheckbox/index.js";
|
|
13
13
|
export { R as RHFDateTime } from "./components/hook-form/RHFDateTime/index.js";
|
|
14
14
|
import "@mui/x-date-pickers";
|
|
15
15
|
export { R as RHFTextField } from "./components/hook-form/RHFTextField/index.js";
|
|
16
|
+
import { I as Icon } from "./components/Icon/index.js";
|
|
17
|
+
export { I as Icon } from "./components/Icon/index.js";
|
|
18
|
+
import "@mui/material/styles";
|
|
19
|
+
import { g as getCommonActionsDictionary } from "./components/CommonActions/components/Actions/index.js";
|
|
20
|
+
export { b as Actions, M as MenuActions, d as defaultCommonActionsDictionary, g as getCommonActionsDictionary } from "./components/CommonActions/components/Actions/index.js";
|
|
21
|
+
import "@mui/material/Button";
|
|
22
|
+
export { B as Button, L as LoadingButton } from "./components/mui_extended/Button/index.js";
|
|
23
|
+
import "react-router-dom";
|
|
24
|
+
export { M as ModalContext, a as ModalProvider } from "./contexts/ModalContext/index.js";
|
|
25
|
+
import "@mui/lab";
|
|
16
26
|
import "./lodash.js";
|
|
17
27
|
import "react-dropzone";
|
|
18
|
-
import "@mui/material/styles";
|
|
19
28
|
import "./react-lazy-load-image-component.js";
|
|
20
29
|
export { I as Image } from "./components/Image/index.js";
|
|
21
30
|
export { R as RHFUploadImage } from "./components/hook-form/RHFUpload/index.js";
|
|
22
|
-
export {
|
|
31
|
+
export { A as Accordion } from "./components/mui_extended/Accordion/index.js";
|
|
23
32
|
export { A as Avatar } from "./components/mui_extended/Avatar/index.js";
|
|
24
|
-
import "react-router-dom";
|
|
25
|
-
import "@mui/lab";
|
|
26
|
-
export { L as LoadingButton } from "./components/mui_extended/Button/index.js";
|
|
27
33
|
export { M as MenuPopover } from "./components/mui_extended/MenuPopover/index.js";
|
|
28
|
-
export { b as Actions, M as MenuActions, d as defaultCommonActionsDictionary, g as getCommonActionsDictionary } from "./components/CommonActions/components/Actions/index.js";
|
|
29
34
|
export { P as Pager, g as getPagerComponentsDictionary } from "./components/mui_extended/Pager/index.js";
|
|
30
35
|
export { T as Tab } from "./components/mui_extended/Tab/index.js";
|
|
31
36
|
import "@m4l/graphics";
|
|
32
37
|
export { C as CompanyLogo } from "./components/CompanyLogo/index.js";
|
|
33
|
-
export { D as DataGrid, g as getGridComponentsDictionary } from "./components/DataGrid/index.js";
|
|
38
|
+
export { D as DataGrid, N as NumberEditor, T as TextEditor, g as getGridComponentsDictionary } from "./components/DataGrid/index.js";
|
|
34
39
|
import "react-dnd";
|
|
35
40
|
import "react-dnd-html5-backend";
|
|
36
|
-
export { M as ModalContext, a as ModalProvider } from "./contexts/ModalContext/index.js";
|
|
37
|
-
import "@mui/material/Button";
|
|
38
41
|
export { S as ScrollBar } from "./components/ScrollBar/index.js";
|
|
39
42
|
export { D as DynamicFilter, d as defaultDynamicFilterDictionary, g as getDynamicFilterComponentsDictionary } from "./components/DynamicFilter/index.js";
|
|
40
43
|
import "simplebar/dist/simplebar.min.css";
|
|
@@ -59,14 +62,13 @@ export { M as MotionLazyContainer } from "./components/animate/MotionLazyContain
|
|
|
59
62
|
export { R as RHFMultiCheckbox } from "./components/hook-form/RHFMultiCheckbox/index.js";
|
|
60
63
|
export { R as RHFSelect } from "./components/hook-form/RHFSelect/index.js";
|
|
61
64
|
export { R as RHFRadioGroup } from "./components/hook-form/RHFRadioGroup/index.js";
|
|
62
|
-
export { A as Accordion } from "./components/mui_extended/Accordion/index.js";
|
|
63
65
|
export { B as BoxIcon } from "./components/mui_extended/BoxIcon/index.js";
|
|
64
66
|
export { B as Breadcrumbs } from "./components/mui_extended/Breadcrumbs/index.js";
|
|
65
67
|
export { L as LinkWithRoute } from "./components/mui_extended/LinkWithRoute/index.js";
|
|
66
68
|
export { T as Typography } from "./components/mui_extended/Typography/index.js";
|
|
67
69
|
export { B as BooleanFormatter } from "./components/formatters/BooleanFormatter/index.js";
|
|
68
70
|
export { D as DateFormatter } from "./components/formatters/DateFormatter/index.js";
|
|
69
|
-
export { d as defaultFormattersDictionary, g as getFormattersComponentsDictionary } from "./components/formatters/index.js";
|
|
71
|
+
export { P as PointsFormatter, a as PriceFormatter, U as UncertaintyFormatter, e as columnNestedValueFormatter, b as columnPointsFormatter, c as columnUncertaintyFormatter, d as defaultFormattersDictionary, g as getFormattersComponentsDictionary } from "./components/formatters/index.js";
|
|
70
72
|
export { A as ActionCancel } from "./components/CommonActions/components/ActionCancel/index.js";
|
|
71
73
|
export { A as ActionIntro } from "./components/CommonActions/components/ActionIntro/index.js";
|
|
72
74
|
export { A as ActionFormCancel } from "./components/CommonActions/components/ActionFormCancel/index.js";
|
|
@@ -76,13 +78,281 @@ export { S as ScrollToTop } from "./components/ScrollToTop/index.js";
|
|
|
76
78
|
export { u as useModal } from "./hooks/useModal/index.js";
|
|
77
79
|
export { L as Logo } from "./assets/Logo/index.js";
|
|
78
80
|
import "./node_modules.js";
|
|
79
|
-
import "./commonjs.js";
|
|
80
|
-
import "react-dom";
|
|
81
|
-
import "prop-types";
|
|
82
|
-
import "clsx";
|
|
83
81
|
import "./utils/index.js";
|
|
84
82
|
import "./react-data-grid.js";
|
|
83
|
+
import "clsx";
|
|
84
|
+
import "./commonjs.js";
|
|
85
|
+
import "prop-types";
|
|
86
|
+
import "react-dom";
|
|
85
87
|
import "simplebar-react";
|
|
86
88
|
import "yup";
|
|
89
|
+
import "./index.js";
|
|
87
90
|
import "./react-resizable.js";
|
|
88
91
|
import "react-helmet-async";
|
|
92
|
+
const Wrapper$1 = styled("div")(({
|
|
93
|
+
theme
|
|
94
|
+
}) => ({
|
|
95
|
+
width: "100%",
|
|
96
|
+
display: "flex",
|
|
97
|
+
flexDirection: "column",
|
|
98
|
+
justifyContent: "center",
|
|
99
|
+
alignItems: "flex-start",
|
|
100
|
+
gap: theme.spacing(1)
|
|
101
|
+
}));
|
|
102
|
+
const ContainerPeriod = styled("div")(({
|
|
103
|
+
theme,
|
|
104
|
+
error
|
|
105
|
+
}) => ({
|
|
106
|
+
display: "flex",
|
|
107
|
+
width: "100%",
|
|
108
|
+
height: "auto",
|
|
109
|
+
alignItems: "center",
|
|
110
|
+
gap: theme.spacing(1),
|
|
111
|
+
border: error ? `1px solid ${theme.palette.error.main}` : `1px solid ${theme.palette.divider}`,
|
|
112
|
+
padding: theme.spacing(0.5, 1),
|
|
113
|
+
borderRadius: "4px",
|
|
114
|
+
"& .MuiAutocomplete-root, & .MuiTextField-root": {
|
|
115
|
+
width: "100%"
|
|
116
|
+
},
|
|
117
|
+
"& .MuiAutocomplete-root .MuiTextField-root": {
|
|
118
|
+
width: "100%"
|
|
119
|
+
},
|
|
120
|
+
"& .MuiTextField-root .MuiInput-input": {
|
|
121
|
+
padding: "5px!important"
|
|
122
|
+
}
|
|
123
|
+
}));
|
|
124
|
+
const SKTWrapper = styled("div")(({
|
|
125
|
+
theme
|
|
126
|
+
}) => ({
|
|
127
|
+
display: "flex",
|
|
128
|
+
width: "auto",
|
|
129
|
+
height: "37.5px",
|
|
130
|
+
alignItems: "center",
|
|
131
|
+
gap: theme.spacing(1),
|
|
132
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
133
|
+
padding: theme.spacing(0.5, 1),
|
|
134
|
+
borderRadius: "4px"
|
|
135
|
+
}));
|
|
136
|
+
const Gap = styled("div")(({
|
|
137
|
+
theme
|
|
138
|
+
}) => ({
|
|
139
|
+
width: "1px",
|
|
140
|
+
height: "20px",
|
|
141
|
+
backgroundColor: theme.palette.divider
|
|
142
|
+
}));
|
|
143
|
+
var ETimePeriods = /* @__PURE__ */ ((ETimePeriods2) => {
|
|
144
|
+
ETimePeriods2[ETimePeriods2["YEARS"] = 0] = "YEARS";
|
|
145
|
+
ETimePeriods2[ETimePeriods2["MONTHS"] = 1] = "MONTHS";
|
|
146
|
+
ETimePeriods2[ETimePeriods2["DAYS"] = 2] = "DAYS";
|
|
147
|
+
return ETimePeriods2;
|
|
148
|
+
})(ETimePeriods || {});
|
|
149
|
+
const Wrapper = styled("p")(({
|
|
150
|
+
theme
|
|
151
|
+
}) => ({
|
|
152
|
+
...theme.typography.caption,
|
|
153
|
+
color: theme.palette.error.main
|
|
154
|
+
}));
|
|
155
|
+
const ErrorLabel = (props) => {
|
|
156
|
+
const {
|
|
157
|
+
message
|
|
158
|
+
} = props;
|
|
159
|
+
return /* @__PURE__ */ jsx(Wrapper, {
|
|
160
|
+
children: message
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
const getSelPeriodTime = (period) => {
|
|
164
|
+
if (!period)
|
|
165
|
+
return ETimePeriods.YEARS;
|
|
166
|
+
if (period.selPeriodTime)
|
|
167
|
+
return period.selPeriodTime;
|
|
168
|
+
if (period.years && period.years > 0)
|
|
169
|
+
return ETimePeriods.YEARS;
|
|
170
|
+
if (period.months && period.months > 0)
|
|
171
|
+
return ETimePeriods.MONTHS;
|
|
172
|
+
if (period.days && period.days > 0)
|
|
173
|
+
return ETimePeriods.DAYS;
|
|
174
|
+
return ETimePeriods.YEARS;
|
|
175
|
+
};
|
|
176
|
+
const getSingleValue = (period) => {
|
|
177
|
+
if (!period)
|
|
178
|
+
return "";
|
|
179
|
+
if (period.singleValue !== void 0)
|
|
180
|
+
return period.singleValue;
|
|
181
|
+
if (period.years && period.years > 0)
|
|
182
|
+
return period.years;
|
|
183
|
+
if (period.months && period.months > 0)
|
|
184
|
+
return period.months;
|
|
185
|
+
if (period.days && period.days > 0)
|
|
186
|
+
return period.days;
|
|
187
|
+
return "";
|
|
188
|
+
};
|
|
189
|
+
const RHFPeriod = (props) => {
|
|
190
|
+
const {
|
|
191
|
+
name,
|
|
192
|
+
variant = "monoperiod"
|
|
193
|
+
} = props;
|
|
194
|
+
const {
|
|
195
|
+
getLabel
|
|
196
|
+
} = useModuleDictionary();
|
|
197
|
+
const isSkeleton = useModuleSkeleton();
|
|
198
|
+
const {
|
|
199
|
+
control
|
|
200
|
+
} = useFormContext();
|
|
201
|
+
const {
|
|
202
|
+
host_static_assets,
|
|
203
|
+
environment_assets
|
|
204
|
+
} = useEnvironment();
|
|
205
|
+
const options = useMemo(() => [{
|
|
206
|
+
id: 0,
|
|
207
|
+
label: getLabel("period.years")
|
|
208
|
+
}, {
|
|
209
|
+
id: 1,
|
|
210
|
+
label: getLabel("period.months")
|
|
211
|
+
}, {
|
|
212
|
+
id: 2,
|
|
213
|
+
label: getLabel("period.days")
|
|
214
|
+
}], [getLabel]);
|
|
215
|
+
if (isSkeleton) {
|
|
216
|
+
return /* @__PURE__ */ jsxs(SKTWrapper, {
|
|
217
|
+
children: [/* @__PURE__ */ jsx(Skeleton, {
|
|
218
|
+
variant: "rounded",
|
|
219
|
+
width: "100%"
|
|
220
|
+
}), /* @__PURE__ */ jsx(Gap, {}), /* @__PURE__ */ jsx(Skeleton, {
|
|
221
|
+
variant: "rounded",
|
|
222
|
+
width: "100%"
|
|
223
|
+
}), /* @__PURE__ */ jsx(Skeleton, {
|
|
224
|
+
variant: "circular",
|
|
225
|
+
width: 20,
|
|
226
|
+
sx: {
|
|
227
|
+
minWidth: "20px",
|
|
228
|
+
minHeight: "20px"
|
|
229
|
+
}
|
|
230
|
+
})]
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
234
|
+
name,
|
|
235
|
+
control,
|
|
236
|
+
render: ({
|
|
237
|
+
field: {
|
|
238
|
+
onChange,
|
|
239
|
+
value
|
|
240
|
+
},
|
|
241
|
+
fieldState: {
|
|
242
|
+
error
|
|
243
|
+
}
|
|
244
|
+
}) => {
|
|
245
|
+
const selPeriodTime = getSelPeriodTime(value);
|
|
246
|
+
const singleValue = getSingleValue(value);
|
|
247
|
+
const onTotalChange = (newPeriodTime, newValue) => {
|
|
248
|
+
const newPeriod = {
|
|
249
|
+
selPeriodTime: newPeriodTime,
|
|
250
|
+
singleValue: newValue,
|
|
251
|
+
variant
|
|
252
|
+
};
|
|
253
|
+
if (newValue !== "" && newValue > 0) {
|
|
254
|
+
newPeriod.years = 0;
|
|
255
|
+
newPeriod.months = 0;
|
|
256
|
+
newPeriod.days = 0;
|
|
257
|
+
if (newPeriodTime === ETimePeriods.YEARS)
|
|
258
|
+
newPeriod.years = newValue;
|
|
259
|
+
if (newPeriodTime === ETimePeriods.MONTHS)
|
|
260
|
+
newPeriod.months = newValue;
|
|
261
|
+
if (newPeriodTime === ETimePeriods.DAYS)
|
|
262
|
+
newPeriod.days = newValue;
|
|
263
|
+
}
|
|
264
|
+
onChange(newPeriod);
|
|
265
|
+
};
|
|
266
|
+
const onChangeTime = (newPeriodTime) => {
|
|
267
|
+
if (newPeriodTime) {
|
|
268
|
+
onTotalChange(newPeriodTime.id, singleValue);
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
return /* @__PURE__ */ jsxs(Wrapper$1, {
|
|
272
|
+
children: [/* @__PURE__ */ jsxs(ContainerPeriod, {
|
|
273
|
+
error: !!error,
|
|
274
|
+
children: [/* @__PURE__ */ jsx(Autocomplete, {
|
|
275
|
+
options,
|
|
276
|
+
value: options[selPeriodTime],
|
|
277
|
+
disableClearable: true,
|
|
278
|
+
onChange: (_event, autcValue) => {
|
|
279
|
+
onChangeTime(autcValue);
|
|
280
|
+
},
|
|
281
|
+
renderInput: (params) => {
|
|
282
|
+
return /* @__PURE__ */ jsx(TextField, {
|
|
283
|
+
...params,
|
|
284
|
+
fullWidth: true,
|
|
285
|
+
variant: "standard",
|
|
286
|
+
SelectProps: {
|
|
287
|
+
native: true
|
|
288
|
+
},
|
|
289
|
+
InputProps: {
|
|
290
|
+
disableUnderline: true,
|
|
291
|
+
...params.InputProps
|
|
292
|
+
},
|
|
293
|
+
autoComplete: "off"
|
|
294
|
+
}, `tx_async_${params.id}`);
|
|
295
|
+
}
|
|
296
|
+
}), /* @__PURE__ */ jsx(Gap, {}), /* @__PURE__ */ jsx(TextField, {
|
|
297
|
+
type: "number",
|
|
298
|
+
variant: "standard",
|
|
299
|
+
value: singleValue,
|
|
300
|
+
InputProps: {
|
|
301
|
+
disableUnderline: true
|
|
302
|
+
},
|
|
303
|
+
onChange: (e2) => {
|
|
304
|
+
onTotalChange(selPeriodTime, e2.target.value === "" ? "" : parseInt(e2.target.value));
|
|
305
|
+
}
|
|
306
|
+
}), /* @__PURE__ */ jsx(Icon, {
|
|
307
|
+
src: `${host_static_assets}/${environment_assets}/frontend/components/period/assets/icons/clock.svg`
|
|
308
|
+
})]
|
|
309
|
+
}), error && /* @__PURE__ */ jsx(ErrorLabel, {
|
|
310
|
+
message: error.message || ""
|
|
311
|
+
})]
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
};
|
|
316
|
+
function getPeriodComponetsDictionary() {
|
|
317
|
+
return ["period"].concat(getCommonActionsDictionary());
|
|
318
|
+
}
|
|
319
|
+
const useFormAddEdit = (props) => {
|
|
320
|
+
const { initialValues, objectId, endPoint, formatDataEnpoint } = props;
|
|
321
|
+
const [formValues, setFormValues] = useState(initialValues);
|
|
322
|
+
const [statusLoad, setStatusLoad] = useState(
|
|
323
|
+
objectId === void 0 ? "new" : "edit"
|
|
324
|
+
);
|
|
325
|
+
const { networkOperation } = useNetwork();
|
|
326
|
+
const { addFlag } = useFlags();
|
|
327
|
+
useEffect(() => {
|
|
328
|
+
let mounted = true;
|
|
329
|
+
if (statusLoad === "edit") {
|
|
330
|
+
networkOperation({
|
|
331
|
+
method: "GET",
|
|
332
|
+
endPoint: `${endPoint}/${objectId}`
|
|
333
|
+
}).then(
|
|
334
|
+
(response) => {
|
|
335
|
+
if (mounted) {
|
|
336
|
+
if (formatDataEnpoint) {
|
|
337
|
+
setFormValues(formatDataEnpoint(response.data));
|
|
338
|
+
} else {
|
|
339
|
+
setFormValues(response.data);
|
|
340
|
+
}
|
|
341
|
+
setStatusLoad("reload_values_provider");
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
() => {
|
|
345
|
+
setStatusLoad("error");
|
|
346
|
+
}
|
|
347
|
+
);
|
|
348
|
+
} else if (statusLoad === "new" || statusLoad === "reload_values_provider") {
|
|
349
|
+
addFlag("form_loaded");
|
|
350
|
+
setStatusLoad("ready");
|
|
351
|
+
}
|
|
352
|
+
return () => {
|
|
353
|
+
mounted = false;
|
|
354
|
+
};
|
|
355
|
+
}, [statusLoad]);
|
|
356
|
+
return { formValues, statusLoad };
|
|
357
|
+
};
|
|
358
|
+
export { ErrorLabel, RHFPeriod, getPeriodComponetsDictionary, useFormAddEdit };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@m4l/core": "*",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"react-helmet-async": "^1.3.0",
|
|
9
9
|
"react-hook-form": "^7.33.1",
|
|
10
10
|
"react-router-dom": "^6.3.0",
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"simplebar-react": "2.4.1",
|
|
12
|
+
"yup": "^0.32.11"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"@mui/lab": "^5.0.0-alpha.89",
|
package/utils/index.js
CHANGED