@m4l/components 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/Logo/index.js +91 -0
- package/commonjs.js +9 -0
- package/components/CommonActions/components/ActionCancel/index.js +15 -0
- package/components/CommonActions/components/ActionFormCancel/index.js +62 -0
- package/components/CommonActions/components/ActionFormIntro/index.js +35 -0
- package/components/CommonActions/components/ActionIntro/index.js +16 -0
- package/components/CommonActions/components/Actions/index.js +859 -0
- package/components/CompanyLogo/{index.f81c179c.js → index.js} +48 -42
- package/components/DataGrid/index.js +1067 -0
- package/components/DynamicFilter/index.js +1573 -0
- package/components/ErrorLabel/index.js +18 -0
- package/components/Icon/index.js +80 -0
- package/components/Image/index.js +128 -0
- package/components/LanguagePopover/index.js +93 -0
- package/components/Loadable/index.js +13 -0
- package/components/ModalDialog/index.js +180 -0
- package/components/NoItemSelected/{index.12f0ca67.js → index.js} +50 -43
- package/components/ObjectLogs/index.js +284 -0
- package/components/Page/index.js +36 -0
- package/components/PaperForm/index.js +110 -0
- package/components/Period/index.js +230 -0
- package/components/PropertyValue/index.js +142 -0
- package/components/Resizeable/{index.45995d2b.js → index.js} +19 -21
- package/components/ScrollBar/index.js +52 -0
- package/components/ScrollToTop/index.js +10 -0
- package/components/SplitLayout/{index.4032673d.js → index.js} +35 -35
- package/components/animate/LoadingScreen/{index.f1cec7db.js → index.js} +27 -29
- package/components/animate/MotionContainer/index.js +31 -0
- package/components/animate/MotionLazyContainer/index.js +13 -0
- package/components/animate/features.js +2 -0
- package/components/animate/variants/{bounce.784aaaaa.js → bounce.js} +16 -15
- package/components/animate/variants/container.js +20 -0
- package/components/animate/variants/fade.js +61 -0
- package/components/animate/variants/{index.7a912140.js → index.js} +0 -0
- package/components/animate/variants/transition.js +16 -0
- package/components/formatters/BooleanFormatter/index.js +52 -0
- package/components/formatters/DateFormatter/index.js +66 -0
- package/components/formatters/index.js +112 -0
- package/components/hook-form/FormProvider/index.js +61 -0
- package/components/hook-form/RHFAutocomplete/index.js +144 -0
- package/components/hook-form/RHFAutocompleteAsync/index.js +191 -0
- package/components/hook-form/RHFCheckbox/index.js +65 -0
- package/components/hook-form/RHFDateTime/index.js +79 -0
- package/components/hook-form/RHFMultiCheckbox/index.js +32 -0
- package/components/hook-form/RHFPeriod/index.js +47 -0
- package/components/hook-form/RHFRadioGroup/index.js +41 -0
- package/components/hook-form/RHFSelect/index.js +34 -0
- package/components/hook-form/RHFTextField/index.js +87 -0
- package/components/hook-form/RHFUpload/index.js +255 -0
- package/components/mui_extended/Accordion/index.js +105 -0
- package/components/mui_extended/Avatar/index.js +33 -0
- package/components/mui_extended/BoxIcon/index.js +20 -0
- package/components/mui_extended/Breadcrumbs/index.js +92 -0
- package/components/mui_extended/Button/index.js +131 -0
- package/components/mui_extended/IconButton/index.js +108 -0
- package/components/mui_extended/LinkWithRoute/index.js +30 -0
- package/components/mui_extended/MenuPopover/index.js +135 -0
- package/components/mui_extended/Pager/index.js +137 -0
- package/components/mui_extended/Tab/index.js +30 -0
- package/components/mui_extended/Typography/index.js +21 -0
- package/contexts/ModalContext/index.js +165 -0
- package/hooks/useFormAddEdit/index.js +42 -0
- package/hooks/useModal/index.js +4 -0
- package/index.js +70 -162
- package/lodash.js +62 -0
- package/node_modules.js +54 -0
- package/package.json +2 -1
- package/react-data-grid.js +2652 -0
- package/react-draggable.js +960 -0
- package/react-json-view.js +2764 -0
- package/react-lazy-load-image-component.js +792 -0
- package/react-resizable.js +541 -0
- package/react-splitter-layout.js +165 -0
- package/utils/index.js +572 -0
- package/assets/Logo/index.228dcb5a.js +0 -86
- package/commonjs.565e6834.js +0 -12
- package/components/CommonActions/components/ActionCancel/index.cba1b460.js +0 -17
- package/components/CommonActions/components/ActionFormCancel/index.be2fe891.js +0 -49
- package/components/CommonActions/components/ActionFormIntro/index.ca4d2674.js +0 -31
- package/components/CommonActions/components/ActionIntro/index.cc4b1e0e.js +0 -18
- package/components/CommonActions/components/Actions/index.e8148d98.js +0 -743
- package/components/DataGrid/index.b688877d.js +0 -894
- package/components/DynamicFilter/index.82ce857e.js +0 -1158
- package/components/ErrorLabel/index.c8615f16.js +0 -19
- package/components/Icon/index.cbca79b0.js +0 -70
- package/components/Image/index.e790b50b.js +0 -122
- package/components/LanguagePopover/index.3d9611cb.js +0 -87
- package/components/Loadable/index.f5518558.js +0 -15
- package/components/ModalDialog/index.3850c053.js +0 -168
- package/components/ObjectLogs/index.27ef875d.js +0 -266
- package/components/Page/index.6d69977e.js +0 -35
- package/components/PaperForm/index.d7c74064.js +0 -105
- package/components/Period/index.5e68286a.js +0 -160
- package/components/PropertyValue/index.ab3dd7e9.js +0 -116
- package/components/ScrollBar/index.39eeb2de.js +0 -49
- package/components/ScrollToTop/index.e06f98f6.js +0 -11
- package/components/animate/MotionContainer/index.8d9f9d80.js +0 -30
- package/components/animate/MotionLazyContainer/index.572dd012.js +0 -15
- package/components/animate/features.0fbf41e1.js +0 -5
- package/components/animate/variants/container.11f82b76.js +0 -20
- package/components/animate/variants/fade.b561c0fc.js +0 -59
- package/components/animate/variants/transition.bd46b9ce.js +0 -15
- package/components/formatters/BooleanFormatter/index.cca53b7f.js +0 -42
- package/components/formatters/DateFormatter/index.ad8d9b8e.js +0 -57
- package/components/formatters/index.55856d65.js +0 -106
- package/components/hook-form/FormProvider/index.257acd9f.js +0 -55
- package/components/hook-form/RHFAutocomplete/index.6ed76d4c.js +0 -122
- package/components/hook-form/RHFAutocompleteAsync/index.8f2c97ea.js +0 -153
- package/components/hook-form/RHFCheckbox/index.f9ce6c39.js +0 -59
- package/components/hook-form/RHFDateTime/index.fc5cbafe.js +0 -68
- package/components/hook-form/RHFMultiCheckbox/index.2680b3b6.js +0 -34
- package/components/hook-form/RHFPeriod/index.23c254e9.js +0 -45
- package/components/hook-form/RHFRadioGroup/index.b3335e13.js +0 -43
- package/components/hook-form/RHFSelect/index.b6ca8bb2.js +0 -36
- package/components/hook-form/RHFTextField/index.4c455f75.js +0 -77
- package/components/hook-form/RHFUpload/index.ed3d739f.js +0 -244
- package/components/mui_extended/Accordion/index.2116e423.js +0 -103
- package/components/mui_extended/Avatar/index.0a2a4523.js +0 -32
- package/components/mui_extended/BoxIcon/index.e638ecc8.js +0 -22
- package/components/mui_extended/Breadcrumbs/index.5e37d903.js +0 -89
- package/components/mui_extended/Button/index.84d8898c.js +0 -110
- package/components/mui_extended/IconButton/index.88f3aadb.js +0 -98
- package/components/mui_extended/LinkWithRoute/index.d4b263de.js +0 -28
- package/components/mui_extended/MenuPopover/index.488fc536.js +0 -131
- package/components/mui_extended/Pager/index.0576814f.js +0 -126
- package/components/mui_extended/Tab/index.e0653a0a.js +0 -28
- package/components/mui_extended/Typography/index.0c4604b3.js +0 -22
- package/contexts/ModalContext/index.2188b69e.js +0 -150
- package/hooks/useFormAddEdit/index.d4845f1a.js +0 -26
- package/hooks/useModal/index.6571d2d9.js +0 -6
- package/lodash.e09401f0.js +0 -32
- package/node_modules.168cb897.js +0 -55
- package/react-data-grid.d46d625e.js +0 -2115
- package/react-draggable.20e95c61.js +0 -714
- package/react-json-view.f56a7f8e.js +0 -2762
- package/react-lazy-load-image-component.45b56650.js +0 -784
- package/react-resizable.5277deaf.js +0 -371
- package/react-splitter-layout.7810ac1b.js +0 -165
- package/utils/index.214d9542.js +0 -435
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { v as varTranEnter, a as varTranExit } from "./transition.js";
|
|
2
|
+
const varFade = (props) => {
|
|
3
|
+
const distance = props?.distance || 120;
|
|
4
|
+
const durationIn = props?.durationIn;
|
|
5
|
+
const durationOut = props?.durationOut;
|
|
6
|
+
const easeIn = props?.easeIn;
|
|
7
|
+
const easeOut = props?.easeOut;
|
|
8
|
+
return {
|
|
9
|
+
in: {
|
|
10
|
+
initial: { opacity: 0 },
|
|
11
|
+
animate: { opacity: 1, transition: varTranEnter },
|
|
12
|
+
exit: { opacity: 0, transition: varTranExit }
|
|
13
|
+
},
|
|
14
|
+
inUp: {
|
|
15
|
+
initial: { y: distance, opacity: 0 },
|
|
16
|
+
animate: { y: 0, opacity: 1, transition: varTranEnter({ durationIn, easeIn }) },
|
|
17
|
+
exit: { y: distance, opacity: 0, transition: varTranExit({ durationOut, easeOut }) }
|
|
18
|
+
},
|
|
19
|
+
inDown: {
|
|
20
|
+
initial: { y: -distance, opacity: 0 },
|
|
21
|
+
animate: { y: 0, opacity: 1, transition: varTranEnter({ durationIn, easeIn }) },
|
|
22
|
+
exit: { y: -distance, opacity: 0, transition: varTranExit({ durationOut, easeOut }) }
|
|
23
|
+
},
|
|
24
|
+
inLeft: {
|
|
25
|
+
initial: { x: -distance, opacity: 0 },
|
|
26
|
+
animate: { x: 0, opacity: 1, transition: varTranEnter({ durationIn, easeIn }) },
|
|
27
|
+
exit: { x: -distance, opacity: 0, transition: varTranExit({ durationOut, easeOut }) }
|
|
28
|
+
},
|
|
29
|
+
inRight: {
|
|
30
|
+
initial: { x: distance, opacity: 0 },
|
|
31
|
+
animate: { x: 0, opacity: 1, transition: varTranEnter({ durationIn, easeIn }) },
|
|
32
|
+
exit: { x: distance, opacity: 0, transition: varTranExit({ durationOut, easeOut }) }
|
|
33
|
+
},
|
|
34
|
+
out: {
|
|
35
|
+
initial: { opacity: 1 },
|
|
36
|
+
animate: { opacity: 0, transition: varTranEnter({ durationIn, easeIn }) },
|
|
37
|
+
exit: { opacity: 1, transition: varTranExit({ durationOut, easeOut }) }
|
|
38
|
+
},
|
|
39
|
+
outUp: {
|
|
40
|
+
initial: { y: 0, opacity: 1 },
|
|
41
|
+
animate: { y: -distance, opacity: 0, transition: varTranEnter({ durationIn, easeIn }) },
|
|
42
|
+
exit: { y: 0, opacity: 1, transition: varTranExit({ durationOut, easeOut }) }
|
|
43
|
+
},
|
|
44
|
+
outDown: {
|
|
45
|
+
initial: { y: 0, opacity: 1 },
|
|
46
|
+
animate: { y: distance, opacity: 0, transition: varTranEnter({ durationIn, easeIn }) },
|
|
47
|
+
exit: { y: 0, opacity: 1, transition: varTranExit({ durationOut, easeOut }) }
|
|
48
|
+
},
|
|
49
|
+
outLeft: {
|
|
50
|
+
initial: { x: 0, opacity: 1 },
|
|
51
|
+
animate: { x: -distance, opacity: 0, transition: varTranEnter({ durationIn, easeIn }) },
|
|
52
|
+
exit: { x: 0, opacity: 1, transition: varTranExit({ durationOut, easeOut }) }
|
|
53
|
+
},
|
|
54
|
+
outRight: {
|
|
55
|
+
initial: { x: 0, opacity: 1 },
|
|
56
|
+
animate: { x: distance, opacity: 0, transition: varTranEnter({ durationIn, easeIn }) },
|
|
57
|
+
exit: { x: 0, opacity: 1, transition: varTranExit({ durationOut, easeOut }) }
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export { varFade as v };
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const varTranHover = (props) => {
|
|
2
|
+
const duration = props?.duration || 0.32;
|
|
3
|
+
const ease = props?.ease || [0.43, 0.13, 0.23, 0.96];
|
|
4
|
+
return { duration, ease };
|
|
5
|
+
};
|
|
6
|
+
const varTranEnter = (props) => {
|
|
7
|
+
const duration = props?.durationIn || 0.64;
|
|
8
|
+
const ease = props?.easeIn || [0.43, 0.13, 0.23, 0.96];
|
|
9
|
+
return { duration, ease };
|
|
10
|
+
};
|
|
11
|
+
const varTranExit = (props) => {
|
|
12
|
+
const duration = props?.durationOut || 0.48;
|
|
13
|
+
const ease = props?.easeOut || [0.43, 0.13, 0.23, 0.96];
|
|
14
|
+
return { duration, ease };
|
|
15
|
+
};
|
|
16
|
+
export { varTranExit as a, varTranHover as b, varTranEnter as v };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useModuleDictionary, useEnvironment, getPropertyByString } from "@m4l/core";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { I as Icon } from "../../Icon/index.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
function BooleanFormatter(props) {
|
|
6
|
+
const {
|
|
7
|
+
presentationType,
|
|
8
|
+
value,
|
|
9
|
+
Component = React.Fragment
|
|
10
|
+
} = props;
|
|
11
|
+
const {
|
|
12
|
+
getLabel
|
|
13
|
+
} = useModuleDictionary();
|
|
14
|
+
const {
|
|
15
|
+
host_static_assets,
|
|
16
|
+
environment_assets
|
|
17
|
+
} = useEnvironment();
|
|
18
|
+
const final_value = value ?? false;
|
|
19
|
+
const srcCheckTrue = `${host_static_assets}/${environment_assets}/frontend/components/data_grid/components/boolean_formatter/assets/icons/check_true.svg`;
|
|
20
|
+
const srcCheckFalse = `${host_static_assets}/${environment_assets}/frontend/components/data_grid/components/boolean_formatter/assets/icons/check_false.svg`;
|
|
21
|
+
if (presentationType === "string_yes_no") {
|
|
22
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
23
|
+
children: final_value ? getLabel("formatters.boolean_yes") : getLabel("formatters.boolean_no")
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (presentationType === "string_true_false") {
|
|
27
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
28
|
+
children: final_value ? getLabel("formatters.boolean_true") : getLabel("formatters.boolean_false")
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
32
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
33
|
+
src: final_value ? srcCheckTrue : srcCheckFalse,
|
|
34
|
+
bgColor: "action.disabled"
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function columnBooleanFormatter(props) {
|
|
39
|
+
const {
|
|
40
|
+
fieldValue,
|
|
41
|
+
presentationType,
|
|
42
|
+
Component = React.Fragment
|
|
43
|
+
} = props;
|
|
44
|
+
return (obProps) => {
|
|
45
|
+
return /* @__PURE__ */ jsx(BooleanFormatter, {
|
|
46
|
+
presentationType,
|
|
47
|
+
value: getPropertyByString(obProps, fieldValue),
|
|
48
|
+
Component
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export { BooleanFormatter as B, columnBooleanFormatter as c };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useEnvironment, useHostTools, getPropertyByString } from "@m4l/core";
|
|
3
|
+
import "../../Icon/index.js";
|
|
4
|
+
import "@mui/material/styles";
|
|
5
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
6
|
+
function DateFormatter(props) {
|
|
7
|
+
const {
|
|
8
|
+
presentationType,
|
|
9
|
+
value,
|
|
10
|
+
format,
|
|
11
|
+
Component = React.Fragment
|
|
12
|
+
} = props;
|
|
13
|
+
const {
|
|
14
|
+
dfnsFormat
|
|
15
|
+
} = useEnvironment();
|
|
16
|
+
const {
|
|
17
|
+
formatDate
|
|
18
|
+
} = useHostTools();
|
|
19
|
+
let finalFormat = format || dfnsFormat.datetime_format;
|
|
20
|
+
let result;
|
|
21
|
+
let resultDate;
|
|
22
|
+
if (value === void 0 || value === null) {
|
|
23
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
24
|
+
children: "-"
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
switch (presentationType) {
|
|
28
|
+
case "datetime":
|
|
29
|
+
finalFormat = format || dfnsFormat.datetime_format;
|
|
30
|
+
break;
|
|
31
|
+
case "date":
|
|
32
|
+
finalFormat = format || dfnsFormat.date_format;
|
|
33
|
+
break;
|
|
34
|
+
case "time":
|
|
35
|
+
finalFormat = format || dfnsFormat.time_format;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
if (typeof value === "number" || typeof value === "string") {
|
|
40
|
+
resultDate = new Date(value);
|
|
41
|
+
} else {
|
|
42
|
+
resultDate = value;
|
|
43
|
+
}
|
|
44
|
+
result = formatDate(resultDate, finalFormat);
|
|
45
|
+
} catch (e) {
|
|
46
|
+
result = "err_typing";
|
|
47
|
+
}
|
|
48
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
49
|
+
children: result
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function columnDateFormatter(props) {
|
|
53
|
+
const {
|
|
54
|
+
fieldValue,
|
|
55
|
+
presentationType,
|
|
56
|
+
Component = React.Fragment
|
|
57
|
+
} = props;
|
|
58
|
+
return (obProps) => {
|
|
59
|
+
return /* @__PURE__ */ jsx(DateFormatter, {
|
|
60
|
+
presentationType,
|
|
61
|
+
value: getPropertyByString(obProps, fieldValue),
|
|
62
|
+
Component
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export { DateFormatter as D, columnDateFormatter as c };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { getPropertyByString } from "@m4l/core";
|
|
4
|
+
import "../Icon/index.js";
|
|
5
|
+
import "@mui/material/styles";
|
|
6
|
+
function UncertaintyFormatter(props) {
|
|
7
|
+
const {
|
|
8
|
+
value,
|
|
9
|
+
unit,
|
|
10
|
+
symbol,
|
|
11
|
+
Component = React.Fragment
|
|
12
|
+
} = props;
|
|
13
|
+
if (value === void 0 || value === null || !Array.isArray(value)) {
|
|
14
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
15
|
+
children: ""
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
let result = "";
|
|
19
|
+
value.map((obj, idx) => {
|
|
20
|
+
const cmc_min_closed = obj.cmc_min_closed != true ? "<" : "\u2264";
|
|
21
|
+
const cmc_max_closed = obj.cmc_max_closed != true ? "<" : "\u2264";
|
|
22
|
+
result = result.concat(`${idx > 0 ? " " : ""}`, obj.cmc_min !== obj.cmc_max ? `[${obj.cmc_min}${unit} ${cmc_min_closed} ${symbol} ${cmc_max_closed} ${obj.cmc_max}${unit} \xB1 ${obj.cmc_uncertainty}]` : `[${obj.cmc_min}${unit} \xB1 ${obj.cmc_uncertainty}]`);
|
|
23
|
+
});
|
|
24
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
25
|
+
children: result
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function PointsFormatter(props) {
|
|
29
|
+
const {
|
|
30
|
+
value,
|
|
31
|
+
unit,
|
|
32
|
+
Component = React.Fragment
|
|
33
|
+
} = props;
|
|
34
|
+
console.log("points", value);
|
|
35
|
+
if (value === void 0 || value === null || !Array.isArray(value)) {
|
|
36
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
37
|
+
children: "[]"
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
let result = "";
|
|
41
|
+
value.map((point) => {
|
|
42
|
+
if (point) {
|
|
43
|
+
console.log("point", point);
|
|
44
|
+
result = result.concat(`[${point}${unit}]`);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
48
|
+
children: result
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function PriceFormatter(props) {
|
|
52
|
+
const {
|
|
53
|
+
value,
|
|
54
|
+
Component = React.Fragment
|
|
55
|
+
} = props;
|
|
56
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
57
|
+
children: `${value}$Cop`
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function getFormattersComponentsDictionary() {
|
|
61
|
+
return ["formatters"];
|
|
62
|
+
}
|
|
63
|
+
const defaultFormattersDictionary = {
|
|
64
|
+
pager: {
|
|
65
|
+
boolean_yes: "Yes",
|
|
66
|
+
boolean_no: "No",
|
|
67
|
+
boolean_true: "True",
|
|
68
|
+
boolean_false: "False"
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
function columnUncertaintyFormatter(props) {
|
|
72
|
+
const {
|
|
73
|
+
fieldUnit,
|
|
74
|
+
fieldValue,
|
|
75
|
+
fieldSymbol,
|
|
76
|
+
Component
|
|
77
|
+
} = props;
|
|
78
|
+
return (obProps) => {
|
|
79
|
+
return /* @__PURE__ */ jsx(UncertaintyFormatter, {
|
|
80
|
+
Component,
|
|
81
|
+
value: getPropertyByString(obProps, fieldValue),
|
|
82
|
+
unit: getPropertyByString(obProps, fieldUnit),
|
|
83
|
+
symbol: getPropertyByString(obProps, fieldSymbol)
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function columnPointsFormatter(props) {
|
|
88
|
+
const {
|
|
89
|
+
fieldUnit,
|
|
90
|
+
fieldValue,
|
|
91
|
+
Component
|
|
92
|
+
} = props;
|
|
93
|
+
return (obProps) => {
|
|
94
|
+
return /* @__PURE__ */ jsx(PointsFormatter, {
|
|
95
|
+
Component,
|
|
96
|
+
value: getPropertyByString(obProps, fieldValue),
|
|
97
|
+
unit: getPropertyByString(obProps, fieldUnit)
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function columnNestedValueFormatter(props) {
|
|
102
|
+
const {
|
|
103
|
+
fieldValue,
|
|
104
|
+
Component = React.Fragment
|
|
105
|
+
} = props;
|
|
106
|
+
return (obProps) => {
|
|
107
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
108
|
+
children: getPropertyByString(obProps, fieldValue) + ""
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
export { PointsFormatter as P, UncertaintyFormatter as U, PriceFormatter as a, columnPointsFormatter as b, columnUncertaintyFormatter as c, defaultFormattersDictionary as d, columnNestedValueFormatter as e, getFormattersComponentsDictionary as g };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { useForm, FormProvider as FormProvider$1 } from "react-hook-form";
|
|
3
|
+
import { o } from "../../../node_modules.js";
|
|
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
|
+
paddingTop: theme.spacing(1),
|
|
11
|
+
marginBottom: theme.spacing(1),
|
|
12
|
+
flexDirection: "column",
|
|
13
|
+
width: "100%",
|
|
14
|
+
overflow: "scroll"
|
|
15
|
+
}));
|
|
16
|
+
function FormProvider(props) {
|
|
17
|
+
const {
|
|
18
|
+
children,
|
|
19
|
+
onSubmit,
|
|
20
|
+
values,
|
|
21
|
+
validationSchema,
|
|
22
|
+
statusLoad = "ready"
|
|
23
|
+
} = props;
|
|
24
|
+
const methods = useForm({
|
|
25
|
+
resolver: o(validationSchema),
|
|
26
|
+
defaultValues: values
|
|
27
|
+
});
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
console.log("useEffect FormProvider reload_values_provider===", statusLoad);
|
|
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$1, {
|
|
53
|
+
...methods,
|
|
54
|
+
children: /* @__PURE__ */ jsx(WrapperFormProvider, {
|
|
55
|
+
id: "formProvider",
|
|
56
|
+
onSubmit: methods.handleSubmit(onSubmit),
|
|
57
|
+
children
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
export { FormProvider as F };
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { useModuleDictionary, useModuleSkeleton } from "@m4l/core";
|
|
2
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
3
|
+
import { Skeleton, Autocomplete, TextField } from "@mui/material";
|
|
4
|
+
import { styled } from "@mui/material/styles";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
const SKTRHFAutocompleteWrapper = styled("div")(() => ({
|
|
7
|
+
display: "flex",
|
|
8
|
+
width: "100%",
|
|
9
|
+
flexDirection: "column"
|
|
10
|
+
}));
|
|
11
|
+
styled("div")(({
|
|
12
|
+
theme
|
|
13
|
+
}) => ({
|
|
14
|
+
display: "flex",
|
|
15
|
+
justifyContent: "flex-end",
|
|
16
|
+
paddingRight: `${theme.spacing(2)}`,
|
|
17
|
+
[theme.breakpoints.down("md")]: {
|
|
18
|
+
justifyContent: "flex-start"
|
|
19
|
+
}
|
|
20
|
+
}));
|
|
21
|
+
const SKTInputText = styled("div")(({
|
|
22
|
+
theme
|
|
23
|
+
}) => ({
|
|
24
|
+
width: "100%",
|
|
25
|
+
display: "grid",
|
|
26
|
+
gridTemplateColumns: "1fr auto",
|
|
27
|
+
gridGap: theme.spacing(2),
|
|
28
|
+
alignItems: "center",
|
|
29
|
+
height: `${theme.spacing(4.5)}`,
|
|
30
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
31
|
+
borderRadius: `${theme.spacing(1)}`,
|
|
32
|
+
padding: `0 ${theme.spacing(2)}`,
|
|
33
|
+
[theme.breakpoints.down("md")]: {
|
|
34
|
+
width: "100%"
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
styled("div")(() => ({
|
|
38
|
+
display: "flex",
|
|
39
|
+
width: "100%",
|
|
40
|
+
"& .MuiAutocomplete-root": {
|
|
41
|
+
width: "100%"
|
|
42
|
+
}
|
|
43
|
+
}));
|
|
44
|
+
function RHFAutocomplete(props) {
|
|
45
|
+
const {
|
|
46
|
+
name,
|
|
47
|
+
getOptionLabel,
|
|
48
|
+
isOptionEqualToValue,
|
|
49
|
+
label,
|
|
50
|
+
skeletonProps = {},
|
|
51
|
+
options,
|
|
52
|
+
disabled,
|
|
53
|
+
...other
|
|
54
|
+
} = props;
|
|
55
|
+
const {
|
|
56
|
+
width = 100,
|
|
57
|
+
height = "18px"
|
|
58
|
+
} = skeletonProps;
|
|
59
|
+
const {
|
|
60
|
+
getLabel
|
|
61
|
+
} = useModuleDictionary();
|
|
62
|
+
const isSkeleton = useModuleSkeleton();
|
|
63
|
+
const {
|
|
64
|
+
control,
|
|
65
|
+
getValues
|
|
66
|
+
} = useFormContext();
|
|
67
|
+
const initialValue = getValues(name);
|
|
68
|
+
const getOptionLabelLocal = (option) => {
|
|
69
|
+
if (option === void 0 || option === null) {
|
|
70
|
+
return "";
|
|
71
|
+
}
|
|
72
|
+
return getOptionLabel(option);
|
|
73
|
+
};
|
|
74
|
+
const isOptionEqualToValueLocal = (option, value) => {
|
|
75
|
+
if (value === void 0 || value === null || option === null) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
return isOptionEqualToValue(option, value);
|
|
79
|
+
};
|
|
80
|
+
if (isSkeleton) {
|
|
81
|
+
return /* @__PURE__ */ jsx(SKTRHFAutocompleteWrapper, {
|
|
82
|
+
children: /* @__PURE__ */ jsxs(SKTInputText, {
|
|
83
|
+
children: [/* @__PURE__ */ jsx(Skeleton, {
|
|
84
|
+
variant: "text",
|
|
85
|
+
width,
|
|
86
|
+
height
|
|
87
|
+
}, "sk1"), /* @__PURE__ */ jsx(Skeleton, {
|
|
88
|
+
variant: "circular",
|
|
89
|
+
width: 16,
|
|
90
|
+
height: 16
|
|
91
|
+
}, "sk2")]
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
96
|
+
name,
|
|
97
|
+
control,
|
|
98
|
+
render: ({
|
|
99
|
+
field: {
|
|
100
|
+
onChange,
|
|
101
|
+
value
|
|
102
|
+
},
|
|
103
|
+
fieldState: {
|
|
104
|
+
error
|
|
105
|
+
}
|
|
106
|
+
}) => {
|
|
107
|
+
return /* @__PURE__ */ jsx(
|
|
108
|
+
Autocomplete,
|
|
109
|
+
{
|
|
110
|
+
options,
|
|
111
|
+
getOptionLabel: getOptionLabelLocal,
|
|
112
|
+
defaultValue: initialValue,
|
|
113
|
+
isOptionEqualToValue: isOptionEqualToValueLocal,
|
|
114
|
+
disableClearable: true,
|
|
115
|
+
value: value || null,
|
|
116
|
+
onChange: (_e, val) => {
|
|
117
|
+
onChange(val);
|
|
118
|
+
},
|
|
119
|
+
loadingText: "",
|
|
120
|
+
disabled,
|
|
121
|
+
noOptionsText: getLabel("rhf_autocomplete.component_no_options"),
|
|
122
|
+
renderInput: (params) => {
|
|
123
|
+
return /* @__PURE__ */ jsx(TextField, {
|
|
124
|
+
...params,
|
|
125
|
+
label,
|
|
126
|
+
fullWidth: true,
|
|
127
|
+
SelectProps: {
|
|
128
|
+
native: true
|
|
129
|
+
},
|
|
130
|
+
InputProps: {
|
|
131
|
+
...params.InputProps
|
|
132
|
+
},
|
|
133
|
+
autoComplete: "off",
|
|
134
|
+
error: !!error,
|
|
135
|
+
helperText: error?.message,
|
|
136
|
+
...other
|
|
137
|
+
}, `tx_async_${params.id}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
export { RHFAutocomplete as R };
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { useState, useEffect, Fragment } from "react";
|
|
2
|
+
import { useModuleDictionary, useModuleSkeleton, useNetwork, getPropertyByString } from "@m4l/core";
|
|
3
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
4
|
+
import { Skeleton, Autocomplete, TextField, CircularProgress } from "@mui/material";
|
|
5
|
+
import { styled } from "@mui/material/styles";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
const SKTRHFAutocompleteAsyncWrapper = styled("div")(() => ({
|
|
8
|
+
display: "flex",
|
|
9
|
+
width: "100%",
|
|
10
|
+
flexDirection: "column"
|
|
11
|
+
}));
|
|
12
|
+
styled("div")(({
|
|
13
|
+
theme
|
|
14
|
+
}) => ({
|
|
15
|
+
display: "flex",
|
|
16
|
+
justifyContent: "flex-end",
|
|
17
|
+
paddingRight: `${theme.spacing(2)}`,
|
|
18
|
+
[theme.breakpoints.down("md")]: {
|
|
19
|
+
justifyContent: "flex-start"
|
|
20
|
+
}
|
|
21
|
+
}));
|
|
22
|
+
const SKTInputText = styled("div")(({
|
|
23
|
+
theme
|
|
24
|
+
}) => ({
|
|
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.palette.divider}`,
|
|
32
|
+
borderRadius: `${theme.spacing(1)}`,
|
|
33
|
+
padding: `0 ${theme.spacing(2)}`,
|
|
34
|
+
[theme.breakpoints.down("md")]: {
|
|
35
|
+
width: "100%"
|
|
36
|
+
}
|
|
37
|
+
}));
|
|
38
|
+
function RHFAutocompleteAsync(props) {
|
|
39
|
+
const {
|
|
40
|
+
name,
|
|
41
|
+
getOptionLabel,
|
|
42
|
+
isOptionEqualToValue,
|
|
43
|
+
label,
|
|
44
|
+
endPoint,
|
|
45
|
+
timeout = 5e3,
|
|
46
|
+
parms,
|
|
47
|
+
resultField = "data",
|
|
48
|
+
skeletonProps = {},
|
|
49
|
+
isRemote = true,
|
|
50
|
+
disabled,
|
|
51
|
+
...other
|
|
52
|
+
} = props;
|
|
53
|
+
const {
|
|
54
|
+
width = 100,
|
|
55
|
+
height = "18px"
|
|
56
|
+
} = skeletonProps;
|
|
57
|
+
const {
|
|
58
|
+
getLabel
|
|
59
|
+
} = useModuleDictionary();
|
|
60
|
+
const isSkeleton = useModuleSkeleton();
|
|
61
|
+
const {
|
|
62
|
+
control,
|
|
63
|
+
getValues,
|
|
64
|
+
setValue
|
|
65
|
+
} = useFormContext();
|
|
66
|
+
const {
|
|
67
|
+
networkOperation
|
|
68
|
+
} = useNetwork();
|
|
69
|
+
const initialValue = getValues(name);
|
|
70
|
+
const [options, setOptions] = useState(initialValue === null ? [] : [initialValue]);
|
|
71
|
+
const [open, setOpen] = useState(false);
|
|
72
|
+
const [optionsLoaded, setOptionsLoaded] = useState(false);
|
|
73
|
+
const loading = open && !optionsLoaded && !!endPoint && !isSkeleton;
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (optionsLoaded) {
|
|
76
|
+
setOptionsLoaded(false);
|
|
77
|
+
setOptions([]);
|
|
78
|
+
setValue(name, null);
|
|
79
|
+
}
|
|
80
|
+
}, [parms, endPoint]);
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (!optionsLoaded && initialValue) {
|
|
83
|
+
setOptions([initialValue]);
|
|
84
|
+
}
|
|
85
|
+
}, [initialValue, optionsLoaded]);
|
|
86
|
+
const getOptionLabelLocal = (option) => {
|
|
87
|
+
if (option === void 0 || option === null) {
|
|
88
|
+
return "";
|
|
89
|
+
}
|
|
90
|
+
return getOptionLabel(option);
|
|
91
|
+
};
|
|
92
|
+
const isOptionEqualToValueLocal = (option, value) => {
|
|
93
|
+
if (value === void 0 || value === null || option === null) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
return isOptionEqualToValue(option, value);
|
|
97
|
+
};
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
let mounted = true;
|
|
100
|
+
if (!loading) {
|
|
101
|
+
return void 0;
|
|
102
|
+
}
|
|
103
|
+
networkOperation({
|
|
104
|
+
method: "GET",
|
|
105
|
+
endPoint,
|
|
106
|
+
timeout,
|
|
107
|
+
parms,
|
|
108
|
+
isRemote
|
|
109
|
+
}).then((response) => {
|
|
110
|
+
if (mounted) {
|
|
111
|
+
setOptions(getPropertyByString(response, resultField));
|
|
112
|
+
setOptionsLoaded(true);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
return () => {
|
|
116
|
+
mounted = false;
|
|
117
|
+
};
|
|
118
|
+
}, [loading]);
|
|
119
|
+
if (isSkeleton) {
|
|
120
|
+
return /* @__PURE__ */ jsx(SKTRHFAutocompleteAsyncWrapper, {
|
|
121
|
+
children: /* @__PURE__ */ jsxs(SKTInputText, {
|
|
122
|
+
children: [/* @__PURE__ */ jsx(Skeleton, {
|
|
123
|
+
variant: "text",
|
|
124
|
+
width,
|
|
125
|
+
height
|
|
126
|
+
}, "sk1"), /* @__PURE__ */ jsx(Skeleton, {
|
|
127
|
+
variant: "circular",
|
|
128
|
+
width: 16,
|
|
129
|
+
height: 16
|
|
130
|
+
}, "sk2")]
|
|
131
|
+
})
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
135
|
+
name,
|
|
136
|
+
control,
|
|
137
|
+
render: ({
|
|
138
|
+
field: {
|
|
139
|
+
onChange,
|
|
140
|
+
value
|
|
141
|
+
},
|
|
142
|
+
fieldState: {
|
|
143
|
+
error
|
|
144
|
+
}
|
|
145
|
+
}) => /* @__PURE__ */ jsx(Autocomplete, {
|
|
146
|
+
options,
|
|
147
|
+
getOptionLabel: getOptionLabelLocal,
|
|
148
|
+
defaultValue: initialValue,
|
|
149
|
+
isOptionEqualToValue: isOptionEqualToValueLocal,
|
|
150
|
+
disableClearable: true,
|
|
151
|
+
value: value || null,
|
|
152
|
+
onOpen: () => {
|
|
153
|
+
setOpen(true);
|
|
154
|
+
},
|
|
155
|
+
onClose: () => {
|
|
156
|
+
setOpen(false);
|
|
157
|
+
},
|
|
158
|
+
onChange: (_e, val) => {
|
|
159
|
+
onChange(val);
|
|
160
|
+
},
|
|
161
|
+
disabled,
|
|
162
|
+
loading,
|
|
163
|
+
loadingText: "",
|
|
164
|
+
noOptionsText: getLabel("rhf_autocomplete.component_no_options"),
|
|
165
|
+
renderInput: (params) => {
|
|
166
|
+
return /* @__PURE__ */ jsx(TextField, {
|
|
167
|
+
...params,
|
|
168
|
+
label,
|
|
169
|
+
fullWidth: true,
|
|
170
|
+
SelectProps: {
|
|
171
|
+
native: true
|
|
172
|
+
},
|
|
173
|
+
InputProps: {
|
|
174
|
+
...params.InputProps,
|
|
175
|
+
endAdornment: /* @__PURE__ */ jsxs(Fragment, {
|
|
176
|
+
children: [loading ? /* @__PURE__ */ jsx(CircularProgress, {
|
|
177
|
+
color: "primary",
|
|
178
|
+
size: 20
|
|
179
|
+
}, `cp_async${params.id}`) : null, params.InputProps.endAdornment]
|
|
180
|
+
}, `fr_async_${params.id}`)
|
|
181
|
+
},
|
|
182
|
+
autoComplete: "off",
|
|
183
|
+
error: !!error,
|
|
184
|
+
helperText: error?.message,
|
|
185
|
+
...other
|
|
186
|
+
}, `tx_async_${params.id}`);
|
|
187
|
+
}
|
|
188
|
+
}, "at_async")
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
export { RHFAutocompleteAsync as R };
|