@m4l/components 9.2.52 → 9.2.53
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/Chip/Chip.js +3 -1
- package/components/Chip/ChipStyles.js +1 -1
- package/components/Chip/types.d.ts +4 -0
- package/components/DataGrid/constants.d.ts +21 -0
- package/components/DataGrid/constants.js +24 -1
- package/components/DataGrid/contexts/DataGridContext/index.js +1 -1
- package/components/DataGrid/contexts/FilterContext/index.js +1 -1
- package/components/DataGrid/dictionary.js +0 -3
- package/components/DataGrid/index.d.ts +1 -0
- package/components/DataGrid/slots/DataGridEnum.js +2 -2
- package/components/DataGrid/slots/DataGridSlot.js +1 -1
- package/components/DataGrid/subcomponents/Table/hooks/useSortColumnsRows.js +2 -0
- package/components/DataGrid/subcomponents/Table/subcomponents/ActionsColumn.js +2 -2
- package/components/DataGrid/subcomponents/Table/subcomponents/CheckboxFormatter.js +1 -1
- package/components/DataGrid/subcomponents/Table/subcomponents/CustomIcons.js +2 -2
- package/components/DragResizeWindowRND/DragResizeWindowRND.js +0 -1
- package/components/DynamicFilter/dictionary.js +0 -12
- package/components/DynamicFilter/store/DynamicFilterContext.js +1 -1
- package/components/DynamicFilter/subcomponents/DynamicFilterBase/DynamicFilterBase.js +1 -1
- package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/helpers.js +3 -2
- package/components/DynamicFilter/subcomponents/PopoverFilter/usePopoverFilter.d.ts +3 -3
- package/components/DynamicFilter/types.d.ts +2 -2
- package/components/DynamicSort/dictionary.js +0 -5
- package/components/DynamicSort/slots/DynamicSortSlots.js +1 -1
- package/components/DynamicSort/store/DynamicSortContext.js +1 -1
- package/components/DynamicSort/subcomponents/DynamicSortBase/DynamicSortBase.js +1 -1
- package/components/DynamicSort/subcomponents/PopoverSort/usePopoverSort.d.ts +3 -3
- package/components/GridLayout/GridLayout.js +1 -1
- package/components/GridLayout/styles.js +1 -1
- package/components/GridLayout/subcomponents/GridItem/index.js +1 -1
- package/components/GridLayout/subcomponents/Responsive/helper.js +1 -1
- package/components/GridLayout/subcomponents/Responsive/index.js +1 -1
- package/components/GridLayout/subcomponents/Responsive/responsiveUtils.js +3 -3
- package/components/GridLayout/subcomponents/withSizeProvider/index.js +1 -1
- package/components/Icon/Icon.js +1 -1
- package/components/Icon/constants.js +2 -2
- package/components/Icon/slots/IconSlots.js +1 -1
- package/components/Image/Image.js +1 -1
- package/components/Image/constant.js +2 -2
- package/components/Image/slots/ImageSlots.js +1 -1
- package/components/Image/subcomponents/IntersectComponent/index.js +1 -1
- package/components/LanguagePopover/LanguagePopover.js +1 -1
- package/components/LoadingError/LoadingError.js +1 -1
- package/components/LoadingError/slots/LoadingErrorSlots.js +1 -1
- package/components/MFIsolationApp/subcomponents/MFAuthApp/MFAuthApp.js +1 -1
- package/components/NoItemSelected/NoItemSelected.js +1 -1
- package/components/NumberInput/hooks/useNumberInput/NumberInputReducer.js +1 -1
- package/components/NumberInput/hooks/useNumberInput/useNumberInput.js +2 -0
- package/components/ObjectLogs/dictionary.js +0 -3
- package/components/ObjectLogs/subcomponents/ObjectLogsByM4L/ObjectLogsByM4L.js +1 -1
- package/components/ObjectLogs/subcomponents/ObjectLogsByOthers/ObjectLogsByOthers.js +2 -2
- package/components/Pager/Pager.styles.js +0 -8
- package/components/Pager/dicctionary.js +0 -5
- package/components/PrintingSystem/subcomponents/ChartNode/index.js +1 -1
- package/components/PropertyValue/PropertyValue.js +2 -2
- package/components/ScrollBar/ScrollBar.js +1 -1
- package/components/SideBar/slots/SideBarEnum.js +4 -4
- package/components/SideBar/slots/SideBarSlots.js +1 -1
- package/components/SideBar/subcomponents/ContentGroups/subcomponents/ContainerMenuItemsMain/styles.js +1 -1
- package/components/ToastContainer/ToastContainer.js +1 -1
- package/components/WindowBase/slots/WindowBaseSlots.js +1 -1
- package/components/animate/variants/bounce.js +1 -1
- package/components/animate/variants/fade.js +1 -1
- package/components/animate/variants/transition.js +2 -2
- package/components/areas/components/AreasAdmin/AreasAdmin.js +1 -1
- package/components/areas/components/AreasViewer/AreasViewer.js +1 -1
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/AreaGridLayout/AreaGridLayout.js +1 -1
- package/components/areas/contexts/AreasContext/helpers/helper.js +14 -14
- package/components/areas/contexts/AreasContext/store.js +5 -5
- package/components/areas/icons.js +0 -8
- package/components/commercial/HamburgerMenu/classes/index.js +1 -1
- package/components/formatters/BooleanFormatter/BooleanFormatter.js +1 -1
- package/components/formatters/BooleanFormatter/slots/BooleanFormatterSlots.js +3 -3
- package/components/formatters/PeriodFormatter/PeriodFormatter.js +1 -1
- package/components/formatters/PeriodFormatter/slots/PeriodFormatterSlots.js +2 -2
- package/components/hook-form/RHFAutocomplete/RHFAutocomplete.js +30 -19
- package/components/hook-form/RHFAutocomplete/tests/common.d.ts +37 -0
- package/components/hook-form/RHFAutocomplete/types.d.ts +3 -8
- package/components/hook-form/RHFAutocompleteAsync/RHFAutocompleteAsync.d.ts +32 -5
- package/components/hook-form/RHFAutocompleteAsync/RHFAutocompleteAsync.js +49 -84
- package/components/hook-form/RHFAutocompleteAsync/RHFAutocompleteAsyncStyles.d.ts +2 -2
- package/components/hook-form/RHFAutocompleteAsync/hooks/useFetchOptions.d.ts +5 -0
- package/components/hook-form/RHFAutocompleteAsync/hooks/useFetchOptions.js +64 -0
- package/components/hook-form/RHFAutocompleteAsync/reducer/RHFAutocompleteReducer.d.ts +14 -0
- package/components/hook-form/RHFAutocompleteAsync/reducer/RHFAutocompleteReducer.js +79 -0
- package/components/hook-form/RHFAutocompleteAsync/slots/RHFAutocompleteSlotsAsync.d.ts +1 -1
- package/components/hook-form/RHFAutocompleteAsync/tests/OnChangFilterParmsDefined.test.d.ts +1 -0
- package/components/hook-form/RHFAutocompleteAsync/tests/OnChangFilterParmsUndefined.test.d.ts +1 -0
- package/components/hook-form/RHFAutocompleteAsync/tests/RHFAutocompleteReducer.test.d.ts +1 -0
- package/components/hook-form/RHFAutocompleteAsync/tests/common.d.ts +41 -0
- package/components/hook-form/RHFAutocompleteAsync/types.d.ts +120 -4
- package/components/hook-form/RHFAutocompleteAsync/types.js +38 -0
- package/components/hook-form/RHFCheckbox/slots/RHFCheckBoxSlots.js +1 -1
- package/components/hook-form/RHFPeriod/RHFPeriod.js +1 -1
- package/components/hook-form/RHFTextField/RHFTextField.js +3 -2
- package/components/hook-form/RHFTextField/RHFTextField.styles.js +1 -3
- package/components/hook-form/RHFTextFieldPassword/slots/RHFTextFieldPasswordSlots.js +1 -1
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/RHFUploadSingleFile.js +1 -1
- package/components/hook-form/RHFormContext/classes/index.js +1 -1
- package/components/hook-form/RHFormContext/index.js +1 -1
- package/components/mui_extended/Accordion/Accordion.js +1 -1
- package/components/mui_extended/Accordion/slots/AccordionSlots.js +2 -2
- package/components/mui_extended/Autocomplete/Autocomplete.d.ts +7 -0
- package/components/mui_extended/Autocomplete/Autocomplete.js +59 -196
- package/components/mui_extended/Autocomplete/Autocomplete.styles.js +27 -16
- package/components/mui_extended/Autocomplete/hooks/useEndAdornments.d.ts +14 -0
- package/components/mui_extended/Autocomplete/hooks/useEndAdornments.js +47 -0
- package/components/mui_extended/Autocomplete/hooks/useStartAdornments.d.ts +21 -0
- package/components/mui_extended/Autocomplete/hooks/useStartAdornments.js +31 -0
- package/components/mui_extended/Autocomplete/hooks/useValuesAndHandlers.d.ts +23 -0
- package/components/mui_extended/Autocomplete/hooks/useValuesAndHandlers.js +135 -0
- package/components/mui_extended/Autocomplete/icons.d.ts +4 -0
- package/components/mui_extended/Autocomplete/icons.js +7 -0
- package/components/mui_extended/Autocomplete/renderOptions/index.d.ts +7 -2
- package/components/mui_extended/Autocomplete/renderOptions/index.js +7 -6
- package/components/mui_extended/Autocomplete/slots/AutocompleteSlots.js +10 -11
- package/components/mui_extended/Autocomplete/types.d.ts +2 -0
- package/components/mui_extended/CheckBox/CheckBox.js +1 -1
- package/components/mui_extended/CheckBox/slots/CheckBoxSlots.js +2 -2
- package/components/mui_extended/DateTimePicker/slots/DateTimePickerSlots.js +1 -1
- package/components/mui_extended/IconButton/slots/IconButtonSlots.js +1 -1
- package/components/mui_extended/ImageButton/utils/Clases/index.js +1 -1
- package/components/mui_extended/MenuItem/slots/MenuItemSlots.js +1 -1
- package/components/mui_extended/NavLink/NavLink.js +1 -1
- package/components/mui_extended/NavLink/constants.js +2 -2
- package/components/mui_extended/NavLink/slots/NavLinkSlots.js +1 -1
- package/components/mui_extended/Popover/Popover.js +1 -1
- package/components/mui_extended/Popover/Popover.styles.js +1 -5
- package/components/mui_extended/Popover/constants.js +2 -2
- package/components/mui_extended/Select/Select.js +1 -1
- package/components/mui_extended/Select/Select.styles.js +1 -1
- package/components/mui_extended/Select/constants.js +1 -1
- package/components/mui_extended/Select/slots/SelectSlots.js +1 -1
- package/components/mui_extended/Tab/Tab.js +1 -1
- package/components/mui_extended/TextField/constants.js +1 -1
- package/components/mui_extended/Tooltip/Tooltip.js +2 -2
- package/components/mui_extended/Tooltip/slots/TooltipSlots.js +2 -2
- package/components/mui_extended/Typography/Typography.js +1 -1
- package/components/mui_extended/Typography/constants.js +3 -3
- package/components/mui_extended/Typography/slots/typographySlots.js +1 -1
- package/components/popups/components/PopupsViewer/icons.js +0 -1
- package/hooks/useDataGridPersistence/constants.js +2 -2
- package/hooks/useDataGridPersistence/useDataGridPersistence.js +1 -1
- package/hooks/useDynamicFilterAndSort/useDynamicFilterAndSort.js +13 -10
- package/hooks/useSvgColor/constants.js +2 -2
- package/hooks/useSvgColor/helpers.js +1 -1
- package/hooks/useSvgColor/useSvgColor.js +1 -1
- package/index.js +14 -12
- package/mockServiceWorker.js +1 -1
- package/package.json +1 -1
- package/storybook/components/extended/mui/Autocomplete/AutoComple.stories.d.ts +1 -0
- package/storybook/hook-form/RHFAutocomplete/RHFAutocomplete.stories.d.ts +8 -6
- package/storybook/hook-form/RHFAutocomplete/constants.d.ts +23 -0
- package/storybook/hook-form/RHFAutocompleteAsync/RHFAutocompleteAsync.stories.d.ts +11 -4
- package/storybook/hook-form/RHFAutocompleteAsync/constants.d.ts +10 -1
- package/storybook/hook-form/RHFAutocompleteAsync/handlers.d.ts +1 -0
- package/components/hook-form/RHFAutocomplete/oldTypes.d.ts +0 -43
- /package/components/hook-form/RHFAutocomplete/{RHFAutocomplete.test.d.ts → tests/RHFAutocomplete.test.d.ts} +0 -0
|
@@ -1,7 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RHFAutocompleteAsyncProps } from './types';
|
|
2
2
|
/**
|
|
3
|
-
* RHFAutocompleteProps is a component that handles asynchronous autocomplete functionality
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* RHFAutocompleteProps is a component that handles asynchronous autocomplete functionality
|
|
4
|
+
* Requerimientos:
|
|
5
|
+
*
|
|
6
|
+
* - Generales
|
|
7
|
+
* - (Test OK) Solo cuando se abre el combo se debe hacer el request si nunca se ha hecho .
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* - Si al componente se le define onChangeFilterParms
|
|
12
|
+
* - (Test OK) Solo cuando se abre el combo se debe hacer el request .
|
|
13
|
+
* - (Test OK) Si se abre el combo varias veces, solo se hace el request la primera vez si no han cambiado los parms.
|
|
14
|
+
* - (Test OK) Si cambian los parms (Normalmente cuando el componente depende de otro componente), al volver a abrir el combo se debe volver a hacer el request.
|
|
15
|
+
* - (Test OK) Si el request esta en curso y se cierra el combo, se debe dejar terminar el request para no perder la respuesta.
|
|
16
|
+
* - (Test OK) Si el request genera un error, debe dejar las mismas opciones y en el proximo open se debe volver a hacer el request.
|
|
17
|
+
* - Si es multiple = false
|
|
18
|
+
* - (Test OK) Si el usuario tiene preseleccionada una opcion al cargar el componente, esta opcion debe verse incluso si no se abierto el combo.
|
|
19
|
+
* - (Test OK) Si tiene preseleccionada una opcion, se abre el combo y cuando llega la respuesta no está dentro de las que llegan de la red,
|
|
20
|
+
* no debe desaparecer la opcion preseleccionada, solo si se selecciona otra opcion.
|
|
21
|
+
*
|
|
22
|
+
* - Si es multiple = true
|
|
23
|
+
* - (Test OK) Si el usuario tiene preseleccionadas una opcion al cargar el componente, esta opcion debe verse incluso si no se abierto el combo.
|
|
24
|
+
* - (Test OK) Si tiene preseleccionadas varias opciones, se abre el combo y cuando llega la respuesta no están dentro de las que llegan de la red,
|
|
25
|
+
* no deben desaparecer las opciones preseleccionadas, solo si se selecciona otra opcion.
|
|
26
|
+
*
|
|
27
|
+
* - Si el componente se le define onChangeFilterParms
|
|
28
|
+
* - (Test OK) Si se define multiple y onChangeFilterParms, se debe lanzar un error.
|
|
29
|
+
* - (Test OK) Cuando se ejecuta se hace la primera apertura debe ejecutarse el request con los parms y adicionalmente los que devuelve onChangeFilterParms.
|
|
30
|
+
* - (Test OK) Si el usuario digita y deja espacios de 300ms, se encola otra petición usando onChangeFilterParms.
|
|
31
|
+
* - (Test OK) Si el request esta en curso y el usuario digita, cancela la petición actual.
|
|
32
|
+
*
|
|
6
33
|
*/
|
|
7
|
-
export declare function RHFAutocompleteAsync<T>(props:
|
|
34
|
+
export declare function RHFAutocompleteAsync<T>(props: RHFAutocompleteAsyncProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useNetwork, getPropertyByString } from "@m4l/core";
|
|
3
2
|
import debounce from "lodash-es/debounce";
|
|
4
|
-
import {
|
|
3
|
+
import { useReducer, useCallback } from "react";
|
|
4
|
+
import { a as actionsType } from "./types.js";
|
|
5
5
|
import { R as RHFAutocomplete } from "../RHFAutocomplete/RHFAutocomplete.js";
|
|
6
|
-
import {
|
|
6
|
+
import { R as RHFAutocompleteAsyncReducer, g as getInitialStateRHFAutocompleteAsync } from "./reducer/RHFAutocompleteReducer.js";
|
|
7
|
+
import { u as useFetchOptions } from "./hooks/useFetchOptions.js";
|
|
7
8
|
function RHFAutocompleteAsync(props) {
|
|
8
9
|
const {
|
|
9
10
|
name,
|
|
10
11
|
endPoint,
|
|
11
|
-
responseToCamelCase,
|
|
12
12
|
label,
|
|
13
13
|
timeout = 5e3,
|
|
14
14
|
parms,
|
|
@@ -17,112 +17,77 @@ function RHFAutocompleteAsync(props) {
|
|
|
17
17
|
isRemote = true,
|
|
18
18
|
isExternalUrl = false,
|
|
19
19
|
onChangeFilterParms,
|
|
20
|
-
onChange,
|
|
21
|
-
onOpen,
|
|
22
|
-
onClose,
|
|
23
20
|
getOptionLabel,
|
|
24
21
|
isOptionEqualToValue,
|
|
25
22
|
multiple,
|
|
26
23
|
disabled,
|
|
27
24
|
skeletonWidth,
|
|
28
|
-
|
|
29
|
-
value
|
|
25
|
+
responseToCamelCase
|
|
30
26
|
} = props;
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
const [state, dispatch] = useReducer(
|
|
28
|
+
RHFAutocompleteAsyncReducer(onChangeFilterParms),
|
|
29
|
+
getInitialStateRHFAutocompleteAsync({
|
|
30
|
+
parms,
|
|
31
|
+
onChangeFilterParms
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
if (multiple && onChangeFilterParms) {
|
|
35
|
+
throw new Error("multiple no puede estar habilitado cuando se define onChangeFilterParms, definir el filtro en los parms, si es necesario");
|
|
36
|
+
}
|
|
37
|
+
useFetchOptions({
|
|
38
|
+
state,
|
|
39
|
+
dispatch,
|
|
40
|
+
endPoint,
|
|
41
|
+
timeout,
|
|
42
|
+
isExternalUrl,
|
|
43
|
+
parms,
|
|
44
|
+
responseToCamelCase,
|
|
45
|
+
isRemote,
|
|
46
|
+
resultField
|
|
47
|
+
});
|
|
38
48
|
const refresh = () => {
|
|
39
|
-
|
|
40
|
-
firstOpen === 0 && hanldeFirstOpen();
|
|
49
|
+
dispatch({ type: actionsType.REFRESH });
|
|
41
50
|
};
|
|
42
|
-
const onOpenLocal = (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
const onOpenLocal = () => {
|
|
52
|
+
dispatch({ type: actionsType.OPEN });
|
|
53
|
+
};
|
|
54
|
+
const onCloseLocal = () => {
|
|
55
|
+
dispatch({ type: actionsType.CLOSE });
|
|
47
56
|
};
|
|
48
57
|
const debouncedFilter = useCallback(
|
|
49
|
-
debounce(
|
|
50
|
-
(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
300
|
|
60
|
-
),
|
|
61
|
-
[setCanLoadOptions, setFilterParms]
|
|
58
|
+
debounce((newFilterParms) => {
|
|
59
|
+
dispatch({
|
|
60
|
+
type: actionsType.SET_QUERY_PARAMS,
|
|
61
|
+
payload: newFilterParms
|
|
62
|
+
});
|
|
63
|
+
}, 300, {
|
|
64
|
+
// leading: true,
|
|
65
|
+
trailing: true
|
|
66
|
+
}),
|
|
67
|
+
[dispatch]
|
|
62
68
|
);
|
|
63
|
-
const onChangeFilterParmsLocal = (newValue) => {
|
|
64
|
-
if (onChangeFilterParms) {
|
|
69
|
+
const onChangeFilterParmsLocal = useCallback((newValue, reason) => {
|
|
70
|
+
if (onChangeFilterParms && reason === "input") {
|
|
65
71
|
debouncedFilter(onChangeFilterParms(newValue));
|
|
66
72
|
}
|
|
67
|
-
};
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
setCanLoadOptions(true);
|
|
70
|
-
}, [parms, endPoint]);
|
|
71
|
-
const hanldeFirstOpen = () => {
|
|
72
|
-
if (firstOpen === 0) {
|
|
73
|
-
setFirstOpen(1);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
useEffect(() => {
|
|
77
|
-
let cancel = false;
|
|
78
|
-
if (firstOpen === 1 && !loading && canLoadOptions) {
|
|
79
|
-
setIsloading(true);
|
|
80
|
-
setOptions([]);
|
|
81
|
-
setCanLoadOptions(false);
|
|
82
|
-
networkOperation({
|
|
83
|
-
method: "GET",
|
|
84
|
-
endPoint,
|
|
85
|
-
timeout,
|
|
86
|
-
isExternalUrl,
|
|
87
|
-
parms: { ...parms, ...filterParms },
|
|
88
|
-
responseToCamelCase,
|
|
89
|
-
isRemote
|
|
90
|
-
}).then((response) => {
|
|
91
|
-
if (cancel) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
const valueMaybeArray = getPropertyByString(response, resultField);
|
|
95
|
-
const newOptions = Array.isArray(valueMaybeArray) ? valueMaybeArray : [];
|
|
96
|
-
setOptions(newOptions);
|
|
97
|
-
}).finally(() => {
|
|
98
|
-
setIsloading(false);
|
|
99
|
-
setCanLoadOptions(true);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
return () => {
|
|
103
|
-
cancel = true;
|
|
104
|
-
};
|
|
105
|
-
}, [firstOpen, parms, filterParms, endPoint, newRefresh]);
|
|
73
|
+
}, [onChangeFilterParms, debouncedFilter]);
|
|
106
74
|
return /* @__PURE__ */ jsx(
|
|
107
75
|
RHFAutocomplete,
|
|
108
76
|
{
|
|
109
77
|
name,
|
|
110
|
-
loading,
|
|
78
|
+
loading: state.loading,
|
|
111
79
|
label,
|
|
112
|
-
options,
|
|
80
|
+
options: state.options,
|
|
113
81
|
onChangeFilterParmsLocal: onChangeFilterParms ? onChangeFilterParmsLocal : void 0,
|
|
114
82
|
size,
|
|
115
83
|
refresh: () => refresh(),
|
|
116
84
|
onOpen: onOpenLocal,
|
|
117
|
-
onChange,
|
|
118
85
|
getOptionLabel,
|
|
119
86
|
isOptionEqualToValue,
|
|
120
87
|
multiple,
|
|
121
88
|
disabled,
|
|
122
|
-
onClose,
|
|
123
|
-
skeletonWidth
|
|
124
|
-
open,
|
|
125
|
-
value
|
|
89
|
+
onClose: onCloseLocal,
|
|
90
|
+
skeletonWidth
|
|
126
91
|
}
|
|
127
92
|
);
|
|
128
93
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const rhfAutocompleteAsyncSyles:
|
|
1
|
+
import { RHFAutocompleteAsyncStyles } from './types';
|
|
2
|
+
export declare const rhfAutocompleteAsyncSyles: RHFAutocompleteAsyncStyles;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { useRef, useEffect } from "react";
|
|
2
|
+
import { a as actionsType } from "../types.js";
|
|
3
|
+
import { useNetwork, getPropertyByString } from "@m4l/core";
|
|
4
|
+
const useFetchOptions = (props) => {
|
|
5
|
+
const {
|
|
6
|
+
state,
|
|
7
|
+
dispatch,
|
|
8
|
+
endPoint,
|
|
9
|
+
timeout,
|
|
10
|
+
isExternalUrl,
|
|
11
|
+
parms,
|
|
12
|
+
responseToCamelCase,
|
|
13
|
+
isRemote,
|
|
14
|
+
resultField = "data"
|
|
15
|
+
} = props;
|
|
16
|
+
const { networkOperation } = useNetwork();
|
|
17
|
+
const abortControllerRef = useRef(null);
|
|
18
|
+
const refFireFetchCount = useRef(state.fireFetchCount);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
dispatch({ type: actionsType.SET_PARAMS, payload: parms });
|
|
21
|
+
}, [parms]);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
let cancel = false;
|
|
24
|
+
if (refFireFetchCount.current === state.fireFetchCount) {
|
|
25
|
+
return;
|
|
26
|
+
} else {
|
|
27
|
+
refFireFetchCount.current = state.fireFetchCount;
|
|
28
|
+
}
|
|
29
|
+
if (state.fireFetchCount > 0) {
|
|
30
|
+
if (abortControllerRef.current) {
|
|
31
|
+
abortControllerRef.current.abort();
|
|
32
|
+
}
|
|
33
|
+
abortControllerRef.current = new AbortController();
|
|
34
|
+
networkOperation({
|
|
35
|
+
method: "GET",
|
|
36
|
+
endPoint,
|
|
37
|
+
timeout,
|
|
38
|
+
isExternalUrl,
|
|
39
|
+
parms: { ...parms, ...state.queryParams },
|
|
40
|
+
responseToCamelCase,
|
|
41
|
+
isRemote,
|
|
42
|
+
signal: abortControllerRef.current.signal
|
|
43
|
+
}).then((response) => {
|
|
44
|
+
if (cancel) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const valueMaybeArray = getPropertyByString(response, resultField);
|
|
48
|
+
const newOptions = Array.isArray(valueMaybeArray) ? valueMaybeArray : [];
|
|
49
|
+
dispatch({ type: actionsType.FINISH_LOAD_OPTIONS, payload: { options: newOptions } });
|
|
50
|
+
}).catch(() => {
|
|
51
|
+
dispatch({ type: actionsType.FINISH_LOAD_OPTIONS, payload: {} });
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return () => {
|
|
55
|
+
cancel = true;
|
|
56
|
+
if (abortControllerRef.current) {
|
|
57
|
+
abortControllerRef.current.abort();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}, [state.fireFetchCount]);
|
|
61
|
+
};
|
|
62
|
+
export {
|
|
63
|
+
useFetchOptions as u
|
|
64
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RHFAutocompleteAsyncAction, RHFAutocompleteAsyncState, OnChangeFilterParms } from '../types';
|
|
2
|
+
type getInitialStateRHFAutocompleteAsyncProps = {
|
|
3
|
+
parms?: Record<string, any>;
|
|
4
|
+
onChangeFilterParms?: OnChangeFilterParms;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Returns the initial state for the RHFAutocompleteAsync component.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getInitialStateRHFAutocompleteAsync: <T>(props: getInitialStateRHFAutocompleteAsyncProps) => RHFAutocompleteAsyncState<T>;
|
|
10
|
+
/**
|
|
11
|
+
* Reducer to manage state of RHFAutocompleteAsync component.
|
|
12
|
+
*/
|
|
13
|
+
export declare const RHFAutocompleteAsyncReducer: <T>(onChangeFilterParms?: OnChangeFilterParms) => (state: RHFAutocompleteAsyncState<T>, action: RHFAutocompleteAsyncAction<T>) => RHFAutocompleteAsyncState<T>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { deepEqual } from "fast-equals";
|
|
2
|
+
import { a as actionsType } from "../types.js";
|
|
3
|
+
const getInitialStateRHFAutocompleteAsync = (props) => ({
|
|
4
|
+
fireFetchCount: 0,
|
|
5
|
+
options: [],
|
|
6
|
+
parms: props.parms,
|
|
7
|
+
// allowFetch: false,
|
|
8
|
+
loading: false,
|
|
9
|
+
queryParams: props.onChangeFilterParms ? props.onChangeFilterParms("") : {},
|
|
10
|
+
isOpen: false,
|
|
11
|
+
firstOpen: true
|
|
12
|
+
// selectedOptions: [],
|
|
13
|
+
});
|
|
14
|
+
const RHFAutocompleteAsyncReducer = (onChangeFilterParms) => (state, action) => {
|
|
15
|
+
switch (action.type) {
|
|
16
|
+
case actionsType.REFRESH:
|
|
17
|
+
return {
|
|
18
|
+
...state,
|
|
19
|
+
fireFetchCount: state.fireFetchCount + 1
|
|
20
|
+
//Lanzr una nueva petición
|
|
21
|
+
};
|
|
22
|
+
case actionsType.SET_PARAMS:
|
|
23
|
+
if (deepEqual(state.parms, action.payload)) {
|
|
24
|
+
return state;
|
|
25
|
+
}
|
|
26
|
+
if (onChangeFilterParms) {
|
|
27
|
+
state.queryParams = onChangeFilterParms("");
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
...state,
|
|
31
|
+
parms: action.payload,
|
|
32
|
+
fireFetchCount: 0,
|
|
33
|
+
firstOpen: true
|
|
34
|
+
};
|
|
35
|
+
case actionsType.SET_QUERY_PARAMS:
|
|
36
|
+
if (deepEqual(state.queryParams, action.payload)) {
|
|
37
|
+
return state;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
...state,
|
|
41
|
+
queryParams: action.payload,
|
|
42
|
+
fireFetchCount: state.fireFetchCount + 1
|
|
43
|
+
};
|
|
44
|
+
case actionsType.FINISH_LOAD_OPTIONS:
|
|
45
|
+
const finalOptions = action.payload?.options || state.options;
|
|
46
|
+
const firstOpen = action.payload?.options ? state.firstOpen : true;
|
|
47
|
+
return {
|
|
48
|
+
...state,
|
|
49
|
+
options: finalOptions,
|
|
50
|
+
loading: false,
|
|
51
|
+
firstOpen
|
|
52
|
+
};
|
|
53
|
+
case actionsType.OPEN:
|
|
54
|
+
return {
|
|
55
|
+
...state,
|
|
56
|
+
isOpen: true,
|
|
57
|
+
fireFetchCount: state.firstOpen ? state.fireFetchCount + 1 : state.fireFetchCount,
|
|
58
|
+
firstOpen: false,
|
|
59
|
+
loading: state.firstOpen ? true : state.loading
|
|
60
|
+
// allowFetch: true,
|
|
61
|
+
};
|
|
62
|
+
case actionsType.CLOSE:
|
|
63
|
+
return {
|
|
64
|
+
...state,
|
|
65
|
+
isOpen: false
|
|
66
|
+
};
|
|
67
|
+
// case actionsType.SET_SELECTED_OPTIONS_TO_AUTOCOMPLETE:
|
|
68
|
+
// return {
|
|
69
|
+
// ...state,
|
|
70
|
+
// selectedOptions: action.payload,
|
|
71
|
+
// };
|
|
72
|
+
default:
|
|
73
|
+
return state;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
export {
|
|
77
|
+
RHFAutocompleteAsyncReducer as R,
|
|
78
|
+
getInitialStateRHFAutocompleteAsync as g
|
|
79
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const RHFAutocompleteAsyncRootStyled: import('@emotion/styled').StyledComponent<Pick<import('../../RHFAutocomplete/types').RHFAutocompleteProps<unknown,
|
|
1
|
+
export declare const RHFAutocompleteAsyncRootStyled: import('@emotion/styled').StyledComponent<Pick<import('../../RHFAutocomplete/types').RHFAutocompleteProps<unknown, undefined, undefined, undefined>, keyof import('../../RHFAutocomplete/types').RHFAutocompleteProps<unknown, undefined, undefined, undefined>> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown>, {}, {}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { RHFAutocompleteAsyncProps } from '../types';
|
|
2
|
+
import { renderMaterialUI } from '../../../../test';
|
|
3
|
+
import { FieldValues } from 'react-hook-form';
|
|
4
|
+
export declare const FIELD_NAME = "rhf-autocomplete-async";
|
|
5
|
+
export declare const FIELD_NAME_PRESELECTED = "rhf-autocomplete-async-preselected";
|
|
6
|
+
export declare const FIELD_NAME_PRESELECTED_NOT_IN_OPTIONS = "rhf-autocomplete-async-preselected-not-in-options";
|
|
7
|
+
export declare const FIELD_NAME_PRESELECTED_MULTIPLE = "rhf-autocomplete-async-preselected-multiple";
|
|
8
|
+
export declare const FIELD_NAME_PRESELECTED_MULTIPLE_NOT_IN_OPTIONS = "rhf-autocomplete-async-preselected-multiple-not-in-options";
|
|
9
|
+
export interface OptionsTests {
|
|
10
|
+
id: number;
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const mockItems: OptionsTests[];
|
|
14
|
+
export declare const mockItemPreselected: OptionsTests;
|
|
15
|
+
export declare const mockItemPreselectedMultiple: OptionsTests[];
|
|
16
|
+
export declare const mockItemPreselectedNotInOptions: OptionsTests;
|
|
17
|
+
export declare const mockItemPreselectedMultipleNotInOptions: OptionsTests[];
|
|
18
|
+
export declare const INITIAL_FORM_VALUES: FieldValues;
|
|
19
|
+
export declare const DEFAULT_PROPS: RHFAutocompleteAsyncProps<OptionsTests>;
|
|
20
|
+
/**
|
|
21
|
+
* Custom filter function
|
|
22
|
+
*/
|
|
23
|
+
export declare const onChangeFilterParms: (newValue: string) => {
|
|
24
|
+
f: ({
|
|
25
|
+
n: string;
|
|
26
|
+
o: string;
|
|
27
|
+
o1: boolean;
|
|
28
|
+
} | {
|
|
29
|
+
n: string;
|
|
30
|
+
o: string;
|
|
31
|
+
o1: string;
|
|
32
|
+
})[];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Renderiza el componente con el contexto de EnvironmentProvider y RHFormProvider.
|
|
36
|
+
*/
|
|
37
|
+
export declare const renderWithContexts: (ui: React.ReactElement, initialValuesFormContext?: FieldValues, validationSchema?: any) => ReturnType<typeof renderMaterialUI>;
|
|
38
|
+
/**
|
|
39
|
+
* Renders the RHFAutocompleteAsync component with the provided props.
|
|
40
|
+
*/
|
|
41
|
+
export declare const renderRHFAutocompleteAsync: (fieldName: string, overrideProps?: Partial<RHFAutocompleteAsyncProps<OptionsTests>>) => ReturnType<typeof renderMaterialUI>;
|
|
@@ -1,17 +1,46 @@
|
|
|
1
|
-
import { OverridesStyleRules } from '@mui/material/styles/overrides';
|
|
2
1
|
import { RHFAutocompleteProps } from '../RHFAutocomplete/types';
|
|
3
2
|
import { RFHAUTOCOMPLETEASYNC_KEY_COMPONENT } from './constants';
|
|
4
3
|
import { RHFAutocompleteAsyncSlots } from './slots';
|
|
5
4
|
import { Theme } from '@mui/material';
|
|
6
|
-
|
|
5
|
+
import { M4LOverridesStyleRules } from '../../../@types/augmentations';
|
|
6
|
+
export type OnChangeFilterParms = (newValue: string) => Record<string, any>;
|
|
7
|
+
export interface RHFAutocompleteAsyncProps<T extends any = unknown> extends Omit<RHFAutocompleteProps<T>, 'options' | 'onOpen' | 'onClose' | 'open' | 'multiple'> {
|
|
8
|
+
/**
|
|
9
|
+
* URL to fetch data from
|
|
10
|
+
*/
|
|
7
11
|
endPoint: string;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the response should be converted to camel case
|
|
14
|
+
*/
|
|
8
15
|
responseToCamelCase?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Timeout for the fetch request
|
|
18
|
+
*/
|
|
9
19
|
timeout?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Parameters to send with the fetch request
|
|
22
|
+
*/
|
|
10
23
|
parms?: Record<string, any>;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the URL is external
|
|
26
|
+
*/
|
|
11
27
|
isExternalUrl?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Field in the response object that contains the data, normalmente data.
|
|
30
|
+
*/
|
|
12
31
|
resultField?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the data is fetched remotely
|
|
34
|
+
*/
|
|
13
35
|
isRemote?: boolean;
|
|
14
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Callback for when the filter parameters change, or initial state.
|
|
38
|
+
*/
|
|
39
|
+
onChangeFilterParms?: OnChangeFilterParms;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the autocomplete is multiple
|
|
42
|
+
*/
|
|
43
|
+
multiple?: boolean;
|
|
15
44
|
}
|
|
16
45
|
/**
|
|
17
46
|
* Defines the types of Slots available for the Autocomplete.
|
|
@@ -20,4 +49,91 @@ export type RHFAutocompleteAsyncSlotsType = keyof typeof RHFAutocompleteAsyncSlo
|
|
|
20
49
|
/**
|
|
21
50
|
* Styles applicable to the Autocomplete using themes and custom slots.
|
|
22
51
|
*/
|
|
23
|
-
export type
|
|
52
|
+
export type RHFAutocompleteAsyncStyles = M4LOverridesStyleRules<RHFAutocompleteAsyncSlotsType, typeof RFHAUTOCOMPLETEASYNC_KEY_COMPONENT, Theme>;
|
|
53
|
+
/**
|
|
54
|
+
* Name of actions for reducer in RHFAutocompleteAsync component.
|
|
55
|
+
*/
|
|
56
|
+
export declare const actionsType: {
|
|
57
|
+
/**
|
|
58
|
+
* Refresh the options of the autocomplete, esta opcion es manual, por lo tanto debe forzar
|
|
59
|
+
* la recarga de las options.
|
|
60
|
+
*/
|
|
61
|
+
readonly REFRESH: "REFRESH";
|
|
62
|
+
/**
|
|
63
|
+
* Set the params to request the options. When the parms change, the options are requested again, and queryParams are rebuilt.
|
|
64
|
+
*/
|
|
65
|
+
readonly SET_PARAMS: "SET_PARAMS";
|
|
66
|
+
/**
|
|
67
|
+
* Set the query params to request the options with the new filter
|
|
68
|
+
* selected from the option listed in the autocomplete.
|
|
69
|
+
*/
|
|
70
|
+
readonly SET_QUERY_PARAMS: "SET_QUERY_PARAMS";
|
|
71
|
+
/**
|
|
72
|
+
* Indicate if the popover options are open.
|
|
73
|
+
*/
|
|
74
|
+
readonly OPEN: "OPEN";
|
|
75
|
+
/**
|
|
76
|
+
* Indicate if the popover options are close.
|
|
77
|
+
*/
|
|
78
|
+
readonly CLOSE: "CLOSE";
|
|
79
|
+
/**
|
|
80
|
+
* Reset the state options, allowFetchingOptionsAutocomplete (false)
|
|
81
|
+
* and loading (true) to initial state before fetching options
|
|
82
|
+
* to wait the response from the server.
|
|
83
|
+
*/
|
|
84
|
+
readonly START_FETCHING_OPTIONS: "START_FETCHING_OPTIONS";
|
|
85
|
+
/**
|
|
86
|
+
* Set new options to list in autocomplete.
|
|
87
|
+
* For example, when the user is typing,
|
|
88
|
+
* the options are filtered from the server and the new options are set to the list.
|
|
89
|
+
*/
|
|
90
|
+
readonly FINISH_LOAD_OPTIONS: "FINISH_LOAD_OPTIONS";
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Action type for RHFAutocompleteAsync component.
|
|
94
|
+
*/
|
|
95
|
+
export type RHFAutocompleteAsyncAction<T> = {
|
|
96
|
+
type: typeof actionsType.REFRESH;
|
|
97
|
+
} | {
|
|
98
|
+
type: typeof actionsType.SET_QUERY_PARAMS;
|
|
99
|
+
payload: Record<string, any>;
|
|
100
|
+
} | {
|
|
101
|
+
type: typeof actionsType.FINISH_LOAD_OPTIONS;
|
|
102
|
+
payload: {
|
|
103
|
+
options?: Array<T>;
|
|
104
|
+
};
|
|
105
|
+
} | {
|
|
106
|
+
type: typeof actionsType.OPEN;
|
|
107
|
+
} | {
|
|
108
|
+
type: typeof actionsType.CLOSE;
|
|
109
|
+
} | {
|
|
110
|
+
type: typeof actionsType.SET_PARAMS;
|
|
111
|
+
payload: Record<string, any> | undefined;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* State type for RHFAutocompleteAsync component.
|
|
115
|
+
*/
|
|
116
|
+
export type RHFAutocompleteAsyncState<T> = {
|
|
117
|
+
options: Array<T>;
|
|
118
|
+
loading: boolean;
|
|
119
|
+
parms?: Record<string, any>;
|
|
120
|
+
queryParams: Record<string, any>;
|
|
121
|
+
isOpen: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Indica si es la primera apertura el componente
|
|
124
|
+
*/
|
|
125
|
+
firstOpen: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Number of times the fetching is fired.
|
|
128
|
+
* the fetching count is incremented, useFetchOptions Effect is fired.
|
|
129
|
+
* When the fetching count is equal to 0, the fetching is not allowed.
|
|
130
|
+
*/
|
|
131
|
+
fireFetchCount: number;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Params for useFetchOptions hook.
|
|
135
|
+
*/
|
|
136
|
+
export interface UseFetchOptionsProps<T> extends Pick<RHFAutocompleteAsyncProps<T>, 'endPoint' | 'timeout' | 'isExternalUrl' | 'parms' | 'responseToCamelCase' | 'isRemote' | 'resultField'> {
|
|
137
|
+
state: RHFAutocompleteAsyncState<T>;
|
|
138
|
+
dispatch: (value: RHFAutocompleteAsyncAction<T>) => void;
|
|
139
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const actionsType = {
|
|
2
|
+
/**
|
|
3
|
+
* Refresh the options of the autocomplete, esta opcion es manual, por lo tanto debe forzar
|
|
4
|
+
* la recarga de las options.
|
|
5
|
+
*/
|
|
6
|
+
REFRESH: "REFRESH",
|
|
7
|
+
/**
|
|
8
|
+
* Set the params to request the options. When the parms change, the options are requested again, and queryParams are rebuilt.
|
|
9
|
+
*/
|
|
10
|
+
SET_PARAMS: "SET_PARAMS",
|
|
11
|
+
/**
|
|
12
|
+
* Set the query params to request the options with the new filter
|
|
13
|
+
* selected from the option listed in the autocomplete.
|
|
14
|
+
*/
|
|
15
|
+
SET_QUERY_PARAMS: "SET_QUERY_PARAMS",
|
|
16
|
+
/**
|
|
17
|
+
* Indicate if the popover options are open.
|
|
18
|
+
*/
|
|
19
|
+
OPEN: "OPEN",
|
|
20
|
+
/**
|
|
21
|
+
* Indicate if the popover options are close.
|
|
22
|
+
*/
|
|
23
|
+
CLOSE: "CLOSE",
|
|
24
|
+
/**
|
|
25
|
+
* Set new options to list in autocomplete.
|
|
26
|
+
* For example, when the user is typing,
|
|
27
|
+
* the options are filtered from the server and the new options are set to the list.
|
|
28
|
+
*/
|
|
29
|
+
FINISH_LOAD_OPTIONS: "FINISH_LOAD_OPTIONS"
|
|
30
|
+
// /**
|
|
31
|
+
// * Set the selected options to the autocomplete because
|
|
32
|
+
// * are necessary merge with the options obtains from the server
|
|
33
|
+
// */
|
|
34
|
+
// SET_SELECTED_OPTIONS_TO_AUTOCOMPLETE: 'SET_SELECTED_OPTIONS_TO_AUTOCOMPLETE',
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
actionsType as a
|
|
38
|
+
};
|
|
@@ -2,8 +2,8 @@ import { styled } from "@mui/material/styles";
|
|
|
2
2
|
import { r as rhfCheckBoxStyles } from "../RHFCheckBox.styles.js";
|
|
3
3
|
import { R as RHFCheckBoxSlots } from "./RHFCheckBoxEnum.js";
|
|
4
4
|
import { R as RHF_CHECKBOX_KEY_COMPONENT } from "../constants.js";
|
|
5
|
-
import { C as CheckBox } from "../../../mui_extended/CheckBox/CheckBox.js";
|
|
6
5
|
import { L as Label } from "../../../Label/Label.js";
|
|
6
|
+
import { C as CheckBox } from "../../../mui_extended/CheckBox/CheckBox.js";
|
|
7
7
|
const RHFCheckboxRoot = styled("div", {
|
|
8
8
|
name: RHF_CHECKBOX_KEY_COMPONENT,
|
|
9
9
|
slot: RHFCheckBoxSlots.root
|
|
@@ -9,8 +9,8 @@ import { R as RHF_PERIOD_KEY_COMPONENT } from "./constants.js";
|
|
|
9
9
|
import clsx from "clsx";
|
|
10
10
|
import { g as getPropDataTestId } from "../../../test/getNameDataTestId.js";
|
|
11
11
|
import { a as getComponentSlotRoot } from "../../../utils/getComponentSlotRoot.js";
|
|
12
|
-
import { R as RHFPeriodSlots } from "./slots/RHFPeriodEnum.js";
|
|
13
12
|
import { H as HelperError } from "../../HelperError/HelperError.js";
|
|
13
|
+
import { R as RHFPeriodSlots } from "./slots/RHFPeriodEnum.js";
|
|
14
14
|
const RHFPeriod = (props) => {
|
|
15
15
|
const {
|
|
16
16
|
name,
|
|
@@ -27,9 +27,11 @@ const RHFTextField = forwardRef((props, ref) => {
|
|
|
27
27
|
mandatoryMessage,
|
|
28
28
|
helperText = true,
|
|
29
29
|
className,
|
|
30
|
+
htmlFor,
|
|
30
31
|
...other
|
|
31
32
|
} = props;
|
|
32
|
-
const
|
|
33
|
+
const id = useId();
|
|
34
|
+
const htmlForId = htmlFor ?? id;
|
|
33
35
|
const ariaLabelledById = `field-label-${htmlForId}`;
|
|
34
36
|
const {
|
|
35
37
|
control
|
|
@@ -87,7 +89,6 @@ const RHFTextField = forwardRef((props, ref) => {
|
|
|
87
89
|
value: type === "number" ? isNaN(parseFloat(value)) ? "" : value : value || "",
|
|
88
90
|
inputProps: {
|
|
89
91
|
name,
|
|
90
|
-
ss: 1,
|
|
91
92
|
id: htmlForId,
|
|
92
93
|
"aria-labelledby": ariaLabelledById,
|
|
93
94
|
...getPropDataTestId(RHF_TEXT_FIELD_KEY_COMPONENT, RHFTextFieldSlots.textField)
|