@m4l/components 9.3.26 → 9.3.27-BE071125-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/types.d.ts +18 -5
- package/components/AccountPopover/slots/AccountPopoverSlots.d.ts +1 -1
- package/components/AccountPopover/subcomponents/MenuPopover/MenuPopover.js +1 -1
- package/components/AppBar/slots/AppBarSlots.d.ts +1 -1
- package/components/Card/constants.d.ts +1 -1
- package/components/Chip/constants.d.ts +1 -1
- package/components/Chip/slots/ChipSlots.d.ts +1 -1
- package/components/Color/slots/ColorSlots.d.ts +1 -1
- package/components/ContainerFlow/constants.d.ts +1 -1
- package/components/DataGrid/subcomponents/editors/EditLabelEditor/formatter.d.ts +8 -0
- package/components/DataGrid/subcomponents/editors/EditLabelEditor/index.d.ts +3 -0
- package/components/DataGrid/subcomponents/editors/EditLabelEditor/types.d.ts +5 -0
- package/components/DataGrid/subcomponents/editors/EditLabelEditor/useColumnEditLabel.d.ts +9 -0
- package/components/DataGrid/tests/helpers/types.d.ts +2 -0
- package/components/DynamicFilter/slots/dynamicFilterSlots.d.ts +2 -2
- package/components/DynamicSort/slots/DynamicSortSlots.d.ts +2 -2
- package/components/EditLabel/EditLabel.d.ts +7 -0
- package/components/EditLabel/EditLabel.styles.d.ts +2 -0
- package/components/EditLabel/constants.d.ts +2 -0
- package/components/EditLabel/hooks/types.d.ts +17 -0
- package/components/EditLabel/hooks/useEditLabel.d.ts +7 -0
- package/components/EditLabel/icons.d.ts +5 -0
- package/components/EditLabel/index.d.ts +2 -0
- package/components/EditLabel/slots/EditLabelEnum.d.ts +8 -0
- package/components/EditLabel/slots/EditLabelSlots.d.ts +18 -0
- package/components/EditLabel/test/EditLabel.test.d.ts +1 -0
- package/components/EditLabel/types.d.ts +43 -0
- package/components/FormContainer/constants.d.ts +1 -1
- package/components/Icon/Icon.js +6 -3
- package/components/Icon/types.d.ts +4 -0
- package/components/Image/constant.d.ts +1 -1
- package/components/ImageText/ImageText.styles.js +1 -1
- package/components/ImageText/constants.d.ts +1 -1
- package/components/LanguagePopover/LanguagePopover.js +2 -0
- package/components/MFIsolationApp/MFIsolationApp.js +13 -8
- package/components/MFIsolationApp/MFIsolationApp.styles.d.ts +2 -0
- package/components/MFIsolationApp/MFIsolationApp.styles.js +22 -0
- package/components/MFIsolationApp/constants.d.ts +1 -0
- package/components/MFIsolationApp/constants.js +4 -0
- package/components/MFIsolationApp/icons.d.ts +3 -0
- package/components/MFIsolationApp/icons.js +6 -0
- package/components/MFIsolationApp/slots/MFIsolationAppEnum.d.ts +4 -0
- package/components/MFIsolationApp/slots/MFIsolationAppEnum.js +8 -0
- package/components/MFIsolationApp/slots/MFIsolationAppSlots.d.ts +2 -0
- package/components/MFIsolationApp/slots/MFIsolationAppSlots.js +17 -0
- package/components/MFIsolationApp/subcomponents/AppBarSettings/AppBarSettings.js +21 -0
- package/components/MFIsolationApp/subcomponents/AppBarSettings/index.js +1 -0
- package/components/MFIsolationApp/types.d.ts +8 -0
- package/components/MFIsolationAppStorybook/MFIsolationAppStorybook.js +137 -0
- package/components/MFIsolationAppStorybook/index.js +1 -0
- package/components/MFIsolationAppStorybook/subcomponents/MFAuthAppStorybook/MFAuthAppStorybook.js +44 -0
- package/components/MFIsolationAppStorybook/subcomponents/MFAuthAppStorybook/index.js +1 -0
- package/components/MFIsolationAppStorybook/types.d.ts +0 -4
- package/components/MenuActions/MenuActions.js +1 -1
- package/components/MenuActions/constants.d.ts +1 -1
- package/components/MenuActions/slots/MenuActionsSlots.d.ts +1 -1
- package/components/ModalDialog/ModalDialog.js +1 -0
- package/components/NoItemSelected/constant.d.ts +1 -1
- package/components/NumberInput/slots/NumberInputSlots.d.ts +2 -2
- package/components/ObjectLogs/slots/ObjectLogsSlots.d.ts +1 -1
- package/components/SideBar/slots/SideBarSlots.d.ts +1 -1
- package/components/ToastContainer/slots/toastContainerSlots.d.ts +2 -2
- package/components/WindowBase/constants.d.ts +1 -1
- package/components/areas/components/AreasAdmin/slots/AreasAdminSlots.d.ts +1 -1
- package/components/areas/contexts/AreasContext/store.js +2 -2
- package/components/extended/React-Json-Viewer/constants.d.ts +1 -1
- package/components/extended/React-resizable-panels/SplitLayout.js +1 -1
- package/components/formatters/ChipStatusFormatter/constants.d.ts +1 -1
- package/components/formatters/EditLabelFormatter/EditLabelFormatter.d.ts +5 -0
- package/components/formatters/EditLabelFormatter/EditLabelFormatter.styles.d.ts +2 -0
- package/components/formatters/EditLabelFormatter/constants.d.ts +5 -0
- package/components/formatters/EditLabelFormatter/index.d.ts +2 -0
- package/components/formatters/EditLabelFormatter/slots/EditLabelFormatterEnum.d.ts +4 -0
- package/components/formatters/EditLabelFormatter/slots/EditLabelFormatterSlots.d.ts +5 -0
- package/components/formatters/EditLabelFormatter/test/EditLabelFormatter.test.d.ts +1 -0
- package/components/formatters/EditLabelFormatter/types.d.ts +23 -0
- package/components/formatters/TagsFormatter/constants.d.ts +1 -1
- package/components/hook-form/RHFAutocomplete/RHFAutocomplete.d.ts +1 -1
- package/components/hook-form/RHFAutocomplete/RHFAutocomplete.js +7 -1
- package/components/hook-form/RHFAutocomplete/constants.d.ts +1 -1
- package/components/hook-form/RHFAutocomplete/types.d.ts +13 -0
- package/components/hook-form/RHFAutocompleteAsync/RHFAutocompleteAsync.js +7 -1
- package/components/hook-form/RHFAutocompleteAsync/slots/RHFAutocompleteSlotsAsync.d.ts +1 -1
- package/components/hook-form/RHFCheckbox/constants.d.ts +1 -1
- package/components/hook-form/RHFSelect/constants.d.ts +1 -1
- package/components/hook-form/RHFTextFieldPassword/slots/RHFTextFieldPasswordSlots.d.ts +1 -1
- package/components/hook-form/RHFUpload/RHFUploadImage/slots/RHFUploadImageSlots.d.ts +1 -1
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/constants.d.ts +25 -1
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/constants.js +5 -1
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/slots/RHFUploadSingleFileSlots.d.ts +1 -1
- package/components/hook-form/RHFormContext/index.d.ts +110 -10
- package/components/hook-form/RHFormContext/index.js +23 -21
- package/components/hook-form/RHFormContext/types.d.ts +64 -1
- package/components/index.d.ts +1 -0
- package/components/mui_extended/Autocomplete/Autocomplete.d.ts +4 -8
- package/components/mui_extended/Autocomplete/Autocomplete.js +24 -112
- package/components/mui_extended/Autocomplete/Autocomplete.styles.js +41 -12
- package/components/mui_extended/Autocomplete/hooks/useAutocomplete/useAutocomplete.d.ts +26 -0
- package/components/mui_extended/Autocomplete/hooks/useAutocomplete/useAutocomplete.js +166 -0
- package/components/mui_extended/Autocomplete/hooks/useEndAdornments.js +2 -1
- package/components/mui_extended/Autocomplete/hooks/useMultipleChips.d.ts +17 -0
- package/components/mui_extended/Autocomplete/hooks/useMultipleChips.js +108 -0
- package/components/mui_extended/Autocomplete/hooks/useValuesAndHandlers.d.ts +0 -2
- package/components/mui_extended/Autocomplete/hooks/useValuesAndHandlers.js +11 -17
- package/components/mui_extended/Autocomplete/slots/AutocompleteEnum.d.ts +2 -1
- package/components/mui_extended/Autocomplete/slots/AutocompleteEnum.js +1 -0
- package/components/mui_extended/Autocomplete/slots/AutocompleteSlots.d.ts +4 -1
- package/components/mui_extended/Autocomplete/slots/AutocompleteSlots.js +5 -0
- package/components/mui_extended/Autocomplete/subcomponents/LoadingText/LoadingText.d.ts +2 -0
- package/components/mui_extended/Autocomplete/subcomponents/LoadingText/LoadingText.js +14 -0
- package/components/mui_extended/Autocomplete/subcomponents/LoadingText/index.d.ts +1 -0
- package/components/mui_extended/Autocomplete/subcomponents/LoadingText/index.js +1 -0
- package/components/mui_extended/Autocomplete/subcomponents/NoOptionsText/NoOptionsText.d.ts +2 -0
- package/components/mui_extended/Autocomplete/subcomponents/NoOptionsText/NoOptionsText.js +14 -0
- package/components/mui_extended/Autocomplete/subcomponents/NoOptionsText/index.d.ts +1 -0
- package/components/mui_extended/Autocomplete/subcomponents/NoOptionsText/index.js +1 -0
- package/components/mui_extended/Autocomplete/subcomponents/PopperComponent/PopperComponent.d.ts +8 -0
- package/components/mui_extended/Autocomplete/subcomponents/PopperComponent/PopperComponent.js +23 -0
- package/components/mui_extended/Autocomplete/subcomponents/PopperComponent/index.d.ts +2 -0
- package/components/mui_extended/Autocomplete/subcomponents/PopperComponent/index.js +1 -0
- package/components/mui_extended/Autocomplete/subcomponents/PopperComponent/types.d.ts +7 -0
- package/components/mui_extended/Autocomplete/subcomponents/PopperComponent/types.js +1 -0
- package/components/mui_extended/Autocomplete/subcomponents/RenderAdornment/RenderAdornment.d.ts +6 -0
- package/components/mui_extended/Autocomplete/subcomponents/RenderAdornment/RenderAdornment.js +45 -0
- package/components/mui_extended/Autocomplete/subcomponents/renderOptions/index.d.ts +9 -0
- package/components/mui_extended/Autocomplete/subcomponents/renderOptions/index.js +61 -0
- package/components/mui_extended/Autocomplete/subcomponents/renderOptions/types.d.ts +7 -0
- package/components/mui_extended/Autocomplete/types.d.ts +21 -1
- package/components/mui_extended/Button/Button.js +15 -4
- package/components/mui_extended/Button/ButtonStyles.js +165 -82
- package/components/mui_extended/Button/{constans.d.ts → constants.d.ts} +1 -0
- package/components/mui_extended/Button/constants.js +8 -0
- package/components/mui_extended/Button/slots/ButtonSlots.js +1 -1
- package/components/mui_extended/Button/types.d.ts +1 -1
- package/components/mui_extended/CheckBox/CheckBox.js +1 -0
- package/components/mui_extended/DateTimePicker/slots/DateTimePickerSlots.d.ts +1 -1
- package/components/mui_extended/IconButton/constants.d.ts +1 -1
- package/components/mui_extended/IconButton/constants.js +4 -1
- package/components/mui_extended/MenuItem/MenuItem.js +1 -1
- package/components/mui_extended/MenuItem/MenuItem.styles.js +4 -1
- package/components/mui_extended/MenuItem/constants.d.ts +1 -1
- package/components/mui_extended/NavLink/constants.d.ts +1 -1
- package/components/mui_extended/Select/Select.js +71 -29
- package/components/mui_extended/Select/Select.styles.js +41 -6
- package/components/mui_extended/Select/constants.d.ts +1 -1
- package/components/mui_extended/Select/slots/SelectSlots.d.ts +1 -1
- package/components/mui_extended/Select/types.d.ts +6 -1
- package/components/mui_extended/TextField/constants.d.ts +1 -1
- package/components/mui_extended/TimePicker/slots/TimePickerSlots.d.ts +1 -1
- package/components/mui_extended/ToggleIconButton/slots/ToggleIconButtonSlots.d.ts +1 -1
- package/components/mui_extended/Tooltip/Tooltip.styles.js +16 -4
- package/components/mui_extended/Tooltip/constants.d.ts +1 -1
- package/components/mui_extended/Typography/constants.d.ts +1 -1
- package/components/mui_extended/Typography/types.d.ts +2 -1
- package/components/mui_extended/Typography/typography.styles.js +4 -9
- package/contexts/AppearanceComponentContext/AppearanceComponentContext.js +9 -1
- package/index.js +12 -10
- package/package.json +1 -1
- package/utils/getComponentSlotRoot.d.ts +3 -1
- package/components/mui_extended/Autocomplete/hooks/useStartAdornments.d.ts +0 -21
- package/components/mui_extended/Autocomplete/hooks/useStartAdornments.js +0 -31
- package/components/mui_extended/Autocomplete/renderOptions/index.d.ts +0 -22
- package/components/mui_extended/Autocomplete/renderOptions/index.js +0 -24
- package/components/mui_extended/Button/constans.js +0 -4
- /package/components/{MFIsolationAppStorybook → MFIsolationApp}/subcomponents/AppBarSettings/AppBarSettings.d.ts +0 -0
- /package/components/{MFIsolationAppStorybook → MFIsolationApp}/subcomponents/AppBarSettings/index.d.ts +0 -0
|
@@ -1,41 +1,30 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
import { S as SkeletonAutocompleteStyled, A as AutocompleteRootStyled, R as RenderInputStyled, P as PopperComponentStyled } from "./slots/AutocompleteSlots.js";
|
|
10
|
-
import { T as Typography } from "../Typography/Typography.js";
|
|
11
|
-
const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { u as useAutocomplete } from "./hooks/useAutocomplete/useAutocomplete.js";
|
|
4
|
+
import { S as SkeletonAutocompleteStyled, A as AutocompleteRootStyled } from "./slots/AutocompleteSlots.js";
|
|
5
|
+
import { P as PopperComponent } from "./subcomponents/PopperComponent/PopperComponent.js";
|
|
6
|
+
import { N as NoOptionsText } from "./subcomponents/NoOptionsText/NoOptionsText.js";
|
|
7
|
+
import { L as LoadingText } from "./subcomponents/LoadingText/LoadingText.js";
|
|
8
|
+
function AutocompleteComponent(props, ref) {
|
|
12
9
|
const {
|
|
13
10
|
options,
|
|
14
11
|
disabled,
|
|
15
12
|
loading,
|
|
16
|
-
variant = "outlined",
|
|
17
|
-
size = "medium",
|
|
18
13
|
onChangeFilterParmsLocal,
|
|
19
|
-
multiple
|
|
20
|
-
getOptionUrlImage,
|
|
21
|
-
// Diferencia
|
|
22
|
-
refresh,
|
|
23
|
-
error = false,
|
|
24
|
-
htmlFor,
|
|
25
|
-
readOnly = false,
|
|
26
|
-
placeholder
|
|
14
|
+
multiple
|
|
27
15
|
} = props;
|
|
28
|
-
const { getLabel } = useModuleDictionary();
|
|
29
|
-
const isSkeleton = useModuleSkeleton();
|
|
30
|
-
const { currentSize } = useComponentSize(size);
|
|
31
|
-
const adjustedSize = currentSize === "small" || currentSize === "medium" ? currentSize : "medium";
|
|
32
16
|
const {
|
|
17
|
+
// propiedades de useAutocomplete
|
|
18
|
+
ownerState,
|
|
19
|
+
isSkeleton,
|
|
20
|
+
currentSize,
|
|
21
|
+
memoizedRenderOption,
|
|
22
|
+
memoizedRenderInput,
|
|
23
|
+
// propiedades de useValuesAndHandlers
|
|
33
24
|
open,
|
|
34
25
|
selectedValue,
|
|
35
26
|
inputValue,
|
|
36
27
|
isOptionEqualToValueLocal,
|
|
37
|
-
handleDelete,
|
|
38
|
-
handleRefresh,
|
|
39
28
|
handleChange,
|
|
40
29
|
handleInputChange,
|
|
41
30
|
onCloseLocal,
|
|
@@ -43,35 +32,7 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
43
32
|
getOptionLabelLocal,
|
|
44
33
|
checkKeyDown,
|
|
45
34
|
scrollPositionOptionsRef
|
|
46
|
-
} =
|
|
47
|
-
const ownerState = useMemo(() => ({
|
|
48
|
-
size: adjustedSize,
|
|
49
|
-
variant,
|
|
50
|
-
disabled,
|
|
51
|
-
multiple: Boolean(multiple),
|
|
52
|
-
error,
|
|
53
|
-
readOnly
|
|
54
|
-
}), [adjustedSize, disabled, error, multiple, variant, readOnly]);
|
|
55
|
-
const startAdornments = useStartAdornments({
|
|
56
|
-
selectedValue,
|
|
57
|
-
multiple,
|
|
58
|
-
adjustedSize,
|
|
59
|
-
getOptionLabelLocal,
|
|
60
|
-
ownerState,
|
|
61
|
-
handleDelete,
|
|
62
|
-
disabled
|
|
63
|
-
});
|
|
64
|
-
const endAdornments = useEndAdornments({
|
|
65
|
-
loading,
|
|
66
|
-
adjustedSize,
|
|
67
|
-
ownerState,
|
|
68
|
-
refresh,
|
|
69
|
-
handleRefresh,
|
|
70
|
-
disabled,
|
|
71
|
-
onOpenLocal,
|
|
72
|
-
open,
|
|
73
|
-
readOnly
|
|
74
|
-
});
|
|
35
|
+
} = useAutocomplete(props);
|
|
75
36
|
if (isSkeleton) {
|
|
76
37
|
return /* @__PURE__ */ jsx(
|
|
77
38
|
SkeletonAutocompleteStyled,
|
|
@@ -86,25 +47,14 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
86
47
|
ownerState: { ...ownerState },
|
|
87
48
|
multiple,
|
|
88
49
|
onKeyDown: checkKeyDown,
|
|
89
|
-
size:
|
|
50
|
+
size: currentSize,
|
|
90
51
|
ref,
|
|
91
52
|
forcePopupIcon: false,
|
|
92
53
|
autoSelect: false,
|
|
93
54
|
options,
|
|
94
55
|
getOptionLabel: getOptionLabelLocal,
|
|
95
56
|
clearOnBlur: false,
|
|
96
|
-
PopperComponent
|
|
97
|
-
const { color: popperColor, ...otherPopperProps } = popperProps;
|
|
98
|
-
return /* @__PURE__ */ jsx(
|
|
99
|
-
PopperComponentStyled,
|
|
100
|
-
{
|
|
101
|
-
...otherPopperProps,
|
|
102
|
-
size: adjustedSize,
|
|
103
|
-
placement: "bottom-start",
|
|
104
|
-
ownerState: { ...ownerState }
|
|
105
|
-
}
|
|
106
|
-
);
|
|
107
|
-
},
|
|
57
|
+
PopperComponent,
|
|
108
58
|
isOptionEqualToValue: isOptionEqualToValueLocal,
|
|
109
59
|
value: selectedValue,
|
|
110
60
|
inputValue,
|
|
@@ -114,20 +64,11 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
114
64
|
onInputChange: handleInputChange,
|
|
115
65
|
onChange: handleChange,
|
|
116
66
|
loading,
|
|
117
|
-
loadingText: /* @__PURE__ */ jsx(
|
|
67
|
+
loadingText: /* @__PURE__ */ jsx(LoadingText, {}),
|
|
118
68
|
disabled,
|
|
119
|
-
noOptionsText: /* @__PURE__ */ jsx(
|
|
69
|
+
noOptionsText: /* @__PURE__ */ jsx(NoOptionsText, {}),
|
|
120
70
|
filterOptions: onChangeFilterParmsLocal ? (x) => x : void 0,
|
|
121
|
-
renderOption:
|
|
122
|
-
const isSelected = multiple ? Array.isArray(selectedValue) && selectedValue.some((val) => isOptionEqualToValueLocal(option, val)) : isOptionEqualToValueLocal(option, selectedValue);
|
|
123
|
-
return renderOption(renderProps, {
|
|
124
|
-
...typeof option === "object" && option !== null ? option : {},
|
|
125
|
-
label: getOptionLabelLocal(option),
|
|
126
|
-
selected: isSelected,
|
|
127
|
-
disabled,
|
|
128
|
-
size
|
|
129
|
-
});
|
|
130
|
-
},
|
|
71
|
+
renderOption: memoizedRenderOption,
|
|
131
72
|
ListboxProps: {
|
|
132
73
|
//Esto para no perder el scroll de la lista de opciones, cuando es multiple, ya que MUI no lo guarda
|
|
133
74
|
onScroll: (event) => {
|
|
@@ -142,40 +83,11 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
142
83
|
}
|
|
143
84
|
}
|
|
144
85
|
},
|
|
145
|
-
renderInput:
|
|
146
|
-
const { InputLabelProps, inputProps, InputProps, ...renderInputOhers } = params;
|
|
147
|
-
const { className: _classNoCount, ...otherInputProps } = InputProps;
|
|
148
|
-
const { className: _ClassNoCount2, ...otherinputProps } = inputProps;
|
|
149
|
-
return /* @__PURE__ */ jsx(
|
|
150
|
-
RenderInputStyled,
|
|
151
|
-
{
|
|
152
|
-
variant,
|
|
153
|
-
ownerState: { ...ownerState },
|
|
154
|
-
InputLabelProps: {
|
|
155
|
-
...InputLabelProps,
|
|
156
|
-
shrink: true
|
|
157
|
-
},
|
|
158
|
-
inputProps: { ...otherinputProps, id: htmlFor },
|
|
159
|
-
error,
|
|
160
|
-
...renderInputOhers,
|
|
161
|
-
autoComplete: "off",
|
|
162
|
-
InputProps: {
|
|
163
|
-
...otherInputProps,
|
|
164
|
-
startAdornment: startAdornments,
|
|
165
|
-
endAdornment: endAdornments,
|
|
166
|
-
readOnly
|
|
167
|
-
},
|
|
168
|
-
SelectProps: { native: true },
|
|
169
|
-
size: adjustedSize,
|
|
170
|
-
fullWidth: true,
|
|
171
|
-
disabled,
|
|
172
|
-
placeholder
|
|
173
|
-
}
|
|
174
|
-
);
|
|
175
|
-
}
|
|
86
|
+
renderInput: memoizedRenderInput
|
|
176
87
|
}
|
|
177
88
|
);
|
|
178
|
-
}
|
|
89
|
+
}
|
|
90
|
+
const Autocomplete = forwardRef(AutocompleteComponent);
|
|
179
91
|
export {
|
|
180
92
|
Autocomplete as A
|
|
181
93
|
};
|
|
@@ -3,9 +3,13 @@ const autocompleteSyles = {
|
|
|
3
3
|
/**
|
|
4
4
|
* Styles for the root component.
|
|
5
5
|
*/
|
|
6
|
-
root: () => ({
|
|
6
|
+
root: ({ theme }) => ({
|
|
7
7
|
width: "100%",
|
|
8
|
-
padding: 0
|
|
8
|
+
padding: 0,
|
|
9
|
+
"& .M4LImage-root": {
|
|
10
|
+
width: theme.vars.size.baseSpacings["sp3-5"],
|
|
11
|
+
height: theme.vars.size.baseSpacings["sp3-5"]
|
|
12
|
+
}
|
|
9
13
|
}),
|
|
10
14
|
/**
|
|
11
15
|
* Styles for the icon button component.
|
|
@@ -70,17 +74,22 @@ const autocompleteSyles = {
|
|
|
70
74
|
/**
|
|
71
75
|
* Styles for the text field component.
|
|
72
76
|
*/
|
|
73
|
-
textField: ({ theme }) => {
|
|
77
|
+
textField: ({ theme, ownerState }) => {
|
|
78
|
+
const sp1 = theme?.vars?.size?.baseSpacings?.sp1 || "4px";
|
|
79
|
+
const sp5 = theme?.vars?.size?.baseSpacings?.sp5 || "16px";
|
|
80
|
+
const sp7 = theme?.vars?.size?.baseSpacings?.sp7 || "24px";
|
|
74
81
|
return {
|
|
75
82
|
height: "auto !important",
|
|
76
83
|
position: "relative",
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
"&& .MuiInputBase-root": {
|
|
85
|
+
...ownerState?.startAdornment ? {
|
|
86
|
+
padding: `${sp1} ${sp7} ${sp1} ${sp5}!important`
|
|
87
|
+
} : {
|
|
88
|
+
padding: `${sp1} ${sp7} ${sp1} ${sp1}!important`
|
|
89
|
+
},
|
|
90
|
+
gap: sp1,
|
|
80
91
|
flexWrap: "wrap",
|
|
81
|
-
|
|
82
|
-
// borderColor: `${ ownerState?.error ? theme.vars.palette.border.error : theme.vars.palette.border.secondary} !important`,
|
|
83
|
-
"& > input": {
|
|
92
|
+
"&& > input": {
|
|
84
93
|
width: "100%",
|
|
85
94
|
textOverflow: "ellipsis",
|
|
86
95
|
whiteSpace: "nowrap",
|
|
@@ -99,9 +108,11 @@ const autocompleteSyles = {
|
|
|
99
108
|
minWidth: "100%",
|
|
100
109
|
maxHeight: "200px",
|
|
101
110
|
"& .MuiAutocomplete-listbox": {
|
|
111
|
+
display: "grid",
|
|
112
|
+
gridTemplateColumns: "auto",
|
|
102
113
|
height: "100%",
|
|
103
114
|
"& .M4LMenuItem-root ": {
|
|
104
|
-
width: "
|
|
115
|
+
width: "100%",
|
|
105
116
|
"& .M4LTypography-root": {
|
|
106
117
|
width: "fit-content",
|
|
107
118
|
overflow: "unset"
|
|
@@ -111,7 +122,7 @@ const autocompleteSyles = {
|
|
|
111
122
|
}
|
|
112
123
|
}),
|
|
113
124
|
/**
|
|
114
|
-
*
|
|
125
|
+
* styles for the circular progress component.
|
|
115
126
|
*/
|
|
116
127
|
circularProgress: {},
|
|
117
128
|
/**
|
|
@@ -149,7 +160,25 @@ const autocompleteSyles = {
|
|
|
149
160
|
display: "flex",
|
|
150
161
|
flexWrap: "wrap",
|
|
151
162
|
gap: theme.vars.size.baseSpacings.sp1
|
|
152
|
-
})
|
|
163
|
+
}),
|
|
164
|
+
/**
|
|
165
|
+
* Styles for the wrapper start adornment component.
|
|
166
|
+
*/
|
|
167
|
+
wrapperStartAdornment: ({ theme }) => {
|
|
168
|
+
const sp1 = theme?.vars?.size?.baseSpacings?.sp1 || "4px";
|
|
169
|
+
return {
|
|
170
|
+
width: "fit-content",
|
|
171
|
+
position: "absolute",
|
|
172
|
+
top: 0,
|
|
173
|
+
bottom: 0,
|
|
174
|
+
left: 0,
|
|
175
|
+
display: "flex",
|
|
176
|
+
flexDirection: "column",
|
|
177
|
+
justifyContent: "center",
|
|
178
|
+
alignItems: "center",
|
|
179
|
+
padding: `0px ${sp1}`
|
|
180
|
+
};
|
|
181
|
+
}
|
|
153
182
|
};
|
|
154
183
|
export {
|
|
155
184
|
autocompleteSyles as a
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AutocompleteOwnerState, AutocompleteProps } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook para el componente Autocomplete local
|
|
4
|
+
*/
|
|
5
|
+
export declare function useAutocomplete<T, Multiple extends boolean | undefined>(props: AutocompleteProps<T, Multiple>): {
|
|
6
|
+
ownerState: AutocompleteOwnerState;
|
|
7
|
+
isSkeleton: boolean;
|
|
8
|
+
currentSize: "small" | "medium";
|
|
9
|
+
memoizedRenderOption: (renderProps: any, option: any) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
memoizedRenderInput: (params: any) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
open: boolean;
|
|
12
|
+
selectedValue: T | T[] | null;
|
|
13
|
+
inputValue: string;
|
|
14
|
+
isOptionEqualToValueLocal: (option: unknown, val: unknown) => boolean;
|
|
15
|
+
handleDelete: (optionToDelete: T) => void;
|
|
16
|
+
handleRefresh: () => void;
|
|
17
|
+
handleChange: (event: React.SyntheticEvent<Element, Event>, newSelectedValue: unknown, reason: import('@mui/material').AutocompleteChangeReason) => void;
|
|
18
|
+
handleInputChange: (_event: React.SyntheticEvent, newValue: string, reason: string) => void;
|
|
19
|
+
onCloseLocal: (event: React.SyntheticEvent, reason: import('@mui/material').AutocompleteCloseReason) => void;
|
|
20
|
+
onOpenLocal: (event: React.SyntheticEvent) => void;
|
|
21
|
+
getOptionLabelLocal: (option: unknown) => string;
|
|
22
|
+
checkKeyDown: (e: import('react').KeyboardEvent<HTMLDivElement>) => void;
|
|
23
|
+
scrollPositionOptionsRef: import('react').MutableRefObject<number>;
|
|
24
|
+
multipleChips: import("react/jsx-runtime").JSX.Element | null;
|
|
25
|
+
endAdornments: import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useModuleSkeleton } from "@m4l/core";
|
|
3
|
+
import { u as useValuesAndHandlers } from "../useValuesAndHandlers.js";
|
|
4
|
+
import { useMemo, useCallback } from "react";
|
|
5
|
+
import { u as useMultipleChips } from "../useMultipleChips.js";
|
|
6
|
+
import { u as useEndAdornments } from "../useEndAdornments.js";
|
|
7
|
+
import { r as renderOption } from "../../subcomponents/renderOptions/index.js";
|
|
8
|
+
import { R as RenderInputStyled } from "../../slots/AutocompleteSlots.js";
|
|
9
|
+
import { u as useComponentSize } from "../../../../../hooks/useComponentSize/useComponentSize.js";
|
|
10
|
+
function useAutocomplete(props) {
|
|
11
|
+
const {
|
|
12
|
+
size,
|
|
13
|
+
variant,
|
|
14
|
+
disabled,
|
|
15
|
+
multiple,
|
|
16
|
+
error,
|
|
17
|
+
readOnly,
|
|
18
|
+
startAdornment,
|
|
19
|
+
getOptionStartAdornment,
|
|
20
|
+
getOptionEndAdornment,
|
|
21
|
+
loading,
|
|
22
|
+
refresh,
|
|
23
|
+
placeholder,
|
|
24
|
+
htmlFor
|
|
25
|
+
} = props;
|
|
26
|
+
const {
|
|
27
|
+
open,
|
|
28
|
+
selectedValue,
|
|
29
|
+
inputValue,
|
|
30
|
+
isOptionEqualToValueLocal,
|
|
31
|
+
handleDelete,
|
|
32
|
+
handleRefresh,
|
|
33
|
+
handleChange,
|
|
34
|
+
handleInputChange,
|
|
35
|
+
onCloseLocal,
|
|
36
|
+
onOpenLocal,
|
|
37
|
+
getOptionLabelLocal,
|
|
38
|
+
checkKeyDown,
|
|
39
|
+
scrollPositionOptionsRef
|
|
40
|
+
} = useValuesAndHandlers(props);
|
|
41
|
+
const { currentSize } = useComponentSize(size);
|
|
42
|
+
const isSkeleton = useModuleSkeleton();
|
|
43
|
+
const hasStartAdornment = !!props.startAdornment;
|
|
44
|
+
const ownerState = useMemo(() => ({
|
|
45
|
+
size: currentSize,
|
|
46
|
+
variant,
|
|
47
|
+
disabled,
|
|
48
|
+
multiple: Boolean(multiple),
|
|
49
|
+
error,
|
|
50
|
+
readOnly,
|
|
51
|
+
startAdornment: hasStartAdornment
|
|
52
|
+
}), [currentSize, variant, disabled, multiple, error, readOnly, hasStartAdornment]);
|
|
53
|
+
const multipleChips = useMultipleChips({
|
|
54
|
+
selectedValue,
|
|
55
|
+
multiple,
|
|
56
|
+
adjustedSize: currentSize,
|
|
57
|
+
getOptionLabelLocal,
|
|
58
|
+
ownerState,
|
|
59
|
+
handleDelete,
|
|
60
|
+
disabled,
|
|
61
|
+
startAdornment,
|
|
62
|
+
getOptionStartAdornment,
|
|
63
|
+
getOptionEndAdornment
|
|
64
|
+
});
|
|
65
|
+
const endAdornments = useEndAdornments({
|
|
66
|
+
loading,
|
|
67
|
+
adjustedSize: currentSize,
|
|
68
|
+
ownerState,
|
|
69
|
+
refresh,
|
|
70
|
+
handleRefresh,
|
|
71
|
+
disabled,
|
|
72
|
+
onOpenLocal,
|
|
73
|
+
open,
|
|
74
|
+
readOnly
|
|
75
|
+
});
|
|
76
|
+
const memoizedRenderOption = useCallback((renderProps, option) => {
|
|
77
|
+
const isSelected = multiple ? Array.isArray(selectedValue) && selectedValue.some((val) => isOptionEqualToValueLocal(option, val)) : isOptionEqualToValueLocal(option, selectedValue);
|
|
78
|
+
return renderOption(renderProps, {
|
|
79
|
+
...typeof option === "object" && option !== null ? option : {},
|
|
80
|
+
label: getOptionLabelLocal(option),
|
|
81
|
+
selected: isSelected,
|
|
82
|
+
disabled,
|
|
83
|
+
size
|
|
84
|
+
}, getOptionStartAdornment, getOptionEndAdornment);
|
|
85
|
+
}, [
|
|
86
|
+
multiple,
|
|
87
|
+
selectedValue,
|
|
88
|
+
isOptionEqualToValueLocal,
|
|
89
|
+
getOptionLabelLocal,
|
|
90
|
+
disabled,
|
|
91
|
+
size,
|
|
92
|
+
getOptionStartAdornment,
|
|
93
|
+
getOptionEndAdornment
|
|
94
|
+
]);
|
|
95
|
+
const memoizedRenderInput = useCallback((params) => {
|
|
96
|
+
const { InputLabelProps, inputProps, InputProps, ...renderInputOhers } = params;
|
|
97
|
+
const { className: _classNoCount, ...otherInputProps } = InputProps;
|
|
98
|
+
const { className: _ClassNoCount2, ...otherinputProps } = inputProps;
|
|
99
|
+
return /* @__PURE__ */ jsx(
|
|
100
|
+
RenderInputStyled,
|
|
101
|
+
{
|
|
102
|
+
variant,
|
|
103
|
+
ownerState: { ...ownerState },
|
|
104
|
+
InputLabelProps: {
|
|
105
|
+
...InputLabelProps,
|
|
106
|
+
shrink: true
|
|
107
|
+
},
|
|
108
|
+
inputProps: { ...otherinputProps, id: htmlFor },
|
|
109
|
+
error,
|
|
110
|
+
...renderInputOhers,
|
|
111
|
+
autoComplete: "off",
|
|
112
|
+
InputProps: {
|
|
113
|
+
...otherInputProps,
|
|
114
|
+
startAdornment: multipleChips,
|
|
115
|
+
endAdornment: endAdornments,
|
|
116
|
+
readOnly
|
|
117
|
+
},
|
|
118
|
+
SelectProps: { native: true },
|
|
119
|
+
size: currentSize,
|
|
120
|
+
fullWidth: true,
|
|
121
|
+
disabled,
|
|
122
|
+
placeholder
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
}, [
|
|
126
|
+
variant,
|
|
127
|
+
ownerState,
|
|
128
|
+
htmlFor,
|
|
129
|
+
error,
|
|
130
|
+
multipleChips,
|
|
131
|
+
endAdornments,
|
|
132
|
+
readOnly,
|
|
133
|
+
currentSize,
|
|
134
|
+
disabled,
|
|
135
|
+
placeholder
|
|
136
|
+
]);
|
|
137
|
+
return {
|
|
138
|
+
// propiedades de useAutocomplete
|
|
139
|
+
ownerState,
|
|
140
|
+
isSkeleton,
|
|
141
|
+
currentSize,
|
|
142
|
+
memoizedRenderOption,
|
|
143
|
+
memoizedRenderInput,
|
|
144
|
+
// propiedades de useValuesAndHandlers
|
|
145
|
+
open,
|
|
146
|
+
selectedValue,
|
|
147
|
+
inputValue,
|
|
148
|
+
isOptionEqualToValueLocal,
|
|
149
|
+
handleDelete,
|
|
150
|
+
handleRefresh,
|
|
151
|
+
handleChange,
|
|
152
|
+
handleInputChange,
|
|
153
|
+
onCloseLocal,
|
|
154
|
+
onOpenLocal,
|
|
155
|
+
getOptionLabelLocal,
|
|
156
|
+
checkKeyDown,
|
|
157
|
+
scrollPositionOptionsRef,
|
|
158
|
+
// propiedades de useMultipleChips
|
|
159
|
+
multipleChips,
|
|
160
|
+
// propiedades de useEndAdornments
|
|
161
|
+
endAdornments
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
export {
|
|
165
|
+
useAutocomplete as u
|
|
166
|
+
};
|
|
@@ -40,7 +40,8 @@ function useEndAdornments(props) {
|
|
|
40
40
|
onClick: (event) => !readOnly ? onOpenLocal(event) : void 0,
|
|
41
41
|
disabled,
|
|
42
42
|
size: adjustedSize,
|
|
43
|
-
rotationAngle: open ? 180 : 0
|
|
43
|
+
rotationAngle: open ? 180 : 0,
|
|
44
|
+
"aria-label": "toggle Autocomplete"
|
|
44
45
|
}
|
|
45
46
|
)
|
|
46
47
|
] });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AutocompleteOwnerState, AutocompleteProps } from '../types';
|
|
2
|
+
export type UseAdornmentsProps<T, Multiple extends boolean | undefined = undefined> = {
|
|
3
|
+
selectedValue: T | T[] | null;
|
|
4
|
+
multiple?: boolean;
|
|
5
|
+
adjustedSize: 'small' | 'medium';
|
|
6
|
+
getOptionLabelLocal: (option: T) => string;
|
|
7
|
+
getOptionStartAdornment?: AutocompleteProps<T, Multiple>['getOptionStartAdornment'];
|
|
8
|
+
getOptionEndAdornment?: AutocompleteProps<T, Multiple>['getOptionEndAdornment'];
|
|
9
|
+
ownerState: AutocompleteOwnerState;
|
|
10
|
+
handleDelete: (option: T) => void;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
startAdornment?: AutocompleteProps<unknown, true>['startAdornment'];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Hook para el componente Autocomplete local
|
|
16
|
+
*/
|
|
17
|
+
export declare function useMultipleChips<T, Multiple extends boolean | undefined = undefined>(props: UseAdornmentsProps<T, Multiple>): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React, { useMemo } from "react";
|
|
3
|
+
import { r as renderAdornment } from "../subcomponents/RenderAdornment/RenderAdornment.js";
|
|
4
|
+
import { b as ContainerMultipleValuesStyled, c as ContainerWrapperStyled, d as ChipStyled, W as WrapperStartAdornmentStyled } from "../slots/AutocompleteSlots.js";
|
|
5
|
+
function useMultipleChips(props) {
|
|
6
|
+
const {
|
|
7
|
+
selectedValue,
|
|
8
|
+
multiple,
|
|
9
|
+
adjustedSize,
|
|
10
|
+
getOptionLabelLocal,
|
|
11
|
+
ownerState,
|
|
12
|
+
handleDelete,
|
|
13
|
+
disabled,
|
|
14
|
+
startAdornment,
|
|
15
|
+
getOptionStartAdornment,
|
|
16
|
+
getOptionEndAdornment
|
|
17
|
+
} = props;
|
|
18
|
+
const startAdornmentClone = useMemo(() => {
|
|
19
|
+
if (!startAdornment) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
return React.cloneElement(startAdornment, {
|
|
24
|
+
size: adjustedSize
|
|
25
|
+
});
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.warn("Error cloning startAdornment:", error);
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}, [startAdornment, adjustedSize]);
|
|
31
|
+
const memoizedIcons = useMemo(() => {
|
|
32
|
+
if (!Array.isArray(selectedValue) || !multiple || selectedValue.length === 0) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const iconMap = /* @__PURE__ */ new Map();
|
|
36
|
+
selectedValue.forEach((option) => {
|
|
37
|
+
const optionKey = getOptionLabelLocal(option);
|
|
38
|
+
const startAdornmentResource = getOptionStartAdornment?.(option);
|
|
39
|
+
const endAdornmentResource = getOptionEndAdornment?.(option);
|
|
40
|
+
if (startAdornmentResource) {
|
|
41
|
+
iconMap.set(`${optionKey}-start`, renderAdornment(startAdornmentResource, adjustedSize));
|
|
42
|
+
}
|
|
43
|
+
if (endAdornmentResource) {
|
|
44
|
+
iconMap.set(`${optionKey}-end`, renderAdornment(endAdornmentResource, adjustedSize));
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return iconMap;
|
|
48
|
+
}, [
|
|
49
|
+
selectedValue,
|
|
50
|
+
multiple,
|
|
51
|
+
getOptionLabelLocal,
|
|
52
|
+
getOptionStartAdornment,
|
|
53
|
+
getOptionEndAdornment,
|
|
54
|
+
adjustedSize
|
|
55
|
+
]);
|
|
56
|
+
const internalAdornments = useMemo(() => {
|
|
57
|
+
if (!(Array.isArray(selectedValue) && multiple)) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return /* @__PURE__ */ jsx(ContainerMultipleValuesStyled, { role: "list", "aria-label": "Selected options", children: /* @__PURE__ */ jsx(ContainerWrapperStyled, { children: selectedValue.map((option, index) => {
|
|
61
|
+
const optionKey = getOptionLabelLocal(option);
|
|
62
|
+
return /* @__PURE__ */ jsx(
|
|
63
|
+
ChipStyled,
|
|
64
|
+
{
|
|
65
|
+
size: adjustedSize,
|
|
66
|
+
label: optionKey,
|
|
67
|
+
opacity: true,
|
|
68
|
+
onDeleted: () => handleDelete(option),
|
|
69
|
+
disabledDeleteButton: disabled,
|
|
70
|
+
ownerState: { ...ownerState },
|
|
71
|
+
startIcon: memoizedIcons?.get(`${optionKey}-start`),
|
|
72
|
+
endIcon: memoizedIcons?.get(`${optionKey}-end`)
|
|
73
|
+
},
|
|
74
|
+
`${optionKey}-${index}`
|
|
75
|
+
);
|
|
76
|
+
}) }) });
|
|
77
|
+
}, [
|
|
78
|
+
selectedValue,
|
|
79
|
+
multiple,
|
|
80
|
+
adjustedSize,
|
|
81
|
+
getOptionLabelLocal,
|
|
82
|
+
handleDelete,
|
|
83
|
+
disabled,
|
|
84
|
+
ownerState,
|
|
85
|
+
memoizedIcons
|
|
86
|
+
]);
|
|
87
|
+
if (startAdornmentClone && internalAdornments) {
|
|
88
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
89
|
+
/* @__PURE__ */ jsx(WrapperStartAdornmentStyled, { role: "img", "aria-hidden": "true", children: startAdornmentClone }),
|
|
90
|
+
internalAdornments
|
|
91
|
+
] });
|
|
92
|
+
}
|
|
93
|
+
if (startAdornmentClone) {
|
|
94
|
+
return /* @__PURE__ */ jsx(WrapperStartAdornmentStyled, { role: "img", "aria-hidden": "true", children: startAdornmentClone });
|
|
95
|
+
}
|
|
96
|
+
if (!getOptionLabelLocal) {
|
|
97
|
+
console.error("useStartAdornments: getOptionLabelLocal is required");
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
if (!handleDelete) {
|
|
101
|
+
console.error("useStartAdornments: handleDelete is required");
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
return internalAdornments;
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
useMultipleChips as u
|
|
108
|
+
};
|
|
@@ -8,7 +8,6 @@ export declare function useValuesAndHandlers<T, Multiple extends boolean | undef
|
|
|
8
8
|
open: boolean;
|
|
9
9
|
inputValue: string;
|
|
10
10
|
selectedValue: T | T[] | null;
|
|
11
|
-
selectedOption: T | undefined;
|
|
12
11
|
isOptionEqualToValueLocal: (option: unknown, val: unknown) => boolean;
|
|
13
12
|
handleDelete: (optionToDelete: T) => void;
|
|
14
13
|
handleRefresh: () => void;
|
|
@@ -17,7 +16,6 @@ export declare function useValuesAndHandlers<T, Multiple extends boolean | undef
|
|
|
17
16
|
onCloseLocal: (event: React.SyntheticEvent, reason: AutocompleteCloseReason) => void;
|
|
18
17
|
onOpenLocal: (event: React.SyntheticEvent) => void;
|
|
19
18
|
getOptionLabelLocal: (option: unknown) => string;
|
|
20
|
-
getOptionUrlImageLocal: (option: T | null) => string;
|
|
21
19
|
checkKeyDown: (e: KeyboardEvent<HTMLDivElement>) => void;
|
|
22
20
|
scrollPositionOptionsRef: import('react').MutableRefObject<number>;
|
|
23
21
|
};
|