@m4l/components 1.1.1 → 2.0.0
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/@types/export.d.ts +0 -5
- package/@types/types.d.ts +9 -0
- package/components/AccountPopover/{index.dde11a5c.js → index.493dbab5.js} +3 -3
- package/components/AppBar/{index.19b11c19.js → index.4b2c02da.js} +4 -4
- package/components/BaseModule/{index.4b725d16.js → index.dba0d174.js} +1 -1
- package/components/CommonActions/components/ActionCancel/{index.c3cddacf.js → index.ce196f96.js} +2 -2
- package/components/CommonActions/components/ActionFormCancel/{index.3ec840af.js → index.d63f6a23.js} +4 -4
- package/components/CommonActions/components/ActionFormIntro/{index.3187e7a7.js → index.0daa98b8.js} +2 -2
- package/components/CommonActions/components/ActionIntro/{index.db2b2999.js → index.1c40d33b.js} +2 -2
- package/components/CommonActions/components/Actions/{index.84b8fd47.js → index.434f4824.js} +1 -1
- package/components/DataGrid/formatters/ColumnBooleanFormatter/{index.ea1b882e.js → index.0a3660c0.js} +1 -1
- package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/{index.cff633f6.js → index.4b1df4ab.js} +1 -1
- package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/{index.d2e656a0.js → index.37f4f359.js} +1 -1
- package/components/DataGrid/formatters/{index.4b65c281.js → index.91129d5e.js} +2 -2
- package/components/DataGrid/{index.9aa088f6.js → index.d538cef8.js} +4 -4
- package/components/DataGrid/subcomponents/Actions/{index.9416e750.js → index.8d2e96e7.js} +11 -11
- package/components/DragResizeWindow/classes/types.d.ts +1 -0
- package/components/DragResizeWindow/helpers/index.d.ts +3 -0
- package/components/DragResizeWindow/{index.8f5a2e3e.js → index.17e7059d.js} +50 -37
- package/components/DragResizeWindow/types.d.ts +7 -0
- package/components/DynamicFilter/{dictionary.e9ad0f7c.js → dictionary.f471309f.js} +2 -2
- package/components/DynamicFilter/{index.e737845f.js → index.a7e772f7.js} +4 -4
- package/components/DynamicFilter/slots/{dynamicFilterSlots.c6d731f1.js → dynamicFilterSlots.1e2dc145.js} +5 -5
- package/components/DynamicFilter/store/{index.7a5e5f6a.js → index.3733c18e.js} +1 -1
- package/components/DynamicFilter/subcomponents/AppliedFilterChip/{index.f714d323.js → index.5b952ba7.js} +3 -3
- package/components/DynamicFilter/subcomponents/AppliedFilters/{index.c4131ff0.js → index.e38ed08e.js} +4 -4
- package/components/DynamicFilter/subcomponents/DynamicFilterBase/{index.9be8d255.js → index.bbc1b1c0.js} +6 -6
- package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/{index.5caf5b34.js → index.b0a2c96e.js} +4 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/{index.f5262ca2.js → index.2036b257.js} +4 -3
- package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/{index.f48b4af1.js → index.d7559fb2.js} +4 -3
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/{index.86de8517.js → index.d628de04.js} +5 -4
- package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/{index.1ba1cc22.js → index.804bb474.js} +4 -3
- package/components/DynamicFilter/subcomponents/FieldTypes/{index.8d2e925e.js → index.de33ba0a.js} +5 -5
- package/components/DynamicFilter/subcomponents/FilterActions/{index.066a32f4.js → index.c8c90968.js} +3 -3
- package/components/DynamicFilter/subcomponents/InputFilter/{index.f3f01ebc.js → index.1b95c167.js} +4 -4
- package/components/DynamicFilter/subcomponents/PopoverFilter/{index.7805f621.js → index.fd8a2421.js} +6 -6
- package/components/DynamicFilter/subcomponents/PopoverMenuFields/{index.d5efe247.js → index.9f07285e.js} +2 -2
- package/components/DynamicFilter/types.d.ts +1 -1
- package/components/FieldLabel/{index.a6235bcc.js → index.44f3e099.js} +3 -3
- package/components/GridLayout/{index.14b734d6.js → index.a9f419d8.js} +2 -2
- package/components/GridLayout/subcomponents/Griditem/{index.5c8546c8.js → index.c9f8165b.js} +1 -1
- package/components/GridLayout/subcomponents/Responsive/{index.6646c077.js → index.ad80dae3.js} +1 -1
- package/components/GridLayout/subcomponents/SizeProvider/{index.1108dd01.js → index.6ebe8790.js} +1 -1
- package/components/HelperText/{index.b1961313.js → index.e9eddfe4.js} +2 -2
- package/components/Icon/{index.e06c693f.js → index.2b591dd6.js} +3 -3
- package/components/Image/{index.8a3d05d3.js → index.fb9e71ba.js} +2 -2
- package/components/LanguagePopover/{index.25266514.js → index.f495b317.js} +4 -4
- package/components/LinearProgressIndeterminate/{index.80f8b74d.js → index.8a0b3615.js} +1 -1
- package/components/LoadingError/{index.81979bb3.js → index.2675dde0.js} +5 -5
- package/components/MFIsolationApp/{index.3125cd12.js → index.359ce9ec.js} +2 -2
- package/components/MFLoader/{index.952a3fee.js → index.49a6bd2c.js} +2 -2
- package/components/ModalDialog/{index.0dba90d3.js → index.3571068b.js} +3 -3
- package/components/NavLink/{index.0c844a30.js → index.82f5f2f4.js} +2 -2
- package/components/NoItemSelected/{index.dd2cee48.js → index.437fb106.js} +1 -1
- package/components/ObjectLogs/{index.f98e884b.js → index.5d260f34.js} +9 -9
- package/components/PDFViewer/{index.1b7068e5.js → index.9f1d12c4.js} +2 -2
- package/components/Page/{index.fa45b3d5.js → index.4e1e1b9b.js} +1 -1
- package/components/PaperForm/{index.f1467e34.js → index.d6293e64.js} +2 -2
- package/components/Period/{index.732248a8.js → index.f0095a0a.js} +4 -4
- package/components/PrintingSystem/{index.7aed44a2.js → index.88fbf9ec.js} +13 -13
- package/components/PrintingSystem/subcomponents/BodyNode/{index.3e82f72e.js → index.79cb87c7.js} +1 -1
- package/components/PrintingSystem/subcomponents/ChartNode/{index.8d4e4894.js → index.a5d910d6.js} +1 -1
- package/components/PrintingSystem/subcomponents/DividerNode/{index.f9343c1f.js → index.350c25de.js} +1 -1
- package/components/PrintingSystem/subcomponents/FooterNode/{index.1cdf54cf.js → index.8c2f7536.js} +1 -1
- package/components/PrintingSystem/subcomponents/GridNode/{index.32a2e08a.js → index.b02b56db.js} +1 -1
- package/components/PrintingSystem/subcomponents/HeaderNode/{index.715f4e49.js → index.462d6322.js} +1 -1
- package/components/PrintingSystem/subcomponents/PaperNode/{index.92df744d.js → index.a5e25147.js} +1 -1
- package/components/PrintingSystem/subcomponents/PropertyValueNode/{index.4316a07a.js → index.430bd242.js} +1 -1
- package/components/PrintingSystem/subcomponents/SectionNode/{index.21b9d770.js → index.d76d27d3.js} +1 -1
- package/components/PrintingSystem/subcomponents/TextBoxNode/{index.03e73c9d.js → index.2dcd8991.js} +1 -1
- package/components/PropertyValue/{index.f85c4118.js → index.5d847b88.js} +3 -3
- package/components/Resizeable/{index.305dae8c.js → index.f22bccb6.js} +1 -1
- package/components/ScrollBar/{index.9c677335.js → index.3f1ca3da.js} +1 -1
- package/components/SideBar/{index.d33d87f4.js → index.f15b9904.js} +5 -5
- package/components/SplitLayout/{index.a5414b61.js → index.4b247e0c.js} +1 -1
- package/components/ToastContainer/{index.ce752150.js → index.dec47e74.js} +2 -2
- package/components/animate/LoadingScreen/{index.881ca784.js → index.db36f970.js} +1 -1
- package/components/animate/{index.d6f073fe.js → index.14aa2d3c.js} +1 -1
- package/components/areas/components/AreasAdmin/{index.80da2678.js → index.55c40f0c.js} +14 -14
- package/components/areas/components/AreasViewer/{index.7836a623.js → index.8a568629.js} +13 -13
- package/components/areas/contexts/AreasContext/{index.c4e41ac3.js → index.c677ccfa.js} +4 -4
- package/components/areas/hooks/useAreas/{index.cf3f35fa.js → index.2d10f64c.js} +1 -1
- package/components/commercial/AppBarCommercial/{index.00571293.js → index.85de55bb.js} +1 -1
- package/components/commercial/SectionCommercial/{index.c3f56cb3.js → index.47c0cb0c.js} +1 -1
- package/components/commercial/TopBar/{index.56ade547.js → index.ec7a6cc6.js} +5 -5
- package/components/commercial/{index.788464b6.js → index.90e72726.js} +3 -3
- package/components/formatters/BooleanFormatter/{index.6f664715.js → index.5243a181.js} +2 -2
- package/components/formatters/{index.d1846e98.js → index.1b738709.js} +2 -2
- package/components/hook-form/HelperError/{index.a0faefe4.js → index.c6f8f840.js} +1 -1
- package/components/hook-form/RHFAutocomplete/RHFAutocomplete.d.ts +1 -1
- package/components/hook-form/RHFAutocomplete/classes/index.d.ts +1 -2
- package/components/hook-form/RHFAutocomplete/classes/types.d.ts +0 -1
- package/components/hook-form/RHFAutocomplete/{index.dab5e2d6.js → index.c8bcfed8.js} +302 -70
- package/components/hook-form/RHFAutocomplete/subcomponents/ComponentTypeImage/index.d.ts +2 -0
- package/components/hook-form/RHFAutocomplete/subcomponents/ComponentTypeText/index.d.ts +2 -0
- package/components/hook-form/RHFAutocomplete/subcomponents/RenderOption/index.d.ts +1 -1
- package/components/hook-form/RHFAutocomplete/subcomponents/Skeleton/types.d.ts +1 -1
- package/components/hook-form/RHFAutocomplete/types.d.ts +17 -9
- package/components/hook-form/RHFAutocompleteAsync/{index.a61e7dda.js → index.2b2ff592.js} +102 -5
- package/components/hook-form/RHFAutocompleteAsync/subcomponents/ComponentTypeImage/index.d.ts +3 -0
- package/components/hook-form/RHFAutocompleteAsync/subcomponents/ComponentTypeText/index.d.ts +2 -0
- package/components/hook-form/RHFAutocompleteAsync/types.d.ts +6 -3
- package/components/hook-form/RHFCheckbox/{index.71751a9d.js → index.06c0b776.js} +3 -3
- package/components/hook-form/RHFColorPicker/{index.3a8f36b1.js → index.f606dce6.js} +6 -6
- package/components/hook-form/RHFDateTime/{index.2f4ce21c.js → index.fb4867fa.js} +4 -4
- package/components/hook-form/RHFPeriod/{index.acf46fb2.js → index.75e07583.js} +4 -4
- package/components/hook-form/RHFRadioGroup/RHFRadioGroup.d.ts +1 -1
- package/components/hook-form/RHFRadioGroup/formatters/OptionIconLabelFormatter/index.d.ts +2 -0
- package/components/hook-form/RHFRadioGroup/index.a0a28a48.js +52 -0
- package/components/hook-form/RHFRadioGroup/types.d.ts +10 -4
- package/components/hook-form/RHFTextField/{index.06342648.js → index.257c6486.js} +4 -4
- package/components/hook-form/RHFUpload/{index.ef58c607.js → index.a6954d0d.js} +5 -5
- package/components/maps/components/GpsTools/{index.3cc627c5.js → index.30fe41d1.js} +28 -25
- package/components/maps/components/Map/external/Control/index.d.ts +1 -1
- package/components/maps/components/Map/{index.c50fc538.js → index.14f082d4.js} +30 -26
- package/components/modal/{WindowBase.af49e2e8.js → WindowBase.0dc3b3ea.js} +3 -3
- package/components/modal/{WindowConfirm.141e19a9.js → WindowConfirm.b8a431dd.js} +6 -6
- package/components/mui_extended/Accordion/{index.e76a8701.js → index.bb0cd2ab.js} +4 -4
- package/components/mui_extended/Avatar/{index.fc674f4b.js → index.bcf4d669.js} +1 -1
- package/components/mui_extended/Badge/{index.615959af.js → index.89ca5b23.js} +1 -1
- package/components/mui_extended/Button/{index.a391ee9f.js → index.24b9496b.js} +3 -3
- package/components/mui_extended/{CheckBox.ae30825c.js → CheckBox.4d930bed.js} +2 -2
- package/components/mui_extended/IconButton/{index.97e91dae.js → index.f5dcf537.js} +2 -2
- package/components/mui_extended/MenuActions/{index.1092605e.js → index.540d82fd.js} +5 -5
- package/components/mui_extended/Pager/classes/index.d.ts +1 -1
- package/components/mui_extended/Pager/{index.4d510ef5.js → index.f3a6c94b.js} +4 -4
- package/components/mui_extended/Popover/{index.82970357.js → index.6d8fe229.js} +1 -1
- package/components/mui_extended/Stack/{index.e64a379b.js → index.9d6ed8c2.js} +1 -1
- package/components/mui_extended/Tab/{index.f31eb904.js → index.0941bb3a.js} +1 -1
- package/components/mui_extended/ToggleButton/{index.4afacb33.js → index.d45c7a60.js} +1 -1
- package/components/mui_extended/ToggleIconButton/{index.621ff8bc.js → index.c51670d1.js} +1 -1
- package/components/mui_extended/Typography/{index.8a0f958b.js → index.dbc44e77.js} +1 -1
- package/components/popups/PopupsProvider/{index.6591c56e.js → index.776c62e7.js} +8 -34
- package/components/popups/PopupsViewer/constants.29247547.js +4 -0
- package/components/popups/PopupsViewer/icons.066abd43.js +7 -0
- package/components/popups/PopupsViewer/{index.caf23a5d.js → index.6a175b73.js} +43 -78
- package/components/popups/PopupsViewer/slots/index.154e4e5f.js +14 -0
- package/components/popups/PopupsViewer/slots/popupsViewerSlots.be9219c7.js +39 -0
- package/components/popups/components/PopupsProvider/contexts/PopupsContext/store.d.ts +1 -1
- package/components/popups/components/PopupsProvider/contexts/PopupsContext/types.d.ts +27 -47
- package/components/popups/components/PopupsViewer/PopupsViewer.d.ts +1 -2
- package/components/popups/components/PopupsViewer/constants.d.ts +1 -1
- package/components/popups/components/PopupsViewer/slots/popupsViewerSlots.d.ts +25 -0
- package/components/popups/components/PopupsViewer/slots/slots.d.ts +10 -0
- package/components/popups/components/PopupsViewer/types.d.ts +17 -3
- package/contexts/ModalContext/{index.8281527d.js → index.26017754.js} +1 -1
- package/contexts/RHFormContext/{index.939811b3.js → index.54d30cb2.js} +1 -1
- package/hooks/useFormAddEdit/{index.dfb5570d.js → index.bd4ae2a5.js} +2 -2
- package/hooks/useModal/{index.538e8219.js → index.d3c18b29.js} +1 -1
- package/hooks/useTab/{index.bc8d38fc.js → index.da9b5a24.js} +1 -1
- package/index.js +123 -119
- package/package.json +1 -1
- package/styles/PopupViewer.styles.d.ts +2 -0
- package/styles/{index.7868464e.js → index.d972f170.js} +101 -11
- package/components/hook-form/RHFRadioGroup/index.11c0add8.js +0 -35
- package/components/popups/components/PopupsProvider/contexts/PopupsContext/helper.d.ts +0 -7
- package/components/popups/components/PopupsViewer/classes/index.d.ts +0 -17
- package/components/popups/components/PopupsViewer/classes/types.d.ts +0 -15
- package/components/popups/components/PopupsViewer/styled.d.ts +0 -2
|
@@ -1,61 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useMemo, useRef, useState, useEffect
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { createElement, useMemo, useRef, useState, useEffect } from "react";
|
|
3
3
|
import { useModuleDictionary, useModuleSkeleton, useEnvironment } from "@m4l/core";
|
|
4
|
+
import { useFormFocus } from "../../../index.js";
|
|
5
|
+
import { generateUtilityClasses, generateUtilityClass, Skeleton, useTheme, Autocomplete, Popper, TextField, Chip } from "@mui/material";
|
|
6
|
+
import { useResponsiveDesktop } from "@m4l/graphics";
|
|
4
7
|
import { useFormContext, Controller } from "react-hook-form";
|
|
5
|
-
import { Skeleton, generateUtilityClasses, generateUtilityClass, useTheme, Autocomplete, Popper, TextField, Chip } from "@mui/material";
|
|
6
|
-
import { ag as WrapperOption, ah as AutocompleteRoot } from "../../../styles/index.7868464e.js";
|
|
7
|
-
import { I as Image } from "../../Image/index.8a3d05d3.js";
|
|
8
|
-
import { T as TEST_PROP_ID } from "../../../test/constants_no_mock.86c553a9.js";
|
|
9
|
-
import { T as Typography } from "../../mui_extended/Typography/index.8a0f958b.js";
|
|
10
8
|
import { unstable_composeClasses } from "@mui/base";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
9
|
+
import { ag as WrapperOption, ah as AutocompleteRoot } from "../../../styles/index.d972f170.js";
|
|
10
|
+
import { T as TEST_PROP_ID } from "../../../test/constants_no_mock.86c553a9.js";
|
|
11
|
+
import { I as Image } from "../../Image/index.fb9e71ba.js";
|
|
12
|
+
import { T as Typography } from "../../mui_extended/Typography/index.dbc44e77.js";
|
|
13
|
+
import { H as HelperText } from "../../HelperText/index.e9eddfe4.js";
|
|
14
|
+
import { F as FieldLabel } from "../../FieldLabel/index.44f3e099.js";
|
|
15
15
|
import { C as CircularProgress } from "../../mui_extended/CircularProgress/index.967e70b7.js";
|
|
16
|
-
import { I as IconButton } from "../../mui_extended/IconButton/index.
|
|
17
|
-
const RHFAUTOCOMPLETE_PREFIX = "RHFAutocomplete";
|
|
18
|
-
const RHFTAUTOCOMPLET_ROOT_TEST_ID = "RHFAutocomplete";
|
|
19
|
-
const getNameDataTestId = (KEY) => {
|
|
20
|
-
return `${RHFAUTOCOMPLETE_PREFIX}-${KEY}`;
|
|
21
|
-
};
|
|
22
|
-
function withRenderOption(getUrlImage, classes, imageWidth) {
|
|
23
|
-
return function RenderOption(optionProps, option) {
|
|
24
|
-
return /* @__PURE__ */ jsxs(
|
|
25
|
-
WrapperOption,
|
|
26
|
-
{
|
|
27
|
-
...optionProps,
|
|
28
|
-
className: classes.withImage,
|
|
29
|
-
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameDataTestId("withImage") } : {},
|
|
30
|
-
children: [
|
|
31
|
-
/* @__PURE__ */ jsx(Image, { src: getUrlImage(option), width: imageWidth, height: "100%" }),
|
|
32
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body", children: optionProps.key })
|
|
33
|
-
]
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
const SkeletonRHFAutocomplete = (props) => {
|
|
39
|
-
const { withImage, classes, hasLabel } = props;
|
|
40
|
-
return /* @__PURE__ */ jsxs("div", { className: classes.skeletonRoot, children: [
|
|
41
|
-
(hasLabel || hasLabel?.length === 0) && /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "30%", height: "16px" }),
|
|
42
|
-
/* @__PURE__ */ jsx(
|
|
43
|
-
"div",
|
|
44
|
-
{
|
|
45
|
-
className: classes.skeleton,
|
|
46
|
-
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameDataTestId("skeleton") } : {},
|
|
47
|
-
children: !withImage ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
48
|
-
/* @__PURE__ */ jsx("div", { className: classes.skeletonContainerText, children: /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "50%", height: "14px" }) }),
|
|
49
|
-
/* @__PURE__ */ jsx(Skeleton, { variant: "circular", width: 16, height: 16, sx: { minWidth: "16px" } })
|
|
50
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
51
|
-
/* @__PURE__ */ jsx(Skeleton, { variant: "circular" }),
|
|
52
|
-
/* @__PURE__ */ jsx("div", { className: classes.skeletonContainerText, children: /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "50%", height: "14px" }) }),
|
|
53
|
-
/* @__PURE__ */ jsx(Skeleton, { variant: "circular", width: 16, height: 16, sx: { minWidth: "16px" } })
|
|
54
|
-
] })
|
|
55
|
-
}
|
|
56
|
-
)
|
|
57
|
-
] });
|
|
58
|
-
};
|
|
16
|
+
import { I as IconButton } from "../../mui_extended/IconButton/index.f5dcf537.js";
|
|
59
17
|
const componentName = "M4LRHFAutocomplete";
|
|
60
18
|
generateUtilityClasses(
|
|
61
19
|
componentName,
|
|
@@ -69,7 +27,6 @@ generateUtilityClasses(
|
|
|
69
27
|
"skeletonContainerText",
|
|
70
28
|
"iconDown",
|
|
71
29
|
"variantInfo",
|
|
72
|
-
"variantImage",
|
|
73
30
|
"isDisabled",
|
|
74
31
|
"imageWidthDefined",
|
|
75
32
|
"variantSuccess",
|
|
@@ -98,17 +55,16 @@ const useUtilityClasses = (ownerState) => {
|
|
|
98
55
|
ownerState.semantics === "success" && "variantSuccess",
|
|
99
56
|
ownerState.semantics === "warning" && "variantWarning",
|
|
100
57
|
ownerState.semantics === "error" && "variantError",
|
|
101
|
-
ownerState.imageWidthDefined && "imageWidthDefined",
|
|
102
58
|
ownerState.multiple && "multiple"
|
|
103
59
|
],
|
|
104
|
-
withImage: ["withImage"],
|
|
105
60
|
skeleton: ["skeleton"],
|
|
106
61
|
label: ["label"],
|
|
107
62
|
popper: [
|
|
108
63
|
"popper",
|
|
109
64
|
ownerState.size === "small" && "sizeSmall",
|
|
110
65
|
ownerState.size === "medium" && "sizeMedium",
|
|
111
|
-
ownerState.
|
|
66
|
+
ownerState.imageScale && "imageScale",
|
|
67
|
+
ownerState.imageRepeat && "imageRepeat"
|
|
112
68
|
],
|
|
113
69
|
skeletonRoot: ["skeletonRoot"],
|
|
114
70
|
skeletonContainerText: ["SkeletonContainerText"],
|
|
@@ -124,7 +80,48 @@ const useUtilityClasses = (ownerState) => {
|
|
|
124
80
|
...composedClasses
|
|
125
81
|
};
|
|
126
82
|
};
|
|
127
|
-
|
|
83
|
+
const RHFAUTOCOMPLETE_PREFIX = "RHFAutocomplete";
|
|
84
|
+
const RHFTAUTOCOMPLET_ROOT_TEST_ID = "RHFAutocomplete";
|
|
85
|
+
const getNameDataTestId = (KEY) => {
|
|
86
|
+
return `${RHFAUTOCOMPLETE_PREFIX}-${KEY}`;
|
|
87
|
+
};
|
|
88
|
+
function withRenderOption(getUrlImage, classes) {
|
|
89
|
+
return function RenderOption(optionProps, option) {
|
|
90
|
+
return /* @__PURE__ */ createElement(
|
|
91
|
+
WrapperOption,
|
|
92
|
+
{
|
|
93
|
+
...optionProps,
|
|
94
|
+
key: optionProps.key,
|
|
95
|
+
className: classes.withImage,
|
|
96
|
+
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameDataTestId("withImage") } : {}
|
|
97
|
+
},
|
|
98
|
+
/* @__PURE__ */ jsx(Image, { src: getUrlImage(option) }),
|
|
99
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body", children: optionProps.key })
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const SkeletonRHFAutocomplete = (props) => {
|
|
104
|
+
const { withImage, classes, hasLabel } = props;
|
|
105
|
+
return /* @__PURE__ */ jsxs("div", { className: classes.skeletonRoot, children: [
|
|
106
|
+
(hasLabel || hasLabel?.length === 0) && /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "30%", height: "16px" }),
|
|
107
|
+
/* @__PURE__ */ jsx(
|
|
108
|
+
"div",
|
|
109
|
+
{
|
|
110
|
+
className: classes.skeleton,
|
|
111
|
+
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameDataTestId("skeleton") } : {},
|
|
112
|
+
children: !withImage ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
113
|
+
/* @__PURE__ */ jsx("div", { className: classes.skeletonContainerText, children: /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "50%", height: "14px" }) }),
|
|
114
|
+
/* @__PURE__ */ jsx(Skeleton, { variant: "circular", width: 16, height: 16, sx: { minWidth: "16px" } })
|
|
115
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
116
|
+
/* @__PURE__ */ jsx(Skeleton, { variant: "circular" }),
|
|
117
|
+
/* @__PURE__ */ jsx("div", { className: classes.skeletonContainerText, children: /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "50%", height: "14px" }) }),
|
|
118
|
+
/* @__PURE__ */ jsx(Skeleton, { variant: "circular", width: 16, height: 16, sx: { minWidth: "16px" } })
|
|
119
|
+
] })
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
] });
|
|
123
|
+
};
|
|
124
|
+
function ComponentTypeImage(props) {
|
|
128
125
|
const {
|
|
129
126
|
name: nameRHF,
|
|
130
127
|
getOptionLabel,
|
|
@@ -142,11 +139,11 @@ function RHFAutocomplete(props) {
|
|
|
142
139
|
helperMessage,
|
|
143
140
|
size = "small",
|
|
144
141
|
onChangeFilterParmsLocal,
|
|
145
|
-
imageWidth,
|
|
146
|
-
imageHeight,
|
|
147
142
|
mandatory,
|
|
148
143
|
mandatoryMessage,
|
|
149
144
|
multiple,
|
|
145
|
+
imageScale = true,
|
|
146
|
+
imageRepeat,
|
|
150
147
|
...other
|
|
151
148
|
} = props;
|
|
152
149
|
const { getLabel } = useModuleDictionary();
|
|
@@ -207,8 +204,9 @@ function RHFAutocomplete(props) {
|
|
|
207
204
|
isTabSelected: !isSkeleton ? isTabSelected : false,
|
|
208
205
|
semantics: currentVariant,
|
|
209
206
|
disabled,
|
|
210
|
-
|
|
211
|
-
|
|
207
|
+
multiple: Boolean(multiple),
|
|
208
|
+
imageScale: Boolean(imageScale),
|
|
209
|
+
imageRepeat: Boolean(imageRepeat)
|
|
212
210
|
};
|
|
213
211
|
const classes = useUtilityClasses(ownerState);
|
|
214
212
|
const theme = useTheme();
|
|
@@ -266,6 +264,7 @@ function RHFAutocomplete(props) {
|
|
|
266
264
|
inputValue,
|
|
267
265
|
clearOnBlur: false,
|
|
268
266
|
PopperComponent: (popperProps) => {
|
|
267
|
+
console.log("popper debug");
|
|
269
268
|
return /* @__PURE__ */ jsx(
|
|
270
269
|
Popper,
|
|
271
270
|
{
|
|
@@ -306,7 +305,7 @@ function RHFAutocomplete(props) {
|
|
|
306
305
|
loadingText: /* @__PURE__ */ jsx(Typography, { variant: "body", children: getLabel("rhf_autocomplete.loading_options") }),
|
|
307
306
|
disabled,
|
|
308
307
|
noOptionsText: getLabel("rhf_autocomplete.no_options"),
|
|
309
|
-
renderOption:
|
|
308
|
+
renderOption: withRenderOption(getOptionUrlImageLocal, classes),
|
|
310
309
|
renderInput: (params) => {
|
|
311
310
|
return /* @__PURE__ */ jsx(
|
|
312
311
|
TextField,
|
|
@@ -325,9 +324,7 @@ function RHFAutocomplete(props) {
|
|
|
325
324
|
!multiple && withImage && value ? /* @__PURE__ */ jsx(
|
|
326
325
|
Image,
|
|
327
326
|
{
|
|
328
|
-
src: getOptionUrlImageLocal(value)
|
|
329
|
-
width: imageWidth,
|
|
330
|
-
height: "100%"
|
|
327
|
+
src: getOptionUrlImageLocal(value)
|
|
331
328
|
},
|
|
332
329
|
"ImageTextField"
|
|
333
330
|
) : null,
|
|
@@ -365,9 +362,7 @@ function RHFAutocomplete(props) {
|
|
|
365
362
|
icon: withImage && option ? /* @__PURE__ */ jsx(
|
|
366
363
|
Image,
|
|
367
364
|
{
|
|
368
|
-
src: getOptionUrlImageLocal(option)
|
|
369
|
-
width: imageWidth,
|
|
370
|
-
height: imageHeight ?? "100%"
|
|
365
|
+
src: getOptionUrlImageLocal(option)
|
|
371
366
|
}
|
|
372
367
|
) : void 0,
|
|
373
368
|
sx: {
|
|
@@ -387,6 +382,243 @@ function RHFAutocomplete(props) {
|
|
|
387
382
|
}
|
|
388
383
|
);
|
|
389
384
|
}
|
|
385
|
+
function ComponentTypeText(props) {
|
|
386
|
+
const {
|
|
387
|
+
name: nameRHF,
|
|
388
|
+
getOptionLabel,
|
|
389
|
+
isOptionEqualToValue,
|
|
390
|
+
label,
|
|
391
|
+
skeletonWidth = 100,
|
|
392
|
+
skeletonHeight = "18px",
|
|
393
|
+
options,
|
|
394
|
+
disabled,
|
|
395
|
+
onOpen,
|
|
396
|
+
onClose,
|
|
397
|
+
loading,
|
|
398
|
+
variant,
|
|
399
|
+
helperMessage,
|
|
400
|
+
size = "small",
|
|
401
|
+
onChangeFilterParmsLocal,
|
|
402
|
+
mandatory,
|
|
403
|
+
mandatoryMessage,
|
|
404
|
+
multiple,
|
|
405
|
+
...other
|
|
406
|
+
} = props;
|
|
407
|
+
const { getLabel } = useModuleDictionary();
|
|
408
|
+
const isSkeleton = useModuleSkeleton();
|
|
409
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
410
|
+
const { isFocus, isTabSelected, handlerFocus, handlerOnKeyUp, handlerOnBlur } = useFormFocus();
|
|
411
|
+
const autocompleteRef = useRef(null);
|
|
412
|
+
const [open, setOpen] = useState(false);
|
|
413
|
+
const isDesktop = useResponsiveDesktop();
|
|
414
|
+
const onCloseLocal = (event, reason) => {
|
|
415
|
+
setOpen(false);
|
|
416
|
+
if (onClose)
|
|
417
|
+
onClose(event, reason);
|
|
418
|
+
};
|
|
419
|
+
const onOpenLocal = (event) => {
|
|
420
|
+
setOpen(true);
|
|
421
|
+
if (onOpen)
|
|
422
|
+
onOpen(event);
|
|
423
|
+
};
|
|
424
|
+
const getOptionLabelLocal = (option) => {
|
|
425
|
+
if (option === void 0 || option === null) {
|
|
426
|
+
return "";
|
|
427
|
+
}
|
|
428
|
+
return getOptionLabel(option);
|
|
429
|
+
};
|
|
430
|
+
const isOptionEqualToValueLocal = (option, value) => {
|
|
431
|
+
if (value === void 0 || value === null || option === null) {
|
|
432
|
+
return false;
|
|
433
|
+
}
|
|
434
|
+
return isOptionEqualToValue(option, value);
|
|
435
|
+
};
|
|
436
|
+
const {
|
|
437
|
+
control,
|
|
438
|
+
formState: { errors }
|
|
439
|
+
} = useFormContext();
|
|
440
|
+
const [currentVariant, setCurrentVariant] = useState(
|
|
441
|
+
null
|
|
442
|
+
);
|
|
443
|
+
useEffect(() => {
|
|
444
|
+
if (errors[nameRHF]) {
|
|
445
|
+
setCurrentVariant("error");
|
|
446
|
+
} else if (variant) {
|
|
447
|
+
setCurrentVariant(variant);
|
|
448
|
+
} else {
|
|
449
|
+
setCurrentVariant(null);
|
|
450
|
+
}
|
|
451
|
+
}, [errors[nameRHF], variant, control]);
|
|
452
|
+
const ownerState = {
|
|
453
|
+
size: !isDesktop ? "medium" : size,
|
|
454
|
+
isFocus: !isSkeleton ? isFocus : false,
|
|
455
|
+
isTabSelected: !isSkeleton ? isTabSelected : false,
|
|
456
|
+
semantics: currentVariant,
|
|
457
|
+
disabled,
|
|
458
|
+
multiple: Boolean(multiple)
|
|
459
|
+
};
|
|
460
|
+
const classes = useUtilityClasses(ownerState);
|
|
461
|
+
const theme = useTheme();
|
|
462
|
+
return /* @__PURE__ */ jsx(
|
|
463
|
+
AutocompleteRoot,
|
|
464
|
+
{
|
|
465
|
+
className: classes.root,
|
|
466
|
+
tabIndex: 0,
|
|
467
|
+
onFocus: handlerFocus,
|
|
468
|
+
onBlur: handlerOnBlur,
|
|
469
|
+
onKeyUp: handlerOnKeyUp,
|
|
470
|
+
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: `${RHFTAUTOCOMPLET_ROOT_TEST_ID}_${nameRHF}` } : {},
|
|
471
|
+
children: !isSkeleton ? /* @__PURE__ */ jsx(
|
|
472
|
+
Controller,
|
|
473
|
+
{
|
|
474
|
+
name: nameRHF,
|
|
475
|
+
control,
|
|
476
|
+
render: ({ field: { onChange, value }, fieldState: { error } }) => {
|
|
477
|
+
const [inputValue, setInputValue] = useState(getOptionLabelLocal(value));
|
|
478
|
+
useEffect(() => {
|
|
479
|
+
if (!open && value === null && inputValue !== "") {
|
|
480
|
+
setInputValue("");
|
|
481
|
+
}
|
|
482
|
+
if (!open && value !== null && options.length === 0) {
|
|
483
|
+
onChangeFilterParmsLocal?.(getOptionLabelLocal(value), "reset");
|
|
484
|
+
}
|
|
485
|
+
}, [value]);
|
|
486
|
+
const checkKeyDown = (e) => {
|
|
487
|
+
if (e.code === "Enter")
|
|
488
|
+
e.preventDefault();
|
|
489
|
+
};
|
|
490
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
491
|
+
label && /* @__PURE__ */ jsx(
|
|
492
|
+
FieldLabel,
|
|
493
|
+
{
|
|
494
|
+
className: classes.label,
|
|
495
|
+
label,
|
|
496
|
+
mandatory,
|
|
497
|
+
mandatoryMessage,
|
|
498
|
+
helperMessage
|
|
499
|
+
}
|
|
500
|
+
),
|
|
501
|
+
/* @__PURE__ */ jsx(
|
|
502
|
+
Autocomplete,
|
|
503
|
+
{
|
|
504
|
+
autoComplete: true,
|
|
505
|
+
disableClearable: true,
|
|
506
|
+
multiple,
|
|
507
|
+
onKeyDown: checkKeyDown,
|
|
508
|
+
size,
|
|
509
|
+
ref: autocompleteRef,
|
|
510
|
+
autoSelect: false,
|
|
511
|
+
options,
|
|
512
|
+
getOptionLabel: getOptionLabelLocal,
|
|
513
|
+
inputValue,
|
|
514
|
+
clearOnBlur: false,
|
|
515
|
+
PopperComponent: (popperProps) => {
|
|
516
|
+
return /* @__PURE__ */ jsx(
|
|
517
|
+
Popper,
|
|
518
|
+
{
|
|
519
|
+
...popperProps,
|
|
520
|
+
className: classes.popper,
|
|
521
|
+
placement: "bottom-start",
|
|
522
|
+
sx: {
|
|
523
|
+
...theme.components?.M4LRHFAutocompletePopover?.styleOverrides
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
);
|
|
527
|
+
},
|
|
528
|
+
onInputChange: (_event, newValue, reason) => {
|
|
529
|
+
if (reason === "input") {
|
|
530
|
+
setInputValue(newValue);
|
|
531
|
+
if (onChangeFilterParmsLocal) {
|
|
532
|
+
onChangeFilterParmsLocal(newValue, reason);
|
|
533
|
+
}
|
|
534
|
+
} else {
|
|
535
|
+
onChange(null);
|
|
536
|
+
}
|
|
537
|
+
},
|
|
538
|
+
isOptionEqualToValue: isOptionEqualToValueLocal,
|
|
539
|
+
value: Array.isArray(value) ? value : multiple ? value ? [value] : [] : value || null,
|
|
540
|
+
onOpen: onOpenLocal,
|
|
541
|
+
onClose: onCloseLocal,
|
|
542
|
+
open,
|
|
543
|
+
onChange: (_e, newValue) => {
|
|
544
|
+
if (!multiple && !Array.isArray(newValue)) {
|
|
545
|
+
setInputValue(getOptionLabelLocal(newValue));
|
|
546
|
+
} else {
|
|
547
|
+
setInputValue("");
|
|
548
|
+
}
|
|
549
|
+
onChange(Array.isArray(newValue) ? [...newValue] : newValue);
|
|
550
|
+
},
|
|
551
|
+
filterOptions: onChangeFilterParmsLocal ? (x) => x : void 0,
|
|
552
|
+
loading,
|
|
553
|
+
loadingText: /* @__PURE__ */ jsx(Typography, { variant: "body", children: getLabel("rhf_autocomplete.loading_options") }),
|
|
554
|
+
disabled,
|
|
555
|
+
noOptionsText: getLabel("rhf_autocomplete.no_options"),
|
|
556
|
+
renderOption: void 0,
|
|
557
|
+
renderInput: (params) => {
|
|
558
|
+
return /* @__PURE__ */ jsx(
|
|
559
|
+
TextField,
|
|
560
|
+
{
|
|
561
|
+
...params,
|
|
562
|
+
InputLabelProps: {
|
|
563
|
+
...params.InputLabelProps,
|
|
564
|
+
shrink: true
|
|
565
|
+
},
|
|
566
|
+
fullWidth: true,
|
|
567
|
+
size,
|
|
568
|
+
SelectProps: { native: true },
|
|
569
|
+
InputProps: {
|
|
570
|
+
...params.InputProps,
|
|
571
|
+
startAdornment: /* @__PURE__ */ jsx(Fragment, { children: params.InputProps.startAdornment }),
|
|
572
|
+
endAdornment: loading ? /* @__PURE__ */ jsx(CircularProgress, { color: "inherit", size: 18 }) : /* @__PURE__ */ jsx(
|
|
573
|
+
IconButton,
|
|
574
|
+
{
|
|
575
|
+
className: classes.iconDown,
|
|
576
|
+
src: `${host_static_assets}/${environment_assets}/frontend/components/RHFAutocompletarAsync/assets/icons/chevronDown.svg`,
|
|
577
|
+
onClick: (event) => onOpenLocal(event),
|
|
578
|
+
disabled,
|
|
579
|
+
size
|
|
580
|
+
}
|
|
581
|
+
)
|
|
582
|
+
},
|
|
583
|
+
autoComplete: "off",
|
|
584
|
+
error: !!error,
|
|
585
|
+
...other
|
|
586
|
+
}
|
|
587
|
+
);
|
|
588
|
+
},
|
|
589
|
+
...multiple ? {
|
|
590
|
+
renderTags: (tagValue, getTagProps) => tagValue.map((option, index) => {
|
|
591
|
+
const { key, ...restTagProps } = getTagProps({
|
|
592
|
+
index
|
|
593
|
+
});
|
|
594
|
+
return /* @__PURE__ */ createElement(
|
|
595
|
+
Chip,
|
|
596
|
+
{
|
|
597
|
+
...restTagProps,
|
|
598
|
+
key,
|
|
599
|
+
label: getOptionLabelLocal(option),
|
|
600
|
+
className: classes.chip,
|
|
601
|
+
icon: void 0,
|
|
602
|
+
sx: {
|
|
603
|
+
...theme.components?.M4LRHFAutocompleteChip?.styleOverrides
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
);
|
|
607
|
+
})
|
|
608
|
+
} : {}
|
|
609
|
+
}
|
|
610
|
+
),
|
|
611
|
+
currentVariant === "error" ? /* @__PURE__ */ jsx(HelperText, { variant: currentVariant, message: error?.message }) : null
|
|
612
|
+
] });
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
) : /* @__PURE__ */ jsx(SkeletonRHFAutocomplete, { classes, hasLabel: label })
|
|
616
|
+
}
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
function RHFAutocomplete(props) {
|
|
620
|
+
return /* @__PURE__ */ jsx(Fragment, { children: props.type === "image" ? /* @__PURE__ */ jsx(ComponentTypeImage, { ...props }) : /* @__PURE__ */ jsx(ComponentTypeText, { ...props }) });
|
|
621
|
+
}
|
|
390
622
|
function getRHFAutocompleteComponentsDictionary() {
|
|
391
623
|
return ["rhf_autocomplete"];
|
|
392
624
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { HTMLAttributes } from 'react';
|
|
2
2
|
import { GetOptionString } from '../../types';
|
|
3
|
-
export declare function withRenderOption<T>(getUrlImage: GetOptionString<T>, classes: any
|
|
3
|
+
export declare function withRenderOption<T>(getUrlImage: GetOptionString<T>, classes: any): (optionProps: HTMLAttributes<HTMLLIElement>, option: T) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,15 +3,17 @@ import { AutocompleteCloseReason, AutocompleteInputChangeReason, TextFieldProps
|
|
|
3
3
|
import { FieldLabelProps } from '../../FieldLabel/types';
|
|
4
4
|
export declare type GetOptionString<T> = (option: T | null) => string;
|
|
5
5
|
export declare type RHFAutocompleteVariants = 'info' | 'success' | 'warning';
|
|
6
|
-
export
|
|
6
|
+
export declare type ImageProps<T> = (RHFAutocompleteTypeImageProps<T> & {
|
|
7
|
+
imageScale?: boolean;
|
|
8
|
+
imageRepeat?: never;
|
|
9
|
+
}) | (RHFAutocompleteTypeImageProps<T> & {
|
|
10
|
+
imageRepeat: boolean;
|
|
11
|
+
imageScale?: never;
|
|
12
|
+
});
|
|
13
|
+
export interface RHFAutocompleteBaseProps<T> extends Omit<TextFieldProps, 'label' | 'variant'>, Omit<FieldLabelProps, 'label'> {
|
|
7
14
|
name: string;
|
|
8
15
|
options: Array<T>;
|
|
9
16
|
getOptionLabel: (option: T) => string;
|
|
10
|
-
getOptionUrlImage?: (option: T) => string;
|
|
11
|
-
/**
|
|
12
|
-
* El valor de tamaño en anchura que va a tener el elemento de imagen.
|
|
13
|
-
*/
|
|
14
|
-
imageWidth?: string | number;
|
|
15
17
|
isOptionEqualToValue: (option: T, value: T) => boolean;
|
|
16
18
|
skeletonWidth?: string | number;
|
|
17
19
|
skeletonHeight?: string | number;
|
|
@@ -22,14 +24,20 @@ export interface RHFAutocompleteProps<T> extends Omit<TextFieldProps, 'label' |
|
|
|
22
24
|
onOpen?: (event: React.SyntheticEvent) => void;
|
|
23
25
|
onClose?: (event: React.SyntheticEvent, reason: AutocompleteCloseReason) => void;
|
|
24
26
|
onChangeFilterParmsLocal?: (newValue: string, reason: AutocompleteInputChangeReason) => void;
|
|
25
|
-
imageHeight?: string | number;
|
|
26
27
|
multiple?: boolean;
|
|
27
28
|
}
|
|
28
|
-
export interface
|
|
29
|
+
export interface RHFAutocompleteTypeTextProps {
|
|
30
|
+
type: 'text';
|
|
31
|
+
}
|
|
32
|
+
export interface RHFAutocompleteTypeImageProps<T> {
|
|
33
|
+
type: 'image';
|
|
34
|
+
getOptionUrlImage: (option: T) => string;
|
|
35
|
+
}
|
|
36
|
+
export declare type RHFAutocompleteProps<T> = (RHFAutocompleteBaseProps<T> & ImageProps<T>) | (RHFAutocompleteBaseProps<T> & RHFAutocompleteTypeTextProps);
|
|
37
|
+
export interface OwnerState extends Pick<RHFAutocompleteProps<any>, 'size' | 'disabled'>, Pick<ImageProps<any>, 'imageScale' | 'imageRepeat'> {
|
|
29
38
|
isFocus: boolean;
|
|
30
39
|
isTabSelected: boolean;
|
|
31
40
|
semantics: RHFAutocompleteVariants | 'error' | null;
|
|
32
41
|
variant?: 'withImage';
|
|
33
|
-
imageWidthDefined: boolean;
|
|
34
42
|
multiple: boolean;
|
|
35
43
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useCallback, useEffect } from "react";
|
|
1
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
3
2
|
import { useNetwork, getPropertyByString } from "@m4l/core";
|
|
3
|
+
import { useState, useCallback, useEffect } from "react";
|
|
4
4
|
import debounce from "lodash/debounce";
|
|
5
|
-
import { ai as RHFAutocompleteAsyncRoot } from "../../../styles/index.7868464e.js";
|
|
6
5
|
import { generateUtilityClasses, generateUtilityClass } from "@mui/material";
|
|
7
6
|
import { unstable_composeClasses } from "@mui/base";
|
|
7
|
+
import { ai as RHFAutocompleteAsyncRoot } from "../../../styles/index.d972f170.js";
|
|
8
8
|
import { T as TEST_PROP_ID } from "../../../test/constants_no_mock.86c553a9.js";
|
|
9
|
-
import { R as RHFAutocomplete, g as getRHFAutocompleteComponentsDictionary } from "../RHFAutocomplete/index.
|
|
9
|
+
import { R as RHFAutocomplete, g as getRHFAutocompleteComponentsDictionary } from "../RHFAutocomplete/index.c8bcfed8.js";
|
|
10
10
|
const componentName = "M4LRHFAutocompleteAsync";
|
|
11
11
|
generateUtilityClasses(
|
|
12
12
|
componentName,
|
|
@@ -30,7 +30,99 @@ const RHFAUTOCOMPLETEASYNC_PREFIX = "RHFAutocompleteAsync";
|
|
|
30
30
|
const getNameDataTestId = (KEY) => {
|
|
31
31
|
return `${RHFAUTOCOMPLETEASYNC_PREFIX}-${KEY}`;
|
|
32
32
|
};
|
|
33
|
-
function
|
|
33
|
+
function ComponentTypeText(props) {
|
|
34
|
+
const {
|
|
35
|
+
name,
|
|
36
|
+
endPoint,
|
|
37
|
+
timeout = 5e3,
|
|
38
|
+
parms,
|
|
39
|
+
resultField = "data",
|
|
40
|
+
size,
|
|
41
|
+
isRemote = true,
|
|
42
|
+
onChangeFilterParms,
|
|
43
|
+
type,
|
|
44
|
+
...other
|
|
45
|
+
} = props;
|
|
46
|
+
const { networkOperation } = useNetwork();
|
|
47
|
+
const [options, setOptions] = useState([]);
|
|
48
|
+
const [open, setOpen] = useState(false);
|
|
49
|
+
const [loading, setIsloading] = useState(false);
|
|
50
|
+
const [canLoadOptions, setCanLoadOptions] = useState(true);
|
|
51
|
+
const [filterParms, setFilterParms] = useState({});
|
|
52
|
+
const debouncedFilter = useCallback(
|
|
53
|
+
debounce(
|
|
54
|
+
(newFilterParms) => {
|
|
55
|
+
setCanLoadOptions(true);
|
|
56
|
+
setFilterParms(newFilterParms);
|
|
57
|
+
},
|
|
58
|
+
300
|
|
59
|
+
),
|
|
60
|
+
[]
|
|
61
|
+
);
|
|
62
|
+
const onChangeFilterParmsLocal = (newValue) => {
|
|
63
|
+
if (onChangeFilterParms) {
|
|
64
|
+
debouncedFilter(onChangeFilterParms(newValue));
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
setCanLoadOptions(true);
|
|
69
|
+
}, [parms, endPoint]);
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (!open || loading) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (!canLoadOptions) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
setIsloading(true);
|
|
78
|
+
setOptions([]);
|
|
79
|
+
setCanLoadOptions(false);
|
|
80
|
+
networkOperation({
|
|
81
|
+
method: "GET",
|
|
82
|
+
endPoint,
|
|
83
|
+
timeout,
|
|
84
|
+
parms: { ...parms, ...filterParms },
|
|
85
|
+
isRemote
|
|
86
|
+
}).then((response) => {
|
|
87
|
+
const valueMaybeArray = getPropertyByString(response, resultField);
|
|
88
|
+
const newOptions = Array.isArray(valueMaybeArray) ? valueMaybeArray : [];
|
|
89
|
+
setOptions(newOptions);
|
|
90
|
+
}).catch(() => {
|
|
91
|
+
setCanLoadOptions(true);
|
|
92
|
+
}).finally(() => {
|
|
93
|
+
setIsloading(false);
|
|
94
|
+
});
|
|
95
|
+
return () => {
|
|
96
|
+
};
|
|
97
|
+
}, [open, parms, filterParms, endPoint]);
|
|
98
|
+
const classes = useUtilityClasses();
|
|
99
|
+
return /* @__PURE__ */ jsx(
|
|
100
|
+
RHFAutocompleteAsyncRoot,
|
|
101
|
+
{
|
|
102
|
+
className: classes.root,
|
|
103
|
+
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameDataTestId("root") } : {},
|
|
104
|
+
children: /* @__PURE__ */ jsx(
|
|
105
|
+
RHFAutocomplete,
|
|
106
|
+
{
|
|
107
|
+
type: "text",
|
|
108
|
+
name,
|
|
109
|
+
loading,
|
|
110
|
+
options,
|
|
111
|
+
onChangeFilterParmsLocal: onChangeFilterParms ? onChangeFilterParmsLocal : void 0,
|
|
112
|
+
size,
|
|
113
|
+
onOpen: () => {
|
|
114
|
+
setOpen(true);
|
|
115
|
+
},
|
|
116
|
+
onClose: () => {
|
|
117
|
+
setOpen(false);
|
|
118
|
+
},
|
|
119
|
+
...other
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
function ComponentTypeImage(props) {
|
|
34
126
|
const {
|
|
35
127
|
name,
|
|
36
128
|
endPoint,
|
|
@@ -40,6 +132,7 @@ function RHFAutocompleteAsync(props) {
|
|
|
40
132
|
size,
|
|
41
133
|
isRemote = true,
|
|
42
134
|
onChangeFilterParms,
|
|
135
|
+
type,
|
|
43
136
|
...other
|
|
44
137
|
} = props;
|
|
45
138
|
const { networkOperation } = useNetwork();
|
|
@@ -103,6 +196,7 @@ function RHFAutocompleteAsync(props) {
|
|
|
103
196
|
children: /* @__PURE__ */ jsx(
|
|
104
197
|
RHFAutocomplete,
|
|
105
198
|
{
|
|
199
|
+
type: "image",
|
|
106
200
|
name,
|
|
107
201
|
loading,
|
|
108
202
|
options,
|
|
@@ -120,6 +214,9 @@ function RHFAutocompleteAsync(props) {
|
|
|
120
214
|
}
|
|
121
215
|
);
|
|
122
216
|
}
|
|
217
|
+
function RHFAutocompleteAsync(props) {
|
|
218
|
+
return /* @__PURE__ */ jsx(Fragment, { children: props.type === "image" ? /* @__PURE__ */ jsx(ComponentTypeImage, { ...props }) : /* @__PURE__ */ jsx(ComponentTypeText, { ...props }) });
|
|
219
|
+
}
|
|
123
220
|
function getRHFAutocompleteAsyncComponentsDictionary() {
|
|
124
221
|
return getRHFAutocompleteComponentsDictionary();
|
|
125
222
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { RHFAutocompleteAsyncBaseProps } from "../../types";
|
|
2
|
+
import { ImageProps, RHFAutocompleteBaseProps } from "src/components/hook-form/RHFAutocomplete/types";
|
|
3
|
+
export declare function ComponentTypeImage<T>(props: Omit<RHFAutocompleteBaseProps<T>, 'options' | 'get'> & ImageProps<T> & RHFAutocompleteAsyncBaseProps): import("react/jsx-runtime").JSX.Element;
|