@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
|
@@ -18,9 +18,7 @@ const rhfTextFieldStyles = {
|
|
|
18
18
|
/**
|
|
19
19
|
* Estilos personalizados para el componente Skeleton.
|
|
20
20
|
*/
|
|
21
|
-
helperErrorStyled: {}
|
|
22
|
-
skeletonTextFieldRoot: {},
|
|
23
|
-
wrapperSkeletonRHFTextField: {}
|
|
21
|
+
helperErrorStyled: {}
|
|
24
22
|
};
|
|
25
23
|
export {
|
|
26
24
|
rhfTextFieldStyles as r
|
|
@@ -2,9 +2,9 @@ import { styled } from "@mui/material";
|
|
|
2
2
|
import { R as RHFTextFieldPasswordSlots } from "./RHFTextFieldPasswordEnum.js";
|
|
3
3
|
import { R as RHF_TEXT_FIELD_PASSWORD_KEY_COMPONENT } from "../constanst.js";
|
|
4
4
|
import { r as rhfTextFieldPasswordStyles } from "../RHFTextFieldPassword.styles.js";
|
|
5
|
+
import { L as Label } from "../../../Label/Label.js";
|
|
5
6
|
import { T as TextField } from "../../../mui_extended/TextField/TextField.js";
|
|
6
7
|
import { I as IconButton } from "../../../mui_extended/IconButton/IconButton.js";
|
|
7
|
-
import { L as Label } from "../../../Label/Label.js";
|
|
8
8
|
const RHFTextFieldPasswordRoot = styled("div", {
|
|
9
9
|
name: RHF_TEXT_FIELD_PASSWORD_KEY_COMPONENT,
|
|
10
10
|
slot: RHFTextFieldPasswordSlots.root
|
|
@@ -3,7 +3,7 @@ import { useFormContext, Controller } from "react-hook-form";
|
|
|
3
3
|
import { U as UploadSingleFile } from "./subcomponents/UploadSingleFile/index.js";
|
|
4
4
|
import { R as RHFUploadSingleFileRootStyled, L as LabelStyled, H as HelperErrorStyled } from "./slots/RHFUploadSingleFileSlots.js";
|
|
5
5
|
import clsx from "clsx";
|
|
6
|
-
import {
|
|
6
|
+
import { D as DEFAULT_MAX_FILE_SIZE, R as RHF_UPLOAD_SINGLE_FILE_KEY_COMPONENT } from "./constants.js";
|
|
7
7
|
import { g as getPropDataTestId } from "../../../../test/getNameDataTestId.js";
|
|
8
8
|
import { R as RHFUploadSingleFileSlots } from "./slots/RHFUploadSingleFileEnum.js";
|
|
9
9
|
import { u as useComponentSize } from "../../../../hooks/useComponentSize/useComponentSize.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { generateUtilityClass, generateUtilityClasses } from "@mui/material";
|
|
2
2
|
import { unstable_composeClasses } from "@mui/base";
|
|
3
3
|
import { c as componentName } from "./constants.js";
|
|
4
4
|
generateUtilityClasses(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
3
|
import clsx from "clsx";
|
|
4
|
-
import {
|
|
4
|
+
import { FormProvider, useForm } from "react-hook-form";
|
|
5
5
|
import { yupResolver } from "@hookform/resolvers/yup";
|
|
6
6
|
import { F as FormProviderRoot } from "./styles.js";
|
|
7
7
|
import { R as RHFormProviderUtilityClasses } from "./classes/index.js";
|
|
@@ -3,7 +3,7 @@ import { T as TEST_PROP_ID } from "../../../test/constants_no_mock.js";
|
|
|
3
3
|
import { a as getNameDataTestId } from "../../../test/getNameDataTestId.js";
|
|
4
4
|
import { P as PATH_EXPANDED_ICON, A as ACCORDION_KEY } from "./constants.js";
|
|
5
5
|
import { a as getComponentSlotRoot } from "../../../utils/getComponentSlotRoot.js";
|
|
6
|
-
import { A as AccordionRootStyled, a as AccordionSummaryStyled, I as
|
|
6
|
+
import { A as AccordionRootStyled, a as AccordionSummaryStyled, I as IconLabelStyled, L as LabelStyled, b as IconExpandedStyled, c as AccordionDetailsStyled } from "./slots/AccordionSlots.js";
|
|
7
7
|
import { forwardRef } from "react";
|
|
8
8
|
import { u as useComponentSize } from "../../../hooks/useComponentSize/useComponentSize.js";
|
|
9
9
|
const Accordion = forwardRef((props, ref) => {
|
|
@@ -31,9 +31,9 @@ const AccordionDetailsStyled = styled(AccordionDetails, {
|
|
|
31
31
|
})(accordionStyles?.accordionDetails);
|
|
32
32
|
export {
|
|
33
33
|
AccordionRootStyled as A,
|
|
34
|
-
|
|
34
|
+
IconLabelStyled as I,
|
|
35
35
|
LabelStyled as L,
|
|
36
36
|
AccordionSummaryStyled as a,
|
|
37
|
-
|
|
37
|
+
IconExpandedStyled as b,
|
|
38
38
|
AccordionDetailsStyled as c
|
|
39
39
|
};
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import { AutocompleteProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Autocomplete refactorizado con slots M4L.
|
|
4
|
+
* Tener en cuenta que cuando es multiple y se abre el dropdown, y el value no está dentro de lasl opciones.
|
|
5
|
+
* MUI va a genera el siguiente warning (Y es normal que suceda, no es necesario darle solución):
|
|
6
|
+
* MUI: The value provided to Autocomplete is invalid.
|
|
7
|
+
* None of the options match with `{"y":y,"x":"xxx"}`. etc.
|
|
8
|
+
*/
|
|
2
9
|
export declare const Autocomplete: import('react').ForwardRefExoticComponent<AutocompleteProps<unknown, boolean | undefined> & import('react').RefAttributes<HTMLInputElement | HTMLTextAreaElement>>;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import { useModuleDictionary, useModuleSkeleton
|
|
3
|
-
import { forwardRef,
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useModuleDictionary, useModuleSkeleton } from "@m4l/core";
|
|
3
|
+
import { forwardRef, useMemo } from "react";
|
|
4
4
|
import { r as renderOption } from "./renderOptions/index.js";
|
|
5
|
+
import { u as useValuesAndHandlers } from "./hooks/useValuesAndHandlers.js";
|
|
6
|
+
import { u as useStartAdornments } from "./hooks/useStartAdornments.js";
|
|
7
|
+
import { u as useEndAdornments } from "./hooks/useEndAdornments.js";
|
|
5
8
|
import { u as useComponentSize } from "../../../hooks/useComponentSize/useComponentSize.js";
|
|
6
|
-
import {
|
|
9
|
+
import { S as SkeletonAutocompleteStyled, A as AutocompleteRootStyled, R as RenderInputStyled, P as PopperComponentStyled } from "./slots/AutocompleteSlots.js";
|
|
7
10
|
import { T as Typography } from "../Typography/Typography.js";
|
|
8
11
|
const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
9
12
|
const {
|
|
10
|
-
getOptionLabel,
|
|
11
|
-
isOptionEqualToValue,
|
|
12
13
|
options,
|
|
13
14
|
disabled,
|
|
14
|
-
onOpen,
|
|
15
|
-
onClose,
|
|
16
15
|
loading,
|
|
17
16
|
variant = "outlined",
|
|
18
17
|
size = "medium",
|
|
@@ -22,203 +21,52 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
22
21
|
// Diferencia
|
|
23
22
|
refresh,
|
|
24
23
|
error = false,
|
|
25
|
-
|
|
26
|
-
value
|
|
24
|
+
htmlFor
|
|
27
25
|
} = props;
|
|
28
26
|
const { getLabel } = useModuleDictionary();
|
|
29
27
|
const isSkeleton = useModuleSkeleton();
|
|
30
|
-
const { host_static_assets, environment_assets } = useEnvironment();
|
|
31
|
-
const [open, setOpen] = useState(false);
|
|
32
28
|
const { currentSize } = useComponentSize(size);
|
|
33
29
|
const adjustedSize = currentSize === "small" || currentSize === "medium" ? currentSize : "medium";
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
} else if (multiple && Array.isArray(value)) {
|
|
50
|
-
setInputValue("");
|
|
51
|
-
} else {
|
|
52
|
-
setInputValue("");
|
|
53
|
-
}
|
|
54
|
-
if (multiple) {
|
|
55
|
-
if (Array.isArray(value)) {
|
|
56
|
-
setSelectedValue(value.filter((option) => options.some((opt) => isOptionEqualToValueLocal(opt, option))));
|
|
57
|
-
} else {
|
|
58
|
-
setSelectedValue([]);
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
if (value) {
|
|
62
|
-
const option = options.find((opt) => isOptionEqualToValueLocal(opt, value));
|
|
63
|
-
setSelectedValue(option || null);
|
|
64
|
-
} else {
|
|
65
|
-
setSelectedValue(null);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}, [value, multiple, getOptionLabel, options, isOptionEqualToValueLocal]);
|
|
69
|
-
const handleDelete = useCallback((optionToDelete) => {
|
|
70
|
-
if (Array.isArray(selectedValue)) {
|
|
71
|
-
const updatedValue = selectedValue.filter(
|
|
72
|
-
(val) => !isOptionEqualToValueLocal(val, optionToDelete)
|
|
73
|
-
);
|
|
74
|
-
setSelectedValue(updatedValue);
|
|
75
|
-
onChange?.(
|
|
76
|
-
{},
|
|
77
|
-
updatedValue,
|
|
78
|
-
"removeOption"
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
}, [selectedValue, isOptionEqualToValueLocal, onChange]);
|
|
82
|
-
const handleRefresh = useCallback(() => {
|
|
83
|
-
refresh?.();
|
|
84
|
-
setOpen(true);
|
|
85
|
-
}, [refresh]);
|
|
86
|
-
const handleChange = (event, newSelectedValue, reason) => {
|
|
87
|
-
const updatedValue = multiple ? Array.isArray(newSelectedValue) ? newSelectedValue : [] : newSelectedValue;
|
|
88
|
-
setSelectedValue(updatedValue);
|
|
89
|
-
setInputValue(
|
|
90
|
-
!multiple && updatedValue ? getOptionLabel(updatedValue) : ""
|
|
91
|
-
);
|
|
92
|
-
onChange?.(event, updatedValue, reason);
|
|
93
|
-
};
|
|
94
|
-
const handleInputChange = (_event, newValue, reason) => {
|
|
95
|
-
setInputValue(newValue);
|
|
96
|
-
if (reason === "input" && onChangeFilterParmsLocal) {
|
|
97
|
-
onChangeFilterParmsLocal(newValue, reason);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
const onCloseLocal = (event, reason) => {
|
|
101
|
-
setOpen(false);
|
|
102
|
-
if (onClose) {
|
|
103
|
-
onClose(event, reason);
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
const onOpenLocal = useCallback((event) => {
|
|
107
|
-
setOpen((currentState) => !currentState);
|
|
108
|
-
if (onOpen) {
|
|
109
|
-
onOpen(event);
|
|
110
|
-
}
|
|
111
|
-
}, [onOpen]);
|
|
112
|
-
const getOptionLabelLocal = useCallback(
|
|
113
|
-
(option) => {
|
|
114
|
-
if (typeof option === "string") {
|
|
115
|
-
return option;
|
|
116
|
-
}
|
|
117
|
-
if (option === null || option === void 0) {
|
|
118
|
-
return "";
|
|
119
|
-
}
|
|
120
|
-
return getOptionLabel(option);
|
|
121
|
-
},
|
|
122
|
-
[getOptionLabel]
|
|
123
|
-
);
|
|
124
|
-
const getOptionUrlImageLocal = useCallback((option) => {
|
|
125
|
-
if (option === void 0 || option === null || getOptionUrlImage === void 0) {
|
|
126
|
-
return "";
|
|
127
|
-
}
|
|
128
|
-
return getOptionUrlImage(option);
|
|
129
|
-
}, [getOptionUrlImage]);
|
|
30
|
+
const {
|
|
31
|
+
open,
|
|
32
|
+
selectedValue,
|
|
33
|
+
inputValue,
|
|
34
|
+
isOptionEqualToValueLocal,
|
|
35
|
+
handleDelete,
|
|
36
|
+
handleRefresh,
|
|
37
|
+
handleChange,
|
|
38
|
+
handleInputChange,
|
|
39
|
+
onCloseLocal,
|
|
40
|
+
onOpenLocal,
|
|
41
|
+
getOptionLabelLocal,
|
|
42
|
+
checkKeyDown,
|
|
43
|
+
scrollPositionOptionsRef
|
|
44
|
+
} = useValuesAndHandlers(props);
|
|
130
45
|
const ownerState = useMemo(() => ({
|
|
131
46
|
size: adjustedSize,
|
|
132
47
|
variant,
|
|
133
48
|
disabled,
|
|
134
|
-
multiple: Boolean(multiple)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (!open && value !== null && options && options.length === 0) {
|
|
142
|
-
onChangeFilterParmsLocal?.(
|
|
143
|
-
getOptionLabelLocal(Array.isArray(value) ? value[0] : value),
|
|
144
|
-
"reset"
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
}, [
|
|
148
|
-
value,
|
|
149
|
-
open,
|
|
150
|
-
inputValue,
|
|
151
|
-
onChangeFilterParmsLocal,
|
|
49
|
+
multiple: Boolean(multiple),
|
|
50
|
+
error
|
|
51
|
+
}), [adjustedSize, disabled, error, multiple, variant]);
|
|
52
|
+
const startAdornments = useStartAdornments({
|
|
53
|
+
selectedValue,
|
|
54
|
+
multiple,
|
|
55
|
+
adjustedSize,
|
|
152
56
|
getOptionLabelLocal,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
57
|
+
ownerState,
|
|
58
|
+
handleDelete,
|
|
59
|
+
disabled
|
|
60
|
+
});
|
|
61
|
+
const endAdornments = useEndAdornments({
|
|
62
|
+
loading,
|
|
63
|
+
adjustedSize,
|
|
64
|
+
ownerState,
|
|
65
|
+
refresh,
|
|
66
|
+
handleRefresh,
|
|
67
|
+
disabled,
|
|
68
|
+
onOpenLocal
|
|
162
69
|
});
|
|
163
|
-
const adornments = useMemo(() => {
|
|
164
|
-
if (disabled) {
|
|
165
|
-
return null;
|
|
166
|
-
}
|
|
167
|
-
const returnValue = {};
|
|
168
|
-
if (Array.isArray(selectedValue) && multiple) {
|
|
169
|
-
returnValue.startAdornment = selectedValue.map((option, index) => /* @__PURE__ */ jsx(
|
|
170
|
-
ChipStyled,
|
|
171
|
-
{
|
|
172
|
-
size: adjustedSize,
|
|
173
|
-
label: getOptionLabelLocal(option),
|
|
174
|
-
opacity: true,
|
|
175
|
-
onDeleted: () => handleDelete(option),
|
|
176
|
-
ownerState: { ...ownerState }
|
|
177
|
-
},
|
|
178
|
-
index
|
|
179
|
-
));
|
|
180
|
-
} else {
|
|
181
|
-
if (getOptionUrlImage && selectedOption) {
|
|
182
|
-
returnValue.startAdornment = /* @__PURE__ */ jsx(
|
|
183
|
-
ImageStyled,
|
|
184
|
-
{
|
|
185
|
-
ownerState: { ...ownerState },
|
|
186
|
-
src: getOptionUrlImageLocal(selectedOption),
|
|
187
|
-
alt: getOptionLabelLocal(selectedOption)
|
|
188
|
-
}
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
returnValue.endAdornment = /* @__PURE__ */ jsxs(AdormentsStyled, { ownerState: {}, children: [
|
|
193
|
-
loading ? /* @__PURE__ */ jsx(
|
|
194
|
-
CircularProgressStyled,
|
|
195
|
-
{
|
|
196
|
-
ownerState: { ...ownerState },
|
|
197
|
-
size: adjustedSize
|
|
198
|
-
}
|
|
199
|
-
) : refresh ? /* @__PURE__ */ jsx(
|
|
200
|
-
IconButtonStyled,
|
|
201
|
-
{
|
|
202
|
-
ownerState: { ...ownerState },
|
|
203
|
-
icon: `${host_static_assets}/${environment_assets}/frontend/components/RHFAutocompletarAsync/assets/icons/round_refresh.svg`,
|
|
204
|
-
onClick: handleRefresh,
|
|
205
|
-
disabled,
|
|
206
|
-
size: adjustedSize
|
|
207
|
-
}
|
|
208
|
-
) : null,
|
|
209
|
-
/* @__PURE__ */ jsx(
|
|
210
|
-
IconButtonStyled,
|
|
211
|
-
{
|
|
212
|
-
ownerState: { ...ownerState },
|
|
213
|
-
icon: `${host_static_assets}/${environment_assets}/frontend/components/RHFAutocompletarAsync/assets/icons/chevronDown.svg`,
|
|
214
|
-
onClick: (event) => onOpenLocal(event),
|
|
215
|
-
disabled,
|
|
216
|
-
size: adjustedSize
|
|
217
|
-
}
|
|
218
|
-
)
|
|
219
|
-
] });
|
|
220
|
-
return returnValue;
|
|
221
|
-
}, [selectedValue, multiple, loading, adjustedSize, getOptionLabelLocal, ownerState, handleDelete, getOptionUrlImage, selectedOption, getOptionUrlImageLocal, refresh, host_static_assets, environment_assets, handleRefresh, disabled, onOpenLocal]);
|
|
222
70
|
if (isSkeleton) {
|
|
223
71
|
return /* @__PURE__ */ jsx(
|
|
224
72
|
SkeletonAutocompleteStyled,
|
|
@@ -275,6 +123,20 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
275
123
|
size
|
|
276
124
|
});
|
|
277
125
|
},
|
|
126
|
+
ListboxProps: {
|
|
127
|
+
//Esto para no perder el scroll de la lista de opciones, cuando es multiple, ya que MUI no lo guarda
|
|
128
|
+
onScroll: (event) => {
|
|
129
|
+
scrollPositionOptionsRef.current = event.currentTarget.scrollTop;
|
|
130
|
+
},
|
|
131
|
+
/**
|
|
132
|
+
* Ref para guardar el scroll de la lista de opciones
|
|
133
|
+
*/
|
|
134
|
+
ref: (listboxNode) => {
|
|
135
|
+
if (listboxNode) {
|
|
136
|
+
listboxNode.scrollTop = scrollPositionOptionsRef.current;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
},
|
|
278
140
|
renderInput: (params) => {
|
|
279
141
|
const { InputLabelProps, inputProps, InputProps, ...renderInputOhers } = params;
|
|
280
142
|
const { className: _classNoCount, ...otherInputProps } = InputProps;
|
|
@@ -288,13 +150,14 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
288
150
|
...InputLabelProps,
|
|
289
151
|
shrink: true
|
|
290
152
|
},
|
|
291
|
-
inputProps: { ...otherinputProps },
|
|
153
|
+
inputProps: { ...otherinputProps, id: htmlFor },
|
|
292
154
|
error,
|
|
293
155
|
...renderInputOhers,
|
|
294
156
|
autoComplete: "off",
|
|
295
157
|
InputProps: {
|
|
296
158
|
...otherInputProps,
|
|
297
|
-
|
|
159
|
+
startAdornment: startAdornments,
|
|
160
|
+
endAdornment: endAdornments
|
|
298
161
|
},
|
|
299
162
|
SelectProps: { native: true },
|
|
300
163
|
size: adjustedSize,
|
|
@@ -45,26 +45,37 @@ const autocompleteSyles = {
|
|
|
45
45
|
/**
|
|
46
46
|
* Styles for the chip component.
|
|
47
47
|
*/
|
|
48
|
-
chip: {}
|
|
48
|
+
chip: ({ theme, ownerState }) => ({
|
|
49
|
+
...ownerState.disabled && {
|
|
50
|
+
background: theme.vars.palette.chips.disabled.contained.backgroundColor,
|
|
51
|
+
color: theme.vars.palette.text.disabled,
|
|
52
|
+
"&& .M4LIcon-icon": {
|
|
53
|
+
backgroundColor: `${theme.vars.palette.text.disabled} !important`
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}),
|
|
49
57
|
/**
|
|
50
58
|
* Styles for the text field component.
|
|
51
59
|
*/
|
|
52
|
-
textField: ({ theme }) =>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
textField: ({ theme }) => {
|
|
61
|
+
return {
|
|
62
|
+
height: "auto !important",
|
|
63
|
+
position: "relative",
|
|
64
|
+
"& .MuiInputBase-root": {
|
|
65
|
+
padding: `${theme.vars.size.baseSpacings.sp1} ${theme.vars.size.baseSpacings.sp12} ${theme.vars.size.baseSpacings.sp1} 0!important`,
|
|
66
|
+
gap: theme.vars.size.baseSpacings.sp1,
|
|
67
|
+
flexWrap: "wrap",
|
|
68
|
+
paddingLeft: `${theme.vars.size.baseSpacings.sp1} !important`,
|
|
69
|
+
// borderColor: `${ ownerState.error ? theme.vars.palette.border.error : theme.vars.palette.border.secondary} !important`,
|
|
70
|
+
"& > input": {
|
|
71
|
+
width: "100%",
|
|
72
|
+
textOverflow: "ellipsis",
|
|
73
|
+
whiteSpace: "nowrap",
|
|
74
|
+
overflow: "hidden!important"
|
|
75
|
+
}
|
|
65
76
|
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
77
|
+
};
|
|
78
|
+
},
|
|
68
79
|
/**
|
|
69
80
|
* Styles for the popper component.
|
|
70
81
|
*/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AutocompleteOwnerState } from '../types';
|
|
2
|
+
export type UseAdornmentsProps = {
|
|
3
|
+
loading?: boolean;
|
|
4
|
+
adjustedSize: 'small' | 'medium';
|
|
5
|
+
ownerState: AutocompleteOwnerState;
|
|
6
|
+
refresh?: () => void;
|
|
7
|
+
handleRefresh: () => void;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
onOpenLocal: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Hook para el componente Autocomplete local
|
|
13
|
+
*/
|
|
14
|
+
export declare function useEndAdornments(props: UseAdornmentsProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { i as icons } from "../icons.js";
|
|
3
|
+
import { useEnvironment } from "@m4l/core";
|
|
4
|
+
import { a as AdormentsStyled, C as CircularProgressStyled, I as IconButtonStyled } from "../slots/AutocompleteSlots.js";
|
|
5
|
+
function useEndAdornments(props) {
|
|
6
|
+
const {
|
|
7
|
+
loading,
|
|
8
|
+
adjustedSize,
|
|
9
|
+
ownerState,
|
|
10
|
+
refresh,
|
|
11
|
+
handleRefresh,
|
|
12
|
+
disabled,
|
|
13
|
+
onOpenLocal
|
|
14
|
+
} = props;
|
|
15
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
16
|
+
return /* @__PURE__ */ jsxs(AdormentsStyled, { ownerState: {}, children: [
|
|
17
|
+
loading ? /* @__PURE__ */ jsx(
|
|
18
|
+
CircularProgressStyled,
|
|
19
|
+
{
|
|
20
|
+
ownerState: { ...ownerState },
|
|
21
|
+
size: adjustedSize
|
|
22
|
+
}
|
|
23
|
+
) : refresh ? /* @__PURE__ */ jsx(
|
|
24
|
+
IconButtonStyled,
|
|
25
|
+
{
|
|
26
|
+
ownerState: { ...ownerState },
|
|
27
|
+
icon: `${host_static_assets}/${environment_assets}/${icons.refresh}`,
|
|
28
|
+
onClick: handleRefresh,
|
|
29
|
+
disabled,
|
|
30
|
+
size: adjustedSize
|
|
31
|
+
}
|
|
32
|
+
) : null,
|
|
33
|
+
/* @__PURE__ */ jsx(
|
|
34
|
+
IconButtonStyled,
|
|
35
|
+
{
|
|
36
|
+
ownerState: { ...ownerState },
|
|
37
|
+
icon: `${host_static_assets}/${environment_assets}/${icons.chevronDown}`,
|
|
38
|
+
onClick: (event) => onOpenLocal(event),
|
|
39
|
+
disabled,
|
|
40
|
+
size: adjustedSize
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
] });
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
useEndAdornments as u
|
|
47
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AutocompleteOwnerState } from '../types';
|
|
2
|
+
export type UseAdornmentsProps<T> = {
|
|
3
|
+
selectedValue: T | T[] | null;
|
|
4
|
+
multiple?: boolean;
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
adjustedSize: 'small' | 'medium';
|
|
7
|
+
getOptionLabelLocal: (option: T) => string;
|
|
8
|
+
ownerState: AutocompleteOwnerState;
|
|
9
|
+
handleDelete: (option: T) => void;
|
|
10
|
+
getOptionUrlImage?: (option: T) => string;
|
|
11
|
+
selectedOption?: T;
|
|
12
|
+
getOptionUrlImageLocal: (option: T) => string;
|
|
13
|
+
refresh?: () => void;
|
|
14
|
+
handleRefresh: () => void;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
onOpenLocal: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Hook para el componente Autocomplete local
|
|
20
|
+
*/
|
|
21
|
+
export declare function useStartAdornments<T>(props: UseAdornmentsProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { b as ChipStyled } from "../slots/AutocompleteSlots.js";
|
|
3
|
+
function useStartAdornments(props) {
|
|
4
|
+
const {
|
|
5
|
+
selectedValue,
|
|
6
|
+
multiple,
|
|
7
|
+
adjustedSize,
|
|
8
|
+
getOptionLabelLocal,
|
|
9
|
+
ownerState,
|
|
10
|
+
handleDelete,
|
|
11
|
+
disabled
|
|
12
|
+
} = props;
|
|
13
|
+
if (!(Array.isArray(selectedValue) && multiple)) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return /* @__PURE__ */ jsx(Fragment, { children: selectedValue.map((option, index) => /* @__PURE__ */ jsx(
|
|
17
|
+
ChipStyled,
|
|
18
|
+
{
|
|
19
|
+
size: adjustedSize,
|
|
20
|
+
label: getOptionLabelLocal(option),
|
|
21
|
+
opacity: true,
|
|
22
|
+
onDeleted: () => handleDelete(option),
|
|
23
|
+
disabledDeleteButton: disabled,
|
|
24
|
+
ownerState: { ...ownerState }
|
|
25
|
+
},
|
|
26
|
+
`${option}-${index}`
|
|
27
|
+
)) });
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
useStartAdornments as u
|
|
31
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AutocompleteChangeReason, AutocompleteCloseReason } from '@mui/material';
|
|
2
|
+
import { KeyboardEvent } from 'react';
|
|
3
|
+
import { AutocompleteProps } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Hook para el componente Autocomplete local, proporciona los valores y los handlers para el componente Autocomplete.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useValuesAndHandlers<T, Multiple extends boolean | undefined>(props: AutocompleteProps<T, Multiple>): {
|
|
8
|
+
open: boolean;
|
|
9
|
+
inputValue: string;
|
|
10
|
+
selectedValue: T | T[] | null;
|
|
11
|
+
selectedOption: T | undefined;
|
|
12
|
+
isOptionEqualToValueLocal: (option: unknown, val: unknown) => boolean;
|
|
13
|
+
handleDelete: (optionToDelete: T) => void;
|
|
14
|
+
handleRefresh: () => void;
|
|
15
|
+
handleChange: (event: React.SyntheticEvent<Element, Event>, newSelectedValue: unknown, reason: AutocompleteChangeReason) => void;
|
|
16
|
+
handleInputChange: (_event: React.SyntheticEvent, newValue: string, reason: string) => void;
|
|
17
|
+
onCloseLocal: (event: React.SyntheticEvent, reason: AutocompleteCloseReason) => void;
|
|
18
|
+
onOpenLocal: (event: React.SyntheticEvent) => void;
|
|
19
|
+
getOptionLabelLocal: (option: unknown) => string;
|
|
20
|
+
getOptionUrlImageLocal: (option: T | null) => string;
|
|
21
|
+
checkKeyDown: (e: KeyboardEvent<HTMLDivElement>) => void;
|
|
22
|
+
scrollPositionOptionsRef: import('react').MutableRefObject<number>;
|
|
23
|
+
};
|