@m4l/components 0.2.36 → 1.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/components/AccountPopover/{index.a9dc9f92.js → index.efc74d5c.js} +3 -5
- package/components/AppBar/{index.7dee7427.js → index.fc126a22.js} +6 -5
- package/components/AppBar/styles.d.ts +1 -1
- package/components/CommonActions/components/Actions/styles.d.ts +1 -1
- package/components/DataGrid/styles.d.ts +1 -1
- package/components/DataGrid/subcomponents/Actions/subcomponents/Settings/subcomponents/ColumnsConfig/styles.d.ts +7 -7
- package/components/DragResizeWindow/{index.a9f25040.js → index.46b380e1.js} +3 -6
- package/components/DynamicFilter/dynamicFilterSlots.d.ts +76 -101
- package/components/DynamicFilter/{index.48d809e2.js → index.d9168c12.js} +22 -96
- package/components/FieldLabel/{index.2622ee40.js → index.f9cdcc27.js} +4 -4
- package/components/GridLayout/{index.b9c47a4c.js → index.bb3b7769.js} +23 -46
- package/components/GridLayout/subcomponents/Griditem/{index.69bc14e5.js → index.bb23f651.js} +4 -3
- package/components/GridLayout/subcomponents/Responsive/{index.094c1d09.js → index.b8a2a121.js} +2 -1
- package/components/GridLayout/subcomponents/SizeProvider/{index.e1d2df80.js → index.094bc6b5.js} +1 -1
- package/components/{commercial/index.b90488db.js → HamburgerMenu/index.5997af31.js} +4 -6
- package/components/HelperText/{index.81c5d349.js → index.be949cdf.js} +3 -2
- package/components/HelperText/styles.d.ts +1 -1
- package/components/Icon/index.d5fed418.js +420 -0
- package/components/Icon/styles.d.ts +2 -2
- package/components/{hook-form/RHFUpload/index.c5e5c61c.js → Image/index.36a3d440.js} +233 -32
- package/components/Image/styles.d.ts +1 -1
- package/components/LanguagePopover/{index.72f316fc.js → index.e6fa2336.js} +5 -8
- package/components/LanguagePopover/styles.d.ts +5 -5
- package/components/LinearProgressIndeterminate/{index.2ecd571e.js → index.de9d447c.js} +2 -4
- package/components/Loadable/{index.97fe63f9.js → index.e83cdb4e.js} +1 -1
- package/components/LoadingError/{index.7aaba1cf.js → index.9f00c83c.js} +8 -12
- package/components/LoadingError/styles.d.ts +1 -1
- package/components/MFLoader/{index.40c419c0.js → index.402c1acc.js} +4 -8
- package/components/ModalDialog/{index.42349189.js → index.ea9189c3.js} +5 -14
- package/components/NavLink/{index.9e847eb5.js → index.4e548cee.js} +4 -4
- package/components/NavLink/styles.d.ts +1 -1
- package/components/NoItemSelected/{index.5a8160fd.js → index.418c8316.js} +6 -15
- package/components/NoItemSelected/styles.d.ts +4 -4
- package/components/ObjectLogs/{index.6955149e.js → index.bfa7dad3.js} +10 -27
- package/components/ObjectLogs/styles.d.ts +3 -3
- package/components/PDFViewer/{index.47bb0928.js → index.bb2eca5a.js} +2 -2
- package/components/{mui_extended/Pager/index.1ba2d52b.js → Page/index.fdf04592.js} +134 -26
- package/components/PaperForm/{index.9f6fd02d.js → index.8121e3da.js} +8 -7
- package/components/PaperForm/styles.d.ts +6 -6
- package/components/Period/{index.c6d1a95a.js → index.5233694b.js} +157 -22
- package/components/Period/styles.d.ts +5 -5
- package/components/PrintingSystem/{index.f51a00f8.js → index.fb176a93.js} +14 -14
- package/components/PrintingSystem/subcomponents/BodyNode/{index.6792c353.js → index.c1d61038.js} +1 -1
- package/components/PrintingSystem/subcomponents/ChartNode/{index.eec6b4cd.js → index.18bd9bad.js} +1 -1
- package/components/PrintingSystem/subcomponents/DividerNode/{index.e58467c9.js → index.67d9f1b4.js} +1 -1
- package/components/PrintingSystem/subcomponents/FooterNode/{index.920b75c9.js → index.eaee152a.js} +1 -1
- package/components/PrintingSystem/subcomponents/GridNode/{index.6c1ad53c.js → index.f5f63a2a.js} +1 -1
- package/components/PrintingSystem/subcomponents/HeaderNode/{index.e8b151ad.js → index.7de4e411.js} +1 -1
- package/components/PrintingSystem/subcomponents/PaperNode/{index.bf199422.js → index.f9ccf22b.js} +1 -1
- package/components/PrintingSystem/subcomponents/PropertyValueNode/{index.44d436b9.js → index.f2f2e903.js} +1 -1
- package/components/PrintingSystem/subcomponents/SectionNode/{index.879cf13d.js → index.540a4b19.js} +1 -1
- package/components/PrintingSystem/subcomponents/TextBoxNode/{index.eb6af0ca.js → index.41e7fcb0.js} +1 -1
- package/components/PropertyValue/{index.5e59580c.js → index.9572c347.js} +4 -7
- package/components/Resizeable/{index.5e8e48b1.js → index.1f0c1359.js} +7 -7
- package/components/ResizeableWindow/styles.d.ts +1 -1
- package/components/ScrollBar/{index.4b965665.js → index.adf0eade.js} +2 -4
- package/components/SideBar/classes/index.d.ts +1 -1
- package/components/SideBar/{index.5d1f4a23.js → index.629ba840.js} +24 -26
- package/components/SideBar/styles.d.ts +2 -2
- package/components/SideBar/subcomponents/ContentGroups/styles.d.ts +3 -3
- package/components/SideBar/subcomponents/ContentGroups/subcomponents/ItemListRoot/styles.d.ts +1 -1
- package/components/SideBar/subcomponents/ContentGroups/subcomponents/ItemListRoot/subcomponents/NavListSub/subcomponents/NavItemSub/subcomponents/NavItemSubContent/styles.d.ts +2 -18
- package/components/SplitLayout/{index.15756f0f.js → index.74091a81.js} +1 -3
- package/components/ToastContainer/{index.dbd78941.js → index.f9b507b9.js} +3 -3
- package/components/animate/LoadingScreen/{index.1a83615a.js → index.779690a7.js} +3 -5
- package/components/animate/PropagateLoader/{index.76d7ea70.js → index.a9da8d00.js} +3 -2
- package/components/animate/PropagateLoader/syles.d.ts +1 -1
- package/components/animate/{index.87296638.js → index.b8497385.js} +3 -2
- package/components/areas/components/AreasAdmin/subcomponents/AreaChip/styles.d.ts +3 -3
- package/components/areas/constants.5387d83e.js +412 -0
- package/components/areas/contexts/AreasContext/{index.19c7b906.js → index.bb316000.js} +5 -6
- package/components/areas/contexts/DynamicMFParmsContext/{index.3d9ad0ad.js → index.37d1d444.js} +2 -2
- package/components/areas/contexts/WindowToolsMFContext/{index.992ae7a3.js → index.69d95c15.js} +2 -2
- package/components/areas/dictionary.7e74022a.js +286 -0
- package/components/areas/hooks/useAreas/{index.cedd30ee.js → index.e24bd74d.js} +1 -1
- package/components/areas/hooks/useDynamicMFParameters/{index.9e09e1e3.js → index.03ce6078.js} +1 -1
- package/components/areas/hooks/useWindowToolsMF/{index.2fbae9dc.js → index.09801b66.js} +1 -1
- package/components/areas/icons.504ec098.js +83 -0
- package/components/commercial/HamburgerMenu/styles.d.ts +1 -1
- package/components/commercial/SectionCommercial/styles.d.ts +4 -9
- package/components/hook-form/RHFAutocomplete/classes/index.d.ts +1 -1
- package/components/hook-form/RHFAutocomplete/styles.d.ts +1 -1
- package/components/hook-form/RHFAutocomplete/subcomponents/RenderOption/styles.d.ts +1 -1
- package/components/hook-form/RHFAutocompleteAsync/styles.d.ts +4 -4
- package/components/hook-form/RHFCheckbox/styles.d.ts +2 -10
- package/components/hook-form/RHFPeriod/styles.d.ts +1 -1
- package/components/hook-form/RHFTextField/styles.d.ts +2 -2
- package/components/hook-form/RHFTextField/subcomponents/Skeleton/styles.d.ts +2 -2
- package/components/hook-form/RHFTextFieldPassword/styles.d.ts +1 -1
- package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/styles.d.ts +1 -1
- package/components/maps/components/GpsTools/{index.4ea69dd1.js → index.75880ce0.js} +14 -136
- package/components/maps/components/GpsTools/subcomponents/TabsGpsTools/subcomponents/GeofencesList/styles.d.ts +4 -9
- package/components/maps/{components/Map/index.62b7d09b.js → index.8ec46ce4.js} +19 -194
- package/components/modal/{WindowBase.2414cd02.js → WindowBase.a3ac7adc.js} +3 -4
- package/components/modal/{WindowConfirm.48140481.js → WindowConfirm.e35da619.js} +6 -10
- package/components/modal/{index.81eb6def.js → index.a0e30c8b.js} +1 -5
- package/components/mui_extended/Accordion/styles.d.ts +3 -3
- package/components/mui_extended/Badge/styles.d.ts +1 -1
- package/components/mui_extended/Button/styles.d.ts +2 -10
- package/components/mui_extended/IconButton/styles.d.ts +1 -1
- package/components/mui_extended/ImageButton/styles.d.ts +1 -1
- package/components/mui_extended/MenuActions/styles.d.ts +2 -27
- package/components/mui_extended/Pager/styles.d.ts +1 -1
- package/components/mui_extended/Stack/styles.d.ts +2 -9
- package/components/mui_extended/Tab/styles.d.ts +2 -2
- package/components/mui_extended/Tabs/styles.d.ts +3 -58
- package/components/mui_extended/Typography/styles.d.ts +1 -1
- package/components/popups/PopupsProvider/{index.8fb6232a.js → index.18669fb4.js} +1 -1
- package/components/popups/PopupsViewer/{index.813854e4.js → index.ba354267.js} +5 -10
- package/contexts/ModalContext/{index.45c275cd.js → index.cf02e6bd.js} +1 -1
- package/contexts/RHFormContext/{index.bf3a2812.js → index.dc955a09.js} +2 -6
- package/hooks/useFormAddEdit/{index.9b27ca02.js → index.f156a2cd.js} +4 -8
- package/hooks/useModal/index.ef54bcf2.js +66 -0
- package/hooks/useTab/{index.f7973779.js → index.bce8b99e.js} +1 -1
- package/index.d.ts +0 -1
- package/index.js +276 -360
- package/package.json +3 -2
- package/{react-draggable.79b4c69a.js → react-draggable.5331add7.js} +1 -1
- package/{react-resizable.af1f31c1.js → react-resizable.37bfb965.js} +3 -5
- package/test/{getNameDataTestId.0faeade8.js → getNameDataTestId.aee44365.js} +2 -2
- package/test/index.6d4b98b9.js +4 -0
- package/utils/{index.0718eeac.js → index.9ee4c99a.js} +113 -3
- package/vendor.a1ce6777.js +6352 -0
- package/assets/Logo/index.109a182d.js +0 -38
- package/assets/Logo.d.ts +0 -6
- package/components/CommonActions/components/ActionCancel/index.46f636e9.js +0 -12
- package/components/CommonActions/components/ActionFormCancel/index.2b0bd50d.js +0 -56
- package/components/CommonActions/components/ActionFormIntro/index.4f212c39.js +0 -33
- package/components/CommonActions/components/ActionIntro/index.7406bd47.js +0 -25
- package/components/CommonActions/components/Actions/index.273645af.js +0 -70
- package/components/DataGrid/constants.e334cd50.js +0 -10
- package/components/DataGrid/formatters/ColumnBooleanFormatter/index.cee6b676.js +0 -26
- package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/index.708f3fb5.js +0 -22
- package/components/DataGrid/formatters/ColumnDateFormatter/index.e00d0cf2.js +0 -19
- package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/index.c064bb07.js +0 -23
- package/components/DataGrid/formatters/ColumnNestedValueFormatter/index.880e743b.js +0 -14
- package/components/DataGrid/formatters/ColumnPointsFormatter/index.226cc583.js +0 -10
- package/components/DataGrid/formatters/ColumnPriceFormatter/index.bf9d9e60.js +0 -10
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/index.4045b2f2.js +0 -36
- package/components/DataGrid/formatters/ColumnUncertaintyFormatter/index.a87302d1.js +0 -10
- package/components/DataGrid/formatters/index.2c2f0ae4.js +0 -1
- package/components/DataGrid/index.304437ee.js +0 -917
- package/components/DataGrid/subcomponents/Actions/index.f14590d2.js +0 -595
- package/components/DataGrid/subcomponents/editors/TextEditor/index.3f0d9e28.js +0 -76
- package/components/Icon/index.ee7b85c9.js +0 -192
- package/components/Image/index.8cc036b1.js +0 -168
- package/components/Page/index.c1d4a319.js +0 -114
- package/components/animate/variants/index.7a912140.js +0 -1
- package/components/areas/components/AreasAdmin/index.f239c717.js +0 -733
- package/components/areas/components/AreasViewer/index.61e0538b.js +0 -1071
- package/components/areas/components/index.558684b3.js +0 -1
- package/components/areas/constants.66529246.js +0 -6
- package/components/areas/contexts/index.24025b97.js +0 -1
- package/components/areas/dictionary.08cfc4c9.js +0 -36
- package/components/areas/hooks/index.d9dc1e21.js +0 -1
- package/components/areas/icons.8266ccc8.js +0 -26
- package/components/areas/index.4cc6a221.js +0 -22
- package/components/commercial/AppBarCommercial/index.9f654f8e.js +0 -28
- package/components/commercial/SectionCommercial/index.3df4685b.js +0 -57
- package/components/commercial/TopBar/index.7aeb6ec0.js +0 -234
- package/components/formatters/BooleanFormatter/index.0c2d8e35.js +0 -44
- package/components/formatters/DateFormatter/index.2ef6f261.js +0 -43
- package/components/formatters/PointsFormatter/index.d8a4ee54.js +0 -25
- package/components/formatters/PriceFormatter/index.97f75b4b.js +0 -35
- package/components/formatters/UncertaintyFormatter/index.c3ffdebc.js +0 -29
- package/components/formatters/index.b816c6b6.js +0 -117
- package/components/hook-form/HelperError/index.c8b046b7.js +0 -19
- package/components/hook-form/RHFAutocomplete/index.ea2ac2b1.js +0 -408
- package/components/hook-form/RHFAutocompleteAsync/index.98dcf0de.js +0 -158
- package/components/hook-form/RHFCheckbox/index.c32278fa.js +0 -142
- package/components/hook-form/RHFColorPicker/index.8c939bfd.js +0 -191
- package/components/hook-form/RHFDateTime/index.ac27deab.js +0 -190
- package/components/hook-form/RHFMultiCheckbox/index.437e6ba3.js +0 -34
- package/components/hook-form/RHFPeriod/index.70cfc422.js +0 -104
- package/components/hook-form/RHFRadioGroup/index.11c0add8.js +0 -35
- package/components/hook-form/RHFSelect/index.c6c60ecc.js +0 -29
- package/components/hook-form/RHFTextField/index.fa97889a.js +0 -325
- package/components/maps/index.13bb982c.js +0 -7
- package/components/mui_extended/Accordion/index.d08a0361.js +0 -142
- package/components/mui_extended/Avatar/index.fb9ad158.js +0 -63
- package/components/mui_extended/Badge/index.2a3aef2c.js +0 -30
- package/components/mui_extended/BoxIcon/index.d61e7ac5.js +0 -22
- package/components/mui_extended/Breadcrumbs/index.4a44883c.js +0 -87
- package/components/mui_extended/Button/index.5395d101.js +0 -213
- package/components/mui_extended/CheckBox.256169f0.js +0 -76
- package/components/mui_extended/CircularProgress/index.967e70b7.js +0 -8
- package/components/mui_extended/IconButton/index.b0ee4965.js +0 -119
- package/components/mui_extended/LinearProgress/index.4092bb69.js +0 -9
- package/components/mui_extended/LinkWithRoute/index.288c51f3.js +0 -15
- package/components/mui_extended/MenuActions/index.d92ed0d6.js +0 -175
- package/components/mui_extended/Popover/index.4e7340b4.js +0 -142
- package/components/mui_extended/Stack/index.fe363ca5.js +0 -31
- package/components/mui_extended/Tab/index.c5ad86e2.js +0 -134
- package/components/mui_extended/ToggleButton/index.7fbc8614.js +0 -18
- package/components/mui_extended/ToggleIconButton/index.0cd347b4.js +0 -24
- package/components/mui_extended/Tooltip/index.49bb5ee1.js +0 -40
- package/components/mui_extended/Typography/index.a1e774a2.js +0 -54
- package/components/mui_extended/index.b606cd9d.js +0 -1
- package/hooks/useModal/index.30674bb7.js +0 -11
- package/style.css +0 -65
- package/test/constants_no_mock.86c553a9.js +0 -4
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { generateUtilityClasses, styled } from "@mui/material";
|
|
3
|
-
import "@mui/base";
|
|
4
|
-
import { W as WrapperComponent } from "../WrapperComponent/index.57964195.js";
|
|
5
|
-
import { useModuleDictionary } from "@m4l/core";
|
|
6
|
-
import { a as BOOLEAN_FORMATTER_DICTIONARY_KEY } from "./BooleanFormatter/index.0c2d8e35.js";
|
|
7
|
-
const COMPONENT_CLASS_NAME = "M4LFormatter";
|
|
8
|
-
const formatterClasses = generateUtilityClasses(COMPONENT_CLASS_NAME, [
|
|
9
|
-
"root",
|
|
10
|
-
"booleanFormatterIcon",
|
|
11
|
-
"booleanFormatterCheck"
|
|
12
|
-
]);
|
|
13
|
-
const FormatterRootContainer = styled("div")(({ theme }) => ({
|
|
14
|
-
...theme.components?.M4LFormatter?.styleOverrides
|
|
15
|
-
}));
|
|
16
|
-
const FormatterRoot = (props) => {
|
|
17
|
-
const { children } = props;
|
|
18
|
-
return /* @__PURE__ */ jsx(FormatterRootContainer, { className: formatterClasses.root, children });
|
|
19
|
-
};
|
|
20
|
-
function getFormatConcatenated(values, separator) {
|
|
21
|
-
const returnSymbol = "";
|
|
22
|
-
if (values === null)
|
|
23
|
-
return returnSymbol;
|
|
24
|
-
if (!Array.isArray(values)) {
|
|
25
|
-
return values.toString();
|
|
26
|
-
} else {
|
|
27
|
-
if (values.length == 0)
|
|
28
|
-
return returnSymbol;
|
|
29
|
-
else {
|
|
30
|
-
const result = values.map((value) => {
|
|
31
|
-
if (value === null || value === void 0)
|
|
32
|
-
return returnSymbol;
|
|
33
|
-
else {
|
|
34
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
35
|
-
return value.toString();
|
|
36
|
-
} else {
|
|
37
|
-
return returnSymbol;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
const output = result.join(separator.toString());
|
|
42
|
-
return output.trim();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function ConcatenatedFormatter(props) {
|
|
47
|
-
const { values = [], separator = " ", Component = WrapperComponent } = props;
|
|
48
|
-
return /* @__PURE__ */ jsx(Component, { children: getFormatConcatenated(values, separator) });
|
|
49
|
-
}
|
|
50
|
-
const PERIOD_FORMATTER_DICTIONARY_KEY = `period_formatter`;
|
|
51
|
-
const dictionary = {
|
|
52
|
-
LABEL_YEARS: `${PERIOD_FORMATTER_DICTIONARY_KEY}.label_years`,
|
|
53
|
-
LABEL_YEAR: `${PERIOD_FORMATTER_DICTIONARY_KEY}.label_year`,
|
|
54
|
-
LABEL_MONTHS: `${PERIOD_FORMATTER_DICTIONARY_KEY}.label_months`,
|
|
55
|
-
LABEL_MONTH: `${PERIOD_FORMATTER_DICTIONARY_KEY}.label_month`,
|
|
56
|
-
LABEL_DAYS: `${PERIOD_FORMATTER_DICTIONARY_KEY}.label_days`,
|
|
57
|
-
LABEL_DAY: `${PERIOD_FORMATTER_DICTIONARY_KEY}.label_day`
|
|
58
|
-
};
|
|
59
|
-
function getFormatPeriod(years, months, days) {
|
|
60
|
-
const { getLabel } = useModuleDictionary();
|
|
61
|
-
let period = "";
|
|
62
|
-
const separator = ", ";
|
|
63
|
-
switch (years) {
|
|
64
|
-
case 0:
|
|
65
|
-
break;
|
|
66
|
-
case 1:
|
|
67
|
-
period = "1 " + getLabel(dictionary.LABEL_YEAR);
|
|
68
|
-
break;
|
|
69
|
-
default:
|
|
70
|
-
period = years.toString() + " " + getLabel(dictionary.LABEL_YEARS);
|
|
71
|
-
}
|
|
72
|
-
switch (months) {
|
|
73
|
-
case 0:
|
|
74
|
-
break;
|
|
75
|
-
case 1:
|
|
76
|
-
if (years > 0)
|
|
77
|
-
period += separator;
|
|
78
|
-
period += "1 " + getLabel(dictionary.LABEL_MONTH);
|
|
79
|
-
break;
|
|
80
|
-
default:
|
|
81
|
-
if (years > 0)
|
|
82
|
-
period += separator;
|
|
83
|
-
period += months.toString() + " " + getLabel(dictionary.LABEL_MONTHS);
|
|
84
|
-
}
|
|
85
|
-
switch (days) {
|
|
86
|
-
case 0:
|
|
87
|
-
break;
|
|
88
|
-
case 1:
|
|
89
|
-
if (years > 0 || months > 0)
|
|
90
|
-
period += separator;
|
|
91
|
-
period += "1 " + getLabel(dictionary.LABEL_DAY);
|
|
92
|
-
break;
|
|
93
|
-
default:
|
|
94
|
-
if (years > 0 || months > 0)
|
|
95
|
-
period += separator;
|
|
96
|
-
period += days.toString() + " " + getLabel(dictionary.LABEL_DAYS);
|
|
97
|
-
}
|
|
98
|
-
if (period == "")
|
|
99
|
-
period = "-";
|
|
100
|
-
return period;
|
|
101
|
-
}
|
|
102
|
-
function PeriodFormatter(props) {
|
|
103
|
-
const { years = 0, months = 0, days = 0, Component = WrapperComponent } = props;
|
|
104
|
-
return /* @__PURE__ */ jsx(Component, { children: getFormatPeriod(years, months, days) });
|
|
105
|
-
}
|
|
106
|
-
function getFormattersComponentsDictionary() {
|
|
107
|
-
return [BOOLEAN_FORMATTER_DICTIONARY_KEY, PERIOD_FORMATTER_DICTIONARY_KEY];
|
|
108
|
-
}
|
|
109
|
-
export {
|
|
110
|
-
ConcatenatedFormatter as C,
|
|
111
|
-
FormatterRoot as F,
|
|
112
|
-
PeriodFormatter as P,
|
|
113
|
-
getFormatPeriod as a,
|
|
114
|
-
getFormattersComponentsDictionary as b,
|
|
115
|
-
formatterClasses as f,
|
|
116
|
-
getFormatConcatenated as g
|
|
117
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useFormContext, useController } from "react-hook-form";
|
|
3
|
-
import { H as HelperText } from "../../HelperText/index.81c5d349.js";
|
|
4
|
-
function HelperError(props) {
|
|
5
|
-
const { name } = props;
|
|
6
|
-
const { control } = useFormContext();
|
|
7
|
-
const { fieldState } = useController({
|
|
8
|
-
name,
|
|
9
|
-
control,
|
|
10
|
-
rules: { required: true }
|
|
11
|
-
});
|
|
12
|
-
if (fieldState?.error?.message) {
|
|
13
|
-
return /* @__PURE__ */ jsx(HelperText, { variant: "error", message: fieldState?.error?.message });
|
|
14
|
-
}
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
export {
|
|
18
|
-
HelperError as H
|
|
19
|
-
};
|
|
@@ -1,408 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo, useRef, useState, useEffect, createElement } from "react";
|
|
3
|
-
import { useModuleDictionary, useModuleSkeleton, useEnvironment } from "@m4l/core";
|
|
4
|
-
import { useFormContext, Controller } from "react-hook-form";
|
|
5
|
-
import { styled, Skeleton, generateUtilityClasses, generateUtilityClass, useTheme, Autocomplete, Popper, TextField, Chip } from "@mui/material";
|
|
6
|
-
import { I as Image } from "../../Image/index.8cc036b1.js";
|
|
7
|
-
import { T as TEST_PROP_ID } from "../../../test/constants_no_mock.86c553a9.js";
|
|
8
|
-
import { T as Typography } from "../../mui_extended/Typography/index.a1e774a2.js";
|
|
9
|
-
import { unstable_composeClasses } from "@mui/base";
|
|
10
|
-
import { H as HelperText } from "../../HelperText/index.81c5d349.js";
|
|
11
|
-
import { useResponsiveDesktop } from "@m4l/graphics";
|
|
12
|
-
import { useFormFocus } from "../../../index.js";
|
|
13
|
-
import { F as FieldLabel } from "../../FieldLabel/index.2622ee40.js";
|
|
14
|
-
import { C as CircularProgress } from "../../mui_extended/CircularProgress/index.967e70b7.js";
|
|
15
|
-
import { I as IconButton } from "../../mui_extended/IconButton/index.b0ee4965.js";
|
|
16
|
-
const AutocompleteRoot = styled("div")(({ theme }) => ({
|
|
17
|
-
...theme.components?.M4LRHFAutocomplete?.styleOverrides
|
|
18
|
-
}));
|
|
19
|
-
const WrapperOption = styled("li")(({ theme }) => ({
|
|
20
|
-
"& .m4l_image": {
|
|
21
|
-
marginRight: theme.spacing(1.5)
|
|
22
|
-
}
|
|
23
|
-
}));
|
|
24
|
-
const RHFAUTOCOMPLETE_PREFIX = "RHFAutocomplete";
|
|
25
|
-
const RHFTAUTOCOMPLET_ROOT_TEST_ID = "RHFAutocomplete";
|
|
26
|
-
const getNameDataTestId = (KEY) => {
|
|
27
|
-
return `${RHFAUTOCOMPLETE_PREFIX}-${KEY}`;
|
|
28
|
-
};
|
|
29
|
-
function withRenderOption(getUrlImage, classes, imageWidth) {
|
|
30
|
-
return function RenderOption(optionProps, option) {
|
|
31
|
-
return /* @__PURE__ */ jsxs(
|
|
32
|
-
WrapperOption,
|
|
33
|
-
{
|
|
34
|
-
...optionProps,
|
|
35
|
-
className: classes.withImage,
|
|
36
|
-
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameDataTestId("withImage") } : {},
|
|
37
|
-
children: [
|
|
38
|
-
/* @__PURE__ */ jsx(Image, { src: getUrlImage(option), width: imageWidth, height: "100%" }),
|
|
39
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body", children: optionProps.key })
|
|
40
|
-
]
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
const SkeletonRHFAutocomplete = (props) => {
|
|
46
|
-
const { withImage, classes, hasLabel } = props;
|
|
47
|
-
return /* @__PURE__ */ jsxs("div", { className: classes.skeletonRoot, children: [
|
|
48
|
-
(hasLabel || hasLabel?.length === 0) && /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "30%", height: "16px" }),
|
|
49
|
-
/* @__PURE__ */ jsx(
|
|
50
|
-
"div",
|
|
51
|
-
{
|
|
52
|
-
className: classes.skeleton,
|
|
53
|
-
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameDataTestId("skeleton") } : {},
|
|
54
|
-
children: !withImage ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
55
|
-
/* @__PURE__ */ jsx("div", { className: classes.skeletonContainerText, children: /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "50%", height: "14px" }) }),
|
|
56
|
-
/* @__PURE__ */ jsx(Skeleton, { variant: "circular", width: 16, height: 16, sx: { minWidth: "16px" } })
|
|
57
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
58
|
-
/* @__PURE__ */ jsx(Skeleton, { variant: "circular" }),
|
|
59
|
-
/* @__PURE__ */ jsx("div", { className: classes.skeletonContainerText, children: /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "50%", height: "14px" }) }),
|
|
60
|
-
/* @__PURE__ */ jsx(Skeleton, { variant: "circular", width: 16, height: 16, sx: { minWidth: "16px" } })
|
|
61
|
-
] })
|
|
62
|
-
}
|
|
63
|
-
)
|
|
64
|
-
] });
|
|
65
|
-
};
|
|
66
|
-
const componentName = "M4LRHFAutocomplete";
|
|
67
|
-
generateUtilityClasses(
|
|
68
|
-
componentName,
|
|
69
|
-
[
|
|
70
|
-
"root",
|
|
71
|
-
"withImage",
|
|
72
|
-
"skeleton",
|
|
73
|
-
"label",
|
|
74
|
-
"popper",
|
|
75
|
-
"skeletonRoot",
|
|
76
|
-
"skeletonContainerText",
|
|
77
|
-
"iconDown",
|
|
78
|
-
"variantInfo",
|
|
79
|
-
"variantImage",
|
|
80
|
-
"isDisabled",
|
|
81
|
-
"imageWidthDefined",
|
|
82
|
-
"variantSuccess",
|
|
83
|
-
"variantWarning",
|
|
84
|
-
"variantError",
|
|
85
|
-
"sizeSmall",
|
|
86
|
-
"sizeMedium",
|
|
87
|
-
"isFocus",
|
|
88
|
-
"isTabSelected",
|
|
89
|
-
"chip"
|
|
90
|
-
]
|
|
91
|
-
);
|
|
92
|
-
function getRHFAutocompleteClassesUtilityClass(slot) {
|
|
93
|
-
return generateUtilityClass(componentName, slot);
|
|
94
|
-
}
|
|
95
|
-
const useUtilityClasses = (ownerState) => {
|
|
96
|
-
const slots = {
|
|
97
|
-
root: [
|
|
98
|
-
"root",
|
|
99
|
-
ownerState.size === "small" && "sizeSmall",
|
|
100
|
-
ownerState.size === "medium" && "sizeMedium",
|
|
101
|
-
ownerState.isFocus && "isFocus",
|
|
102
|
-
ownerState.isTabSelected && "isTabSelected",
|
|
103
|
-
ownerState.disabled && "isDisabled",
|
|
104
|
-
ownerState.semantics === "info" && "variantInfo",
|
|
105
|
-
ownerState.semantics === "success" && "variantSuccess",
|
|
106
|
-
ownerState.semantics === "warning" && "variantWarning",
|
|
107
|
-
ownerState.semantics === "error" && "variantError",
|
|
108
|
-
ownerState.imageWidthDefined && "imageWidthDefined",
|
|
109
|
-
ownerState.multiple && "multiple"
|
|
110
|
-
],
|
|
111
|
-
withImage: ["withImage"],
|
|
112
|
-
skeleton: ["skeleton"],
|
|
113
|
-
label: ["label"],
|
|
114
|
-
popper: [
|
|
115
|
-
"popper",
|
|
116
|
-
ownerState.size === "small" && "sizeSmall",
|
|
117
|
-
ownerState.size === "medium" && "sizeMedium",
|
|
118
|
-
ownerState.imageWidthDefined && "imageWidthDefined"
|
|
119
|
-
],
|
|
120
|
-
skeletonRoot: ["skeletonRoot"],
|
|
121
|
-
skeletonContainerText: ["SkeletonContainerText"],
|
|
122
|
-
iconDown: ["iconDown"],
|
|
123
|
-
chip: [
|
|
124
|
-
"chip",
|
|
125
|
-
ownerState.size === "small" && "sizeSmall",
|
|
126
|
-
ownerState.size === "medium" && "sizeMedium"
|
|
127
|
-
]
|
|
128
|
-
};
|
|
129
|
-
const composedClasses = unstable_composeClasses(slots, getRHFAutocompleteClassesUtilityClass, {});
|
|
130
|
-
return {
|
|
131
|
-
...composedClasses
|
|
132
|
-
};
|
|
133
|
-
};
|
|
134
|
-
function RHFAutocomplete(props) {
|
|
135
|
-
const {
|
|
136
|
-
name: nameRHF,
|
|
137
|
-
getOptionLabel,
|
|
138
|
-
isOptionEqualToValue,
|
|
139
|
-
label,
|
|
140
|
-
skeletonWidth = 100,
|
|
141
|
-
skeletonHeight = "18px",
|
|
142
|
-
options,
|
|
143
|
-
disabled,
|
|
144
|
-
getOptionUrlImage,
|
|
145
|
-
onOpen,
|
|
146
|
-
onClose,
|
|
147
|
-
loading,
|
|
148
|
-
variant,
|
|
149
|
-
helperMessage,
|
|
150
|
-
size = "small",
|
|
151
|
-
onChangeFilterParmsLocal,
|
|
152
|
-
imageWidth,
|
|
153
|
-
imageHeight,
|
|
154
|
-
mandatory,
|
|
155
|
-
mandatoryMessage,
|
|
156
|
-
multiple,
|
|
157
|
-
...other
|
|
158
|
-
} = props;
|
|
159
|
-
const { getLabel } = useModuleDictionary();
|
|
160
|
-
const isSkeleton = useModuleSkeleton();
|
|
161
|
-
const withImage = useMemo(() => getOptionUrlImage !== void 0, [getOptionUrlImage]);
|
|
162
|
-
const { host_static_assets, environment_assets } = useEnvironment();
|
|
163
|
-
const { isFocus, isTabSelected, handlerFocus, handlerOnKeyUp, handlerOnBlur } = useFormFocus();
|
|
164
|
-
const autocompleteRef = useRef(null);
|
|
165
|
-
const [open, setOpen] = useState(false);
|
|
166
|
-
const isDesktop = useResponsiveDesktop();
|
|
167
|
-
const onCloseLocal = (event, reason) => {
|
|
168
|
-
setOpen(false);
|
|
169
|
-
if (onClose)
|
|
170
|
-
onClose(event, reason);
|
|
171
|
-
};
|
|
172
|
-
const onOpenLocal = (event) => {
|
|
173
|
-
setOpen(true);
|
|
174
|
-
if (onOpen)
|
|
175
|
-
onOpen(event);
|
|
176
|
-
};
|
|
177
|
-
const getOptionLabelLocal = (option) => {
|
|
178
|
-
if (option === void 0 || option === null) {
|
|
179
|
-
return "";
|
|
180
|
-
}
|
|
181
|
-
return getOptionLabel(option);
|
|
182
|
-
};
|
|
183
|
-
const getOptionUrlImageLocal = (option) => {
|
|
184
|
-
if (option === void 0 || option === null || getOptionUrlImage === void 0) {
|
|
185
|
-
return "";
|
|
186
|
-
}
|
|
187
|
-
return getOptionUrlImage(option);
|
|
188
|
-
};
|
|
189
|
-
const isOptionEqualToValueLocal = (option, value) => {
|
|
190
|
-
if (value === void 0 || value === null || option === null) {
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
return isOptionEqualToValue(option, value);
|
|
194
|
-
};
|
|
195
|
-
const {
|
|
196
|
-
control,
|
|
197
|
-
formState: { errors }
|
|
198
|
-
} = useFormContext();
|
|
199
|
-
const [currentVariant, setCurrentVariant] = useState(
|
|
200
|
-
null
|
|
201
|
-
);
|
|
202
|
-
useEffect(() => {
|
|
203
|
-
if (errors[nameRHF]) {
|
|
204
|
-
setCurrentVariant("error");
|
|
205
|
-
} else if (variant) {
|
|
206
|
-
setCurrentVariant(variant);
|
|
207
|
-
} else {
|
|
208
|
-
setCurrentVariant(null);
|
|
209
|
-
}
|
|
210
|
-
}, [errors[nameRHF], variant, control]);
|
|
211
|
-
const ownerState = {
|
|
212
|
-
size: !isDesktop ? "medium" : size,
|
|
213
|
-
isFocus: !isSkeleton ? isFocus : false,
|
|
214
|
-
isTabSelected: !isSkeleton ? isTabSelected : false,
|
|
215
|
-
semantics: currentVariant,
|
|
216
|
-
disabled,
|
|
217
|
-
imageWidthDefined: Boolean(imageWidth),
|
|
218
|
-
multiple: Boolean(multiple)
|
|
219
|
-
};
|
|
220
|
-
const classes = useUtilityClasses(ownerState);
|
|
221
|
-
const theme = useTheme();
|
|
222
|
-
return /* @__PURE__ */ jsx(
|
|
223
|
-
AutocompleteRoot,
|
|
224
|
-
{
|
|
225
|
-
className: classes.root,
|
|
226
|
-
tabIndex: 0,
|
|
227
|
-
onFocus: handlerFocus,
|
|
228
|
-
onBlur: handlerOnBlur,
|
|
229
|
-
onKeyUp: handlerOnKeyUp,
|
|
230
|
-
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: `${RHFTAUTOCOMPLET_ROOT_TEST_ID}_${nameRHF}` } : {},
|
|
231
|
-
children: !isSkeleton ? /* @__PURE__ */ jsx(
|
|
232
|
-
Controller,
|
|
233
|
-
{
|
|
234
|
-
name: nameRHF,
|
|
235
|
-
control,
|
|
236
|
-
render: ({ field: { onChange, value }, fieldState: { error } }) => {
|
|
237
|
-
const [inputValue, setInputValue] = useState(getOptionLabelLocal(value));
|
|
238
|
-
useEffect(() => {
|
|
239
|
-
if (!open && value === null && inputValue !== "") {
|
|
240
|
-
setInputValue("");
|
|
241
|
-
}
|
|
242
|
-
if (!open && value !== null && options.length === 0) {
|
|
243
|
-
onChangeFilterParmsLocal?.(getOptionLabelLocal(value), "reset");
|
|
244
|
-
}
|
|
245
|
-
}, [value]);
|
|
246
|
-
const checkKeyDown = (e) => {
|
|
247
|
-
if (e.code === "Enter")
|
|
248
|
-
e.preventDefault();
|
|
249
|
-
};
|
|
250
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
251
|
-
label && /* @__PURE__ */ jsx(
|
|
252
|
-
FieldLabel,
|
|
253
|
-
{
|
|
254
|
-
className: classes.label,
|
|
255
|
-
label,
|
|
256
|
-
mandatory,
|
|
257
|
-
mandatoryMessage,
|
|
258
|
-
helperMessage
|
|
259
|
-
}
|
|
260
|
-
),
|
|
261
|
-
/* @__PURE__ */ jsx(
|
|
262
|
-
Autocomplete,
|
|
263
|
-
{
|
|
264
|
-
autoComplete: true,
|
|
265
|
-
disableClearable: true,
|
|
266
|
-
multiple,
|
|
267
|
-
onKeyDown: checkKeyDown,
|
|
268
|
-
size,
|
|
269
|
-
ref: autocompleteRef,
|
|
270
|
-
autoSelect: false,
|
|
271
|
-
options,
|
|
272
|
-
getOptionLabel: getOptionLabelLocal,
|
|
273
|
-
inputValue,
|
|
274
|
-
clearOnBlur: false,
|
|
275
|
-
PopperComponent: (popperProps) => {
|
|
276
|
-
return /* @__PURE__ */ jsx(
|
|
277
|
-
Popper,
|
|
278
|
-
{
|
|
279
|
-
...popperProps,
|
|
280
|
-
className: classes.popper,
|
|
281
|
-
placement: "bottom-start",
|
|
282
|
-
placeholder: void 0,
|
|
283
|
-
onPointerEnterCapture: () => {
|
|
284
|
-
},
|
|
285
|
-
onPointerLeaveCapture: () => {
|
|
286
|
-
},
|
|
287
|
-
sx: {
|
|
288
|
-
...theme.components?.M4LRHFAutocompletePopover?.styleOverrides
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
);
|
|
292
|
-
},
|
|
293
|
-
onInputChange: (_event, newValue, reason) => {
|
|
294
|
-
if (reason === "input") {
|
|
295
|
-
setInputValue(newValue);
|
|
296
|
-
if (onChangeFilterParmsLocal) {
|
|
297
|
-
onChangeFilterParmsLocal(newValue, reason);
|
|
298
|
-
}
|
|
299
|
-
} else {
|
|
300
|
-
onChange(null);
|
|
301
|
-
}
|
|
302
|
-
},
|
|
303
|
-
isOptionEqualToValue: isOptionEqualToValueLocal,
|
|
304
|
-
value: Array.isArray(value) ? value : multiple ? value ? [value] : [] : value || null,
|
|
305
|
-
onOpen: onOpenLocal,
|
|
306
|
-
onClose: onCloseLocal,
|
|
307
|
-
open,
|
|
308
|
-
onChange: (_e, newValue) => {
|
|
309
|
-
if (!multiple && !Array.isArray(newValue)) {
|
|
310
|
-
setInputValue(getOptionLabelLocal(newValue));
|
|
311
|
-
} else {
|
|
312
|
-
setInputValue("");
|
|
313
|
-
}
|
|
314
|
-
onChange(Array.isArray(newValue) ? [...newValue] : newValue);
|
|
315
|
-
},
|
|
316
|
-
filterOptions: onChangeFilterParmsLocal ? (x) => x : void 0,
|
|
317
|
-
loading,
|
|
318
|
-
loadingText: /* @__PURE__ */ jsx(Typography, { variant: "body", children: getLabel("rhf_autocomplete.loading_options") }),
|
|
319
|
-
disabled,
|
|
320
|
-
noOptionsText: getLabel("rhf_autocomplete.no_options"),
|
|
321
|
-
renderOption: withImage ? withRenderOption(getOptionUrlImageLocal, classes, imageWidth) : void 0,
|
|
322
|
-
renderInput: (params) => {
|
|
323
|
-
return /* @__PURE__ */ jsx(
|
|
324
|
-
TextField,
|
|
325
|
-
{
|
|
326
|
-
...params,
|
|
327
|
-
InputLabelProps: {
|
|
328
|
-
...params.InputLabelProps,
|
|
329
|
-
shrink: true
|
|
330
|
-
},
|
|
331
|
-
fullWidth: true,
|
|
332
|
-
size,
|
|
333
|
-
SelectProps: { native: true },
|
|
334
|
-
InputProps: {
|
|
335
|
-
...params.InputProps,
|
|
336
|
-
startAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
337
|
-
!multiple && withImage && value ? /* @__PURE__ */ jsx(
|
|
338
|
-
Image,
|
|
339
|
-
{
|
|
340
|
-
src: getOptionUrlImageLocal(value),
|
|
341
|
-
width: imageWidth,
|
|
342
|
-
height: "100%"
|
|
343
|
-
},
|
|
344
|
-
"ImageTextField"
|
|
345
|
-
) : null,
|
|
346
|
-
params.InputProps.startAdornment
|
|
347
|
-
] }),
|
|
348
|
-
endAdornment: loading ? /* @__PURE__ */ jsx(CircularProgress, { color: "inherit", size: 18 }) : /* @__PURE__ */ jsx(
|
|
349
|
-
IconButton,
|
|
350
|
-
{
|
|
351
|
-
className: classes.iconDown,
|
|
352
|
-
src: `${host_static_assets}/${environment_assets}/frontend/components/RHFAutocompletarAsync/assets/icons/chevronDown.svg`,
|
|
353
|
-
onClick: (event) => onOpenLocal(event),
|
|
354
|
-
disabled,
|
|
355
|
-
size
|
|
356
|
-
}
|
|
357
|
-
)
|
|
358
|
-
},
|
|
359
|
-
autoComplete: "off",
|
|
360
|
-
error: !!error,
|
|
361
|
-
...other
|
|
362
|
-
}
|
|
363
|
-
);
|
|
364
|
-
},
|
|
365
|
-
...multiple ? {
|
|
366
|
-
renderTags: (tagValue, getTagProps) => tagValue.map((option, index) => {
|
|
367
|
-
const { key, ...restTagProps } = getTagProps({
|
|
368
|
-
index
|
|
369
|
-
});
|
|
370
|
-
return /* @__PURE__ */ createElement(
|
|
371
|
-
Chip,
|
|
372
|
-
{
|
|
373
|
-
...restTagProps,
|
|
374
|
-
key,
|
|
375
|
-
label: getOptionLabelLocal(option),
|
|
376
|
-
className: classes.chip,
|
|
377
|
-
icon: withImage && option ? /* @__PURE__ */ jsx(
|
|
378
|
-
Image,
|
|
379
|
-
{
|
|
380
|
-
src: getOptionUrlImageLocal(option),
|
|
381
|
-
width: imageWidth,
|
|
382
|
-
height: imageHeight ?? "100%"
|
|
383
|
-
}
|
|
384
|
-
) : void 0,
|
|
385
|
-
sx: {
|
|
386
|
-
...theme.components?.M4LRHFAutocompleteChip?.styleOverrides
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
);
|
|
390
|
-
})
|
|
391
|
-
} : {}
|
|
392
|
-
}
|
|
393
|
-
),
|
|
394
|
-
currentVariant === "error" ? /* @__PURE__ */ jsx(HelperText, { variant: currentVariant, message: error?.message }) : null
|
|
395
|
-
] });
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
) : /* @__PURE__ */ jsx(SkeletonRHFAutocomplete, { withImage, classes, hasLabel: label })
|
|
399
|
-
}
|
|
400
|
-
);
|
|
401
|
-
}
|
|
402
|
-
function getRHFAutocompleteComponentsDictionary() {
|
|
403
|
-
return ["rhf_autocomplete"];
|
|
404
|
-
}
|
|
405
|
-
export {
|
|
406
|
-
RHFAutocomplete as R,
|
|
407
|
-
getRHFAutocompleteComponentsDictionary as g
|
|
408
|
-
};
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useCallback, useEffect } from "react";
|
|
3
|
-
import { useNetwork, getPropertyByString } from "@m4l/core";
|
|
4
|
-
import debounce from "lodash/debounce";
|
|
5
|
-
import { styled, generateUtilityClasses, generateUtilityClass } from "@mui/material";
|
|
6
|
-
import { unstable_composeClasses } from "@mui/base";
|
|
7
|
-
import { T as TEST_PROP_ID } from "../../../test/constants_no_mock.86c553a9.js";
|
|
8
|
-
import { R as RHFAutocomplete, g as getRHFAutocompleteComponentsDictionary } from "../RHFAutocomplete/index.ea2ac2b1.js";
|
|
9
|
-
styled("div")(() => ({
|
|
10
|
-
display: "flex",
|
|
11
|
-
width: "100%",
|
|
12
|
-
flexDirection: "column"
|
|
13
|
-
}));
|
|
14
|
-
styled("div")(({ theme }) => ({
|
|
15
|
-
display: "flex",
|
|
16
|
-
justifyContent: "flex-end",
|
|
17
|
-
paddingRight: `${theme.spacing(2)}`,
|
|
18
|
-
[theme.breakpoints.down("md")]: {
|
|
19
|
-
justifyContent: "flex-start"
|
|
20
|
-
}
|
|
21
|
-
}));
|
|
22
|
-
styled("div")(({ theme }) => ({
|
|
23
|
-
width: "100%",
|
|
24
|
-
display: "grid",
|
|
25
|
-
gridTemplateColumns: "1fr auto",
|
|
26
|
-
gridGap: theme.spacing(2),
|
|
27
|
-
alignItems: "center",
|
|
28
|
-
height: `${theme.spacing(4.5)}`,
|
|
29
|
-
border: `1px solid ${theme.palette.divider}`,
|
|
30
|
-
borderRadius: `${theme.spacing(1)}`,
|
|
31
|
-
padding: `0 ${theme.spacing(2)}`,
|
|
32
|
-
[theme.breakpoints.down("md")]: {
|
|
33
|
-
width: "100%"
|
|
34
|
-
}
|
|
35
|
-
}));
|
|
36
|
-
const RHFAutocompleteAsyncRoot = styled("div")(({ theme }) => ({
|
|
37
|
-
...theme.components?.M4LRHFAutocompleteAsync?.styleOverrides
|
|
38
|
-
}));
|
|
39
|
-
const componentName = "M4LRHFAutocompleteAsync";
|
|
40
|
-
generateUtilityClasses(
|
|
41
|
-
componentName,
|
|
42
|
-
[
|
|
43
|
-
"root"
|
|
44
|
-
]
|
|
45
|
-
);
|
|
46
|
-
function getRHFAutocompleteAsyncClassesUtilityClass(slot) {
|
|
47
|
-
return generateUtilityClass(componentName, slot);
|
|
48
|
-
}
|
|
49
|
-
const useUtilityClasses = () => {
|
|
50
|
-
const slots = {
|
|
51
|
-
root: ["root"]
|
|
52
|
-
};
|
|
53
|
-
const composedClasses = unstable_composeClasses(slots, getRHFAutocompleteAsyncClassesUtilityClass, {});
|
|
54
|
-
return {
|
|
55
|
-
...composedClasses
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
const RHFAUTOCOMPLETEASYNC_PREFIX = "RHFAutocompleteAsync";
|
|
59
|
-
const getNameDataTestId = (KEY) => {
|
|
60
|
-
return `${RHFAUTOCOMPLETEASYNC_PREFIX}-${KEY}`;
|
|
61
|
-
};
|
|
62
|
-
function RHFAutocompleteAsync(props) {
|
|
63
|
-
const {
|
|
64
|
-
name,
|
|
65
|
-
endPoint,
|
|
66
|
-
timeout = 5e3,
|
|
67
|
-
parms,
|
|
68
|
-
resultField = "data",
|
|
69
|
-
size,
|
|
70
|
-
isRemote = true,
|
|
71
|
-
onChangeFilterParms,
|
|
72
|
-
...other
|
|
73
|
-
} = props;
|
|
74
|
-
const { networkOperation } = useNetwork();
|
|
75
|
-
const [options, setOptions] = useState([]);
|
|
76
|
-
const [open, setOpen] = useState(false);
|
|
77
|
-
const [loading, setIsloading] = useState(false);
|
|
78
|
-
const [canLoadOptions, setCanLoadOptions] = useState(true);
|
|
79
|
-
const [filterParms, setFilterParms] = useState({});
|
|
80
|
-
const debouncedFilter = useCallback(
|
|
81
|
-
debounce(
|
|
82
|
-
(newFilterParms) => {
|
|
83
|
-
setCanLoadOptions(true);
|
|
84
|
-
setFilterParms(newFilterParms);
|
|
85
|
-
},
|
|
86
|
-
300
|
|
87
|
-
),
|
|
88
|
-
[]
|
|
89
|
-
);
|
|
90
|
-
const onChangeFilterParmsLocal = (newValue) => {
|
|
91
|
-
if (onChangeFilterParms) {
|
|
92
|
-
debouncedFilter(onChangeFilterParms(newValue));
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
useEffect(() => {
|
|
96
|
-
setCanLoadOptions(true);
|
|
97
|
-
}, [parms, endPoint]);
|
|
98
|
-
useEffect(() => {
|
|
99
|
-
if (!open || loading) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
if (!canLoadOptions) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
setIsloading(true);
|
|
106
|
-
setOptions([]);
|
|
107
|
-
setCanLoadOptions(false);
|
|
108
|
-
networkOperation({
|
|
109
|
-
method: "GET",
|
|
110
|
-
endPoint,
|
|
111
|
-
timeout,
|
|
112
|
-
parms: { ...parms, ...filterParms },
|
|
113
|
-
isRemote
|
|
114
|
-
}).then((response) => {
|
|
115
|
-
const valueMaybeArray = getPropertyByString(response, resultField);
|
|
116
|
-
const newOptions = Array.isArray(valueMaybeArray) ? valueMaybeArray : [];
|
|
117
|
-
setOptions(newOptions);
|
|
118
|
-
}).catch(() => {
|
|
119
|
-
setCanLoadOptions(true);
|
|
120
|
-
}).finally(() => {
|
|
121
|
-
setIsloading(false);
|
|
122
|
-
});
|
|
123
|
-
return () => {
|
|
124
|
-
};
|
|
125
|
-
}, [open, parms, filterParms, endPoint]);
|
|
126
|
-
const classes = useUtilityClasses();
|
|
127
|
-
return /* @__PURE__ */ jsx(
|
|
128
|
-
RHFAutocompleteAsyncRoot,
|
|
129
|
-
{
|
|
130
|
-
className: classes.root,
|
|
131
|
-
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameDataTestId("root") } : {},
|
|
132
|
-
children: /* @__PURE__ */ jsx(
|
|
133
|
-
RHFAutocomplete,
|
|
134
|
-
{
|
|
135
|
-
name,
|
|
136
|
-
loading,
|
|
137
|
-
options,
|
|
138
|
-
onChangeFilterParmsLocal: onChangeFilterParms ? onChangeFilterParmsLocal : void 0,
|
|
139
|
-
size,
|
|
140
|
-
onOpen: () => {
|
|
141
|
-
setOpen(true);
|
|
142
|
-
},
|
|
143
|
-
onClose: () => {
|
|
144
|
-
setOpen(false);
|
|
145
|
-
},
|
|
146
|
-
...other
|
|
147
|
-
}
|
|
148
|
-
)
|
|
149
|
-
}
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
function getRHFAutocompleteAsyncComponentsDictionary() {
|
|
153
|
-
return getRHFAutocompleteComponentsDictionary();
|
|
154
|
-
}
|
|
155
|
-
export {
|
|
156
|
-
RHFAutocompleteAsync as R,
|
|
157
|
-
getRHFAutocompleteAsyncComponentsDictionary as g
|
|
158
|
-
};
|