@m4l/components 9.1.53 → 9.1.55
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 +10 -1
- package/components/Chip/Chip.js +108 -0
- package/components/Chip/ChipStyles.js +533 -0
- package/components/Chip/constants.d.ts +4 -0
- package/components/Chip/constants.js +8 -0
- package/components/Chip/slots/ChipEnum.d.ts +7 -7
- package/components/Chip/slots/ChipEnum.js +11 -0
- package/components/Chip/slots/ChipSlots.js +35 -0
- package/components/Chip/slots/index.js +1 -0
- package/components/Chip/types.d.ts +41 -11
- package/components/DynamicFilter/types.d.ts +2 -2
- package/components/Label/Label.styles.js +28 -8
- package/components/SideBar/subcomponents/ContentGroups/subcomponents/ContainerMenuItemsMain/styles.js +9 -21
- package/components/hook-form/RHFAutocomplete/RFHAutocompleteStyles.d.ts +2 -0
- package/components/hook-form/RHFAutocomplete/RFHAutocompleteStyles.js +24 -0
- package/components/hook-form/RHFAutocomplete/RHFAutocomplete.d.ts +3 -5
- package/components/hook-form/RHFAutocomplete/RHFAutocomplete.js +161 -4
- package/components/hook-form/RHFAutocomplete/RHFAutocomplete.test.d.ts +1 -0
- package/components/hook-form/RHFAutocomplete/constants.d.ts +9 -0
- package/components/hook-form/RHFAutocomplete/constants.js +4 -0
- package/components/hook-form/RHFAutocomplete/oldTypes.d.ts +43 -0
- package/components/hook-form/RHFAutocomplete/slots/RHFAutocompleteEnum.d.ts +4 -0
- package/components/hook-form/RHFAutocomplete/slots/RHFAutocompleteEnum.js +8 -0
- package/components/hook-form/RHFAutocomplete/slots/RHFAutocompleteSlots.d.ts +6 -0
- package/components/hook-form/RHFAutocomplete/slots/RHFAutocompleteSlots.js +17 -0
- package/components/hook-form/RHFAutocomplete/slots/index.d.ts +2 -0
- package/components/hook-form/RHFAutocomplete/slots/index.js +1 -0
- package/components/hook-form/RHFAutocomplete/types.d.ts +63 -25
- package/components/hook-form/RHFAutocompleteAsync/RHFAutocompleteAsync.d.ts +5 -8
- package/components/hook-form/RHFAutocompleteAsync/RHFAutocompleteAsync.js +105 -4
- package/components/hook-form/RHFAutocompleteAsync/RHFAutocompleteAsyncStyles.d.ts +2 -0
- package/components/hook-form/RHFAutocompleteAsync/RHFAutocompleteAsyncStyles.js +6 -0
- package/components/hook-form/RHFAutocompleteAsync/constants.d.ts +9 -0
- package/components/hook-form/RHFAutocompleteAsync/constants.js +4 -0
- package/components/hook-form/RHFAutocompleteAsync/slots/RHFAutocompleteEnumAsync.d.ts +3 -0
- package/components/hook-form/RHFAutocompleteAsync/slots/RHFAutocompleteEnumAsync.js +7 -0
- package/components/hook-form/RHFAutocompleteAsync/slots/RHFAutocompleteSlotsAsync.d.ts +1 -0
- package/components/hook-form/RHFAutocompleteAsync/slots/RHFAutocompleteSlotsAsync.js +12 -0
- package/components/hook-form/RHFAutocompleteAsync/slots/index.d.ts +2 -0
- package/components/hook-form/RHFAutocompleteAsync/slots/index.js +1 -0
- package/components/hook-form/RHFAutocompleteAsync/types.d.ts +19 -5
- package/components/mui_extended/Autocomplete/Autocomplete.d.ts +1 -1
- package/components/mui_extended/Autocomplete/Autocomplete.js +299 -0
- package/components/mui_extended/Autocomplete/AutocompleteStyles.js +136 -0
- package/components/mui_extended/Autocomplete/constants.js +4 -0
- package/components/mui_extended/Autocomplete/dictionary.d.ts +0 -2
- package/components/mui_extended/Autocomplete/index.js +1 -0
- package/components/mui_extended/Autocomplete/renderOptions/index.d.ts +3 -0
- package/components/mui_extended/Autocomplete/renderOptions/index.js +24 -0
- package/components/mui_extended/Autocomplete/slots /AutocompleteEnum.d.ts +2 -1
- package/components/mui_extended/Autocomplete/slots /AutocompleteEnum.js +19 -0
- package/components/mui_extended/Autocomplete/slots /AutocompleteSlots.d.ts +3 -0
- package/components/mui_extended/Autocomplete/slots /AutocompleteSlots.js +72 -0
- package/components/mui_extended/Autocomplete/slots /index.js +1 -0
- package/components/mui_extended/Autocomplete/types.d.ts +2 -2
- package/components/mui_extended/CircularProgress/CircularProgress.js +1 -1
- package/components/mui_extended/MenuItem/MenuItem.js +11 -12
- package/components/mui_extended/MenuItem/MenuItem.styles.js +56 -66
- package/components/mui_extended/MenuItem/constants.d.ts +4 -0
- package/components/mui_extended/MenuItem/constants.js +5 -1
- package/components/mui_extended/MenuItem/slots/MenuItemEnum.d.ts +1 -1
- package/components/mui_extended/MenuItem/slots/MenuItemEnum.js +1 -1
- package/components/mui_extended/MenuItem/slots/MenuItemSlots.js +3 -3
- package/components/mui_extended/MenuItem/types.d.ts +32 -11
- package/components/mui_extended/Pager/classes/index.d.ts +1 -1
- package/components/mui_extended/Popper/Popper.js +79 -0
- package/components/mui_extended/Popper/PopperStyles.js +265 -0
- package/components/mui_extended/Popper/constants.js +4 -0
- package/components/mui_extended/Popper/index.js +1 -0
- package/components/mui_extended/Popper/slots/PopperEnum.js +6 -0
- package/components/mui_extended/Popper/slots/PopperStlots.js +12 -0
- package/components/mui_extended/Popper/slots/index.js +1 -0
- package/components/mui_extended/Popper/types.js +1 -0
- package/components/mui_extended/Select/slots/SelectSlots.d.ts +1 -1
- package/components/mui_extended/Select/slots/SelectSlots.js +1 -1
- package/components/mui_extended/TextField/TextField.js +11 -11
- package/components/mui_extended/TextField/TextField.styles.js +108 -203
- package/components/mui_extended/TextField/constants.d.ts +10 -0
- package/components/mui_extended/TextField/constants.js +8 -3
- package/components/mui_extended/TextField/slots/TextFieldEnum.d.ts +4 -0
- package/components/mui_extended/TextField/slots/TextFieldEnum.js +7 -1
- package/components/mui_extended/TextField/slots/TextFieldSlots.js +1 -1
- package/components/mui_extended/TextField/types.d.ts +3 -4
- package/components/mui_extended/Typography/Typography.js +4 -3
- package/components/mui_extended/Typography/constants.d.ts +4 -0
- package/components/mui_extended/Typography/constants.js +5 -1
- package/components/mui_extended/Typography/slots/typographySlots.js +1 -1
- package/package.json +1 -1
- package/utils/getHeightSizeStyles.d.ts +12 -0
- package/utils/getHeightSizeStyles.js +13 -0
- package/components/hook-form/RHFAutocomplete/classes/constant.d.ts +0 -1
- package/components/hook-form/RHFAutocomplete/classes/constant.js +0 -4
- package/components/hook-form/RHFAutocomplete/classes/index.d.ts +0 -19
- package/components/hook-form/RHFAutocomplete/classes/index.js +0 -77
- package/components/hook-form/RHFAutocomplete/classes/types.d.ts +0 -26
- package/components/hook-form/RHFAutocomplete/styles.d.ts +0 -1
- package/components/hook-form/RHFAutocomplete/styles.js +0 -7
- package/components/hook-form/RHFAutocomplete/subcomponents/ComponentTypeImage/index.d.ts +0 -5
- package/components/hook-form/RHFAutocomplete/subcomponents/ComponentTypeImage/index.js +0 -293
- package/components/hook-form/RHFAutocomplete/subcomponents/ComponentTypeText/index.d.ts +0 -9
- package/components/hook-form/RHFAutocomplete/subcomponents/ComponentTypeText/index.js +0 -281
- package/components/hook-form/RHFAutocomplete/subcomponents/RenderOption/index.d.ts +0 -6
- package/components/hook-form/RHFAutocomplete/subcomponents/RenderOption/index.js +0 -25
- package/components/hook-form/RHFAutocomplete/subcomponents/RenderOption/styles.d.ts +0 -1
- package/components/hook-form/RHFAutocomplete/subcomponents/RenderOption/styles.js +0 -9
- package/components/hook-form/RHFAutocomplete/subcomponents/Skeleton/index.d.ts +0 -5
- package/components/hook-form/RHFAutocomplete/subcomponents/Skeleton/index.js +0 -28
- package/components/hook-form/RHFAutocomplete/subcomponents/Skeleton/types.d.ts +0 -6
- package/components/hook-form/RHFAutocomplete/test/constants.d.ts +0 -2
- package/components/hook-form/RHFAutocomplete/test/constants.js +0 -6
- package/components/hook-form/RHFAutocomplete/test/utils.d.ts +0 -2
- package/components/hook-form/RHFAutocomplete/test/utils.js +0 -7
- package/components/hook-form/RHFAutocompleteAsync/classes/constant.d.ts +0 -1
- package/components/hook-form/RHFAutocompleteAsync/classes/constant.js +0 -4
- package/components/hook-form/RHFAutocompleteAsync/classes/index.d.ts +0 -9
- package/components/hook-form/RHFAutocompleteAsync/classes/index.js +0 -26
- package/components/hook-form/RHFAutocompleteAsync/classes/types.d.ts +0 -4
- package/components/hook-form/RHFAutocompleteAsync/styles.d.ts +0 -4
- package/components/hook-form/RHFAutocompleteAsync/styles.js +0 -34
- package/components/hook-form/RHFAutocompleteAsync/subcomponents/ComponentTypeImage/index.d.ts +0 -10
- package/components/hook-form/RHFAutocompleteAsync/subcomponents/ComponentTypeImage/index.js +0 -103
- package/components/hook-form/RHFAutocompleteAsync/subcomponents/ComponentTypeText/index.d.ts +0 -9
- package/components/hook-form/RHFAutocompleteAsync/subcomponents/ComponentTypeText/index.js +0 -103
- package/components/hook-form/RHFAutocompleteAsync/tests/constants.d.ts +0 -1
- package/components/hook-form/RHFAutocompleteAsync/tests/constants.js +0 -4
- package/components/hook-form/RHFAutocompleteAsync/tests/utils.d.ts +0 -2
- package/components/hook-form/RHFAutocompleteAsync/tests/utils.js +0 -7
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { useUtilityClasses } from '.';
|
|
2
|
-
export interface RHFAutocompleteClassesType {
|
|
3
|
-
root: string;
|
|
4
|
-
withImage: string;
|
|
5
|
-
skeleton: string;
|
|
6
|
-
label: string;
|
|
7
|
-
popper: string;
|
|
8
|
-
skeletonRoot: string;
|
|
9
|
-
skeletonContainerText: string;
|
|
10
|
-
containerRefreshDown: string;
|
|
11
|
-
iconRefresh: string;
|
|
12
|
-
iconDown: string;
|
|
13
|
-
variantInfo: string;
|
|
14
|
-
isDisabled: string;
|
|
15
|
-
imageWidthDefined: string;
|
|
16
|
-
variantSuccess: string;
|
|
17
|
-
variantWarning: string;
|
|
18
|
-
variantError: string;
|
|
19
|
-
sizeSmall: string;
|
|
20
|
-
sizeMedium: string;
|
|
21
|
-
isFocus: string;
|
|
22
|
-
isTabSelected: string;
|
|
23
|
-
chip: string;
|
|
24
|
-
}
|
|
25
|
-
export type RHFAutocompleteClassesKey = keyof RHFAutocompleteClassesType;
|
|
26
|
-
export type Classes = ReturnType<typeof useUtilityClasses>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const AutocompleteRoot: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme>, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo, useRef, useState, useEffect, createElement } from "react";
|
|
3
|
-
import { useModuleDictionary, useModuleSkeleton, useEnvironment } from "@m4l/core";
|
|
4
|
-
import { u as useFormFocus } from "../../../../../hooks/useFormFocus/index.js";
|
|
5
|
-
import { useTheme, Autocomplete, Popper, TextField, Chip } from "@mui/material";
|
|
6
|
-
import { useResponsiveDesktop } from "@m4l/graphics";
|
|
7
|
-
import { useFormContext, Controller } from "react-hook-form";
|
|
8
|
-
import { u as useUtilityClasses } from "../../classes/index.js";
|
|
9
|
-
import { A as AutocompleteRoot } from "../../styles.js";
|
|
10
|
-
import { T as TEST_PROP_ID } from "../../../../../test/constants_no_mock.js";
|
|
11
|
-
import { R as RHFTAUTOCOMPLET_ROOT_TEST_ID } from "../../test/constants.js";
|
|
12
|
-
import { w as withRenderOption } from "../RenderOption/index.js";
|
|
13
|
-
import { S as SkeletonRHFAutocomplete } from "../Skeleton/index.js";
|
|
14
|
-
import { L as Label } from "../../../../Label/Label.js";
|
|
15
|
-
import { T as Typography } from "../../../../mui_extended/Typography/Typography.js";
|
|
16
|
-
import { C as CircularProgress } from "../../../../mui_extended/CircularProgress/CircularProgress.js";
|
|
17
|
-
import { I as IconButton } from "../../../../mui_extended/IconButton/IconButton.js";
|
|
18
|
-
import { H as HelperError } from "../../../../HelperError/HelperError.js";
|
|
19
|
-
import { I as Image } from "../../../../Image/Image.js";
|
|
20
|
-
function ComponentTypeImage(props) {
|
|
21
|
-
const {
|
|
22
|
-
name: nameRHF,
|
|
23
|
-
getOptionLabel,
|
|
24
|
-
isOptionEqualToValue,
|
|
25
|
-
label,
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
27
|
-
skeletonWidth = 100,
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
29
|
-
skeletonHeight = "18px",
|
|
30
|
-
options,
|
|
31
|
-
disabled,
|
|
32
|
-
getOptionUrlImage,
|
|
33
|
-
onOpen,
|
|
34
|
-
onClose,
|
|
35
|
-
loading,
|
|
36
|
-
variant,
|
|
37
|
-
helperMessage,
|
|
38
|
-
size = "small",
|
|
39
|
-
onChangeFilterParmsLocal,
|
|
40
|
-
mandatory,
|
|
41
|
-
mandatoryMessage,
|
|
42
|
-
multiple,
|
|
43
|
-
imageScale = true,
|
|
44
|
-
imageRepeat,
|
|
45
|
-
refresh,
|
|
46
|
-
...other
|
|
47
|
-
} = props;
|
|
48
|
-
const { getLabel } = useModuleDictionary();
|
|
49
|
-
const isSkeleton = useModuleSkeleton();
|
|
50
|
-
const withImage = useMemo(() => getOptionUrlImage !== void 0, [getOptionUrlImage]);
|
|
51
|
-
const { host_static_assets, environment_assets } = useEnvironment();
|
|
52
|
-
const { isFocus, isTabSelected, handlerFocus, handlerOnKeyUp, handlerOnBlur } = useFormFocus();
|
|
53
|
-
const autocompleteRef = useRef(null);
|
|
54
|
-
const [open, setOpen] = useState(false);
|
|
55
|
-
const isDesktop = useResponsiveDesktop();
|
|
56
|
-
const onCloseLocal = (event, reason) => {
|
|
57
|
-
setOpen(false);
|
|
58
|
-
if (onClose) {
|
|
59
|
-
onClose(event, reason);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
const onOpenLocal = (event) => {
|
|
63
|
-
setOpen((currentState) => !currentState);
|
|
64
|
-
if (onOpen) {
|
|
65
|
-
onOpen(event);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
const getOptionLabelLocal = (option) => {
|
|
69
|
-
if (option === void 0 || option === null) {
|
|
70
|
-
return "";
|
|
71
|
-
}
|
|
72
|
-
return getOptionLabel(option);
|
|
73
|
-
};
|
|
74
|
-
const getOptionUrlImageLocal = (option) => {
|
|
75
|
-
if (option === void 0 || option === null || getOptionUrlImage === void 0) {
|
|
76
|
-
return "";
|
|
77
|
-
}
|
|
78
|
-
return getOptionUrlImage(option);
|
|
79
|
-
};
|
|
80
|
-
const isOptionEqualToValueLocal = (option, value) => {
|
|
81
|
-
if (value === void 0 || value === null || option === null) {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
return isOptionEqualToValue(option, value);
|
|
85
|
-
};
|
|
86
|
-
const {
|
|
87
|
-
control,
|
|
88
|
-
formState: { errors }
|
|
89
|
-
} = useFormContext();
|
|
90
|
-
const [currentVariant, setCurrentVariant] = useState(
|
|
91
|
-
null
|
|
92
|
-
);
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
if (errors[nameRHF]) {
|
|
95
|
-
setCurrentVariant("error");
|
|
96
|
-
} else if (variant) {
|
|
97
|
-
setCurrentVariant(variant);
|
|
98
|
-
} else {
|
|
99
|
-
setCurrentVariant(null);
|
|
100
|
-
}
|
|
101
|
-
}, [errors[nameRHF], variant, control]);
|
|
102
|
-
const ownerState = {
|
|
103
|
-
size: !isDesktop ? "medium" : size,
|
|
104
|
-
isFocus: !isSkeleton ? isFocus : false,
|
|
105
|
-
isTabSelected: !isSkeleton ? isTabSelected : false,
|
|
106
|
-
semantics: currentVariant,
|
|
107
|
-
disabled,
|
|
108
|
-
multiple: Boolean(multiple),
|
|
109
|
-
imageScale: Boolean(imageScale),
|
|
110
|
-
imageRepeat: Boolean(imageRepeat)
|
|
111
|
-
};
|
|
112
|
-
const classes = useUtilityClasses(ownerState);
|
|
113
|
-
const theme = useTheme();
|
|
114
|
-
return /* @__PURE__ */ jsx(
|
|
115
|
-
AutocompleteRoot,
|
|
116
|
-
{
|
|
117
|
-
className: classes.root,
|
|
118
|
-
onFocus: handlerFocus,
|
|
119
|
-
onBlur: handlerOnBlur,
|
|
120
|
-
onKeyUp: handlerOnKeyUp,
|
|
121
|
-
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: `${RHFTAUTOCOMPLET_ROOT_TEST_ID}_${nameRHF}` } : {},
|
|
122
|
-
children: !isSkeleton ? /* @__PURE__ */ jsx(
|
|
123
|
-
Controller,
|
|
124
|
-
{
|
|
125
|
-
name: nameRHF,
|
|
126
|
-
control,
|
|
127
|
-
render: ({ field: { onChange, value }, fieldState: { error } }) => {
|
|
128
|
-
const [inputValue, setInputValue] = useState(getOptionLabelLocal(value));
|
|
129
|
-
useEffect(() => {
|
|
130
|
-
if (!open && value === null && inputValue !== "") {
|
|
131
|
-
setInputValue("");
|
|
132
|
-
}
|
|
133
|
-
if (!open && value !== null && options.length === 0) {
|
|
134
|
-
onChangeFilterParmsLocal?.(getOptionLabelLocal(value), "reset");
|
|
135
|
-
}
|
|
136
|
-
}, [value]);
|
|
137
|
-
const checkKeyDown = (e) => {
|
|
138
|
-
if (e.code === "Enter") {
|
|
139
|
-
e.preventDefault();
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
143
|
-
label && /* @__PURE__ */ jsx(
|
|
144
|
-
Label,
|
|
145
|
-
{
|
|
146
|
-
label,
|
|
147
|
-
mandatory,
|
|
148
|
-
mandatoryMessage,
|
|
149
|
-
helperMessage
|
|
150
|
-
}
|
|
151
|
-
),
|
|
152
|
-
/* @__PURE__ */ jsx(
|
|
153
|
-
Autocomplete,
|
|
154
|
-
{
|
|
155
|
-
autoComplete: true,
|
|
156
|
-
disableClearable: true,
|
|
157
|
-
multiple,
|
|
158
|
-
onKeyDown: checkKeyDown,
|
|
159
|
-
size,
|
|
160
|
-
ref: autocompleteRef,
|
|
161
|
-
autoSelect: false,
|
|
162
|
-
options,
|
|
163
|
-
getOptionLabel: getOptionLabelLocal,
|
|
164
|
-
inputValue,
|
|
165
|
-
clearOnBlur: false,
|
|
166
|
-
PopperComponent: (popperProps) => {
|
|
167
|
-
return /* @__PURE__ */ jsx(
|
|
168
|
-
Popper,
|
|
169
|
-
{
|
|
170
|
-
...popperProps,
|
|
171
|
-
className: classes.popper,
|
|
172
|
-
placement: "bottom-start",
|
|
173
|
-
sx: {
|
|
174
|
-
...theme.components?.M4LRHFAutocompletePopover?.styleOverrides || {}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
);
|
|
178
|
-
},
|
|
179
|
-
onInputChange: (_event, newValue, reason) => {
|
|
180
|
-
if (reason === "input") {
|
|
181
|
-
setInputValue(newValue);
|
|
182
|
-
if (onChangeFilterParmsLocal) {
|
|
183
|
-
onChangeFilterParmsLocal(newValue, reason);
|
|
184
|
-
}
|
|
185
|
-
} else {
|
|
186
|
-
onChange(null);
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
isOptionEqualToValue: isOptionEqualToValueLocal,
|
|
190
|
-
value: Array.isArray(value) ? value : multiple ? value ? [value] : [] : value || null,
|
|
191
|
-
onOpen: onOpenLocal,
|
|
192
|
-
onClose: onCloseLocal,
|
|
193
|
-
open,
|
|
194
|
-
onChange: (_e, newValue) => {
|
|
195
|
-
if (!multiple && !Array.isArray(newValue)) {
|
|
196
|
-
setInputValue(getOptionLabelLocal(newValue));
|
|
197
|
-
} else {
|
|
198
|
-
setInputValue("");
|
|
199
|
-
}
|
|
200
|
-
onChange(Array.isArray(newValue) ? [...newValue] : newValue);
|
|
201
|
-
},
|
|
202
|
-
filterOptions: onChangeFilterParmsLocal ? (x) => x : void 0,
|
|
203
|
-
loading,
|
|
204
|
-
loadingText: /* @__PURE__ */ jsx(Typography, { variant: "body", children: getLabel("rhf_autocomplete.loading_options") }),
|
|
205
|
-
disabled,
|
|
206
|
-
noOptionsText: getLabel("rhf_autocomplete.no_options"),
|
|
207
|
-
renderOption: withRenderOption(getOptionUrlImageLocal, classes),
|
|
208
|
-
renderInput: (params) => {
|
|
209
|
-
return /* @__PURE__ */ jsx(
|
|
210
|
-
TextField,
|
|
211
|
-
{
|
|
212
|
-
...params,
|
|
213
|
-
InputLabelProps: {
|
|
214
|
-
...params.InputLabelProps,
|
|
215
|
-
shrink: true
|
|
216
|
-
},
|
|
217
|
-
fullWidth: true,
|
|
218
|
-
size,
|
|
219
|
-
SelectProps: { native: true },
|
|
220
|
-
InputProps: {
|
|
221
|
-
...params.InputProps,
|
|
222
|
-
startAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
223
|
-
!multiple && withImage && value ? /* @__PURE__ */ jsx(Image, { src: getOptionUrlImageLocal(value) }, "ImageTextField") : null,
|
|
224
|
-
params.InputProps.startAdornment
|
|
225
|
-
] }),
|
|
226
|
-
endAdornment: loading ? (
|
|
227
|
-
//Se debe refactorizar el componente RHFAutoComplete para recibir la propr de color.
|
|
228
|
-
/* @__PURE__ */ jsx(CircularProgress, { color: "primary", size })
|
|
229
|
-
) : /* @__PURE__ */ jsxs("div", { className: classes.containerRefreshDown, children: [
|
|
230
|
-
refresh && /* @__PURE__ */ jsx(
|
|
231
|
-
IconButton,
|
|
232
|
-
{
|
|
233
|
-
className: classes.iconRefresh,
|
|
234
|
-
src: `${host_static_assets}/${environment_assets}/frontend/components/RHFAutocompletarAsync/assets/icons/round_refresh.svg`,
|
|
235
|
-
onClick: () => refresh(),
|
|
236
|
-
disabled,
|
|
237
|
-
size
|
|
238
|
-
}
|
|
239
|
-
),
|
|
240
|
-
/* @__PURE__ */ jsx(
|
|
241
|
-
IconButton,
|
|
242
|
-
{
|
|
243
|
-
className: classes.iconDown,
|
|
244
|
-
src: `${host_static_assets}/${environment_assets}/frontend/components/RHFAutocompletarAsync/assets/icons/chevronDown.svg`,
|
|
245
|
-
onClick: (event) => onOpenLocal(event),
|
|
246
|
-
disabled,
|
|
247
|
-
size
|
|
248
|
-
}
|
|
249
|
-
)
|
|
250
|
-
] })
|
|
251
|
-
},
|
|
252
|
-
autoComplete: "off",
|
|
253
|
-
error: !!error,
|
|
254
|
-
...other
|
|
255
|
-
}
|
|
256
|
-
);
|
|
257
|
-
},
|
|
258
|
-
...multiple ? {
|
|
259
|
-
/**
|
|
260
|
-
* renderTags: Se encarga de renderizar las etiquetas de las opciones seleccionadas en el componente Autocomplete.
|
|
261
|
-
*/
|
|
262
|
-
renderTags: (tagValue, getTagProps) => tagValue.map((option, index) => {
|
|
263
|
-
const { key, ...restTagProps } = getTagProps({
|
|
264
|
-
index
|
|
265
|
-
});
|
|
266
|
-
return /* @__PURE__ */ createElement(
|
|
267
|
-
Chip,
|
|
268
|
-
{
|
|
269
|
-
...restTagProps,
|
|
270
|
-
key,
|
|
271
|
-
label: getOptionLabelLocal(option),
|
|
272
|
-
className: classes.chip,
|
|
273
|
-
icon: withImage && option ? /* @__PURE__ */ jsx(Image, { src: getOptionUrlImageLocal(option) }) : void 0,
|
|
274
|
-
sx: {
|
|
275
|
-
...theme.components?.M4LRHFAutocompleteChip?.styleOverrides || {}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
);
|
|
279
|
-
})
|
|
280
|
-
} : {}
|
|
281
|
-
}
|
|
282
|
-
),
|
|
283
|
-
currentVariant === "error" ? /* @__PURE__ */ jsx(HelperError, { message: error?.message }) : null
|
|
284
|
-
] });
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
) : /* @__PURE__ */ jsx(SkeletonRHFAutocomplete, { withImage, classes, hasLabel: label })
|
|
288
|
-
}
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
export {
|
|
292
|
-
ComponentTypeImage as C
|
|
293
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { RHFAutocompleteBaseProps, RHFAutocompleteTypeTextProps } from '../../types';
|
|
2
|
-
/**
|
|
3
|
-
* TODO: Documentar
|
|
4
|
-
* @author Andrés Quintero - automatic
|
|
5
|
-
* @createdAt 2024-12-30 14:36:06 - automatic
|
|
6
|
-
* @updatedAt 2024-12-30 14:36:10 - automatic
|
|
7
|
-
* @updatedUser Andrés Quintero - automatic
|
|
8
|
-
*/
|
|
9
|
-
export declare function ComponentTypeText<T>(props: RHFAutocompleteBaseProps<T> & RHFAutocompleteTypeTextProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useRef, useState, useEffect, createElement } from "react";
|
|
3
|
-
import { useModuleDictionary, useModuleSkeleton, useEnvironment } from "@m4l/core";
|
|
4
|
-
import { u as useFormFocus } from "../../../../../hooks/useFormFocus/index.js";
|
|
5
|
-
import { useTheme, Autocomplete, Popper, TextField, Chip } from "@mui/material";
|
|
6
|
-
import { useResponsiveDesktop } from "@m4l/graphics";
|
|
7
|
-
import { useFormContext, Controller } from "react-hook-form";
|
|
8
|
-
import { u as useUtilityClasses } from "../../classes/index.js";
|
|
9
|
-
import { A as AutocompleteRoot } from "../../styles.js";
|
|
10
|
-
import { T as TEST_PROP_ID } from "../../../../../test/constants_no_mock.js";
|
|
11
|
-
import { R as RHFTAUTOCOMPLET_ROOT_TEST_ID } from "../../test/constants.js";
|
|
12
|
-
import { C as CircularProgress } from "../../../../mui_extended/CircularProgress/CircularProgress.js";
|
|
13
|
-
import { T as Typography } from "../../../../mui_extended/Typography/Typography.js";
|
|
14
|
-
import { I as IconButton } from "../../../../mui_extended/IconButton/IconButton.js";
|
|
15
|
-
import { S as SkeletonRHFAutocomplete } from "../Skeleton/index.js";
|
|
16
|
-
import { L as Label } from "../../../../Label/Label.js";
|
|
17
|
-
import { H as HelperError } from "../../../../HelperError/HelperError.js";
|
|
18
|
-
function ComponentTypeText(props) {
|
|
19
|
-
const {
|
|
20
|
-
name: nameRHF,
|
|
21
|
-
getOptionLabel,
|
|
22
|
-
isOptionEqualToValue,
|
|
23
|
-
label,
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
25
|
-
skeletonWidth = 100,
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
27
|
-
skeletonHeight = "18px",
|
|
28
|
-
options,
|
|
29
|
-
disabled,
|
|
30
|
-
onOpen,
|
|
31
|
-
onClose,
|
|
32
|
-
loading,
|
|
33
|
-
variant,
|
|
34
|
-
helperMessage,
|
|
35
|
-
size = "small",
|
|
36
|
-
onChangeFilterParmsLocal,
|
|
37
|
-
mandatory,
|
|
38
|
-
mandatoryMessage,
|
|
39
|
-
multiple,
|
|
40
|
-
refresh,
|
|
41
|
-
...other
|
|
42
|
-
} = props;
|
|
43
|
-
const { getLabel } = useModuleDictionary();
|
|
44
|
-
const isSkeleton = useModuleSkeleton();
|
|
45
|
-
const { host_static_assets, environment_assets } = useEnvironment();
|
|
46
|
-
const { isFocus, isTabSelected, handlerFocus, handlerOnKeyUp, handlerOnBlur } = useFormFocus();
|
|
47
|
-
const autocompleteRef = useRef(null);
|
|
48
|
-
const [open, setOpen] = useState(false);
|
|
49
|
-
const isDesktop = useResponsiveDesktop();
|
|
50
|
-
const onCloseLocal = (event, reason) => {
|
|
51
|
-
setOpen(false);
|
|
52
|
-
if (onClose) {
|
|
53
|
-
onClose(event, reason);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const onOpenLocal = (event) => {
|
|
57
|
-
setOpen((currentState) => !currentState);
|
|
58
|
-
if (onOpen) {
|
|
59
|
-
onOpen(event);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
const getOptionLabelLocal = (option) => {
|
|
63
|
-
if (option === void 0 || option === null) {
|
|
64
|
-
return "";
|
|
65
|
-
}
|
|
66
|
-
return getOptionLabel(option);
|
|
67
|
-
};
|
|
68
|
-
const isOptionEqualToValueLocal = (option, value) => {
|
|
69
|
-
if (value === void 0 || value === null || option === null) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
return isOptionEqualToValue(option, value);
|
|
73
|
-
};
|
|
74
|
-
const {
|
|
75
|
-
control,
|
|
76
|
-
formState: { errors }
|
|
77
|
-
} = useFormContext();
|
|
78
|
-
const [currentVariant, setCurrentVariant] = useState(
|
|
79
|
-
null
|
|
80
|
-
);
|
|
81
|
-
useEffect(() => {
|
|
82
|
-
if (errors[nameRHF]) {
|
|
83
|
-
setCurrentVariant("error");
|
|
84
|
-
} else if (variant) {
|
|
85
|
-
setCurrentVariant(variant);
|
|
86
|
-
} else {
|
|
87
|
-
setCurrentVariant(null);
|
|
88
|
-
}
|
|
89
|
-
}, [errors[nameRHF], variant, control]);
|
|
90
|
-
const ownerState = {
|
|
91
|
-
size: !isDesktop ? "medium" : size,
|
|
92
|
-
isFocus: !isSkeleton ? isFocus : false,
|
|
93
|
-
isTabSelected: !isSkeleton ? isTabSelected : false,
|
|
94
|
-
semantics: currentVariant,
|
|
95
|
-
disabled,
|
|
96
|
-
multiple: Boolean(multiple)
|
|
97
|
-
};
|
|
98
|
-
const classes = useUtilityClasses(ownerState);
|
|
99
|
-
const theme = useTheme();
|
|
100
|
-
return /* @__PURE__ */ jsx(
|
|
101
|
-
AutocompleteRoot,
|
|
102
|
-
{
|
|
103
|
-
className: classes.root,
|
|
104
|
-
tabIndex: 0,
|
|
105
|
-
onFocus: handlerFocus,
|
|
106
|
-
onBlur: handlerOnBlur,
|
|
107
|
-
onKeyUp: handlerOnKeyUp,
|
|
108
|
-
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: `${RHFTAUTOCOMPLET_ROOT_TEST_ID}_${nameRHF}` } : {},
|
|
109
|
-
children: !isSkeleton ? /* @__PURE__ */ jsx(
|
|
110
|
-
Controller,
|
|
111
|
-
{
|
|
112
|
-
name: nameRHF,
|
|
113
|
-
control,
|
|
114
|
-
render: ({ field: { onChange, value }, fieldState: { error } }) => {
|
|
115
|
-
const [inputValue, setInputValue] = useState(getOptionLabelLocal(value));
|
|
116
|
-
useEffect(() => {
|
|
117
|
-
if (!open && value === null && inputValue !== "") {
|
|
118
|
-
setInputValue("");
|
|
119
|
-
}
|
|
120
|
-
if (!open && value !== null && options.length === 0) {
|
|
121
|
-
onChangeFilterParmsLocal?.(getOptionLabelLocal(value), "reset");
|
|
122
|
-
}
|
|
123
|
-
}, [value]);
|
|
124
|
-
const checkKeyDown = (e) => {
|
|
125
|
-
if (e.code === "Enter") {
|
|
126
|
-
e.preventDefault();
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
130
|
-
label && /* @__PURE__ */ jsx(
|
|
131
|
-
Label,
|
|
132
|
-
{
|
|
133
|
-
label,
|
|
134
|
-
mandatory,
|
|
135
|
-
mandatoryMessage,
|
|
136
|
-
helperMessage
|
|
137
|
-
}
|
|
138
|
-
),
|
|
139
|
-
/* @__PURE__ */ jsx(
|
|
140
|
-
Autocomplete,
|
|
141
|
-
{
|
|
142
|
-
autoComplete: true,
|
|
143
|
-
disableClearable: true,
|
|
144
|
-
multiple,
|
|
145
|
-
onKeyDown: checkKeyDown,
|
|
146
|
-
size,
|
|
147
|
-
ref: autocompleteRef,
|
|
148
|
-
autoSelect: false,
|
|
149
|
-
options,
|
|
150
|
-
getOptionLabel: getOptionLabelLocal,
|
|
151
|
-
inputValue,
|
|
152
|
-
clearOnBlur: false,
|
|
153
|
-
PopperComponent: (popperProps) => {
|
|
154
|
-
return /* @__PURE__ */ jsx(
|
|
155
|
-
Popper,
|
|
156
|
-
{
|
|
157
|
-
...popperProps,
|
|
158
|
-
className: classes.popper,
|
|
159
|
-
placement: "bottom-start",
|
|
160
|
-
sx: {
|
|
161
|
-
...theme.components?.M4LRHFAutocompletePopover?.styleOverrides || {}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
);
|
|
165
|
-
},
|
|
166
|
-
onInputChange: (_event, newValue, reason) => {
|
|
167
|
-
if (reason === "input") {
|
|
168
|
-
setInputValue(newValue);
|
|
169
|
-
if (onChangeFilterParmsLocal) {
|
|
170
|
-
onChangeFilterParmsLocal(newValue, reason);
|
|
171
|
-
}
|
|
172
|
-
} else {
|
|
173
|
-
onChange(null);
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
|
-
isOptionEqualToValue: isOptionEqualToValueLocal,
|
|
177
|
-
value: Array.isArray(value) ? value : multiple ? value ? [value] : [] : value || null,
|
|
178
|
-
onOpen: onOpenLocal,
|
|
179
|
-
onClose: onCloseLocal,
|
|
180
|
-
open,
|
|
181
|
-
onChange: (_e, newValue) => {
|
|
182
|
-
if (!multiple && !Array.isArray(newValue)) {
|
|
183
|
-
setInputValue(getOptionLabelLocal(newValue));
|
|
184
|
-
} else {
|
|
185
|
-
setInputValue("");
|
|
186
|
-
}
|
|
187
|
-
onChange(Array.isArray(newValue) ? [...newValue] : newValue);
|
|
188
|
-
},
|
|
189
|
-
filterOptions: onChangeFilterParmsLocal ? (x) => x : void 0,
|
|
190
|
-
loading,
|
|
191
|
-
loadingText: /* @__PURE__ */ jsx(Typography, { variant: "body", children: getLabel("rhf_autocomplete.loading_options") }),
|
|
192
|
-
disabled,
|
|
193
|
-
noOptionsText: getLabel("rhf_autocomplete.no_options"),
|
|
194
|
-
renderOption: void 0,
|
|
195
|
-
renderInput: (params) => {
|
|
196
|
-
return /* @__PURE__ */ jsx(
|
|
197
|
-
TextField,
|
|
198
|
-
{
|
|
199
|
-
...params,
|
|
200
|
-
InputLabelProps: {
|
|
201
|
-
...params.InputLabelProps,
|
|
202
|
-
shrink: true
|
|
203
|
-
},
|
|
204
|
-
fullWidth: true,
|
|
205
|
-
size,
|
|
206
|
-
SelectProps: { native: true },
|
|
207
|
-
InputProps: {
|
|
208
|
-
...params.InputProps,
|
|
209
|
-
startAdornment: /* @__PURE__ */ jsx(Fragment, { children: params.InputProps.startAdornment }),
|
|
210
|
-
endAdornment: loading ? (
|
|
211
|
-
//Se debe refactorizar el componente RHFAutoComplete para recibir la propr de color.
|
|
212
|
-
/* @__PURE__ */ jsx(CircularProgress, { color: "primary", size })
|
|
213
|
-
) : /* @__PURE__ */ jsxs("div", { className: classes.containerRefreshDown, children: [
|
|
214
|
-
refresh && /* @__PURE__ */ jsx(
|
|
215
|
-
IconButton,
|
|
216
|
-
{
|
|
217
|
-
className: classes.iconRefresh,
|
|
218
|
-
src: `${host_static_assets}/${environment_assets}/frontend/components/RHFAutocompletarAsync/assets/icons/round_refresh.svg`,
|
|
219
|
-
onClick: () => refresh(),
|
|
220
|
-
disabled,
|
|
221
|
-
size
|
|
222
|
-
}
|
|
223
|
-
),
|
|
224
|
-
/* @__PURE__ */ jsx(
|
|
225
|
-
IconButton,
|
|
226
|
-
{
|
|
227
|
-
className: classes.iconDown,
|
|
228
|
-
src: `${host_static_assets}/${environment_assets}/frontend/components/RHFAutocompletarAsync/assets/icons/chevronDown.svg`,
|
|
229
|
-
onClick: (event) => onOpenLocal(event),
|
|
230
|
-
disabled,
|
|
231
|
-
size
|
|
232
|
-
}
|
|
233
|
-
)
|
|
234
|
-
] })
|
|
235
|
-
},
|
|
236
|
-
autoComplete: "off",
|
|
237
|
-
error: !!error,
|
|
238
|
-
...other
|
|
239
|
-
}
|
|
240
|
-
);
|
|
241
|
-
},
|
|
242
|
-
...multiple ? {
|
|
243
|
-
/**
|
|
244
|
-
* renderTags: Se encarga de renderizar las etiquetas de las opciones seleccionadas en el componente Autocomplete.
|
|
245
|
-
* @author Andrés Quintero - automatic
|
|
246
|
-
* @createdAt 2024-12-30 14:36:06 - automatic
|
|
247
|
-
* @updatedAt 2024-12-30 14:36:10 - automatic
|
|
248
|
-
* @updatedUser Andrés Quintero - automatic
|
|
249
|
-
*/
|
|
250
|
-
renderTags: (tagValue, getTagProps) => tagValue.map((option, index) => {
|
|
251
|
-
const { key, ...restTagProps } = getTagProps({
|
|
252
|
-
index
|
|
253
|
-
});
|
|
254
|
-
return /* @__PURE__ */ createElement(
|
|
255
|
-
Chip,
|
|
256
|
-
{
|
|
257
|
-
...restTagProps,
|
|
258
|
-
key,
|
|
259
|
-
label: getOptionLabelLocal(option),
|
|
260
|
-
className: classes.chip,
|
|
261
|
-
icon: void 0,
|
|
262
|
-
sx: {
|
|
263
|
-
...theme.components?.M4LRHFAutocompleteChip?.styleOverrides || {}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
);
|
|
267
|
-
})
|
|
268
|
-
} : {}
|
|
269
|
-
}
|
|
270
|
-
),
|
|
271
|
-
currentVariant === "error" ? /* @__PURE__ */ jsx(HelperError, { message: error?.message }) : null
|
|
272
|
-
] });
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
) : /* @__PURE__ */ jsx(SkeletonRHFAutocomplete, { classes, hasLabel: label })
|
|
276
|
-
}
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
export {
|
|
280
|
-
ComponentTypeText as C
|
|
281
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { HTMLAttributes } from 'react';
|
|
2
|
-
import { GetOptionString } from '../../types';
|
|
3
|
-
/**
|
|
4
|
-
* TODO: Documentar
|
|
5
|
-
*/
|
|
6
|
-
export declare function withRenderOption<T>(getUrlImage: GetOptionString<T>, classes: any): (optionProps: HTMLAttributes<HTMLLIElement>, option: T) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createElement } from "react";
|
|
3
|
-
import { W as WrapperOption } from "./styles.js";
|
|
4
|
-
import { I as Image } from "../../../../Image/Image.js";
|
|
5
|
-
import { T as TEST_PROP_ID } from "../../../../../test/constants_no_mock.js";
|
|
6
|
-
import { g as getNameDataTestId } from "../../test/utils.js";
|
|
7
|
-
import { T as Typography } from "../../../../mui_extended/Typography/Typography.js";
|
|
8
|
-
function withRenderOption(getUrlImage, classes) {
|
|
9
|
-
return function RenderOption(optionProps, option) {
|
|
10
|
-
return /* @__PURE__ */ createElement(
|
|
11
|
-
WrapperOption,
|
|
12
|
-
{
|
|
13
|
-
...optionProps,
|
|
14
|
-
key: optionProps.key,
|
|
15
|
-
className: classes.withImage,
|
|
16
|
-
...process.env.NODE_ENV !== "production" ? { [TEST_PROP_ID]: getNameDataTestId("withImage") } : {}
|
|
17
|
-
},
|
|
18
|
-
/* @__PURE__ */ jsx(Image, { src: getUrlImage(option) }),
|
|
19
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body", children: optionProps.key })
|
|
20
|
-
);
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export {
|
|
24
|
-
withRenderOption as w
|
|
25
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const WrapperOption: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme>, import('react').DetailedHTMLProps<import('react').LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, {}>;
|