@m4l/components 9.3.19-BE171025-beta.1 → 9.3.19-BE241025-beta.2
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/DataGrid/DataGrid.js +9 -4
- package/components/DataGrid/Datagrid.styles.js +270 -0
- package/components/DataGrid/constants.js +2 -2
- package/components/DataGrid/contexts/DataGridContext/index.js +322 -112
- package/components/DataGrid/contexts/DataGridContext/types.d.ts +63 -4
- package/components/DataGrid/dictionary.d.ts +5 -0
- package/components/DataGrid/dictionary.js +6 -1
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/formatter.js +2 -2
- package/components/DataGrid/hooks/useModalCardDetail.d.ts +6 -0
- package/components/DataGrid/hooks/useModalCardDetail.js +74 -0
- package/components/DataGrid/hooks/useProcessedColumns.d.ts +50 -0
- package/components/DataGrid/hooks/useProcessedColumns.js +44 -0
- package/components/DataGrid/icons.d.ts +7 -0
- package/components/DataGrid/icons.js +5 -1
- package/components/DataGrid/index.d.ts +1 -1
- package/components/DataGrid/slots/DataGridEnum.d.ts +22 -1
- package/components/DataGrid/slots/DataGridEnum.js +21 -0
- package/components/DataGrid/slots/DataGridSlot.d.ts +24 -0
- package/components/DataGrid/slots/DataGridSlot.js +123 -21
- package/components/DataGrid/subcomponents/Cards/hooks/useCardContent.d.ts +9 -0
- package/components/DataGrid/subcomponents/Cards/hooks/useCardContent.js +91 -0
- package/components/DataGrid/subcomponents/Cards/index.d.ts +5 -0
- package/components/DataGrid/subcomponents/Cards/index.js +40 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardDetails/index.d.ts +8 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardDetails/index.js +79 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardHeader/index.d.ts +7 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardHeader/index.js +98 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardRow/index.d.ts +6 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardRow/index.js +71 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/IntersectCard/index.d.ts +20 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/IntersectCard/index.js +46 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/LazyLoadCard/index.d.ts +17 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/LazyLoadCard/index.js +34 -0
- package/components/DataGrid/subcomponents/Cards/types.d.ts +118 -0
- package/components/DataGrid/subcomponents/CheckboxCellAdapter/index.d.ts +7 -0
- package/components/DataGrid/subcomponents/CheckboxCellAdapter/index.js +43 -0
- package/components/DataGrid/subcomponents/CheckboxCellAdapter/types.d.ts +7 -0
- package/components/DataGrid/subcomponents/ControlNavigate/ControlNavigate.js +1 -1
- package/components/DataGrid/subcomponents/HeaderActions/index.js +5 -3
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/RowsCount/index.js +1 -1
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/index.js +11 -2
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/subcomponents/ColumnsConfig/index.js +1 -1
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/subcomponents/ColumnsConfigCards/index.d.ts +2 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/subcomponents/ColumnsConfigCards/index.js +304 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/subcomponents/ColumnsConfigCards/types.d.ts +31 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/ViewMode/index.d.ts +4 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/ViewMode/index.js +125 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/hooks/useModalSettings/index.js +2 -2
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/hooks/useModalSettingsCards/index.d.ts +7 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/hooks/useModalSettingsCards/index.js +74 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/hooks/useModalSettingsCards/types.d.ts +4 -0
- package/components/DataGrid/subcomponents/RenderContent/index.d.ts +5 -0
- package/components/DataGrid/subcomponents/RenderContent/index.js +11 -0
- package/components/DataGrid/subcomponents/Table/hooks/useHeaderMenuActions.js +2 -2
- package/components/DataGrid/subcomponents/Table/hooks/useSortColumnsRows.js +1 -1
- package/components/DataGrid/subcomponents/Table/index.js +1 -1
- package/components/DataGrid/subcomponents/Table/subcomponents/ActionsColumn.js +1 -1
- package/components/DataGrid/subcomponents/Table/subcomponents/DraggableHeaderRenderer.js +1 -1
- package/components/DataGrid/subcomponents/Table/subcomponents/HeaderRenderClick/HeaderRenderClick.js +1 -1
- package/components/DataGrid/subcomponents/editors/TextEditor/index.js +1 -1
- package/components/DataGrid/tests/components/CardDetails.test.d.ts +1 -0
- package/components/DataGrid/tests/components/CardHeader.test.d.ts +1 -0
- package/components/DataGrid/tests/components/CardRow.test.d.ts +1 -0
- package/components/DataGrid/tests/components/Cards.test.d.ts +1 -0
- package/components/DataGrid/tests/components/CheckboxCellAdapter.test.d.ts +1 -0
- package/components/DataGrid/tests/components/ColumnsConfigCards.test.d.ts +1 -0
- package/components/DataGrid/tests/components/IntersectCard.test.d.ts +1 -0
- package/components/DataGrid/tests/components/ViewMode.test.d.ts +1 -0
- package/components/DataGrid/tests/helpers/types.d.ts +1 -0
- package/components/DataGrid/tests/helpers/useCardsViewConfig.d.ts +24 -0
- package/components/DataGrid/tests/helpers/useCustomCardExample.d.ts +7 -0
- package/components/DataGrid/tests/hooks/useCardContent.test.d.ts +1 -0
- package/components/DataGrid/tests/hooks/useModalDetail.test.d.ts +1 -0
- package/components/DataGrid/tests/hooks/useModalSettingsCards.test.d.ts +1 -0
- package/components/DataGrid/tests/hooks/useProcessedColumns.test.d.ts +1 -0
- package/components/DataGrid/types.d.ts +87 -5
- package/components/DynamicFilter/helpers/formatToInitialFilters.js +3 -3
- package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/helpers.js +11 -3
- package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/helpers.js +16 -4
- package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/helpers.js +11 -8
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectAsyncFilter/helpers.js +21 -8
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/helpers.js +18 -8
- package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/helpers.js +5 -3
- package/components/EditLabel/hooks/useEditLabel.d.ts +1 -0
- package/components/LanguagePopover/LanguagePopover.js +2 -0
- package/components/MFIsolationApp/MFIsolationApp.js +3 -6
- package/components/MFIsolationApp/subcomponents/AppBarSettings/AppBarSettings.js +1 -1
- package/components/MFIsolationAppStorybook/MFIsolationAppStorybook.js +4 -20
- package/components/MFIsolationAppStorybook/types.d.ts +0 -4
- package/components/MenuActions/MenuActions.js +105 -55
- package/components/hook-form/RHFAutocomplete/RHFAutocomplete.d.ts +1 -1
- package/components/hook-form/RHFAutocomplete/RHFAutocomplete.js +4 -4
- package/components/hook-form/RHFAutocomplete/types.d.ts +2 -2
- package/components/hook-form/RHFAutocompleteAsync/RHFAutocompleteAsync.js +4 -4
- package/components/hook-form/RHFAutocompleteAsync/slots/RHFAutocompleteSlotsAsync.d.ts +1 -1
- package/components/mui_extended/Autocomplete/Autocomplete.d.ts +4 -8
- package/components/mui_extended/Autocomplete/Autocomplete.js +92 -67
- package/components/mui_extended/Autocomplete/Autocomplete.styles.js +11 -5
- package/components/mui_extended/Autocomplete/RenderAdornment/RenderAdornment.d.ts +6 -0
- package/components/mui_extended/Autocomplete/RenderAdornment/RenderAdornment.js +45 -0
- package/components/mui_extended/Autocomplete/hooks/useEndAdornments.js +2 -1
- package/components/mui_extended/Autocomplete/hooks/useStartAdornments.d.ts +4 -12
- package/components/mui_extended/Autocomplete/hooks/useStartAdornments.js +72 -23
- package/components/mui_extended/Autocomplete/hooks/useValuesAndHandlers.d.ts +0 -2
- package/components/mui_extended/Autocomplete/hooks/useValuesAndHandlers.js +0 -13
- package/components/mui_extended/Autocomplete/renderOptions/index.d.ts +4 -17
- package/components/mui_extended/Autocomplete/renderOptions/index.js +42 -5
- package/components/mui_extended/Autocomplete/renderOptions/types.d.ts +7 -0
- package/components/mui_extended/Autocomplete/slots/AutocompleteSlots.js +2 -2
- package/components/mui_extended/Autocomplete/types.d.ts +10 -3
- package/components/mui_extended/MenuItem/MenuItem.styles.js +4 -1
- package/contexts/AppearanceComponentContext/AppearanceComponentContext.js +4 -1
- package/hooks/useDataGridPersistence/helpers.d.ts +2 -2
- package/hooks/useDataGridPersistence/useDataGridPersistence.d.ts +2 -2
- package/hooks/useDataGridPersistence/useDataGridPersistence.js +5 -0
- package/index.js +8 -8
- package/package.json +1 -1
- package/components/MFIsolationAppStorybook/icons.js +0 -6
- package/components/MFIsolationAppStorybook/subcomponents/AppBarSettings/AppBarSettings.d.ts +0 -4
- package/components/MFIsolationAppStorybook/subcomponents/AppBarSettings/AppBarSettings.js +0 -21
- package/components/MFIsolationAppStorybook/subcomponents/AppBarSettings/index.d.ts +0 -1
- package/components/MFIsolationAppStorybook/subcomponents/AppBarSettings/index.js +0 -1
|
@@ -34,6 +34,7 @@ function MenuActions(props) {
|
|
|
34
34
|
className,
|
|
35
35
|
onOpen,
|
|
36
36
|
slots = {},
|
|
37
|
+
variant = "text",
|
|
37
38
|
...other
|
|
38
39
|
} = props;
|
|
39
40
|
const { currentSize } = useComponentSize(size);
|
|
@@ -41,11 +42,14 @@ function MenuActions(props) {
|
|
|
41
42
|
const { getLabel } = useModuleDictionary();
|
|
42
43
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
43
44
|
const open = Boolean(externalOpen ?? anchorEl);
|
|
44
|
-
const ownerState = useMemo(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
const ownerState = useMemo(
|
|
46
|
+
() => ({
|
|
47
|
+
iconSize: currentSize,
|
|
48
|
+
selected: open,
|
|
49
|
+
paletteColor: color
|
|
50
|
+
}),
|
|
51
|
+
[currentSize, open, color]
|
|
52
|
+
);
|
|
49
53
|
useEffect(() => {
|
|
50
54
|
if (onOpen) {
|
|
51
55
|
onOpen(open);
|
|
@@ -60,21 +64,27 @@ function MenuActions(props) {
|
|
|
60
64
|
const finalIcon = useMemo(() => {
|
|
61
65
|
return icon || urlIcon || `${host_static_assets}/${environment_assets}/${ICON_PATH}/${ICONS.MENU}`;
|
|
62
66
|
}, [urlIcon, icon, host_static_assets, environment_assets]);
|
|
63
|
-
const handleClick = useCallback(
|
|
64
|
-
e
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
onOpen
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
const handleClick = useCallback(
|
|
68
|
+
(e, menuAction) => {
|
|
69
|
+
e.stopPropagation();
|
|
70
|
+
setAnchorEl(null);
|
|
71
|
+
if (onOpen) {
|
|
72
|
+
onOpen(false);
|
|
73
|
+
}
|
|
74
|
+
menuAction.onClick && menuAction.onClick(e);
|
|
75
|
+
},
|
|
76
|
+
[onOpen]
|
|
77
|
+
);
|
|
78
|
+
const handleButtonClick = useCallback(
|
|
79
|
+
(e) => {
|
|
80
|
+
e.stopPropagation();
|
|
81
|
+
setAnchorEl(e.currentTarget);
|
|
82
|
+
if (onOpen) {
|
|
83
|
+
onOpen(true);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
[onOpen]
|
|
87
|
+
);
|
|
78
88
|
const renderMenuContent = useCallback(() => {
|
|
79
89
|
let processedActions = [];
|
|
80
90
|
let finalActions = [];
|
|
@@ -89,7 +99,16 @@ function MenuActions(props) {
|
|
|
89
99
|
finalActions = processedActions;
|
|
90
100
|
}
|
|
91
101
|
if (finalActions.length === 0) {
|
|
92
|
-
return /* @__PURE__ */ jsx(
|
|
102
|
+
return /* @__PURE__ */ jsx(
|
|
103
|
+
MenuItem,
|
|
104
|
+
{
|
|
105
|
+
disabled: true,
|
|
106
|
+
role: "menu-no-actions",
|
|
107
|
+
label: getLabel(
|
|
108
|
+
getMenuActionsDictionary(DICTIONARY.no_actions_label)
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
);
|
|
93
112
|
}
|
|
94
113
|
const RenderHeader = () => {
|
|
95
114
|
return /* @__PURE__ */ jsx(HeaderMenuActionsStyled, { children: header });
|
|
@@ -104,7 +123,14 @@ function MenuActions(props) {
|
|
|
104
123
|
const key = actionKey ?? index;
|
|
105
124
|
switch (menuAction.type ?? "menuItem") {
|
|
106
125
|
case "divider":
|
|
107
|
-
return /* @__PURE__ */ jsx(
|
|
126
|
+
return /* @__PURE__ */ jsx(
|
|
127
|
+
MenuDivider,
|
|
128
|
+
{
|
|
129
|
+
variant: "solid",
|
|
130
|
+
size
|
|
131
|
+
},
|
|
132
|
+
`divider-${key}`
|
|
133
|
+
);
|
|
108
134
|
case "loader":
|
|
109
135
|
return /* @__PURE__ */ jsx(MenuLoaderStyled, { size, children: /* @__PURE__ */ jsx(CircularProgress, { size }) }, `loader-${key}`);
|
|
110
136
|
case "customNode":
|
|
@@ -115,7 +141,9 @@ function MenuActions(props) {
|
|
|
115
141
|
{
|
|
116
142
|
size,
|
|
117
143
|
...menuAction,
|
|
118
|
-
label: menuAction.label ?? getLabel(
|
|
144
|
+
label: menuAction.label ?? getLabel(
|
|
145
|
+
getMenuActionsDictionary(DICTIONARY.no_actions_label)
|
|
146
|
+
),
|
|
119
147
|
onClick: menuAction.onClick ? (e) => handleClick(e, menuAction) : void 0
|
|
120
148
|
},
|
|
121
149
|
`${MENU_ACTIONS_}${menuAction.label ?? key}`
|
|
@@ -128,38 +156,60 @@ function MenuActions(props) {
|
|
|
128
156
|
footer && /* @__PURE__ */ jsx(RenderFooter, {}),
|
|
129
157
|
endListElement && endListElement
|
|
130
158
|
] });
|
|
131
|
-
}, [
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
{
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
159
|
+
}, [
|
|
160
|
+
menuActions,
|
|
161
|
+
header,
|
|
162
|
+
size,
|
|
163
|
+
footer,
|
|
164
|
+
endListElement,
|
|
165
|
+
objItem,
|
|
166
|
+
getLabel,
|
|
167
|
+
actionKey,
|
|
168
|
+
handleClick
|
|
169
|
+
]);
|
|
170
|
+
return /* @__PURE__ */ jsxs(
|
|
171
|
+
RootStyled,
|
|
172
|
+
{
|
|
173
|
+
className: clsx(
|
|
174
|
+
className,
|
|
175
|
+
MENU_ACTIONS_CLASSES.root,
|
|
176
|
+
ownerState.selected && MENU_ACTIONS_CLASSES.selected
|
|
177
|
+
),
|
|
178
|
+
ownerState: { ownerState },
|
|
179
|
+
children: [
|
|
180
|
+
/* @__PURE__ */ jsx(
|
|
181
|
+
IconButtonStyled,
|
|
182
|
+
{
|
|
183
|
+
ownerState: { ...ownerState },
|
|
184
|
+
tooltip: toolTip,
|
|
185
|
+
size,
|
|
186
|
+
icon: finalIcon,
|
|
187
|
+
onClick: handleButtonClick,
|
|
188
|
+
className: iconButtonClassName,
|
|
189
|
+
selected: open,
|
|
190
|
+
disabled,
|
|
191
|
+
badgeProps: { badgeContent },
|
|
192
|
+
"aria-label": other?.["aria-label"] ?? "menu-actions",
|
|
193
|
+
variant
|
|
194
|
+
}
|
|
195
|
+
),
|
|
196
|
+
open && /* @__PURE__ */ jsx(
|
|
197
|
+
Popover,
|
|
198
|
+
{
|
|
199
|
+
id: "Popover",
|
|
200
|
+
open,
|
|
201
|
+
anchorEl,
|
|
202
|
+
onClose: handleOpenClose,
|
|
203
|
+
arrowType,
|
|
204
|
+
...other,
|
|
205
|
+
slots: { ...slots },
|
|
206
|
+
slotProps: { paper: { ...paperProps } },
|
|
207
|
+
children: renderMenuContent()
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
|
+
);
|
|
163
213
|
}
|
|
164
214
|
const MemonizedMenuActions = React.memo(MenuActions);
|
|
165
215
|
export {
|
|
@@ -4,4 +4,4 @@ import { RHFAutocompleteProps } from './types';
|
|
|
4
4
|
* @param props - The properties for the RHFAutocomplete component.
|
|
5
5
|
* @returns The RHFAutocomplete component.
|
|
6
6
|
*/
|
|
7
|
-
export declare function RHFAutocomplete<T>(props: RHFAutocompleteProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function RHFAutocomplete<T, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined>(props: RHFAutocompleteProps<T, Multiple, DisableClearable, FreeSolo>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -25,8 +25,8 @@ function RHFAutocomplete(props) {
|
|
|
25
25
|
multiple,
|
|
26
26
|
refresh,
|
|
27
27
|
startAdornment,
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
getOptionStartAdornment,
|
|
29
|
+
getOptionEndAdornment,
|
|
30
30
|
className
|
|
31
31
|
// onChange: onChangeRHF,
|
|
32
32
|
} = props;
|
|
@@ -121,8 +121,8 @@ function RHFAutocomplete(props) {
|
|
|
121
121
|
value,
|
|
122
122
|
htmlFor: htmlForId,
|
|
123
123
|
startAdornment,
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
getOptionStartAdornment,
|
|
125
|
+
getOptionEndAdornment
|
|
126
126
|
}
|
|
127
127
|
),
|
|
128
128
|
error?.message ? /* @__PURE__ */ jsx(HelperError, { message: error?.message }) : null
|
|
@@ -54,11 +54,11 @@ export interface RHFAutocompleteProps<T = any, Multiple extends boolean | undefi
|
|
|
54
54
|
/**
|
|
55
55
|
* Icono o adorno inicial que se muestra en cada opción del autocomplete.
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
getOptionEndAdornment?: AutocompleteProps<T, Multiple>['getOptionEndAdornment'];
|
|
58
58
|
/**
|
|
59
59
|
* Icono o adorno final que se muestra en cada opción del autocomplete.
|
|
60
60
|
*/
|
|
61
|
-
|
|
61
|
+
getOptionStartAdornment?: AutocompleteProps<T, Multiple>['getOptionStartAdornment'];
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Represents the owner state of the Autocomplete component for styling purposes.
|
|
@@ -24,8 +24,8 @@ function RHFAutocompleteAsync(props) {
|
|
|
24
24
|
skeletonWidth,
|
|
25
25
|
responseToCamelCase,
|
|
26
26
|
startAdornment,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
getOptionStartAdornment,
|
|
28
|
+
getOptionEndAdornment,
|
|
29
29
|
className
|
|
30
30
|
} = props;
|
|
31
31
|
const [state, dispatch] = useReducer(
|
|
@@ -94,8 +94,8 @@ function RHFAutocompleteAsync(props) {
|
|
|
94
94
|
onClose: onCloseLocal,
|
|
95
95
|
skeletonWidth,
|
|
96
96
|
startAdornment,
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
getOptionStartAdornment,
|
|
98
|
+
getOptionEndAdornment
|
|
99
99
|
}
|
|
100
100
|
);
|
|
101
101
|
}
|
|
@@ -1 +1 @@
|
|
|
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>, {}, {}>;
|
|
1
|
+
export declare const RHFAutocompleteAsyncRootStyled: import('@emotion/styled').StyledComponent<Pick<import('../../RHFAutocomplete/types').RHFAutocompleteProps<unknown, boolean | undefined, boolean | undefined, boolean | undefined>, keyof import('../../RHFAutocomplete/types').RHFAutocompleteProps<unknown, boolean | undefined, boolean | undefined, boolean | undefined>> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown>, {}, {}>;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
+
import { Ref } from 'react';
|
|
1
2
|
import { AutocompleteProps } from './types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
*/
|
|
9
|
-
export declare const Autocomplete: import('react').ForwardRefExoticComponent<AutocompleteProps<unknown, boolean | undefined> & import('react').RefAttributes<HTMLInputElement | HTMLTextAreaElement>>;
|
|
3
|
+
export declare const Autocomplete: <T, Multiple extends boolean | undefined = undefined>(props: AutocompleteProps<T, Multiple> & {
|
|
4
|
+
ref?: Ref<HTMLInputElement | HTMLTextAreaElement>;
|
|
5
|
+
}) => JSX.Element;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useModuleDictionary, useModuleSkeleton } from "@m4l/core";
|
|
3
|
-
import { forwardRef, useMemo } from "react";
|
|
3
|
+
import { forwardRef, useMemo, useCallback } from "react";
|
|
4
4
|
import { r as renderOption } from "./renderOptions/index.js";
|
|
5
5
|
import { u as useValuesAndHandlers } from "./hooks/useValuesAndHandlers.js";
|
|
6
6
|
import { u as useStartAdornments } from "./hooks/useStartAdornments.js";
|
|
7
7
|
import { u as useEndAdornments } from "./hooks/useEndAdornments.js";
|
|
8
8
|
import { u as useComponentSize } from "../../../hooks/useComponentSize/useComponentSize.js";
|
|
9
|
-
import {
|
|
9
|
+
import { P as PopperComponentStyled, R as RenderInputStyled, S as SkeletonAutocompleteStyled, A as AutocompleteRootStyled } from "./slots/AutocompleteSlots.js";
|
|
10
10
|
import { T as Typography } from "../Typography/Typography.js";
|
|
11
|
-
|
|
11
|
+
function AutocompleteComponent(props, ref) {
|
|
12
12
|
const {
|
|
13
13
|
options,
|
|
14
14
|
disabled,
|
|
@@ -17,16 +17,14 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
17
17
|
size = "medium",
|
|
18
18
|
onChangeFilterParmsLocal,
|
|
19
19
|
multiple,
|
|
20
|
-
getOptionUrlImage,
|
|
21
|
-
// Diferencia
|
|
22
20
|
refresh,
|
|
23
21
|
error = false,
|
|
24
22
|
htmlFor,
|
|
25
23
|
readOnly = false,
|
|
26
24
|
placeholder,
|
|
27
25
|
startAdornment,
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
getOptionStartAdornment,
|
|
27
|
+
getOptionEndAdornment
|
|
30
28
|
} = props;
|
|
31
29
|
const { getLabel } = useModuleDictionary();
|
|
32
30
|
const isSkeleton = useModuleSkeleton();
|
|
@@ -47,6 +45,7 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
47
45
|
checkKeyDown,
|
|
48
46
|
scrollPositionOptionsRef
|
|
49
47
|
} = useValuesAndHandlers(props);
|
|
48
|
+
const hasStartAdornment = !!startAdornment;
|
|
50
49
|
const ownerState = useMemo(() => ({
|
|
51
50
|
size: adjustedSize,
|
|
52
51
|
variant,
|
|
@@ -54,8 +53,8 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
54
53
|
multiple: Boolean(multiple),
|
|
55
54
|
error,
|
|
56
55
|
readOnly,
|
|
57
|
-
startAdornment:
|
|
58
|
-
}), [adjustedSize, disabled, error, multiple, variant, readOnly,
|
|
56
|
+
startAdornment: hasStartAdornment
|
|
57
|
+
}), [adjustedSize, disabled, error, multiple, variant, readOnly, hasStartAdornment]);
|
|
59
58
|
const startAdornments = useStartAdornments({
|
|
60
59
|
selectedValue,
|
|
61
60
|
multiple,
|
|
@@ -65,8 +64,8 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
65
64
|
handleDelete,
|
|
66
65
|
disabled,
|
|
67
66
|
startAdornment,
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
getOptionStartAdornment,
|
|
68
|
+
getOptionEndAdornment
|
|
70
69
|
});
|
|
71
70
|
const endAdornments = useEndAdornments({
|
|
72
71
|
loading,
|
|
@@ -79,6 +78,81 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
79
78
|
open,
|
|
80
79
|
readOnly
|
|
81
80
|
});
|
|
81
|
+
const MemoizedPopperComponent = useCallback((popperProps) => {
|
|
82
|
+
const { color: popperColor, ...otherPopperProps } = popperProps;
|
|
83
|
+
return /* @__PURE__ */ jsx(
|
|
84
|
+
PopperComponentStyled,
|
|
85
|
+
{
|
|
86
|
+
...otherPopperProps,
|
|
87
|
+
size: adjustedSize,
|
|
88
|
+
placement: "bottom-start",
|
|
89
|
+
ownerState: { ...ownerState }
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
}, [adjustedSize, ownerState]);
|
|
93
|
+
const memoizedRenderOption = useCallback((renderProps, option) => {
|
|
94
|
+
const isSelected = multiple ? Array.isArray(selectedValue) && selectedValue.some((val) => isOptionEqualToValueLocal(option, val)) : isOptionEqualToValueLocal(option, selectedValue);
|
|
95
|
+
return renderOption(renderProps, {
|
|
96
|
+
...typeof option === "object" && option !== null ? option : {},
|
|
97
|
+
label: getOptionLabelLocal(option),
|
|
98
|
+
selected: isSelected,
|
|
99
|
+
disabled,
|
|
100
|
+
size
|
|
101
|
+
}, getOptionStartAdornment, getOptionEndAdornment);
|
|
102
|
+
}, [
|
|
103
|
+
multiple,
|
|
104
|
+
selectedValue,
|
|
105
|
+
isOptionEqualToValueLocal,
|
|
106
|
+
getOptionLabelLocal,
|
|
107
|
+
disabled,
|
|
108
|
+
size,
|
|
109
|
+
getOptionStartAdornment,
|
|
110
|
+
getOptionEndAdornment
|
|
111
|
+
]);
|
|
112
|
+
const memoizedRenderInput = useCallback((params) => {
|
|
113
|
+
const { InputLabelProps, inputProps, InputProps, ...renderInputOhers } = params;
|
|
114
|
+
const { className: _classNoCount, ...otherInputProps } = InputProps;
|
|
115
|
+
const { className: _ClassNoCount2, ...otherinputProps } = inputProps;
|
|
116
|
+
return /* @__PURE__ */ jsx(
|
|
117
|
+
RenderInputStyled,
|
|
118
|
+
{
|
|
119
|
+
variant,
|
|
120
|
+
ownerState: { ...ownerState },
|
|
121
|
+
InputLabelProps: {
|
|
122
|
+
...InputLabelProps,
|
|
123
|
+
shrink: true
|
|
124
|
+
},
|
|
125
|
+
inputProps: { ...otherinputProps, id: htmlFor },
|
|
126
|
+
error,
|
|
127
|
+
...renderInputOhers,
|
|
128
|
+
autoComplete: "off",
|
|
129
|
+
InputProps: {
|
|
130
|
+
...otherInputProps,
|
|
131
|
+
startAdornment: startAdornments,
|
|
132
|
+
endAdornment: endAdornments,
|
|
133
|
+
readOnly
|
|
134
|
+
},
|
|
135
|
+
SelectProps: { native: true },
|
|
136
|
+
size: adjustedSize,
|
|
137
|
+
fullWidth: true,
|
|
138
|
+
disabled,
|
|
139
|
+
placeholder
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
}, [
|
|
143
|
+
variant,
|
|
144
|
+
ownerState,
|
|
145
|
+
htmlFor,
|
|
146
|
+
error,
|
|
147
|
+
startAdornments,
|
|
148
|
+
endAdornments,
|
|
149
|
+
readOnly,
|
|
150
|
+
adjustedSize,
|
|
151
|
+
disabled,
|
|
152
|
+
placeholder
|
|
153
|
+
]);
|
|
154
|
+
const memoizedLoadingText = useMemo(() => /* @__PURE__ */ jsx(Typography, { variant: "body", size: adjustedSize, children: getLabel("autocomplete.loading_options") }), [adjustedSize, getLabel]);
|
|
155
|
+
const memoizedNoOptionsText = useMemo(() => /* @__PURE__ */ jsx(Typography, { variant: "body", size: adjustedSize, children: getLabel("autocomplete.no_options") }), [adjustedSize, getLabel]);
|
|
82
156
|
if (isSkeleton) {
|
|
83
157
|
return /* @__PURE__ */ jsx(
|
|
84
158
|
SkeletonAutocompleteStyled,
|
|
@@ -100,18 +174,7 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
100
174
|
options,
|
|
101
175
|
getOptionLabel: getOptionLabelLocal,
|
|
102
176
|
clearOnBlur: false,
|
|
103
|
-
PopperComponent:
|
|
104
|
-
const { color: popperColor, ...otherPopperProps } = popperProps;
|
|
105
|
-
return /* @__PURE__ */ jsx(
|
|
106
|
-
PopperComponentStyled,
|
|
107
|
-
{
|
|
108
|
-
...otherPopperProps,
|
|
109
|
-
size: adjustedSize,
|
|
110
|
-
placement: "bottom-start",
|
|
111
|
-
ownerState: { ...ownerState }
|
|
112
|
-
}
|
|
113
|
-
);
|
|
114
|
-
},
|
|
177
|
+
PopperComponent: MemoizedPopperComponent,
|
|
115
178
|
isOptionEqualToValue: isOptionEqualToValueLocal,
|
|
116
179
|
value: selectedValue,
|
|
117
180
|
inputValue,
|
|
@@ -121,20 +184,11 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
121
184
|
onInputChange: handleInputChange,
|
|
122
185
|
onChange: handleChange,
|
|
123
186
|
loading,
|
|
124
|
-
loadingText:
|
|
187
|
+
loadingText: memoizedLoadingText,
|
|
125
188
|
disabled,
|
|
126
|
-
noOptionsText:
|
|
189
|
+
noOptionsText: memoizedNoOptionsText,
|
|
127
190
|
filterOptions: onChangeFilterParmsLocal ? (x) => x : void 0,
|
|
128
|
-
renderOption:
|
|
129
|
-
const isSelected = multiple ? Array.isArray(selectedValue) && selectedValue.some((val) => isOptionEqualToValueLocal(option, val)) : isOptionEqualToValueLocal(option, selectedValue);
|
|
130
|
-
return renderOption(renderProps, {
|
|
131
|
-
...typeof option === "object" && option !== null ? option : {},
|
|
132
|
-
label: getOptionLabelLocal(option),
|
|
133
|
-
selected: isSelected,
|
|
134
|
-
disabled,
|
|
135
|
-
size
|
|
136
|
-
});
|
|
137
|
-
},
|
|
191
|
+
renderOption: memoizedRenderOption,
|
|
138
192
|
ListboxProps: {
|
|
139
193
|
//Esto para no perder el scroll de la lista de opciones, cuando es multiple, ya que MUI no lo guarda
|
|
140
194
|
onScroll: (event) => {
|
|
@@ -149,40 +203,11 @@ const Autocomplete = forwardRef(function Autocomplete2(props, ref) {
|
|
|
149
203
|
}
|
|
150
204
|
}
|
|
151
205
|
},
|
|
152
|
-
renderInput:
|
|
153
|
-
const { InputLabelProps, inputProps, InputProps, ...renderInputOhers } = params;
|
|
154
|
-
const { className: _classNoCount, ...otherInputProps } = InputProps;
|
|
155
|
-
const { className: _ClassNoCount2, ...otherinputProps } = inputProps;
|
|
156
|
-
return /* @__PURE__ */ jsx(
|
|
157
|
-
RenderInputStyled,
|
|
158
|
-
{
|
|
159
|
-
variant,
|
|
160
|
-
ownerState: { ...ownerState },
|
|
161
|
-
InputLabelProps: {
|
|
162
|
-
...InputLabelProps,
|
|
163
|
-
shrink: true
|
|
164
|
-
},
|
|
165
|
-
inputProps: { ...otherinputProps, id: htmlFor },
|
|
166
|
-
error,
|
|
167
|
-
...renderInputOhers,
|
|
168
|
-
autoComplete: "off",
|
|
169
|
-
InputProps: {
|
|
170
|
-
...otherInputProps,
|
|
171
|
-
startAdornment: startAdornments,
|
|
172
|
-
endAdornment: endAdornments,
|
|
173
|
-
readOnly
|
|
174
|
-
},
|
|
175
|
-
SelectProps: { native: true },
|
|
176
|
-
size: adjustedSize,
|
|
177
|
-
fullWidth: true,
|
|
178
|
-
disabled,
|
|
179
|
-
placeholder
|
|
180
|
-
}
|
|
181
|
-
);
|
|
182
|
-
}
|
|
206
|
+
renderInput: memoizedRenderInput
|
|
183
207
|
}
|
|
184
208
|
);
|
|
185
|
-
}
|
|
209
|
+
}
|
|
210
|
+
const Autocomplete = forwardRef(AutocompleteComponent);
|
|
186
211
|
export {
|
|
187
212
|
Autocomplete as A
|
|
188
213
|
};
|
|
@@ -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.
|
|
@@ -81,7 +85,7 @@ const autocompleteSyles = {
|
|
|
81
85
|
...ownerState?.startAdornment ? {
|
|
82
86
|
padding: `${sp1} ${sp7} ${sp1} ${sp5}!important`
|
|
83
87
|
} : {
|
|
84
|
-
padding: `${sp1} ${sp7} ${sp1}
|
|
88
|
+
padding: `${sp1} ${sp7} ${sp1} ${sp1}!important`
|
|
85
89
|
},
|
|
86
90
|
gap: sp1,
|
|
87
91
|
flexWrap: "wrap",
|
|
@@ -104,9 +108,11 @@ const autocompleteSyles = {
|
|
|
104
108
|
minWidth: "100%",
|
|
105
109
|
maxHeight: "200px",
|
|
106
110
|
"& .MuiAutocomplete-listbox": {
|
|
111
|
+
display: "grid",
|
|
112
|
+
gridTemplateColumns: "auto",
|
|
107
113
|
height: "100%",
|
|
108
114
|
"& .M4LMenuItem-root ": {
|
|
109
|
-
width: "
|
|
115
|
+
width: "100%",
|
|
110
116
|
"& .M4LTypography-root": {
|
|
111
117
|
width: "fit-content",
|
|
112
118
|
overflow: "unset"
|
|
@@ -116,7 +122,7 @@ const autocompleteSyles = {
|
|
|
116
122
|
}
|
|
117
123
|
}),
|
|
118
124
|
/**
|
|
119
|
-
*
|
|
125
|
+
* styles for the circular progress component.
|
|
120
126
|
*/
|
|
121
127
|
circularProgress: {},
|
|
122
128
|
/**
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Sizes } from '@m4l/styles';
|
|
2
|
+
import { ResourceType } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Render adornment function similar to useStartAdornments
|
|
5
|
+
*/
|
|
6
|
+
export declare const renderAdornment: (propsResource: ResourceType, adjustedSize: Extract<Sizes, "small" | "medium">) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { I as Image } from "../../../Image/Image.js";
|
|
4
|
+
import { I as Icon } from "../../../Icon/Icon.js";
|
|
5
|
+
const renderAdornment = (propsResource, adjustedSize) => {
|
|
6
|
+
const { resource, type } = propsResource;
|
|
7
|
+
if (!resource) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
if (React.isValidElement(resource)) {
|
|
11
|
+
try {
|
|
12
|
+
return React.cloneElement(resource, {
|
|
13
|
+
size: adjustedSize
|
|
14
|
+
});
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.warn("Error cloning React element:", error);
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (typeof resource === "string") {
|
|
21
|
+
if (type === "image") {
|
|
22
|
+
return /* @__PURE__ */ jsx(
|
|
23
|
+
Image,
|
|
24
|
+
{
|
|
25
|
+
src: resource,
|
|
26
|
+
width: 14,
|
|
27
|
+
height: 14
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
} else {
|
|
31
|
+
return /* @__PURE__ */ jsx(
|
|
32
|
+
Icon,
|
|
33
|
+
{
|
|
34
|
+
src: resource,
|
|
35
|
+
size: adjustedSize
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
console.warn("Invalid icon type provided to renderAdornment:", typeof resource);
|
|
41
|
+
return null;
|
|
42
|
+
};
|
|
43
|
+
export {
|
|
44
|
+
renderAdornment as r
|
|
45
|
+
};
|
|
@@ -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
|
] });
|
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
1
|
import { AutocompleteOwnerState, AutocompleteProps } from '../types';
|
|
3
|
-
export type UseAdornmentsProps<T> = {
|
|
2
|
+
export type UseAdornmentsProps<T, Multiple extends boolean | undefined = undefined> = {
|
|
4
3
|
selectedValue: T | T[] | null;
|
|
5
4
|
multiple?: boolean;
|
|
6
|
-
loading?: boolean;
|
|
7
5
|
adjustedSize: 'small' | 'medium';
|
|
8
6
|
getOptionLabelLocal: (option: T) => string;
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
getOptionStartAdornment?: AutocompleteProps<T, Multiple>['getOptionStartAdornment'];
|
|
8
|
+
getOptionEndAdornment?: AutocompleteProps<T, Multiple>['getOptionEndAdornment'];
|
|
11
9
|
ownerState: AutocompleteOwnerState;
|
|
12
10
|
handleDelete: (option: T) => void;
|
|
13
|
-
getOptionUrlImage?: (option: T) => string;
|
|
14
|
-
selectedOption?: T;
|
|
15
|
-
getOptionUrlImageLocal: (option: T) => string;
|
|
16
|
-
refresh?: () => void;
|
|
17
|
-
handleRefresh: () => void;
|
|
18
11
|
disabled?: boolean;
|
|
19
|
-
onOpenLocal: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
20
12
|
startAdornment?: AutocompleteProps<unknown, true>['startAdornment'];
|
|
21
13
|
};
|
|
22
14
|
/**
|
|
23
15
|
* Hook para el componente Autocomplete local
|
|
24
16
|
*/
|
|
25
|
-
export declare function useStartAdornments<T>(props: UseAdornmentsProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
17
|
+
export declare function useStartAdornments<T, Multiple extends boolean | undefined = undefined>(props: UseAdornmentsProps<T, Multiple>): import("react/jsx-runtime").JSX.Element | null;
|