@m4l/components 1.1.2 → 2.0.1
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 +269 -269
- package/@types/types.d.ts +34 -34
- package/components/AccountPopover/{index.84049a50.js → index.68a8c117.js} +3 -3
- package/components/AppBar/{index.22ed1a0e.js → index.09ac84de.js} +4 -4
- package/components/BaseModule/{index.0fc648c5.js → index.51f3fd59.js} +1 -1
- package/components/CommonActions/components/ActionCancel/{index.33cf608e.js → index.f6c15443.js} +2 -2
- package/components/CommonActions/components/ActionFormCancel/{index.d1359a38.js → index.33d49d50.js} +4 -4
- package/components/CommonActions/components/ActionFormIntro/{index.415de2bb.js → index.0e78a223.js} +2 -2
- package/components/CommonActions/components/ActionIntro/{index.0893587b.js → index.73b33789.js} +2 -2
- package/components/CommonActions/components/Actions/{index.2342a37e.js → index.c7fab394.js} +2 -2
- package/components/DataGrid/assets/icons/datagrid.svg +4 -4
- package/components/DataGrid/formatters/ColumnBooleanFormatter/{index.9d6f8597.js → index.0a1b3610.js} +1 -1
- package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/{index.9bcaba12.js → index.30890ddd.js} +1 -1
- package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/{index.a58a8712.js → index.9aa14799.js} +1 -1
- package/components/DataGrid/formatters/{index.6698b419.js → index.90ed715b.js} +2 -2
- package/components/DataGrid/{index.b1cac6af.js → index.58b8d903.js} +4 -4
- package/components/DataGrid/subcomponents/Actions/{index.a60b17d5.js → index.ea70129c.js} +11 -11
- package/components/DragResizeWindow/DragResizeWindow.d.ts +1 -1
- package/components/DragResizeWindow/{index.46048367.js → index.8c51fb79.js} +3 -3
- package/components/DynamicFilter/{dictionary.da256925.js → dictionary.10bebb21.js} +2 -2
- package/components/DynamicFilter/{index.08abfc2c.js → index.a978aea9.js} +4 -4
- package/components/DynamicFilter/slots/{dynamicFilterSlots.b02bff6a.js → dynamicFilterSlots.26eaa1b1.js} +6 -6
- package/components/DynamicFilter/store/{index.1e4af8b4.js → index.81a5dd49.js} +1 -1
- package/components/DynamicFilter/subcomponents/AppliedFilterChip/{index.37bcd016.js → index.bc09a76f.js} +3 -3
- package/components/DynamicFilter/subcomponents/AppliedFilters/{index.2740f285.js → index.891b913a.js} +4 -4
- package/components/DynamicFilter/subcomponents/DynamicFilterBase/{index.63102514.js → index.8fbcaf0f.js} +6 -6
- package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/{index.3824d701.js → index.699a1d82.js} +4 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/{index.57ddf344.js → index.59293b05.js} +5 -4
- package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/{index.7beac9f0.js → index.ca652641.js} +4 -3
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/{index.e9e1af93.js → index.22eac312.js} +5 -4
- package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/{index.d27a8bcc.js → index.3e2ae583.js} +4 -3
- package/components/DynamicFilter/subcomponents/FieldTypes/{index.e8f1d8e5.js → index.0abab72e.js} +5 -5
- package/components/DynamicFilter/subcomponents/FilterActions/{index.35014c15.js → index.06e8baff.js} +3 -3
- package/components/DynamicFilter/subcomponents/InputFilter/{index.f42e9571.js → index.b312fd70.js} +4 -4
- package/components/DynamicFilter/subcomponents/PopoverFilter/{index.ada7eb0c.js → index.eeb15b54.js} +6 -6
- package/components/DynamicFilter/subcomponents/PopoverMenuFields/{index.144885cf.js → index.43857f7a.js} +2 -2
- package/components/DynamicFilter/types.d.ts +1 -1
- package/components/FieldLabel/{index.59b9b63a.js → index.2aaaac6f.js} +4 -4
- package/components/GridLayout/{index.56c3f4fa.js → index.2f9a1cff.js} +2 -2
- package/components/GridLayout/subcomponents/Griditem/{index.02bcb3b3.js → index.f904e69e.js} +3 -3
- package/components/GridLayout/subcomponents/Responsive/{index.65aeef5e.js → index.ef62bea3.js} +1 -1
- package/components/GridLayout/subcomponents/SizeProvider/{index.0aad6f90.js → index.2707f196.js} +1 -1
- package/components/HelperText/{index.5c72277a.js → index.25891eda.js} +2 -2
- package/components/Icon/{index.13aaae3c.js → index.89dba21c.js} +3 -3
- package/components/Image/{index.4b51d4ba.js → index.94949e55.js} +2 -2
- package/components/LanguagePopover/{index.7605fda8.js → index.54aff144.js} +4 -4
- package/components/LinearProgressIndeterminate/{index.292a4af8.js → index.e25f9201.js} +2 -2
- package/components/LoadingError/{index.b129b573.js → index.ef15a461.js} +5 -5
- package/components/MFIsolationApp/{index.9f718621.js → index.083fad1c.js} +2 -2
- package/components/MFLoader/{index.5d340e32.js → index.342598a8.js} +2 -2
- package/components/ModalDialog/{index.ff275011.js → index.545ef5eb.js} +4 -4
- package/components/NavLink/{index.506c7827.js → index.6a6f3671.js} +2 -2
- package/components/NoItemSelected/{index.1d7d5a9d.js → index.0d1e8d29.js} +1 -1
- package/components/ObjectLogs/{index.473ebd65.js → index.32555956.js} +9 -9
- package/components/PDFViewer/{index.4e7ffac8.js → index.e909be56.js} +2 -2
- package/components/Page/{index.b75c74e3.js → index.d42de29f.js} +1 -1
- package/components/PaperForm/{index.8289409f.js → index.dbcbd677.js} +2 -2
- package/components/Period/{index.13e4c351.js → index.76c4e428.js} +4 -4
- package/components/PrintingSystem/{index.e1535b80.js → index.3381ece1.js} +14 -14
- package/components/PrintingSystem/subcomponents/BodyNode/{index.6b36842d.js → index.da4c231c.js} +1 -1
- package/components/PrintingSystem/subcomponents/ChartNode/{index.4aab9d2c.js → index.4871c76e.js} +1 -1
- package/components/PrintingSystem/subcomponents/DividerNode/{index.23a9dc95.js → index.f768c90f.js} +1 -1
- package/components/PrintingSystem/subcomponents/FooterNode/{index.d0e8fd15.js → index.725664fd.js} +1 -1
- package/components/PrintingSystem/subcomponents/GridNode/{index.35ff7dab.js → index.caebf8e6.js} +1 -1
- package/components/PrintingSystem/subcomponents/HeaderNode/{index.9547c826.js → index.a5f20406.js} +1 -1
- package/components/PrintingSystem/subcomponents/PaperNode/{index.71afe03e.js → index.6d2ed690.js} +1 -1
- package/components/PrintingSystem/subcomponents/PropertyValueNode/{index.abbb154c.js → index.ec9d332c.js} +1 -1
- package/components/PrintingSystem/subcomponents/SectionNode/{index.b3f2ba6c.js → index.e9449a3f.js} +1 -1
- package/components/PrintingSystem/subcomponents/TextBoxNode/{index.809aaad2.js → index.bf55f5a7.js} +1 -1
- package/components/PropertyValue/{index.36555931.js → index.9dd592cd.js} +3 -3
- package/components/Resizeable/{index.57363836.js → index.6cbe80f0.js} +1 -1
- package/components/ScrollBar/{index.236e2aa3.js → index.aedb43d9.js} +1 -1
- package/components/SideBar/{index.bb6c2c7b.js → index.edd76204.js} +6 -6
- package/components/SplitLayout/{index.75953afb.js → index.5289a660.js} +1 -1
- package/components/ToastContainer/{index.bb972338.js → index.8f9f75e9.js} +3 -3
- package/components/animate/LoadingScreen/{index.09915798.js → index.c5cf3b93.js} +1 -1
- package/components/animate/{index.5c545243.js → index.9c9ee071.js} +1 -1
- package/components/areas/components/AreasAdmin/{index.42d40964.js → index.a52bb40d.js} +15 -15
- package/components/areas/components/AreasViewer/{index.266a3815.js → index.de8df5d3.js} +15 -15
- package/components/areas/contexts/AreasContext/{index.c2289888.js → index.514df5ff.js} +4 -13
- package/components/areas/contexts/AreasContext/types.d.ts +1 -6
- package/components/areas/hooks/useAreas/{index.509c1703.js → index.6c943645.js} +1 -1
- package/components/areas/types.d.ts +1 -1
- package/components/commercial/AppBarCommercial/{index.3fd10868.js → index.cac50795.js} +2 -2
- package/components/commercial/SectionCommercial/{index.bd45c64e.js → index.c967ba14.js} +2 -2
- package/components/commercial/TopBar/{index.4e55cffa.js → index.85568231.js} +6 -6
- package/components/commercial/{index.4bdbb8fe.js → index.d872094e.js} +3 -3
- package/components/formatters/BooleanFormatter/{index.ac870381.js → index.1da1e6b0.js} +2 -2
- package/components/formatters/{index.53ad2f51.js → index.ac081b3a.js} +2 -2
- package/components/hook-form/HelperError/{index.9f93c627.js → index.296a4c82.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.b8347185.js → index.b1c29dd0.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.aeb3bf66.js → index.fb434e68.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.c3b7ce0f.js → index.140d872f.js} +3 -3
- package/components/hook-form/RHFColorPicker/{index.c259b8ac.js → index.3eb719ac.js} +6 -6
- package/components/hook-form/RHFDateTime/{index.4efe48ce.js → index.54f97b37.js} +4 -4
- package/components/hook-form/RHFPeriod/{index.0f912e3e.js → index.c8238ea4.js} +4 -4
- package/components/hook-form/RHFRadioGroup/{index.96c94958.js → index.78ec0e22.js} +1 -1
- package/components/hook-form/RHFTextField/{index.828b30f5.js → index.984a4dba.js} +5 -5
- package/components/hook-form/RHFUpload/{index.b664c68b.js → index.0516dc8f.js} +5 -5
- package/components/maps/components/GpsTools/{index.e759163d.js → index.779e5b17.js} +27 -24
- package/components/maps/components/Map/external/googleMutant/index.d.ts +159 -159
- package/components/maps/components/Map/{index.c568e68d.js → index.14ce256b.js} +14 -13
- package/components/maps/leaflet-geoman.d.ts +1476 -1476
- package/components/modal/{WindowBase.58f9e2b0.js → WindowBase.a6654e8c.js} +3 -3
- package/components/modal/{WindowConfirm.60955735.js → WindowConfirm.38a79eee.js} +6 -6
- package/components/mui_extended/Accordion/{index.e6971e30.js → index.0e62423b.js} +4 -4
- package/components/mui_extended/Avatar/{index.8cc99f13.js → index.edcf899d.js} +1 -1
- package/components/mui_extended/Badge/{index.07fb40c0.js → index.a6dceff2.js} +1 -1
- package/components/mui_extended/Button/{index.111f830e.js → index.9c6c173c.js} +3 -3
- package/components/mui_extended/{CheckBox.a8958eb8.js → CheckBox.9d43398b.js} +2 -2
- package/components/mui_extended/IconButton/{index.9425bdc5.js → index.42efd85d.js} +2 -2
- package/components/mui_extended/MenuActions/{index.8b0d69b7.js → index.b1f8a1be.js} +5 -5
- package/components/mui_extended/Pager/classes/index.d.ts +1 -1
- package/components/mui_extended/Pager/{index.cb749e65.js → index.3687d8b6.js} +4 -4
- package/components/mui_extended/Popover/{index.5e78a637.js → index.58f8522b.js} +1 -1
- package/components/mui_extended/Stack/{index.3674daf7.js → index.b0690398.js} +1 -1
- package/components/mui_extended/Tab/{index.a94a92c1.js → index.8a0bd49c.js} +1 -1
- package/components/mui_extended/ToggleButton/{index.a55def3b.js → index.c4e62f10.js} +1 -1
- package/components/mui_extended/ToggleIconButton/{index.cd20de81.js → index.7635e223.js} +1 -1
- package/components/mui_extended/Typography/{index.45e97bdd.js → index.24a872e2.js} +1 -1
- package/components/popups/PopupsViewer/{index.8fe4aa5d.js → index.eaa54c6c.js} +4 -4
- package/components/popups/PopupsViewer/slots/{popupsViewerSlots.aaf546e2.js → popupsViewerSlots.45032030.js} +2 -2
- package/contexts/ModalContext/{index.a5c622d6.js → index.7f4d2b18.js} +1 -1
- package/contexts/RHFormContext/{index.40a9547e.js → index.19edaacb.js} +1 -1
- package/hooks/useFormAddEdit/{index.b6a3cf63.js → index.aa9cc210.js} +2 -2
- package/hooks/useModal/{index.3ad1e014.js → index.a2a50f01.js} +1 -1
- package/hooks/useTab/{index.4081b113.js → index.c0a8f413.js} +1 -1
- package/index.js +123 -123
- package/package.json +1 -1
- package/{react-draggable.310e3387.js → react-draggable.1c1ba224.js} +1 -1
- package/{react-resizable.3755959b.js → react-resizable.a59c14f4.js} +2 -2
- package/styles/{DynamicFilter.557ee3a7.js → DynamicFilter.27c16026.js} +1 -1
- package/styles/{index.239f949e.js → index.59da2f54.js} +11 -11
- package/vite-env.d.ts +4 -4
- /package/utils/{index.78d1638f.js → index.14912462.js} +0 -0
|
@@ -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.239f949e.js";
|
|
7
|
-
import { I as Image } from "../../Image/index.4b51d4ba.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.45e97bdd.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.59da2f54.js";
|
|
10
|
+
import { T as TEST_PROP_ID } from "../../../test/constants_no_mock.86c553a9.js";
|
|
11
|
+
import { I as Image } from "../../Image/index.94949e55.js";
|
|
12
|
+
import { T as Typography } from "../../mui_extended/Typography/index.24a872e2.js";
|
|
13
|
+
import { H as HelperText } from "../../HelperText/index.25891eda.js";
|
|
14
|
+
import { F as FieldLabel } from "../../FieldLabel/index.2aaaac6f.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.42efd85d.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.239f949e.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.59da2f54.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.b1c29dd0.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;
|